5.15.82-rc1 review
Greg Kroah-Hartman
maintainercover 5.15.82-rc1 review
This is the start of the stable review cycle for the 5.15.82 release. There are 120 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.15.82-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.15.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 5.15.82-rc1
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()
Lukas Wunner <[email protected]>
serial: stm32: Deassert Transmit Enable on ->rs485_config()
Marek Vasut <[email protected]>
serial: stm32: Use TC interrupt to deassert GPIO RTS in RS485 mode
Marek Vasut <[email protected]>
serial: stm32: Factor out GPIO RTS toggling into separate function
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
Gavin Shan <[email protected]>
mm: migrate: fix THP's mapcount on isolation
Hugh Dickins <[email protected]>
mm: __isolate_lru_page_prepare() in isolate_migratepages_block()
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()
Caleb Sander <[email protected]>
nvme: fix SRCU protection of nvme_ns_head list
Guo Ren <[email protected]>
riscv: kexec: Fixup crash_smp_send_stop without multi cores
Guo Ren <[email protected]>
riscv: kexec: Fixup irq controller broken in kexec crash path
Jisheng Zhang <[email protected]>
riscv: fix race when vmap stack overflow
Alexandre Ghiti <[email protected]>
riscv: Sync efi page table's kernel mappings before switching
Maxim Korotkov <[email protected]>
pinctrl: single: Fix potential division by zero
Mark Brown <[email protected]>
ASoC: ops: Fix bounds check for _sx controls
Kazuki Takiguchi <[email protected]>
KVM: x86/mmu: Fix race condition in direct_page_fault
Lin Ma <[email protected]>
io_uring/poll: fix poll_refs race with cancelation
Pavel Begunkov <[email protected]>
io_uring: make poll refs more robust
Pavel Begunkov <[email protected]>
io_uring: cmpxchg for poll arm refs release
Pavel Begunkov <[email protected]>
io_uring: fix tw losing poll events
Pavel Begunkov <[email protected]>
io_uring: update res mask in io_poll_check_events
Steven Rostedt (Google) <[email protected]>
tracing: Free buffers when a used dynamic event is removed
Steven Rostedt (Google) <[email protected]>
tracing: Fix race where histograms can be called before the event
Daniel Bristot de Oliveira <[email protected]>
tracing/osnoise: Fix duration type
Janusz Krzysztofik <[email protected]>
drm/i915: Never return 0 if not all requests retired
Janusz Krzysztofik <[email protected]>
drm/i915: Fix negative value passed as remaining time
Leo Liu <[email protected]>
drm/amdgpu: enable Vangogh VCN indirect sram mode
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
Linus Torvalds <[email protected]>
v4l2: don't fall back to follow_pfn() if pin_user_pages_fast() fails
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
Takashi Sakamoto <[email protected]>
ALSA: dice: fix regression for Lexicon I-ONIX FW810S
Björn Töpel <[email protected]>
riscv: mm: Proper page permissions after initmem free
Jisheng Zhang <[email protected]>
riscv: vdso: fix section overlapping under some conditions
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
Yang Yingliang <[email protected]>
net: mdiobus: fix unbalanced node reference count
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
M Chetan Kumar <[email protected]>
net: wwan: iosm: fix dma_alloc_coherent incompatible pointer type
M Chetan Kumar <[email protected]>
net: wwan: iosm: fix kernel test robot reported error
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()
Zhang Changzhong <[email protected]>
net: ethernet: ti: am65-cpsw: fix error handling in am65_cpsw_nuss_probe()
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
Jiasheng Jiang <[email protected]>
can: m_can: Add check for devm_clk_get
Zhang Changzhong <[email protected]>
can: m_can: pci: add missing m_can_class_free_dev() in probe/remove methods
Zhang Changzhong <[email protected]>
can: etas_es58x: es58x_init_netdev(): free netdev when register_candev()
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()
YueHaibing <[email protected]>
net/mlx5: DR, Fix uninitialized var warning
Yevgeny Kliteynik <[email protected]>
net/mlx5: DR, Rename list field in matcher struct to list_node
Wang Hai <[email protected]>
e100: Fix possible use after free in e100_xmit_prepare
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()
Wei Yongjun <[email protected]>
nvmem: rmem: Fix return value check in rmem_read()
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
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
ChenXiaoSong <[email protected]>
btrfs: qgroup: fix sleep from invalid context bug in btrfs_qgroup_inherit()
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
Gao Xiang <[email protected]>
erofs: fix order >= MAX_ORDER warning due to crafted negative i_size
Chris Wilson <[email protected]>
drm/i915/gt: Use i915_vm_put on ppgtt_create error paths
Maarten Lankhorst <[email protected]>
drm/i915: Create a dummy object for gen6 ppgtt
Catalin Marinas <[email protected]>
arm64: mte: Avoid setting PG_mte_tagged if no tags cleared or restored
-------------
Diffstat:
Makefile | 4 +- arch/arm/boot/dts/at91rm9200.dtsi | 2 +- arch/arm64/kernel/mte.c | 9 +- arch/arm64/mm/mteswap.c | 7 +- arch/riscv/include/asm/asm.h | 1 + arch/riscv/include/asm/efi.h | 6 +- arch/riscv/include/asm/pgalloc.h | 11 +- arch/riscv/include/asm/smp.h | 3 + arch/riscv/kernel/entry.S | 13 ++ arch/riscv/kernel/machine_kexec.c | 46 +++++-- arch/riscv/kernel/setup.c | 9 +- arch/riscv/kernel/smp.c | 93 +++++++++++++- arch/riscv/kernel/traps.c | 18 +++ arch/riscv/kernel/vdso/Makefile | 1 + arch/x86/include/asm/nospec-branch.h | 2 +- arch/x86/kernel/cpu/bugs.c | 21 ++-- arch/x86/kernel/process.c | 2 +- arch/x86/kvm/mmu/mmu.c | 12 +- 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/amdgpu/amdgpu_vcn.c | 3 + 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/gem/i915_gem_internal.c | 44 ++++--- drivers/gpu/drm/i915/gt/gen6_ppgtt.c | 137 ++++++++++++--------- drivers/gpu/drm/i915/gt/gen6_ppgtt.h | 1 - drivers/gpu/drm/i915/gt/gen8_ppgtt.c | 56 +++++---- drivers/gpu/drm/i915/gt/intel_gt.c | 9 +- drivers/gpu/drm/i915/gt/intel_gt_requests.c | 2 +- drivers/gpu/drm/i915/gt/intel_gtt.c | 3 + drivers/gpu/drm/i915/i915_drv.h | 4 + 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/media/common/videobuf2/frame_vector.c | 53 ++------ 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/m_can/m_can.c | 2 +- drivers/net/can/m_can/m_can_pci.c | 9 +- drivers/net/can/sja1000/sja1000_isa.c | 10 +- drivers/net/can/usb/etas_es58x/es58x_core.c | 5 +- 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 | 5 +- 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_matcher.c | 26 ++-- .../mellanox/mlx5/core/steering/dr_table.c | 7 +- .../mellanox/mlx5/core/steering/dr_types.h | 2 +- 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/ethernet/ti/am65-cpsw-nuss.c | 2 +- drivers/net/mdio/fwnode_mdio.c | 2 +- drivers/net/ntb_netdev.c | 9 +- drivers/net/phy/phy_device.c | 2 + drivers/net/tun.c | 4 +- drivers/net/wwan/iosm/iosm_ipc_mux_codec.c | 3 +- drivers/net/wwan/iosm/iosm_ipc_protocol.h | 2 +- drivers/nvme/host/core.c | 2 +- drivers/nvme/host/multipath.c | 3 + drivers/nvmem/rmem.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/serial/stm32-usart.c | 131 ++++++++++++++------ drivers/tty/serial/stm32-usart.h | 1 + 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/erofs/inode.c | 2 +- fs/io_uring.c | 57 +++++++-- fs/nilfs2/dat.c | 7 ++ include/linux/license.h | 2 + include/linux/mmc/mmc.h | 2 +- include/linux/swap.h | 1 - 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 +- kernel/trace/trace_events_hist.c | 3 + kernel/trace/trace_osnoise.c | 6 +- lib/Kconfig.debug | 14 ++- mm/compaction.c | 67 +++++++--- mm/vmscan.c | 101 +++------------ 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/firewire/dice/dice-stream.c | 12 +- 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 +- 133 files changed, 1132 insertions(+), 554 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/120 arm64: mte: Avoid setting PG_mte_tagged if no tags cleared or restored
From: Catalin Marinas <[email protected]>
[ Upstream commit a8e5e5146ad08d794c58252bab00b261045ef16d ]
Prior to commit 69e3b846d8a7 ("arm64: mte: Sync tags for pages where PTE is untagged"), mte_sync_tags() was only called for pte_tagged() entries (those mapped with PROT_MTE). Therefore mte_sync_tags() could safely use test_and_set_bit(PG_mte_tagged, &page->flags) without inadvertently setting PG_mte_tagged on an untagged page.
The above commit was required as guests may enable MTE without any control at the stage 2 mapping, nor a PROT_MTE mapping in the VMM. However, the side-effect was that any page with a PTE that looked like swap (or migration) was getting PG_mte_tagged set automatically. A subsequent page copy (e.g. migration) copied the tags to the destination page even if the tags were owned by KASAN.
This issue was masked by the page_kasan_tag_reset() call introduced in commit e5b8d9218951 ("arm64: mte: reset the page tag in page->flags"). When this commit was reverted (20794545c146), KASAN started reporting access faults because the overriding tags in a page did not match the original page->flags (with CONFIG_KASAN_HW_TAGS=y):
BUG: KASAN: invalid-access in copy_page+0x10/0xd0 arch/arm64/lib/copy_page.S:26 Read at addr f5ff000017f2e000 by task syz-executor.1/2218 Pointer tag: [f5], memory tag: [f2]
Move the PG_mte_tagged bit setting from mte_sync_tags() to the actual place where tags are cleared (mte_sync_page_tags()) or restored (mte_restore_tags()).
--- arch/arm64/kernel/mte.c | 9 +++++++-- arch/arm64/mm/mteswap.c | 7 ++++++- 2 files changed, 13 insertions(+), 3 deletions(-)
arch/arm64/kernel/mte.c +7 -2
@@ -53,7 +53,12 @@ static void mte_sync_page_tags(struct page *page, pte_t old_pte,* the new page->flags are visible before the tags were updated. */ smp_wmb (); -mte_clear_page_tags (page_address (page)); +/* +* Test PG_mte_tagged again in case it was racing with another +* set_pte_at(). +*/ +if (!test_and_set_bit (PG_mte_tagged, &page->flags)) +mte_clear_page_tags (page_address (page)); }void mte_sync_tags (pte_t old_pte,pte_t pte)
@@ -69,7 +74,7 @@ void mte_sync_tags(pte_t old_pte, pte_t pte)/* if PG_mte_tagged is set, tags have already been initialised */ for (i =0 ; i < nr_pages; i++, page++) { -if (!test_and_set_bit (PG_mte_tagged, &page->flags)) +if (!test_bit (PG_mte_tagged, &page->flags))mte_sync_page_tags (page, old_pte, check_swap, pte_is_tagged); }
arch/arm64/mm/mteswap.c +6 -1
@@ -62,7 +62,12 @@ bool mte_restore_tags(swp_entry_t entry, struct page *page)* the new page->flags are visible before the tags were updated. */ smp_wmb (); -mte_restore_page_tags (page_address (page), tags); +/* +* Test PG_mte_tagged again in case it was racing with another +* set_pte_at(). +*/ +if (!test_and_set_bit (PG_mte_tagged, &page->flags)) +mte_restore_page_tags (page_address (page), tags);return true; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 2/120 drm/i915: Create a dummy object for gen6 ppgtt
In reply to Greg Kroah-HartmanFrom: Maarten Lankhorst <[email protected]>
[ Upstream commit b0b0f2d225da6fe58417fae37e3f797e2db27b62 ]
We currently have to special case vma->obj being NULL because of gen6 ppgtt and mock_engine. Fix gen6 ppgtt, so we may soon be able to remove a few checks. As the object only exists as a fake object pointing to ggtt, we have no backing storage, so no real object is created. It just has to look real enough.
Also kill pin_mutex, it's not compatible with ww locking, and we can use the vm lock instead.
v2:
- Drop IS_SHRINKABLE and shorten overly long line
v3:
- Checkpatch fix for alignment
Stable-dep-of: 20e377e7b2e7 ("drm/i915/gt: Use i915_vm_put on ppgtt_create error paths")
--- drivers/gpu/drm/i915/gem/i915_gem_internal.c | 44 ++++--- drivers/gpu/drm/i915/gt/gen6_ppgtt.c | 123 +++++++++++-------- drivers/gpu/drm/i915/gt/gen6_ppgtt.h | 1 - drivers/gpu/drm/i915/i915_drv.h | 4 + 4 files changed, 100 insertions(+), 72 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_internal.c +26 -18
@@ -143,24 +143,10 @@ static const struct drm_i915_gem_object_ops i915_gem_object_internal_ops = { .put_pages = i915_gem_object_put_pages_internal, }; -/** -* i915_gem_object_create_internal: create an object with volatile pages -* @i915: the i915 device -* @size: the size in bytes of backing storage to allocate for the object -* -* Creates a new object that wraps some internal memory for private use. -* This object is not backed by swappable storage, and as such its contents -* are volatile and only valid whilst pinned. If the object is reaped by the -* shrinker, its pages and data will be discarded. Equally, it is not a full -* GEM object and so not valid for access from userspace. This makes it useful -* for hardware interfaces like ringbuffers (which are pinned from the time -* the request is written to the time the hardware stops accessing it), but -* not for contexts (which need to be preserved when not active for later -* reuse). Note that it is not cleared upon allocation. -*/ struct drm_i915_gem_object * -i915_gem_object_create_internal (struct drm_i915_private *i915, -phys_addr_t size) +__i915_gem_object_create_internal (struct drm_i915_private *i915, +const struct drm_i915_gem_object_ops *ops, +phys_addr_t size) {static struct lock_class_key lock_class;struct drm_i915_gem_object *obj;
@@ -177,7 +163,7 @@ i915_gem_object_create_internal(struct drm_i915_private *i915,return ERR_PTR (-ENOMEM );drm_gem_private_object_init (&i915->drm, &obj->base, size); -i915_gem_object_init (obj, &i915_gem_object_internal_ops, &lock_class,0 ); +i915_gem_object_init (obj, ops, &lock_class,0 ); obj->mem_flags |=I915_BO_FLAG_STRUCT_PAGE ;/*
@@ -197,3 +183,25 @@ i915_gem_object_create_internal(struct drm_i915_private *i915,return obj; } + +/** +* i915_gem_object_create_internal: create an object with volatile pages +* @i915: the i915 device +* @size: the size in bytes of backing storage to allocate for the object +* +* Creates a new object that wraps some internal memory for private use. +* This object is not backed by swappable storage, and as such its contents +* are volatile and only valid whilst pinned. If the object is reaped by the +* shrinker, its pages and data will be discarded. Equally, it is not a full +* GEM object and so not valid for access from userspace. This makes it useful +* for hardware interfaces like ringbuffers (which are pinned from the time +* the request is written to the time the hardware stops accessing it), but +* not for contexts (which need to be preserved when not active for later +* reuse). Note that it is not cleared upon allocation. +*/ +struct drm_i915_gem_object * +i915_gem_object_create_internal (struct drm_i915_private *i915, +phys_addr_t size) +{ +return __i915_gem_object_create_internal (i915, &i915_gem_object_internal_ops, size); +}
drivers/gpu/drm/i915/gt/gen6_ppgtt.c +70 -53
180 lines not on this page · raw message
drivers/gpu/drm/i915/gt/gen6_ppgtt.h +0 -1
@@ -19,7 +19,6 @@ struct gen6_ppgtt {u32 pp_dir;atomic_t pin_count; -struct mutex pin_mutex;bool scan_for_unused_pt; };
drivers/gpu/drm/i915/i915_drv.h +4 -0
@@ -1905,6 +1905,10 @@ int i915_gem_evict_vm(struct i915_address_space *vm);struct drm_i915_gem_object *i915_gem_object_create_internal (struct drm_i915_private *dev_priv,phys_addr_t size); +struct drm_i915_gem_object * +__i915_gem_object_create_internal (struct drm_i915_private *dev_priv, +const struct drm_i915_gem_object_ops *ops, +phys_addr_t size);/* i915_gem_tiling.c */ static inline bool i915_gem_object_needs_bit17_swizzle (struct drm_i915_gem_object *obj)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 3/120 drm/i915/gt: Use i915_vm_put on ppgtt_create error paths
In reply to Greg Kroah-HartmanFrom: Chris Wilson <[email protected]>
[ Upstream commit 20e377e7b2e7c327039f10db80ba5bcc1f6c882d ]
Now that the scratch page and page directories have a reference back to the i915_address_space, we cannot do an immediate free of the ppgtt upon error as those buffer objects will perform a later i915_vm_put in their deferred frees.
The downside is that by replacing the onion unwind along the error paths, the ppgtt cleanup must handle a partially constructed vm. This includes ensuring that the vm->cleanup is set prior to the error path.
--- drivers/gpu/drm/i915/gt/gen6_ppgtt.c | 16 ++++---- drivers/gpu/drm/i915/gt/gen8_ppgtt.c | 56 ++++++++++++++-------------- drivers/gpu/drm/i915/gt/intel_gtt.c | 3 ++ 3 files changed, 40 insertions(+), 35 deletions(-)
drivers/gpu/drm/i915/gt/gen6_ppgtt.c +8 -8
@@ -244,6 +244,7 @@ static int gen6_ppgtt_init_scratch(struct gen6_ppgtt *ppgtt)i915_gem_object_put (vm->scratch[1 ]); err_scratch0:i915_gem_object_put (vm->scratch[0 ]); + vm->scratch[0 ] =NULL ;return ret; }
@@ -265,9 +266,10 @@ static void gen6_ppgtt_cleanup(struct i915_address_space *vm)gen6_ppgtt_free_pd (ppgtt);free_scratch (vm); -mutex_destroy (&ppgtt->flush); +if (ppgtt->base.pd) +free_pd (&ppgtt->base.vm, ppgtt->base.pd); -free_pd (&ppgtt->base.vm, ppgtt->base.pd); +mutex_destroy (&ppgtt->flush); }static int pd_vma_set_pages (struct i915_vma *vma)
@@ -470,19 +472,17 @@ struct i915_ppgtt *gen6_ppgtt_create(struct intel_gt *gt) err =gen6_ppgtt_init_scratch (ppgtt);if (err) - goto err_free; + goto err_put; ppgtt->base.pd =gen6_alloc_top_pd (ppgtt);if (IS_ERR (ppgtt->base.pd)) { err =PTR_ERR (ppgtt->base.pd); - goto err_scratch; + goto err_put; }return &ppgtt->base; -err_scratch: -free_scratch (&ppgtt->base.vm); -err_free: -kfree (ppgtt); +err_put: +i915_vm_put (&ppgtt->base.vm);return ERR_PTR (err); }
drivers/gpu/drm/i915/gt/gen8_ppgtt.c +29 -27
101 lines not on this page · raw message
drivers/gpu/drm/i915/gt/intel_gtt.c +3 -0
@@ -341,6 +341,9 @@ void free_scratch(struct i915_address_space *vm) {int i; +if (!vm->scratch[0 ]) +return ; +for (i =0 ; i <= vm->top; i++)i915_gem_object_put (vm->scratch[i]); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 4/120 erofs: fix order >= MAX_ORDER warning due to crafted negative i_size
In reply to Greg Kroah-HartmanFrom: Gao Xiang <[email protected]>
[ Upstream commit 1dd73601a1cba37a0ed5f89a8662c90191df5873 ]
As syzbot reported [1], the root cause is that i_size field is a signed type, and negative i_size is also less than EROFS_BLKSIZ. As a consequence, it's handled as fast symlink unexpectedly.
Let's fall back to the generic path to deal with such unusual i_size.
[1] https://lore.kernel.org/r/[email protected]
--- fs/erofs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/erofs/inode.c +1 -1
@@ -222,7 +222,7 @@ static int erofs_fill_symlink(struct inode *inode, void *data,/* if it cannot be handled with fast symlink scheme */ if (vi->datalayout !=EROFS_INODE_FLAT_INLINE || - inode->i_size >=PAGE_SIZE ) { + inode->i_size >=PAGE_SIZE || inode->i_size <0 ) { inode->i_op = &erofs_symlink_iops;return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 5/120 btrfs: sink iterator parameter to btrfs_ioctl_logical_to_ino
In reply to Greg Kroah-HartmanFrom: 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
@@ -3911,26 +3911,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) {
@@ -3980,7 +3960,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 6/120 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
@@ -3946,21 +3946,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 )
@@ -3972,7 +3971,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 7/120 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
@@ -439,8 +439,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 8/120 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
@@ -3280,7 +3280,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)
@@ -3310,11 +3311,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
@@ -3328,7 +3327,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 9/120 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
@@ -2903,14 +2903,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/120 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
@@ -5285,7 +5285,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 11/120 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 12/120 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
@@ -2997,13 +2997,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 13/120 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 14/120 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 15/120 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 16/120 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 17/120 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
@@ -9077,7 +9077,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 18/120 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 19/120 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
@@ -40,7 +40,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 20/120 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 libbpf_err (-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 21/120 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 22/120 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
@@ -228,7 +228,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 23/120 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 24/120 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 25/120 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
@@ -71,7 +71,7 @@ bpf_selem_alloc(struct bpf_local_storage_map *smap, void *owner, 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 26/120 nvmem: rmem: Fix return value check in rmem_read()
In reply to Greg Kroah-HartmanFrom: Wei Yongjun <[email protected]>
[ Upstream commit 58e92c4a496b27156020a59a98c7f4a92c2b1533 ]
In case of error, the function memremap() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.
--- drivers/nvmem/rmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvmem/rmem.c +2 -2
@@ -37,9 +37,9 @@ static int rmem_read(void *context, unsigned int offset,* but as of Dec 2020 this isn't possible on arm64. */ addr =memremap (priv->mem->base, available,MEMREMAP_WB ); -if (IS_ERR (addr)) { +if (!addr) {dev_err (priv->dev,"Failed to remap memory region\n" ); -return PTR_ERR (addr); +return -ENOMEM ; } count =memory_read_from_buffer (val, bytes, &off, addr, available);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 27/120 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
@@ -975,8 +975,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 28/120 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
@@ -4859,6 +4859,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);
@@ -4867,7 +4869,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 29/120 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
@@ -16494,6 +16494,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);
@@ -16511,7 +16513,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 30/120 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 31/120 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
@@ -1448,7 +1448,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 */
@@ -1464,9 +1463,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); }/**
@@ -4343,8 +4341,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);
@@ -4355,8 +4351,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 32/120 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
@@ -4341,6 +4341,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);
@@ -4351,7 +4353,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 33/120 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 34/120 net/mlx5: DR, Rename list field in matcher struct to list_node
In reply to Greg Kroah-HartmanFrom: Yevgeny Kliteynik <[email protected]>
[ Upstream commit 08fac109f7bb5e12ae14def56b3ad57ce67cd9fe ]
In dr_types structs, some list fields are list heads, and some are just list nodes that are stored on the other structs' lists. Rename the appropriate list field to reflect this distinction.
Stable-dep-of: 52f7cf70eb8f ("net/mlx5: DR, Fix uninitialized var warning")
--- .../mellanox/mlx5/core/steering/dr_matcher.c | 26 +++++++++---------- .../mellanox/mlx5/core/steering/dr_table.c | 2 +- .../mellanox/mlx5/core/steering/dr_types.h | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_matcher.c +13 -13
@@ -709,7 +709,7 @@ static int dr_matcher_add_to_tbl(struct mlx5dr_matcher *matcher)int ret; next_matcher =NULL ; -list_for_each_entry (tmp_matcher, &tbl->matcher_list, matcher_list) { +list_for_each_entry (tmp_matcher, &tbl->matcher_list, list_node) {if (tmp_matcher->prio >= matcher->prio) { next_matcher = tmp_matcher;break ;
@@ -719,11 +719,11 @@ static int dr_matcher_add_to_tbl(struct mlx5dr_matcher *matcher) prev_matcher =NULL ;if (next_matcher && !first) - prev_matcher =list_prev_entry (next_matcher, matcher_list); + prev_matcher =list_prev_entry (next_matcher, list_node);else if (!first) prev_matcher =list_last_entry (&tbl->matcher_list, struct mlx5dr_matcher, - matcher_list); + list_node);if (dmn->type ==MLX5DR_DOMAIN_TYPE_FDB || dmn->type ==MLX5DR_DOMAIN_TYPE_NIC_RX ) {
@@ -744,12 +744,12 @@ static int dr_matcher_add_to_tbl(struct mlx5dr_matcher *matcher) }if (prev_matcher) -list_add (&matcher->matcher_list, &prev_matcher->matcher_list); +list_add (&matcher->list_node, &prev_matcher->list_node);else if (next_matcher) -list_add_tail (&matcher->matcher_list, - &next_matcher->matcher_list); +list_add_tail (&matcher->list_node, + &next_matcher->list_node);else -list_add (&matcher->matcher_list, &tbl->matcher_list); +list_add (&matcher->list_node, &tbl->matcher_list);return 0 ; }
@@ -922,7 +922,7 @@ mlx5dr_matcher_create(struct mlx5dr_table *tbl, matcher->prio = priority; matcher->match_criteria = match_criteria_enable;refcount_set (&matcher->refcount,1 ); -INIT_LIST_HEAD (&matcher->matcher_list); +INIT_LIST_HEAD (&matcher->list_node);mlx5dr_domain_lock (tbl->dmn);
@@ -985,15 +985,15 @@ static int dr_matcher_remove_from_tbl(struct mlx5dr_matcher *matcher)struct mlx5dr_domain *dmn = tbl->dmn;int ret =0 ; -if (list_is_last (&matcher->matcher_list, &tbl->matcher_list)) +if (list_is_last (&matcher->list_node, &tbl->matcher_list)) next_matcher =NULL ;else - next_matcher =list_next_entry (matcher, matcher_list); + next_matcher =list_next_entry (matcher, list_node); -if (matcher->matcher_list.prev == &tbl->matcher_list) +if (matcher->list_node.prev == &tbl->matcher_list) prev_matcher =NULL ;else - prev_matcher =list_prev_entry (matcher, matcher_list); + prev_matcher =list_prev_entry (matcher, list_node);if (dmn->type ==MLX5DR_DOMAIN_TYPE_FDB || dmn->type ==MLX5DR_DOMAIN_TYPE_NIC_RX ) {
@@ -1013,7 +1013,7 @@ static int dr_matcher_remove_from_tbl(struct mlx5dr_matcher *matcher)return ret; } -list_del (&matcher->matcher_list); +list_del (&matcher->list_node);return 0 ; }
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c +1 -1
@@ -19,7 +19,7 @@ int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl,if (!list_empty (&tbl->matcher_list)) last_matcher =list_last_entry (&tbl->matcher_list, struct mlx5dr_matcher, - matcher_list); + list_node);if (tbl->dmn->type ==MLX5DR_DOMAIN_TYPE_NIC_RX || tbl->dmn->type ==MLX5DR_DOMAIN_TYPE_FDB ) {
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h +1 -1
@@ -891,7 +891,7 @@ struct mlx5dr_matcher {struct mlx5dr_table *tbl;struct mlx5dr_matcher_rx_tx rx;struct mlx5dr_matcher_rx_tx tx; -struct list_head matcher_list; +struct list_head list_node;u32 prio;struct mlx5dr_match_param mask;u8 match_criteria;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 35/120 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 36/120 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
@@ -1434,8 +1434,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 37/120 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
@@ -309,6 +309,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 38/120 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 39/120 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 40/120 can: etas_es58x: es58x_init_netdev(): free netdev when register_candev()
In reply to Greg Kroah-HartmanFrom: Zhang Changzhong <[email protected]>
[ Upstream commit 709cb2f9ed2006eb1dc4b36b99d601cd24889ec4 ]
In case of register_candev() fails, clear es58x_dev->netdev[channel_idx] and add free_candev(). Otherwise es58x_free_netdevs() will unregister the netdev that has never been registered.
--- drivers/net/can/usb/etas_es58x/es58x_core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/can/usb/etas_es58x/es58x_core.c +4 -1
@@ -2098,8 +2098,11 @@ static int es58x_init_netdev(struct es58x_device *es58x_dev, int channel_idx) netdev->flags |=IFF_ECHO ;/* We support local echo */ ret =register_candev (netdev); -if (ret) +if (ret) { + es58x_dev->netdev[channel_idx] =NULL ; +free_candev (netdev);return ret; + }netdev_queue_set_dql_min_limit (netdev_get_tx_queue (netdev,0 ), es58x_dev->param->dql_min_limit);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 41/120 can: m_can: pci: add missing m_can_class_free_dev() in probe/remove methods
In reply to Greg Kroah-HartmanFrom: Zhang Changzhong <[email protected]>
[ Upstream commit 1eca1d4cc21b6d0fc5f9a390339804c0afce9439 ]
In m_can_pci_remove() and error handling path of m_can_pci_probe(), m_can_class_free_dev() should be called to free resource allocated by m_can_class_allocate_dev(), otherwise there will be memleak.
--- drivers/net/can/m_can/m_can_pci.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/can/m_can/m_can_pci.c +6 -3
@@ -120,7 +120,7 @@ static int m_can_pci_probe(struct pci_dev *pci, const struct pci_device_id *id) ret =pci_alloc_irq_vectors (pci,1 ,1 ,PCI_IRQ_ALL_TYPES );if (ret <0 ) -return ret; + goto err_free_dev; mcan_class->dev = &pci->dev; mcan_class->net->irq =pci_irq_vector (pci,0 );
@@ -132,7 +132,7 @@ static int m_can_pci_probe(struct pci_dev *pci, const struct pci_device_id *id) ret =m_can_class_register (mcan_class);if (ret) - goto err; + goto err_free_irq;/* Enable interrupt control at CAN wrapper IP */ writel (0x1 , base +CTL_CSR_INT_CTL_OFFSET );
@@ -144,8 +144,10 @@ static int m_can_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)return 0 ; -err: +err_free_irq:pci_free_irq_vectors (pci); +err_free_dev: +m_can_class_free_dev (mcan_class->net);return ret; }
@@ -161,6 +163,7 @@ static void m_can_pci_remove(struct pci_dev *pci)writel (0x0 , priv->base +CTL_CSR_INT_CTL_OFFSET );m_can_class_unregister (mcan_class); +m_can_class_free_dev (mcan_class->net);pci_free_irq_vectors (pci); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 42/120 can: m_can: Add check for devm_clk_get
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 68b4f9e0bdd0f920d7303d07bfe226cd0976961d ]
Since the devm_clk_get may return error,
it should be better to add check for the cdev->hclk, as same as cdev->cclk.
--- drivers/net/can/m_can/m_can.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/m_can/m_can.c +1 -1
@@ -1931,7 +1931,7 @@ int m_can_class_get_clocks(struct m_can_classdev *cdev) cdev->hclk =devm_clk_get (cdev->dev,"hclk" ); cdev->cclk =devm_clk_get (cdev->dev,"cclk" ); -if (IS_ERR (cdev->cclk)) { +if (IS_ERR (cdev->hclk) ||IS_ERR (cdev->cclk)) {dev_err (cdev->dev,"no clock found\n" ); ret = -ENODEV ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 43/120 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 44/120 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>
@@ -845,7 +846,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);
@@ -861,7 +862,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 45/120 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 46/120 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
@@ -2477,10 +2477,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 47/120 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 48/120 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
@@ -1518,6 +1518,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 49/120 net: ethernet: ti: am65-cpsw: fix error handling in am65_cpsw_nuss_probe()
In reply to Greg Kroah-HartmanFrom: Zhang Changzhong <[email protected]>
[ Upstream commit 46fb6512538d201d9a5b2bd7138b6751c37fdf0b ]
The am65_cpsw_nuss_cleanup_ndev() function calls unregister_netdev() even if register_netdev() fails, which triggers WARN_ON(1) in unregister_netdevice_many(). To fix it, make sure that unregister_netdev() is called only on registered netdev.
Compile tested only.
--- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/ti/am65-cpsw-nuss.c +1 -1
@@ -2054,7 +2054,7 @@ static void am65_cpsw_nuss_cleanup_ndev(struct am65_cpsw_common *common)for (i =0 ; i < common->port_num; i++) { port = &common->ports[i]; -if (port->ndev) +if (port->ndev && port->ndev->reg_state ==NETREG_REGISTERED )unregister_netdev (port->ndev); } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 50/120 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 51/120 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
@@ -864,8 +864,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 52/120 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 53/120 net: wwan: iosm: fix kernel test robot reported error
In reply to Greg Kroah-HartmanFrom: M Chetan Kumar <[email protected]>
[ Upstream commit 985a02e75881b73a43c9433a718b49d272a9dd6b ]
sparse warnings - iosm_ipc_mux_codec.c:1474 using plain integer as NULL pointer.
Use skb_trim() to reset skb tail & len.
--- drivers/net/wwan/iosm/iosm_ipc_mux_codec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/wwan/iosm/iosm_ipc_mux_codec.c +1 -2
@@ -830,8 +830,7 @@ void ipc_mux_ul_encoded_process(struct iosm_mux *ipc_mux, struct sk_buff *skb) ipc_mux->ul_data_pend_bytes);/* Reset the skb settings. */ - skb->tail =0 ; - skb->len =0 ; +skb_trim (skb,0 );/* Add the consumed ADB to the free list. */ skb_queue_tail ((&ipc_mux->ul_adb.free_list), skb);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 54/120 net: wwan: iosm: fix dma_alloc_coherent incompatible pointer type
In reply to Greg Kroah-HartmanFrom: M Chetan Kumar <[email protected]>
[ Upstream commit 4a99e3c8ed888577b947cbed97d88c9706896105 ]
Fix build error reported on armhf while preparing 6.1-rc5 for Debian.
iosm_ipc_protocol.c:244:36: error: passing argument 3 of 'dma_alloc_coherent' from incompatible pointer type.
Change phy_ap_shm type from phys_addr_t to dma_addr_t.
--- drivers/net/wwan/iosm/iosm_ipc_protocol.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wwan/iosm/iosm_ipc_protocol.h +1 -1
@@ -122,7 +122,7 @@ struct iosm_protocol {struct iosm_imem *imem;struct ipc_rsp *rsp_ring[IPC_MEM_MSG_ENTRIES ];struct device *dev; -phys_addr_t phy_ap_shm; +dma_addr_t phy_ap_shm;u32 old_msg_tail; };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 55/120 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
@@ -959,7 +959,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 56/120 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
@@ -1982,6 +1982,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 57/120 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
@@ -309,17 +309,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 58/120 net: mdiobus: fix unbalanced node reference count
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit cdde1560118f82498fc9e9a7c1ef7f0ef7755891 ]
I got the following report while doing device(mscc-miim) load test with CONFIG_OF_UNITTEST and CONFIG_OF_DYNAMIC enabled:
OF: ERROR: memory leak, expected refcount 1 instead of 2, of_node_get()/of_node_put() unbalanced - destroy cset entry:
attach overlay node /spi/soc@0/mdio@7107009c/ethernet-phy@0
If the 'fwnode' is not an acpi node, the refcount is get in fwnode_mdiobus_phy_device_register(), but it has never been put when the device is freed in the normal path. So call fwnode_handle_put() in phy_device_release() to avoid leak.
If it's an acpi node, it has never been get, but it's put in the error path, so call fwnode_handle_get() before phy_device_register() to keep get/put operation balanced.
--- drivers/net/mdio/fwnode_mdio.c | 2 +- drivers/net/phy/phy_device.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/mdio/fwnode_mdio.c +1 -1
@@ -120,7 +120,7 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus,/* Associate the fwnode with the device structure so it * can be looked up later. */ - phy->mdio.dev.fwnode = child; + phy->mdio.dev.fwnode =fwnode_handle_get (child);/* All data is now stored in the phy struct, so register it */ rc =phy_device_register (phy);
drivers/net/phy/phy_device.c +1 -0
@@ -215,6 +215,7 @@ static void phy_mdio_device_free(struct mdio_device *mdiodev)static void phy_device_release (struct device *dev) { +fwnode_handle_put (dev->fwnode);kfree (to_phy_device (dev)); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 59/120 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
@@ -167,8 +167,8 @@ void afs_fileserver_probe_result(struct afs_call *call)clear_bit (AFS_SERVER_FL_HAS_FS64 , &server->flags); } -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 60/120 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
@@ -687,7 +687,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); } }
@@ -703,6 +702,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 61/120 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
@@ -2246,8 +2246,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 62/120 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 63/120 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
@@ -2491,6 +2491,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 64/120 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 65/120 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 66/120 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)
Greg Kroah-Hartman
maintainerPATCH 67/120 riscv: mm: Proper page permissions after initmem free
In reply to Greg Kroah-HartmanFrom: Björn Töpel <[email protected]>
commit 6fdd5d2f8c2f54b7fad4ff4df2a19542aeaf6102 upstream.
64-bit RISC-V kernels have the kernel image mapped separately to alias the linear map. The linear map and the kernel image map are documented as "direct mapping" and "kernel" respectively in [1].
At image load time, the linear map corresponding to the kernel image is set to PAGE_READ permission, and the kernel image map is set to PAGE_READ|PAGE_EXEC.
When the initmem is freed, the pages in the linear map should be restored to PAGE_READ|PAGE_WRITE, whereas the corresponding pages in the kernel image map should be restored to PAGE_READ, by removing the PAGE_EXEC permission.
This is not the case. For 64-bit kernels, only the linear map is restored to its proper page permissions at initmem free, and not the kernel image map.
In practise this results in that the kernel can potentially jump to dead __init code, and start executing invalid instructions, without getting an exception.
Restore the freed initmem properly, by setting both the kernel image map to the correct permissions.
[1] Documentation/riscv/vm-layout.rst
--- arch/riscv/kernel/setup.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
arch/riscv/kernel/setup.c +5 -4
@@ -331,10 +331,11 @@ subsys_initcall(topology_init);void free_initmem (void ) { -if (IS_ENABLED (CONFIG_STRICT_KERNEL_RWX )) -set_kernel_memory (lm_alias (__init_begin),lm_alias (__init_end), -IS_ENABLED (CONFIG_64BIT ) ? - set_memory_rw : set_memory_rw_nx); +if (IS_ENABLED (CONFIG_STRICT_KERNEL_RWX )) { +set_kernel_memory (lm_alias (__init_begin),lm_alias (__init_end), set_memory_rw_nx); +if (IS_ENABLED (CONFIG_64BIT )) +set_kernel_memory (__init_begin, __init_end, set_memory_nx); + }free_initmem_default (POISON_FREE_INITMEM ); }
Greg Kroah-Hartman
maintainerPATCH 68/120 ALSA: dice: fix regression for Lexicon I-ONIX FW810S
In reply to Greg Kroah-HartmanFrom: Takashi Sakamoto <[email protected]>
commit 9b84f0f74d0d716e3fd18dc428ac111266ef5844 upstream.
For Lexicon I-ONIX FW810S, the call of ioctl(2) with SNDRV_PCM_IOCTL_HW_PARAMS can returns -ETIMEDOUT. This is a regression due to the commit 41319eb56e19 ("ALSA: dice: wait just for NOTIFY_CLOCK_ACCEPTED after GLOBAL_CLOCK_SELECT operation"). The device does not emit NOTIFY_CLOCK_ACCEPTED notification when accepting GLOBAL_CLOCK_SELECT operation with the same parameters as current ones.
This commit fixes the regression. When receiving no notification, return -ETIMEDOUT as long as operating for any change.
--- sound/firewire/dice/dice-stream.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
sound/firewire/dice/dice-stream.c +7 -5
@@ -59,7 +59,7 @@ int snd_dice_stream_get_rate_mode(struct snd_dice *dice, unsigned int rate,static int select_clock (struct snd_dice *dice,unsigned int rate) { -__be32 reg; +__be32 reg, new;u32 data;int i;int err;
@@ -83,15 +83,17 @@ static int select_clock(struct snd_dice *dice, unsigned int rate)if (completion_done (&dice->clock_accepted))reinit_completion (&dice->clock_accepted); - reg =cpu_to_be32 (data); + new =cpu_to_be32 (data); err =snd_dice_transaction_write_global (dice,GLOBAL_CLOCK_SELECT , - ®,sizeof (reg)); + &new,sizeof (new));if (err <0 )return err;if (wait_for_completion_timeout (&dice->clock_accepted, -msecs_to_jiffies (NOTIFICATION_TIMEOUT_MS )) ==0 ) -return -ETIMEDOUT ; +msecs_to_jiffies (NOTIFICATION_TIMEOUT_MS )) ==0 ) { +if (reg != new) +return -ETIMEDOUT ; + }return 0 ; }
Signature · 1 line
2.38.1
Greg Kroah-Hartman
maintainerPATCH 69/120 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
@@ -1872,8 +1872,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 70/120 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 71/120 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 72/120 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
@@ -60,11 +60,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 ;
@@ -75,7 +82,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); }
@@ -1328,7 +1335,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); } }
@@ -1450,7 +1457,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) {
@@ -1564,7 +1571,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. */
@@ -1797,7 +1804,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); } }
@@ -2048,7 +2055,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
@@ -584,7 +584,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 73/120 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
@@ -436,9 +436,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)
@@ -1659,6 +1664,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;
@@ -1673,6 +1679,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 74/120 v4l2: dont fall back to follow_pfn() if pin_user_pages_fast() fails
In reply to Greg Kroah-HartmanFrom: Linus Torvalds <[email protected]>
commit 6647e76ab623b2b3fb2efe03a86e9c9046c52c33 upstream.
The V4L2_MEMORY_USERPTR interface is long deprecated and shouldn't be used (and is discouraged for any modern v4l drivers). And Seth Jenkins points out that the fallback to VM_PFNMAP/VM_IO is fundamentally racy and dangerous.
Note that it's not even a case that should trigger, since any normal user pointer logic ends up just using the pin_user_pages_fast() call that does the proper page reference counting. That's not the problem case, only if you try to use special device mappings do you have any issues.
Normally I'd just remove this during the merge window, but since Seth pointed out the problem cases, we really want to know as soon as possible if there are actually any users of this odd special case of a legacy interface. Neither Hans nor Mauro seem to think that such mis-uses of the old legacy interface should exist. As Mauro says:
"See, V4L2 has actually 4 streaming APIs:
- Kernel-allocated mmap (usually referred simply as just mmap);
- USERPTR mmap;
- read();
- dmabuf;
The USERPTR is one of the oldest way to use it, coming from V4L version 1 times, and by far the least used one"
And Hans chimed in on the USERPTR interface:
"To be honest, I wouldn't mind if it goes away completely, but that's a
bit of a pipe dream right now"
but while removing this legacy interface entirely may be a pipe dream we can at least try to remove the unlikely (and actively broken) case of using special device mappings for USERPTR accesses.
This replaces it with a WARN_ONCE() that we can remove once we've hopefully confirmed that no actual users exist.
NOTE! Longer term, this means that a 'struct frame_vector' only ever contains proper page pointers, and all the games we have with converting them to pages can go away (grep for 'frame_vector_to_pages()' and the uses of 'vec->is_pfns'). But this is just the first step, to verify that this code really is all dead, and do so as quickly as possible.
--- drivers/media/common/videobuf2/frame_vector.c | 55 +++++--------------------- 1 file changed, 12 insertions(+), 43 deletions(-)
drivers/media/common/videobuf2/frame_vector.c +12 -43
@@ -35,10 +35,7 @@int get_vaddr_frames (unsigned long start,unsigned int nr_frames,struct frame_vector *vec) { -struct mm_struct *mm = current->mm; -struct vm_area_struct *vma; -int ret =0 ; -int err; +int ret;if (nr_frames ==0 )return 0 ;
@@ -51,45 +48,17 @@ int get_vaddr_frames(unsigned long start ret =pin_user_pages_fast (start, nr_frames,FOLL_FORCE |FOLL_WRITE |FOLL_LONGTERM , (struct page **)(vec->ptrs)); -if (ret >0 ) { - vec->got_ref = true; - vec->is_pfns = false; - goto out_unlocked; - } - -mmap_read_lock (mm); - vec->got_ref = false; - vec->is_pfns = true; - ret =0 ; -do { -unsigned long *nums =frame_vector_pfns (vec); - - vma =vma_lookup (mm, start); -if (!vma) -break ; - -while (ret < nr_frames && start +PAGE_SIZE <= vma->vm_end) { - err =follow_pfn (vma, start, &nums[ret]); -if (err) { -if (ret ==0 ) - ret = err; - goto out; - } - start +=PAGE_SIZE ; - ret++; - } -/* Bail out if VMA doesn't completely cover the tail page. */ -if (start < vma->vm_end) -break ; - }while (ret < nr_frames); -out: -mmap_read_unlock (mm); -out_unlocked: -if (!ret) - ret = -EFAULT ; -if (ret >0 ) - vec->nr_frames = ret; -return ret; + vec->got_ref = true; + vec->is_pfns = false; + vec->nr_frames = ret; + +if (likely (ret >0 )) +return ret; + +/* This used to (racily) return non-refcounted pfns. Let people know */ +WARN_ONCE (1 ,"get_vaddr_frames() cannot follow VM_IO mapping" ); + vec->nr_frames =0 ; +return ret ? ret : -EFAULT ; }EXPORT_SYMBOL (get_vaddr_frames);
Greg Kroah-Hartman
maintainerPATCH 75/120 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
@@ -745,6 +745,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
@@ -1158,8 +1158,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);if (ctrl != old_ctrl)writel (ctrl, priv->ioaddr +MAC_CTRL_REG );
Greg Kroah-Hartman
maintainerPATCH 76/120 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
@@ -3181,7 +3181,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 77/120 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
@@ -1482,6 +1482,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) {
@@ -1764,7 +1769,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 ;
@@ -1794,7 +1799,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 78/120 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
@@ -1495,7 +1495,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 79/120 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 80/120 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
@@ -338,6 +338,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); } }
@@ -2257,11 +2258,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 ;
@@ -2287,6 +2323,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;
@@ -2313,6 +2351,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 )) {
@@ -2356,6 +2405,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
@@ -2383,19 +2433,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 */
@@ -3711,6 +3756,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, (mmc->pm_flags &MMC_PM_KEEP_POWER ));
@@ -3773,6 +3819,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
@@ -523,6 +523,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 81/120 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 82/120 drm/amdgpu: enable Vangogh VCN indirect sram mode
In reply to Greg Kroah-HartmanFrom: Leo Liu <[email protected]>
commit 9a8cc8cabc1e351614fd7f9e774757a5143b6fe8 upstream.
So that uses PSP to initialize HW.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +3 -0
@@ -149,6 +149,9 @@ int amdgpu_vcn_sw_init(struct amdgpu_devbreak ;case CHIP_VANGOGH : fw_name =FIRMWARE_VANGOGH ; +if ((adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ) && + (adev->pg_flags &AMD_PG_SUPPORT_VCN_DPG )) + adev->vcn.indirect_sram = true;break ;case CHIP_DIMGREY_CAVEFISH : fw_name =FIRMWARE_DIMGREY_CAVEFISH ;
Greg Kroah-Hartman
maintainerPATCH 83/120 drm/i915: Fix negative value passed as remaining time
In reply to Greg Kroah-HartmanFrom: Janusz Krzysztofik <[email protected]>
commit a8899b8728013c7b2456f0bfa20e5fea85ee0fd1 upstream.
Commit b97060a99b01 ("drm/i915/guc: Update intel_gt_wait_for_idle to work with GuC") extended the API of intel_gt_retire_requests_timeout() with an extra argument 'remaining_timeout', intended for passing back unconsumed portion of requested timeout when 0 (success) is returned. However, when request retirement happens to succeed despite an error returned by a call to dma_fence_wait_timeout(), that error code (a negative value) is passed back instead of remaining time. If we then pass that negative value forward as requested timeout to intel_uc_wait_for_idle(), an explicit BUG will be triggered.
If request retirement succeeds but an error code is passed back via remaininig_timeout, we may have no clue on how much of the initial timeout might have been left for spending it on waiting for GuC to become idle. OTOH, since all pending requests have been successfully retired, that error code has been already ignored by intel_gt_retire_requests_timeout(), then we shouldn't fail.
Assume no more time has been left on error and pass 0 timeout value to intel_uc_wait_for_idle() to give it a chance to return success if GuC is already idle.
v3: Don't fail on any error passed back via remaining_timeout.
v2: Fix the issue on the caller side, not the provider.
--- drivers/gpu/drm/i915/gt/intel_gt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gt/intel_gt.c +7 -2
@@ -650,8 +650,13 @@ int intel_gt_wait_for_idle(struct intel_return -EINTR ; } -return timeout ? timeout :intel_uc_wait_for_idle (>->uc, - remaining_timeout); +if (timeout) +return timeout; + +if (remaining_timeout <0 ) + remaining_timeout =0 ; + +return intel_uc_wait_for_idle (>->uc, remaining_timeout); }int intel_gt_init (struct intel_gt *gt)
Greg Kroah-Hartman
maintainerPATCH 84/120 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
@@ -199,7 +199,7 @@ out_active: spin_lock(&timelines->lock);if (remaining_timeout) *remaining_timeout = timeout; -return active_count ? timeout :0 ; +return active_count ? timeout ?: -ETIME :0 ; }static void retire_work_handler (struct work_struct *work)
Greg Kroah-Hartman
maintainerPATCH 85/120 tracing/osnoise: Fix duration type
In reply to Greg Kroah-HartmanFrom: Daniel Bristot de Oliveira <[email protected]>
commit 022632f6c43a86f2135642dccd5686de318e861d upstream.
The duration type is a 64 long value, not an int. This was causing some long noise to report wrong values.
Change the duration to a 64 bits value.
--- kernel/trace/trace_osnoise.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/trace/trace_osnoise.c +3 -3
@@ -730,7 +730,7 @@ void osnoise_trace_irq_entry(int id)void osnoise_trace_irq_exit (int id,const char *desc) {struct osnoise_variables *osn_var =this_cpu_osn_var (); -int duration; +s64 duration;if (!osn_var->sampling)return ;
@@ -861,7 +861,7 @@ static void trace_softirq_entry_callbackstatic void trace_softirq_exit_callback (void *data,unsigned int vec_nr) {struct osnoise_variables *osn_var =this_cpu_osn_var (); -int duration; +s64 duration;if (!osn_var->sampling)return ;
@@ -969,7 +969,7 @@ thread_entry(struct osnoise_variables *ostatic void thread_exit (struct osnoise_variables *osn_var,struct task_struct *t) { -int duration; +s64 duration;if (!osn_var->sampling)return ;
Greg Kroah-Hartman
maintainerPATCH 86/120 tracing: Fix race where histograms can be called before the event
In reply to Greg Kroah-HartmanFrom: Steven Rostedt (Google) <[email protected]>
commit ef38c79a522b660f7f71d45dad2d6244bc741841 upstream.
commit 94eedf3dded5 ("tracing: Fix race where eprobes can be called before the event") fixed an issue where if an event is soft disabled, and the trigger is being added, there's a small window where the event sees that there's a trigger but does not see that it requires reading the event yet, and then calls the trigger with the record == NULL.
This could be solved with adding memory barriers in the hot path, or to make sure that all the triggers requiring a record check for NULL. The latter was chosen.
Commit 94eedf3dded5 set the eprobe trigger handle to check for NULL, but the same needs to be done with histograms.
--- kernel/trace/trace_events_hist.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/trace/trace_events_hist.c +3 -0
@@ -4677,6 +4677,9 @@ static void event_hist_trigger(struct evvoid *key =NULL ;unsigned int i; +if (unlikely (!rbe)) +return ; +memset (compound_key,0 , hist_data->key_size);for_each_hist_key_field (i, hist_data) {
Greg Kroah-Hartman
maintainerPATCH 87/120 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
@@ -118,6 +118,7 @@ int dyn_event_release(const char *raw_coif (ret)break ; } +tracing_reset_all_online_cpus ();mutex_unlock (&event_mutex); out:argv_free (argv);
@@ -214,6 +215,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
@@ -2874,7 +2874,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
@@ -2887,6 +2890,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 88/120 io_uring: update res mask in io_poll_check_events
In reply to Greg Kroah-HartmanFrom: Pavel Begunkov <[email protected]>
[ upstream commit b98186aee22fa593bc8c6b2c5d839c2ee518bc8c ]
When io_poll_check_events() collides with someone attempting to queue a task work, it'll spin for one more time. However, it'll continue to use the mask from the first iteration instead of updating it. For example, if the first wake up was a EPOLLIN and the second EPOLLOUT, the userspace will not get EPOLLOUT in time.
Clear the mask for all subsequent iterations to force vfs_poll().
--- fs/io_uring.c | 3 +++ 1 file changed, 3 insertions(+)
fs/io_uring.c +3 -0
@@ -5464,6 +5464,9 @@ static int io_poll_check_events(struct ireturn 0 ; } +/* force the next iteration to vfs_poll() */ + req->result =0 ; +/* * Release all references, retry if someone tried to restart * task_work while we were executing it.
Greg Kroah-Hartman
maintainerPATCH 89/120 io_uring: fix tw losing poll events
In reply to Greg Kroah-HartmanFrom: Pavel Begunkov <[email protected]>
[ upstream commit 539bcb57da2f58886d7d5c17134236b0ec9cd15d ]
We may never try to process a poll wake and its mask if there was multiple wake ups racing for queueing up a tw. Force io_poll_check_events() to update the mask by vfs_poll().
--- fs/io_uring.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/io_uring.c +7 -0
@@ -5440,6 +5440,13 @@ static int io_poll_check_events(struct ireturn 0 ;if (v &IO_POLL_CANCEL_FLAG )return -ECANCELED ; +/* +* cqe.res contains only events of the first wake up +* and all others are be lost. Redo vfs_poll() to get +* up to date state. +*/ +if ((v &IO_POLL_REF_MASK ) !=1 ) + req->result =0 ;if (!req->result) {struct poll_table_struct pt = { ._key = poll->events };
Greg Kroah-Hartman
maintainerPATCH 90/120 io_uring: cmpxchg for poll arm refs release
In reply to Greg Kroah-HartmanFrom: Pavel Begunkov <[email protected]>
[ upstream commit 2f3893437a4ebf2e892ca172e9e122841319d675 ]
Replace atomically substracting the ownership reference at the end of arming a poll with a cmpxchg. We try to release ownership by setting 0 assuming that poll_refs didn't change while we were arming. If it did change, we keep the ownership and use it to queue a tw, which is fully capable to process all events and (even tolerates spurious wake ups).
It's a bit more elegant as we reduce races b/w setting the cancellation flag and getting refs with this release, and with that we don't have to worry about any kinds of underflows. It's not the fastest path for polling. The performance difference b/w cmpxchg and atomic dec is usually negligible and it's not the fastest path.
--- fs/io_uring.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
fs/io_uring.c +3 -5
@@ -5650,7 +5650,6 @@ static int __io_arm_poll_handler(struct struct io_poll_table *ipt, __poll_t mask) {struct io_ring_ctx *ctx = req->ctx; -int v;INIT_HLIST_NODE (&req->hash_node);io_init_poll_iocb (poll, mask, io_poll_wake);
@@ -5696,11 +5695,10 @@ static int __io_arm_poll_handler(struct }/* -* Release ownership. If someone tried to queue a tw while it was -* locked, kick it off for them. +* Try to release ownership. If we see a change of state, e.g. +* poll was waken up, queue up a tw, it'll deal with it. */ - v =atomic_dec_return (&req->poll_refs); -if (unlikely (v &IO_POLL_REF_MASK )) +if (atomic_cmpxchg (&req->poll_refs,1 ,0 ) !=1 )__io_poll_execute (req,0 );return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 91/120 io_uring: make poll refs more robust
In reply to Greg Kroah-HartmanFrom: Pavel Begunkov <[email protected]>
[ upstream commit a26a35e9019fd70bf3cf647dcfdae87abc7bacea ]
poll_refs carry two functions, the first is ownership over the request. The second is notifying the io_poll_check_events() that there was an event but wake up couldn't grab the ownership, so io_poll_check_events() should retry.
We want to make poll_refs more robust against overflows. Instead of always incrementing it, which covers two purposes with one atomic, check if poll_refs is elevated enough and if so set a retry flag without attempts to grab ownership. The gap between the bias check and following atomics may seem racy, but we don't need it to be strict. Moreover there might only be maximum 4 parallel updates: by the first and the second poll entries, __io_arm_poll_handler() and cancellation. From those four, only poll wake ups may be executed multiple times, but they're protected by a spin.
--- fs/io_uring.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-)
fs/io_uring.c +35 -1
@@ -5322,7 +5322,29 @@ struct io_poll_table { };#define IO_POLL_CANCEL_FLAG BIT(31) -#define IO_POLL_REF_MASK GENMASK(30, 0) +#define IO_POLL_RETRY_FLAG BIT(30) +#define IO_POLL_REF_MASK GENMASK(29, 0) + +/* +* We usually have 1-2 refs taken, 128 is more than enough and we want to +* maximise the margin between this amount and the moment when it overflows. +*/ +#define IO_POLL_REF_BIAS 128 + +static bool io_poll_get_ownership_slowpath (struct io_kiocb *req) +{ +int v; + +/* +* poll_refs are already elevated and we don't have much hope for +* grabbing the ownership. Instead of incrementing set a retry flag +* to notify the loop that there might have been some change. +*/ + v =atomic_fetch_or (IO_POLL_RETRY_FLAG , &req->poll_refs); +if (v &IO_POLL_REF_MASK ) +return false; +return !(atomic_fetch_inc (&req->poll_refs) &IO_POLL_REF_MASK ); +}/* * If refs part of ->poll_refs (see IO_POLL_REF_MASK) is 0, it's free. We can
@@ -5332,6 +5354,8 @@ struct io_poll_table {*/ static inline bool io_poll_get_ownership (struct io_kiocb *req) { +if (unlikely (atomic_read (&req->poll_refs) >=IO_POLL_REF_BIAS )) +return io_poll_get_ownership_slowpath (req);return !(atomic_fetch_inc (&req->poll_refs) &IO_POLL_REF_MASK ); }
@@ -5447,6 +5471,16 @@ static int io_poll_check_events(struct i*/ if ((v &IO_POLL_REF_MASK ) !=1 ) req->result =0 ; +if (v &IO_POLL_RETRY_FLAG ) { + req->result =0 ; +/* +* We won't find new events that came in between +* vfs_poll and the ref put unless we clear the +* flag in advance. +*/ +atomic_andnot (IO_POLL_RETRY_FLAG , &req->poll_refs); + v &= ~IO_POLL_RETRY_FLAG ; + }if (!req->result) {struct poll_table_struct pt = { ._key = poll->events };
Greg Kroah-Hartman
maintainerPATCH 92/120 io_uring/poll: fix poll_refs race with cancelation
In reply to Greg Kroah-HartmanFrom: Lin Ma <[email protected]>
[ upstream commit 12ad3d2d6c5b0131a6052de91360849e3e154846 ]
There is an interesting race condition of poll_refs which could result in a NULL pointer dereference. The crash trace is like:
KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f] CPU: 0 PID: 30781 Comm: syz-executor.2 Not tainted 6.0.0-g493ffd6605b2 #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 RIP: 0010:io_poll_remove_entry io_uring/poll.c:154 [inline] RIP: 0010:io_poll_remove_entries+0x171/0x5b4 io_uring/poll.c:190 Code: ... RSP: 0018:ffff88810dfefba0 EFLAGS: 00010202 RAX: 0000000000000001 RBX: 0000000000000000 RCX: 0000000000040000 RDX: ffffc900030c4000 RSI: 000000000003ffff RDI: 0000000000040000 RBP: 0000000000000008 R08: ffffffff9764d3dd R09: fffffbfff3836781 R10: fffffbfff3836781 R11: 0000000000000000 R12: 1ffff11003422d60 R13: ffff88801a116b04 R14: ffff88801a116ac0 R15: dffffc0000000000 FS: 00007f9c07497700(0000) GS:ffff88811a600000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007ffb5c00ea98 CR3: 0000000105680005 CR4: 0000000000770ef0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: <TASK> io_apoll_task_func+0x3f/0xa0 io_uring/poll.c:299 handle_tw_list io_uring/io_uring.c:1037 [inline] tctx_task_work+0x37e/0x4f0 io_uring/io_uring.c:1090 task_work_run+0x13a/0x1b0 kernel/task_work.c:177 get_signal+0x2402/0x25a0 kernel/signal.c:2635 arch_do_signal_or_restart+0x3b/0x660 arch/x86/kernel/signal.c:869 exit_to_user_mode_loop kernel/entry/common.c:166 [inline] exit_to_user_mode_prepare+0xc2/0x160 kernel/entry/common.c:201 __syscall_exit_to_user_mode_work kernel/entry/common.c:283 [inline] syscall_exit_to_user_mode+0x58/0x160 kernel/entry/common.c:294 entry_SYSCALL_64_after_hwframe+0x63/0xcd
The root cause for this is a tiny overlooking in io_poll_check_events() when cocurrently run with poll cancel routine io_poll_cancel_req().
The interleaving to trigger use-after-free:
CPU0 | CPU1
|
io_apoll_task_func() | io_poll_cancel_req()
io_poll_check_events() |
// do while first loop |
v = atomic_read(...) |
// v = poll_refs = 1 |
... | io_poll_mark_cancelled()
| atomic_or()
| // poll_refs =
IO_POLL_CANCEL_FLAG | 1
|
atomic_sub_return(...) |
// poll_refs = IO_POLL_CANCEL_FLAG |
// loop continue |
|
| io_poll_execute()
| io_poll_get_ownership()
| // poll_refs =
IO_POLL_CANCEL_FLAG | 1
| // gets the ownership
v = atomic_read(...) |
// poll_refs not change |
|
if (v & IO_POLL_CANCEL_FLAG) |
return -ECANCELED; |
// io_poll_check_events return |
// will go into |
// io_req_complete_failed() free req |
|
| io_apoll_task_func()
| // also go intoio_req_complete_failed()
And the interleaving to trigger the kernel WARNING:
CPU0 | CPU1
|
io_apoll_task_func() | io_poll_cancel_req()
io_poll_check_events() |
// do while first loop |
v = atomic_read(...) |
// v = poll_refs = 1 |
... | io_poll_mark_cancelled()
| atomic_or()
| // poll_refs =
IO_POLL_CANCEL_FLAG | 1
|
atomic_sub_return(...) |
// poll_refs = IO_POLL_CANCEL_FLAG |
// loop continue |
|
v = atomic_read(...) |
// v = IO_POLL_CANCEL_FLAG |
| io_poll_execute()
| io_poll_get_ownership()
| // poll_refs =
IO_POLL_CANCEL_FLAG | 1
| // gets the ownership
|
WARN_ON_ONCE(!(v & IO_POLL_REF_MASK))) |
// v & IO_POLL_REF_MASK = 0 WARN |
|
| io_apoll_task_func()
| // also go intoio_req_complete_failed()
By looking up the source code and communicating with Pavel, the implementation of this atomic poll refs should continue the loop of io_poll_check_events() just to avoid somewhere else to grab the ownership. Therefore, this patch simply adds another AND operation to make sure the loop will stop if it finds the poll_refs is exactly equal to IO_POLL_CANCEL_FLAG. Since io_poll_cancel_req() grabs ownership and will finally make its way to io_req_complete_failed(), the req will be reclaimed as expected.
--- fs/io_uring.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/io_uring.c +2 -1
@@ -5512,7 +5512,8 @@ static int io_poll_check_events(struct i* Release all references, retry if someone tried to restart * task_work while we were executing it. */ - }while (atomic_sub_return (v &IO_POLL_REF_MASK , &req->poll_refs)); + }while (atomic_sub_return (v &IO_POLL_REF_MASK , &req->poll_refs) & +IO_POLL_REF_MASK );return 1 ; }
Greg Kroah-Hartman
maintainerPATCH 93/120 KVM: x86/mmu: Fix race condition in direct_page_fault
In reply to Greg Kroah-HartmanFrom: Kazuki Takiguchi <[email protected]>
commit 47b0c2e4c220f2251fd8dcfbb44479819c715e15 upstream.
make_mmu_pages_available() must be called with mmu_lock held for write. However, if the TDP MMU is used, it will be called with mmu_lock held for read.
This function does nothing unless shadow pages are used, so there is no race unless nested TDP is used.
Since nested TDP uses shadow pages, old shadow pages may be zapped by this function even when the TDP MMU is enabled.
Since shadow pages are never allocated by kvm_tdp_mmu_map(), a race condition can be avoided by not calling make_mmu_pages_available() if the TDP MMU is currently in use.
I encountered this when repeatedly starting and stopping nested VM. It can be artificially caused by allocating a large number of nested TDP SPTEs.
For example, the following BUG and general protection fault are caused in the host kernel.
pte_list_remove: 00000000cd54fc10 many->many
------------[ cut here ]------------ kernel BUG at arch/x86/kvm/mmu/mmu.c:963! invalid opcode: 0000 [#1] PREEMPT SMP NOPTI RIP: 0010:pte_list_remove.cold+0x16/0x48 [kvm] Call Trace: <TASK> drop_spte+0xe0/0x180 [kvm] mmu_page_zap_pte+0x4f/0x140 [kvm] __kvm_mmu_prepare_zap_page+0x62/0x3e0 [kvm] kvm_mmu_zap_oldest_mmu_pages+0x7d/0xf0 [kvm] direct_page_fault+0x3cb/0x9b0 [kvm] kvm_tdp_page_fault+0x2c/0xa0 [kvm] kvm_mmu_page_fault+0x207/0x930 [kvm] npf_interception+0x47/0xb0 [kvm_amd] svm_invoke_exit_handler+0x13c/0x1a0 [kvm_amd] svm_handle_exit+0xfc/0x2c0 [kvm_amd] kvm_arch_vcpu_ioctl_run+0xa79/0x1780 [kvm] kvm_vcpu_ioctl+0x29b/0x6f0 [kvm] __x64_sys_ioctl+0x95/0xd0 do_syscall_64+0x5c/0x90 general protection fault, probably for non-canonical address 0xdead000000000122: 0000 [#1] PREEMPT SMP NOPTI RIP: 0010:kvm_mmu_commit_zap_page.part.0+0x4b/0xe0 [kvm] Call Trace: <TASK> kvm_mmu_zap_oldest_mmu_pages+0xae/0xf0 [kvm] direct_page_fault+0x3cb/0x9b0 [kvm] kvm_tdp_page_fault+0x2c/0xa0 [kvm] kvm_mmu_page_fault+0x207/0x930 [kvm] npf_interception+0x47/0xb0 [kvm_amd]
CVE: CVE-2022-45869
--- arch/x86/kvm/mmu/mmu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
arch/x86/kvm/mmu/mmu.c +7 -5
@@ -2357,6 +2357,7 @@ static bool __kvm_mmu_prepare_zap_page(s {bool list_unstable; +lockdep_assert_held_write (&kvm->mmu_lock);trace_kvm_mmu_prepare_zap_page (sp); ++kvm->stat.mmu_shadow_zapped; *nr_zapped =mmu_zap_unsync_children (kvm, sp, invalid_list);
@@ -4007,16 +4008,17 @@ static int direct_page_fault(struct kvm_if (!is_noslot_pfn (pfn) &&mmu_notifier_retry_hva (vcpu->kvm, mmu_seq, hva)) goto out_unlock; - r =make_mmu_pages_available (vcpu); -if (r) - goto out_unlock; -if (is_tdp_mmu_fault) +if (is_tdp_mmu_fault) { r =kvm_tdp_mmu_map (vcpu, gpa, error_code, map_writable, max_level, pfn, prefault); -else + }else { + r =make_mmu_pages_available (vcpu); +if (r) + goto out_unlock; r =__direct_map (vcpu, gpa, error_code, map_writable, max_level, pfn, prefault, is_tdp); + } out_unlock:if (is_tdp_mmu_fault)
Greg Kroah-Hartman
maintainerPATCH 94/120 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
@@ -433,7 +433,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 95/120 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
@@ -727,7 +727,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; }else {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 96/120 riscv: Sync efi page tables kernel mappings before switching
In reply to Greg Kroah-HartmanFrom: Alexandre Ghiti <[email protected]>
[ Upstream commit 3f105a742725a1b78766a55169f1d827732e62b8 ]
The EFI page table is initially created as a copy of the kernel page table. With VMAP_STACK enabled, kernel stacks are allocated in the vmalloc area:
if the stack is allocated in a new PGD (one that was not present at the moment of the efi page table creation or not synced in a previous vmalloc fault), the kernel will take a trap when switching to the efi page table when the vmalloc kernel stack is accessed, resulting in a kernel panic.
Fix that by updating the efi kernel mappings before switching to the efi page table.
--- arch/riscv/include/asm/efi.h | 6 +++++- arch/riscv/include/asm/pgalloc.h | 11 ++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-)
arch/riscv/include/asm/efi.h +5 -1
@@ -10,6 +10,7 @@#include <asm/mmu_context.h> #include <asm/ptrace.h> #include <asm/tlbflush.h> +#include <asm/pgalloc.h> #ifdef CONFIG_EFI extern void efi_init (void );
@@ -20,7 +21,10 @@ extern void efi_init(void);int efi_create_mapping (struct mm_struct *mm,efi_memory_desc_t *md);int efi_set_mapping_permissions (struct mm_struct *mm,efi_memory_desc_t *md); -#define arch_efi_call_virt_setup () efi_virtmap_load() +#define arch_efi_call_virt_setup () ({ \ + sync_kernel_mappings(efi_mm.pgd); \ + efi_virtmap_load(); \ + })#define arch_efi_call_virt_teardown () efi_virtmap_unload() #define arch_efi_call_virt(p, f, args...) p->f(args)
arch/riscv/include/asm/pgalloc.h +8 -3
@@ -38,6 +38,13 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd) }#endif /* __PAGETABLE_PMD_FOLDED */ +static inline void sync_kernel_mappings (pgd_t *pgd) +{ +memcpy (pgd +USER_PTRS_PER_PGD , + init_mm.pgd +USER_PTRS_PER_PGD , + (PTRS_PER_PGD -USER_PTRS_PER_PGD ) *sizeof (pgd_t)); +} +static inline pgd_t *pgd_alloc (struct mm_struct *mm) {pgd_t *pgd;
@@ -46,9 +53,7 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)if (likely (pgd !=NULL )) {memset (pgd,0 ,USER_PTRS_PER_PGD *sizeof (pgd_t));/* Copy kernel mappings */ -memcpy (pgd +USER_PTRS_PER_PGD , - init_mm.pgd +USER_PTRS_PER_PGD , - (PTRS_PER_PGD -USER_PTRS_PER_PGD ) *sizeof (pgd_t)); +sync_kernel_mappings (pgd); }return pgd; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 97/120 riscv: fix race when vmap stack overflow
In reply to Greg Kroah-HartmanFrom: Jisheng Zhang <[email protected]>
[ Upstream commit 7e1864332fbc1b993659eab7974da9fe8bf8c128 ]
Currently, when detecting vmap stack overflow, riscv firstly switches to the so called shadow stack, then use this shadow stack to call the get_overflow_stack() to get the overflow stack. However, there's a race here if two or more harts use the same shadow stack at the same time.
To solve this race, we introduce spin_shadow_stack atomic var, which will be swap between its own address and 0 in atomic way, when the var is set, it means the shadow_stack is being used; when the var is cleared, it means the shadow_stack isn't being used.
--- arch/riscv/include/asm/asm.h | 1 + arch/riscv/kernel/entry.S | 13 +++++++++++++ arch/riscv/kernel/traps.c | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+)
arch/riscv/include/asm/asm.h +1 -0
@@ -23,6 +23,7 @@#define REG_L __REG_SEL(ld, lw)#define REG_S __REG_SEL(sd, sw)#define REG_SC __REG_SEL(sc.d, sc.w) +#define REG_AMOSWAP_AQ __REG_SEL(amoswap.d.aq, amoswap.w.aq)#define REG_ASM __REG_SEL(.dword, .word)#define SZREG __REG_SEL(8, 4)#define LGREG __REG_SEL(3, 2)
arch/riscv/kernel/entry.S +13 -0
@@ -387,6 +387,19 @@ handle_syscall_trace_exit: #ifdef CONFIG_VMAP_STACK handle_kernel_stack_overflow: + /* + * Takes the psuedo-spinlock for the shadow stack, in case multiple + * harts are concurrently overflowing their kernel stacks. We could + * store any value here, but since we're overflowing the kernel stack + * already we only have SP to use as a scratch register. So we just + * swap in the address of the spinlock, as that's definately non-zero. + * + * Pairs with a store_release in handle_bad_stack(). + */ +1: la sp, spin_shadow_stack + REG_AMOSWAP_AQ sp, sp, (sp) + bnez sp, 1b + la sp, shadow_stack addi sp, sp, SHADOW_OVERFLOW_STACK_SIZE
arch/riscv/kernel/traps.c +18 -0
@@ -218,11 +218,29 @@ asmlinkage unsigned long get_overflow_stack(void)OVERFLOW_STACK_SIZE ; } +/* +* A pseudo spinlock to protect the shadow stack from being used by multiple +* harts concurrently. This isn't a real spinlock because the lock side must +* be taken without a valid stack and only a single register, it's only taken +* while in the process of panicing anyway so the performance and error +* checking a proper spinlock gives us doesn't matter. +*/ +unsigned long spin_shadow_stack; + asmlinkage void handle_bad_stack(struct pt_regs *regs) {unsigned long tsk_stk = (unsigned long )current->stack;unsigned long ovf_stk = (unsigned long )this_cpu_ptr (overflow_stack); +/* +* We're done with the shadow stack by this point, as we're on the +* overflow stack. Tell any other concurrent overflowing harts that +* they can proceed with panicing by releasing the pseudo-spinlock. +* +* This pairs with an amoswap.aq in handle_kernel_stack_overflow. +*/ +smp_store_release (&spin_shadow_stack,0 ); +console_verbose ();pr_emerg ("Insufficient stack space to handle exception!\n" );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 98/120 riscv: kexec: Fixup irq controller broken in kexec crash path
In reply to Greg Kroah-HartmanFrom: Guo Ren <[email protected]>
[ Upstream commit b17d19a5314a37f7197afd1a0200affd21a7227d ]
If a crash happens on cpu3 and all interrupts are binding on cpu0, the bad irq routing will cause a crash kernel which can't receive any irq. Because crash kernel won't clean up all harts' PLIC enable bits in enable registers. This patch is similar to 9141a003a491 ("ARM: 7316/1:
kexec: EOI active and mask all interrupts in kexec crash path") and 78fd584cdec0 ("arm64: kdump: implement machine_crash_shutdown()"), and PowerPC also has the same mechanism.
--- arch/riscv/kernel/machine_kexec.c | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
arch/riscv/kernel/machine_kexec.c +35 -0
@@ -15,6 +15,8 @@#include <linux/compiler.h> /* For unreachable() */ #include <linux/cpu.h> /* For cpu_down() */ #include <linux/reboot.h> +#include <linux/interrupt.h> +#include <linux/irq.h> /* * kexec_image_info - Print received image details
@@ -154,6 +156,37 @@ void crash_smp_send_stop(void) cpus_stopped =1 ; } +static void machine_kexec_mask_interrupts (void ) +{ +unsigned int i; +struct irq_desc *desc; + +for_each_irq_desc (i, desc) { +struct irq_chip *chip; +int ret; + + chip =irq_desc_get_chip (desc); +if (!chip) +continue ; + +/* +* First try to remove the active state. If this +* fails, try to EOI the interrupt. +*/ + ret =irq_set_irqchip_state (i,IRQCHIP_STATE_ACTIVE , false); + +if (ret &&irqd_irq_inprogress (&desc->irq_data) && + chip->irq_eoi) + chip->irq_eoi (&desc->irq_data); + +if (chip->irq_mask) + chip->irq_mask (&desc->irq_data); + +if (chip->irq_disable && !irqd_irq_disabled (&desc->irq_data)) + chip->irq_disable (&desc->irq_data); + } +} +/* * machine_crash_shutdown - Prepare to kexec after a kernel crash *
@@ -169,6 +202,8 @@ machine_crash_shutdown(struct pt_regs *regs)crash_smp_send_stop ();crash_save_cpu (regs,smp_processor_id ()); +machine_kexec_mask_interrupts (); +pr_info ("Starting crashdump kernel...\n" ); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 99/120 riscv: kexec: Fixup crash_smp_send_stop without multi cores
In reply to Greg Kroah-HartmanFrom: Guo Ren <[email protected]>
[ Upstream commit 9b932aadfc47de5d70b53ea04b0d1b5f6c82945b ]
Current crash_smp_send_stop is the same as the generic one in kernel/panic and misses crash_save_cpu in percpu. This patch is inspired by 78fd584cdec0 ("arm64: kdump: implement machine_crash_shutdown()") and adds the same mechanism for riscv.
Before this patch, test result:
crash> help -r
CPU 0: [OFFLINE]
CPU 1:
epc : ffffffff80009ff0 ra : ffffffff800b789a sp : ff2000001098bb40
gp : ffffffff815fca60 tp : ff60000004680000 t0 : 6666666666663c5b t1 : 0000000000000000 t2 : 666666666666663c s0 : ff2000001098bc90 s1 : ffffffff81600798 a0 : ff2000001098bb48 a1 : 0000000000000000 a2 : 0000000000000000 a3 : 0000000000000001 a4 : 0000000000000000 a5 : ff60000004690800 a6 : 0000000000000000 a7 : 0000000000000000 s2 : ff2000001098bb48 s3 : ffffffff81093ec8 s4 : ffffffff816004ac s5 : 0000000000000000 s6 : 0000000000000007 s7 : ffffffff80e7f720 s8 : 00fffffffffff3f0 s9 : 0000000000000007 s10: 00aaaaaaaab98700
s11: 0000000000000001 t3 : ffffffff819a8097 t4 : ffffffff819a8097 t5 : ffffffff819a8098 t6 : ff2000001098b9a8
CPU 2: [OFFLINE]
CPU 3: [OFFLINE]
After this patch, test result:
crash> help -r
CPU 0:
epc : ffffffff80003f34 ra : ffffffff808caa7c sp : ffffffff81403eb0
gp : ffffffff815fcb48 tp : ffffffff81413400 t0 : 0000000000000000 t1 : 0000000000000000 t2 : 0000000000000000 s0 : ffffffff81403ec0 s1 : 0000000000000000 a0 : 0000000000000000 a1 : 0000000000000000 a2 : 0000000000000000 a3 : 0000000000000000 a4 : 0000000000000000 a5 : 0000000000000000 a6 : 0000000000000000 a7 : 0000000000000000 s2 : ffffffff816001c8 s3 : ffffffff81600370 s4 : ffffffff80c32e18 s5 : ffffffff819d3018 s6 : ffffffff810e2110 s7 : 0000000000000000 s8 : 0000000000000000 s9 : 0000000080039eac s10: 0000000000000000
s11: 0000000000000000 t3 : 0000000000000000 t4 : 0000000000000000 t5 : 0000000000000000 t6 : 0000000000000000
CPU 1:
epc : ffffffff80003f34 ra : ffffffff808caa7c sp : ff2000000068bf30
gp : ffffffff815fcb48 tp : ff6000000240d400 t0 : 0000000000000000 t1 : 0000000000000000 t2 : 0000000000000000 s0 : ff2000000068bf40 s1 : 0000000000000001 a0 : 0000000000000000 a1 : 0000000000000000 a2 : 0000000000000000 a3 : 0000000000000000 a4 : 0000000000000000 a5 : 0000000000000000 a6 : 0000000000000000 a7 : 0000000000000000 s2 : ffffffff816001c8 s3 : ffffffff81600370 s4 : ffffffff80c32e18 s5 : ffffffff819d3018 s6 : ffffffff810e2110 s7 : 0000000000000000 s8 : 0000000000000000 s9 : 0000000080039ea8 s10: 0000000000000000
s11: 0000000000000000 t3 : 0000000000000000 t4 : 0000000000000000 t5 : 0000000000000000 t6 : 0000000000000000
CPU 2:
epc : ffffffff80003f34 ra : ffffffff808caa7c sp : ff20000000693f30
gp : ffffffff815fcb48 tp : ff6000000240e900 t0 : 0000000000000000 t1 : 0000000000000000 t2 : 0000000000000000 s0 : ff20000000693f40 s1 : 0000000000000002 a0 : 0000000000000000 a1 : 0000000000000000 a2 : 0000000000000000 a3 : 0000000000000000 a4 : 0000000000000000 a5 : 0000000000000000 a6 : 0000000000000000 a7 : 0000000000000000 s2 : ffffffff816001c8 s3 : ffffffff81600370 s4 : ffffffff80c32e18 s5 : ffffffff819d3018 s6 : ffffffff810e2110 s7 : 0000000000000000 s8 : 0000000000000000 s9 : 0000000080039eb0 s10: 0000000000000000
s11: 0000000000000000 t3 : 0000000000000000 t4 : 0000000000000000 t5 : 0000000000000000 t6 : 0000000000000000
CPU 3:
epc : ffffffff8000a1e4 ra : ffffffff800b7bba sp : ff200000109bbb40
gp : ffffffff815fcb48 tp : ff6000000373aa00 t0 : 6666666666663c5b t1 : 0000000000000000 t2 : 666666666666663c s0 : ff200000109bbc90 s1 : ffffffff816007a0 a0 : ff200000109bbb48 a1 : 0000000000000000 a2 : 0000000000000000 a3 : 0000000000000001 a4 : 0000000000000000 a5 : ff60000002c61c00 a6 : 0000000000000000 a7 : 0000000000000000 s2 : ff200000109bbb48 s3 : ffffffff810941a8 s4 : ffffffff816004b4 s5 : 0000000000000000 s6 : 0000000000000007 s7 : ffffffff80e7f7a0 s8 : 00fffffffffff3f0 s9 : 0000000000000007 s10: 00aaaaaaaab98700
s11: 0000000000000001 t3 : ffffffff819a8097 t4 : ffffffff819a8097 t5 : ffffffff819a8098 t6 : ff200000109bb9a8
--- arch/riscv/include/asm/smp.h | 3 + arch/riscv/kernel/machine_kexec.c | 21 ++----- arch/riscv/kernel/smp.c | 93 ++++++++++++++++++++++++++++++- 3 files changed, 100 insertions(+), 17 deletions(-)
arch/riscv/include/asm/smp.h +3 -0
@@ -50,6 +50,9 @@ void riscv_set_ipi_ops(const struct riscv_ipi_ops *ops);/* Clear IPI for current CPU */ void riscv_clear_ipi (void ); +/* Check other CPUs stop or not */ +bool smp_crash_stop_failed (void ); +/* Secondary hart entry */ asmlinkage void smp_callin(void);
arch/riscv/kernel/machine_kexec.c +5 -16
@@ -140,22 +140,6 @@ void machine_shutdown(void)#endif } -/* Override the weak function in kernel/panic.c */ -void crash_smp_send_stop (void ) -{ -static int cpus_stopped; - -/* -* This function can be called twice in panic path, but obviously -* we execute this only once. -*/ -if (cpus_stopped) -return ; - -smp_send_stop (); - cpus_stopped =1 ; -} -static void machine_kexec_mask_interrupts (void ) {unsigned int i;
@@ -230,6 +214,11 @@ machine_kexec(struct kimage *image)void *control_code_buffer =page_address (image->control_code_page);riscv_kexec_method kexec_method =NULL ; +#ifdef CONFIG_SMP +WARN (smp_crash_stop_failed (), +"Some CPUs may be stale, kdump will be unreliable.\n" ); +#endif +if (image->type !=KEXEC_TYPE_CRASH ) kexec_method = control_code_buffer;else
arch/riscv/kernel/smp.c +92 -1
140 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 100/120 nvme: fix SRCU protection of nvme_ns_head list
In reply to Greg Kroah-HartmanFrom: Caleb Sander <[email protected]>
[ Upstream commit 899d2a05dc14733cfba6224083c6b0dd5a738590 ]
Walking the nvme_ns_head siblings list is protected by the head's srcu in nvme_ns_head_submit_bio() but not nvme_mpath_revalidate_paths(). Removing namespaces from the list also fails to synchronize the srcu. Concurrent scan work can therefore cause use-after-frees.
Hold the head's srcu lock in nvme_mpath_revalidate_paths() and synchronize with the srcu, not the global RCU, in nvme_ns_remove().
Observed the following panic when making NVMe/RDMA connections with native multipath on the Rocky Linux 8.6 kernel
(it seems the upstream kernel has the same race condition). Disassembly shows the faulting instruction is cmp 0x50(%rdx),%rcx; computing capacity != get_capacity(ns->disk).
Address 0x50 is dereferenced because ns->disk is NULL.
The NULL disk appears to be the result of concurrent scan work freeing the namespace (note the log line in the middle of the panic).
[37314.206036] BUG: unable to handle kernel NULL pointer dereference at 0000000000000050 [37314.206036] nvme0n3: detected capacity change from 0 to 11811160064 [37314.299753] PGD 0 P4D 0 [37314.299756] Oops: 0000 [#1] SMP PTI [37314.299759] CPU: 29 PID: 322046 Comm: kworker/u98:3 Kdump: loaded Tainted: G W X --------- - - 4.18.0-372.32.1.el8test86.x86_64 #1 [37314.299762] Hardware name: Dell Inc. PowerEdge R720/0JP31P, BIOS 2.7.0 05/23/2018 [37314.299763] Workqueue: nvme-wq nvme_scan_work [nvme_core] [37314.299783] RIP: 0010:nvme_mpath_revalidate_paths+0x26/0xb0 [nvme_core] [37314.299790] Code: 1f 44 00 00 66 66 66 66 90 55 53 48 8b 5f 50 48 8b 83 c8 c9 00 00 48 8b 13 48 8b 48 50 48 39 d3 74 20 48 8d 42 d0 48 8b 50 20 <48> 3b 4a 50 74 05 f0 80 60 70 ef 48 8b 50 30 48 8d 42 d0 48 39 d3 [37315.058803] RSP: 0018:ffffabe28f913d10 EFLAGS: 00010202 [37315.121316] RAX: ffff927a077da800 RBX: ffff92991dd70000 RCX: 0000000001600000 [37315.206704] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff92991b719800 [37315.292106] RBP: ffff929a6b70c000 R08: 000000010234cd4a R09: c0000000ffff7fff [37315.377501] R10: 0000000000000001 R11: ffffabe28f913a30 R12: 0000000000000000 [37315.462889] R13: ffff92992716600c R14: ffff929964e6e030 R15: ffff92991dd70000 [37315.548286] FS: 0000000000000000(0000) GS:ffff92b87fb80000(0000) knlGS:0000000000000000 [37315.645111] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [37315.713871] CR2: 0000000000000050 CR3: 0000002208810006 CR4: 00000000000606e0 [37315.799267] Call Trace: [37315.828515] nvme_update_ns_info+0x1ac/0x250 [nvme_core] [37315.892075] nvme_validate_or_alloc_ns+0x2ff/0xa00 [nvme_core] [37315.961871] ? __blk_mq_free_request+0x6b/0x90 [37316.015021] nvme_scan_work+0x151/0x240 [nvme_core] [37316.073371] process_one_work+0x1a7/0x360 [37316.121318] ? create_worker+0x1a0/0x1a0 [37316.168227] worker_thread+0x30/0x390 [37316.212024] ? create_worker+0x1a0/0x1a0 [37316.258939] kthread+0x10a/0x120 [37316.297557] ? set_kthread_struct+0x50/0x50 [37316.347590] ret_from_fork+0x35/0x40 [37316.390360] Modules linked in: nvme_rdma nvme_tcp(X) nvme_fabrics nvme_core netconsole iscsi_tcp libiscsi_tcp dm_queue_length dm_service_time nf_conntrack_netlink br_netfilter bridge stp llc overlay nft_chain_nat ipt_MASQUERADE nf_nat xt_addrtype xt_CT nft_counter xt_state xt_conntrack nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 xt_comment xt_multiport nft_compat nf_tables libcrc32c nfnetlink dm_multipath tg3 rpcrdma sunrpc rdma_ucm ib_srpt ib_isert iscsi_target_mod target_core_mod ib_iser libiscsi scsi_transport_iscsi ib_umad rdma_cm ib_ipoib iw_cm ib_cm intel_rapl_msr iTCO_wdt iTCO_vendor_support dcdbas intel_rapl_common sb_edac x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel ipmi_ssif kvm irqbypass crct10dif_pclmul crc32_pclmul mlx5_ib ghash_clmulni_intel ib_uverbs rapl intel_cstate intel_uncore ib_core ipmi_si joydev mei_me pcspkr ipmi_devintf mei lpc_ich wmi ipmi_msghandler acpi_power_meter ext4 mbcache jbd2 sd_mod t10_pi sg mgag200 mlx5_core drm_kms_helper syscopyarea [37316.390419] sysfillrect ahci sysimgblt fb_sys_fops libahci drm crc32c_intel libata mlxfw pci_hyperv_intf tls i2c_algo_bit psample dm_mirror dm_region_hash dm_log dm_mod fuse [last unloaded: nvme_core] [37317.645908] CR2: 0000000000000050
--- drivers/nvme/host/core.c | 2 +- drivers/nvme/host/multipath.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +1 -1
@@ -3920,7 +3920,7 @@ static void nvme_ns_remove(struct nvme_ns *ns)mutex_unlock (&ns->ctrl->subsys->lock);/* guarantee not available in head->list */ -synchronize_rcu (); +synchronize_srcu (&ns->head->srcu);/* wait for concurrent submissions */ if (nvme_mpath_clear_current_path (ns))
drivers/nvme/host/multipath.c +3 -0
@@ -151,11 +151,14 @@ void nvme_mpath_revalidate_paths(struct nvme_ns *ns)struct nvme_ns_head *head = ns->head;sector_t capacity =get_capacity (head->disk);int node; +int srcu_idx; + srcu_idx =srcu_read_lock (&head->srcu);list_for_each_entry_rcu (ns, &head->list, siblings) {if (capacity !=get_capacity (ns->disk))clear_bit (NVME_NS_READY , &ns->flags); } +srcu_read_unlock (&head->srcu, srcu_idx);for_each_node (node)rcu_assign_pointer (head->current_path[node],NULL );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 101/120 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
@@ -4241,8 +4241,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 102/120 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
@@ -822,6 +822,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 103/120 mm: __isolate_lru_page_prepare() in isolate_migratepages_block()
In reply to Greg Kroah-HartmanFrom: Hugh Dickins <[email protected]>
[ Upstream commit 89f6c88a6ab4a11deb14c270f7f1454cda4f73d6 ]
__isolate_lru_page_prepare() conflates two unrelated functions, with the flags to one disjoint from the flags to the other; and hides some of the important checks outside of isolate_migratepages_block(), where the sequence is better to be visible. It comes from the days of lumpy reclaim, before compaction, when the combination made more sense.
Move what's needed by mm/compaction.c isolate_migratepages_block() inline there, and what's needed by mm/vmscan.c isolate_lru_pages() inline there.
Shorten "isolate_mode" to "mode", so the sequence of conditions is easier to read. Declare a "mapping" variable, to save one call to page_mapping() (but not another: calling again after page is locked is necessary). Simplify isolate_lru_pages() with a "move_to" list pointer.
Stable-dep-of: 829ae0f81ce0 ("mm: migrate: fix THP's mapcount on isolation")
--- include/linux/swap.h | 1 - mm/compaction.c | 51 +++++++++++++++++++--- mm/vmscan.c | 101 ++++++++----------------------------------- 3 files changed, 62 insertions(+), 91 deletions(-)
include/linux/swap.h +0 -1
@@ -378,7 +378,6 @@ extern void lru_cache_add_inactive_or_unevictable(struct page *page,extern unsigned long zone_reclaimable_pages (struct zone *zone);extern unsigned long try_to_free_pages (struct zonelist *zonelist,int order,gfp_t gfp_mask,nodemask_t *mask); -extern bool __isolate_lru_page_prepare (struct page *page,isolate_mode_t mode); extern unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg, unsigned long nr_pages, gfp_t gfp_mask,
mm/compaction.c +44 -7
95 lines not on this page · raw message
mm/vmscan.c +18 -83
151 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 104/120 mm: migrate: fix THPs mapcount on isolation
In reply to Greg Kroah-HartmanFrom: Gavin Shan <[email protected]>
[ Upstream commit 829ae0f81ce093d674ff2256f66a714753e9ce32 ]
The issue is reported when removing memory through virtio_mem device. The transparent huge page, experienced copy-on-write fault, is wrongly regarded as pinned. The transparent huge page is escaped from being isolated in isolate_migratepages_block(). The transparent huge page can't be migrated and the corresponding memory block can't be put into offline state.
Fix it by replacing page_mapcount() with total_mapcount(). With this, the transparent huge page can be isolated and migrated, and the memory block can be put into offline state. Besides, The page's refcount is increased a bit earlier to avoid the page is released when the check is executed.
--- mm/compaction.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
mm/compaction.c +11 -11
@@ -992,29 +992,29 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, goto isolate_fail; } +/* +* Be careful not to clear PageLRU until after we're +* sure the page is not being freed elsewhere -- the +* page release code relies on it. +*/ +if (unlikely (!get_page_unless_zero (page))) + goto isolate_fail; +/* * Migration will fail if an anonymous page is pinned in memory, * so avoid taking lru_lock and isolating it unnecessarily in an * admittedly racy check. */ mapping =page_mapping (page); -if (!mapping &&page_count (page) >page_mapcount (page)) - goto isolate_fail; +if (!mapping && (page_count (page) -1 ) >total_mapcount (page)) + goto isolate_fail_put;/* * Only allow to migrate anonymous pages in GFP_NOFS context * because those do not depend on fs locks. */ if (!(cc->gfp_mask & __GFP_FS) && mapping) - goto isolate_fail; - -/* -* Be careful not to clear PageLRU until after we're -* sure the page is not being freed elsewhere -- the -* page release code relies on it. -*/ -if (unlikely (!get_page_unless_zero (page))) - goto isolate_fail; + goto isolate_fail_put;/* Only take pages on LRU: a check now makes later tests safe */ if (!PageLRU (page))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 105/120 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
@@ -352,8 +352,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 106/120 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
@@ -354,6 +354,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 107/120 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
@@ -1145,6 +1145,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 108/120 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
@@ -1157,8 +1157,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 109/120 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
@@ -886,13 +886,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
@@ -1159,6 +1159,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 110/120 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
@@ -886,9 +886,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
@@ -1164,6 +1164,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 111/120 serial: stm32: Factor out GPIO RTS toggling into separate function
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
[ Upstream commit 3bcea529b295a993b1b05db63f245ae8030c5acf ]
Pull out the GPIO RTS enable and disable handling into separate function. Limit the scope of GPIO RTS toggling only to GPIO emulated RS485 too.
--- drivers/tty/serial/stm32-usart.c | 61 ++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 23 deletions(-)
drivers/tty/serial/stm32-usart.c +38 -23
@@ -325,6 +325,42 @@ static void stm32_usart_tx_interrupt_disable(struct uart_port *port)stm32_usart_clr_bits (port, ofs->cr1,USART_CR1_TXEIE ); } +static void stm32_usart_rs485_rts_enable (struct uart_port *port) +{ +struct stm32_port *stm32_port =to_stm32_port (port); +struct serial_rs485 *rs485conf = &port->rs485; + +if (stm32_port->hw_flow_control || + !(rs485conf->flags &SER_RS485_ENABLED )) +return ; + +if (rs485conf->flags &SER_RS485_RTS_ON_SEND ) { +mctrl_gpio_set (stm32_port->gpios, + stm32_port->port.mctrl |TIOCM_RTS ); + }else { +mctrl_gpio_set (stm32_port->gpios, + stm32_port->port.mctrl & ~TIOCM_RTS ); + } +} + +static void stm32_usart_rs485_rts_disable (struct uart_port *port) +{ +struct stm32_port *stm32_port =to_stm32_port (port); +struct serial_rs485 *rs485conf = &port->rs485; + +if (stm32_port->hw_flow_control || + !(rs485conf->flags &SER_RS485_ENABLED )) +return ; + +if (rs485conf->flags &SER_RS485_RTS_ON_SEND ) { +mctrl_gpio_set (stm32_port->gpios, + stm32_port->port.mctrl & ~TIOCM_RTS ); + }else { +mctrl_gpio_set (stm32_port->gpios, + stm32_port->port.mctrl |TIOCM_RTS ); + } +} +static void stm32_usart_transmit_chars_pio (struct uart_port *port) {struct stm32_port *stm32_port =to_stm32_port (port);
@@ -566,41 +602,20 @@ static void stm32_usart_disable_ms(struct uart_port *port)/* Transmit stop */ static void stm32_usart_stop_tx (struct uart_port *port) { -struct stm32_port *stm32_port =to_stm32_port (port); -struct serial_rs485 *rs485conf = &port->rs485; -stm32_usart_tx_interrupt_disable (port); -if (rs485conf->flags &SER_RS485_ENABLED ) { -if (rs485conf->flags &SER_RS485_RTS_ON_SEND ) { -mctrl_gpio_set (stm32_port->gpios, - stm32_port->port.mctrl & ~TIOCM_RTS ); - }else { -mctrl_gpio_set (stm32_port->gpios, - stm32_port->port.mctrl |TIOCM_RTS ); - } - } +stm32_usart_rs485_rts_disable (port); }/* There are probably characters waiting to be transmitted. */ static void stm32_usart_start_tx (struct uart_port *port) { -struct stm32_port *stm32_port =to_stm32_port (port); -struct serial_rs485 *rs485conf = &port->rs485;struct circ_buf *xmit = &port->state->xmit;if (uart_circ_empty (xmit) && !port->x_char)return ; -if (rs485conf->flags &SER_RS485_ENABLED ) { -if (rs485conf->flags &SER_RS485_RTS_ON_SEND ) { -mctrl_gpio_set (stm32_port->gpios, - stm32_port->port.mctrl |TIOCM_RTS ); - }else { -mctrl_gpio_set (stm32_port->gpios, - stm32_port->port.mctrl & ~TIOCM_RTS ); - } - } +stm32_usart_rs485_rts_enable (port);stm32_usart_transmit_chars (port); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 112/120 serial: stm32: Use TC interrupt to deassert GPIO RTS in RS485 mode
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
[ Upstream commit d7c76716169ddc37cf6316ff381d34ea807fbfd7 ]
In case the RS485 mode is emulated using GPIO RTS, use the TC interrupt to deassert the GPIO RTS, otherwise the GPIO RTS stays asserted after a transmission ended and the RS485 cannot work.
--- drivers/tty/serial/stm32-usart.c | 42 ++++++++++++++++++++++++++++++-- drivers/tty/serial/stm32-usart.h | 1 + 2 files changed, 41 insertions(+), 2 deletions(-)
drivers/tty/serial/stm32-usart.c +40 -2
@@ -314,6 +314,14 @@ static void stm32_usart_tx_interrupt_enable(struct uart_port *port)stm32_usart_set_bits (port, ofs->cr1,USART_CR1_TXEIE ); } +static void stm32_usart_tc_interrupt_enable (struct uart_port *port) +{ +struct stm32_port *stm32_port =to_stm32_port (port); +const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + +stm32_usart_set_bits (port, ofs->cr1,USART_CR1_TCIE ); +} +static void stm32_usart_tx_interrupt_disable (struct uart_port *port) {struct stm32_port *stm32_port =to_stm32_port (port);
@@ -325,6 +333,14 @@ static void stm32_usart_tx_interrupt_disable(struct uart_port *port)stm32_usart_clr_bits (port, ofs->cr1,USART_CR1_TXEIE ); } +static void stm32_usart_tc_interrupt_disable (struct uart_port *port) +{ +struct stm32_port *stm32_port =to_stm32_port (port); +const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + +stm32_usart_clr_bits (port, ofs->cr1,USART_CR1_TCIE ); +} +static void stm32_usart_rs485_rts_enable (struct uart_port *port) {struct stm32_port *stm32_port =to_stm32_port (port);
@@ -462,6 +478,13 @@ static void stm32_usart_transmit_chars(struct uart_port *port)u32 isr;int ret; +if (!stm32_port->hw_flow_control && + port->rs485.flags &SER_RS485_ENABLED ) { + stm32_port->txdone = false; +stm32_usart_tc_interrupt_disable (port); +stm32_usart_rs485_rts_enable (port); + } +if (port->x_char) {if (stm32_port->tx_dma_busy)stm32_usart_clr_bits (port, ofs->cr3,USART_CR3_DMAT );
@@ -501,8 +524,14 @@ static void stm32_usart_transmit_chars(struct uart_port *port)if (uart_circ_chars_pending (xmit) <WAKEUP_CHARS )uart_write_wakeup (port); -if (uart_circ_empty (xmit)) +if (uart_circ_empty (xmit)) {stm32_usart_tx_interrupt_disable (port); +if (!stm32_port->hw_flow_control && + port->rs485.flags &SER_RS485_ENABLED ) { + stm32_port->txdone = true; +stm32_usart_tc_interrupt_enable (port); + } + } }static irqreturn_t stm32_usart_interrupt (int irq,void *ptr)
@@ -515,6 +544,13 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr) sr =readl_relaxed (port->membase + ofs->isr); +if (!stm32_port->hw_flow_control && + port->rs485.flags &SER_RS485_ENABLED && + (sr &USART_SR_TC )) { +stm32_usart_tc_interrupt_disable (port); +stm32_usart_rs485_rts_disable (port); + } +if ((sr &USART_SR_RTOF ) && ofs->icr !=UNDEF_REG )writel_relaxed (USART_ICR_RTOCF , port->membase + ofs->icr);
@@ -612,8 +648,10 @@ static void stm32_usart_start_tx(struct uart_port *port) {struct circ_buf *xmit = &port->state->xmit; -if (uart_circ_empty (xmit) && !port->x_char) +if (uart_circ_empty (xmit) && !port->x_char) { +stm32_usart_rs485_rts_disable (port);return ; + }stm32_usart_rs485_rts_enable (port);
drivers/tty/serial/stm32-usart.h +1 -0
@@ -267,6 +267,7 @@ struct stm32_port {bool hw_flow_control;bool swap;/* swap RX & TX pins */ bool fifoen; +bool txdone;int rxftcfg;/* RX FIFO threshold CFG */ int txftcfg;/* TX FIFO threshold CFG */ bool wakeup_src;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 113/120 serial: stm32: Deassert Transmit Enable on ->rs485_config()
In reply to Greg Kroah-HartmanFrom: Lukas Wunner <[email protected]>
[ Upstream commit adafbbf6895eb0ce41a313c6ee68870ab9aa93cd ]
The STM32 USART can control RS-485 Transmit Enable in hardware. Since commit 7df5081cbf5e ("serial: stm32: Add RS485 RTS GPIO control"), it can alternatively be controlled in software. That was done to allow RS-485 even if the RTS pin is unavailable because it's pinmuxed to a different function.
However the commit neglected to deassert Transmit Enable upon invocation of the ->rs485_config() callback. Fix it.
Avoid forward declarations by moving stm32_usart_tx_empty(), stm32_usart_rs485_rts_enable() and stm32_usart_rs485_rts_disable() further up in the driver.
--- drivers/tty/serial/stm32-usart.c | 100 ++++++++++++++++--------------- 1 file changed, 53 insertions(+), 47 deletions(-)
drivers/tty/serial/stm32-usart.c +53 -47
@@ -61,6 +61,53 @@ static void stm32_usart_clr_bits(struct uart_port *port, u32 reg, u32 bits)writel_relaxed (val, port->membase + reg); } +static unsigned int stm32_usart_tx_empty (struct uart_port *port) +{ +struct stm32_port *stm32_port =to_stm32_port (port); +const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + +if (readl_relaxed (port->membase + ofs->isr) &USART_SR_TC ) +return TIOCSER_TEMT ; + +return 0 ; +} + +static void stm32_usart_rs485_rts_enable (struct uart_port *port) +{ +struct stm32_port *stm32_port =to_stm32_port (port); +struct serial_rs485 *rs485conf = &port->rs485; + +if (stm32_port->hw_flow_control || + !(rs485conf->flags &SER_RS485_ENABLED )) +return ; + +if (rs485conf->flags &SER_RS485_RTS_ON_SEND ) { +mctrl_gpio_set (stm32_port->gpios, + stm32_port->port.mctrl |TIOCM_RTS ); + }else { +mctrl_gpio_set (stm32_port->gpios, + stm32_port->port.mctrl & ~TIOCM_RTS ); + } +} + +static void stm32_usart_rs485_rts_disable (struct uart_port *port) +{ +struct stm32_port *stm32_port =to_stm32_port (port); +struct serial_rs485 *rs485conf = &port->rs485; + +if (stm32_port->hw_flow_control || + !(rs485conf->flags &SER_RS485_ENABLED )) +return ; + +if (rs485conf->flags &SER_RS485_RTS_ON_SEND ) { +mctrl_gpio_set (stm32_port->gpios, + stm32_port->port.mctrl & ~TIOCM_RTS ); + }else { +mctrl_gpio_set (stm32_port->gpios, + stm32_port->port.mctrl |TIOCM_RTS ); + } +} +static void stm32_usart_config_reg_rs485 (u32 *cr1,u32 *cr3,u32 delay_ADE,u32 delay_DDE,u32 baud) {
@@ -149,6 +196,12 @@ static int stm32_usart_config_rs485(struct uart_port *port,stm32_usart_set_bits (port, ofs->cr1,BIT (cfg->uart_enable_bit)); +/* Adjust RTS polarity in case it's driven in software */ +if (stm32_usart_tx_empty (port)) +stm32_usart_rs485_rts_disable (port); +else +stm32_usart_rs485_rts_enable (port); +return 0 ; }
@@ -341,42 +394,6 @@ static void stm32_usart_tc_interrupt_disable(struct uart_port *port)stm32_usart_clr_bits (port, ofs->cr1,USART_CR1_TCIE ); } -static void stm32_usart_rs485_rts_enable (struct uart_port *port) -{ -struct stm32_port *stm32_port =to_stm32_port (port); -struct serial_rs485 *rs485conf = &port->rs485; - -if (stm32_port->hw_flow_control || - !(rs485conf->flags &SER_RS485_ENABLED )) -return ; - -if (rs485conf->flags &SER_RS485_RTS_ON_SEND ) { -mctrl_gpio_set (stm32_port->gpios, - stm32_port->port.mctrl |TIOCM_RTS ); - }else { -mctrl_gpio_set (stm32_port->gpios, - stm32_port->port.mctrl & ~TIOCM_RTS ); - } -} - -static void stm32_usart_rs485_rts_disable (struct uart_port *port) -{ -struct stm32_port *stm32_port =to_stm32_port (port); -struct serial_rs485 *rs485conf = &port->rs485; - -if (stm32_port->hw_flow_control || - !(rs485conf->flags &SER_RS485_ENABLED )) -return ; - -if (rs485conf->flags &SER_RS485_RTS_ON_SEND ) { -mctrl_gpio_set (stm32_port->gpios, - stm32_port->port.mctrl & ~TIOCM_RTS ); - }else { -mctrl_gpio_set (stm32_port->gpios, - stm32_port->port.mctrl |TIOCM_RTS ); - } -} -static void stm32_usart_transmit_chars_pio (struct uart_port *port) {struct stm32_port *stm32_port =to_stm32_port (port);
@@ -590,17 +607,6 @@ static irqreturn_t stm32_usart_threaded_interrupt(int irq, void *ptr)return IRQ_HANDLED ; } -static unsigned int stm32_usart_tx_empty (struct uart_port *port) -{ -struct stm32_port *stm32_port =to_stm32_port (port); -const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; - -if (readl_relaxed (port->membase + ofs->isr) &USART_SR_TC ) -return TIOCSER_TEMT ; - -return 0 ; -} -static void stm32_usart_set_mctrl (struct uart_port *port,unsigned int mctrl) {struct stm32_port *stm32_port =to_stm32_port (port);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 114/120 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 115/120 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
@@ -1051,7 +1051,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",
@@ -1217,7 +1218,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 116/120 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 117/120 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 118/120 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 119/120 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 120/120 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.15.82 release. There are 120 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.15.82-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.15.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
Hello!
Quoted 23 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.15.82 release. There are 120 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.15.82-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.15.y
and the diffstat can be found below.thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:Greg Kroah-Hartman <[email protected]>
Linux 5.15.82-rc1
[...]
Quoted 2 lines
Guo Ren <[email protected]>
riscv: kexec: Fixupcrash_smp_send_stopwithout multi cores
[...]
We have found regression with RISC V with GCC 8 and 11:
-----8<----------8<----------8<----- /builds/linux/arch/riscv/kernel/smp.c: In function 'handle_IPI':
/builds/linux/arch/riscv/kernel/smp.c:195:44: error: 'cpu' undeclared (first use in this function)
195 | ipi_cpu_crash_stop(cpu, get_irq_regs());
| ^~~
/builds/linux/arch/riscv/kernel/smp.c:195:44: note: each undeclared identifier is reported only once for each function it appears in /builds/linux/arch/riscv/kernel/smp.c:217:22: error: 'old_regs' undeclared (first use in this function)
217 | set_irq_regs(old_regs);
| ^~~~~~~~make[3]: *** [/builds/linux/scripts/Makefile.build:289:arch/riscv/kernel/smp.o] Error 1
make[3]: Target '__build' not remade because of errors. make[2]: *** [/builds/linux/scripts/Makefile.build:552:arch/riscv/kernel] Error 2
make[2]: Target '__build' not remade because of errors. make[1]: *** [/builds/linux/Makefile:1900: arch/riscv] Error 2 make[1]: Target '__all' not remade because of errors.
make: *** [Makefile:219: __sub-make] Error 2 ----->8---------->8---------->8-----
Bisection points to the above commit ("riscv: kexec: Fixup crash_smp_send_stop without multi cores"). Reverting it makes the build pass.
In order to reproduce:
# See https://docs.tuxmake.org/ for complete documentation. # Original tuxmake command with fragments listed below. tuxmake --runtime podman --target-arch riscv --toolchain gcc-11 --kconfig defconfig
Greetings!
Daniel Díaz
[email protected]
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.15.82 release. There are 120 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.15.82-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.15.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Quoted 5 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.15.82 release. There are 120 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.
Successfully cross-compiled for arm64 (bcm2711_defconfig, GCC 10.2.0) and powerpc (ps3_defconfig, GCC 12.2.0).
Signature · 1 line
An old man doll... just what I always wanted! - Clara
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.15.82 release. There are 120 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.15.82-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.15.y
and the diffstat can be found below.thanks,
greg k-h
Fails to build on RISC-V RV64 with the following:
arch/riscv/kernel/smp.c: In function ‘handle_IPI’:arch/riscv/kernel/smp.c:195:44: error: ‘cpu’ undeclared (first use in this function)
195 | ipi_cpu_crash_stop(cpu, get_irq_regs());
| ^~~arch/riscv/kernel/smp.c:195:44: note: each undeclared identifier is reported only once for each function it appears in arch/riscv/kernel/smp.c:217:22: error: ‘old_regs’ undeclared (first use in this function)
217 | set_irq_regs(old_regs);
| ^~~~~~~~
It's caused by the patch "riscv: kexec: Fixup crash_smp_send_stop without multi cores".
That patch relies on a much older patch that was never backported to 5.15.
The patch "riscv: kexec: Fixup irq controller broken in kexec crash path" should also be reverted since it's part of the same series.
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.15.82 release. There are 120 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.15.82-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.15.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
RISC V build regression reported.
NOTE:
RISC V defconfig build regression,
Build error:
make --silent --keep-going --jobs=8 O=/home/tuxbuild/.cache/tuxmake/builds/1/build LLVM=1 LLVM_IAS=1 ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- 'HOSTCC=sccache clang' 'CC=sccache clang'arch/riscv/kernel/smp.c:195:23: error: use of undeclared identifier 'cpu'
ipi_cpu_crash_stop(cpu, get_irq_regs());
^
arch/riscv/kernel/smp.c:217:15: error: use of undeclared identifier 'old_regs'
set_irq_regs(old_regs);
^2 errors generated.
make[3]: *** [scripts/Makefile.build:289: arch/riscv/kernel/smp.o] Error 1
ref:
https://lore.kernel.org/stable/CAEUSe7_2g6fde2JU7_yA9QCK+FfdLshCRnDd81FF3=SJwwDAzg@mail.gmail.com/
## Build
* kernel: 5.15.82-rc1
* git: https://gitlab.com/Linaro/lkft/mirrors/stable/linux-stable-rc
* git branch: linux-5.15.y
* git commit: 0ba3dda3cd904c39dff762076fae4a21634b8db6
* git describe: v5.15.81-121-g0ba3dda3cd90
* test details:
https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-5.15.y/build/v5.15.81-121-g0ba3dda3cd90
## Test Regressions (compared to v5.15.81)
* riscv, build
- clang-15-defconfig
- clang-nightly-defconfig
- gcc-11-defconfig
- gcc-8-defconfig
## Metric Regressions (compared to v5.15.81)
## Test Fixes (compared to v5.15.81)
## Metric Fixes (compared to v5.15.81)
## Test result summary
total: 119887, pass: 104751, fail: 2682, skip: 12101, xfail: 353
## Build Summary
* arc: 5 total, 5 passed, 0 failed
* arm: 147 total, 146 passed, 1 failed
* arm64: 45 total, 43 passed, 2 failed
* i386: 35 total, 33 passed, 2 failed
* mips: 27 total, 27 passed, 0 failed
* parisc: 6 total, 6 passed, 0 failed
* powerpc: 30 total, 30 passed, 0 failed
* riscv: 10 total, 6 passed, 4 failed
* s390: 12 total, 12 passed, 0 failed
* sh: 12 total, 12 passed, 0 failed
* sparc: 6 total, 6 passed, 0 failed
* x86_64: 38 total, 36 passed, 2 failed
## Test suites summary
* boot
* fwts
* igt-gpu-tools
* kselftest-android
* kselftest-arm64
* kselftest-arm64/arm64.btitest.bti_c_func
* kselftest-arm64/arm64.btitest.bti_j_func
* kselftest-arm64/arm64.btitest.bti_jc_func
* kselftest-arm64/arm64.btitest.bti_none_func
* kselftest-arm64/arm64.btitest.nohint_func
* kselftest-arm64/arm64.btitest.paciasp_func
* kselftest-arm64/arm64.nobtitest.bti_c_func
* kselftest-arm64/arm64.nobtitest.bti_j_func
* kselftest-arm64/arm64.nobtitest.bti_jc_func
* kselftest-arm64/arm64.nobtitest.bti_none_func
* kselftest-arm64/arm64.nobtitest.nohint_func
* kselftest-arm64/arm64.nobtitest.paciasp_func
* kselftest-breakpoints
* kselftest-drivers-dma-buf
* kselftest-efivarfs
* kselftest-gpio
* kselftest-intel_pstate
* kselftest-lib
* kselftest-net
* kselftest-net-forwarding
* kselftest-net-mptcp
* kselftest-netfilter
* kselftest-openat2
* kselftest-seccomp
* kselftest-timens
* kunit
* kvm-unit-tests
* libgpiod
* libhugetlbfs
* log-parser-boot
* log-parser-test
* ltp-cap_bounds
* ltp-commands
* ltp-containers
* ltp-controllers
* ltp-cpuhotplug
* ltp-crypto
* ltp-cve
* ltp-dio
* ltp-fcntl-locktests
* ltp-filecaps
* ltp-fs
* ltp-fs_bind
* ltp-fs_perms_simple
* ltp-fsx
* ltp-hugetlb
* ltp-io
* ltp-ipc
* ltp-math
* ltp-mm
* ltp-nptl
* ltp-open-posix-tests
* ltp-pty
* ltp-sched
* ltp-securebits
* ltp-smoke
* ltp-syscalls
* ltp-tracing
* network-basic-tests
* packetdrill
* perf
* perf/Zstd-perf.data-compression
* rcutorture
* v4l2-compliance
* vdso
--
Linaro LKFT
https://lkft.linaro.org