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, 19 May 2022 18:27:17 +0300
From:   Dmytro Bagrii <dimich.dmb@...il.com>
To:     Greg KH <gregkh@...uxfoundation.org>,
        Alan Stern <stern@...land.harvard.edu>,
        Oliver Neukum <oneukum@...e.com>
Cc:     linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] usb: core: Call disconnect() only if it is provided by
 driver

On 19.05.22 16:45, Greg KH wrote:
> On Thu, May 19, 2022 at 04:29:00PM +0300, Dmytro Bagrii wrote:
>> A driver may use devres allocations. Disconnect handler is not needed in
>> this case. Allow such driver to leave .disconnect field uninitialized in
>> struct usb_driver instead of providing empty stub function.
>>
>> Signed-off-by: Dmytro Bagrii <dimich.dmb@...il.com>
>> ---
>>  drivers/usb/core/driver.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
>> index 355ed33a2179..d7fe440b033c 100644
>> --- a/drivers/usb/core/driver.c
>> +++ b/drivers/usb/core/driver.c
>> @@ -455,7 +455,8 @@ static int usb_unbind_interface(struct device *dev)
>>  	if (!driver->soft_unbind || udev->state == USB_STATE_NOTATTACHED)
>>  		usb_disable_interface(udev, intf, false);
>>  
>> -	driver->disconnect(intf);
>> +	if (driver->disconnect)
>> +		driver->disconnect(intf);
>>  
>>  	/* Free streams */
>>  	for (i = 0, j = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
>> -- 
>> 2.36.1
>>
> 
> What in-kernel driver has this issue and does not have a disconnect
> callback?

I don't see such in-kernel USB drivers yet. I develop an out-of-tree driver
and use devres for all initialization including controllers registration
etc. For actions which aren't available with devm_*, e.g. URB allocation i
use devm_add_action_or_reset() for deinit. I realized my _disconnect()
function is empty, nothing to do there. All deinitialization is done during
usb interface release. If i leave .disconnect field uninitialized in struct
usb_driver, obviously i get NULL pointer dereference bug. Thus i decided
that allowing a driver not to provide disconnect() is a good idea, as it is
done for remove() in SPI and I2C subsystems.

-- 
Best Regards,
Dmytro Bagrii.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ