[PATCH] comedi: aio_iiro_16: Prevent invlaid irq number

Edward Adam Davis posted 1 patch 3 months ago
drivers/comedi/drivers/aio_iiro_16.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] comedi: aio_iiro_16: Prevent invlaid irq number
Posted by Edward Adam Davis 3 months ago
The irq number 0x2166 passed by the reproducer is too large and is not
within the supported range [2-7, 10-12, 14, or 15], which triggers the oob.

Fixes: ad7a370c8be4 ("staging: comedi: aio_iiro_16: add command support for change of state detection")
Reported-by: syzbot+f1bb7e4ea47ea12b535c@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=f1bb7e4ea47ea12b535c
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
 drivers/comedi/drivers/aio_iiro_16.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/comedi/drivers/aio_iiro_16.c b/drivers/comedi/drivers/aio_iiro_16.c
index b00fab0b89d4..e43730f00c8b 100644
--- a/drivers/comedi/drivers/aio_iiro_16.c
+++ b/drivers/comedi/drivers/aio_iiro_16.c
@@ -177,7 +177,8 @@ static int aio_iiro_16_attach(struct comedi_device *dev,
 	 * Digital input change of state interrupts are optionally supported
 	 * using IRQ 2-7, 10-12, 14, or 15.
 	 */
-	if ((1 << it->options[1]) & 0xdcfc) {
+	if (it->options[1] > 1 && it->options[1] < 16 &&
+	    (1 << it->options[1]) & 0xdcfc) {
 		ret = request_irq(it->options[1], aio_iiro_16_cos, 0,
 				  dev->board_name, dev);
 		if (ret == 0)
-- 
2.43.0
Re: [PATCH] comedi: aio_iiro_16: Prevent invlaid irq number
Posted by Ian Abbott 3 months ago
On 08/07/2025 13:37, Edward Adam Davis wrote:
> The irq number 0x2166 passed by the reproducer is too large and is not
> within the supported range [2-7, 10-12, 14, or 15], which triggers the oob.
> 
> Fixes: ad7a370c8be4 ("staging: comedi: aio_iiro_16: add command support for change of state detection")
> Reported-by: syzbot+f1bb7e4ea47ea12b535c@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=f1bb7e4ea47ea12b535c
> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> ---
>   drivers/comedi/drivers/aio_iiro_16.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/comedi/drivers/aio_iiro_16.c b/drivers/comedi/drivers/aio_iiro_16.c
> index b00fab0b89d4..e43730f00c8b 100644
> --- a/drivers/comedi/drivers/aio_iiro_16.c
> +++ b/drivers/comedi/drivers/aio_iiro_16.c
> @@ -177,7 +177,8 @@ static int aio_iiro_16_attach(struct comedi_device *dev,
>   	 * Digital input change of state interrupts are optionally supported
>   	 * using IRQ 2-7, 10-12, 14, or 15.
>   	 */
> -	if ((1 << it->options[1]) & 0xdcfc) {
> +	if (it->options[1] > 1 && it->options[1] < 16 &&
> +	    (1 << it->options[1]) & 0xdcfc) {
>   		ret = request_irq(it->options[1], aio_iiro_16_cos, 0,
>   				  dev->board_name, dev);
>   		if (ret == 0)

The patch is fine apart from the misspelling of "invalid" in the subject 
line, but I'd already submitted a patch for this before syzbot detected it:

https://lore.kernel.org/lkml/20250707134622.75403-1-abbotti@mev.co.uk/

-- 
-=( Ian Abbott <abbotti@mev.co.uk> || MEV Ltd. is a company  )=-
-=( registered in England & Wales.  Regd. number: 02862268.  )=-
-=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
-=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-
Re: [PATCH] comedi: aio_iiro_16: Prevent invlaid irq number
Posted by Abhinav Saxena 1 week, 1 day ago
Ian Abbott <abbotti@mev.co.uk> writes:

> On 08/07/2025 13:37, Edward Adam Davis wrote:
>> The irq number 0x2166 passed by the reproducer is too large and is not
>> within the supported range [2-7, 10-12, 14, or 15], which triggers the oob.
>> Fixes: ad7a370c8be4 (“staging: comedi: aio_iiro_16: add command
>> support for change of state detection”)
>> Reported-by: syzbot+f1bb7e4ea47ea12b535c@syzkaller.appspotmail.com
>> Closes: <https://syzkaller.appspot.com/bug?extid=f1bb7e4ea47ea12b535c>
>> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
>> —
>>   drivers/comedi/drivers/aio_iiro_16.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>> diff –git a/drivers/comedi/drivers/aio_iiro_16.c
>> b/drivers/comedi/drivers/aio_iiro_16.c
>> index b00fab0b89d4..e43730f00c8b 100644
>> — a/drivers/comedi/drivers/aio_iiro_16.c
>> +++ b/drivers/comedi/drivers/aio_iiro_16.c
>> @@ -177,7 +177,8 @@ static int aio_iiro_16_attach(struct comedi_device *dev,
>>   	 * Digital input change of state interrupts are optionally supported
>>   	 * using IRQ 2-7, 10-12, 14, or 15.
>>   	 */
>> -	if ((1 << it->options[1]) & 0xdcfc) {
>> +	if (it->options[1] > 1 && it->options[1] < 16 &&
>> +	    (1 << it->options[1]) & 0xdcfc) {
>>   		ret = request_irq(it->options[1], aio_iiro_16_cos, 0,
>>   				  dev->board_name, dev);
>>   		if (ret == 0)
>
> The patch is fine apart from the misspelling of “invalid” in the subject
> line, but I’d already submitted a patch for this before syzbot detected
> it:
>
> <https://lore.kernel.org/lkml/20250707134622.75403-1-abbotti@mev.co.uk/>

#syz fix: comedi: aio_iiro_16: Fix bit shift out of bounds