lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 26 Aug 2021 12:22:21 +0300
From:   Pavel Skripkin <paskripkin@...il.com>
To:     David Laight <David.Laight@...LAB.COM>
Cc:     "Larry.Finger@...inger.net" <Larry.Finger@...inger.net>,
        "phil@...lpotter.co.uk" <phil@...lpotter.co.uk>,
        "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
        "straube.linux@...il.com" <straube.linux@...il.com>,
        "fmdefrancesco@...il.com" <fmdefrancesco@...il.com>,
        "linux-staging@...ts.linux.dev" <linux-staging@...ts.linux.dev>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3 5/6] staging: r8188eu: add error handling of
 rtw_read32

On Thu, 26 Aug 2021 08:51:23 +0000
David Laight <David.Laight@...LAB.COM> wrote:

> From: Pavel Skripkin <paskripkin@...il.com>
> > Sent: 24 August 2021 08:28
> > 
> > _rtw_read32 function can fail in case of usb transfer failure. But
> > previous function prototype wasn't designed to return an error to
> > caller. It can cause a lot uninit value bugs all across the driver
> > code, since rtw_read32() returns local stack variable to caller.
> > 
> > Fix it by changing the prototype of this function. Now it returns an
> > int: 0 on success, negative error value on failure and callers
> > should pass the pointer to storage location for register value.
> 
> Pretty horrid API interface.
> Functions like readl() - which can fail just return ~0u and let
> the caller worry about whether that causes serious grief.
> 
> You could make all the read functions return __u64 and return ~0ull
> on error.
> Testing for (value & 1ull << 63) will be reasonable even on 32bit.
> 

I am not the best at API related questions, so can you, please,
explain why your approach is better? 

As I can see, most of the drivers in usb/ directory use smth like this
interface for private reading funcions. We anyway creating tmp variable
(but 64 bit _always_) and checking for mistery error, which we cannot
pass up to callers.

Sorry, if it's _too_ dumb question, but I really can't get your
point....



 

> ...
> > -static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr)
> > +static int usb_read32(struct intf_hdl *pintfhdl, u32 addr, u32
> > *data) {
> >  	u8 requesttype;
> >  	u16 wvalue;
> >  	u16 len;
> > -	__le32 data;
> > +	int res;
> > +	__le32 tmp;
> > +
> > +	if (WARN_ON(unlikely(!data)))
> > +		return -EINVAL;
> > 
> 
> Kill the NULL check - it is a silly coding error.
> An OOPS is just as easy to debug.
> 


I don't think that one single driver should kill the whole system. It's
100% an error, but kernel can recover from it (for example disconnect
the driver, since it's broken).


AFIAK, Greg and Linus do not like BUG_ONs in recoverable state...
Correct me, if I am wrong




With regards,
Pavel Skripkin


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ