1
0
Fork 0
alistair23-linux/drivers/usb
Quentin Perret 264ae08bb7 ehci-hcd: Move include to keep CRC stable
commit 29231826f3 upstream.

The CRC calculation done by genksyms is triggered when the parser hits
EXPORT_SYMBOL*() macros. At this point, genksyms recursively expands the
types of the function parameters, and uses that as the input for the CRC
calculation. In the case of forward-declared structs, the type expands
to 'UNKNOWN'. Following this, it appears that the result of the
expansion of each type is cached somewhere, and seems to be re-used
when/if the same type is seen again for another exported symbol in the
same C file.

Unfortunately, this can cause CRC 'stability' issues when a struct
definition becomes visible in the middle of a C file. For example, let's
assume code with the following pattern:

    struct foo;

    int bar(struct foo *arg)
    {
	/* Do work ... */
    }
    EXPORT_SYMBOL_GPL(bar);

    /* This contains struct foo's definition */
    #include "foo.h"

    int baz(struct foo *arg)
    {
	/* Do more work ... */
    }
    EXPORT_SYMBOL_GPL(baz);

Here, baz's CRC will be computed using the expansion of struct foo that
was cached after bar's CRC calculation ('UNKOWN' here). But if
EXPORT_SYMBOL_GPL(bar) is removed from the file (because of e.g. symbol
trimming using CONFIG_TRIM_UNUSED_KSYMS), struct foo will be expanded
late, during baz's CRC calculation, which now has visibility over the
full struct definition, hence resulting in a different CRC for baz.

The proper fix for this certainly is in genksyms, but that will take me
some time to get right. In the meantime, we have seen one occurrence of
this in the ehci-hcd code which hits this problem because of the way it
includes C files halfway through the code together with an unlucky mix
of symbol trimming.

In order to workaround this, move the include done in ehci-hub.c early
in ehci-hcd.c, hence making sure the struct definitions are visible to
the entire file. This improves CRC stability of the ehci-hcd exports
even when symbol trimming is enabled.

Acked-by: Alan Stern <stern@rowland.harvard.edu>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Quentin Perret <qperret@google.com>
Link: https://lore.kernel.org/r/20200916171825.3228122-1-qperret@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-09-23 12:40:46 +02:00
..
atm USB: atm: ueagle-atm: add missing endpoint check 2019-12-17 19:55:44 +01:00
c67x00 USB: c67x00: fix use after free in c67x00_giveback_urb 2020-07-22 09:33:09 +02:00
cdns3 usb: cdns3: gadget: always zeroed TRB buffer when enable endpoint 2020-09-03 11:26:49 +02:00
chipidea usb: chipidea: core: add wakeup support for extcon 2020-07-22 09:33:10 +02:00
class usblp: fix race between disconnect() and read() 2020-09-23 12:40:44 +02:00
common usb: common: usb-conn-gpio: Don't log an error on probe deferral 2019-12-17 19:55:39 +01:00
core USB: quirks: Add USB_QUIRK_IGNORE_REMOTE_WAKEUP quirk for BYD zhaoxin notebook 2020-09-23 12:40:43 +02:00
dwc2 usb: dwc2: Fix error path in gadget registration 2020-08-19 08:16:15 +02:00
dwc3 usb: dwc3: gadget: Handle ZLP for sg requests 2020-09-03 11:27:09 +02:00
early USB: early: Handle AMD's spec-compliant identifiers, too 2020-04-29 16:33:13 +02:00
gadget USB: gadget: u_f: Unbreak offset calculation in VLAs 2020-09-03 11:27:08 +02:00
host ehci-hcd: Move include to keep CRC stable 2020-09-23 12:40:46 +02:00
image USB: microtek: fix info-leak at probe 2019-10-04 11:02:58 +02:00
isp1760 usb: add a HCD_DMA flag instead of guestimating DMA capabilities 2019-08-21 10:03:35 -07:00
misc USB: yurex: Fix bad gfp argument 2020-09-03 11:27:07 +02:00
mon usb: mon: Fix a deadlock in usbmon between mmap and read 2019-12-17 19:55:49 +01:00
mtu3 usb: mtu3: clear dual mode of u3port when disable device 2020-08-19 08:16:02 +02:00
musb usb: musb: Fix runtime PM imbalance on error 2020-06-10 20:24:56 +02:00
phy usb: phy: twl6030-usb: Fix a resource leak in an error handling path in 'twl6030_usb_probe()' 2020-06-03 08:21:12 +02:00
renesas_usbhs usb: renesas_usbhs: getting residue from callback_result 2020-06-30 15:37:00 -04:00
roles usb: roles: fix a potential use after free 2019-12-17 19:55:46 +01:00
serial USB: serial: option: add support for SIM7070/SIM7080/SIM7090 modules 2020-09-17 13:47:56 +02:00
storage USB: UAS: fix disconnect by unplugging a hub 2020-09-23 12:40:43 +02:00
typec usb: typec: ucsi: Prevent mode overrun 2020-09-23 12:40:44 +02:00
usbip usbip: Fix error path of vhci_recv_ret_submit() 2019-12-31 16:46:05 +01:00
Kconfig usb: common: create Kconfig file 2019-09-03 19:00:39 +02:00
Makefile USB: Changes for v5.4 merge window 2019-09-02 19:20:57 +02:00
usb-skeleton.c USB: usb-skeleton: drop redundant in-urb check 2019-10-10 12:41:19 +02:00