linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] esas2r: Fix array overrun
@ 2016-02-15 19:01 Alan
  2016-02-16  7:02 ` Johannes Thumshirn
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alan @ 2016-02-15 19:01 UTC (permalink / raw)
  To: thenzl, linux-scsi

Check the array size *before* dereferencing it with a user provided offset

Signed-off-by: Alan Cox <alan@linux.intel.com>
---
 drivers/scsi/esas2r/esas2r_ioctl.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/esas2r/esas2r_ioctl.c b/drivers/scsi/esas2r/esas2r_ioctl.c
index baf9130..3e84834 100644
--- a/drivers/scsi/esas2r/esas2r_ioctl.c
+++ b/drivers/scsi/esas2r/esas2r_ioctl.c
@@ -1360,14 +1360,15 @@ int esas2r_ioctl_handler(void *hostdata, int cmd, void __user *arg)
 	if (ioctl->header.channel == 0xFF) {
 		a = (struct esas2r_adapter *)hostdata;
 	} else {
-		a = esas2r_adapters[ioctl->header.channel];
-		if (ioctl->header.channel >= MAX_ADAPTERS || (a == NULL)) {
+		if (ioctl->header.channel >= MAX_ADAPTERS ||
+			esas2r_adapters[ioctl->header.channel] == NULL) {
 			ioctl->header.return_code = IOCTL_BAD_CHANNEL;
 			esas2r_log(ESAS2R_LOG_WARN, "bad channel value");
 			kfree(ioctl);
 
 			return -ENOTSUPP;
 		}
+		a = esas2r_adapters[ioctl->header.channel];
 	}
 
 	switch (cmd) {


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-02-18  0:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-15 19:01 [PATCH] esas2r: Fix array overrun Alan
2016-02-16  7:02 ` Johannes Thumshirn
2016-02-16 12:24 ` Tomas Henzl
2016-02-18  0:16 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).