netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mwifiex: Fix divide error in mwifiex_usb_dnld_fw
@ 2021-10-19  3:31 Wan Jiabing
  2021-10-19  4:04 ` Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: Wan Jiabing @ 2021-10-19  3:31 UTC (permalink / raw)
  To: Amitkumar Karwar, Ganapathi Bhat, Sharvari Harisangam,
	Xinming Hu, Kalle Valo, David S. Miller, Jakub Kicinski,
	linux-wireless, netdev, linux-kernel
  Cc: kael_w, Wan Jiabing, syzbot+4e7b6c94d22f4bfca9a0

This patch try to fix bug reported by syzkaller:
divide error: 0000 [#1] SMP KASAN
CPU: 1 PID: 17 Comm: kworker/1:0 Not tainted 5.15.0-rc5-syzkaller #0
Hardware name: Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events request_firmware_work_func
RIP: 0010:mwifiex_write_data_sync drivers/net/wireless/marvell/mwifiex/usb.c:696 [inline]
RIP: 0010:mwifiex_prog_fw_w_helper drivers/net/wireless/marvell/mwifiex/usb.c:1437 [inline]
RIP: 0010:mwifiex_usb_dnld_fw+0xabd/0x11a0 drivers/net/wireless/marvell/mwifiex/usb.c:1518
Call Trace:
 _mwifiex_fw_dpc+0x181/0x10a0 drivers/net/wireless/marvell/mwifiex/main.c:542
 request_firmware_work_func+0x12c/0x230 drivers/base/firmware_loader/main.c:1081
 process_one_work+0x9bf/0x1620 kernel/workqueue.c:2297
 worker_thread+0x658/0x11f0 kernel/workqueue.c:2444
 kthread+0x3c2/0x4a0 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Link: https://syzkaller.appspot.com/bug?extid=4e7b6c94d22f4bfca9a0
Reported-and-tested-by: syzbot+4e7b6c94d22f4bfca9a0@syzkaller.appspotmail.com
Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
---
 drivers/net/wireless/marvell/mwifiex/usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/usb.c b/drivers/net/wireless/marvell/mwifiex/usb.c
index 426e39d4ccf0..c24ec27d4057 100644
--- a/drivers/net/wireless/marvell/mwifiex/usb.c
+++ b/drivers/net/wireless/marvell/mwifiex/usb.c
@@ -693,7 +693,7 @@ static int mwifiex_write_data_sync(struct mwifiex_adapter *adapter, u8 *pbuf,
 	struct usb_card_rec *card = adapter->card;
 	int actual_length, ret;
 
-	if (!(*len % card->bulk_out_maxpktsize))
+	if (card->bulk_out_maxpktsize && !(*len % card->bulk_out_maxpktsize))
 		(*len)++;
 
 	/* Send the data block */
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mwifiex: Fix divide error in mwifiex_usb_dnld_fw
  2021-10-19  3:31 [PATCH] mwifiex: Fix divide error in mwifiex_usb_dnld_fw Wan Jiabing
@ 2021-10-19  4:04 ` Eric Dumazet
  2021-10-19 17:06   ` Brian Norris
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2021-10-19  4:04 UTC (permalink / raw)
  To: Wan Jiabing, Amitkumar Karwar, Ganapathi Bhat,
	Sharvari Harisangam, Xinming Hu, Kalle Valo, David S. Miller,
	Jakub Kicinski, linux-wireless, netdev, linux-kernel
  Cc: kael_w, syzbot+4e7b6c94d22f4bfca9a0



On 10/18/21 8:31 PM, Wan Jiabing wrote:
> This patch try to fix bug reported by syzkaller:
> divide error: 0000 [#1] SMP KASAN
> CPU: 1 PID: 17 Comm: kworker/1:0 Not tainted 5.15.0-rc5-syzkaller #0
> Hardware name: Google Compute Engine, BIOS Google 01/01/2011
> Workqueue: events request_firmware_work_func
> RIP: 0010:mwifiex_write_data_sync drivers/net/wireless/marvell/mwifiex/usb.c:696 [inline]
> RIP: 0010:mwifiex_prog_fw_w_helper drivers/net/wireless/marvell/mwifiex/usb.c:1437 [inline]
> RIP: 0010:mwifiex_usb_dnld_fw+0xabd/0x11a0 drivers/net/wireless/marvell/mwifiex/usb.c:1518
> Call Trace:
>  _mwifiex_fw_dpc+0x181/0x10a0 drivers/net/wireless/marvell/mwifiex/main.c:542
>  request_firmware_work_func+0x12c/0x230 drivers/base/firmware_loader/main.c:1081
>  process_one_work+0x9bf/0x1620 kernel/workqueue.c:2297
>  worker_thread+0x658/0x11f0 kernel/workqueue.c:2444
>  kthread+0x3c2/0x4a0 kernel/kthread.c:319
>  ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
> 
> Link: https://syzkaller.appspot.com/bug?extid=4e7b6c94d22f4bfca9a0

Please provide a Fixes: tag

> Reported-and-tested-by: syzbot+4e7b6c94d22f4bfca9a0@syzkaller.appspotmail.com
> Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
> ---
>  drivers/net/wireless/marvell/mwifiex/usb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/marvell/mwifiex/usb.c b/drivers/net/wireless/marvell/mwifiex/usb.c
> index 426e39d4ccf0..c24ec27d4057 100644
> --- a/drivers/net/wireless/marvell/mwifiex/usb.c
> +++ b/drivers/net/wireless/marvell/mwifiex/usb.c
> @@ -693,7 +693,7 @@ static int mwifiex_write_data_sync(struct mwifiex_adapter *adapter, u8 *pbuf,
>  	struct usb_card_rec *card = adapter->card;
>  	int actual_length, ret;
>  
> -	if (!(*len % card->bulk_out_maxpktsize))
> +	if (card->bulk_out_maxpktsize && !(*len % card->bulk_out_maxpktsize))


Are you sure this fix is not working around the real bug ?

In which cases bulk_out_maxpktsize would be zero ?

If this is a valid case, this needs to be explained in the changelog.

>  		(*len)++;
>  
>  	/* Send the data block */
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mwifiex: Fix divide error in mwifiex_usb_dnld_fw
  2021-10-19  4:04 ` Eric Dumazet
@ 2021-10-19 17:06   ` Brian Norris
  0 siblings, 0 replies; 3+ messages in thread
From: Brian Norris @ 2021-10-19 17:06 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Wan Jiabing, Amitkumar Karwar, Ganapathi Bhat,
	Sharvari Harisangam, Xinming Hu, Kalle Valo, David S. Miller,
	Jakub Kicinski, linux-wireless, <netdev@vger.kernel.org>,
	Linux Kernel, kael_w, syzbot+4e7b6c94d22f4bfca9a0

On Mon, Oct 18, 2021 at 9:04 PM Eric Dumazet <eric.dumazet@gmail.com> wrote:
> On 10/18/21 8:31 PM, Wan Jiabing wrote:
> > --- a/drivers/net/wireless/marvell/mwifiex/usb.c
> > +++ b/drivers/net/wireless/marvell/mwifiex/usb.c
> > @@ -693,7 +693,7 @@ static int mwifiex_write_data_sync(struct mwifiex_adapter *adapter, u8 *pbuf,
> >       struct usb_card_rec *card = adapter->card;
> >       int actual_length, ret;
> >
> > -     if (!(*len % card->bulk_out_maxpktsize))
> > +     if (card->bulk_out_maxpktsize && !(*len % card->bulk_out_maxpktsize))
>
>
> Are you sure this fix is not working around the real bug ?
>
> In which cases bulk_out_maxpktsize would be zero ?
>
> If this is a valid case, this needs to be explained in the changelog.

I'm with Eric here. This was a bug reported by a fuzzer, which throws
invalid input at the driver. The right answer is likely that we should
reject such invalid input when we receive it -- i.e., we should fail
to probe() the device if it has invalid capabilities. In particular,
we should fail to probe if wMaxPacketSize==0.

I was thinking of sending such a patch myself, but I don't have any
USB mwifiex hardware to test, so I deferred. It's probably pretty low
risk anyway, though.

Brian

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-19 17:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-19  3:31 [PATCH] mwifiex: Fix divide error in mwifiex_usb_dnld_fw Wan Jiabing
2021-10-19  4:04 ` Eric Dumazet
2021-10-19 17:06   ` Brian Norris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).