Skip to content

Commit

Permalink
esas2r: Fix array overrun
Browse files Browse the repository at this point in the history
Check the array size *before* dereferencing it with a user provided
offset.

Signed-off-by: Alan Cox <[email protected]>
Reviewed-by: Johannes Thumshirn <[email protected]>
Reviewed-by: Tomas Henzl <[email protected]>
Signed-off-by: Martin K. Petersen <[email protected]>
  • Loading branch information
Alan authored and martinkpetersen committed Feb 24, 2016
1 parent 5a51a7a commit 5b2e0c1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/scsi/esas2r/esas2r_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 5b2e0c1

Please sign in to comment.