5.10.158-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainercover 5.10.158-rc1 review
This is the start of the stable review cycle for the 5.10.158 release. There are 92 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, 07 Dec 2022 19:07:46 +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.10.158-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.10.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 5.10.158-rc1
Ming Lei <[email protected]>
block: unhash blkdev part inode when the part is deleted
Zhang Xiaoxu <[email protected]>
Input: raydium_ts_i2c - fix memory leak in raydium_i2c_send()
Jan Dabros <[email protected]>
char: tpm: Protect tpm_pm_suspend with locks
Conor Dooley <[email protected]>
Revert "clocksource/drivers/riscv: Events are stopped during CPU suspend"
Vishal Verma <[email protected]>
ACPI: HMAT: Fix initiator registration for single-initiator systems
Vishal Verma <[email protected]>
ACPI: HMAT: remove unnecessary variable initialization
Andrew Lunn <[email protected]>
i2c: imx: Only DMA messages with I2C_M_DMA_SAFE flag set
Yuan Can <[email protected]>
i2c: npcm7xx: Fix error handling in npcm_i2c_init()
Pawan Gupta <[email protected]>
x86/pm: Add enumeration check before spec MSRs save/restore setup
Pawan Gupta <[email protected]>
x86/tsx: Add a feature bit for TSX control MSR support
Fedor Pchelkin <[email protected]>
Revert "tty: n_gsm: avoid call of sleeping functions from atomic context"
Ido Schimmel <[email protected]>
ipv4: Fix route deletion when nexthop info is not specified
David Ahern <[email protected]>
ipv4: Handle attempt to delete multipath route when fib_info contains an nh reference
Nikolay Aleksandrov <[email protected]>
selftests: net: fix nexthop warning cleanup double ip typo
Nikolay Aleksandrov <[email protected]>
selftests: net: add delete nexthop route warning test
Lee Jones <[email protected]>
Kconfig.debug: provide a little extra FRAME_WARN leeway when KASAN is enabled
Helge Deller <[email protected]>
parisc: Increase FRAME_WARN to 2048 bytes on parisc
Guenter Roeck <[email protected]>
xtensa: increase size of gcc stack frame check
Helge Deller <[email protected]>
parisc: Increase size of gcc stack frame check
Xiongfeng Wang <[email protected]>
iommu/vt-d: Fix PCI device refcount leak in dmar_dev_scope_init()
Xiongfeng Wang <[email protected]>
iommu/vt-d: Fix PCI device refcount leak in has_external_pci()
Maxim Korotkov <[email protected]>
pinctrl: single: Fix potential division by zero
Mark Brown <[email protected]>
ASoC: ops: Fix bounds check for _sx controls
Hao Xu <[email protected]>
io_uring: don't hold uring_lock when calling io_run_task_work*
Steven Rostedt (Google) <[email protected]>
tracing: Free buffers when a used dynamic event is removed
Janusz Krzysztofik <[email protected]>
drm/i915: Never return 0 if not all requests retired
Lee Jones <[email protected]>
drm/amdgpu: temporarily disable broken Clang builds due to blown stack-frame
Adrian Hunter <[email protected]>
mmc: sdhci: Fix voltage switch delay
Wenchao Chen <[email protected]>
mmc: sdhci-sprd: Fix no reset data and command after voltage switch
Sebastian Falbesoner <[email protected]>
mmc: sdhci-esdhc-imx: correct CQHCI exit halt state check
Christian Löhle <[email protected]>
mmc: core: Fix ambiguous TRIM and DISCARD arg
Ye Bin <[email protected]>
mmc: mmc_test: Fix removal of debugfs file
Goh, Wei Sheng <[email protected]>
net: stmmac: Set MAC's flow control register to reflect current settings
Andy Shevchenko <[email protected]>
pinctrl: intel: Save and restore pins in "direct IRQ" mode
Pawan Gupta <[email protected]>
x86/bugs: Make sure MSR_SPEC_CTRL is updated properly upon resume from S3
ZhangPeng <[email protected]>
nilfs2: fix NULL pointer dereference in nilfs_palloc_commit_free_entry()
Tiezhu Yang <[email protected]>
tools/vm/slabinfo-gnuplot: use "grep -E" instead of "egrep"
Steven Rostedt (Google) <[email protected]>
error-injection: Add prompt for function error injection
Jisheng Zhang <[email protected]>
riscv: vdso: fix section overlapping under some conditions
YueHaibing <[email protected]>
net/mlx5: DR, Fix uninitialized var warning
Yang Yingliang <[email protected]>
hwmon: (coretemp) fix pci device refcount leak in nv1a_ram_new()
Phil Auld <[email protected]>
hwmon: (coretemp) Check for null before removing sysfs attrs
Yoshihiro Shimoda <[email protected]>
net: ethernet: renesas: ravb: Fix promiscuous mode after system resumed
Zhengchao Shao <[email protected]>
sctp: fix memory leak in sctp_stream_outq_migrate()
Willem de Bruijn <[email protected]>
packet: do not set TP_STATUS_CSUM_VALID on CHECKSUM_COMPLETE
Shigeru Yoshida <[email protected]>
net: tun: Fix use-after-free in tun_detach()
David Howells <[email protected]>
afs: Fix fileserver probe RTT handling
YueHaibing <[email protected]>
net: hsr: Fix potential use-after-free
Xin Long <[email protected]>
tipc: re-fetch skb cb after tipc_msg_validate
Jerry Ray <[email protected]>
dsa: lan9303: Correct stat name
Yuri Karpov <[email protected]>
net: ethernet: nixge: fix NULL dereference
Wang Hai <[email protected]>
net/9p: Fix a potential socket leak in p9_socket_open
Yuan Can <[email protected]>
net: net_netdev: Fix error handling in ntb_netdev_init_module()
Yang Yingliang <[email protected]>
net: phy: fix null-ptr-deref while probe() failed
Lorenzo Bianconi <[email protected]>
wifi: mac8021: fix possible oob access in ieee80211_get_rate_duration
Johannes Berg <[email protected]>
wifi: cfg80211: don't allow multi-BSSID in S1G
Johannes Berg <[email protected]>
wifi: cfg80211: fix buffer overflow in elem comparison
Izabela Bakollari <[email protected]>
aquantia: Do not purge addresses when setting the number of rings
Duoming Zhou <[email protected]>
qlcnic: fix sleep-in-atomic-context bugs caused by msleep
Zhang Changzhong <[email protected]>
can: cc770: cc770_isa_probe(): add missing free_cc770dev()
Zhang Changzhong <[email protected]>
can: sja1000_isa: sja1000_isa_probe(): add missing free_sja1000dev()
Roi Dayan <[email protected]>
net/mlx5e: Fix use-after-free when reverting termination table
YueHaibing <[email protected]>
net/mlx5: Fix uninitialized variable bug in outlen_write()
Wang Hai <[email protected]>
e100: Fix possible use after free in e100_xmit_prepare
Christophe JAILLET <[email protected]>
e100: switch from 'pci_' to 'dma_' API
Yuan Can <[email protected]>
iavf: Fix error handling in iavf_init_module()
Minghao Chi <[email protected]>
iavf: remove redundant ret variable
Yuan Can <[email protected]>
fm10k: Fix error handling in fm10k_init_module()
Shang XiaoJing <[email protected]>
i40e: Fix error handling in i40e_init_module()
Shang XiaoJing <[email protected]>
ixgbevf: Fix resource leak in ixgbevf_init_module()
Yang Yingliang <[email protected]>
of: property: decrement node refcount in of_fwnode_get_reference_args()
Xu Kuohai <[email protected]>
bpf: Do not copy spin lock field from user in bpf_selem_alloc
Gaosheng Cui <[email protected]>
hwmon: (ibmpex) Fix possible UAF when ibmpex_register_bmc() fails
Yang Yingliang <[email protected]>
hwmon: (i5500_temp) fix missing pci_disable_device()
Ninad Malwade <[email protected]>
hwmon: (ina3221) Fix shunt sum critical calculation
Derek Nguyen <[email protected]>
hwmon: (ltc2947) fix temperature scaling
Hou Tao <[email protected]>
libbpf: Handle size overflow for ringbuf mmap
Michael Grzeschik <[email protected]>
ARM: at91: rm9200: fix usb device clock id
Srikar Dronamraju <[email protected]>
scripts/faddr2line: Fix regression in name resolution on ppc64le
Hou Tao <[email protected]>
bpf, perf: Use subprog name when reporting subprog ksymbol
Paul Gazzillo <[email protected]>
iio: light: rpr0521: add missing Kconfig dependencies
Wei Yongjun <[email protected]>
iio: health: afe4404: Fix oob read in afe4404_[read|write]_raw
Wei Yongjun <[email protected]>
iio: health: afe4403: Fix oob read in afe4403_read_raw
ChenXiaoSong <[email protected]>
btrfs: qgroup: fix sleep from invalid context bug in btrfs_qgroup_inherit()
Alex Deucher <[email protected]>
drm/amdgpu: Partially revert "drm/amdgpu: update drm_display_info correctly when the edid is read"
Claudio Suarez <[email protected]>
drm/amdgpu: update drm_display_info correctly when the edid is read
Sam James <[email protected]>
kbuild: fix -Wimplicit-function-declaration in license_is_gpl_compatible
Lyude Paul <[email protected]>
drm/display/dp_mst: Fix drm_dp_mst_add_affected_dsc_crtcs() return code
Nikolay Borisov <[email protected]>
btrfs: move QUOTA_ENABLED check to rescan_should_stop from btrfs_qgroup_rescan_worker
Frieder Schrempf <[email protected]>
spi: spi-imx: Fix spi_bus_clk if requested clock is higher than input clock
Anand Jain <[email protected]>
btrfs: free btrfs_path before copying inodes to userspace
David Sterba <[email protected]>
btrfs: sink iterator parameter to btrfs_ioctl_logical_to_ino
-------------
Diffstat:
Makefile | 4 +- arch/arm/boot/dts/at91rm9200.dtsi | 2 +- arch/riscv/kernel/vdso/Makefile | 1 + arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/include/asm/nospec-branch.h | 2 +- arch/x86/kernel/cpu/bugs.c | 21 +++-- arch/x86/kernel/cpu/tsx.c | 33 ++++---- arch/x86/kernel/process.c | 2 +- arch/x86/power/cpu.c | 23 ++++-- block/partitions/core.c | 7 ++ drivers/acpi/numa/hmat.c | 27 ++++-- drivers/char/tpm/tpm-interface.c | 5 +- drivers/clk/at91/at91rm9200.c | 2 +- drivers/clocksource/timer-riscv.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c | 4 +- drivers/gpu/drm/amd/display/Kconfig | 7 ++ drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +- drivers/gpu/drm/drm_dp_mst_topology.c | 2 +- drivers/gpu/drm/i915/gt/intel_gt_requests.c | 2 +- drivers/hwmon/coretemp.c | 9 +- drivers/hwmon/i5500_temp.c | 2 +- drivers/hwmon/ibmpex.c | 1 + drivers/hwmon/ina3221.c | 4 +- drivers/hwmon/ltc2947-core.c | 2 +- drivers/i2c/busses/i2c-imx.c | 6 +- drivers/i2c/busses/i2c-npcm7xx.c | 11 ++- drivers/iio/health/afe4403.c | 5 +- drivers/iio/health/afe4404.c | 12 +-- drivers/iio/light/Kconfig | 2 + drivers/input/touchscreen/raydium_i2c_ts.c | 4 +- drivers/iommu/intel/dmar.c | 1 + drivers/iommu/intel/iommu.c | 4 +- drivers/mmc/core/core.c | 9 +- drivers/mmc/core/mmc_test.c | 3 +- drivers/mmc/host/sdhci-esdhc-imx.c | 2 +- drivers/mmc/host/sdhci-sprd.c | 4 +- drivers/mmc/host/sdhci.c | 61 ++++++++++++-- drivers/mmc/host/sdhci.h | 2 + drivers/net/can/cc770/cc770_isa.c | 10 ++- drivers/net/can/sja1000/sja1000_isa.c | 10 ++- drivers/net/dsa/lan9303-core.c | 2 +- .../net/ethernet/aquantia/atlantic/aq_ethtool.c | 5 +- drivers/net/ethernet/aquantia/atlantic/aq_main.c | 4 +- drivers/net/ethernet/aquantia/atlantic/aq_main.h | 2 + drivers/net/ethernet/intel/e100.c | 95 +++++++++++----------- drivers/net/ethernet/intel/fm10k/fm10k_main.c | 10 ++- drivers/net/ethernet/intel/i40e/i40e_main.c | 11 ++- drivers/net/ethernet/intel/iavf/iavf_main.c | 8 +- drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 10 ++- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 4 +- .../mellanox/mlx5/core/eswitch_offloads_termtbl.c | 2 + .../mellanox/mlx5/core/steering/dr_table.c | 5 +- drivers/net/ethernet/ni/nixge.c | 29 +++---- .../net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c | 4 +- drivers/net/ethernet/renesas/ravb_main.c | 1 + drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 2 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 12 ++- drivers/net/ntb_netdev.c | 9 +- drivers/net/phy/phy_device.c | 1 + drivers/net/tun.c | 4 +- drivers/of/property.c | 4 +- drivers/pinctrl/intel/pinctrl-intel.c | 27 +++++- drivers/pinctrl/pinctrl-single.c | 2 +- drivers/spi/spi-imx.c | 3 +- drivers/tty/n_gsm.c | 39 +++++---- fs/afs/fs_probe.c | 4 +- fs/btrfs/backref.c | 25 +++++- fs/btrfs/backref.h | 3 +- fs/btrfs/ioctl.c | 38 ++------- fs/btrfs/qgroup.c | 22 ++--- fs/io_uring.c | 82 ++++++++++++++----- fs/nilfs2/dat.c | 7 ++ include/linux/license.h | 2 + include/linux/mmc/mmc.h | 2 +- include/net/sctp/stream_sched.h | 2 + kernel/bpf/bpf_local_storage.c | 2 +- kernel/events/core.c | 2 +- kernel/trace/trace_dynevent.c | 2 + kernel/trace/trace_events.c | 11 ++- lib/Kconfig.debug | 14 +++- net/9p/trans_fd.c | 4 +- net/hsr/hsr_forward.c | 5 +- net/ipv4/fib_semantics.c | 10 ++- net/mac80211/airtime.c | 3 + net/packet/af_packet.c | 6 +- net/sctp/stream.c | 25 ++++-- net/sctp/stream_sched.c | 5 ++ net/sctp/stream_sched_prio.c | 19 +++++ net/sctp/stream_sched_rr.c | 5 ++ net/tipc/crypto.c | 3 + net/wireless/scan.c | 10 ++- scripts/faddr2line | 7 +- sound/soc/soc-ops.c | 2 +- tools/lib/bpf/ringbuf.c | 12 ++- tools/testing/selftests/net/fib_nexthops.sh | 30 +++++++ tools/vm/slabinfo-gnuplot.sh | 4 +- 96 files changed, 672 insertions(+), 305 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/92 btrfs: sink iterator parameter to btrfs_ioctl_logical_to_ino
From: David Sterba <[email protected]>
[ Upstream commit e3059ec06b9f1a96826cc2bb6ed131aac0942446 ]
There's only one function we pass to iterate_inodes_from_logical as iterator, so we can drop the indirection and call it directly, after moving the function to backref.c
Stable-dep-of: 418ffb9e3cf6 ("btrfs: free btrfs_path before copying inodes to userspace")
--- fs/btrfs/backref.c | 25 ++++++++++++++++++++++--- fs/btrfs/backref.h | 3 +-- fs/btrfs/ioctl.c | 22 +--------------------- 3 files changed, 24 insertions(+), 26 deletions(-)
fs/btrfs/backref.c +22 -3
@@ -2060,10 +2060,29 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info,return ret; } +static int build_ino_list (u64 inum,u64 offset,u64 root,void *ctx) +{ +struct btrfs_data_container *inodes = ctx; +const size_t c =3 *sizeof (u64); + +if (inodes->bytes_left >= c) { + inodes->bytes_left -= c; + inodes->val[inodes->elem_cnt] = inum; + inodes->val[inodes->elem_cnt +1 ] = offset; + inodes->val[inodes->elem_cnt +2 ] = root; + inodes->elem_cnt +=3 ; + }else { + inodes->bytes_missing += c - inodes->bytes_left; + inodes->bytes_left =0 ; + inodes->elem_missed +=3 ; + } + +return 0 ; +} +int iterate_inodes_from_logical (u64 logical,struct btrfs_fs_info *fs_info,struct btrfs_path *path, -iterate_extent_inodes_t *iterate,void *ctx, -bool ignore_offset) +void *ctx,bool ignore_offset) {int ret;u64 extent_item_pos;
@@ -2081,7 +2100,7 @@ int iterate_inodes_from_logical(u64 logical, struct btrfs_fs_info *fs_info, extent_item_pos = logical - found_key.objectid; ret =iterate_extent_inodes (fs_info, found_key.objectid, extent_item_pos, search_commit_root, - iterate, ctx, ignore_offset); + build_ino_list, ctx, ignore_offset);return ret; }
fs/btrfs/backref.h +1 -2
@@ -35,8 +35,7 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info, bool ignore_offset);int iterate_inodes_from_logical (u64 logical,struct btrfs_fs_info *fs_info, -struct btrfs_path *path, -iterate_extent_inodes_t *iterate,void *ctx, +struct btrfs_path *path,void *ctx,bool ignore_offset);int paths_from_inode (u64 inum,struct inode_fs_paths *ipath);
fs/btrfs/ioctl.c +1 -21
@@ -3898,26 +3898,6 @@ static long btrfs_ioctl_ino_to_path(struct btrfs_root *root, void __user *arg)return ret; } -static int build_ino_list (u64 inum,u64 offset,u64 root,void *ctx) -{ -struct btrfs_data_container *inodes = ctx; -const size_t c =3 *sizeof (u64); - -if (inodes->bytes_left >= c) { - inodes->bytes_left -= c; - inodes->val[inodes->elem_cnt] = inum; - inodes->val[inodes->elem_cnt +1 ] = offset; - inodes->val[inodes->elem_cnt +2 ] = root; - inodes->elem_cnt +=3 ; - }else { - inodes->bytes_missing += c - inodes->bytes_left; - inodes->bytes_left =0 ; - inodes->elem_missed +=3 ; - } - -return 0 ; -} -static long btrfs_ioctl_logical_to_ino (struct btrfs_fs_info *fs_info,void __user *arg,int version) {
@@ -3967,7 +3947,7 @@ static long btrfs_ioctl_logical_to_ino(struct btrfs_fs_info *fs_info, } ret =iterate_inodes_from_logical (loi->logical, fs_info, path, - build_ino_list, inodes, ignore_offset); + inodes, ignore_offset);if (ret == -EINVAL ) ret = -ENOENT ;if (ret <0 )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 2/92 btrfs: free btrfs_path before copying inodes to userspace
In reply to Greg Kroah-HartmanFrom: Anand Jain <[email protected]>
[ Upstream commit 418ffb9e3cf6c4e2574d3a732b724916684bd133 ]
btrfs_ioctl_logical_to_ino() frees the search path after the userspace copy from the temp buffer @inodes. Which potentially can lead to a lock splat.
Fix this by freeing the path before we copy @inodes to userspace.
--- fs/btrfs/ioctl.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
fs/btrfs/ioctl.c +7 -9
@@ -3933,21 +3933,20 @@ static long btrfs_ioctl_logical_to_ino(struct btrfs_fs_info *fs_info, size =min_t (u32, loi->size,SZ_16M ); } - path =btrfs_alloc_path (); -if (!path) { - ret = -ENOMEM ; - goto out; - } - inodes =init_data_container (size);if (IS_ERR (inodes)) { ret =PTR_ERR (inodes); - inodes =NULL ; - goto out; + goto out_loi; } + path =btrfs_alloc_path (); +if (!path) { + ret = -ENOMEM ; + goto out; + } ret =iterate_inodes_from_logical (loi->logical, fs_info, path, inodes, ignore_offset); +btrfs_free_path (path);if (ret == -EINVAL ) ret = -ENOENT ;if (ret <0 )
@@ -3959,7 +3958,6 @@ static long btrfs_ioctl_logical_to_ino(struct btrfs_fs_info *fs_info, ret = -EFAULT ; out: -btrfs_free_path (path);kvfree (inodes); out_loi:kfree (loi);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 3/92 spi: spi-imx: Fix spi_bus_clk if requested clock is higher than input clock
In reply to Greg Kroah-HartmanFrom: Frieder Schrempf <[email protected]>
[ Upstream commit db2d2dc9a0b58c6faefb6b002fdbed4f0362d1a4 ]
In case the requested bus clock is higher than the input clock, the correct dividers (pre = 0, post = 0) are returned from mx51_ecspi_clkdiv(), but *fres is left uninitialized and therefore contains an arbitrary value.
This causes trouble for the recently introduced PIO polling feature as the value in spi_imx->spi_bus_clk is used there to calculate for which transfers to enable PIO polling.
Fix this by setting *fres even if no clock dividers are in use.
This issue was observed on Kontron BL i.MX8MM with an SPI peripheral clock set to 50 MHz by default and a requested SPI bus clock of 80 MHz for the SPI NOR flash.
With the fix applied the debug message from mx51_ecspi_clkdiv() now prints the following:
spi_imx 30820000.spi: mx51_ecspi_clkdiv: fin: 50000000, fspi: 50000000,
post: 0, pre: 0
--- drivers/spi/spi-imx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/spi/spi-imx.c +1 -2
@@ -434,8 +434,7 @@ static unsigned int mx51_ecspi_clkdiv(struct spi_imx_data *spi_imx,unsigned int pre, post;unsigned int fin = spi_imx->spi_clk; -if (unlikely (fspi > fin)) -return 0 ; + fspi =min (fspi, fin); post =fls (fin) -fls (fspi);if (fin > fspi << post)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 4/92 btrfs: move QUOTA_ENABLED check to rescan_should_stop from btrfs_qgroup_rescan_worker
In reply to Greg Kroah-HartmanFrom: Nikolay Borisov <[email protected]>
[ Upstream commit db5df254120004471e1c957957ab2f1e612dcbd6 ]
Instead of having 2 places that short circuit the qgroup leaf scan have everything in the qgroup_rescan_leaf function. In addition to that, also ensure that the inconsistent qgroup flag is set when rescan_should_stop returns true. This both retains the old behavior when -EINTR was set in the body of the loop and at the same time also extends this behavior when scanning is interrupted due to remount or unmount operations.
Stable-dep-of: f7e942b5bb35 ("btrfs: qgroup: fix sleep from invalid context bug in btrfs_qgroup_inherit()")
--- fs/btrfs/qgroup.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
fs/btrfs/qgroup.c +6 -7
@@ -3290,7 +3290,8 @@ static int qgroup_rescan_leaf(struct btrfs_trans_handle *trans,static bool rescan_should_stop (struct btrfs_fs_info *fs_info) {return btrfs_fs_closing (fs_info) || -test_bit (BTRFS_FS_STATE_REMOUNTING , &fs_info->fs_state); +test_bit (BTRFS_FS_STATE_REMOUNTING , &fs_info->fs_state) || + !test_bit (BTRFS_FS_QUOTA_ENABLED , &fs_info->flags); }static void btrfs_qgroup_rescan_worker (struct btrfs_work *work)
@@ -3320,11 +3321,9 @@ static void btrfs_qgroup_rescan_worker(struct btrfs_work *work) err =PTR_ERR (trans);break ; } -if (!test_bit (BTRFS_FS_QUOTA_ENABLED , &fs_info->flags)) { - err = -EINTR ; - }else { - err =qgroup_rescan_leaf (trans, path); - } + + err =qgroup_rescan_leaf (trans, path); +if (err >0 )btrfs_commit_transaction (trans);else
@@ -3338,7 +3337,7 @@ static void btrfs_qgroup_rescan_worker(struct btrfs_work *work)if (err >0 && fs_info->qgroup_flags &BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT ) { fs_info->qgroup_flags &= ~BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT ; - }else if (err <0 ) { + }else if (err <0 || stopped) { fs_info->qgroup_flags |=BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT ; }mutex_unlock (&fs_info->qgroup_rescan_lock);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 5/92 drm/display/dp_mst: Fix drm_dp_mst_add_affected_dsc_crtcs() return code
In reply to Greg Kroah-HartmanFrom: Lyude Paul <[email protected]>
[ Upstream commit 2f3a1273862cb82cca227630cc7f04ce0c94b6bb ]
Looks like that we're accidentally dropping a pretty important return code here. For some reason, we just return -EINVAL if we fail to get the MST topology state. This is wrong: error codes are important and should never be squashed without being handled, which here seems to have the potential to cause a deadlock.
--- drivers/gpu/drm/drm_dp_mst_topology.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_dp_mst_topology.c +1 -1
@@ -5238,7 +5238,7 @@ int drm_dp_mst_add_affected_dsc_crtcs(struct drm_atomic_state *state, struct drm mst_state =drm_atomic_get_mst_topology_state (state, mgr);if (IS_ERR (mst_state)) -return -EINVAL ; +return PTR_ERR (mst_state);list_for_each_entry (pos, &mst_state->vcpis, next) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 6/92 kbuild: fix -Wimplicit-function-declaration in license_is_gpl_compatible
In reply to Greg Kroah-HartmanFrom: Sam James <[email protected]>
[ Upstream commit 50c697215a8cc22f0e58c88f06f2716c05a26e85 ]
Add missing <linux/string.h> include for strcmp.
Clang 16 makes -Wimplicit-function-declaration an error by default. Unfortunately, out of tree modules may use this in configure scripts, which means failure might cause silent miscompilation or misconfiguration.
For more information, see LWN.net [0] or LLVM's Discourse [1], gentoo-dev@ [2], or the (new) c-std-porting mailing list [3].
[0] https://lwn.net/Articles/913505/
[1] https://discourse.llvm.org/t/configure-script-breakage-with-the-new-werror-implicit-function-declaration/65213
[2] https://archives.gentoo.org/gentoo-dev/message/dd9f2d3082b8b6f8dfbccb0639e6e240
[3] hosted at lists.linux.dev.
--- include/linux/license.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/license.h +2 -0
@@ -2,6 +2,8 @@#ifndef __LICENSE_H#define __LICENSE_H +#include <linux/string.h> +static inline int license_is_gpl_compatible (const char *license) { return (strcmp(license, "GPL") == 0
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 7/92 drm/amdgpu: update drm_display_info correctly when the edid is read
In reply to Greg Kroah-HartmanFrom: Claudio Suarez <[email protected]>
[ Upstream commit 20543be93ca45968f344261c1a997177e51bd7e1 ]
drm_display_info is updated by drm_get_edid() or drm_connector_update_edid_property(). In the amdgpu driver it is almost always updated when the edid is read in amdgpu_connector_get_edid(), but not always. Change amdgpu_connector_get_edid() and amdgpu_connector_free_edid() to keep drm_display_info updated.
Stable-dep-of: 602ad43c3cd8 ("drm/amdgpu: Partially revert "drm/amdgpu: update drm_display_info correctly when the edid is read"")
--- drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c | 5 ++++- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c +4 -1
@@ -315,8 +315,10 @@ static void amdgpu_connector_get_edid(struct drm_connector *connector)if (!amdgpu_connector->edid) {/* some laptops provide a hardcoded edid in rom for LCDs */ if (((connector->connector_type ==DRM_MODE_CONNECTOR_LVDS ) || - (connector->connector_type == DRM_MODE_CONNECTOR_eDP))) + (connector->connector_type == DRM_MODE_CONNECTOR_eDP))) { amdgpu_connector->edid =amdgpu_connector_get_hardcoded_edid (adev); +drm_connector_update_edid_property (connector, amdgpu_connector->edid); + } } }
@@ -326,6 +328,7 @@ static void amdgpu_connector_free_edid(struct drm_connector *connector)kfree (amdgpu_connector->edid); amdgpu_connector->edid =NULL ; +drm_connector_update_edid_property (connector,NULL ); }static int amdgpu_connector_ddc_get_modes (struct drm_connector *connector)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -2
@@ -2348,13 +2348,12 @@ void amdgpu_dm_update_connector_after_detect( aconnector->edid = (struct edid *)sink->dc_edid.raw_edid; -drm_connector_update_edid_property (connector, - aconnector->edid);if (aconnector->dc_link->aux_mode)drm_dp_cec_set_edid (&aconnector->dm_dp_aux.aux, aconnector->edid); } +drm_connector_update_edid_property (connector, aconnector->edid);amdgpu_dm_update_freesync_caps (connector, aconnector->edid);update_connector_ext_caps (aconnector); }else {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 8/92 drm/amdgpu: Partially revert "drm/amdgpu: update drm_display_info correctly when the edid is read"
In reply to Greg Kroah-HartmanFrom: Alex Deucher <[email protected]>
[ Upstream commit 602ad43c3cd8f15cbb25ce9bb494129edb2024ed ]
This partially reverts 20543be93ca45968f344261c1a997177e51bd7e1.
Calling drm_connector_update_edid_property() in amdgpu_connector_free_edid() causes a noticeable pause in the system every 10 seconds on polled outputs so revert this part of the change.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c | 1 - 1 file changed, 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c +0 -1
@@ -328,7 +328,6 @@ static void amdgpu_connector_free_edid(struct drm_connector *connector)kfree (amdgpu_connector->edid); amdgpu_connector->edid =NULL ; -drm_connector_update_edid_property (connector,NULL ); }static int amdgpu_connector_ddc_get_modes (struct drm_connector *connector)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 9/92 btrfs: qgroup: fix sleep from invalid context bug in btrfs_qgroup_inherit()
In reply to Greg Kroah-HartmanFrom: ChenXiaoSong <[email protected]>
[ Upstream commit f7e942b5bb35d8e3af54053d19a6bf04143a3955 ]
Syzkaller reported BUG as follows:
BUG: sleeping function called from invalid context at
include/linux/sched/mm.h:274
Call Trace:
<TASK>
dump_stack_lvl+0xcd/0x134
__might_resched.cold+0x222/0x26b
kmem_cache_alloc+0x2e7/0x3c0
update_qgroup_limit_item+0xe1/0x390
btrfs_qgroup_inherit+0x147b/0x1ee0
create_subvol+0x4eb/0x1710
btrfs_mksubvol+0xfe5/0x13f0
__btrfs_ioctl_snap_create+0x2b0/0x430
btrfs_ioctl_snap_create_v2+0x25a/0x520
btrfs_ioctl+0x2a1c/0x5ce0
__x64_sys_ioctl+0x193/0x200
do_syscall_64+0x35/0x80Fix this by calling qgroup_dirty() on @dstqgroup, and update limit item in btrfs_run_qgroups() later outside of the spinlock context.
--- fs/btrfs/qgroup.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
fs/btrfs/qgroup.c +1 -8
@@ -2913,14 +2913,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid, dstgroup->rsv_rfer = inherit->lim.rsv_rfer; dstgroup->rsv_excl = inherit->lim.rsv_excl; - ret =update_qgroup_limit_item (trans, dstgroup); -if (ret) { - fs_info->qgroup_flags |=BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT ; -btrfs_info (fs_info, -"unable to update quota limit for %llu" , - dstgroup->qgroupid); - goto unlock; - } +qgroup_dirty (fs_info, dstgroup); }if (srcid) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 10/92 iio: health: afe4403: Fix oob read in afe4403_read_raw
In reply to Greg Kroah-HartmanFrom: Wei Yongjun <[email protected]>
[ Upstream commit 58143c1ed5882c138a3cd2251a336fc8755f23d9 ]
KASAN report out-of-bounds read as follows:
BUG: KASAN: global-out-of-bounds in afe4403_read_raw+0x42e/0x4c0 Read of size 4 at addr ffffffffc02ac638 by task cat/279 Call Trace: afe4403_read_raw iio_read_channel_info dev_attr_show The buggy address belongs to the variable: afe4403_channel_leds+0x18/0xffffffffffffe9e0
This issue can be reproduced by singe command:
$ cat /sys/bus/spi/devices/spi0.0/iio\:device0/in_intensity6_raw
The array size of afe4403_channel_leds is less than channels, so access with chan->address cause OOB read in afe4403_read_raw. Fix it by moving access before use it.
--- drivers/iio/health/afe4403.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/iio/health/afe4403.c +3 -2
@@ -245,14 +245,14 @@ static int afe4403_read_raw(struct iio_dev *indio_dev, int *val, int *val2, long mask) { struct afe4403_data *afe = iio_priv(indio_dev); -unsigned int reg = afe4403_channel_values[chan->address]; -unsigned int field = afe4403_channel_leds[chan->address]; +unsigned int reg, field;int ret;switch (chan->type) {case IIO_INTENSITY :switch (mask) {case IIO_CHAN_INFO_RAW : + reg = afe4403_channel_values[chan->address]; ret =afe4403_read (afe, reg, val);if (ret)return ret;
@@ -262,6 +262,7 @@ static int afe4403_read_raw(struct iio_dev *indio_dev,case IIO_CURRENT :switch (mask) {case IIO_CHAN_INFO_RAW : + field = afe4403_channel_leds[chan->address]; ret =regmap_field_read (afe->fields[field], val);if (ret)return ret;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 11/92 iio: health: afe4404: Fix oob read in afe4404_[read|write]_raw
In reply to Greg Kroah-HartmanFrom: Wei Yongjun <[email protected]>
[ Upstream commit fc92d9e3de0b2d30a3ccc08048a5fad533e4672b ]
KASAN report out-of-bounds read as follows:
BUG: KASAN: global-out-of-bounds in afe4404_read_raw+0x2ce/0x380 Read of size 4 at addr ffffffffc00e4658 by task cat/278 Call Trace: afe4404_read_raw iio_read_channel_info dev_attr_show The buggy address belongs to the variable: afe4404_channel_leds+0x18/0xffffffffffffe9c0
This issue can be reproduce by singe command:
$ cat /sys/bus/i2c/devices/0-0058/iio\:device0/in_intensity6_raw
The array size of afe4404_channel_leds and afe4404_channel_offdacs are less than channels, so access with chan->address cause OOB read in afe4404_[read|write]_raw. Fix it by moving access before use them.
--- drivers/iio/health/afe4404.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/iio/health/afe4404.c +7 -5
@@ -250,20 +250,20 @@ static int afe4404_read_raw(struct iio_dev *indio_dev, int *val, int *val2, long mask) { struct afe4404_data *afe = iio_priv(indio_dev); -unsigned int value_reg = afe4404_channel_values[chan->address]; -unsigned int led_field = afe4404_channel_leds[chan->address]; -unsigned int offdac_field = afe4404_channel_offdacs[chan->address]; +unsigned int value_reg, led_field, offdac_field;int ret;switch (chan->type) {case IIO_INTENSITY :switch (mask) {case IIO_CHAN_INFO_RAW : + value_reg = afe4404_channel_values[chan->address]; ret =regmap_read (afe->regmap, value_reg, val);if (ret)return ret;return IIO_VAL_INT ;case IIO_CHAN_INFO_OFFSET : + offdac_field = afe4404_channel_offdacs[chan->address]; ret =regmap_field_read (afe->fields[offdac_field], val);if (ret)return ret;
@@ -273,6 +273,7 @@ static int afe4404_read_raw(struct iio_dev *indio_dev,case IIO_CURRENT :switch (mask) {case IIO_CHAN_INFO_RAW : + led_field = afe4404_channel_leds[chan->address]; ret =regmap_field_read (afe->fields[led_field], val);if (ret)return ret;
@@ -295,19 +296,20 @@ static int afe4404_write_raw(struct iio_dev *indio_dev, int val, int val2, long mask) { struct afe4404_data *afe = iio_priv(indio_dev); -unsigned int led_field = afe4404_channel_leds[chan->address]; -unsigned int offdac_field = afe4404_channel_offdacs[chan->address]; +unsigned int led_field, offdac_field;switch (chan->type) {case IIO_INTENSITY :switch (mask) {case IIO_CHAN_INFO_OFFSET : + offdac_field = afe4404_channel_offdacs[chan->address];return regmap_field_write (afe->fields[offdac_field], val); }break ;case IIO_CURRENT :switch (mask) {case IIO_CHAN_INFO_RAW : + led_field = afe4404_channel_leds[chan->address];return regmap_field_write (afe->fields[led_field], val); }break ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 12/92 iio: light: rpr0521: add missing Kconfig dependencies
In reply to Greg Kroah-HartmanFrom: Paul Gazzillo <[email protected]>
[ Upstream commit 6ac12303572ef9ace5603c2c07f5f1b00a33f580 ]
Fix an implicit declaration of function error for rpr0521 under some configs
When CONFIG_RPR0521 is enabled without CONFIG_IIO_TRIGGERED_BUFFER, the build results in "implicit declaration of function" errors, e.g.,
drivers/iio/light/rpr0521.c:434:3: error: implicit declaration of function
'iio_trigger_poll_chained' [-Werror=implicit-function-declaration]
434 | iio_trigger_poll_chained(data->drdy_trigger0);
| ^~~~~~~~~~~~~~~~~~~~~~~~This fix adds select dependencies to RPR0521's configuration declaration.
--- drivers/iio/light/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/light/Kconfig +2 -0
@@ -294,6 +294,8 @@ config RPR0521 tristate "ROHM RPR0521 ALS and proximity sensor driver" depends on I2C select REGMAP_I2C + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER help Say Y here if you want to build support for ROHM's RPR0521 ambient light and proximity sensor device.
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 13/92 bpf, perf: Use subprog name when reporting subprog ksymbol
In reply to Greg Kroah-HartmanFrom: Hou Tao <[email protected]>
[ Upstream commit 47df8a2f78bc34ff170d147d05b121f84e252b85 ]
Since commit bfea9a8574f3 ("bpf: Add name to struct bpf_ksym"), when reporting subprog ksymbol to perf, prog name instead of subprog name is used. The backtrace of bpf program with subprogs will be incorrect as shown below:
ffffffffc02deace bpf_prog_e44a3057dcb151f8_overwrite+0x66 ffffffffc02de9f7 bpf_prog_e44a3057dcb151f8_overwrite+0x9f ffffffffa71d8d4e trace_call_bpf+0xce ffffffffa71c2938 perf_call_bpf_enter.isra.0+0x48
overwrite is the entry program and it invokes the overwrite_htab subprog through bpf_loop, but in above backtrace, overwrite program just jumps inside itself.
Fixing it by using subprog name when reporting subprog ksymbol. After the fix, the output of perf script will be correct as shown below:
ffffffffc031aad2 bpf_prog_37c0bec7d7c764a4_overwrite_htab+0x66 ffffffffc031a9e7 bpf_prog_c7eb827ef4f23e71_overwrite+0x9f ffffffffa3dd8d4e trace_call_bpf+0xce ffffffffa3dc2938 perf_call_bpf_enter.isra.0+0x48
--- kernel/events/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/core.c +1 -1
@@ -8740,7 +8740,7 @@ static void perf_event_bpf_emit_ksymbols(struct bpf_prog *prog,PERF_RECORD_KSYMBOL_TYPE_BPF , (u64 )(unsigned long )subprog->bpf_func, subprog->jited_len, unregister, - prog->aux->ksym.name); + subprog->aux->ksym.name); } } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 14/92 scripts/faddr2line: Fix regression in name resolution on ppc64le
In reply to Greg Kroah-HartmanFrom: Srikar Dronamraju <[email protected]>
[ Upstream commit 2d77de1581bb5b470486edaf17a7d70151131afd ]
Commit 1d1a0e7c5100 ("scripts/faddr2line: Fix overlapping text section failures") can cause faddr2line to fail on ppc64le on some distributions, while it works fine on other distributions. The failure can be attributed to differences in the readelf output.
$ ./scripts/faddr2line vmlinux find_busiest_group+0x00 no match for find_busiest_group+0x00
On ppc64le, readelf adds the localentry tag before the symbol name on some distributions, and adds the localentry tag after the symbol name on other distributions. This problem has been discussed previously:
https://lore.kernel.org/bpf/20191211160133.GB4580@calabresa/
This problem can be overcome by filtering out the localentry tags in the readelf output. Similar fixes are already present in the kernel by way of the following commits:
1fd6cee127e2 ("libbpf: Fix VERSIONED_SYM_COUNT number parsing") aa915931ac3e ("libbpf: Fix readelf output parsing for Fedora")
[jpoimboe: rework commit log]
--- scripts/faddr2line | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
scripts/faddr2line +4 -3
@@ -73,7 +73,8 @@ command -v ${ADDR2LINE} >/dev/null 2>&1 || die "${ADDR2LINE} isn't installed" find_dir_prefix() { local objfile=$1 - local start_kernel_addr=$(${READELF} --symbols --wide $objfile | ${AWK} '$8 == "start_kernel" {printf "0x%s", $2}') + local start_kernel_addr=$(${READELF} --symbols --wide $objfile | sed 's/\[.*\]//' | + ${AWK} '$8 == "start_kernel" {printf "0x%s", $2}') [[ -z $start_kernel_addr ]] && return local file_line=$(${ADDR2LINE} -e $objfile $start_kernel_addr)
@@ -177,7 +178,7 @@ __faddr2line() { found=2 break fi - done < <(${READELF} --symbols --wide $objfile | ${AWK} -v sec=$sym_sec '$7 == sec' | sort --key=2) + done < <(${READELF} --symbols --wide $objfile | sed 's/\[.*\]//' | ${AWK} -v sec=$sym_sec '$7 == sec' | sort --key=2) if [[ $found = 0 ]]; then warn "can't find symbol: sym_name: $sym_name sym_sec: $sym_sec sym_addr: $sym_addr sym_elf_size: $sym_elf_size"
@@ -258,7 +259,7 @@ __faddr2line() { DONE=1 - done < <(${READELF} --symbols --wide $objfile | ${AWK} -v fn=$sym_name '$4 == "FUNC" && $8 == fn') + done < <(${READELF} --symbols --wide $objfile | sed 's/\[.*\]//' | ${AWK} -v fn=$sym_name '$4 == "FUNC" && $8 == fn') } [[ $# -lt 2 ]] && usage
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 15/92 ARM: at91: rm9200: fix usb device clock id
In reply to Greg Kroah-HartmanFrom: Michael Grzeschik <[email protected]>
[ Upstream commit 57976762428675f259339385d3324d28ee53ec02 ]
Referring to the datasheet the index 2 is the MCKUDP. When enabled, it "Enables the automatic disable of the Master Clock of the USB Device Port when a suspend condition occurs". We fix the index to the real UDP id which "Enables the 48 MHz clock of the USB Device Port".
--- arch/arm/boot/dts/at91rm9200.dtsi | 2 +- drivers/clk/at91/at91rm9200.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/boot/dts/at91rm9200.dtsi +1 -1
@@ -660,7 +660,7 @@ usb1: gadget@fffb0000 { compatible = "atmel,at91rm9200-udc"; reg = <0xfffb0000 0x4000>; interrupts = <11 IRQ_TYPE_LEVEL_HIGH 2>; - clocks = <&pmc PMC_TYPE_PERIPHERAL 11>, <&pmc PMC_TYPE_SYSTEM 2>; + clocks = <&pmc PMC_TYPE_PERIPHERAL 11>, <&pmc PMC_TYPE_SYSTEM 1>; clock-names = "pclk", "hclk"; status = "disabled"; };
drivers/clk/at91/at91rm9200.c +1 -1
@@ -38,7 +38,7 @@ static const struct clk_pll_characteristics rm9200_pll_characteristics = { };static const struct sck at91rm9200_systemck[] = { - { .n ="udpck" , .p ="usbck" , .id =2 }, + { .n ="udpck" , .p ="usbck" , .id =1 }, { .n ="uhpck" , .p ="usbck" , .id =4 }, { .n ="pck0" , .p ="prog0" , .id =8 }, { .n ="pck1" , .p ="prog1" , .id =9 },
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 16/92 libbpf: Handle size overflow for ringbuf mmap
In reply to Greg Kroah-HartmanFrom: Hou Tao <[email protected]>
[ Upstream commit 927cbb478adf917e0a142b94baa37f06279cc466 ]
The maximum size of ringbuf is 2GB on x86-64 host, so 2 * max_entries will overflow u32 when mapping producer page and data pages. Only casting max_entries to size_t is not enough, because for 32-bits application on 64-bits kernel the size of read-only mmap region also could overflow size_t.
So fixing it by casting the size of read-only mmap region into a __u64 and checking whether or not there will be overflow during mmap.
--- tools/lib/bpf/ringbuf.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
tools/lib/bpf/ringbuf.c +8 -4
@@ -59,6 +59,7 @@ int ring_buffer__add(struct ring_buffer *rb, int map_fd,__u32 len =sizeof (info);struct epoll_event *e;struct ring *r; +__u64 mmap_sz;void *tmp;int err;
@@ -97,8 +98,7 @@ int ring_buffer__add(struct ring_buffer *rb, int map_fd, r->mask = info.max_entries -1 ;/* Map writable consumer page */ - tmp =mmap (NULL , rb->page_size,PROT_READ |PROT_WRITE ,MAP_SHARED , - map_fd,0 ); + tmp =mmap (NULL , rb->page_size,PROT_READ |PROT_WRITE ,MAP_SHARED , map_fd,0 );if (tmp ==MAP_FAILED ) { err = -errno; pr_warn("ringbuf: failed to mmap consumer page for map fd=%d: %d\n",
@@ -111,8 +111,12 @@ int ring_buffer__add(struct ring_buffer *rb, int map_fd,* data size to allow simple reading of samples that wrap around the * end of a ring buffer. See kernel implementation for details. * */ - tmp =mmap (NULL , rb->page_size +2 * info.max_entries,PROT_READ , -MAP_SHARED , map_fd, rb->page_size); + mmap_sz = rb->page_size +2 * (__u64 )info.max_entries; +if (mmap_sz != (__u64 )(size_t )mmap_sz) { +pr_warn ("ringbuf: ring buffer size (%u) is too big\n" , info.max_entries); +return -E2BIG ; + } + tmp =mmap (NULL , (size_t )mmap_sz,PROT_READ ,MAP_SHARED , map_fd, rb->page_size);if (tmp ==MAP_FAILED ) { err = -errno;ringbuf_unmap_ring (rb, r);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 17/92 hwmon: (ltc2947) fix temperature scaling
In reply to Greg Kroah-HartmanFrom: Derek Nguyen <[email protected]>
[ Upstream commit 07e06193ead86d4812f431b4d87bbd4161222e3f ]
The LTC2947 datasheet (Rev. B) calls out in the section "Register
Description: Non-Accumulated Result Registers" (pg. 30) that "To calculate temperature, multiply the TEMP register value by 0.204°C and add 5.5°C". Fix to add 5.5C and not 0.55C.
--- drivers/hwmon/ltc2947-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/ltc2947-core.c +1 -1
@@ -396,7 +396,7 @@ static int ltc2947_read_temp(struct device *dev, const u32 attr, long *val,return ret;/* in milidegrees celcius, temp is given by: */ - *val = (__val *204 ) +550 ; + *val = (__val *204 ) +5500 ;return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 18/92 hwmon: (ina3221) Fix shunt sum critical calculation
In reply to Greg Kroah-HartmanFrom: Ninad Malwade <[email protected]>
[ Upstream commit b8d27d2ce8dfc207e4b67b929a86f2be76fbc6ef ]
The shunt sum critical limit register value should be left shifted by one bit as its LSB-0 is a reserved bit.
--- drivers/hwmon/ina3221.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hwmon/ina3221.c +2 -2
@@ -230,7 +230,7 @@ static int ina3221_read_value(struct ina3221_data *ina, unsigned int reg,* Shunt Voltage Sum register has 14-bit value with 1-bit shift * Other Shunt Voltage registers have 12 bits with 3-bit shift */ -if (reg ==INA3221_SHUNT_SUM ) +if (reg ==INA3221_SHUNT_SUM || reg ==INA3221_CRIT_SUM ) *val =sign_extend32 (regval >>1 ,14 );else *val =sign_extend32 (regval >>3 ,12 );
@@ -465,7 +465,7 @@ static int ina3221_write_curr(struct device *dev, u32 attr,* SHUNT_SUM: (1 / 40uV) << 1 = 1 / 20uV * SHUNT[1-3]: (1 / 40uV) << 3 = 1 / 5uV */ -if (reg ==INA3221_SHUNT_SUM ) +if (reg ==INA3221_SHUNT_SUM || reg ==INA3221_CRIT_SUM ) regval =DIV_ROUND_CLOSEST (voltage_uv,20 ) &0xfffe ;else regval =DIV_ROUND_CLOSEST (voltage_uv,5 ) &0xfff8 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 19/92 hwmon: (i5500_temp) fix missing pci_disable_device()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 3b7f98f237528c496ea0b689bace0e35eec3e060 ]
pci_disable_device() need be called while module exiting, switch to use pcim_enable(), pci_disable_device() will be called in pcim_release().
--- drivers/hwmon/i5500_temp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/i5500_temp.c +1 -1
@@ -108,7 +108,7 @@ static int i5500_temp_probe(struct pci_dev *pdev,u32 tstimer;s8 tsfsc; - err =pci_enable_device (pdev); + err =pcim_enable_device (pdev);if (err) {dev_err (&pdev->dev,"Failed to enable device\n" );return err;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 20/92 hwmon: (ibmpex) Fix possible UAF when ibmpex_register_bmc() fails
In reply to Greg Kroah-HartmanFrom: Gaosheng Cui <[email protected]>
[ Upstream commit e2a87785aab0dac190ac89be6a9ba955e2c634f2 ]
Smatch report warning as follows:
drivers/hwmon/ibmpex.c:509 ibmpex_register_bmc() warn:
'&data->list' not removed from list
If ibmpex_find_sensors() fails in ibmpex_register_bmc(), data will be freed, but data->list will not be removed from driver_data.bmc_data, then list traversal may cause UAF.
Fix by removeing it from driver_data.bmc_data before free().
--- drivers/hwmon/ibmpex.c | 1 + 1 file changed, 1 insertion(+)
drivers/hwmon/ibmpex.c +1 -0
@@ -502,6 +502,7 @@ static void ibmpex_register_bmc(int iface, struct device *dev)return ; out_register: +list_del (&data->list);hwmon_device_unregister (data->hwmon_dev); out_user:ipmi_destroy_user (data->user);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 21/92 bpf: Do not copy spin lock field from user in bpf_selem_alloc
In reply to Greg Kroah-HartmanFrom: Xu Kuohai <[email protected]>
[ Upstream commit 836e49e103dfeeff670c934b7d563cbd982fce87 ]
bpf_selem_alloc function is used by inode_storage, sk_storage and task_storage maps to set map value, for these map types, there may be a spin lock in the map value, so if we use memcpy to copy the whole map value from user, the spin lock field may be initialized incorrectly.
Since the spin lock field is zeroed by kzalloc, call copy_map_value instead of memcpy to skip copying the spin lock field to fix it.
--- kernel/bpf/bpf_local_storage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/bpf_local_storage.c +1 -1
@@ -70,7 +70,7 @@ bpf_selem_alloc(struct bpf_local_storage_map *smap, void *owner, selem =kzalloc (smap->elem_size,GFP_ATOMIC | __GFP_NOWARN);if (selem) {if (value) -memcpy (SDATA (selem)->data, value, smap->map.value_size); +copy_map_value (&smap->map,SDATA (selem)->data, value);return selem; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 22/92 of: property: decrement node refcount in of_fwnode_get_reference_args()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 60d865bd5a9b15a3961eb1c08bd4155682a3c81e ]
In of_fwnode_get_reference_args(), the refcount of of_args.np has been incremented in the case of successful return from of_parse_phandle_with_args() or of_parse_phandle_with_fixed_args().
Decrement the refcount if of_args is not returned to the caller of of_fwnode_get_reference_args().
--- drivers/of/property.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/of/property.c +3 -1
@@ -956,8 +956,10 @@ of_fwnode_get_reference_args(const struct fwnode_handle *fwnode, nargs, index, &of_args);if (ret <0 )return ret; -if (!args) +if (!args) { +of_node_put (of_args.np);return 0 ; + } args->nargs = of_args.args_count; args->fwnode =of_fwnode_handle (of_args.np);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 23/92 ixgbevf: Fix resource leak in ixgbevf_init_module()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit 8cfa238a48f34038464b99d0b4825238c2687181 ]
ixgbevf_init_module() won't destroy the workqueue created by create_singlethread_workqueue() when pci_register_driver() failed. Add destroy_workqueue() in fail path to prevent the resource leak.
Similar to the handling of u132_hcd_init in commit f276e002793c ("usb: u132-hcd: fix resource leak")
--- drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +9 -1
@@ -4878,6 +4878,8 @@ static struct pci_driver ixgbevf_driver = {**/ static int __init ixgbevf_init_module (void ) { +int err; +pr_info ("%s\n" , ixgbevf_driver_string);pr_info ("%s\n" , ixgbevf_copyright); ixgbevf_wq =create_singlethread_workqueue (ixgbevf_driver_name);
@@ -4886,7 +4888,13 @@ static int __init ixgbevf_init_module(void)return -ENOMEM ; } -return pci_register_driver (&ixgbevf_driver); + err =pci_register_driver (&ixgbevf_driver); +if (err) { +destroy_workqueue (ixgbevf_wq); +return err; + } + +return 0 ; }module_init (ixgbevf_init_module);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 24/92 i40e: Fix error handling in i40e_init_module()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit 479dd06149425b9e00477f52200872587af76a48 ]
i40e_init_module() won't free the debugfs directory created by i40e_dbg_init() when pci_register_driver() failed. Add fail path to call i40e_dbg_exit() to remove the debugfs entries to prevent the bug.
i40e: Intel(R) Ethernet Connection XL710 Network Driver
i40e: Copyright (c) 2013 - 2019 Intel Corporation.
debugfs: Directory 'i40e' with parent '/' already present!
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +10 -1
@@ -15972,6 +15972,8 @@ static struct pci_driver i40e_driver = {**/ static int __init i40e_init_module (void ) { +int err; +pr_info ("%s: %s\n" , i40e_driver_name, i40e_driver_string);pr_info ("%s: %s\n" , i40e_driver_name, i40e_copyright);
@@ -15989,7 +15991,14 @@ static int __init i40e_init_module(void) }i40e_dbg_init (); -return pci_register_driver (&i40e_driver); + err =pci_register_driver (&i40e_driver); +if (err) { +destroy_workqueue (i40e_wq); +i40e_dbg_exit (); +return err; + } + +return 0 ; }module_init (i40e_init_module);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 25/92 fm10k: Fix error handling in fm10k_init_module()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit 771a794c0a3c3e7f0d86cc34be4f9537e8c0a20c ]
A problem about modprobe fm10k failed is triggered with the following log given:
Intel(R) Ethernet Switch Host Interface Driver Copyright(c) 2013 - 2019 Intel Corporation.
debugfs: Directory 'fm10k' with parent '/' already present!
The reason is that fm10k_init_module() returns fm10k_register_pci_driver() directly without checking its return value, if fm10k_register_pci_driver() failed, it returns without removing debugfs and destroy workqueue, resulting the debugfs of fm10k can never be created later and leaks the workqueue.
fm10k_init_module()
alloc_workqueue()
fm10k_dbg_init() # create debugfs
fm10k_register_pci_driver()
pci_register_driver()
driver_register()
bus_add_driver()
priv = kzalloc(...) # OOM happened
# return without remove debugfs and destroy workqueue
Fix by remove debugfs and destroy workqueue whenfm10k_register_pci_driver() returns error.
--- drivers/net/ethernet/intel/fm10k/fm10k_main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/fm10k/fm10k_main.c +9 -1
@@ -32,6 +32,8 @@ struct workqueue_struct *fm10k_workqueue;**/ static int __init fm10k_init_module (void ) { +int ret; +pr_info ("%s\n" , fm10k_driver_string);pr_info ("%s\n" , fm10k_copyright);
@@ -43,7 +45,13 @@ static int __init fm10k_init_module(void)fm10k_dbg_init (); -return fm10k_register_pci_driver (); + ret =fm10k_register_pci_driver (); +if (ret) { +fm10k_dbg_exit (); +destroy_workqueue (fm10k_workqueue); + } + +return ret; }module_init (fm10k_init_module);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 26/92 iavf: remove redundant ret variable
In reply to Greg Kroah-HartmanFrom: Minghao Chi <[email protected]>
[ Upstream commit c3fec56e12678c3ad68084048a73818a7968d6b8 ]
Return value directly instead of taking this in another redundant variable.
Stable-dep-of: 227d8d2f7f22 ("iavf: Fix error handling in iavf_init_module()")
--- drivers/net/ethernet/intel/iavf/iavf_main.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +2 -7
@@ -1318,7 +1318,6 @@ static void iavf_fill_rss_lut(struct iavf_adapter *adapter)static int iavf_init_rss (struct iavf_adapter *adapter) {struct iavf_hw *hw = &adapter->hw; -int ret;if (!RSS_PF (adapter)) {/* Enable PCTYPES for RSS, TCP/UDP with IPv4/IPv6 */
@@ -1334,9 +1333,8 @@ static int iavf_init_rss(struct iavf_adapter *adapter)iavf_fill_rss_lut (adapter);netdev_rss_key_fill ((void *)adapter->rss_key, adapter->rss_key_size); - ret =iavf_config_rss (adapter); -return ret; +return iavf_config_rss (adapter); }/**
@@ -4028,8 +4026,6 @@ static struct pci_driver iavf_driver = {**/ static int __init iavf_init_module (void ) { -int ret; -pr_info ("iavf: %s\n" , iavf_driver_string);pr_info ("%s\n" , iavf_copyright);
@@ -4040,8 +4036,7 @@ static int __init iavf_init_module(void)pr_err ("%s: Failed to create workqueue\n" , iavf_driver_name);return -ENOMEM ; } - ret =pci_register_driver (&iavf_driver); -return ret; +return pci_register_driver (&iavf_driver); }module_init (iavf_init_module);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 27/92 iavf: Fix error handling in iavf_init_module()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit 227d8d2f7f2278b8468c5531b0cd0f2a905b4486 ]
The iavf_init_module() won't destroy workqueue when pci_register_driver() failed. Call destroy_workqueue() when pci_register_driver() failed to prevent the resource leak.
Similar to the handling of u132_hcd_init in commit f276e002793c ("usb: u132-hcd: fix resource leak")
--- drivers/net/ethernet/intel/iavf/iavf_main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +8 -1
@@ -4026,6 +4026,8 @@ static struct pci_driver iavf_driver = {**/ static int __init iavf_init_module (void ) { +int ret; +pr_info ("iavf: %s\n" , iavf_driver_string);pr_info ("%s\n" , iavf_copyright);
@@ -4036,7 +4038,12 @@ static int __init iavf_init_module(void)pr_err ("%s: Failed to create workqueue\n" , iavf_driver_name);return -ENOMEM ; } -return pci_register_driver (&iavf_driver); + + ret =pci_register_driver (&iavf_driver); +if (ret) +destroy_workqueue (iavf_wq); + +return ret; }module_init (iavf_init_module);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 28/92 e100: switch from pci_ to dma_ API
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 4140ff1ba06d3fc16afd518736940ab742886317 ]
The wrappers in include/linux/pci-dma-compat.h should go away.
The patch has been generated with the coccinelle script below and has been hand modified to replace GFP_ with a correct flag.
It has been compile tested.
When memory is allocated in 'e100_alloc()', GFP_KERNEL can be used because it is only called from the probe function and no lock is acquired.
@@
@@
- PCI_DMA_BIDIRECTIONAL
+ DMA_BIDIRECTIONAL
@@
@@
- PCI_DMA_TODEVICE
+ DMA_TO_DEVICE
@@
@@
- PCI_DMA_FROMDEVICE
+ DMA_FROM_DEVICE
@@
@@
- PCI_DMA_NONE
+ DMA_NONE
@@
expression e1, e2, e3;
@@
- pci_alloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3;
@@
- pci_zalloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3, e4;
@@
- pci_free_consistent(e1, e2, e3, e4)
+ dma_free_coherent(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_single(e1, e2, e3, e4)
+ dma_map_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_single(e1, e2, e3, e4)
+ dma_unmap_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4, e5;
@@
- pci_map_page(e1, e2, e3, e4, e5)
+ dma_map_page(&e1->dev, e2, e3, e4, e5)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_page(e1, e2, e3, e4)
+ dma_unmap_page(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_sg(e1, e2, e3, e4)
+ dma_map_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_sg(e1, e2, e3, e4)
+ dma_unmap_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+ dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_device(e1, e2, e3, e4)
+ dma_sync_single_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+ dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+ dma_sync_sg_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2;
@@
- pci_dma_mapping_error(e1, e2)
+ dma_mapping_error(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_dma_mask(e1, e2)
+ dma_set_mask(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_consistent_dma_mask(e1, e2)
+ dma_set_coherent_mask(&e1->dev, e2)
Stable-dep-of: 45605c75c52c ("e100: Fix possible use after free in e100_xmit_prepare")
--- drivers/net/ethernet/intel/e100.c | 92 ++++++++++++++++--------------- 1 file changed, 49 insertions(+), 43 deletions(-)
drivers/net/ethernet/intel/e100.c +49 -43
@@ -1739,10 +1739,10 @@ static int e100_xmit_prepare(struct nic *nic, struct cb *cb,dma_addr_t dma_addr; cb->command = nic->tx_command; - dma_addr =pci_map_single (nic->pdev, - skb->data, skb->len,PCI_DMA_TODEVICE ); + dma_addr =dma_map_single (&nic->pdev->dev, skb->data, skb->len, +DMA_TO_DEVICE );/* If we can't map the skb, have the upper layer try later */ -if (pci_dma_mapping_error (nic->pdev, dma_addr)) { +if (dma_mapping_error (&nic->pdev->dev, dma_addr)) {dev_kfree_skb_any (skb); skb =NULL ;return -ENOMEM ;
@@ -1828,10 +1828,10 @@ static int e100_tx_clean(struct nic *nic) dev->stats.tx_packets++; dev->stats.tx_bytes += cb->skb->len; -pci_unmap_single (nic->pdev, -le32_to_cpu (cb->u.tcb.tbd.buf_addr), -le16_to_cpu (cb->u.tcb.tbd.size), -PCI_DMA_TODEVICE ); +dma_unmap_single (&nic->pdev->dev, +le32_to_cpu (cb->u.tcb.tbd.buf_addr), +le16_to_cpu (cb->u.tcb.tbd.size), +DMA_TO_DEVICE );dev_kfree_skb_any (cb->skb); cb->skb =NULL ; tx_cleaned =1 ;
@@ -1855,10 +1855,10 @@ static void e100_clean_cbs(struct nic *nic)while (nic->cbs_avail != nic->params.cbs.count) {struct cb *cb = nic->cb_to_clean;if (cb->skb) { -pci_unmap_single (nic->pdev, -le32_to_cpu (cb->u.tcb.tbd.buf_addr), -le16_to_cpu (cb->u.tcb.tbd.size), -PCI_DMA_TODEVICE ); +dma_unmap_single (&nic->pdev->dev, +le32_to_cpu (cb->u.tcb.tbd.buf_addr), +le16_to_cpu (cb->u.tcb.tbd.size), +DMA_TO_DEVICE );dev_kfree_skb (cb->skb); } nic->cb_to_clean = nic->cb_to_clean->next;
@@ -1925,10 +1925,10 @@ static int e100_rx_alloc_skb(struct nic *nic, struct rx *rx)/* Init, and map the RFD. */ skb_copy_to_linear_data (rx->skb, &nic->blank_rfd,sizeof (struct rfd )); - rx->dma_addr =pci_map_single (nic->pdev, rx->skb->data, -RFD_BUF_LEN ,PCI_DMA_BIDIRECTIONAL ); + rx->dma_addr =dma_map_single (&nic->pdev->dev, rx->skb->data, +RFD_BUF_LEN ,DMA_BIDIRECTIONAL ); -if (pci_dma_mapping_error (nic->pdev, rx->dma_addr)) { +if (dma_mapping_error (&nic->pdev->dev, rx->dma_addr)) {dev_kfree_skb_any (rx->skb); rx->skb =NULL ; rx->dma_addr =0 ;
@@ -1941,8 +1941,10 @@ static int e100_rx_alloc_skb(struct nic *nic, struct rx *rx)if (rx->prev->skb) {struct rfd *prev_rfd = (struct rfd *)rx->prev->skb->data;put_unaligned_le32 (rx->dma_addr, &prev_rfd->link); -pci_dma_sync_single_for_device (nic->pdev, rx->prev->dma_addr, -sizeof (struct rfd ),PCI_DMA_BIDIRECTIONAL ); +dma_sync_single_for_device (&nic->pdev->dev, + rx->prev->dma_addr, +sizeof (struct rfd ), +DMA_BIDIRECTIONAL ); }return 0 ;
@@ -1961,8 +1963,8 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,return -EAGAIN ;/* Need to sync before taking a peek at cb_complete bit */ -pci_dma_sync_single_for_cpu (nic->pdev, rx->dma_addr, -sizeof (struct rfd ),PCI_DMA_BIDIRECTIONAL ); +dma_sync_single_for_cpu (&nic->pdev->dev, rx->dma_addr, +sizeof (struct rfd ),DMA_BIDIRECTIONAL ); rfd_status =le16_to_cpu (rfd->status); netif_printk(nic, rx_status, KERN_DEBUG, nic->netdev,
@@ -1981,9 +1983,9 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,if (ioread8 (&nic->csr->scb.status) & rus_no_res) nic->ru_running =RU_SUSPENDED ; -pci_dma_sync_single_for_device (nic->pdev, rx->dma_addr, -sizeof (struct rfd ), -PCI_DMA_FROMDEVICE ); +dma_sync_single_for_device (&nic->pdev->dev, rx->dma_addr, +sizeof (struct rfd ), +DMA_FROM_DEVICE );return -ENODATA ; }
@@ -1995,8 +1997,8 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx, actual_size =RFD_BUF_LEN -sizeof (struct rfd );/* Get data */ -pci_unmap_single (nic->pdev, rx->dma_addr, -RFD_BUF_LEN ,PCI_DMA_BIDIRECTIONAL ); +dma_unmap_single (&nic->pdev->dev, rx->dma_addr,RFD_BUF_LEN , +DMA_BIDIRECTIONAL );/* If this buffer has the el bit, but we think the receiver * is still running, check to see if it really stopped while
@@ -2097,22 +2099,25 @@ static void e100_rx_clean(struct nic *nic, unsigned int *work_done, (struct rfd *)new_before_last_rx->skb->data; new_before_last_rfd->size =0 ; new_before_last_rfd->command |=cpu_to_le16 (cb_el); -pci_dma_sync_single_for_device (nic->pdev, - new_before_last_rx->dma_addr,sizeof (struct rfd ), -PCI_DMA_BIDIRECTIONAL ); +dma_sync_single_for_device (&nic->pdev->dev, + new_before_last_rx->dma_addr, +sizeof (struct rfd ), +DMA_BIDIRECTIONAL );/* Now that we have a new stopping point, we can clear the old * stopping point. We must sync twice to get the proper * ordering on the hardware side of things. */ old_before_last_rfd->command &= ~cpu_to_le16 (cb_el); -pci_dma_sync_single_for_device (nic->pdev, - old_before_last_rx->dma_addr,sizeof (struct rfd ), -PCI_DMA_BIDIRECTIONAL ); +dma_sync_single_for_device (&nic->pdev->dev, + old_before_last_rx->dma_addr, +sizeof (struct rfd ), +DMA_BIDIRECTIONAL ); old_before_last_rfd->size =cpu_to_le16 (VLAN_ETH_FRAME_LEN +ETH_FCS_LEN ); -pci_dma_sync_single_for_device (nic->pdev, - old_before_last_rx->dma_addr,sizeof (struct rfd ), -PCI_DMA_BIDIRECTIONAL ); +dma_sync_single_for_device (&nic->pdev->dev, + old_before_last_rx->dma_addr, +sizeof (struct rfd ), +DMA_BIDIRECTIONAL ); }if (restart_required) {
@@ -2134,8 +2139,9 @@ static void e100_rx_clean_list(struct nic *nic)if (nic->rxs) {for (rx = nic->rxs, i =0 ; i < count; rx++, i++) {if (rx->skb) { -pci_unmap_single (nic->pdev, rx->dma_addr, -RFD_BUF_LEN ,PCI_DMA_BIDIRECTIONAL ); +dma_unmap_single (&nic->pdev->dev, + rx->dma_addr,RFD_BUF_LEN , +DMA_BIDIRECTIONAL );dev_kfree_skb (rx->skb); } }
@@ -2177,8 +2183,8 @@ static int e100_rx_alloc_list(struct nic *nic) before_last = (struct rfd *)rx->skb->data; before_last->command |=cpu_to_le16 (cb_el); before_last->size =0 ; -pci_dma_sync_single_for_device (nic->pdev, rx->dma_addr, -sizeof (struct rfd ),PCI_DMA_BIDIRECTIONAL ); +dma_sync_single_for_device (&nic->pdev->dev, rx->dma_addr, +sizeof (struct rfd ),DMA_BIDIRECTIONAL ); nic->rx_to_use = nic->rx_to_clean = nic->rxs; nic->ru_running =RU_SUSPENDED ;
@@ -2377,8 +2383,8 @@ static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode)msleep (10 ); -pci_dma_sync_single_for_cpu (nic->pdev, nic->rx_to_clean->dma_addr, -RFD_BUF_LEN ,PCI_DMA_BIDIRECTIONAL ); +dma_sync_single_for_cpu (&nic->pdev->dev, nic->rx_to_clean->dma_addr, +RFD_BUF_LEN ,DMA_BIDIRECTIONAL );if (memcmp (nic->rx_to_clean->skb->data +sizeof (struct rfd ), skb->data,ETH_DATA_LEN ))
@@ -2759,16 +2765,16 @@ static int e100_do_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)static int e100_alloc (struct nic *nic) { - nic->mem =pci_alloc_consistent (nic->pdev,sizeof (struct mem ), - &nic->dma_addr); + nic->mem =dma_alloc_coherent (&nic->pdev->dev,sizeof (struct mem ), + &nic->dma_addr,GFP_KERNEL );return nic->mem ?0 : -ENOMEM ; }static void e100_free (struct nic *nic) {if (nic->mem) { -pci_free_consistent (nic->pdev,sizeof (struct mem ), - nic->mem, nic->dma_addr); +dma_free_coherent (&nic->pdev->dev,sizeof (struct mem ), + nic->mem, nic->dma_addr); nic->mem =NULL ; } }
@@ -2861,7 +2867,7 @@ static int e100_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_out_disable_pdev; } -if ((err =pci_set_dma_mask (pdev,DMA_BIT_MASK (32 )))) { +if ((err =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )))) {netif_err (nic, probe, nic->netdev,"No usable DMA configuration, aborting\n" ); goto err_out_free_res; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 29/92 e100: Fix possible use after free in e100_xmit_prepare
In reply to Greg Kroah-HartmanFrom: Wang Hai <[email protected]>
[ Upstream commit 45605c75c52c7ae7bfe902214343aabcfe5ba0ff ]
In e100_xmit_prepare(), if we can't map the skb, then return -ENOMEM, so e100_xmit_frame() will return NETDEV_TX_BUSY and the upper layer will resend the skb. But the skb is already freed, which will cause UAF bug when the upper layer resends the skb.
Remove the harmful free.
--- drivers/net/ethernet/intel/e100.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/ethernet/intel/e100.c +1 -4
@@ -1742,11 +1742,8 @@ static int e100_xmit_prepare(struct nic *nic, struct cb *cb, dma_addr =dma_map_single (&nic->pdev->dev, skb->data, skb->len,DMA_TO_DEVICE );/* If we can't map the skb, have the upper layer try later */ -if (dma_mapping_error (&nic->pdev->dev, dma_addr)) { -dev_kfree_skb_any (skb); - skb =NULL ; +if (dma_mapping_error (&nic->pdev->dev, dma_addr))return -ENOMEM ; - }/* * Use the last 4 bytes of the SKB payload packet as the CRC, used for
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 30/92 net/mlx5: Fix uninitialized variable bug in outlen_write()
In reply to Greg Kroah-HartmanFrom: YueHaibing <[email protected]>
[ Upstream commit 3f5769a074c13d8f08455e40586600419e02a880 ]
If sscanf() return 0, outlen is uninitialized and used in kzalloc(), this is unexpected. We should return -EINVAL if the string is invalid.
--- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +2 -2
@@ -1422,8 +1422,8 @@ static ssize_t outlen_write(struct file *filp, const char __user *buf,return -EFAULT ; err =sscanf (outlen_str,"%d" , &outlen); -if (err <0 ) -return err; +if (err !=1 ) +return -EINVAL ; ptr =kzalloc (outlen,GFP_KERNEL );if (!ptr)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 31/92 net/mlx5e: Fix use-after-free when reverting termination table
In reply to Greg Kroah-HartmanFrom: Roi Dayan <[email protected]>
[ Upstream commit 52c795af04441d76f565c4634f893e5b553df2ae ]
When having multiple dests with termination tables and second one or afterwards fails the driver reverts usage of term tables but doesn't reset the assignment in attr->dests[num_vport_dests].termtbl which case a use-after-free when releasing the rule.
Fix by resetting the assignment of termtbl to null.
--- .../net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads_termtbl.c +2 -0
@@ -308,6 +308,8 @@ mlx5_eswitch_add_termtbl_rule(struct mlx5_eswitch *esw,for (curr_dest =0 ; curr_dest < num_vport_dests; curr_dest++) {struct mlx5_termtbl_handle *tt = attr->dests[curr_dest].termtbl; + attr->dests[curr_dest].termtbl =NULL ; +/* search for the destination associated with the * current term table */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 32/92 can: sja1000_isa: sja1000_isa_probe(): add missing free_sja1000dev()
In reply to Greg Kroah-HartmanFrom: Zhang Changzhong <[email protected]>
[ Upstream commit 92dfd9310a71d28cefe6a2d5174d43fab240e631 ]
Add the missing free_sja1000dev() before return from sja1000_isa_probe() in the register_sja1000dev() error handling case.
In addition, remove blanks before goto labels.
--- drivers/net/can/sja1000/sja1000_isa.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/can/sja1000/sja1000_isa.c +6 -4
@@ -202,22 +202,24 @@ static int sja1000_isa_probe(struct platform_device *pdev)if (err) {dev_err (&pdev->dev,"registering %s failed (err=%d)\n" ,DRV_NAME , err); - goto exit_unmap; + goto exit_free; }dev_info (&pdev->dev,"%s device registered (reg_base=0x%p, irq=%d)\n" ,DRV_NAME , priv->reg_base, dev->irq);return 0 ; - exit_unmap: +exit_free: +free_sja1000dev (dev); +exit_unmap:if (mem[idx])iounmap (base); - exit_release: +exit_release:if (mem[idx])release_mem_region (mem[idx], iosize);else release_region (port[idx], iosize); - exit: +exit:return err; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 33/92 can: cc770: cc770_isa_probe(): add missing free_cc770dev()
In reply to Greg Kroah-HartmanFrom: Zhang Changzhong <[email protected]>
[ Upstream commit 62ec89e74099a3d6995988ed9f2f996b368417ec ]
Add the missing free_cc770dev() before return from cc770_isa_probe() in the register_cc770dev() error handling case.
In addition, remove blanks before goto labels.
--- drivers/net/can/cc770/cc770_isa.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/can/cc770/cc770_isa.c +6 -4
@@ -264,22 +264,24 @@ static int cc770_isa_probe(struct platform_device *pdev)if (err) {dev_err (&pdev->dev,"couldn't register device (err=%d)\n" , err); - goto exit_unmap; + goto exit_free; }dev_info (&pdev->dev,"device registered (reg_base=0x%p, irq=%d)\n" , priv->reg_base, dev->irq);return 0 ; - exit_unmap: +exit_free: +free_cc770dev (dev); +exit_unmap:if (mem[idx])iounmap (base); - exit_release: +exit_release:if (mem[idx])release_mem_region (mem[idx], iosize);else release_region (port[idx], iosize); - exit: +exit:return err; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 34/92 qlcnic: fix sleep-in-atomic-context bugs caused by msleep
In reply to Greg Kroah-HartmanFrom: Duoming Zhou <[email protected]>
[ Upstream commit 8dbd6e4ce1b9c527921643d9e34f188a10d4e893 ]
The watchdog timer is used to monitor whether the process of transmitting data is timeout. If we use qlcnic driver, the dev_watchdog() that is the timer handler of watchdog timer will call qlcnic_tx_timeout() to process the timeout. But the qlcnic_tx_timeout() calls msleep(), as a result, the sleep-in-atomic-context bugs will happen. The processes are shown below:
(atomic context)dev_watchdog
qlcnic_tx_timeout
qlcnic_83xx_idc_request_reset
qlcnic_83xx_lock_driver
msleep
---------------------------
(atomic context)dev_watchdog
qlcnic_tx_timeout
qlcnic_83xx_idc_request_reset
qlcnic_83xx_lock_driver
qlcnic_83xx_recover_driver_lock
msleep
Fix by changing msleep() to mdelay(), the mdelay() is busy-waiting and the bugs could be mitigated.
--- drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c +2 -2
@@ -2991,7 +2991,7 @@ static void qlcnic_83xx_recover_driver_lock(struct qlcnic_adapter *adapter)QLCWRX (adapter->ahw,QLC_83XX_RECOVER_DRV_LOCK , val);dev_info (&adapter->pdev->dev,"%s: lock recovery initiated\n" , __func__); -msleep (QLC_83XX_DRV_LOCK_RECOVERY_DELAY ); +mdelay (QLC_83XX_DRV_LOCK_RECOVERY_DELAY ); val =QLCRDX (adapter->ahw,QLC_83XX_RECOVER_DRV_LOCK ); id = ((val >>2 ) &0xF );if (id == adapter->portnum) {
@@ -3027,7 +3027,7 @@ int qlcnic_83xx_lock_driver(struct qlcnic_adapter *adapter)if (status)break ; -msleep (QLC_83XX_DRV_LOCK_WAIT_DELAY ); +mdelay (QLC_83XX_DRV_LOCK_WAIT_DELAY ); i++;if (i ==1 )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 35/92 aquantia: Do not purge addresses when setting the number of rings
In reply to Greg Kroah-HartmanFrom: Izabela Bakollari <[email protected]>
[ Upstream commit 2a83891130512dafb321418a8e7c9c09268d8c59 ]
IPV6 addresses are purged when setting the number of rx/tx rings using ethtool -G. The function aq_set_ringparam calls dev_close, which removes the addresses. As a solution, call an internal function (aq_ndev_close).
--- drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c | 5 +++-- drivers/net/ethernet/aquantia/atlantic/aq_main.c | 4 ++-- drivers/net/ethernet/aquantia/atlantic/aq_main.h | 2 ++ 3 files changed, 7 insertions(+), 4 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c +3 -2
@@ -13,6 +13,7 @@#include "aq_ptp.h" #include "aq_filters.h" #include "aq_macsec.h" +#include "aq_main.h" #include <linux/ptp_clock_kernel.h>
@@ -841,7 +842,7 @@ static int aq_set_ringparam(struct net_device *ndev,if (netif_running (ndev)) { ndev_running = true; -dev_close (ndev); +aq_ndev_close (ndev); } cfg->rxds =max (ring->rx_pending, hw_caps->rxds_min);
@@ -857,7 +858,7 @@ static int aq_set_ringparam(struct net_device *ndev, goto err_exit;if (ndev_running) - err =dev_open (ndev,NULL ); + err =aq_ndev_open (ndev); err_exit:return err;
drivers/net/ethernet/aquantia/atlantic/aq_main.c +2 -2
@@ -53,7 +53,7 @@ struct net_device *aq_ndev_alloc(void)return ndev; } -static int aq_ndev_open (struct net_device *ndev) +int aq_ndev_open (struct net_device *ndev) {struct aq_nic_s *aq_nic =netdev_priv (ndev);int err =0 ;
@@ -83,7 +83,7 @@ static int aq_ndev_open(struct net_device *ndev)return err; } -static int aq_ndev_close (struct net_device *ndev) +int aq_ndev_close (struct net_device *ndev) {struct aq_nic_s *aq_nic =netdev_priv (ndev);int err =0 ;
drivers/net/ethernet/aquantia/atlantic/aq_main.h +2 -0
@@ -14,5 +14,7 @@void aq_ndev_schedule_work (struct work_struct *work);struct net_device *aq_ndev_alloc (void ); +int aq_ndev_open (struct net_device *ndev); +int aq_ndev_close (struct net_device *ndev);#endif /* AQ_MAIN_H */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 36/92 wifi: cfg80211: fix buffer overflow in elem comparison
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 9f16b5c82a025cd4c864737409234ddc44fb166a ]
For vendor elements, the code here assumes that 5 octets are present without checking. Since the element itself is already checked to fit, we only need to check the length.
--- net/wireless/scan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/wireless/scan.c +2 -1
@@ -330,7 +330,8 @@ static size_t cfg80211_gen_new_ie(const u8 *ie, size_t ielen,* determine if they are the same ie. */ if (tmp_old[0 ] ==WLAN_EID_VENDOR_SPECIFIC ) { -if (!memcmp (tmp_old +2 , tmp +2 ,5 )) { +if (tmp_old[1 ] >=5 && tmp[1 ] >=5 && + !memcmp (tmp_old +2 , tmp +2 ,5 )) {/* same vendor ie, copy from * subelement */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 37/92 wifi: cfg80211: dont allow multi-BSSID in S1G
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit acd3c92acc7aaec50a94d0a7faf7ccd74e952493 ]
In S1G beacon frames there shouldn't be multi-BSSID elements since that's not supported, remove that to avoid a potential integer underflow and/or misparsing the frames due to the different length of the fixed part of the frame.
While at it, initialize non_tx_data so we don't send garbage values to the user (even if it doesn't seem to matter now.)
--- net/wireless/scan.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/wireless/scan.c +6 -1
@@ -2467,10 +2467,15 @@ cfg80211_inform_bss_frame_data(struct wiphy *wiphy,const struct cfg80211_bss_ies *ies1, *ies2;size_t ielen = len - offsetof(struct ieee80211_mgmt , u.probe_resp.variable); -struct cfg80211_non_tx_bss non_tx_data; +struct cfg80211_non_tx_bss non_tx_data = {}; res =cfg80211_inform_single_bss_frame_data (wiphy, data, mgmt, len, gfp); + +/* don't do any further MBSSID handling for S1G */ +if (ieee80211_is_s1g_beacon (mgmt->frame_control)) +return res; +if (!res || !wiphy->support_mbssid || !cfg80211_find_ie (WLAN_EID_MULTIPLE_BSSID , ie, ielen))return res;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 38/92 wifi: mac8021: fix possible oob access in ieee80211_get_rate_duration
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit 3e8f7abcc3473bc9603323803aeaed4ffcc3a2ab ]
Fix possible out-of-bound access in ieee80211_get_rate_duration routine as reported by the following UBSAN report:
UBSAN: array-index-out-of-bounds in net/mac80211/airtime.c:455:47 index 15 is out of range for type 'u16 [12]' CPU: 2 PID: 217 Comm: kworker/u32:10 Not tainted 6.1.0-060100rc3-generic Hardware name: Acer Aspire TC-281/Aspire TC-281, BIOS R01-A2 07/18/2017 Workqueue: mt76 mt76u_tx_status_data [mt76_usb] Call Trace: <TASK> show_stack+0x4e/0x61 dump_stack_lvl+0x4a/0x6f dump_stack+0x10/0x18 ubsan_epilogue+0x9/0x43 __ubsan_handle_out_of_bounds.cold+0x42/0x47 ieee80211_get_rate_duration.constprop.0+0x22f/0x2a0 [mac80211] ? ieee80211_tx_status_ext+0x32e/0x640 [mac80211] ieee80211_calc_rx_airtime+0xda/0x120 [mac80211] ieee80211_calc_tx_airtime+0xb4/0x100 [mac80211] mt76x02_send_tx_status+0x266/0x480 [mt76x02_lib] mt76x02_tx_status_data+0x52/0x80 [mt76x02_lib] mt76u_tx_status_data+0x67/0xd0 [mt76_usb] process_one_work+0x225/0x400 worker_thread+0x50/0x3e0 ? process_one_work+0x400/0x400 kthread+0xe9/0x110 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x22/0x30
--- net/mac80211/airtime.c | 3 +++ 1 file changed, 3 insertions(+)
net/mac80211/airtime.c +3 -0
@@ -457,6 +457,9 @@ static u32 ieee80211_get_rate_duration(struct ieee80211_hw *hw, (status->encoding == RX_ENC_HE && streams > 8)))return 0 ; +if (idx >=MCS_GROUP_RATES ) +return 0 ; + duration = airtime_mcs_groups[group].duration[idx]; duration <<= airtime_mcs_groups[group].shift; *overhead =36 + (streams <<2 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 39/92 net: phy: fix null-ptr-deref while probe() failed
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 369eb2c9f1f72adbe91e0ea8efb130f0a2ba11a6 ]
I got a null-ptr-deref report as following when doing fault injection test:
BUG: kernel NULL pointer dereference, address: 0000000000000058 Oops: 0000 [#1] PREEMPT SMP KASAN PTI CPU: 1 PID: 253 Comm: 507-spi-dm9051 Tainted: G B N 6.1.0-rc3+ Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 RIP: 0010:klist_put+0x2d/0xd0 Call Trace: <TASK> klist_remove+0xf1/0x1c0 device_release_driver_internal+0x23e/0x2d0 bus_remove_device+0x1bd/0x240 device_del+0x357/0x770 phy_device_remove+0x11/0x30 mdiobus_unregister+0xa5/0x140 release_nodes+0x6a/0xa0 devres_release_all+0xf8/0x150 device_unbind_cleanup+0x19/0xd0
//probe path:phy_device_register()
device_add()
phy_connect
phy_attach_direct() //set device driver
probe() //it's failed, driver is not bound device_bind_driver() // probe failed, it's not called
//remove path:phy_device_remove()
device_del()
device_release_driver_internal()
__device_release_driver() //dev->drv is not NULL
klist_remove() <- knode_driver is not added yet, cause null-ptr-deref
In phy_attach_direct(), after setting the 'dev->driver', probe() fails, device_bind_driver() is not called, so the knode_driver->n_klist is not set, then it causes null-ptr-deref in __device_release_driver() while deleting device. Fix this by setting dev->driver to NULL in the error path in phy_attach_direct().
--- drivers/net/phy/phy_device.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/phy/phy_device.c +1 -0
@@ -1423,6 +1423,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, error_module_put:module_put (d->driver->owner); + d->driver =NULL ; error_put_device:put_device (d);if (ndev_owner != bus->owner)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 40/92 net: net_netdev: Fix error handling in ntb_netdev_init_module()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit b8f79dccd38edf7db4911c353d9cd792ab13a327 ]
The ntb_netdev_init_module() returns the ntb_transport_register_client() directly without checking its return value, if ntb_transport_register_client() failed, the NTB client device is not unregistered.
Fix by unregister NTB client device when ntb_transport_register_client() failed.
--- drivers/net/ntb_netdev.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/ntb_netdev.c +8 -1
@@ -484,7 +484,14 @@ static int __init ntb_netdev_init_module(void) rc =ntb_transport_register_client_dev (KBUILD_MODNAME );if (rc)return rc; -return ntb_transport_register_client (&ntb_netdev_client); + + rc =ntb_transport_register_client (&ntb_netdev_client); +if (rc) { +ntb_transport_unregister_client_dev (KBUILD_MODNAME ); +return rc; + } + +return 0 ; }module_init (ntb_netdev_init_module);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 41/92 net/9p: Fix a potential socket leak in p9_socket_open
In reply to Greg Kroah-HartmanFrom: Wang Hai <[email protected]>
[ Upstream commit dcc14cfd7debe11b825cb077e75d91d2575b4cb8 ]
Both p9_fd_create_tcp() and p9_fd_create_unix() will call p9_socket_open(). If the creation of p9_trans_fd fails, p9_fd_create_tcp() and p9_fd_create_unix() will return an error directly instead of releasing the cscoket, which will result in a socket leak.
This patch adds sock_release() to fix the leak issue.
--- net/9p/trans_fd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/9p/trans_fd.c +3 -1
@@ -852,8 +852,10 @@ static int p9_socket_open(struct p9_client *client, struct socket *csocket)struct file *file; p =kzalloc (sizeof (struct p9_trans_fd ),GFP_KERNEL ); -if (!p) +if (!p) { +sock_release (csocket);return -ENOMEM ; + } csocket->sk->sk_allocation =GFP_NOIO ; file =sock_alloc_file (csocket,0 ,NULL );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 42/92 net: ethernet: nixge: fix NULL dereference
In reply to Greg Kroah-HartmanFrom: Yuri Karpov <[email protected]>
[ Upstream commit 9256db4e45e8b497b0e993cc3ed4ad08eb2389b6 ]
In function nixge_hw_dma_bd_release() dereference of NULL pointer priv->rx_bd_v is possible for the case of its allocation failure in nixge_hw_dma_bd_init().
Move for() loop with priv->rx_bd_v dereference under the check for its validity.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/net/ethernet/ni/nixge.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
drivers/net/ethernet/ni/nixge.c +15 -14
@@ -249,25 +249,26 @@ static void nixge_hw_dma_bd_release(struct net_device *ndev)struct sk_buff *skb;int i; -for (i =0 ; i <RX_BD_NUM ; i++) { - phys_addr =nixge_hw_dma_bd_get_addr (&priv->rx_bd_v[i], - phys); - -dma_unmap_single (ndev->dev.parent, phys_addr, -NIXGE_MAX_JUMBO_FRAME_SIZE , -DMA_FROM_DEVICE ); - - skb = (struct sk_buff *)(uintptr_t ) -nixge_hw_dma_bd_get_addr (&priv->rx_bd_v[i], - sw_id_offset); -dev_kfree_skb (skb); - } +if (priv->rx_bd_v) { +for (i =0 ; i <RX_BD_NUM ; i++) { + phys_addr =nixge_hw_dma_bd_get_addr (&priv->rx_bd_v[i], + phys); + +dma_unmap_single (ndev->dev.parent, phys_addr, +NIXGE_MAX_JUMBO_FRAME_SIZE , +DMA_FROM_DEVICE ); + + skb = (struct sk_buff *)(uintptr_t ) +nixge_hw_dma_bd_get_addr (&priv->rx_bd_v[i], + sw_id_offset); +dev_kfree_skb (skb); + } -if (priv->rx_bd_v)dma_free_coherent (ndev->dev.parent,sizeof (*priv->rx_bd_v) *RX_BD_NUM , priv->rx_bd_v, priv->rx_bd_p); + }if (priv->tx_skb)devm_kfree (ndev->dev.parent, priv->tx_skb);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 43/92 dsa: lan9303: Correct stat name
In reply to Greg Kroah-HartmanFrom: Jerry Ray <[email protected]>
[ Upstream commit 39f59bca275d2d819a8788c0f962e9e89843efc9 ]
This patch changes the reported ethtool statistics for the lan9303 family of parts covered by this driver.
The TxUnderRun statistic label is renamed to RxShort to accurately reflect what stat the device is reporting. I did not reorder the statistics as that might cause problems with existing user code that are expecting the stats at a certain offset.
--- drivers/net/dsa/lan9303-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/lan9303-core.c +1 -1
@@ -958,7 +958,7 @@ static const struct lan9303_mib_desc lan9303_mib[] = { { .offset = LAN9303_MAC_TX_BRDCST_CNT_0, .name = "TxBroad", }, { .offset = LAN9303_MAC_TX_PAUSE_CNT_0, .name = "TxPause", }, { .offset = LAN9303_MAC_TX_MULCST_CNT_0, .name = "TxMulti", }, - { .offset = LAN9303_MAC_RX_UNDSZE_CNT_0, .name = "TxUnderRun", }, + { .offset = LAN9303_MAC_RX_UNDSZE_CNT_0, .name = "RxShort", }, { .offset = LAN9303_MAC_TX_64_CNT_0, .name = "Tx64Byte", }, { .offset = LAN9303_MAC_TX_127_CNT_0, .name = "Tx128Byte", }, { .offset = LAN9303_MAC_TX_255_CNT_0, .name = "Tx256Byte", },
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 44/92 tipc: re-fetch skb cb after tipc_msg_validate
In reply to Greg Kroah-HartmanFrom: Xin Long <[email protected]>
[ Upstream commit 3067bc61fcfe3081bf4807ce65560f499e895e77 ]
As the call trace shows, the original skb was freed in tipc_msg_validate(), and dereferencing the old skb cb would cause an use-after-free crash.
BUG: KASAN: use-after-free in tipc_crypto_rcv_complete+0x1835/0x2240 [tipc] Call Trace: <IRQ> tipc_crypto_rcv_complete+0x1835/0x2240 [tipc] tipc_crypto_rcv+0xd32/0x1ec0 [tipc] tipc_rcv+0x744/0x1150 [tipc] ... Allocated by task 47078: kmem_cache_alloc_node+0x158/0x4d0 __alloc_skb+0x1c1/0x270 tipc_buf_acquire+0x1e/0xe0 [tipc] tipc_msg_create+0x33/0x1c0 [tipc] tipc_link_build_proto_msg+0x38a/0x2100 [tipc] tipc_link_timeout+0x8b8/0xef0 [tipc] tipc_node_timeout+0x2a1/0x960 [tipc] call_timer_fn+0x2d/0x1c0 ... Freed by task 47078: tipc_msg_validate+0x7b/0x440 [tipc] tipc_crypto_rcv_complete+0x4b5/0x2240 [tipc] tipc_crypto_rcv+0xd32/0x1ec0 [tipc] tipc_rcv+0x744/0x1150 [tipc]
This patch fixes it by re-fetching the skb cb from the new allocated skb after calling tipc_msg_validate().
--- net/tipc/crypto.c | 3 +++ 1 file changed, 3 insertions(+)
net/tipc/crypto.c +3 -0
@@ -1975,6 +1975,9 @@ static void tipc_crypto_rcv_complete(struct net *net, struct tipc_aead *aead,/* Ok, everything's fine, try to synch own keys according to peers' */ tipc_crypto_key_synch (rx, *skb); +/* Re-fetch skb cb as skb might be changed in tipc_msg_validate */ + skb_cb =TIPC_SKB_CB (*skb); +/* Mark skb decrypted */ skb_cb->decrypted =1 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 45/92 net: hsr: Fix potential use-after-free
In reply to Greg Kroah-HartmanFrom: YueHaibing <[email protected]>
[ Upstream commit 7e177d32442b7ed08a9fa61b61724abc548cb248 ]
The skb is delivered to netif_rx() which may free it, after calling this, dereferencing skb may trigger use-after-free.
--- net/hsr/hsr_forward.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/hsr/hsr_forward.c +3 -2
@@ -303,17 +303,18 @@ static void hsr_deliver_master(struct sk_buff *skb, struct net_device *dev, struct hsr_node *node_src) {bool was_multicast_frame; -int res; +int res, recv_len; was_multicast_frame = (skb->pkt_type ==PACKET_MULTICAST );hsr_addr_subst_source (node_src, skb);skb_pull (skb,ETH_HLEN ); + recv_len = skb->len; res =netif_rx (skb);if (res ==NET_RX_DROP ) { dev->stats.rx_dropped++; }else { dev->stats.rx_packets++; - dev->stats.rx_bytes += skb->len; + dev->stats.rx_bytes += recv_len;if (was_multicast_frame) dev->stats.multicast++; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 46/92 afs: Fix fileserver probe RTT handling
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit ca57f02295f188d6c65ec02202402979880fa6d8 ]
The fileserver probing code attempts to work out the best fileserver to use for a volume by retrieving the RTT calculated by AF_RXRPC for the probe call sent to each server and comparing them. Sometimes, however, no RTT estimate is available and rxrpc_kernel_get_srtt() returns false, leading good fileservers to be given an RTT of UINT_MAX and thus causing the rotation algorithm to ignore them.
Fix afs_select_fileserver() to ignore rxrpc_kernel_get_srtt()'s return value and just take the estimated RTT it provides - which will be capped at 1 second.
--- fs/afs/fs_probe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/afs/fs_probe.c +2 -2
@@ -161,8 +161,8 @@ void afs_fileserver_probe_result(struct afs_call *call) } } -if (rxrpc_kernel_get_srtt (call->net->socket, call->rxcall, &rtt_us) && - rtt_us < server->probe.rtt) { +rxrpc_kernel_get_srtt (call->net->socket, call->rxcall, &rtt_us); +if (rtt_us < server->probe.rtt) { server->probe.rtt = rtt_us; server->rtt = rtt_us; alist->preferred = index;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 47/92 net: tun: Fix use-after-free in tun_detach()
In reply to Greg Kroah-HartmanFrom: Shigeru Yoshida <[email protected]>
[ Upstream commit 5daadc86f27ea4d691e2131c04310d0418c6cd12 ]
syzbot reported use-after-free in tun_detach() [1]. This causes call trace like below:
==================================================================
BUG: KASAN: use-after-free in notifier_call_chain+0x1ee/0x200 kernel/notifier.c:75 Read of size 8 at addr ffff88807324e2a8 by task syz-executor.0/3673 CPU: 0 PID: 3673 Comm: syz-executor.0 Not tainted 6.1.0-rc5-syzkaller-00044-gcc675d22e422 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022 Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd1/0x138 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:284 [inline] print_report+0x15e/0x461 mm/kasan/report.c:395 kasan_report+0xbf/0x1f0 mm/kasan/report.c:495 notifier_call_chain+0x1ee/0x200 kernel/notifier.c:75 call_netdevice_notifiers_info+0x86/0x130 net/core/dev.c:1942 call_netdevice_notifiers_extack net/core/dev.c:1983 [inline] call_netdevice_notifiers net/core/dev.c:1997 [inline] netdev_wait_allrefs_any net/core/dev.c:10237 [inline] netdev_run_todo+0xbc6/0x1100 net/core/dev.c:10351 tun_detach drivers/net/tun.c:704 [inline] tun_chr_close+0xe4/0x190 drivers/net/tun.c:3467 __fput+0x27c/0xa90 fs/file_table.c:320 task_work_run+0x16f/0x270 kernel/task_work.c:179 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0xb3d/0x2a30 kernel/exit.c:820 do_group_exit+0xd4/0x2a0 kernel/exit.c:950 get_signal+0x21b1/0x2440 kernel/signal.c:2858 arch_do_signal_or_restart+0x86/0x2300 arch/x86/kernel/signal.c:869 exit_to_user_mode_loop kernel/entry/common.c:168 [inline] exit_to_user_mode_prepare+0x15f/0x250 kernel/entry/common.c:203 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:296 do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd
The cause of the issue is that sock_put() from __tun_detach() drops last reference count for struct net, and then notifier_call_chain() from netdev_state_change() accesses that struct net.
This patch fixes the issue by calling sock_put() from tun_detach() after all necessary accesses for the struct net has done.
--- drivers/net/tun.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/tun.c +3 -1
@@ -698,7 +698,6 @@ static void __tun_detach(struct tun_file *tfile, bool clean)if (tun)xdp_rxq_info_unreg (&tfile->xdp_rxq);ptr_ring_cleanup (&tfile->tx_ring, tun_ptr_free); -sock_put (&tfile->sk); } }
@@ -714,6 +713,9 @@ static void tun_detach(struct tun_file *tfile, bool clean)if (dev)netdev_state_change (dev);rtnl_unlock (); + +if (clean) +sock_put (&tfile->sk); }static void tun_detach_all (struct net_device *dev)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 48/92 packet: do not set TP_STATUS_CSUM_VALID on CHECKSUM_COMPLETE
In reply to Greg Kroah-HartmanFrom: Willem de Bruijn <[email protected]>
[ Upstream commit b85f628aa158a653c006e9c1405a117baef8c868 ]
CHECKSUM_COMPLETE signals that skb->csum stores the sum over the entire packet. It does not imply that an embedded l4 checksum field has been validated.
--- net/packet/af_packet.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
net/packet/af_packet.c +2 -4
@@ -2243,8 +2243,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,if (skb->ip_summed ==CHECKSUM_PARTIAL ) status |=TP_STATUS_CSUMNOTREADY ;else if (skb->pkt_type !=PACKET_OUTGOING && - (skb->ip_summed ==CHECKSUM_COMPLETE || -skb_csum_unnecessary (skb))) +skb_csum_unnecessary (skb)) status |=TP_STATUS_CSUM_VALID ;if (snaplen > res)
@@ -3480,8 +3479,7 @@ static int packet_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,if (skb->ip_summed ==CHECKSUM_PARTIAL ) aux.tp_status |=TP_STATUS_CSUMNOTREADY ;else if (skb->pkt_type !=PACKET_OUTGOING && - (skb->ip_summed ==CHECKSUM_COMPLETE || -skb_csum_unnecessary (skb))) +skb_csum_unnecessary (skb)) aux.tp_status |=TP_STATUS_CSUM_VALID ; aux.tp_len = origlen;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 49/92 sctp: fix memory leak in sctp_stream_outq_migrate()
In reply to Greg Kroah-HartmanFrom: Zhengchao Shao <[email protected]>
[ Upstream commit 9ed7bfc79542119ac0a9e1ce8a2a5285e43433e9 ]
When sctp_stream_outq_migrate() is called to release stream out resources, the memory pointed to by prio_head in stream out is not released.
The memory leak information is as follows:
unreferenced object 0xffff88801fe79f80 (size 64):
comm "sctp_repo", pid 7957, jiffies 4294951704 (age 36.480s) hex dump (first 32 bytes):
80 9f e7 1f 80 88 ff ff 80 9f e7 1f 80 88 ff ff ................
90 9f e7 1f 80 88 ff ff 90 9f e7 1f 80 88 ff ff ................
backtrace:
[<ffffffff81b215c6>] kmalloc_trace+0x26/0x60
[<ffffffff88ae517c>] sctp_sched_prio_set+0x4cc/0x770
[<ffffffff88ad64f2>] sctp_stream_init_ext+0xd2/0x1b0
[<ffffffff88aa2604>] sctp_sendmsg_to_asoc+0x1614/0x1a30
[<ffffffff88ab7ff1>] sctp_sendmsg+0xda1/0x1ef0
[<ffffffff87f765ed>] inet_sendmsg+0x9d/0xe0
[<ffffffff8754b5b3>] sock_sendmsg+0xd3/0x120
[<ffffffff8755446a>] __sys_sendto+0x23a/0x340
[<ffffffff87554651>] __x64_sys_sendto+0xe1/0x1b0
[<ffffffff89978b49>] do_syscall_64+0x39/0xb0
[<ffffffff89a0008b>] entry_SYSCALL_64_after_hwframe+0x63/0xcd--- include/net/sctp/stream_sched.h | 2 ++ net/sctp/stream.c | 25 ++++++++++++++++++------- net/sctp/stream_sched.c | 5 +++++ net/sctp/stream_sched_prio.c | 19 +++++++++++++++++++ net/sctp/stream_sched_rr.c | 5 +++++ 5 files changed, 49 insertions(+), 7 deletions(-)
include/net/sctp/stream_sched.h +2 -0
@@ -26,6 +26,8 @@ struct sctp_sched_ops {int (*init)(struct sctp_stream *stream);/* Init a stream */ int (*init_sid)(struct sctp_stream *stream,__u16 sid,gfp_t gfp); +/* free a stream */ +void (*free_sid)(struct sctp_stream *stream,__u16 sid);/* Frees the entire thing */ void (*free)(struct sctp_stream *stream);
net/sctp/stream.c +18 -7
@@ -52,6 +52,19 @@ static void sctp_stream_shrink_out(struct sctp_stream *stream, __u16 outcnt) } } +static void sctp_stream_free_ext (struct sctp_stream *stream,__u16 sid) +{ +struct sctp_sched_ops *sched; + +if (!SCTP_SO (stream, sid)->ext) +return ; + + sched =sctp_sched_ops_from_stream (stream); + sched->free_sid (stream, sid); +kfree (SCTP_SO (stream, sid)->ext); +SCTP_SO (stream, sid)->ext =NULL ; +} +/* Migrates chunks from stream queues to new stream queues if needed, * but not across associations. Also, removes those chunks to streams * higher than the new max.
@@ -70,16 +83,14 @@ static void sctp_stream_outq_migrate(struct sctp_stream *stream,* sctp_stream_update will swap ->out pointers. */ for (i =0 ; i < outcnt; i++) { -kfree (SCTP_SO (new, i)->ext); +sctp_stream_free_ext (new, i);SCTP_SO (new, i)->ext =SCTP_SO (stream, i)->ext;SCTP_SO (stream, i)->ext =NULL ; } } -for (i = outcnt; i < stream->outcnt; i++) { -kfree (SCTP_SO (stream, i)->ext); -SCTP_SO (stream, i)->ext =NULL ; - } +for (i = outcnt; i < stream->outcnt; i++) +sctp_stream_free_ext (stream, i); } static int sctp_stream_alloc_out(struct sctp_stream *stream, __u16 outcnt,
@@ -174,9 +185,9 @@ void sctp_stream_free(struct sctp_stream *stream)struct sctp_sched_ops *sched =sctp_sched_ops_from_stream (stream);int i; - sched->free (stream); + sched->unsched_all (stream);for (i =0 ; i < stream->outcnt; i++) -kfree (SCTP_SO (stream, i)->ext); +sctp_stream_free_ext (stream, i);genradix_free (&stream->out);genradix_free (&stream->in); }
net/sctp/stream_sched.c +5 -0
@@ -46,6 +46,10 @@ static int sctp_sched_fcfs_init_sid(struct sctp_stream *stream, __u16 sid,return 0 ; } +static void sctp_sched_fcfs_free_sid (struct sctp_stream *stream,__u16 sid) +{ +} +static void sctp_sched_fcfs_free (struct sctp_stream *stream) { }
@@ -96,6 +100,7 @@ static struct sctp_sched_ops sctp_sched_fcfs = { .get = sctp_sched_fcfs_get, .init = sctp_sched_fcfs_init, .init_sid = sctp_sched_fcfs_init_sid, + .free_sid = sctp_sched_fcfs_free_sid, .free = sctp_sched_fcfs_free, .enqueue = sctp_sched_fcfs_enqueue, .dequeue = sctp_sched_fcfs_dequeue,
net/sctp/stream_sched_prio.c +19 -0
@@ -204,6 +204,24 @@ static int sctp_sched_prio_init_sid(struct sctp_stream *stream, __u16 sid,return sctp_sched_prio_set (stream, sid,0 , gfp); } +static void sctp_sched_prio_free_sid (struct sctp_stream *stream,__u16 sid) +{ +struct sctp_stream_priorities *prio =SCTP_SO (stream, sid)->ext->prio_head; +int i; + +if (!prio) +return ; + +SCTP_SO (stream, sid)->ext->prio_head =NULL ; +for (i =0 ; i < stream->outcnt; i++) { +if (SCTP_SO (stream, i)->ext && +SCTP_SO (stream, i)->ext->prio_head == prio) +return ; + } + +kfree (prio); +} +static void sctp_sched_prio_free (struct sctp_stream *stream) {struct sctp_stream_priorities *prio, *n;
@@ -323,6 +341,7 @@ static struct sctp_sched_ops sctp_sched_prio = { .get = sctp_sched_prio_get, .init = sctp_sched_prio_init, .init_sid = sctp_sched_prio_init_sid, + .free_sid = sctp_sched_prio_free_sid, .free = sctp_sched_prio_free, .enqueue = sctp_sched_prio_enqueue, .dequeue = sctp_sched_prio_dequeue,
net/sctp/stream_sched_rr.c +5 -0
@@ -90,6 +90,10 @@ static int sctp_sched_rr_init_sid(struct sctp_stream *stream, __u16 sid,return 0 ; } +static void sctp_sched_rr_free_sid (struct sctp_stream *stream,__u16 sid) +{ +} +static void sctp_sched_rr_free (struct sctp_stream *stream) {sctp_sched_rr_unsched_all (stream);
@@ -177,6 +181,7 @@ static struct sctp_sched_ops sctp_sched_rr = { .get = sctp_sched_rr_get, .init = sctp_sched_rr_init, .init_sid = sctp_sched_rr_init_sid, + .free_sid = sctp_sched_rr_free_sid, .free = sctp_sched_rr_free, .enqueue = sctp_sched_rr_enqueue, .dequeue = sctp_sched_rr_dequeue,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 50/92 net: ethernet: renesas: ravb: Fix promiscuous mode after system resumed
In reply to Greg Kroah-HartmanFrom: Yoshihiro Shimoda <[email protected]>
[ Upstream commit d66233a312ec9013af3e37e4030b479a20811ec3 ]
After system resumed on some environment board, the promiscuous mode is disabled because the SoC turned off. So, call ravb_set_rx_mode() in the ravb_resume() to fix the issue.
--- drivers/net/ethernet/renesas/ravb_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/renesas/ravb_main.c +1 -0
@@ -2364,6 +2364,7 @@ static int __maybe_unused ravb_resume(struct device *dev) ret =ravb_open (ndev);if (ret <0 )return ret; +ravb_set_rx_mode (ndev);netif_device_attach (ndev); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 51/92 hwmon: (coretemp) Check for null before removing sysfs attrs
In reply to Greg Kroah-HartmanFrom: Phil Auld <[email protected]>
[ Upstream commit a89ff5f5cc64b9fe7a992cf56988fd36f56ca82a ]
If coretemp_add_core() gets an error then pdata->core_data[indx] is already NULL and has been kfreed. Don't pass that to sysfs_remove_group() as that will crash in sysfs_remove_group().
[Shortened for readability]
[91854.020159] sysfs: cannot create duplicate filename '/devices/platform/coretemp.0/hwmon/hwmon2/temp20_label' <cpu offline> [91855.126115] BUG: kernel NULL pointer dereference, address: 0000000000000188 [91855.165103] #PF: supervisor read access in kernel mode [91855.194506] #PF: error_code(0x0000) - not-present page [91855.224445] PGD 0 P4D 0 [91855.238508] Oops: 0000 [#1] PREEMPT SMP PTI ... [91855.342716] RIP: 0010:sysfs_remove_group+0xc/0x80 ... [91855.796571] Call Trace: [91855.810524] coretemp_cpu_offline+0x12b/0x1dd [coretemp] [91855.841738] ? coretemp_cpu_online+0x180/0x180 [coretemp] [91855.871107] cpuhp_invoke_callback+0x105/0x4b0 [91855.893432] cpuhp_thread_fun+0x8e/0x150
...
Fix this by checking for NULL first.
--- drivers/hwmon/coretemp.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/hwmon/coretemp.c +4 -0
@@ -533,6 +533,10 @@ static void coretemp_remove_core(struct platform_data *pdata, int indx) {struct temp_data *tdata = pdata->core_data[indx]; +/* if we errored on add then this is already gone */ +if (!tdata) +return ; +/* Remove the sysfs attributes */ sysfs_remove_group (&pdata->hwmon_dev->kobj, &tdata->attr_group);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 52/92 hwmon: (coretemp) fix pci device refcount leak in nv1a_ram_new()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 7dec14537c5906b8bf40fd6fd6d9c3850f8df11d ]
As comment of pci_get_domain_bus_and_slot() says, it returns a pci device with refcount increment, when finish using it, the caller must decrement the reference count by calling pci_dev_put(). So call it after using to avoid refcount leak.
--- drivers/hwmon/coretemp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/hwmon/coretemp.c +4 -1
@@ -242,10 +242,13 @@ static int adjust_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)*/ if (host_bridge && host_bridge->vendor ==PCI_VENDOR_ID_INTEL ) {for (i =0 ; i <ARRAY_SIZE (tjmax_pci_table); i++) { -if (host_bridge->device == tjmax_pci_table[i].device) +if (host_bridge->device == tjmax_pci_table[i].device) { +pci_dev_put (host_bridge);return tjmax_pci_table[i].tjmax; + } } } +pci_dev_put (host_bridge);for (i =0 ; i <ARRAY_SIZE (tjmax_table); i++) {if (strstr (c->x86_model_id, tjmax_table[i].id))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 53/92 net/mlx5: DR, Fix uninitialized var warning
In reply to Greg Kroah-HartmanFrom: YueHaibing <[email protected]>
[ Upstream commit 52f7cf70eb8fac6111786c59ae9dfc5cf2bee710 ]
Smatch warns this:
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c:81
mlx5dr_table_set_miss_action() error: uninitialized symbol 'ret'.
Initializing ret with -EOPNOTSUPP and fix missing action case.
--- drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c +4 -1
@@ -9,7 +9,7 @@ int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl,struct mlx5dr_matcher *last_matcher =NULL ;struct mlx5dr_htbl_connect_info info;struct mlx5dr_ste_htbl *last_htbl; -int ret; +int ret = -EOPNOTSUPP ;if (action && action->action_type !=DR_ACTION_TYP_FT )return -EOPNOTSUPP ;
@@ -68,6 +68,9 @@ int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl, } } +if (ret) + goto out; +/* Release old action */ if (tbl->miss_action)refcount_dec (&tbl->miss_action->refcount);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 54/92 riscv: vdso: fix section overlapping under some conditions
In reply to Greg Kroah-HartmanFrom: Jisheng Zhang <[email protected]>
commit 74f6bb55c834da6d4bac24f44868202743189b2b upstream.
lkp reported a build error, I tried the config and can reproduce build error as below:
VDSOLD arch/riscv/kernel/vdso/vdso.so.dbg
ld.lld: error: section .note file range overlaps with .text
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
.note range is [
0x7C8,0x803]
.text range is [0x800,0x1993]
ld.lld: error: section .text file range overlaps with .dynamic
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
.text range is [
0x800,0x1993]
.dynamic range is [0x808,0x937]
ld.lld: error: section .note virtual address range overlaps with .text
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
.note range is [
0x7C8,0x803]
.text range is [0x800,0x1993]
Fix it by setting DISABLE_BRANCH_PROFILING which will disable branch tracing for vdso, thus avoid useless _ftrace_annotated_branch section and _ftrace_branch section. Although we can also fix it by removing the hardcoded .text begin address, but I think that's another story and should be put into another patch.
--- arch/riscv/kernel/vdso/Makefile | 1 + 1 file changed, 1 insertion(+)
arch/riscv/kernel/vdso/Makefile +1 -0
@@ -17,6 +17,7 @@ vdso-syms += flush_icache obj-vdso = $(patsubst %, %.o, $(vdso-syms)) note.o ccflags-y := -fno-stack-protector +ccflags-y += -DDISABLE_BRANCH_PROFILING ifneq ($(c-gettimeofday-y),) CFLAGS_vgettimeofday.o += -fPIC -include $(c-gettimeofday-y)
Signature · 1 line
2.38.1
Greg Kroah-Hartman
maintainerPATCH 55/92 error-injection: Add prompt for function error injection
In reply to Greg Kroah-HartmanFrom: Steven Rostedt (Google) <[email protected]>
commit a4412fdd49dc011bcc2c0d81ac4cab7457092650 upstream.
The config to be able to inject error codes into any function annotated with ALLOW_ERROR_INJECTION() is enabled when FUNCTION_ERROR_INJECTION is enabled. But unfortunately, this is always enabled on x86 when KPROBES is enabled, and there's no way to turn it off.
As kprobes is useful for observability of the kernel, it is useful to have it enabled in production environments. But error injection should be avoided. Add a prompt to the config to allow it to be disabled even when kprobes is enabled, and get rid of the "def_bool y".
This is a kernel debug feature (it's in Kconfig.debug), and should have never been something enabled by default.
--- lib/Kconfig.debug | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
lib/Kconfig.debug +7 -1
@@ -1801,8 +1801,14 @@ config NETDEV_NOTIFIER_ERROR_INJECT If unsure, say N. config FUNCTION_ERROR_INJECTION - def_bool y + bool "Fault-injections of functions" depends on HAVE_FUNCTION_ERROR_INJECTION && KPROBES + help + Add fault injections into various functions that are annotated with + ALLOW_ERROR_INJECTION() in the kernel. BPF may also modify the return + value of theses functions. This is useful to test error paths of code. + + If unsure, say N config FAULT_INJECTION bool "Fault-injection framework"
Greg Kroah-Hartman
maintainerPATCH 56/92 tools/vm/slabinfo-gnuplot: use "grep -E" instead of "egrep"
In reply to Greg Kroah-HartmanFrom: Tiezhu Yang <[email protected]>
commit a435874bf626f55d7147026b059008c8de89fbb8 upstream.
The latest version of grep claims the egrep is now obsolete so the build now contains warnings that look like:
egrep: warning: egrep is obsolescent; using grep -E
fix this up by moving the related file to use "grep -E" instead.
sed -i "s/egrep/grep -E/g" grep egrep -rwl tools/vm
Here are the steps to install the latest grep:
wget http://ftp.gnu.org/gnu/grep/grep-3.8.tar.gz tar xf grep-3.8.tar.gz cd grep-3.8 && ./configure && make sudo make install export PATH=/usr/local/bin:$PATH
--- tools/vm/slabinfo-gnuplot.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/vm/slabinfo-gnuplot.sh +2 -2
@@ -150,7 +150,7 @@ do_preprocess() let lines=3 out=`basename "$in"`"-slabs-by-loss" `cat "$in" | grep -A "$lines" 'Slabs sorted by loss' |\ - egrep -iv '\-\-|Name|Slabs'\ + grep -E -iv '\-\-|Name|Slabs'\ | awk '{print $1" "$4+$2*$3" "$4}' > "$out"` if [ $? -eq 0 ]; then do_slabs_plotting "$out"
@@ -159,7 +159,7 @@ do_preprocess() let lines=3 out=`basename "$in"`"-slabs-by-size" `cat "$in" | grep -A "$lines" 'Slabs sorted by size' |\ - egrep -iv '\-\-|Name|Slabs'\ + grep -E -iv '\-\-|Name|Slabs'\ | awk '{print $1" "$4" "$4-$2*$3}' > "$out"` if [ $? -eq 0 ]; then do_slabs_plotting "$out"
Greg Kroah-Hartman
maintainerPATCH 57/92 nilfs2: fix NULL pointer dereference in nilfs_palloc_commit_free_entry()
In reply to Greg Kroah-HartmanFrom: ZhangPeng <[email protected]>
commit f0a0ccda18d6fd826d7c7e7ad48a6ed61c20f8b4 upstream.
Syzbot reported a null-ptr-deref bug:
NILFS (loop0): segctord starting. Construction interval = 5 seconds, CP frequency < 30 seconds
general protection fault, probably for non-canonical address 0xdffffc0000000002: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017] CPU: 1 PID: 3603 Comm: segctord Not tainted 6.1.0-rc2-syzkaller-00105-gb229b6ca5abb #0 Hardware name: Google Compute Engine/Google Compute Engine, BIOS Google 10/11/2022 RIP: 0010:nilfs_palloc_commit_free_entry+0xe5/0x6b0 fs/nilfs2/alloc.c:608 Code: 00 00 00 00 fc ff df 80 3c 02 00 0f 85 cd 05 00 00 48 b8 00 00 00 00 00 fc ff df 4c 8b 73 08 49 8d 7e 10 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 26 05 00 00 49 8b 46 10 be a6 00 00 00 48 c7 c7 RSP: 0018:ffffc90003dff830 EFLAGS: 00010212 RAX: dffffc0000000000 RBX: ffff88802594e218 RCX: 000000000000000d RDX: 0000000000000002 RSI: 0000000000002000 RDI: 0000000000000010 RBP: ffff888071880222 R08: 0000000000000005 R09: 000000000000003f R10: 000000000000000d R11: 0000000000000000 R12: ffff888071880158 R13: ffff88802594e220 R14: 0000000000000000 R15: 0000000000000004 FS: 0000000000000000(0000) GS:ffff8880b9b00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fb1c08316a8 CR3: 0000000018560000 CR4: 0000000000350ee0 Call Trace: <TASK> nilfs_dat_commit_free fs/nilfs2/dat.c:114 [inline] nilfs_dat_commit_end+0x464/0x5f0 fs/nilfs2/dat.c:193 nilfs_dat_commit_update+0x26/0x40 fs/nilfs2/dat.c:236 nilfs_btree_commit_update_v+0x87/0x4a0 fs/nilfs2/btree.c:1940 nilfs_btree_commit_propagate_v fs/nilfs2/btree.c:2016 [inline] nilfs_btree_propagate_v fs/nilfs2/btree.c:2046 [inline] nilfs_btree_propagate+0xa00/0xd60 fs/nilfs2/btree.c:2088 nilfs_bmap_propagate+0x73/0x170 fs/nilfs2/bmap.c:337 nilfs_collect_file_data+0x45/0xd0 fs/nilfs2/segment.c:568 nilfs_segctor_apply_buffers+0x14a/0x470 fs/nilfs2/segment.c:1018 nilfs_segctor_scan_file+0x3f4/0x6f0 fs/nilfs2/segment.c:1067 nilfs_segctor_collect_blocks fs/nilfs2/segment.c:1197 [inline] nilfs_segctor_collect fs/nilfs2/segment.c:1503 [inline] nilfs_segctor_do_construct+0x12fc/0x6af0 fs/nilfs2/segment.c:2045 nilfs_segctor_construct+0x8e3/0xb30 fs/nilfs2/segment.c:2379 nilfs_segctor_thread_construct fs/nilfs2/segment.c:2487 [inline] nilfs_segctor_thread+0x3c3/0xf30 fs/nilfs2/segment.c:2570 kthread+0x2e4/0x3a0 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306 </TASK> ...
If DAT metadata file is corrupted on disk, there is a case where req->pr_desc_bh is NULL and blocknr is 0 at nilfs_dat_commit_end() during a b-tree operation that cascadingly updates ancestor nodes of the b-tree, because nilfs_dat_commit_alloc() for a lower level block can initialize the blocknr on the same DAT entry between nilfs_dat_prepare_end() and nilfs_dat_commit_end().
If this happens, nilfs_dat_commit_end() calls nilfs_dat_commit_free() without valid buffer heads in req->pr_desc_bh and req->pr_bitmap_bh, and causes the NULL pointer dereference above in nilfs_palloc_commit_free_entry() function, which leads to a crash.
Fix this by adding a NULL check on req->pr_desc_bh and req->pr_bitmap_bh before nilfs_palloc_commit_free_entry() in nilfs_dat_commit_free().
This also calls nilfs_error() in that case to notify that there is a fatal flaw in the filesystem metadata and prevent further operations.
--- fs/nilfs2/dat.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/nilfs2/dat.c +7 -0
@@ -111,6 +111,13 @@ static void nilfs_dat_commit_free(structkunmap_atomic (kaddr);nilfs_dat_commit_entry (dat, req); + +if (unlikely (req->pr_desc_bh ==NULL || req->pr_bitmap_bh ==NULL )) { +nilfs_error (dat->i_sb, +"state inconsistency probably due to duplicate use of vblocknr = %llu" , + (unsigned long long )req->pr_entry_nr); +return ; + }nilfs_palloc_commit_free_entry (dat, req); }
Greg Kroah-Hartman
maintainerPATCH 58/92 x86/bugs: Make sure MSR_SPEC_CTRL is updated properly upon resume from S3
In reply to Greg Kroah-HartmanFrom: Pawan Gupta <[email protected]>
commit 66065157420c5b9b3f078f43d313c153e1ff7f83 upstream.
The "force" argument to write_spec_ctrl_current() is currently ambiguous as it does not guarantee the MSR write. This is due to the optimization that writes to the MSR happen only when the new value differs from the cached value.
This is fine in most cases, but breaks for S3 resume when the cached MSR value gets out of sync with the hardware MSR value due to S3 resetting it.
When x86_spec_ctrl_current is same as x86_spec_ctrl_base, the MSR write is skipped. Which results in SPEC_CTRL mitigations not getting restored.
Move the MSR write from write_spec_ctrl_current() to a new function that unconditionally writes to the MSR. Update the callers accordingly and rename functions.
[ bp: Rework a bit. ]
--- arch/x86/include/asm/nospec-branch.h | 2 +- arch/x86/kernel/cpu/bugs.c | 21 ++++++++++++++------- arch/x86/kernel/process.c | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-)
arch/x86/include/asm/nospec-branch.h +1 -1
@@ -310,7 +310,7 @@ static inline void indirect_branch_predi/* The Intel SPEC CTRL MSR base value cache */ extern u64 x86_spec_ctrl_base;DECLARE_PER_CPU (u64, x86_spec_ctrl_current); -extern void write_spec_ctrl_current (u64 val,bool force); +extern void update_spec_ctrl_cond (u64 val);extern u64 spec_ctrl_current (void );/*
arch/x86/kernel/cpu/bugs.c +14 -7
@@ -59,11 +59,18 @@ EXPORT_SYMBOL_GPL(x86_spec_ctrl_current)static DEFINE_MUTEX (spec_ctrl_mutex); +/* Update SPEC_CTRL MSR and its cached copy unconditionally */ +static void update_spec_ctrl (u64 val) +{ +this_cpu_write (x86_spec_ctrl_current, val); +wrmsrl (MSR_IA32_SPEC_CTRL , val); +} +/* * Keep track of the SPEC_CTRL MSR value for the current task, which may differ * from x86_spec_ctrl_base due to STIBP/SSB in __speculation_ctrl_update(). */ -void write_spec_ctrl_current (u64 val,bool force) +void update_spec_ctrl_cond (u64 val) {if (this_cpu_read (x86_spec_ctrl_current) == val)return ;
@@ -74,7 +81,7 @@ void write_spec_ctrl_current(u64 val, bo* When KERNEL_IBRS this MSR is written on return-to-user, unless * forced the update can be delayed until that time. */ -if (force || !cpu_feature_enabled (X86_FEATURE_KERNEL_IBRS )) +if (!cpu_feature_enabled (X86_FEATURE_KERNEL_IBRS ))wrmsrl (MSR_IA32_SPEC_CTRL , val); }
@@ -1291,7 +1298,7 @@ static void __init spec_ctrl_disable_kerif (ia32_cap &ARCH_CAP_RRSBA ) { x86_spec_ctrl_base |=SPEC_CTRL_RRSBA_DIS_S ; -write_spec_ctrl_current (x86_spec_ctrl_base, true); +update_spec_ctrl (x86_spec_ctrl_base); } }
@@ -1413,7 +1420,7 @@ static void __init spectre_v2_select_mitif (spectre_v2_in_ibrs_mode (mode)) { x86_spec_ctrl_base |=SPEC_CTRL_IBRS ; -write_spec_ctrl_current (x86_spec_ctrl_base, true); +update_spec_ctrl (x86_spec_ctrl_base); }switch (mode) {
@@ -1527,7 +1534,7 @@ static void __init spectre_v2_select_mitstatic void update_stibp_msr (void * __unused) {u64 val =spec_ctrl_current () | (x86_spec_ctrl_base &SPEC_CTRL_STIBP ); -write_spec_ctrl_current (val, true); +update_spec_ctrl (val); }/* Update x86_spec_ctrl_base in case SMT state changed. */
@@ -1760,7 +1767,7 @@ static enum ssb_mitigation __init __ssb_x86_amd_ssb_disable (); }else { x86_spec_ctrl_base |=SPEC_CTRL_SSBD ; -write_spec_ctrl_current (x86_spec_ctrl_base, true); +update_spec_ctrl (x86_spec_ctrl_base); } }
@@ -1978,7 +1985,7 @@ int arch_prctl_spec_ctrl_get(struct taskvoid x86_spec_ctrl_setup_ap (void ) {if (boot_cpu_has (X86_FEATURE_MSR_SPEC_CTRL )) -write_spec_ctrl_current (x86_spec_ctrl_base, true); +update_spec_ctrl (x86_spec_ctrl_base);if (ssb_mode ==SPEC_STORE_BYPASS_DISABLE )x86_amd_ssb_disable ();
arch/x86/kernel/process.c +1 -1
@@ -556,7 +556,7 @@ static __always_inline void __speculatio }if (updmsr) -write_spec_ctrl_current (msr, false); +update_spec_ctrl_cond (msr); }static unsigned long speculation_ctrl_update_tif (struct task_struct *tsk)
Greg Kroah-Hartman
maintainerPATCH 59/92 pinctrl: intel: Save and restore pins in "direct IRQ" mode
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
commit 6989ea4881c8944fbf04378418bb1af63d875ef8 upstream.
The firmware on some systems may configure GPIO pins to be an interrupt source in so called "direct IRQ" mode. In such cases the GPIO controller driver has no idea if those pins are being used or not. At the same time, there is a known bug in the firmwares that don't restore the pin settings correctly after suspend, i.e. by an unknown reason the Rx value becomes inverted.
Hence, let's save and restore the pins that are configured as GPIOs in the input mode with GPIROUTIOXAPIC bit set.
--- drivers/pinctrl/intel/pinctrl-intel.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
drivers/pinctrl/intel/pinctrl-intel.c +26 -1
@@ -426,9 +426,14 @@ static void __intel_gpio_set_direction(vwritel (value, padcfg0); } +static int __intel_gpio_get_gpio_mode (u32 value) +{ +return (value &PADCFG0_PMODE_MASK ) >>PADCFG0_PMODE_SHIFT ; +} +static int intel_gpio_get_gpio_mode (void __iomem *padcfg0) { -return (readl (padcfg0) &PADCFG0_PMODE_MASK ) >>PADCFG0_PMODE_SHIFT ; +return __intel_gpio_get_gpio_mode (readl (padcfg0)); }static void intel_gpio_set_gpio_mode (void __iomem *padcfg0)
@@ -1604,6 +1609,7 @@ EXPORT_SYMBOL_GPL(intel_pinctrl_get_soc_static bool intel_pinctrl_should_save (struct intel_pinctrl *pctrl,unsigned int pin) {const struct pin_desc *pd =pin_desc_get (pctrl->pctldev, pin); +u32 value;if (!pd || !intel_pad_usable (pctrl, pin))return false;
@@ -1618,6 +1624,25 @@ static bool intel_pinctrl_should_save(st gpiochip_line_is_irq(&pctrl->chip, intel_pin_to_gpio(pctrl, pin)))return true; +/* +* The firmware on some systems may configure GPIO pins to be +* an interrupt source in so called "direct IRQ" mode. In such +* cases the GPIO controller driver has no idea if those pins +* are being used or not. At the same time, there is a known bug +* in the firmwares that don't restore the pin settings correctly +* after suspend, i.e. by an unknown reason the Rx value becomes +* inverted. +* +* Hence, let's save and restore the pins that are configured +* as GPIOs in the input mode with GPIROUTIOXAPIC bit set. +* +* See https://bugzilla.kernel.org/show_bug.cgi?id=214749. +*/ + value =readl (intel_get_padcfg (pctrl, pin,PADCFG0 )); +if ((value &PADCFG0_GPIROUTIOXAPIC ) && (value &PADCFG0_GPIOTXDIS ) && + (__intel_gpio_get_gpio_mode (value) ==PADCFG0_PMODE_GPIO )) +return true; +return false; }
Greg Kroah-Hartman
maintainerPATCH 60/92 net: stmmac: Set MACs flow control register to reflect current settings
In reply to Greg Kroah-HartmanFrom: Goh, Wei Sheng <[email protected]>
commit cc3d2b5fc0d6f8ad8a52da5ea679e5c2ec2adbd4 upstream.
Currently, pause frame register GMAC_RX_FLOW_CTRL_RFE is not updated correctly when 'ethtool -A <IFACE> autoneg off rx off tx off' command is issued. This fix ensures the flow control change is reflected directly in the GMAC_RX_FLOW_CTRL_RFE register.
--- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 2 ++ drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +2 -0
@@ -720,6 +720,8 @@ static void dwmac4_flow_ctrl(struct mac_if (fc &FLOW_RX ) {pr_debug ("\tReceive Flow-Control ON\n" ); flow |=GMAC_RX_FLOW_CTRL_RFE ; + }else { +pr_debug ("\tReceive Flow-Control OFF\n" ); }writel (flow, ioaddr +GMAC_RX_FLOW_CTRL );
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +10 -2
@@ -1043,8 +1043,16 @@ static void stmmac_mac_link_up(struct ph ctrl |= priv->hw->link.duplex;/* Flow Control operation */ -if (tx_pause && rx_pause) -stmmac_mac_flow_ctrl (priv, duplex); +if (rx_pause && tx_pause) + priv->flow_ctrl =FLOW_AUTO ; +else if (rx_pause && !tx_pause) + priv->flow_ctrl =FLOW_RX ; +else if (!rx_pause && tx_pause) + priv->flow_ctrl =FLOW_TX ; +else + priv->flow_ctrl =FLOW_OFF ; + +stmmac_mac_flow_ctrl (priv, duplex);writel (ctrl, priv->ioaddr +MAC_CTRL_REG );
Greg Kroah-Hartman
maintainerPATCH 61/92 mmc: mmc_test: Fix removal of debugfs file
In reply to Greg Kroah-HartmanFrom: Ye Bin <[email protected]>
commit f4307b4df1c28842bb1950ff0e1b97e17031b17f upstream.
In __mmc_test_register_dbgfs_file(), we need to assign 'file', as it's being used when removing the debugfs files when the mmc_test module is removed.
--- drivers/mmc/core/mmc_test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/core/mmc_test.c +2 -1
@@ -3195,7 +3195,8 @@ static int __mmc_test_register_dbgfs_filstruct mmc_test_dbgfs_file *df;if (card->debugfs_root) -debugfs_create_file (name, mode, card->debugfs_root, card, fops); + file =debugfs_create_file (name, mode, card->debugfs_root, + card, fops); df =kmalloc (sizeof (*df),GFP_KERNEL );if (!df) {
Greg Kroah-Hartman
maintainerPATCH 62/92 mmc: core: Fix ambiguous TRIM and DISCARD arg
In reply to Greg Kroah-HartmanFrom: Christian Löhle <[email protected]>
commit 489d144563f23911262a652234b80c70c89c978b upstream.
Clean up the MMC_TRIM_ARGS define that became ambiguous with DISCARD introduction. While at it, let's fix one usage where MMC_TRIM_ARGS falsely included DISCARD too.
--- drivers/mmc/core/core.c | 9 +++++++-- include/linux/mmc/mmc.h | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-)
drivers/mmc/core/core.c +7 -2
@@ -1539,6 +1539,11 @@ void mmc_init_erase(struct mmc_card *car card->pref_erase =0 ; } +static bool is_trim_arg (unsigned int arg) +{ +return (arg &MMC_TRIM_OR_DISCARD_ARGS ) && arg !=MMC_DISCARD_ARG ; +} +static unsigned int mmc_mmc_erase_timeout (struct mmc_card *card,unsigned int arg,unsigned int qty) {
@@ -1837,7 +1842,7 @@ int mmc_erase(struct mmc_card *card, uns !(card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN))return -EOPNOTSUPP ; -if (mmc_card_mmc (card) && (arg &MMC_TRIM_ARGS ) && +if (mmc_card_mmc (card) &&is_trim_arg (arg) && !(card->ext_csd.sec_feature_support &EXT_CSD_SEC_GB_CL_EN ))return -EOPNOTSUPP ;
@@ -1867,7 +1872,7 @@ int mmc_erase(struct mmc_card *card, uns* identified by the card->eg_boundary flag. */ rem = card->erase_size - (from % card->erase_size); -if ((arg &MMC_TRIM_ARGS ) && (card->eg_boundary) && (nr > rem)) { +if ((arg &MMC_TRIM_OR_DISCARD_ARGS ) && card->eg_boundary && nr > rem) { err =mmc_do_erase (card, from, from + rem -1 , arg); from += rem;if ((err) || (to <= from))
include/linux/mmc/mmc.h +1 -1
@@ -445,7 +445,7 @@ static inline bool mmc_ready_for_data(u3#define MMC_SECURE_TRIM1_ARG 0x80000001#define MMC_SECURE_TRIM2_ARG 0x80008000#define MMC_SECURE_ARGS 0x80000000 -#define MMC_TRIM_ARGS 0x00008001 +#define MMC_TRIM_OR_DISCARD_ARGS 0x00008003#define mmc_driver_type_mask (n) (1 << (n))
Greg Kroah-Hartman
maintainerPATCH 63/92 mmc: sdhci-esdhc-imx: correct CQHCI exit halt state check
In reply to Greg Kroah-HartmanFrom: Sebastian Falbesoner <[email protected]>
commit a3cab1d2132474969871b5d7f915c5c0167b48b0 upstream.
With the current logic the "failed to exit halt state" error would be shown even if any other bit than CQHCI_HALT was set in the CQHCI_CTL register, since the right hand side is always true. Fix this by using the correct operator (bit-wise instead of logical AND) to only check for the halt bit flag, which was obviously intended here.
--- drivers/mmc/host/sdhci-esdhc-imx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci-esdhc-imx.c +1 -1
@@ -1449,7 +1449,7 @@ static void esdhc_cqe_enable(struct mmc_* system resume back. */ cqhci_writel (cq_host,0 ,CQHCI_CTL ); -if (cqhci_readl (cq_host,CQHCI_CTL ) &&CQHCI_HALT ) +if (cqhci_readl (cq_host,CQHCI_CTL ) &CQHCI_HALT )dev_err (mmc_dev (host->mmc),"failed to exit halt state when enable CQE\n" );
Greg Kroah-Hartman
maintainerPATCH 64/92 mmc: sdhci-sprd: Fix no reset data and command after voltage switch
In reply to Greg Kroah-HartmanFrom: Wenchao Chen <[email protected]>
commit dd30dcfa7a74a06f8dcdab260d8d5adf32f17333 upstream.
After switching the voltage, no reset data and command will cause CMD2 timeout.
--- drivers/mmc/host/sdhci-sprd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-sprd.c +3 -1
@@ -457,7 +457,7 @@ static int sdhci_sprd_voltage_switch(str }if (IS_ERR (sprd_host->pinctrl)) -return 0 ; + goto reset;switch (ios->signal_voltage) {case MMC_SIGNAL_VOLTAGE_180 :
@@ -485,6 +485,8 @@ static int sdhci_sprd_voltage_switch(str/* Wait for 300 ~ 500 us for pin state stable */ usleep_range (300 ,500 ); + +reset:sdhci_reset (host,SDHCI_RESET_CMD |SDHCI_RESET_DATA );return 0 ;
Greg Kroah-Hartman
maintainerPATCH 65/92 mmc: sdhci: Fix voltage switch delay
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
commit c981cdfb9925f64a364f13c2b4f98f877308a408 upstream.
Commit 20b92a30b561 ("mmc: sdhci: update signal voltage switch code") removed voltage switch delays from sdhci because mmc core had been enhanced to support them. However that assumed that sdhci_set_ios() did a single clock change, which it did not, and so the delays in mmc core, which should have come after the first clock change, were not effective.
Fix by avoiding re-configuring UHS and preset settings when the clock is turning on and the settings have not changed. That then also avoids the associated clock changes, so that then sdhci_set_ios() does a single clock change when voltage switching, and the mmc core delays become effective.
To do that has meant keeping track of driver strength (host->drv_type), and cases of reinitialization (host->reinit_uhs).
Note also, the 'turning_on_clk' restriction should not be necessary but is done to minimize the impact of the change on stable kernels.
--- drivers/mmc/host/sdhci.c | 61 +++++++++++++++++++++++++++++++++++++++++------ drivers/mmc/host/sdhci.h | 2 + 2 files changed, 56 insertions(+), 7 deletions(-)
drivers/mmc/host/sdhci.c +54 -7
@@ -339,6 +339,7 @@ static void sdhci_init(struct sdhci_hostif (soft) {/* force clock reconfiguration */ host->clock =0 ; + host->reinit_uhs = true; mmc->ops->set_ios (mmc, &mmc->ios); } }
@@ -2258,11 +2259,46 @@ void sdhci_set_uhs_signaling(struct sdhc }EXPORT_SYMBOL_GPL (sdhci_set_uhs_signaling); +static bool sdhci_timing_has_preset (unsigned char timing) +{ +switch (timing) { +case MMC_TIMING_UHS_SDR12 : +case MMC_TIMING_UHS_SDR25 : +case MMC_TIMING_UHS_SDR50 : +case MMC_TIMING_UHS_SDR104 : +case MMC_TIMING_UHS_DDR50 : +case MMC_TIMING_MMC_DDR52 : +return true; + }; +return false; +} + +static bool sdhci_preset_needed (struct sdhci_host *host,unsigned char timing) +{ +return !(host->quirks2 &SDHCI_QUIRK2_PRESET_VALUE_BROKEN ) && +sdhci_timing_has_preset (timing); +} + +static bool sdhci_presetable_values_change (struct sdhci_host *host,struct mmc_ios *ios) +{ +/* +* Preset Values are: Driver Strength, Clock Generator and SDCLK/RCLK +* Frequency. Check if preset values need to be enabled, or the Driver +* Strength needs updating. Note, clock changes are handled separately. +*/ +return !host->preset_enabled && + (sdhci_preset_needed (host, ios->timing) || host->drv_type != ios->drv_type); +} +void sdhci_set_ios (struct mmc_host *mmc,struct mmc_ios *ios) {struct sdhci_host *host =mmc_priv (mmc); +bool reinit_uhs = host->reinit_uhs; +bool turning_on_clk = false;u8 ctrl; + host->reinit_uhs = false; +if (ios->power_mode ==MMC_POWER_UNDEFINED )return ;
@@ -2288,6 +2324,8 @@ void sdhci_set_ios(struct mmc_host *mmc,sdhci_enable_preset_value (host, false);if (!ios->clock || ios->clock != host->clock) { + turning_on_clk = ios->clock && !host->clock; + host->ops->set_clock (host, ios->clock); host->clock = ios->clock;
@@ -2314,6 +2352,17 @@ void sdhci_set_ios(struct mmc_host *mmc, host->ops->set_bus_width (host, ios->bus_width); +/* +* Special case to avoid multiple clock changes during voltage +* switching. +*/ +if (!reinit_uhs && + turning_on_clk && + host->timing == ios->timing && + host->version >=SDHCI_SPEC_300 && + !sdhci_presetable_values_change (host, ios)) +return ; + ctrl =sdhci_readb (host,SDHCI_HOST_CONTROL );if (!(host->quirks &SDHCI_QUIRK_NO_HISPD_BIT )) {
@@ -2357,6 +2406,7 @@ void sdhci_set_ios(struct mmc_host *mmc, }sdhci_writew (host, ctrl_2,SDHCI_HOST_CONTROL2 ); + host->drv_type = ios->drv_type; }else {/* * According to SDHC Spec v3.00, if the Preset Value
@@ -2384,19 +2434,14 @@ void sdhci_set_ios(struct mmc_host *mmc, host->ops->set_uhs_signaling (host, ios->timing); host->timing = ios->timing; -if (!(host->quirks2 &SDHCI_QUIRK2_PRESET_VALUE_BROKEN ) && - ((ios->timing ==MMC_TIMING_UHS_SDR12 ) || - (ios->timing ==MMC_TIMING_UHS_SDR25 ) || - (ios->timing ==MMC_TIMING_UHS_SDR50 ) || - (ios->timing ==MMC_TIMING_UHS_SDR104 ) || - (ios->timing ==MMC_TIMING_UHS_DDR50 ) || - (ios->timing ==MMC_TIMING_MMC_DDR52 ))) { +if (sdhci_preset_needed (host, ios->timing)) {u16 preset;sdhci_enable_preset_value (host, true); preset =sdhci_get_preset_value (host); ios->drv_type =FIELD_GET (SDHCI_PRESET_DRV_MASK , preset); + host->drv_type = ios->drv_type; }/* Re-enable SD Clock */
@@ -3707,6 +3752,7 @@ int sdhci_resume_host(struct sdhci_hostsdhci_init (host,0 ); host->pwr =0 ; host->clock =0 ; + host->reinit_uhs = true; mmc->ops->set_ios (mmc, &mmc->ios); }else {sdhci_init (host, (host->mmc->pm_flags &MMC_PM_KEEP_POWER ));
@@ -3769,6 +3815,7 @@ int sdhci_runtime_resume_host(struct sdh/* Force clock and power re-program */ host->pwr =0 ; host->clock =0 ; + host->reinit_uhs = true; mmc->ops->start_signal_voltage_switch (mmc, &mmc->ios); mmc->ops->set_ios (mmc, &mmc->ios);
drivers/mmc/host/sdhci.h +2 -0
@@ -520,6 +520,8 @@ struct sdhci_host {unsigned int clock;/* Current clock (MHz) */ u8 pwr;/* Current voltage */ +u8 drv_type;/* Current UHS-I driver type */ +bool reinit_uhs;/* Force UHS-related re-initialization */ bool runtime_suspended;/* Host is runtime suspended */ bool bus_on;/* Bus power prevents runtime suspend */
Greg Kroah-Hartman
maintainerPATCH 66/92 drm/amdgpu: temporarily disable broken Clang builds due to blown stack-frame
In reply to Greg Kroah-HartmanFrom: Lee Jones <[email protected]>
commit 6f6cb1714365a07dbc66851879538df9f6969288 upstream.
Patch series "Fix a bunch of allmodconfig errors", v2.
Since b339ec9c229aa ("kbuild: Only default to -Werror if COMPILE_TEST") WERROR now defaults to COMPILE_TEST meaning that it's enabled for allmodconfig builds. This leads to some interesting build failures when using Clang, each resolved in this set.
With this set applied, I am able to obtain a successful allmodconfig Arm build.
This patch (of 2):
calculate_bandwidth() is presently broken on all !(X86_64 || SPARC64 || ARM64) architectures built with Clang (all released versions), whereby the stack frame gets blown up to well over 5k. This would cause an immediate kernel panic on most architectures. We'll revert this when the following bug report has been resolved:
https://github.com/llvm/llvm-project/issues/41896.
--- drivers/gpu/drm/amd/display/Kconfig | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/display/Kconfig +7 -0
@@ -5,6 +5,7 @@ menu "Display Engine Configuration" config DRM_AMD_DC bool "AMD DC - Enable new display engine" default y + depends on BROKEN || !CC_IS_CLANG || X86_64 || SPARC64 || ARM64 select SND_HDA_COMPONENT if SND_HDA_CORE select DRM_AMD_DC_DCN if (X86 || PPC64) && !(KCOV_INSTRUMENT_ALL && KCOV_ENABLE_COMPARISONS) help
@@ -12,6 +13,12 @@ config DRM_AMD_DC support for AMDGPU. This adds required support for Vega and Raven ASICs. + calculate_bandwidth() is presently broken on all !(X86_64 || SPARC64 || ARM64) + architectures built with Clang (all released versions), whereby the stack + frame gets blown up to well over 5k. This would cause an immediate kernel + panic on most architectures. We'll revert this when the following bug report + has been resolved: https://github.com/llvm/llvm-project/issues/41896. + config DRM_AMD_DC_DCN def_bool n help
Greg Kroah-Hartman
maintainerPATCH 67/92 drm/i915: Never return 0 if not all requests retired
In reply to Greg Kroah-HartmanFrom: Janusz Krzysztofik <[email protected]>
commit 12b8b046e4c9de40fa59b6f067d6826f4e688f68 upstream.
Users of intel_gt_retire_requests_timeout() expect 0 return value on success. However, we have no protection from passing back 0 potentially returned by a call to dma_fence_wait_timeout() when it succedes right after its timeout has expired.
Replace 0 with -ETIME before potentially using the timeout value as return code, so -ETIME is returned if there are still some requests not retired after timeout, 0 otherwise.
v3: Use conditional expression, more compact but also better reflecting
intention standing behind the change.
v2: Move the added lines down so flush_submission() is not affected.
--- drivers/gpu/drm/i915/gt/intel_gt_requests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/intel_gt_requests.c +1 -1
@@ -200,7 +200,7 @@ out_active: spin_lock(&timelines->lock);if (flush_submission (gt, timeout))/* Wait, there's more! */ active_count++; -return active_count ? timeout :0 ; +return active_count ? timeout ?: -ETIME :0 ; }int intel_gt_wait_for_idle (struct intel_gt *gt,long timeout)
Greg Kroah-Hartman
maintainerPATCH 68/92 tracing: Free buffers when a used dynamic event is removed
In reply to Greg Kroah-HartmanFrom: Steven Rostedt (Google) <[email protected]>
commit 4313e5a613049dfc1819a6dfb5f94cf2caff9452 upstream.
After 65536 dynamic events have been added and removed, the "type" field of the event then uses the first type number that is available (not currently used by other events). A type number is the identifier of the binary blobs in the tracing ring buffer (known as events) to map them to logic that can parse the binary blob.
The issue is that if a dynamic event (like a kprobe event) is traced and is in the ring buffer, and then that event is removed (because it is dynamic, which means it can be created and destroyed), if another dynamic event is created that has the same number that new event's logic on parsing the binary blob will be used.
To show how this can be an issue, the following can crash the kernel:
# cd /sys/kernel/tracing
# for i in `seq 65536`; do
echo 'p:kprobes/foo do_sys_openat2 $arg1:u32' > kprobe_events
# doneFor every iteration of the above, the writing to the kprobe_events will remove the old event and create a new one (with the same format) and increase the type number to the next available on until the type number reaches over 65535 which is the max number for the 16 bit type. After it reaches that number, the logic to allocate a new number simply looks for the next available number. When an dynamic event is removed, that number is then available to be reused by the next dynamic event created. That is, once the above reaches the max number, the number assigned to the event in that loop will remain the same.
Now that means deleting one dynamic event and created another will reuse the previous events type number. This is where bad things can happen. After the above loop finishes, the kprobes/foo event which reads the do_sys_openat2 function call's first parameter as an integer.
# echo 1 > kprobes/foo/enable
# cat /etc/passwd > /dev/null
# cat trace
cat-2211 [005] .... 2007.849603: foo: (do_sys_openat2+0x0/0x130) arg1=4294967196
cat-2211 [005] .... 2007.849620: foo: (do_sys_openat2+0x0/0x130) arg1=4294967196
cat-2211 [005] .... 2007.849838: foo: (do_sys_openat2+0x0/0x130) arg1=4294967196
cat-2211 [005] .... 2007.849880: foo: (do_sys_openat2+0x0/0x130) arg1=4294967196
# echo 0 > kprobes/foo/enableNow if we delete the kprobe and create a new one that reads a string:
# echo 'p:kprobes/foo do_sys_openat2 +0($arg2):string' > kprobe_events
And now we can the trace:
# cat trace
sendmail-1942 [002] ..... 530.136320: foo: (do_sys_openat2+0x0/0x240) arg1= cat-2046 [004] ..... 530.930817: foo: (do_sys_openat2+0x0/0x240) arg1="������������������������������������������������������������������������������������������������"
cat-2046 [004] ..... 530.930961: foo: (do_sys_openat2+0x0/0x240) arg1="������������������������������������������������������������������������������������������������"
cat-2046 [004] ..... 530.934278: foo: (do_sys_openat2+0x0/0x240) arg1="������������������������������������������������������������������������������������������������"
cat-2046 [004] ..... 530.934563: foo: (do_sys_openat2+0x0/0x240) arg1="������������������������������������������������������������������������������������������������"
bash-1515 [007] ..... 534.299093: foo: (do_sys_openat2+0x0/0x240) arg1="kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk���������@��4Z����;Y�����UAnd dmesg has:
==================================================================
BUG: KASAN: use-after-free in string+0xd4/0x1c0
Read of size 1 at addr ffff88805fdbbfa0 by task cat/2049
CPU: 0 PID: 2049 Comm: cat Not tainted 6.1.0-rc6-test+ #641
Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016
Call Trace:
<TASK>
dump_stack_lvl+0x5b/0x77
print_report+0x17f/0x47b
kasan_report+0xad/0x130
string+0xd4/0x1c0
vsnprintf+0x500/0x840
seq_buf_vprintf+0x62/0xc0
trace_seq_printf+0x10e/0x1e0
print_type_string+0x90/0xa0
print_kprobe_event+0x16b/0x290
print_trace_line+0x451/0x8e0
s_show+0x72/0x1f0
seq_read_iter+0x58e/0x750
seq_read+0x115/0x160
vfs_read+0x11d/0x460
ksys_read+0xa9/0x130
do_syscall_64+0x3a/0x90
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fc2e972ade2
Code: c0 e9 b2 fe ff ff 50 48 8d 3d b2 3f 0a 00 e8 05 f0 01 00 0f 1f 44 00 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 0f 05 <48> 3d 00 f0 ff ff 77 56 c3 0f 1f 44 00 00 48 83 ec 28 48 89 54 24
RSP: 002b:00007ffc64e687c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 0000000000020000 RCX: 00007fc2e972ade2
RDX: 0000000000020000 RSI: 00007fc2e980d000 RDI: 0000000000000003
RBP: 00007fc2e980d000 R08: 00007fc2e980c010 R09: 0000000000000000
R10: 0000000000000022 R11: 0000000000000246 R12: 0000000000020f00
R13: 0000000000000003 R14: 0000000000020000 R15: 0000000000020000
</TASK>
The buggy address belongs to the physical page:
page:ffffea00017f6ec0 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x5fdbb
flags: 0xfffffc0000000(node=0|zone=1|lastcpupid=0x1fffff)
raw: 000fffffc0000000 0000000000000000 ffffea00017f6ec8 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88805fdbbe80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88805fdbbf00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff88805fdbbf80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff88805fdbc000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88805fdbc080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================This was found when Zheng Yejian sent a patch to convert the event type number assignment to use IDA, which gives the next available number, and this bug showed up in the fuzz testing by Yujie Liu and the kernel test robot. But after further analysis, I found that this behavior is the same as when the event type numbers go past the 16bit max (and the above shows that).
As modules have a similar issue, but is dealt with by setting a "WAS_ENABLED" flag when a module event is enabled, and when the module is freed, if any of its events were enabled, the ring buffer that holds that event is also cleared, to prevent reading stale events. The same can be done for dynamic events.
If any dynamic event that is being removed was enabled, then make sure the buffers they were enabled in are now cleared.
Cc: [email protected]
Cc: Andrew Morton <[email protected]>
Depends-on: e18eb8783ec49 ("tracing: Add tracing_reset_all_online_cpus_unlocked() function")
Depends-on: 5448d44c38557 ("tracing: Add unified dynamic event framework")
Depends-on: 6212dd29683ee ("tracing/kprobes: Use dyn_event framework for kprobe events")
Depends-on: 065e63f951432 ("tracing: Only have rmmod clear buffers that its events were active in")
Depends-on: 575380da8b469 ("tracing: Only clear trace buffer on module unload if event was traced")
--- kernel/trace/trace_dynevent.c | 2 ++ kernel/trace/trace_events.c | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-)
kernel/trace/trace_dynevent.c +2 -0
@@ -70,6 +70,7 @@ int dyn_event_release(int argc, char **aif (ret)break ; } +tracing_reset_all_online_cpus ();mutex_unlock (&event_mutex);return ret;
@@ -165,6 +166,7 @@ int dyn_events_release_all(struct dyn_evbreak ; } out: +tracing_reset_all_online_cpus ();mutex_unlock (&event_mutex);return ret;
kernel/trace/trace_events.c +10 -1
@@ -2572,7 +2572,10 @@ static int probe_remove_event_call(struc* TRACE_REG_UNREGISTER. */ if (file->flags &EVENT_FILE_FL_ENABLED ) -return -EBUSY ; + goto busy; + +if (file->flags &EVENT_FILE_FL_WAS_ENABLED ) + tr->clear_trace = true;/* * The do_for_each_event_file_safe() is * a double loop. After finding the call for this
@@ -2585,6 +2588,12 @@ static int probe_remove_event_call(struc__trace_remove_event_call (call);return 0 ; + busy: +/* No need to clear the trace now */ +list_for_each_entry (tr, &ftrace_trace_arrays, list) { + tr->clear_trace = false; + } +return -EBUSY ; }/* Remove an event_call */
Greg Kroah-Hartman
maintainerPATCH 69/92 io_uring: dont hold uring_lock when calling io_run_task_work*
In reply to Greg Kroah-HartmanFrom: Hao Xu <[email protected]>
commit 8bad28d8a305b0e5ae444c8c3051e8744f5a4296 upstream.
Abaci reported the below issue:
[ 141.400455] hrtimer: interrupt took 205853 ns
[ 189.869316] process 'usr/local/ilogtail/ilogtail_0.16.26' started with executable stack
[ 250.188042]
[ 250.188327] ============================================
[ 250.189015] WARNING: possible recursive locking detected
[ 250.189732] 5.11.0-rc4 #1 Not tainted
[ 250.190267] --------------------------------------------
[ 250.190917] a.out/7363 is trying to acquire lock:
[ 250.191506] ffff888114dbcbe8 (&ctx->uring_lock){+.+.}-{3:3}, at: __io_req_task_submit+0x29/0xa0
[ 250.192599]
[ 250.192599] but task is already holding lock:
[ 250.193309] ffff888114dbfbe8 (&ctx->uring_lock){+.+.}-{3:3}, at: __x64_sys_io_uring_register+0xad/0x210
[ 250.194426]
[ 250.194426] other info that might help us debug this:
[ 250.195238] Possible unsafe locking scenario:
[ 250.195238]
[ 250.196019] CPU0
[ 250.196411] ----
[ 250.196803] lock(&ctx->uring_lock);
[ 250.197420] lock(&ctx->uring_lock);
[ 250.197966]
[ 250.197966] *** DEADLOCK ***
[ 250.197966]
[ 250.198837] May be due to missing lock nesting notation
[ 250.198837]
[ 250.199780] 1 lock held by a.out/7363:
[ 250.200373] #0: ffff888114dbfbe8 (&ctx->uring_lock){+.+.}-{3:3}, at: __x64_sys_io_uring_register+0xad/0x210
[ 250.201645]
[ 250.201645] stack backtrace:
[ 250.202298] CPU: 0 PID: 7363 Comm: a.out Not tainted 5.11.0-rc4 #1
[ 250.203144] Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
[ 250.203887] Call Trace:
[ 250.204302] dump_stack+0xac/0xe3
[ 250.204804] __lock_acquire+0xab6/0x13a0
[ 250.205392] lock_acquire+0x2c3/0x390
[ 250.205928] ? __io_req_task_submit+0x29/0xa0
[ 250.206541] __mutex_lock+0xae/0x9f0
[ 250.207071] ? __io_req_task_submit+0x29/0xa0
[ 250.207745] ? 0xffffffffa0006083
[ 250.208248] ? __io_req_task_submit+0x29/0xa0
[ 250.208845] ? __io_req_task_submit+0x29/0xa0
[ 250.209452] ? __io_req_task_submit+0x5/0xa0
[ 250.210083] __io_req_task_submit+0x29/0xa0
[ 250.210687] io_async_task_func+0x23d/0x4c0
[ 250.211278] task_work_run+0x89/0xd0
[ 250.211884] io_run_task_work_sig+0x50/0xc0
[ 250.212464] io_sqe_files_unregister+0xb2/0x1f0
[ 250.213109] __io_uring_register+0x115a/0x1750
[ 250.213718] ? __x64_sys_io_uring_register+0xad/0x210
[ 250.214395] ? __fget_files+0x15a/0x260
[ 250.214956] __x64_sys_io_uring_register+0xbe/0x210
[ 250.215620] ? trace_hardirqs_on+0x46/0x110
[ 250.216205] do_syscall_64+0x2d/0x40
[ 250.216731] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[ 250.217455] RIP: 0033:0x7f0fa17e5239
[ 250.218034] Code: 01 00 48 81 c4 80 00 00 00 e9 f1 fe ff ff 0f 1f 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 3d 01 f0 ff ff 73 01 c3 48 8b 0d 27 ec 2c 00 f7 d8 64 89 01 48
[ 250.220343] RSP: 002b:00007f0fa1eeac48 EFLAGS: 00000246 ORIG_RAX: 00000000000001ab
[ 250.221360] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f0fa17e5239
[ 250.222272] RDX: 0000000000000000 RSI: 0000000000000003 RDI: 0000000000000008
[ 250.223185] RBP: 00007f0fa1eeae20 R08: 0000000000000000 R09: 0000000000000000
[ 250.224091] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
[ 250.224999] R13: 0000000000021000 R14: 0000000000000000 R15: 00007f0fa1eeb700This is caused by calling io_run_task_work_sig() to do work under uring_lock while the caller io_sqe_files_unregister() already held uring_lock.
To fix this issue, briefly drop uring_lock when calling io_run_task_work_sig(), and there are two things to concern:
- hold uring_lock in io_ring_ctx_free() around io_sqe_files_unregister() this is for consistency of lock/unlock.
- add new fixed rsrc ref node before dropping uring_lock
it's not safe to do io_uring_enter-->percpu_ref_get() with a dying one.
- check if rsrc_data->refs is dying to avoid parallel io_sqe_files_unregister
--- fs/io_uring.c | 82 +++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 61 insertions(+), 21 deletions(-)
fs/io_uring.c +61 -21
@@ -217,6 +217,7 @@ struct fixed_file_data {struct completion done;struct list_head ref_list;spinlock_t lock; +bool quiesce; };struct io_buffer {
@@ -7105,41 +7106,79 @@ static void io_sqe_files_set_node(structpercpu_ref_get (&file_data->refs); } -static int io_sqe_files_unregister (struct io_ring_ctx *ctx) -{ -struct fixed_file_data *data = ctx->file_data; -struct fixed_file_ref_node *backup_node, *ref_node =NULL ; -unsigned nr_tables, i; -int ret; -if (!data) -return -ENXIO ; - backup_node =alloc_fixed_file_ref_node (ctx); -if (!backup_node) -return -ENOMEM ; +static void io_sqe_files_kill_node (struct fixed_file_data *data) +{ +struct fixed_file_ref_node *ref_node =NULL ;spin_lock_bh (&data->lock); ref_node = data->node;spin_unlock_bh (&data->lock);if (ref_node)percpu_ref_kill (&ref_node->refs); +} + +static int io_file_ref_quiesce (struct fixed_file_data *data, +struct io_ring_ctx *ctx) +{ +int ret; +struct fixed_file_ref_node *backup_node; -percpu_ref_kill (&data->refs); +if (data->quiesce) +return -ENXIO ; -/* wait for all refs nodes to complete */ -flush_delayed_work (&ctx->file_put_work); + data->quiesce = true;do { + backup_node =alloc_fixed_file_ref_node (ctx); +if (!backup_node) +break ; + +io_sqe_files_kill_node (data); +percpu_ref_kill (&data->refs); +flush_delayed_work (&ctx->file_put_work); + ret =wait_for_completion_interruptible (&data->done);if (!ret)break ; + +percpu_ref_resurrect (&data->refs); +io_sqe_files_set_node (data, backup_node); + backup_node =NULL ; +reinit_completion (&data->done); +mutex_unlock (&ctx->uring_lock); ret =io_run_task_work_sig (); -if (ret <0 ) { -percpu_ref_resurrect (&data->refs); -reinit_completion (&data->done); -io_sqe_files_set_node (data, backup_node); -return ret; - } +mutex_lock (&ctx->uring_lock); + +if (ret <0 ) +break ; + backup_node =alloc_fixed_file_ref_node (ctx); + ret = -ENOMEM ; +if (!backup_node) +break ; }while (1 ); + data->quiesce = false; + +if (backup_node) +destroy_fixed_file_ref_node (backup_node); +return ret; +} + +static int io_sqe_files_unregister (struct io_ring_ctx *ctx) +{ +struct fixed_file_data *data = ctx->file_data; +unsigned nr_tables, i; +int ret; + +/* +* percpu_ref_is_dying() is to stop parallel files unregister +* Since we possibly drop uring lock later in this function to +* run task work. +*/ +if (!data ||percpu_ref_is_dying (&data->refs)) +return -ENXIO ; + ret =io_file_ref_quiesce (data, ctx); +if (ret) +return ret;__io_sqe_files_unregister (ctx); nr_tables =DIV_ROUND_UP (ctx->nr_user_files,IORING_MAX_FILES_TABLE );
@@ -7150,7 +7189,6 @@ static int io_sqe_files_unregister(struckfree (data); ctx->file_data =NULL ; ctx->nr_user_files =0 ; -destroy_fixed_file_ref_node (backup_node);return 0 ; }
@@ -8444,7 +8482,9 @@ static void io_ring_ctx_free(struct io_rcss_put (ctx->sqo_blkcg_css);#endif +mutex_lock (&ctx->uring_lock);io_sqe_files_unregister (ctx); +mutex_unlock (&ctx->uring_lock);io_eventfd_unregister (ctx);io_destroy_buffers (ctx);
Greg Kroah-Hartman
maintainerPATCH 70/92 ASoC: ops: Fix bounds check for _sx controls
In reply to Greg Kroah-HartmanFrom: Mark Brown <[email protected]>
[ Upstream commit 698813ba8c580efb356ace8dbf55f61dac6063a8 ]
For _sx controls the semantics of the max field is not the usual one, max is the number of steps rather than the maximum value. This means that our check in snd_soc_put_volsw_sx() needs to just check against the maximum value.
--- sound/soc/soc-ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/soc-ops.c +1 -1
@@ -432,7 +432,7 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol, val = ucontrol->value.integer.value[0 ];if (mc->platform_max && val > mc->platform_max)return -EINVAL ; -if (val > max - min) +if (val > max)return -EINVAL ;if (val <0 )return -EINVAL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 71/92 pinctrl: single: Fix potential division by zero
In reply to Greg Kroah-HartmanFrom: Maxim Korotkov <[email protected]>
[ Upstream commit 64c150339e7f6c5cbbe8c17a56ef2b3902612798 ]
There is a possibility of dividing by zero due to the pcs->bits_per_pin if pcs->fmask() also has a value of zero and called fls
from asm-generic/bitops/builtin-fls.h or arch/x86/include/asm/bitops.h. The function pcs_probe() has the branch that assigned to fmask 0 before pcs_allocate_pin_table() was called
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/pinctrl/pinctrl-single.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/pinctrl-single.c +1 -1
@@ -726,7 +726,7 @@ static int pcs_allocate_pin_table(struct pcs_device *pcs) mux_bytes = pcs->width /BITS_PER_BYTE ; -if (pcs->bits_per_mux) { +if (pcs->bits_per_mux && pcs->fmask) { pcs->bits_per_pin =fls (pcs->fmask); nr_pins = (pcs->size *BITS_PER_BYTE ) / pcs->bits_per_pin; num_pins_in_register = pcs->width / pcs->bits_per_pin;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 72/92 iommu/vt-d: Fix PCI device refcount leak in has_external_pci()
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit afca9e19cc720bfafc75dc5ce429c185ca93f31d ]
for_each_pci_dev() is implemented by pci_get_device(). The comment of pci_get_device() says that it will increase the reference count for the returned pci_dev and also decrease the reference count for the input pci_dev @from if it is not NULL.
If we break for_each_pci_dev() loop with pdev not NULL, we need to call pci_dev_put() to decrease the reference count. Add the missing pci_dev_put() before 'return true' to avoid reference count leak.
--- drivers/iommu/intel/iommu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iommu/intel/iommu.c +3 -1
@@ -4893,8 +4893,10 @@ static inline bool has_external_pci(void)struct pci_dev *pdev =NULL ;for_each_pci_dev (pdev) -if (pdev->external_facing) +if (pdev->external_facing) { +pci_dev_put (pdev);return true; + }return false; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 73/92 iommu/vt-d: Fix PCI device refcount leak in dmar_dev_scope_init()
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit 4bedbbd782ebbe7287231fea862c158d4f08a9e3 ]
for_each_pci_dev() is implemented by pci_get_device(). The comment of pci_get_device() says that it will increase the reference count for the returned pci_dev and also decrease the reference count for the input pci_dev @from if it is not NULL.
If we break for_each_pci_dev() loop with pdev not NULL, we need to call pci_dev_put() to decrease the reference count. Add the missing pci_dev_put() for the error path to avoid reference count leak.
--- drivers/iommu/intel/dmar.c | 1 + 1 file changed, 1 insertion(+)
drivers/iommu/intel/dmar.c +1 -0
@@ -816,6 +816,7 @@ int __init dmar_dev_scope_init(void) info =dmar_alloc_pci_notify_info (dev,BUS_NOTIFY_ADD_DEVICE );if (!info) { +pci_dev_put (dev);return dmar_dev_scope_status; }else {dmar_pci_bus_add_dev (info);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 74/92 parisc: Increase size of gcc stack frame check
In reply to Greg Kroah-HartmanFrom: Helge Deller <[email protected]>
[ Upstream commit 55b70eed81cba1331773d4aaf5cba2bb07475cd8 ]
parisc uses much bigger frames than other architectures, so increase the stack frame check value to avoid compiler warnings.
Stable-dep-of: 152fe65f300e ("Kconfig.debug: provide a little extra FRAME_WARN leeway when KASAN is enabled")
--- lib/Kconfig.debug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/Kconfig.debug +1 -1
@@ -298,7 +298,7 @@ config FRAME_WARN int "Warn for stack frames larger than" range 0 8192 default 2048 if GCC_PLUGIN_LATENT_ENTROPY - default 1280 if (!64BIT && PARISC) + default 1536 if (!64BIT && PARISC) default 1024 if (!64BIT && !PARISC) default 2048 if 64BIT help
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 75/92 xtensa: increase size of gcc stack frame check
In reply to Greg Kroah-HartmanFrom: Guenter Roeck <[email protected]>
[ Upstream commit 867050247e295cf20fce046a92a7e6491fcfe066 ]
xtensa frame size is larger than the frame size for almost all other architectures. This results in more than 50 "the frame size of <n> is larger than 1024 bytes" errors when trying to build xtensa:allmodconfig.
Increase frame size for xtensa to 1536 bytes to avoid compile errors due to frame size limits.
Stable-dep-of: 152fe65f300e ("Kconfig.debug: provide a little extra FRAME_WARN leeway when KASAN is enabled")
--- lib/Kconfig.debug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/Kconfig.debug +1 -1
@@ -298,7 +298,7 @@ config FRAME_WARN int "Warn for stack frames larger than" range 0 8192 default 2048 if GCC_PLUGIN_LATENT_ENTROPY - default 1536 if (!64BIT && PARISC) + default 1536 if (!64BIT && (PARISC || XTENSA)) default 1024 if (!64BIT && !PARISC) default 2048 if 64BIT help
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 76/92 parisc: Increase FRAME_WARN to 2048 bytes on parisc
In reply to Greg Kroah-HartmanFrom: Helge Deller <[email protected]>
[ Upstream commit 8d192bec534bd5b778135769a12e5f04580771f7 ]
PA-RISC uses a much bigger frame size for functions than other architectures. So increase it to 2048 for 32- and 64-bit kernels. This fixes e.g. a warning in lib/xxhash.c.
Stable-dep-of: 152fe65f300e ("Kconfig.debug: provide a little extra FRAME_WARN leeway when KASAN is enabled")
--- lib/Kconfig.debug | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
lib/Kconfig.debug +3 -2
@@ -298,8 +298,9 @@ config FRAME_WARN int "Warn for stack frames larger than" range 0 8192 default 2048 if GCC_PLUGIN_LATENT_ENTROPY - default 1536 if (!64BIT && (PARISC || XTENSA)) - default 1024 if (!64BIT && !PARISC) + default 2048 if PARISC + default 1536 if (!64BIT && XTENSA) + default 1024 if !64BIT default 2048 if 64BIT help Tell gcc to warn at build time for stack frames larger than this.
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 77/92 Kconfig.debug: provide a little extra FRAME_WARN leeway when KASAN is enabled
In reply to Greg Kroah-HartmanFrom: Lee Jones <[email protected]>
[ Upstream commit 152fe65f300e1819d59b80477d3e0999b4d5d7d2 ]
When enabled, KASAN enlarges function's stack-frames. Pushing quite a few over the current threshold. This can mainly be seen on 32-bit architectures where the present limit (when !GCC) is a lowly 1024-Bytes.
--- lib/Kconfig.debug | 1 + 1 file changed, 1 insertion(+)
lib/Kconfig.debug +1 -0
@@ -300,6 +300,7 @@ config FRAME_WARN default 2048 if GCC_PLUGIN_LATENT_ENTROPY default 2048 if PARISC default 1536 if (!64BIT && XTENSA) + default 1280 if KASAN && !64BIT default 1024 if !64BIT default 2048 if 64BIT help
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 78/92 selftests: net: add delete nexthop route warning test
In reply to Greg Kroah-HartmanFrom: Nikolay Aleksandrov <[email protected]>
[ Upstream commit 392baa339c6a42a2cb088e5e5df2b59b8f89be24 ]
Add a test which causes a WARNING on kernels which treat a nexthop route like a normal route when comparing for deletion and a device is specified. That is, a route is found but we hit a warning while matching it. The warning is from fib_info_nh() in include/net/nexthop.h because we run it on a fib_info with nexthop object. The call chain is:
inet_rtm_delroute -> fib_table_delete -> fib_nh_match (called with a
nexthop fib_info and also with fc_oif set thus calling fib_info_nh on the fib_info and triggering the warning).
Repro steps:
$ ip nexthop add id 12 via 172.16.1.3 dev veth1 $ ip route add 172.16.101.1/32 nhid 12 $ ip route delete 172.16.101.1/32 dev veth1
Stable-dep-of: d5082d386eee ("ipv4: Fix route deletion when nexthop info is not specified")
--- tools/testing/selftests/net/fib_nexthops.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
tools/testing/selftests/net/fib_nexthops.sh +14 -0
@@ -931,6 +931,20 @@ ipv4_fcnal() set +e check_nexthop "dev veth1" "" log_test $? 0 "Nexthops removed on admin down" + + # nexthop route delete warning: route add with nhid and delete + # using device + run_cmd "$IP li set dev veth1 up" + run_cmd "$IP nexthop add id 12 via 172.16.1.3 dev veth1" + out1=`dmesg | grep "WARNING:.*fib_nh_match.*" | wc -l` + run_cmd "$IP route add 172.16.101.1/32 nhid 12" + run_cmd "$IP route delete 172.16.101.1/32 dev veth1" + out2=`dmesg | grep "WARNING:.*fib_nh_match.*" | wc -l` + [ $out1 -eq $out2 ] + rc=$? + log_test $rc 0 "Delete nexthop route warning" + run_cmd "$IP ip route delete 172.16.101.1/32 nhid 12" + run_cmd "$IP ip nexthop del id 12" } ipv4_grp_fcnal()
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 79/92 selftests: net: fix nexthop warning cleanup double ip typo
In reply to Greg Kroah-HartmanFrom: Nikolay Aleksandrov <[email protected]>
[ Upstream commit 692930cc435099580a4b9e32fa781b0688c18439 ]
I made a stupid typo when adding the nexthop route warning selftest and added both $IP and ip after it (double ip) on the cleanup path. The error doesn't show up when running the test, but obviously it doesn't cleanup properly after it.
Stable-dep-of: d5082d386eee ("ipv4: Fix route deletion when nexthop info is not specified")
--- tools/testing/selftests/net/fib_nexthops.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/net/fib_nexthops.sh +2 -2
@@ -943,8 +943,8 @@ ipv4_fcnal() [ $out1 -eq $out2 ] rc=$? log_test $rc 0 "Delete nexthop route warning" - run_cmd "$IP ip route delete 172.16.101.1/32 nhid 12" - run_cmd "$IP ip nexthop del id 12" + run_cmd "$IP route delete 172.16.101.1/32 nhid 12" + run_cmd "$IP nexthop del id 12" } ipv4_grp_fcnal()
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 80/92 ipv4: Handle attempt to delete multipath route when fib_info contains an nh reference
In reply to Greg Kroah-HartmanFrom: David Ahern <[email protected]>
[ Upstream commit 61b91eb33a69c3be11b259c5ea484505cd79f883 ]
Gwangun Jung reported a slab-out-of-bounds access in fib_nh_match:
fib_nh_match+0xf98/0x1130 linux-6.0-rc7/net/ipv4/fib_semantics.c:961
fib_table_delete+0x5f3/0xa40 linux-6.0-rc7/net/ipv4/fib_trie.c:1753
inet_rtm_delroute+0x2b3/0x380 linux-6.0-rc7/net/ipv4/fib_frontend.c:874Separate nexthop objects are mutually exclusive with the legacy multipath spec. Fix fib_nh_match to return if the config for the to be deleted route contains a multipath spec while the fib_info is using a nexthop object.
Stable-dep-of: d5082d386eee ("ipv4: Fix route deletion when nexthop info is not specified")
--- net/ipv4/fib_semantics.c | 8 ++++---- tools/testing/selftests/net/fib_nexthops.sh | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-)
net/ipv4/fib_semantics.c +4 -4
@@ -887,13 +887,13 @@ int fib_nh_match(struct net *net, struct fib_config *cfg, struct fib_info *fi,return 1 ; } +/* cannot match on nexthop object attributes */ +if (fi->nh) +return 1 ; +if (cfg->fc_oif || cfg->fc_gw_family) {struct fib_nh *nh; -/* cannot match on nexthop object attributes */ -if (fi->nh) -return 1 ; - nh =fib_info_nh (fi,0 );if (cfg->fc_encap) { if (fib_encap_match(net, cfg->fc_encap_type,
tools/testing/selftests/net/fib_nexthops.sh +5 -0
@@ -945,6 +945,11 @@ ipv4_fcnal() log_test $rc 0 "Delete nexthop route warning" run_cmd "$IP route delete 172.16.101.1/32 nhid 12" run_cmd "$IP nexthop del id 12" + + run_cmd "$IP nexthop add id 21 via 172.16.1.6 dev veth1" + run_cmd "$IP ro add 172.16.101.0/24 nhid 21" + run_cmd "$IP ro del 172.16.101.0/24 nexthop via 172.16.1.7 dev veth1 nexthop via 172.16.1.8 dev veth1" + log_test $? 2 "Delete multipath route with only nh id based entry" } ipv4_grp_fcnal()
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 81/92 ipv4: Fix route deletion when nexthop info is not specified
In reply to Greg Kroah-HartmanFrom: Ido Schimmel <[email protected]>
[ Upstream commit d5082d386eee7e8ec46fa8581932c81a4961dcef ]
When the kernel receives a route deletion request from user space it tries to delete a route that matches the route attributes specified in the request.
If only prefix information is specified in the request, the kernel should delete the first matching FIB alias regardless of its associated FIB info. However, an error is currently returned when the FIB info is backed by a nexthop object:
# ip nexthop add id 1 via 192.0.2.2 dev dummy10 # ip route add 198.51.100.0/24 nhid 1 # ip route del 198.51.100.0/24 RTNETLINK answers: No such process
Fix by matching on such a FIB info when legacy nexthop attributes are not specified in the request. An earlier check already covers the case where a nexthop ID is specified in the request.
Add tests that cover these flows. Before the fix:
# ./fib_nexthops.sh -t ipv4_fcnal ... TEST: Delete route when not specifying nexthop attributes [FAIL]
Tests passed: 11
Tests failed: 1
After the fix:
# ./fib_nexthops.sh -t ipv4_fcnal ... TEST: Delete route when not specifying nexthop attributes [ OK ]
Tests passed: 12
Tests failed: 0
No regressions in other tests:
# ./fib_nexthops.sh ... Tests passed: 228 Tests failed: 0
# ./fib_tests.sh ... Tests passed: 186 Tests failed: 0
--- net/ipv4/fib_semantics.c | 8 +++++--- tools/testing/selftests/net/fib_nexthops.sh | 11 +++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-)
net/ipv4/fib_semantics.c +5 -3
@@ -887,9 +887,11 @@ int fib_nh_match(struct net *net, struct fib_config *cfg, struct fib_info *fi,return 1 ; } -/* cannot match on nexthop object attributes */ -if (fi->nh) -return 1 ; +if (fi->nh) { +if (cfg->fc_oif || cfg->fc_gw_family || cfg->fc_mp) +return 1 ; +return 0 ; + }if (cfg->fc_oif || cfg->fc_gw_family) {struct fib_nh *nh;
tools/testing/selftests/net/fib_nexthops.sh +11 -0
@@ -950,6 +950,17 @@ ipv4_fcnal() run_cmd "$IP ro add 172.16.101.0/24 nhid 21" run_cmd "$IP ro del 172.16.101.0/24 nexthop via 172.16.1.7 dev veth1 nexthop via 172.16.1.8 dev veth1" log_test $? 2 "Delete multipath route with only nh id based entry" + + run_cmd "$IP nexthop add id 22 via 172.16.1.6 dev veth1" + run_cmd "$IP ro add 172.16.102.0/24 nhid 22" + run_cmd "$IP ro del 172.16.102.0/24 dev veth1" + log_test $? 2 "Delete route when specifying only nexthop device" + + run_cmd "$IP ro del 172.16.102.0/24 via 172.16.1.6" + log_test $? 2 "Delete route when specifying only gateway" + + run_cmd "$IP ro del 172.16.102.0/24" + log_test $? 0 "Delete route when not specifying nexthop attributes" } ipv4_grp_fcnal()
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 82/92 Revert "tty: n_gsm: avoid call of sleeping functions from atomic context"
In reply to Greg Kroah-HartmanFrom: Fedor Pchelkin <[email protected]>
commit acdab4cb4ba7e5f94d2b422ebd7bf4bf68178fb2 upstream.
This reverts commit 902e02ea9385373ce4b142576eef41c642703955.
The above commit is reverted as the usage of tx_mutex seems not to solve the problem described in 902e02ea9385 ("tty: n_gsm: avoid call of sleeping functions from atomic context") and just moves the bug to another place.
--- drivers/tty/n_gsm.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-)
drivers/tty/n_gsm.c +21 -18
@@ -235,7 +235,7 @@ struct gsm_mux {int old_c_iflag;/* termios c_iflag value before attach */ bool constipated;/* Asked by remote to shut up */ -struct mutex tx_mutex; +spinlock_t tx_lock;unsigned int tx_bytes;/* TX data outstanding */ #define TX_THRESH_HI 8192#define TX_THRESH_LO 2048
@@ -820,14 +820,15 @@ static void __gsm_data_queue(struct gsm_* * Add data to the transmit queue and try and get stuff moving * out of the mux tty if not already doing so. Take the -* the gsm tx mutex and dlci lock. +* the gsm tx lock and dlci lock. */ static void gsm_data_queue (struct gsm_dlci *dlci,struct gsm_msg *msg) { -mutex_lock (&dlci->gsm->tx_mutex); +unsigned long flags; +spin_lock_irqsave (&dlci->gsm->tx_lock, flags);__gsm_data_queue (dlci, msg); -mutex_unlock (&dlci->gsm->tx_mutex); +spin_unlock_irqrestore (&dlci->gsm->tx_lock, flags); }/**
@@ -839,7 +840,7 @@ static void gsm_data_queue(struct gsm_dl* is data. Keep to the MRU of the mux. This path handles the usual tty * interface which is a byte stream with optional modem data. * -* Caller must hold the tx_mutex of the mux. +* Caller must hold the tx_lock of the mux. */ static int gsm_dlci_data_output (struct gsm_mux *gsm,struct gsm_dlci *dlci)
@@ -902,7 +903,7 @@ static int gsm_dlci_data_output(struct g* is data. Keep to the MRU of the mux. This path handles framed data * queued as skbuffs to the DLCI. * -* Caller must hold the tx_mutex of the mux. +* Caller must hold the tx_lock of the mux. */ static int gsm_dlci_data_output_framed(struct gsm_mux *gsm,
@@ -918,7 +919,7 @@ static int gsm_dlci_data_output_framed(sif (dlci->adaption ==4 ) overhead =1 ; -/* dlci->skb is locked by tx_mutex */ +/* dlci->skb is locked by tx_lock */ if (dlci->skb ==NULL ) { dlci->skb =skb_dequeue_tail (&dlci->skb_list);if (dlci->skb ==NULL )
@@ -1018,12 +1019,13 @@ static void gsm_dlci_data_sweep(struct gstatic void gsm_dlci_data_kick (struct gsm_dlci *dlci) { +unsigned long flags;int sweep;if (dlci->constipated)return ; -mutex_lock (&dlci->gsm->tx_mutex); +spin_lock_irqsave (&dlci->gsm->tx_lock, flags);/* If we have nothing running then we need to fire up */ sweep = (dlci->gsm->tx_bytes <TX_THRESH_LO );if (dlci->gsm->tx_bytes ==0 ) {
@@ -1034,7 +1036,7 @@ static void gsm_dlci_data_kick(struct gs }if (sweep)gsm_dlci_data_sweep (dlci->gsm); -mutex_unlock (&dlci->gsm->tx_mutex); +spin_unlock_irqrestore (&dlci->gsm->tx_lock, flags); }/*
@@ -1256,6 +1258,7 @@ static void gsm_control_message(struct g const u8 *data, int clen) {u8 buf[1 ]; +unsigned long flags;switch (command) {case CMD_CLD : {
@@ -1277,9 +1280,9 @@ static void gsm_control_message(struct g gsm->constipated = false;gsm_control_reply (gsm,CMD_FCON ,NULL ,0 );/* Kick the link in case it is idling */ -mutex_lock (&gsm->tx_mutex); +spin_lock_irqsave (&gsm->tx_lock, flags);gsm_data_kick (gsm,NULL ); -mutex_unlock (&gsm->tx_mutex); +spin_unlock_irqrestore (&gsm->tx_lock, flags);break ;case CMD_FCOFF :/* Modem wants us to STFU */
@@ -2225,7 +2228,6 @@ static void gsm_free_mux(struct gsm_muxbreak ; } } -mutex_destroy (&gsm->tx_mutex);mutex_destroy (&gsm->mutex);kfree (gsm->txframe);kfree (gsm->buf);
@@ -2297,12 +2299,12 @@ static struct gsm_mux *gsm_alloc_mux(voi }spin_lock_init (&gsm->lock);mutex_init (&gsm->mutex); -mutex_init (&gsm->tx_mutex);kref_init (&gsm->ref);INIT_LIST_HEAD (&gsm->tx_list);timer_setup (&gsm->t2_timer, gsm_control_retransmit,0 );init_waitqueue_head (&gsm->event);spin_lock_init (&gsm->control_lock); +spin_lock_init (&gsm->tx_lock); gsm->t1 =T1 ; gsm->t2 =T2 ;
@@ -2327,7 +2329,6 @@ static struct gsm_mux *gsm_alloc_mux(voi }spin_unlock (&gsm_mux_lock);if (i ==MAX_MUX ) { -mutex_destroy (&gsm->tx_mutex);mutex_destroy (&gsm->mutex);kfree (gsm->txframe);kfree (gsm->buf);
@@ -2652,15 +2653,16 @@ static int gsmld_open(struct tty_structstatic void gsmld_write_wakeup (struct tty_struct *tty) {struct gsm_mux *gsm = tty->disc_data; +unsigned long flags;/* Queue poll */ clear_bit (TTY_DO_WRITE_WAKEUP , &tty->flags); -mutex_lock (&gsm->tx_mutex); +spin_lock_irqsave (&gsm->tx_lock, flags);gsm_data_kick (gsm,NULL );if (gsm->tx_bytes <TX_THRESH_LO ) {gsm_dlci_data_sweep (gsm); } -mutex_unlock (&gsm->tx_mutex); +spin_unlock_irqrestore (&gsm->tx_lock, flags); }/**
@@ -2703,6 +2705,7 @@ static ssize_t gsmld_write(struct tty_st const unsigned char *buf, size_t nr) {struct gsm_mux *gsm = tty->disc_data; +unsigned long flags;int space;int ret;
@@ -2710,13 +2713,13 @@ static ssize_t gsmld_write(struct tty_streturn -ENODEV ; ret = -ENOBUFS ; -mutex_lock (&gsm->tx_mutex); +spin_lock_irqsave (&gsm->tx_lock, flags); space =tty_write_room (tty);if (space >= nr) ret = tty->ops->write (tty, buf, nr);else set_bit (TTY_DO_WRITE_WAKEUP , &tty->flags); -mutex_unlock (&gsm->tx_mutex); +spin_unlock_irqrestore (&gsm->tx_lock, flags);return ret; }
Greg Kroah-Hartman
maintainerPATCH 83/92 x86/tsx: Add a feature bit for TSX control MSR support
In reply to Greg Kroah-HartmanFrom: Pawan Gupta <[email protected]>
commit aaa65d17eec372c6a9756833f3964ba05b05ea14 upstream.
Support for the TSX control MSR is enumerated in MSR_IA32_ARCH_CAPABILITIES. This is different from how other CPU features are enumerated i.e. via CPUID. Currently, a call to tsx_ctrl_is_supported() is required for enumerating the feature. In the absence of a feature bit for TSX control, any code that relies on checking feature bits directly will not work.
In preparation for adding a feature bit check in MSR save/restore during suspend/resume, set a new feature bit X86_FEATURE_TSX_CTRL when MSR_IA32_TSX_CTRL is present.
[ bp: Remove tsx_ctrl_is_supported()]
[Pawan: Resolved conflicts in backport; Removed parts of commit message
referring to removed function tsx_ctrl_is_supported()]
--- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/tsx.c | 33 ++++++++++++++------------------- 2 files changed, 15 insertions(+), 19 deletions(-)
arch/x86/include/asm/cpufeatures.h +1 -0
@@ -300,6 +300,7 @@#define X86_FEATURE_UNRET (11*32+15)/* "" AMD BTB untrain return */ #define X86_FEATURE_USE_IBPB_FW (11*32+16)/* "" Use IBPB during runtime firmware calls */ #define X86_FEATURE_RSB_VMEXIT_LITE (11*32+17)/* "" Fill RSB on VM exit when EIBRS is enabled */ +#define X86_FEATURE_MSR_TSX_CTRL (11*32+18)/* "" MSR IA32_TSX_CTRL (Intel) implemented */ /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */ #define X86_FEATURE_AVX512_BF16 (12*32+ 5)/* AVX512 BFLOAT16 instructions */
arch/x86/kernel/cpu/tsx.c +14 -19
@@ -58,24 +58,6 @@ void tsx_enable(void)wrmsrl (MSR_IA32_TSX_CTRL , tsx); } -static bool __init tsx_ctrl_is_supported (void ) -{ -u64 ia32_cap =x86_read_arch_cap_msr (); - -/* -* TSX is controlled via MSR_IA32_TSX_CTRL. However, support for this -* MSR is enumerated by ARCH_CAP_TSX_MSR bit in MSR_IA32_ARCH_CAPABILITIES. -* -* TSX control (aka MSR_IA32_TSX_CTRL) is only available after a -* microcode update on CPUs that have their MSR_IA32_ARCH_CAPABILITIES -* bit MDS_NO=1. CPUs with MDS_NO=0 are not planned to get -* MSR_IA32_TSX_CTRL support even after a microcode update. Thus, -* tsx= cmdline requests will do nothing on CPUs without -* MSR_IA32_TSX_CTRL support. -*/ -return !!(ia32_cap &ARCH_CAP_TSX_CTRL_MSR ); -} -static enum tsx_ctrl_states x86_get_tsx_auto_mode (void ) {if (boot_cpu_has_bug (X86_BUG_TAA ))
@@ -89,9 +71,22 @@ void __init tsx_init(void)char arg[5 ] = {};int ret; -if (!tsx_ctrl_is_supported ()) +/* +* TSX is controlled via MSR_IA32_TSX_CTRL. However, support for this +* MSR is enumerated by ARCH_CAP_TSX_MSR bit in MSR_IA32_ARCH_CAPABILITIES. +* +* TSX control (aka MSR_IA32_TSX_CTRL) is only available after a +* microcode update on CPUs that have their MSR_IA32_ARCH_CAPABILITIES +* bit MDS_NO=1. CPUs with MDS_NO=0 are not planned to get +* MSR_IA32_TSX_CTRL support even after a microcode update. Thus, +* tsx= cmdline requests will do nothing on CPUs without +* MSR_IA32_TSX_CTRL support. +*/ +if (!(x86_read_arch_cap_msr () &ARCH_CAP_TSX_CTRL_MSR ))return ; +setup_force_cpu_cap (X86_FEATURE_MSR_TSX_CTRL ); + ret =cmdline_find_option (boot_command_line,"tsx" , arg,sizeof (arg));if (ret >=0 ) {if (!strcmp (arg,"on" )) {
Greg Kroah-Hartman
maintainerPATCH v2 92/92 block: unhash blkdev part inode when the part is deleted
In reply to Greg Kroah-Hartmanv5.11 changes the blkdev lookup mechanism completely since commit 22ae8ce8b892 ("block: simplify bdev/disk lookup in blkdev_get"), and small part of the change is to unhash part bdev inode when deleting partition. Turns out this kind of change does fix one nasty issue in case of BLOCK_EXT_MAJOR:
1) when one partition is deleted & closed, disk_put_part() is always called before bdput(bdev), see blkdev_put(); so the part's devt can be freed & re-used before the inode is dropped
2) then new partition with same devt can be created just before the inode in 1) is dropped, then the old inode/bdev structurein 1) is re-used for this new partition, this way causes use-after-free and kernel panic.
It isn't possible to backport the whole big patchset of "merge struct block_device and struct hd_struct v4" for addressing this issue.
https://lore.kernel.org/linux-block/[email protected]/
So fixes it by unhashing part bdev in delete_partition(), and this way is actually aligned with v5.11+'s behavior.
--- block/partitions/core.c | 7 +++++++ 1 file changed, 7 insertions(+)
block/partitions/core.c +7 -0
@@ -329,6 +329,7 @@ void delete_partition(struct hd_struct *struct gendisk *disk =part_to_disk (part);struct disk_part_tbl *ptbl =rcu_dereference_protected (disk->part_tbl,1 ); +struct block_device *bdev;/* * ->part_tbl is referenced in this part's release handler, so
@@ -346,6 +347,12 @@ void delete_partition(struct hd_struct ** "in-use" until we really free the gendisk. */ blk_invalidate_devt (part_devt (part)); + + bdev =bdget_part (part); +if (bdev) { +remove_inode_hash (bdev->bd_inode); +bdput (bdev); + }percpu_ref_kill (&part->ref); }
Greg Kroah-Hartman
maintainerPATCH 84/92 x86/pm: Add enumeration check before spec MSRs save/restore setup
In reply to Greg Kroah-HartmanFrom: Pawan Gupta <[email protected]>
commit 50bcceb7724e471d9b591803889df45dcbb584bc upstream.
pm_save_spec_msr() keeps a list of all the MSRs which _might_ need to be saved and restored at hibernate and resume. However, it has zero awareness of CPU support for these MSRs. It mostly works by unconditionally attempting to manipulate these MSRs and relying on rdmsrl_safe() being able to handle a #GP on CPUs where the support is unavailable.
However, it's possible for reads (RDMSR) to be supported for a given MSR while writes (WRMSR) are not. In this case, msr_build_context() sees a successful read (RDMSR) and marks the MSR as valid. Then, later, a write (WRMSR) fails, producing a nasty (but harmless) error message. This causes restore_processor_state() to try and restore it, but writing this MSR is not allowed on the Intel Atom N2600 leading to:
unchecked MSR access error: WRMSR to 0x122 (tried to write 0x0000000000000002) \
at rIP: 0xffffffff8b07a574 (native_write_msr+0x4/0x20)
Call Trace:
<TASK>
restore_processor_state
x86_acpi_suspend_lowlevel
acpi_suspend_enter
suspend_devices_and_enter
pm_suspend.cold
state_store
kernfs_fop_write_iter
vfs_write
ksys_write
do_syscall_64
? do_syscall_64
? up_read
? lock_is_held_type
? asm_exc_page_fault
? lockdep_hardirqs_on
entry_SYSCALL_64_after_hwframeTo fix this, add the corresponding X86_FEATURE bit for each MSR. Avoid trying to manipulate the MSR when the feature bit is clear. This required adding a X86_FEATURE bit for MSRs that do not have one already, but it's a small price to pay.
[ bp: Move struct msr_enumeration inside the only function that uses it. ] [Pawan: Resolve build issue in backport]
--- arch/x86/power/cpu.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
arch/x86/power/cpu.c +15 -8
@@ -516,16 +516,23 @@ static int pm_cpu_check(const struct x86static void pm_save_spec_msr (void ) { -u32 spec_msr_id[] = { -MSR_IA32_SPEC_CTRL , -MSR_IA32_TSX_CTRL , -MSR_TSX_FORCE_ABORT , -MSR_IA32_MCU_OPT_CTRL , -MSR_AMD64_LS_CFG , -MSR_AMD64_DE_CFG , +struct msr_enumeration { +u32 msr_no; +u32 feature; + } msr_enum[] = { + {MSR_IA32_SPEC_CTRL ,X86_FEATURE_MSR_SPEC_CTRL }, + {MSR_IA32_TSX_CTRL ,X86_FEATURE_MSR_TSX_CTRL }, + {MSR_TSX_FORCE_ABORT ,X86_FEATURE_TSX_FORCE_ABORT }, + {MSR_IA32_MCU_OPT_CTRL ,X86_FEATURE_SRBDS_CTRL }, + {MSR_AMD64_LS_CFG ,X86_FEATURE_LS_CFG_SSBD }, + {MSR_AMD64_DE_CFG ,X86_FEATURE_LFENCE_RDTSC }, }; +int i; -msr_build_context (spec_msr_id,ARRAY_SIZE (spec_msr_id)); +for (i =0 ; i <ARRAY_SIZE (msr_enum); i++) { +if (boot_cpu_has (msr_enum[i].feature)) +msr_build_context (&msr_enum[i].msr_no,1 ); + } }static int pm_check_save_msr (void )
Greg Kroah-Hartman
maintainerPATCH 85/92 i2c: npcm7xx: Fix error handling in npcm_i2c_init()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit 145900cf91c4b32ac05dbc8675a0c7f4a278749d ]
A problem about i2c-npcm7xx create debugfs failed is triggered with the following log given:
[ 173.827310] debugfs: Directory 'npcm_i2c' with parent '/' already present!
The reason is that npcm_i2c_init() returns platform_driver_register() directly without checking its return value, if platform_driver_register() failed, it returns without destroy the newly created debugfs, resulting the debugfs of npcm_i2c can never be created later.
npcm_i2c_init()
debugfs_create_dir() # create debugfs directory platform_driver_register()
driver_register()
bus_add_driver()
priv = kzalloc(...) # OOM happened
# return without destroy debugfs directory
Fix by removing debugfs when platform_driver_register() returns error.
--- drivers/i2c/busses/i2c-npcm7xx.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-npcm7xx.c +10 -1
@@ -2362,8 +2362,17 @@ static struct platform_driver npcm_i2c_bus_driver = {static int __init npcm_i2c_init (void ) { +int ret; + npcm_i2c_debugfs_dir =debugfs_create_dir ("npcm_i2c" ,NULL ); -return platform_driver_register (&npcm_i2c_bus_driver); + + ret =platform_driver_register (&npcm_i2c_bus_driver); +if (ret) { +debugfs_remove_recursive (npcm_i2c_debugfs_dir); +return ret; + } + +return 0 ; }module_init (npcm_i2c_init);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 86/92 i2c: imx: Only DMA messages with I2C_M_DMA_SAFE flag set
In reply to Greg Kroah-HartmanFrom: Andrew Lunn <[email protected]>
[ Upstream commit d36678f7905cbd1dc55a8a96e066dafd749d4600 ]
Recent changes to the DMA code has resulting in the IMX driver failing I2C transfers when the buffer has been vmalloc. Only perform DMA transfers if the message has the I2C_M_DMA_SAFE flag set, indicating the client is providing a buffer which is DMA safe.
This is a minimal fix for stable. The I2C core provides helpers to allocate a bounce buffer. For a fuller fix the master should make use of these helpers.
--- drivers/i2c/busses/i2c-imx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-imx.c +4 -2
@@ -843,7 +843,8 @@ static int i2c_imx_read(struct imx_i2c_struct *i2c_imx, struct i2c_msg *msgs,int i, result;unsigned int temp;int block_data = msgs->flags &I2C_M_RECV_LEN ; -int use_dma = i2c_imx->dma && msgs->len >=DMA_THRESHOLD && !block_data; +int use_dma = i2c_imx->dma && msgs->flags &I2C_M_DMA_SAFE && + msgs->len >=DMA_THRESHOLD && !block_data; dev_dbg(&i2c_imx->adapter.dev, "<%s> write slave address: addr=0x%x\n",
@@ -1011,7 +1012,8 @@ static int i2c_imx_xfer_common(struct i2c_adapter *adapter, result =i2c_imx_read (i2c_imx, &msgs[i], is_lastmsg, atomic); }else {if (!atomic && - i2c_imx->dma && msgs[i].len >=DMA_THRESHOLD ) + i2c_imx->dma && msgs[i].len >=DMA_THRESHOLD && + msgs[i].flags &I2C_M_DMA_SAFE ) result =i2c_imx_dma_write (i2c_imx, &msgs[i]);else result =i2c_imx_write (i2c_imx, &msgs[i], atomic);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 87/92 ACPI: HMAT: remove unnecessary variable initialization
In reply to Greg Kroah-HartmanFrom: Vishal Verma <[email protected]>
[ Upstream commit 14f16d47561ba9249efc6c2db9d47ed56841f070 ]
In hmat_register_target_initiators(), the variable 'best' gets initialized in the outer per-locality-type for loop. The initialization just before setting up 'Access 1' targets was unnecessary. Remove it.
Stable-dep-of: 48d4180939e1 ("ACPI: HMAT: Fix initiator registration for single-initiator systems")
--- drivers/acpi/numa/hmat.c | 1 - 1 file changed, 1 deletion(-)
drivers/acpi/numa/hmat.c +0 -1
@@ -645,7 +645,6 @@ static void hmat_register_target_initiators(struct memory_target *target)/* Access 1 ignores Generic Initiators */ bitmap_zero (p_nodes,MAX_NUMNODES );list_sort (p_nodes, &initiators, initiator_cmp); - best =0 ;for (i =WRITE_LATENCY ; i <=READ_BANDWIDTH ; i++) { loc = localities_types[i];if (!loc)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 88/92 ACPI: HMAT: Fix initiator registration for single-initiator systems
In reply to Greg Kroah-HartmanFrom: Vishal Verma <[email protected]>
[ Upstream commit 48d4180939e12c4bd2846f984436d895bb9699ed ]
In a system with a single initiator node, and one or more memory-only 'target' nodes, the memory-only node(s) would fail to register their initiator node correctly. i.e. in sysfs:
# ls /sys/devices/system/node/node0/access0/targets/ node0
Where as the correct behavior should be:
# ls /sys/devices/system/node/node0/access0/targets/ node0 node1
This happened because hmat_register_target_initiators() uses list_sort() to sort the initiator list, but the sort comparision function (initiator_cmp()) is overloaded to also set the node mask's bits.
In a system with a single initiator, the list is singular, and list_sort elides the comparision helper call. Thus the node mask never gets set, and the subsequent search for the best initiator comes up empty.
Add a new helper to consume the sorted initiator list, and generate the nodemask, decoupling it from the overloaded initiator_cmp() comparision callback. This prevents the singular list corner case naturally, and makes the code easier to follow as well.
--- drivers/acpi/numa/hmat.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
drivers/acpi/numa/hmat.c +20 -6
@@ -563,17 +563,26 @@ static int initiator_cmp(void *priv, const struct list_head *a, {struct memory_initiator *ia;struct memory_initiator *ib; -unsigned long *p_nodes = priv; ia = list_entry(a, struct memory_initiator, node); ib = list_entry(b, struct memory_initiator, node); -set_bit (ia->processor_pxm, p_nodes); -set_bit (ib->processor_pxm, p_nodes); -return ia->processor_pxm - ib->processor_pxm; } +static int initiators_to_nodemask (unsigned long *p_nodes) +{ +struct memory_initiator *initiator; + +if (list_empty (&initiators)) +return -ENXIO ; + +list_for_each_entry (initiator, &initiators, node) +set_bit (initiator->processor_pxm, p_nodes); + +return 0 ; +} +static void hmat_register_target_initiators (struct memory_target *target) { static DECLARE_BITMAP(p_nodes, MAX_NUMNODES);
@@ -610,7 +619,10 @@ static void hmat_register_target_initiators(struct memory_target *target)* initiators. */ bitmap_zero (p_nodes,MAX_NUMNODES ); -list_sort (p_nodes, &initiators, initiator_cmp); +list_sort (NULL , &initiators, initiator_cmp); +if (initiators_to_nodemask (p_nodes) <0 ) +return ; +if (!access0done) {for (i =WRITE_LATENCY ; i <=READ_BANDWIDTH ; i++) { loc = localities_types[i];
@@ -644,7 +656,9 @@ static void hmat_register_target_initiators(struct memory_target *target)/* Access 1 ignores Generic Initiators */ bitmap_zero (p_nodes,MAX_NUMNODES ); -list_sort (p_nodes, &initiators, initiator_cmp); +if (initiators_to_nodemask (p_nodes) <0 ) +return ; +for (i =WRITE_LATENCY ; i <=READ_BANDWIDTH ; i++) { loc = localities_types[i];if (!loc)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 89/92 Revert "clocksource/drivers/riscv: Events are stopped during CPU suspend"
In reply to Greg Kroah-HartmanFrom: Conor Dooley <[email protected]>
[ Upstream commit d9f15a9de44affe733e34f93bc184945ba277e6d ]
This reverts commit 232ccac1bd9b5bfe73895f527c08623e7fa0752d.
On the subject of suspend, the RISC-V SBI spec states:
This does not cover whether any given events actually reach the hart or not, just what the hart will do if it receives an event. On PolarFire SoC, and potentially other SiFive based implementations, events from the RISC-V timer do reach a hart during suspend. This is not the case for the implementation on the Allwinner D1 - there timer events are not received during suspend.
To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the timer driver - but this has broken both RCU stall detection and timers generally on PolarFire SoC and potentially other SiFive based implementations.
If an AXI read to the PCIe controller on PolarFire SoC times out, the system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system just locks up without RCU stalling:
io scheduler mq-deadline registered
io scheduler kyber registered
microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
microchip-pcie 2000000000.pcie: MEM 0x2008000000..0x2087ffffff -> 0x0008000000
microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer microchip-pcie 2000000000.pcie: axi read request error microchip-pcie 2000000000.pcie: axi read timeout microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer Freeing initrd memory: 7332K
Similarly issues were reported with clock_nanosleep() - with a test app that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed commit in place, the sleep times are rounded up to the next jiffy:
== CPU: 1 == == CPU: 2 == == CPU: 3 == == CPU: 4 == Mean: 7.974992 Mean: 7.976534 Mean: 7.962591 Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000 Hi: 10.495000 Hi: 8.864000 Hi: 4.736000
Lo: 6.087000 Lo: 6.380000 Lo: 4.872000 Lo: 3.403000
Samples: 521 Samples: 521 Samples: 521 Samples: 521
Fortunately, the D1 has a second timer, which is "currently used in preference to the RISC-V/SBI timer driver" so a revert here does not hurt operation of D1 in its current form.
Ultimately, a DeviceTree property (or node) will be added to encode the behaviour of the timers, but until then revert the addition of CLOCK_EVT_FEAT_C3STOP.
--- drivers/clocksource/timer-riscv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/timer-riscv.c +1 -1
@@ -32,7 +32,7 @@ static int riscv_clock_next_event(unsigned long delta,static unsigned int riscv_clock_event_irq; static DEFINE_PER_CPU(struct clock_event_device, riscv_clock_event) = { .name ="riscv_timer_clockevent" , - .features =CLOCK_EVT_FEAT_ONESHOT |CLOCK_EVT_FEAT_C3STOP , + .features =CLOCK_EVT_FEAT_ONESHOT , .rating =100 , .set_next_event = riscv_clock_next_event, };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 90/92 char: tpm: Protect tpm_pm_suspend with locks
In reply to Greg Kroah-HartmanFrom: Jan Dabros <[email protected]>
commit 23393c6461422df5bf8084a086ada9a7e17dc2ba upstream.
Currently tpm transactions are executed unconditionally in tpm_pm_suspend() function, which may lead to races with other tpm accessors in the system.
Specifically, the hw_random tpm driver makes use of tpm_get_random(), and this function is called in a loop from a kthread, which means it's not frozen alongside userspace, and so can race with the work done during system suspend:
tpm tpm0: tpm_transmit: tpm_recv: error -52
tpm tpm0: invalid TPM_STS.x 0xff, dumping stack for forensics
CPU: 0 PID: 1 Comm: init Not tainted 6.1.0-rc5+ #135 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.0-20220807_005459-localhost 04/01/2014 Call Trace: tpm_tis_status.cold+0x19/0x20 tpm_transmit+0x13b/0x390 tpm_transmit_cmd+0x20/0x80 tpm1_pm_suspend+0xa6/0x110 tpm_pm_suspend+0x53/0x80 __pnp_bus_suspend+0x35/0xe0 __device_suspend+0x10f/0x350
Fix this by calling tpm_try_get_ops(), which itself is a wrapper around tpm_chip_start(), but takes the appropriate mutex.
--- drivers/char/tpm/tpm-interface.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/char/tpm/tpm-interface.c +3 -2
@@ -401,13 +401,14 @@ int tpm_pm_suspend(struct device *dev) !pm_suspend_via_firmware()) goto suspended; -if (!tpm_chip_start (chip)) { + rc =tpm_try_get_ops (chip); +if (!rc) {if (chip->flags &TPM_CHIP_FLAG_TPM2 )tpm2_shutdown (chip,TPM2_SU_STATE );else rc =tpm1_pm_suspend (chip, tpm_suspend_pcr); -tpm_chip_stop (chip); +tpm_put_ops (chip); } suspended:
Greg Kroah-Hartman
maintainerPATCH 91/92 Input: raydium_ts_i2c - fix memory leak in raydium_i2c_send()
In reply to Greg Kroah-HartmanFrom: Zhang Xiaoxu <[email protected]>
commit 8c9a59939deb4bfafdc451100c03d1e848b4169b upstream.
There is a kmemleak when test the raydium_i2c_ts with bpf mock device:
unreferenced object 0xffff88812d3675a0 (size 8):
comm "python3", pid 349, jiffies 4294741067 (age 95.695s)
hex dump (first 8 bytes):
11 0e 10 c0 01 00 04 00 ........
backtrace:
[<0000000068427125>] __kmalloc+0x46/0x1b0
[<0000000090180f91>] raydium_i2c_send+0xd4/0x2bf [raydium_i2c_ts]
[<000000006e631aee>] raydium_i2c_initialize.cold+0xbc/0x3e4 [raydium_i2c_ts]
[<00000000dc6fcf38>] raydium_i2c_probe+0x3cd/0x6bc [raydium_i2c_ts]
[<00000000a310de16>] i2c_device_probe+0x651/0x680
[<00000000f5a96bf3>] really_probe+0x17c/0x3f0
[<00000000096ba499>] __driver_probe_device+0xe3/0x170
[<00000000c5acb4d9>] driver_probe_device+0x49/0x120
[<00000000264fe082>] __device_attach_driver+0xf7/0x150
[<00000000f919423c>] bus_for_each_drv+0x114/0x180
[<00000000e067feca>] __device_attach+0x1e5/0x2d0
[<0000000054301fc2>] bus_probe_device+0x126/0x140
[<00000000aad93b22>] device_add+0x810/0x1130
[<00000000c086a53f>] i2c_new_client_device+0x352/0x4e0
[<000000003c2c248c>] of_i2c_register_device+0xf1/0x110
[<00000000ffec4177>] of_i2c_notify+0x100/0x160
unreferenced object 0xffff88812d3675c8 (size 8):
comm "python3", pid 349, jiffies 4294741070 (age 95.692s)
hex dump (first 8 bytes):
22 00 36 2d 81 88 ff ff ".6-....
backtrace:
[<0000000068427125>] __kmalloc+0x46/0x1b0
[<0000000090180f91>] raydium_i2c_send+0xd4/0x2bf [raydium_i2c_ts]
[<000000001d5c9620>] raydium_i2c_initialize.cold+0x223/0x3e4 [raydium_i2c_ts]
[<00000000dc6fcf38>] raydium_i2c_probe+0x3cd/0x6bc [raydium_i2c_ts]
[<00000000a310de16>] i2c_device_probe+0x651/0x680
[<00000000f5a96bf3>] really_probe+0x17c/0x3f0
[<00000000096ba499>] __driver_probe_device+0xe3/0x170
[<00000000c5acb4d9>] driver_probe_device+0x49/0x120
[<00000000264fe082>] __device_attach_driver+0xf7/0x150
[<00000000f919423c>] bus_for_each_drv+0x114/0x180
[<00000000e067feca>] __device_attach+0x1e5/0x2d0
[<0000000054301fc2>] bus_probe_device+0x126/0x140
[<00000000aad93b22>] device_add+0x810/0x1130
[<00000000c086a53f>] i2c_new_client_device+0x352/0x4e0
[<000000003c2c248c>] of_i2c_register_device+0xf1/0x110
[<00000000ffec4177>] of_i2c_notify+0x100/0x160After BANK_SWITCH command from i2c BUS, no matter success or error happened, the tx_buf should be freed.
--- drivers/input/touchscreen/raydium_i2c_ts.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/input/touchscreen/raydium_i2c_ts.c +3 -1
@@ -210,12 +210,14 @@ static int raydium_i2c_send(struct i2c_c error =raydium_i2c_xfer (client, addr, xfer,ARRAY_SIZE (xfer));if (likely (!error)) -return 0 ; + goto out;msleep (RM_RETRY_DELAY_MS ); }while (++tries <RM_MAX_RETRIES );dev_err (&client->dev,"%s failed: %d\n" , __func__, error); +out: +kfree (tx_buf);return error; }
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.158 release. There are 92 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, 07 Dec 2022 19:07:46 +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.10.158-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.10.y
and the diffstat can be found below.thanks,
greg k-h
On ARCH_BRCMSTB using 32-bit and 64-bit ARM kernels, build tested on BMIPS_GENERIC:
Signature · 1 line
Florian
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.158 release. There are 92 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, 07 Dec 2022 19:07:46 +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.10.158-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.10.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Hi!
Quoted 4 lines
This is the start of the stable review cycle for the 5.10.158 release. There are 92 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.
CIP testing did not find any problems here:
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/tree/linux-5.10.y
Best regards,
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Quoted 7 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.158 release. There are 92 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, 07 Dec 2022 19:07:46 +0000. Anything received after that time might be too late.
Hi Greg,
5.10.158-rc1 tested.
Run tested on:
- Intel Skylake x86_64 (nuc6 i5-6260U)
In addition - build tested for:
- Allwinner A64
- Allwinner H3
- Allwinner H5
- Allwinner H6
- Rockchip RK3288
- Rockchip RK3328
- Rockchip RK3399pro
--
Rudi
Quoted 14 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.10.158 release. There are 92 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, 07 Dec 2022 19:07:46 +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.10.158-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.10.y
and the diffstat can be found below.
Quoted 5 lines
thanks,
greg k-h
-------------
Tested on arm64 and x86 for 5.10.158-rc2,
Kernel repo:https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
Branch: linux-5.10.y
Version: 5.10.158-rc2
Commit: 8dca57ec68a7eca30ce178d858b45748b2a65eaf
Compiler: gcc version 7.3.0 (GCC)
arm64:
--------------------------------------------------------------------
Testcase Result Summary:
total: 9023
passed: 9023
failed: 0
timeout: 0
--------------------------------------------------------------------
x86:
--------------------------------------------------------------------
Testcase Result Summary:
total: 9023
passed: 9023
failed: 0
timeout: 0
--------------------------------------------------------------------