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]
Message-ID: <ab20fcd7-69a8-0530-7770-0e309178b0f0@gmail.com>
Date:   Wed, 25 Aug 2021 11:22:16 +0300
From:   Pavel Skripkin <paskripkin@...il.com>
To:     "Fabio M. De Francesco" <fmdefrancesco@...il.com>,
        Larry.Finger@...inger.net, phil@...lpotter.co.uk,
        gregkh@...uxfoundation.org, straube.linux@...il.com
Cc:     linux-staging@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 4/6] staging: r8188eu: add error handling of rtw_read16

On 8/25/21 7:35 AM, Fabio M. De Francesco wrote:
> On Tuesday, August 24, 2021 9:27:35 AM CEST Pavel Skripkin wrote:
>> _rtw_read16 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_read16() 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.
>> 
>> Signed-off-by: Pavel Skripkin <paskripkin@...il.com>
>> 
>> [...]
>>
>> -static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr)
>> +static int usb_read16(struct intf_hdl *pintfhdl, u32 addr, u16 *data)
>>  {
>>  	u8 requesttype;
>>  	u16 wvalue;
>>  	u16 len;
>> -	__le32 data;
>> +	int res;
>> +	__le32 tmp;
>> +
>> +	if (WARN_ON(unlikely(!data)))
>> +		return -EINVAL;
>>  
>>  	requesttype = 0x01;/* read_in */
>>  	wvalue = (u16)(addr & 0x0000ffff);
>>  	len = 2;
>> -	usbctrl_vendorreq(pintfhdl, wvalue, &data, len, requesttype);
>> +	res = usbctrl_vendorreq(pintfhdl, wvalue, &tmp, len, requesttype);
>> +	if (res < 0) {
>> +		dev_err(dvobj_to_dev(pintfhdl->pintf_dev), "Failed to read 16 bytes: %d\n", res);
>> +		return res;
>> +	} else if (res != len) {
> 
> Dear Pavel,
> 
> Please note that if and when my patch "Use usb_control_msg_recv / send () in
> usbctrl_vendorreq ()" will be merged, "if (res! = len)" will always evaluate 'true'
> and usb_read16 () will always return -EIO even if usbctrl_vendorreq () succeeds.
> 

Yep, thank you, but it depends on which series will go in first :)

There is a chance, that you will need to clean up this part, if mine 
will be merged before yours



With regards,
Pavel Skripkin

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ