5.10.273-rc1 review
Subsystems (6)
Greg Kroah-Hartman
maintainerPATCH 123/516 pinctrl: sunxi: keep a shadow copy of the data register output latches
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Titov <[email protected]>
[ Upstream commit a13f7f5d14af9baf34eb12c25962f8d3542b281d ]
On Allwinner SoCs, reading a bank's data register returns the pin level, not the output latch, for pins that are muxed as inputs. Writing a GPIO therefore corrupts the output latches of all input-muxed pins in the same bank: the read-modify-write in sunxi_pinctrl_gpio_set() reads back their pin levels and writes those into their latches.
This breaks emulated open-drain lines (e.g. a bit-banged I2C bus from i2c-gpio). Such a line is released high by muxing it as input and letting the pull-up raise it, so any concurrent GPIO write in the same bank stores 1 into its latch. Driving the line low afterwards is a non-atomic data-then-mux sequence in sunxi_pinctrl_gpio_direction_output(); if the poisoning write lands between the two steps, the pin actively drives high (push-pull) instead of low.
Observed in practice as sporadic glitches on a T507 board bit-banging I2C on port E while other PE GPIOs are toggled. On a scope the failure is unmistakable: on a clock pulse where SCL should fall to GND, the line instead steps *above* its idle high level for the whole low phase — the pad drives a strong push-pull 3.3 V high, higher than the level the pull-up sustains on the loaded bus — before the next transition recovers it. The same can hit SDA, corrupting data instead of clocks.
Steps to reproduce on any sunxi board with a bit-banged (i2c-gpio) bus:
# background: toggle any other GPIO of the same bank, e.g. line 21 gpioset -c <chip> --toggle 100us 21=0 &
# foreground: keep the bit-banged bus busy
while :; do i2cdetect -y <bus> 0x50 0x57; done
# watch SCL/SDA with a scope or logic analyzer: sporadic clock-low # phases driven high (above the pull-up level) instead of low
The bank spinlock cannot help: the racing write is a perfectly valid whole-register RMW that faithfully writes back what the hardware returned. There are no set/clear registers on this IP to write a single bit atomically.
Fix it the same way gpio-mmio handles hardware whose data register read does not return the output latch: keep a shadow copy of each bank's latches, base the read-modify-write on the shadow, and only write the register. The shadow is seeded from the hardware at probe time so pins left in output mode by the bootloader keep their state. Pins that reach output mode through the gpiolib paths write their value (and thereby their shadow bit) before the mux switch in sunxi_pinctrl_gpio_direction_output(); pins muxed to gpio_out directly through a pinmux node bypass that path, so sunxi_pmx_set() refreshes their shadow bit from the latch (readable once the pin is in output mode) to keep them driving their pre-existing level.
Seeding the shadow reads the PIO registers at probe time, which requires the bus clock to be enabled. The clock was only requested at the very end of probe, after devm_pinctrl_register() had already claimed the pin hogs described in the device tree - which mux pins, and thus access registers, with the clock still gated. Move the request ahead of both. Boards whose bootloader leaves the PIO clock running are unaffected, which is why the pre-existing hog problem has gone unnoticed since commit 950707c0eb5c ("pinctrl: sunxi: add clock support").
--- drivers/pinctrl/sunxi/pinctrl-sunxi.c | 76 +++++++++++++++++++++------ drivers/pinctrl/sunxi/pinctrl-sunxi.h | 7 +++ 2 files changed, 68 insertions(+), 15 deletions(-)
drivers/pinctrl/sunxi/pinctrl-sunxi.c +61 -15
@@ -778,6 +778,21 @@ static void sunxi_pmx_set(struct pinctrl_dev *pctldev,writel ((readl (pctl->membase + reg) & ~mask) | config << shift, pctl->membase + reg); +/* +* A pin muxed to gpio_out directly through a pinmux node bypasses +* sunxi_pinctrl_gpio_set() and drives whatever its output latch +* holds. Now that the pin is in output mode the data register +* reads back the latch, so refresh the shadow to keep such pins +* driving their pre-existing level. +*/ +if (config ==SUN4I_FUNC_OUTPUT ) { +u32 *shadow = &pctl->dat_shadow[pin /PINS_PER_BANK ]; + +sunxi_data_reg (pin, ®, &shift, &mask); + *shadow = (*shadow & ~mask) | + (readl (pctl->membase + reg) & mask); + } +raw_spin_unlock_irqrestore (&pctl->lock, flags); }
@@ -929,21 +944,29 @@ static void sunxi_pinctrl_gpio_set(struct gpio_chip *chip, unsigned offset, int value) {struct sunxi_pinctrl *pctl =gpiochip_get_data (chip); -u32 reg, shift, mask, val; +u32 *shadow = &pctl->dat_shadow[offset /PINS_PER_BANK ]; +u32 reg, shift, mask;unsigned long flags;sunxi_data_reg (offset, ®, &shift, &mask);raw_spin_lock_irqsave (&pctl->lock, flags); - val =readl (pctl->membase + reg); - +/* +* Reading the data register returns the pin level, not the output +* latch, for pins muxed as inputs. A read-modify-write based on +* the register would therefore corrupt the latches of input-muxed +* pins in the same bank (e.g. an emulated open-drain I2C line +* released high), making them drive the wrong level once switched +* to output. Base the read-modify-write on a shadow copy of the +* latches instead. +*/ if (value) - val |= mask; + *shadow |= mask;else - val &= ~mask; + *shadow &= ~mask; -writel (val, pctl->membase + reg); +writel (*shadow, pctl->membase + reg);raw_spin_unlock_irqrestore (&pctl->lock, flags); }
@@ -1465,7 +1488,7 @@ int sunxi_pinctrl_init_with_variant(struct platform_device *pdev,struct pinctrl_pin_desc *pins;struct sunxi_pinctrl *pctl;struct pinmux_ops *pmxops; -int i, ret, last_pin, pin_idx; +int i, ret, last_pin, pin_idx, nbanks;struct clk *clk; pctl =devm_kzalloc (&pdev->dev,sizeof (*pctl),GFP_KERNEL );
@@ -1490,6 +1513,37 @@ int sunxi_pinctrl_init_with_variant(struct platform_device *pdev,if (!pctl->irq_array)return -ENOMEM ; +/* +* The bus clock has to be enabled before the pinctrl device +* registers, as the pin hogs claimed from there access registers. +*/ + ret =of_clk_get_parent_count (node); + clk =devm_clk_get_enabled (&pdev->dev, ret ==1 ?NULL :"apb" ); +if (IS_ERR (clk)) +return PTR_ERR (clk); + +/* +* Seed the output latch shadow from the hardware so pins the +* bootloader left in output mode keep their state; see +* sunxi_pinctrl_gpio_set() for why a shadow is needed. This must +* happen before the pinctrl device registers, as pin hogs can mux +* pins to gpio_out and thereby update the shadow. +*/ + last_pin = pctl->desc->pins[pctl->desc->npins -1 ].pin.number; + nbanks =DIV_ROUND_UP (last_pin +1 - pctl->desc->pin_base, +PINS_PER_BANK ); + pctl->dat_shadow =devm_kcalloc (&pdev->dev, nbanks, +sizeof (*pctl->dat_shadow),GFP_KERNEL ); +if (!pctl->dat_shadow) +return -ENOMEM ; + +for (i =0 ; i < nbanks; i++) { +u32 reg, shift, mask; + +sunxi_data_reg (i *PINS_PER_BANK , ®, &shift, &mask); + pctl->dat_shadow[i] =readl (pctl->membase + reg); + } + ret =sunxi_pinctrl_build_state (pdev);if (ret) {dev_err (&pdev->dev,"dt probe failed: %d\n" , ret);
@@ -1544,7 +1598,6 @@ int sunxi_pinctrl_init_with_variant(struct platform_device *pdev,if (!pctl->chip)return -ENOMEM ; - last_pin = pctl->desc->pins[pctl->desc->npins -1 ].pin.number; pctl->chip->owner =THIS_MODULE ; pctl->chip->request = gpiochip_generic_request; pctl->chip->free = gpiochip_generic_free;
@@ -1577,13 +1630,6 @@ int sunxi_pinctrl_init_with_variant(struct platform_device *pdev, goto gpiochip_error; } - ret =of_clk_get_parent_count (node); - clk =devm_clk_get_enabled (&pdev->dev, ret ==1 ?NULL :"apb" ); -if (IS_ERR (clk)) { - ret =PTR_ERR (clk); - goto gpiochip_error; - } - pctl->irq = devm_kcalloc(&pdev->dev, pctl->desc->irq_banks, sizeof(*pctl->irq),
drivers/pinctrl/sunxi/pinctrl-sunxi.h +7 -0
@@ -76,6 +76,7 @@#define IO_BIAS_MASK GENMASK(3, 0)#define SUN4I_FUNC_INPUT 0 +#define SUN4I_FUNC_OUTPUT 1#define SUN4I_FUNC_IRQ 6#define PINCTRL_SUN5I_A10S BIT(1)
@@ -160,6 +161,12 @@ struct sunxi_pinctrl {int *irq;unsigned *irq_array;raw_spinlock_t lock; +/* +* Output latch shadow, one word per bank. Seeded lockless at +* probe before the pinctrl device registers, protected by @lock +* afterwards. +*/ +u32 *dat_shadow;struct pinctrl_dev *pctl_dev;unsigned long variant; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 124/516 net: ena: fix MMIO read buffer leak on probe failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 9476b4468862927297c94c440863cd8ed1e7cc83 ]
ena_device_init() initializes the MMIO read mechanism with ena_com_mmio_reg_read_request_init(), which allocates a coherent DMA buffer for MMIO read responses.
The normal removal path releases this buffer through ena_com_mmio_reg_read_request_destroy(). However, if ena_probe() fails after ena_device_init() succeeds, the error path destroys the admin resources and eventually frees ena_dev without destroying the MMIO read request, leaving the coherent DMA buffer allocated.
Call ena_com_mmio_reg_read_request_destroy() in the probe error path before releasing the remaining device resources.
This issue was found by manual code inspection.
--- drivers/net/ethernet/amazon/ena/ena_netdev.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/amazon/ena/ena_netdev.c +1 -0
@@ -4356,6 +4356,7 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err_device_destroy:ena_com_delete_host_info (ena_dev);ena_com_admin_destroy (ena_dev); +ena_com_mmio_reg_read_request_destroy (ena_dev); err_free_region:ena_release_bars (ena_dev, pdev); err_free_ena_dev:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 125/516 smb: client: use finish_no_open() for non-regular inodes
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit e66cf1625ec4a3fe68346119f371def713fd0a4d ]
An O_CREAT open can find an existing symlink or another non-regular inode. cifs_atomic_open() calls finish_open() on it and attaches a cifsFileInfo. Symlink inodes have no CIFS release operation, so the dentry reference held by cifsFileInfo is leaked. FMODE_OPENED also prevents the VFS from following the symlink.
Track whether cifs_do_create() returned an open server handle. For non-regular inodes, close the handle if present, remove the pending open, and call finish_no_open() so the VFS can continue the lookup. Do not set FMODE_CREATED unless a regular file was opened. For O_NOFOLLOW with __O_REGULAR, return -ELOOP before the VFS's -EFTYPE check.
Defer closing a legacy POSIX handle on a non-regular inode until after inode lookup. This avoids closing it again if lookup fails.
--- fs/cifs/dir.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-)
fs/cifs/dir.c +27 -10
@@ -225,7 +225,7 @@ check_name(struct dentry *direntry, struct cifs_tcon *tcon)static int cifs_do_create (struct inode *inode,struct dentry *direntry,unsigned int xid,struct tcon_link *tlink,unsigned oflags,umode_t mode, -__u32 *oplock,struct cifs_fid *fid) +__u32 *oplock,struct cifs_fid *fid,bool *opened) {int rc = -ENOENT ;int create_options =CREATE_NOT_DIR ;
@@ -239,6 +239,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,struct TCP_Server_Info *server = tcon->ses->server;struct cifs_open_parms oparms; + *opened = false; *oplock =0 ;if (tcon->ses->server->oplocks) *oplock =REQ_OPLOCK ;
@@ -254,6 +255,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid, oflags, oplock, &fid->netfid, xid);switch (rc) {case 0 : + *opened = true;if (newinode ==NULL ) {/* query inode info */ goto cifs_create_get_file_info;
@@ -270,11 +272,9 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,/* * The server may allow us to open things like * FIFOs, but the client isn't set up to deal -* with that. If it's not a regular file, just -* close it and proceed as if it were a normal -* lookup. +* with that. Keep the handle until the caller +* can finish the lookup. */ -CIFSSMBClose (xid, tcon, fid->netfid); goto cifs_create_get_file_info; }/* success, no need to query */
@@ -370,6 +370,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,cifs_dbg (FYI ,"cifs_create returned 0x%x\n" , rc); goto out; } + *opened = true;/* * If Open reported that we actually created a file then we now have to
@@ -452,7 +453,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,return rc; out_err: -if (server->ops->close) +if (*opened && server->ops->close) server->ops->close (xid, tcon, fid);if (newinode)iput (newinode);
@@ -472,6 +473,8 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,struct cifs_pending_open open;__u32 oplock;struct cifsFileInfo *file_info; +bool is_regular; +bool opened;/* * Posix open is only called (at lookup time) for file create now. For
@@ -526,16 +529,29 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,cifs_add_pending_open (&fid, tlink, &open); rc =cifs_do_create (inode, direntry, xid, tlink, oflags, mode, - &oplock, &fid); + &oplock, &fid, &opened);if (rc) {cifs_del_pending_open (&open); goto out; } -if ((oflags & (O_CREAT |O_EXCL )) == (O_CREAT |O_EXCL )) + is_regular =d_is_reg (direntry); +if (!is_regular || !opened) { +if (opened && server->ops->close) + server->ops->close (xid, tcon, &fid); +cifs_del_pending_open (&open); + } + +if (is_regular && opened && + (oflags & (O_CREAT |O_EXCL )) == (O_CREAT |O_EXCL )) file->f_mode |=FMODE_CREATED ; +if (!is_regular || !opened) { + rc =finish_no_open (file,NULL ); + goto out; + } + rc =finish_open (file, direntry, generic_file_open);if (rc) {if (server->ops->close)
@@ -585,6 +601,7 @@ int cifs_create(struct inode *inode, struct dentry *direntry, umode_t mode,struct TCP_Server_Info *server;struct cifs_fid fid;__u32 oplock; +bool opened;cifs_dbg (FYI ,"cifs_create parent inode = 0x%p name is: %pd and dentry = 0x%p\n" , inode, direntry, direntry);
@@ -601,8 +618,8 @@ int cifs_create(struct inode *inode, struct dentry *direntry, umode_t mode, server->ops->new_lease_key (&fid); rc =cifs_do_create (inode, direntry, xid, tlink, oflags, mode, - &oplock, &fid); -if (!rc && server->ops->close) + &oplock, &fid, &opened); +if (!rc && opened && server->ops->close) server->ops->close (xid, tcon, &fid);cifs_put_tlink (tlink);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 126/516 tools/thermal/tmon: Fix compilation warning for wrong format
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Eckert <[email protected]>
commit 9da39ef332c417ce52732564c1c682a6e1209302 upstream.
The following warnings are shown during compilation:
tui.c: In function 'show_cooling_device':
tui.c:216:40: warning: format '%d' expects argument of type 'int', but
argument 7 has type 'long unsigned int' [-Wformat=]
216 | "%02d %12.12s%6d %6d",
| ~~^
| |
| int
| %6ld
.....
219 | ptdata.cdi[j].cur_state,
| ~~~~~~~~~~~~~~~~~~~~~~~
| |
| long unsigned int
tui.c:216:44: warning: format '%d' expects argument of type 'int', but
argument 8 has type 'long unsigned int' [-Wformat=]
216 | "%02d %12.12s%6d %6d",
| ~~^
| |
| int
| %6ld
.....
220 | ptdata.cdi[j].max_state);
| ~~~~~~~~~~~~~~~~~~~~~~~
| |
| long unsigned intTo fix this, the correct string format must be used for printing.
--- tools/thermal/tmon/tui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/thermal/tmon/tui.c +1 -1
@@ -213,7 +213,7 @@ void show_cooling_device(void)* cooling device instances. skip unused idr. */ mvwprintw(cooling_device_window, j + 2, 1, - "%02d %12.12s%6d %6d", + "%02d %12.12s%6lu %6lu", ptdata.cdi[j].instance, ptdata.cdi[j].type, ptdata.cdi[j].cur_state,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 127/516 smb: client: validate POSIX create context length
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zihan Xi <[email protected]>
[ Upstream commit fa2e9900dd2a3f5a1e7ef5a8c5e8d435feedbfcc ]
parse_posix_ctxt() reads the fixed nlink, reparse_tag, and mode fields before checking that the POSIX create context contains them. A short context can pass the generic checks and still make these fixed-width reads run past its declared data.
The current in-tree smb2_open_file() path passes a NULL posix pointer, so this handler is not reached on the ordinary open path. Still require the POSIX data to cover all three fields before reading them because the helper performs those unguarded reads. Keep the existing soft-failure behavior so malformed optional metadata does not fail the open.
--- fs/cifs/smb2pdu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/cifs/smb2pdu.c +5 -2
@@ -1972,12 +1972,15 @@ static void parse_posix_ctxt(struct create_context *cc, struct smb2_file_all_info *info, struct create_posix_rsp *posix) { - int sid_len; u8 *beg = (u8 *)cc + le16_to_cpu(cc->DataOffset); -u8 *end = beg +le32_to_cpu (cc->DataLength); +u32 dlen =le32_to_cpu (cc->DataLength); +u8 *end = beg + dlen; +int sid_len;u8 *sid;memset (posix,0 ,sizeof (*posix)); +if (dlen <3 *sizeof (__le32)) +return ; posix->nlink =get_unaligned_le32 (beg); posix->reparse_tag =get_unaligned_le32 (beg +4 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 128/516 Bluetooth: mgmt: fix race in read_unconf_index_list()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aldo Ariel Panzardo <[email protected]>
[ Upstream commit b5dbb41b212c50c095a4dbee3017a84fe94f033b ]
read_unconf_index_list() counts unconfigured controllers before allocating its response, then checks the device flags again while filling it.
hci_dev_list_lock stabilizes list membership, but it does not serialize the per-device flags. During asynchronous controller setup, the worker can set HCI_UNCONFIGURED and clear HCI_SETUP between the two passes. A controller omitted from the allocation count can then become eligible for the fill pass, causing an out-of-bounds write to rp->index[].
Allocate space for every device on hci_dev_list. Since list membership cannot change while hci_dev_list_lock is held, the response remains large enough regardless of flag transitions. The reported count and response length still include only eligible unconfigured controllers.
--- net/bluetooth/mgmt.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
net/bluetooth/mgmt.c +3 -6
@@ -454,13 +454,10 @@ static int read_unconf_index_list(struct sock *sk, struct hci_dev *hdev,read_lock (&hci_dev_list_lock); count =0 ; -list_for_each_entry (d, &hci_dev_list, list) { -if (d->dev_type ==HCI_PRIMARY && -hci_dev_test_flag (d,HCI_UNCONFIGURED )) - count++; - } +list_for_each_entry (d, &hci_dev_list, list) + count++; - rp_len =sizeof (*rp) + (2 * count); + rp_len =sizeof (*rp) + (sizeof (__le16) * count); rp =kmalloc (rp_len,GFP_ATOMIC );if (!rp) {read_unlock (&hci_dev_list_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 129/516 Bluetooth: btusb: Add IMC Networks QCA9377 to quirks table
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tibor Harcsa <[email protected]>
[ Upstream commit dc16388d45ecbd3be0d8c9424dbbaa2c81806578 ]
Add the USB ID (13d3:3503) for the IMC Networks Qualcomm Atheros QCA9377 Bluetooth controller to the btusb quirks table. This device requires Qualcomm Rome firmware and wideband speech support to function properly; otherwise, BLE scanning fails with HCI unexpected event opcode 0x2005 errors.
The device reports the following in /sys/kernel/debug/usb/devices:
P: Vendor=13d3 ProdID=3503 Rev= 0.01
C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms
--- drivers/bluetooth/btusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
@@ -302,6 +302,8 @@ static const struct usb_device_id blacklist_table[] = { BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x13d3, 0x3501), .driver_info = BTUSB_QCA_ROME | BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x13d3, 0x3503), .driver_info = BTUSB_QCA_ROME | + BTUSB_WIDEBAND_SPEECH }, /* QCA WCN6855 chipset */ { USB_DEVICE(0x0cf3, 0xe600), .driver_info = BTUSB_QCA_WCN6855 |
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 130/516 HID: core: remove #ifdef CONFIG_PM from hid_driver
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit df8b030d82dd1224881acb4e778fa06c4824f72b ]
Allow HID drivers to pass ->suspend, ->resume and ->reset_resume via pm_ptr().
Through the usage of pm_ptr() the CONFIG_PM-dependent code will always be compiled, protecting against bitrot.
The linker will then garbage-collect the unused function avoiding any overhead.
The only overhead in the final kernel image and at runtime are a few extra bytes in 'struct hid_driver'.
The same approach is chosen by 'struct usb_driver' and other subsystems.
--- include/linux/hid.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/hid.h +2 -2
@@ -809,11 +809,11 @@ struct hid_driver {void (*feature_mapping)(struct hid_device *hdev,struct hid_field *field,struct hid_usage *usage); -#ifdef CONFIG_PM +int (*suspend)(struct hid_device *hdev,pm_message_t message);int (*resume)(struct hid_device *hdev);int (*reset_resume)(struct hid_device *hdev); -#endif +/* private: */ struct device_driver driver; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 131/516 HID: hid-alps: use default remove for hid device
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marcus Folkesson <[email protected]>
[ Upstream commit 989f7cc94f1174269282a4a46bb735c7f11527de ]
hid_device_remove() will call hid_hw_stop() as default .remove function if no function is specified.
Stable-dep-of: aa9dde93e05a ("HID: alps: unregister DualPoint Stick input device on remove")
--- drivers/hid/hid-alps.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/hid/hid-alps.c +0 -6
@@ -825,11 +825,6 @@ static int alps_probe(struct hid_device *hdev, const struct hid_device_id *id)return 0 ; } -static void alps_remove (struct hid_device *hdev) -{ -hid_hw_stop (hdev); -} -static const struct hid_device_id alps_id[] = { {HID_DEVICE (HID_BUS_ANY ,HID_GROUP_ANY ,USB_VENDOR_ID_ALPS_JP ,HID_DEVICE_ID_ALPS_U1_DUAL ) },
@@ -847,7 +842,6 @@ static struct hid_driver alps_driver = { .name = "hid-alps", .id_table = alps_id, .probe = alps_probe, - .remove = alps_remove, .raw_event = alps_raw_event, .input_mapping = alps_input_mapping, .input_configured = alps_input_configured,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 132/516 HID: hid-alps: Use pm_ptr instead of #ifdef CONFIG_PM
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bastien Nocera <[email protected]>
[ Upstream commit 5e130f58629a2819c9d053507ad368160d25eb65 ]
This increases build coverage and allows to drop an #ifdef.
Stable-dep-of: aa9dde93e05a ("HID: alps: unregister DualPoint Stick input device on remove")
--- drivers/hid/hid-alps.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/hid/hid-alps.c +2 -4
@@ -845,10 +845,8 @@ static struct hid_driver alps_driver = { .raw_event = alps_raw_event, .input_mapping = alps_input_mapping, .input_configured = alps_input_configured, -#ifdef CONFIG_PM - .resume = alps_post_resume, - .reset_resume = alps_post_reset, -#endif + .resume = pm_ptr(alps_post_resume), + .reset_resume = pm_ptr(alps_post_reset), };module_hid_driver (alps_driver);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 133/516 HID: alps: unregister DualPoint Stick input device on remove
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Changcheng <[email protected]>
[ Upstream commit aa9dde93e05a837645fdfd577eea71f0733f0694 ]
alps_input_configured() allocates a second input device ("DualPoint Stick") with input_allocate_device() and registers it, but the alps_driver struct has no .remove handler and input2 is not tracked in hdev->inputs. The default remove path (hid_hw_stop -> hidinput_disconnect) only iterates hdev->inputs, so input2 is never unregistered and leaks on every device removal.
Add a .remove handler that stops the device first (preventing URB callbacks from touching input2 during teardown) and then unregisters input2.
--- drivers/hid/hid-alps.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/hid/hid-alps.c +19 -0
@@ -825,6 +825,24 @@ static int alps_probe(struct hid_device *hdev, const struct hid_device_id *id)return 0 ; } +static void alps_remove (struct hid_device *hdev) +{ +struct alps_dev *data =hid_get_drvdata (hdev); + +/* +* input2 ("DualPoint Stick") is allocated separately and is not +* tracked in hdev->inputs, so the default remove path +* (hid_hw_stop -> hidinput_disconnect) does not unregister it. +* +* Stop the device first so that no URB callback can touch input2 +* while it is being unregistered, then drop it explicitly. +*/ +hid_hw_stop (hdev); + +if (data->input2) +input_unregister_device (data->input2); +} +static const struct hid_device_id alps_id[] = { {HID_DEVICE (HID_BUS_ANY ,HID_GROUP_ANY ,USB_VENDOR_ID_ALPS_JP ,HID_DEVICE_ID_ALPS_U1_DUAL ) },
@@ -847,6 +865,7 @@ static struct hid_driver alps_driver = { .input_configured = alps_input_configured, .resume = pm_ptr(alps_post_resume), .reset_resume = pm_ptr(alps_post_reset), + .remove = alps_remove, };module_hid_driver (alps_driver);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 134/516 smb/client: use stack-allocated smb2_file_all_info in smb3_query_mf_symlink()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: ChenXiaoSong <[email protected]>
[ Upstream commit fc8789bb57e625e5f32ac57ca2e7d3e7b7fda225 ]
SMB2_open() only fills the fixed fields, so a stack-allocated smb2_file_all_info is sufficient here.
Stable-dep-of: 566820af017e ("smb: client: close handle after create-context parsing failure")
--- fs/cifs/link.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)
fs/cifs/link.c +3 -12
@@ -396,7 +396,7 @@ smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,int buf_type =CIFS_NO_BUFFER ;__le16 *utf16_path;__u8 oplock =SMB2_OPLOCK_LEVEL_NONE ; -struct smb2_file_all_info *pfile_info =NULL ; +struct smb2_file_all_info file_info = {}; oparms.tcon = tcon; oparms.cifs_sb = cifs_sb;
@@ -410,20 +410,12 @@ smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,if (utf16_path ==NULL )return -ENOMEM ; - pfile_info =kzalloc (sizeof (struct smb2_file_all_info ) +PATH_MAX *2 , -GFP_KERNEL ); - -if (pfile_info ==NULL ) { -kfree (utf16_path); -return -ENOMEM ; - } - - rc =SMB2_open (xid, &oparms, utf16_path, &oplock, pfile_info,NULL , + rc =SMB2_open (xid, &oparms, utf16_path, &oplock, &file_info,NULL ,NULL ,NULL );if (rc) goto qmf_out_open_fail; -if (pfile_info->EndOfFile !=cpu_to_le64 (CIFS_MF_SYMLINK_FILE_SIZE )) { +if (file_info.EndOfFile !=cpu_to_le64 (CIFS_MF_SYMLINK_FILE_SIZE )) {/* it's not a symlink */ rc = -ENOENT ;/* Is there a better rc to return? */ goto qmf_out;
@@ -441,7 +433,6 @@ smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,SMB2_close (xid, tcon, fid.persistent_fid, fid.volatile_fid); qmf_out_open_fail:kfree (utf16_path); -kfree (pfile_info);return rc; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 135/516 smb/client: pass cifs_open_info_data to SMB2_open()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: ChenXiaoSong <[email protected]>
[ Upstream commit 1f551e407bb49dce0bbd34ed6a499dad69e18020 ]
Let SMB2_open() fill the smb2_file_all_info embedded in cifs_open_info_data directly. This removes the temporary smb2_file_all_info copy in smb2_open_file().
[5.10 dependency adaptation]
This tree still uses fs/cifs and does not define cifs_open_info_data. Keep the existing SMB2_open() argument type and the FILE_ALL_INFO conversion in smb2_open_file(); drop the wrapper-type and caller changes. Use the dependency's file_info pointer directly on the existing buffer inside SMB2_open(), preserving the stable metadata-copy behavior.
Move the existing open_done trace after smb2_parse_contexts(), retaining its six-argument stable signature. Together with the file_info argument, this allows 566820af017e ("smb: client: close handle after create-context parsing failure") to cherry-pick cleanly across the directory rename. No functions are added, and the target's close-on-error fix remains for the target commit.
[ sashal: Reduced backport -- upstream 1f551e407bb49 touches 4 file(s), this
backport carries 1. Not backported here:
fs/smb/client/link.c
fs/smb/client/smb2file.c
fs/smb/client/smb2pdu.c
fs/smb/client/smb2proto.h
This note is generated from the file lists only; see the resolution record for the reasoning. ]
Stable-dep-of: 566820af017e ("smb: client: close handle after create-context parsing failure")
--- fs/cifs/smb2pdu.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)
fs/cifs/smb2pdu.c +13 -12
@@ -2902,6 +2902,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,int resp_buftype =CIFS_NO_BUFFER ;int rc =0 ;int flags =0 ; +struct smb2_file_all_info *file_info = buf;cifs_dbg (FYI ,"create/open\n" );if (!ses || !server)
@@ -2944,10 +2945,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, tcon->need_reconnect = true; } goto creat_exit; - }else -trace_smb3_open_done (xid, rsp->PersistentFileId, tcon->tid, - ses->Suid, oparms->create_options, - oparms->desired_access); + }atomic_inc (&tcon->num_remote_opens); oparms->fid->persistent_fid = rsp->PersistentFileId;
@@ -2957,18 +2955,21 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, oparms->fid->mid =le64_to_cpu (rsp->hdr.MessageId);#endif /* CIFS_DEBUG2 */ -if (buf) { -memcpy (buf, &rsp->CreationTime,32 ); - buf->AllocationSize = rsp->AllocationSize; - buf->EndOfFile = rsp->EndofFile; - buf->Attributes = rsp->FileAttributes; - buf->NumberOfLinks =cpu_to_le32 (1 ); - buf->DeletePending =0 ; +if (file_info) { +memcpy (file_info, &rsp->CreationTime,32 ); + file_info->AllocationSize = rsp->AllocationSize; + file_info->EndOfFile = rsp->EndofFile; + file_info->Attributes = rsp->FileAttributes; + file_info->NumberOfLinks =cpu_to_le32 (1 ); + file_info->DeletePending =0 ; } rc =smb2_parse_contexts (server, &rsp_iov, &oparms->fid->epoch, - oparms->fid->lease_key, oplock, buf, posix); + oparms->fid->lease_key, oplock, file_info, posix); + +trace_smb3_open_done (xid, rsp->PersistentFileId, tcon->tid, ses->Suid, + oparms->create_options, oparms->desired_access); creat_exit:SMB2_open_free (&rqst);free_rsp_buf (resp_buftype, rsp);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 136/516 smb: client: close handle after create-context parsing failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zihan Xi <[email protected]>
[ Upstream commit 566820af017e81497fb5e9d3ad6e7ffe2828bc8b ]
SMB2_open() accounts a successful CREATE response as a remote open before parsing its create contexts. If smb2_parse_contexts() rejects malformed context data, SMB2_open() returns without closing the handle, leaving the server-side handle open and num_remote_opens elevated.
Close the handle after a post-CREATE context parsing failure so the error path releases the remote resource and balances the open count.
--- fs/cifs/smb2pdu.c | 3 +++ 1 file changed, 3 insertions(+)
fs/cifs/smb2pdu.c +3 -0
@@ -2967,6 +2967,9 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, rc =smb2_parse_contexts (server, &rsp_iov, &oparms->fid->epoch, oparms->fid->lease_key, oplock, file_info, posix); +if (rc) +SMB2_close (xid, tcon, oparms->fid->persistent_fid, + oparms->fid->volatile_fid);trace_smb3_open_done (xid, rsp->PersistentFileId, tcon->tid, ses->Suid, oparms->create_options, oparms->desired_access);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 137/516 smb: client: close completed creates on compound wait errors
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zihan Xi <[email protected]>
[ Upstream commit 6c5c547f037bc18f0b8d0b5db5a648f8f630ce85 ]
compound_send_recv() waits for responses in order. If a later wait is interrupted, or if a later MID fails during response synchronization, an earlier CREATE may already have opened a remote handle. The earlier mid is then released without invoking handle_cancelled_mid(), leaving the remote handle open because no FID was copied to the caller.
Mark completed earlier mids as cancelled when a compound wait or MID synchronization aborts. Keep their response buffers attached while the MIDs are synchronized, and transfer them only after synchronization of the processed responses, so the release path can inspect successful CREATE responses and queue SMB2_close() after a later failure. Account for a remote open only after the close work is allocated and before it is queued, since the caller has not yet updated num_remote_opens. Mark the create+close compound used by smb2_unlink() so it is not closed again. Non-CREATE responses and compounds that already include a close keep their existing behavior.
--- fs/cifs/smb2misc.c | 9 ++++-- fs/cifs/transport.c | 70 ++++++++++++++++++++++++++++++++++----------- 2 files changed, 60 insertions(+), 19 deletions(-)
fs/cifs/smb2misc.c +6 -3
@@ -803,7 +803,8 @@ smb2_cancelled_close_fid(struct work_struct *work)*/ static int __smb2_handle_cancelled_cmd (struct cifs_tcon *tcon,__u16 cmd,__u64 mid, -__u64 persistent_fid,__u64 volatile_fid) +__u64 persistent_fid,__u64 volatile_fid, +bool account_remote_open) {struct close_cancelled_open *cancelled;
@@ -817,6 +818,8 @@ __smb2_handle_cancelled_cmd(struct cifs_tcon *tcon, __u16 cmd, __u64 mid, cancelled->cmd = cmd; cancelled->mid = mid;INIT_WORK (&cancelled->work, smb2_cancelled_close_fid); +if (account_remote_open) +atomic_inc (&tcon->num_remote_opens);WARN_ON (queue_work (cifsiod_wq, &cancelled->work) == false);return 0 ;
@@ -849,7 +852,7 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,spin_unlock (&cifs_tcp_ses_lock); rc =__smb2_handle_cancelled_cmd (tcon,SMB2_CLOSE_HE ,0 , - persistent_fid, volatile_fid); + persistent_fid, volatile_fid, false);if (rc)cifs_put_tcon (tcon);
@@ -877,7 +880,7 @@ smb2_handle_cancelled_mid(struct mid_q_entry *mid, struct TCP_Server_Info *servele16_to_cpu (hdr->Command),le64_to_cpu (hdr->MessageId), rsp->PersistentFileId, - rsp->VolatileFileId); + rsp->VolatileFileId, true);if (rc)cifs_put_tcon (tcon);
fs/cifs/transport.c +54 -16
111 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 138/516 audit: fix exe mark UAF in kill_rules()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
commit aa650d87a498844060eecb1d336f4d46f4d1b0b3 upstream.
kill_rules() removes mixed AUDIT_DIR and AUDIT_EXE rules when an audit tree is pruned. It drops entry->rule.exe before removing the rule from the RCU-visible filter lists.
After a rule has been installed with AUDIT_ADD_RULE, which requires CAP_AUDIT_CONTROL, removing the watched directory can race with another task that is still evaluating the rule. In that case, fsnotify can free the executable mark before the reader reaches audit_mark_compare(), causing a use-after-free.
KASAN reports:
BUG: KASAN: slab-use-after-free in audit_mark_compare+0x8d/0xa0
Unlink the published rules from the RCU-visible lists and retain them on tree->rules for cleanup. If any rule has an executable mark, wait for a single RCU grace period before removing the marks and scheduling the entries for freeing. Otherwise, call_rcu() already provides the required deferred freeing without a synchronous wait.
--- kernel/audit_tree.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
kernel/audit_tree.c +20 -4
@@ -543,22 +543,38 @@ static void kill_rules(struct audit_cont {struct audit_krule *rule, *next;struct audit_entry *entry; +bool need_sync = false;list_for_each_entry_safe (rule, next, &tree->rules, rlist) { entry = container_of(rule, struct audit_entry, rule); -list_del_init (&rule->rlist);if (rule->tree) {/* not a half-baked one */ audit_tree_log_remove_rule (context, rule); -if (entry->rule.exe) -audit_remove_mark (entry->rule.exe); rule->tree =NULL ;list_del_rcu (&entry->list);list_del (&entry->rule.list); -call_rcu (&entry->rcu, audit_free_rule_rcu); +if (entry->rule.exe) + need_sync = true; + }else { +list_del_init (&rule->rlist); } } + +if (list_empty (&tree->rules)) +return ; + +if (need_sync) +synchronize_rcu (); + +list_for_each_entry_safe (rule, next, &tree->rules, rlist) { + entry = container_of(rule, struct audit_entry, rule); + +list_del_init (&rule->rlist); +if (entry->rule.exe) +audit_remove_mark (entry->rule.exe); +call_rcu (&entry->rcu, audit_free_rule_rcu); + } }/*
Greg Kroah-Hartman
maintainerPATCH 139/516 of/irq: Fix remaining refcount leaks in of_irq_init()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit 30724547b221e0e670ddfef140fc7d816b2aaec6 upstream.
Successfully initialized controllers are moved to intc_parent_list, but the final cleanup only frees the descriptors. The device node references taken with of_node_get() and the interrupt parent references are therefore leaked on the normal return path. Drop both before kfree(), as the intc_desc_list cleanup already does.
--- drivers/of/irq.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/of/irq.c +2 -0
@@ -582,6 +582,8 @@ void __init of_irq_init(const struct of_list_for_each_entry_safe (desc, temp_desc, &intc_parent_list, list) {list_del (&desc->list); +of_node_put (desc->interrupt_parent); +of_node_put (desc->dev);kfree (desc); } err:
Greg Kroah-Hartman
maintainerPATCH 140/516 of/overlay: put property on deadprops only after changeset add succeeds
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdurrahman Hussain <[email protected]>
commit 814f2da6995772c07a7c9c2cc6028b6e3f3ecc9c upstream.
add_changeset_property() links a new property of a not-yet-live target node into the node's deadprops list before handing it to of_changeset_add_property(). If that fails, the error path frees the property but leaves the freed pointer linked in deadprops, and of_node_release() frees it a second time when the aborted overlay's node is released.
Record the changeset entry first and link the property into deadprops only on success. of_changeset_add_property() never looks at the node's property lists, so the order of the two steps is otherwise immaterial, and the error path frees a property that nothing references.
--- drivers/of/overlay.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/of/overlay.c +4 -3
@@ -348,12 +348,13 @@ static int add_changeset_property(structreturn -ENOMEM ;if (!prop) { -if (!target->in_livetree) { + ret =of_changeset_add_property (&ovcs->cset, target->np, + new_prop); +/* the detached node owns the property until the apply */ +if (!ret && !target->in_livetree) { new_prop->next = target->np->deadprops; target->np->deadprops = new_prop; } - ret =of_changeset_add_property (&ovcs->cset, target->np, - new_prop); }else { ret =of_changeset_update_property (&ovcs->cset, target->np, new_prop);
Greg Kroah-Hartman
maintainerPATCH 141/516 netfilter: nft_flow_offload: drop flowtable reference on init error path
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aohan Mei <[email protected]>
commit 747928b5d4ff8c8de55138a54c13980e4bb88578 upstream.
nft_flow_offload_init() bumps the flowtable use count with nft_use_inc() before calling nf_ct_netns_get(). When the latter fails, the error is returned as-is and the reference is leaked.
The upper layers do not balance it either: nf_tables_newexpr() clears expr->ops when the expression init callback fails, so the nft_expr_more() iteration in nft_rule_expr_deactivate() and nf_tables_rule_destroy() stops right before the failed expression and its ->destroy callback, which would drop the reference, never runs.
Each failed rule addition therefore leaks one flowtable reference and the flowtable can no longer be removed: NFT_MSG_DELFLOWTABLE keeps reporting -EBUSY even though no rule references it.
Save the nf_ct_netns_get() return value and undo the nft_use_inc() when it fails, restoring the inc/dec pairing within nft_flow_offload_init() itself.
--- net/netfilter/nft_flow_offload.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/netfilter/nft_flow_offload.c +6 -1
@@ -170,6 +170,7 @@ static int nft_flow_offload_init(const sstruct nft_flow_offload *priv =nft_expr_priv (expr);u8 genmask =nft_genmask_next (ctx->net);struct nft_flowtable *flowtable; +int err;if (!tb[NFTA_FLOW_TABLE_NAME ])return -EINVAL ;
@@ -184,7 +185,11 @@ static int nft_flow_offload_init(const s priv->flowtable = flowtable; -return nf_ct_netns_get (ctx->net, ctx->family); + err =nf_ct_netns_get (ctx->net, ctx->family); +if (err <0 ) +nft_use_dec (&flowtable->use); + +return err; } static void nft_flow_offload_deactivate(const struct nft_ctx *ctx,
Greg Kroah-Hartman
maintainerPATCH 142/516 net/packet: prevent TX_RING byte count overflow
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilkka Lappeteläinen <[email protected]>
commit 2cf81fc9505b148b1b70068303ea6ea4b1212403 upstream.
tpacket_snd() drains every SEND_REQUEST frame in a TX ring and adds each valid packet length to the signed int len_sum. Userspace can recycle completed frames concurrently, so a single blocking send call is not bounded by the ring size.
After enough successful transmissions len_sum wraps into the negative range. In particular, 65536 65535-byte frames followed by a 65007-byte frame produce 0xfffffdef, or -EIOCBQUEUED. sock_sendmsg_nosec() treats that as an impossible return and triggers a BUG. On systems configured to panic on oops, a CAP_NET_RAW holder can panic the host kernel.
Stop before the next frame would make the byte count exceed INT_MAX. The positive short count leaves that frame pending for a later send call.
A two-thread TPACKET_V2 reproducer triggered the BUG on an arm64 build of Linux 7.3-rc4. With this change, the same reproducer returned the expected positive short count without an oops.
--- net/packet/af_packet.c | 3 +++ 1 file changed, 3 insertions(+)
net/packet/af_packet.c +3 -0
@@ -2867,6 +2867,9 @@ static int tpacket_snd(struct packet_soc vnet_hdr.hdr_len); has_vnet_hdr = true; } +/* Prevent the byte count from wrapping into a negative errno */ +if (unlikely (tp_len >INT_MAX - len_sum)) +break ; copylen =max_t (int, copylen, hard_header_len); skb = sock_alloc_send_skb(&po->sk, hlen + tlen + sizeof(struct sockaddr_ll) +
Greg Kroah-Hartman
maintainerPATCH 143/516 rtc: spear: initialize IRQ state before requesting alarm IRQ
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
commit 055ef5ce9f67a6a3a1363fa663007f8196cc0fb8 upstream.
devm_request_irq() enables the interrupt before it returns, so the handler may run while probe is still initializing the device. Initialize the MMIO address and spinlock before requesting the alarm IRQ.
--- drivers/rtc/rtc-spear.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/rtc/rtc-spear.c +6 -5
@@ -360,6 +360,12 @@ static int spear_rtc_probe(struct platfoif (irq <0 )return irq; + config->ioaddr =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (config->ioaddr)) +return PTR_ERR (config->ioaddr); + +spin_lock_init (&config->lock); + status =devm_request_irq (&pdev->dev, irq, spear_rtc_irq,0 , pdev->name, config);if (status) {
@@ -368,10 +374,6 @@ static int spear_rtc_probe(struct platforeturn status; } - config->ioaddr =devm_platform_ioremap_resource (pdev,0 ); -if (IS_ERR (config->ioaddr)) -return PTR_ERR (config->ioaddr); - config->clk =devm_clk_get (&pdev->dev,NULL );if (IS_ERR (config->clk))return PTR_ERR (config->clk);
@@ -380,7 +382,6 @@ static int spear_rtc_probe(struct platfoif (status <0 )return status; -spin_lock_init (&config->lock);platform_set_drvdata (pdev, config); config->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
Greg Kroah-Hartman
maintainerPATCH 144/516 sctp: check RCV_SHUTDOWN after the sendmsg connect wait
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jun Yang <[email protected]>
commit 4f1da630d13de0370e2f6361f961f1c8b384af1c upstream.
sctp_wait_for_connect() drops the socket lock while it sleeps. An out-of-the-blue ABORT can then be processed from the socket backlog and unlink the association. If a concurrent shutdown(fd, SHUT_RD) sets RCV_SHUTDOWN, the waiter breaks with err == 0 before checking asoc->base.dead. Its final sctp_association_put() can then free the association, leaving sctp_sendmsg_to_asoc() to continue with a dangling pointer.
Check RCV_SHUTDOWN along with the wait error in sctp_sendmsg_to_asoc() before using the association again. The check only accesses the socket, so it needs no additional association reference. Return the existing -ESRCH so that sctp_sendmsg() skips freeing a new association that may already have been destroyed.
Keep sctp_wait_for_connect() unchanged to preserve its behavior for the connect() caller.
--- net/sctp/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sctp/socket.c +1 -1
@@ -1846,7 +1846,7 @@ static int sctp_sendmsg_to_asoc(struct sif (asoc->ep->intl_enable) { timeo =sock_sndtimeo (sk,0 ); err =sctp_wait_for_connect (asoc, &timeo); -if (err) { +if (err || sk->sk_shutdown &RCV_SHUTDOWN ) { err = -ESRCH ; goto err; }
Greg Kroah-Hartman
maintainerPATCH 145/516 wifi: cfg80211: avoid double free if updating BSS fails
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Berg <[email protected]>
[ Upstream commit acc44cbd7727115f9381c35c2898b1b5af665ec8 ]
cfg80211_update_known_bss will always consume the passed IEs. As such, cfg80211_update_assoc_bss_entry also needs to always set the pointers to NULL so that no double free can occur.
Note that hitting this would probably require being connected to a hidden BSS which is then doing a channel switch while also switching to be not hidden anymore at the same time.
--- net/wireless/scan.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
net/wireless/scan.c +3 -4
@@ -2751,10 +2751,9 @@ void cfg80211_update_assoc_bss_entry(struct wireless_dev *wdev,if (new) {/* to save time, update IEs for transmitting bss only */ -if (cfg80211_update_known_bss (rdev, cbss, new, false)) { - new->pub.proberesp_ies =NULL ; - new->pub.beacon_ies =NULL ; - } +cfg80211_update_known_bss (rdev, cbss, new, false); + new->pub.proberesp_ies =NULL ; + new->pub.beacon_ies =NULL ; list_for_each_entry_safe(nontrans_bss, tmp, &new->pub.nontrans_list,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 146/516 drm/msm/adreno: Assign msm_gpu->pdev earlier to avoid nullptrs
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit 16007768551d5bfe53426645401435ca8d2ef54f ]
There are some cases, such as the one uncovered by Commit 46d4efcccc68 ("drm/msm/a6xx: Avoid a nullptr dereference when speedbin setting fails") where
msm_gpu_cleanup() : platform_set_drvdata(gpu->pdev, NULL);
is called on gpu->pdev == NULL, as the GPU device has not been fully initialized yet.
Turns out that there's more than just the aforementioned path that causes this to happen (e.g. the case when there's speedbin data in the catalog, but opp-supported-hw is missing in DT).
Assigning msm_gpu->pdev earlier seems like the least painful solution to this, therefore do so.
Patchwork: https://patchwork.freedesktop.org/patch/602742/
--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 2 ++ drivers/gpu/drm/msm/msm_gpu.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +2 -0
@@ -907,6 +907,8 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, adreno_gpu->revn = adreno_gpu->info->revn; adreno_gpu->rev = config->rev; + gpu->pdev = pdev; + adreno_gpu_config.ioname ="kgsl_3d0_reg_memory" ; adreno_gpu_config.nr_rings = nr_rings;
drivers/gpu/drm/msm/msm_gpu.c +0 -1
@@ -921,7 +921,6 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,if (IS_ERR (gpu->gpu_cx)) gpu->gpu_cx =NULL ; - gpu->pdev = pdev;platform_set_drvdata (pdev, &gpu->adreno_smmu);msm_devfreq_init (gpu);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 147/516 openvswitch: add nf_ct_is_confirmed check before assigning the helper
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
[ Upstream commit 3c1860543fccc1d0cfe3fd6b190e414a418fe60e ]
A WARN_ON call trace would be triggered when 'ct(commit, alg=helper)' applies on a confirmed connection:
WARNING: CPU: 0 PID: 1251 at net/netfilter/nf_conntrack_extend.c:98 RIP: 0010:nf_ct_ext_add+0x12d/0x150 [nf_conntrack] Call Trace: <TASK> nf_ct_helper_ext_add+0x12/0x60 [nf_conntrack] __nf_ct_try_assign_helper+0xc4/0x160 [nf_conntrack] __ovs_ct_lookup+0x72e/0x780 [openvswitch] ovs_ct_execute+0x1d8/0x920 [openvswitch] do_execute_actions+0x4e6/0xb60 [openvswitch] ovs_execute_actions+0x60/0x140 [openvswitch] ovs_packet_cmd_execute+0x2ad/0x310 [openvswitch] genl_family_rcv_msg_doit.isra.15+0x113/0x150 genl_rcv_msg+0xef/0x1f0
which can be reproduced with these OVS flows:
table=0, in_port=veth1,tcp,tcp_dst=2121,ct_state=-trk actions=ct(commit, table=1)
table=1, in_port=veth1,tcp,tcp_dst=2121,ct_state=+trk+new actions=ct(commit, alg=ftp),normal
The issue was introduced by commit 248d45f1e193 ("openvswitch: Allow attaching helper in later commit") where it somehow removed the check of nf_ct_is_confirmed before asigning the helper. This patch is to fix it by bringing it back.
--- net/openvswitch/conntrack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/openvswitch/conntrack.c +2 -1
@@ -1024,7 +1024,8 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,* connections which we will commit, we may need to attach * the helper here. */ -if (info->commit && info->helper && !nfct_help (ct)) { +if (!nf_ct_is_confirmed (ct) && info->commit && + info->helper && !nfct_help (ct)) {int err =__nf_ct_try_assign_helper (ct, info->ct,GFP_ATOMIC );if (err)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 148/516 rds_tcp: close NULL deref window in rds_tcp_set_callbacks
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maoyi Xie <[email protected]>
commit d2bfdbb69cf87676981b1043010b6224d84c6d3a upstream.
rds_tcp_set_callbacks() links a new rds_tcp_connection onto rds_tcp_tc_list under rds_tcp_tc_list_lock. It releases the lock, then assigns tc->t_sock = sock outside the lock.
rds_tcp_tc_info() and rds6_tcp_tc_info() walk rds_tcp_tc_list under the same lock. Both dereference tc->t_sock->sk without a NULL check.
A reader can acquire rds_tcp_tc_list_lock between the writer's spin_unlock and the t_sock store. It then sees a list entry whose t_sock is NULL. The dereference of tc->t_sock->sk is a NULL access.
Move tc->t_sock = sock inside rds_tcp_tc_list_lock, before list_add_tail. A reader holding the lock then observes the linkage and the t_sock store together.
The restore path is safe. rds_tcp_restore_callbacks() does list_del_init inside the lock. The matching tc->t_sock = NULL after unlink is harmless to readers holding the lock.
[ achender: resolved context conflict; tc->t_rtn initialization is not
present in this tree ]
--- net/rds/tcp.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/rds/tcp.c +6 -3
@@ -231,16 +231,19 @@ void rds_tcp_set_callbacks(struct socket *sock, struct rds_conn_path *cp)rdsdebug ("setting sock %p callbacks to tc %p\n" , sock, tc);write_lock_bh (&sock->sk->sk_callback_lock); -/* done under the callback_lock to serialize with write_space */ +/* done under the callback_lock to serialize with write_space. +* Set t_sock inside rds_tcp_tc_list_lock so readers walking +* rds_tcp_tc_list under the same lock cannot observe an +* entry whose t_sock is NULL. +*/ spin_lock (&rds_tcp_tc_list_lock); + tc->t_sock = sock;list_add_tail (&tc->t_list_item, &rds_tcp_tc_list);spin_unlock (&rds_tcp_tc_list_lock);/* accepted sockets need our listen data ready undone */ if (sock->sk->sk_data_ready == rds_tcp_listen_data_ready) sock->sk->sk_data_ready = sock->sk->sk_user_data; - - tc->t_sock = sock; tc->t_cpath = cp; tc->t_orig_data_ready = sock->sk->sk_data_ready; tc->t_orig_write_space = sock->sk->sk_write_space;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 149/516 vxlan: use one headroom snapshot for neighbour replies
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sanghyun Park <[email protected]>
[ Upstream commit 481506a756dcd828ef42391cb08f38d8d96d38fc ]
vxlan_na_create() samples LL_RESERVED_SPACE() to size the reply skb and then samples it again to reserve headroom. A concurrent vxlan_changelink() can update needed_headroom between the two reads, creating a TOCTOU race. The second value can exceed the allocation and make the Ethernet header write out of bounds.
The race is reproducible on the unpatched kernel. It occurred when vxlan_na_create() generated a neighbour reply while vxlan_changelink() changed the link headroom. KASAN caught a four-byte write two bytes beyond a 704-byte skbuff_small_head allocation.
Snapshot the headroom once and use that value for both allocation and reservation.
--- drivers/net/vxlan/vxlan_core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/vxlan/vxlan_core.c +4 -2
@@ -2085,13 +2085,15 @@ static struct sk_buff *vxlan_na_create(struct sk_buff *request,struct ipv6hdr *pip6;u8 *daddr;int na_olen =8 ;/* opt hdr + ETH_ALEN for target */ +int headroom;int ns_olen;int i, len;if (dev ==NULL || !pskb_may_pull (request, request->len))return NULL ; - len =LL_RESERVED_SPACE (dev) +sizeof (struct ipv6hdr ) + + headroom =LL_RESERVED_SPACE (dev); + len = headroom +sizeof (struct ipv6hdr ) +sizeof (*na) + na_olen + dev->needed_tailroom; reply =alloc_skb (len,GFP_ATOMIC );if (reply ==NULL )
@@ -2099,7 +2101,7 @@ static struct sk_buff *vxlan_na_create(struct sk_buff *request, reply->protocol =htons (ETH_P_IPV6 ); reply->dev = dev; -skb_reserve (reply,LL_RESERVED_SPACE (request->dev)); +skb_reserve (reply, headroom);skb_push (reply,sizeof (struct ethhdr ));skb_reset_mac_header (reply);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 150/516 of/irq: add missing of_node_put() for interrupt parent node
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Clément Léger <[email protected]>
[ Upstream commit eb2b4ecf7299ee39ee9cecc4d3f2633aeb10cefb ]
After calling of_irq_parse_one(), the node provided in the of_phandle_args has a refcount increment by one. Add missing of_node_put in of_irq_get() to decrement the refcount once used.
--- drivers/of/irq.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/of/irq.c +9 -3
@@ -407,10 +407,16 @@ int of_irq_get(struct device_node *dev, int index)return rc; domain =irq_find_host (oirq.np); -if (!domain) -return -EPROBE_DEFER ; +if (!domain) { + rc = -EPROBE_DEFER ; + goto out; + } -return irq_create_of_mapping (&oirq); + rc =irq_create_of_mapping (&oirq); +out: +of_node_put (oirq.np); + +return rc; }EXPORT_SYMBOL_GPL (of_irq_get);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 151/516 vt: skip screen update for DEC alignment test on backgroup consoles
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zizhi Wo <[email protected]>
commit 0928ed9bd7946baee911efa401088697836e3b1e upstream.
[BUG]
Recently, we encountered a KASAN warning as follows:
BUG: KASAN: slab-out-of-bounds in fb_pad_aligned_buffer+0x11f/0x140 Read of size 1 at addr ff1100015fd9f6a4 by task tty_fbcon_oob/1239 CPU: 7 UID: 0 PID: 1239 Comm: tty_fbcon_oob Not tainted 7.3.0-rc1 #100 PREEMPT(full) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-4.fc41 04/01/2014 Call Trace: <TASK> ... kasan_report+0xf0/0x120 fb_pad_aligned_buffer+0x11f/0x140 ccw_putcs+0x86c/0xa80 fbcon_putcs+0x338/0x410 do_update_region+0x21d/0x450 do_con_write+0x1e0e/0x4880 con_write+0x13/0x80 n_tty_write+0x374/0x1010 file_tty_write.isra.0+0x404/0x7a0 ...
reproduce:
1) open /dev/tty0, set a KDFONTOP ioctl with op.op = KD_FONT_OP_SET, op.width = 8 and op.height = 16 (visible VC1)
2) open /dev/tty1, set a KDFONTOP ioctl with op.op = KD_FONT_OP_SET, op.width = 28 and op.height = 24 (invisible VC2)
3) echo 3 > /sys/devices/virtual/graphics/fbcon/rotate_all
4) write EShash8(esc hash8) to tty1
[CAUSE]
All VCs render to the framebuffer. setfont only modifies the target VC's font without resizing the framebuffer backing buffer (par->rotated.buf); the buffer is only resized for the visible VC (fbcon_do_set_font -> ... -> vc_do_resize -> update_screen). This relies on the con_should_update() check performed before every update_region().
However, the ESC # 8 path (do_con_trol -> do_update_region) omits the con_should_update() check. After changing the font size of an invisible VC, do_update_region() fills using the new font size against a buffer that was never resized, causing an out-of-bounds access.
[FIX]
Only push the update when the console is visible and not blanked, add the con_should_update() check in the do_con_trol() like every other call site of do_update_region() (update_region(), invert_screen(), ...).
--- drivers/tty/vt/vt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/tty/vt/vt.c +2 -1
@@ -2544,7 +2544,8 @@ static void do_con_trol(struct tty_struccsi_J (vc,2 ); vc->vc_video_erase_char = (vc->vc_video_erase_char &0xff00 ) |' ' ; -do_update_region (vc, vc->vc_origin, vc->vc_screenbuf_size /2 ); +if (con_should_update (vc)) +do_update_region (vc, vc->vc_origin, vc->vc_screenbuf_size /2 ); }return ;case ESsetG0:
Greg Kroah-Hartman
maintainerPATCH 152/516 ALSA: caiaq: unregister the input device when probe fails
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nguyen Ngoc Thang <[email protected]>
commit 0b7bd20f6379bc5e431fd74d866390f5b5b63f3c upstream.
setup_card() registers the input device, whose name and phys point into struct snd_usb_caiaqdev, and then goes on to snd_card_register() and snd_usb_caiaq_control_init(). If either fails, snd_probe() calls snd_card_free(), which frees the device state but leaves the input device registered: card_free() only clears the pointer, and the input device is unregistered from snd_disconnect() alone. Reading its "uevent" attribute afterwards dereferences freed memory:
BUG: KASAN: slab-use-after-free in string+0x4a9/0x4f0 Read of size 1 at addr ffff8880208f5043 by task caiaq/4967 add_uevent_var+0x183/0x3a0 input_dev_uevent+0x162/0x900 dev_uevent+0x2f1/0x870 uevent_show+0x1ca/0x3a0 ...
Unregister the input device on the probe error path, as snd_disconnect() does. snd_usb_caiaq_input_disconnect() is a no-op when no input device was registered.
Reproduced with a raw-gadget Audio Kontrol 1 and a temporary hack that makes snd_usb_caiaq_control_init() fail.
--- sound/usb/caiaq/device.c | 3 +++ 1 file changed, 3 insertions(+)
sound/usb/caiaq/device.c +3 -0
@@ -576,6 +576,9 @@ static int snd_probe(struct usb_interfac ret =init_card (caiaqdev (card));if (ret <0 ) {dev_err (&usb_dev->dev,"unable to init card! (ret=%d)\n" , ret); +#ifdef CONFIG_SND_USB_CAIAQ_INPUT +snd_usb_caiaq_input_disconnect (caiaqdev (card)); +#endif snd_card_free (card);return ret; }
Greg Kroah-Hartman
maintainerPATCH 153/516 ALSA: line6: reject oversized playback packets
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
commit 61b0a5a114fa4552892da5c0ff2f42e63bf08c6b upstream.
Each playback URB is handed a slice of out.buffer that is exactly LINE6_ISO_PACKETS * max_packet_size_out bytes, sized from the OUT endpoint, but the number of bytes written into that slice is never compared against it.
submit_audio_out_urb() takes the frame count from prev_fsize, which audio_in_callback() derived from the *IN* endpoint's received packet length, and rescales it with the playback frame size; when prev_fsize is still zero it synthesizes a length from the sample rate instead. On a device declaring a large IN wMaxPacketSize and a small OUT wMaxPacketSize, the resulting memcpy(), or the memset() when the playback stream is idle, runs past its slice and, as the reproducer below shows, beyond the allocation.
usb_submit_urb() is not a backstop. max_packet_size_out comes from usb_maxpacket(), which returns only the low 11 bits of wMaxPacketSize, while USB core validates a high-speed isochronous length against that base scaled by usb_endpoint_maxp_mult(). A length of up to three times the allocated slice is therefore accepted, and even a rejected URB is only rejected after the write.
Reject a packet that does not fit the slice the driver allocated for it. Clamping it instead would silently shorten the capture-derived rate feedback and desynchronize the two streams.
BUG: KASAN: slab-out-of-bounds in submit_audio_out_urb (sound/usb/line6/playback.c:229) Write of size 1024 at addr ffff888100bbd400 by task kworker/1:2/5002 Workqueue: events line6_startup_work Call Trace: __asan_memcpy (mm/kasan/shadow.c:106) submit_audio_out_urb (sound/usb/line6/playback.c:229) line6_submit_audio_out_all_urbs (sound/usb/line6/playback.c:291) line6_stream_start (sound/usb/line6/pcm.c:194) line6_pcm_acquire (sound/usb/line6/pcm.c:337) line6_startup_work (sound/usb/line6/driver.c:728) process_one_work (kernel/workqueue.c:3396) worker_thread (kernel/workqueue.c:3479 kernel/workqueue.c:3560) kthread (kernel/kthread.c:436) ret_from_fork (arch/x86/kernel/process.c:158) ret_from_fork_asm (arch/x86/entry/entry_64.S:245) The buggy address belongs to the object at ffff888100bbd400 which belongs to the cache kmalloc-256 of size 256 The buggy address is located 0 bytes inside of allocated 256-byte region [ffff888100bbd400, ffff888100bbd500)
--- sound/usb/line6/playback.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/usb/line6/playback.c +7 -0
@@ -182,6 +182,13 @@ static int submit_audio_out_urb(struct s fsize *= bytes_per_frame; +if (fsize > line6pcm->max_packet_size_out) { +dev_err (line6pcm->line6->ifcdev, +"playback packet too large: %d > %d\n" , + fsize, line6pcm->max_packet_size_out); +return -EMSGSIZE ; + } + fout->offset = urb_size; fout->length = fsize; urb_size += fsize;
Greg Kroah-Hartman
maintainerPATCH 154/516 hsr: Remove WARN_ONCE() in hsr_addr_is_self().
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit afd0f17ca46258cec3a5cc48b8df9327fe772490 ]
syzbot reported the warning [0] in hsr_addr_is_self(), whose assumption is simply wrong.
hsr->self_node is cleared in hsr_del_self_node(), which is called from hsr_dellink().
Since dev->rtnl_link_ops->dellink() is called before unregister_netdevice_many(), there is a window when user can find the device but without hsr->self_node.
Let's remove WARN_ONCE() in hsr_addr_is_self().
[0]:
HSR: No self node
WARNING: net/hsr/hsr_framereg.c:39 at hsr_addr_is_self+0x211/0x3f0 net/hsr/hsr_framereg.c:39, CPU#0: syz.4.16848/17220
Modules linked in:
CPU: 0 UID: 0 PID: 17220 Comm: syz.4.16848 Tainted: G L syzkaller #0 PREEMPT_{RT,(full)}
Tainted: [L]=SOFTLOCKUP
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/18/2026
RIP: 0010:hsr_addr_is_self+0x211/0x3f0 net/hsr/hsr_framereg.c:39
Code: 33 2f 41 0f b7 dd 89 ee 09 de 31 ff e8 c8 b4 c6 f6 09 dd 74 54 e8 0f b0 c6 f6 31 ed eb 53 e8 06 b0 c6 f6 48 8d 3d 2f 50 9c 04 <67> 48 0f b9 3a 31 ed eb 42 e8 c1 13 1f 00 89 c5 31 ff 89 c6 e8 96
RSP: 0018:ffffc900041c70e0 EFLAGS: 00010283
RAX: ffffffff8afdc6ca RBX: ffffffff8afdc4e6 RCX: 0000000000080000
RDX: ffffc90010493000 RSI: 0000000000000948 RDI: ffffffff8f9a1700
RBP: 0000000000000001 R08: 0000000000000000 R09: 0000000000000000
R10: ffffc900041c71e8 R11: fffff52000838e3f R12: dffffc0000000000
R13: ffff888041f9e3c0 R14: ffff888086ee3802 R15: 0000000000000000
FS: 00007f6fe985d6c0(0000) GS:ffff888126176000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f80bd437dac CR3: 0000000025096000 CR4: 00000000003526f0
DR0: ffffffffffffffff DR1: 00000000000001f8 DR2: 0000000000000002
DR3: ffffffffefffff15 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
check_local_dest net/hsr/hsr_forward.c:592 [inline]
fill_frame_info net/hsr/hsr_forward.c:728 [inline]
hsr_forward_skb+0xa11/0x2a80 net/hsr/hsr_forward.c:739
hsr_dev_xmit+0x253/0x370 net/hsr/hsr_device.c:236
__netdev_start_xmit include/linux/netdevice.h:5368 [inline]
netdev_start_xmit include/linux/netdevice.h:5377 [inline]
xmit_one net/core/dev.c:3888 [inline]
dev_hard_start_xmit+0x2df/0x860 net/core/dev.c:3904
__dev_queue_xmit+0x1428/0x3900 net/core/dev.c:4870
neigh_output include/net/neighbour.h:556 [inline]
ip_finish_output2+0xcec/0x10b0 net/ipv4/ip_output.c:237
ip_send_skb net/ipv4/ip_output.c:1510 [inline]
ip_push_pending_frames+0x8b/0x110 net/ipv4/ip_output.c:1530
raw_sendmsg+0x1547/0x1a50 net/ipv4/raw.c:659
sock_sendmsg_nosec net/socket.c:787 [inline]
__sock_sendmsg net/socket.c:802 [inline]
____sys_sendmsg+0x7da/0x9c0 net/socket.c:2698
___sys_sendmsg+0x2a5/0x360 net/socket.c:2752
__sys_sendmsg net/socket.c:2784 [inline]
__do_sys_sendmsg net/socket.c:2789 [inline]
__se_sys_sendmsg net/socket.c:2787 [inline]
__x64_sys_sendmsg+0x1c3/0x2a0 net/socket.c:2787
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f6feb62ce59
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f6fe985d028 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007f6feb8a6090 RCX: 00007f6feb62ce59
RDX: 0000000000000000 RSI: 0000200000000000 RDI: 0000000000000004
RBP: 00007f6feb6c2d6f R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f6feb8a6128 R14: 00007f6feb8a6090 R15: 00007ffcf01cc488
</TASK>--- net/hsr/hsr_framereg.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
net/hsr/hsr_framereg.c +1 -3
@@ -45,10 +45,8 @@ bool hsr_addr_is_self(struct hsr_priv *hsr, unsigned char *addr)rcu_read_lock (); sn =rcu_dereference (hsr->self_node); -if (!sn) { -WARN_ONCE (1 ,"HSR: No self node\n" ); +if (!sn) goto out; - }if (ether_addr_equal (addr, sn->macaddress_A) ||ether_addr_equal (addr, sn->macaddress_B))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 155/516 scsi: qla2xxx: Initialize NVMe abort_work once at submission
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nilesh Javali <[email protected]>
[ Upstream commit 7e85f6dbc85616de2172bce8eaf84b387a723cd1 ]
qla_nvme_fcp_abort() and qla_nvme_ls_abort() ran INIT_WORK() on priv->abort_work immediately before schedule_work(). INIT_WORK() reinitializes the work_struct, resetting its list head and clearing the pending bit. If an abort is issued more than once for the same command (for example, concurrent transport teardown and a timeout-driven abort), the second INIT_WORK() reinitializes a work item that is already queued, which can corrupt the workqueue list and lead to crashes or a looping worker.
Initialize priv->abort_work once at command submission, next to the existing per-command spin_lock_init(&priv->cmd_lock), and leave only schedule_work() in the abort paths. schedule_work() already does nothing when the work item is still pending, so a repeated abort no longer disturbs an in-flight work item. The command is not returned to the transport until the final kref_put()/release callback runs after abort_work has completed, so the work item is idle before priv is reused and the single submission-time INIT_WORK() is safe.
--- drivers/scsi/qla2xxx/qla_nvme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_nvme.c +2 -2
@@ -278,7 +278,6 @@ static void qla_nvme_ls_abort(struct nvme_fc_local_port *lport, }spin_unlock_irqrestore (&priv->cmd_lock, flags); -INIT_WORK (&priv->abort_work, qla_nvme_abort_work);schedule_work (&priv->abort_work); }
@@ -317,6 +316,7 @@ static int qla_nvme_ls_req(struct nvme_fc_local_port *lport, priv->sp = sp;kref_init (&sp->cmd_kref);spin_lock_init (&priv->cmd_lock); +INIT_WORK (&priv->abort_work, qla_nvme_abort_work); nvme = &sp->u.iocb_cmd; priv->fd = fd; nvme->u.nvme.desc = fd;
@@ -361,7 +361,6 @@ static void qla_nvme_fcp_abort(struct nvme_fc_local_port *lport, }spin_unlock_irqrestore (&priv->cmd_lock, flags); -INIT_WORK (&priv->abort_work, qla_nvme_abort_work);schedule_work (&priv->abort_work); }
@@ -600,6 +599,7 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port *lport,kref_init (&sp->cmd_kref);spin_lock_init (&priv->cmd_lock); +INIT_WORK (&priv->abort_work, qla_nvme_abort_work); sp->priv = priv; priv->sp = sp; sp->type =SRB_NVME_CMD ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 156/516 scsi: qla2xxx: Fix NVMe abort reference leak on repeated abort
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nilesh Javali <[email protected]>
[ Upstream commit 06b5b2a5d499323f1c3256ead35798e8e3d15e60 ]
qla_nvme_ls_abort() and qla_nvme_fcp_abort() take a command reference with kref_get_unless_zero() and then call schedule_work() on priv->abort_work, ignoring its return value. qla_nvme_abort_work() runs once and drops exactly one reference via kref_put(&sp->cmd_kref, sp->put_fn).
Since the per-abort INIT_WORK() was moved to submission time, schedule_work() now returns false when the work is already pending, for example on a concurrent transport teardown and timeout-driven abort of the same command. In that case the reference taken for the second abort is never released because the work still executes only once, leaking a reference. The command is then never returned to the NVMe-FC transport, which can hang the port.
Drop the reference when schedule_work() returns false, so each kref_get_unless_zero() is balanced regardless of whether the work was newly queued. The held reference keeps priv->sp valid for the put.
--- drivers/scsi/qla2xxx/qla_nvme.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_nvme.c +4 -2
@@ -278,7 +278,8 @@ static void qla_nvme_ls_abort(struct nvme_fc_local_port *lport, }spin_unlock_irqrestore (&priv->cmd_lock, flags); -schedule_work (&priv->abort_work); +if (!schedule_work (&priv->abort_work)) +kref_put (&priv->sp->cmd_kref, priv->sp->put_fn); } static int qla_nvme_ls_req(struct nvme_fc_local_port *lport,
@@ -361,7 +362,8 @@ static void qla_nvme_fcp_abort(struct nvme_fc_local_port *lport, }spin_unlock_irqrestore (&priv->cmd_lock, flags); -schedule_work (&priv->abort_work); +if (!schedule_work (&priv->abort_work)) +kref_put (&priv->sp->cmd_kref, priv->sp->put_fn); }static inline int qla2x00_start_nvme_mq (srb_t *sp)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 157/516 nvmet: preserve device path on allocation failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Sun <[email protected]>
[ Upstream commit 2f271b812170d4cad578bae1f91db72f3c2e36e7 ]
nvmet_ns_device_path_store() frees the old path before allocating its replacement, losing the existing configuration if allocation fails. Allocate the new path before freeing the old one.
--- drivers/nvme/target/configfs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/nvme/target/configfs.c +6 -3
@@ -341,6 +341,7 @@ static ssize_t nvmet_ns_device_path_store(struct config_item *item,struct nvmet_subsys *subsys = ns->subsys;size_t len;int ret; +char *new_path =NULL ;mutex_lock (&subsys->lock); ret = -EBUSY ;
@@ -352,12 +353,14 @@ static ssize_t nvmet_ns_device_path_store(struct config_item *item,if (!len) goto out_unlock; -kfree (ns->device_path); ret = -ENOMEM ; - ns->device_path =kmemdup_nul (page, len,GFP_KERNEL ); -if (!ns->device_path) + new_path =kmemdup_nul (page, len,GFP_KERNEL ); +if (!new_path) goto out_unlock; +kfree (ns->device_path); + ns->device_path = new_path; +mutex_unlock (&subsys->lock);return count;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 158/516 of/overlay: dont leak fragment references when changeset init fails
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdurrahman Hussain <[email protected]>
[ Upstream commit 1d62f0f2bc7edb12ed09f71203df0e47fa4efca4 ]
init_overlay_changeset() stores the number of initialized fragments in ovcs->count only on full success. When find_target() or the __symbols__ lookup fails partway through, the target and overlay references taken for the fragments initialized so far are never
dropped: free_overlay_changeset() bounds its cleanup loop by ovcs->count, which is still 0.
Store the running count on the error path so free_overlay_changeset() puts whatever was set up. The store is guarded by ovcs->fragments because on the allocation-failure path cnt still holds the counting pass total while there is no fragments array; everywhere else cnt only counts fully-initialized fragments.
--- drivers/of/overlay.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/of/overlay.c +4 -0
@@ -841,6 +841,10 @@ static int init_overlay_changeset(struct overlay_changeset *ovcs,pr_err ("%s() failed, ret = %d\n" , __func__, ret); +/* let free_overlay_changeset() put the fragments set up so far */ +if (ovcs->fragments) + ovcs->count = cnt; +return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 159/516 of/overlay: dont create "//" paths for fragments targeting the root
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdurrahman Hussain <[email protected]>
[ Upstream commit 21c89ff1fc86ffa517f3a9ca1ba5c48e9e37c1ba ]
dup_and_fixup_symbol_prop() rewrites a symbol value by replacing its "/fragment/__overlay__" prefix with the fragment's target path. When the fragment targets the root node the target path is "/" and the result starts with "//", which __of_find_node_by_full_path() cannot
resolve: symbols pointing into such fragments silently stop resolving.
Drop the target path when it is the root and the tail is non-empty. A value naming the fragment root itself (empty tail) keeps the "/".
--- drivers/of/overlay.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/of/overlay.c +3 -0
@@ -243,6 +243,9 @@ static struct property *dup_and_fixup_symbol_prop(if (!target_path)return NULL ; target_path_len =strlen (target_path); +/* a root target renders as "/"; drop it to avoid "//" results */ +if (target_path_len ==1 && target_path[0 ] =='/' && path_tail_len) + target_path_len =0 ; new_prop =kzalloc (sizeof (*new_prop),GFP_KERNEL );if (!new_prop)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 160/516 ASoC: wm8903: Move the DRC QR threshold to the register that holds it
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit e31ae4aeb049983fe3be0cf1e12c8074811a7685 ]
The DRC_THRESH_QR field is bits 7 and 6 of DRC_1, but the control sits on DRC_0. Its shift and max are right for the field, only the register is wrong.
Those bits of DRC_0 belong to DRC_STARTUP_GAIN, which "DRC Startup Volume" claims as bits 10 to 6. So the two controls share bits 7 and 6. Writing either one moves the other, and the quick release threshold is never reached at all.
The six fields of DRC_1 tile it exactly, so there is nowhere else the threshold could live. Point the control at DRC_1.
Found by a sweep for two controls claiming the same bits of one register. No board with this codec was to hand, the register map is the driver's own wm8903.h.
--- sound/soc/codecs/wm8903.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8903.c +1 -1
@@ -678,7 +678,7 @@ SOC_ENUM("DRC Decay Rate", drc_decay),SOC_ENUM ("DRC FF Delay" , drc_ff_delay),SOC_SINGLE ("DRC Anticlip Switch" ,WM8903_DRC_0 ,1 ,1 ,0 ),SOC_SINGLE ("DRC QR Switch" ,WM8903_DRC_0 ,2 ,1 ,0 ), -SOC_SINGLE_TLV ("DRC QR Threshold Volume" ,WM8903_DRC_0 ,6 ,3 ,0 , drc_tlv_max), +SOC_SINGLE_TLV ("DRC QR Threshold Volume" ,WM8903_DRC_1 ,6 ,3 ,0 , drc_tlv_max),SOC_ENUM ("DRC QR Decay Rate" , drc_qr_decay),SOC_SINGLE ("DRC Smoothing Switch" ,WM8903_DRC_0 ,3 ,1 ,0 ), SOC_SINGLE("DRC Smoothing Hysteresis Switch", WM8903_DRC_0, 0, 1, 0),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 161/516 wifi: ath11k: reset ar->num_stations on hardware start
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Escande <[email protected]>
[ Upstream commit 7e0ad05ebc72fffba2bdf2400400902d94ed7272 ]
When (multiple) hw restart occurs, we end up in a situation where we cannot accept new stations / mesh peers. This seems to be the 'num_stations' in 'struct ath11k' that did not get reset properly in this case. In ath11k_mac_op_start(), it was indeed the only accounting var that did not get reset so let's clear it too.
This avoids problems like those:
[1248828.088023] WARNING: CPU: 0 PID: 12281 at net/mac80211/util.c:1682 ieee80211_reconfig_stations+0x98/0xc0 [1248828.088115] Call trace: [1248828.088116] ieee80211_reconfig_stations+0x98/0xc0 (P) [1248828.088119] ieee80211_reconfig+0x774/0x1438 [1248828.088123] ieee80211_restart_work+0x10c/0x178 [1248828.088127] process_one_work+0x178/0x3c0 [1248828.088130] worker_thread+0x280/0x440 [1248828.088133] kthread+0xe0/0xf8 [1248828.088137] ret_from_fork+0x10/0x20 [1248828.088141] ---[ end trace 0000000000000000 ]--- [1248836.686604] ath11k_pci 0000:04:00.0: refusing to associate station: too many connected already (128) [1248836.686609] ath11k_pci 0000:04:00.0: Failed to add station: xx:xx:xx:xx:xx:xx for VDEV: 1
Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.9.0.1-01977-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/mac.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/ath/ath11k/mac.c +1 -0
@@ -4242,6 +4242,7 @@ static int ath11k_mac_op_start(struct ieee80211_hw *hw) ar->num_started_vdevs =0 ; ar->num_created_vdevs =0 ; ar->num_peers =0 ; + ar->num_stations =0 ; ar->allocated_vdev_map =0 ;/* Configure monitor status ring with default rx_filter to get rx status
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 162/516 wifi: cfg80211: preserve hidden-group beacon IE ownership
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Li <[email protected]>
[ Upstream commit cc45f313d85533d647ce619326302aad6f797c14 ]
A hidden-group probe-response entry borrows its beacon IEs from the group's beacon entry. cfg80211_update_assoc_bss_entry() can pass such an entry to cfg80211_update_known_bss() when merging scan entries after a channel switch.
Copying the borrowed beacon_ies into the associated entry gives the same allocation two owners. Releasing the group's beacon entry can then leave the associated entry pointing to freed IEs, which are freed again when that entry is released.
Skip beacon IE replacement when the source entry belongs to a hidden group. Preserve probe-response processing, the subsequent metadata updates, and the existing rejection path for conflicting hidden beacon updates.
--- net/wireless/scan.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
net/wireless/scan.c +12 -10
@@ -1765,20 +1765,22 @@ cfg80211_update_known_bss(struct cfg80211_registered_device *rdev,return false; } - old =rcu_access_pointer (known->pub.beacon_ies); +if (!new->pub.hidden_beacon_bss) { + old =rcu_access_pointer (known->pub.beacon_ies); -rcu_assign_pointer (known->pub.beacon_ies, new->pub.beacon_ies); +rcu_assign_pointer (known->pub.beacon_ies, new->pub.beacon_ies); -/* Override IEs if they were from a beacon before */ -if (old ==rcu_access_pointer (known->pub.ies)) -rcu_assign_pointer (known->pub.ies, new->pub.beacon_ies); +/* Override IEs if they were from a beacon before */ +if (old ==rcu_access_pointer (known->pub.ies)) +rcu_assign_pointer (known->pub.ies, new->pub.beacon_ies); -cfg80211_update_hidden_bsses (known, -rcu_access_pointer (new->pub.beacon_ies), - old); +cfg80211_update_hidden_bsses (known, +rcu_access_pointer (new->pub.beacon_ies), + old); -if (old) -kfree_rcu ((struct cfg80211_bss_ies *)old, rcu_head); +if (old) +kfree_rcu ((struct cfg80211_bss_ies *)old, rcu_head); + } } known->pub.beacon_interval = new->pub.beacon_interval;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 163/516 ASoC: codecs: rt274: Fix format setting for 44100 rate
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cezary Rojewski <[email protected]>
[ Upstream commit 6eda8938a790f65bd24fcfaae7b40ad4613fb7a2 ]
As per specification, Sample Base Rate (bit 14) shall be set to 1 for 44.1 kHz.
--- sound/soc/codecs/rt274.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/codecs/rt274.c +3 -1
@@ -619,9 +619,11 @@ static int rt274_hw_params(struct snd_pcm_substream *substream,unsigned int val =0 ;int d_len_code =0 , c_len_code =0 ; +/* bit 14 Sample Rate Base, 0: 48kHz 1: 44.1kHz */ switch (params_rate (params)) { -/* bit 14 0:48K 1:44.1K */ case 44100 : + val |=BIT (14 ); +break ;case 48000 :break ;default :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 164/516 Bluetooth: hci_core: free the HCI ID if naming fails
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sang-Hoon Choi <[email protected]>
[ Upstream commit d1ac915fb4184faad1b62148be50f317de7c24b5 ]
hci_register_dev() allocates an ID before calling dev_set_name(). If naming fails, it returns without releasing that ID. The device has not been registered and hdev->id has not been assigned, so the normal unregister path cannot release it.
Free the allocated ID before returning the naming error.
--- net/bluetooth/hci_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/bluetooth/hci_core.c +3 -1
@@ -3759,8 +3759,10 @@ int hci_register_dev(struct hci_dev *hdev)return id; error =dev_set_name (&hdev->dev,"hci%u" , id); -if (error) +if (error) { +ida_free (&hci_index_ida, id);return error; + } hdev->name =dev_name (&hdev->dev); hdev->id = id;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 165/516 Bluetooth: btintel: validate DDC record lengths
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sai Teja Aluvala <[email protected]>
[ Upstream commit c9c15d4d8956df8c564f7c210e4dc5b9b820d97a ]
Parse DDC record lengths in unsigned storage so 0xFF does not wrap. Reject records smaller than the mandatory three-byte header, records exceeding U8_MAX, and records exceeding remaining firmware bytes before issuing Intel_Write_DDC.
This issue was reported by Claude Mythos.
--- drivers/bluetooth/btintel.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/bluetooth/btintel.c +10 -2
@@ -284,8 +284,16 @@ int btintel_load_ddc_config(struct hci_dev *hdev, const char *ddc_name)/* DDC file contains one or more DDC structure which has * Length (1 byte), DDC ID (2 bytes), and DDC value (Length - 2). */ -while (fw->size > fw_ptr - fw->data) { -u8 cmd_plen = fw_ptr[0 ] +sizeof (u8); +while (fw->size > (size_t )(fw_ptr - fw->data)) { +size_t remaining = fw->size - (fw_ptr - fw->data); +unsigned int cmd_plen = fw_ptr[0 ] +1U ; + +if (cmd_plen <3 || cmd_plen >U8_MAX || cmd_plen > remaining) { +bt_dev_err (hdev,"Malformed DDC record (plen=%u, remaining=%zu)" , + cmd_plen, remaining); +release_firmware (fw); +return -EINVAL ; + } skb =__hci_cmd_sync (hdev,0xfc8b , cmd_plen, fw_ptr,HCI_INIT_TIMEOUT );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 166/516 netfilter: ipset: do not update comments from kernel-side adds
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit a442c8a89fb9c531f9d6ab86120c31decd778d51 ]
'Fixes' commit stopped calling ip_set_init_comment() for hash types from kernel-side-adds (xtables .. -j SET). ip_set_init_comment() says:
"The kadt functions don't use the comment extensions in any way."
But bitmap set type calls the function from kadt cb too.
While this appears to be safe (serialized via the set spinlock), it seems better to not call the init function either, least of all to keep behaviour consistent.
ip_set_list calls ip_set_init_comment() only from uadt cb, it can be kept as-is.
This was triggered by yet another LLM review, hinting that the existing rcu_dereference_protected() cannot be downgraded to only check if the nfnl mutex is held.
--- net/netfilter/ipset/ip_set_bitmap_gen.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/ipset/ip_set_bitmap_gen.h +1 -1
@@ -157,7 +157,7 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext,if (SET_WITH_COUNTER (set))ip_set_init_counter (ext_counter (x, set), ext); -if (SET_WITH_COMMENT (set)) +if (SET_WITH_COMMENT (set) && !ext->target)ip_set_init_comment (set,ext_comment (x, set), ext);if (SET_WITH_SKBINFO (set))ip_set_init_skbinfo (ext_skbinfo (x, set), ext);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 167/516 net: systemport: Fix RUNT MIB counter register offset calculation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit 242935adfeb096f09b29fb2cfcf12f9eb2911fc6 ]
In UniMAC hardware, there is a 0xC byte gap between the RX MIB counters and the TX MIB counters, and a second 0xC byte gap between the TX MIB counters and the RX RUNT MIB counters.
In bcm_sysport_update_mib_counters(), 'offset' was only set to UMAC_MIB_STAT_OFFSET (0xC) for all non-RX counters, omitting the second 0xC gap for BCM_SYSPORT_STAT_RUNT counters. As a result, all 4 RUNT MIB counters were read from unmapped gap register space.
Fix this by setting offset to 2 * UMAC_MIB_STAT_OFFSET (0x18) when reading BCM_SYSPORT_STAT_RUNT counters.
--- drivers/net/ethernet/broadcom/bcmsysport.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bcmsysport.c +3 -1
@@ -421,8 +421,10 @@ static void bcm_sysport_update_mib_counters(struct bcm_sysport_priv *priv)if (priv->is_lite)continue ; -if (s->type !=BCM_SYSPORT_STAT_MIB_RX ) +if (s->type ==BCM_SYSPORT_STAT_MIB_TX ) offset =UMAC_MIB_STAT_OFFSET ; +else if (s->type ==BCM_SYSPORT_STAT_RUNT ) + offset =2 *UMAC_MIB_STAT_OFFSET ; val =umac_readl (priv,UMAC_MIB_START + j + offset);break ;case BCM_SYSPORT_STAT_RXCHK :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 168/516 tipc: prevent GCM nonce reuse on peer key changes
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
[ Upstream commit 512ccd3d0e91e791fb37442aa0a2599aca19783d ]
TIPC can encrypt traffic between nodes using a different transmit key for each node. In this mode, the AES-GCM nonce for a packet sent to a known peer consists of a 32-bit prefix (a per-key salt XOR the peer's address) followed by a 64-bit counter. That counter is stored in the peer's RX crypto object. When the peer reports a change in which key it uses to receive packets, TIPC resets this counter. The sender can still be using the same TX key and salt, so subsequent packets reuse earlier nonces. This nonce reuse breaks confidentiality and exposes GCM's authentication key. This makes forgeries trivial: an attacker can exploit CTR malleability to alter captured ciphertexts and use the recovered authentication key to compute a valid tag for the modified ciphertext, under the same key and nonce.
Use the TX key's existing aead->seqno counter instead. All encryptions using that key object share the same atomic counter, so concurrent encryptions get distinct nonce counter values. The counter survives key activation and peer reconnection, and peer key-status reports cannot reset it. This prevents those transitions from causing nonce reuse while the same TX key remains installed.
The nonce format is unchanged, and receivers do not require consecutive counter values, so sharing the counter across peers remains compatible with existing receivers. A pre-existing check still invokes key revocation in the unlikely event that the counter wraps to zero.
--- net/tipc/crypto.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-)
net/tipc/crypto.c +5 -15
@@ -142,7 +142,7 @@ struct tipc_tfm {* @rcu: struct rcu_head * @key: the aead key * @gen: the key's generation -* @seqno: the key seqno (cluster scope) +* @seqno: the per-key TX nonce counter * @refcnt: the key reference counter */ struct tipc_aead {
@@ -187,7 +187,6 @@ struct tipc_crypto_stats {* @rekeying_intv: rekeying interval (in minutes) * @stats: the crypto statistics * @name: the crypto name -* @sndnxt: the per-peer sndnxt (TX) * @timer1: general timer 1 (jiffies) * @timer2: general timer 2 (jiffies) * @working: the crypto is working or not
@@ -215,7 +214,6 @@ struct tipc_crypto {struct tipc_crypto_stats __percpu *stats;char name[48 ]; -atomic64_t sndnxt____cacheline_aligned ;unsigned long timer1;unsigned long timer2;union {
@@ -1064,14 +1062,11 @@ static int tipc_ehdr_build(struct net *net, struct tipc_aead *aead,WARN_ON (skb_headroom (skb) < ehsz); ehdr = (struct tipc_ehdr *)skb_push (skb, ehsz); -/* Obtain a seqno first: -* Use the key seqno (= cluster wise) if dest is unknown or we're in -* cluster key mode, otherwise it's better for a per-peer seqno! +/* +* Keep the nonce unique for the lifetime of the TX key, +* including key state changes and peer reconnection. */ -if (!__rx || aead->mode ==CLUSTER_KEY ) - seqno =atomic64_inc_return (&aead->seqno); -else - seqno =atomic64_inc_return (&__rx->sndnxt); + seqno =atomic64_inc_return (&aead->seqno);/* Revoke the key if seqno is wrapped around */ if (unlikely (!seqno))
@@ -1250,7 +1245,6 @@ void tipc_crypto_key_flush(struct tipc_crypto *c)tipc_crypto_key_set_state (c,0 ,0 ,0 );for (k =KEY_MIN ; k <=KEY_MAX ; k++)tipc_crypto_key_detach (c->aead[k], &c->lock); -atomic64_set (&c->sndnxt,0 );spin_unlock_bh (&c->lock); }
@@ -1397,8 +1391,6 @@ static struct tipc_aead *tipc_crypto_key_pick_tx(struct tipc_crypto *tx,* It also considers if peer has no key, then we need to make own master key * (if any) taking over i.e. starting grace period and also trigger key * distributing process. -* -* The "per-peer" sndnxt is also reset when the peer key has switched. */ static void tipc_crypto_key_synch (struct tipc_crypto *rx,struct sk_buff *skb) {
@@ -1449,7 +1441,6 @@ static void tipc_crypto_key_synch(struct tipc_crypto *rx, struct sk_buff *skb)if (cur)tipc_aead_users_dec (tx->aead[cur],0 ); -atomic64_set (&rx->sndnxt,0 );/* Mark the point TX key users changed */ tx->timer1 = jiffies;
@@ -1514,7 +1505,6 @@ int tipc_crypto_start(struct tipc_crypto **crypto, struct net *net,tipc_crypto_key_set_state (c,0 ,0 ,0 );atomic_set (&c->key_distr,0 );atomic_set (&c->peer_rx_active,0 ); -atomic64_set (&c->sndnxt,0 ); c->timer1 = jiffies; c->timer2 = jiffies; c->rekeying_intv =TIPC_REKEYING_INTV_DEF ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 169/516 net/sched: fq_codel: match the no-drop threshold to the packet size
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit d031465acc362866f27e4f8f79cfecf1037fe2e5 ]
commit d9ebd8f9aa8b ("net/sched: fq_codel: clamp default quantum and mtu") clamped both q->quantum and q->cparams.mtu to [256, FQ_CODEL_QUANTUM_MAX]. The two fields mean different things: quantum is a DRR credit that wants the 256 floor, but cparams.mtu is the CoDel no-drop threshold (codel_impl.h "*backlog <= params->mtu"). On a link whose maximum transmitted packet size is below 256, the floor extends CoDel's minimum-backlog exemption beyond one packet and delays drop or mark eligibility by several small packets.
Split the clamp. quantum keeps [256, FQ_CODEL_QUANTUM_MAX]; cparams.mtu tracks psched_mtu() (the device MTU plus its hard-header length) with only the upper bound that guards the original overflow (psched_mtu() wrapping to ~2 GiB on a huge-MTU device).
Conditions to recreate the bug: attach an fq_codel qdisc on a link whose MTU plus hard_header_len is below 256 (e.g. a CAN interface). At that MTU the no-drop threshold must equal the device MTU plus its hard-header length; before this patch it was forced to 256. Basic Testing done: with dev->mtu=100 and hard_header_len=14, a return probe on fq_codel_init() observed cparams.mtu change from 256 to 114
--- net/sched/sch_fq_codel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/sched/sch_fq_codel.c +2 -2
@@ -499,8 +499,8 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt, q->flows_cnt =1024 ; q->memory_limit =32 <<20 ;/* 32 MBytes */ q->drop_batch_size =64 ; - mtu =clamp_t (u32,psched_mtu (qdisc_dev (sch)),256 ,FQ_CODEL_QUANTUM_MAX ); - q->quantum = mtu; + mtu =min_t (u32,psched_mtu (qdisc_dev (sch)),FQ_CODEL_QUANTUM_MAX ); + q->quantum =clamp_t (u32, mtu,256 ,FQ_CODEL_QUANTUM_MAX );INIT_LIST_HEAD (&q->new_flows);INIT_LIST_HEAD (&q->old_flows);codel_params_init (&q->cparams);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 170/516 net/sched: sch_codel: match the no-drop threshold to the packet size
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit 54518e0e827f4ca9229ae657022c60bf60f5c1bf ]
commit 6439461f1618 ("net/sched: sch_codel: clamp default mtu to avoid disabling CoDel") clamped q->params.mtu to [256, 1 << 20]. The value is the CoDel no-drop threshold (codel_impl.h "*backlog <= params->mtu"), so on a link whose maximum transmitted packet size is below 256 the floor extends CoDel's minimum-backlog exemption beyond one packet and delays drop or mark eligibility by several small packets.
Keep the upper bound that guards the original overflow (psched_mtu() wrapping to ~2 GiB on a huge-MTU device) but drop the 256 floor, so the threshold tracks the real device packet size.
Conditions to recreate the bug: attach a codel qdisc on a link whose MTU plus hard_header_len is below 256 (e.g. a CAN interface). At that MTU the no-drop threshold must equal the device MTU plus its hard-header length; before this patch it was forced to 256. Requires CAP_NET_ADMIN in a user namespace.
--- net/sched/sch_codel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_codel.c +1 -1
@@ -231,7 +231,7 @@ static int codel_init(struct Qdisc *sch, struct nlattr *opt,codel_params_init (&q->params);codel_vars_init (&q->vars);codel_stats_init (&q->stats); - q->params.mtu =clamp_t (u32,psched_mtu (qdisc_dev (sch)),256 ,1 <<20 ); + q->params.mtu =min_t (u32,psched_mtu (qdisc_dev (sch)),1 <<20 );if (opt) {int err =codel_change (sch, opt, extack);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 171/516 tcp: refresh TS.Recent for accepted old ACKs
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Jo <[email protected]>
[ Upstream commit 1b92780ae4fc3be64f05d97ed8833c445e73b0cf ]
A TCP packet can carry new data while acknowledging traffic in the opposite direction. With overlapping traffic in both directions, a delayed packet's acknowledgment can be older than one Linux has already accepted, even when that packet fills a gap in the received data.
Linux accepts the data, but tcp_ack() takes the old_ack path and skips updating TS.Recent, the timestamp saved for outgoing acknowledgments. The reply therefore echoes an older timestamp. If the sender uses this echo to measure round-trip time after a long idle period, its estimate includes the idle time and can reduce its sending rate.
Update TS.Recent in old_ack using tcp_replace_ts_recent(), before SACK processing can trigger a transmission. This reuses the existing timestamp and sequence checks, including PAWS protection against old duplicate packets. ACK validation already rejects old ACKs in SYN_RECV before this path, so no additional state check is needed.
Echoing the timestamp of the packet that fills the receive gap follows RFC 7323 section 4.3. In a socket reproduction with 300 seconds idle, controlled reordering and retransmission to exercise timestamp-based RTT sampling, the sender's smoothed round-trip time was 37.5 seconds without the fix and 15.5 ms with it.
--- net/ipv4/tcp_input.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/ipv4/tcp_input.c +6 -0
@@ -3976,6 +3976,12 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)return 1 ; old_ack: +/* An old ACK can carry new data. Update TS.Recent before SACK +* processing can trigger a retransmission. +*/ +if (flag &FLAG_UPDATE_TS_RECENT ) +tcp_replace_ts_recent (tp,TCP_SKB_CB (skb)->seq); +/* If data was SACKed, tag it and see if we should send more data. * If data was DSACKed, see if we can undo a cwnd reduction. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 172/516 ipvs: fix missing counter decrement in lblc
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Anastasov <[email protected]>
[ Upstream commit bdac17779f46817f60103baf09f0370546c3f023 ]
LBLC may delete cache entries for destinations that are removed or overloaded and replace them with available ones. But ip_vs_lblc_new() forgets to decrement the tbl->entries counter after calling ip_vs_lblc_del(). This can lead to increased shrinking of the cache with every new garbage collection.
--- net/netfilter/ipvs/ip_vs_lblc.c | 1 + 1 file changed, 1 insertion(+)
net/netfilter/ipvs/ip_vs_lblc.c +1 -0
@@ -205,6 +205,7 @@ ip_vs_lblc_new(struct ip_vs_lblc_table *tbl, const union nf_inet_addr *daddr,if (en->dest == dest)return en;ip_vs_lblc_del (en); +atomic_dec (&tbl->entries); } en =kmalloc (sizeof (*en),GFP_ATOMIC );if (!en)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 173/516 ipvs: do not create invisible templates
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Anastasov <[email protected]>
[ Upstream commit 616cf5c06934364ab1002b420ebe975850b4b208 ]
The IP_VS_CONN_F_ONE_PACKET flag was implemented for normal connections. When conn template inherits this flag from dest->conn_flags it will not be hashed. As result, we will create new template for every new normal connection.
Fix it to allow one template to be used by many normal connections.
--- net/netfilter/ipvs/ip_vs_conn.c | 3 +++ 1 file changed, 3 insertions(+)
net/netfilter/ipvs/ip_vs_conn.c +3 -0
@@ -591,6 +591,9 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)if (cp->protocol !=IPPROTO_UDP ) conn_flags &= ~IP_VS_CONN_F_ONE_PACKET ; flags = cp->flags; +/* Only visible templates can control multiple connections */ +if (flags &IP_VS_CONN_F_TEMPLATE ) + conn_flags &= ~IP_VS_CONN_F_ONE_PACKET ;/* Bind with the destination and its corresponding transmitter */ if (flags &IP_VS_CONN_F_SYNC ) {/* Synced conns are hashed, so they can not get this flag */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 174/516 ipvs: filter some flags received in the backup server
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Anastasov <[email protected]>
[ Upstream commit f96e91748f6304668fe647e686d199d7207d36f1 ]
While the IPVS SYNC protocol is not secure by design we can still protect the backup server from messages that can wreak havoc.
This commit addresses problems from received connection flags or their combinations. We now drop messages as follows:
1. the NO_CPORT+TEMPLATE combination allows lookups for normal connections to hit template which can break in many ways. While the master does not sync connections with NO_CPORT flag, i.e. before they are established, we still accept NO_CPORT without TEMPLATE.
2. ONE_PACKET: it is not sent by master, so we do not expect it in backup. Before now it was ignored by IP_VS_CONN_F_BACKUP_MASK for protocol v1 while protocol v0 created connections that are not hashed and dropped immediately. Better to apply the IP_VS_CONN_F_BACKUP_MASK also to the flags from v0 messages for consistency with v1.
--- net/netfilter/ipvs/ip_vs_sync.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-)
net/netfilter/ipvs/ip_vs_sync.c +30 -3
@@ -950,6 +950,21 @@ static void ip_vs_proc_conn(struct netns_ipvs *ipvs, struct ip_vs_conn_param *paip_vs_conn_put (cp); } +/* Check for incompatible flags */ +static bool ip_vs_sync_validate_flags (u32 flags) +{ +/* We do not expect NO_CPORT, especially to allow lookups +* to hit templates +*/ +if (flags &IP_VS_CONN_F_NO_CPORT ) { +if (flags &IP_VS_CONN_F_TEMPLATE ) +return false; + } +if (flags &IP_VS_CONN_F_ONE_PACKET ) +return false; +return true; +} +/* * Process received multicast message for Version 0 */
@@ -973,8 +988,7 @@ static void ip_vs_process_message_v0(struct netns_ipvs *ipvs, const char *bufferreturn ; } s = (struct ip_vs_sync_conn_v0 *) p; - flags =ntohs (s->flags) |IP_VS_CONN_F_SYNC ; - flags &= ~IP_VS_CONN_F_HASHED ; + flags =ntohs (s->flags);if (flags &IP_VS_CONN_F_SEQ_MASK ) { opt = (struct ip_vs_sync_conn_options *)&s[1 ]; p +=FULL_CONN_SIZE ;
@@ -987,6 +1001,13 @@ static void ip_vs_process_message_v0(struct netns_ipvs *ipvs, const char *buffer p +=SIMPLE_CONN_SIZE ; } +if (!ip_vs_sync_validate_flags (flags)) { +IP_VS_DBG (2 ,"BACKUP v0, Invalid flags 0x%X\n" , flags); +continue ; + } + flags &=IP_VS_CONN_F_BACKUP_MASK ; + flags |=IP_VS_CONN_F_SYNC ; + state =ntohs (s->state);if (!(flags &IP_VS_CONN_F_TEMPLATE )) { pp =ip_vs_proto_get (s->protocol);
@@ -1142,7 +1163,13 @@ static inline int ip_vs_proc_sync_conn(struct netns_ipvs *ipvs, __u8 *p, __u8 *m }/* Get flags and Mask off unsupported */ - flags =ntohl (s->v4.flags) &IP_VS_CONN_F_BACKUP_MASK ; + flags =ntohl (s->v4.flags); +if (!ip_vs_sync_validate_flags (flags)) { +IP_VS_DBG (3 ,"BACKUP, Invalid flags 0x%X\n" , flags); + retc =25 ; + goto out; + } + flags &=IP_VS_CONN_F_BACKUP_MASK ; flags |=IP_VS_CONN_F_SYNC ; state =ntohs (s->v4.state);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 175/516 netfilter: nf_tables: avoid skb access on nf_stolen
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit e34b9ed96ce3b06c79bf884009b16961ca478f87 ]
When verdict is NF_STOLEN, the skb might have been freed.
When tracing is enabled, this can result in a use-after-free:
1. access to skb->nf_trace
2. access to skb->mark
3. computation of trace id
4. dump of packet payload
To avoid 1, keep a cached copy of skb->nf_trace in the trace state struct.
Refresh this copy whenever verdict is != STOLEN.
Avoid 2 by skipping skb->mark access if verdict is STOLEN.
3 is avoided by precomputing the trace id.
Only dump the packet when verdict is not "STOLEN".
Stable-dep-of: 8ec454dcd00c ("ipv6: sr: use skb_get_hash_net() in seg6_make_flowlabel()")
--- include/net/netfilter/nf_tables.h | 16 ++++++----- net/netfilter/nf_tables_core.c | 24 ++++++++++++++--- net/netfilter/nf_tables_trace.c | 44 +++++++++++++++++-------------- 3 files changed, 55 insertions(+), 29 deletions(-)
include/net/netfilter/nf_tables.h +10 -6
@@ -1297,24 +1297,28 @@ void nft_unregister_flowtable_type(struct nf_flowtable_type *type);/** * struct nft_traceinfo - nft tracing information and state * +* @trace: other struct members are initialised +* @nf_trace: copy of skb->nf_trace before rule evaluation +* @type: event type (enum nft_trace_types) +* @skbid: hash of skb to be used as trace id +* @packet_dumped: packet headers sent in a previous traceinfo message * @pkt: pktinfo currently processed * @basechain: base chain currently processed * @chain: chain currently processed * @rule: rule that was evaluated * @verdict: verdict given by rule -* @type: event type (enum nft_trace_types) -* @packet_dumped: packet headers sent in a previous traceinfo message -* @trace: other struct members are initialised */ struct nft_traceinfo { +bool trace; +bool nf_trace; +bool packet_dumped; +enum nft_trace_types type:8 ; +u32 skbid;const struct nft_pktinfo *pkt;const struct nft_base_chain *basechain;const struct nft_chain *chain;const struct nft_rule *rule;const struct nft_verdict *verdict; -enum nft_trace_types type; -bool packet_dumped; -bool trace; }; void nft_trace_init(struct nft_traceinfo *info, const struct nft_pktinfo *pkt,
net/netfilter/nf_tables_core.c +21 -3
@@ -25,9 +25,7 @@ static noinline void __nft_trace_packet(struct nft_traceinfo *info, const struct nft_chain *chain, enum nft_trace_types type) { -const struct nft_pktinfo *pkt = info->pkt; - -if (!info->trace || !pkt->skb->nf_trace) + if (!info->trace || !info->nf_trace) return; info->chain = chain;
@@ -42,11 +40,24 @@ static inline void nft_trace_packet(struct nft_traceinfo *info, enum nft_trace_types type) {if (static_branch_unlikely (&nft_trace_enabled)) { +const struct nft_pktinfo *pkt = info->pkt; + + info->nf_trace = pkt->skb->nf_trace; info->rule = rule;__nft_trace_packet (info, chain, type); } } +static inline void nft_trace_copy_nftrace (struct nft_traceinfo *info) +{ +if (static_branch_unlikely (&nft_trace_enabled)) { +const struct nft_pktinfo *pkt = info->pkt; + +if (info->trace) + info->nf_trace = pkt->skb->nf_trace; + } +} +static void nft_bitwise_fast_eval (const struct nft_expr *expr,struct nft_regs *regs) {
@@ -85,6 +96,7 @@ static noinline void __nft_trace_verdict(struct nft_traceinfo *info,const struct nft_chain *chain, const struct nft_regs *regs) { + const struct nft_pktinfo *pkt = info->pkt;enum nft_trace_types type;switch (regs->verdict.code) {
@@ -92,8 +104,13 @@ static noinline void __nft_trace_verdict(struct nft_traceinfo *info,case NFT_RETURN : type =NFT_TRACETYPE_RETURN ;break ; +case NF_STOLEN : + type =NFT_TRACETYPE_RULE ; +/* can't access skb->nf_trace; use copy */ +break ;default : type =NFT_TRACETYPE_RULE ; + info->nf_trace = pkt->skb->nf_trace;break ; }
@@ -244,6 +261,7 @@ nft_do_chain(struct nft_pktinfo *pkt, void *priv)switch (regs.verdict.code) {case NFT_BREAK : regs.verdict.code =NFT_CONTINUE ; +nft_trace_copy_nftrace (&info);continue ;case NFT_CONTINUE : nft_trace_packet(&info, chain, rule,
net/netfilter/nf_tables_trace.c +24 -20
91 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 176/516 net: add and use skb_get_hash_net
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit b975d3ee5962237c1e2f5d5aeeaaf0dc2173486c ]
Years ago flow dissector gained ability to delegate flow dissection to a bpf program, scoped per netns.
Unfortunately, skb_get_hash() only gets an sk_buff argument instead of both net+skb. This means the flow dissector needs to obtain the netns pointer from somewhere else.
The netns is derived from skb->dev, and if that is not available, from skb->sk. If neither is set, we hit a (benign) WARN_ON_ONCE().
Trying both dev and sk covers most cases, but not all, as recently reported by Christoph Paasch.
In case of nf-generated tcp reset, both sk and dev are NULL:
WARNING: .. net/core/flow_dissector.c:1104
skb_flow_dissect_flow_keys include/linux/skbuff.h:1536 [inline] skb_get_hash include/linux/skbuff.h:1578 [inline] nft_trace_init+0x7d/0x120 net/netfilter/nf_tables_trace.c:320 nft_do_chain+0xb26/0xb90 net/netfilter/nf_tables_core.c:268 nft_do_chain_ipv4+0x7a/0xa0 net/netfilter/nft_chain_filter.c:23 nf_hook_slow+0x57/0x160 net/netfilter/core.c:626 __ip_local_out+0x21d/0x260 net/ipv4/ip_output.c:118 ip_local_out+0x26/0x1e0 net/ipv4/ip_output.c:127 nf_send_reset+0x58c/0x700 net/ipv4/netfilter/nf_reject_ipv4.c:308 nft_reject_ipv4_eval+0x53/0x90 net/ipv4/netfilter/nft_reject_ipv4.c:30 [..]
syzkaller did something like this:
table inet filter {
chain input {
type filter hook input priority filter; policy accept; meta nftrace set 1
tcp dport 42 reject with tcp reset
}
chain output {
type filter hook output priority filter; policy accept; # empty chain is enough
}
}
... then sends a tcp packet to port 42.
Initial attempt to simply set skb->dev from nf_reject_ipv4 doesn't cover all cases: skbs generated via ipv4 igmp_send_report trigger similar splat.
Moreover, Pablo Neira found that nft_hash.c uses __skb_get_hash_symmetric() which would trigger same warn splat for such skbs.
Lets allow callers to pass the current netns explicitly. The nf_trace infrastructure is adjusted to use the new helper.
__skb_get_hash_symmetric is handled in the next patch.
Stable-dep-of: 8ec454dcd00c ("ipv6: sr: use skb_get_hash_net() in seg6_make_flowlabel()")
--- include/linux/skbuff.h | 12 ++++++++++-- net/core/flow_dissector.c | 15 +++++++++++---- net/netfilter/nf_tables_trace.c | 2 +- 3 files changed, 22 insertions(+), 7 deletions(-)
include/linux/skbuff.h +10 -2
@@ -1282,7 +1282,7 @@ __skb_set_sw_hash(struct sk_buff *skb, __u32 hash, bool is_l4)__skb_set_hash (skb, hash, true, is_l4); } -void __skb_get_hash (struct sk_buff *skb); +void __skb_get_hash_net (const struct net *net,struct sk_buff *skb);u32 __skb_get_hash_symmetric (const struct sk_buff *skb);u32 skb_get_poff (const struct sk_buff *skb); u32 __skb_get_poff(const struct sk_buff *skb, void *data,
@@ -1363,10 +1363,18 @@ void skb_flow_dissect_hash(const struct sk_buff *skb,struct flow_dissector *flow_dissector, void *target_container); +static inline __u32 skb_get_hash_net (const struct net *net,struct sk_buff *skb) +{ +if (!skb->l4_hash && !skb->sw_hash) +__skb_get_hash_net (net, skb); + +return skb->hash; +} +static inline __u32 skb_get_hash (struct sk_buff *skb) {if (!skb->l4_hash && !skb->sw_hash) -__skb_get_hash (skb); +__skb_get_hash_net (NULL , skb);return skb->hash; }
net/core/flow_dissector.c +11 -4
@@ -1660,7 +1660,8 @@ u32 __skb_get_hash_symmetric(const struct sk_buff *skb)EXPORT_SYMBOL_GPL (__skb_get_hash_symmetric);/** -* __skb_get_hash: calculate a flow hash +* __skb_get_hash_net: calculate a flow hash +* @net: associated network namespace, derived from @skb if NULL * @skb: sk_buff to calculate flow hash from * * This function calculates a flow hash based on src/dst addresses
@@ -1668,18 +1669,24 @@ EXPORT_SYMBOL_GPL(__skb_get_hash_symmetric);* on success, zero indicates no valid hash. Also, sets l4_hash in skb * if hash is a canonical 4-tuple hash over transport ports. */ -void __skb_get_hash (struct sk_buff *skb) +void __skb_get_hash_net (const struct net *net,struct sk_buff *skb) {struct flow_keys keys;u32 hash; +memset (&keys,0 ,sizeof (keys)); + +__skb_flow_dissect (net, skb, &flow_keys_dissector, + &keys,NULL ,0 ,0 ,0 , +FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL ); +__flow_hash_secret_init (); - hash =___skb_get_hash (skb, &keys, &hashrnd); + hash =__flow_hash_from_keys (&keys, &hashrnd);__skb_set_sw_hash (skb, hash,flow_keys_have_l4 (&keys)); } -EXPORT_SYMBOL (__skb_get_hash); +EXPORT_SYMBOL (__skb_get_hash_net);__u32 skb_get_hash_perturb (const struct sk_buff *skb,const siphash_key_t *perturb)
net/netfilter/nf_tables_trace.c +1 -1
@@ -289,7 +289,7 @@ void nft_trace_init(struct nft_traceinfo *info, const struct nft_pktinfo *pkt,net_get_random_once (&trace_key,sizeof (trace_key)); info->skbid = (u32 )siphash_3u32 (hash32_ptr (skb), -skb_get_hash (skb), +skb_get_hash_net (nft_net (pkt), skb), skb->skb_iif, &trace_key); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 177/516 ipv6: sr: use skb_get_hash_net() in seg6_make_flowlabel()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 8ec454dcd00ce3375119111c6394964455b36d0d ]
Since commit d58e468b1112 ("flow_dissector: implements flow dissector BPF hook") __skb_flow_dissect() needs a net pointer, either from skb->dev, skb->sk, or since commit 3cbf4ffba5ee ("net: plumb network namespace into __skb_flow_dissect") a caller provided pointer.
syzbot was able to reach seg6_make_flowlabel() with an skb having neither skb->dev nor skb->sk set: a TIPC UDP bearer sends a discovery message through an IPv4 route using seg6 encap, while net.ipv6.seg6_flowlabel is set to 1.
seg6_make_flowlabel() already has a net pointer, use skb_get_hash_net().
WARNING: net/core/flow_dissector.c:1131 at __skb_flow_dissect+0x910/0x5368 net/core/flow_dissector.c:1126, CPU#0: syz.0.17/4930 Call trace: __skb_flow_dissect+0x910/0x5368 net/core/flow_dissector.c:1126 (P) __skb_get_hash_net+0xe0/0x29c net/core/flow_dissector.c:1903 skb_get_hash include/linux/skbuff.h:1663 [inline] seg6_make_flowlabel+0xcc/0x1ec net/ipv6/seg6_iptunnel.c:132 __seg6_do_srh_encap+0x320/0xbf4 net/ipv6/seg6_iptunnel.c:161 seg6_do_srh+0x4b4/0xa44 net/ipv6/seg6_iptunnel.c:431 seg6_output_core+0x164/0x688 net/ipv6/seg6_iptunnel.c:681 seg6_output+0x44/0x1ac net/ipv6/seg6_iptunnel.c:744 lwtunnel_output+0x3d0/0x664 net/core/lwtunnel.c:356 dst_output include/net/dst.h:470 [inline] ip_local_out+0x110/0x148 net/ipv4/ip_output.c:131 iptunnel_xmit+0x50c/0xd38 net/ipv4/ip_tunnel_core.c:97 udp_tunnel_xmit_skb+0x220/0x348 net/ipv4/udp_tunnel_core.c:187 tipc_udp_xmit+0x75c/0x9c0 net/tipc/udp_media.c:202 tipc_udp_send_msg+0x214/0x374 net/tipc/udp_media.c:274 tipc_bearer_xmit_skb+0x260/0x3b0 net/tipc/bearer.c:576 tipc_enable_bearer net/tipc/bearer.c:366 [inline] __tipc_nl_bearer_enable+0xc90/0xfb0 net/tipc/bearer.c:1048 tipc_nl_bearer_enable+0x2c/0x48 net/tipc/bearer.c:1057 genl_family_rcv_msg_doit+0x1e4/0x2d4 net/netlink/genetlink.c:1114
--- net/ipv6/seg6_iptunnel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/seg6_iptunnel.c +1 -1
@@ -113,7 +113,7 @@ static __be32 seg6_make_flowlabel(struct net *net, struct sk_buff *skb,u32 hash;if (do_flowlabel >0 ) { - hash =skb_get_hash (skb); + hash =skb_get_hash_net (net, skb); hash =rol32 (hash,16 ); flowlabel = (__force __be32 )hash &IPV6_FLOWLABEL_MASK ; }else if (!do_flowlabel && skb->protocol ==htons (ETH_P_IPV6 )) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 178/516 i2c: at91: release DMA channels when probe defers
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongjian Dai <[email protected]>
[ Upstream commit c98bf3b86609a18ab16d067280257326e557c636 ]
at91_twi_probe_master() can return -EPROBE_DEFER from at91_init_twi_recovery_info() after at91_twi_configure_dma() has already claimed the tx/rx DMA channels. at91_twi_probe() then returns without releasing them, and since dma_request_chan() is not devres-managed the channels leak on every deferred probe attempt.
Release the channels before deferring the probe.
--- drivers/i2c/busses/i2c-at91-master.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-at91-master.c +7 -1
@@ -920,8 +920,14 @@ int at91_twi_probe_master(struct platform_device *pdev,at91_calc_twi_clock (dev); rc =at91_init_twi_recovery_info (pdev, dev); -if (rc == -EPROBE_DEFER ) +if (rc == -EPROBE_DEFER ) { +/* +* The DMA channels were already set up above, release them +* before deferring the probe so they are not leaked. +*/ +at91_twi_dma_release (dev);return rc; + } dev->adapter.algo = &at91_twi_algorithm; dev->adapter.quirks = &at91_twi_quirks;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 179/516 PCI: Accept AtomicOps already enabled by the hypervisor
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikola Prica <[email protected]>
[ Upstream commit 40cce45b921f7930886bcba43069edc579725457 ]
pci_enable_atomic_ops_to_root() currently fails when no Root Port is visible. That is common in passthrough guests (ESXi, Hyper-V): the Endpoint is assigned to the VM, but the Root Port above it is not visible in the guest topology.
In those setups the hypervisor may already have enabled AtomicOp Requester Enable on the device. If PCI_EXP_DEVCTL2_ATOMIC_REQ is set, treat AtomicOps as already enabled and return success instead of failing the Root Port walk.
After 1ae8c4ce1570 ("PCI: Enable AtomicOps only if Root Port supports them"), pci_enable_atomic_ops_to_root() always returns failure if the Root Port is not visible, so drivers don't use atomics when they could. On systems where the Root Port is not visible but *does* support AtomicOps, this is a regression: prior to 1ae8c4ce1570, it enabled AtomicOps in the endpoint and returned success.
--- drivers/pci/pci.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/pci/pci.c +14 -1
@@ -3598,8 +3598,21 @@ int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask) } root =pcie_find_root_port (dev); -if (!root) +if (!root) { + +/* +* A hypervisor may expose a topology with the root port +* not visible to the guest. If the hypervisor has already +* set AtomicOp Requester Enable in the endpoint, we assume +* it has verified support in the root port, so it is safe +* for the driver to use AtomicOps. +*/ +pcie_capability_read_dword (dev,PCI_EXP_DEVCTL2 , &ctl2); +if (ctl2 &PCI_EXP_DEVCTL2_ATOMIC_REQ ) +return 0 ; +return -EINVAL ; + }pcie_capability_read_dword (root,PCI_EXP_DEVCAP2 , &cap);if ((cap & cap_mask) != cap_mask)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 180/516 drm/radeon: Read the VRAM VBIOS signature with readb()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Kaloz <[email protected]>
commit de1eab13efef83fd2b76f4688de5bf672644596f upstream.
igp_read_bios_from_vram() checked bios[0]/bios[1] with a plain __iomem load, which faults on sparc64 before the copy runs at all. radeon_read_bios() already reads its two signature bytes with readb() ahead of its own copy; use the same accessor here, keeping the check before the allocation.
--- drivers/gpu/drm/radeon/radeon_bios.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_bios.c +5 -1
@@ -49,6 +49,7 @@static bool igp_read_bios_from_vram (struct radeon_device *rdev) {uint8_t __iomem *bios; +uint8_t val1, val2;resource_size_t vram_base;resource_size_t size =256 *1024 ;/* ??? */
@@ -63,7 +64,10 @@ static bool igp_read_bios_from_vram(strureturn false; } -if (size ==0 || bios[0 ] !=0x55 || bios[1 ] !=0xaa ) { + val1 =readb (&bios[0 ]); + val2 =readb (&bios[1 ]); + +if (size ==0 || val1 !=0x55 || val2 !=0xaa ) {iounmap (bios);return false; }
Greg Kroah-Hartman
maintainerPATCH 181/516 kgdboc: Fix tty driver reference leak in configure_kgdboc()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit ef3134cd0d4831ae2137aee2883987859b80b2c6 upstream.
tty_find_polling_driver() returns the tty driver with an extra reference taken by tty_driver_kref_get(). configure_kgdboc() stores it in kgdb_tty_driver but the reference is never dropped: it is leaked when kgdb_register_io_module() fails, when the configuration is cleared, and on every reconfigure.
Release the reference both when unconfiguring and on the error path.
--- drivers/tty/serial/kgdboc.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/tty/serial/kgdboc.c +9 -0
@@ -190,6 +190,11 @@ static void cleanup_kgdboc(void)return ;kgdboc_unregister_kbd ();kgdb_unregister_io_module (&kgdboc_io_ops); + +if (kgdb_tty_driver) { +tty_driver_kref_put (kgdb_tty_driver); + kgdb_tty_driver =NULL ; + } }static int configure_kgdboc (void )
@@ -250,6 +255,10 @@ nmi_con_failed:kgdb_unregister_io_module (&kgdboc_io_ops); noconfig:kgdboc_unregister_kbd (); +if (kgdb_tty_driver) { +tty_driver_kref_put (kgdb_tty_driver); + kgdb_tty_driver =NULL ; + } configured =0 ;return err;
Greg Kroah-Hartman
maintainerPATCH 182/516 Input: atkbd - skip deactivate for Lenovo IdeaPad Slim 3 15IWC11
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martino Papero <[email protected]>
commit 3bf8d603fd45649c106cae6290a10f20b1bbb569 upstream.
The internal keyboard on the Lenovo IdeaPad Slim 3 15IWC11 (83RR) does not work correctly with the default i8042 settings. Using i8042.nopnp=1 and i8042.dumbkbd=1 restores keyboard input, but prevents the Caps Lock LED from working. Using i8042.nopnp=1 alone does not fix the keyboard.
The laptop works correctly when atkbd_deactivate_fixup is used instead. Add a DMI quirk for the 83RR to enable it.
This was tested without any i8042 command-line parameters. Keyboard input and the Caps Lock LED work correctly, including after suspend and resume and after a cold boot.
--- drivers/input/keyboard/atkbd.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/input/keyboard/atkbd.c +8 -0
@@ -1955,6 +1955,14 @@ static const struct dmi_system_id atkbd_ .callback = atkbd_deactivate_fixup, }, { +/* Lenovo IdeaPad Slim 3 15IWC11 (83RR) */ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"LENOVO" ), + DMI_MATCH(DMI_PRODUCT_NAME, "83RR"), + }, + .callback = atkbd_deactivate_fixup, + }, + {/* Xiaomi Book Pro 14 (TM2424) */ .matches = { DMI_MATCH(DMI_SYS_VENDOR, "XIAOMI"),
Greg Kroah-Hartman
maintainerPATCH 183/516 Input: i8042 - add nomux quirk for Fujitsu LIFEBOOK U7410
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lovekesh Solanki <[email protected]>
commit 495cd7f858b45d2ffa9b685bba3a8c23c1ca4dd3 upstream.
On the Fujitsu LIFEBOOK U7410 the internal keyboard and touchpad die shortly after boot if i8042 multiplexing controller is probed and switched to muxed mode. These multiplexing setup commands disturb the EC emulated keyboard and atkbd reports "Spurious ACK" and "Unknown key pressed" warnings, after which both keyboard and touchpad stop delivering events. Both touchpad and keyboard work in BIOS and GRUB.
Disabling multiplexer using i8042.nomux=1 makes both devices work on warm/cold boot.
Add a DMI quirk to force nomux mode for this model.
--- drivers/input/serio/i8042-acpipnpio.h | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/input/serio/i8042-acpipnpio.h +9 -0
@@ -661,6 +661,15 @@ static const struct dmi_system_id i8042_ .driver_data = (void *)(SERIO_QUIRK_NOAUX) }, { +/* Fujitsu LIFEBOOK U7410 */ +/* Mux mode also disturbs the EC keyboard, causing spurious ACKs */ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"FUJITSU CLIENT COMPUTING LIMITED" ), + DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK U7410"), + }, + .driver_data = (void *)(SERIO_QUIRK_NOMUX ) + }, + {/* Gigabyte M912 */ .matches = { DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
Greg Kroah-Hartman
maintainerPATCH 184/516 Input: synaptics - add LEN205b entry to smbus_pnp_ids for ThinkPad T490
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lovekesh Solanki <[email protected]>
commit a961417c5ae77bbb728a23d9577ecd8f4d8a4b5a upstream.
Lenovo ThinkPad T490 has a Synaptics Touchpad that supports SMBus/RMI4 mode, but is not listed in smbus_pnp_ids table.
Add LEN205b to smbus_pnp_ids[] passlist.
--- drivers/input/mouse/synaptics.c | 1 + 1 file changed, 1 insertion(+)
drivers/input/mouse/synaptics.c +1 -0
@@ -188,6 +188,7 @@ static const char * const smbus_pnp_ids["LEN2054" ,/* E480 */ "LEN2055" ,/* E580 */ "LEN2058" ,/* E490 */ +"LEN205b" ,/* T490 */ "LEN2068" ,/* T14 Gen 1 */ "SYN1221" ,/* TUXEDO InfinityBook Pro 14 v5 */ "SYN3003", /* HP EliteBook 850 G1 */
Greg Kroah-Hartman
maintainerPATCH 185/516 Input: synaptics - limit T440p InterTouch quirk to LEN0036
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raphaël Larocque <[email protected]>
commit f0fd8993082ca229faa3f9844f1c9fe182eca20b upstream.
The ThinkPad L440 also uses board id 2722, but does not have the SMBus initialization problem seen on the T440p. On the L440, the SMBus companion becomes available shortly after psmouse probes, allowing the touchpad to use SMBus/RMI4 normally.
The T440p's quirk is currently applied to all Synaptics touchpads with board id 2722, unnecessarily disabling SMBus InterTouch on the L440, as reported by Daniel Salmun.
Restrict the quirk to PNP ID LEN0036, which identifies the T440p, so that other devices sharing board id 2722 retain their normal SMBus/RMI4 operation.
--- drivers/input/mouse/synaptics.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/input/mouse/synaptics.c +4 -2
@@ -1806,8 +1806,10 @@ static int synaptics_setup_intertouch(streturn -ENXIO ; } -/* Disable intertouch on known-broken board revisions */ -if (info->board_id ==2722 ) { +/* Disable intertouch on known-broken T440p board revisions */ +if (info->board_id ==2722 && +psmouse_matches_pnp_id (psmouse, + (const char *const []){"LEN0036" ,NULL })) {psmouse_info (psmouse,"Disabling intertouch for board id %u\n" , info->board_id);
Greg Kroah-Hartman
maintainerPATCH 186/516 nitro_enclaves: fix use-after-free on SLOT_ALLOC failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuxiao Wang <[email protected]>
commit 9bc184a2eda8b773c88ecbff934001ad649b9cc1 upstream.
When ne_create_vm_ioctl() fails the SLOT_ALLOC request after anon_inode_getfile() has succeeded, the error path calls fput(enclave_file) and then frees ne_enclave.
In normal userspace context, fput() defers the final __fput() via task_work. ne_enclave_release() therefore runs after ne_enclave has already been freed and dereferences ne_enclave->slot_uid, causing a
use-after-free: KASAN: slab-use-after-free in ne_enclave_release.
The enclave has no slot allocated and is not yet linked into the enclaves list on this error path, so ne_enclave_release() is expected to return early when slot_uid is zero. However, reading slot_uid already accesses the freed object.
Clear enclave_file->private_data before fput() on the error path. ne_enclave_release() then returns immediately when private_data is NULL, leaving the ioctl error path as the sole owner of ne_enclave. This is safe because the file has not been fd_install()'d yet.
Tested on an AWS EC2 m5.2xlarge with CONFIG_KASAN=y. Without the patch, the reproducer triggers a KASAN slab-use-after-free on every SLOT_ALLOC failure. With the patch, no KASAN report is produced and the SLOT_ALLOC error is still returned. Normal enclave creation and teardown are unaffected.
--- drivers/virt/nitro_enclaves/ne_misc_dev.c | 1 + 1 file changed, 1 insertion(+)
drivers/virt/nitro_enclaves/ne_misc_dev.c +1 -0
@@ -1653,6 +1653,7 @@ static int ne_create_vm_ioctl(struct ne_return enclave_fd; put_file: + enclave_file->private_data =NULL ;fput (enclave_file); put_fd:put_unused_fd (enclave_fd);
Greg Kroah-Hartman
maintainerPATCH 187/516 USB: cdc-acm: fix racy TIOCMIWAIT implementation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit be4219dd98608736e13e0b790ef742b76a13254d upstream.
Check the wakeup condition after adding the task to the waitqueue and updating the task state to avoid missing a racing modem status update or disconnect.
Store the old icount on entry and do not update it in the completion handler to avoid missing events or reporting spurious ones (due to modem status changes before TIOCMIWAIT was called).
--- drivers/usb/class/cdc-acm.c | 36 +++++++++++++++++++----------------- drivers/usb/class/cdc-acm.h | 1 - 2 files changed, 19 insertions(+), 18 deletions(-)
drivers/usb/class/cdc-acm.c +19 -17
@@ -320,7 +320,6 @@ static void acm_process_notification(str difference = acm->ctrlin ^ newctrl;spin_lock_irqsave (&acm->read_lock, flags); acm->ctrlin = newctrl; - acm->oldcount = acm->iocount;if (difference &ACM_CTRL_DSR ) acm->iocount.dsr++;
@@ -994,11 +993,16 @@ static int wait_serial_change(struct acmDECLARE_WAITQUEUE (wait, current);struct async_icount old, new; - do { +spin_lock_irq (&acm->read_lock); + old = acm->iocount; +spin_unlock_irq (&acm->read_lock); + +add_wait_queue (&acm->wioctl, &wait); +for (;;) { +set_current_state (TASK_INTERRUPTIBLE ); +spin_lock_irq (&acm->read_lock); - old = acm->oldcount; new = acm->iocount; - acm->oldcount = new;spin_unlock_irq (&acm->read_lock); if ((arg & TIOCM_DSR) &&
@@ -1011,22 +1015,20 @@ static int wait_serial_change(struct acm old.rng != new.rng)break ; -add_wait_queue (&acm->wioctl, &wait); -set_current_state (TASK_INTERRUPTIBLE ); -schedule (); -remove_wait_queue (&acm->wioctl, &wait);if (acm->disconnected) { -if (arg &TIOCM_CD ) -break ; -else - rv = -ENODEV ; - }else { -if (signal_pending (current)) - rv = -ERESTARTSYS ; + rv = -ENODEV ; +break ; } - }while (!rv); - +schedule (); + +if (signal_pending (current)) { + rv = -ERESTARTSYS ; +break ; + } + } +__set_current_state (TASK_RUNNING ); +remove_wait_queue (&acm->wioctl, &wait);return rv; }
drivers/usb/class/cdc-acm.h +0 -1
@@ -118,7 +118,6 @@ struct acm {unsigned int ctrlin;/* input control lines (DCD, DSR, RI, break, overruns) */ unsigned int ctrlout;/* output control lines (DTR, RTS) */ struct async_icount iocount;/* counters for control line changes */ -struct async_icount oldcount;/* for comparison of counter */ wait_queue_head_t wioctl;/* for ioctl */ unsigned int writesize;/* max packet size for the output bulk endpoint */ unsigned int readsize,ctrlsize;/* buffer sizes for freeing */
Greg Kroah-Hartman
maintainerPATCH 188/516 USB: serial: fix port tear down use-after-free
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 33c920f7c5952dfc42d1b8ea6efe16b1f0bb0c5b upstream.
Some drivers for multiport devices access port driver data from completion handlers of shared URBs submitted at attach() or first open() and stopped at disconnect() or last close(), respectively.
A simple NULL check before accessing the driver data makes sure that a port state container has at least been allocated, but a completion handler can still race with port tear down.
Reorder the disconnect handling so that ports are not deregistered (and their driver data freed) until after all ports have been hung up and the driver disconnect() callback has run so that all I/O has been stopped.
--- drivers/usb/serial/usb-serial.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/usb/serial/usb-serial.c +7 -2
@@ -1098,12 +1098,17 @@ static void usb_serial_disconnect(structusb_serial_port_poison_urbs (port);wake_up_interruptible (&port->port.delta_msr_wait);cancel_work_sync (&port->work); -if (device_is_registered (&port->dev)) -device_del (&port->dev); } +if (serial->type->disconnect) serial->type->disconnect (serial); +for (i =0 ; i < serial->num_ports; ++i) { + port = serial->port[i]; +if (device_is_registered (&port->dev)) +device_del (&port->dev); + } +/* let the last holder of this object cause it to be cleaned up */ usb_serial_put (serial);dev_info (dev,"device disconnected\n" );
Greg Kroah-Hartman
maintainerPATCH 189/516 usb: storage: sierra_ms: reject short SWoC info transfers
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Syed Labeeq Sajid Bukhari <[email protected]>
commit 8a0200d14acd9db388b85cd016e68a4e60d900ec upstream.
sierra_get_swoc_info() requests sizeof(struct swoc_info) (60) bytes from the device via usb_control_msg(), but its callers only treat a negative return value as failure. A device that answers the vendor-specific GetSwocInfo request with a short IN transfer is therefore accepted, leaving the tail of the freshly allocated (kmalloc(), non-zeroing) swoc_info buffer uninitialized.
truinst_show() subsequently prints swocInfo->rev, swocInfo->LinuxSKU and swocInfo->LinuxVer from that buffer into the world-readable (0444) "truinst" sysfs attribute. An emulated/malicious USB device (VID 0x1199, PID 0x0fff) can exploit this to disclose up to 5 bytes of stale kernel heap memory (kmalloc-64) to unprivileged userspace, once per sysfs read, indefinitely. On kernels built without init_on_alloc this leaks recently freed heap contents.
Only accept the transfer when the full structure was received. sierra_ms_init() already retries failed queries, so well-behaved devices are unaffected.
--- drivers/usb/storage/sierra_ms.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/storage/sierra_ms.c +7 -0
@@ -77,6 +77,13 @@ static int sierra_get_swoc_info(struct usizeof (struct swoc_info ),/* __u16 size */ USB_CTRL_SET_TIMEOUT); /* int timeout */ +/* +* A short IN transfer leaves the tail of swocInfo uninitialized; +* only a full transfer is valid. +*/ +if (result !=sizeof (struct swoc_info )) +return -EIO ; + swocInfo->LinuxSKU =le16_to_cpu (swocInfo->LinuxSKU); swocInfo->LinuxVer =le16_to_cpu (swocInfo->LinuxVer);return result;
Greg Kroah-Hartman
maintainerPATCH 190/516 usb: hub: use shorter 120ms post resume hold for SS root hubs
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lovekesh Solanki <[email protected]>
commit 29480b05e6e226594dc11ccf2a036fbd5cdd0e42 upstream.
Holding a USB3 hub PM runtime reference for 200ms at hub resume triggers an AMD platform issue. Users running Android adb report crashes after adb has been polling and waking up the USB subsystem once a second for some time. Vendors are working on a solution. Disabling USB runtime PM is one way to prevent this issue, but it is also proven that reducing the hold time to 120ms in resume also mitigates it. See Link for more details.
Reducing the hold time to 120ms for the USB3 roothub is in itself a valid change and optimization, as the current 200ms is excessive: a root hub has no upstream suspended hub whose wake propagation needs to be accounted for, but still need some time for USB3 link training to complete.
Keep the 200ms hold for external hubs that commit 8f5b7e2bec1c ("usb: hub: fix detection of high tier USB3 devices behind suspended hubs") is intended for.
--- drivers/usb/core/hub.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/usb/core/hub.c +6 -1
@@ -56,8 +56,11 @@/* * Give SS hubs 200ms time after wake to train downstream links before * assuming no port activity and allowing hub to runtime suspend back. +* Root hubs have no upstream hub whose wake propagation needs to be +* accounted for, so they need less time, use 120ms for them. */ #define USB_SS_PORT_U0_WAKE_TIME 200/* ms */ +#define USB_SS_RH_PORT_U0_WAKE_TIME 120/* ms */ /* Protect struct usb_device->state and ->children members * Note: Both are also protected by ->dev.sem, except that ->state can
@@ -1319,7 +1322,9 @@ static void hub_activate(struct usb_hubqueue_delayed_work (system_power_efficient_wq, &hub->post_resume_work, -msecs_to_jiffies (USB_SS_PORT_U0_WAKE_TIME )); +msecs_to_jiffies (hdev->parent ? +USB_SS_PORT_U0_WAKE_TIME : +USB_SS_RH_PORT_U0_WAKE_TIME ));return ; }
Greg Kroah-Hartman
maintainerPATCH 191/516 usb: ohci-da8xx: disable controller wakeup on cleanup
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
commit 901197dd4c7dcffbf97426487d4c047555c98554 upstream.
The OHCI core marks controllers with RemoteWakeupConnected as wakeup-capable. Probe enables wakeup, but neither removal nor a later notifier registration failure disables it, leaving the wakeup source attached.
Disable controller wakeup after removing the HCD on both paths.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/usb/host/ohci-da8xx.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/host/ohci-da8xx.c +2 -0
@@ -464,6 +464,7 @@ static int ohci_da8xx_probe(struct platf err_remove_hcd:usb_remove_hcd (hcd); +device_wakeup_disable (hcd->self.controller); err:usb_put_hcd (hcd);return error;
@@ -474,6 +475,7 @@ static int ohci_da8xx_remove(struct platstruct usb_hcd *hcd =platform_get_drvdata (pdev);usb_remove_hcd (hcd); +device_wakeup_disable (hcd->self.controller);usb_put_hcd (hcd);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 192/516 usb: ohci-s3c2410: disable controller wakeup on removal
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
commit 8dd8451c527e2a723bca20da5a6d724b8592551f upstream.
Probe enables controller wakeup after the OHCI core marks controllers with RemoteWakeupConnected as wakeup-capable. Removal does not undo this, so the wakeup source can remain attached after driver unbind.
Disable controller wakeup after removing the HCD.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/usb/host/ohci-s3c2410.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/host/ohci-s3c2410.c +1 -0
@@ -338,6 +338,7 @@ ohci_hcd_s3c2410_remove(struct platform_struct usb_hcd *hcd =platform_get_drvdata (dev);usb_remove_hcd (hcd); +device_wakeup_disable (hcd->self.controller);s3c2410_stop_hc (dev);usb_put_hcd (hcd);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 193/516 usb: ohci-st: disable controller wakeup on removal
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
commit 08b2ccd7eb7e41f77a04a09112ca3edcc588e3f0 upstream.
Probe enables controller wakeup after the OHCI core marks controllers with RemoteWakeupConnected as wakeup-capable. Removal does not undo this, so the wakeup source can remain attached after driver unbind.
Disable controller wakeup after removing the HCD.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/usb/host/ohci-st.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/host/ohci-st.c +1 -0
@@ -243,6 +243,7 @@ static int st_ohci_platform_remove(strucint clk;usb_remove_hcd (hcd); +device_wakeup_disable (hcd->self.controller);if (pdata->power_off) pdata->power_off (dev);
Greg Kroah-Hartman
maintainerPATCH 194/516 usb: gadget: f_uac1_legacy: validate bRequest index in generic_{set,get}_cmd
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liu Chao <[email protected]>
commit 9062d50e75c24dc7911be05c9b1719b3b256af15 upstream.
generic_set_cmd() and generic_get_cmd() use the low nibble of ctrl->bRequest as an index into con->data[]:
u8 cmd = (ctrl->bRequest & 0x0F); /* 0 .. 15 */
...
con->data[cmd] = value; /* OOB when cmd >= 5 */struct usb_audio_control (include/linux/usb/audio.h) declares data as a 5-element array, so indices 5 through 15 write (or read) up to 44 bytes past the end of the array on the heap.
A malicious USB host can craft a class-specific SET_CUR / GET_CUR request with an arbitrary bRequest value, triggering the out-of-bounds access from an IRQ completion handler with no further preconditions.
Add an ARRAY_SIZE() guard to both functions.
--- drivers/usb/gadget/function/f_uac1_legacy.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/usb/gadget/function/f_uac1_legacy.c +6 -0
@@ -797,6 +797,9 @@ fail:static int generic_set_cmd (struct usb_audio_control *con,u8 cmd,int value) { +if (cmd >=ARRAY_SIZE (con->data)) +return -EINVAL ; + con->data[cmd] = value;return 0 ;
@@ -804,6 +807,9 @@ static int generic_set_cmd(struct usb_austatic int generic_get_cmd (struct usb_audio_control *con,u8 cmd) { +if (cmd >=ARRAY_SIZE (con->data)) +return -EINVAL ; +return con->data[cmd]; }
Greg Kroah-Hartman
maintainerPATCH 195/516 usb: gadget: aspeed-vhub: cancel wake work on device removal
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
commit 20388c8d1d74c203fec8194c45cd31afdfab934e upstream.
wake_work is armed from the gadget .wakeup callback to resume suspended downstream ports, and it is never cancelled in ast_vhub_remove(), so a work item queued before or during removal can run after devm has freed vhub and its ports, a use-after-free.
Cancelling the work alone is not sufficient: usb_gadget_wakeup() takes no lock and the unbind path never clears wakeup_en, so a remote-wakeup request in flight on another CPU can re-arm the work after the cancel and before vhub is freed.
ast_vhub_del_dev() already clears d->registered under vhub->lock before unregistering the gadget. Refuse the wakeup in ast_vhub_udc_wakeup() once d->registered is clear: the check and the schedule_work() are then atomic against the unbind, so a wakeup that passed before the flag was cleared is drained by the cancel_work_sync() after the del_dev loop, and one that arrives later returns without arming. Also move INIT_WORK() to the top of ast_vhub_probe(), since the probe error path reuses ast_vhub_remove() and would otherwise cancel a never-initialized work item.
This issue was found by an in-house static analysis tool.
--- drivers/usb/gadget/udc/aspeed-vhub/core.c | 4 ++++ drivers/usb/gadget/udc/aspeed-vhub/dev.c | 2 +- drivers/usb/gadget/udc/aspeed-vhub/hub.c | 5 +++-- drivers/usb/gadget/udc/aspeed-vhub/vhub.h | 1 + 4 files changed, 9 insertions(+), 3 deletions(-)
drivers/usb/gadget/udc/aspeed-vhub/core.c +4 -0
@@ -272,6 +272,9 @@ static int ast_vhub_remove(struct platfofor (i =0 ; i < vhub->max_ports; i++)ast_vhub_del_dev (&vhub->ports[i].dev); +/* Final drain; the worker takes vhub->lock, so stay outside of it */ +cancel_work_sync (&vhub->wake_work); +spin_lock_irqsave (&vhub->lock, flags);/* Mask & ack all interrupts */
@@ -332,6 +335,7 @@ static int ast_vhub_probe(struct platforreturn -ENOMEM ;spin_lock_init (&vhub->lock); +INIT_WORK (&vhub->wake_work, ast_vhub_wake_work); vhub->pdev = pdev; vhub->port_irq_mask =GENMASK (VHUB_IRQ_DEV1_BIT + vhub->max_ports -1 ,VHUB_IRQ_DEV1_BIT );
drivers/usb/gadget/udc/aspeed-vhub/dev.c +1 -1
@@ -275,7 +275,7 @@ static int ast_vhub_udc_wakeup(struct usint rc = -EINVAL ;spin_lock_irqsave (&d->vhub->lock, flags); -if (!d->wakeup_en) +if (!d->wakeup_en || !d->registered) goto err;DDBG (d,"Device initiated wakeup\n" );
drivers/usb/gadget/udc/aspeed-vhub/hub.c +3 -2
@@ -532,7 +532,7 @@ void ast_vhub_device_connect(struct ast_ast_vhub_send_host_wakeup (vhub); } -static void ast_vhub_wake_work (struct work_struct *work) +void ast_vhub_wake_work (struct work_struct *work) { struct ast_vhub *vhub = container_of(work, struct ast_vhub,
@@ -562,6 +562,8 @@ static void ast_vhub_wake_work(struct wovoid ast_vhub_hub_wake_all (struct ast_vhub *vhub) { +lockdep_assert_held (&vhub->lock); +/* * A device is trying to wake the world, because this * can recurse into the device, we break the call chain
@@ -1046,7 +1048,6 @@ static int ast_vhub_init_desc(struct astint ast_vhub_init_hub (struct ast_vhub *vhub) { vhub->speed =USB_SPEED_UNKNOWN ; -INIT_WORK (&vhub->wake_work, ast_vhub_wake_work);return ast_vhub_init_desc (vhub); }
drivers/usb/gadget/udc/aspeed-vhub/vhub.h +1 -0
@@ -545,6 +545,7 @@ void ast_vhub_hub_suspend(struct ast_vhuvoid ast_vhub_hub_resume (struct ast_vhub *vhub);void ast_vhub_hub_reset (struct ast_vhub *vhub);void ast_vhub_hub_wake_all (struct ast_vhub *vhub); +void ast_vhub_wake_work (struct work_struct *work);/* dev.c */ int ast_vhub_init_dev (struct ast_vhub *vhub,unsigned int idx);
Greg Kroah-Hartman
maintainerPATCH 196/516 USB: gadget: dummy-hcd: Fix wait for outstanding request completions
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit b263ff9b0fc5c1f371d65c4eb196b31263d039ff upstream.
The dummy-hcd driver emulates synchronize_irq() by waiting until its private callback_usage counter drops to 0 (with the private lock not held). This counter is incremented whenever a gadget driver callback occurs (which requires the private lock to be dropped), but not when a request completion handler is called.
This is an oversight. Request completion is triggered by timer interrupts (emulating device IRQs in a real UDC), and the interrupt handlers are supposed to have completed when the synchronize_irq() emulation routine returns -- they aren't supposed to be in the middle of a completion callback. If this happens it can lead to a gadget driver's unbind routine running before all outstanding request completions have finished, maybe even allowing the gadget driver's module to be unloaded while a completion handler is still running.
Fix the oversight by incrementing the callback_usage value across request completion callbacks.
--- drivers/usb/gadget/udc/dummy_hcd.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/gadget/udc/dummy_hcd.c +4 -0
@@ -339,9 +339,11 @@ static void dummy_giveback(struct dummy {bool fifo = req == &dum->fifo_req; + ++dum->callback_usage;spin_unlock (&dum->lock);usb_gadget_giveback_request (_ep, &req->req);spin_lock (&dum->lock); + --dum->callback_usage;if (fifo) dum->fifo_req_busy =0 ; }
@@ -753,11 +755,13 @@ static int dummy_queue(struct usb_ep *_e req->req.complete = fifo_complete;list_add_tail (&req->queue, &ep->queue); + ++dum->callback_usage;spin_unlock (&dum->lock); _req->actual = _req->length; _req->status =0 ;usb_gadget_giveback_request (_ep, _req);spin_lock (&dum->lock); + --dum->callback_usage; }else list_add_tail (&req->queue, &ep->queue);spin_unlock_irqrestore (&dum->lock, flags);
Greg Kroah-Hartman
maintainerPATCH 197/516 usb: gadget: f_fs: Fix NULL pointer dereference in FUNCTIONFS_ENDPOINT_DESC
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuchao Zhang <[email protected]>
commit 9cd072788c76595529eb38f42bf94d23852f8534 upstream.
When user space sets up FunctionFS with only full-speed descriptors (e.g., flags = FUNCTIONFS_HAS_FS_DESC) and the gadget operates at a higher speed (such as USB_SPEED_HIGH or USB_SPEED_SUPER), config_ep_by_speed() detects that the function lacks descriptors for the current speed, logs a warning, and falls back to full-speed descriptors. The endpoint is then successfully enabled via usb_ep_enable(), and epfile->ep becomes valid.
However, when user space subsequently issues the FUNCTIONFS_ENDPOINT_DESC ioctl to query the endpoint descriptor, ffs_epfile_ioctl() selects the descriptor index solely based on gadget->speed:
switch (epfile->ffs->gadget->speed) {
case USB_SPEED_SUPER:
case USB_SPEED_SUPER_PLUS:
desc_idx = 2;
break;
case USB_SPEED_HIGH:
desc_idx = 1;
break;
default:
desc_idx = 0;
}
desc = epfile->ep->descs[desc_idx];
memcpy(&desc1, desc, desc->bLength);Because user space only supplied full-speed descriptors, epfile->ep->descs[1] is NULL. Dereferencing desc->bLength triggers an immediate kernel NULL pointer dereference panic.
Fix this by falling back through lower speed descriptors if the current speed descriptor was not supplied, matching the fallback logic in config_ep_by_speed() and historical f_fs behavior. If still missing, fall back to epfile->ep->ep->desc (the active descriptor), and return -EINVAL safely if no valid descriptor is found. In addition, mark desc as const to match struct usb_ep::desc and avoid discarding qualifiers.
--- drivers/usb/gadget/function/f_fs.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/usb/gadget/function/f_fs.c +13 -2
@@ -1338,8 +1338,9 @@ static long ffs_epfile_ioctl(struct filebreak ;case FUNCTIONFS_ENDPOINT_DESC : { +const struct usb_endpoint_descriptor *desc; +struct usb_endpoint_descriptor desc1;int desc_idx; -struct usb_endpoint_descriptor desc1, *desc;switch (epfile->ffs->gadget->speed) {case USB_SPEED_SUPER :
@@ -1353,7 +1354,17 @@ static long ffs_epfile_ioctl(struct file desc_idx =0 ; } - desc = epfile->ep->descs[desc_idx]; +do { + desc = epfile->ep->descs[desc_idx]; + }while (!desc && --desc_idx >=0 ); + +if (!desc) + desc = epfile->ep->ep->desc; +if (!desc) { + ret = -EINVAL ; +break ; + } +memcpy (&desc1, desc, desc->bLength);spin_unlock_irq (&epfile->ffs->eps_lock);
Greg Kroah-Hartman
maintainerPATCH 198/516 usb: core: clear both ep_in and ep_out for non-ep0 control endpoints
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Peng <[email protected]>
commit 0e8baa78d872f2db440d8b9ded946ab8dceb89eb upstream.
In usb_enable_endpoint(), non-zero control endpoints (where usb_endpoint_xfer_control(&ep->desc) is true) populate both dev->ep_in[epnum] and dev->ep_out[epnum] with the same struct usb_host_endpoint pointer.
However, usb_disable_endpoint() only clears either dev->ep_out[epnum] or dev->ep_in[epnum] depending on the direction bit of epaddr when reset_hardware is set, leaving the opposite direction's array slot pointing to the disabled/freed endpoint.
Clear both dev->ep_out[epnum] and dev->ep_in[epnum] when disabling a non-ep0 control endpoint with reset_hardware set, and update the function kerneldoc accordingly.
Tested in QEMU against Linux 7.3.0-rc3 using dummy_hcd and raw-gadget to enumerate a USB device with a non-zero control endpoint (bEndpointAddress 0x01, bmAttributes USB_ENDPOINT_XFER_CONTROL), verifying that both dev->ep_in[1] and dev->ep_out[1] are cleared when the interface is disabled.
--- drivers/usb/core/message.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/core/message.c +7 -1
@@ -1329,7 +1329,8 @@ static void remove_intf_ep_devs(struct u* * Disables the endpoint for URB submission and nukes all pending URBs. * If @reset_hardware is set then also deallocates hcd/hardware state -* for the endpoint. +* for the endpoint (clearing both ep_in and ep_out pointers for +* bidirectional non-ep0 control endpoints). */ void usb_disable_endpoint (struct usb_device *dev,unsigned int epaddr,bool reset_hardware)
@@ -1350,6 +1351,11 @@ void usb_disable_endpoint(struct usb_dev dev->ep_in[epnum] =NULL ; }if (ep) { +if (reset_hardware && epnum !=0 && +usb_endpoint_xfer_control (&ep->desc)) { + dev->ep_out[epnum] =NULL ; + dev->ep_in[epnum] =NULL ; + } ep->enabled =0 ;usb_hcd_flush_endpoint (dev, ep);if (reset_hardware)
Greg Kroah-Hartman
maintainerPATCH 199/516 usb: typec: ucsi: Get the connector fwnode based on reg value
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prashanth K <[email protected]>
commit 6c51f09c6db5868a5090e8dd4d7764660c87f1ad upstream.
ucsi_find_fwnode() currently maps UCSI connectors to Device tree connector nodes based on the order in which connector child nodes are described in DT.
This can fail because the ordering of child nodes isn't guaranteed in Device-tree. For example, DTB may contain connector@1 before connector@0, causing connector numbers to be associated with the wrong fwnode. As a result, role switch and Type-C notifications can be delivered to the wrong remote endpoints.
Fix this by using the "reg" property of each connector to match its corresponding fwnode. While at it, if the reg property isn't present, then fall back to the old method.
--- drivers/usb/typec/ucsi/ucsi.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/usb/typec/ucsi/ucsi.c +14 -3
@@ -1060,10 +1060,21 @@ static struct fwnode_handle *ucsi_find_f {struct fwnode_handle *fwnode;int i =1 ; +int ret; +u32 port; -device_for_each_child_node (con->ucsi->dev, fwnode) -if (i++ == con->num) -return fwnode; +device_for_each_child_node (con->ucsi->dev, fwnode) { + ret =fwnode_property_read_u32 (fwnode,"reg" , &port); +if (ret <0 ) { +if (i == con->num) +return fwnode; + }else { +if (port == con->num -1 ) +return fwnode; + } + + i++; + }return NULL ; }
Greg Kroah-Hartman
maintainerPATCH 200/516 usb: typec: ucsi: displayport: Current CAM OOB index fixup
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jameson Thies <[email protected]>
commit ea31c6498c61307dc0d8ce338a7f268cb8cbdd57 upstream.
Update ucsi_displayport_enter() to return invalid error when the PPM reports an current alternate mode greater than or equal to UCSI_MAX_ALTMODES. While here, remove 0xff current cam assignment on failed GET_CURRENT_CAM response.
--- drivers/usb/typec/ucsi/displayport.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/usb/typec/ucsi/displayport.c +6 -3
@@ -69,11 +69,14 @@ static int ucsi_displayport_enter(structif (ret <0 ) {if (ucsi->version >0x0100 ) goto err_unlock; - cur =0xff ; } -if (cur <UCSI_MAX_ALTMODES ) { - ret = dp->con->port_altmode[cur] == alt ?0 : -EBUSY ; +if (cur !=0xff ) { +if (cur <UCSI_MAX_ALTMODES ) + ret = dp->con->port_altmode[cur] == alt ?0 : -EBUSY ; +else + ret = -EINVAL ; + goto err_unlock; }
Greg Kroah-Hartman
maintainerPATCH 201/516 usb: cdns3: Fix NULL pointer dereference in cdns3_pci_probe
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jie Deng <[email protected]>
commit e5052f2c5c73c1dcca42bafc0bc737af2b2af059 upstream.
The Cadence USBSS controller is a two-function PCI device. The first probed function allocates the driver data and stores it with pci_set_drvdata(), while the second function reuses it via pci_get_drvdata() when pci_is_enabled() reports that the first function has already been probed.
When the second function is probed while the first one has been enabled but has not yet set its driver data, pci_get_drvdata() returns NULL, and the subsequent wrap->devfn assignment dereferences a NULL pointer and crashes the kernel.
logs:
Call trace: cdns3_pci_probe+0xa4/0x300 local_pci_probe+0x44/0xa8 pci_call_probe+0x54/0x158 pci_device_probe+0x84/0x100 really_probe+0x184/0x3d0 __driver_probe_device+0x80/0x178 driver_probe_device+0x44/0xe8 __driver_attach+0xec/0x1f8 bus_for_each_dev+0x7c/0xe0 driver_attach+0x28/0x38 bus_add_driver+0x110/0x238 driver_register+0x64/0x128 __pci_register_driver+0x50/0x60 cdns3_pci_driver_init+0x28/0x38 do_one_initcall+0x5c/0x280 do_initcalls+0x104/0x1d8 kernel_init_freeable+0x140/0x218 kernel_init+0x28/0x1f8 ret_from_fork+0x10/0x20
Return -EPROBE_DEFER in this case so that probing is retried after the first function has completed its probe.
--- drivers/usb/cdns3/cdns3-pci-wrap.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/cdns3/cdns3-pci-wrap.c +5 -0
@@ -99,6 +99,11 @@ static int cdns3_pci_probe(struct pci_deif (pci_is_enabled (func)) { wrap =pci_get_drvdata (func); +if (!wrap) { +dev_err (&pdev->dev, +"second function not initialized, retrying\n" ); +return -EPROBE_DEFER ; + } }else { wrap =kzalloc (sizeof (*wrap),GFP_KERNEL );if (!wrap)
Greg Kroah-Hartman
maintainerPATCH 202/516 tty: amiserial: fix broken TIOCMIWAIT
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 615f35fd5aee169cc4881a8594f2fa234a4d0bb8 upstream.
A change replacing interruptible_sleep_on() inadvertently broke the TIOCMIWAIT implementation which now immediately returns -EIO (unless there is a racing modem status update).
Replace the old hangup (and signal) detection with a check for the TTY_IO_ERROR flag which is set on hangup.
--- drivers/tty/amiserial.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/tty/amiserial.c +4 -5
@@ -1173,11 +1173,6 @@ static int rs_ioctl(struct tty_struct *tlocal_irq_save (flags); cnow = info->icount;/* atomic copy */ local_irq_restore (flags); -if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && - cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) { - ret = -EIO ;/* no change => error */ -break ; - } if ( ((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
@@ -1185,6 +1180,10 @@ static int rs_ioctl(struct tty_struct *t ret =0 ;break ; } +if (tty_io_error (tty)) { + ret = -EIO ; +break ; + }schedule ();/* see if a signal did it */ if (signal_pending (current)) {
Greg Kroah-Hartman
maintainerPATCH 203/516 tty: vcc: zero-initialize control packet in vcc_send_ctl()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joshua Rogers <[email protected]>
commit 1f71f565e3585da1098ff19ca3c24687dab59185 upstream.
The stack-allocated struct vio_vcc pkt was partially initialized, leaving the tag.stype_env field uninitialized before being sent via ldc_write(), potentially leaking kernel stack data to the LDC peer.
--- drivers/tty/vcc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/vcc.c +1 -1
@@ -500,7 +500,7 @@ static ssize_t vcc_sysfs_domain_show(strstatic int vcc_send_ctl (struct vcc_port *port,int ctl) { -struct vio_vcc pkt; +struct vio_vcc pkt = {};int rv; pkt.tag.type =VIO_TYPE_CTRL ;
Greg Kroah-Hartman
maintainerPATCH 204/516 tty: vcc: hold port lock when clearing tty pointer in vcc_cleanup
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joshua Rogers <[email protected]>
commit 03b49c991abb8d021ca6fe51cd173447236b0552 upstream.
vcc_cleanup() sets port->tty to NULL without holding port->lock, racing with vcc_event() LDC callbacks that read port->tty under port->lock and then use tty->port. This can cause a use-after-free when the callback dereferences tty->port after cleanup has already destroyed and freed it.
--- drivers/tty/vcc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/tty/vcc.c +2 -1
@@ -1047,7 +1047,8 @@ static void vcc_cleanup(struct tty_struc port =vcc_get (tty->index, true);if (port) { - port->tty =NULL ; +scoped_guard (spinlock_irqsave, &port->lock) + port->tty = NULL;if (port->removed) {vcc_table_remove (tty->index);
Greg Kroah-Hartman
maintainerPATCH 205/516 tty: serial: qcom_geni_serial: Keep console RX functional after deep idle
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viken Dadhaniya <[email protected]>
commit 63ef71d1474b5417b5b2dec700cd251c44a570d9 upstream.
At baud rates up to 115200, the serial console uses only a 1 kBps keepalive vote for the GENI_TO_CORE ("qup-core") ICC path. This vote keeps the path active but does not request a QUP Core 2X clock rate.
When the CPU enters a deeper idle state, the missing Core clock vote can leave the console RX path unresponsive.
Use the 19.2 MHz Core 2X vote at low baud rates, while retaining the 50 MHz vote at higher baud rates, so that console RX remains functional after deep idle transitions.
--- drivers/tty/serial/qcom_geni_serial.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/tty/serial/qcom_geni_serial.c +2 -3
@@ -1017,9 +1017,8 @@ static void qcom_geni_serial_set_termios* Bump up BW vote on CPU and CORE path as driver supports FIFO mode * only. */ - avg_bw_core = (baud >115200 ) ?Bps_to_icc (CORE_2X_50_MHZ ) - :GENI_DEFAULT_BW ; - port->se.icc_paths[GENI_TO_CORE ].avg_bw = avg_bw_core; + avg_bw_core = baud >115200 ?CORE_2X_50_MHZ :CORE_2X_19_2_MHZ ; + port->se.icc_paths[GENI_TO_CORE ].avg_bw =Bps_to_icc (avg_bw_core); port->se.icc_paths[CPU_TO_GENI ].avg_bw =Bps_to_icc (baud);geni_icc_set_bw (&port->se);
Greg Kroah-Hartman
maintainerPATCH 206/516 serial: tegra: dont clear the Tx FIFO on an Rx-only reset
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Simon Gassner <[email protected]>
commit 8aebfde6e84dceb7d47fe8001e50b754eb45d5df upstream.
tegra_uart_fifo_reset() applies the Tegra30 workaround for "cannot clear the Tx FIFO while FIFO mode is enabled"
unconditionally: it leaves FIFO mode, writes the requested FCR clear bits, and re-enters FIFO mode. Leaving FIFO mode empties both FIFOs, so an Rx-only reset discards queued Tx data as well.
The break handler in tegra_uart_decode_rx_error() calls it with UART_FCR_CLEAR_RCVR only. On a half-duplex RS485 board whose Rx line is pulled low while the transceiver drives the bus, every transmission raises a spurious break, and all but the first character of the frame is lost.
Only take the FIFO-mode path when the caller actually asked for CLEAR_XMIT. Likewise only wait for TEMT in that case: with the Tx FIFO deliberately left intact, that loop would otherwise spin for a full frame time in hard IRQ context with the port lock held.
Tested on a Colibri T30 (Tegra30) with Rx DMA:
- Break during transmission: the reset still fires from tegra_uart_decode_rx_error(), and the complete frame now reaches the peer. Before this change only the character in the shift register was sent.
- Internal loopback with a generated break: the Rx FIFO is correctly cleared by the plain FCR write, and subsequent receive works with no frame, parity or overrun errors.
--- drivers/tty/serial/serial-tegra.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/tty/serial/serial-tegra.c +16 -2
@@ -302,11 +302,19 @@ static void tegra_uart_fifo_reset(struct {unsigned long fcr = tup->fcr_shadow;unsigned int lsr, tmout =10000 ; +bool clear_tx = !!(fcr_bits &UART_FCR_CLEAR_XMIT );if (tup->rts_active)set_rts (tup, false); -if (tup->cdata->allow_txfifo_reset_fifo_mode) { +/* +* Leaving FIFO mode below is a workaround for a Tegra30 +* restriction on clearing the Tx FIFO while FIFO mode is +* enabled. It empties both FIFOs, so applying it to an +* Rx-only reset would destroy an in-flight transmission. +* Only take that path when the caller asked for CLEAR_XMIT. +*/ +if (tup->cdata->allow_txfifo_reset_fifo_mode || !clear_tx) { fcr |= fcr_bits & (UART_FCR_CLEAR_RCVR |UART_FCR_CLEAR_XMIT );tegra_uart_write (tup, fcr,UART_FCR ); }else {
@@ -331,9 +339,15 @@ static void tegra_uart_fifo_reset(struct*/ tegra_uart_wait_cycle_time (tup,32 ); +/* +* Only wait for the transmitter to drain when the Tx FIFO was +* part of the reset. For an Rx-only reset it is left intact, +* and waiting for TEMT here would spin for a full frame time. +*/ do { lsr =tegra_uart_read (tup,UART_LSR ); -if ((lsr &UART_LSR_TEMT ) && !(lsr &UART_LSR_DR )) +if ((!clear_tx || (lsr &UART_LSR_TEMT )) && + !(lsr &UART_LSR_DR ))break ;udelay (1 ); }while (--tmout);
Greg Kroah-Hartman
maintainerPATCH 207/516 serial: vt8500: Fix clock reference leak in vt8500_serial_probe()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit 9d8955281d9229a899e2041659a59b389027b711 upstream.
of_clk_get() returns a clock with a reference that has to be released with clk_put(). If clk_prepare_enable() fails the function returns without doing so, leaking the reference.
Add the missing clk_put() on that error path.
--- drivers/tty/serial/vt8500_serial.c | 1 + 1 file changed, 1 insertion(+)
drivers/tty/serial/vt8500_serial.c +1 -0
@@ -682,6 +682,7 @@ static int vt8500_serial_probe(struct pl ret =clk_prepare_enable (vt8500_port->clk);if (ret) {dev_err (&pdev->dev,"failed to enable clock\n" ); +clk_put (vt8500_port->clk);return ret; }
Greg Kroah-Hartman
maintainerPATCH 208/516 ALSA: ua101: reject mismatched capture/playback packet sizes
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
commit 86f86e6fdedc33c5b8d38b9208b350f8accf57ee upstream.
detect_usb_format() cross-checks bSubframeSize, bBitResolution and tSamFreq between the capture and playback interfaces, but never relates the two endpoints' wMaxPacketSize and bNrChannels. Each playback URB gets a buffer of ua->playback.max_packet_bytes, while the number of bytes written into it is derived from the capture stream:capture_urb_complete() computes frames from the received capture packet and capture.frame_bytes, and start_usb_playback() and playback_work() multiply that by playback.frame_bytes.
A device declaring a large capture wMaxPacketSize with few capture channels and a small playback wMaxPacketSize with many playback channels therefore memset()s and memcpy()s past the end of the playback buffer, in open() of the PCM node the driver registers during probe. usb_submit_urb() rejects the over-long iso_frame_desc[0].length with -EMSGSIZE, but only after the write.
Reject such descriptors at probe time. Genuine UA-101/UA-1000 hardware declares proportional packet sizes and is unaffected.
BUG: KASAN: slab-out-of-bounds in start_usb_playback (sound/usb/misc/ua101.c:586) Write of size 2048 at addr ffff8881098f3c00 by task exploit/5021 Call Trace: __asan_memset (mm/kasan/shadow.c:84) start_usb_playback (sound/usb/misc/ua101.c:586) playback_pcm_open (sound/usb/misc/ua101.c:679) snd_pcm_open_substream (sound/core/pcm_native.c:2829) snd_pcm_open (sound/core/pcm_native.c:2865 sound/core/pcm_native.c:2932) snd_pcm_playback_open (sound/core/pcm_native.c:2891) snd_open (sound/core/sound.c:166) chrdev_open (fs/char_dev.c:411) do_dentry_open (fs/open.c:996) vfs_open (fs/open.c:1101) path_openat (fs/namei.c:4837 fs/namei.c:5000) do_file_open (fs/namei.c:5029) do_sys_openat2 (fs/open.c:1417) __x64_sys_openat (fs/open.c:1423 fs/open.c:1439 fs/open.c:1434) do_syscall_64 (arch/x86/entry/syscall_64.c:61 arch/x86/entry/syscall_64.c:84) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) The buggy address belongs to the object at ffff8881098f3c00 which belongs to the cache kmalloc-192 of size 192 The buggy address is located 0 bytes inside of allocated 168-byte region [ffff8881098f3c00, ffff8881098f3ca8)
--- sound/usb/misc/ua101.c | 9 +++++++++ 1 file changed, 9 insertions(+)
sound/usb/misc/ua101.c +9 -0
@@ -1023,6 +1023,15 @@ static int detect_usb_format(struct ua10 } ua->playback.usb_pipe =usb_sndisocpipe (ua->dev,usb_endpoint_num (epd)); ua->playback.max_packet_bytes =usb_endpoint_maxp (epd); + +if (ua->capture.max_packet_bytes / ua->capture.frame_bytes * + ua->playback.frame_bytes > ua->playback.max_packet_bytes) { +dev_err (&ua->dev->dev, +"playback packet size %u too small for %u capture frames\n" , + ua->playback.max_packet_bytes, + ua->capture.max_packet_bytes / ua->capture.frame_bytes); +return -ENXIO ; + }return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 209/516 Bluetooth: RFCOMM: Fix initial port reference race
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chengfeng Ye <[email protected]>
commit 2d696c1ed3468dcb62578a3911e687110d463520 upstream.
For RFCOMM_RELEASE_ONHUP devices, rfcomm_tty_install() and __rfcomm_release_dev() both use RFCOMM_TTY_OWNED to decide who drops the initial tty_port reference. The release path tests the bit separately from the install path setting it, so both can drop that reference.
The synchronous hangup does not prevent this race: port->tty is not assigned until tty_port_open(), after installation. The following interleaving is possible:
1. Install and release each obtain a reference with rfcomm_dev_get().
2. Release observes RFCOMM_TTY_OWNED clear.
3. Install sets RFCOMM_TTY_OWNED and drops the initial reference.
4. Release drops the same initial reference again.
5. TTY cleanup drops its reference and frees the device.
6. Release performs its final tty_port_put() on the freed port.
KASAN reported:
BUG: KASAN: slab-use-after-free in tty_port_put+0x22/0x190 Write of size 4 at addr ffff8881001d3d5c by task poc/92 Call Trace: tty_port_put+0x22/0x190 rfcomm_dev_ioctl+0x1d4/0x1930 sock_do_ioctl+0x110/0x260 sock_ioctl+0x380/0x590 __x64_sys_ioctl+0x134/0x1c0 Allocated by task 88: rfcomm_dev_ioctl+0x8f6/0x1930 sock_do_ioctl+0x110/0x260 sock_ioctl+0x380/0x590 __x64_sys_ioctl+0x134/0x1c0 Freed by task 65: kfree+0x131/0x3c0 rfcomm_dev_destruct+0x23b/0x2f0 release_one_tty+0xc1/0x370 process_one_work+0x661/0x1090
Use test_and_set_bit() in both paths so that only the caller that changes RFCOMM_TTY_OWNED from clear to set drops the initial reference. Each path keeps its own lookup reference until release or TTY cleanup, preserving the existing callback ordering and error handling.
--- net/bluetooth/rfcomm/tty.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
net/bluetooth/rfcomm/tty.c +3 -4
@@ -469,7 +469,7 @@ static int __rfcomm_release_dev(void __utty_kref_put (tty); } -if (!test_bit (RFCOMM_TTY_OWNED , &dev->status)) +if (!test_and_set_bit (RFCOMM_TTY_OWNED , &dev->status))tty_port_put (&dev->port);tty_port_put (&dev->port);
@@ -734,10 +734,9 @@ static int rfcomm_tty_install(struct tty* when the last process closes the tty. The behaviour is expected by * userspace. */ -if (test_bit (RFCOMM_RELEASE_ONHUP , &dev->flags)) { -set_bit (RFCOMM_TTY_OWNED , &dev->status); +if (test_bit (RFCOMM_RELEASE_ONHUP , &dev->flags) && + !test_and_set_bit (RFCOMM_TTY_OWNED , &dev->status))tty_port_put (&dev->port); - }return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 210/516 Bluetooth: hci_core: Fix inquiry cache timestamps on 64-bit systems
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
commit 74847177eca5638827ab74cdf77f0b10fc40ca6c upstream.
On 64-bit systems, outgoing BR/EDR connections always fall back to page scan repetition mode R2 with no clock offset once the system has been up for more than five minutes, even when inquiry found the peer only seconds earlier. This lengthens paging and can increase the risk of a Page Timeout.
The inquiry cache stores jiffies in __u32 timestamps, but its age helpers subtract them from unsigned long jiffies. INITIAL_JIFFIES casts -300 * HZ through unsigned int, so jiffies crosses 2^32 five minutes after boot on 64-bit systems. Assigning it to __u32 then drops the upper 32 bits. In one trace, a 7.6-second-old entry (HZ=1000) was reported as 2^32 + 7620 ticks old and rejected by hci_acl_create_conn_sync(). hci_inquiry() is affected by the same truncation when checking the whole cache. 32-bit systems are unaffected because unsigned long is 32 bits wide there.
Use unsigned long for both timestamps so they have the same width as jiffies on 32-bit and 64-bit systems, and update the debugfs format specifier accordingly.
--- include/net/bluetooth/hci_core.h | 4 ++-- net/bluetooth/hci_debugfs.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
include/net/bluetooth/hci_core.h +2 -2
@@ -60,7 +60,7 @@ struct inquiry_entry {NAME_PENDING ,NAME_KNOWN , } name_state; -__u32 timestamp; +unsigned long timestamp;struct inquiry_data data; };
@@ -76,7 +76,7 @@ struct discovery_state {struct list_head all;/* All devices found during inquiry */ struct list_head unknown;/* Name state not known */ struct list_head resolve;/* Name needs to be resolved */ -__u32 timestamp; +unsigned long timestamp;bdaddr_t last_adv_addr;u8 last_adv_addr_type;s8 last_adv_rssi;
net/bluetooth/hci_debugfs.c +1 -1
@@ -366,7 +366,7 @@ static int inquiry_cache_show(struct seqlist_for_each_entry (e, &cache->all, all) {struct inquiry_data *data = &e->data; - seq_printf(f, "%pMR %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %u\n", + seq_printf(f, "%pMR %d %d %d 0x%.2x%.2x%.2x 0x%.4x %d %d %lu\n", &data->bdaddr, data->pscan_rep_mode, data->pscan_period_mode, data->pscan_mode, data->dev_class[2],
Greg Kroah-Hartman
maintainerPATCH 211/516 Bluetooth: hci_core: Serialize ACL scheduling with channel deletion
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chengfeng Ye <[email protected]>
commit f4845ab191a4f686a5da481fbba90ed73bb693b0 upstream.
hci_chan_sent() selects a channel under RCU but drops the read lock before accessing chan->conn and returning the channel. The ACL and LE schedulers then use its packet queue and update its transmit counters without any protection against channel deletion.
After TX selects a channel and releases RCU, a disconnect command timeout on the separate request workqueue can run hci_conn_failed() and l2cap_conn_del(). hci_chan_del() can then unlink the channel, complete synchronize_rcu(), purge its queue and free it before TX resumes. This causes use-after-free both in hci_chan_sent() and in its callers.
KASAN reported:
BUG: KASAN: slab-use-after-free in hci_chan_sent+0x892/0x9b0 Workqueue: hci0 hci_tx_work Call Trace: hci_chan_sent+0x892/0x9b0 hci_tx_work+0x5e6/0xb70 Allocated by task 91: hci_chan_create+0xe3/0x350 l2cap_conn_add.part.0+0x12/0xa30 l2cap_chan_connect+0x110d/0x1b60 l2cap_sock_connect+0x310/0x530 Freed by task 99: hci_chan_del+0x11f/0x170 l2cap_conn_del+0x4f1/0x800 l2cap_connect_cfm+0x88c/0xd30 hci_conn_failed+0x150/0x250 hci_abort_conn_sync+0x3e3/0x800 hci_cmd_sync_run+0x7e/0xc0 hci_abort_conn+0x105/0x1f0 disconnect_sync+0x157/0x290 hci_cmd_sync_work+0x13c/0x290
Hold the existing device mutex across channel selection and transmission in both schedulers to serialize them with channel teardown. Keep timeout handling outside the critical sections because hci_link_tx_to() acquires the same mutex. This also permits the transmit path to sleep, unlike extending the RCU read-side critical section across packet submission.
--- net/bluetooth/hci_core.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/bluetooth/hci_core.c +8 -0
@@ -4599,6 +4599,8 @@ static void hci_sched_acl_pkt(struct hci__check_timeout (hdev, cnt,ACL_LINK ); +hci_dev_lock (hdev); +while (hdev->acl_cnt && (chan =hci_chan_sent (hdev,ACL_LINK , "e))) {u32 priority = (skb_peek (&chan->data_q))->priority;
@@ -4630,6 +4632,8 @@ static void hci_sched_acl_pkt(struct hciif (cnt != hdev->acl_cnt)hci_prio_recalculate (hdev,ACL_LINK ); + +hci_dev_unlock (hdev); }static void hci_sched_acl_blk (struct hci_dev *hdev)
@@ -4724,6 +4728,8 @@ static void hci_sched_le(struct hci_dev__check_timeout (hdev, *cnt,LE_LINK ); +hci_dev_lock (hdev); + tmp = *cnt;while (*cnt && (chan =hci_chan_sent (hdev,LE_LINK , "e))) {u32 priority = (skb_peek (&chan->data_q))->priority;
@@ -4752,6 +4758,8 @@ static void hci_sched_le(struct hci_devif (*cnt != tmp)hci_prio_recalculate (hdev,LE_LINK ); + +hci_dev_unlock (hdev); }static void hci_tx_work (struct work_struct *work)
Greg Kroah-Hartman
maintainerPATCH 212/516 Bluetooth: btintel: fix buffer over-read in btintel_hw_error()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrashekar Devegowda <[email protected]>
commit 40eb4b18ad167b63644c27fa67a7400ba050379a upstream.
The "Exception info %s" print uses skb->data + 1, but the 12-byte payload is not guaranteed to be NUL-terminated and can be read past its end.
Bound the print with "%.*s" and skb->len - 1.
--- drivers/bluetooth/btintel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/bluetooth/btintel.c +2 -1
@@ -210,7 +210,8 @@ void btintel_hw_error(struct hci_dev *hdreturn ; } -bt_dev_err (hdev,"Exception info %s" , (char *)(skb->data +1 )); +bt_dev_err (hdev,"Exception info %.*s" , (int )(skb->len -1 ), + (char *)(skb->data +1 ));kfree_skb (skb); }
Greg Kroah-Hartman
maintainerPATCH 213/516 ipvs: bound LBLCR and LBLC cache growth
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiling Zou <[email protected]>
[ Upstream commit 2a3c3de660f96865f303fd25f1285f2ffbfd521d ]
ip_vs_lblcr_new() and ip_vs_lblc_new() create cache entries for every previously unseen destination address. The table max_size only tells the periodic collector to reclaim entries after the cache has already exceeded the limit. It does not reclaim entries that the attacker continues to use.
Reject new cache entries once either table reaches max_size * 3 / 2. The extra headroom lets the periodic collector catch up while the existing scheduler fallback continues to use the selected destination when cache creation fails. New traffic therefore stays serviceable without growing the tables further.
--- net/netfilter/ipvs/ip_vs_lblc.c | 3 +++ net/netfilter/ipvs/ip_vs_lblcr.c | 3 +++ 2 files changed, 6 insertions(+)
net/netfilter/ipvs/ip_vs_lblc.c +3 -0
@@ -207,6 +207,9 @@ ip_vs_lblc_new(struct ip_vs_lblc_table *tbl, const union nf_inet_addr *daddr,ip_vs_lblc_del (en);atomic_dec (&tbl->entries); } +if (atomic_read (&tbl->entries) >= tbl->max_size *3 /2 ) +return NULL ; + en =kmalloc (sizeof (*en),GFP_ATOMIC );if (!en)return NULL ;
net/netfilter/ipvs/ip_vs_lblcr.c +3 -0
@@ -365,6 +365,9 @@ ip_vs_lblcr_new(struct ip_vs_lblcr_table *tbl, const union nf_inet_addr *daddr, en =ip_vs_lblcr_get (af, tbl, daddr);if (!en) { +if (atomic_read (&tbl->entries) >= tbl->max_size *3 /2 ) +return NULL ; + en =kmalloc (sizeof (*en),GFP_ATOMIC );if (!en)return NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 214/516 kprobes: Skip disarmed probes when checking optkprobe overlap
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Hwang <[email protected]>
[ Upstream commit 7a39c732a22ec4a369af9e19fbe3d666ec83eec4 ]
On x86, an optkprobe at A replaces five bytes with a jump. If a disabled probe B is at A+2, get_optimized_kprobe() stops at B when arming a new probe C at A+4. It leaves A optimized:
A A+1 A+2 A+3 A+4 A's jump | e9 | d0 | d1 | d2 | d3 | after C | e9 | d0 | d1 | d2 | cc |
The INT3 for C overwrites the last byte of A's jump displacement, so execution can jump to the wrong address. B can have prepared optinsns while disarmed, but has no jump to unoptimize.
Continue past disarmed and unprepared probes to find the active optimized probe before arming a probe in its jump.
--- kernel/kprobes.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
kernel/kprobes.c +5 -3
@@ -481,14 +481,16 @@ static int kprobe_queued(struct kprobe *p)static struct kprobe *get_optimized_kprobe (unsigned long addr) {int i; -struct kprobe *p =NULL ; +struct kprobe *p;struct optimized_kprobe *op;/* Don't check i == 0, since that is a breakpoint case. */ -for (i =1 ; !p && i <MAX_OPTIMIZED_LENGTH ; i++) +for (i =1 ; i <MAX_OPTIMIZED_LENGTH ; i++) { p =get_kprobe ((void *)(addr - i)); +/* A disabled probe can have prepared, but inactive, optinsns. */ +if (!p || !kprobe_optready (p) ||kprobe_disarmed (p)) +continue ; -if (p &&kprobe_optready (p)) { op = container_of(p, struct optimized_kprobe, kp);if (arch_within_optimized_kprobe (op, addr))return p;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 215/516 nvme-multipath: fix underflow in ANA log bounds checks
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daehyeon Ko <[email protected]>
commit 63fa2d9c9c37020bd2703fe2a6a38027b5abeb15 upstream.
The number of ANA groups advertised through Identify Controller sizes the ANA log buffer. The ANA log header and group descriptors independently supply the number of groups and namespace IDs to parse.
Both bounds checks subtract an untrusted object size from ana_log_size before comparing the current offset. If the object is larger than the buffer, the size_t subtraction underflows and lets the parser read beyond ana_log_buf.
Check the current offset before the first subtraction and compare each object size with the remaining buffer instead. This rejects inconsistent ANA data before dereferencing a truncated group descriptor or walking an oversized namespace ID array.
--- drivers/nvme/host/multipath.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/nvme/host/multipath.c +3 -2
@@ -445,7 +445,8 @@ static int nvme_parse_ana_log(struct nvmu32 nr_nsids;size_t nsid_buf_size; -if (WARN_ON_ONCE (offset > ctrl->ana_log_size -sizeof (*desc))) +if (WARN_ON_ONCE (offset > ctrl->ana_log_size || +sizeof (*desc) > ctrl->ana_log_size - offset))return -EINVAL ; nr_nsids =le32_to_cpu (desc->nnsids);
@@ -461,7 +462,7 @@ static int nvme_parse_ana_log(struct nvmreturn -EINVAL ; offset +=sizeof (*desc); -if (WARN_ON_ONCE (offset > ctrl->ana_log_size - nsid_buf_size)) +if (WARN_ON_ONCE (nsid_buf_size > ctrl->ana_log_size - offset))return -EINVAL ; error =cb (ctrl, desc, data);
Greg Kroah-Hartman
maintainerPATCH 216/516 mtd: rawnand: cadence: Initialize IRQ state before requesting IRQ
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
commit 21f027016b1290d13c30b198ae7a00e6b3d1d5a5 upstream.
The Cadence NAND interrupt handler uses both the IRQ lock and completion object. Registering the IRQ before initializing them leaves a window in which a pending interrupt can access uninitialized synchronization state.
Initialize them before registering the handler.
--- drivers/mtd/nand/raw/cadence-nand-controller.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/cadence-nand-controller.c +3 -3
@@ -2850,6 +2850,9 @@ static int cadence_nand_init(struct cdns goto free_buf_desc; } +spin_lock_init (&cdns_ctrl->irq_lock); +init_completion (&cdns_ctrl->complete); +if (devm_request_irq (cdns_ctrl->dev, cdns_ctrl->irq, cadence_nand_isr,IRQF_SHARED ,"cadence-nand-controller" , cdns_ctrl)) {
@@ -2858,9 +2861,6 @@ static int cadence_nand_init(struct cdns goto free_buf; } -spin_lock_init (&cdns_ctrl->irq_lock); -init_completion (&cdns_ctrl->complete); - ret =cadence_nand_hw_init (cdns_ctrl);if (ret) goto disable_irq;
Greg Kroah-Hartman
maintainerPATCH 217/516 mtd: rawnand: vf610_nfc: fix reads on chips with more than 64 bytes of OOB
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mehmet Fide <[email protected]>
commit 37adc9c5789c76db3b1ee7aeec3999b8503020d0 upstream.
The controller transfers 64 spare bytes per page and the driver only implements the matching 64-byte ECC layout, so attach_chip() shrinks mtd->oobsize when the chip provides more. That clamp does not survive:nand_scan_tail() runs nanddev_init() after ->attach_chip(), and it restores mtd->oobsize from the memory organization, which still holds the value detected from the chip. The driver then transfers writesize plus the chip's full OOB size, the hardware ECC parity ends up at a different offset than the layout the controller was set up for, and every ECC-protected read fails with -EBADMSG.
Measured on a Colibri VF61 (MX30LF4G28AC, 2048-byte pages, 112 bytes of OOB): with the clamp lost, UBI cannot read the erase counter headers of the pages U-Boot has just written, and the on-flash bad block table written by an older kernel reads back with ECC errors, so the board does not boot. Kernels before commit a7ab085d7c16 ("mtd: rawnand:
Initialize the nand_device object") are not affected because nothing overwrote the clamp there, which is why the same chip works with a v4.4 kernel and with U-Boot, whose copy of this driver has no memory organization to restore the value from. Edward Karpicz reported that the clamp no longer takes effect on this chip; see the link below.
Instead of modifying the memory organization, keep the detected OOB size and give the driver its own mtd_ooblayout_ops: the same layout the NAND core uses for large pages, but computed on the first 64 OOB bytes instead of the whole OOB, so the ECC bytes stay where U-Boot and the old kernels put them. The data paths transfer writesize plus those 64 bytes, as the controller always has.
Since mtd->oobsize now reports the chip's real spare size, fill the tail of oob_poi with 0xff after the 64 transferred bytes on ECC page
reads: the core may copy the full mtd->oobsize from it, which would otherwise expose whatever the buffer held before. 0xff also matches what a raw read returns from flash, since the write path only ever programs the first 64 spare bytes.
--- drivers/mtd/nand/raw/vf610_nfc.c | 72 ++++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 12 deletions(-)
drivers/mtd/nand/raw/vf610_nfc.c +60 -12
@@ -504,6 +504,11 @@ static int vf610_nfc_exec_op(struct nand check_only); } +static unsigned int vf610_nfc_spare_size (struct mtd_info *mtd) +{ + return min_t(unsigned int, mtd->oobsize, 64); +} +static inline int vf610_nfc_correct_data (struct nand_chip *chip,uint8_t *dat,uint8_t *oob,int page) {
@@ -521,7 +526,7 @@ static inline int vf610_nfc_correct_datareturn ecc_count; nfc->data_access = true; -nand_read_oob_op (&nfc->chip, page,0 , oob, mtd->oobsize); +nand_read_oob_op (&nfc->chip, page,0 , oob,vf610_nfc_spare_size (mtd)); nfc->data_access = false;/*
@@ -529,7 +534,7 @@ static inline int vf610_nfc_correct_data* at least less then half of the ECC strength. */ return nand_check_erased_ecc_chunk (dat, nfc->chip.ecc.size, oob, - mtd->oobsize,NULL ,0 , +vf610_nfc_spare_size (mtd),NULL ,0 , flips_threshold); }
@@ -550,7 +555,7 @@ static int vf610_nfc_read_page(struct na {struct vf610_nfc *nfc =chip_to_nfc (chip);struct mtd_info *mtd =nand_to_mtd (chip); -int trfr_sz = mtd->writesize + mtd->oobsize; +int trfr_sz = mtd->writesize +vf610_nfc_spare_size (mtd);u32 row =0 , cmd1 =0 , cmd2 =0 , code =0 ;int stat;
@@ -576,11 +581,16 @@ static int vf610_nfc_read_page(struct na*/ vf610_nfc_rd_from_sram (buf, nfc->regs +NFC_MAIN_AREA (0 ), mtd->writesize, false); -if (oob_required) +if (oob_required) { +unsigned int spare =vf610_nfc_spare_size (mtd); +vf610_nfc_rd_from_sram (chip->oob_poi, nfc->regs +NFC_MAIN_AREA (0 ) + mtd->writesize, - mtd->oobsize, false); + spare, false); +/* Not transferred, and never written: reads back erased */ +memset (chip->oob_poi + spare,0xff , mtd->oobsize - spare); + } stat =vf610_nfc_correct_data (chip, buf, chip->oob_poi, page);
@@ -598,7 +608,7 @@ static int vf610_nfc_write_page(struct n {struct vf610_nfc *nfc =chip_to_nfc (chip);struct mtd_info *mtd =nand_to_mtd (chip); -int trfr_sz = mtd->writesize + mtd->oobsize; +int trfr_sz = mtd->writesize +vf610_nfc_spare_size (mtd);u32 row =0 , cmd1 =0 , cmd2 =0 , code =0 ;u8 status;int ret;
@@ -739,6 +749,49 @@ static void vf610_nfc_init_controller(st } } +/* +* With 64 byte OOB chips the core's large page layout matches what +* U-Boot uses, and on chips with more, U-Boot and older kernels clamped +* mtd->oobsize to 64. Modifying the OOB size is no longer possible, the +* actual chip geometry must be respected, so to avoid breaking those +* existing setups use our own layout: the core's large page one, +* computed over the first 64 spare bytes only. +*/ +static int vf610_nfc_ooblayout_ecc (struct mtd_info *mtd,int section, +struct mtd_oob_region *oobregion) +{ +struct nand_device *nand =mtd_to_nanddev (mtd); +unsigned int total_ecc_bytes = nand->ecc.ctx.total; + +if (section || !total_ecc_bytes) +return -ERANGE ; + + oobregion->length = total_ecc_bytes; + oobregion->offset =vf610_nfc_spare_size (mtd) - oobregion->length; + +return 0 ; +} + +static int vf610_nfc_ooblayout_free (struct mtd_info *mtd,int section, +struct mtd_oob_region *oobregion) +{ +struct nand_device *nand =mtd_to_nanddev (mtd); +unsigned int total_ecc_bytes = nand->ecc.ctx.total; + +if (section) +return -ERANGE ; + + oobregion->length =vf610_nfc_spare_size (mtd) - total_ecc_bytes -2 ; + oobregion->offset =2 ; + +return 0 ; +} + +static const struct mtd_ooblayout_ops vf610_nfc_ooblayout_ops = { + .ecc = vf610_nfc_ooblayout_ecc, + .free = vf610_nfc_ooblayout_free, +}; +static int vf610_nfc_attach_chip (struct nand_chip *chip) {struct mtd_info *mtd =nand_to_mtd (chip);
@@ -769,12 +822,7 @@ static int vf610_nfc_attach_chip(structreturn -ENXIO ; } -/* Only 64 byte ECC layouts known */ -if (mtd->oobsize >64 ) - mtd->oobsize =64 ; - -/* Use default large page ECC layout defined in NAND core */ -mtd_set_ooblayout (mtd,nand_get_large_page_ooblayout ()); +mtd_set_ooblayout (mtd, &vf610_nfc_ooblayout_ops);if (chip->ecc.strength ==32 ) { nfc->ecc_mode =ECC_60_BYTE ; chip->ecc.bytes =60 ;
Greg Kroah-Hartman
maintainerPATCH 218/516 wifi: cw1200: fix TX padding OOB read leaking heap data to device
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tianchu Chen <[email protected]>
commit 7c1611780823b76219cb1478db53dfd890c4a9a2 upstream.
The TX path rounds the transfer size up to the bus alignment (align_size(), up to 511 bytes for SDIO, 1 byte for SPI) but sends the padded length straight from the frame buffer, which has no room reserved for the padding. cw1200_data_write() therefore reads past the end of the frame and the bus transfer carries those bytes to the device. A bogus device can collect up to 511 bytes of kernel heap data per TX frame.
The RX path does not have this problem: it allocates the skb with the aligned length (alloc_len) before reading.
Compute the exact padding with the bus align_size() callback, make sure queued TX frames have tailroom for it, and zero the padding bytes before the transfer so nothing past the frame is exposed.
This is not expected to change driver behavior on most cases: frame contents and transfer sizes are unchanged, only the content of the padding bytes (previously undefined stale memory, now zero), which the device never reads since the WSM header carries the real frame length. The skb expansion can only fail under memory exhaustion, in which case the frame is dropped like on the existing error paths of cw1200_tx().
Discovered by Atuin - Automated Vulnerability Discovery Engine.
--- drivers/net/wireless/st/cw1200/bh.c | 8 +++++++- drivers/net/wireless/st/cw1200/txrx.c | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-)
drivers/net/wireless/st/cw1200/bh.c +7 -1
@@ -352,6 +352,7 @@ static int cw1200_bh_tx_helper(struct cw int *tx_burst) {size_t tx_len; +size_t aligned_len;u8 *data;int ret;struct wsm_hdr *wsm;
@@ -384,9 +385,14 @@ static int cw1200_bh_tx_helper(struct cwatomic_add (1 , &priv->bh_tx); - tx_len = priv->hwbus_ops->align_size ( + aligned_len = priv->hwbus_ops->align_size ( priv->hwbus_priv, tx_len); +/* Zero the bus alignment padding so no stale data is sent. */ +if (aligned_len > tx_len) +memset (data + tx_len,0 , aligned_len - tx_len); + tx_len = aligned_len; +/* Check if not exceeding CW1200 capabilities */ if (WARN_ON_ONCE (tx_len >EFFECTIVE_BUF_SIZE ))pr_debug ("Write aligned len: %zu\n" , tx_len);
drivers/net/wireless/st/cw1200/txrx.c +14 -0
@@ -14,6 +14,7 @@#include "wsm.h" #include "bh.h" #include "sta.h" +#include "hwbus.h" #include "debug.h" #define CW1200_INVALID_RATE_ID (0xFF)
@@ -716,6 +717,7 @@ void cw1200_tx(struct ieee80211_hw *dev,struct ieee80211_sta *sta;struct wsm_tx *wsm;bool tid_update = false; +size_t pad_len;u8 flags =0 ;int ret;
@@ -765,6 +767,18 @@ void cw1200_tx(struct ieee80211_hw *dev,rcu_read_lock (); sta =rcu_dereference (t.sta); +/* +* The bus transfer is padded up to the bus alignment and the +* padding is transferred from the frame buffer. Make sure the +* buffer has room for the padding so the device never receives +* data past the end of the frame. +*/ + pad_len = priv->hwbus_ops->align_size (priv->hwbus_priv, skb->len) - + skb->len; +if (skb_tailroom (skb) < pad_len && +pskb_expand_head (skb,0 , pad_len,GFP_ATOMIC )) + goto drop; +spin_lock_bh (&priv->ps_state_lock); { tid_update =cw1200_tx_h_pm_state (priv, &t);
Greg Kroah-Hartman
maintainerPATCH 219/516 wifi: iwlegacy: 3945: free EEPROM data on remove
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
commit f8ebe286394c0bbb4a6dbacb182a34ab6376922d upstream.
il3945_pci_probe() calls il_eeprom_init(), which allocates memory for the EEPROM data. The probe failure paths release this allocation with il_eeprom_free(), but the remove path does not free it after a successful probe.
As a result, the EEPROM data is leaked when the PCI device is removed.
Free the EEPROM data in il3945_pci_remove() before releasing the mac80211 hardware structure.
This issue was found by manual code inspection.
--- drivers/net/wireless/intel/iwlegacy/3945-mac.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/intel/iwlegacy/3945-mac.c +1 -0
@@ -3849,6 +3849,7 @@ il3945_pci_remove(struct pci_dev *pdev)il_free_channel_map (il);il_free_geos (il); +il_eeprom_free (il);kfree (il->scan_cmd);dev_kfree_skb (il->beacon_skb);ieee80211_free_hw (il->hw);
Greg Kroah-Hartman
maintainerPATCH 220/516 wifi: mac80211: drain PS delivery work during station teardown
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Li <[email protected]>
commit 67a9e80c3ca20c9044cd6ee72cd6278dd19b5023 upstream.
Removing an AP or mesh station can notify the driver and wake TXQs after the station has already been removed from the driver, and can update num_sta_ps and the power-save queues after station cleanup has purged them.
sta_deliver_ps_frames() tests sta->dead only before it starts delivery. A worker that passes that test can be delayed while teardown sets sta->dead and removes the station from the driver; when it resumes it still runs the full delivery.
The existing cancel_work_sync() sits near the end of __cleanup_single_sta(), after the final driver state transition and after PS accounting and queue purging, so it drains the worker only once the state it has to protect has already changed. Before commit d34ba2168a3c ("mac80211: don't delay station destruction") cleanup was deferred through the same ordered workqueue as the delivery work, which kept the two ordered.
Cancel the work after setting sta->dead and before moving the driver state, and move the existing cancellation to the start of __cleanup_single_sta(). The first drain closes the driver-lifetime window; driver callbacks during the remaining state transitions can still queue drv_deliver_wk through ieee80211_sta_block_awake(), so retain the second drain at the start of __cleanup_single_sta(). That drain also covers insertion failures, which reach cleanup without setting sta->dead.
--- net/mac80211/sta_info.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/mac80211/sta_info.c +4 -2
@@ -89,6 +89,8 @@ static void __cleanup_single_sta(structstruct ieee80211_local *local = sdata->local;struct ps_data *ps; +cancel_work_sync (&sta->drv_deliver_wk); +if (test_sta_flag (sta,WLAN_STA_PS_STA ) ||test_sta_flag (sta,WLAN_STA_PS_DRIVER ) ||test_sta_flag (sta,WLAN_STA_PS_DELIVER )) {
@@ -129,8 +131,6 @@ static void __cleanup_single_sta(structif (ieee80211_vif_is_mesh (&sdata->vif))mesh_sta_cleanup (sta); -cancel_work_sync (&sta->drv_deliver_wk); -/* * Destroy aggregation state here. It would be nice to wait for the * driver to finish aggregation stop and then clean up, but for now
@@ -1094,6 +1094,8 @@ static void __sta_info_destroy_part2(str sta->dead = true; +cancel_work_sync (&sta->drv_deliver_wk); + local->num_sta--; local->sta_generation++;
Greg Kroah-Hartman
maintainerPATCH 221/516 wifi: mac80211: release mesh path quota on failed additions
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Li <[email protected]>
commit 7325a44474f20c1393a1c114c6811abce6ddfaf4 upstream.
Repeated failed or duplicate mesh path additions can exhaust MESH_MAX_MPATHS while the path table holds fewer paths, which stops new paths to reachable destinations from being created.
mesh_path_add() reserves a slot before allocating and inserting a path. If allocation fails, the function returns without releasing the slot. If the rhashtable insertion reports an error or an existing destination, the function discards its candidate but retains the reservation. No new path is installed in any of these cases.
Release the reservation whenever the candidate is not installed.
--- net/mac80211/mesh_pathtbl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/mac80211/mesh_pathtbl.c +4 -1
@@ -407,8 +407,10 @@ struct mesh_path *mesh_path_add(struct ireturn ERR_PTR (-ENOSPC ); new_mpath =mesh_path_new (sdata, dst,GFP_ATOMIC ); -if (!new_mpath) +if (!new_mpath) { +atomic_dec (&sdata->u.mesh.mpaths);return ERR_PTR (-ENOMEM ); + } tbl = &sdata->u.mesh.mesh_paths;spin_lock_bh (&tbl->walk_lock);
@@ -421,6 +423,7 @@ struct mesh_path *mesh_path_add(struct iif (mpath) {kfree (new_mpath); +atomic_dec (&sdata->u.mesh.mpaths);if (IS_ERR (mpath))return mpath;
Greg Kroah-Hartman
maintainerPATCH 222/516 wifi: mac80211: handle empty FILS association request payload
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuqi Xu <[email protected]>
commit 5bfd4b0b40b79781d900cb2f7da0685070f53c67 upstream.
fils_encrypt_assoc_req() accepts a (Re)Association Request frame whose last element is the FILS Session element. crypt_len is then zero and aes_siv_encrypt() is called with an empty plaintext.
kmemdup() returns ZERO_SIZE_PTR for a zero-length allocation, so the unconditional sg_init_one() puts an invalid page into the scatterlist. With CONFIG_DEBUG_SG this triggers a kernel BUG in sg_set_buf(); without the debug check the bogus page is handed to the crypto backend.
AES-SIV is defined for empty plaintext and the S2V result is then the complete output, so handle this case before the CTR step, which has nothing to encrypt.
--- net/mac80211/fils_aead.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/mac80211/fils_aead.c +8 -0
@@ -95,6 +95,14 @@ static int aes_siv_encrypt(const u8 *keyif (res)return res; +/* With an empty plaintext there is no ciphertext to produce and +* the S2V result is the complete output. +*/ +if (!plain_len) { +memcpy (out, v,AES_BLOCK_SIZE ); +return 0 ; + } +/* Use a temporary buffer of the plaintext to handle need for * overwriting this during AES-CTR. */
Greg Kroah-Hartman
maintainerPATCH 223/516 USB: serial: cp210x: add Corsair AX1500i Power Supply
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Carrat <[email protected]>
commit d84e27d87738634b92001500435ae4dadba10a13 upstream.
The Corsair AX1500i power supply exposes its Corsair Link monitoring interface on a mini-USB port through an on-board CP2103, using a Corsair-specific product ID. Without the ID in the table no driver binds and no tty is created.
Tested by forcing the driver association with
echo 1b1c 1c02 > /sys/bus/usb-serial/drivers/cp210x/new_id
and then setting the serial port to 115200 8N1. Adding the ID is sufficient to talk to the device: the tty reaches a USB-to-SMBus bridge sitting behind the UART, which identifies itself as "USB to SMB Bridge (Firmware by Ross Fosler)" version 0.9 and relays PMBus reads to the power supply controller. Input voltage and current, input and output power, internal temperature and fan speed were all read back on an AX1500i.
[ 7.806181] usb 3-14: New USB device found, idVendor=1b1c, idProduct=1c02, bcdDevice= 1.00 [ 698.526754] usbcore: registered new interface driver cp210x [ 698.526767] usbserial: USB Serial support registered for cp210x [ 698.527863] cp210x 3-14:1.0: cp210x converter detected [ 698.529263] usb 3-14: cp210x converter now attached to ttyUSB0
The related AX1600i (1b1c:1c11, iProduct "USB API") is expected to be the same kind of device but has not been tested here, so it is not added.
--- drivers/usb/serial/cp210x.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/cp210x.c +1 -0
@@ -227,6 +227,7 @@ static const struct usb_device_id id_tab { USB_DEVICE(0x19CF, 0x3000) }, /* Parrot NMEA GPS Flight Recorder */ { USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */ { USB_DEVICE(0x1B1C, 0x1C00) }, /* Corsair USB Dongle */ + { USB_DEVICE(0x1B1C, 0x1C02) }, /* Corsair AX1500i Power Supply */ { USB_DEVICE(0x1B93, 0x1013) }, /* Phoenix Contact UPS Device */ { USB_DEVICE(0x1BA4, 0x0002) }, /* Silicon Labs 358x factory default */ { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */
Greg Kroah-Hartman
maintainerPATCH 224/516 USB: serial: quatech2: fix baud rate overflow
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit ec06546b43b612cefc851558981b4955c0ef9e46 upstream.
The requested baud rate is incorrectly truncated to 16 bits so that line speeds above 65535 bps cannot be set.
Use 32 bits for the rate while rejecting rates outside of [50,921600] to avoid having the 16-bit divisor overflow.
--- drivers/usb/serial/quatech2.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/usb/serial/quatech2.c +16 -3
@@ -54,6 +54,7 @@#define QT2_XMIT_FLUSH 0x05/* no following info */ #define QT2_CONTROL_ESCAPE 0xff/* pass through previous 2 control bytes */ +#define MIN_BAUD_RATE 50#define MAX_BAUD_RATE 921600#define DEFAULT_BAUD_RATE 9600
@@ -158,7 +159,7 @@ static inline int calc_baud_divisor(intstatic inline int qt2_set_port_config (struct usb_device *dev,unsigned char port_number, -u16 baudrate,u16 lcr) +speed_t baudrate,u16 lcr) {int divisor =calc_baud_divisor (baudrate);u16 index = ((u16) (lcr <<8 ) | (u16) (port_number));
@@ -267,9 +268,9 @@ static void qt2_set_termios(struct tty_sstruct usb_device *dev = port->serial->dev;struct qt2_port_private *port_priv;struct ktermios *termios = &tty->termios; -u16 baud;unsigned int cflag = termios->c_cflag;u16 new_lcr =0 ; +speed_t baud;int status; port_priv =usb_get_serial_port_data (port);
@@ -301,6 +302,18 @@ static void qt2_set_termios(struct tty_sif (!baud) baud =9600 ; +if (baud <MIN_BAUD_RATE || baud >MAX_BAUD_RATE ) { +if (old_termios) + baud =tty_termios_baud_rate (old_termios); +else + baud =clamp (baud,MIN_BAUD_RATE ,MAX_BAUD_RATE ); + +tty_encode_baud_rate (tty, baud, baud); + +if (!baud) + baud =9600 ; + } + status =qt2_set_port_config (dev, port_priv->device_port, baud, new_lcr);if (status <0 )
@@ -397,7 +410,7 @@ static int qt2_open(struct tty_struct *t port_priv->device_port = (u8 ) device_port;if (tty) -qt2_set_termios (tty, port, &tty->termios); +qt2_set_termios (tty, port,NULL );return 0 ;
Greg Kroah-Hartman
maintainerPATCH 225/516 USB: serial: ssu100: fix baud rate overflow
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit afc235a217360c6859068d2e37a4df305c4d1be2 upstream.
The requested baud rate is incorrectly truncated to 16 bits so that line speeds above 65535 bps cannot be set.
Use 32 bits for the rate and remainder while rejecting rates outside of [50,460800] to avoid having the divisor or remainder overflow.
This issue was flagged by an LLM.
--- drivers/usb/serial/ssu100.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/usb/serial/ssu100.c +16 -2
@@ -34,6 +34,7 @@#define SERIAL_EVEN_PARITY (UART_LCR_PARITY | UART_LCR_EPAR) +#define MIN_BAUD_RATE 50#define MAX_BAUD_RATE 460800#define ATC_DISABLED 0x00
@@ -219,9 +220,10 @@ static void ssu100_set_termios(struct tt {struct usb_device *dev = port->serial->dev;struct ktermios *termios = &tty->termios; -u16 baud, divisor, remainder; +speed_t baud, remainder;unsigned int cflag = termios->c_cflag;u16 urb_value =0 ;/* will hold the new flags */ +u16 divisor;int result;if (cflag &PARENB ) {
@@ -251,6 +253,18 @@ static void ssu100_set_termios(struct ttif (!baud) baud =9600 ; +if (baud <MIN_BAUD_RATE || baud >MAX_BAUD_RATE ) { +if (old_termios) + baud =tty_termios_baud_rate (old_termios); +else + baud =clamp (baud,MIN_BAUD_RATE ,MAX_BAUD_RATE ); + +tty_encode_baud_rate (tty, baud, baud); + +if (!baud) + baud =9600 ; + } +dev_dbg (&port->dev,"%s - got baud = %d\n" , __func__, baud);
@@ -326,7 +340,7 @@ static int ssu100_open(struct tty_structdev_dbg (&port->dev,"%s - set uart failed\n" , __func__);if (tty) -ssu100_set_termios (tty, port, &tty->termios); +ssu100_set_termios (tty, port,NULL );return usb_serial_generic_open (tty, port); }
Greg Kroah-Hartman
maintainerPATCH 226/516 USB: serial: fix dynamic id driver deregistration race
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 63594e8ffe097bc0b7639936f33799a7653dded2 upstream.
Only free the dynamic ids after having deregistered the driver and removed the "new_id" attribute to avoid leaking any id added by a racing write to the attribute.
--- drivers/usb/serial/bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/serial/bus.c +1 -1
@@ -184,7 +184,7 @@ int usb_serial_bus_register(struct usb_svoid usb_serial_bus_deregister (struct usb_serial_driver *driver) { -free_dynids (driver);driver_unregister (&driver->driver); +free_dynids (driver); }
Greg Kroah-Hartman
maintainerPATCH 227/516 USB: serial: option: add support for SIMCom SIM8260C
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Dongdong <[email protected]>
commit 35c950c9ec2c4c4d45dc9b63cfe8fca774ce33a0 upstream.
Add support for SIMCom SIM8260C (1e0e:902b).
T: Bus=08 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=5000 MxCh= 0 D: Ver= 3.20 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs= 1 P: Vendor=1e0e ProdID=902b Rev= 5.04 S: Manufacturer=SIMCOM S: Product=SDXLEMUR-LITE-MTP _SN:120696AB S: SerialNumber=0123456789ABCDEF C:* #Ifs= 8 Cfg#= 1 Atr=a0 MxPwr=896mA A: FirstIf#= 5 IfCount= 3 Cls=01(audio) Sub=00 Prot=20 I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option E: Ad=01(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms E: Ad=81(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=60 Driver=option E: Ad=83(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=82(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=85(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=84(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms E: Ad=03(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=87(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=86(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms E: Ad=04(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=50 Driver=qmi_wwan_simcom E: Ad=88(I) Atr=03(Int.) MxPS= 8 Ivl=32ms E: Ad=8e(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms E: Ad=0f(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms I:* If#= 5 Alt= 0 #EPs= 0 Cls=01(audio) Sub=01 Prot=20 Driver=snd-usb-audio I:* If#= 6 Alt= 0 #EPs= 0 Cls=01(audio) Sub=02 Prot=20 Driver=snd-usb-audio I: If#= 6 Alt= 1 #EPs= 1 Cls=01(audio) Sub=02 Prot=20 Driver=snd-usb-audio E: Ad=05(O) Atr=0d(Isoc) MxPS= 34 Ivl=1ms I:* If#= 7 Alt= 0 #EPs= 0 Cls=01(audio) Sub=02 Prot=20 Driver=(none) I: If#= 7 Alt= 1 #EPs= 1 Cls=01(audio) Sub=02 Prot=20 Driver=(none) E: Ad=89(I) Atr=0d(Isoc) MxPS= 34 Ivl=1ms
--- drivers/usb/serial/option.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/serial/option.c +2 -0
@@ -2169,6 +2169,8 @@ static const struct usb_device_id option { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9003, 0xff) }, /* Simcom SIM7500/SIM7600 MBIM mode */ { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9011, 0xff), /* Simcom SIM7500/SIM7600 RNDIS mode */ .driver_info = RSVD(7) }, + { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x902b, 0xff), + .driver_info = RSVD(4) }, { USB_DEVICE(0x1e0e, 0x9071), /* Simcom SIM8230 RMNET mode */ .driver_info = RSVD(3) | RSVD(4) }, { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9078, 0xff), /* Simcom SIM8230 ECM mode */
Greg Kroah-Hartman
maintainerPATCH 228/516 USB: serial: option: add Quectel EG060W
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carlo Szelinsky <[email protected]>
commit cd243401994880b8b6810c53177bce56eebaece5 upstream.
Add Quectel EG060W with product ID 0x6004.
The three vendor-specific interfaces are DIAG, NMEA and AT; the CDC-NCM data interfaces are handled by the cdc_ncm driver.
T: Bus=01 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 2 Spd=480 MxCh= 0 D: Ver= 2.10 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=2c7c ProdID=6004 Rev= 3.18 S: Manufacturer=Quectel S: Product=EG060W-EAAA S: SerialNumber=123456789ABCD C:* #Ifs= 5 Cfg#= 1 Atr=e0 MxPwr= 2mA A: FirstIf#= 0 IfCount= 2 Cls=02(comm.) Sub=0d Prot=00 I:* If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=0d Prot=00 Driver=cdc_ncm E: Ad=82(I) Atr=03(Int.) MxPS= 16 Ivl=32ms I: If#= 1 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=01 Driver=cdc_ncm I:* If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=01 Driver=cdc_ncm E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
--- drivers/usb/serial/option.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/serial/option.c +2 -0
@@ -281,6 +281,7 @@ static void option_instat_callback(struc#define QUECTEL_PRODUCT_EC200U 0x0901#define QUECTEL_PRODUCT_EG912Y 0x6001#define QUECTEL_PRODUCT_EC200S_CN 0x6002 +#define QUECTEL_PRODUCT_EG060W 0x6004#define QUECTEL_PRODUCT_EC200A 0x6005#define QUECTEL_PRODUCT_EG916Q 0x6007#define QUECTEL_PRODUCT_EM061K_LWW 0x6008
@@ -1269,6 +1270,7 @@ static const struct usb_device_id option { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC200A, 0xff, 0, 0) }, { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC200U, 0xff, 0, 0) }, { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC200S_CN, 0xff, 0, 0) }, + { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG060W, 0xff, 0, 0) }, { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC200T, 0xff, 0, 0) }, { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG912Y, 0xff, 0, 0) }, { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG916Q, 0xff, 0x00, 0x00) },
Greg Kroah-Hartman
maintainerPATCH 229/516 USB: serial: option: add Compal EXM-G1x support
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Lin <[email protected]>
commit 7f11480cda081de78a05d8c97073df66326b50b3 upstream.
The Compal EXM-G1x is a Qualcomm SDX12-based LTE modem. Add support for its vendor-specific serial interfaces with protocols 0x30, 0x40, and 0x60.
Relevant output from usb-devices:
T: Bus=04 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 4 Spd=5000 MxCh= 0 D: Ver= 3.20 Cls=ef(misc ) Sub=02 Prot=01 MxPS= 9 #Cfgs= 1 P: Vendor=04b7 ProdID=8217 Rev=05.04 S: Manufacturer=COMPAL S: Product=EXM-G1x C: #Ifs= 6 Cfg#= 1 Atr=a0 MxPwr=896mA I: If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=(none) I: If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=60 Driver=option I: If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option I: If#= 4 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none) I: If#= 8 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=50 Driver=qmi_wwan
Tested on a Compal EXM-G1x modem.
--- drivers/usb/serial/option.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/serial/option.c +3 -0
@@ -2434,6 +2434,9 @@ static const struct usb_device_id option .driver_info = RSVD(5) }, { USB_DEVICE_INTERFACE_CLASS(0x0489, 0xe167, 0xff), /* Foxconn T99W640 MBIM */ .driver_info = RSVD(3) }, + { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x8217, 0xff, 0xff, 0x30) }, /* Compal EXM-G1x */ + { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x8217, 0xff, 0xff, 0x40) }, + { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x8217, 0xff, 0xff, 0x60) }, { USB_DEVICE(0x1508, 0x1001), /* Fibocom NL668 (IOT version) */ .driver_info = RSVD(4) | RSVD(5) | RSVD(6) }, { USB_DEVICE(0x1782, 0x4d10) }, /* Fibocom L610 (AT mode) */
Greg Kroah-Hartman
maintainerPATCH 230/516 USB: serial: option: add Quectel RG660QB
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Sjoholm <[email protected]>
commit 6177bcd94be83f80a032c2e69a06606d325335b9 upstream.
Add support for the Quectel RG660QB 5G module (USB ID 2c7c:013d). The interface layout is the same as the RG650V:
If 0: DIAG ff/ff/30, 2 endpoints If 1: NMEA ff/00/00, 2 endpoints If 2: AT ff/00/00, 3 endpoints If 3: Modem ff/00/00, 3 endpoints If 4: QMI ff/ff/ff, 3 endpoints
Match the serial interfaces on class/subclass/protocol so that the QMI interface is left to qmi_wwan.
# lsusb -v -d 2c7c:013d
Bus 004 Device 002: ID 2c7c:013d Quectel Wireless Solutions Co., Ltd. RG660QB-EU Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 3.20
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 9
idVendor 0x2c7c Quectel Wireless Solutions Co., Ltd.
idProduct 0x013d
bcdDevice 6.06
iManufacturer 1 Quectel
iProduct 2 RG660QB-EU
iSerial 3 f50119d0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x0105
bNumInterfaces 5
bConfigurationValue 1
iConfiguration 4 DIAG_SER_RMNET
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 896mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 48
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 0
bNumEndpoints 3
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 6 CDEV Serial
** UNRECOGNIZED: 05 24 00 10 01
** UNRECOGNIZED: 05 24 01 00 00
** UNRECOGNIZED: 04 24 02 02
** UNRECOGNIZED: 05 24 06 00 00
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x84 EP 4 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x000a 1x 10 bytes
bInterval 9
bMaxBurst 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x03 EP 3 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 0
bNumEndpoints 3
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 6 CDEV Serial
** UNRECOGNIZED: 05 24 00 10 01
** UNRECOGNIZED: 05 24 01 00 00
** UNRECOGNIZED: 04 24 02 02
** UNRECOGNIZED: 05 24 06 00 00
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x86 EP 6 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x000a 1x 10 bytes
bInterval 9
bMaxBurst 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x85 EP 5 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x04 EP 4 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 4
bAlternateSetting 0
bNumEndpoints 3
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 7 RmNet
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x88 EP 8 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 9
bMaxBurst 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x87 EP 7 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 6
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x05 EP 5 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 2
Binary Object Store Descriptor:
bLength 5
bDescriptorType 15
wTotalLength 0x0023
bNumDeviceCaps 2
SuperSpeed USB Device Capability:
bLength 10
bDescriptorType 16
bDevCapabilityType 3
bmAttributes 0x00
wSpeedsSupported 0x000f
Device can operate at Low Speed (1Mbps)
Device can operate at Full Speed (12Mbps)
Device can operate at High Speed (480Mbps)
Device can operate at SuperSpeed (5Gbps)
bFunctionalitySupport 1
Lowest fully-functional device speed is Full Speed (12Mbps)
bU1DevExitLat 0 micro seconds
bU2DevExitLat 0 micro seconds
SuperSpeedPlus USB Device Capability:
bLength 20
bDescriptorType 16
bDevCapabilityType 10
bmAttributes 0x00000001
Sublink Speed Attribute count 1
Sublink Speed ID count 0
wFunctionalitySupport 0x1100
bmSublinkSpeedAttr[0] 0x000a4030
Speed Attribute ID: 0 10Gb/s Symmetric RX SuperSpeedPlus
bmSublinkSpeedAttr[1] 0x000a40b0
Speed Attribute ID: 0 10Gb/s Symmetric TX SuperSpeedPlus
Device Status: 0x0000
(Bus Powered)
Tested with an early sample of the module on a Quectel 5G EVB connected over USB 3 to a Raspberry Pi 5.
--- drivers/usb/serial/option.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/serial/option.c +3 -0
@@ -261,6 +261,7 @@ static void option_instat_callback(struc#define QUECTEL_PRODUCT_EM060K_12a 0x012a#define QUECTEL_PRODUCT_EM060K_12b 0x012b#define QUECTEL_PRODUCT_EM060K_12c 0x012c +#define QUECTEL_PRODUCT_RG660QB 0x013d#define QUECTEL_PRODUCT_EG91 0x0191#define QUECTEL_PRODUCT_EG95 0x0195#define QUECTEL_PRODUCT_BG96 0x0296
@@ -1277,6 +1278,8 @@ static const struct usb_device_id option { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RM500K, 0xff, 0x00, 0x00) }, { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RG650V, 0xff, 0xff, 0x30) }, { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RG650V, 0xff, 0, 0) }, + { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RG660QB, 0xff, 0xff, 0x30) }, + { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RG660QB, 0xff, 0, 0) }, { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RG255C, 0xff, 0xff, 0x30) }, { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RG255C, 0xff, 0, 0) }, { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RG255C, 0xff, 0xff, 0x40) },
Greg Kroah-Hartman
maintainerPATCH 231/516 USB: serial: option: add Compal EXC-T1 support
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Lin <[email protected]>
commit b51faf3f2e307f114854bbe6d495f03cd5370686 upstream.
The Compal EXC-T1 is a Qualcomm MDM9207-based LTE modem which reports "EXC-x1" as its USB product string. It exposes diagnostic, modem, AT, and NMEA ports as vendor-specific interfaces with subclass 0x10 and protocols 0x01 through 0x04.
Add exact interface matches for these four ports, leaving the ff/ff/ff interface unbound.
Relevant output from usb-devices:
T: Bus=03 Lev=02 Prnt=03 Port=03 Cnt=01 Dev#= 6 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=04b7 ProdID=4d22 Rev=03.18 S: Manufacturer=CEI S: Product=EXC-x1 C: #Ifs= 6 Cfg#= 1 Atr=a0 MxPwr=500mA I: If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=10 Prot=01 Driver=option I: If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=10 Prot=02 Driver=option I: If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=10 Prot=03 Driver=option I: If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=10 Prot=04 Driver=option I: If#= 4 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none) I: If#= 5 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=10 Prot=05 Driver=qmi_wwan
Tested on a Compal EXC-T1 modem using an Ubuntu kernel build. The four serial interfaces bound to option and exposed ttyUSB3 through ttyUSB6.
--- drivers/usb/serial/option.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/serial/option.c +4 -0
@@ -2437,6 +2437,10 @@ static const struct usb_device_id option .driver_info = RSVD(5) }, { USB_DEVICE_INTERFACE_CLASS(0x0489, 0xe167, 0xff), /* Foxconn T99W640 MBIM */ .driver_info = RSVD(3) }, + { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x4d22, 0xff, 0x10, 0x01) }, /* Compal EXC-T1 */ + { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x4d22, 0xff, 0x10, 0x02) }, + { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x4d22, 0xff, 0x10, 0x03) }, + { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x4d22, 0xff, 0x10, 0x04) }, { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x8217, 0xff, 0xff, 0x30) }, /* Compal EXM-G1x */ { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x8217, 0xff, 0xff, 0x40) }, { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x8217, 0xff, 0xff, 0x60) },
Greg Kroah-Hartman
maintainerPATCH 232/516 thunderbolt: Reject oversized XDomain properties responses
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daehyeon Ko <[email protected]>
commit 80756e263846ab694984e749e8c626897331438f upstream.
tb_xdp_properties_request() allocates room for 45 data dwords in its 252-byte response buffer. The XDomain length field is six bits wide, however, and a malicious peer can set it to 63. After the fixed response fields are subtracted, the driver treats this as 48 data dwords.
Commit 322e93448d90 ("thunderbolt: Clamp XDomain response data copy to allocation size") only bounds the copy against data_len. If data_len is at least 48, memcpy() reads 192 bytes from the 180-byte res->data array, causing a 12-byte heap out-of-bounds read. Commit 4db2bd2ed478 ("thunderbolt: Limit XDomain response copy to actual frame size") limits the earlier copy but does not constrain this header-derived length.
Reject response data lengths that exceed the allocated source buffer before copying them into the assembled property block.
--- drivers/thunderbolt/xdomain.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/thunderbolt/xdomain.c +4 -0
@@ -338,6 +338,10 @@ static int tb_xdp_properties_request(str len +=sizeof (res->hdr.xd_hdr) /4 ; len -=sizeof (*res) /4 ; +if (len >TB_XDP_PROPERTIES_MAX_DATA_LENGTH ) { + ret = -EINVAL ; + goto err; + }if (res->offset != req.offset) { ret = -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 233/516 iio: accel: kxcjk-1013: reject duplicate event disable
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
commit dd30c10ff60d2b30386c23bb7c61cc97f2385c97 upstream.
The IIO core does not filter duplicate writes to the event enable attribute. kxcjk1013_write_event_config() already ignores repeated enable requests, but a repeated disable request still calls kxcjk1013_set_power_state(data, false), dropping a runtime PM reference that was not acquired for this request. This can underflow the runtime PM usage count and trigger a "Runtime PM usage count underflow" warning.
Return early when the requested state already matches ev_enable_state.
--- drivers/iio/accel/kxcjk-1013.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/kxcjk-1013.c +1 -1
@@ -934,7 +934,7 @@ static int kxcjk1013_write_event_config(struct kxcjk1013_data *data =iio_priv (indio_dev);int ret; -if (state && data->ev_enable_state) +if (state == data->ev_enable_state)return 0 ;mutex_lock (&data->mutex);
Greg Kroah-Hartman
maintainerPATCH 234/516 iio: accel: sca3000: fix frequency divider condition check
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Salah Triki <[email protected]>
commit d380bf5f94a892e546d9a94e8557ad866b043a2a upstream.
When setting the sampling frequency, the check for base_freq / 2 is followed by an independent if statement for base_freq / 4. If val equals base_freq / 2, the second check fails and falls through to the else if (val != base_freq) branch, returning -EINVAL erroneously.
Fix this by chaining the checks with else if.
--- drivers/iio/accel/sca3000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/sca3000.c +1 -1
@@ -645,7 +645,7 @@ static int sca3000_write_raw_samp_freq(sif (val == base_freq /2 ) ctrlval |=SCA3000_REG_OUT_CTRL_BUF_DIV_2 ; -if (val == base_freq /4 ) +else if (val == base_freq /4 ) ctrlval |=SCA3000_REG_OUT_CTRL_BUF_DIV_4 ;else if (val != base_freq)return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 235/516 iio: adc: sun4i-gpadc-iio: clean up on thermal zone registration failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
commit 2cdc7ef31827db4fbc6283750420639569e1f0e9 upstream.
If devm_thermal_of_zone_register() fails, probe returns without unregistering the IIO map array or disabling runtime PM.
Jump to err_map to release them.
--- drivers/iio/adc/sun4i-gpadc-iio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/iio/adc/sun4i-gpadc-iio.c +4 -4
@@ -645,10 +645,10 @@ static int sun4i_gpadc_probe(struct plat* thermal because no thermal DT node is found. */ if (IS_ERR (info->tzd) &&PTR_ERR (info->tzd) != -ENODEV ) { -dev_err (&pdev->dev, -"could not register thermal sensor: %ld\n" , -PTR_ERR (info->tzd)); -return PTR_ERR (info->tzd); + ret =dev_err_probe (&pdev->dev, +PTR_ERR (info->tzd), +"could not register thermal sensor\n" ); + goto err_map; } }
Greg Kroah-Hartman
maintainerPATCH 236/516 iio: adc: sun4i-gpadc-iio: drop underflowing pm_runtime_put() calls
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
commit 8b958dd214ad0c003f56549e9e039cb8067dc1a2 upstream.
Neither the error path in sun4i_gpadc_probe() nor sun4i_gpadc_remove() ever holds a runtime PM usage count. So the pm_runtime_put() in both places always triggers the "Runtime PM usage count underflow!" warning on every failed probe and every unbind.
Drop both calls.
--- drivers/iio/adc/sun4i-gpadc-iio.c | 2 -- 1 file changed, 2 deletions(-)
drivers/iio/adc/sun4i-gpadc-iio.c +0 -2
@@ -664,7 +664,6 @@ err_map:if (!info->no_irq &&IS_ENABLED (CONFIG_THERMAL_OF ))iio_map_array_unregister (indio_dev); -pm_runtime_put (&pdev->dev);pm_runtime_disable (&pdev->dev);return ret;
@@ -675,7 +674,6 @@ static int sun4i_gpadc_remove(struct plastruct iio_dev *indio_dev =platform_get_drvdata (pdev);struct sun4i_gpadc_iio *info =iio_priv (indio_dev); -pm_runtime_put (&pdev->dev);pm_runtime_disable (&pdev->dev);if (!IS_ENABLED (CONFIG_THERMAL_OF ))
Greg Kroah-Hartman
maintainerPATCH 237/516 iio: gyro: adis16136: fix unprotected debugfs reads
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arka Mondal <[email protected]>
commit 2b498df75d6c29aa3e760127ae0f0003df598b53 upstream.
The serial_number file operations are open coded and never call debugfs_file_get(), which debugfs_create_file_unsafe() requires. debugfs_remove_recursive() therefore does not wait for a read in progress, and unbind frees the iio_dev underneath it.
Use debugfs_create_file() instead.
--- drivers/iio/gyro/adis16136.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/gyro/adis16136.c +1 -1
@@ -150,7 +150,7 @@ static int adis16136_debugfs_init(structstruct adis16136 *adis16136 =iio_priv (indio_dev);struct dentry *d =iio_get_debugfs_dentry (indio_dev); -debugfs_create_file_unsafe ("serial_number" ,0400 , +debugfs_create_file ("serial_number" ,0400 , d, adis16136, &adis16136_serial_fops);debugfs_create_file_unsafe ("product_id" ,0400 , d, adis16136, &adis16136_product_id_fops);
Greg Kroah-Hartman
maintainerPATCH 238/516 iio: imu: adis16400: fix unprotected debugfs reads
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arka Mondal <[email protected]>
commit d94787287a113a1326211647d5e0deed1e9de105 upstream.
adis16400_serial_number_fops is open coded and never calls debugfs_file_get(), so debugfs_remove_recursive() does not wait for a read in progress and unbind frees the iio_dev underneath it.
Commit ae1d37a9bb4b ("iio: imu: adis16400: use DEFINE_DEBUGFS_ATTRIBUTE instead of DEFINE_SIMPLE_ATTRIBUTE") converted product_id and flash_count to DEFINE_DEBUGFS_ATTRIBUTE, which protects itself, but moved all three files to debugfs_create_file_unsafe().
serial_number prints three registers as "%.4x-%.4x-%.4x" and DEFINE_DEBUGFS_ATTRIBUTE() formats a single u64, so it cannot be converted without changing what the file returns. adis16475 and adis16550 already use debugfs_create_file() for their open coded files. Use it here too.
--- drivers/iio/imu/adis16400.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/imu/adis16400.c +1 -1
@@ -286,7 +286,7 @@ static int adis16400_debugfs_init(structstruct dentry *d =iio_get_debugfs_dentry (indio_dev);if (st->variant->flags &ADIS16400_HAS_SERIAL_NUMBER ) -debugfs_create_file_unsafe ("serial_number" ,0400 , +debugfs_create_file ("serial_number" ,0400 , d, st, &adis16400_serial_number_fops);if (st->variant->flags &ADIS16400_HAS_PROD_ID ) debugfs_create_file_unsafe("product_id", 0400,
Greg Kroah-Hartman
maintainerPATCH 239/516 iio: imu: adis16480: fix unprotected debugfs reads
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arka Mondal <[email protected]>
commit e1dea54496f90a62318cf4eeaa1e9ef8316e92b6 upstream.
The firmware_revision and firmware_date file operations are open coded and never call debugfs_file_get(), which debugfs_create_file_unsafe() requires. debugfs_remove_recursive() therefore does not wait for a read in progress, and unbind frees the iio_dev underneath it.
Use debugfs_create_file() instead.
--- drivers/iio/imu/adis16480.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/imu/adis16480.c +2 -2
@@ -286,9 +286,9 @@ static int adis16480_debugfs_init(structstruct adis16480 *adis16480 =iio_priv (indio_dev);struct dentry *d =iio_get_debugfs_dentry (indio_dev); -debugfs_create_file_unsafe ("firmware_revision" ,0400 , +debugfs_create_file ("firmware_revision" ,0400 , d, adis16480, &adis16480_firmware_revision_fops); -debugfs_create_file_unsafe ("firmware_date" ,0400 , +debugfs_create_file ("firmware_date" ,0400 , d, adis16480, &adis16480_firmware_date_fops);debugfs_create_file_unsafe ("serial_number" ,0400 , d, adis16480, &adis16480_serial_number_fops);
Greg Kroah-Hartman
maintainerPATCH 240/516 iio: light: gp2ap020a00f: drain irq_work after free_irq
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
commit 63213927b141085b6c8719b8037dab3074b7e0fe upstream.
The threaded IRQ handler queues data->work through irq_work_queue() so the trigger is polled from a per-CPU context. free_irq() does not flush an irq_work the handler already queued, so after gp2ap020a00f_remove() returns that work may still run and call iio_trigger_poll() on data->trig, which the devm cleanup has already freed, causing a use-after-free.
Add irq_work_sync(&data->work) after free_irq() in remove() and in the probe error path, mirroring commit 78601726d4a5 ("iio: trigger: sysfs:
fix use-after-free on remove").
Found by an in-house static analysis tool, confirmed by manual review.
--- drivers/iio/light/gp2ap020a00f.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/light/gp2ap020a00f.c +2 -0
@@ -1571,6 +1571,7 @@ error_trigger_unregister:iio_trigger_unregister (data->trig); error_free_irq:free_irq (client->irq, indio_dev); +irq_work_sync (&data->work); error_uninit_buffer:iio_triggered_buffer_cleanup (indio_dev); error_regulator_disable:
@@ -1593,6 +1594,7 @@ static int gp2ap020a00f_remove(struct i2iio_device_unregister (indio_dev);iio_trigger_unregister (data->trig);free_irq (client->irq, indio_dev); +irq_work_sync (&data->work);iio_triggered_buffer_cleanup (indio_dev);regulator_disable (data->vled_reg);
Greg Kroah-Hartman
maintainerPATCH 241/516 iio: proximity: isl29501: Fix return type of isl29501_register_write
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Salah Triki <[email protected]>
commit e8dd273d199f5bbe295a8e3d8b777c5505b6b2e1 upstream.
isl29501_register_write() was returning a u32 instead of an int. Since the function returns negative error codes (such as -ERANGE or return values from i2c_smbus_write_byte_data()), returning an unsigned integer type prevents callers from correctly checking for negative error conditions.
Fix this by changing the function return type from u32 to int.
This was found through manual code review.
--- drivers/iio/proximity/isl29501.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/proximity/isl29501.c +1 -1
@@ -227,7 +227,7 @@ err:return ret; } -static u32 isl29501_register_write (struct isl29501_private *isl29501, +static int isl29501_register_write (struct isl29501_private *isl29501,enum isl29501_register_name name,u32 value) {
Greg Kroah-Hartman
maintainerPATCH 242/516 iio: proximity: pulsedlight: fix iio_device left registered on PM setup failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cong Nguyen <[email protected]>
commit 4daa9ca557b4b98ae1ad38a6d1deaa3e31eb8edf upstream.
pm_runtime_set_active() failing in probe() jumps to error_unreg_buffer, which only calls iio_triggered_buffer_cleanup() -- it does not undo the iio_device_register() that already succeeded a few lines above. probe() then returns the error, the devm-managed indio_dev is freed, but the iio core still has it registered: the sysfs/chardev nodes stay live and point at freed memory.
Add an error_unreg_dev label that unregisters the iio device before falling through to the existing buffer cleanup, mirroring the teardown order already used in lidar_remove().
--- drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +3 -1
@@ -297,12 +297,14 @@ static int lidar_probe(struct i2c_client ret =pm_runtime_set_active (&client->dev);if (ret) - goto error_unreg_buffer; + goto error_unreg_dev;pm_runtime_enable (&client->dev);pm_runtime_idle (&client->dev);return 0 ; +error_unreg_dev: +iio_device_unregister (indio_dev); error_unreg_buffer:iio_triggered_buffer_cleanup (indio_dev);
Greg Kroah-Hartman
maintainerPATCH 243/516 loop: Fix use-after-free issues
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit 9b0cb770f5d7b1ff40bea7ca385438ee94570eec ]
do_req_filebacked() calls blk_mq_complete_request() synchronously or asynchronously when using asynchronous I/O unless memory allocation fails. Hence, modify loop_handle_cmd() such that it does not dereference 'cmd' nor 'rq' after do_req_filebacked() finished unless we are sure that the request has not yet been completed. This patch fixes the following kernel crash:
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000054 Call trace: css_put.42938+0x1c/0x1ac loop_process_work+0xc8c/0xfd4 loop_rootcg_workfn+0x24/0x34 process_one_work+0x244/0x558 worker_thread+0x400/0x8fc kthread+0x16c/0x1e0 ret_from_fork+0x10/0x20
[ Dropped the part fixing c74d40e8b5e2 as this commit isn't included in 5.10. Kept the part fixing bc07c10a3603 ]
--- drivers/block/loop.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/block/loop.c +9 -1
@@ -2032,16 +2032,24 @@ static void loop_handle_cmd(struct loop_cmd *cmd)const bool write =op_is_write (req_op (rq));struct loop_device *lo = rq->q->queuedata;int ret =0 ; +const bool use_aio = cmd->use_aio;if (write && (lo->lo_flags &LO_FLAGS_READ_ONLY )) { ret = -EIO ; goto failed; } +/* +* do_req_filebacked() may call blk_mq_complete_request() synchronously +* or asynchronously if using aio. Hence, do not touch 'cmd' after +* do_req_filebacked() has returned unless we are sure that 'cmd' has +* not yet been completed. +*/ ret =do_req_filebacked (lo, rq); + failed:/* complete non-aio request */ -if (!cmd->use_aio || ret) { +if (!use_aio || ret) {if (ret == -EOPNOTSUPP ) cmd->ret = ret;else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 244/516 net: sched: cls_u32: Undo tcf_bind_filter if u32_replace_hw_knode
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit 9cb36faedeafb9720ac236aeae2ea57091d90a09 ]
When u32_replace_hw_knode fails, we need to undo the tcf_bind_filter operation done at u32_set_parms.
--- net/sched/cls_u32.c | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-)
net/sched/cls_u32.c +30 -10
@@ -709,8 +709,23 @@ static const struct nla_policy u32_policy[TCA_U32_MAX + 1] = { [TCA_U32_FLAGS] = { .type = NLA_U32 }, }; +static void u32_unbind_filter (struct tcf_proto *tp,struct tc_u_knode *n, +struct nlattr **tb) +{ +if (tb[TCA_U32_CLASSID ]) +tcf_unbind_filter (tp, &n->res); +} + +static void u32_bind_filter (struct tcf_proto *tp,struct tc_u_knode *n, +unsigned long base,struct nlattr **tb) +{ +if (tb[TCA_U32_CLASSID ]) { + n->res.classid =nla_get_u32 (tb[TCA_U32_CLASSID ]); +tcf_bind_filter (tp, &n->res, base); + } +} +static int u32_set_parms (struct net *net,struct tcf_proto *tp, -unsigned long base,struct tc_u_knode *n,struct nlattr **tb,struct nlattr *est,bool ovr,struct netlink_ext_ack *extack)
@@ -756,10 +771,6 @@ static int u32_set_parms(struct net *net, struct tcf_proto *tp,if (ht_old) ht_old->refcnt--; } -if (tb[TCA_U32_CLASSID ]) { - n->res.classid =nla_get_u32 (tb[TCA_U32_CLASSID ]); -tcf_bind_filter (tp, &n->res, base); - }if (ifindex >=0 ) n->ifindex = ifindex;
@@ -898,16 +909,20 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,if (!new)return -ENOMEM ; - err =u32_set_parms (net, tp, base, new, tb, - tca[TCA_RATE ], ovr, extack); + err =u32_set_parms (net, tp, new, tb,tca[TCA_RATE ], + ovr, extack);if (err) {__u32_destroy_key (new);return err; } +u32_bind_filter (tp, new, base, tb); + err =u32_replace_hw_knode (tp, new, flags, extack);if (err) { +u32_unbind_filter (tp, new, tb); +__u32_destroy_key (new);return err; }
@@ -1108,15 +1123,18 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, }#endif - err =u32_set_parms (net, tp, base, n, tb, tca[TCA_RATE ], ovr, + err =u32_set_parms (net, tp, n, tb, tca[TCA_RATE ], ovr, extack); + +u32_bind_filter (tp, n, base, tb); +if (err ==0 ) {struct tc_u_knode __rcu **ins;struct tc_u_knode *pins; err =u32_replace_hw_knode (tp, n, flags, extack);if (err) - goto errhw; + goto errunbind;if (!tc_in_hw (n->flags)) n->flags |=TCA_CLS_FLAGS_NOT_IN_HW ;
@@ -1134,7 +1152,9 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,return 0 ; } -errhw: +errunbind: +u32_unbind_filter (tp, n, tb); +#ifdef CONFIG_CLS_U32_MARK free_percpu (n->pcpu_success);#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 245/516 Revert "scsi: sd: sd_zbc: Use logical blocks as unit when querying zones"
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit cab3909d1be51cf1caa78ac8683e4bb69aab4c4f, the 5.10.y backport of upstream 43af5da09efb.
As Simon Liebold found for the identical 5.15.y backport, the change makes sd_zbc_report_zones() advance with
lba += sdkp->zone_blocks * i;
zone_blocks is u32, so the product is computed in 32 bits and wraps before being widened into the 64-bit lba. A host-managed SMR drive that returns 8192 or more zones in one REPORT ZONES has the next batch requested at a wrapped LBA, zone revalidation fails, and sd truncates the device to zero capacity.
Mainline never shipped this form: c976e588b34e ("scsi: sd: sd_zbc: Hide gap zones") rewrote the loop in the same series, and it is not in 5.10.y. 43af5da09efb is only a cleanup, and the scsi_debug fix that pulled it in as a dependency (93dde0bf2f39) touches only scsi_debug.c, so revert it.
--- drivers/scsi/sd_zbc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/scsi/sd_zbc.c +6 -5
@@ -224,7 +224,7 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, unsigned int nr_zones, report_zones_cb cb, void *data) { struct scsi_disk *sdkp = scsi_disk(disk); -sector_t lba =sectors_to_logical (sdkp->device, sector); +sector_t capacity =logical_to_sectors (sdkp->device, sdkp->capacity);unsigned int nr, i;unsigned char *buf;size_t offset, buflen =0 ;
@@ -235,7 +235,7 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector,/* Not a zoned device */ return -EOPNOTSUPP ; -if (!sdkp->capacity) +if (!capacity)/* Device gone or invalid */ return -ENODEV ;
@@ -243,8 +243,9 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector,if (!buf)return -ENOMEM ; -while (zone_idx < nr_zones && lba < sdkp->capacity) { - ret =sd_zbc_do_report_zones (sdkp, buf, buflen, lba, true); +while (zone_idx < nr_zones && sector < capacity) { + ret =sd_zbc_do_report_zones (sdkp, buf, buflen, +sectors_to_logical (sdkp->device, sector), true);if (ret) goto out;
@@ -262,7 +263,7 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, zone_idx++; } - lba += sdkp->zone_blocks * i; + sector +=sd_zbc_zone_sectors (sdkp) * i; } ret = zone_idx;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 246/516 arm64: dts: qcom: sdm845-db845c: Mark cont splash memory region as reserved
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amit Pundir <[email protected]>
[ Upstream commit 110e70fccce4f22b53986ae797d665ffb1950aa6 ]
Adding a reserved memory region for the framebuffer memory (the splash memory region set up by the bootloader).
It fixes a kernel panic (arm-smmu: Unhandled context fault at this particular memory region) reported on DB845c running v5.10.y.
--- arch/arm64/boot/dts/qcom/sdm845-db845c.dts | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm64/boot/dts/qcom/sdm845-db845c.dts +9 -0
@@ -85,6 +85,14 @@ hdmi_con: endpoint { }; }; + reserved-memory { + /* Cont splash region set up by the bootloader */ + cont_splash_mem: framebuffer@9d400000 { + reg = <0x0 0x9d400000 0x0 0x2400000>; + no-map; + }; + }; + lt9611_1v8: lt9611-vdd18-regulator { compatible = "regulator-fixed"; regulator-name = "LT9611_1V8";
@@ -488,6 +496,7 @@ &i2c14 { }; &mdss { + memory-region = <&cont_splash_mem>; status = "okay"; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 247/516 drm/amd/powerplay: fix VoltageObjectInfo zero-stride loop and OOB read
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Asad Kamal <[email protected]>
[ Upstream commit 5d3cc8e388464f485d0944b87b8f9426e637d082 ]
Reject voltage objects whose usSize is smaller than the header or would advance the cursor past the table end, preventing an infinite loop or heap OOB read when the VBIOS supplies a malformed VoltageObjectInfo table.
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c | 10 ++++++++-- drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomfwctrl.c | 11 ++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c +8 -2
@@ -224,15 +224,21 @@ static const ATOM_VOLTAGE_OBJECT_V3 *atomctrl_lookup_voltage_type_v3( unsigned int offset = offsetof(ATOM_VOLTAGE_OBJECT_INFO_V3_1, asVoltageObj[0]);uint8_t *start = (uint8_t *)voltage_object_info_table; -while (offset < size) { +while (offset +sizeof (ATOM_VOLTAGE_OBJECT_HEADER_V3 ) <= size) {const ATOM_VOLTAGE_OBJECT_V3 *voltage_object = (const ATOM_VOLTAGE_OBJECT_V3 *)(start + offset); +u16 obj_size; + + obj_size =le16_to_cpu (voltage_object->asGpioVoltageObj.sHeader.usSize); +if (obj_size <sizeof (voltage_object->asGpioVoltageObj.sHeader) || + offset + obj_size > size) +break ;if (voltage_type == voltage_object->asGpioVoltageObj.sHeader.ucVoltageType && voltage_mode == voltage_object->asGpioVoltageObj.sHeader.ucVoltageMode)return voltage_object; - offset +=le16_to_cpu (voltage_object->asGpioVoltageObj.sHeader.usSize); + offset += obj_size; }return NULL ;
drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomfwctrl.c +8 -3
@@ -36,16 +36,21 @@ static const union atom_voltage_object_v4 *pp_atomfwctrl_lookup_voltage_type_v4( offsetof(struct atom_voltage_objects_info_v4_1, voltage_object[0]);unsigned long start = (unsigned long )voltage_object_info_table; -while (offset < size) { +while (offset +sizeof (struct atom_voltage_object_header_v4 ) <= size) {const union atom_voltage_object_v4 *voltage_object = (const union atom_voltage_object_v4 *)(start + offset); +u16 obj_size; + + obj_size =le16_to_cpu (voltage_object->gpio_voltage_obj.header.object_size); +if (obj_size <sizeof (voltage_object->gpio_voltage_obj.header) || + offset + obj_size > size) +break ;if (voltage_type == voltage_object->gpio_voltage_obj.header.voltage_type && voltage_mode == voltage_object->gpio_voltage_obj.header.voltage_mode)return voltage_object; - offset +=le16_to_cpu (voltage_object->gpio_voltage_obj.header.object_size); - + offset += obj_size; }return NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 248/516 SUNRPC: fix gssx_dec_option_array error path bugs
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Mason <[email protected]>
[ Upstream commit 5e9a94539b1ec17a89177d952badfd0d844d694a ]
Four coupled defects in the gssx XDR option-array decoder make the error paths unsafe: a NULL deref in the caller, a refcount leak on the decoded group_info, and a latent use-after-free that the leak fix would otherwise expose.
gssx_dec_option_array() sets oa->count = 1 before allocating oa->data. If that allocation fails, -ENOMEM is returned with oa->count == 1 and oa->data == NULL. All other error paths jump to free_oa: which frees oa->data and NULLs it but also leaves oa->count == 1. The caller trusts the count:
gssp_accept_sec_context_upcall()
gssx_dec_accept_sec_context()
gssx_dec_option_array() /* fails, count=1 data=NULL */
data = res.options.data[0].value /* NULL deref */
Independently, free_creds: releases the partially decoded svc_cred with a bare kfree(creds). gssx_dec_linux_creds() installs a groups_alloc() result into creds->cr_group_info; that object is kvmalloc-backed and refcounted, and only put_group_info() reaches kvfree(). A plain kfree(creds) drops the wrapper and leaks the group_info allocation.
The natural fix for the leak is to call free_svc_cred(creds) before kfree(creds), but free_svc_cred() invokes put_group_info() on creds->cr_group_info unconditionally when non-NULL. The existingout_free_groups: path in gssx_dec_linux_creds() already called groups_free() on that pointer without clearing it, so once free_svc_cred() is wired in, the subsequent put_group_info() would touch freed memory.
Fix all four together:
- Move the oa->count = 1 assignment below the oa->data allocation
so it is never set when oa->data is NULL.
- Reset oa->count to 0 at free_oa: so count and data stay coherent and the caller sees an empty option array.
- Call free_svc_cred(creds) before kfree(creds) at free_creds:
so the refcounted cr_group_info is released. free_svc_cred() either NULL-guards each field explicitly (cr_group_info has an if() check) or delegates to a helper that is NULL-safe itself (kfree for the string fields, gss_mech_put() which guards with if(gm) at gss_mech_switch.c:342), so it is safe to call on a partially decoded svc_cred where only cr_uid/cr_gid/cr_group_info have been written and everything else is zero from kzalloc.
- In gssx_dec_linux_creds()'s out_free_groups: path, release cr_group_info with put_group_info() rather than groups_free() so the teardown matches free_svc_cred()'s refcount-aware path, and clear the pointer so a later free_svc_cred() on the same creds does not release it a second time.
--- net/sunrpc/auth_gss/gss_rpc_xdr.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/sunrpc/auth_gss/gss_rpc_xdr.c +6 -3
@@ -222,7 +222,8 @@ static int gssx_dec_linux_creds(struct xdr_stream *xdr,return 0 ; out_free_groups: -groups_free (creds->cr_group_info); +put_group_info (creds->cr_group_info); + creds->cr_group_info =NULL ;return err; }
@@ -242,12 +243,12 @@ static int gssx_dec_option_array(struct xdr_stream *xdr,return 0 ;/* we recognize only 1 currently: CREDS_VALUE */ - oa->count =1 ; - oa->data =kmalloc (sizeof (struct gssx_option ),GFP_KERNEL );if (!oa->data)return -ENOMEM ; + oa->count =1 ; + creds =kzalloc (sizeof (struct svc_cred ),GFP_KERNEL );if (!creds) { err = -ENOMEM ;
@@ -294,8 +295,10 @@ static int gssx_dec_option_array(struct xdr_stream *xdr,return 0 ; free_creds: +free_svc_cred (creds);kfree (creds); free_oa: + oa->count =0 ;kfree (oa->data); oa->data =NULL ;return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 249/516 SUNRPC: reject duplicate CREDS_VALUE options
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Mason <[email protected]>
[ Upstream commit 2e4ce62385c1b8a887c5370af058ac7b52a8eaf9 ]
gssx_dec_option_array() walks the wire-supplied option array and, for every entry whose name matches CREDS_VALUE, calls gssx_dec_linux_creds() on the same struct svc_cred. That helper unconditionally installs a fresh groups_alloc() result into creds->cr_group_info without releasing whatever pointer was already there:
for (i = 0; i < count; i++) {
... decode name ...
if (length == sizeof(CREDS_VALUE) &&
memcmp(p, CREDS_VALUE, sizeof(CREDS_VALUE)) == 0) {
err = gssx_dec_linux_creds(xdr, creds);
...
}
}A reply that carries two CREDS_VALUE entries therefore overwrites cr_group_info on the second iteration and orphans the group_info allocated by the first call. The earlier free_creds path only releases the last cr_group_info via free_svc_cred(), so the first allocation's refcount stays at one and its kvmalloc-backed storage is leaked. No in-tree caller of gssp_accept_sec_context_upcall() expects more than one CREDS_VALUE per reply.
Fix by tracking whether a CREDS_VALUE option has already been decoded and returning -EINVAL on any subsequent match, so the free_creds path releases the single group_info that was installed.
--- net/sunrpc/auth_gss/gss_rpc_xdr.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/sunrpc/auth_gss/gss_rpc_xdr.c +6 -0
@@ -231,6 +231,7 @@ static int gssx_dec_option_array(struct xdr_stream *xdr, struct gssx_option_array *oa) {struct svc_cred *creds; +bool creds_decoded = false;u32 count, i;__be32 *p;int err;
@@ -281,9 +282,14 @@ static int gssx_dec_option_array(struct xdr_stream *xdr,if (length ==sizeof (CREDS_VALUE ) &&memcmp (p,CREDS_VALUE ,sizeof (CREDS_VALUE )) ==0 ) {/* We have creds here. parse them */ +if (creds_decoded) { + err = -EINVAL ; + goto free_creds; + } err =gssx_dec_linux_creds (xdr, creds);if (err) goto free_creds; + creds_decoded = true; oa->data[0 ].value.len =1 ;/* presence */ }else {/* consume uninteresting buffer */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 250/516 vc_screen: reload vc pointer before if (ret) in vcs_write() to avoid UAF
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yi Yang <[email protected]>
[ Upstream commit 226bd5603371cd9f6642cbb9e9a677f445de3530 ]
The reload of 'vc' added by commit 8fb9ea65c9d1 ("vc_screen: reload load of struct vc_data pointer in vcs_write() to avoid UAF") sits after the 'if (ret)' block, so the copy-failure break path exits the loop without reloading vc. If the vc was kfree()'d via vc_port_destruct during the unlocked copy_from_user() window, the post-loop
'if (written && vc) vcs_scr_updated(vc)' is reached with a stale non-NULL vc. The '&& vc' guard from commit a287620312dc ("vc_screen:
fix null-ptr-deref in vcs_notifier() during concurrent vcs_write") only handles the NULL case, not this stale-non-NULL case; vcs_notifier() then reads param->vc->vc_num from freed memory:
BUG: KASAN: slab-use-after-free in vcs_notifier+0x7c/0xd0 Read of size 2 at addr ffff888007149190 Call Trace: vcs_notifier+0x7c/0xd0 atomic_notifier_call_chain+0x70/0xa0 vcs_scr_updated+0x77/0xa0 vcs_write+0x71b/0x7e0 Allocated by task: vc_allocate -> con_install -> tty_open Freed by task: kfree <- vt_ioctl (VT_DISALLOCATE -> vc_port_destruct)
Move the reload to immediately after console_lock(), before 'if (ret)', so every break path below passes a fresh vc to the post-loop vcs_scr_updated().
--- drivers/tty/vt/vc_screen.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)
drivers/tty/vt/vc_screen.c +13 -12
@@ -643,6 +643,19 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) ret =copy_from_user (con_buf, buf, this_round);console_lock (); +/* The vc might have been freed or vcs_size might have changed +* while we slept to grab the user buffer; recheck here, before +* if (ret), so every break path below passes a fresh vc to the +* post-loop vcs_scr_updated(). Return data written so far. +*/ + vc =vcs_vc (inode, &viewed); +if (!vc) { +if (written) +break ; + ret = -ENXIO ; + goto unlock_out; + } +if (ret) { this_round -= ret;if (!this_round) {
@@ -655,18 +668,6 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) goto unlock_out; } } - -/* The vc might have been freed or vcs_size might have changed -* while we slept to grab the user buffer, so recheck. -* Return data written up to now on failure. -*/ - vc =vcs_vc (inode, &viewed); -if (!vc) { -if (written) -break ; - ret = -ENXIO ; - goto unlock_out; - } size =vcs_size (vc, attr, false);if (size <0 ) {if (written)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 251/516 page_pool: always add GFP_NOWARN for ATOMIC allocations
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit f3b52167a0cb23b27414452fbc1278da2ee884fc ]
Driver authors often forget to add GFP_NOWARN for page allocation from the datapath. This is annoying to users as OOMs are a fact of life, and we pretty much expect network Rx to hit page allocation failures during OOM. Make page pool add GFP_NOWARN for ATOMIC allocations by default.
--- net/core/page_pool.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/core/page_pool.c +6 -0
@@ -185,6 +185,12 @@ static struct page *__page_pool_alloc_pages_slow(struct page_pool *pool,gfp_t gfp = _gfp;dma_addr_t dma; +/* Unconditionally set NOWARN if allocating from NAPI. +* Drivers forget to set it, and OOM reports on packet Rx are useless. +*/ +if ((gfp &GFP_ATOMIC ) ==GFP_ATOMIC ) + gfp |= __GFP_NOWARN; +/* We could always set __GFP_COMP, and avoid this branch, as * prep_new_page() can handle order-0 with __GFP_COMP. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 252/516 mtd: rawnand: vf610_nfc: fix false bitflips on reads of erased pages
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mehmet Fide <[email protected]>
[ Upstream commit 68fe2faf5c69d0e21f94cd695d28f0ba677d484f ]
When the ECC engine fails to decode a page, the driver re-reads the OOB area with the engine bypassed, but runs the erased-page check for the data area on the buffer left in the controller SRAM by the failed transfer.
That buffer does not hold what is on the flash: the failing engine writes a bogus single-bit "correction" into it. In the 60-byte ECC mode the all-0xff content of an erased page always decodes to the same error location, so every erased page shows one stale zero bit at data offset 0x5FD, which the erased-page check then reports as a corrected bitflip.
Edward Karpicz discovered this behaviour and identified the offset on a Colibri VF61; the analysis and the fix build on his finding. Measured with an instrumented driver on a Colibri VF50 (MX30LF1G18AC, 32-bit ECC): reading a 126 MiB partition with nanddump increased the corrected counter by 18035, exactly one per erased page, while raw reads of the same pages return clean 0xff. A v4.4 kernel on the VF61 (MX30LF4G28AC) accumulates the same false counts, so the behaviour follows the controller rather than the chip or the driver generation. Neither the Vybrid reference manual nor the published mask set errata (VFXXX_2N02G) document it. The 45-byte ECC mode is not affected.
Restoring the known byte is not enough: on pages that fail to decode with content other than all-0xff the engine writes its correction wherever the syndrome points (measured at a different offset on such a page), so the check has to run on what the flash holds. Re-read the data area with the ECC engine bypassed, exactly as already done for the OOB area. The corrected counter then stays at zero on both boards.
--- drivers/mtd/nand/raw/vf610_nfc.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/mtd/nand/raw/vf610_nfc.c +11 -4
@@ -518,6 +518,7 @@ static inline int vf610_nfc_correct_data(struct nand_chip *chip, uint8_t *dat,u8 ecc_status;u8 ecc_count;int flips_threshold = nfc->chip.ecc.strength /2 ; +int ret; ecc_status =vf610_nfc_read (nfc, ecc_status_off) &0xff ; ecc_count = ecc_status &ECC_STATUS_ERR_COUNT ;
@@ -525,15 +526,21 @@ static inline int vf610_nfc_correct_data(struct nand_chip *chip, uint8_t *dat,if (!(ecc_status &ECC_STATUS_MASK ))return ecc_count; +/* The failed decode leaves a bogus correction in SRAM; re-read without ECC */ nfc->data_access = true; -nand_read_oob_op (&nfc->chip, page,0 , oob,vf610_nfc_spare_size (mtd)); + ret =nand_read_page_op (&nfc->chip, page,0 , dat, mtd->writesize); +if (!ret) + ret =nand_read_oob_op (&nfc->chip, page,0 , oob, +vf610_nfc_spare_size (mtd)); nfc->data_access = false; +if (ret) +return ret;/* -* On an erased page, bit count (including OOB) should be zero or -* at least less then half of the ECC strength. +* Run the erased-page check with the driver's historic threshold +* of half the ECC strength. */ -return nand_check_erased_ecc_chunk (dat, nfc->chip.ecc.size, oob, +return nand_check_erased_ecc_chunk (dat, mtd->writesize, oob,vf610_nfc_spare_size (mtd),NULL ,0 , flips_threshold); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 253/516 smb: client: split cifsFileInfo bitfields to avoid shared-byte RMW races
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Sorenson <[email protected]>
[ Upstream commit 19465a9aeb664f1d710d0d22c07c31bfb7c85446 ]
The invalidHandle, swapfile, oplock_break_cancelled, offload, and status_file_deleted fields are stored in the same bitfield byte in struct cifsFileInfo, but are updated in different code paths that may run simultaneously, and are protected by different locks. Since bitfield assignments generate byte-level read-modify-write operations, a modification to one flag can overwrite a concurrent modification to another flag.
To avoid these races, convert these flags from a bitfield to separate bool fields.
--- fs/cifs/cifsglob.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/cifs/cifsglob.h +3 -3
@@ -1322,9 +1322,9 @@ struct cifsFileInfo {struct dentry *dentry;struct tcon_link *tlink;unsigned int f_flags; - bool invalidHandle:1; /* file closed via session abend */ - bool swapfile:1; - bool oplock_break_cancelled:1; +bool invalidHandle;/* file closed via session abend */ +bool swapfile; +bool oplock_break_cancelled;unsigned int oplock_epoch;/* epoch from the lease break */ __u32 oplock_level;/* oplock/lease level from the lease break */ int count;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 254/516 wifi: wl12xx: Drop if with an always false condition
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 69ddcea564437ce4b0d5143f37a9154fcef8d3d2 ]
The remove callback is only called after probe completed successfully. In this case platform_set_drvdata() was called with a non-NULL argument (in wlcore_probe()) and so wl is never NULL.
This is a preparation for making platform remove callbacks return void.
Stable-dep-of: a8b8881d0c1a ("wifi: wlcore: Fix runtime PM leak in wlcore_remove()")
--- drivers/net/wireless/ti/wl12xx/main.c | 3 --- 1 file changed, 3 deletions(-)
drivers/net/wireless/ti/wl12xx/main.c +0 -3
@@ -1924,13 +1924,10 @@ static int wl12xx_remove(struct platform_device *pdev)struct wl1271 *wl =platform_get_drvdata (pdev);struct wl12xx_priv *priv; -if (!wl) - goto out; priv = wl->priv;kfree (priv->rx_mem_addr); -out:return wlcore_remove (pdev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 255/516 wifi: wlcore: Convert to platform remove callback returning void
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit f00928012886a07ca6817ea70eb4856ce280ce05 ]
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is (mostly) ignored and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void.
wlcore_remove() returned zero unconditionally. With that converted to return void instead, the wl12xx and wl18xx driver can be converted to .remove_new trivially.
Stable-dep-of: a8b8881d0c1a ("wifi: wlcore: Fix runtime PM leak in wlcore_remove()")
--- drivers/net/wireless/ti/wl12xx/main.c | 6 +++--- drivers/net/wireless/ti/wl18xx/main.c | 2 +- drivers/net/wireless/ti/wlcore/main.c | 6 ++---- drivers/net/wireless/ti/wlcore/wlcore.h | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-)
drivers/net/wireless/ti/wl12xx/main.c +3 -3
@@ -1919,7 +1919,7 @@ static int wl12xx_probe(struct platform_device *pdev)return ret; } -static int wl12xx_remove (struct platform_device *pdev) +static void wl12xx_remove (struct platform_device *pdev) {struct wl1271 *wl =platform_get_drvdata (pdev);struct wl12xx_priv *priv;
@@ -1928,7 +1928,7 @@ static int wl12xx_remove(struct platform_device *pdev)kfree (priv->rx_mem_addr); -return wlcore_remove (pdev); +wlcore_remove (pdev); }static const struct platform_device_id wl12xx_id_table[] = {
@@ -1939,7 +1939,7 @@ MODULE_DEVICE_TABLE(platform, wl12xx_id_table);static struct platform_driver wl12xx_driver = { .probe = wl12xx_probe, - .remove = wl12xx_remove, + .remove_new = wl12xx_remove, .id_table = wl12xx_id_table, .driver = { .name ="wl12xx_driver" ,
drivers/net/wireless/ti/wl18xx/main.c +1 -1
@@ -2033,7 +2033,7 @@ MODULE_DEVICE_TABLE(platform, wl18xx_id_table);static struct platform_driver wl18xx_driver = { .probe = wl18xx_probe, - .remove = wlcore_remove, + .remove_new = wlcore_remove, .id_table = wl18xx_id_table, .driver = { .name ="wl18xx_driver" ,
drivers/net/wireless/ti/wlcore/main.c +2 -4
@@ -6803,7 +6803,7 @@ int wlcore_probe(struct wl1271 *wl, struct platform_device *pdev) }EXPORT_SYMBOL_GPL (wlcore_probe); -int wlcore_remove (struct platform_device *pdev) +void wlcore_remove (struct platform_device *pdev) {struct wlcore_platdev_data *pdev_data =dev_get_platdata (&pdev->dev);struct wl1271 *wl =platform_get_drvdata (pdev);
@@ -6818,7 +6818,7 @@ int wlcore_remove(struct platform_device *pdev)if (pdev_data->family && pdev_data->family->nvs_name)wait_for_completion (&wl->nvs_loading_complete);if (!wl->initialized) -return 0 ; +return ;if (wl->wakeirq >=0 ) {dev_pm_clear_wake_irq (wl->dev);
@@ -6838,8 +6838,6 @@ int wlcore_remove(struct platform_device *pdev)free_irq (wl->irq, wl);wlcore_free_hw (wl); - -return 0 ; }EXPORT_SYMBOL_GPL (wlcore_remove);
drivers/net/wireless/ti/wlcore/wlcore.h +1 -1
@@ -497,7 +497,7 @@ struct wl1271 { };int wlcore_probe (struct wl1271 *wl,struct platform_device *pdev); -int wlcore_remove (struct platform_device *pdev); +void wlcore_remove (struct platform_device *pdev);struct ieee80211_hw *wlcore_alloc_hw (size_t priv_size,u32 aggr_buf_size,u32 mbox_size);int wlcore_free_hw (struct wl1271 *wl);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 256/516 wifi: wlcore: Fix runtime PM leak in wlcore_remove()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit a8b8881d0c1aff544fae190469d86db7b07f43a9 ]
pm_runtime_get_sync() keeps the runtime PM usage counter elevated even when it returns an error, so the reference taken at the beginning of wlcore_remove() has to be dropped on every exit path. When the device was not initialized the function returned early without doing so, leaking the reference.
Release it with pm_runtime_put_noidle() as done on the other early error paths of this driver.
--- drivers/net/wireless/ti/wlcore/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/ti/wlcore/main.c +3 -1
@@ -6817,8 +6817,10 @@ void wlcore_remove(struct platform_device *pdev)if (pdev_data->family && pdev_data->family->nvs_name)wait_for_completion (&wl->nvs_loading_complete); -if (!wl->initialized) +if (!wl->initialized) { +pm_runtime_put_noidle (wl->dev);return ; + }if (wl->wakeirq >=0 ) {dev_pm_clear_wake_irq (wl->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 257/516 RDMA/hns: Fix WQ_MEM_RECLAIM warning
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chengchang Tang <[email protected]>
commit c0a26bbd3f99b7b03f072e3409aff4e6ec8af6f6 upstream.
When sunrpc is used, if a reset triggered, our wq may lead the following trace:
workqueue: WQ_MEM_RECLAIM xprtiod:xprt_rdma_connect_worker [rpcrdma] is flushing !WQ_MEM_RECLAIM hns_roce_irq_workq:flush_work_handle [hns_roce_hw_v2]
WARNING: CPU: 0 PID: 8250 at kernel/workqueue.c:2644 check_flush_dependency+0xe0/0x144 Call trace: check_flush_dependency+0xe0/0x144 start_flush_work.constprop.0+0x1d0/0x2f0 __flush_work.isra.0+0x40/0xb0 flush_work+0x14/0x30 hns_roce_v2_destroy_qp+0xac/0x1e0 [hns_roce_hw_v2] ib_destroy_qp_user+0x9c/0x2b4 rdma_destroy_qp+0x34/0xb0 rpcrdma_ep_destroy+0x28/0xcc [rpcrdma] rpcrdma_ep_put+0x74/0xb4 [rpcrdma] rpcrdma_xprt_disconnect+0x1d8/0x260 [rpcrdma] xprt_rdma_connect_worker+0xc0/0x120 [rpcrdma] process_one_work+0x1cc/0x4d0 worker_thread+0x154/0x414 kthread+0x104/0x144 ret_from_fork+0x10/0x18
Since QP destruction frees memory, this wq should have the WQ_MEM_RECLAIM.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +2 -1
@@ -6087,7 +6087,8 @@ static int hns_roce_v2_init_eq_table(str goto err_request_irq_fail; } - hr_dev->irq_workq =alloc_ordered_workqueue ("hns_roce_irq_workq" ,0 ); + hr_dev->irq_workq =alloc_ordered_workqueue ("hns_roce_irq_workq" , +WQ_MEM_RECLAIM );if (!hr_dev->irq_workq) {dev_err (dev,"Create irq workqueue failed!\n" ); ret = -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 258/516 staging: vchiq_arm: Avoid NULL ptr deref in vchiq_dump_platform_instances
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Wahren <[email protected]>
commit aa899e686d442c63d50f4d369cc02dbbf0941cb0 upstream.
vchiq_get_state() can return a NULL pointer. So handle this cases and avoid a NULL pointer derefence in vchiq_dump_platform_instances.
--- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +3 -0
@@ -2063,6 +2063,9 @@ int vchiq_dump_platform_instances(void *int len;int i; +if (!state) +return -ENOTCONN ; +/* There is no list of instances, so instead scan all services, marking those that have been dumped. */
Greg Kroah-Hartman
maintainerPATCH 259/516 vxlan: Fix potential null-ptr-deref in vxlan_gro_prepare_receive().
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
commit 30a45c0bffdd62350261e2f2689fdba426a33578 upstream.
udp_tunnel_sock_release() could set sk->sk_user_data to NULL while vxlan_gro_prepare_receive() is running.
Let's check if rcu_dereference_sk_user_data() is NULL after skb_gro_remcsum_init().
[ Artem Novikov: Apply the check to the older vxlan_gro_receive()
implementation. Initialize the remcsum state first and use the existing out path for cleanup when sk_user_data has been cleared. ]
--- drivers/net/vxlan/vxlan_core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/vxlan/vxlan_core.c +5 -1
@@ -790,12 +790,16 @@ static struct sk_buff *vxlan_gro_receivestruct vxlanhdr *vh, *vh2;unsigned int hlen, off_vx;int flush =1 ; -struct vxlan_sock *vs =rcu_dereference_sk_user_data (sk); +struct vxlan_sock *vs;__be32 flags;struct gro_remcsum grc;skb_gro_remcsum_init (&grc); + vs =rcu_dereference_sk_user_data (sk); +if (!vs) + goto out; + off_vx =skb_gro_offset (skb); hlen = off_vx +sizeof (*vh); vh =skb_gro_header_fast (skb, off_vx);
Greg Kroah-Hartman
maintainerPATCH 260/516 iommu: disable SVA when CONFIG_X86 is set
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lu Baolu <[email protected]>
commit 72f98ef9a4be30d2a60136dd6faee376f780d06c upstream.
Patch series "Fix stale IOTLB entries for kernel address space", v7.
This proposes a fix for a security vulnerability related to IOMMU Shared Virtual Addressing (SVA). In an SVA context, an IOMMU can cache kernel page table entries. When a kernel page table page is freed and reallocated for another purpose, the IOMMU might still hold stale, incorrect entries. This can be exploited to cause a use-after-free or write-after-free condition, potentially leading to privilege escalation or data corruption.
This solution introduces a deferred freeing mechanism for kernel page table pages, which provides a safe window to notify the IOMMU to invalidate its caches before the page is reused.
This patch (of 8):
In the IOMMU Shared Virtual Addressing (SVA) context, the IOMMU hardware shares and walks the CPU's page tables. The x86 architecture maps the kernel's virtual address space into the upper portion of every process's page table. Consequently, in an SVA context, the IOMMU hardware can walk and cache kernel page table entries.
The Linux kernel currently lacks a notification mechanism for kernel page table changes, specifically when page table pages are freed and reused. The IOMMU driver is only notified of changes to user virtual address mappings. This can cause the IOMMU's internal caches to retain stale entries for kernel VA.
Use-After-Free (UAF) and Write-After-Free (WAF) conditions arise when kernel page table pages are freed and later reallocated. The IOMMU could misinterpret the new data as valid page table entries. The IOMMU might then walk into attacker-controlled memory, leading to arbitrary physical memory DMA access or privilege escalation. This is also a Write-After-Free issue, as the IOMMU will potentially continue to write Accessed and Dirty bits to the freed memory while attempting to walk the stale page tables.
Currently, SVA contexts are unprivileged and cannot access kernel mappings. However, the IOMMU will still walk kernel-only page tables all the way down to the leaf entries, where it realizes the mapping is for the kernel and errors out. This means the IOMMU still caches these intermediate page table entries, making the described vulnerability a real concern.
Disable SVA on x86 architecture until the IOMMU can receive notification to flush the paging cache before freeing the CPU kernel page table pages.
[ The context change is due to the commit
be51b1d6bbff ("iommu/sva: Refactoring iommu_sva_bind/unbind_device()") and the commit 757636ed2607 ("iommu: Rename iommu-sva-lib.{c,h}") in v6.2 which are irrelevant to the logic of this patch. ]
--- drivers/iommu/iommu.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iommu/iommu.c +3 -0
@@ -2988,6 +2988,9 @@ iommu_sva_bind_device(struct device *devstruct iommu_sva *handle =ERR_PTR (-EINVAL );const struct iommu_ops *ops = dev->bus->iommu_ops; +if (IS_ENABLED (CONFIG_X86 )) +return ERR_PTR (-EOPNOTSUPP ); +if (!ops || !ops->sva_bind)return ERR_PTR (-ENODEV );
Greg Kroah-Hartman
maintainerPATCH 261/516 ALSA: seq: Clear variable event pointer on read
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
commit 705dd6dcbc0ea87351c660c1a6443f85f1001c76 upstream.
snd_seq_read() copies a queued variable-length event header to userspace before expanding the payload. Queued variable-length events use SNDRV_SEQ_EXT_CHAINED internally, and data.ext.ptr points at the first extension cell.
The read side strips SNDRV_SEQ_EXT_* bits from data.ext.len before the copy, but it leaves data.ext.ptr untouched. A userspace sequencer client can therefore write a direct variable event to itself and read back the extension-cell kernel address from the returned header.
Clear the temporary header pointer before copy_to_user(). The original queued event remains unchanged and is still passed to snd_seq_expand_var_event(), so payload expansion keeps using the internal chain.
--- sound/core/seq/seq_clientmgr.c | 1 + 1 file changed, 1 insertion(+)
sound/core/seq/seq_clientmgr.c +1 -0
@@ -441,6 +441,7 @@ static ssize_t snd_seq_read(struct filestruct snd_seq_event tmpev; tmpev = cell->event; tmpev.data.ext.len &= ~SNDRV_SEQ_EXT_MASK ; + tmpev.data.ext.ptr =NULL ;if (copy_to_user (buf, &tmpev,sizeof (struct snd_seq_event ))) { err = -EFAULT ;break ;
Greg Kroah-Hartman
maintainerPATCH 262/516 wifi: wcn36xx: fix heap overflow from oversized firmware HAL response
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tristan Madani <[email protected]>
commit 88a240d86d3d64521f9194abe185ac71cc74d0bd upstream.
The firmware response dispatcher copies all synchronous HAL responses into the 4096-byte hal_buf without validating the response length. A response exceeding WCN36XX_HAL_BUF_SIZE causes a heap buffer overflow with firmware-controlled content.
Add a bounds check on the response length.
--- drivers/net/wireless/ath/wcn36xx/smd.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/ath/wcn36xx/smd.c +4 -0
@@ -2835,6 +2835,10 @@ int wcn36xx_smd_rsp_process(struct rpmsgcase WCN36XX_HAL_8023_MULTICAST_LIST_RSP :case WCN36XX_HAL_START_SCAN_OFFLOAD_RSP :case WCN36XX_HAL_STOP_SCAN_OFFLOAD_RSP : +if (len >WCN36XX_HAL_BUF_SIZE ) { +wcn36xx_warn ("HAL response too large: %d\n" , len); +break ; + }memcpy (wcn->hal_buf, buf, len); wcn->hal_rsp_len = len;complete (&wcn->hal_rsp_compl);
Greg Kroah-Hartman
maintainerPATCH 263/516 net: usb: qmi_wwan: add Quectel EG120K-EA
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gilberto Conde <[email protected]>
commit 0f2fd31f63c65c409bd336af3a42d478a9207c1f upstream.
Add support for the Quectel EG120K-EA LTE Cat.12 module (USB ID 2c7c:030b). Its QMI interface (interface 4) uses class/subclass/protocol ff/ff/ff like the other recent Quectel modules, so match it the same way.
The product ID is shared with the EM060K, which the option driver already knows and uses to claim the serial interfaces. Without a qmi_wwan entry the data interface is left unbound.
Tested on a GL.iNet GL-X2000, where the module is soldered down and enumerates at SuperSpeed: cdc-wdm0 and wwan0 appear and ModemManager brings up a data session.
T: Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=5000 MxCh= 0 D: Ver= 3.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs= 1 P: Vendor=2c7c ProdID=030b Rev= 5.04 S: Manufacturer=Quectel S: Product=EG120K-EA S: SerialNumber=45546267 C:* #Ifs= 6 Cfg#= 1 Atr=a0 MxPwr=896mA I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option E: Ad=01(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms E: Ad=81(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=40 Driver=option E: Ad=83(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=82(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=85(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=84(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms E: Ad=03(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=87(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=86(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms E: Ad=04(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan E: Ad=88(I) Atr=03(Int.) MxPS= 8 Ivl=32ms E: Ad=8e(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms E: Ad=0f(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
I:* If#=12 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=ff Prot=70 Driver=(none)
E: Ad=89(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
--- drivers/net/usb/qmi_wwan.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/usb/qmi_wwan.c +1 -0
@@ -1029,6 +1029,7 @@ static const struct usb_device_id produc {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0122)}, /* Quectel RG650V */ {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0125)}, /* Quectel EC25, EC20 R2.0 Mini PCIe */ {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0306)}, /* Quectel EP06/EG06/EM06 */ + {QMI_MATCH_FF_FF_FF(0x2c7c, 0x030b)}, /* Quectel EM060K/EG120K-EA */ {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0512)}, /* Quectel EG12/EM12 */ {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0620)}, /* Quectel EM160R-GL */ {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0800)}, /* Quectel RM500Q-GL */
Greg Kroah-Hartman
maintainerPATCH 264/516 usb: typec: tcpm: fix debug accessory mode detection for sink ports
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Yang <[email protected]>
[ Upstream commit f6ec9bb4acc7182b25a793ad094a764e1cb819a7 ]
The port in debug accessory mode can be either a source or sink. The previous tcpm_port_is_debug() function only checked for source port.
Commit 8db73e6a42b6 ("usb: typec: tcpm: allow sink (ufp) to toggle into accessory mode debug") changed the detection logic to support both roles, but left some logic in _tcpm_cc_change() unchanged, This causes the state machine to transition to an incorrect state when operating as a sink in debug accessory mode. Log as below:
[ 978.637541] CC1: 0 -> 5, CC2: 0 -> 5 [state TOGGLING, polarity 0, connected] [ 978.637567] state change TOGGLING -> SRC_ATTACH_WAIT [rev1 NONE_AMS] [ 978.637596] pending state change SRC_ATTACH_WAIT -> DEBUG_ACC_ATTACHED @ 180 ms [rev1 NONE_AMS] [ 978.647098] CC1: 5 -> 0, CC2: 5 -> 5 [state SRC_ATTACH_WAIT, polarity 0, connected] [ 978.647115] state change SRC_ATTACH_WAIT -> SRC_ATTACH_WAIT [rev1 NONE_AMS]
It should go to SNK_ATTACH_WAIT instead of SRC_ATTACH_WAIT state.
To fix this, add tcpm_port_is_debug_source() and tcpm_port_is_debug_sink() helper to explicitly identify the power mode in debug accessory mode. Update the state transition logic in _tcpm_cc_change() to ensure the state machine transitions comply with Type-C specification. Also update the logic in run_state_machine() to keep consistency.
[5.10 dependency adaptation: This tree does not contain 8db73e6a42b6 or sink debug accessory support. Retain the source debug predicate and its source-path callers, and keep tcpm_port_is_debug() source-only. Drop the sink predicate and sink accessory state transitions, which require the missing feature. This supplies tcpm_port_is_debug_source() for cd3b9cea675b without changing 5.10 accessory behavior or adding functions. The target applies with a three-way merge; its references to AMS_START and upcoming_state still require a separate 5.10 adaptation because AMS and Collision Avoidance was not backported.]
Stable-dep-of: cd3b9cea675b ("usb: typec: tcpm: constrain TCPM_SOURCING_VBUS event handling")
--- drivers/usb/typec/tcpm/tcpm.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +7 -4
@@ -420,9 +420,12 @@ struct pd_rx_event { (tcpm_cc_is_source((port)->cc2) && \ !tcpm_cc_is_source((port)->cc1))) -#define tcpm_port_is_debug (port) \ +#define tcpm_port_is_debug_source (port) \ (tcpm_cc_is_source((port)->cc1) && tcpm_cc_is_source((port)->cc2)) +#define tcpm_port_is_debug (port) \ + tcpm_port_is_debug_source(port) +#define tcpm_port_is_audio (port) \ (tcpm_cc_is_audio((port)->cc1) && tcpm_cc_is_audio((port)->cc2))
@@ -3095,7 +3098,7 @@ static void run_state_machine(struct tcptcpm_set_state (port,SNK_UNATTACHED ,PD_T_DRP_SNK );break ;case SRC_ATTACH_WAIT : -if (tcpm_port_is_debug (port)) +if (tcpm_port_is_debug_source (port))tcpm_set_state (port,DEBUG_ACC_ATTACHED ,PD_T_CC_DEBOUNCE );else if (tcpm_port_is_audio (port))
@@ -3918,7 +3921,7 @@ static void _tcpm_cc_change(struct tcpm_switch (port->state) {case TOGGLING : -if (tcpm_port_is_debug (port) ||tcpm_port_is_audio (port) || +if (tcpm_port_is_debug_source (port) ||tcpm_port_is_audio (port) ||tcpm_port_is_source (port))tcpm_set_state (port,SRC_ATTACH_WAIT ,0 );else if (tcpm_port_is_sink (port))
@@ -3926,7 +3929,7 @@ static void _tcpm_cc_change(struct tcpm_break ;case SRC_UNATTACHED :case ACC_UNATTACHED : -if (tcpm_port_is_debug (port) ||tcpm_port_is_audio (port) || +if (tcpm_port_is_debug_source (port) ||tcpm_port_is_audio (port) ||tcpm_port_is_source (port))tcpm_set_state (port,SRC_ATTACH_WAIT ,0 );break ;
Greg Kroah-Hartman
maintainerPATCH 265/516 usb: typec: tcpm: constrain TCPM_SOURCING_VBUS event handling
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amit Sunil Dhamne <[email protected]>
[ Upstream commit cd3b9cea675bbfebc223f007dc2f4e79524fa54c ]
When a sink detach occurs while waiting for TX send status, the old TCPM_SOURCING_VBUS event along with TCPM_VBUS_EVENT and TCPM_CC_EVENT can be queued in port->pd_events. Because TCPM_SOURCING_VBUS is evaluated after TCPM_VBUS_EVENT and TCPM_CC_EVENT in tcpm_pd_event_handler(), a stale TCPM_SOURCING_VBUS event can override the detach handling and incorrectly set port->vbus_source and port->vbus_present to true.
Add a state guard to check that the port is either operating as a Source (tcpm_port_is_source(port)) or in a Fast Role Swap (FRS) state up to FR_SWAP_SNK_SRC_SOURCE_VBUS_APPLIED before processing TCPM_SOURCING_VBUS. Otherwise, discard and log the event.
Log snippet for error condition before fix:
[72792.204955] state change SRC_ATTACHED -> SRC_STARTUP [rev3 NONE_AMS] [72792.204960] sourcing vbus [72792.204962] VBUS on [72792.204970] AMS POWER_NEGOTIATION start [72792.204974] cc:=4 [72792.205319] state change SRC_STARTUP -> AMS_START [rev3 POWER_NEGOTIATION] [72792.205325] state change AMS_START -> SRC_SEND_CAPABILITIES [rev3 POWER_NEGOTIATION] [72792.205332] PD TX, header: 0x11a1 [72792.216911] PD TX complete, status: 2 [72792.216957] pending state change SRC_SEND_CAPABILITIES -> SRC_SEND_CAPABILITIES @ 150 ms [rev3 POWER_NEGOTIATION] [72792.218005] VBUS off [72792.218013] pending state change SRC_SEND_CAPABILITIES -> SNK_UNATTACHED @ 650 ms [rev3 POWER_NEGOTIATION] [72792.218020] VBUS VSAFE0V [72792.218024] state change SRC_SEND_CAPABILITIES -> SNK_UNATTACHED [rev3 POWER_NEGOTIATION] [72792.218458] CC1: 2 -> 0, CC2: 0 -> 0 [state SNK_UNATTACHED, polarity 0, disconnected] [72792.218467] VBUS on --> VBUS left on [72792.218980] disable vbus discharge ret:0 [72792.235193] Start toggling
After fix:
[ 1195.291691] state change SRC_ATTACHED -> SRC_STARTUP [rev3 NONE_AMS] [ 1195.291698] sourcing vbus [ 1195.291700] VBUS on [ 1195.291707] AMS POWER_NEGOTIATION start [ 1195.291710] cc:=4 [ 1195.291758] state change SRC_STARTUP -> AMS_START [rev3 POWER_NEGOTIATION] [ 1195.291794] state change AMS_START -> SRC_SEND_CAPABILITIES [rev3 POWER_NEGOTIATION] [ 1195.291798] PD TX, header: 0x11a1 [ 1195.297056] PD TX complete, status: 2 [ 1195.297092] pending state change SRC_SEND_CAPABILITIES -> SRC_SEND_CAPABILITIES @ 150 ms [rev3 POWER_NEGOTIATION] [ 1195.297177] VBUS off [ 1195.297184] pending state change SRC_SEND_CAPABILITIES -> SNK_UNATTACHED @ 650 ms [rev3 POWER_NEGOTIATION] [ 1195.297227] CC1: 2 -> 0, CC2: 0 -> 0 [state SRC_SEND_CAPABILITIES, polarity 0, disconnected] [ 1195.307469] cc:=2 [ 1195.307544] pending state change SRC_SEND_CAPABILITIES -> SNK_UNATTACHED @ 650 ms [rev3 POWER_NEGOTIATION] [ 1195.307555] Discarding sourcing vbus! Invalid state SRC_SEND_CAPABILITIES [ 1195.957636] state change SRC_SEND_CAPABILITIES -> SNK_UNATTACHED [delayed 650 ms] [ 1195.957732] disable vbus discharge ret:0 [ 1195.970196] Start toggling [ 1195.970468] VBUS off [ 1196.051637] VBUS off [ 1196.051642] VBUS VSAFE0V
--- drivers/usb/typec/tcpm/tcpm.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +20 -6
@@ -4287,16 +4287,30 @@ static void tcpm_pd_event_handler(structtcpm_log (port,"Discarding FRS_SIGNAL! Not in sink ready" ); }if (events &TCPM_SOURCING_VBUS ) { -tcpm_log (port,"sourcing vbus" );/* * In fast role swap case TCPC autonomously sources vbus. Set vbus_source -* true as TCPM wouldn't have called tcpm_set_vbus. +* true conditionally as TCPM wouldn't have called tcpm_set_vbus. +* If TCPM calls tcpm_set_vbus to source vbus, vbus_source would already +* be true. * -* When vbus is sourced on the command on TCPM i.e. TCPM called -* tcpm_set_vbus to source vbus, vbus_source would already be true. +* When TCPM_FRS_EVENT and TCPM_SOURCING_VBUS arrive simultaneously, +* handling TCPM_FRS_EVENT above transitions the state to FR_SWAP_SEND. */ - port->vbus_source = true; -_tcpm_pd_vbus_on (port); + +if (tcpm_port_is_source (port) || +tcpm_port_is_debug_source (port) || + port->state ==FR_SWAP_SEND || + port->state ==FR_SWAP_SEND_TIMEOUT || + port->state ==FR_SWAP_SNK_SRC_TRANSITION_TO_OFF || + port->state ==FR_SWAP_SNK_SRC_NEW_SINK_READY || + port->state ==FR_SWAP_SNK_SRC_SOURCE_VBUS_APPLIED ) { +tcpm_log (port,"sourcing vbus" ); + port->vbus_source = true; +_tcpm_pd_vbus_on (port); + }else { +tcpm_log (port,"Discarding sourcing vbus! Invalid state %s" , + tcpm_states[port->state]); + } }spin_lock (&port->pd_event_lock);
Greg Kroah-Hartman
maintainerPATCH 266/516 xen/netfront: drop RX packets with a short Ethernet header
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit 089e58805c452e52179482b1025a8e309a57f801 upstream.
handle_incoming_queue() pulls pull_to bytes into the head before calling eth_type_trans(). pull_to is the length of the first RX slot, capped at RX_COPY_THRESHOLD, and that length comes from the backend. Nothing checks it against ETH_HLEN.
If the first slot is shorter than ETH_HLEN and more slots follow, the head ends up shorter than an Ethernet header while skb->len is longer, and eth_type_trans() BUG()s in __skb_pull(). If the whole packet is shorter than ETH_HLEN, eth_type_trans() reads the header past the end of the data instead.
Pull at least ETH_HLEN, and drop the packet if that fails, which also drops packets too short to hold an Ethernet header. This also checks the return value of the pull, which was ignored.
--- drivers/net/xen-netfront.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/net/xen-netfront.c +10 -2
@@ -1229,8 +1229,16 @@ static int handle_incoming_queue(structwhile ((skb =__skb_dequeue (rxq)) !=NULL ) {int pull_to =NETFRONT_SKB_CB (skb)->pull_to; -if (pull_to >skb_headlen (skb)) -__pskb_pull_tail (skb, pull_to -skb_headlen (skb)); +/* pull_to comes from the first slot's length, which the +* backend controls. Make sure the head holds at least an +* Ethernet header for eth_type_trans(). +*/ +if (!pskb_may_pull (skb,max (pull_to,ETH_HLEN ))) { +kfree_skb (skb); + packets_dropped++; + queue->info->netdev->stats.rx_errors++; +continue ; + }/* Ethernet work: Delayed to here as it peeks the header. */ skb->protocol =eth_type_trans (skb, queue->info->netdev);
Greg Kroah-Hartman
maintainerPATCH 267/516 smb: client: clear setuid/setgid bit on write with cifsacl/modefromsid/posix extensions
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiangshan Yi <[email protected]>
[ Upstream commit b8e5dc4f95e5484159b343903f302eb6d783f2e6 ]
When a file has the setuid or setgid bit set and is written to, the VFS strips those bits and issues a setattr with ATTR_KILL_SUID/ATTR_KILL_SGID together with an ATTR_MODE carrying the already-cleared mode.
Both cifs_setattr_unix() and cifs_setattr_nounix() unconditionally dropped ATTR_MODE in that case:
/* skip mode change if it's just for clearing setuid/setgid */ if (attrs->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID)) attrs->ia_valid &= ~ATTR_MODE;
This is fine for the default mount, where the mode is only emulated via the DOS read-only attribute and cannot represent the setuid/setgid bits anyway. However, with the "cifsacl" or "modefromsid" mount options the mode is stored on the server through an ACL (id_mode_to_cifs_acl()), with the SMB3.1.1 POSIX extensions the mode is sent to the server directly, and with the SMB1 Unix extensions (cifs_setattr_unix) the mode is sent via CIFSSMBUnixSetPathInfo(). In all those cases dropping ATTR_MODE means the cleared mode is never pushed to the server, so the setuid/setgid bit survives the write.
This is a security issue: on local filesystems the setuid bit is stripped when a file is written, but over these cifs.ko mounts the bit persists on the server, potentially allowing an unexpected privilege escalation on subsequent execution.
Fix this in two places:
1. cifs_setattr_nounix(): only take the "skip mode change" shortcut when the mode is emulated via the DOS read-only attribute (i.e. neither cifsacl/modefromsid nor the SMB3.1.1 POSIX extensions are in effect), so that the cleared mode is propagated to the server in the ACL / POSIX cases.
2. cifs_setattr_unix(): this function is only called when Unix extensions are in effect, so the mode is always stored on the server. Remove the shortcut entirely so that the cleared mode is always pushed.
[ Backport note for 5.10: code lives in fs/cifs/inode.c; no sbflags
local exists here, so test cifs_sb->mnt_cifs_flags directly (same flag bits). Drop the upstream posix_extensions clause: 5.10 lacks d413eabff18d ("fs/smb/client: implement chmod() for SMB3 POSIX Extensions"), so cifs_setattr_nounix() has no POSIX ATTR_MODE branch; match its CIFS_ACL/MODE_FROM_SID check. ]
--- fs/cifs/inode.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-)
fs/cifs/inode.c +23 -5
@@ -2646,9 +2646,13 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs) goto out; } -/* skip mode change if it's just for clearing setuid/setgid */ -if (attrs->ia_valid & (ATTR_KILL_SUID |ATTR_KILL_SGID )) - attrs->ia_valid &= ~ATTR_MODE ; +/* +* This function is only called when Unix extensions are in effect, +* so the mode is always sent to and stored on the server. Do not +* skip the mode change when clearing setuid/setgid bits: dropping +* ATTR_MODE here would leave those bits set on the server after a +* write, which is a security issue. +*/ args =kmalloc (sizeof (*args),GFP_KERNEL );if (args ==NULL ) {
@@ -2832,8 +2836,22 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_SET_UID )) attrs->ia_valid &= ~(ATTR_UID |ATTR_GID ); -/* skip mode change if it's just for clearing setuid/setgid */ -if (attrs->ia_valid & (ATTR_KILL_SUID |ATTR_KILL_SGID )) +/* +* Skip the mode change if it is only being done to clear the +* setuid/setgid bits *and* the mode is emulated via the DOS +* read-only attribute (the default, non-ACL case), which cannot +* represent the setuid/setgid bits anyway. +* +* When the mode is instead stored on the server - i.e. with the +* cifsacl or modefromsid mount options (via an ACL) - the cleared +* mode must be pushed to the server. Dropping ATTR_MODE here +* would leave the setuid/setgid bit set on the server after a +* write, which is a security issue (the bits are not stripped as +* they are on local filesystems). +*/ +if ((attrs->ia_valid & (ATTR_KILL_SUID |ATTR_KILL_SGID )) && + !(cifs_sb->mnt_cifs_flags & + (CIFS_MOUNT_CIFS_ACL |CIFS_MOUNT_MODE_FROM_SID ))) attrs->ia_valid &= ~ATTR_MODE ;if (attrs->ia_valid &ATTR_MODE ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 268/516 drm/amd/pm/si: Check AMD_IS_MOBILITY flag for PPSMC_SYSTEMFLAG_GPIO_DC
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit cd883d0a3937df82a5ea03709ba8ba623b868419 ]
Unfortunately, some desktop boards eg. the FirePro D500 have the HARDWAREDC platform flag set and also have a battery power state configured in their VBIOS. This makes no sense for a desktop GPU and results in incorrect behaviour: the clocks are stuck at lowest.
We observed that the kernel driver can work around the issue in two possible ways:
1. Set PPSMC_SWSTATE_FLAG_DC on all power states
2. Clear PPSMC_SYSTEMFLAG_GPIO_DC
We think that the PPSMC_SYSTEMFLAG_GPIO_DC flag makes the SMC assume it's running on battery even though this is a desktop machine with no battery, and that's why it doesn't do DPM on power states without PPSMC_SYSTEMFLAG_GPIO_DC.
Issue was uncovered by "Fix updating clock limits from power states" because previously the limits for the battery state were not tracked separately. However, battery power state has lower frequencies and voltages, so the kernel doesn't set the DC flag on the current power state anymore. That causes the SMC to be stuck on the lowest clocks.
Let's clear PPSMC_SYSTEMFLAG_GPIO_DC on desktop GPUs. We can use the AMD_IS_MOBILITY flag to determine that.
--- drivers/gpu/drm/amd/pm/powerplay/si_dpm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/powerplay/si_dpm.c +2 -1
@@ -5164,7 +5164,8 @@ static int si_init_smc_table(struct amdgpu_device *adev)break ; } -if (adev->pm.dpm.platform_caps &ATOM_PP_PLATFORM_CAP_HARDWAREDC ) +if ((adev->flags &AMD_IS_MOBILITY ) && + (adev->pm.dpm.platform_caps &ATOM_PP_PLATFORM_CAP_HARDWAREDC )) table->systemFlags |=PPSMC_SYSTEMFLAG_GPIO_DC ;if (adev->pm.dpm.platform_caps &ATOM_PP_PLATFORM_CAP_REGULATOR_HOT ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 269/516 soc: qcom: geni-se: Correct QUP Core ICC vote constants
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viken Dadhaniya <[email protected]>
[ Upstream commit 1cd9b1be5a9c56fd69e3f555b200a1844f9b873e ]
The GENI_TO_CORE ("qup-core") ICC vote selects the QUP Core 2X clock rate. The CORE_2X_*_MHZ constants are expressed in Bps, but their values are several orders of magnitude too small. For example, the 50 MHz threshold is represented by 2500 rather than 25000000 Bps.
As a result, clients using these constants can severely under-vote the QUP Core clock.
Correct the constants to their intended Bps thresholds so that the ICC provider selects the corresponding QUP Core 2X clock rate. Drop the unused definitions.
--- include/linux/qcom-geni-se.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
include/linux/qcom-geni-se.h +5 -10
@@ -252,17 +252,12 @@ struct geni_se {#define QUP_SE_VERSION_2_5 0x20050000/* -* Define bandwidth thresholds that cause the underlying Core 2X interconnect -* clock to run at the named frequency. These baseline values are recommended -* by the hardware team, and are not dynamically scaled with GENI bandwidth -* beyond basic on/off. +* QUP Core 2X clock votes used by GENI clients through the "qup-core" ICC +* path. Values are in Bps and must be converted with Bps_to_icc() before +* setting avg_bw. */ -#define CORE_2X_19_2_MHZ 960 -#define CORE_2X_50_MHZ 2500 -#define CORE_2X_100_MHZ 5000 -#define CORE_2X_150_MHZ 7500 -#define CORE_2X_200_MHZ 10000 -#define CORE_2X_236_MHZ 16383 +#define CORE_2X_19_2_MHZ 9600000 +#define CORE_2X_50_MHZ 25000000#define GENI_DEFAULT_BW Bps_to_icc(1000)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 270/516 tty: fix saved termios reset race
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit 8df07fe93573e9e548d6645273e9bcb6eb74059e ]
Resetting saved termios state on device registration is needed where a minor number can be reused for an entirely different device and where the old settings may prevent the port from even being opened (e.g. when CLOCAL is not set).
Not all TTY drivers guarantee that the minor number is no longer in use when registering devices however, something which can lead to a use-after-free when closing a TTY (and saving its termios) races with re-registration.
Add a new TTY_DRIVER_RESET_SAVED_TERMIOS flag to request that any saved termios state is reset on registration and only set it for drivers that make sure that the minor number is no longer in use.
--- drivers/staging/greybus/uart.c | 3 ++- drivers/tty/tty_io.c | 18 ++++++++++-------- drivers/usb/class/cdc-acm.c | 3 ++- drivers/usb/serial/usb-serial.c | 3 ++- include/linux/tty_driver.h | 5 +++++ 5 files changed, 21 insertions(+), 11 deletions(-)
drivers/staging/greybus/uart.c +2 -1
@@ -974,7 +974,8 @@ static int gb_tty_init(void) gb_tty_driver->minor_start =0 ; gb_tty_driver->type =TTY_DRIVER_TYPE_SERIAL ; gb_tty_driver->subtype =SERIAL_TYPE_NORMAL ; - gb_tty_driver->flags =TTY_DRIVER_REAL_RAW |TTY_DRIVER_DYNAMIC_DEV ; + gb_tty_driver->flags =TTY_DRIVER_REAL_RAW |TTY_DRIVER_DYNAMIC_DEV | +TTY_DRIVER_RESET_SAVED_TERMIOS ; gb_tty_driver->init_termios = tty_std_termios; gb_tty_driver->init_termios.c_cflag =B9600 |CS8 |CREAD |HUPCL |CLOCAL ;
drivers/tty/tty_io.c +10 -8
@@ -3244,14 +3244,16 @@ struct device *tty_register_device_attr(struct tty_driver *driver, goto err_put;if (!(driver->flags &TTY_DRIVER_DYNAMIC_ALLOC )) { -/* -* Free any saved termios data so that the termios state is -* reset when reusing a minor number. -*/ - tp = driver->termios[index]; -if (tp) { - driver->termios[index] =NULL ; -kfree (tp); +if (driver->flags &TTY_DRIVER_RESET_SAVED_TERMIOS ) { +/* +* Free any saved termios data so that the termios +* state is reset when reusing a minor number. +*/ + tp = driver->termios[index]; +if (tp) { + driver->termios[index] =NULL ; +kfree (tp); + } } retval =tty_cdev_add (driver, devt, index,1 );
drivers/usb/class/cdc-acm.c +2 -1
@@ -2094,7 +2094,8 @@ static int __init acm_init(void) acm_tty_driver->minor_start =0 , acm_tty_driver->type =TTY_DRIVER_TYPE_SERIAL , acm_tty_driver->subtype =SERIAL_TYPE_NORMAL , - acm_tty_driver->flags =TTY_DRIVER_REAL_RAW |TTY_DRIVER_DYNAMIC_DEV ; + acm_tty_driver->flags =TTY_DRIVER_REAL_RAW |TTY_DRIVER_DYNAMIC_DEV | +TTY_DRIVER_RESET_SAVED_TERMIOS ; acm_tty_driver->init_termios = tty_std_termios; acm_tty_driver->init_termios.c_cflag =B9600 |CS8 |CREAD |HUPCL |CLOCAL ;
drivers/usb/serial/usb-serial.c +2 -1
@@ -1232,7 +1232,8 @@ static int __init usb_serial_init(void) usb_serial_tty_driver->type =TTY_DRIVER_TYPE_SERIAL ; usb_serial_tty_driver->subtype =SERIAL_TYPE_NORMAL ; usb_serial_tty_driver->flags =TTY_DRIVER_REAL_RAW | -TTY_DRIVER_DYNAMIC_DEV ; +TTY_DRIVER_DYNAMIC_DEV | +TTY_DRIVER_RESET_SAVED_TERMIOS ; usb_serial_tty_driver->init_termios = tty_std_termios; usb_serial_tty_driver->init_termios.c_cflag =B9600 |CS8 |CREAD |HUPCL |CLOCAL ;
include/linux/tty_driver.h +5 -0
@@ -403,6 +403,10 @@ static inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d)* other words create /dev/ttyprintk and not /dev/ttyprintk0. * Applicable only when a driver for a single tty device is * being allocated. +* +* TTY_DRIVER_RESET_SAVED_TERMIOS -- reset any saved termios settings on +* device registration when reusing a minor number. Must only be set by +* drivers that guarantee that the minor number is no longer in use. */ #define TTY_DRIVER_INSTALLED 0x0001#define TTY_DRIVER_RESET_TERMIOS 0x0002
@@ -412,6 +416,7 @@ static inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d)#define TTY_DRIVER_HARDWARE_BREAK 0x0020#define TTY_DRIVER_DYNAMIC_ALLOC 0x0040#define TTY_DRIVER_UNNUMBERED_NODE 0x0080 +#define TTY_DRIVER_RESET_SAVED_TERMIOS 0x0200/* tty driver types */ #define TTY_DRIVER_TYPE_SYSTEM 0x0001
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 271/516 perf: Require kernel access for text poke events
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhengchuan Liang <[email protected]>
[ Upstream commit 357e8a77a501d96c9517f01f4a211eed5e9c9184 ]
Perf events with exclude_kernel=1 can be opened without kernel perf access. However, exclude_kernel does not suppress text-poke sideband records. Every PERF_RECORD_TEXT_POKE is marked PERF_RECORD_MISC_KERNEL and contains a raw kernel instruction address.
An unprivileged task can therefore open and mmap a task-local software event with text_poke=1. Both opening a count-only tracepoint event and configuring UDP GRO for ESP-in-UDP cause updates to inline static calls; the observer receives the relocated addresses of the modified instructions. For a known kernel image, any such address reveals the runtime kernel text base despite KASLR.
Call perf_allow_kernel() whenever attr.text_poke is set, regardless of exclude_kernel. Events that neither monitor kernel execution nor request text-poke records retain their existing permissions.
--- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/core.c +1 -1
@@ -11936,7 +11936,7 @@ SYSCALL_DEFINE5(perf_event_open,if (err)return err; -if (!attr.exclude_kernel) { +if (!attr.exclude_kernel || attr.text_poke) { err =perf_allow_kernel (&attr);if (err)return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 272/516 ALSA: seq: Serialize compat port-info ioctls
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
[ Upstream commit 95b2e0361c88753afa030c10698be0a1a5b67650 ]
The native sequencer ioctl path serializes handler calls with client->ioctl_mutex, but the translated port-info compat path invokes the same handlers through snd_seq_kernel_client_ctl() without taking that mutex.
This lets concurrent compat CREATE_PORT requests pass the port-count check before any request reaches the serialized insertion. The computed integer port index can then exceed the address field range and wrap to an existing index. Subsequent subscriber teardown can resolve the duplicate address to the wrong port and access a freed subscriber.
Take ioctl_mutex while dispatching converted port-info requests, matching the native ioctl path. All translated port-info commands share this helper, so their accesses to the client port state are serialized as well.
--- sound/core/seq/seq_compat.c | 2 ++ 1 file changed, 2 insertions(+)
sound/core/seq/seq_compat.c +2 -0
@@ -44,7 +44,9 @@ static int snd_seq_call_port_info_ioctl(struct snd_seq_client *client, unsigned goto error; data->kernel =NULL ; +mutex_lock (&client->ioctl_mutex); err =snd_seq_kernel_client_ctl (client->number, cmd, data); +mutex_unlock (&client->ioctl_mutex);if (err <0 ) goto error;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 273/516 arm64: errata: Factor out broken AMU const counter cap
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Beata Michalska <[email protected]>
[ Upstream commit 573371caf7aea8582212da81dcead2c3f48fac4b ]
Move the workaround from the erratum 2457168-specific cpucap to a generic broken AMU constant-counter one. This keeps the existing Cortex-A510 handling unchanged while allowing other errata with similar AMU constant counter issue to share the capability bit and call sites.
Dropped changes related to CPPC/FFH as support for that is not available here. Additionally renamed define for WORKAROUND_2457168 to new one, WORKAROUND_BROKEN_AMU_CONSTCNT to reuse it as this kernel still relies on the cpucaps header file for the workaround/errata ids.
--- arch/arm64/Kconfig | 8 ++++++++ arch/arm64/include/asm/cpucaps.h | 2 +- arch/arm64/kernel/cpu_errata.c | 19 ++++++++++++++----- arch/arm64/kernel/cpufeature.c | 2 +- 4 files changed, 24 insertions(+), 7 deletions(-)
arch/arm64/Kconfig +8 -0
@@ -673,9 +673,17 @@ config ARM64_ERRATUM_1508412 If unsure, say Y. +config ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT + bool + # Targeting errata affecting AMEVCNTR01, the AMU constant counter. + # On affected CPUs the counter may not increment at the expected rate, + # making it unreliable. As a result, AMU users should treat it as + # unavailable rather than relying on misleading counter values. + config ARM64_ERRATUM_2457168 bool "Cortex-A510: 2457168: workaround for AMEVCNTR01 incrementing incorrectly" depends on ARM64_AMU_EXTN + select ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT default y help This option adds the workaround for ARM Cortex-A510 erratum 2457168.
arch/arm64/include/asm/cpucaps.h +1 -1
@@ -67,7 +67,7 @@#define ARM64_MTE 57#define ARM64_WORKAROUND_1508412 58#define ARM64_SPECTRE_BHB 59 -#define ARM64_WORKAROUND_2457168 60 +#define ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT 60#define ARM64_WORKAROUND_1742098 61#define ARM64_WORKAROUND_SPECULATIVE_SSBS 62
arch/arm64/kernel/cpu_errata.c +14 -5
@@ -260,6 +260,16 @@ static const struct arm64_cpu_capabilities arm64_repeat_tlbi_list[] = { };#endif +#ifdef CONFIG_ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT +static const struct midr_range workaround_amu_constcnt_list[] = { +#ifdef CONFIG_ARM64_ERRATUM_2457168 +/* Cortex-A510 r0p0-r1p1 */ +MIDR_RANGE (MIDR_CORTEX_A510 ,0 ,0 ,1 ,1 ), +#endif + {} +}; +#endif /* CONFIG_ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT */ +#ifdef CONFIG_CAVIUM_ERRATUM_27456 const struct midr_range cavium_erratum_27456_cpus[] = { /* Cavium ThunderX, T88 pass 1.x - 2.1 */
@@ -611,13 +621,12 @@ const struct arm64_cpu_capabilities arm64_errata[] = { 1, 0), },#endif -#ifdef CONFIG_ARM64_ERRATUM_2457168 +#ifdef CONFIG_ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT { - .desc = "ARM erratum 2457168", - .capability = ARM64_WORKAROUND_2457168, + .desc = "Broken AMU AMEVCNTR01 (const counter)", + .capability = ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT, .type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE, - /* Cortex-A510 r0p0-r1p1 */ - CAP_MIDR_RANGE(MIDR_CORTEX_A510, 0, 0, 1, 1) + CAP_MIDR_RANGE_LIST(workaround_amu_constcnt_list) }, #endif #ifdef CONFIG_ARM64_ERRATUM_1742098
arch/arm64/kernel/cpufeature.c +1 -1
@@ -1608,7 +1608,7 @@ static void cpu_amu_enable(struct arm64_cpu_capabilities const *cap)cpumask_set_cpu (smp_processor_id (), &amu_cpus);/* 0 reference values signal broken/disabled counters */ -if (!this_cpu_has_cap (ARM64_WORKAROUND_2457168 )) +if (!this_cpu_has_cap (ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT ))init_cpu_freq_invariance_counters (); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 274/516 arm64: errata: Add Cortex-A725 erratum 3821522 workaround
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Beata Michalska <[email protected]>
[ Upstream commit 45f7304679875eb000d67e194090ee7abd05c89c ]
Cortex-A725 erratum 3821522 affects the CNT_CYCLES event, which can incur a significant increment error when a CPU enters and subsequently exits WFE or WFI, and may no longer track the system counter frequency.
The AMEVCNTR01_EL0 counter is used as the AMU constant counter for frequency invariance and CPPC FFH feedback counters. Wire the affected Cortex-A725 range into the shared broken AMU constant-counter capability so the affected counter is treated as unavailable by returning zero in the AMU counter paths. This prevents the broken counter from being used as a reference source.
The erratum can also affect PMUv3 users of the CNT_CYCLES event, but this workaround intentionally does not change PMU event handling. Hiding or rejecting the PMU event from the erratum code would change the perf-visible PMU event interface, including raw event selection, and would need a separate PMU-specific approach rather than being folded into the AMU reference-counter workaround.
--- Documentation/arm64/silicon-errata.rst | 2 ++ arch/arm64/Kconfig | 22 ++++++++++++++++++++++ arch/arm64/kernel/cpu_errata.c | 4 ++++ 3 files changed, 28 insertions(+)
Documentation/arm64/silicon-errata.rst +2 -0
@@ -128,6 +128,8 @@ stable kernels. +----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A725 | #3456106 | ARM64_ERRATUM_3194386 | +----------------+-----------------+-----------------+-----------------------------+ +| ARM | Cortex-A725 | #3821522 | ARM64_ERRATUM_3821522 | ++----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-X1 | #3324344 | ARM64_ERRATUM_3194386 | +----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-X1 | #4193791 | ARM64_ERRATUM_4118414 |
arch/arm64/Kconfig +22 -0
@@ -699,6 +699,28 @@ config ARM64_ERRATUM_2457168 If unsure, say Y. +config ARM64_ERRATUM_3821522 + bool "Cortex-A725: 3821522: workaround for possible CNT_CYCLES increment error due to WFE/WFI" + depends on ARM64_AMU_EXTN + select ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT + default y + help + This option adds the workaround for ARM Cortex-A725 erratum 3821522. + + On affected A725 cores, the CNT_CYCLES event may incur a significant + increment error when entering and subsequently exiting WFx. + As a result, the CNT_CYCLES may diverge from the system counter + frequency at which it is expected to increment. + This renders the AMU counter AMEVCNTR01, that implements CNT_CYCLES, + being unreliable and unsuitable for use. + + Since there is no hardware workaround, reads of the affected CNT_CYCLES + counter return 0 in the relevant paths. This causes users of the counter + to treat it as unavailable and is functionally equivalent to firmware + disabling the affected counter. + + If unsure, say Y. + config ARM64_ERRATUM_3194386 bool "Cortex-*/Neoverse-*: workaround for MSR SSBS not self-synchronizing" default y
arch/arm64/kernel/cpu_errata.c +4 -0
@@ -265,6 +265,10 @@ static const struct midr_range workaround_amu_constcnt_list[] = {#ifdef CONFIG_ARM64_ERRATUM_2457168 /* Cortex-A510 r0p0-r1p1 */ MIDR_RANGE(MIDR_CORTEX_A510, 0, 0, 1, 1), +#endif +#ifdef CONFIG_ARM64_ERRATUM_3821522 +/* Cortex-A725 r0p0 - r0p2 */ + MIDR_RANGE(MIDR_CORTEX_A725, 0, 0, 0, 2),#endif {} };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 275/516 fsverity: add dependency on 64K or smaller pages
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit a300000233a9ff842e2fb450fb9a79f7827a586d upstream.
Currently, all filesystems that support fsverity (ext4, f2fs, and btrfs) cache the Merkle tree in the pagecache at a 64K aligned offset after the end of the file data. This offset needs to be a multiple of the page size, which is guaranteed only when the page size is 64K or smaller.
64K was chosen to be the "largest reasonable page size". But it isn't the largest *possible* page size: the hexagon and powerpc ports of Linux support 256K pages, though that configuration is rarely used.
For now, just disable support for FS_VERITY in these odd configurations to ensure it isn't used in cases where it would have incorrect behavior.
--- fs/verity/Kconfig | 3 +++ 1 file changed, 3 insertions(+)
fs/verity/Kconfig +3 -0
@@ -2,6 +2,9 @@ config FS_VERITY bool "FS Verity (read-only file-based authenticity protection)" + # Filesystems cache the Merkle tree at a 64K aligned offset in the + # pagecache. That approach assumes the page size is at most 64K. + depends on !PAGE_SIZE_256KB && !PPC_256K_PAGES select CRYPTO # SHA-256 is selected as it's intended to be the default hash algorithm. # To avoid bloat, other wanted algorithms must be selected explicitly.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 276/516 drm/amd/pm/si: Fix updating clock limits on AC/DC
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit 08c9100f65299c64439e22e6057d750ae0e6c660 ]
Assume that the AC limits are the maximum of all power states, and the DC limits are the maximum of battery power states. This shouldn't make any difference in practice, but is cleaner and more robust against bogus information in the VBIOS.
--- drivers/gpu/drm/amd/pm/powerplay/si_dpm.c | 36 +++++++++++------------ 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/si_dpm.c +18 -18
@@ -7136,6 +7136,19 @@ static void si_parse_pplib_non_clock_info(struct amdgpu_device *adev, adev->pm.dpm.uvd_ps = rps; } +static void si_update_limits (struct amdgpu_clock_and_voltage_limits *limits, +struct rv7xx_pl *pl) +{ +if (pl->sclk > limits->sclk) + limits->sclk = pl->sclk; +if (pl->mclk > limits->mclk) + limits->mclk = pl->mclk; +if (pl->vddc > limits->vddc) + limits->vddc = pl->vddc; +if (pl->vddci > limits->vddci) + limits->vddci = pl->vddci; +} +static void si_parse_pplib_clock_info (struct amdgpu_device *adev,struct amdgpu_ps *rps,int index,union pplib_clock_info *clock_info)
@@ -7144,7 +7157,6 @@ static void si_parse_pplib_clock_info(struct amdgpu_device *adev,struct evergreen_power_info *eg_pi =evergreen_get_pi (adev);struct si_power_info *si_pi =si_get_pi (adev);struct si_ps *ps =si_get_ps (rps); -struct amdgpu_clock_and_voltage_limits *limits;u16 leakage_voltage;struct rv7xx_pl *pl = &ps->performance_levels[index];int ret;
@@ -7209,26 +7221,14 @@ static void si_parse_pplib_clock_info(struct amdgpu_device *adev,* VBIOS can contain conflicting values between: * - the maximum allowed clocks and voltages on AC or DC * - the clocks and voltages in power states on AC or DC +* +* Assume that the AC limits are the maximum of all power states, +* and the DC limits are the maximum of battery power states. */ +si_update_limits (&adev->pm.dpm.dyn_state.max_clock_voltage_on_ac, pl);if ((rps->class &ATOM_PPLIB_CLASSIFICATION_UI_MASK ) == -ATOM_PPLIB_CLASSIFICATION_UI_PERFORMANCE ) - limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_ac; -else if ((rps->class &ATOM_PPLIB_CLASSIFICATION_UI_MASK ) ==ATOM_PPLIB_CLASSIFICATION_UI_BATTERY ) - limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_dc; -else - limits =NULL ; - -if (limits) { -if (pl->sclk > limits->sclk) - limits->sclk = pl->sclk; -if (pl->mclk > limits->mclk) - limits->mclk = pl->mclk; -if (pl->vddc > limits->vddc) - limits->vddc = pl->vddc; -if (pl->vddci > limits->vddci) - limits->vddci = pl->vddci; - } +si_update_limits (&adev->pm.dpm.dyn_state.max_clock_voltage_on_dc, pl); }union pplib_power_state {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 277/516 drm/amdgpu: reset VI ASIC on MacBookPro15,1
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andre Eikmeyer <[email protected]>
[ Upstream commit a5be7ad8f5f0e067613e9197638f216f46252946 ]
After S3, reloading amdgpu on MacBookPro15,1 systems with a Radeon Pro 555X or 560X fails while loading the SMU firmware. The existing SMC register check does not request a reset because the registers do not reliably reflect the stale SMU state on these machines.
Frederick Morlock found that forcing a VI ASIC reset allows the driver to initialize again. This patch limits his workaround to the exact PCI device, Apple subsystem device and revision combinations used by these two GPUs, leaving other VI hardware unchanged.
Stable-dep-of: a22e5e4f2ebb ("drm/amdgpu: reset VI ASIC on MacBookPro14,3")
--- drivers/gpu/drm/amd/amdgpu/vi.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/gpu/drm/amd/amdgpu/vi.c +20 -0
@@ -1058,10 +1058,30 @@ static uint64_t vi_get_pcie_replay_count(struct amdgpu_device *adev)return (nak_r + nak_g); } +struct vi_reset_quirk { +u16 device; +u16 subsystem_vendor; +u16 subsystem_device; +u8 revision; +}; + +static const struct vi_reset_quirk vi_reset_quirks[] = { + {0x67ef ,PCI_VENDOR_ID_APPLE ,0x0190 ,0xe3 },/* Radeon Pro 555X */ + {0x67ef ,PCI_VENDOR_ID_APPLE ,0x018f ,0xc2 },/* Radeon Pro 560X */ +}; +static bool vi_need_reset_on_init (struct amdgpu_device *adev) { +unsigned int i;u32 clock_cntl, pc; +for (i =0 ; i <ARRAY_SIZE (vi_reset_quirks); i++) +if (adev->pdev->device == vi_reset_quirks[i].device && + adev->pdev->subsystem_vendor == vi_reset_quirks[i].subsystem_vendor && + adev->pdev->subsystem_device == vi_reset_quirks[i].subsystem_device && + adev->pdev->revision == vi_reset_quirks[i].revision) +return true; +if (adev->flags &AMD_IS_APU )return false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 278/516 drm/amdgpu: reset VI ASIC on MacBookPro14,3
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Francisco Beltrán Millalén <[email protected]>
[ Upstream commit a22e5e4f2ebbdbb962cc3233094d189c4dfaa051 ]
On a MacBookPro14,3 with a Radeon Pro 555 (Polaris11), the framebuffer is at MC address 0 when amdgpu loads after a cold boot, as the firmware leaves it (MC_VM_FB_LOCATION = 0x007f0000), while the VBIOS ASIC_Init table places it at 0xF4_0000_0000 (0xf47ff400). amdgpu reads the location once, at init, so after a re-POST (S3 resume or GPU reset) the framebuffer has moved and the driver keeps programming the old
one: the SMU is handed a table that was never written and the GPU does not come back, which leaves the internal panel black.
Resetting the ASIC on load makes ASIC_Init run before the driver reads the location, so the driver uses the VBIOS placement from the start and every later re-POST puts the framebuffer back where it already is.
Add the Radeon Pro 555 used in this machine to the existing VI reset quirk table.
Tested on a MacBookPro14,3 on 6.18.49 with the quirk table backported (the kernel also carries unrelated local PCI and ACPI patches for this machine). The framebuffer is at 0x000000F400000000 after both cold and warm boot, and the GPU survived 9 S3 cycles (lid close and rtcwake, one of them with the lid closed for about 7.5 minutes and a USB-C disk attached), each followed by a few minutes of 3D load; no ring timeouts or VM faults were reported. The reset adds about 0.23 s to amdgpu init.
--- drivers/gpu/drm/amd/amdgpu/vi.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/vi.c +1 -0
@@ -1068,6 +1068,7 @@ struct vi_reset_quirk {static const struct vi_reset_quirk vi_reset_quirks[] = { {0x67ef ,PCI_VENDOR_ID_APPLE ,0x0190 ,0xe3 },/* Radeon Pro 555X */ {0x67ef ,PCI_VENDOR_ID_APPLE ,0x018f ,0xc2 },/* Radeon Pro 560X */ + {0x67ef ,PCI_VENDOR_ID_APPLE ,0x017a ,0xc7 },/* Radeon Pro 555 */ };static bool vi_need_reset_on_init (struct amdgpu_device *adev)
Signature · 1 line
2.53.0