* [PATCH] arcmsr: Fix a potential data corruption issue
@ 2015-07-10 5:18 ` Christophe JAILLET
0 siblings, 0 replies; 4+ messages in thread
From: Christophe JAILLET @ 2015-07-10 5:18 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, linux-kernel, kernel-janitors, Christophe JAILLET
Resetting rqbuffer or wqbuffer must be done within a critial section
in order to avoir potential data corruption.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
This change is *untested* because I don't have the corresponding hardware.
However, it should'nt have any evil side effect (just a few lines of code
moved from outside to within a spin_lock)
This just a "guess" based on the other uses of the 2 buffers within the
code.
It is also inspired on how things are done in arcmsr_hba.c
(see line #2390)
So please ignore if not relevant.
---
drivers/scsi/arcmsr/arcmsr_attr.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/scsi/arcmsr/arcmsr_attr.c b/drivers/scsi/arcmsr/arcmsr_attr.c
index 9c86481..2ad970d 100644
--- a/drivers/scsi/arcmsr/arcmsr_attr.c
+++ b/drivers/scsi/arcmsr/arcmsr_attr.c
@@ -171,22 +171,21 @@ static ssize_t arcmsr_sysfs_iop_message_clear(struct file *filp,
return -EACCES;
arcmsr_clear_iop2drv_rqueue_buffer(acb);
- acb->acb_flags |=
- (ACB_F_MESSAGE_WQBUFFER_CLEARED
- | ACB_F_MESSAGE_RQBUFFER_CLEARED
- | ACB_F_MESSAGE_WQBUFFER_READED);
spin_lock_irqsave(&acb->rqbuffer_lock, flags);
+ acb->acb_flags |= ACB_F_MESSAGE_RQBUFFER_CLEARED;
acb->rqbuf_getIndex = 0;
acb->rqbuf_putIndex = 0;
+ pQbuffer = acb->rqbuffer;
+ memset(pQbuffer, 0, sizeof (struct QBUFFER));
spin_unlock_irqrestore(&acb->rqbuffer_lock, flags);
spin_lock_irqsave(&acb->wqbuffer_lock, flags);
+ acb->acb_flags |= (ACB_F_MESSAGE_WQBUFFER_CLEARED |
+ ACB_F_MESSAGE_WQBUFFER_READED);
acb->wqbuf_getIndex = 0;
acb->wqbuf_putIndex = 0;
- spin_unlock_irqrestore(&acb->wqbuffer_lock, flags);
- pQbuffer = acb->rqbuffer;
- memset(pQbuffer, 0, sizeof (struct QBUFFER));
pQbuffer = acb->wqbuffer;
memset(pQbuffer, 0, sizeof (struct QBUFFER));
+ spin_unlock_irqrestore(&acb->wqbuffer_lock, flags);
return 1;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] arcmsr: Fix a potential data corruption issue
@ 2015-07-10 5:18 ` Christophe JAILLET
0 siblings, 0 replies; 4+ messages in thread
From: Christophe JAILLET @ 2015-07-10 5:18 UTC (permalink / raw)
To: JBottomley; +Cc: linux-scsi, linux-kernel, kernel-janitors, Christophe JAILLET
Resetting rqbuffer or wqbuffer must be done within a critial section
in order to avoir potential data corruption.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
This change is *untested* because I don't have the corresponding hardware.
However, it should'nt have any evil side effect (just a few lines of code
moved from outside to within a spin_lock)
This just a "guess" based on the other uses of the 2 buffers within the
code.
It is also inspired on how things are done in arcmsr_hba.c
(see line #2390)
So please ignore if not relevant.
---
drivers/scsi/arcmsr/arcmsr_attr.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/scsi/arcmsr/arcmsr_attr.c b/drivers/scsi/arcmsr/arcmsr_attr.c
index 9c86481..2ad970d 100644
--- a/drivers/scsi/arcmsr/arcmsr_attr.c
+++ b/drivers/scsi/arcmsr/arcmsr_attr.c
@@ -171,22 +171,21 @@ static ssize_t arcmsr_sysfs_iop_message_clear(struct file *filp,
return -EACCES;
arcmsr_clear_iop2drv_rqueue_buffer(acb);
- acb->acb_flags |- (ACB_F_MESSAGE_WQBUFFER_CLEARED
- | ACB_F_MESSAGE_RQBUFFER_CLEARED
- | ACB_F_MESSAGE_WQBUFFER_READED);
spin_lock_irqsave(&acb->rqbuffer_lock, flags);
+ acb->acb_flags |= ACB_F_MESSAGE_RQBUFFER_CLEARED;
acb->rqbuf_getIndex = 0;
acb->rqbuf_putIndex = 0;
+ pQbuffer = acb->rqbuffer;
+ memset(pQbuffer, 0, sizeof (struct QBUFFER));
spin_unlock_irqrestore(&acb->rqbuffer_lock, flags);
spin_lock_irqsave(&acb->wqbuffer_lock, flags);
+ acb->acb_flags |= (ACB_F_MESSAGE_WQBUFFER_CLEARED |
+ ACB_F_MESSAGE_WQBUFFER_READED);
acb->wqbuf_getIndex = 0;
acb->wqbuf_putIndex = 0;
- spin_unlock_irqrestore(&acb->wqbuffer_lock, flags);
- pQbuffer = acb->rqbuffer;
- memset(pQbuffer, 0, sizeof (struct QBUFFER));
pQbuffer = acb->wqbuffer;
memset(pQbuffer, 0, sizeof (struct QBUFFER));
+ spin_unlock_irqrestore(&acb->wqbuffer_lock, flags);
return 1;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] arcmsr: Fix a potential data corruption issue
2015-07-10 5:18 ` Christophe JAILLET
@ 2015-07-10 9:25 ` Dan Carpenter
-1 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2015-07-10 9:25 UTC (permalink / raw)
To: Christophe JAILLET; +Cc: JBottomley, linux-scsi, linux-kernel, kernel-janitors
On Fri, Jul 10, 2015 at 07:18:10AM +0200, Christophe JAILLET wrote:
> Resetting rqbuffer or wqbuffer must be done within a critial section
> in order to avoir potential data corruption.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
I don't know the code well enough to say if it's necessary, but it seems
reasonable to me.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arcmsr: Fix a potential data corruption issue
@ 2015-07-10 9:25 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2015-07-10 9:25 UTC (permalink / raw)
To: Christophe JAILLET; +Cc: JBottomley, linux-scsi, linux-kernel, kernel-janitors
On Fri, Jul 10, 2015 at 07:18:10AM +0200, Christophe JAILLET wrote:
> Resetting rqbuffer or wqbuffer must be done within a critial section
> in order to avoir potential data corruption.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
I don't know the code well enough to say if it's necessary, but it seems
reasonable to me.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-07-10 9:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-10 5:18 [PATCH] arcmsr: Fix a potential data corruption issue Christophe JAILLET
2015-07-10 5:18 ` Christophe JAILLET
2015-07-10 9:25 ` Dan Carpenter
2015-07-10 9:25 ` Dan Carpenter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.