patch "staging: rtl8712: error handling refactoring" added to staging-linus
Subsystems (2)
This is a note to let you know that I've just added the patch titled
staging: rtl8712: error handling refactoring
to my staging git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
in the staging-linus branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.
If you have any questions about this process, please let me know.
From e9e6aa51b2735d83a67d9fa0119cf11abef80d99 Mon Sep 17 00:00:00 2001
From: Pavel Skripkin <[email protected]>
Date: Wed, 21 Jul 2021 22:34:47 +0300
Subject: staging: rtl8712: error handling refactoring
There was strange error handling logic in case of fw load failure. For some reason fw loader callback was doing clean up stuff when fw is not available. I don't see any reason behind doing this. Since this driver doesn't have EEPROM firmware let's just disconnect it in case of fw load failure. Doing clean up stuff in 2 different place which can run concurently is not good idea and syzbot found 2 bugs related to this strange approach.
So, in this pacth I deleted all clean up code from fw callback and made a call to device_release_driver() under device_lock(parent) in case of fw load failure. This approach is more generic and it defend driver from UAF bugs, since all clean up code is moved to one place.
--- drivers/staging/rtl8712/hal_init.c | 30 +++++++++++------ drivers/staging/rtl8712/usb_intf.c | 52 +++++++++++++----------------- 2 files changed, 43 insertions(+), 39 deletions(-)
drivers/staging/rtl8712/hal_init.c +20 -10
@@ -29,21 +29,31 @@#define FWBUFF_ALIGN_SZ 512#define MAX_DUMP_FWSZ (48 * 1024) +static void rtl871x_load_fw_fail (struct _adapter *adapter) +{ +struct usb_device *udev = adapter->dvobjpriv.pusbdev; +struct device *dev = &udev->dev; +struct device *parent = dev->parent; + +complete (&adapter->rtl8712_fw_ready); + +dev_err (&udev->dev,"r8712u: Firmware request failed\n" ); + +if (parent) +device_lock (parent); + +device_release_driver (dev); + +if (parent) +device_unlock (parent); +} +static void rtl871x_load_fw_cb (const struct firmware *firmware,void *context) {struct _adapter *adapter = context;if (!firmware) { -struct usb_device *udev = adapter->dvobjpriv.pusbdev; -struct usb_interface *usb_intf = adapter->pusb_intf; - -dev_err (&udev->dev,"r8712u: Firmware request failed\n" ); -usb_put_dev (udev); -usb_set_intfdata (usb_intf,NULL ); -r8712_free_drv_sw (adapter); - adapter->dvobj_deinit (adapter); -complete (&adapter->rtl8712_fw_ready); -free_netdev (adapter->pnetdev); +rtl871x_load_fw_fail (adapter);return ; } adapter->fw = firmware;
drivers/staging/rtl8712/usb_intf.c +23 -29
59 lines not on this page · raw message
Signature · 1 line
2.32.0