5.4.247-rc1 review
Subsystems (4)
Greg Kroah-Hartman
maintainercover 5.4.247-rc1 review
This is the start of the stable review cycle for the 5.4.247 release. There are 45 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 14 Jun 2023 10:16:41 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.247-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-5.4.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 5.4.247-rc1
Greg Kroah-Hartman <[email protected]>
Revert "staging: rtl8192e: Replace macro RTL_PCI_DEVICE with PCI_DEVICE"
YouChing Lin <[email protected]>
mtd: spinand: macronix: Add support for MX35LFxGE4AD
Zixuan Fu <[email protected]>
btrfs: unset reloc control if transaction commit fails in prepare_to_relocate()
Josef Bacik <[email protected]>
btrfs: check return value of btrfs_commit_transaction in relocation
Ilya Dryomov <[email protected]>
rbd: get snapshot context after exclusive lock is ensured to be held
Ville Syrjälä <[email protected]>
drm/atomic: Don't pollute crtc_state->mode_blob with error pointers
Paulo Alcantara <[email protected]>
cifs: handle empty list of targets in cifs_reconnect()
Paulo Alcantara <[email protected]>
cifs: get rid of unused parameter in reconn_setup_dfs_targets()
Theodore Ts'o <[email protected]>
ext4: only check dquot_initialize_needed() when debugging
Randy Dunlap <[email protected]>
eeprom: at24: also select REGMAP
Uwe Kleine-König <[email protected]>
i2c: sprd: Delete i2c adapter in .remove's error path
Jiri Slaby (SUSE) <[email protected]>
bonding (gcc13): synchronize bond_{a,t}lb_xmit() types
Ruihan Li <[email protected]>
usb: usbfs: Use consistent mmap functions
Ruihan Li <[email protected]>
usb: usbfs: Enforce page requirements for mmap
Martin Hundebøll <[email protected]>
pinctrl: meson-axg: add missing GPIOA_18 gpio group
Ilya Dryomov <[email protected]>
rbd: move RBD_OBJ_FLAG_COPYUP_ENABLED flag setting
Luiz Augusto von Dentz <[email protected]>
Bluetooth: Fix use-after-free in hci_remove_ltk/hci_remove_irk
Xiubo Li <[email protected]>
ceph: fix use-after-free bug for inodes when flushing capsnaps
Fedor Pchelkin <[email protected]>
can: j1939: avoid possible use-after-free when j1939_can_rx_register fails
Fedor Pchelkin <[email protected]>
can: j1939: change j1939_netdev_lock type to mutex
Oleksij Rempel <[email protected]>
can: j1939: j1939_sk_send_loop_abort(): improved error queue handling in J1939 Socket
Chia-I Wu <[email protected]>
drm/amdgpu: fix xclk freq on CHIP_STONEY
RenHai <[email protected]>
ALSA: hda/realtek: Add Lenovo P3 Tower platform
Ai Chao <[email protected]>
ALSA: hda/realtek: Add a quirk for HP Slim Desktop S01
Dmitry Torokhov <[email protected]>
Input: psmouse - fix OOB access in Elantech protocol
Ismael Ferreras Morezuelas <[email protected]>
Input: xpad - delete a Razer DeathAdder mouse VID/PID entry
Vladislav Efanov <[email protected]>
batman-adv: Broken sync while rescheduling delayed work
Somnath Kotur <[email protected]>
bnxt_en: Query default VLAN before VNIC setup on a VF
Ben Hutchings <[email protected]>
lib: cpu_rmap: Fix potential use-after-free in irq_cpu_rmap_release()
Hangyu Hua <[email protected]>
net: sched: fix possible refcount leak in tc_chain_tmplt_add()
Eric Dumazet <[email protected]>
net: sched: move rtm_tca_policy declaration to include file
Eric Dumazet <[email protected]>
rfs: annotate lockless accesses to RFS sock flow table
Eric Dumazet <[email protected]>
rfs: annotate lockless accesses to sk->sk_rxhash
Kuniyuki Iwashima <[email protected]>
netfilter: ipset: Add schedule point in call_ad().
Tijs Van Buggenhout <[email protected]>
netfilter: conntrack: fix NULL pointer dereference in nf_confirm_cthelper
Sungwoo Kim <[email protected]>
Bluetooth: L2CAP: Add missing checks for invalid DCID
Ying Hsu <[email protected]>
Bluetooth: Fix l2cap_disconnect_req deadlock
Alexander Sverdlin <[email protected]>
net: dsa: lan9303: allow vid != 0 in port_fdb_{add|del} methodsQingfang DENG <[email protected]>
neighbour: fix unaligned access to pneigh_entry
Gustavo A. R. Silva <[email protected]>
neighbour: Replace zero-length array with flexible-array member
Stephan Gerhold <[email protected]>
spi: qup: Request DMA before enabling clocks
Greg Kroah-Hartman <[email protected]>
i40e: fix build warnings in i40e_alloc.h
Greg Kroah-Hartman <[email protected]>
i40iw: fix build warning in i40iw_manage_apbvt()
Jiri Slaby (SUSE) <[email protected]>
block/blk-iocost (gcc13): keep large values in a new enum
Arnd Bergmann <[email protected]>
blk-iocost: avoid 64-bit division in ioc_timer_fn
-------------
Diffstat:
Makefile | 4 +- block/blk-iocost.c | 10 ++-- drivers/block/rbd.c | 73 +++++++++++++++++----------- drivers/gpu/drm/amd/amdgpu/vi.c | 11 ++++- drivers/gpu/drm/drm_atomic_uapi.c | 14 +++--- drivers/i2c/busses/i2c-sprd.c | 8 +-- drivers/infiniband/hw/i40iw/i40iw.h | 5 +- drivers/input/joystick/xpad.c | 1 - drivers/input/mouse/elantech.c | 9 ++-- drivers/misc/eeprom/Kconfig | 1 + drivers/mtd/nand/spi/macronix.c | 16 ++++++ drivers/net/dsa/lan9303-core.c | 4 -- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 ++ drivers/net/ethernet/intel/i40e/i40e_alloc.h | 17 +++---- drivers/pinctrl/meson/pinctrl-meson-axg.c | 1 + drivers/spi/spi-qup.c | 37 +++++++------- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 6 +-- drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 5 ++ drivers/usb/core/buffer.c | 41 ++++++++++++++++ drivers/usb/core/devio.c | 20 +++++--- fs/btrfs/relocation.c | 14 ++++-- fs/ceph/caps.c | 6 +++ fs/ceph/snap.c | 4 +- fs/cifs/connect.c | 15 +++--- fs/ext4/xattr.c | 6 ++- include/linux/netdevice.h | 7 ++- include/linux/usb/hcd.h | 5 ++ include/net/bond_alb.h | 4 +- include/net/neighbour.h | 2 +- include/net/pkt_sched.h | 2 + include/net/sock.h | 18 +++++-- lib/cpu_rmap.c | 2 +- net/batman-adv/distributed-arp-table.c | 2 +- net/bluetooth/hci_core.c | 8 +-- net/bluetooth/l2cap_core.c | 13 +++++ net/can/j1939/main.c | 24 ++++----- net/can/j1939/socket.c | 5 ++ net/core/dev.c | 6 ++- net/netfilter/ipset/ip_set_core.c | 8 +++ net/netfilter/nf_conntrack_core.c | 3 ++ net/sched/cls_api.c | 3 +- sound/pci/hda/patch_realtek.c | 2 + 42 files changed, 305 insertions(+), 140 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/45 blk-iocost: avoid 64-bit division in ioc_timer_fn
From: Arnd Bergmann <[email protected]>
commit 5f2779dfa7b8cc7dfd4a1b6586d86e0d193266f3 upstream.
The behavior of 'enum' types has changed in gcc-13, so now the UNBUSY_THR_PCT constant is interpreted as a 64-bit number because it is defined as part of the same enum definition as some other constants that do not fit within a 32-bit integer. This in turn leads to some inefficient code on 32-bit architectures as well as a link error:
arm-linux-gnueabi/bin/arm-linux-gnueabi-ld: block/blk-iocost.o: in function `ioc_timer_fn':
blk-iocost.c:(.text+0x68e8): undefined reference to `__aeabi_uldivmod'
arm-linux-gnueabi-ld: blk-iocost.c:(.text+0x6908): undefined reference to `__aeabi_uldivmod'
Split the enum definition to keep the 64-bit timing constants in a separate enum type from those constants that can clearly fit within a smaller type.
--- block/blk-iocost.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
block/blk-iocost.c +5 -3
@@ -271,6 +271,11 @@ enum {VRATE_MIN =VTIME_PER_USEC *VRATE_MIN_PPM /MILLION ,VRATE_CLAMP_ADJ_PCT =4 , +/* switch iff the conditions are met for longer than this */ + AUTOP_CYCLE_NSEC = 10LLU * NSEC_PER_SEC, +}; + +enum {/* if IOs end up waiting for requests, issue less */ RQ_WAIT_BUSY_PCT = 5,
@@ -288,9 +293,6 @@ enum {SURPLUS_SCALE_ABS =HWEIGHT_WHOLE /50 ,/* + 2% */ SURPLUS_MIN_ADJ_DELTA = HWEIGHT_WHOLE / 33, /* 3% */ -/* switch iff the conditions are met for longer than this */ -AUTOP_CYCLE_NSEC =10LLU *NSEC_PER_SEC , -/* * Count IO size in 4k pages. The 12bit shift helps keeping * size-proportional components of cost calculation in closer
Greg Kroah-Hartman
maintainerPATCH 2/45 block/blk-iocost (gcc13): keep large values in a new enum
In reply to Greg Kroah-HartmanFrom: Jiri Slaby (SUSE) <[email protected]>
commit ff1cc97b1f4c10db224f276d9615b22835b8c424 upstream.
Since gcc13, each member of an enum has the same type as the enum [1]. And that is inherited from its members. Provided:
VTIME_PER_SEC_SHIFT = 37,
VTIME_PER_SEC = 1LLU << VTIME_PER_SEC_SHIFT,
...
AUTOP_CYCLE_NSEC = 10LLU * NSEC_PER_SEC,
the named type is unsigned long.
This generates warnings with gcc-13:
block/blk-iocost.c: In function 'ioc_weight_prfill':
block/blk-iocost.c:3037:37: error: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'long unsigned int'
block/blk-iocost.c: In function 'ioc_weight_show':
block/blk-iocost.c:3047:34: error: format '%u' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int'
So split the anonymous enum with large values to a separate enum, so that they don't affect other members.
[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36113
--- block/blk-iocost.c | 2 ++ 1 file changed, 2 insertions(+)
block/blk-iocost.c +2 -0
@@ -248,7 +248,9 @@ enum {/* 1/64k is granular enough and can easily be handled w/ u32 */ HWEIGHT_WHOLE = 1 << 16, +}; +enum {/* * As vtime is used to calculate the cost of each IO, it needs to * be fairly high precision. For example, it should be able to
Greg Kroah-Hartman
maintainerPATCH 3/45 i40iw: fix build warning in i40iw_manage_apbvt()
In reply to Greg Kroah-HartmanNot upstream as this function is no longer around anymore.
The function i40iw_manage_apbvt() has the wrong prototype match from the .h file to the .c declaration, so fix it up, otherwise gcc-13 complains (rightfully) that the type is incorrect.
--- drivers/infiniband/hw/i40iw/i40iw.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/infiniband/hw/i40iw/i40iw.h +2 -3
@@ -411,9 +411,8 @@ void i40iw_manage_arp_cache(struct i40iwbool ipv4, u32 action); -int i40iw_manage_apbvt (struct i40iw_device *iwdev, -u16 accel_local_port, -bool add_port); +enum i40iw_status_code i40iw_manage_apbvt (struct i40iw_device *iwdev, +u16 accel_local_port,bool add_port);struct i40iw_cqp_request *i40iw_get_cqp_request (struct i40iw_cqp *cqp,bool wait);void i40iw_free_cqp_request (struct i40iw_cqp *cqp,struct i40iw_cqp_request *cqp_request);
Greg Kroah-Hartman
maintainerPATCH 4/45 i40e: fix build warnings in i40e_alloc.h
In reply to Greg Kroah-HartmanNot upstream as it was fixed in a much larger api change in newer kernels.
gcc-13 rightfully complains that enum is not the same as an int, so fix up the function prototypes in i40e_alloc.h to be correct, solving a bunch of build warnings.
--- drivers/net/ethernet/intel/i40e/i40e_alloc.h | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_alloc.h +6 -11
@@ -20,16 +20,11 @@ enum i40e_memory_type { };/* prototype for functions used for dynamic memory allocation */ -i40e_status i40e_allocate_dma_mem (struct i40e_hw *hw, -struct i40e_dma_mem *mem, -enum i40e_memory_type type, -u64 size,u32 alignment); -i40e_status i40e_free_dma_mem (struct i40e_hw *hw, -struct i40e_dma_mem *mem); -i40e_status i40e_allocate_virt_mem (struct i40e_hw *hw, -struct i40e_virt_mem *mem, -u32 size); -i40e_status i40e_free_virt_mem (struct i40e_hw *hw, -struct i40e_virt_mem *mem); +int i40e_allocate_dma_mem (struct i40e_hw *hw,struct i40e_dma_mem *mem, +enum i40e_memory_type type,u64 size,u32 alignment); +int i40e_free_dma_mem (struct i40e_hw *hw,struct i40e_dma_mem *mem); +int i40e_allocate_virt_mem (struct i40e_hw *hw,struct i40e_virt_mem *mem, +u32 size); +int i40e_free_virt_mem (struct i40e_hw *hw,struct i40e_virt_mem *mem);#endif /* _I40E_ALLOC_H_ */
Greg Kroah-Hartman
maintainerPATCH 5/45 spi: qup: Request DMA before enabling clocks
In reply to Greg Kroah-HartmanFrom: Stephan Gerhold <[email protected]>
[ Upstream commit 0c331fd1dccfba657129380ee084b95c1cedfbef ]
It is usually better to request all necessary resources (clocks, regulators, ...) before starting to make use of them. That way they do not change state in case one of the resources is not available yet and probe deferral (-EPROBE_DEFER) is necessary. This is particularly important for DMA channels and IOMMUs which are not enforced by fw_devlink yet (unless you use fw_devlink.strict=1).
spi-qup does this in the wrong order, the clocks are enabled and disabled again when the DMA channels are not available yet.
This causes issues in some cases: On most SoCs one of the SPI QUP clocks is shared with the UART controller. When using earlycon UART is actively used during boot but might not have probed yet, usually for the same reason (waiting for the DMA controller). In this case, the brief enable/disable cycle ends up gating the clock and further UART console output will halt the system completely.
Avoid this by requesting the DMA channels before changing the clock state.
--- drivers/spi/spi-qup.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-)
drivers/spi/spi-qup.c +18 -19
@@ -1030,23 +1030,8 @@ static int spi_qup_probe(struct platform_device *pdev)return -ENXIO ; } - ret =clk_prepare_enable (cclk); -if (ret) { -dev_err (dev,"cannot enable core clock\n" ); -return ret; - } - - ret =clk_prepare_enable (iclk); -if (ret) { -clk_disable_unprepare (cclk); -dev_err (dev,"cannot enable iface clock\n" ); -return ret; - } - master =spi_alloc_master (dev,sizeof (struct spi_qup ));if (!master) { -clk_disable_unprepare (cclk); -clk_disable_unprepare (iclk);dev_err (dev,"cannot allocate master\n" );return -ENOMEM ; }
@@ -1092,6 +1077,19 @@ static int spi_qup_probe(struct platform_device *pdev)spin_lock_init (&controller->lock);init_completion (&controller->done); + ret =clk_prepare_enable (cclk); +if (ret) { +dev_err (dev,"cannot enable core clock\n" ); + goto error_dma; + } + + ret =clk_prepare_enable (iclk); +if (ret) { +clk_disable_unprepare (cclk); +dev_err (dev,"cannot enable iface clock\n" ); + goto error_dma; + } + iomode =readl_relaxed (base +QUP_IO_M_MODES ); size =QUP_IO_M_OUTPUT_BLOCK_SIZE (iomode);
@@ -1121,7 +1119,7 @@ static int spi_qup_probe(struct platform_device *pdev) ret =spi_qup_set_state (controller,QUP_STATE_RESET );if (ret) {dev_err (dev,"cannot set RESET state\n" ); - goto error_dma; + goto error_clk; }writel_relaxed (0 , base +QUP_OPERATIONAL );
@@ -1145,7 +1143,7 @@ static int spi_qup_probe(struct platform_device *pdev) ret =devm_request_irq (dev, irq, spi_qup_qup_irq,IRQF_TRIGGER_HIGH , pdev->name, controller);if (ret) - goto error_dma; + goto error_clk;pm_runtime_set_autosuspend_delay (dev,MSEC_PER_SEC );pm_runtime_use_autosuspend (dev);
@@ -1160,11 +1158,12 @@ static int spi_qup_probe(struct platform_device *pdev) disable_pm:pm_runtime_disable (&pdev->dev); +error_clk: +clk_disable_unprepare (cclk); +clk_disable_unprepare (iclk); error_dma:spi_qup_release_dma (master); error: -clk_disable_unprepare (cclk); -clk_disable_unprepare (iclk);spi_master_put (master);return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 6/45 neighbour: Replace zero-length array with flexible-array member
In reply to Greg Kroah-HartmanFrom: Gustavo A. R. Silva <[email protected]>
[ Upstream commit 08ca27d027c238ed3f9b9968d349cebde44d99a6 ]
The current codebase makes use of the zero-length array language extension to the C90 standard, but the preferred mechanism to declare variable-length types such as these ones is a flexible array member[1][2], introduced in C99:
struct foo {
int stuff;
struct boo array[];
};By making use of the mechanism above, we will get a compiler warning in case the flexible array does not occur last in the structure, which will help us prevent some kind of undefined behavior bugs from being inadvertently introduced[3] to the codebase from now on.
Also, notice that, dynamic memory allocations won't be affected by this change:
"Flexible array members have incomplete type, and so the sizeof operator may not be applied. As a quirk of the original implementation of zero-length arrays, sizeof evaluates to zero."[1]
This issue was found with the help of Coccinelle.
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")
Stable-dep-of: ed779fe4c9b5 ("neighbour: fix unaligned access to pneigh_entry")
--- include/net/neighbour.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/neighbour.h +1 -1
@@ -174,7 +174,7 @@ struct pneigh_entry {struct net_device *dev;u8 flags;u8 protocol; -u8 key[0 ]; +u8 key[]; };/*
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 7/45 neighbour: fix unaligned access to pneigh_entry
In reply to Greg Kroah-HartmanFrom: Qingfang DENG <[email protected]>
[ Upstream commit ed779fe4c9b5a20b4ab4fd6f3e19807445bb78c7 ]
After the blamed commit, the member key is longer 4-byte aligned. On platforms that do not support unaligned access, e.g., MIPS32R2 with unaligned_action set to 1, this will trigger a crash when accessing an IPv6 pneigh_entry, as the key is cast to an in6_addr pointer.
Change the type of the key to u32 to make it aligned.
--- include/net/neighbour.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/neighbour.h +1 -1
@@ -174,7 +174,7 @@ struct pneigh_entry {struct net_device *dev;u8 flags;u8 protocol; -u8 key[]; +u32 key[]; };/*
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 8/45 net: dsa: lan9303: allow vid != 0 in port_fdb_{add|del} methods
In reply to Greg Kroah-HartmanFrom: Alexander Sverdlin <[email protected]>
[ Upstream commit 5a59a58ec25d44f853c26bdbfda47d73b3067435 ]
LAN9303 doesn't associate FDB (ALR) entries with VLANs, it has just one global Address Logic Resolution table [1].
Ignore VID in port_fdb_{add|del} methods, go on with the global table. This is the same semantics as hellcreek or RZ/N1 implement.
Visible symptoms:LAN9303_MDIO 5b050000.ethernet-1:00: port 2 failed to delete 00:xx:xx:xx:xx:cf vid 1 from fdb: -2 LAN9303_MDIO 5b050000.ethernet-1:00: port 2 failed to add 00:xx:xx:xx:xx:cf vid 1 to fdb: -95
[1] https://ww1.microchip.com/downloads/en/DeviceDoc/00002308A.pdf
--- drivers/net/dsa/lan9303-core.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/net/dsa/lan9303-core.c +0 -4
@@ -1187,8 +1187,6 @@ static int lan9303_port_fdb_add(struct dsa_switch *ds, int port,struct lan9303 *chip = ds->priv;dev_dbg (chip->dev,"%s(%d, %pM, %d)\n" , __func__, port, addr, vid); -if (vid) -return -EOPNOTSUPP ;return lan9303_alr_add_port (chip, addr, port, false); }
@@ -1200,8 +1198,6 @@ static int lan9303_port_fdb_del(struct dsa_switch *ds, int port,struct lan9303 *chip = ds->priv;dev_dbg (chip->dev,"%s(%d, %pM, %d)\n" , __func__, port, addr, vid); -if (vid) -return -EOPNOTSUPP ;lan9303_alr_del_port (chip, addr, port);return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 9/45 Bluetooth: Fix l2cap_disconnect_req deadlock
In reply to Greg Kroah-HartmanFrom: Ying Hsu <[email protected]>
[ Upstream commit 02c5ea5246a44d6ffde0fddebfc1d56188052976 ]
L2CAP assumes that the locks conn->chan_lock and chan->lock are acquired in the order conn->chan_lock, chan->lock to avoid potential deadlock.
For example, l2sock_shutdown acquires these locks in the order:
mutex_lock(&conn->chan_lock)
l2cap_chan_lock(chan)
However, l2cap_disconnect_req acquires chan->lock in l2cap_get_chan_by_scid first and then acquires conn->chan_lock before calling l2cap_chan_del. This means that these locks are acquired in unexpected order, which leads to potential deadlock:
l2cap_chan_lock(c)
mutex_lock(&conn->chan_lock)
This patch releases chan->lock before acquiring the conn_chan_lock to avoid the potential deadlock.
--- net/bluetooth/l2cap_core.c | 4 ++++ 1 file changed, 4 insertions(+)
net/bluetooth/l2cap_core.c +4 -0
@@ -4380,7 +4380,9 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, chan->ops->set_shutdown (chan); +l2cap_chan_unlock (chan);mutex_lock (&conn->chan_lock); +l2cap_chan_lock (chan);l2cap_chan_del (chan,ECONNRESET );mutex_unlock (&conn->chan_lock);
@@ -4419,7 +4421,9 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn,return 0 ; } +l2cap_chan_unlock (chan);mutex_lock (&conn->chan_lock); +l2cap_chan_lock (chan);l2cap_chan_del (chan,0 );mutex_unlock (&conn->chan_lock);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 10/45 Bluetooth: L2CAP: Add missing checks for invalid DCID
In reply to Greg Kroah-HartmanFrom: Sungwoo Kim <[email protected]>
[ Upstream commit 75767213f3d9b97f63694d02260b6a49a2271876 ]
When receiving a connect response we should make sure that the DCID is within the valid range and that we don't already have another channel allocated for the same DCID.
Missing checks may violate the specification (BLUETOOTH CORE SPECIFICATION Version 5.4 | Vol 3, Part A, Page 1046).
--- net/bluetooth/l2cap_core.c | 9 +++++++++ 1 file changed, 9 insertions(+)
net/bluetooth/l2cap_core.c +9 -0
@@ -4024,6 +4024,10 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn, result =__le16_to_cpu (rsp->result); status =__le16_to_cpu (rsp->status); +if (result ==L2CAP_CR_SUCCESS && (dcid <L2CAP_CID_DYN_START || + dcid >L2CAP_CID_DYN_END )) +return -EPROTO ; +BT_DBG ("dcid 0x%4.4x scid 0x%4.4x result 0x%2.2x status 0x%2.2x" , dcid, scid, result, status);
@@ -4055,6 +4059,11 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn,switch (result) {case L2CAP_CR_SUCCESS : +if (__l2cap_get_chan_by_dcid (conn, dcid)) { + err = -EBADSLT ; +break ; + } +l2cap_state_change (chan,BT_CONFIG ); chan->ident =0 ; chan->dcid = dcid;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 11/45 netfilter: conntrack: fix NULL pointer dereference in nf_confirm_cthelper
In reply to Greg Kroah-HartmanFrom: Tijs Van Buggenhout <[email protected]>
[ Upstream commit e1f543dc660b44618a1bd72ddb4ca0828a95f7ad ]
An nf_conntrack_helper from nf_conn_help may become NULL after DNAT.
Observed when TCP port 1720 (Q931_PORT), associated with h323 conntrack helper, is DNAT'ed to another destination port (e.g. 1730), while nfqueue is being used for final acceptance (e.g. snort).
This happenned after transition from kernel 4.14 to 5.10.161.
Workarounds:
* keep the same port (1720) in DNAT
* disable nfqueue
* disable/unload h323 NAT helper
$ linux-5.10/scripts/decode_stacktrace.sh vmlinux < /tmp/kernel.log BUG: kernel NULL pointer dereference, address: 0000000000000084 [..] RIP: 0010:nf_conntrack_update (net/netfilter/nf_conntrack_core.c:2080 net/netfilter/nf_conntrack_core.c:2134) nf_conntrack [..] nfqnl_reinject (net/netfilter/nfnetlink_queue.c:237) nfnetlink_queue nfqnl_recv_verdict (net/netfilter/nfnetlink_queue.c:1230) nfnetlink_queue nfnetlink_rcv_msg (net/netfilter/nfnetlink.c:241) nfnetlink [..]
--- net/netfilter/nf_conntrack_core.c | 3 +++ 1 file changed, 3 insertions(+)
net/netfilter/nf_conntrack_core.c +3 -0
@@ -1943,6 +1943,9 @@ static int nf_confirm_cthelper(struct sk_buff *skb, struct nf_conn *ct,return 0 ; helper =rcu_dereference (help->helper); +if (!helper) +return 0 ; +if (!(helper->flags &NF_CT_HELPER_F_USERSPACE ))return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 12/45 netfilter: ipset: Add schedule point in call_ad().
In reply to Greg Kroah-HartmanFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 24e227896bbf003165e006732dccb3516f87f88e ]
syzkaller found a repro that causes Hung Task [0] with ipset. The repro first creates an ipset and then tries to delete a large number of IPs from the ipset concurrently:
IPSET_ATTR_IPADDR_IPV4 : 172.20.20.187
IPSET_ATTR_CIDR : 2
The first deleting thread hogs a CPU with nfnl_lock(NFNL_SUBSYS_IPSET) held, and other threads wait for it to be released.
Previously, the same issue existed in set->variant->uadt() that could run so long under ip_set_lock(set). Commit 5e29dc36bd5e ("netfilter: ipset:
Rework long task execution when adding/deleting entries") tried to fix it, but the issue still exists in the caller with another mutex.
While adding/deleting many IPs, we should release the CPU periodically to prevent someone from abusing ipset to hang the system.
Note we need to increment the ipset's refcnt to prevent the ipset from being destroyed while rescheduling.
[0]:
INFO: task syz-executor174:268 blocked for more than 143 seconds.
Not tainted 6.4.0-rc1-00145-gba79e9a73284 #1
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz-executor174 state:D stack:0 pid:268 ppid:260 flags:0x0000000d
Call trace:
__switch_to+0x308/0x714 arch/arm64/kernel/process.c:556
context_switch kernel/sched/core.c:5343 [inline]
__schedule+0xd84/0x1648 kernel/sched/core.c:6669
schedule+0xf0/0x214 kernel/sched/core.c:6745
schedule_preempt_disabled+0x58/0xf0 kernel/sched/core.c:6804
__mutex_lock_common kernel/locking/mutex.c:679 [inline]
__mutex_lock+0x6fc/0xdb0 kernel/locking/mutex.c:747
__mutex_lock_slowpath+0x14/0x20 kernel/locking/mutex.c:1035
mutex_lock+0x98/0xf0 kernel/locking/mutex.c:286
nfnl_lock net/netfilter/nfnetlink.c:98 [inline]
nfnetlink_rcv_msg+0x480/0x70c net/netfilter/nfnetlink.c:295
netlink_rcv_skb+0x1c0/0x350 net/netlink/af_netlink.c:2546
nfnetlink_rcv+0x18c/0x199c net/netfilter/nfnetlink.c:658
netlink_unicast_kernel net/netlink/af_netlink.c:1339 [inline]
netlink_unicast+0x664/0x8cc net/netlink/af_netlink.c:1365
netlink_sendmsg+0x6d0/0xa4c net/netlink/af_netlink.c:1913
sock_sendmsg_nosec net/socket.c:724 [inline]
sock_sendmsg net/socket.c:747 [inline]
____sys_sendmsg+0x4b8/0x810 net/socket.c:2503
___sys_sendmsg net/socket.c:2557 [inline]
__sys_sendmsg+0x1f8/0x2a4 net/socket.c:2586
__do_sys_sendmsg net/socket.c:2595 [inline]
__se_sys_sendmsg net/socket.c:2593 [inline]
__arm64_sys_sendmsg+0x80/0x94 net/socket.c:2593
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x84/0x270 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x134/0x24c arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x198 arch/arm64/kernel/syscall.c:193
el0_svc+0x2c/0x7c arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:591--- net/netfilter/ipset/ip_set_core.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/netfilter/ipset/ip_set_core.c +8 -0
@@ -1539,6 +1539,14 @@ call_ad(struct sock *ctnl, struct sk_buff *skb, struct ip_set *set,bool eexist = flags &IPSET_FLAG_EXIST , retried = false; do { + if (retried) { + __ip_set_get(set); + nfnl_unlock(NFNL_SUBSYS_IPSET); + cond_resched(); + nfnl_lock(NFNL_SUBSYS_IPSET); + __ip_set_put(set); + } + ip_set_lock(set); ret = set->variant->uadt(set, tb, adt, &lineno, flags, retried); ip_set_unlock(set);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 13/45 rfs: annotate lockless accesses to sk->sk_rxhash
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 1e5c647c3f6d4f8497dedcd226204e1880e0ffb3 ]
Add READ_ONCE()/WRITE_ONCE() on accesses to sk->sk_rxhash.
This also prevents a (smart ?) compiler to remove the condition in:
if (sk->sk_rxhash != newval)
sk->sk_rxhash = newval;
We need the condition to avoid dirtying a shared cache line.
--- include/net/sock.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
include/net/sock.h +13 -5
@@ -997,8 +997,12 @@ static inline void sock_rps_record_flow(const struct sock *sk)* OR an additional socket flag * [1] : sk_state and sk_prot are in the same cache line. */ -if (sk->sk_state ==TCP_ESTABLISHED ) - sock_rps_record_flow_hash(sk->sk_rxhash); +if (sk->sk_state ==TCP_ESTABLISHED ) { +/* This READ_ONCE() is paired with the WRITE_ONCE() +* from sock_rps_save_rxhash() and sock_rps_reset_rxhash(). +*/ +sock_rps_record_flow_hash (READ_ONCE (sk->sk_rxhash)); + } }#endif }
@@ -1007,15 +1011,19 @@ static inline void sock_rps_save_rxhash(struct sock *sk, const struct sk_buff *skb) {#ifdef CONFIG_RPS -if (unlikely (sk->sk_rxhash != skb->hash)) - sk->sk_rxhash = skb->hash; +/* The following WRITE_ONCE() is paired with the READ_ONCE() +* here, and another one in sock_rps_record_flow(). +*/ +if (unlikely (READ_ONCE (sk->sk_rxhash) != skb->hash)) +WRITE_ONCE (sk->sk_rxhash, skb->hash);#endif }static inline void sock_rps_reset_rxhash (struct sock *sk) {#ifdef CONFIG_RPS - sk->sk_rxhash =0 ; +/* Paired with READ_ONCE() in sock_rps_record_flow() */ +WRITE_ONCE (sk->sk_rxhash,0 );#endif }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 14/45 rfs: annotate lockless accesses to RFS sock flow table
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 5c3b74a92aa285a3df722bf6329ba7ccf70346d6 ]
Add READ_ONCE()/WRITE_ONCE() on accesses to the sock flow table.
This also prevents a (smart ?) compiler to remove the condition in:
if (table->ents[index] != newval)
table->ents[index] = newval;
We need the condition to avoid dirtying a shared cache line.
--- include/linux/netdevice.h | 7 +++++-- net/core/dev.c | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-)
include/linux/netdevice.h +5 -2
@@ -732,8 +732,11 @@ static inline void rps_record_sock_flow(struct rps_sock_flow_table *table,/* We only give a hint, preemption can change CPU under us */ val |=raw_smp_processor_id (); -if (table->ents[index] != val) - table->ents[index] = val; +/* The following WRITE_ONCE() is paired with the READ_ONCE() +* here, and another one in get_rps_cpu(). +*/ +if (READ_ONCE (table->ents[index]) != val) +WRITE_ONCE (table->ents[index], val); } }
net/core/dev.c +4 -2
@@ -4002,8 +4002,10 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,u32 next_cpu;u32 ident; -/* First check into global flow table if there is a match */ - ident = sock_flow_table->ents[hash & sock_flow_table->mask]; +/* First check into global flow table if there is a match. +* This READ_ONCE() pairs with WRITE_ONCE() from rps_record_sock_flow(). +*/ + ident =READ_ONCE (sock_flow_table->ents[hash & sock_flow_table->mask]);if ((ident ^ hash) & ~rps_cpu_mask) goto try_rps;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 15/45 net: sched: move rtm_tca_policy declaration to include file
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 886bc7d6ed3357975c5f1d3c784da96000d4bbb4 ]
rtm_tca_policy is used from net/sched/sch_api.c and net/sched/cls_api.c, thus should be declared in an include file.
This fixes the following sparse warning:net/sched/sch_api.c:1434:25: warning: symbol 'rtm_tca_policy' was not declared. Should it be static?
--- include/net/pkt_sched.h | 2 ++ net/sched/cls_api.c | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-)
include/net/pkt_sched.h +2 -0
@@ -124,6 +124,8 @@ static inline void qdisc_run(struct Qdisc *q) } } +extern const struct nla_policy rtm_tca_policy[TCA_MAX +1 ]; +/* Calculate maximal size of packet seen by hard_start_xmit routine of this device. */
net/sched/cls_api.c +0 -2
@@ -40,8 +40,6 @@#include <net/tc_act/tc_mpls.h> #include <net/flow_offload.h> -extern const struct nla_policy rtm_tca_policy[TCA_MAX +1 ]; -/* The list of all installed classifier types */ static LIST_HEAD (tcf_proto_base);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 16/45 net: sched: fix possible refcount leak in tc_chain_tmplt_add()
In reply to Greg Kroah-HartmanFrom: Hangyu Hua <[email protected]>
[ Upstream commit 44f8baaf230c655c249467ca415b570deca8df77 ]
try_module_get will be called in tcf_proto_lookup_ops. So module_put needs to be called to drop the refcount if ops don't implement the required function.
--- net/sched/cls_api.c | 1 + 1 file changed, 1 insertion(+)
net/sched/cls_api.c +1 -0
@@ -2732,6 +2732,7 @@ static int tc_chain_tmplt_add(struct tcf_chain *chain, struct net *net,return PTR_ERR (ops);if (!ops->tmplt_create || !ops->tmplt_destroy || !ops->tmplt_dump) {NL_SET_ERR_MSG (extack,"Chain templates are not supported with specified classifier" ); +module_put (ops->owner);return -EOPNOTSUPP ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 17/45 lib: cpu_rmap: Fix potential use-after-free in irq_cpu_rmap_release()
In reply to Greg Kroah-HartmanFrom: Ben Hutchings <[email protected]>
[ Upstream commit 7c5d4801ecf0564c860033d89726b99723c55146 ]
irq_cpu_rmap_release() calls cpu_rmap_put(), which may free the rmap. So we need to clear the pointer to our glue structure in rmap before doing that, not after.
--- lib/cpu_rmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/cpu_rmap.c +1 -1
@@ -268,8 +268,8 @@ static void irq_cpu_rmap_release(struct kref *ref)struct irq_glue *glue = container_of(ref, struct irq_glue, notify.kref); -cpu_rmap_put (glue->rmap); glue->rmap->obj[glue->index] =NULL ; +cpu_rmap_put (glue->rmap);kfree (glue); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 18/45 bnxt_en: Query default VLAN before VNIC setup on a VF
In reply to Greg Kroah-HartmanFrom: Somnath Kotur <[email protected]>
[ Upstream commit 1a9e4f501bc6ff1b6ecb60df54fbf2b54db43bfe ]
We need to call bnxt_hwrm_func_qcfg() on a VF to query the default VLAN that may be setup by the PF. If a default VLAN is enabled, the VF cannot support VLAN acceleration on the receive side and the VNIC must be setup to strip out the default VLAN tag. If a default VLAN is not enabled, the VF can support VLAN acceleration on the receive side. The VNIC should be set up to strip or not strip the VLAN based on the RX VLAN acceleration setting.
Without this call to determine the default VLAN before calling bnxt_setup_vnic(), the VNIC may not be set up correctly. For example, bnxt_setup_vnic() may set up to strip the VLAN tag based on stale default VLAN information. If RX VLAN acceleration is not enabled, the VLAN tag will be incorrectly stripped and the RX data path will not work correctly.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +3 -0
@@ -7781,6 +7781,9 @@ static int bnxt_init_chip(struct bnxt *bp, bool irq_re_init) goto err_out; } +if (BNXT_VF (bp)) +bnxt_hwrm_func_qcfg (bp); + rc =bnxt_setup_vnic (bp,0 );if (rc) goto err_out;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 19/45 batman-adv: Broken sync while rescheduling delayed work
In reply to Greg Kroah-HartmanFrom: Vladislav Efanov <[email protected]>
commit abac3ac97fe8734b620e7322a116450d7f90aa43 upstream.
Syzkaller got a lot of crashes like:
KASAN: use-after-free Write in *_timers*
All of these crashes point to the same memory area:
The buggy address belongs to the object at ffff88801f870000 which belongs to the cache kmalloc-8k of size 8192
The buggy address is located 5320 bytes inside of
8192-byte region [ffff88801f870000, ffff88801f872000)
This area belongs to :
batadv_priv->batadv_priv_dat->delayed_work->timer_list
The reason for these issues is the lack of synchronization. Delayed work (batadv_dat_purge) schedules new timer/work while the device is being deleted. As the result new timer/delayed work is set after cancel_delayed_work_sync() was called. So after the device is freed the timer list contains pointer to already freed memory.
Found by Linux Verification Center (linuxtesting.org) with syzkaller.
--- net/batman-adv/distributed-arp-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/batman-adv/distributed-arp-table.c +1 -1
@@ -102,7 +102,6 @@ static void batadv_dat_purge(struct work*/ static void batadv_dat_start_timer (struct batadv_priv *bat_priv) { -INIT_DELAYED_WORK (&bat_priv->dat.work, batadv_dat_purge);queue_delayed_work (batadv_event_workqueue, &bat_priv->dat.work,msecs_to_jiffies (10000 )); }
@@ -817,6 +816,7 @@ int batadv_dat_init(struct batadv_priv *if (!bat_priv->dat.hash)return -ENOMEM ; +INIT_DELAYED_WORK (&bat_priv->dat.work, batadv_dat_purge);batadv_dat_start_timer (bat_priv); batadv_tvlv_handler_register(bat_priv, batadv_dat_tvlv_ogm_handler_v1,
Greg Kroah-Hartman
maintainerPATCH 20/45 Input: xpad - delete a Razer DeathAdder mouse VID/PID entry
In reply to Greg Kroah-HartmanFrom: Ismael Ferreras Morezuelas <[email protected]>
commit feee70f4568650cf44c573488798ffc0a2faeea3 upstream.
While doing my research to improve the xpad device names I noticed that the 1532:0037 VID/PID seems to be used by the DeathAdder 2013, so that Razer Sabertooth instance looked wrong and very suspect to me. I didn't see any mention in the official drivers, either.
After doing more research, it turns out that the xpad list is used by many other projects (like Steam) as-is [1], this issue was reported [2] and Valve/Sam Lantinga fixed it [3]:
[1]: https://github.com/libsdl-org/SDL/blob/dcc5eef0e2395854b254ea2873a4899edab347c6/src/joystick/controller_type.h#L251
[2]: https://steamcommunity.com/app/353380/discussions/0/1743392486228754770/
[3]: https://hg.libsdl.org/SDL/rev/29809f6f0271
(With multiple Internet users reporting similar issues, not linked here)
After not being able to find the correct VID/PID combination anywhere on the Internet and not receiving any reply from Razer support I did some additional detective work, it seems like it presents itself as "Razer Sabertooth Gaming Controller (XBOX360)", code 1689:FE00.
Leaving us with this:
* Razer Sabertooth (1689:fe00)
* Razer Sabertooth Elite (24c6:5d04)
* Razer DeathAdder 2013 (1532:0037) [note: not a gamepad]
So, to sum things up; remove this conflicting/duplicate entry:
{ 0x1532, 0x0037, "Razer Sabertooth", 0, XTYPE_XBOX360 },
As the real/correct one is already present there, even if the Internet as a whole insists on presenting it as the Razer Sabertooth Elite, which (by all accounts) is not:
{ 0x1689, 0xfe00, "Razer Sabertooth", 0, XTYPE_XBOX360 },
Actual change in SDL2 referencing this kernel issue:
https://github.com/libsdl-org/SDL/commit/e5e54169754ca5d3e86339d968b20126d9da0a15
For more information of the device, take a look here:
https://github.com/xboxdrv/xboxdrv/pull/59
You can see a lsusb dump here: https://github.com/xboxdrv/xboxdrv/files/76581/Qa6dBcrv.txt
--- drivers/input/joystick/xpad.c | 1 - 1 file changed, 1 deletion(-)
drivers/input/joystick/xpad.c +0 -1
@@ -262,7 +262,6 @@ static const struct xpad_device { { 0x1430, 0xf801, "RedOctane Controller", 0, XTYPE_XBOX360 }, { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 }, { 0x146b, 0x0604, "Bigben Interactive DAIJA Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, - { 0x1532, 0x0037, "Razer Sabertooth", 0, XTYPE_XBOX360 }, { 0x1532, 0x0a00, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, { 0x1532, 0x0a03, "Razer Wildcat", 0, XTYPE_XBOXONE }, { 0x15e4, 0x3f00, "Power A Mini Pro Elite", 0, XTYPE_XBOX360 },
Greg Kroah-Hartman
maintainerPATCH 21/45 Input: psmouse - fix OOB access in Elantech protocol
In reply to Greg Kroah-HartmanFrom: Dmitry Torokhov <[email protected]>
commit 7b63a88bb62ba2ddf5fcd956be85fe46624628b9 upstream.
The kernel only allocate 5 MT slots; check that transmitted slot ID falls within the acceptable range.
--- drivers/input/mouse/elantech.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/input/mouse/elantech.c +5 -4
@@ -674,10 +674,11 @@ static void process_packet_head_v4(strucstruct input_dev *dev = psmouse->dev;struct elantech_data *etd = psmouse->private;unsigned char *packet = psmouse->packet; -int id = ((packet[3 ] &0xe0 ) >>5 ) -1 ; +int id;int pres, traces; -if (id <0 ) + id = ((packet[3 ] &0xe0 ) >>5 ) -1 ; +if (id <0 || id >=ETP_MAX_FINGERS )return ; etd->mt[id].x = ((packet[1 ] &0x0f ) <<8 ) | packet[2 ];
@@ -707,7 +708,7 @@ static void process_packet_motion_v4(strint id, sid; id = ((packet[0 ] &0xe0 ) >>5 ) -1 ; -if (id <0 ) +if (id <0 || id >=ETP_MAX_FINGERS )return ; sid = ((packet[3 ] &0xe0 ) >>5 ) -1 ;
@@ -728,7 +729,7 @@ static void process_packet_motion_v4(strinput_report_abs (dev,ABS_MT_POSITION_X , etd->mt[id].x);input_report_abs (dev,ABS_MT_POSITION_Y , etd->mt[id].y); -if (sid >=0 ) { +if (sid >=0 && sid <ETP_MAX_FINGERS ) { etd->mt[sid].x += delta_x2 * weight; etd->mt[sid].y -= delta_y2 * weight;input_mt_slot (dev, sid);
Greg Kroah-Hartman
maintainerPATCH 22/45 ALSA: hda/realtek: Add a quirk for HP Slim Desktop S01
In reply to Greg Kroah-HartmanFrom: Ai Chao <[email protected]>
commit 527c356b51f3ddee02c9ed5277538f85e30a2cdc upstream.
Add a quirk for HP Slim Desktop S01 to fixup headset MIC no presence.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -10345,6 +10345,7 @@ static const struct snd_pci_quirk alc662SND_PCI_QUIRK (0x103c ,0x8719 ,"HP" ,ALC897_FIXUP_HP_HSMIC_VERB ),SND_PCI_QUIRK (0x103c ,0x872b ,"HP" ,ALC897_FIXUP_HP_HSMIC_VERB ),SND_PCI_QUIRK (0x103c ,0x873e ,"HP" ,ALC671_FIXUP_HP_HEADSET_MIC2 ), +SND_PCI_QUIRK (0x103c ,0x8768 ,"HP Slim Desktop S01" ,ALC671_FIXUP_HP_HEADSET_MIC2 ),SND_PCI_QUIRK (0x103c ,0x877e ,"HP 288 Pro G6" ,ALC671_FIXUP_HP_HEADSET_MIC2 ),SND_PCI_QUIRK (0x103c ,0x885f ,"HP 288 Pro G8" ,ALC671_FIXUP_HP_HEADSET_MIC2 ), SND_PCI_QUIRK(0x1043, 0x1080, "Asus UX501VW", ALC668_FIXUP_HEADSET_MODE),
Greg Kroah-Hartman
maintainerPATCH 23/45 ALSA: hda/realtek: Add Lenovo P3 Tower platform
In reply to Greg Kroah-HartmanFrom: RenHai <[email protected]>
commit 7ca4c8d4d3f41c2cd9b4cf22bb829bf03dac0956 upstream.
Headset microphone on this platform does not work without ALC897_FIXUP_HEADSET_MIC_PIN fixup.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -10367,6 +10367,7 @@ static const struct snd_pci_quirk alc662SND_PCI_QUIRK (0x14cd ,0x5003 ,"USI" ,ALC662_FIXUP_USI_HEADSET_MODE ),SND_PCI_QUIRK (0x17aa ,0x1036 ,"Lenovo P520" ,ALC662_FIXUP_LENOVO_MULTI_CODECS ),SND_PCI_QUIRK (0x17aa ,0x1057 ,"Lenovo P360" ,ALC897_FIXUP_HEADSET_MIC_PIN ), +SND_PCI_QUIRK (0x17aa ,0x1064 ,"Lenovo P3 Tower" ,ALC897_FIXUP_HEADSET_MIC_PIN ),SND_PCI_QUIRK (0x17aa ,0x32ca ,"Lenovo ThinkCentre M80" ,ALC897_FIXUP_HEADSET_MIC_PIN ),SND_PCI_QUIRK (0x17aa ,0x32cb ,"Lenovo ThinkCentre M70" ,ALC897_FIXUP_HEADSET_MIC_PIN ), SND_PCI_QUIRK(0x17aa, 0x32cf, "Lenovo ThinkCentre M950", ALC897_FIXUP_HEADSET_MIC_PIN),
Greg Kroah-Hartman
maintainerPATCH 24/45 drm/amdgpu: fix xclk freq on CHIP_STONEY
In reply to Greg Kroah-HartmanFrom: Chia-I Wu <[email protected]>
commit b447b079cf3a9971ea4d31301e673f49612ccc18 upstream.
According to Alex, most APUs from that time seem to have the same issue (vbios says 48Mhz, actual is 100Mhz). I only have a CHIP_STONEY so I limit the fixup to CHIP_STONEY
--- drivers/gpu/drm/amd/amdgpu/vi.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/vi.c +9 -2
@@ -329,8 +329,15 @@ static u32 vi_get_xclk(struct amdgpu_devu32 reference_clock = adev->clock.spll.reference_freq;u32 tmp; -if (adev->flags &AMD_IS_APU ) -return reference_clock; +if (adev->flags &AMD_IS_APU ) { +switch (adev->asic_type) { +case CHIP_STONEY : +/* vbios says 48Mhz, but the actual freq is 100Mhz */ +return 10000 ; +default : +return reference_clock; + } + } tmp =RREG32_SMC (ixCG_CLKPIN_CNTL_2);if (REG_GET_FIELD (tmp,CG_CLKPIN_CNTL_2 ,MUX_TCLK_TO_XCLK ))
Greg Kroah-Hartman
maintainerPATCH 25/45 can: j1939: j1939_sk_send_loop_abort(): improved error queue handling in J1939 Socket
In reply to Greg Kroah-HartmanFrom: Oleksij Rempel <[email protected]>
commit 2a84aea80e925ecba6349090559754f8e8eb68ef upstream.
This patch addresses an issue within the j1939_sk_send_loop_abort() function in the j1939/socket.c file, specifically in the context of Transport Protocol (TP) sessions.
Without this patch, when a TP session is initiated and a Clear To Send (CTS) frame is received from the remote side requesting one data packet, the kernel dispatches the first Data Transport (DT) frame and then waits for the next CTS. If the remote side doesn't respond with another CTS, the kernel aborts due to a timeout. This leads to the user-space receiving an EPOLLERR on the socket, and the socket becomes active.
However, when trying to read the error queue from the socket with sock.recvmsg(, , socket.MSG_ERRQUEUE), it returns -EAGAIN, given that the socket is non-blocking. This situation results in an infinite loop: the user-space repeatedly calls epoll(), epoll() returns the socket file descriptor with EPOLLERR, but the socket then blocks on the recv() of ERRQUEUE.
This patch introduces an additional check for the J1939_SOCK_ERRQUEUE flag within the j1939_sk_send_loop_abort() function. If the flag is set, it indicates that the application has subscribed to receive error queue messages. In such cases, the kernel can communicate the current transfer state via the error queue. This allows for the function to return early, preventing the unnecessary setting of the socket into an error state, and breaking the infinite loop. It is crucial to note that a socket error is only needed if the application isn't using the error queue, as, without it, the application wouldn't be aware of transfer issues.
--- net/can/j1939/socket.c | 5 +++++ 1 file changed, 5 insertions(+)
net/can/j1939/socket.c +5 -0
@@ -1013,6 +1013,11 @@ void j1939_sk_errqueue(struct j1939_sessvoid j1939_sk_send_loop_abort (struct sock *sk,int err) { +struct j1939_sock *jsk =j1939_sk (sk); + +if (jsk->state &J1939_SOCK_ERRQUEUE ) +return ; + sk->sk_err = err; sk->sk_error_report (sk);
Greg Kroah-Hartman
maintainerPATCH 26/45 can: j1939: change j1939_netdev_lock type to mutex
In reply to Greg Kroah-HartmanFrom: Fedor Pchelkin <[email protected]>
commit cd9c790de2088b0d797dc4d244b4f174f9962554 upstream.
It turns out access to j1939_can_rx_register() needs to be serialized, otherwise j1939_priv can be corrupted when parallel threads call j1939_netdev_start() and j1939_can_rx_register() fails. This issue is thoroughly covered in other commit which serializes access to j1939_can_rx_register().
Change j1939_netdev_lock type to mutex so that we do not need to remove GFP_KERNEL from can_rx_register().
j1939_netdev_lock seems to be used in normal contexts where mutex usage is not prohibited.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- net/can/j1939/main.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
net/can/j1939/main.c +11 -11
@@ -122,7 +122,7 @@ static void j1939_can_recv(struct sk_buf#define J1939_CAN_ID CAN_EFF_FLAG#define J1939_CAN_MASK (CAN_EFF_FLAG | CAN_RTR_FLAG) -static DEFINE_SPINLOCK (j1939_netdev_lock); +static DEFINE_MUTEX (j1939_netdev_lock);static struct j1939_priv *j1939_priv_create (struct net_device *ndev) {
@@ -216,7 +216,7 @@ static void __j1939_rx_release(struct krj1939_can_rx_unregister (priv);j1939_ecu_unmap_all (priv);j1939_priv_set (priv->ndev,NULL ); -spin_unlock (&j1939_netdev_lock); +mutex_unlock (&j1939_netdev_lock); }/* get pointer to priv without increasing ref counter */
@@ -244,9 +244,9 @@ static struct j1939_priv *j1939_priv_get {struct j1939_priv *priv; -spin_lock (&j1939_netdev_lock); +mutex_lock (&j1939_netdev_lock); priv =j1939_priv_get_by_ndev_locked (ndev); -spin_unlock (&j1939_netdev_lock); +mutex_unlock (&j1939_netdev_lock);return priv; }
@@ -256,14 +256,14 @@ struct j1939_priv *j1939_netdev_start(ststruct j1939_priv *priv, *priv_new;int ret; -spin_lock (&j1939_netdev_lock); +mutex_lock (&j1939_netdev_lock); priv =j1939_priv_get_by_ndev_locked (ndev);if (priv) {kref_get (&priv->rx_kref); -spin_unlock (&j1939_netdev_lock); +mutex_unlock (&j1939_netdev_lock);return priv; } -spin_unlock (&j1939_netdev_lock); +mutex_unlock (&j1939_netdev_lock); priv =j1939_priv_create (ndev);if (!priv)
@@ -273,20 +273,20 @@ struct j1939_priv *j1939_netdev_start(stspin_lock_init (&priv->j1939_socks_lock);INIT_LIST_HEAD (&priv->j1939_socks); -spin_lock (&j1939_netdev_lock); +mutex_lock (&j1939_netdev_lock); priv_new =j1939_priv_get_by_ndev_locked (ndev);if (priv_new) {/* Someone was faster than us, use their priv and roll * back our's. */ kref_get (&priv_new->rx_kref); -spin_unlock (&j1939_netdev_lock); +mutex_unlock (&j1939_netdev_lock);dev_put (ndev);kfree (priv);return priv_new; }j1939_priv_set (ndev, priv); -spin_unlock (&j1939_netdev_lock); +mutex_unlock (&j1939_netdev_lock); ret =j1939_can_rx_register (priv);if (ret <0 )
@@ -304,7 +304,7 @@ struct j1939_priv *j1939_netdev_start(stvoid j1939_netdev_stop (struct j1939_priv *priv) { -kref_put_lock (&priv->rx_kref, __j1939_rx_release, &j1939_netdev_lock); +kref_put_mutex (&priv->rx_kref, __j1939_rx_release, &j1939_netdev_lock);j1939_priv_put (priv); }
Greg Kroah-Hartman
maintainerPATCH 27/45 can: j1939: avoid possible use-after-free when j1939_can_rx_register fails
In reply to Greg Kroah-HartmanFrom: Fedor Pchelkin <[email protected]>
commit 9f16eb106aa5fce15904625661312623ec783ed3 upstream.
Syzkaller reports the following failure:
BUG: KASAN: use-after-free in kref_put include/linux/kref.h:64 [inline] BUG: KASAN: use-after-free in j1939_priv_put+0x25/0xa0 net/can/j1939/main.c:172 Write of size 4 at addr ffff888141c15058 by task swapper/3/0 CPU: 3 PID: 0 Comm: swapper/3 Not tainted 5.10.144-syzkaller #0 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014 Call Trace: <IRQ> __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x107/0x167 lib/dump_stack.c:118 print_address_description.constprop.0+0x1c/0x220 mm/kasan/report.c:385 __kasan_report mm/kasan/report.c:545 [inline] kasan_report.cold+0x1f/0x37 mm/kasan/report.c:562 check_memory_region_inline mm/kasan/generic.c:186 [inline] check_memory_region+0x145/0x190 mm/kasan/generic.c:192 instrument_atomic_read_write include/linux/instrumented.h:101 [inline] atomic_fetch_sub_release include/asm-generic/atomic-instrumented.h:220 [inline] __refcount_sub_and_test include/linux/refcount.h:272 [inline] __refcount_dec_and_test include/linux/refcount.h:315 [inline] refcount_dec_and_test include/linux/refcount.h:333 [inline] kref_put include/linux/kref.h:64 [inline] j1939_priv_put+0x25/0xa0 net/can/j1939/main.c:172 j1939_sk_sock_destruct+0x44/0x90 net/can/j1939/socket.c:374 __sk_destruct+0x4e/0x820 net/core/sock.c:1784 rcu_do_batch kernel/rcu/tree.c:2485 [inline] rcu_core+0xb35/0x1a30 kernel/rcu/tree.c:2726 __do_softirq+0x289/0x9a3 kernel/softirq.c:298 asm_call_irq_on_stack+0x12/0x20 </IRQ> __run_on_irqstack arch/x86/include/asm/irq_stack.h:26 [inline] run_on_irqstack_cond arch/x86/include/asm/irq_stack.h:77 [inline] do_softirq_own_stack+0xaa/0xe0 arch/x86/kernel/irq_64.c:77 invoke_softirq kernel/softirq.c:393 [inline] __irq_exit_rcu kernel/softirq.c:423 [inline] irq_exit_rcu+0x136/0x200 kernel/softirq.c:435 sysvec_apic_timer_interrupt+0x4d/0x100 arch/x86/kernel/apic/apic.c:1095 asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:635 Allocated by task 1141: kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48 kasan_set_track mm/kasan/common.c:56 [inline] __kasan_kmalloc.constprop.0+0xc9/0xd0 mm/kasan/common.c:461 kmalloc include/linux/slab.h:552 [inline] kzalloc include/linux/slab.h:664 [inline] j1939_priv_create net/can/j1939/main.c:131 [inline] j1939_netdev_start+0x111/0x860 net/can/j1939/main.c:268 j1939_sk_bind+0x8ea/0xd30 net/can/j1939/socket.c:485 __sys_bind+0x1f2/0x260 net/socket.c:1645 __do_sys_bind net/socket.c:1656 [inline] __se_sys_bind net/socket.c:1654 [inline] __x64_sys_bind+0x6f/0xb0 net/socket.c:1654 do_syscall_64+0x33/0x40 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x61/0xc6 Freed by task 1141: kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48 kasan_set_track+0x1c/0x30 mm/kasan/common.c:56 kasan_set_free_info+0x1b/0x30 mm/kasan/generic.c:355 __kasan_slab_free+0x112/0x170 mm/kasan/common.c:422 slab_free_hook mm/slub.c:1542 [inline] slab_free_freelist_hook+0xad/0x190 mm/slub.c:1576 slab_free mm/slub.c:3149 [inline] kfree+0xd9/0x3b0 mm/slub.c:4125 j1939_netdev_start+0x5ee/0x860 net/can/j1939/main.c:300 j1939_sk_bind+0x8ea/0xd30 net/can/j1939/socket.c:485 __sys_bind+0x1f2/0x260 net/socket.c:1645 __do_sys_bind net/socket.c:1656 [inline] __se_sys_bind net/socket.c:1654 [inline] __x64_sys_bind+0x6f/0xb0 net/socket.c:1654 do_syscall_64+0x33/0x40 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x61/0xc6
It can be caused by this scenario:
CPU0 CPU1j1939_sk_bind(socket0, ndev0, ...)
j1939_netdev_start()
j1939_sk_bind(socket1, ndev0, ...)
j1939_netdev_start()
mutex_lock(&j1939_netdev_lock)
j1939_priv_set(ndev0, priv)
mutex_unlock(&j1939_netdev_lock)
if (priv_new)
kref_get(&priv_new->rx_kref)
return priv_new;
/* inside j1939_sk_bind() */
jsk->priv = priv
j1939_can_rx_register(priv) // fails
j1939_priv_set(ndev, NULL)
kfree(priv)
j1939_sk_sock_destruct()
j1939_priv_put() // <- uafTo avoid this, call j1939_can_rx_register() under j1939_netdev_lock so that a concurrent thread cannot process j1939_priv before j1939_can_rx_register() returns.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- net/can/j1939/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/can/j1939/main.c +3 -1
@@ -286,16 +286,18 @@ struct j1939_priv *j1939_netdev_start(streturn priv_new; }j1939_priv_set (ndev, priv); -mutex_unlock (&j1939_netdev_lock); ret =j1939_can_rx_register (priv);if (ret <0 ) goto out_priv_put; +mutex_unlock (&j1939_netdev_lock);return priv; out_priv_put:j1939_priv_set (ndev,NULL ); +mutex_unlock (&j1939_netdev_lock); +dev_put (ndev);kfree (priv);
Greg Kroah-Hartman
maintainerPATCH 28/45 ceph: fix use-after-free bug for inodes when flushing capsnaps
In reply to Greg Kroah-HartmanFrom: Xiubo Li <[email protected]>
commit 409e873ea3c1fd3079909718bbeb06ac1ec7f38b upstream.
There is a race between capsnaps flush and removing the inode from 'mdsc->snap_flush_list' list:
== Thread A == == Thread B ==ceph_queue_cap_snap()
-> allocate 'capsnapA'
->ihold('&ci->vfs_inode')
->add 'capsnapA' to 'ci->i_cap_snaps'
->add 'ci' to 'mdsc->snap_flush_list'
...
== Thread C ==ceph_flush_snaps()
->__ceph_flush_snaps()
->__send_flush_snap()
handle_cap_flushsnap_ack()
->iput('&ci->vfs_inode')
this also will release 'ci'
...
== Thread D ==
ceph_handle_snap()
->flush_snaps()
->iterate 'mdsc->snap_flush_list'
->get the stale 'ci' ->remove 'ci' from ->ihold(&ci->vfs_inode) this
'mdsc->snap_flush_list' will WARNING
To fix this we will increase the inode's i_count ref when adding 'ci' to the 'mdsc->snap_flush_list' list.
[ idryomov: need_put int -> bool ]
--- fs/ceph/caps.c | 6 ++++++ fs/ceph/snap.c | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-)
fs/ceph/caps.c +6 -0
@@ -1558,6 +1558,7 @@ void ceph_flush_snaps(struct ceph_inode_struct inode *inode = &ci->vfs_inode;struct ceph_mds_client *mdsc =ceph_inode_to_client (inode)->mdsc;struct ceph_mds_session *session =NULL ; +bool need_put = false;int mds;dout ("ceph_flush_snaps %p\n" , inode);
@@ -1609,8 +1610,13 @@ out: }/* we flushed them all; remove this inode from the queue */ spin_lock (&mdsc->snap_flush_lock); +if (!list_empty (&ci->i_snap_flush_item)) + need_put = true;list_del_init (&ci->i_snap_flush_item);spin_unlock (&mdsc->snap_flush_lock); + +if (need_put) +iput (inode); }/*
fs/ceph/snap.c +3 -1
@@ -644,8 +644,10 @@ int __ceph_finish_cap_snap(struct ceph_i capsnap->size);spin_lock (&mdsc->snap_flush_lock); -if (list_empty (&ci->i_snap_flush_item)) +if (list_empty (&ci->i_snap_flush_item)) { +ihold (inode);list_add_tail (&ci->i_snap_flush_item, &mdsc->snap_flush_list); + }spin_unlock (&mdsc->snap_flush_lock);return 1 ;/* caller may want to ceph_flush_snaps */ }
Greg Kroah-Hartman
maintainerPATCH 29/45 Bluetooth: Fix use-after-free in hci_remove_ltk/hci_remove_irk
In reply to Greg Kroah-HartmanFrom: Luiz Augusto von Dentz <[email protected]>
commit c5d2b6fa26b5b8386a9cc902cdece3a46bef2bd2 upstream.
Similar to commit 0f7d9b31ce7a ("netfilter: nf_tables: fix use-after-free in nft_set_catchall_destroy()"). We can not access k after kfree_rcu() call.
--- net/bluetooth/hci_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/bluetooth/hci_core.c +4 -4
@@ -2572,10 +2572,10 @@ int hci_remove_link_key(struct hci_dev *int hci_remove_ltk (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 bdaddr_type) { -struct smp_ltk *k; +struct smp_ltk *k, *tmp;int removed =0 ; -list_for_each_entry_rcu (k, &hdev->long_term_keys, list) { +list_for_each_entry_safe (k, tmp, &hdev->long_term_keys, list) {if (bacmp (bdaddr, &k->bdaddr) || k->bdaddr_type != bdaddr_type)continue ;
@@ -2591,9 +2591,9 @@ int hci_remove_ltk(struct hci_dev *hdev,void hci_remove_irk (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 addr_type) { -struct smp_irk *k; +struct smp_irk *k, *tmp; -list_for_each_entry_rcu (k, &hdev->identity_resolving_keys, list) { +list_for_each_entry_safe (k, tmp, &hdev->identity_resolving_keys, list) {if (bacmp (bdaddr, &k->bdaddr) || k->addr_type != addr_type)continue ;
Greg Kroah-Hartman
maintainerPATCH 30/45 rbd: move RBD_OBJ_FLAG_COPYUP_ENABLED flag setting
In reply to Greg Kroah-HartmanFrom: Ilya Dryomov <[email protected]>
commit 09fe05c57b5aaf23e2c35036c98ea9f282b19a77 upstream.
Move RBD_OBJ_FLAG_COPYUP_ENABLED flag setting into the object request state machine to allow for the snapshot context to be captured in the image request state machine rather than in rbd_queue_workfn().
--- drivers/block/rbd.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-)
drivers/block/rbd.c +21 -11
@@ -1493,14 +1493,28 @@ static bool rbd_obj_is_tail(struct rbd_o/* * Must be called after rbd_obj_calc_img_extents(). */ -static bool rbd_obj_copyup_enabled (struct rbd_obj_request *obj_req) +static void rbd_obj_set_copyup_enabled (struct rbd_obj_request *obj_req) { -if (!obj_req->num_img_extents || - (rbd_obj_is_entire (obj_req) && - !obj_req->img_request->snapc->num_snaps)) -return false; +if (obj_req->img_request->op_type ==OBJ_OP_DISCARD ) { +dout ("%s %p objno %llu discard\n" , __func__, obj_req, + obj_req->ex.oe_objno); +return ; + } -return true; +if (!obj_req->num_img_extents) { +dout ("%s %p objno %llu not overlapping\n" , __func__, obj_req, + obj_req->ex.oe_objno); +return ; + } + +if (rbd_obj_is_entire (obj_req) && + !obj_req->img_request->snapc->num_snaps) { +dout ("%s %p objno %llu entire\n" , __func__, obj_req, + obj_req->ex.oe_objno); +return ; + } + + obj_req->flags |=RBD_OBJ_FLAG_COPYUP_ENABLED ; }static u64 rbd_obj_img_extents_bytes (struct rbd_obj_request *obj_req)
@@ -2389,9 +2403,6 @@ static int rbd_obj_init_write(struct rbdif (ret)return ret; -if (rbd_obj_copyup_enabled (obj_req)) - obj_req->flags |=RBD_OBJ_FLAG_COPYUP_ENABLED ; - obj_req->write_state =RBD_OBJ_WRITE_START ;return 0 ; }
@@ -2497,8 +2508,6 @@ static int rbd_obj_init_zeroout(struct rif (ret)return ret; -if (rbd_obj_copyup_enabled (obj_req)) - obj_req->flags |=RBD_OBJ_FLAG_COPYUP_ENABLED ;if (!obj_req->num_img_extents) { obj_req->flags |=RBD_OBJ_FLAG_NOOP_FOR_NONEXISTENT ;if (rbd_obj_is_entire (obj_req))
@@ -3439,6 +3448,7 @@ again:case RBD_OBJ_WRITE_START :rbd_assert (!*result); +rbd_obj_set_copyup_enabled (obj_req);if (rbd_obj_write_is_noop (obj_req))return true;
Greg Kroah-Hartman
maintainerPATCH 31/45 pinctrl: meson-axg: add missing GPIOA_18 gpio group
In reply to Greg Kroah-HartmanFrom: Martin Hundebøll <[email protected]>
commit 5b10ff013e8a57f8845615ac2cc37edf7f6eef05 upstream.
Without this, the gpio cannot be explicitly mux'ed to its gpio function.
--- drivers/pinctrl/meson/pinctrl-meson-axg.c | 1 + 1 file changed, 1 insertion(+)
drivers/pinctrl/meson/pinctrl-meson-axg.c +1 -0
@@ -400,6 +400,7 @@ static struct meson_pmx_group meson_axg_GPIO_GROUP (GPIOA_15 ),GPIO_GROUP (GPIOA_16 ),GPIO_GROUP (GPIOA_17 ), +GPIO_GROUP (GPIOA_18 ),GPIO_GROUP (GPIOA_19 ), GPIO_GROUP(GPIOA_20),
Greg Kroah-Hartman
maintainerPATCH 32/45 usb: usbfs: Enforce page requirements for mmap
In reply to Greg Kroah-HartmanFrom: Ruihan Li <[email protected]>
commit 0143d148d1e882fb1538dc9974c94d63961719b9 upstream.
The current implementation of usbdev_mmap uses usb_alloc_coherent to allocate memory pages that will later be mapped into the user space. Meanwhile, usb_alloc_coherent employs three different methods to allocate memory, as outlined below:
* If hcd->localmem_pool is non-null, it uses gen_pool_dma_alloc to allocate memory;
* If DMA is not available, it uses kmalloc to allocate memory;
* Otherwise, it uses dma_alloc_coherent.
However, it should be noted that gen_pool_dma_alloc does not guarantee that the resulting memory will be page-aligned. Furthermore, trying to map slab pages (i.e., memory allocated by kmalloc) into the user space is not resonable and can lead to problems, such as a type confusion bug when PAGE_TABLE_CHECK=y [1].
To address these issues, this patch introduces hcd_alloc_coherent_pages, which addresses the above two problems. Specifically, hcd_alloc_coherent_pages uses gen_pool_dma_alloc_align instead of gen_pool_dma_alloc to ensure that the memory is page-aligned. To replace kmalloc, hcd_alloc_coherent_pages directly allocates pages by calling __get_free_pages.
--- drivers/usb/core/buffer.c | 41 +++++++++++++++++++++++++++++++++++++++++ drivers/usb/core/devio.c | 9 +++++---- include/linux/usb/hcd.h | 5 +++++ 3 files changed, 51 insertions(+), 4 deletions(-)
drivers/usb/core/buffer.c +41 -0
@@ -170,3 +170,44 @@ void hcd_buffer_free( }dma_free_coherent (hcd->self.sysdev, size, addr, dma); } + +void *hcd_buffer_alloc_pages (struct usb_hcd *hcd, +size_t size,gfp_t mem_flags,dma_addr_t *dma) +{ +if (size ==0 ) +return NULL ; + +if (hcd->localmem_pool) +return gen_pool_dma_alloc_align (hcd->localmem_pool, + size, dma,PAGE_SIZE ); + +/* some USB hosts just use PIO */ +if (!hcd_uses_dma (hcd)) { + *dma =DMA_MAPPING_ERROR ; +return (void *)__get_free_pages (mem_flags, +get_order (size)); + } + +return dma_alloc_coherent (hcd->self.sysdev, + size, dma, mem_flags); +} + +void hcd_buffer_free_pages (struct usb_hcd *hcd, +size_t size,void *addr,dma_addr_t dma) +{ +if (!addr) +return ; + +if (hcd->localmem_pool) { +gen_pool_free (hcd->localmem_pool, + (unsigned long )addr, size); +return ; + } + +if (!hcd_uses_dma (hcd)) { +free_pages ((unsigned long )addr,get_order (size)); +return ; + } + +dma_free_coherent (hcd->self.sysdev, size, addr, dma); +}
drivers/usb/core/devio.c +5 -4
@@ -173,6 +173,7 @@ static int connected(struct usb_dev_statstatic void dec_usb_memory_use_count (struct usb_memory *usbm,int *count) {struct usb_dev_state *ps = usbm->ps; +struct usb_hcd *hcd =bus_to_hcd (ps->dev->bus);unsigned long flags;spin_lock_irqsave (&ps->lock, flags);
@@ -181,8 +182,8 @@ static void dec_usb_memory_use_count(strlist_del (&usbm->memlist);spin_unlock_irqrestore (&ps->lock, flags); -usb_free_coherent (ps->dev, usbm->size, usbm->mem, - usbm->dma_handle); +hcd_buffer_free_pages (hcd, usbm->size, + usbm->mem, usbm->dma_handle);usbfs_decrease_memory_usage ( usbm->size +sizeof (struct usb_memory ));kfree (usbm);
@@ -234,8 +235,8 @@ static int usbdev_mmap(struct file *file goto error_decrease_mem; } - mem =usb_alloc_coherent (ps->dev, size,GFP_USER | __GFP_NOWARN, - &dma_handle); + mem =hcd_buffer_alloc_pages (hcd, + size,GFP_USER | __GFP_NOWARN, &dma_handle);if (!mem) { ret = -ENOMEM ; goto error_free_usbm;
include/linux/usb/hcd.h +5 -0
@@ -503,6 +503,11 @@ void *hcd_buffer_alloc(struct usb_bus *bvoid hcd_buffer_free (struct usb_bus *bus,size_t size,void *addr,dma_addr_t dma); +void *hcd_buffer_alloc_pages (struct usb_hcd *hcd, +size_t size,gfp_t mem_flags,dma_addr_t *dma); +void hcd_buffer_free_pages (struct usb_hcd *hcd, +size_t size,void *addr,dma_addr_t dma); +/* generic bus glue, needed for host controllers that don't use PCI */ extern irqreturn_t usb_hcd_irq (int irq,void *__hcd);
Greg Kroah-Hartman
maintainerPATCH 33/45 usb: usbfs: Use consistent mmap functions
In reply to Greg Kroah-HartmanFrom: Ruihan Li <[email protected]>
commit d0b861653f8c16839c3035875b556afc4472f941 upstream.
When hcd->localmem_pool is non-null, localmem_pool is used to allocate DMA memory. In this case, the dma address will be properly returned (in dma_handle), and dma_mmap_coherent should be used to map this memory into the user space. However, the current implementation uses pfn_remap_range, which is supposed to map normal pages.
Instead of repeating the logic in the memory allocation function, this patch introduces a more robust solution. Here, the type of allocated memory is checked by testing whether dma_handle is properly set. If dma_handle is properly returned, it means some DMA pages are allocated and dma_mmap_coherent should be used to map them. Otherwise, normal pages are allocated and pfn_remap_range should be called. This ensures that the correct mmap functions are used consistently, independently with logic details that determine which type of memory gets allocated.
--- drivers/usb/core/devio.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/usb/core/devio.c +9 -2
@@ -222,7 +222,7 @@ static int usbdev_mmap(struct file *filesize_t size = vma->vm_end - vma->vm_start;void *mem;unsigned long flags; -dma_addr_t dma_handle; +dma_addr_t dma_handle =DMA_MAPPING_ERROR ;int ret; ret =usbfs_increase_memory_usage (size +sizeof (struct usb_memory ));
@@ -252,7 +252,14 @@ static int usbdev_mmap(struct file *file usbm->vma_use_count =1 ;INIT_LIST_HEAD (&usbm->memlist); -if (hcd->localmem_pool || !hcd_uses_dma (hcd)) { +/* +* In DMA-unavailable cases, hcd_buffer_alloc_pages allocates +* normal pages and assigns DMA_MAPPING_ERROR to dma_handle. Check +* whether we are in such cases, and then use remap_pfn_range (or +* dma_mmap_coherent) to map normal (or DMA) pages into the user +* space, respectively. +*/ +if (dma_handle ==DMA_MAPPING_ERROR ) {if (remap_pfn_range (vma, vma->vm_start,virt_to_phys (usbm->mem) >>PAGE_SHIFT , size, vma->vm_page_prot) <0 ) {
Greg Kroah-Hartman
maintainerPATCH 34/45 bonding (gcc13): synchronize bond_{a,t}lb_xmit() types
In reply to Greg Kroah-HartmanFrom: Jiri Slaby (SUSE) <[email protected]>
commit 777fa87c7682228e155cf0892ba61cb2ab1fe3ae upstream.
Both bond_alb_xmit() and bond_tlb_xmit() produce a valid warning with
gcc-13:
drivers/net/bonding/bond_alb.c:1409:13: error: conflicting types for 'bond_tlb_xmit' due to enum/integer mismatch; have 'netdev_tx_t(struct sk_buff *, struct net_device *)' ... include/net/bond_alb.h:160:5: note: previous declaration of 'bond_tlb_xmit' with type 'int(struct sk_buff *, struct net_device *)'
drivers/net/bonding/bond_alb.c:1523:13: error: conflicting types for 'bond_alb_xmit' due to enum/integer mismatch; have 'netdev_tx_t(struct sk_buff *, struct net_device *)' ... include/net/bond_alb.h:159:5: note: previous declaration of 'bond_alb_xmit' with type 'int(struct sk_buff *, struct net_device *)'
I.e. the return type of the declaration is int, while the definitions spell netdev_tx_t. Synchronize both of them to the latter.
--- include/net/bond_alb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/net/bond_alb.h +2 -2
@@ -156,8 +156,8 @@ int bond_alb_init_slave(struct bonding *void bond_alb_deinit_slave (struct bonding *bond,struct slave *slave);void bond_alb_handle_link_change (struct bonding *bond,struct slave *slave,char link);void bond_alb_handle_active_change (struct bonding *bond,struct slave *new_slave); -int bond_alb_xmit (struct sk_buff *skb,struct net_device *bond_dev); -int bond_tlb_xmit (struct sk_buff *skb,struct net_device *bond_dev); +netdev_tx_t bond_alb_xmit (struct sk_buff *skb,struct net_device *bond_dev); +netdev_tx_t bond_tlb_xmit (struct sk_buff *skb,struct net_device *bond_dev);void bond_alb_monitor (struct work_struct *);int bond_alb_set_mac_address (struct net_device *bond_dev,void *addr);void bond_alb_clear_vlan (struct bonding *bond,unsigned short vlan_id);
Greg Kroah-Hartman
maintainerPATCH 35/45 i2c: sprd: Delete i2c adapter in .removes error path
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit ca0aa17f2db3468fd017038d23a78e17388e2f67 ]
If pm runtime resume fails the .remove callback used to exit early. This resulted in an error message by the driver core but the device gets removed anyhow. This lets the registered i2c adapter stay around with an unbound parent device.
So only skip clk disabling if resume failed, but do delete the adapter.
--- drivers/i2c/busses/i2c-sprd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-sprd.c +5 -3
@@ -577,12 +577,14 @@ static int sprd_i2c_remove(struct platform_device *pdev)struct sprd_i2c *i2c_dev =platform_get_drvdata (pdev);int ret; - ret =pm_runtime_resume_and_get (i2c_dev->dev); + ret =pm_runtime_get_sync (i2c_dev->dev);if (ret <0 ) -return ret; +dev_err (&pdev->dev,"Failed to resume device (%pe)\n" ,ERR_PTR (ret));i2c_del_adapter (&i2c_dev->adap); -clk_disable_unprepare (i2c_dev->clk); + +if (ret >=0 ) +clk_disable_unprepare (i2c_dev->clk);pm_runtime_put_noidle (i2c_dev->dev);pm_runtime_disable (i2c_dev->dev);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 36/45 eeprom: at24: also select REGMAP
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 7f3c782b3914e510b646a77aedc3adeac2e4a63b ]
Selecting only REGMAP_I2C can leave REGMAP unset, causing build errors, so also select REGMAP to prevent the build errors.
../drivers/misc/eeprom/at24.c:540:42: warning: 'struct regmap_config' declared inside parameter list will not be visible outside of this definition or declaration
540 | struct regmap_config *regmap_config)../drivers/misc/eeprom/at24.c: In function 'at24_make_dummy_client':../drivers/misc/eeprom/at24.c:552:18: error: implicit declaration of function 'devm_regmap_init_i2c' [-Werror=implicit-function-declaration]
552 | regmap = devm_regmap_init_i2c(dummy_client, regmap_config);../drivers/misc/eeprom/at24.c:552:16: warning: assignment to 'struct regmap *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
552 | regmap = devm_regmap_init_i2c(dummy_client, regmap_config);../drivers/misc/eeprom/at24.c: In function 'at24_probe':../drivers/misc/eeprom/at24.c:586:16: error: variable 'regmap_config' has initializer but incomplete type
586 | struct regmap_config regmap_config = { };../drivers/misc/eeprom/at24.c:586:30: error: storage size of 'regmap_config' isn't known
586 | struct regmap_config regmap_config = { };../drivers/misc/eeprom/at24.c:586:30: warning: unused variable 'regmap_config' [-Wunused-variable]
--- drivers/misc/eeprom/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/misc/eeprom/Kconfig +1 -0
@@ -6,6 +6,7 @@ config EEPROM_AT24 depends on I2C && SYSFS select NVMEM select NVMEM_SYSFS + select REGMAP select REGMAP_I2C help Enable this driver to get read/write support to most I2C EEPROMs
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 37/45 ext4: only check dquot_initialize_needed() when debugging
In reply to Greg Kroah-HartmanFrom: Theodore Ts'o <[email protected]>
commit dea9d8f7643fab07bf89a1155f1f94f37d096a5e upstream.
ext4_xattr_block_set() relies on its caller to call dquot_initialize() on the inode. To assure that this has happened there are WARN_ON checks. Unfortunately, this is subject to false positives if there is an antagonist thread which is flipping the file system at high rates between r/o and rw. So only do the check if EXT4_XATTR_DEBUG is enabled.
--- fs/ext4/xattr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/ext4/xattr.c +4 -2
@@ -2016,8 +2016,9 @@ inserted:else {u32 ref; +#ifdef EXT4_XATTR_DEBUG WARN_ON_ONCE (dquot_initialize_needed (inode)); - +#endif /* The old block is released after updating the inode. */ error = dquot_alloc_block(inode,
@@ -2079,8 +2080,9 @@ inserted:/* We need to allocate a new block */ ext4_fsblk_t goal, block; +#ifdef EXT4_XATTR_DEBUG WARN_ON_ONCE (dquot_initialize_needed (inode)); - +#endif goal =ext4_group_first_block_no (sb,EXT4_I (inode)->i_block_group); block = ext4_new_meta_blocks(handle, inode, goal, 0,
Greg Kroah-Hartman
maintainerPATCH 38/45 cifs: get rid of unused parameter in reconn_setup_dfs_targets()
In reply to Greg Kroah-HartmanFrom: Paulo Alcantara <[email protected]>
commit baf3f08ef4083b76ca67b143e135213a7f941879 upstream.
The target iterator parameter "it" is not used in reconn_setup_dfs_targets(), so just remove it.
--- fs/cifs/connect.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/cifs/connect.c +2 -3
@@ -469,8 +469,7 @@ static void reconn_inval_dfs_target(stru }static inline int reconn_setup_dfs_targets (struct cifs_sb_info *cifs_sb, -struct dfs_cache_tgt_list *tl, -struct dfs_cache_tgt_iterator **it) +struct dfs_cache_tgt_list *tl) {if (!cifs_sb->origin_fullpath)return -EOPNOTSUPP ;
@@ -515,7 +514,7 @@ cifs_reconnect(struct TCP_Server_Info *s }else { cifs_sb =CIFS_SB (sb); - rc =reconn_setup_dfs_targets (cifs_sb, &tgt_list, &tgt_it); + rc =reconn_setup_dfs_targets (cifs_sb, &tgt_list);if (rc && (rc != -EOPNOTSUPP )) {cifs_server_dbg (VFS ,"%s: no target servers for DFS failover\n" , __func__);
Greg Kroah-Hartman
maintainerPATCH 39/45 cifs: handle empty list of targets in cifs_reconnect()
In reply to Greg Kroah-HartmanFrom: Paulo Alcantara <[email protected]>
commit a52930353eaf443489a350a135c5525a4acbbf56 upstream.
In case there were no cached DFS referrals in reconn_setup_dfs_targets(), set cifs_sb to NULL prior to calling reconn_set_next_dfs_target() so it would not try to access an empty tgt_list.
--- fs/cifs/connect.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
fs/cifs/connect.c +6 -4
@@ -513,11 +513,13 @@ cifs_reconnect(struct TCP_Server_Info *s sb =NULL ; }else { cifs_sb =CIFS_SB (sb); - rc =reconn_setup_dfs_targets (cifs_sb, &tgt_list); -if (rc && (rc != -EOPNOTSUPP )) { -cifs_server_dbg (VFS ,"%s: no target servers for DFS failover\n" , - __func__); +if (rc) { + cifs_sb =NULL ; +if (rc != -EOPNOTSUPP ) { +cifs_server_dbg (VFS ,"%s: no target servers for DFS failover\n" , + __func__); + } }else { server->nr_targets =dfs_cache_get_nr_tgts (&tgt_list); }
Greg Kroah-Hartman
maintainerPATCH 40/45 drm/atomic: Dont pollute crtc_state->mode_blob with error pointers
In reply to Greg Kroah-HartmanFrom: Ville Syrjälä <[email protected]>
commit 439cf34c8e0a8a33d8c15a31be1b7423426bc765 upstream.
Make sure we don't assign an error pointer to crtc_state->mode_blob as that will break all kinds of places that assume either NULL or a valid pointer (eg. drm_property_blob_put()).
--- drivers/gpu/drm/drm_atomic_uapi.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/drm_atomic_uapi.c +8 -6
@@ -75,15 +75,17 @@ int drm_atomic_set_mode_for_crtc(struct state->mode_blob =NULL ;if (mode) { +struct drm_property_blob *blob; +drm_mode_convert_to_umode (&umode, mode); - state->mode_blob = -drm_property_create_blob (state->crtc->dev, -sizeof (umode), - &umode); -if (IS_ERR (state->mode_blob)) -return PTR_ERR (state->mode_blob); + blob =drm_property_create_blob (crtc->dev, +sizeof (umode), &umode); +if (IS_ERR (blob)) +return PTR_ERR (blob);drm_mode_copy (&state->mode, mode); + + state->mode_blob = blob; state->enable = true;DRM_DEBUG_ATOMIC ("Set [MODE:%s] for [CRTC:%d:%s] state %p\n" , mode->name, crtc->base.id, crtc->name, state);
Greg Kroah-Hartman
maintainerPATCH 41/45 rbd: get snapshot context after exclusive lock is ensured to be held
In reply to Greg Kroah-HartmanFrom: Ilya Dryomov <[email protected]>
commit 870611e4877eff1e8413c3fb92a585e45d5291f6 upstream.
Move capturing the snapshot context into the image request state machine, after exclusive lock is ensured to be held for the duration of dealing with the image request. This is needed to ensure correctness of fast-diff states (OBJECT_EXISTS vs OBJECT_EXISTS_CLEAN) and object deltas computed based off of them. Otherwise the object map that is forked for the snapshot isn't guaranteed to accurately reflect the contents of the snapshot when the snapshot is taken under I/O. This breaks differential backup and snapshot-based mirroring use cases with fast-diff enabled: since some object deltas may be incomplete, the destination image may get corrupted.
[[email protected]: backport to 5.4: no rbd_img_capture_header(),
img_request not embedded in blk-mq pdu]
--- drivers/block/rbd.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-)
drivers/block/rbd.c +24 -17
@@ -1495,6 +1495,8 @@ static bool rbd_obj_is_tail(struct rbd_o*/ static void rbd_obj_set_copyup_enabled (struct rbd_obj_request *obj_req) { +rbd_assert (obj_req->img_request->snapc); +if (obj_req->img_request->op_type ==OBJ_OP_DISCARD ) {dout ("%s %p objno %llu discard\n" , __func__, obj_req, obj_req->ex.oe_objno);
@@ -1613,6 +1615,7 @@ __rbd_obj_add_osd_request(struct rbd_objstatic struct ceph_osd_request *rbd_obj_add_osd_request (struct rbd_obj_request *obj_req,int num_ops) { +rbd_assert (obj_req->img_request->snapc);return __rbd_obj_add_osd_request (obj_req, obj_req->img_request->snapc, num_ops); }
@@ -1741,11 +1744,14 @@ static bool rbd_dev_parent_get(struct rb* Caller is responsible for filling in the list of object requests * that comprises the image request, and the Linux request pointer * (if there is one). +* +* Only snap_id is captured here, for reads. For writes, snapshot +* context is captured in rbd_img_object_requests() after exclusive +* lock is ensured to be held. */ static struct rbd_img_request *rbd_img_request_create (struct rbd_device *rbd_dev, -enum obj_operation_type op_type, -struct ceph_snap_context *snapc) +enum obj_operation_type op_type) {struct rbd_img_request *img_request;
@@ -1757,8 +1763,6 @@ static struct rbd_img_request *rbd_img_r img_request->op_type = op_type;if (!rbd_img_is_write (img_request)) img_request->snap_id = rbd_dev->spec->snap_id; -else - img_request->snapc = snapc;if (rbd_dev_parent_get (rbd_dev))img_request_layered_set (img_request);
@@ -2944,7 +2948,7 @@ static int rbd_obj_read_from_parent(struint ret; child_img_req =rbd_img_request_create (img_req->rbd_dev->parent, -OBJ_OP_READ ,NULL ); +OBJ_OP_READ );if (!child_img_req)return -ENOMEM ;
@@ -3635,9 +3639,19 @@ static int rbd_img_exclusive_lock(structstatic void rbd_img_object_requests (struct rbd_img_request *img_req) { +struct rbd_device *rbd_dev = img_req->rbd_dev;struct rbd_obj_request *obj_req;rbd_assert (!img_req->pending.result && !img_req->pending.num_pending); +rbd_assert (!need_exclusive_lock (img_req) || +__rbd_is_lock_owner (rbd_dev)); + +if (rbd_img_is_write (img_req)) { +rbd_assert (!img_req->snapc); +down_read (&rbd_dev->header_rwsem); + img_req->snapc =ceph_get_snap_context (rbd_dev->header.snapc); +up_read (&rbd_dev->header_rwsem); + }for_each_obj_request (img_req, obj_req) {int result =0 ;
@@ -3655,7 +3669,6 @@ static void rbd_img_object_requests(strustatic bool rbd_img_advance (struct rbd_img_request *img_req,int *result) { -struct rbd_device *rbd_dev = img_req->rbd_dev;int ret; again:
@@ -3676,9 +3689,6 @@ again:if (*result)return true; -rbd_assert (!need_exclusive_lock (img_req) || -__rbd_is_lock_owner (rbd_dev)); -rbd_img_object_requests (img_req);if (!img_req->pending.num_pending) { *result = img_req->pending.result;
@@ -4140,6 +4150,10 @@ static int rbd_post_acquire_action(struc {int ret; + ret =rbd_dev_refresh (rbd_dev); +if (ret) +return ret; +if (rbd_dev->header.features &RBD_FEATURE_OBJECT_MAP ) { ret =rbd_object_map_open (rbd_dev);if (ret)
@@ -4798,7 +4812,6 @@ static void rbd_queue_workfn(struct workstruct request *rq =blk_mq_rq_from_pdu (work);struct rbd_device *rbd_dev = rq->q->queuedata;struct rbd_img_request *img_request; -struct ceph_snap_context *snapc =NULL ;u64 offset = (u64 )blk_rq_pos (rq) <<SECTOR_SHIFT ;u64 length =blk_rq_bytes (rq);enum obj_operation_type op_type;
@@ -4863,10 +4876,6 @@ static void rbd_queue_workfn(struct workdown_read (&rbd_dev->header_rwsem); mapping_size = rbd_dev->mapping.size; -if (op_type !=OBJ_OP_READ ) { - snapc = rbd_dev->header.snapc; -ceph_get_snap_context (snapc); - }up_read (&rbd_dev->header_rwsem);if (offset + length > mapping_size) {
@@ -4876,13 +4885,12 @@ static void rbd_queue_workfn(struct work goto err_rq; } - img_request =rbd_img_request_create (rbd_dev, op_type, snapc); + img_request =rbd_img_request_create (rbd_dev, op_type);if (!img_request) { result = -ENOMEM ; goto err_rq; } img_request->rq = rq; - snapc =NULL ;/* img_request consumes a ref */ dout ("%s rbd_dev %p img_req %p %s %llu~%llu\n" , __func__, rbd_dev, img_request,obj_op_name (op_type), offset, length);
@@ -4904,7 +4912,6 @@ err_rq:if (result)rbd_warn (rbd_dev,"%s %llx at %llx result %d" ,obj_op_name (op_type), length, offset, result); -ceph_put_snap_context (snapc); err:blk_mq_end_request (rq,errno_to_blk_status (result)); }
Greg Kroah-Hartman
maintainerPATCH 42/45 btrfs: check return value of btrfs_commit_transaction in relocation
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit fb686c6824dd6294ca772b92424b8fba666e7d00 upstream.
There are a few places where we don't check the return value of btrfs_commit_transaction in relocation.c. Thankfully all these places have straightforward error handling, so simply change all of the sites at once.
--- fs/btrfs/relocation.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/btrfs/relocation.c +5 -4
@@ -2511,7 +2511,7 @@ again:list_splice (&reloc_roots, &rc->reloc_roots);if (!err) -btrfs_commit_transaction (trans); + err =btrfs_commit_transaction (trans);else btrfs_end_transaction (trans);return err;
@@ -4102,8 +4102,7 @@ int prepare_to_relocate(struct reloc_con*/ return PTR_ERR (trans); } -btrfs_commit_transaction (trans); -return 0 ; +return btrfs_commit_transaction (trans); } static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
@@ -4263,7 +4262,9 @@ restart: err =PTR_ERR (trans); goto out_free; } -btrfs_commit_transaction (trans); + ret =btrfs_commit_transaction (trans); +if (ret && !err) + err = ret; out_free: ret =clean_dirty_subvols (rc);if (ret <0 && !err)
Greg Kroah-Hartman
maintainerPATCH 43/45 btrfs: unset reloc control if transaction commit fails in prepare_to_relocate()
In reply to Greg Kroah-HartmanFrom: Zixuan Fu <[email protected]>
commit 85f02d6c856b9f3a0acf5219de6e32f58b9778eb upstream.
In btrfs_relocate_block_group(), the rc is allocated. Then btrfs_relocate_block_group() calls
relocate_block_group()
prepare_to_relocate()
set_reloc_control()
that assigns rc to the variable fs_info->reloc_ctl. When prepare_to_relocate() returns, it calls
btrfs_commit_transaction()
btrfs_start_dirty_block_groups()
btrfs_alloc_path()
kmem_cache_zalloc()
which may fail for example (or other errors could happen). When the failure occurs, btrfs_relocate_block_group() detects the error and frees rc and doesn't set fs_info->reloc_ctl to NULL. After that, in btrfs_init_reloc_root(), rc is retrieved from fs_info->reloc_ctl and then used, which may cause a use-after-free bug.
This possible bug can be triggered by calling btrfs_ioctl_balance() before calling btrfs_ioctl_defrag().
To fix this possible bug, in prepare_to_relocate(), check if btrfs_commit_transaction() fails. If the failure occurs, unset_reloc_control() is called to set fs_info->reloc_ctl to NULL.
The error log in our fault-injection testing is shown as follows:
[ 58.751070] BUG: KASAN: use-after-free in btrfs_init_reloc_root+0x7ca/0x920 [btrfs] ... [ 58.753577] Call Trace: ... [ 58.755800] kasan_report+0x45/0x60 [ 58.756066] btrfs_init_reloc_root+0x7ca/0x920 [btrfs] [ 58.757304] record_root_in_trans+0x792/0xa10 [btrfs] [ 58.757748] btrfs_record_root_in_trans+0x463/0x4f0 [btrfs] [ 58.758231] start_transaction+0x896/0x2950 [btrfs] [ 58.758661] btrfs_defrag_root+0x250/0xc00 [btrfs] [ 58.759083] btrfs_ioctl_defrag+0x467/0xa00 [btrfs] [ 58.759513] btrfs_ioctl+0x3c95/0x114e0 [btrfs] ... [ 58.768510] Allocated by task 23683: [ 58.768777] ____kasan_kmalloc+0xb5/0xf0 [ 58.769069] __kmalloc+0x227/0x3d0 [ 58.769325] alloc_reloc_control+0x10a/0x3d0 [btrfs] [ 58.769755] btrfs_relocate_block_group+0x7aa/0x1e20 [btrfs] [ 58.770228] btrfs_relocate_chunk+0xf1/0x760 [btrfs] [ 58.770655] __btrfs_balance+0x1326/0x1f10 [btrfs] [ 58.771071] btrfs_balance+0x3150/0x3d30 [btrfs] [ 58.771472] btrfs_ioctl_balance+0xd84/0x1410 [btrfs] [ 58.771902] btrfs_ioctl+0x4caa/0x114e0 [btrfs] ... [ 58.773337] Freed by task 23683: ... [ 58.774815] kfree+0xda/0x2b0 [ 58.775038] free_reloc_control+0x1d6/0x220 [btrfs] [ 58.775465] btrfs_relocate_block_group+0x115c/0x1e20 [btrfs] [ 58.775944] btrfs_relocate_chunk+0xf1/0x760 [btrfs] [ 58.776369] __btrfs_balance+0x1326/0x1f10 [btrfs] [ 58.776784] btrfs_balance+0x3150/0x3d30 [btrfs] [ 58.777185] btrfs_ioctl_balance+0xd84/0x1410 [btrfs] [ 58.777621] btrfs_ioctl+0x4caa/0x114e0 [btrfs] ...
--- fs/btrfs/relocation.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/btrfs/relocation.c +6 -1
@@ -4102,7 +4102,12 @@ int prepare_to_relocate(struct reloc_con*/ return PTR_ERR (trans); } -return btrfs_commit_transaction (trans); + + ret =btrfs_commit_transaction (trans); +if (ret) +unset_reloc_control (rc); + +return ret; } static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
Greg Kroah-Hartman
maintainerPATCH 44/45 mtd: spinand: macronix: Add support for MX35LFxGE4AD
In reply to Greg Kroah-HartmanFrom: YouChing Lin <[email protected]>
commit 5ece78de88739b4c68263e9f2582380c1fd8314f upstream.
The Macronix MX35LF2GE4AD / MX35LF4GE4AD are 3V, 2G / 4Gbit serial SLC NAND flash device (with on-die ECC).
Validated by read, erase, read back, write, read back and nandtest on Xilinx Zynq PicoZed FPGA board which included Macronix SPI Host (drivers/spi/spi-mxic.c).
--- drivers/mtd/nand/spi/macronix.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/mtd/nand/spi/macronix.c +16 -0
@@ -116,6 +116,22 @@ static const struct spinand_info macroni &update_cache_variants), SPINAND_HAS_QE_BIT, SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL)), +SPINAND_INFO ("MX35LF2GE4AD" ,0x26 , +NAND_MEMORG (1 ,2048 ,64 ,64 ,2048 ,40 ,1 ,1 ,1 ), +NAND_ECCREQ (8 ,512 ), +SPINAND_INFO_OP_VARIANTS (&read_cache_variants, + &write_cache_variants, + &update_cache_variants), +SPINAND_HAS_QE_BIT , +SPINAND_ECCINFO (&mx35lfxge4ab_ooblayout,NULL )), +SPINAND_INFO ("MX35LF4GE4AD" ,0x37 , +NAND_MEMORG (1 ,2048 ,128 ,64 ,2048 ,40 ,1 ,1 ,1 ), +NAND_ECCREQ (8 ,512 ), +SPINAND_INFO_OP_VARIANTS (&read_cache_variants, + &write_cache_variants, + &update_cache_variants), +SPINAND_HAS_QE_BIT , + SPINAND_ECCINFO(&mx35lfxge4ab_ooblayout, NULL)), };static int macronix_spinand_detect (struct spinand_device *spinand)
Greg Kroah-Hartman
maintainerPATCH 45/45 Revert "staging: rtl8192e: Replace macro RTL_PCI_DEVICE with PCI_DEVICE"
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
This reverts commit 8a65476dd1cad790ca67ea639be98c14fcd86288 which is commit fda2093860df4812d69052a8cf4997e53853a340 upstream.
Ben reports that this should not have been backported to the older kernels as the rest of the macro is not empty. It was a clean-up patch in 6.4-rc1 only, it did not add new device ids.
--- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 6 +++--- drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-)
drivers/staging/rtl8192e/rtl8192e/rtl_core.c +3 -3
@@ -50,9 +50,9 @@ static const struct rtl819x_ops rtl819xp };static struct pci_device_id rtl8192_pci_id_tbl[] = { - {PCI_DEVICE (0x10ec ,0x8192 )}, - {PCI_DEVICE (0x07aa ,0x0044 )}, - {PCI_DEVICE (0x07aa ,0x0047 )}, + {RTL_PCI_DEVICE (0x10ec ,0x8192 , rtl819xp_ops)}, + {RTL_PCI_DEVICE (0x07aa ,0x0044 , rtl819xp_ops)}, + {RTL_PCI_DEVICE (0x07aa ,0x0047 , rtl819xp_ops)}, {} };
drivers/staging/rtl8192e/rtl8192e/rtl_core.h +5 -0
@@ -55,6 +55,11 @@#define IS_HARDWARE_TYPE_8192SE (_priv) \ (((struct r8192_priv *)rtllib_priv(dev))->card_8192 == NIC_8192SE) +#define RTL_PCI_DEVICE (vend, dev, cfg) \ + .vendor = (vend), .device = (dev), \ + .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \ + .driver_data = (kernel_ulong_t)&(cfg) +#define TOTAL_CAM_ENTRY 32#define CAM_CONTENT_COUNT 8
Hello Greg,
Quoted 10 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, June 12, 2023 11:26 AMThis is the start of the stable review cycle for the 5.4.247 release. There are 45 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 14 Jun 2023 10:16:41 +0000. Anything received after that time might be too late.
Thank you for the release!
CIP configurations built and booted okay with Linux 5.4.247-rc1 (6385fa103774):
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/pipelines/897026070
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/commits/linux-5.4.y
Kind regards, Chris
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.247 release. There are 45 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 14 Jun 2023 10:16:41 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.247-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.4.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.247 release. There are 45 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 14 Jun 2023 10:16:41 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.247-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.4.y
and the diffstat can be found below.thanks,
greg k-h
All tests passing for Tegra ...
Test results for stable-v5.4:
10 builds: 10 pass, 0 fail
26 boots: 26 pass, 0 fail
59 tests: 59 pass, 0 failLinux version: 5.4.247-rc1-g6385fa103774
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
tegra194-p2972-0000, tegra20-ventana,
tegra210-p2371-2180, tegra210-p3450-0000,
tegra30-cardhu-a04Jon
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.247 release. There are 45 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 14 Jun 2023 10:16:41 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.247-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.4.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.
## Build
* kernel: 5.4.247-rc1
* git: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
* git branch: linux-5.4.y
* git commit: 6385fa10377499ea394f124b27ddc00506535785
* git describe: v5.4.246-46-g6385fa103774
* test details:
https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-5.4.y/build/v5.4.246-46-g6385fa103774
## Test Regressions (compared to v5.4.246)
## Metric Regressions (compared to v5.4.246)
## Test Fixes (compared to v5.4.246)
## Metric Fixes (compared to v5.4.246)
## Test result summary
total: 127521, pass: 108735, fail: 3405, skip: 15204, xfail: 177
## Build Summary
* arc: 5 total, 5 passed, 0 failed
* arm: 148 total, 133 passed, 15 failed
* arm64: 48 total, 42 passed, 6 failed
* i386: 30 total, 22 passed, 8 failed
* mips: 30 total, 29 passed, 1 failed
* parisc: 4 total, 4 passed, 0 failed
* powerpc: 33 total, 32 passed, 1 failed
* riscv: 15 total, 13 passed, 2 failed
* s390: 8 total, 8 passed, 0 failed
* sh: 14 total, 12 passed, 2 failed
* sparc: 8 total, 8 passed, 0 failed
* x86_64: 41 total, 39 passed, 2 failed
## Test suites summary
* boot
* fwts
* igt-gpu-tools
* kselftest-android
* kselftest-arm64
* kselftest-breakpoints
* kselftest-capabilities
* kselftest-cgroup
* kselftest-clone3
* kselftest-core
* kselftest-cpu-hotplug
* kselftest-cpufreq
* kselftest-drivers-dma-buf
* kselftest-efivarfs
* kselftest-exec
* kselftest-filesystems
* kselftest-filesystems-binderfs
* kselftest-firmware
* kselftest-fpu
* kselftest-ftrace
* kselftest-futex
* kselftest-gpio
* kselftest-intel_pstate
* kselftest-ipc
* kselftest-ir
* kselftest-kcmp
* kselftest-kexec
* kselftest-kvm
* kselftest-lib
* kselftest-livepatch
* kselftest-membarrier
* kselftest-memfd
* kselftest-memory-hotplug
* kselftest-mincore
* kselftest-mount
* kselftest-mqueue
* kselftest-net
* kselftest-net-forwarding
* kselftest-netfilter
* kselftest-nsfs
* kselftest-openat2
* kselftest-pid_namespace
* kselftest-pidfd
* kselftest-proc
* kselftest-pstore
* kselftest-ptrace
* kselftest-rseq
* kselftest-rtc
* kselftest-sigaltstack
* kselftest-size
* kselftest-tc-testing
* kselftest-timens
* kselftest-timers
* kselftest-tmpfs
* kselftest-tpm2
* kselftest-user
* kselftest-user_events
* kselftest-vDSO
* kselftest-watchdog
* kselftest-x86
* kselftest-zram
* kunit
* kvm-unit-tests
* libhugetlbfs
* log-parser-boot
* log-parser-test
* ltp-cap_bounds
* ltp-commands
* ltp-containers
* ltp-controllers
* ltp-cpuhotplug
* ltp-crypto
* ltp-cve
* ltp-dio
* ltp-fcntl-locktests
* ltp-filecaps
* ltp-fs
* ltp-fs_bind
* ltp-fs_perms_simple
* ltp-fsx
* ltp-hugetlb
* ltp-io
* ltp-ipc
* ltp-math
* ltp-mm
* ltp-nptl
* ltp-pty
* ltp-sched
* ltp-securebits
* ltp-smoke
* ltp-syscalls
* ltp-tracing
* network-basic-tests
* perf
* rcutorture
* v4l2-compliance
* vdso
--
Linaro LKFT
https://lkft.linaro.org
Hi Greg,
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.247 release. There are 45 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 14 Jun 2023 10:16:41 +0000. Anything received after that time might be too late.
No problems seen on x86_64 and aarch64.
Thanks,
Harshit
Quoted 11 lines
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.247-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.4.y
and the diffstat can be found below.thanks,
greg k-h
Hi Greg,
Quoted 4 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.247 release. There are 45 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Build test (gcc version 11.3.1 20230511):
mips: 65 configs -> no failure
arm: 106 configs -> no failure
arm64: 2 configs -> no failurex86_64: 4 configs -> no failure
alpha allmodconfig -> no failure
powerpc allmodconfig -> no failure
riscv allmodconfig -> no failure
s390 allmodconfig -> no failure
xtensa allmodconfig -> no failure
Boot test:x86_64: Booted on my test laptop. No regression.x86_64: Booted on qemu. No regression. [1]
[1]. https://openqa.qa.codethink.co.uk/tests/3933
--
Regards
Sudip
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.247 release. There are 45 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 14 Jun 2023 10:16:41 +0000. Anything received after that time might be too late.
Build results:
total: 159 pass: 159 fail: 0 Qemu test results: total: 455 pass: 455 fail: 0
Guenter