netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Skripkin <paskripkin@gmail.com>
To: David Kahurani <k.kahurani@gmail.com>, netdev@vger.kernel.org
Cc: syzbot+d3dbdf31fbe9d8f5f311@syzkaller.appspotmail.com,
	davem@davemloft.net, jgg@ziepe.ca, kuba@kernel.org,
	linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	phil@philpotter.co.uk, syzkaller-bugs@googlegroups.com,
	arnd@arndb.de, dan.carpenter@oracle.com
Subject: Re: [PATCH] net: ax88179: add proper error handling of usb read errors
Date: Sat, 14 May 2022 19:51:12 +0300	[thread overview]
Message-ID: <ebf3adc8-3e33-7ef3-e74d-29a32640972f@gmail.com> (raw)
In-Reply-To: <20220514133234.33796-1-k.kahurani@gmail.com>


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

Hi David,

On 5/14/22 16:32, David Kahurani wrote:
> Reads that are lesser than the requested size lead to uninit-value bugs.
> In this particular case a variable which was supposed to be initialized
> after a read is left uninitialized after a partial read.
> 
> Qualify such reads as errors and handle them correctly and while at it
> convert the reader functions to return zero on success for easier error
> handling.
> 
> Fixes: e2ca90c276e1 ("ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver")
> Signed-off-by: David Kahurani <k.kahurani@gmail.com>
> Reported-and-tested-by: syzbot+d3dbdf31fbe9d8f5f311@syzkaller.appspotmail.com
> ---

<--- here (*)

>   drivers/net/usb/ax88179_178a.c | 281 ++++++++++++++++++++++++++-------
>   1 file changed, 227 insertions(+), 54 deletions(-)
> 

I don't see any error in that patch, but I had to find previous versions 
of that patch in my inbox.

Usually new versions of single patches are linked in one thread and have 
a version number in a title. You can generate patch with version using 
-v option of git format-patch like:

$ git format-patch -v2 HEAD~

And you can send new version as reply using --in-reply= option of git 
send-email. It helps a lot with finding previous version, since all 
version are linked in one thread

And all updates from version to version should be put under --- (*), 
since it's hard to remember why previous version was rejected.


>  		jtimeout = jiffies + delay;
>  		do {
> -			ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD,
> -					 1, 1, &buf);
> +			ret = ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD,
> +					       1, 1, &buf);
> +			if (ret) {
> +				netdev_dbg(dev->net,
> +					   "Failed to read SROM_CMD: %d\n",
> +					   ret);
> +				return ret;
> +			}
>  
>  			if (time_after(jiffies, jtimeout))
>  				return -EINVAL;
>  
>  		} while (buf & EEP_BUSY);

I think, this change might be dangerous. Maybe it should be done in the 
same way as in asix driver [1]. Code polls for some register after a 
write and maybe non-fatal read error might occur here.

Just my thoughts, I don't know anything about that device :)


> +		ret = ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN,
> +				       ETH_ALEN, mac);
> +
> +		if (ret)
> +			netdev_dbg(dev->net, "Failed to read NODE_ID: %d", ret);
> +		else
> +			netif_dbg(dev, ifup, dev->net,
> +				  "MAC address read from ASIX chip");

Maybe also use `netif_dbg` here?... There should be a reason why it was 
used here in the first place. Or should not :)

Anyway, if someone will say that bailing out from while loop on any 
error is OK feel free to add

Reviewed-by: Pavel Skripkin <paskripkin@gmail.com>



[1] 
https://elixir.bootlin.com/linux/latest/source/drivers/net/usb/asix_common.c#L78


With regards,
Pavel Skripkin

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

  reply	other threads:[~2022-05-14 16:51 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-14 13:32 [PATCH] net: ax88179: add proper error handling of usb read errors David Kahurani
2022-05-14 16:51 ` Pavel Skripkin [this message]
2022-05-14 18:54   ` Dan Carpenter
2022-05-14 18:57     ` Pavel Skripkin
2022-05-16 19:31 ` Jakub Kicinski
  -- strict thread matches above, loose matches on Subject: below --
2022-04-16  7:48 David Kahurani
2022-04-16 11:05 ` Pavel Skripkin
2022-04-16 11:10 ` Pavel Skripkin
2022-04-16 11:49   ` David Kahurani
2022-04-16 11:53     ` Pavel Skripkin
2022-04-16 11:57       ` Pavel Skripkin
2022-04-19 13:41 ` Paolo Abeni
2022-04-04 15:10 David Kahurani
2022-04-04 15:31 ` Dan Carpenter
2022-04-13 12:36   ` David Kahurani
2022-04-13 15:32     ` Dan Carpenter
2022-04-14  7:31       ` Oliver Neukum
2022-04-14  8:21         ` Dan Carpenter
2022-04-14  9:13           ` Oliver Neukum
2022-04-04 16:50 ` Pavel Skripkin
2022-04-11 15:11   ` Andy Shevchenko
2022-04-05  9:44 ` Paolo Abeni
2022-04-05 20:44 ` kernel test robot

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=ebf3adc8-3e33-7ef3-e74d-29a32640972f@gmail.com \
    --to=paskripkin@gmail.com \
    --cc=arnd@arndb.de \
    --cc=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --cc=jgg@ziepe.ca \
    --cc=k.kahurani@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=phil@philpotter.co.uk \
    --cc=syzbot+d3dbdf31fbe9d8f5f311@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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;
as well as URLs for NNTP newsgroup(s).