Skip to content

Commit ed93c6f

Browse files
ian-abbottgregkh
authored andcommitted
comedi: das16m1: Fix bit shift out of bounds
When checking for a supported IRQ number, the following test is used: /* only irqs 2, 3, 4, 5, 6, 7, 10, 11, 12, 14, and 15 are valid */ if ((1 << it->options[1]) & 0xdcfc) { However, `it->options[i]` is an unchecked `int` value from userspace, so the shift amount could be negative or out of bounds. Fix the test by requiring `it->options[1]` to be within bounds before proceeding with the original test. Reported-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=c52293513298e0fd9a94 Fixes: 7299885 ("staging: comedi: das16m1: tidy up the irq support in das16m1_attach()") Tested-by: [email protected] Suggested-by: "Enju, Kohei" <[email protected]> Cc: [email protected] # 5.13+ Signed-off-by: Ian Abbott <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ab705c8 commit ed93c6f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/comedi/drivers/das16m1.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,8 @@ static int das16m1_attach(struct comedi_device *dev,
522522
devpriv->extra_iobase = dev->iobase + DAS16M1_8255_IOBASE;
523523

524524
/* only irqs 2, 3, 4, 5, 6, 7, 10, 11, 12, 14, and 15 are valid */
525-
if ((1 << it->options[1]) & 0xdcfc) {
525+
if (it->options[1] >= 2 && it->options[1] <= 15 &&
526+
(1 << it->options[1]) & 0xdcfc) {
526527
ret = request_irq(it->options[1], das16m1_interrupt, 0,
527528
dev->board_name, dev);
528529
if (ret == 0)

0 commit comments

Comments
 (0)