All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Greg KH <greg@kroah.com>
Cc: Anant Thazhemadam <anant.thazhemadam@gmail.com>,
	petkan@nucleusys.com, davem@davemloft.net, kuba@kernel.org,
	linux-usb@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-kernel-mentees@lists.linuxfoundation.org,
	linux-next@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>
Subject: Re: [PATCH v2] net: usb: rtl8150: don't incorrectly assign random MAC addresses
Date: Mon, 12 Oct 2020 09:14:28 +1100	[thread overview]
Message-ID: <20201012091428.103fc2be@canb.auug.org.au> (raw)
In-Reply-To: <20201011173030.141582-1-anant.thazhemadam@gmail.com>

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

Hi Greg,

On Sun, 11 Oct 2020 23:00:30 +0530 Anant Thazhemadam <anant.thazhemadam@gmail.com> wrote:
>
> In set_ethernet_addr(), if get_registers() succeeds, the ethernet address
> that was read must be copied over. Otherwise, a random ethernet address
> must be assigned.
> 
> get_registers() returns 0 if successful, and negative error number
> otherwise. However, in set_ethernet_addr(), this return value is
> incorrectly checked.
> 
> Since this return value will never be equal to sizeof(node_id), a
> random MAC address will always be generated and assigned to the
> device; even in cases when get_registers() is successful.
> 
> Correctly modifying the condition that checks if get_registers() was
> successful or not fixes this problem, and copies the ethernet address
> appropriately.
> 
> Fixes: f45a4248ea4c ("net: usb: rtl8150: set random MAC address when set_ethernet_addr() fails")
> Signed-off-by: Anant Thazhemadam <anant.thazhemadam@gmail.com>
> ---
> Changes in v2:
>         * Fixed the format of the Fixes tag
>         * Modified the commit message to better describe the issue being 
>           fixed
> 
> +CCing Stephen and linux-next, since the commit fixed isn't in the networking
> tree, but is present in linux-next.
> 
>  drivers/net/usb/rtl8150.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
> index f020401adf04..bf8a60533f3e 100644
> --- a/drivers/net/usb/rtl8150.c
> +++ b/drivers/net/usb/rtl8150.c
> @@ -261,7 +261,7 @@ static void set_ethernet_addr(rtl8150_t *dev)
>  
>  	ret = get_registers(dev, IDR, sizeof(node_id), node_id);
>  
> -	if (ret == sizeof(node_id)) {
> +	if (!ret) {
>  		ether_addr_copy(dev->netdev->dev_addr, node_id);
>  	} else {
>  		eth_hw_addr_random(dev->netdev);
> -- 
> 2.25.1
> 

I will apply the above patch to the merge of the usb tree today to fix
up a semantic conflict between the usb tree and Linus' tree.

-- 
Cheers,
Stephen Rothwell

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Greg KH <greg@kroah.com>
Cc: Anant Thazhemadam <anant.thazhemadam@gmail.com>,
	petkan@nucleusys.com, netdev@vger.kernel.org,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-next@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
	linux-kernel-mentees@lists.linuxfoundation.org,
	davem@davemloft.net
Subject: Re: [Linux-kernel-mentees] [PATCH v2] net: usb: rtl8150: don't incorrectly assign random MAC addresses
Date: Mon, 12 Oct 2020 09:14:28 +1100	[thread overview]
Message-ID: <20201012091428.103fc2be@canb.auug.org.au> (raw)
In-Reply-To: <20201011173030.141582-1-anant.thazhemadam@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 2045 bytes --]

Hi Greg,

On Sun, 11 Oct 2020 23:00:30 +0530 Anant Thazhemadam <anant.thazhemadam@gmail.com> wrote:
>
> In set_ethernet_addr(), if get_registers() succeeds, the ethernet address
> that was read must be copied over. Otherwise, a random ethernet address
> must be assigned.
> 
> get_registers() returns 0 if successful, and negative error number
> otherwise. However, in set_ethernet_addr(), this return value is
> incorrectly checked.
> 
> Since this return value will never be equal to sizeof(node_id), a
> random MAC address will always be generated and assigned to the
> device; even in cases when get_registers() is successful.
> 
> Correctly modifying the condition that checks if get_registers() was
> successful or not fixes this problem, and copies the ethernet address
> appropriately.
> 
> Fixes: f45a4248ea4c ("net: usb: rtl8150: set random MAC address when set_ethernet_addr() fails")
> Signed-off-by: Anant Thazhemadam <anant.thazhemadam@gmail.com>
> ---
> Changes in v2:
>         * Fixed the format of the Fixes tag
>         * Modified the commit message to better describe the issue being 
>           fixed
> 
> +CCing Stephen and linux-next, since the commit fixed isn't in the networking
> tree, but is present in linux-next.
> 
>  drivers/net/usb/rtl8150.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
> index f020401adf04..bf8a60533f3e 100644
> --- a/drivers/net/usb/rtl8150.c
> +++ b/drivers/net/usb/rtl8150.c
> @@ -261,7 +261,7 @@ static void set_ethernet_addr(rtl8150_t *dev)
>  
>  	ret = get_registers(dev, IDR, sizeof(node_id), node_id);
>  
> -	if (ret == sizeof(node_id)) {
> +	if (!ret) {
>  		ether_addr_copy(dev->netdev->dev_addr, node_id);
>  	} else {
>  		eth_hw_addr_random(dev->netdev);
> -- 
> 2.25.1
> 

I will apply the above patch to the merge of the usb tree today to fix
up a semantic conflict between the usb tree and Linus' tree.

-- 
Cheers,
Stephen Rothwell

[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

  parent reply	other threads:[~2020-10-11 22:14 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-10  6:44 [PATCH] net: usb: rtl8150: don't incorrectly assign random MAC addresses Anant Thazhemadam
2020-10-10  6:44 ` [Linux-kernel-mentees] " Anant Thazhemadam
2020-10-10 16:59 ` Jakub Kicinski
2020-10-10 16:59   ` [Linux-kernel-mentees] " Jakub Kicinski
2020-10-10 18:04   ` Anant Thazhemadam
2020-10-10 18:04     ` [Linux-kernel-mentees] " Anant Thazhemadam
2020-10-10 18:16     ` Jakub Kicinski
2020-10-10 18:16       ` [Linux-kernel-mentees] " Jakub Kicinski
2020-10-10 18:44       ` Anant Thazhemadam
2020-10-10 18:44         ` [Linux-kernel-mentees] " Anant Thazhemadam
2020-10-10 19:20         ` Jakub Kicinski
2020-10-10 19:20           ` [Linux-kernel-mentees] " Jakub Kicinski
2020-10-11 17:30 ` [PATCH v2] " Anant Thazhemadam
2020-10-11 17:30   ` [Linux-kernel-mentees] " Anant Thazhemadam
2020-10-11 17:59   ` Jakub Kicinski
2020-10-11 17:59     ` [Linux-kernel-mentees] " Jakub Kicinski
2020-10-11 18:33     ` Joe Perches
2020-10-11 18:33       ` [Linux-kernel-mentees] " Joe Perches
2020-10-11 19:31       ` Petko Manolov
2020-10-11 19:31         ` [Linux-kernel-mentees] " Petko Manolov
2020-10-11 20:14         ` Joe Perches
2020-10-11 20:14           ` [Linux-kernel-mentees] " Joe Perches
2020-10-11 22:14   ` Stephen Rothwell [this message]
2020-10-11 22:14     ` Stephen Rothwell
2020-10-15 21:59     ` Stephen Rothwell
2020-10-15 21:59       ` [Linux-kernel-mentees] " Stephen Rothwell
2020-10-15 22:24       ` Jakub Kicinski
2020-10-15 22:24         ` [Linux-kernel-mentees] " Jakub Kicinski
2020-10-15 22:37         ` Jakub Kicinski
2020-10-15 22:37           ` [Linux-kernel-mentees] " Jakub Kicinski
2020-10-18 19:54           ` Jakub Kicinski
2020-10-18 19:54             ` [Linux-kernel-mentees] " Jakub Kicinski

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=20201012091428.103fc2be@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=anant.thazhemadam@gmail.com \
    --cc=davem@davemloft.net \
    --cc=greg@kroah.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=petkan@nucleusys.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.