From: Anant Thazhemadam <anant.thazhemadam@gmail.com>
To: Joe Perches <joe@perches.com>
Cc: linux-kernel-mentees@lists.linuxfoundation.org,
syzbot+abbc768b560c84d92fd3@syzkaller.appspotmail.com,
Petko Manolov <petkan@nucleusys.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
linux-usb@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] net: usb: rtl8150: prevent set_ethernet_addr from setting uninit address
Date: Sun, 4 Oct 2020 02:28:14 +0530 [thread overview]
Message-ID: <81a5d8b6-5258-1f2e-15da-4324579799df@gmail.com> (raw)
In-Reply-To: <dbe67fce55c6bbe569cefdc1a01708a0d01b140a.camel@perches.com>
On 04/10/20 1:08 am, Joe Perches wrote:
> On Thu, 2020-10-01 at 13:02 +0530, Anant Thazhemadam wrote:
>> When get_registers() fails (which happens when usb_control_msg() fails)
>> in set_ethernet_addr(), the uninitialized value of node_id gets copied
>> as the address.
> unrelated trivia:
>
>> diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
> []
>> @@ -274,12 +274,17 @@ static int write_mii_word(rtl8150_t * dev, u8 phy, __u8 indx, u16 reg)
>> return 1;
>> }
>>
>> -static inline void set_ethernet_addr(rtl8150_t * dev)
>> +static bool set_ethernet_addr(rtl8150_t *dev)
>> {
>> u8 node_id[6];
> This might be better as:
>
> u8 node_id[ETH_ALEN];
>
>> + int ret;
>>
>> - get_registers(dev, IDR, sizeof(node_id), node_id);
>> - memcpy(dev->netdev->dev_addr, node_id, sizeof(node_id));
>> + ret = get_registers(dev, IDR, sizeof(node_id), node_id);
>> + if (ret == sizeof(node_id)) {
>> + memcpy(dev->netdev->dev_addr, node_id, sizeof(node_id));
> and
> ether_addr_copy(dev->netdev->dev_addr, node_id);
>
>
I will include this change as well, in the v3.
Thank you for pointing that out.
Thanks,
Anant
prev parent reply other threads:[~2020-10-03 20:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-01 7:32 [Linux-kernel-mentees][PATCH v2] net: usb: rtl8150: prevent set_ethernet_addr from setting uninit address Anant Thazhemadam
2020-10-02 2:15 ` David Miller
2020-10-02 11:34 ` [PATCH " Anant Thazhemadam
2020-10-02 11:54 ` Greg KH
2020-10-02 12:05 ` Anant Thazhemadam
2020-10-02 14:29 ` Petko Manolov
2020-10-03 5:51 ` Anant Thazhemadam
2020-10-02 22:38 ` David Miller
2020-10-03 5:54 ` Anant Thazhemadam
2020-10-03 19:38 ` [Linux-kernel-mentees][PATCH " Joe Perches
2020-10-03 20:58 ` Anant Thazhemadam [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=81a5d8b6-5258-1f2e-15da-4324579799df@gmail.com \
--to=anant.thazhemadam@gmail.com \
--cc=davem@davemloft.net \
--cc=joe@perches.com \
--cc=kuba@kernel.org \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=petkan@nucleusys.com \
--cc=syzbot+abbc768b560c84d92fd3@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox