* [Linux-kernel-mentees] [PATCH] usb: asix: Fix uninit-value in asix_mdio_write
[not found] <0000000000009763320594f993ee@google.com>
@ 2019-11-07 0:44 ` Phong Tran
2019-11-07 23:21 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Phong Tran @ 2019-11-07 0:44 UTC (permalink / raw)
To: syzbot+7dc7c28d4577bbe55b10, davem, gregkh
Cc: kstewart, netdev, linux-usb, hslester96, linux-kernel,
syzkaller-bugs, glider, tglx, linux-kernel-mentees
The local variables use without initilization value.
This fixes the syzbot report.
Reported-by: syzbot+7dc7c28d4577bbe55b10@syzkaller.appspotmail.com
Test result:
https://groups.google.com/d/msg/syzkaller-bugs/3H_n05x_sPU/sUoHhxgAAgAJ
Signed-off-by: Phong Tran <tranmanphong@gmail.com>
---
drivers/net/usb/asix_common.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
index e39f41efda3e..3c7ccd8a9da8 100644
--- a/drivers/net/usb/asix_common.c
+++ b/drivers/net/usb/asix_common.c
@@ -444,8 +444,8 @@ void asix_set_multicast(struct net_device *net)
int asix_mdio_read(struct net_device *netdev, int phy_id, int loc)
{
struct usbnet *dev = netdev_priv(netdev);
- __le16 res;
- u8 smsr;
+ __le16 res = 0;
+ u8 smsr = 0;
int i = 0;
int ret;
@@ -478,7 +478,7 @@ void asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val)
{
struct usbnet *dev = netdev_priv(netdev);
__le16 res = cpu_to_le16(val);
- u8 smsr;
+ u8 smsr = 0;
int i = 0;
int ret;
@@ -508,8 +508,8 @@ void asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val)
int asix_mdio_read_nopm(struct net_device *netdev, int phy_id, int loc)
{
struct usbnet *dev = netdev_priv(netdev);
- __le16 res;
- u8 smsr;
+ __le16 res = 0;
+ u8 smsr = 0;
int i = 0;
int ret;
@@ -543,7 +543,7 @@ asix_mdio_write_nopm(struct net_device *netdev, int phy_id, int loc, int val)
{
struct usbnet *dev = netdev_priv(netdev);
__le16 res = cpu_to_le16(val);
- u8 smsr;
+ u8 smsr = 0;
int i = 0;
int ret;
--
2.20.1
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Linux-kernel-mentees] [PATCH] usb: asix: Fix uninit-value in asix_mdio_write
2019-11-07 0:44 ` [Linux-kernel-mentees] [PATCH] usb: asix: Fix uninit-value in asix_mdio_write Phong Tran
@ 2019-11-07 23:21 ` David Miller
2019-11-10 14:07 ` [Linux-kernel-mentees] [[Patch V2]] usb: asix: cleanup the buffer in asix_read_cmd Phong Tran
2019-11-10 14:11 ` [Linux-kernel-mentees] [PATCH] usb: asix: Fix uninit-value in asix_mdio_write Phong Tran
0 siblings, 2 replies; 4+ messages in thread
From: David Miller @ 2019-11-07 23:21 UTC (permalink / raw)
To: tranmanphong
Cc: kstewart, linux-usb, hslester96, linux-kernel,
syzbot+7dc7c28d4577bbe55b10, syzkaller-bugs, glider, netdev,
tglx, linux-kernel-mentees
From: Phong Tran <tranmanphong@gmail.com>
Date: Thu, 7 Nov 2019 07:44:04 +0700
> The local variables use without initilization value.
> This fixes the syzbot report.
>
> Reported-by: syzbot+7dc7c28d4577bbe55b10@syzkaller.appspotmail.com
>
> Test result:
>
> https://groups.google.com/d/msg/syzkaller-bugs/3H_n05x_sPU/sUoHhxgAAgAJ
>
> Signed-off-by: Phong Tran <tranmanphong@gmail.com>
There are several more situations in this file where the data blob passed
to asix_read_cmd() is read without pre-initialization not checking the
return value from asix_read_cmd().
So, syzbot can see some of them but not all of them, yet all of them
are buggy and should be fixed.
These kinds of patches drive me absolutely crazy :-)
Really, one of two things needs to happen, either asix_read_cmd() clears
the incoming buffer unconditionally, or these call sites strictly must
check the return value always before accessing the buffer after the call.
I'm not applying this, sorry.
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Linux-kernel-mentees] [[Patch V2]] usb: asix: cleanup the buffer in asix_read_cmd
2019-11-07 23:21 ` David Miller
@ 2019-11-10 14:07 ` Phong Tran
2019-11-10 14:11 ` [Linux-kernel-mentees] [PATCH] usb: asix: Fix uninit-value in asix_mdio_write Phong Tran
1 sibling, 0 replies; 4+ messages in thread
From: Phong Tran @ 2019-11-10 14:07 UTC (permalink / raw)
To: davem
Cc: kstewart, linux-usb, hslester96, linux-kernel,
syzbot+7dc7c28d4577bbe55b10, syzkaller-bugs, glider, netdev,
tglx, linux-kernel-mentees
This is for fixing KMSAN: uninit-value in asix_mdio_write
comes from syzbot.
Reported-by: syzbot+7dc7c28d4577bbe55b10@syzkaller.appspotmail.com
Tested by:
https://groups.google.com/d/msg/syzkaller-bugs/3H_n05x_sPU/07UIX_TUEgAJ
Signed-off-by: Phong Tran <tranmanphong@gmail.com>
---
drivers/net/usb/asix_common.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
index e39f41efda3e..f3eeb7875a4d 100644
--- a/drivers/net/usb/asix_common.c
+++ b/drivers/net/usb/asix_common.c
@@ -22,6 +22,8 @@ int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
else
fn = usbnet_read_cmd_nopm;
+ memset(data, 0, size);
+
ret = fn(dev, cmd, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
value, index, data, size);
--
2.20.1
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Linux-kernel-mentees] [PATCH] usb: asix: Fix uninit-value in asix_mdio_write
2019-11-07 23:21 ` David Miller
2019-11-10 14:07 ` [Linux-kernel-mentees] [[Patch V2]] usb: asix: cleanup the buffer in asix_read_cmd Phong Tran
@ 2019-11-10 14:11 ` Phong Tran
1 sibling, 0 replies; 4+ messages in thread
From: Phong Tran @ 2019-11-10 14:11 UTC (permalink / raw)
To: David Miller
Cc: kstewart, linux-usb, hslester96, linux-kernel,
syzbot+7dc7c28d4577bbe55b10, syzkaller-bugs, glider, netdev,
tglx, linux-kernel-mentees
On 11/8/19 6:21 AM, David Miller wrote:
> From: Phong Tran <tranmanphong@gmail.com>
> Date: Thu, 7 Nov 2019 07:44:04 +0700
>
>> The local variables use without initilization value.
>> This fixes the syzbot report.
>>
>> Reported-by: syzbot+7dc7c28d4577bbe55b10@syzkaller.appspotmail.com
>>
>> Test result:
>>
>> https://groups.google.com/d/msg/syzkaller-bugs/3H_n05x_sPU/sUoHhxgAAgAJ
>>
>> Signed-off-by: Phong Tran <tranmanphong@gmail.com>
>
> There are several more situations in this file where the data blob passed
> to asix_read_cmd() is read without pre-initialization not checking the
> return value from asix_read_cmd().
>
> So, syzbot can see some of them but not all of them, yet all of them
> are buggy and should be fixed.
>
> These kinds of patches drive me absolutely crazy :-)
>
> Really, one of two things needs to happen, either asix_read_cmd() clears
> the incoming buffer unconditionally,
thank you for your suggestion.
Sent Patch v2 reply-to this mail thread.
regards,
Phong.
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-11-10 14:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <0000000000009763320594f993ee@google.com>
2019-11-07 0:44 ` [Linux-kernel-mentees] [PATCH] usb: asix: Fix uninit-value in asix_mdio_write Phong Tran
2019-11-07 23:21 ` David Miller
2019-11-10 14:07 ` [Linux-kernel-mentees] [[Patch V2]] usb: asix: cleanup the buffer in asix_read_cmd Phong Tran
2019-11-10 14:11 ` [Linux-kernel-mentees] [PATCH] usb: asix: Fix uninit-value in asix_mdio_write Phong Tran
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).