Re: [syzbot] KMSAN: uninit-value in asix_mdio_read (2)

From: Pavel Skripkin
Date: Sat Dec 18 2021 - 16:14:51 EST


On 12/18/21 14:07, syzbot wrote:
Hello,

syzbot found the following issue on:

HEAD commit: b0a8b5053e8b kmsan: core: add dependency on DEBUG_KERNEL
git tree: https://github.com/google/kmsan.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=13a4d133b00000
kernel config: https://syzkaller.appspot.com/x/.config?x=46a956fc7a887c60
dashboard link: https://syzkaller.appspot.com/bug?extid=f44badb06036334e867a
compiler: clang version 14.0.0 (/usr/local/google/src/llvm-git-monorepo 2b554920f11c8b763cd9ed9003f4e19b919b8e1f), GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=149fddcbb00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17baef25b00000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+f44badb06036334e867a@xxxxxxxxxxxxxxxxxxxxxxxxx


The last unhanded case is asix_read_cmd() == 0. Let's handle it...

#syz test: https://github.com/google/kmsan.git master



With regards,
Pavel Skripkin

diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
index 42ba4af68090..fb4f6ce9466a 100644
--- a/drivers/net/usb/asix_common.c
+++ b/drivers/net/usb/asix_common.c
@@ -77,7 +77,7 @@ static int asix_check_host_enable(struct usbnet *dev, int in_pm)
0, 0, 1, &smsr, in_pm);
if (ret == -ENODEV)
break;
- else if (ret < 0)
+ else if (ret <= 0)
continue;
else if (smsr & AX_HOST_EN)
break;