From: Rohinthan P <rokinthanp03@gmail.com>
To: Ian Abbott <abbotti@mev.co.uk>,
H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: linux-kernel@vger.kernel.org,
syzbot+a4cedab706d0a8a3f988@syzkaller.appspotmail.com,
Rohinthan P <rokinthanp03@gmail.com>
Subject: [PATCH] comedi: dt2811: fix shift-out-of-bounds in dt2811_attach()
Date: Wed, 23 Sep 2026 11:38:59 +0530 [thread overview]
Message-ID: <20260923060859.15694-1-rokinthanp03@gmail.com> (raw)
In dt2811_attach(), the driver checks whether the user-supplied IRQ in
it->options[1] is valid for async command support using:
if (it->options[1] <= 7 && (BIT(it->options[1]) & 0xac))
Because it->options[1] is a signed integer, passing a negative value
(such as -251) satisfies it->options[1] <= 7 and causes the BIT()
macro to evaluate a negative shift exponent (1UL << -251), resulting in
undefined behavior and triggering a UBSAN shift-out-of-bounds warning:
UBSAN: shift-out-of-bounds in drivers/comedi/drivers/dt2811.c
shift exponent -251 is negative
CPU: 0 UID: 0 PID: 5925 Comm: syz.0.17 Not tainted
Call Trace:
dt2811_attach.cold+0x19/0x1e drivers/comedi/drivers/dt2811.c:570
comedi_device_attach+0x40e/0x6b0 drivers/comedi/drivers.c:1101
do_devconfig_ioctl+0x1b3/0x6d0 drivers/comedi/comedi_fops.c:930
Only IRQs 2, 3, 5, and 7 are valid on the DT2811. Add a check that
it->options[1] >= 2 before evaluating BIT(it->options[1]) to avoid
negative shift values.
Fixes: 8ffdff6a8cfb ("staging: comedi: move out of staging directory")
Reported-by: syzbot+a4cedab706d0a8a3f988@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=a4cedab706d0a8a3f988
Signed-off-by: Rohinthan P <rokinthanp03@gmail.com>
---
drivers/comedi/drivers/dt2811.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/comedi/drivers/dt2811.c b/drivers/comedi/drivers/dt2811.c
index bcc4b5e..813b1aa 100644
--- a/drivers/comedi/drivers/dt2811.c
+++ b/drivers/comedi/drivers/dt2811.c
@@ -564,7 +564,8 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it)
dt2811_reset(dev);
/* IRQ's 2,3,5,7 are valid for async command support */
- if (it->options[1] <= 7 && (BIT(it->options[1]) & 0xac)) {
+ if (it->options[1] >= 2 && it->options[1] <= 7 &&
+ (BIT(it->options[1]) & 0xac)) {
ret = request_irq(it->options[1], dt2811_interrupt, 0,
dev->board_name, dev);
if (ret == 0)
--
2.53.0
next reply other threads:[~2026-09-23 6:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 6:08 Rohinthan P [this message]
2026-09-23 9:17 ` Ian Abbott
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260923060859.15694-1-rokinthanp03@gmail.com \
--to=rokinthanp03@gmail.com \
--cc=abbotti@mev.co.uk \
--cc=hsweeten@visionengravers.com \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+a4cedab706d0a8a3f988@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®