lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 10 Jul 2015 07:18:10 +0200
From:	Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:	JBottomley@...n.com
Cc:	linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
	kernel-janitors@...r.kernel.org,
	Christophe JAILLET <christophe.jaillet@...adoo.fr>
Subject: [PATCH] arcmsr: Fix a potential data corruption issue

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@...adoo.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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ