* [PATCH 5.10.y] comedi: das16m1: Fix bit shift out of bounds
2025-07-24 18:12 [PATCH 5.10.y] comedi: Fail COMEDI_INSNLIST ioctl if n_insns is too large Ian Abbott
@ 2025-07-24 18:12 ` Ian Abbott
2025-07-25 23:24 ` Sasha Levin
0 siblings, 1 reply; 4+ messages in thread
From: Ian Abbott @ 2025-07-24 18:12 UTC (permalink / raw)
To: stable
Cc: Ian Abbott, syzbot+c52293513298e0fd9a94, Enju, Kohei,
Greg Kroah-Hartman
[ Upstream commit ed93c6f68a3be06e4e0c331c6e751f462dee3932 ]
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: syzbot+c52293513298e0fd9a94@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=c52293513298e0fd9a94
Fixes: 729988507680 ("staging: comedi: das16m1: tidy up the irq support in das16m1_attach()")
Tested-by: syzbot+c52293513298e0fd9a94@syzkaller.appspotmail.com
Suggested-by: "Enju, Kohei" <enjuk@amazon.co.jp>
Cc: stable@vger.kernel.org # 5.13+
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Link: https://lore.kernel.org/r/20250707130908.70758-1-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/staging/comedi/drivers/das16m1.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c
index 75f3dbbe97ac..0d54387a1c26 100644
--- a/drivers/staging/comedi/drivers/das16m1.c
+++ b/drivers/staging/comedi/drivers/das16m1.c
@@ -523,7 +523,8 @@ static int das16m1_attach(struct comedi_device *dev,
devpriv->extra_iobase = dev->iobase + DAS16M1_8255_IOBASE;
/* only irqs 2, 3, 4, 5, 6, 7, 10, 11, 12, 14, and 15 are valid */
- if ((1 << it->options[1]) & 0xdcfc) {
+ if (it->options[1] >= 2 && it->options[1] <= 15 &&
+ (1 << it->options[1]) & 0xdcfc) {
ret = request_irq(it->options[1], das16m1_interrupt, 0,
dev->board_name, dev);
if (ret == 0)
--
2.47.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 5.10.y] comedi: das16m1: Fix bit shift out of bounds
@ 2025-07-24 18:16 Ian Abbott
2025-07-25 23:26 ` Sasha Levin
0 siblings, 1 reply; 4+ messages in thread
From: Ian Abbott @ 2025-07-24 18:16 UTC (permalink / raw)
To: stable
Cc: Ian Abbott, syzbot+c52293513298e0fd9a94, Enju, Kohei,
Greg Kroah-Hartman
[ Upstream commit ed93c6f68a3be06e4e0c331c6e751f462dee3932 ]
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: syzbot+c52293513298e0fd9a94@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=c52293513298e0fd9a94
Fixes: 729988507680 ("staging: comedi: das16m1: tidy up the irq support in das16m1_attach()")
Tested-by: syzbot+c52293513298e0fd9a94@syzkaller.appspotmail.com
Suggested-by: "Enju, Kohei" <enjuk@amazon.co.jp>
Cc: stable@vger.kernel.org # 5.13+
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Link: https://lore.kernel.org/r/20250707130908.70758-1-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/staging/comedi/drivers/das16m1.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c
index 75f3dbbe97ac..0d54387a1c26 100644
--- a/drivers/staging/comedi/drivers/das16m1.c
+++ b/drivers/staging/comedi/drivers/das16m1.c
@@ -523,7 +523,8 @@ static int das16m1_attach(struct comedi_device *dev,
devpriv->extra_iobase = dev->iobase + DAS16M1_8255_IOBASE;
/* only irqs 2, 3, 4, 5, 6, 7, 10, 11, 12, 14, and 15 are valid */
- if ((1 << it->options[1]) & 0xdcfc) {
+ if (it->options[1] >= 2 && it->options[1] <= 15 &&
+ (1 << it->options[1]) & 0xdcfc) {
ret = request_irq(it->options[1], das16m1_interrupt, 0,
dev->board_name, dev);
if (ret == 0)
--
2.47.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 5.10.y] comedi: das16m1: Fix bit shift out of bounds
2025-07-24 18:12 ` [PATCH 5.10.y] comedi: das16m1: Fix bit shift out of bounds Ian Abbott
@ 2025-07-25 23:24 ` Sasha Levin
0 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2025-07-25 23:24 UTC (permalink / raw)
To: stable; +Cc: Sasha Levin
[ Sasha's backport helper bot ]
Hi,
✅ All tests passed successfully. No issues detected.
No action required from the submitter.
The upstream commit SHA1 provided is correct: ed93c6f68a3be06e4e0c331c6e751f462dee3932
Status in newer kernel trees:
6.15.y | Not found
6.12.y | Not found
6.6.y | Not found
6.1.y | Not found
5.15.y | Not found
Note: The patch differs from the upstream commit:
---
1: ed93c6f68a3b ! 1: 866ef819f63e comedi: das16m1: Fix bit shift out of bounds
@@ Metadata
## Commit message ##
comedi: das16m1: Fix bit shift out of bounds
+ [ Upstream commit ed93c6f68a3be06e4e0c331c6e751f462dee3932 ]
+
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 */
@@ Commit message
Link: https://lore.kernel.org/r/20250707130908.70758-1-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
- ## drivers/comedi/drivers/das16m1.c ##
-@@ drivers/comedi/drivers/das16m1.c: static int das16m1_attach(struct comedi_device *dev,
+ ## drivers/staging/comedi/drivers/das16m1.c ##
+@@ drivers/staging/comedi/drivers/das16m1.c: static int das16m1_attach(struct comedi_device *dev,
devpriv->extra_iobase = dev->iobase + DAS16M1_8255_IOBASE;
/* only irqs 2, 3, 4, 5, 6, 7, 10, 11, 12, 14, and 15 are valid */
---
Results of testing on various branches:
| Branch | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| origin/linux-5.10.y | Success | Success |
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 5.10.y] comedi: das16m1: Fix bit shift out of bounds
2025-07-24 18:16 [PATCH 5.10.y] comedi: das16m1: Fix bit shift out of bounds Ian Abbott
@ 2025-07-25 23:26 ` Sasha Levin
0 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2025-07-25 23:26 UTC (permalink / raw)
To: stable; +Cc: Sasha Levin
[ Sasha's backport helper bot ]
Hi,
✅ All tests passed successfully. No issues detected.
No action required from the submitter.
The upstream commit SHA1 provided is correct: ed93c6f68a3be06e4e0c331c6e751f462dee3932
Status in newer kernel trees:
6.15.y | Not found
6.12.y | Not found
6.6.y | Not found
6.1.y | Not found
5.15.y | Not found
Note: The patch differs from the upstream commit:
---
1: ed93c6f68a3b ! 1: cd8b98d5fa76 comedi: das16m1: Fix bit shift out of bounds
@@ Metadata
## Commit message ##
comedi: das16m1: Fix bit shift out of bounds
+ [ Upstream commit ed93c6f68a3be06e4e0c331c6e751f462dee3932 ]
+
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 */
@@ Commit message
Link: https://lore.kernel.org/r/20250707130908.70758-1-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
- ## drivers/comedi/drivers/das16m1.c ##
-@@ drivers/comedi/drivers/das16m1.c: static int das16m1_attach(struct comedi_device *dev,
+ ## drivers/staging/comedi/drivers/das16m1.c ##
+@@ drivers/staging/comedi/drivers/das16m1.c: static int das16m1_attach(struct comedi_device *dev,
devpriv->extra_iobase = dev->iobase + DAS16M1_8255_IOBASE;
/* only irqs 2, 3, 4, 5, 6, 7, 10, 11, 12, 14, and 15 are valid */
---
Results of testing on various branches:
| Branch | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| origin/linux-5.10.y | Success | Success |
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-07-25 23:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-24 18:16 [PATCH 5.10.y] comedi: das16m1: Fix bit shift out of bounds Ian Abbott
2025-07-25 23:26 ` Sasha Levin
-- strict thread matches above, loose matches on Subject: below --
2025-07-24 18:12 [PATCH 5.10.y] comedi: Fail COMEDI_INSNLIST ioctl if n_insns is too large Ian Abbott
2025-07-24 18:12 ` [PATCH 5.10.y] comedi: das16m1: Fix bit shift out of bounds Ian Abbott
2025-07-25 23:24 ` Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox