mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pei Xiao <xiaopei01@kylinos.cn>
To: Ian Abbott <abbotti@mev.co.uk>,
	hsweeten@visionengravers.com, linux-kernel@vger.kernel.org,
	syzbot+a4cedab706d0a8a3f988@syzkaller.appspotmail.com
Cc: syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] comedi: dt2811: fix shift-out-of-bounds in IRQ check
Date: Tue, 22 Sep 2026 17:17:39 +0800	[thread overview]
Message-ID: <374a9258-48cd-489c-a652-251863eba680@kylinos.cn> (raw)
In-Reply-To: <82ccb90f-4d0f-44a9-ba3f-11c391cd4bca@mev.co.uk>



在 2026/9/22 17:11, Ian Abbott 写道:
> On 2026-09-22 08:16, Pei Xiao wrote:
>> The IRQ number passed via comedi_devconfig->options[1] is a signed int
>> that comes from userspace.  The check `it->options[1] <= 7` does not
>> reject negative values, so a negative IRQ number reaches
>> `BIT(it->options[1])`, which is undefined behavior and triggers a UBSAN
>> shift-out-of-bounds warning:
>>
>>    UBSAN: shift-out-of-bounds in drivers/comedi/drivers/dt2811.c:570:31
>>    shift exponent -251 is negative
>>
>> Add an explicit lower bound check (`it->options[1] >= 0`) so that only
>> valid IRQ numbers 0..7 are accepted before the shift.
>>
>> Fixes: f2975a9b2ab9 ("staging: comedi: dt2811: add async command
>> support for AI subdevice")
>> Reported-by: syzbot+a4cedab706d0a8a3f988@syzkaller.appspotmail.com
>> Closes: https://lore.kernel.org/
>> all/6ab21240.e548f532.1ca396.0018.GAE@google.com/#R
>> Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
>> ---
>>   drivers/comedi/drivers/dt2811.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/comedi/drivers/dt2811.c b/drivers/comedi/drivers/
>> dt2811.c
>> index 0438b8c90e44..53cb17993ae7 100644
>> --- a/drivers/comedi/drivers/dt2811.c
>> +++ b/drivers/comedi/drivers/dt2811.c
>> @@ -567,7 +567,7 @@ 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] >= 0 && 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)
> 
> Looks good, thanks!
> 
> Please could you resend and Cc: Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> ?  Thanks!
ok. Thanks!

Pei.>


  reply	other threads:[~2026-09-22  9:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22  5:29 [syzbot] [comedi?] UBSAN: shift-out-of-bounds in dt2811_attach syzbot
2026-09-22  6:37 ` [PATCH] test dt2811 Pei Xiao
2026-09-22  6:57   ` [syzbot] [comedi?] UBSAN: shift-out-of-bounds in dt2811_attach syzbot
2026-09-22  7:16 ` [PATCH] comedi: dt2811: fix shift-out-of-bounds in IRQ check Pei Xiao
2026-09-22  9:11   ` Ian Abbott
2026-09-22  9:17     ` Pei Xiao [this message]
2026-09-22  9:19   ` Pei Xiao
2026-09-23  9:11   ` 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=374a9258-48cd-489c-a652-251863eba680@kylinos.cn \
    --to=xiaopei01@kylinos.cn \
    --cc=abbotti@mev.co.uk \
    --cc=hsweeten@visionengravers.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+a4cedab706d0a8a3f988@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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®