linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [syzbot] divide error in ath9k_htc_swba
@ 2021-06-18  9:25 syzbot
  2021-06-18 10:31 ` Pavel Skripkin
  0 siblings, 1 reply; 3+ messages in thread
From: syzbot @ 2021-06-18  9:25 UTC (permalink / raw)
  To: ath9k-devel, davem, kuba, kvalo, linux-kernel, linux-usb,
	linux-wireless, netdev, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    37fdb7c9 Merge tag 'v5.13-rc6' into usb-next
git tree:       https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
console output: https://syzkaller.appspot.com/x/log.txt?x=1702bbebd00000
kernel config:  https://syzkaller.appspot.com/x/.config?x=e3b6ba4f6e6c6ddf
dashboard link: https://syzkaller.appspot.com/bug?extid=90d241d7661ca2493f0b
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=113b98b8300000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=134650f7d00000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+90d241d7661ca2493f0b@syzkaller.appspotmail.com

divide error: 0000 [#1] SMP KASAN
CPU: 1 PID: 32 Comm: kworker/1:1 Not tainted 5.13.0-rc6-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events request_firmware_work_func
RIP: 0010:ath9k_htc_choose_bslot drivers/net/wireless/ath/ath9k/htc_drv_beacon.c:277 [inline]
RIP: 0010:ath9k_htc_swba+0x1b2/0xc70 drivers/net/wireless/ath/ath9k/htc_drv_beacon.c:310
Code: c0 40 84 c6 0f 85 db 09 00 00 48 8b 55 00 0f b7 c9 bd 01 00 00 00 48 0f ca 48 89 d0 c1 ea 0a 48 c1 e8 20 c1 e0 16 09 d0 31 d2 <f7> f1 8d 04 12 31 d2 f7 f1 29 c5 48 8d 83 b0 03 00 00 48 89 c7 48
RSP: 0018:ffffc90000148dc8 EFLAGS: 00010246
RAX: 0000000000000000 RBX: ffff88811a0d31e0 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000001
RBP: 0000000000000001 R08: 0000000000000000 R09: 0000000000000000
R10: ffffffff8304a44a R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000000 R14: ffff88810efedc0c R15: ffff88811a63c1f0
FS:  0000000000000000(0000) GS:ffff8881f6900000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020001038 CR3: 00000001081c0000 CR4: 00000000001506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <IRQ>
 ath9k_wmi_event_tasklet+0x2e7/0x3f0 drivers/net/wireless/ath/ath9k/wmi.c:165
 tasklet_action_common.constprop.0+0x201/0x2e0 kernel/softirq.c:784
 __do_softirq+0x1b0/0x944 kernel/softirq.c:559
 invoke_softirq kernel/softirq.c:433 [inline]
 __irq_exit_rcu kernel/softirq.c:637 [inline]
 irq_exit_rcu+0x119/0x1a0 kernel/softirq.c:649
 sysvec_apic_timer_interrupt+0x6a/0x90 arch/x86/kernel/apic/apic.c:1100
 </IRQ>
 asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:647
RIP: 0010:preempt_count arch/x86/include/asm/preempt.h:27 [inline]
RIP: 0010:check_kcov_mode kernel/kcov.c:163 [inline]
RIP: 0010:__sanitizer_cov_trace_pc+0x0/0x60 kernel/kcov.c:197
Code: 89 03 e9 04 fd ff ff b9 ff ff ff ff ba 08 00 00 00 4d 8b 03 48 0f bd ca 49 8b 45 00 48 63 c9 e9 64 ff ff ff 66 0f 1f 44 00 00 <65> 8b 05 b9 d5 c0 7e 89 c1 48 8b 34 24 81 e1 00 01 00 00 65 48 8b
RSP: 0018:ffffc90000197540 EFLAGS: 00000293
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: ffff888107ff0000 RSI: ffffffff812a3455 RDI: 0000000000000003
RBP: 0000000000000000 R08: 0000000000000000 R09: ffffffff8a8f0727
R10: ffffffff812a344b R11: 0000000000000000 R12: ffffffff82d1e760
R13: 0000000000000200 R14: dffffc0000000000 R15: ffffc900001975a0
 console_unlock+0x7cb/0xc20 kernel/printk/printk.c:2653
 vprintk_emit+0x20a/0x580 kernel/printk/printk.c:2174
 dev_vprintk_emit+0x36e/0x3b2 drivers/base/core.c:4553
 dev_printk_emit+0xba/0xf1 drivers/base/core.c:4564
 __dev_printk+0xcf/0xf5 drivers/base/core.c:4576
 _dev_err+0xd7/0x109 drivers/base/core.c:4619
 ath9k_init_htc_services.constprop.0.cold+0x32/0x11a drivers/net/wireless/ath/ath9k/htc_drv_init.c:220
 ath9k_htc_probe_device+0x25f/0x1e50 drivers/net/wireless/ath/ath9k/htc_drv_init.c:960
 ath9k_htc_hw_init+0x31/0x60 drivers/net/wireless/ath/ath9k/htc_hst.c:503
 ath9k_hif_usb_firmware_cb+0x274/0x530 drivers/net/wireless/ath/ath9k/hif_usb.c:1239
 request_firmware_work_func+0x12c/0x230 drivers/base/firmware_loader/main.c:1081
 process_one_work+0x98d/0x1580 kernel/workqueue.c:2276
 worker_thread+0x64c/0x1120 kernel/workqueue.c:2422
 kthread+0x38c/0x460 kernel/kthread.c:313
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294
Modules linked in:
---[ end trace 3235ce4c0fe1a3c7 ]---
RIP: 0010:ath9k_htc_choose_bslot drivers/net/wireless/ath/ath9k/htc_drv_beacon.c:277 [inline]
RIP: 0010:ath9k_htc_swba+0x1b2/0xc70 drivers/net/wireless/ath/ath9k/htc_drv_beacon.c:310
Code: c0 40 84 c6 0f 85 db 09 00 00 48 8b 55 00 0f b7 c9 bd 01 00 00 00 48 0f ca 48 89 d0 c1 ea 0a 48 c1 e8 20 c1 e0 16 09 d0 31 d2 <f7> f1 8d 04 12 31 d2 f7 f1 29 c5 48 8d 83 b0 03 00 00 48 89 c7 48
RSP: 0018:ffffc90000148dc8 EFLAGS: 00010246
RAX: 0000000000000000 RBX: ffff88811a0d31e0 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000001
RBP: 0000000000000001 R08: 0000000000000000 R09: 0000000000000000
R10: ffffffff8304a44a R11: 0000000000000000 R12: 0000000000000000
R13: 0000000000000000 R14: ffff88810efedc0c R15: ffff88811a63c1f0
FS:  0000000000000000(0000) GS:ffff8881f6900000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020001038 CR3: 00000001081c0000 CR4: 00000000001506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

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

* Re: [syzbot] divide error in ath9k_htc_swba
  2021-06-18  9:25 [syzbot] divide error in ath9k_htc_swba syzbot
@ 2021-06-18 10:31 ` Pavel Skripkin
  2021-06-18 10:49   ` syzbot
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Skripkin @ 2021-06-18 10:31 UTC (permalink / raw)
  To: syzbot
  Cc: ath9k-devel, davem, kuba, kvalo, linux-kernel, linux-usb,
	linux-wireless, netdev, syzkaller-bugs

[-- Attachment #1: Type: text/plain, Size: 968 bytes --]

On Fri, 18 Jun 2021 02:25:22 -0700
syzbot <syzbot+90d241d7661ca2493f0b@syzkaller.appspotmail.com> wrote:

> Hello,
> 
> syzbot found the following issue on:
> 
> HEAD commit:    37fdb7c9 Merge tag 'v5.13-rc6' into usb-next
> git tree:
> https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
> usb-testing console output:
> https://syzkaller.appspot.com/x/log.txt?x=1702bbebd00000 kernel
> config:  https://syzkaller.appspot.com/x/.config?x=e3b6ba4f6e6c6ddf
> dashboard link:
> https://syzkaller.appspot.com/bug?extid=90d241d7661ca2493f0b syz
> repro:
> https://syzkaller.appspot.com/x/repro.syz?x=113b98b8300000 C
> reproducer:   https://syzkaller.appspot.com/x/repro.c?x=134650f7d00000
> 
> IMPORTANT: if you fix the issue, please add the following tag to the
> commit: Reported-by:
> syzbot+90d241d7661ca2493f0b@syzkaller.appspotmail.com

 
#syz test
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master





With regards,
Pavel Skripkin

[-- Attachment #2: 0001-net-wireless-ath9k-fix-divide-error.patch --]
[-- Type: text/x-patch, Size: 1976 bytes --]

From d9a4de91e4752866c78019fbeadaa471543550a5 Mon Sep 17 00:00:00 2001
From: Pavel Skripkin <paskripkin@gmail.com>
Date: Fri, 18 Jun 2021 13:29:27 +0300
Subject: [PATCH] net: wireless: ath9k: fix divide error

/* ---- */

Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
 drivers/net/wireless/ath/ath9k/htc.h          | 1 +
 drivers/net/wireless/ath/ath9k/htc_drv_init.c | 2 ++
 drivers/net/wireless/ath/ath9k/wmi.c          | 6 ++++++
 3 files changed, 9 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/htc.h b/drivers/net/wireless/ath/ath9k/htc.h
index 0a1634238e67..1aaacdcda7ea 100644
--- a/drivers/net/wireless/ath/ath9k/htc.h
+++ b/drivers/net/wireless/ath/ath9k/htc.h
@@ -532,6 +532,7 @@ struct ath9k_htc_priv {
 #endif
 	struct mutex mutex;
 	struct ieee80211_vif *csa_vif;
+	atomic_t initialized;
 };
 
 static inline void ath_read_cachesize(struct ath_common *common, int *csz)
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
index ff61ae34ecdf..c3288bb07137 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
@@ -965,6 +965,8 @@ int ath9k_htc_probe_device(struct htc_target *htc_handle, struct device *dev,
 	if (ret)
 		goto err_init;
 
+	atomic_set(&priv->initialized, 1);
+
 	return 0;
 
 err_init:
diff --git a/drivers/net/wireless/ath/ath9k/wmi.c b/drivers/net/wireless/ath/ath9k/wmi.c
index fe29ad4b9023..a5f31ee86f04 100644
--- a/drivers/net/wireless/ath/ath9k/wmi.c
+++ b/drivers/net/wireless/ath/ath9k/wmi.c
@@ -146,6 +146,12 @@ void ath9k_wmi_event_tasklet(struct tasklet_struct *t)
 	unsigned long flags;
 	u16 cmd_id;
 
+	if (!atomic_read(&priv->initialized))
+		/* If tasked has been called with uninitalized ath9k_htc_priv,
+		 * it can cause divide-by-zero error in ath9k_htc_swba
+		 */
+		return;
+
 	do {
 		spin_lock_irqsave(&wmi->wmi_lock, flags);
 		skb = __skb_dequeue(&wmi->wmi_event_queue);
-- 
2.32.0


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

* Re: [syzbot] divide error in ath9k_htc_swba
  2021-06-18 10:31 ` Pavel Skripkin
@ 2021-06-18 10:49   ` syzbot
  0 siblings, 0 replies; 3+ messages in thread
From: syzbot @ 2021-06-18 10:49 UTC (permalink / raw)
  To: ath9k-devel, davem, kuba, kvalo, linux-kernel, linux-usb,
	linux-wireless, netdev, paskripkin, syzkaller-bugs

Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+90d241d7661ca2493f0b@syzkaller.appspotmail.com

Tested on:

commit:         fd0aa1a4 Merge tag 'for-linus' of git://git.kernel.org/pub..
git tree:       upstream
kernel config:  https://syzkaller.appspot.com/x/.config?x=5a4fe6d9e0a3e71f
dashboard link: https://syzkaller.appspot.com/bug?extid=90d241d7661ca2493f0b
compiler:       
patch:          https://syzkaller.appspot.com/x/patch.diff?x=14f9aff0300000

Note: testing is done by a robot and is best-effort only.

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

end of thread, other threads:[~2021-06-18 10:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18  9:25 [syzbot] divide error in ath9k_htc_swba syzbot
2021-06-18 10:31 ` Pavel Skripkin
2021-06-18 10:49   ` syzbot

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).