Skip to contentSkip to conversation

6.12.113-rc1 review

PATCH Applied Greg Kroah-Hartman 13 participants 529 messages Oct 13 – Oct 15 Page 1 of 4

Subsystems (5)
lore
Share & tools
lore

Greg Kroah-Hartman

author maintainer
#0 lore raw

cover 6.12.113-rc1 review

This is the start of the stable review cycle for the 6.12.113 release. There are 497 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 Thu, 15 Oct 2026 11:28:22 +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/v6.x/stable-review/patch-6.12.113-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-6.12.y
and the diffstat can be found below.

thanks,

greg k-h

-------------
Pseudo-Shortlog of commits:

Greg Kroah-Hartman <[email protected]>

    Linux 6.12.113-rc1

Adrian Bente <[email protected]>
netfilter: flowtable: fix offloaded ct timeout never being extended

Florian Westphal <[email protected]>
netfilter: conntrack: fix erronous removal of offload bit

Jens Axboe <[email protected]>

    io_uring/waitid: fix KCSAN warning on io_waitid->head

Jens Axboe <[email protected]>
io_uring/waitid: use io_waitid_remove_wq() consistently

Osama Abdelkader <[email protected]>
drm/panthor: validate userspace queue count against initialized firmware slot count

Maíra Canal <[email protected]>
drm/vc4: Fix binner slot allocation failing on an idle GPU

Maxime Ripard <[email protected]>
drm/vc4: Make v3d paths unavailable on any generation newer than vc4

Ilia Gavrilov <[email protected]>
vsock: Fix memory leak in vmci_transport_recv_dgram_cb()

Fernando Fernandez Mancera <[email protected]>
net: openvswitch: validate transport header presence in set_ipv6_addr

Vadim Fedorenko <[email protected]>
ptp: ocp: fix PCIe delay estimation calculation

Willem de Bruijn <[email protected]>
net/packet: call packet_parse_headers after virtio_net_hdr_to_skb

Petr Machata <[email protected]>
mlxsw: spectrum_flower: Fix port range register leak in tmplt_create()

Li RongQing <[email protected]>
net/mlx5e: Order ICOSQ cc update after CQ doorbell

Tianyi Gao <[email protected]>
veth: fix peer NETDEV_XDP_ACT_NDO_XMIT after GRO is toggled while down

Gyeyoung Baek <[email protected]>
drm/imagination: Fix reference and vm_bo handling in remap()

Eric Dumazet <[email protected]>
flow_dissector: avoid u16 truncation of hlen in bpf_flow_dissect()

Michael Chan <[email protected]>
bnxt_en: Fix driver init in kdump kernel

Michael Chan <[email protected]>
bnxt_en: Add bnxt_clear_bars() helper

Haishuang Yan <[email protected]>
pfcp: make sure the SEID is linear before reading it

Victor Nogueira <[email protected]>
net/sched: cls_route: reject change with no routing attribute

Haishuang Yan <[email protected]>
devlink: fix devlink_rel reference leak when notify work is pending

Eric Dumazet <[email protected]>

    flow_dissector: avoid u16 truncation of skb->len when computing thoff

Waiman Long <[email protected]>
cgroup/cpuset: Call is_in_v2_mode() after acquiring cpuset_mutex in cpuset_handle_hotplug()

Chen Ridong <[email protected]>
cpuset: separate tmpmasks and cpuset allocation logic

Marek Szyprowski <[email protected]>
ASoC: samsung: i2s: enable op_clk in probe to balance runtime PM

Alvin Šipraga <[email protected]>
ASoC: adau1372: fix invalid default state of output ASRC and DAC muxes

Alvin Šipraga <[email protected]>
ASoC: adau1372: allow sleepy powerdown GPIOs

Devin Wittmayer <[email protected]>
wifi: mt76: mt792x: pick the SAR table layout from the table itself

Junjie Cao <[email protected]>

    wifi: mt76: mt792x: treat 0xff ACPI SAR entries as no limit

Devin Wittmayer <[email protected]>
wifi: mt76: mt7925: don't put the band auto marker in TGID

Nicolas Cavallari <[email protected]>
wifi: mt76: mt7915: disable rx napi when removing device

Tao Gong <[email protected]>

    wifi: mt76: mt7996: fix struct mt7996_mcu_wed_rro_ba_delete_event layout

Aaron Ma <[email protected]>
wifi: mt76: mt7925: restore the legacy BSS after MLO teardown

Filipe Manana <[email protected]>
btrfs: fix lost error return value in btrfs_listxattr()

Filipe Manana <[email protected]>
btrfs: fix xattr replace when multiple xattrs are packed in the same item

Fuad Tabba <[email protected]>
arm64/boot: Don't set PMUv3p9 FGT2 bits without PMUv3

Sang-Hoon Choi <[email protected]>
nvmet: use the local P2P device on metadata allocation failure

Mahantesh Salimath <[email protected]>
tee: optee: ffa: support shared memory offsets on large-page kernels

Rodrigo Zaiden <[email protected]>
tee: optee: fix kernel-doc warnings

Jens Wiklander <[email protected]>
optee: sync secure world ABI headers

Sang-Hoon Choi <[email protected]>
cxgb4/ch_ktls: disable softirqs around tid_list erases

Omar Ramadan <[email protected]>
amt: send the relay's General Query directly from the receive path

Jamal Hadi Salim <[email protected]>
net/sched: em_text: reject unterminated algo before autoload

Maíra Canal <[email protected]>
drm/vc4: Free the BO cache size list on teardown

Myeonghun Pak <[email protected]>
drm/aspeed: Balance the display clock enable on teardown

Sang-Hoon Choi <[email protected]>
gpio: exar: initialize the ID before registering its cleanup

Oleg Keri <[email protected]>
drm/dp: don't mark the AUX backlight enabled when enabling failed

Sai Teja Aluvala <[email protected]>
Bluetooth: btintel_pcie: Add shared HW reset for clean start

Kiran K <[email protected]>
Bluetooth: btintel_pcie: Add recovery mechanism

Ravindra <[email protected]>
Bluetooth: btintel_pcie: fix TX descriptor bounds check

Vincent Jardin <[email protected]>
arm64: dts: lx2160a: fix the iic5 spi3 pinmux offset and value

Vincent Jardin <[email protected]>
arm64: dts: lx2160a: fix IIC1 pinmux submask rejected by pinctrl-single

Vincent Jardin <[email protected]>
arm64: dts: lx2160a: fix incorrect pinmux

Christian Brauner <[email protected]>
namespace: refuse an automount below a mount that is in no namespace

Christian Brauner <[email protected]>
namei: don't reveal overmounted entries in refwalk

Christian Brauner <[email protected]>
namespace: don't let a pseudo dentry become the root of a mount

Christian Brauner <[email protected]>
dcache: don't put a mountpoint on a dentry that's being removed

Christian Brauner <[email protected]>
namespace: check a submount for references right before unmounting it

Christian Brauner <[email protected]>
fs: refuse fspick() on internal superblocks

Christian Brauner <[email protected]>
namespace: don't copy an unmounted mount tree

Leo Li <[email protected]>
drm/amd/display: Fix direct scanout alpha on some DRM_FORMATs

Mikhail Gavrilov <[email protected]>
drm/amdgpu: copy debugfs register data outside the GRBM/SRBM locks

Alex Deucher <[email protected]>
drm/amdgpu: make Mac FB workaround generic

Vitaly Prosyak <[email protected]>
drm/amdgpu: serialize vblank counter reads against GPU reset

Haojie Li <[email protected]>
drm/amdkfd: fix dma_buf reference leak in get_dmabuf_info

Saleel Kudchadker <[email protected]>
drm/amdkfd: align SDMA doorbell base for shader doorbell writes

Fan Wu <[email protected]>
drm/vc4: drain the hangcheck timer and works on V3D unbind

Gyeyoung Baek <[email protected]>
drm/imagination: Size page table preallocation by device address

Krzysztof Karas <[email protected]>
drm/i915/gt: Unmask interrupts only when ACTIVE is true

Krzysztof Karas <[email protected]>
drm/i915/gem: Prevent overstepping exec array boundary

Sajal Gupta <[email protected]>
drm/gud: don't keep a connector without a CRTC as connector_state

Nguyen Ngoc Thang <[email protected]>
drm/fb-helper: defer setup when fbdev_probe() fails, not just on -EAGAIN

Palla Raghunath <[email protected]>
Bluetooth: RFCOMM: Fix NULL tty_dev dereference in rfcomm_dev_shutdown

Maxim Skokov <[email protected]>
Bluetooth: RFCOMM: free the skb when the DLC has no owner

Iaroslav Voitovych <[email protected]>
Bluetooth: MGMT: Fix status of pending commands flushed on power off

Chengfeng Ye <[email protected]>
Bluetooth: ISO: Serialize concurrent connect calls

Chengfeng Ye <[email protected]>
Bluetooth: ISO: Reject concurrent BIS listener setup

Chengfeng Ye <[email protected]>
Bluetooth: hci_sock: Serialize dead-device detachment

Runyu Xiao <[email protected]>
Bluetooth: btintel_pcie: use managed IRQ teardown

Karl Mehltretter <[email protected]>
riscv: fix load_unaligned_zeropad() fixup for RV32

Ziyi Guo <[email protected]>
riscv: entry: gate shadow call stack reload on sstatus.SPP, not tp

Runyu Xiao <[email protected]>
scsi: qedi: Initialize callback state before registration

Shawn Lin <[email protected]>
pmdomain: rockchip: propagate subdomain add errors

Shawn Lin <[email protected]>
pmdomain: rockchip: fix clock leak on domain probe failure

Shawn Lin <[email protected]>
pmdomain: rockchip: don't ignore clock lookup errors on attach

Ming Qian <[email protected]>
pmdomain: imx8m-blk-ctrl: Serialize power on/off across sibling domains

Ridham Khurana <[email protected]>
regulator: tps6594-regulator: Fix n_linear_ranges for TPS65224 BUCK2-4

Abhishek Ojha <[email protected]>
regulator: ltc3676: don't read the write-only HRST and CLIRQ registers

Shao-Fu Chen <[email protected]>
optee: register TEE devices only once fully initialized

Denis V. Lunev <[email protected]>
openvswitch: fix soft lockup in the netlink flow dump

Karl Bonde Torp <[email protected]>
nvme: fix swapped ZRASF zone state values for full and read only

Weiming Shi <[email protected]>
net: team: free skb when broadcast has no txable port

Fredrik Nyberg <[email protected]>
net: usb: ax88179_178a: fix rx frame length for non-last packets

Daniel Machon <[email protected]>
net: sparx5: free the matchall entry on destroy

Josef Bacik <[email protected]>
net: skbuff: don't leave stale bytes in skb_copy_and_csum_bits()

Sebastien Royen <[email protected]>
net: dsa: microchip: fix KSZ8765 fiber detection

Zixuan Chai <[email protected]>
net: bridge: avoid recursive multicast port cleanup

Chengfeng Ye <[email protected]>
net/smc: protect clcsock lifetime in smc_getname

Quchaosheng <[email protected]>
net/packet: guard the ll header push in packet_rcv_spkt()

Guangshuo Li <[email protected]>
mmc: sdhci-sprd: disable runtime PM on remove

Yibo Tan <[email protected]>
mmc: mtk-sd: Cancel request timeout work on remove

Guangshuo Li <[email protected]>
mmc: cavium-thunderx: destroy slot platform devices on remove

Guangshuo Li <[email protected]>
mmc: cavium-octeon: destroy slot platform devices on remove

Mikulas Patocka <[email protected]>
dm: fix reading free memory in do_resume

Ma Xinmeng <[email protected]>
dm-snap: reject the transient exception store for snapshot-merge

Ben Cressey <[email protected]>
dm-crypt: reject the lmk IV mode with AEAD ciphers

Nguyen Ngoc Thang <[email protected]>
memstick: rtsx_usb_ms: complete requests after eject instead of dropping them

Raj Ojha <[email protected]>
memstick: core: wait for request completion before freeing card

성병찬 <[email protected]>
KEYS: Fix add_key() race with keyring restriction

Karl Mehltretter <[email protected]>
keys: finalize persistent keyring timeout after link attempt

Tristan Madani <[email protected]>
ice: fix metadata_dst refcount handling on representor teardown

Mingming Cao <[email protected]>
ibmveth: fix TX LTB and filter unwind on open-fail

Mingming Cao <[email protected]>
ibmveth: h_free logical LAN on open-fail after register

Ridham Khurana <[email protected]>
gpio: xilinx: fix runtime PM leak on request error path

Vishal Badole <[email protected]>
EDAC/amd64: Mask UMC chip select to the four implemented selects

Hui Peng <[email protected]>
sctp: copy zeroed stats to user in sctp_getsockopt_pr_streamstatus() when !streamoute

Stephen Smalley <[email protected]>
selinux: preserve NATIVE_LABELS on already-initialized sb in set_mnt_opts

Christian Göttsche <[email protected]>
selinux: fix data race on AVC latest_notif

Johannes Berg <[email protected]>
Revert "wifi: libertas: reject short monitor TX frames"

Chengfeng Ye <[email protected]>
tipc: hold a reference to nodes found by link name

Yuqi Xu <[email protected]>
tipc: destroy topsrv workqueues before closing connections

Daehyeon Ko <[email protected]>
tcp: reject net_iov in zerocopy receive mapping hints

Marek Szyprowski <[email protected]>
swiotlb: fix default_swiotlb_limit() for non-growable default pool

Sabrina Dubroca <[email protected]>
strparser: make sure __strp_recv isn't running before tearing down the parser

Georgiy Osokin <[email protected]>
tee: shm: reject zero-sized allocations in tee_dyn_shm_alloc_helper()

Josef Bacik <[email protected]>
xen/netfront: don't leak the skb when xennet_fill_frags() fails

Pavankumar Kondeti <[email protected]>
workqueue: Fix NULL current_pwq deref in chained work check

Jason A. Donenfeld <[email protected]>
wireguard: noise: reject response consumption after intermediate initiation

Ramses de Norre <[email protected]>
wireguard: queueing: preserve tstamp_type when encapsulating packet

Michele Dionisio <[email protected]>
wifi: brcmfmac: fix P2P device removal race in brcmf_detach()

Daehyeon Ko <[email protected]>
vsock/virtio: account only unread bytes in read_skb()

Ji-Ze Hong (Peter Hong) <[email protected]>

    usb: f81604: fix struct f81604_int_data size mismatch

Palla Raghunath <[email protected]>
dm ioctl: don't let data_start run past the buffer

Daehyeon Ko <[email protected]>
cipso: adjust cached option offsets when removing CIPSO

Wentao Liang <[email protected]>
btrfs: scrub: fix local_root reference leak in scrub_print_warning_inode()

Michael Garland <[email protected]>
ASoC: amd: yc: Add DMI quirk for Acer Aspire Go 15 (AG15-21P)

Karl Mehltretter <[email protected]>
arm64: irq: exclude the softirq stack switch from KCOV

Krzysztof Furman <[email protected]>
Input: xpad - add support for Corsair Novablade Pro

Haotian Zhang <[email protected]>
Input: ati_remote2 - fix type confusion in device attribute handlers

Daehyeon Ko <[email protected]>
ipv6: do not warn on route notification size race

Daehyeon Ko <[email protected]>
ipv4: do not warn on route notification size race

Daehyeon Ko <[email protected]>
ipv4: stop route notification sizing when nexthop group shrinks

Daehyeon Ko <[email protected]>
ipv4: stop exception dump when nexthop group shrinks

Daehyeon Ko <[email protected]>
ipv4: stop PMTU walk when nexthop group shrinks

Michael S. Tsirkin <[email protected]>
ipv4: validate checksum_start before completing checksum

Eric Biggers <[email protected]>
crypto: drbg - Fix ineffective sanity check

Baochen Qiang <[email protected]>
wifi: ath12k: fix reusing m3 memory

Jiajia Liu <[email protected]>
Bluetooth: hci_event: fix simultaneous discovery stuck in FINDING

Liew Rui Yan <[email protected]>
mm/damon/core: fix unconditionally skip last region

SeongJae Park <[email protected]>
mm/damon/core: do non-safe region walk on kdamond_apply_schemes()

Chao Yu <[email protected]>
f2fs: fix to reset all pinned status during fggc

Chao Yu <[email protected]>
f2fs: fix to shrink gc_lock coverage in f2fs_gc_range()

Chao Yu <[email protected]>
f2fs: fix to reclaim space in f2fs_allocate_pinning_section()

Remy D. Farley <[email protected]>
doc/netlink: netlink-raw: Add max check

Jakub Kicinski <[email protected]>
tools: ynl: add scope qualifier for definitions

Jakub Kicinski <[email protected]>
tools: ynl-gen: support limits using definitions

Jakub Kicinski <[email protected]>
tools: ynl-gen: use names of constants in generated limits

Matti Vaittinen <[email protected]>
iio: light: rohm-bu27034: Fix error return

Matti Vaittinen <[email protected]>
iio: light: rohm-bu27034: Fix infinite delay on error

Matti Vaittinen <[email protected]>
iio: bu27034: simplify using guard(mutex)

Pengpeng Hou <[email protected]>
iio: cdc: ad7150: fix OF matching and publish module aliases

Michael Hennerich <[email protected]>
iio: buffer-dmaengine: fix sg entry iteration when building dma_vecs

Paulo Alcantara <[email protected]>
smb: client: only require read lease for size-extending preallocate

Fabrice Gasnier <[email protected]>
iio: adc: stm32-adc: fix possible division by zero in processed channel

Vladyslav Ivashchenko <[email protected]>
iio: adc: axp288: Add TS bias override for Haier HV103H

Cong Nguyen <[email protected]>
iio: adc: max1363: sign-extend bipolar differential channel reads

Pengpeng Hou <[email protected]>
iio: adc: aspeed: propagate reset deassert errors

Krzysztof Kozlowski <[email protected]>
iio: adc: aspeed: Simplify with dev_err_probe

Fan Wu <[email protected]>
iio: adc: ad_sigma_delta: fix use-after-free on unbind

Matti Vaittinen <[email protected]>
iio: accel: kionix-kx022a: Prevent memory leak and fix state

Matti Vaittinen <[email protected]>
iio: accel: kx022a: Use cleanup.h helpers

Felix Fietkau <[email protected]>

    wifi: mac80211: set info->band for 802.3 encap offload frames

Tamizh Chelvam Raja <[email protected]>

    wifi: mac80211: Add sta pointer sanity check in ieee80211_8023_xmit()

Sean Christopherson <[email protected]>
KVM: SVM: Use the active VMCB's MSR bitmap when checking if MSR is intercepted

Dipayaan Roy <[email protected]>
net: mana: remove double CQ cleanup in mana_create_rxq error path

Dipayaan Roy <[email protected]>
net: mana: Skip WQ object destruction for uninitialized RXQ

Dipayaan Roy <[email protected]>
net: mana: check xdp_rxq registration before unreg in mana_destroy_rxq()

Jerome Tollet <[email protected]>
net/mlx5e: Prevent stale XSK buffer release on MPWQE refill retry

Jerome Tollet <[email protected]>
net/mlx5e: Prevent stale XSK buffer release on refill retry

Matthew Wilcox (Oracle) <[email protected]>
fs: Free any excess xarray nodes in clear_inode()

Zhiling Zou <[email protected]>
wifi: mac80211: count only matching reservations in reserved switch

Johan Hovold <[email protected]>
tty: port: fix tty_port_tty_vhangup() race

Eric Dumazet <[email protected]>
bnxt_en: fix DMA mapping length for padded small packets

Eric Dumazet <[email protected]>
ipv4: free inet_opt and ireq_opt after an RCU grace period

Fuad Tabba <[email protected]>
KVM: arm64: Apply the fine-grained UNDEFs without FEAT_FGT

Guixin Liu <[email protected]>
nvme-multipath: set BLK_FEAT_ZONED only after the zone info is known

Han Xu <[email protected]>
mtd: spinand: Enable QE on all dies

Zhao Li <[email protected]>
wifi: mac80211: shut down RX BA session timer on teardown

Nuno Sá <[email protected]>
mtd: spinand: fix NULL pointer dereference with no ECC engine

Timur Kristóf <[email protected]>
drm/amd/display: Mark DCE 6.4 as not APU

Abdurrahman Hussain <[email protected]>
i2c: xiic: preserve PEC byte length in SMBus block read setup

Manikanta Guntupalli <[email protected]>
i2c: xiic: Relocate xiic_i2c_runtime_suspend and xiic_i2c_runtime_resume to facilitate atomic mode

Aaron Kling <[email protected]>
ALSA: hda/tegra: Re-enable SDO workaround for Tegra194

Ian Rogers <[email protected]>
perf: Replace perf_event_header__init_id with full header init

Daniel Starke <[email protected]>
tty: n_gsm: fix missing modem controls after DLCI open in convergence layer type 2

Johan Hovold <[email protected]>
tty: tty_port: restore TTY_IO_ERROR on activation failure

Jiri Slaby (SUSE) <[email protected]>
tty: tty_port: use guard()s

Jiri Slaby (SUSE) <[email protected]>
tty: introduce tty_port_tty guard()

Pannarat Wiriyaarritham <[email protected]>
usb: typec: ucsi: acpi: Assume UCSI 1.2 on Acer Nitro ANV15-41

Arthur Heymans <[email protected]>
drm/amd/display: Preserve eDP mode on initial ASSR failure

Runyu Xiao <[email protected]>
USB: dwc2: shut down wakeup timer before freeing HCD state

Myeonghun Pak <[email protected]>
usb: ohci-spear: disable controller wakeup on removal

Chen Ni <[email protected]>
usb: ohci-spear: Remove unnecessary NULL check before clk_disable_unprepare()

Francisco Beltrán Millalén <[email protected]>
drm/amdgpu: reset VI ASIC on MacBookPro14,3

Andre Eikmeyer <[email protected]>
drm/amdgpu: reset VI ASIC on MacBookPro15,1

Eric Biggers <[email protected]>
fsverity: add dependency on 64K or smaller pages

Mostafa Saleh <[email protected]>
KVM: arm64: Use stage-1 leaf size for VM_PFNMAP

Beata Michalska <[email protected]>

    arm64: errata: Add Cortex-A725 erratum 3821522 workaround

Beata Michalska <[email protected]>
arm64: errata: Factor out broken AMU const counter cap

Chengfeng Ye <[email protected]>
Bluetooth: Serialize SMP remote OOB data access

Chengfeng Ye <[email protected]>
Bluetooth: hci_core: Serialize SCO and ISO scheduling with teardown

Mark Rutland <[email protected]>
arm64/fpsimd: signal: Forbid non-streaming SVE payload on SME-only systems

Mark Rutland <[email protected]>
arm64/fpsimd: signal: Consistently read FPSIMD context

Mark Rutland <[email protected]>
arm64/fpsimd: signal: Mandate SVE payload for streaming-mode state

Mark Rutland <[email protected]>
arm64/fpsimd: signal: Clear PSTATE.SM when restoring FPSIMD frame only

Zhengchuan Liang <[email protected]>
perf: Require kernel access for text poke events

Dapeng Mi <[email protected]>
perf/core: Check kernel access when kernel callchains are requested

Luo Gengkun <[email protected]>
perf: Remove unnecessary parameter of security check

Johan Hovold <[email protected]>
tty: fix saved termios reset race

Jiazi Liu <[email protected]>
usb: dwc3: gadget: fix IRQ storm on invalid event buffer count

Timur Kristóf <[email protected]>
drm/amd/display: Fix fast updates on DCE 8.1

Andrey Albershteyn <[email protected]>
fs,fsverity: remove check for fsverity being enabled in setattr_prepare()

Christoph Hellwig <[email protected]>
fs,fsverity: reject size changes on fsverity files in setattr_prepare

Josef Bacik <[email protected]>
xen/netfront: drop RX packets with a short Ethernet header

Gilberto Conde <[email protected]>
net: usb: qmi_wwan: add Quectel EG120K-EA

David Howells <[email protected]>
cifs: Fix handling of a beyond-EOF DIO/unbuffered read over SMB1

Marc Zyngier <[email protected]>
KVM: arm64: vgic-its: Fix MOVALL handling of source redistributor

Baolin Wang <[email protected]>
mm: shmem: ignore sysfs configs for shmem forced collapse

Baolin Wang <[email protected]>
mm: shmem: change shmem_huge_global_enabled() to return huge order bitmap

Baolin Wang <[email protected]>
mm: factor out the order calculation into a new helper

Kefeng Wang <[email protected]>
mm: shmem: remove __shmem_huge_global_enabled()

Paulo Alcantara <[email protected]>
netfs: clear post-EOF pagecache when extending a file via write

Xuanqiang Luo <[email protected]>
pfcp: fix socket lifetime on netdevice registration failure

Bartosz Golaszewski <[email protected]>
net: phy: aquantia: fix system interface type not updated in forced mode

Paolo Abeni <[email protected]>
mptcp: prevent race between disconnect() and rtx

Mehmet Fide <[email protected]>
mtd: rawnand: vf610_nfc: fix false bitflips on reads of erased pages

Yi Yang <[email protected]>
vc_screen: reload vc pointer before if (ret) in vcs_write() to avoid UAF

Jiri Slaby (SUSE) <[email protected]>
tty/vt: use guard()s

Jiri Slaby (SUSE) <[email protected]>
console: introduce console_lock guard()s

Asad Kamal <[email protected]>
drm/amd/powerplay: fix VoltageObjectInfo zero-stride loop and OOB read

Chuck Lever <[email protected]>
svcrdma: Use svc_xprt_put to free listener on create failure

Fuad Tabba <[email protected]>
KVM: arm64: vgic-its: Don't dereference a NULL collection on ITT save

Aditya Dutt <[email protected]>
jfs: fix array-index-out-of-bounds read in add_missing_indices

Eric Dumazet <[email protected]>
ipv6: use RCU in ip6_output()

Fan Wu <[email protected]>
iio: trigger: cancel reenable_work before freeing trigger

Salah Triki <[email protected]>
iio: proximity: vcnl3020: fix ISR bitmask check in IRQ handler

Zhang Jie <[email protected]>
iio: proximity: sx9324: Correct proximity channel resolution

Cong Nguyen <[email protected]>
iio: proximity: pulsedlight: fix iio_device left registered on PM setup failure

Salah Triki <[email protected]>
iio: proximity: isl29501: Fix return type of isl29501_register_write

Laxman Acharya Padhya <[email protected]>
iio: proximity: aw96103: validate firmware data length

Hui Su <[email protected]>
iio: pressure: bmp280: fix out-of-bounds access in sampling frequency lookup

Fan Wu <[email protected]>
iio: light: gp2ap020a00f: drain irq_work after free_irq

Arka Mondal <[email protected]>
iio: imu: adis16480: fix unprotected debugfs reads

Arka Mondal <[email protected]>
iio: imu: adis16400: fix unprotected debugfs reads

Marco Chen <[email protected]>
iio: health: max30102: fix NULL dereference in interrupt handler

Arka Mondal <[email protected]>
iio: gyro: adis16136: fix unprotected debugfs reads

Salah Triki <[email protected]>
iio: frequency: admv1013: fix wrong channel field used in admv1013_read_raw()

Jonathan Cameron <[email protected]>
iio: buffer: Ensure bounce buffer used for unaligned case is zeroed.

Jinseob Kim <[email protected]>
iio: buffer: serialize buffer teardown with mode claims

Runyu Xiao <[email protected]>
iio: admv1013: initialize callback mutex before registering notifier

Fan Wu <[email protected]>
iio: adc: xilinx-xadc: free IRQ before cancelling the unmask worker on unbind

Felix Gu <[email protected]>
iio: adc: sun4i-gpadc-iio: drop underflowing pm_runtime_put() calls

Felix Gu <[email protected]>
iio: adc: sun4i-gpadc-iio: clean up on thermal zone registration failure

Fabrice Gasnier <[email protected]>
iio: adc: stm32-adc: fix check on internal channel availability

Slavin Liu <[email protected]>
iio: adc: pac1934: check ACPI label duplication

Salah Triki <[email protected]>
iio: accel: sca3000: fix frequency divider condition check

Jiale Yao <[email protected]>
iio: accel: kxcjk-1013: reject duplicate event disable

Frank Sorenson <[email protected]>
smb: client: split cifsFileInfo bitfields to avoid shared-byte RMW races

Paulo Alcantara <[email protected]>
smb: client: discard post-EOF pagecache when extending a file via copy range

Paulo Alcantara <[email protected]>
smb: client: discard post-EOF pagecache when extending a file via zero range

Daehyeon Ko <[email protected]>
thunderbolt: Reject oversized XDomain properties responses

Kurt Lieber <[email protected]>
thunderbolt: Disable CL states for the Anker Prime TB5 dock

Mika Westerberg <[email protected]>
thunderbolt: Fix KASAN reported use-after-free when request is canceled

Ian Lin <[email protected]>
USB: serial: option: add Compal EXC-T1 support

Sebastian Sjoholm <[email protected]>
USB: serial: option: add Quectel RG660QB

Ian Lin <[email protected]>
USB: serial: option: add Compal EXM-G1x support

Carlo Szelinsky <[email protected]>
USB: serial: option: add Quectel EG060W

Zhao Dongdong <[email protected]>
USB: serial: option: add support for SIMCom SIM8260C

Johan Hovold <[email protected]>
USB: serial: fix ioctl hangup race

Johan Hovold <[email protected]>
USB: serial: fix driver deregistration order

Johan Hovold <[email protected]>
USB: serial: fix dynamic id driver deregistration race

Johan Hovold <[email protected]>
USB: serial: ssu100: fix baud rate overflow

Johan Hovold <[email protected]>
USB: serial: quatech2: fix baud rate overflow

Jérémy Carrat <[email protected]>

    USB: serial: cp210x: add Corsair AX1500i Power Supply

Yuqi Xu <[email protected]>
wifi: mac80211: handle empty FILS association request payload

Zihan Xi <[email protected]>
wifi: mac80211: fix mesh fast xmit path deletion UAF

Zhao Li <[email protected]>
wifi: mac80211: release mesh path quota on failed additions

Ruide Cao <[email protected]>
wifi: mac80211: reject invalid 320 MHz CSA bandwidth

Yuqi Xu <[email protected]>
wifi: mac80211: minstrel_ht: validate fixed rate index

Zhao Li <[email protected]>
wifi: mac80211: keep fallback association elements alive

Zhao Li <[email protected]>
wifi: mac80211: account proxy paths against the mesh path limit

Zhao Li <[email protected]>
wifi: mac80211: drain PS delivery work during station teardown

Zhiling Zou <[email protected]>
wifi: mac80211: keep paired old chanctx alive

Guangshuo Li <[email protected]>
wifi: iwlegacy: 3945: free EEPROM data on remove

Tianchu Chen <[email protected]>
wifi: cw1200: fix TX padding OOB read leaking heap data to device

Sean Christopherson <[email protected]>
KVM: x86/mmu: Bail from shadow walks if the root is invalid or a dummy

Sean Christopherson <[email protected]>
KVM: nVMX: Force MSR bitmap refresh if runtime eVMCS controls are modified

Nuno Sá <[email protected]>
mtd: spinand: fix zero oobavail when no ECC engine is used

Mehmet Fide <[email protected]>
mtd: rawnand: vf610_nfc: fix reads on chips with more than 64 bytes of OOB

Runyu Xiao <[email protected]>
mtd: rawnand: cadence: Initialize IRQ state before requesting IRQ

Pei Xiao <[email protected]>
mtd: block2mtd: Fix divide error when erase_size is zero

Weiming Shi <[email protected]>
nvmet-auth: fix out-of-bounds write in nvmet_auth_challenge()

Bean Huo <[email protected]>
nvme-pci: add NVME_QUIRK_DMAPOOL_ALIGN_512 for Micron 4100AT

Daehyeon Ko <[email protected]>
nvme-multipath: fix underflow in ANA log bounds checks

Jiangshan Yi <[email protected]>
tpm: fix off-by-four bounds check in tpm2_get_random()

Willem de Bruijn <[email protected]>
net: extend IPv6 exthdr detection of tunneled packets

Aldo Ariel Panzardo <[email protected]>
HID: multitouch: stop the release timer from being rearmed on remove

Zhiling Zou <[email protected]>
ipvs: bound LBLCR and LBLC cache growth

Jens Axboe <[email protected]>
io_uring: fix task_work add use-after-free with SQPOLL

Chandrashekar Devegowda <[email protected]>
Bluetooth: btintel_pcie: reject oversized TX packets in send_frame()

Chandrashekar Devegowda <[email protected]>
Bluetooth: btintel_pcie: fix plen overflow in btintel_pcie_recv_frame()

Chandrashekar Devegowda <[email protected]>
Bluetooth: btintel: fix buffer over-read in btintel_hw_error()

Chengfeng Ye <[email protected]>
Bluetooth: hci_core: Serialize fragmented ISO packet queueing

Chengfeng Ye <[email protected]>
Bluetooth: hci_core: Serialize ACL scheduling with channel deletion

Linmao Li <[email protected]>
Bluetooth: hci_core: Fix inquiry cache timestamps on 64-bit systems

Chengfeng Ye <[email protected]>
Bluetooth: hci_conn: Lock parent access during enhanced SCO setup

Chengfeng Ye <[email protected]>
Bluetooth: hci_sync: Fix inquiry cache use-after-free

Chengfeng Ye <[email protected]>
Bluetooth: RFCOMM: Fix initial port reference race

Abdurrahman Hussain <[email protected]>

    i2c: xiic: don't clobber msg->len to signal block-read completion

Dinh Nguyen <[email protected]>
EDAC/altera: Fix memory leak on dci allocation failure

Xiang Mei <[email protected]>
ALSA: ua101: reject mismatched capture/playback packet sizes

Kyle Zeng <[email protected]>
ALSA: seq: Serialize compat port-info ioctls

Zimeng Li <[email protected]>
ASoC: qcom: lpass-cpu: use DAI table index for playback constraints

Jiangshan Yi <[email protected]>

    ASoC: codecs: rt1017-sdca-sdw: fix uninitialized stream_config->type

Jiangshan Yi <[email protected]>

    ASoC: codecs: max98363: fix uninitialized stream_config->type

Paul Mbewe <[email protected]>
serial: sc16is7xx: refill TX FIFO below trigger using fresh TXLVL

Paul Mbewe <[email protected]>
serial: sc16is7xx: fix TX gap caused by kfifo circular buffer wrap-around

Wentao Liang <[email protected]>
serial: vt8500: Fix clock reference leak in vt8500_serial_probe()

Simon Gassner <[email protected]>
serial: tegra: don't clear the Tx FIFO on an Rx-only reset

Wentao Liang <[email protected]>
serial: ma35d1: Fix clock reference leak in ma35d1serial_probe()

Johan Hovold <[email protected]>
serial: fix TIOCMIWAIT race

Fan Wu <[email protected]>

    serial: 8250_bcm7271: fix use-after-free in brcmuart_remove()

Fan Wu <[email protected]>
tty: serial: max3100: shut down timer before freeing port

Johan Hovold <[email protected]>
tty: abort break signalling on hangup

Viken Dadhaniya <[email protected]>
tty: serial: qcom_geni_serial: Keep console RX functional after deep idle

Joshua Rogers <[email protected]>
tty: vcc: hold port lock when clearing tty pointer in vcc_cleanup

Joshua Rogers <[email protected]>
tty: vcc: zero-initialize control packet in vcc_send_ctl()

Johan Hovold <[email protected]>
tty: amiserial: fix broken TIOCMIWAIT

Mingyu Wang <[email protected]>
tty: vt: fix memory leak in vc_allocate()

Jie Deng <[email protected]>
usb: cdns3: Fix NULL pointer dereference in cdns3_pci_probe

Fan Wu <[email protected]>
usb: cdns3: fix use-after-free in cdns3_gadget_exit()

Jameson Thies <[email protected]>
usb: typec: ucsi: displayport: Current CAM OOB index fixup

Prashanth K <[email protected]>
usb: typec: ucsi: Get the connector fwnode based on reg value

Fan Wu <[email protected]>
usb: typec: ucsi: glink: fix use-after-free of ucsi on remove

Radhey Shyam Pandey <[email protected]>
usb: typec: tipd: fix uninitialized typec_partner_desc in tps6598x_connect()

Marian Rotariu <[email protected]>
usb: typec: tipd: don't send GAID when probe fails in APP mode

Amit Sunil Dhamne <[email protected]>
usb: typec: tcpm: recover after failure to start the frs ams

Hui Peng <[email protected]>
usb: core: clear both ep_in and ep_out for non-ep0 control endpoints

Myeonghun Pak <[email protected]>
usb: chipidea: tegra: disable runtime PM on resume failure

Yuchao Zhang <[email protected]>
usb: gadget: f_fs: Fix NULL pointer dereference in FUNCTIONFS_ENDPOINT_DESC

Alan Stern <[email protected]>
USB: gadget: dummy-hcd: Fix wait for outstanding request completions

Fan Wu <[email protected]>
usb: gadget: aspeed-vhub: cancel wake work on device removal

Radhey Shyam Pandey <[email protected]>
usb: dwc3: am62: Fix runtime PM usage count leak on probe error path

Linkai Gong <[email protected]>
usb: typec: anx7411 - stop the IRQ before destroying the workqueue

Liu Chao <[email protected]>
usb: gadget: f_uac1_legacy: validate bRequest index in generic_{set,get}_cmd

Takashi Iwai <[email protected]>
usb: gadget: midi2: Fix the jack descriptor array sizes

Myeonghun Pak <[email protected]>
usb: ohci-st: disable controller wakeup on removal

Myeonghun Pak <[email protected]>
usb: ohci-s3c2410: disable controller wakeup on removal

Myeonghun Pak <[email protected]>
usb: ohci-da8xx: disable controller wakeup on cleanup

Orgad Shaneh <[email protected]>
usb: octeon-hcd: fix the FIFO-flush timeout computation

Lovekesh Solanki <[email protected]>
usb: hub: use shorter 120ms post resume hold for SS root hubs

Syed Labeeq Sajid Bukhari <[email protected]>
usb: storage: sierra_ms: reject short SWoC info transfers

Johan Hovold <[email protected]>
USB: serial: fix port tear down use-after-free

Yuchao Zhang <[email protected]>
USB: cdc-acm: skip URB restart in port_shutdown if disconnected

Johan Hovold <[email protected]>
USB: cdc-acm: fix racy TIOCMIWAIT implementation

Viken Dadhaniya <[email protected]>
soc: qcom: geni-se: Correct QUP Core ICC vote constants

Yuxiao Wang <[email protected]>
nitro_enclaves: fix use-after-free on SLOT_ALLOC failure

Raphaël Larocque <[email protected]>
Input: synaptics - limit T440p InterTouch quirk to LEN0036

Lovekesh Solanki <[email protected]>
Input: synaptics - add LEN205b entry to smbus_pnp_ids for ThinkPad T490

David Heidelberg <[email protected]>
Input: s6sy761 - fix resume ordering and restore sensing

Lovekesh Solanki <[email protected]>
Input: i8042 - add nomux quirk for Fujitsu LIFEBOOK U7410

Martino Papero <[email protected]>
Input: atkbd - skip deactivate for Lenovo IdeaPad Slim 3 15IWC11

Wentao Liang <[email protected]>
kgdboc: Fix tty driver reference leak in configure_kgdboc()

Tomer Pomeranc <[email protected]>
binder: fix leaked fd fixups on TF_UPDATE_TXN supersede

Tomer Pomeranc <[email protected]>
binder: fix is_failure flag for superseded transaction cleanup

Guangshuo Li <[email protected]>
drm/amdgpu: fix ACP MFD device leak on init failure

Guangshuo Li <[email protected]>
drm/amdgpu: fix IP instance memory leak on kobject add failure

Wentao Liang <[email protected]>
drm/mediatek: Fix pdev reference leak in mtk_drm_bind()

Guangshuo Li <[email protected]>
drm/mediatek: Fix ovl adaptor platform device leak

Haojie Li <[email protected]>
drm/mediatek: Add missing IS_ERR check for ovl_adaptor platform device

Imre Kaloz <[email protected]>
drm/radeon: Read the VRAM VBIOS signature with readb()

Willian Oliveira <[email protected]>
drm/amdgpu/gfx6: fix firmware leak on teardown

Timur Kristóf <[email protected]>
drm/amd/pm/si: Fix updating clock limits on AC/DC

Timur Kristóf <[email protected]>
drm/amd/pm/si: Check AMD_IS_MOBILITY flag for PPSMC_SYSTEMFLAG_GPIO_DC

Jiangshan Yi <[email protected]>
drm/amd/display: check dc_state_create_copy() for NULL in dm_suspend

Nikola Prica <[email protected]>
PCI: Accept AtomicOps already enabled by the hypervisor

Takashi Iwai <[email protected]>
ALSA: ice1712: Fix the error handling via auto-cleanup at probe

Takashi Iwai <[email protected]>
ALSA: core: Define auto-cleanup for snd_card_free()

Luo Gengkun <[email protected]>
perf: Fix race between perf_event_exit_task() and perf_pending_task()

Hongjian Dai <[email protected]>
i2c: at91: release DMA channels when probe defers

Lorenzo Bianconi <[email protected]>
net: mvneta: clear XDP pfmemalloc flag between frames

Alexander Lobakin <[email protected]>
xdp, xsk: constify read-only arguments of some static inline helpers

Eric Dumazet <[email protected]>
ipv6: sr: use skb_get_hash_net() in seg6_make_flowlabel()

Prathamesh Deshpande <[email protected]>
net/mlx5e: Fix AF_XDP TX timestamp teardown NULL dereference

Quentin Freimanis <[email protected]>
net: sparx5: make ports inherit the switch base mac address type

Harshit Mogalapalli <[email protected]>
net: microchip: vcap: stop scanning after deleting key field

Pablo Neira Ayuso <[email protected]>
netfilter: flowtable: generalize pending status bit

Florian Westphal <[email protected]>
netfilter: conntrack: rework offload nf_conn timeout extension logic

Florian Westphal <[email protected]>
netfilter: conntrack: remove skb argument from nf_ct_refresh

Fernando Fernandez Mancera <[email protected]>
netfilter: bpf: reject invalid NAT manipulation types

Julian Anastasov <[email protected]>
ipvs: filter some flags received in the backup server

Julian Anastasov <[email protected]>
ipvs: do not create invisible templates

Julian Anastasov <[email protected]>
ipvs: fix missing counter decrement in lblc

Jeff Jo <[email protected]>
tcp: refresh TS.Recent for accepted old ACKs

Sandeep Haemoon <[email protected]>
net: ethernet: mtk_eth_soc: allocate dummy netdev sooner

Jamal Hadi Salim <[email protected]>

    net: cap skb->queue_mapping when the tx queue is picked

Nicolai Buchwitz <[email protected]>
net: bcmgenet: fix NULL dereference in set_coalesce before first open

Niklas Cassel <[email protected]>
virtio_blk: set the zone write granularity

Jamal Hadi Salim <[email protected]>
net/sched: sch_codel: match the no-drop threshold to the packet size

Jamal Hadi Salim <[email protected]>
net/sched: fq_codel: match the no-drop threshold to the packet size

Eric Dumazet <[email protected]>
net: restrict SO_RESERVE_MEM to TCP sockets and cap max value

Kuniyuki Iwashima <[email protected]>
net-memcg: Introduce mem_cgroup_sk_enabled().

Kuniyuki Iwashima <[email protected]>
net-memcg: Introduce mem_cgroup_from_sk().

Kuniyuki Iwashima <[email protected]>
net: Clean up __sk_mem_raise_allocated().

Kuniyuki Iwashima <[email protected]>
mptcp: Fix up subflow's memcg when CONFIG_SOCK_CGROUP_DATA=n.

Kuniyuki Iwashima <[email protected]>

    memcg: convert memcg->socket_pressure to u64

Jérémy Jean <[email protected]>
tipc: prevent GCM nonce reuse on peer key changes

Baha Mesleh <[email protected]>
octeontx2-af: mcs: Fix SC resource cleanup loop

Anirudh Virdi <[email protected]>
net/mlx5: Fix slab-out-of-bounds when handling team device events

Rongwei Liu <[email protected]>
net/mlx5: LAG, Refactor lag logic

Florian Fainelli <[email protected]>
net: systemport: Fix RUNT MIB counter register offset calculation

Florian Fainelli <[email protected]>
net: systemport: Fix buffer overflow in bcm_sysport_get_stats()

Nguyen Ngoc Thang <[email protected]>
Bluetooth: hci_sync: don't drain cmd_sync backlog on unregister

Florian Westphal <[email protected]>
netfilter: ipset: do not update comments from kernel-side adds

Qishuai Liu <[email protected]>
ipv6: fix prefix route expiry in modify_prefix_route()

Jamal Hadi Salim <[email protected]>
net/sched: cls_api: reclaim an empty proto on the error path

Binbin Deng <[email protected]>
net/mctp: publish the mctp_dev only after it is initialised

Sai Teja Aluvala <[email protected]>
Bluetooth: btintel: validate DDC record lengths

Sang-Hoon Choi <[email protected]>
Bluetooth: hci_core: free the HCI ID if naming fails

Cezary Rojewski <[email protected]>
ASoC: codecs: rt274: Fix format setting for 44100 rate

Cezary Rojewski <[email protected]>
ASoC: codecs: rt286: Revert delay value for jack setup

Felix Fietkau <[email protected]>
wifi: mac80211: prevent AP VLAN tx from other interfaces

Tamizh Chelvam Raja <[email protected]>
wifi: mac80211: Add 802.3 multicast encapsulation offload support

Tamizh Chelvam Raja <[email protected]>
wifi: mac80211: Add multicast to unicast support for 802.3 path

Zhao Li <[email protected]>
wifi: cfg80211: preserve hidden-group beacon IE ownership

Manush Prajwal <[email protected]>
rtc: mpfs: fix unchecked devm_clk_get() error pointer in probe()

Aamir Ahmed <[email protected]>
rtc: ac100: Fix clock provider use-after-free on probe failure

Uwe Kleine-König <[email protected]>
rtc: Switch back to struct platform_driver::remove()

Liu Dalin <[email protected]>
rtc: dev: zero-initialize struct rtc_wkalrm to prevent information leak

Georgios Karantzas <[email protected]>
wifi: ath9k_htc: bound TX aggregation to MAX_TX_BUF_SIZE

Pengpeng Hou <[email protected]>
wifi: ath9k: reject short WMI command responses

Nicolas Escande <[email protected]>

    wifi: ath11k: reset ar->num_stations on hardware start

Sheetal <[email protected]>
ASoC: tegra: Fix ASRC Stream6 input threshold control

Aamir Ahmed <[email protected]>
wifi: wfx: validate MIB read length before copying to caller

HyeongJun An <[email protected]>
ASoC: wm8903: Move the DRC QR threshold to the register that holds it

Abdurrahman Hussain <[email protected]>
of/overlay: don't create "//" paths for fragments targeting the root

Abdurrahman Hussain <[email protected]>
of/overlay: don't leak fragment references when changeset init fails

Karl Mehltretter <[email protected]>
random: fix vgetrandom_opaque_params kernel-doc

Julian Sun <[email protected]>
nvmet: preserve device path on allocation failure

Karl Mehltretter <[email protected]>
mtd: core: call _get_device() with the master MTD

Matti Vaittinen <[email protected]>
iio: accel: kionix-kx022a: Fix array boundary check

SJ Park <[email protected]>
mm/damon/core: don't skip damos_adjust_quota() while esz is not zero

Nathan Chancellor <[email protected]>
random: vDSO: avoid call to memset() when zeroing reserved parameter

Tetsuo Handa <[email protected]>
perf/core: Fix WARN in perf_sigtrap()

Lorenzo Stoakes (ARM) <[email protected]>
mm/secretmem: properly account locked pages

Xiang Mei <[email protected]>
ALSA: line6: reject oversized playback packets

Nguyen Ngoc Thang <[email protected]>
ALSA: caiaq: unregister the input device when probe fails

Wentao Liang <[email protected]>
wifi: wlcore: Fix runtime PM leak in wlcore_remove()

Zizhi Wo <[email protected]>
vt: skip screen update for DEC alignment test on backgroup consoles

Maoyi Xie <[email protected]>
rds_tcp: close NULL deref window in rds_tcp_set_callbacks

Jiangshan Yi <[email protected]>
smb: client: clear setuid/setgid bit on write with cifsacl/modefromsid/posix extensions

Zhichen Wang <[email protected]>
virt: vmgenid: set driver_data before registering notification handlers

Surendran Kanagaraj <[email protected]>
tpm: Disable TPM on null key name mismatch

Jun Yang <[email protected]>
sctp: check RCV_SHUTDOWN after the sendmsg connect wait

Runyu Xiao <[email protected]>
rtc: spear: initialize IRQ state before requesting alarm IRQ

Aamir Ahmed <[email protected]>
rtc: ac100: Assign .num before accessing .hws

Ilkka Lappeteläinen <[email protected]>
net/packet: prevent TX_RING byte count overflow

Aohan Mei <[email protected]>
netfilter: nft_flow_offload: drop flowtable reference on init error path

Alireza Asgari <[email protected]>
net: fix checksum offsets in skb_splice_from_iter()

Abdurrahman Hussain <[email protected]>
of/overlay: only treat a positive changeset id as registered

Abdurrahman Hussain <[email protected]>
of/overlay: put property on deadprops only after changeset add succeeds

Wentao Liang <[email protected]>
of/irq: Fix remaining refcount leaks in of_irq_init()

Leon Hwang <[email protected]>
kprobes: Skip disarmed probes when checking optkprobe overlap

Benjamin Tissoires <[email protected]>
HID: bpf: cast size to ssize_t when checking hid_bpf_hw_request

Jérémy Jean <[email protected]>
audit: fix exe mark UAF in kill_rules()

Takashi Iwai <[email protected]>
ALSA: usb-audio: Apply IGNORE_CTL_ERROR quirk to all Audient devices

Kuniyuki Iwashima <[email protected]>
neighbour: Skip default parms when resumed in neightbl_dump_info().

Darrick J. Wong <[email protected]>
xfs: fix cursor and pointer handling when recovering iunlink buckets

Zihan Xi <[email protected]>
smb: client: close completed creates on compound wait errors

Aldo Ariel Panzardo <[email protected]>
Bluetooth: ISO: release unused CIS holds after channel attach

SeungJu Cheon <[email protected]>
Bluetooth: ISO: Fix data-race on iso_pi(sk) in socket and HCI event paths

Zihan Xi <[email protected]>
smb: client: close handle after create-context parsing failure

ChenXiaoSong <[email protected]>
smb/client: pass cifs_open_info_data to SMB2_open()

ChenXiaoSong <[email protected]>
smb/client: use stack-allocated smb2_file_all_info in smb3_query_mf_symlink()

Peter Ujfalusi <[email protected]>
ASoC: SOF: ipc4/Intel: Add support for library restore firmware functionality

Peter Ujfalusi <[email protected]>
ASoC: SOF: ipc4-priv: Add kernel doc for fw_context_save of sof_ipc4_fw_data

Tibor Harcsa <[email protected]>
Bluetooth: btusb: Add IMC Networks QCA9377 to quirks table

Richard Fitzgerald <[email protected]>
ASoC: sdw_utils: Set snd_soc_dai_link_ch_map.codec_ch_mask for capture

Jiayuan Chen <[email protected]>
bpf, xdp: move offload check into dev_xdp_install()

Jiakai Xu <[email protected]>
RISC-V: KVM: Fix null pointer dereference in kvm_riscv_aia_imsic_has_attr()

Darrick J. Wong <[email protected]>
xfs: don't let memory failures leak blocks and kill repairs

Namjae Jeon <[email protected]>
smb: client: use finish_no_open() for non-regular inodes

Mike Rapoport (Microsoft) <[email protected]>
selftests/mm: hugetlb-mremap: add setup of HugeTLB pages

Marc Zyngier <[email protected]>
KVM: arm64: nv: Delay freeing of shadow S2 structures until VM destruction

Marc Zyngier <[email protected]>
KVM: arm64: nv: Fix life cycle of the nested_mmus array

Fan Wu <[email protected]>
smb: client: fix cifsFileInfo reference leak in deferred close

Frank Sorenson <[email protected]>
smb: client: fix OOB read/write from unvalidated DataOffset in coalesce_t2()

-------------

Diffstat:

 Documentation/arch/arm64/silicon-errata.rst        |   2 +
 Documentation/filesystems/netfs_library.rst        |  26 ++
 Documentation/netlink/genetlink-c.yaml             |  14 +-
 Documentation/netlink/genetlink-legacy.yaml        |  14 +-
 Documentation/netlink/genetlink.yaml               |  14 +-
 Documentation/netlink/netlink-raw.yaml             |  20 +-
 Documentation/networking/strparser.rst             |   2 +-
 Makefile                                           |   4 +-
 arch/arm64/Kconfig                                 |  30 ++
 arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi     |  19 +-
 arch/arm64/include/asm/el2_setup.h                 |   5 +-
 arch/arm64/include/asm/kvm_host.h                  |   2 +-
 arch/arm64/include/asm/kvm_nested.h                |   3 +-
 arch/arm64/kernel/Makefile                         |   3 +
 arch/arm64/kernel/cpu_errata.c                     |  24 +-
 arch/arm64/kernel/cpufeature.c                     |   2 +-
 arch/arm64/kernel/signal.c                         |  85 +++---
 arch/arm64/kernel/topology.c                       |  11 +-
 arch/arm64/kernel/vdso/Makefile                    |   2 +-
 arch/arm64/kvm/arm.c                               |  10 +-
 arch/arm64/kvm/emulate-nested.c                    |   4 -
 arch/arm64/kvm/mmu.c                               |  46 +--
 arch/arm64/kvm/nested.c                            |  95 +++---
 arch/arm64/kvm/vgic/vgic-its.c                     |  22 +-
 arch/arm64/tools/cpucaps                           |   2 +-
 arch/loongarch/vdso/Makefile                       |   1 +
 arch/powerpc/kernel/vdso/Makefile                  |   1 +
 arch/powerpc/perf/imc-pmu.c                        |  23 +-
 arch/riscv/include/asm/scs.h                       |  17 +-
 arch/riscv/kernel/entry.S                          |   2 +-
 arch/riscv/kvm/aia_imsic.c                         |   5 +-
 arch/riscv/mm/extable.c                            |   4 +-
 arch/s390/kernel/vdso64/Makefile                   |   1 +
 arch/x86/entry/vdso/Makefile                       |   1 +
 arch/x86/events/intel/bts.c                        |   2 +-
 arch/x86/events/intel/core.c                       |   2 +-
 arch/x86/events/intel/p4.c                         |   2 +-
 arch/x86/kvm/mmu/mmu.c                             |   6 +
 arch/x86/kvm/svm/svm.c                             |  12 +-
 arch/x86/kvm/vmx/nested.c                          |   6 +
 crypto/drbg.c                                      |  11 +-
 drivers/android/binder.c                           |   3 +-
 drivers/block/virtio_blk.c                         |   1 +
 drivers/bluetooth/btintel.c                        |  29 +-
 drivers/bluetooth/btintel_pcie.c                   | 138 ++++++---
 drivers/bluetooth/btintel_pcie.h                   |   2 +
 drivers/bluetooth/btusb.c                          |   2 +
 drivers/char/tpm/tpm2-cmd.c                        |   2 +-
 drivers/char/tpm/tpm2-sessions.c                   |   1 +
 drivers/edac/altera_edac.c                         |   4 +-
 drivers/edac/amd64_edac.c                          |   4 +-
 drivers/gpio/gpio-exar.c                           |   2 +-
 drivers/gpio/gpio-xilinx.c                         |   9 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c            |  13 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c         |   8 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c        |  77 +++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c      |   2 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c            |  17 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c            |   5 +
 drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c              |   9 +
 drivers/gpu/drm/amd/amdgpu/vi.c                    |  21 ++
 .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  |  32 ++-
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h              |   7 +
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  |   9 +-
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c    |  20 +-
 drivers/gpu/drm/amd/display/dc/dc.h                |   1 +
 .../gpu/drm/amd/display/dc/dce60/dce60_resource.c  |   1 -
 .../dc/link/protocols/link_edp_panel_control.c     |   4 +-
 .../amd/display/dc/resource/dce80/dce80_resource.c |   1 +
 drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c         |  39 +--
 .../gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c    |  10 +-
 .../gpu/drm/amd/pm/powerplay/hwmgr/ppatomfwctrl.c  |  11 +-
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c            |   5 +-
 drivers/gpu/drm/display/drm_dp_helper.c            |   4 +-
 drivers/gpu/drm/drm_fb_helper.c                    |   6 +-
 drivers/gpu/drm/gud/gud_pipe.c                     |   1 +
 drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c     |   2 +-
 drivers/gpu/drm/i915/gt/intel_rps.c                |   3 +-
 drivers/gpu/drm/imagination/pvr_mmu.c              |  25 +-
 drivers/gpu/drm/imagination/pvr_vm.c               |   8 +-
 drivers/gpu/drm/mediatek/mtk_drm_drv.c             |  17 +-
 drivers/gpu/drm/panthor/panthor_sched.c            |   3 +
 drivers/gpu/drm/radeon/radeon_bios.c               |   6 +-
 drivers/gpu/drm/vc4/vc4_bo.c                       |  29 +-
 drivers/gpu/drm/vc4/vc4_crtc.c                     |   4 +-
 drivers/gpu/drm/vc4/vc4_drv.c                      |   8 +-
 drivers/gpu/drm/vc4/vc4_drv.h                      |   2 +-
 drivers/gpu/drm/vc4/vc4_gem.c                      |  32 ++-
 drivers/gpu/drm/vc4/vc4_irq.c                      |  16 +-
 drivers/gpu/drm/vc4/vc4_kms.c                      |   2 +-
 drivers/gpu/drm/vc4/vc4_perfmon.c                  |  20 +-
 drivers/gpu/drm/vc4/vc4_render_cl.c                |   2 +-
 drivers/gpu/drm/vc4/vc4_v3d.c                      |  60 ++--
 drivers/gpu/drm/vc4/vc4_validate.c                 |  10 +-
 drivers/gpu/drm/vc4/vc4_validate_shaders.c         |   2 +-
 drivers/hid/bpf/hid_bpf_dispatch.c                 |   2 +-
 drivers/hid/hid-multitouch.c                       |   2 +-
 drivers/i2c/busses/i2c-at91-master.c               |   8 +-
 drivers/i2c/busses/i2c-xiic.c                      |  98 ++++---
 drivers/iio/accel/kionix-kx022a.c                  |  77 ++---
 drivers/iio/accel/kxcjk-1013.c                     |   2 +-
 drivers/iio/accel/sca3000.c                        |   2 +-
 drivers/iio/adc/ad_sigma_delta.c                   |  27 +-
 drivers/iio/adc/aspeed_adc.c                       |  13 +-
 drivers/iio/adc/axp288_adc.c                       |   8 +
 drivers/iio/adc/max1363.c                          |   8 +
 drivers/iio/adc/pac1934.c                          |   4 +
 drivers/iio/adc/stm32-adc.c                        |  47 +--
 drivers/iio/adc/sun4i-gpadc-iio.c                  |  10 +-
 drivers/iio/adc/xilinx-xadc-core.c                 |   9 +-
 drivers/iio/buffer/industrialio-buffer-dmaengine.c |  16 +-
 drivers/iio/cdc/ad7150.c                           |   8 +-
 drivers/iio/frequency/admv1013.c                   |   9 +-
 drivers/iio/gyro/adis16136.c                       |   2 +-
 drivers/iio/health/max30102.c                      |  12 +-
 drivers/iio/imu/adis16400.c                        |   2 +-
 drivers/iio/imu/adis16480.c                        |   4 +-
 drivers/iio/industrialio-buffer.c                  |   7 +-
 drivers/iio/industrialio-trigger.c                 |   2 +
 drivers/iio/light/gp2ap020a00f.c                   |   2 +
 drivers/iio/light/rohm-bu27034.c                   | 133 ++++-----
 drivers/iio/pressure/bmp280-core.c                 |   2 +-
 drivers/iio/proximity/aw96103.c                    |  30 +-
 drivers/iio/proximity/isl29501.c                   |   2 +-
 drivers/iio/proximity/pulsedlight-lidar-lite-v2.c  |   4 +-
 drivers/iio/proximity/sx9324.c                     |   2 +-
 drivers/iio/proximity/vcnl3020.c                   |  24 +-
 drivers/input/joystick/xpad.c                      |   3 +
 drivers/input/keyboard/atkbd.c                     |   8 +
 drivers/input/misc/ati_remote2.c                   |  12 +-
 drivers/input/mouse/synaptics.c                    |   7 +-
 drivers/input/serio/i8042-acpipnpio.h              |   9 +
 drivers/input/touchscreen/s6sy761.c                |  14 +-
 drivers/md/dm-crypt.c                              |   7 +-
 drivers/md/dm-ioctl.c                              |  14 +-
 drivers/md/dm-snap.c                               |  14 +
 drivers/memstick/core/memstick.c                   |   8 +-
 drivers/memstick/host/rtsx_usb_ms.c                |  31 +-
 drivers/mmc/host/cavium-octeon.c                   |   5 +-
 drivers/mmc/host/cavium-thunderx.c                 |   5 +-
 drivers/mmc/host/mtk-sd.c                          |   1 +
 drivers/mmc/host/sdhci-sprd.c                      |   4 +
 drivers/mtd/devices/block2mtd.c                    |   2 +-
 drivers/mtd/mtdcore.c                              |   2 +-
 drivers/mtd/nand/raw/cadence-nand-controller.c     |   6 +-
 drivers/mtd/nand/raw/vf610_nfc.c                   |  85 +++++-
 drivers/mtd/nand/spi/core.c                        |  37 ++-
 drivers/net/amt.c                                  |  48 +---
 drivers/net/can/usb/f81604.c                       |   2 +-
 drivers/net/dsa/microchip/ksz_common.h             |   2 +-
 drivers/net/ethernet/broadcom/bcmsysport.c         |   8 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt.c          |  84 ++++--
 drivers/net/ethernet/broadcom/genet/bcmgenet.c     |   5 +-
 .../chelsio/inline_crypto/ch_ktls/chcr_ktls.c      |   4 +-
 drivers/net/ethernet/ibm/ibmveth.c                 |  22 +-
 drivers/net/ethernet/intel/ice/ice_eswitch.c       |   2 +-
 drivers/net/ethernet/marvell/mvneta.c              |   2 +-
 drivers/net/ethernet/marvell/octeontx2/af/mcs.c    |   4 +-
 drivers/net/ethernet/mediatek/mtk_eth_soc.c        |  38 ++-
 drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c   |   3 +
 .../net/ethernet/mellanox/mlx5/core/en/xsk/rx.c    |   2 +
 drivers/net/ethernet/mellanox/mlx5/core/en_rx.c    |  13 +-
 .../net/ethernet/mellanox/mlx5/core/lag/debugfs.c  |  13 +-
 drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c  | 191 +++++++------
 drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h  |  14 +-
 drivers/net/ethernet/mellanox/mlx5/core/lag/mp.c   |  24 +-
 .../net/ethernet/mellanox/mlx5/core/lag/mpesw.c    |  10 +-
 .../net/ethernet/mellanox/mlx5/core/lag/port_sel.c |  16 +-
 drivers/net/ethernet/mellanox/mlxsw/spectrum.h     |   2 +
 drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c |  10 +-
 .../net/ethernet/mellanox/mlxsw/spectrum_flower.c  |   9 +-
 .../net/ethernet/microchip/sparx5/sparx5_main.c    |   1 +
 .../net/ethernet/microchip/sparx5/sparx5_main.h    |   1 +
 .../net/ethernet/microchip/sparx5/sparx5_netdev.c  |   1 +
 .../ethernet/microchip/sparx5/sparx5_tc_matchall.c |   1 +
 drivers/net/ethernet/microchip/vcap/vcap_api.c     |   2 +-
 drivers/net/ethernet/microsoft/mana/mana_en.c      |  10 +-
 drivers/net/pfcp.c                                 |  10 +
 drivers/net/phy/aquantia/aquantia_main.c           |   5 +-
 drivers/net/team/team_mode_broadcast.c             |   2 +
 drivers/net/usb/ax88179_178a.c                     |   6 +-
 drivers/net/usb/qmi_wwan.c                         |   1 +
 drivers/net/veth.c                                 |   1 +
 drivers/net/wireguard/noise.c                      |   7 +-
 drivers/net/wireguard/queueing.h                   |   2 +
 drivers/net/wireless/ath/ath11k/mac.c              |   1 +
 drivers/net/wireless/ath/ath12k/qmi.c              |   9 +-
 drivers/net/wireless/ath/ath12k/qmi.h              |   3 +
 drivers/net/wireless/ath/ath9k/hif_usb.c           |  21 +-
 drivers/net/wireless/ath/ath9k/wmi.c               |  16 +-
 drivers/net/wireless/ath/ath9k/wmi.h               |   1 +
 .../wireless/broadcom/brcm80211/brcmfmac/core.c    |  27 +-
 drivers/net/wireless/intel/iwlegacy/3945-mac.c     |   1 +
 drivers/net/wireless/marvell/libertas/tx.c         |   7 -
 drivers/net/wireless/mediatek/mt76/mt7915/init.c   |   6 +
 drivers/net/wireless/mediatek/mt76/mt7925/mac.c    |   3 +-
 drivers/net/wireless/mediatek/mt76/mt7925/main.c   |  12 +
 .../net/wireless/mediatek/mt76/mt792x_acpi_sar.c   | 134 ++++++---
 .../net/wireless/mediatek/mt76/mt792x_acpi_sar.h   |   2 +
 drivers/net/wireless/mediatek/mt76/mt7996/mcu.h    |   3 +
 drivers/net/wireless/silabs/wfx/hif_tx.c           |   4 +-
 drivers/net/wireless/st/cw1200/bh.c                |   8 +-
 drivers/net/wireless/st/cw1200/txrx.c              |  14 +
 drivers/net/wireless/ti/wlcore/main.c              |   4 +-
 drivers/net/xen-netfront.c                         |  16 +-
 drivers/nvme/host/multipath.c                      |  10 +-
 drivers/nvme/host/pci.c                            |   2 +
 drivers/nvme/target/configfs.c                     |   9 +-
 drivers/nvme/target/core.c                         |   2 +-
 drivers/nvme/target/fabrics-cmd-auth.c             |   2 +-
 drivers/of/irq.c                                   |   2 +
 drivers/of/overlay.c                               |  17 +-
 drivers/pci/pci.c                                  |  15 +-
 drivers/perf/arm_spe_pmu.c                         |   4 +-
 drivers/pmdomain/imx/imx8m-blk-ctrl.c              |  15 +
 drivers/pmdomain/rockchip/pm-domains.c             |  20 +-
 drivers/ptp/ptp_ocp.c                              |   2 +-
 drivers/regulator/ltc3676.c                        |  15 +-
 drivers/regulator/tps6594-regulator.c              |   6 +-
 drivers/rtc/dev.c                                  |   2 +-
 drivers/rtc/rtc-88pm80x.c                          |   2 +-
 drivers/rtc/rtc-88pm860x.c                         |   2 +-
 drivers/rtc/rtc-ab8500.c                           |   2 +-
 drivers/rtc/rtc-ac100.c                            |  39 +--
 drivers/rtc/rtc-asm9260.c                          |   2 +-
 drivers/rtc/rtc-at91rm9200.c                       |   2 +-
 drivers/rtc/rtc-at91sam9.c                         |   2 +-
 drivers/rtc/rtc-brcmstb-waketimer.c                |   2 +-
 drivers/rtc/rtc-cadence.c                          |   2 +-
 drivers/rtc/rtc-cmos.c                             |   2 +-
 drivers/rtc/rtc-cros-ec.c                          |   2 +-
 drivers/rtc/rtc-ds1685.c                           |   2 +-
 drivers/rtc/rtc-ftrtc010.c                         |   2 +-
 drivers/rtc/rtc-hid-sensor-time.c                  |   2 +-
 drivers/rtc/rtc-imxdi.c                            |   2 +-
 drivers/rtc/rtc-loongson.c                         |   2 +-
 drivers/rtc/rtc-lpc24xx.c                          |   2 +-
 drivers/rtc/rtc-max77686.c                         |   2 +-
 drivers/rtc/rtc-mc13xxx.c                          |   2 +-
 drivers/rtc/rtc-mpc5121.c                          |   2 +-
 drivers/rtc/rtc-mpfs.c                             |   8 +-
 drivers/rtc/rtc-mt7622.c                           |   2 +-
 drivers/rtc/rtc-mv.c                               |   2 +-
 drivers/rtc/rtc-mxc_v2.c                           |   2 +-
 drivers/rtc/rtc-omap.c                             |   2 +-
 drivers/rtc/rtc-palmas.c                           |   2 +-
 drivers/rtc/rtc-pcf50633.c                         |   2 +-
 drivers/rtc/rtc-pic32.c                            |   2 +-
 drivers/rtc/rtc-pm8xxx.c                           |   2 +-
 drivers/rtc/rtc-pxa.c                              |   2 +-
 drivers/rtc/rtc-rc5t583.c                          |   2 +-
 drivers/rtc/rtc-rtd119x.c                          |   2 +-
 drivers/rtc/rtc-rzn1.c                             |   2 +-
 drivers/rtc/rtc-s3c.c                              |   2 +-
 drivers/rtc/rtc-sa1100.c                           |   2 +-
 drivers/rtc/rtc-sh.c                               |   2 +-
 drivers/rtc/rtc-spear.c                            |  13 +-
 drivers/rtc/rtc-stm32.c                            |   2 +-
 drivers/rtc/rtc-stmp3xxx.c                         |   2 +-
 drivers/rtc/rtc-sunplus.c                          |   2 +-
 drivers/rtc/rtc-tegra.c                            |   2 +-
 drivers/rtc/rtc-tps6586x.c                         |   2 +-
 drivers/rtc/rtc-twl.c                              |   2 +-
 drivers/rtc/rtc-vt8500.c                           |   2 +-
 drivers/rtc/rtc-wm8350.c                           |   2 +-
 drivers/rtc/rtc-xgene.c                            |   2 +-
 drivers/rtc/rtc-zynqmp.c                           |   2 +-
 drivers/scsi/qedi/qedi_main.c                      |   3 +-
 drivers/staging/greybus/uart.c                     |   3 +-
 drivers/tee/optee/ffa_abi.c                        |  38 ++-
 drivers/tee/optee/optee_ffa.h                      |  29 +-
 drivers/tee/optee/optee_msg.h                      | 132 ++++++---
 drivers/tee/optee/optee_private.h                  | 120 ++++----
 drivers/tee/optee/optee_smc.h                      |  37 ++-
 drivers/tee/optee/smc_abi.c                        |  17 +-
 drivers/tee/tee_shm.c                              |   4 +
 drivers/thunderbolt/ctl.c                          |  63 ++--
 drivers/thunderbolt/quirks.c                       |   3 +
 drivers/thunderbolt/xdomain.c                      |   4 +
 drivers/tty/amiserial.c                            |   9 +-
 drivers/tty/n_gsm.c                                |  47 +--
 drivers/tty/serial/8250/8250_bcm7271.c             |   2 +-
 drivers/tty/serial/kgdboc.c                        |   9 +
 drivers/tty/serial/ma35d1_serial.c                 |   6 +-
 drivers/tty/serial/max3100.c                       |  13 +-
 drivers/tty/serial/qcom_geni_serial.c              |   5 +-
 drivers/tty/serial/sc16is7xx.c                     |  53 +++-
 drivers/tty/serial/serial-tegra.c                  |  18 +-
 drivers/tty/serial/serial_core.c                   |   4 +-
 drivers/tty/serial/vt8500_serial.c                 |   1 +
 drivers/tty/tty_io.c                               |  54 ++--
 drivers/tty/tty_port.c                             | 205 ++++++-------
 drivers/tty/vcc.c                                  |   5 +-
 drivers/tty/vt/vc_screen.c                         |  50 ++--
 drivers/tty/vt/vt.c                                |   5 +-
 drivers/usb/cdns3/cdns3-gadget.c                   |   4 +
 drivers/usb/cdns3/cdns3-pci-wrap.c                 |   5 +
 drivers/usb/chipidea/ci_hdrc_tegra.c               |   4 +-
 drivers/usb/class/cdc-acm.c                        |  41 +--
 drivers/usb/class/cdc-acm.h                        |   1 -
 drivers/usb/core/hub.c                             |   7 +-
 drivers/usb/core/message.c                         |   8 +-
 drivers/usb/dwc2/hcd.c                             |   3 +-
 drivers/usb/dwc3/core.h                            |  19 ++
 drivers/usb/dwc3/dwc3-am62.c                       |   1 +
 drivers/usb/dwc3/ep0.c                             |   9 +
 drivers/usb/dwc3/gadget.c                          | 108 ++++++-
 drivers/usb/gadget/function/f_fs.c                 |  15 +-
 drivers/usb/gadget/function/f_midi2.c              |   4 +-
 drivers/usb/gadget/function/f_uac1_legacy.c        |   6 +
 drivers/usb/gadget/udc/aspeed-vhub/core.c          |   4 +
 drivers/usb/gadget/udc/aspeed-vhub/dev.c           |   2 +-
 drivers/usb/gadget/udc/aspeed-vhub/hub.c           |   5 +-
 drivers/usb/gadget/udc/aspeed-vhub/vhub.h          |   1 +
 drivers/usb/gadget/udc/dummy_hcd.c                 |   4 +
 drivers/usb/host/octeon-hcd.c                      |   2 +-
 drivers/usb/host/ohci-da8xx.c                      |   2 +
 drivers/usb/host/ohci-s3c2410.c                    |   1 +
 drivers/usb/host/ohci-spear.c                      |   4 +-
 drivers/usb/host/ohci-st.c                         |   1 +
 drivers/usb/serial/bus.c                           |   6 +-
 drivers/usb/serial/cp210x.c                        |   1 +
 drivers/usb/serial/generic.c                       |  10 +-
 drivers/usb/serial/option.c                        |  14 +
 drivers/usb/serial/quatech2.c                      |  19 +-
 drivers/usb/serial/ssu100.c                        |  18 +-
 drivers/usb/serial/usb-serial.c                    | 127 ++++++--
 drivers/usb/serial/xr_serial.c                     |  10 +-
 drivers/usb/storage/sierra_ms.c                    |   7 +
 drivers/usb/typec/anx7411.c                        |   5 +-
 drivers/usb/typec/tcpm/tcpm.c                      |   2 +-
 drivers/usb/typec/tipd/core.c                      |   8 +-
 drivers/usb/typec/ucsi/displayport.c               |   9 +-
 drivers/usb/typec/ucsi/ucsi.c                      |  17 +-
 drivers/usb/typec/ucsi/ucsi_acpi.c                 |  33 +++
 drivers/usb/typec/ucsi/ucsi_glink.c                |  15 +-
 drivers/virt/nitro_enclaves/ne_misc_dev.c          |   1 +
 drivers/virt/vmgenid.c                             |   6 +-
 fs/attr.c                                          |  12 +-
 fs/btrfs/scrub.c                                   |   4 +-
 fs/btrfs/xattr.c                                   |  15 +-
 fs/dcache.c                                        |   4 +-
 fs/ext4/inode.c                                    |   4 -
 fs/f2fs/f2fs.h                                     |   2 +-
 fs/f2fs/file.c                                     |   4 -
 fs/f2fs/gc.c                                       |  36 ++-
 fs/f2fs/segment.c                                  |  13 +-
 fs/fsopen.c                                        |   3 +
 fs/inode.c                                         |  23 +-
 fs/jfs/jfs_dtree.c                                 |  18 +-
 fs/namei.c                                         |  29 ++
 fs/namespace.c                                     |  87 ++++--
 fs/netfs/buffered_write.c                          |   9 +
 fs/netfs/direct_write.c                            |   9 +
 fs/netfs/internal.h                                |   2 +
 fs/netfs/misc.c                                    |  99 +++++++
 fs/smb/client/cifsfs.c                             |   7 +-
 fs/smb/client/cifsglob.h                           |  10 +-
 fs/smb/client/cifssmb.c                            |   2 +-
 fs/smb/client/dir.c                                |  39 ++-
 fs/smb/client/file.c                               |  17 +-
 fs/smb/client/inode.c                              |  30 +-
 fs/smb/client/link.c                               |  15 +-
 fs/smb/client/smb1ops.c                            |  21 +-
 fs/smb/client/smb2file.c                           |  19 +-
 fs/smb/client/smb2misc.c                           |   9 +-
 fs/smb/client/smb2ops.c                            |  38 ++-
 fs/smb/client/smb2pdu.c                            |  38 +--
 fs/smb/client/smb2proto.h                          |   2 +-
 fs/smb/client/trace.h                              |  16 +-
 fs/smb/client/transport.c                          |  69 +++--
 fs/verity/Kconfig                                  |   3 +
 fs/verity/open.c                                   |   8 -
 fs/xfs/scrub/newbt.c                               |   8 +-
 fs/xfs/xfs_log_recover.c                           |  13 +-
 include/linux/console.h                            |   2 +
 include/linux/fsverity.h                           |  25 --
 include/linux/lsm_hook_defs.h                      |   2 +-
 include/linux/memcontrol.h                         |  50 +++-
 include/linux/netfilter_netdev.h                   |   2 +-
 include/linux/netfs.h                              |   2 +
 include/linux/nvme.h                               |   4 +-
 include/linux/pagemap.h                            |  16 +-
 include/linux/perf_event.h                         |  17 +-
 include/linux/rtnetlink.h                          |   7 +-
 include/linux/sched/user.h                         |   3 +-
 include/linux/security.h                           |   5 +-
 include/linux/skbuff.h                             |   2 +-
 include/linux/soc/qcom/geni-se.h                   |  15 +-
 include/linux/tty.h                                |   1 +
 include/linux/tty_driver.h                         |   6 +
 include/linux/tty_port.h                           |  30 +-
 include/linux/usb/serial.h                         |   1 +
 include/net/amt.h                                  |   4 -
 include/net/bluetooth/hci_core.h                   |   5 +-
 include/net/ip.h                                   |   7 +
 include/net/mac80211.h                             |   4 +
 include/net/netfilter/nf_conntrack.h               |  18 +-
 include/net/netfilter/nf_flow_table.h              |   2 +-
 include/net/proto_memory.h                         |   2 +-
 include/net/sch_generic.h                          |   9 +
 include/net/sock.h                                 |  22 ++
 include/net/strparser.h                            |  10 +-
 include/net/tcp.h                                  |   2 +-
 include/net/xdp.h                                  |  34 ++-
 include/net/xdp_sock_drv.h                         |  11 +-
 include/net/xsk_buff_pool.h                        |   2 +-
 include/sound/core.h                               |   9 +
 include/sound/sof/ipc4/header.h                    |   2 +
 include/uapi/linux/random.h                        |   2 +-
 init/Kconfig                                       |   5 +
 io_uring/io_uring.c                                |   7 +-
 io_uring/waitid.c                                  |  19 +-
 kernel/audit_tree.c                                |  36 ++-
 kernel/cgroup/cpuset.c                             | 134 +++++----
 kernel/dma/swiotlb.c                               |   6 +-
 kernel/events/core.c                               | 318 +++++++++------------
 kernel/events/ring_buffer.c                        |   7 +-
 kernel/kprobes.c                                   |   8 +-
 kernel/trace/trace_event_perf.c                    |   4 +-
 kernel/workqueue.c                                 |   2 +-
 mm/damon/core.c                                    |  48 ++--
 mm/memcontrol.c                                    |  27 +-
 mm/secretmem.c                                     | 117 +++++++-
 mm/shmem.c                                         |  70 ++---
 mm/vmpressure.c                                    |   2 +-
 net/bluetooth/hci_conn.c                           |  18 +-
 net/bluetooth/hci_core.c                           |  55 +++-
 net/bluetooth/hci_debugfs.c                        |   2 +-
 net/bluetooth/hci_event.c                          |   7 +
 net/bluetooth/hci_sock.c                           |   2 +
 net/bluetooth/hci_sync.c                           |  19 +-
 net/bluetooth/iso.c                                | 153 +++++++---
 net/bluetooth/mgmt.c                               |   2 +-
 net/bluetooth/rfcomm/sock.c                        |   5 +-
 net/bluetooth/rfcomm/tty.c                         |   9 +-
 net/bluetooth/smp.c                                |   2 +
 net/bridge/br_multicast.c                          |  23 +-
 net/bridge/netfilter/nf_conntrack_bridge.c         |  10 +-
 net/core/dev.c                                     | 137 +++++----
 net/core/flow_dissector.c                          |  11 +-
 net/core/neighbour.c                               |  12 +-
 net/core/netdev-genl-gen.c                         |   4 +-
 net/core/skbuff.c                                  |  14 +-
 net/core/sock.c                                    |  15 +-
 net/devlink/core.c                                 |  10 +-
 net/ipv4/af_inet.c                                 |   2 +-
 net/ipv4/cipso_ipv4.c                              |   8 +
 net/ipv4/fib_semantics.c                           |   3 +
 net/ipv4/fib_trie.c                                |   2 -
 net/ipv4/inet_connection_sock.c                    |   2 +-
 net/ipv4/ip_output.c                               |  10 +-
 net/ipv4/route.c                                   |   5 +
 net/ipv4/tcp.c                                     |   2 +
 net/ipv4/tcp_input.c                               |   6 +
 net/ipv4/tcp_ipv4.c                                |   2 +-
 net/ipv4/tcp_output.c                              |   2 +-
 net/ipv6/addrconf.c                                |   2 +-
 net/ipv6/ip6_output.c                              |  29 +-
 net/ipv6/route.c                                   |   2 -
 net/ipv6/seg6_iptunnel.c                           |   2 +-
 net/mac80211/agg-rx.c                              |   2 +-
 net/mac80211/chan.c                                |  45 ++-
 net/mac80211/fils_aead.c                           |   8 +
 net/mac80211/ieee80211_i.h                         |   2 +-
 net/mac80211/mesh_pathtbl.c                        |  30 +-
 net/mac80211/mlme.c                                |   4 +-
 net/mac80211/rc80211_minstrel_ht.c                 |  30 +-
 net/mac80211/spectmgmt.c                           |   4 +-
 net/mac80211/sta_info.c                            |   6 +-
 net/mac80211/tx.c                                  | 128 +++++++--
 net/mctp/device.c                                  |   6 +-
 net/mptcp/protocol.c                               |  10 +-
 net/mptcp/subflow.c                                |  11 +-
 net/netfilter/ipset/ip_set_bitmap_gen.h            |   2 +-
 net/netfilter/ipvs/ip_vs_conn.c                    |   3 +
 net/netfilter/ipvs/ip_vs_lblc.c                    |   4 +
 net/netfilter/ipvs/ip_vs_lblcr.c                   |   3 +
 net/netfilter/ipvs/ip_vs_sync.c                    |  33 ++-
 net/netfilter/nf_conntrack_amanda.c                |   2 +-
 net/netfilter/nf_conntrack_broadcast.c             |   2 +-
 net/netfilter/nf_conntrack_core.c                  |  13 +-
 net/netfilter/nf_conntrack_h323_main.c             |   4 +-
 net/netfilter/nf_conntrack_sip.c                   |   4 +-
 net/netfilter/nf_flow_table_core.c                 | 123 +++++++-
 net/netfilter/nf_flow_table_offload.c              |  14 +-
 net/netfilter/nf_nat_bpf.c                         |   3 +
 net/netfilter/nf_nat_core.c                        |   5 +-
 net/netfilter/nfnetlink_queue.c                    |   7 +
 net/netfilter/nft_ct.c                             |   2 +-
 net/netfilter/nft_flow_offload.c                   |   7 +-
 net/netfilter/xt_CHECKSUM.c                        |   6 +-
 net/openvswitch/actions.c                          |   7 +-
 net/openvswitch/datapath.c                         |   8 +
 net/packet/af_packet.c                             |  31 +-
 net/rds/tcp.c                                      |   9 +-
 net/sched/act_ct.c                                 |   2 +-
 net/sched/act_skbedit.c                            |   5 +-
 net/sched/cls_api.c                                |  15 +-
 net/sched/cls_route.c                              |   6 +
 net/sched/em_text.c                                |   3 +
 net/sched/sch_codel.c                              |   2 +-
 net/sched/sch_fq_codel.c                           |   4 +-
 net/sctp/socket.c                                  |   8 +-
 net/smc/af_smc.c                                   |   7 +-
 net/strparser/strparser.c                          |   6 +-
 net/sunrpc/xprtrdma/svc_rdma_transport.c           |   8 +-
 net/tipc/crypto.c                                  |  20 +-
 net/tipc/node.c                                    |  10 +-
 net/tipc/topsrv.c                                  |  80 +++++-
 net/vmw_vsock/af_vsock.c                           |   2 +
 net/vmw_vsock/virtio_transport_common.c            |   4 +-
 net/wireless/scan.c                                |  22 +-
 net/xfrm/xfrm_output.c                             |  16 +-
 security/keys/key.c                                |   6 +-
 security/keys/persistent.c                         |  55 ++--
 security/security.c                                |   5 +-
 security/selinux/avc.c                             |   5 +-
 security/selinux/hooks.c                           |  11 +-
 sound/core/seq/seq_compat.c                        |   4 +-
 sound/pci/hda/hda_tegra.c                          |   3 +-
 sound/pci/ice1712/ice1712.c                        |   2 +-
 sound/soc/amd/yc/acp6x-mach.c                      |   7 +
 sound/soc/codecs/adau1372.c                        |  18 +-
 sound/soc/codecs/max98363.c                        |   2 +-
 sound/soc/codecs/rt1017-sdca-sdw.c                 |  27 +-
 sound/soc/codecs/rt274.c                           |   4 +-
 sound/soc/codecs/rt286.c                           |   2 +-
 sound/soc/codecs/wm8903.c                          |   2 +-
 sound/soc/qcom/lpass-cpu.c                         |   4 +-
 sound/soc/samsung/i2s.c                            |   8 +
 sound/soc/sdw_utils/soc_sdw_utils.c                |  20 +-
 sound/soc/sof/intel/hda-loader.c                   |   7 +-
 sound/soc/sof/ipc4-loader.c                        |   6 +
 sound/soc/sof/ipc4-priv.h                          |   3 +
 sound/soc/sof/ipc4.c                               |  14 +-
 sound/soc/tegra/tegra186_asrc.c                    |   2 +-
 sound/usb/caiaq/device.c                           |   3 +
 sound/usb/line6/playback.c                         |   7 +
 sound/usb/misc/ua101.c                             |   9 +
 sound/usb/quirks.c                                 |   4 +-
 tools/net/ynl/ynl-gen-c.py                         |  70 ++++-
 tools/testing/selftests/mm/hugepage-mremap.c       |   5 +
 tools/testing/selftests/mm/memfd_secret.c          |  30 +-
 544 files changed, 5630 insertions(+), 2793 deletions(-)
author maintainer
#1 lore raw

PATCH 1/497 smb: client: fix OOB read/write from unvalidated DataOffset in coalesce_t2()

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Frank Sorenson <[email protected]>

[ Upstream commit 6343c1da561962688f203362d80d6a3bfa39fa1b ]

coalesce_t2() computes data pointers directly from server-supplied DataOffset fields with no validation against buffer bounds:

  data_area_of_tgt = (char *)&pSMBt->hdr.Protocol +
                     get_unaligned_le16(&pSMBt->t2_rsp.DataOffset);
  data_area_of_src = (char *)&pSMBs->hdr.Protocol +
                     get_unaligned_le16(&pSMBs->t2_rsp.DataOffset);
  data_area_of_tgt += total_in_tgt;
  ...
  memcpy(data_area_of_tgt, data_area_of_src, total_in_src);

A small DataOffset can push a pointer below the actual byte area, overwriting header fields; a large one can push it past the buffer end, causing out-of-bounds heap reads (source) or writes (target). The BCC overflow guard does not prevent this: BCC reflects how much data is present, while DataOffset controls where in the buffer it starts.

The "validate target area" comment present since the function was first written in 2005 was a placeholder that was never implemented.

Add lower- and upper-bound checks for both data pointers before the memcpy, and before any target header fields are modified.

Fixes e4eb295d38b5 ("[PATCH] cifs: Handle multiple response transact2 part 1 of 2")
[ transplanted the bounds validation to coalesce_t2() in smb1ops.c due to code relocation ]
---
 fs/smb/client/smb1ops.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
fs/smb/client/smb1ops.c +20 -1
index eafdf6c38796a..5556601abfe9e 100644
@@ -325,12 +325,31 @@ coalesce_t2(char *second_buf, struct smb_hdr *target_hdr)
 	data_area_of_tgt = (char *)&pSMBt->hdr.Protocol +
 				get_unaligned_le16(&pSMBt->t2_rsp.DataOffset);
 
-	/* validate target area */
 	data_area_of_src = (char *)&pSMBs->hdr.Protocol +
 				get_unaligned_le16(&pSMBs->t2_rsp.DataOffset);
 
 	data_area_of_tgt += total_in_tgt;
 
+	/*
+	 * DataOffset fields are server-supplied and not validated against
+	 * buffer bounds; check both data pointers before mutating the
+	 * target header.
+	 */
+	if (data_area_of_tgt < (char *)target_hdr +
+				sizeof(struct smb_t2_rsp) + sizeof(__le16) ||
+	    data_area_of_tgt + total_in_src >
+	    (char *)target_hdr + CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) {
+		cifs_dbg(VFS, "%s: target data area out of bounds\n", __func__);
+		return -EPROTO;
+	}
+	if (data_area_of_src < second_buf +
+				sizeof(struct smb_t2_rsp) + sizeof(__le16) ||
+	    data_area_of_src + total_in_src >
+	    second_buf + smbCalcSize((struct smb_hdr *)second_buf)) {
+		cifs_dbg(VFS, "%s: secondary data area out of bounds\n", __func__);
+		return -EPROTO;
+	}
+
 	total_in_tgt += total_in_src;
 	/* is the result too big for the field? */
 	if (total_in_tgt > USHRT_MAX) {
Signature · 1 line
2.53.0
author maintainer
#2 lore raw

PATCH 2/497 smb: client: fix cifsFileInfo reference leak in deferred close

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Fan Wu <[email protected]>

[ Upstream commit 5520e89a5a4f834bced64cf2ac927001cc513a40 ]

When cifs_close() defers a close, it hands the cifsFileInfo reference of the closing struct file to the queued work. Each execution of smb2_deferred_work_close() drops one such reference.

deferred_close_scheduled can be false while the work is pending: the workqueue clears PENDING when the callback starts to run, before the callback clears the flag under deferred_lock. A close in that interval requeues the running work, and the callback then clears the flag, leaving the requeued work pending with the flag down. A later cifs_open() can reuse the handle and its cifs_close() reaches the same branch: queue_delayed_work() fails because the work is still pending, but cifs_close() returns without dropping the closing file's reference. The cifsFileInfo count stays pinned and its tlink, dentry and server handle are leaked.

Check the return value and hand off the reference only when work was actually queued. Otherwise, use the shared _cifsFileInfo_put(), like the mod_delayed_work() branch above: the pending execution already owns its reference.

This issue was found by an in-house static analysis tool.

Fixes c3f207ab29f7 ("cifs: Deferred close for files")
Assisted-by Codex:gpt-5.6
[ Adjusted cifs_close() context due to missing trace_smb3_close_cached(). ]
---
 fs/smb/client/file.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
fs/smb/client/file.c +12 -5
index afe00c0cc696a..ee3cc2b2fda41 100644
@@ -1378,11 +1378,18 @@ int cifs_close(struct inode *inode, struct file *file)
 					cifsFileInfo_get(cfile);
 			} else {
 				/* Deferred close for files */
-				queue_delayed_work(deferredclose_wq,
-						&cfile->deferred, cifs_sb->ctx->closetimeo);
-				cfile->deferred_close_scheduled = true;
-				spin_unlock(&cinode->deferred_lock);
-				return 0;
+				/*
+				 * Each queued execution owns one reference.
+				 * If nothing was queued, the reference of
+				 * the closing file is dropped below.
+				 */
+				if (queue_delayed_work(deferredclose_wq,
+						       &cfile->deferred,
+						       cifs_sb->ctx->closetimeo)) {
+					cfile->deferred_close_scheduled = true;
+					spin_unlock(&cinode->deferred_lock);
+					return 0;
+				}
 			}
 			spin_unlock(&cinode->deferred_lock);
 			_cifsFileInfo_put(cfile, true, false);
Signature · 1 line
2.53.0
author maintainer
#3 lore raw

PATCH 3/497 KVM: arm64: nv: Fix life cycle of the nested_mmus array

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Marc Zyngier <[email protected]>

[ Upstream commit 33346f8960c7bb6a3b4e273b5cfe25c5a8be349f ]

The nested_mmus array holds the shadow page tables that are used when a guest is running a nested context. These structures are allocated on VCPU_INIT for whole guest, which implies that they may have to be relocated as the array grows.

Should a VCPU_INIT occur whilst a vcpu is actively running an L2 and that the allocation requires relocation, that vcpu will still be running with a pointer to the previous structure, which will have been freed.

Fix this by turning the array of structures to an array of pointers, which is now allocated at VM creation, sized to the absolute maximum that KVM can handle.

In turn, each VCPU_INIT contributes S2_MMU_PER_VCPU to the pool. No reallocation is ever performed, and the life cycle of each object is much clearer:

- the nested_mmus array is allocated in kvm_init_nested(), and freed in kvm_arch_destroy_vm()

- s2_mmu structures are allocated in kvm_vcpu_init_nested(), and freed on kvm_arch_flush_shadow_all()

Finally, the freeing of vcpu->arch.vncr_array is made consistent rather than being done on some failure paths, but not others.

[6.12 backport: Retain the fixed pointer array and per-vCPU MMU batches, including publication under mmu_lock and cleanup of partially initialized batches. Add the stage-2 unwind label to the existing VM initialization path without importing the newer protected-VM setup. Omit VNCR allocation, VNCR TLB accounting, E2H0 checks and the debug-exception declaration, whose support is absent here. No new functions are introduced. Keep the MMU cleanup layout needed by e5843f4effaa ("KVM: arm64: nv: Delay freeing of shadow S2 structures until VM destruction").]

Stable-dep-of: e5843f4effaa ("KVM: arm64: nv: Delay freeing of shadow S2 structures until VM destruction")

---
 arch/arm64/include/asm/kvm_host.h   |  2 +-
 arch/arm64/include/asm/kvm_nested.h |  2 +-
 arch/arm64/kvm/arm.c                | 10 +++-
 arch/arm64/kvm/nested.c             | 88 +++++++++++++++--------------
 4 files changed, 55 insertions(+), 47 deletions(-)
arch/arm64/include/asm/kvm_host.h +1 -1
index ab0402642f347..4f6afd2c042fe 100644
@@ -292,7 +292,7 @@ struct kvm_arch {
 	 * Stage 2 paging state for VMs with nested S2 using a virtual
 	 * VMID.
 	 */
-	struct kvm_s2_mmu *nested_mmus;
+	struct kvm_s2_mmu **nested_mmus;
 	size_t nested_mmus_size;
 	int nested_mmus_next;
 
arch/arm64/include/asm/kvm_nested.h +1 -1
index 233e655227164..d9250fa8cdd03 100644
@@ -64,7 +64,7 @@ static inline u64 translate_ttbr0_el2_to_ttbr0_el1(u64 ttbr0)
 }
 
 extern bool forward_smc_trap(struct kvm_vcpu *vcpu);
-extern void kvm_init_nested(struct kvm *kvm);
+extern int kvm_init_nested(struct kvm *kvm);
 extern int kvm_vcpu_init_nested(struct kvm_vcpu *vcpu);
 extern void kvm_init_nested_s2_mmu(struct kvm_s2_mmu *mmu);
 extern struct kvm_s2_mmu *lookup_s2_mmu(struct kvm_vcpu *vcpu);
arch/arm64/kvm/arm.c +8 -2
index 72e4c290d8fca..ec229e6a0b731 100644
@@ -181,8 +181,6 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 	mutex_unlock(&kvm->lock);
 #endif
 
-	kvm_init_nested(kvm);
-
 	ret = kvm_share_hyp(kvm, kvm + 1);
 	if (ret)
 		return ret;
@@ -201,6 +199,10 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 	if (ret)
 		goto err_free_cpumask;
 
+	ret = kvm_init_nested(kvm);
+	if (ret)
+		goto err_uninit_mmu;
+
 	kvm_vgic_early_init(kvm);
 
 	kvm_timer_init_vm(kvm);
@@ -214,6 +216,9 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 
 	return 0;
 
+err_uninit_mmu:
+	kvm_uninit_stage2_mmu(kvm);
+	kvfree(kvm->arch.nested_mmus);
 err_free_cpumask:
 	free_cpumask_var(kvm->arch.supported_cpus);
 err_unshare_kvm:
@@ -270,6 +275,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
 
 	kvm_unshare_hyp(kvm, kvm + 1);
 
+	kvfree(kvm->arch.nested_mmus);
 	kvm_arm_teardown_hypercalls(kvm);
 }
 
arch/arm64/kvm/nested.c +45 -43

155 lines not on this page · raw message

Signature · 1 line
2.53.0
author maintainer
#4 lore raw

PATCH 4/497 KVM: arm64: nv: Delay freeing of shadow S2 structures until VM destruction

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Marc Zyngier <[email protected]>

[ Upstream commit e5843f4effaa2ffac3e789ecd4456403564961d4 ]

We free the shadow S2 structures from kvm_arch_flush_shadow_all(), which is a Bad Idea(tm). Freeing the page tables is fair game (this is what this callback is for), but freeing the container that could still be referenced by another part of the system is not great.

Instead, grow separate destructors that gets called when we tear the VM down for good. From there, we can nuke both the individual MMUs as well as the global array that points to them, safe in the knowledge that the vcpus themselves have been destroyed already.

---
 arch/arm64/include/asm/kvm_nested.h |  1 +
 arch/arm64/kvm/arm.c                |  4 ++--
 arch/arm64/kvm/nested.c             | 15 ++++++++++-----
 3 files changed, 13 insertions(+), 7 deletions(-)
arch/arm64/include/asm/kvm_nested.h +1 -0
index d9250fa8cdd03..ae3a285e99d06 100644
@@ -65,6 +65,7 @@ static inline u64 translate_ttbr0_el2_to_ttbr0_el1(u64 ttbr0)
 
 extern bool forward_smc_trap(struct kvm_vcpu *vcpu);
 extern int kvm_init_nested(struct kvm *kvm);
+extern void kvm_destroy_nested(struct kvm *kvm);
 extern int kvm_vcpu_init_nested(struct kvm_vcpu *vcpu);
 extern void kvm_init_nested_s2_mmu(struct kvm_s2_mmu *mmu);
 extern struct kvm_s2_mmu *lookup_s2_mmu(struct kvm_vcpu *vcpu);
arch/arm64/kvm/arm.c +2 -2
index ec229e6a0b731..2a156ddf0c314 100644
@@ -218,7 +218,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 
 err_uninit_mmu:
 	kvm_uninit_stage2_mmu(kvm);
-	kvfree(kvm->arch.nested_mmus);
+	kvm_destroy_nested(kvm);
 err_free_cpumask:
 	free_cpumask_var(kvm->arch.supported_cpus);
 err_unshare_kvm:
@@ -275,7 +275,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
 
 	kvm_unshare_hyp(kvm, kvm + 1);
 
-	kvfree(kvm->arch.nested_mmus);
+	kvm_destroy_nested(kvm);
 	kvm_arm_teardown_hypercalls(kvm);
 }
 
arch/arm64/kvm/nested.c +10 -5
index aae70f62133a6..45836a9c001d1 100644
@@ -37,6 +37,15 @@ int kvm_init_nested(struct kvm *kvm)
 	return kvm->arch.nested_mmus ? 0 : -ENOMEM;
 }
 
+void kvm_destroy_nested(struct kvm *kvm)
+{
+	for (int i = 0; i < kvm->arch.nested_mmus_size; i+= S2_MMU_PER_VCPU)
+		kvfree(kvm->arch.nested_mmus[i]);
+
+	kvm->arch.nested_mmus_size = 0;
+	kvfree(kvm->arch.nested_mmus);
+}
+
 static int init_nested_s2_mmu(struct kvm *kvm, struct kvm_s2_mmu *mmu)
 {
 	/*
@@ -788,16 +797,12 @@ void kvm_nested_s2_flush(struct kvm *kvm)
 
 void kvm_arch_flush_shadow_all(struct kvm *kvm)
 {
-	for (int i = kvm->arch.nested_mmus_size - 1; i >= 0; i--) {
+	for (int i = 0; i < kvm->arch.nested_mmus_size; i++) {
 		struct kvm_s2_mmu *mmu = kvm->arch.nested_mmus[i];
 
 		if (!WARN_ON(atomic_read(&mmu->refcnt)))
 			kvm_free_stage2_pgd(mmu);
-
-		if ((i % S2_MMU_PER_VCPU) == 0)
-			kvfree(mmu);
 	}
-	kvm->arch.nested_mmus_size = 0;
 	kvm_uninit_stage2_mmu(kvm);
 }
 
Signature · 1 line
2.53.0
author maintainer
#5 lore raw

PATCH 5/497 selftests/mm: hugetlb-mremap: add setup of HugeTLB pages

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Mike Rapoport (Microsoft) <[email protected]>

commit a914785f6349da754e1226420bf4e51961956769 upstream.

hugetlb-mremap test fails if there are no free huge pages prepared by a wrapper script.

Add setup of HugeTLB pages to the test and make sure that the original settings are restored on the test exit.

Cc Baolin Wang <[email protected]>
Cc Barry Song <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Dev Jain <[email protected]>
Cc Donet Tom <[email protected]>
Cc Jason Gunthorpe <[email protected]>
Cc John Hubbard <[email protected]>
Cc Lance Yang <[email protected]>
Cc Leon Romanovsky <[email protected]>
Cc Liam Howlett <[email protected]>
Cc Li Wang <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Mark Brown <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Nico Pache <[email protected]>
Cc Peter Xu <[email protected]>
Cc Ryan Roberts <[email protected]>
Cc Shuah Khan <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Zi Yan <[email protected]>

[ Backport-notes: this is a partial backport containing only the aligning of 'length' to the hugepage size. The hugepage_settings.h include line and the hugetlb_setup_default() call are omitted. Without this fix, the uffd_register() call always fails on arm64 with 64K base pages and 512 MiB default HugeTLB page size causing the test to fail with the error below as 'length' is 10 MiB and not aligned to the HugeTLB page size.

# -------------------------

  # running ./hugepage-mremap
  # -------------------------
  # TAP version 13
  # 1..1
  # # Map haddr: Returned address is 0x7eaa40000000
  # # Map daddr: Returned address is 0x7daa40000000
  # # Map vaddr: Returned address is 0x7faa40000000
  # Bail out! ioctl-UFFDIO_REGISTER: Invalid argument
  # # Planned tests != run tests (1 != 0)
  # # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0
  # [FAIL]
  not ok 1 hugepage-mremap # exit=1
  # NOTE: These hugetlb tests provide minimal coverage.  Use
  #       https://github.com/libhugetlbfs/libhugetlbfs.git for
  #       hugetlb regression testing.
  # SKIP ./uffd-wp-mremap
]
Signed-off-by: Luiz Capitulino <[email protected]>
---
 tools/testing/selftests/mm/hugepage-mremap.c | 5 +++++
 1 file changed, 5 insertions(+)
tools/testing/selftests/mm/hugepage-mremap.c +5 -0
index 3070484f9ed0a..164bbda8128f9 100644
@@ -87,6 +87,7 @@ static void register_region_with_uffd(char *addr, size_t len)
 
 int main(int argc, char *argv[])
 {
+	unsigned long hugepage_size;
 	size_t length = 0;
 	int ret = 0, fd;
 
@@ -104,7 +105,11 @@ int main(int argc, char *argv[])
 	else
 		length = DEFAULT_LENGTH_MB;
 
+	hugepage_size = default_huge_page_size();
+	if (!hugepage_size)
+		ksft_exit_skip("Could not detect default hugetlb page size\n");
 	length = MB_TO_BYTES(length);
+	length = (length + hugepage_size - 1) & ~(hugepage_size - 1);
 	fd = memfd_create(argv[0], MFD_HUGETLB);
 	if (fd < 0)
 		ksft_exit_fail_msg("Open failed: %s\n", strerror(errno));
Signature · 1 line
2.53.0
author maintainer
#6 lore raw

PATCH 6/497 smb: client: use finish_no_open() for non-regular inodes

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Namjae Jeon <[email protected]>

[ Upstream commit e66cf1625ec4a3fe68346119f371def713fd0a4d ]

An O_CREAT open can find an existing symlink or another non-regular inode. cifs_atomic_open() calls finish_open() on it and attaches a cifsFileInfo. Symlink inodes have no CIFS release operation, so the dentry reference held by cifsFileInfo is leaked. FMODE_OPENED also prevents the VFS from following the symlink.

Track whether cifs_do_create() returned an open server handle. For non-regular inodes, close the handle if present, remove the pending open, and call finish_no_open() so the VFS can continue the lookup. Do not set FMODE_CREATED unless a regular file was opened. For O_NOFOLLOW with __O_REGULAR, return -ELOOP before the VFS's -EFTYPE check.

Defer closing a legacy POSIX handle on a non-regular inode until after inode lookup. This avoids closing it again if lookup fails.

Fixes d2c127197dfc ("cifs: implement i_op->atomic_open()")
[ replaced S_ISREG(inode->i_mode) with d_is_reg(direntry) because the older cifs_do_create() already attaches the inode. ]
---
 fs/smb/client/dir.c | 39 +++++++++++++++++++++++++++++----------
 1 file changed, 29 insertions(+), 10 deletions(-)
fs/smb/client/dir.c +29 -10
index 6bb0e98462a98..66bf81d159625 100644
@@ -176,7 +176,8 @@ check_name(struct dentry *direntry, struct cifs_tcon *tcon)
 
 static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
 			  struct tcon_link *tlink, unsigned int oflags, umode_t mode, __u32 *oplock,
-			  struct cifs_fid *fid, struct cifs_open_info_data *buf)
+			  struct cifs_fid *fid, struct cifs_open_info_data *buf,
+			  bool *opened)
 {
 	int rc = -ENOENT;
 	int create_options = CREATE_NOT_DIR;
@@ -191,6 +192,7 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned
 	struct cifs_open_parms oparms;
 	int rdwr_for_fscache = 0;
 
+	*opened = false;
 	*oplock = 0;
 	if (tcon->ses->server->oplocks)
 		*oplock = REQ_OPLOCK;
@@ -213,6 +215,7 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned
 				     oflags, oplock, &fid->netfid, xid);
 		switch (rc) {
 		case 0:
+			*opened = true;
 			if (newinode == NULL) {
 				/* query inode info */
 				goto cifs_create_get_file_info;
@@ -229,11 +232,9 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned
 				/*
 				 * The server may allow us to open things like
 				 * FIFOs, but the client isn't set up to deal
-				 * with that. If it's not a regular file, just
-				 * close it and proceed as if it were a normal
-				 * lookup.
+				 * with that. Keep the handle until the caller
+				 * can finish the lookup.
 				 */
-				CIFSSMBClose(xid, tcon, fid->netfid);
 				goto cifs_create_get_file_info;
 			}
 			/* success, no need to query */
@@ -333,6 +334,7 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned
 		}
 		goto out;
 	}
+	*opened = true;
 	if (rdwr_for_fscache == 2)
 		cifs_invalidate_cache(inode, FSCACHE_INVAL_DIO_WRITE);
 
@@ -423,7 +425,7 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned
 	return rc;
 
 out_err:
-	if (server->ops->close)
+	if (*opened && server->ops->close)
 		server->ops->close(xid, tcon, fid);
 	if (newinode)
 		iput(newinode);
@@ -442,6 +444,8 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,
 	struct cifs_fid fid = {};
 	struct cifs_pending_open open;
 	__u32 oplock;
+	bool is_regular;
+	bool opened;
 	struct cifsFileInfo *file_info;
 	struct cifs_open_info_data buf = {};
 
@@ -501,15 +505,28 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,
 	cifs_add_pending_open(&fid, tlink, &open);
 
 	rc = cifs_do_create(inode, direntry, xid, tlink, oflags, mode,
-			    &oplock, &fid, &buf);
+			    &oplock, &fid, &buf, &opened);
 	if (rc) {
 		cifs_del_pending_open(&open);
 		goto out;
 	}
 
-	if ((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
+	is_regular = d_is_reg(direntry);
+	if (!is_regular || !opened) {
+		if (opened && server->ops->close)
+			server->ops->close(xid, tcon, &fid);
+		cifs_del_pending_open(&open);
+	}
+
+	if (is_regular && opened &&
+	    (oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
 		file->f_mode |= FMODE_CREATED;
 
+	if (!is_regular || !opened) {
+		rc = finish_no_open(file, NULL);
+		goto out;
+	}
+
 	rc = finish_open(file, direntry, generic_file_open);
 	if (rc) {
 		if (server->ops->close)
@@ -564,6 +581,7 @@ int cifs_create(struct mnt_idmap *idmap, struct inode *inode,
 	struct TCP_Server_Info *server;
 	struct cifs_fid fid;
 	__u32 oplock;
+	bool opened;
 	struct cifs_open_info_data buf = {};
 
 	cifs_dbg(FYI, "cifs_create parent inode = 0x%p name is: %pd and dentry = 0x%p\n",
@@ -585,8 +603,9 @@ int cifs_create(struct mnt_idmap *idmap, struct inode *inode,
 	if (server->ops->new_lease_key)
 		server->ops->new_lease_key(&fid);
 
-	rc = cifs_do_create(inode, direntry, xid, tlink, oflags, mode, &oplock, &fid, &buf);
-	if (!rc && server->ops->close)
+	rc = cifs_do_create(inode, direntry, xid, tlink, oflags, mode,
+			    &oplock, &fid, &buf, &opened);
+	if (!rc && opened && server->ops->close)
 		server->ops->close(xid, tcon, &fid);
 
 	cifs_free_open_info(&buf);
Signature · 1 line
2.53.0
author maintainer
#7 lore raw

PATCH 7/497 xfs: dont let memory failures leak blocks and kill repairs

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Darrick J. Wong <[email protected]>

[ Upstream commit ab1c416d2377cdc16123ef521aac4da1c468c3d4 ]

LOLLM complains that a memory allocation failure in xrep_newbt_add_blocks results in online repair leaking blocks that were previously allocated to write a new btree, but the problem is worse than that -- a limitation of the codebase is that the callers cannot undo the transaction /and/ return the error -- either you undo all changes and commit the transaction, or you error out and the filesystem goes down.

However, the new btree space reservation object isn't that big (~48 bytes). Let's just do a NOFAIL allocation and the problem goes away.

Fixes be408417630427 ("xfs: implement block reservation accounting for btrees we're staging")
Assisted-by LOLLM # finding obvious bugs
[ Changed kmalloc_obj() to kmalloc(sizeof(struct xrep_newbt_resv), ...) to preserve the branch’s existing allocation syntax. ]
---
 fs/xfs/scrub/newbt.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
fs/xfs/scrub/newbt.c +5 -3
index 2aa14b7ab6306..1e362e6eb87a0 100644
@@ -147,9 +147,11 @@ xrep_newbt_add_blocks(
 	struct xrep_newbt_resv		*resv;
 	int				error;
 
-	resv = kmalloc(sizeof(struct xrep_newbt_resv), XCHK_GFP_FLAGS);
-	if (!resv)
-		return -ENOMEM;
+	/*
+	 * We have no way to clean up the allocated space *and* return an
+	 * ENOMEM if we fail to allocate this control structure.
+	 */
+	resv = kmalloc(sizeof(struct xrep_newbt_resv), GFP_KERNEL | __GFP_NOFAIL);
 
 	INIT_LIST_HEAD(&resv->list);
 	resv->agbno = XFS_FSB_TO_AGBNO(mp, args->fsbno);
Signature · 1 line
2.53.0
author maintainer
#8 lore raw

PATCH 8/497 RISC-V: KVM: Fix null pointer dereference in kvm_riscv_aia_imsic_has_attr()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jiakai Xu <[email protected]>

[ Upstream commit 11366ead4f1412befea660777576c89a1bac0c1e ]

Add a null pointer check for imsic_state before dereferencing it in kvm_riscv_aia_imsic_has_attr(). While the function checks that the vcpu exists, it doesn't verify that the vcpu's imsic_state has been initialized, leading to a null pointer dereference when accessed.

This issue was discovered during fuzzing of RISC-V KVM code. The crash occurs when userspace calls KVM_HAS_DEVICE_ATTR ioctl on an AIA IMSIC device before the IMSIC state has been fully initialized for a vcpu.

The crash manifests as:

  Unable to handle kernel paging request at virtual address
  dfffffff00000001
  ...
  epc : kvm_riscv_aia_imsic_has_attr+0x464/0x50e
  arch/riscv/kvm/aia_imsic.c:998
  ...
  kvm_riscv_aia_imsic_has_attr+0x464/0x50e arch/riscv/kvm/aia_imsic.c:998
  aia_has_attr+0x128/0x2bc arch/riscv/kvm/aia_device.c:471
  kvm_device_ioctl_attr virt/kvm/kvm_main.c:4722 [inline]
  kvm_device_ioctl+0x296/0x374 virt/kvm/kvm_main.c:4739
  ...

The fix adds a check to return -ENODEV if imsic_state is NULL, which is consistent with other error handling in the function and prevents the null pointer dereference.

Fixes 5463091a51cf ("RISC-V: KVM: Expose IMSIC registers as attributes of AIA irqchip")
---
 arch/riscv/kvm/aia_imsic.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
arch/riscv/kvm/aia_imsic.c +4 -1
index abc247f7c9034..3da37586a6750 100644
@@ -945,8 +945,11 @@ int kvm_riscv_aia_imsic_has_attr(struct kvm *kvm, unsigned long type)
 	if (!vcpu)
 		return -ENODEV;
 
-	isel = KVM_DEV_RISCV_AIA_IMSIC_GET_ISEL(type);
 	imsic = vcpu->arch.aia_context.imsic_state;
+	if (!imsic)
+		return -ENODEV;
+
+	isel = KVM_DEV_RISCV_AIA_IMSIC_GET_ISEL(type);
 	return imsic_mrif_isel_check(imsic->nr_eix, isel);
 }
 
Signature · 1 line
2.53.0
author maintainer
#9 lore raw

PATCH 9/497 bpf, xdp: move offload check into dev_xdp_install()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jiayuan Chen <[email protected]>

[ Upstream commit ad27ed7d2309419a129078d781504f486b1b469a ]

bpf_xdp_link_update() calls dev_xdp_install() directly and skips dev_xdp_attach(), so the checks in dev_xdp_attach() do not run. A user can make an XDP link with a normal program and then swap in an offloaded or device-bound program with BPF_LINK_UPDATE, which puts it on the software path.

dev_xdp_install() is the one place all three paths go through:
"ip link set xdp" and BPF_LINK_CREATE reach it via dev_xdp_attach(), and BPF_LINK_UPDATE calls it directly. So move the program checks (offloaded, bound to another device, device-bound in generic mode, native vs generic, DEVMAP and CPUMAP) there, and keep only the netlink-flag check (XDP_FLAGS_UPDATE_IF_NOEXIST) in dev_xdp_attach().

Fixes 026a4c28e1db3 ("bpf, xdp: Implement LINK_UPDATE for BPF XDP link")
---
 net/core/dev.c | 59 ++++++++++++++++++++++++++------------------------
 1 file changed, 31 insertions(+), 28 deletions(-)
net/core/dev.c +31 -28
index 6c63867ff76d6..97be4f9dfa771 100644
@@ -9539,6 +9539,37 @@ static int dev_xdp_install(struct net_device *dev, enum bpf_xdp_mode mode,
 	struct netdev_bpf xdp;
 	int err;
 
+	if (prog) {
+		enum bpf_xdp_mode other_mode = mode == XDP_MODE_SKB
+					       ? XDP_MODE_DRV : XDP_MODE_SKB;
+		bool offload = mode == XDP_MODE_HW;
+
+		if (!offload && dev_xdp_prog(dev, other_mode)) {
+			NL_SET_ERR_MSG(extack, "Native and generic XDP can't be active at the same time");
+			return -EEXIST;
+		}
+		if (!offload && bpf_prog_is_offloaded(prog->aux)) {
+			NL_SET_ERR_MSG(extack, "Using offloaded program without HW_MODE flag is not supported");
+			return -EINVAL;
+		}
+		if (bpf_prog_is_dev_bound(prog->aux) && !bpf_offload_dev_match(prog, dev)) {
+			NL_SET_ERR_MSG(extack, "Program bound to different device");
+			return -EINVAL;
+		}
+		if (bpf_prog_is_dev_bound(prog->aux) && mode == XDP_MODE_SKB) {
+			NL_SET_ERR_MSG(extack, "Can't attach device-bound programs in generic mode");
+			return -EINVAL;
+		}
+		if (prog->expected_attach_type == BPF_XDP_DEVMAP) {
+			NL_SET_ERR_MSG(extack, "BPF_XDP_DEVMAP programs can not be attached to a device");
+			return -EINVAL;
+		}
+		if (prog->expected_attach_type == BPF_XDP_CPUMAP) {
+			NL_SET_ERR_MSG(extack, "BPF_XDP_CPUMAP programs can not be attached to a device");
+			return -EINVAL;
+		}
+	}
+
 	if (dev_get_min_mp_channel_count(dev)) {
 		NL_SET_ERR_MSG(extack, "unable to install XDP to device using memory provider");
 		return -EBUSY;
@@ -9672,38 +9703,10 @@ static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extack
 		new_prog = link->link.prog;
 
 	if (new_prog) {
-		bool offload = mode == XDP_MODE_HW;
-		enum bpf_xdp_mode other_mode = mode == XDP_MODE_SKB
-					       ? XDP_MODE_DRV : XDP_MODE_SKB;
-
 		if ((flags & XDP_FLAGS_UPDATE_IF_NOEXIST) && cur_prog) {
 			NL_SET_ERR_MSG(extack, "XDP program already attached");
 			return -EBUSY;
 		}
-		if (!offload && dev_xdp_prog(dev, other_mode)) {
-			NL_SET_ERR_MSG(extack, "Native and generic XDP can't be active at the same time");
-			return -EEXIST;
-		}
-		if (!offload && bpf_prog_is_offloaded(new_prog->aux)) {
-			NL_SET_ERR_MSG(extack, "Using offloaded program without HW_MODE flag is not supported");
-			return -EINVAL;
-		}
-		if (bpf_prog_is_dev_bound(new_prog->aux) && !bpf_offload_dev_match(new_prog, dev)) {
-			NL_SET_ERR_MSG(extack, "Program bound to different device");
-			return -EINVAL;
-		}
-		if (bpf_prog_is_dev_bound(new_prog->aux) && mode == XDP_MODE_SKB) {
-			NL_SET_ERR_MSG(extack, "Can't attach device-bound programs in generic mode");
-			return -EINVAL;
-		}
-		if (new_prog->expected_attach_type == BPF_XDP_DEVMAP) {
-			NL_SET_ERR_MSG(extack, "BPF_XDP_DEVMAP programs can not be attached to a device");
-			return -EINVAL;
-		}
-		if (new_prog->expected_attach_type == BPF_XDP_CPUMAP) {
-			NL_SET_ERR_MSG(extack, "BPF_XDP_CPUMAP programs can not be attached to a device");
-			return -EINVAL;
-		}
 	}
 
 	/* don't call drivers if the effective program didn't change */
Signature · 1 line
2.53.0
author maintainer
#10 lore raw

PATCH 10/497 ASoC: sdw_utils: Set snd_soc_dai_link_ch_map.codec_ch_mask for capture

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Richard Fitzgerald <[email protected]>

[ Upstream commit 290845e151cd4e307cc1f25319583aaceb4eeb30 ]

In asoc_sdw_hw_params() set the codec_ch_mask member of struct snd_soc_dai_link_ch_map for capture streams. ASoC will then pass the correct number of channels to each codec hw_params(). This prevents trying to enable more channels on the codec DP than have been allocated bitslots in the SoundWire frame, which would cause bus clash errors.

In theory codec_ch_mask could also be set for playback streams, but for those the CPU is the only sender so there is no risk of bus clash. For playback streams codec_ch_mask is set to 0 to preserve the existing behavior and avoid introducing bugs.

---
 sound/soc/sdw_utils/soc_sdw_utils.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
sound/soc/sdw_utils/soc_sdw_utils.c +14 -6
index 70a7abede618f..44b132bc10439 100644
@@ -764,7 +764,7 @@ int asoc_sdw_hw_params(struct snd_pcm_substream *substream,
 	struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
 	struct snd_soc_dai_link_ch_map *ch_maps;
 	int ch = params_channels(params);
-	unsigned int ch_mask;
+	unsigned int cpu_ch_mask, codec_ch_mask;
 	int num_codecs;
 	int step;
 	int i;
@@ -774,8 +774,9 @@ int asoc_sdw_hw_params(struct snd_pcm_substream *substream,
 
 	/* Identical data will be sent to all codecs in playback */
 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-		ch_mask = GENMASK(ch - 1, 0);
+		cpu_ch_mask = GENMASK(ch - 1, 0);
 		step = 0;
+		codec_ch_mask = 0;
 	} else {
 		num_codecs = rtd->dai_link->num_codecs;
 
@@ -785,17 +786,24 @@ int asoc_sdw_hw_params(struct snd_pcm_substream *substream,
 			return -EINVAL;
 		}
 
-		ch_mask = GENMASK(ch / num_codecs - 1, 0);
-		step = hweight_long(ch_mask);
+		cpu_ch_mask = GENMASK(ch / num_codecs - 1, 0);
+		step = hweight_long(cpu_ch_mask);
+		codec_ch_mask = cpu_ch_mask;
 	}
 
 	/*
 	 * The captured data will be combined from each cpu DAI if the dai
 	 * link has more than one codec DAIs. Set codec channel mask and
 	 * ASoC will set the corresponding channel numbers for each cpu dai.
+	 *
+	 * sdw_stream_add_slave() assigns different payload offsets to each
+	 * codec in a capture stream, so that the same channels on each
+	 * codec map to different channels on the CPU.
 	 */
-	for_each_link_ch_maps(rtd->dai_link, i, ch_maps)
-		ch_maps->cpu_ch_mask = ch_mask << (i * step);
+	for_each_link_ch_maps(rtd->dai_link, i, ch_maps) {
+		ch_maps->cpu_ch_mask = cpu_ch_mask << (i * step);
+		ch_maps->codec_ch_mask = codec_ch_mask;
+	}
 
 	return 0;
 }
Signature · 1 line
2.53.0
author maintainer
#11 lore raw

PATCH 11/497 Bluetooth: btusb: Add IMC Networks QCA9377 to quirks table

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Tibor Harcsa <[email protected]>

[ Upstream commit dc16388d45ecbd3be0d8c9424dbbaa2c81806578 ]

Add the USB ID (13d3:3503) for the IMC Networks Qualcomm Atheros QCA9377 Bluetooth controller to the btusb quirks table. This device requires Qualcomm Rome firmware and wideband speech support to function properly; otherwise, BLE scanning fails with HCI unexpected event opcode 0x2005 errors.

The device reports the following in /sys/kernel/debug/usb/devices:

P: Vendor=13d3 ProdID=3503 Rev= 0.01
C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb

E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
---
 drivers/bluetooth/btusb.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
index 677919e02d29c..00aa0fffd0c94 100644
@@ -305,6 +305,8 @@ static const struct usb_device_id quirks_table[] = {
 						     BTUSB_WIDEBAND_SPEECH },
 	{ USB_DEVICE(0x13d3, 0x3501), .driver_info = BTUSB_QCA_ROME |
 						     BTUSB_WIDEBAND_SPEECH },
+	{ USB_DEVICE(0x13d3, 0x3503), .driver_info = BTUSB_QCA_ROME |
+						     BTUSB_WIDEBAND_SPEECH },
 
 	/* QCA WCN6855 chipset */
 	{ USB_DEVICE(0x0cf3, 0xe600), .driver_info = BTUSB_QCA_WCN6855 |
Signature · 1 line
2.53.0
author maintainer
#12 lore raw

PATCH 12/497 ASoC: SOF: ipc4-priv: Add kernel doc for fw_context_save of sof_ipc4_fw_data

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Peter Ujfalusi <[email protected]>

[ Upstream commit cec49fa47bccadb288fd984ef2a5c45e8a2e2099 ]

The kernel documentation is missing entry for the fw_context_save.

---
 sound/soc/sof/ipc4-priv.h | 1 +
 1 file changed, 1 insertion(+)
sound/soc/sof/ipc4-priv.h +1 -0
index ea3323b90343d..0889de04b0170 100644
@@ -71,6 +71,7 @@ struct sof_ipc4_fw_library {
  * @max_num_pipelines: max number of pipelines
  * @max_libs_count: Maximum number of libraries support by the FW including the
  *		    base firmware
+ * @fw_context_save: Firmware supports full context save and restore
  *
  * @load_library: Callback function for platform dependent library loading
  * @pipeline_state_mutex: Mutex to protect pipeline triggers, ref counts, states and deletion
Signature · 1 line
2.53.0
author maintainer
#13 lore raw

PATCH 13/497 ASoC: SOF: ipc4/Intel: Add support for library restore firmware functionality

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Peter Ujfalusi <[email protected]>

[ Upstream commit ace9b3daf2b4778358573d3698e34cb1c0fa7e14 ]

The firmware will be able to only save and restore the context related to library management.
This means that even without a full context save, the libraries do not need to be re-loaded to the firmware after second or consecutive boots.

This is reported via the FW_READY notification, where BIT(15) indicates:
0 - the library restore is not done
1 - library restore is done

This bit is only valid if full context save is not enabled, full context save is by definition saves and restores the library related book-keeping as well.

Add a new flag to tell the platform code if the libraries have been restored, no need to reload them after boot.

---
 include/sound/sof/ipc4/header.h  |  2 ++
 sound/soc/sof/intel/hda-loader.c |  7 +++++--
 sound/soc/sof/ipc4-loader.c      |  6 ++++++
 sound/soc/sof/ipc4-priv.h        |  2 ++
 sound/soc/sof/ipc4.c             | 14 ++++++++++++--
 5 files changed, 27 insertions(+), 4 deletions(-)
include/sound/sof/ipc4/header.h +2 -0
index 0c0cf47946b1d..5302721c154d0 100644
@@ -485,6 +485,8 @@ struct sof_ipc4_dx_state_info {
 #define SOF_IPC4_LOG_CORE_GET(x)		(((x) & SOF_IPC4_LOG_CORE_MASK) >> \
 						 SOF_IPC4_LOG_CORE_SHIFT)
 
+#define SOF_IPC4_FW_READY_LIB_RESTORED		BIT(15)
+
 /* Value of notification type field - must fit into 8 bits */
 enum sof_ipc4_notification_type {
 	/* Phrase detected (notification from WoV module) */
sound/soc/sof/intel/hda-loader.c +5 -2
index 9d8ebb7c6a106..a1cd80eba6ebc 100644
@@ -548,8 +548,11 @@ int hda_dsp_ipc4_load_library(struct snd_sof_dev *sdev,
 	struct snd_dma_buffer dmab;
 	int ret, ret1;
 
-	/* if IMR booting is enabled and fw context is saved for D3 state, skip the loading */
-	if (reload && hda->booted_from_imr && ipc4_data->fw_context_save)
+	/*
+	 * if IMR booting is enabled and libraries have been restored during fw
+	 * boot, skip the loading
+	 */
+	if (reload && hda->booted_from_imr && ipc4_data->libraries_restored)
 		return 0;
 
 	/* the fw_lib has been verified during loading, we can trust the validity here */
sound/soc/sof/ipc4-loader.c +6 -0
index bcdb33d036820..bba5c1a8e27ed 100644
@@ -401,6 +401,12 @@ int sof_ipc4_query_fw_configuration(struct snd_sof_dev *sdev)
 			break;
 		case SOF_IPC4_FW_CONTEXT_SAVE:
 			ipc4_data->fw_context_save = *tuple->value;
+			/*
+			 * Set the default libraries_restored value - if full
+			 * context save is supported then it means that
+			 * libraries are restored
+			 */
+			ipc4_data->libraries_restored = ipc4_data->fw_context_save;
 			break;
 		default:
 			break;
sound/soc/sof/ipc4-priv.h +2 -0
index 0889de04b0170..bd3cb79084154 100644
@@ -72,6 +72,7 @@ struct sof_ipc4_fw_library {
  * @max_libs_count: Maximum number of libraries support by the FW including the
  *		    base firmware
  * @fw_context_save: Firmware supports full context save and restore
+ * @libraries_restored: The libraries have been retained during firmware boot
  *
  * @load_library: Callback function for platform dependent library loading
  * @pipeline_state_mutex: Mutex to protect pipeline triggers, ref counts, states and deletion
@@ -87,6 +88,7 @@ struct sof_ipc4_fw_data {
 	int max_num_pipelines;
 	u32 max_libs_count;
 	bool fw_context_save;
+	bool libraries_restored;
 
 	int (*load_library)(struct snd_sof_dev *sdev,
 			    struct sof_ipc4_fw_library *fw_lib, bool reload);
sound/soc/sof/ipc4.c +12 -2
index e4eb8e004885e..9427d80ceafaa 100644
@@ -616,9 +616,19 @@ EXPORT_SYMBOL(sof_ipc4_find_debug_slot_offset_by_type);
 
 static int ipc4_fw_ready(struct snd_sof_dev *sdev, struct sof_ipc4_msg *ipc4_msg)
 {
-	/* no need to re-check version/ABI for subsequent boots */
-	if (!sdev->first_boot)
+	if (!sdev->first_boot) {
+		struct sof_ipc4_fw_data *ipc4_data = sdev->private;
+
+		/*
+		 * After the initial boot only check if the libraries have been
+		 * restored when full context save is not enabled
+		 */
+		if (!ipc4_data->fw_context_save)
+			ipc4_data->libraries_restored = !!(ipc4_msg->primary &
+							   SOF_IPC4_FW_READY_LIB_RESTORED);
+
 		return 0;
+	}
 
 	sof_ipc4_create_exception_debugfs_node(sdev);
 
Signature · 1 line
2.53.0
author maintainer
#14 lore raw

PATCH 14/497 smb/client: use stack-allocated smb2_file_all_info in smb3_query_mf_symlink()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: ChenXiaoSong <[email protected]>

[ Upstream commit fc8789bb57e625e5f32ac57ca2e7d3e7b7fda225 ]

SMB2_open() only fills the fixed fields, so a stack-allocated smb2_file_all_info is sufficient here.

Stable-dep-of: 566820af017e ("smb: client: close handle after create-context parsing failure")

---
 fs/smb/client/link.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)
fs/smb/client/link.c +3 -12
index 82156543f1f91..433dce48a6874 100644
@@ -343,7 +343,7 @@ smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
 	int buf_type = CIFS_NO_BUFFER;
 	__le16 *utf16_path;
 	__u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
-	struct smb2_file_all_info *pfile_info = NULL;
+	struct smb2_file_all_info file_info = {};
 
 	oparms = (struct cifs_open_parms) {
 		.tcon = tcon,
@@ -359,20 +359,12 @@ smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
 	if (utf16_path == NULL)
 		return -ENOMEM;
 
-	pfile_info = kzalloc(sizeof(struct smb2_file_all_info) + PATH_MAX * 2,
-			     GFP_KERNEL);
-
-	if (pfile_info == NULL) {
-		kfree(utf16_path);
-		return  -ENOMEM;
-	}
-
-	rc = SMB2_open(xid, &oparms, utf16_path, &oplock, pfile_info, NULL,
+	rc = SMB2_open(xid, &oparms, utf16_path, &oplock, &file_info, NULL,
 		       NULL, NULL);
 	if (rc)
 		goto qmf_out_open_fail;
 
-	if (pfile_info->EndOfFile != cpu_to_le64(CIFS_MF_SYMLINK_FILE_SIZE)) {
+	if (file_info.EndOfFile != cpu_to_le64(CIFS_MF_SYMLINK_FILE_SIZE)) {
 		/* it's not a symlink */
 		rc = -ENOENT; /* Is there a better rc to return? */
 		goto qmf_out;
@@ -390,7 +382,6 @@ smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
 	SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
 qmf_out_open_fail:
 	kfree(utf16_path);
-	kfree(pfile_info);
 	return rc;
 }
 
Signature · 1 line
2.53.0
author maintainer
#15 lore raw

PATCH 15/497 smb/client: pass cifs_open_info_data to SMB2_open()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: ChenXiaoSong <[email protected]>

[ Upstream commit 1f551e407bb49dce0bbd34ed6a499dad69e18020 ]

Let SMB2_open() fill the smb2_file_all_info embedded in cifs_open_info_data directly. This removes the temporary smb2_file_all_info copy in smb2_open_file().

Stable backport notes:
- Preserve the 6.12 replay backoff initialization (cur_sleep = 1) and the existing extern declaration style in smb2proto.h.
- Include the existing open-completion trace changes from 4c46b677f352d (smb: client: add oplock level to smb3_open_done tracepoint). Move the trace after create-context parsing and extend its existing event class and both callers with the oplock argument. This supplies the context required for 566820af017e to apply unchanged and keeps the trace call compatible with its declaration. No new functions are introduced.

Stable-dep-of: 566820af017e ("smb: client: close handle after create-context parsing failure")

---
 fs/smb/client/link.c      |  6 +++---
 fs/smb/client/smb2file.c  | 19 ++++++++-----------
 fs/smb/client/smb2pdu.c   | 35 +++++++++++++++++++----------------
 fs/smb/client/smb2proto.h |  2 +-
 fs/smb/client/trace.h     | 16 ++++++++++------
 5 files changed, 41 insertions(+), 37 deletions(-)
fs/smb/client/link.c +3 -3
index 433dce48a6874..44249e48143f9 100644
@@ -343,7 +343,7 @@ smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
 	int buf_type = CIFS_NO_BUFFER;
 	__le16 *utf16_path;
 	__u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
-	struct smb2_file_all_info file_info = {};
+	struct cifs_open_info_data data = {};
 
 	oparms = (struct cifs_open_parms) {
 		.tcon = tcon,
@@ -359,12 +359,12 @@ smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
 	if (utf16_path == NULL)
 		return -ENOMEM;
 
-	rc = SMB2_open(xid, &oparms, utf16_path, &oplock, &file_info, NULL,
+	rc = SMB2_open(xid, &oparms, utf16_path, &oplock, &data, NULL,
 		       NULL, NULL);
 	if (rc)
 		goto qmf_out_open_fail;
 
-	if (file_info.EndOfFile != cpu_to_le64(CIFS_MF_SYMLINK_FILE_SIZE)) {
+	if (data.fi.EndOfFile != cpu_to_le64(CIFS_MF_SYMLINK_FILE_SIZE)) {
 		/* it's not a symlink */
 		rc = -ENOENT; /* Is there a better rc to return? */
 		goto qmf_out;
fs/smb/client/smb2file.c +8 -11
index 14463d353ea0c..e8e5261d01e6d 100644
@@ -111,8 +111,6 @@ int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms, __u32
 	__le16 *smb2_path;
 	__u8 smb2_oplock;
 	struct cifs_open_info_data *data = buf;
-	struct smb2_file_all_info file_info = {};
-	struct smb2_file_all_info *smb2_data = data ? &file_info : NULL;
 	struct kvec err_iov = {};
 	int err_buftype = CIFS_NO_BUFFER;
 	struct cifs_fid *fid = oparms->fid;
@@ -129,14 +127,14 @@ int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms, __u32
 	}
 	smb2_oplock = SMB2_OPLOCK_LEVEL_BATCH;
 
-	rc = SMB2_open(xid, oparms, smb2_path, &smb2_oplock, smb2_data, NULL, &err_iov,
+	rc = SMB2_open(xid, oparms, smb2_path, &smb2_oplock, data, NULL, &err_iov,
 		       &err_buftype);
 	if (rc == -EACCES && retry_without_read_attributes) {
 		free_rsp_buf(err_buftype, err_iov.iov_base);
 		memset(&err_iov, 0, sizeof(err_iov));
 		err_buftype = CIFS_NO_BUFFER;
 		oparms->desired_access &= ~FILE_READ_ATTRIBUTES;
-		rc = SMB2_open(xid, oparms, smb2_path, &smb2_oplock, smb2_data, NULL, &err_iov,
+		rc = SMB2_open(xid, oparms, smb2_path, &smb2_oplock, data, NULL, &err_iov,
 			       &err_buftype);
 	}
 	if (rc && data) {
@@ -149,9 +147,9 @@ int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms, __u32
 							 oparms->path,
 							 &data->symlink_target);
 			if (!rc) {
-				memset(smb2_data, 0, sizeof(*smb2_data));
+				memset(&data->fi, 0, sizeof(data->fi));
 				oparms->create_options |= OPEN_REPARSE_POINT;
-				rc = SMB2_open(xid, oparms, smb2_path, &smb2_oplock, smb2_data,
+				rc = SMB2_open(xid, oparms, smb2_path, &smb2_oplock, data,
 					       NULL, NULL, NULL);
 				oparms->create_options &= ~OPEN_REPARSE_POINT;
 			}
@@ -180,23 +178,22 @@ int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms, __u32
 		rc = 0;
 	}
 
-	if (smb2_data) {
+	if (data) {
 		/* if open response does not have IndexNumber field - get it */
-		if (smb2_data->IndexNumber == 0) {
+		if (data->fi.IndexNumber == 0) {
 			rc = SMB2_get_srv_num(xid, oparms->tcon,
 				      fid->persistent_fid,
 				      fid->volatile_fid,
-				      &smb2_data->IndexNumber);
+				      &data->fi.IndexNumber);
 			if (rc) {
 				/*
 				 * let get_inode_info disable server inode
 				 * numbers
 				 */
-				smb2_data->IndexNumber = 0;
+				data->fi.IndexNumber = 0;
 				rc = 0;
 			}
 		}
-		memcpy(&data->fi, smb2_data, sizeof(data->fi));
 	}
 
 	*oplock = smb2_oplock;
fs/smb/client/smb2pdu.c +19 -16
index 3c170d7242ee0..31b427d5702e5 100644
@@ -3018,7 +3018,8 @@ int smb311_posix_mkdir(const unsigned int xid, struct inode *inode,
 	}
 
 	trace_smb3_posix_mkdir_done(xid, rsp->PersistentFileId, tcon->tid, ses->Suid,
-				    CREATE_NOT_FILE, FILE_WRITE_ATTRIBUTES);
+				    CREATE_NOT_FILE, FILE_WRITE_ATTRIBUTES,
+				    rsp->OplockLevel);
 
 	SMB2_close(xid, tcon, rsp->PersistentFileId, rsp->VolatileFileId);
 
@@ -3224,7 +3225,7 @@ SMB2_open_free(struct smb_rqst *rqst)
 
 int
 SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
-	  __u8 *oplock, struct smb2_file_all_info *buf,
+	  __u8 *oplock, struct cifs_open_info_data *buf,
 	  struct create_posix_rsp *posix,
 	  struct kvec *err_iov, int *buftype)
 {
@@ -3239,6 +3240,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
 	int rc = 0;
 	int flags = 0;
 	int retries = 0, cur_sleep = 1;
+	struct smb2_file_all_info *file_info = buf ? &buf->fi : NULL;
 
 replay_again:
 	/* reinitialize for possible replay */
@@ -3294,9 +3296,6 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
 		goto creat_exit;
 	} else if (rsp == NULL) /* unlikely to happen, but safer to check */
 		goto creat_exit;
-	else
-		trace_smb3_open_done(xid, rsp->PersistentFileId, tcon->tid, ses->Suid,
-				     oparms->create_options, oparms->desired_access);
 
 	atomic_inc(&tcon->num_remote_opens);
 	oparms->fid->persistent_fid = rsp->PersistentFileId;
@@ -3306,21 +3305,25 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
 	oparms->fid->mid = le64_to_cpu(rsp->hdr.MessageId);
 #endif /* CIFS_DEBUG2 */
 
-	if (buf) {
-		buf->CreationTime = rsp->CreationTime;
-		buf->LastAccessTime = rsp->LastAccessTime;
-		buf->LastWriteTime = rsp->LastWriteTime;
-		buf->ChangeTime = rsp->ChangeTime;
-		buf->AllocationSize = rsp->AllocationSize;
-		buf->EndOfFile = rsp->EndofFile;
-		buf->Attributes = rsp->FileAttributes;
-		buf->NumberOfLinks = cpu_to_le32(1);
-		buf->DeletePending = 0;
+	if (file_info) {
+		file_info->CreationTime = rsp->CreationTime;
+		file_info->LastAccessTime = rsp->LastAccessTime;
+		file_info->LastWriteTime = rsp->LastWriteTime;
+		file_info->ChangeTime = rsp->ChangeTime;
+		file_info->AllocationSize = rsp->AllocationSize;
+		file_info->EndOfFile = rsp->EndofFile;
+		file_info->Attributes = rsp->FileAttributes;
+		file_info->NumberOfLinks = cpu_to_le32(1);
+		file_info->DeletePending = 0; /* successful open = not delete pending */
 	}
 
 
 	rc = smb2_parse_contexts(server, &rsp_iov, &oparms->fid->epoch,
-				 oparms->fid->lease_key, oplock, buf, posix);
+				 oparms->fid->lease_key, oplock, file_info, posix);
+
+	trace_smb3_open_done(xid, rsp->PersistentFileId, tcon->tid, ses->Suid,
+			     oparms->create_options, oparms->desired_access,
+			     *oplock);
 creat_exit:
 	SMB2_open_free(&rqst);
 	free_rsp_buf(resp_buftype, rsp);
fs/smb/client/smb2proto.h +1 -1
index 51d890f74e36f..23e2e5623e721 100644
@@ -154,7 +154,7 @@ extern int SMB2_tcon(const unsigned int xid, struct cifs_ses *ses,
 extern int SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon);
 extern int SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms,
 		     __le16 *path, __u8 *oplock,
-		     struct smb2_file_all_info *buf,
+		     struct cifs_open_info_data *buf,
 		     struct create_posix_rsp *posix,
 		     struct kvec *err_iov, int *resp_buftype);
 extern int SMB2_open_init(struct cifs_tcon *tcon,
fs/smb/client/trace.h +10 -6
index 724ca0d7eeecb..55b37dc74aa85 100644
@@ -1103,8 +1103,9 @@ DECLARE_EVENT_CLASS(smb3_open_done_class,
 		__u32	tid,
 		__u64	sesid,
 		int	create_options,
-		int	desired_access),
-	TP_ARGS(xid, fid, tid, sesid, create_options, desired_access),
+		int	desired_access,
+		__u8	oplock),
+	TP_ARGS(xid, fid, tid, sesid, create_options, desired_access, oplock),
 	TP_STRUCT__entry(
 		__field(unsigned int, xid)
 		__field(__u64, fid)
@@ -1112,6 +1113,7 @@ DECLARE_EVENT_CLASS(smb3_open_done_class,
 		__field(__u64, sesid)
 		__field(int, create_options)
 		__field(int, desired_access)
+		__field(__u8, oplock)
 	),
 	TP_fast_assign(
 		__entry->xid = xid;
@@ -1120,10 +1122,11 @@ DECLARE_EVENT_CLASS(smb3_open_done_class,
 		__entry->sesid = sesid;
 		__entry->create_options = create_options;
 		__entry->desired_access = desired_access;
+		__entry->oplock = oplock;
 	),
-	TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx cr_opts=0x%x des_access=0x%x",
+	TP_printk("xid=%u sid=0x%llx tid=0x%x fid=0x%llx cr_opts=0x%x des_access=0x%x oplock=0x%x",
 		__entry->xid, __entry->sesid, __entry->tid, __entry->fid,
-		__entry->create_options, __entry->desired_access)
+		__entry->create_options, __entry->desired_access, __entry->oplock)
 )
 
 #define DEFINE_SMB3_OPEN_DONE_EVENT(name)        \
@@ -1133,8 +1136,9 @@ DEFINE_EVENT(smb3_open_done_class, smb3_##name,  \
 		__u32	tid,			\
 		__u64	sesid,			\
 		int	create_options,		\
-		int	desired_access),	\
-	TP_ARGS(xid, fid, tid, sesid, create_options, desired_access))
+		int	desired_access,		\
+		__u8	oplock),		\
+	TP_ARGS(xid, fid, tid, sesid, create_options, desired_access, oplock))
 
 DEFINE_SMB3_OPEN_DONE_EVENT(open_done);
 DEFINE_SMB3_OPEN_DONE_EVENT(posix_mkdir_done);
Signature · 1 line
2.53.0
author maintainer
#16 lore raw

PATCH 16/497 smb: client: close handle after create-context parsing failure

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Zihan Xi <[email protected]>

[ Upstream commit 566820af017e81497fb5e9d3ad6e7ffe2828bc8b ]

SMB2_open() accounts a successful CREATE response as a remote open before parsing its create contexts. If smb2_parse_contexts() rejects malformed context data, SMB2_open() returns without closing the handle, leaving the server-side handle open and num_remote_opens elevated.

Close the handle after a post-CREATE context parsing failure so the error path releases the remote resource and balances the open count.

Fixes af1689a9b770 ("smb: client: fix potential OOBs in smb2_parse_contexts()")
Assisted-by LLM
---
 fs/smb/client/smb2pdu.c | 3 +++
 1 file changed, 3 insertions(+)
fs/smb/client/smb2pdu.c +3 -0
index 31b427d5702e5..1dbf8d28bdf76 100644
@@ -3320,6 +3320,9 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
 
 	rc = smb2_parse_contexts(server, &rsp_iov, &oparms->fid->epoch,
 				 oparms->fid->lease_key, oplock, file_info, posix);
+	if (rc)
+		SMB2_close(xid, tcon, oparms->fid->persistent_fid,
+			   oparms->fid->volatile_fid);
 
 	trace_smb3_open_done(xid, rsp->PersistentFileId, tcon->tid, ses->Suid,
 			     oparms->create_options, oparms->desired_access,
Signature · 1 line
2.53.0
author maintainer
#17 lore raw

PATCH 17/497 Bluetooth: ISO: Fix data-race on iso_pi(sk) in socket and HCI event paths

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: SeungJu Cheon <[email protected]>

[ Upstream commit f958c7805b18e9d69f6b322b231ecee46ec6f331 ]

Several iso_pi(sk) fields (qos, qos_user_set, bc_sid, base, base_len, sync_handle, bc_num_bis) are written under lock_sock in iso_sock_setsockopt() and iso_sock_bind(), but read and written under hci_dev_lock only in two other paths:

- iso_connect_bis() / iso_connect_cis(), invoked from connect(2), read qos/base/bc_sid and reset qos to default_qos on the qos_user_set validation failure -- all without lock_sock.

- iso_connect_ind(), invoked from hci_rx_work, writes sync_handle, bc_sid, qos.bcast.encryption, bc_num_bis, base and base_len on PA_SYNC_ESTABLISHED / PAST_RECEIVED / BIG_INFO_ADV_REPORT / PER_ADV_REPORT events. The BIG_INFO handler additionally passes &iso_pi(sk)->qos together with sync_handle / bc_num_bis / bc_bis to hci_conn_big_create_sync() while setsockopt may be mutating them.

Acquire lock_sock around the affected accesses in both paths.

The locking order hci_dev_lock -> lock_sock matches the existing iso_conn_big_sync() precedent, whose comment documents the same requirement for hci_conn_big_create_sync(). The HCI connect/bind helpers do not wait for command completion -- they enqueue work via hci_cmd_sync_queue{,_once}() / hci_le_create_cis_pending() and return -- so the added hold time is comparable to iso_conn_big_sync().

KCSAN report:

BUG: KCSAN: data-race in iso_connect_cis / iso_sock_setsockopt

read to 0xffffa3ae8ce3cdc8 of 1 bytes by task 335 on cpu 0:

 iso_connect_cis+0x49f/0xa20
 iso_sock_connect+0x60e/0xb40
 __sys_connect_file+0xbd/0xe0
 __sys_connect+0xe0/0x110
 __x64_sys_connect+0x40/0x50
 x64_sys_call+0xcad/0x1c60
 do_syscall_64+0x133/0x590
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

write to 0xffffa3ae8ce3cdc8 of 60 bytes by task 334 on cpu 1:

 iso_sock_setsockopt+0x69a/0x930
 do_sock_setsockopt+0xc3/0x170
 __sys_setsockopt+0xd1/0x130
 __x64_sys_setsockopt+0x64/0x80
 x64_sys_call+0x1547/0x1c60
 do_syscall_64+0x133/0x590
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Reported by Kernel Concurrency Sanitizer on:

CPU: 1 UID: 0 PID: 334 Comm: iso_setup_race Not tainted 7.0.0-10949-g8541d8f725c6 #44 PREEMPT(lazy)

The iso_connect_ind() races were found by inspection.

Fixes ccf74f2390d6 ("Bluetooth: Add BTPROTO_ISO socket type")

Stable adaptation for 6.12:
- Omit the PAST_RECEIVED locking hunk: this tree has neither that event path nor iso_match_sid_past(). Keep locking for the existing connect, PA sync, BIG info, and periodic advertising paths.
- Fold in the connection lifetime prerequisites from aa9f7cb2bd3a2 and fdfde532ab1ca. Give each socket association its own iso_conn reference, balance temporary references at all iso_conn_add() callers, and detach hcon explicitly during teardown. Use kref_get() directly instead of adding the upstream iso_conn_hold() helper.

These prerequisites let 0fcd4dad555c96e0bd3a1b8c569f989be85c7341 apply unchanged with the reference ownership it expects. Its seven-line fix is intentionally left for the target commit.

Stable-dep-of: 0fcd4dad555c ("Bluetooth: ISO: release unused CIS holds after channel attach")

---
 net/bluetooth/iso.c | 96 +++++++++++++++++++++++++++------------------
 1 file changed, 58 insertions(+), 38 deletions(-)
net/bluetooth/iso.c +58 -38
index 3cf4ef291bf54..b3df3a5137fee 100644
@@ -106,9 +106,6 @@ static void iso_conn_free(struct kref *ref)
 
 	BT_DBG("conn %p", conn);
 
-	if (conn->sk)
-		iso_pi(conn->sk)->conn = NULL;
-
 	if (conn->hcon) {
 		conn->hcon->iso_data = NULL;
 		if (!test_and_set_bit(ISO_CONN_DROPPED, conn->flags))
@@ -208,7 +205,6 @@ static struct iso_conn *iso_conn_add(struct hci_conn *hcon)
 			conn->hcon = hcon;
 			iso_conn_unlock(conn);
 		}
-		iso_conn_put(conn);
 		return conn;
 	}
 
@@ -261,6 +257,7 @@ static void iso_chan_del(struct sock *sk, int err)
 }
 
 static void iso_conn_del(struct hci_conn *hcon, int err)
+	__must_hold(&hcon->hdev->lock)
 {
 	struct iso_conn *conn = hcon->iso_data;
 	struct sock *sk;
@@ -275,12 +272,9 @@ static void iso_conn_del(struct hci_conn *hcon, int err)
 	iso_conn_lock(conn);
 	sk = iso_sock_hold(conn);
 	iso_conn_unlock(conn);
-	iso_conn_put(conn);
 
-	if (!sk) {
-		iso_conn_put(conn);
-		return;
-	}
+	if (!sk)
+		goto done;
 
 	iso_sock_disable_timer(sk);
 
@@ -289,6 +283,15 @@ static void iso_conn_del(struct hci_conn *hcon, int err)
 	release_sock(sk);
 	iso_sock_kill(sk);
 	sock_put(sk);
+
+done:
+	/* No sk access to conn->hcon any more (lock_sock + hdev->lock) */
+	iso_conn_lock(conn);
+	conn->hcon = NULL;
+	hcon->iso_data = NULL;
+	iso_conn_unlock(conn);
+
+	iso_conn_put(conn);
 }
 
 static int __iso_chan_add(struct iso_conn *conn, struct sock *sk,
@@ -304,6 +307,12 @@ static int __iso_chan_add(struct iso_conn *conn, struct sock *sk,
 		return -EBUSY;
 	}
 
+	if (!conn->hcon) {
+		BT_ERR("conn->hcon missing");
+		return -EIO;
+	}
+
+	kref_get(&conn->ref);
 	iso_pi(sk)->conn = conn;
 	conn->sk = sk;
 	clear_bit(ISO_CONN_DROPPED, conn->flags);
@@ -357,6 +366,7 @@ static int iso_connect_bis(struct sock *sk)
 		return -EHOSTUNREACH;
 
 	hci_dev_lock(hdev);
+	lock_sock(sk);
 
 	if (!bis_capable(hdev)) {
 		err = -EOPNOTSUPP;
@@ -407,13 +417,10 @@ static int iso_connect_bis(struct sock *sk)
 		goto unlock;
 	}
 
-	lock_sock(sk);
-
 	err = iso_chan_add(conn, sk, NULL);
-	if (err) {
-		release_sock(sk);
+	iso_conn_put(conn);
+	if (err)
 		goto unlock;
-	}
 
 	/* Update source addr of the socket */
 	bacpy(&iso_pi(sk)->src, &hcon->src);
@@ -429,9 +436,8 @@ static int iso_connect_bis(struct sock *sk)
 		iso_sock_set_timer(sk, sk->sk_sndtimeo);
 	}
 
-	release_sock(sk);
-
 unlock:
+	release_sock(sk);
 	hci_dev_unlock(hdev);
 	hci_dev_put(hdev);
 	return err;
@@ -459,6 +465,7 @@ static int iso_connect_cis(struct sock *sk)
 		return -EHOSTUNREACH;
 
 	hci_dev_lock(hdev);
+	lock_sock(sk);
 
 	if (!cis_central_capable(hdev)) {
 		err = -EOPNOTSUPP;
@@ -504,13 +511,10 @@ static int iso_connect_cis(struct sock *sk)
 		goto unlock;
 	}
 
-	lock_sock(sk);
-
 	err = iso_chan_add(conn, sk, NULL);
-	if (err) {
-		release_sock(sk);
+	iso_conn_put(conn);
+	if (err)
 		goto unlock;
-	}
 
 	/* Update source addr of the socket */
 	bacpy(&iso_pi(sk)->src, &hcon->src);
@@ -526,9 +530,8 @@ static int iso_connect_cis(struct sock *sk)
 		iso_sock_set_timer(sk, sk->sk_sndtimeo);
 	}
 
-	release_sock(sk);
-
 unlock:
+	release_sock(sk);
 	hci_dev_unlock(hdev);
 	hci_dev_put(hdev);
 	return err;
@@ -1211,10 +1214,9 @@ static int iso_listen_bis(struct sock *sk)
 	}
 
 	err = iso_chan_add(conn, sk, NULL);
-	if (err) {
-		hci_conn_drop(hcon);
+	iso_conn_put(conn);
+	if (err)
 		goto unlock;
-	}
 
 unlock:
 	release_sock(sk);
@@ -2164,8 +2166,10 @@ int iso_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags)
 		sk = iso_get_sock(&hdev->bdaddr, bdaddr, BT_LISTEN,
 				  iso_match_sid, ev1);
 		if (sk && !ev1->status) {
+			lock_sock(sk);
 			iso_pi(sk)->sync_handle = le16_to_cpu(ev1->handle);
 			iso_pi(sk)->bc_sid = ev1->sid;
+			release_sock(sk);
 		}
 
 		goto done;
@@ -2192,27 +2196,35 @@ int iso_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags)
 					  ev2);
 
 		if (sk) {
-			int err;
-			struct hci_conn	*hcon = iso_pi(sk)->conn->hcon;
+			int err = 0;
+			bool big_sync;
+			struct hci_conn *hcon;
+
+			lock_sock(sk);
 
+			hcon = iso_pi(sk)->conn->hcon;
 			iso_pi(sk)->qos.bcast.encryption = ev2->encryption;
 
 			if (ev2->num_bis < iso_pi(sk)->bc_num_bis)
 				iso_pi(sk)->bc_num_bis = ev2->num_bis;
 
-			if (!test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags) &&
-			    !test_and_set_bit(BT_SK_BIG_SYNC, &iso_pi(sk)->flags)) {
+			big_sync = !test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags) &&
+				   !test_and_set_bit(BT_SK_BIG_SYNC, &iso_pi(sk)->flags);
+
+			if (big_sync)
 				err = hci_conn_big_create_sync(hdev, hcon,
 							       &iso_pi(sk)->qos,
 							       iso_pi(sk)->sync_handle,
 							       iso_pi(sk)->bc_num_bis,
 							       iso_pi(sk)->bc_bis);
-				if (err) {
-					bt_dev_err(hdev, "hci_le_big_create_sync: %d",
-						   err);
-					sock_put(sk);
-					sk = NULL;
-				}
+
+			release_sock(sk);
+
+			if (big_sync && err) {
+				bt_dev_err(hdev, "hci_le_big_create_sync: %d",
+					   err);
+				sock_put(sk);
+				sk = NULL;
 			}
 		}
 
@@ -2266,8 +2278,10 @@ int iso_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags)
 			if (!base || base_len > BASE_MAX_LENGTH)
 				goto done;
 
+			lock_sock(sk);
 			memcpy(iso_pi(sk)->base, base, base_len);
 			iso_pi(sk)->base_len = base_len;
+			release_sock(sk);
 		} else {
 			/* This is a PA data fragment. Keep pa_data_len set to 0
 			 * until all data has been reassembled.
@@ -2292,6 +2306,7 @@ int iso_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags)
 }
 
 static void iso_connect_cfm(struct hci_conn *hcon, __u8 status)
+	__must_hold(&hcon->hdev->lock)
 {
 	if (hcon->type != CIS_LINK && hcon->type != BIS_LINK &&
 	    hcon->type != PA_LINK) {
@@ -2303,8 +2318,10 @@ static void iso_connect_cfm(struct hci_conn *hcon, __u8 status)
 			struct hci_link *link, *t;
 
 			list_for_each_entry_safe(link, t, &hcon->link_list,
-						 list)
+						 list) {
+				lockdep_assert_held(&link->conn->hdev->lock);
 				iso_conn_del(link->conn, bt_to_errno(status));
+			}
 
 			return;
 		}
@@ -2326,14 +2343,17 @@ static void iso_connect_cfm(struct hci_conn *hcon, __u8 status)
 		struct iso_conn *conn;
 
 		conn = iso_conn_add(hcon);
-		if (conn)
+		if (conn) {
 			iso_conn_ready(conn);
+			iso_conn_put(conn);
+		}
 	} else {
 		iso_conn_del(hcon, bt_to_errno(status));
 	}
 }
 
 static void iso_disconn_cfm(struct hci_conn *hcon, __u8 reason)
+	__must_hold(&hcon->hdev->lock)
 {
 	if (hcon->type != CIS_LINK && hcon->type !=  BIS_LINK &&
 	    hcon->type != PA_LINK)
Signature · 1 line
2.53.0
author maintainer
#18 lore raw

PATCH 18/497 Bluetooth: ISO: release unused CIS holds after channel attach

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Aldo Ariel Panzardo <[email protected]>

[ Upstream commit 0fcd4dad555c96e0bd3a1b8c569f989be85c7341 ]

hci_bind_cis() and hci_connect_cis() return one hci_conn hold for the ISO layer. A new channel association consumes that hold, which is eventually released by iso_conn_free().

There are two cases where iso_chan_add() does not create an association:
it returns success when the socket is already attached to the same iso_conn, and it returns -EBUSY when another socket is attached. The hold returned for the current call is unused in both cases. This occurs when deferred setup calls iso_connect_cis() again for its existing socket, or when another socket attempts to reuse the CIS.

Detect the idempotent case while the connection is locked and release the unused hold after iso_chan_add(). Also release it on -EBUSY. Do not drop it for other errors: a newly allocated iso_conn releases the transferred hold when its last temporary reference is put.

Fixes 69997d50ec57 ("Bluetooth: ISO: handle bound CIS cleanup via hci_conn")
---
 net/bluetooth/iso.c | 7 +++++++
 1 file changed, 7 insertions(+)
net/bluetooth/iso.c +7 -0
index b3df3a5137fee..fc9b9c11ab4c5 100644
@@ -450,6 +450,7 @@ static int iso_connect_cis(struct sock *sk)
 	struct hci_dev  *hdev;
 	bdaddr_t src, dst;
 	u8 src_type;
+	bool already_attached;
 	int err;
 
 	lock_sock(sk);
@@ -511,8 +512,14 @@ static int iso_connect_cis(struct sock *sk)
 		goto unlock;
 	}
 
+	iso_conn_lock(conn);
+	already_attached = iso_pi(sk)->conn == conn && conn->sk == sk;
+	iso_conn_unlock(conn);
+
 	err = iso_chan_add(conn, sk, NULL);
 	iso_conn_put(conn);
+	if (already_attached || err == -EBUSY)
+		hci_conn_drop(hcon);
 	if (err)
 		goto unlock;
 
Signature · 1 line
2.53.0
author maintainer
#19 lore raw

PATCH 19/497 smb: client: close completed creates on compound wait errors

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Zihan Xi <[email protected]>

[ Upstream commit 6c5c547f037bc18f0b8d0b5db5a648f8f630ce85 ]

compound_send_recv() waits for responses in order. If a later wait is interrupted, or if a later MID fails during response synchronization, an earlier CREATE may already have opened a remote handle. The earlier mid is then released without invoking handle_cancelled_mid(), leaving the remote handle open because no FID was copied to the caller.

Mark completed earlier mids as cancelled when a compound wait or MID synchronization aborts. Keep their response buffers attached while the MIDs are synchronized, and transfer them only after synchronization of the processed responses, so the release path can inspect successful CREATE responses and queue SMB2_close() after a later failure. Account for a remote open only after the close work is allocated and before it is queued, since the caller has not yet updated num_remote_opens. Mark the create+close compound used by smb2_unlink() so it is not closed again. Non-CREATE responses and compounds that already include a close keep their existing behavior.

Fixes e0bba0b85481 ("cifs: add compound_send_recv()")
Assisted-by LLM
[ replaced the upstream cancellation helper with inline loops using midQ and MID_WAIT_CANCELLED under server->mid_lock. ]
---
 fs/smb/client/smb2misc.c  |  9 +++--
 fs/smb/client/transport.c | 69 ++++++++++++++++++++++++++++++---------
 2 files changed, 59 insertions(+), 19 deletions(-)
fs/smb/client/smb2misc.c +6 -3
index f4a38b0ce8402..23320b794b177 100644
@@ -818,7 +818,8 @@ smb2_cancelled_close_fid(struct work_struct *work)
  */
 static int
 __smb2_handle_cancelled_cmd(struct cifs_tcon *tcon, __u16 cmd, __u64 mid,
-			    __u64 persistent_fid, __u64 volatile_fid)
+			    __u64 persistent_fid, __u64 volatile_fid,
+			    bool account_remote_open)
 {
 	struct close_cancelled_open *cancelled;
 
@@ -832,6 +833,8 @@ __smb2_handle_cancelled_cmd(struct cifs_tcon *tcon, __u16 cmd, __u64 mid,
 	cancelled->cmd = cmd;
 	cancelled->mid = mid;
 	INIT_WORK(&cancelled->work, smb2_cancelled_close_fid);
+	if (account_remote_open)
+		atomic_inc(&tcon->num_remote_opens);
 	WARN_ON(queue_work(cifsiod_wq, &cancelled->work) == false);
 
 	return 0;
@@ -868,7 +871,7 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,
 	spin_unlock(&tcon->tc_lock);
 
 	rc = __smb2_handle_cancelled_cmd(tcon, SMB2_CLOSE_HE, 0,
-					 persistent_fid, volatile_fid);
+					 persistent_fid, volatile_fid, false);
 	if (rc)
 		cifs_put_tcon(tcon, netfs_trace_tcon_ref_put_cancelled_close);
 
@@ -896,7 +899,7 @@ smb2_handle_cancelled_mid(struct mid_q_entry *mid, struct TCP_Server_Info *serve
 					 le16_to_cpu(hdr->Command),
 					 le64_to_cpu(hdr->MessageId),
 					 rsp->PersistentFileId,
-					 rsp->VolatileFileId);
+					 rsp->VolatileFileId, true);
 	if (rc)
 		cifs_put_tcon(tcon, netfs_trace_tcon_ref_put_cancelled_mid);
 
fs/smb/client/transport.c +53 -16

113 lines not on this page · raw message

Signature · 1 line
2.53.0
author maintainer
#20 lore raw

PATCH 20/497 xfs: fix cursor and pointer handling when recovering iunlink buckets

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Darrick J. Wong <[email protected]>

[ Upstream commit 65f39d09d73718611cee40399179323b5d4ead00 ]

LOLLM pointed out a bug in xlog_recover_iunlink_bucket:

1. We don't null out prev_ip after releasing it, which can lead to UAF problems if the inodegc flush call in the loop fails.

at which point I noticed even more bugs:

2. If the inodegc flush inside the loop fails, we also leak @ip.

3. We set prev_agino to agino having already advanced agino, which results in inodes with i_prev_unlinked set to itself.

4. If we exit the bottom of the loop with prev_ip set, then prev_ip aliases ip and we also set its i_prev_unlinked to itself.

Bugs 3 and 4 introduce loops into the unlinked list, though these loops don't surface because we immediately flush each unlinked inode after loading it.

Fix all of these issues.

Fixes 04755d2e5821b3 ("xfs: refactor xlog_recover_process_iunlinks()")
Assisted-by LOLLM # finding obvious bugs
[ Replaced unavailable xfs_agino_to_ino() with the existing XFS_AGINO_TO_INO() macro. ]
---
 fs/xfs/xfs_log_recover.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
fs/xfs/xfs_log_recover.c +8 -5
index 4884bbf5df80e..05bef0b44693c 100644
@@ -2730,12 +2730,13 @@ xlog_recover_iunlink_bucket(
 {
 	struct xfs_mount	*mp = pag->pag_mount;
 	struct xfs_inode	*prev_ip = NULL;
-	struct xfs_inode	*ip;
 	xfs_agino_t		prev_agino, agino;
 	int			error = 0;
 
 	agino = be32_to_cpu(agi->agi_unlinked[bucket]);
 	while (agino != NULLAGINO) {
+		struct xfs_inode	*ip;
+
 		error = xfs_iget(mp, NULL,
 				XFS_AGINO_TO_INO(mp, pag->pag_agno, agino),
 				0, 0, &ip);
@@ -2745,11 +2746,11 @@ xlog_recover_iunlink_bucket(
 		ASSERT(VFS_I(ip)->i_nlink == 0);
 		ASSERT(VFS_I(ip)->i_mode != 0);
 		xfs_iflags_clear(ip, XFS_IRECOVERY);
-		agino = ip->i_next_unlinked;
 
 		if (prev_ip) {
 			ip->i_prev_unlinked = prev_agino;
 			xfs_irele(prev_ip);
+			prev_ip = NULL;
 
 			/*
 			 * Ensure the inode is removed from the unlinked list
@@ -2761,18 +2762,20 @@ xlog_recover_iunlink_bucket(
 			 * complete.
 			 */
 			error = xfs_inodegc_flush(mp);
-			if (error)
-				break;
+			if (error) {
+				xfs_irele(ip);
+				return error;
+			}
 		}
 
 		prev_agino = agino;
+		agino = ip->i_next_unlinked;
 		prev_ip = ip;
 	}
 
 	if (prev_ip) {
 		int	error2;
 
-		ip->i_prev_unlinked = prev_agino;
 		xfs_irele(prev_ip);
 
 		error2 = xfs_inodegc_flush(mp);
Signature · 1 line
2.53.0
author maintainer
#21 lore raw

PATCH 21/497 neighbour: Skip default parms when resumed in neightbl_dump_info().

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Kuniyuki Iwashima <[email protected]>

[ Upstream commit 979aabdad8dd03394467ee484a1a70f3d40b19ba ]

neightbl_dump_info() calls neightbl_fill_info() in each loop to render the default parms.

If there are many devices and neightbl_fill_param_info() failed, neightbl_fill_info() is called again when the dump resumes:

  # ynl --family rt-neigh --dump getneightbl --output-json |
    jq '.[] | {name: .name, ifindex: .parms.ifindex}'
  ...
  {
    "name": "ndisc_cache",
    "ifindex": null
  }
  ...
  {
    "name": "ndisc_cache",
    "ifindex": 6
  }
  {
    "name": "ndisc_cache",
    "ifindex": null
  }
  {
    "name": "ndisc_cache",
    "ifindex": 5
  }

Let's skip neightbl_fill_info() if it is already called in neightbl_dump_info().

Note that we cannot use !neigh_skip instead of !default_skip because default_skip == 1 && neigh_skip == 0 could be true if the first neightbl_fill_param_info() fails.

Also, nidx must be cleared at the end of each table loop; otherwise, if neightbl_fill_info() for a subsequent table fails, the leftover nidx from the previous table would be saved in cb->args[1], resulting in erroneously skipping parms of the subsequent table in the next dump.

Fixes c7fb64db001f ("[NETLINK]: Neighbour table configuration and statistics via rtnetlink")
---
 net/core/neighbour.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
net/core/neighbour.c +9 -3
index bf07438d6dfa5..172974574f18f 100644
@@ -2517,9 +2517,10 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
 {
 	const struct nlmsghdr *nlh = cb->nlh;
 	struct net *net = sock_net(skb->sk);
+	int default_skip = cb->args[2];
+	int neigh_skip = cb->args[1];
 	int family, tidx, nidx = 0;
 	int tbl_skip = cb->args[0];
-	int neigh_skip = cb->args[1];
 	struct neigh_table *tbl;
 
 	if (cb->strict_check) {
@@ -2541,12 +2542,14 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
 		if (tidx < tbl_skip || (family && tbl->family != family))
 			continue;
 
-		if (neightbl_fill_info(skb, tbl, NETLINK_CB(cb->skb).portid,
+		if (!default_skip &&
+		    neightbl_fill_info(skb, tbl, NETLINK_CB(cb->skb).portid,
 				       nlh->nlmsg_seq, RTM_NEWNEIGHTBL,
 				       NLM_F_MULTI) < 0)
 			break;
 
-		nidx = 0;
+		default_skip = 1;
+
 		p = list_next_entry(&tbl->parms, list);
 		list_for_each_entry_from(p, &tbl->parms_list, list) {
 			if (!net_eq(neigh_parms_net(p), net))
@@ -2566,10 +2569,13 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
 		}
 
 		neigh_skip = 0;
+		nidx = 0;
+		default_skip = 0;
 	}
 out:
 	cb->args[0] = tidx;
 	cb->args[1] = nidx;
+	cb->args[2] = default_skip;
 
 	return skb->len;
 }
Signature · 1 line
2.53.0
author maintainer
#22 lore raw

PATCH 22/497 ALSA: usb-audio: Apply IGNORE_CTL_ERROR quirk to all Audient devices

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Takashi Iwai <[email protected]>

[ Upstream commit a154f7b9f197b3d5e41fa3ad62083f5aa93b1fe8 ]

Faaris reported a problem with Audient EVO4 device and it turned out to be a regression by the recent fix commit 87a6f2fa6e6c ("ALSA:
usb-audio: Propagate write errors in generic mixer put callbacks"). It exhibited that the hardware gives errors at accessing the mixer unit 10 on certain channels, and the change above made it a fatal error.

We had already a quirk for Audient iD14 to work around such errors from the mixer controls, and we can simply apply the same for EVO4. OTOH, it's highly possible that other Audient devices suffer from the same issue; they must be using similar firmware, after all.

So, in this patch, we apply the quirk generically to all devices with the vendor ID Audient (2708), instead. Ignoring the control error isn't usually less critical than overreaction to the firmware misbehavior.

---
 sound/usb/quirks.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/usb/quirks.c +2 -2
index 0872432b8574b..cc8d755256f2e 100644
@@ -2371,8 +2371,6 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = {
 		   QUIRK_FLAG_SET_IFACE_FIRST),
 	DEVICE_FLG(0x262a, 0x9302, /* ddHiFi TC44C */
 		   QUIRK_FLAG_DSD_RAW),
-	DEVICE_FLG(0x2708, 0x0002, /* Audient iD14 */
-		   QUIRK_FLAG_IGNORE_CTL_ERROR),
 	DEVICE_FLG(0x2772, 0x0502, /* Musical Fidelity M6s DAC */
 		   0), /* for avoiding QUIRK_FLAG_DSD_RAW with vendor match */
 	DEVICE_FLG(0x2912, 0x30c8, /* Audioengine D1 */
@@ -2440,6 +2438,8 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = {
 		   QUIRK_FLAG_DSD_RAW),
 	VENDOR_FLG(0x2622, /* IAG Limited devices */
 		   QUIRK_FLAG_DSD_RAW),
+	VENDOR_FLG(0x2708, /* Audient devices */
+		   QUIRK_FLAG_IGNORE_CTL_ERROR),
 	VENDOR_FLG(0x2772, /* Musical Fidelity devices */
 		   QUIRK_FLAG_DSD_RAW),
 	VENDOR_FLG(0x278b, /* Rotel? */
Signature · 1 line
2.53.0
author maintainer
#23 lore raw

PATCH 23/497 audit: fix exe mark UAF in kill_rules()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jérémy Jean <[email protected]>

commit aa650d87a498844060eecb1d336f4d46f4d1b0b3 upstream.

kill_rules() removes mixed AUDIT_DIR and AUDIT_EXE rules when an audit tree is pruned. It drops entry->rule.exe before removing the rule from the RCU-visible filter lists.

After a rule has been installed with AUDIT_ADD_RULE, which requires CAP_AUDIT_CONTROL, removing the watched directory can race with another task that is still evaluating the rule. In that case, fsnotify can free the executable mark before the reader reaches audit_mark_compare(), causing a use-after-free.

KASAN reports:

    BUG: KASAN: slab-use-after-free in audit_mark_compare+0x8d/0xa0

Unlink the published rules from the RCU-visible lists and retain them on tree->rules for cleanup. If any rule has an executable mark, wait for a single RCU grace period before removing the marks and scheduling the entries for freeing. Otherwise, call_rcu() already provides the required deferred freeing without a synchronous wait.

Fixes 34d99af52ad4 ("audit: implement audit by executable")
Assisted-by Codex:gpt-5
---
 kernel/audit_tree.c |   24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)
kernel/audit_tree.c +20 -4
@@ -543,22 +543,38 @@ static void kill_rules(struct audit_cont
 {
 	struct audit_krule *rule, *next;
 	struct audit_entry *entry;
+	bool need_sync = false;
 
 	list_for_each_entry_safe(rule, next, &tree->rules, rlist) {
 		entry = container_of(rule, struct audit_entry, rule);
 
-		list_del_init(&rule->rlist);
 		if (rule->tree) {
 			/* not a half-baked one */
 			audit_tree_log_remove_rule(context, rule);
-			if (entry->rule.exe)
-				audit_remove_mark(entry->rule.exe);
 			rule->tree = NULL;
 			list_del_rcu(&entry->list);
 			list_del(&entry->rule.list);
-			call_rcu(&entry->rcu, audit_free_rule_rcu);
+			if (entry->rule.exe)
+				need_sync = true;
+		} else {
+			list_del_init(&rule->rlist);
 		}
 	}
+
+	if (list_empty(&tree->rules))
+		return;
+
+	if (need_sync)
+		synchronize_rcu();
+
+	list_for_each_entry_safe(rule, next, &tree->rules, rlist) {
+		entry = container_of(rule, struct audit_entry, rule);
+
+		list_del_init(&rule->rlist);
+		if (entry->rule.exe)
+			audit_remove_mark(entry->rule.exe);
+		call_rcu(&entry->rcu, audit_free_rule_rcu);
+	}
 }
 
 /*
author maintainer
#24 lore raw

PATCH 24/497 HID: bpf: cast size to ssize_t when checking hid_bpf_hw_request

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Benjamin Tissoires <[email protected]>

commit 3afefbfe55c2a8a0c4bdf6f4cc1f773da120027c upstream.

As reported by Sashiko:
If a transport driver encounters a hardware error and returns a negative error code such as -EPIPE, ret is implicitly promoted to size_t when compared against size. This causes the negative error code to evaluate as a large positive number, making the (ret > size) condition true.

This silently converts the hardware error into a success return value and copies the unmodified buffer back, which could leave BPF programs operating on uninitialized or stale data.

Fix this by casting size into ssize_t to return the actual negative error code.

---
 drivers/hid/bpf/hid_bpf_dispatch.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/bpf/hid_bpf_dispatch.c +1 -1
@@ -459,7 +459,7 @@ hid_bpf_hw_request(struct hid_bpf_ctx *c
 					      (u64)(long)ctx,
 					      true); /* prevent infinite recursions */
 
-	if (ret > size)
+	if (ret > (ssize_t)size)
 		ret = size;
 	if (ret > 0)
 		memcpy(buf, dma_data, ret);
author maintainer
#25 lore raw

PATCH 25/497 kprobes: Skip disarmed probes when checking optkprobe overlap

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Leon Hwang <[email protected]>

commit 7a39c732a22ec4a369af9e19fbe3d666ec83eec4 upstream.

On x86, an optkprobe at A replaces five bytes with a jump. If a disabled probe B is at A+2, get_optimized_kprobe() stops at B when arming a new probe C at A+4. It leaves A optimized:

              A    A+1  A+2  A+3  A+4
  A's jump  | e9 | d0 | d1 | d2 | d3 |
  after C   | e9 | d0 | d1 | d2 | cc |

The INT3 for C overwrites the last byte of A's jump displacement, so execution can jump to the wrong address. B can have prepared optinsns while disarmed, but has no jump to unoptimize.

Continue past disarmed and unprepared probes to find the active optimized probe before arming a probe in its jump.

Fixes afd66255b9a4 ("kprobes: Introduce kprobes jump optimization")
---
 kernel/kprobes.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
kernel/kprobes.c +5 -3
@@ -491,14 +491,16 @@ static bool kprobe_queued(struct kprobe
 static struct kprobe *get_optimized_kprobe(kprobe_opcode_t *addr)
 {
 	int i;
-	struct kprobe *p = NULL;
+	struct kprobe *p;
 	struct optimized_kprobe *op;
 
 	/* Don't check i == 0, since that is a breakpoint case. */
-	for (i = 1; !p && i < MAX_OPTIMIZED_LENGTH / sizeof(kprobe_opcode_t); i++)
+	for (i = 1; i < MAX_OPTIMIZED_LENGTH / sizeof(kprobe_opcode_t); i++) {
 		p = get_kprobe(addr - i);
+		/* A disabled probe can have prepared, but inactive, optinsns. */
+		if (!p || !kprobe_optready(p) || kprobe_disarmed(p))
+			continue;
 
-	if (p && kprobe_optready(p)) {
 		op = container_of(p, struct optimized_kprobe, kp);
 		if (arch_within_optimized_kprobe(op, addr))
 			return p;
author maintainer
#26 lore raw

PATCH 26/497 of/irq: Fix remaining refcount leaks in of_irq_init()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Wentao Liang <[email protected]>

commit 30724547b221e0e670ddfef140fc7d816b2aaec6 upstream.

Successfully initialized controllers are moved to intc_parent_list, but the final cleanup only frees the descriptors. The device node references taken with of_node_get() and the interrupt parent references are therefore leaked on the normal return path. Drop both before kfree(), as the intc_desc_list cleanup already does.

---
 drivers/of/irq.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/of/irq.c +2 -0
@@ -659,6 +659,8 @@ void __init of_irq_init(const struct of_
 
 	list_for_each_entry_safe(desc, temp_desc, &intc_parent_list, list) {
 		list_del(&desc->list);
+		of_node_put(desc->interrupt_parent);
+		of_node_put(desc->dev);
 		kfree(desc);
 	}
 err:
author maintainer
#27 lore raw

PATCH 27/497 of/overlay: put property on deadprops only after changeset add succeeds

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Abdurrahman Hussain <[email protected]>

commit 814f2da6995772c07a7c9c2cc6028b6e3f3ecc9c upstream.

add_changeset_property() links a new property of a not-yet-live target node into the node's deadprops list before handing it to of_changeset_add_property(). If that fails, the error path frees the property but leaves the freed pointer linked in deadprops, and of_node_release() frees it a second time when the aborted overlay's node is released.

Record the changeset entry first and link the property into deadprops only on success. of_changeset_add_property() never looks at the node's property lists, so the order of the two steps is otherwise immaterial, and the error path frees a property that nothing references.

Fixes f96278810150 ("of: overlay: set node fields from properties when add new overlay node")
Assisted-by Claude:claude-fable-5 [Claude Code]
---
 drivers/of/overlay.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/of/overlay.c +4 -3
@@ -353,12 +353,13 @@ static int add_changeset_property(struct
 		return -ENOMEM;
 
 	if (!prop) {
-		if (!target->in_livetree) {
+		ret = of_changeset_add_property(&ovcs->cset, target->np,
+						new_prop);
+		/* the detached node owns the property until the apply */
+		if (!ret && !target->in_livetree) {
 			new_prop->next = target->np->deadprops;
 			target->np->deadprops = new_prop;
 		}
-		ret = of_changeset_add_property(&ovcs->cset, target->np,
-						new_prop);
 	} else {
 		ret = of_changeset_update_property(&ovcs->cset, target->np,
 						   new_prop);
author maintainer
#28 lore raw

PATCH 28/497 of/overlay: only treat a positive changeset id as registered

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Abdurrahman Hussain <[email protected]>

commit 44081d708b5b885487bac792db78324b7b4c267d upstream.

of_overlay_fdt_apply() stores the idr_alloc() return value in ovcs->id before checking it. On failure the stored id is negative, free_overlay_changeset()'s "if (ovcs->id)" check passes, idr_remove() is called with a negative id and list_del() runs on ovcs->ovcs_list, which is not initialized until after the id allocation. An allocation failure at that point dereferences NULL.

Make free_overlay_changeset() treat only a strict-positive id as registered. The rest of the function already copes with a partially-initialized ovcs, so the error path stays a plain goto err_free_ovcs.

Fixes 61b4de4e0b38 ("of: overlay: minor restructuring")
Assisted-by Claude:claude-fable-5 [Claude Code]
---
 drivers/of/overlay.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/of/overlay.c +2 -1
@@ -859,7 +859,8 @@ static void free_overlay_changeset(struc
 	if (ovcs->cset.entries.next)
 		of_changeset_destroy(&ovcs->cset);
 
-	if (ovcs->id) {
+	/* a failed idr_alloc() leaves its negative error in ovcs->id */
+	if (ovcs->id > 0) {
 		idr_remove(&ovcs_idr, ovcs->id);
 		list_del(&ovcs->ovcs_list);
 		ovcs->id = 0;
author maintainer
#29 lore raw

PATCH 29/497 net: fix checksum offsets in skb_splice_from_iter()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Alireza Asgari <[email protected]>

commit febec6a7076499d16b37f556724a942633a270a6 upstream.

skb_splice_from_iter() appends multiple page fragments before updating skb->len. However, skb_splice_csum_page() uses that unchanged length as the offset for every fragment checksum. If bytes already appended during the call have an odd total length, a later fragment's checksum is combined with the wrong parity.

For example, prime a UDP socket with sendto(MSG_MORE) and splice two distinct pipe buffers containing "abc" and "DEFGH". Uncorking reports success, but the receiver discards the packet for a bad checksum. This also affects IPv6 and fragments beginning near a page boundary.

Pass the initial skb length plus the bytes already spliced to the checksum helper. Keep the existing final length update and partial-progress error handling unchanged. CHECKSUM_PARTIAL does not use this helper and remains unaffected.

Fixes 2e910b95329c ("net: Add a function to splice pages into an skbuff for MSG_SPLICE_PAGES")
---
 net/core/skbuff.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
net/core/skbuff.c +5 -3
@@ -7258,7 +7258,8 @@ nodefer:	kfree_skb_napi_cache(skb);
 }
 
 static void skb_splice_csum_page(struct sk_buff *skb, struct page *page,
-				 size_t offset, size_t len)
+				 size_t offset, size_t len,
+				 unsigned int csum_offset)
 {
 	const char *kaddr;
 	__wsum csum;
@@ -7266,7 +7267,7 @@ static void skb_splice_csum_page(struct
 	kaddr = kmap_local_page(page);
 	csum = csum_partial(kaddr + offset, len, 0);
 	kunmap_local(kaddr);
-	skb->csum = csum_block_add(skb->csum, csum, skb->len);
+	skb->csum = csum_block_add(skb->csum, csum, csum_offset);
 }
 
 /**
@@ -7327,7 +7328,8 @@ ssize_t skb_splice_from_iter(struct sk_b
 			}
 
 			if (skb->ip_summed == CHECKSUM_NONE)
-				skb_splice_csum_page(skb, page, off, part);
+				skb_splice_csum_page(skb, page, off, part,
+						     skb->len + spliced);
 
 			off = 0;
 			spliced += part;
author maintainer
#30 lore raw

PATCH 30/497 netfilter: nft_flow_offload: drop flowtable reference on init error path

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Aohan Mei <[email protected]>

commit 747928b5d4ff8c8de55138a54c13980e4bb88578 upstream.

nft_flow_offload_init() bumps the flowtable use count with nft_use_inc() before calling nf_ct_netns_get(). When the latter fails, the error is returned as-is and the reference is leaked.

The upper layers do not balance it either: nf_tables_newexpr() clears expr->ops when the expression init callback fails, so the nft_expr_more() iteration in nft_rule_expr_deactivate() and nf_tables_rule_destroy() stops right before the failed expression and its ->destroy callback, which would drop the reference, never runs.

Each failed rule addition therefore leaks one flowtable reference and the flowtable can no longer be removed: NFT_MSG_DELFLOWTABLE keeps reporting -EBUSY even though no rule references it.

Save the nf_ct_netns_get() return value and undo the nft_use_inc() when it fails, restoring the inc/dec pairing within nft_flow_offload_init() itself.

Fixes a3c90f7a2323 ("netfilter: nf_tables: flow offload expression")
Assisted-by CodeBuddy:Kimi-K3
---
 net/netfilter/nft_flow_offload.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
net/netfilter/nft_flow_offload.c +6 -1
@@ -418,6 +418,7 @@ static int nft_flow_offload_init(const s
 	struct nft_flow_offload *priv = nft_expr_priv(expr);
 	u8 genmask = nft_genmask_next(ctx->net);
 	struct nft_flowtable *flowtable;
+	int err;
 
 	if (!tb[NFTA_FLOW_TABLE_NAME])
 		return -EINVAL;
@@ -432,7 +433,11 @@ static int nft_flow_offload_init(const s
 
 	priv->flowtable = flowtable;
 
-	return nf_ct_netns_get(ctx->net, ctx->family);
+	err = nf_ct_netns_get(ctx->net, ctx->family);
+	if (err < 0)
+		nft_use_dec(&flowtable->use);
+
+	return err;
 }
 
 static void nft_flow_offload_deactivate(const struct nft_ctx *ctx,
author maintainer
#31 lore raw

PATCH 31/497 net/packet: prevent TX_RING byte count overflow

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Ilkka Lappeteläinen <[email protected]>

commit 2cf81fc9505b148b1b70068303ea6ea4b1212403 upstream.

tpacket_snd() drains every SEND_REQUEST frame in a TX ring and adds each valid packet length to the signed int len_sum. Userspace can recycle completed frames concurrently, so a single blocking send call is not bounded by the ring size.

After enough successful transmissions len_sum wraps into the negative range. In particular, 65536 65535-byte frames followed by a 65007-byte frame produce 0xfffffdef, or -EIOCBQUEUED. sock_sendmsg_nosec() treats that as an impossible return and triggers a BUG. On systems configured to panic on oops, a CAP_NET_RAW holder can panic the host kernel.

Stop before the next frame would make the byte count exceed INT_MAX. The positive short count leaves that frame pending for a later send call.

A two-thread TPACKET_V2 reproducer triggered the BUG on an arm64 build of Linux 7.3-rc4. With this change, the same reproducer returned the expected positive short count without an oops.

---
 net/packet/af_packet.c |    3 +++
 1 file changed, 3 insertions(+)
net/packet/af_packet.c +3 -0
@@ -2926,6 +2926,9 @@ static int tpacket_snd(struct packet_soc
 						    vnet_hdr.hdr_len);
 			has_vnet_hdr = true;
 		}
+		/* Prevent the byte count from wrapping into a negative errno */
+		if (unlikely(tp_len > INT_MAX - len_sum))
+			break;
 		copylen = max_t(int, copylen, hard_header_len);
 		skb = sock_alloc_send_skb(&po->sk,
 				hlen + tlen + sizeof(struct sockaddr_ll) +
author maintainer
#32 lore raw

PATCH 32/497 rtc: ac100: Assign .num before accessing .hws

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Aamir Ahmed <[email protected]>

commit 6a4117eee82dd85f11bf898bf66026764011eeb6 upstream.

Commit f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by") annotated the hws member of 'struct clk_hw_onecell_data' with __counted_by, which informs the bounds sanitizer (UBSAN_BOUNDS) about the number of elements in .hws[], so that it can warn when .hws[] is accessed out of bounds. As noted in that change, the __counted_by member must be initialized with the number of elements before the first array access happens, otherwise there will be a warning from each access prior to the initialization because the number of elements is zero. This occurs in ac100_rtc_register_clks() due to .num being assigned only after every clkout clock has been stored in .hws[]. With CONFIG_UBSAN_BOUNDS and a compiler that implements __counted_by (GCC 15.1+ or Clang 20.1+), this triggers an array-index-out-of-bounds report during probe, and with CONFIG_UBSAN_TRAP the first store traps.

Initialize .num with AC100_CLKOUT_NUM, the number of elements .hws[] was allocated with, right after the allocation. That is the value the loop counter ends up at on the success path anyway, so the provider's behaviour is unchanged.

---
 drivers/rtc/rtc-ac100.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/rtc/rtc-ac100.c +2 -1
@@ -316,6 +316,8 @@ static int ac100_rtc_register_clks(struc
 	if (!chip->clk_data)
 		return -ENOMEM;
 
+	chip->clk_data->num = AC100_CLKOUT_NUM;
+
 	chip->rtc_32k_clk = clk_hw_register_fixed_rate(chip->dev,
 						       AC100_RTC_32K_NAME,
 						       NULL, 0,
@@ -359,7 +361,6 @@ static int ac100_rtc_register_clks(struc
 		chip->clk_data->hws[i] = &clk->hw;
 	}
 
-	chip->clk_data->num = i;
 	ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, chip->clk_data);
 	if (ret)
 		goto err_unregister_rtc_32k;
author maintainer
#33 lore raw

PATCH 33/497 rtc: spear: initialize IRQ state before requesting alarm IRQ

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Runyu Xiao <[email protected]>

commit 055ef5ce9f67a6a3a1363fa663007f8196cc0fb8 upstream.

devm_request_irq() enables the interrupt before it returns, so the handler may run while probe is still initializing the device. Initialize the MMIO address and spinlock before requesting the alarm IRQ.

Fixes 0942a71e435f ("rtc: add support for spear rtc")
Assisted-by Codex:GPT-5
---
 drivers/rtc/rtc-spear.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/rtc/rtc-spear.c +6 -5
@@ -363,6 +363,12 @@ static int spear_rtc_probe(struct platfo
 	if (irq < 0)
 		return irq;
 
+	config->ioaddr = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(config->ioaddr))
+		return PTR_ERR(config->ioaddr);
+
+	spin_lock_init(&config->lock);
+
 	status = devm_request_irq(&pdev->dev, irq, spear_rtc_irq, 0, pdev->name,
 			config);
 	if (status) {
@@ -371,10 +377,6 @@ static int spear_rtc_probe(struct platfo
 		return status;
 	}
 
-	config->ioaddr = devm_platform_ioremap_resource(pdev, 0);
-	if (IS_ERR(config->ioaddr))
-		return PTR_ERR(config->ioaddr);
-
 	config->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(config->clk))
 		return PTR_ERR(config->clk);
@@ -383,7 +385,6 @@ static int spear_rtc_probe(struct platfo
 	if (status < 0)
 		return status;
 
-	spin_lock_init(&config->lock);
 	platform_set_drvdata(pdev, config);
 
 	config->rtc->ops = &spear_rtc_ops;
author maintainer
#34 lore raw

PATCH 34/497 sctp: check RCV_SHUTDOWN after the sendmsg connect wait

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jun Yang <[email protected]>

commit 4f1da630d13de0370e2f6361f961f1c8b384af1c upstream.

sctp_wait_for_connect() drops the socket lock while it sleeps. An out-of-the-blue ABORT can then be processed from the socket backlog and unlink the association. If a concurrent shutdown(fd, SHUT_RD) sets RCV_SHUTDOWN, the waiter breaks with err == 0 before checking asoc->base.dead. Its final sctp_association_put() can then free the association, leaving sctp_sendmsg_to_asoc() to continue with a dangling pointer.

Check RCV_SHUTDOWN along with the wait error in sctp_sendmsg_to_asoc() before using the association again. The check only accesses the socket, so it needs no additional association reference. Return the existing -ESRCH so that sctp_sendmsg() skips freeing a new association that may already have been destroyed.

Keep sctp_wait_for_connect() unchanged to preserve its behavior for the connect() caller.

---
 net/sctp/socket.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sctp/socket.c +1 -1
@@ -1844,7 +1844,7 @@ static int sctp_sendmsg_to_asoc(struct s
 		if (asoc->ep->intl_enable) {
 			timeo = sock_sndtimeo(sk, 0);
 			err = sctp_wait_for_connect(asoc, &timeo);
-			if (err) {
+			if (err || sk->sk_shutdown & RCV_SHUTDOWN) {
 				err = -ESRCH;
 				goto err;
 			}
author maintainer
#35 lore raw

PATCH 35/497 tpm: Disable TPM on null key name mismatch

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Surendran Kanagaraj <[email protected]>

commit 015fb29a748342a186f37b602ac70017098c8251 upstream.

The null key name check exists to protect against TPM reset attacks, so a mismatch should stop the device from serving further requests. Currently it does not disable the chip when it finds a mismatch.

The mismatch is logged:

tpm tpm0: null key integrity check failed

but the chip keeps serving commands:

/ # tpm2_getcap -c properties-fixed
TPM_PT_FAMILY_INDICATOR:
as UINT32: 0x08322e3000
as string: "2.0"
...

tpm2_load_null() where the null key name check is run sets the chip as disabled only if the rc is non zero. When the mismatch is seen, rc is zero at that point and it returns success. The other issue is that the caller expects the null key handle to be populated when the function returns 0 which it does here without writing the handle and proceeds assuming the null key handle is valid.

During the test, I noticed that tpm2_start_auth_session() uses the uninitialized stack value as the key handle since tpm2_load_null() returns 0 despite the integrity failure and proceeds with TPM2_CC_START_AUTH_SESS with this value as salt key handle.

Set rc to -ENODEV on the mismatch. The error path then disables the chip and returns the correct code to the caller.

Tested in QEMU with swtpm and CONFIG_TCG_TPM2_HMAC=y by making TPM2_CC_CONTEXT_LOAD fail with TPM2_RC_INTEGRITY and changing the name of the re-created null key. The chip is now disabled on the mismatch.

Fixes cc7d8594342a ("tpm: Rollback tpm2_load_null()")
Fixes 423893fcbe7e ("tpm: Disable TPM on tpm2_create_primary() failure")
Cc [email protected] # v6.12+
Assisted-by LLM
---
 drivers/char/tpm/tpm2-sessions.c |    1 +
 1 file changed, 1 insertion(+)
drivers/char/tpm/tpm2-sessions.c +1 -0
@@ -1025,6 +1025,7 @@ static int tpm2_load_null(struct tpm_chi
 	/* Deduce from the name change TPM interference: */
 	dev_err(&chip->dev, "null key integrity check failed\n");
 	tpm2_flush_context(chip, tmp_null_key);
+	rc = -ENODEV;
 
 err:
 	if (rc) {
author maintainer
#36 lore raw

PATCH 36/497 virt: vmgenid: set driver_data before registering notification handlers

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Zhichen Wang <[email protected]>

commit 9f8139c6145cf17d690d6c414d43b4c0bef632fb upstream.

Both probe paths register their notification handler before assigning driver_data, which the handler dereferences.

In the devicetree path, the notification IRQ can fire as soon as devm_request_irq() registers the handler: the interrupt may already be pending at probe time, for example when a VMM injects the generation-changed notification while restoring a guest from a snapshot that was taken before the driver had probed (Firecracker does exactly this on snapshot restore). The IRQ is also requested with IRQF_SHARED, so another device sharing the line can trigger the handler just as early. The handler then calls vmgenid_notify(), which dereferences the still-NULL driver_data and panics:

  Unable to handle kernel NULL pointer dereference at virtual address 0000000000000010
  CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.18.38+ #1 PREEMPT(none)
  Hardware name: linux,dummy-virt (DT)
  pc : vmgenid_notify.isra.0+0x24/0x8c
  lr : vmgenid_of_irq_handler+0x14/0x34
  Call trace:
   vmgenid_notify.isra.0+0x24/0x8c (P)
   vmgenid_of_irq_handler+0x14/0x34
   __handle_irq_event_percpu+0x44/0x1bc
   handle_irq_event+0x4c/0xb4
   handle_fasteoi_irq+0xf8/0x1f8

The ACPI path has the same ordering problem: the handler is installed with acpi_install_notify_handler() before driver_data is assigned. ACPI notifications are dispatched asynchronously from a workqueue, so the window is narrow, but a notification arriving between the two calls hits the same NULL dereference.

Assign driver_data before registering the handlers. The state is fully initialized at that point, so the handlers are safe to run. Should registration fail, the probe error path leaves no dangling pointer
behind: the driver core clears driver_data in device_unbind_cleanup().

Fixes 7b1bcd6b50a6 ("virt: vmgenid: add support for devicetree bindings")
Fixes e07606713a90 ("virt: vmgenid: change implementation to use a platform driver")
---
 drivers/virt/vmgenid.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/virt/vmgenid.c +4 -2
@@ -82,6 +82,8 @@ static int vmgenid_add_acpi(struct devic
 	}
 	setup_vmgenid_state(state, virt_addr);
 
+	dev->driver_data = state;
+
 	status = acpi_install_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
 					     vmgenid_acpi_handler, dev);
 	if (ACPI_FAILURE(status)) {
@@ -89,7 +91,6 @@ static int vmgenid_add_acpi(struct devic
 		goto out;
 	}
 
-	dev->driver_data = state;
 out:
 	ACPI_FREE(parsed.pointer);
 	return ret;
@@ -123,12 +124,13 @@ static int vmgenid_add_of(struct platfor
 	if (ret < 0)
 		return ret;
 
+	pdev->dev.driver_data = state;
+
 	ret = devm_request_irq(&pdev->dev, ret, vmgenid_of_irq_handler,
 			       IRQF_SHARED, "vmgenid", &pdev->dev);
 	if (ret < 0)
 		return ret;
 
-	pdev->dev.driver_data = state;
 	return 0;
 }
 
author maintainer
#37 lore raw

PATCH 37/497 smb: client: clear setuid/setgid bit on write with cifsacl/modefromsid/posix extensions

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jiangshan Yi <[email protected]>

commit b8e5dc4f95e5484159b343903f302eb6d783f2e6 upstream.

When a file has the setuid or setgid bit set and is written to, the VFS strips those bits and issues a setattr with ATTR_KILL_SUID/ATTR_KILL_SGID together with an ATTR_MODE carrying the already-cleared mode.

Both cifs_setattr_unix() and cifs_setattr_nounix() unconditionally dropped ATTR_MODE in that case:

	/* skip mode change if it's just for clearing setuid/setgid */
	if (attrs->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID))
		attrs->ia_valid &= ~ATTR_MODE;

This is fine for the default mount, where the mode is only emulated via the DOS read-only attribute and cannot represent the setuid/setgid bits anyway. However, with the "cifsacl" or "modefromsid" mount options the mode is stored on the server through an ACL (id_mode_to_cifs_acl()), with the SMB3.1.1 POSIX extensions the mode is sent to the server directly, and with the SMB1 Unix extensions (cifs_setattr_unix) the mode is sent via CIFSSMBUnixSetPathInfo(). In all those cases dropping ATTR_MODE means the cleared mode is never pushed to the server, so the setuid/setgid bit survives the write.

This is a security issue: on local filesystems the setuid bit is stripped when a file is written, but over these cifs.ko mounts the bit persists on the server, potentially allowing an unexpected privilege escalation on subsequent execution.

Fix this in two places:

1. cifs_setattr_nounix(): only take the "skip mode change" shortcut when the mode is emulated via the DOS read-only attribute (i.e. neither cifsacl/modefromsid nor the SMB3.1.1 POSIX extensions are in effect), so that the cleared mode is propagated to the server in the ACL / POSIX cases.

2. cifs_setattr_unix(): this function is only called when Unix extensions are in effect, so the mode is always stored on the server. Remove the shortcut entirely so that the cleared mode is always pushed.

Fixes d32c4f2626ac ("CIFS: ignore mode change if it's just for clearing setuid/setgid bits")

[ Backport note for 6.12: no sbflags local exists here, so test
cifs_sb->mnt_cifs_flags directly (same flag bits); uses existing "bool posix". ]

Assisted-by opencode:kimi-k3
---
 fs/smb/client/inode.c | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)
fs/smb/client/inode.c +25 -5
index b67b316538b83..7c4828580076c 100644
@@ -3117,9 +3117,13 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
 			goto out;
 	}
 
-	/* skip mode change if it's just for clearing setuid/setgid */
-	if (attrs->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID))
-		attrs->ia_valid &= ~ATTR_MODE;
+	/*
+	 * This function is only called when Unix extensions are in effect,
+	 * so the mode is always sent to and stored on the server.  Do not
+	 * skip the mode change when clearing setuid/setgid bits: dropping
+	 * ATTR_MODE here would leave those bits set on the server after a
+	 * write, which is a security issue.
+	 */
 
 	args = kmalloc(sizeof(*args), GFP_KERNEL);
 	if (args == NULL) {
@@ -3307,8 +3311,24 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
 	if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID))
 		attrs->ia_valid &= ~(ATTR_UID | ATTR_GID);
 
-	/* skip mode change if it's just for clearing setuid/setgid */
-	if (attrs->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID))
+	/*
+	 * Skip the mode change if it is only being done to clear the
+	 * setuid/setgid bits *and* the mode is emulated via the DOS
+	 * read-only attribute (the default, non-ACL case), which cannot
+	 * represent the setuid/setgid bits anyway.
+	 *
+	 * When the mode is instead stored on the server - i.e. with the
+	 * cifsacl or modefromsid mount options (via an ACL) or with the
+	 * SMB3.1.1 POSIX extensions - the cleared mode must be pushed to
+	 * the server.  Dropping ATTR_MODE here would leave the setuid/
+	 * setgid bit set on the server after a write, which is a security
+	 * issue (the bits are not stripped as they are on local
+	 * filesystems).
+	 */
+	if ((attrs->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID)) &&
+	    !((cifs_sb->mnt_cifs_flags &
+	       (CIFS_MOUNT_CIFS_ACL | CIFS_MOUNT_MODE_FROM_SID)) ||
+	      posix))
 		attrs->ia_valid &= ~ATTR_MODE;
 
 	if (attrs->ia_valid & ATTR_MODE) {
Signature · 1 line
2.53.0
author maintainer
#38 lore raw

PATCH 38/497 rds_tcp: close NULL deref window in rds_tcp_set_callbacks

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Maoyi Xie <[email protected]>

commit d2bfdbb69cf87676981b1043010b6224d84c6d3a upstream.

rds_tcp_set_callbacks() links a new rds_tcp_connection onto rds_tcp_tc_list under rds_tcp_tc_list_lock. It releases the lock, then assigns tc->t_sock = sock outside the lock.

rds_tcp_tc_info() and rds6_tcp_tc_info() walk rds_tcp_tc_list under the same lock. Both dereference tc->t_sock->sk without a NULL check.

A reader can acquire rds_tcp_tc_list_lock between the writer's spin_unlock and the t_sock store. It then sees a list entry whose t_sock is NULL. The dereference of tc->t_sock->sk is a NULL access.

Move tc->t_sock = sock inside rds_tcp_tc_list_lock, before list_add_tail. A reader holding the lock then observes the linkage and the t_sock store together.

The restore path is safe. rds_tcp_restore_callbacks() does list_del_init inside the lock. The matching tc->t_sock = NULL after unlink is harmless to readers holding the lock.

[ achender: resolved context conflict; tc->t_rtn initialization is not
present in this tree ]

---
 net/rds/tcp.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
net/rds/tcp.c +6 -3
index f6d243c4e52cb..eab960d10ab08 100644
@@ -232,16 +232,19 @@ void rds_tcp_set_callbacks(struct socket *sock, struct rds_conn_path *cp)
 	rdsdebug("setting sock %p callbacks to tc %p\n", sock, tc);
 	write_lock_bh(&sock->sk->sk_callback_lock);
 
-	/* done under the callback_lock to serialize with write_space */
+	/* done under the callback_lock to serialize with write_space.
+	 * Set t_sock inside rds_tcp_tc_list_lock so readers walking
+	 * rds_tcp_tc_list under the same lock cannot observe an
+	 * entry whose t_sock is NULL.
+	 */
 	spin_lock(&rds_tcp_tc_list_lock);
+	tc->t_sock = sock;
 	list_add_tail(&tc->t_list_item, &rds_tcp_tc_list);
 	spin_unlock(&rds_tcp_tc_list_lock);
 
 	/* accepted sockets need our listen data ready undone */
 	if (sock->sk->sk_data_ready == rds_tcp_listen_data_ready)
 		sock->sk->sk_data_ready = sock->sk->sk_user_data;
-
-	tc->t_sock = sock;
 	tc->t_cpath = cp;
 	tc->t_orig_data_ready = sock->sk->sk_data_ready;
 	tc->t_orig_write_space = sock->sk->sk_write_space;
Signature · 1 line
2.53.0
author maintainer
#39 lore raw

PATCH 39/497 vt: skip screen update for DEC alignment test on backgroup consoles

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Zizhi Wo <[email protected]>

commit 0928ed9bd7946baee911efa401088697836e3b1e upstream.

[BUG]
Recently, we encountered a KASAN warning as follows:

BUG: KASAN: slab-out-of-bounds in fb_pad_aligned_buffer+0x11f/0x140
Read of size 1 at addr ff1100015fd9f6a4 by task tty_fbcon_oob/1239
CPU: 7 UID: 0 PID: 1239 Comm: tty_fbcon_oob Not tainted 7.3.0-rc1 #100 PREEMPT(full)
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-4.fc41 04/01/2014
Call Trace:
 <TASK>
 ...
 kasan_report+0xf0/0x120
 fb_pad_aligned_buffer+0x11f/0x140
 ccw_putcs+0x86c/0xa80
 fbcon_putcs+0x338/0x410
 do_update_region+0x21d/0x450
 do_con_write+0x1e0e/0x4880
 con_write+0x13/0x80
 n_tty_write+0x374/0x1010
 file_tty_write.isra.0+0x404/0x7a0
 ...

reproduce:
1) open /dev/tty0, set a KDFONTOP ioctl with op.op = KD_FONT_OP_SET, op.width = 8 and op.height = 16 (visible VC1)
2) open /dev/tty1, set a KDFONTOP ioctl with op.op = KD_FONT_OP_SET, op.width = 28 and op.height = 24 (invisible VC2)
3) echo 3 > /sys/devices/virtual/graphics/fbcon/rotate_all
4) write EShash8(esc hash8) to tty1

[CAUSE]
All VCs render to the framebuffer. setfont only modifies the target VC's font without resizing the framebuffer backing buffer (par->rotated.buf); the buffer is only resized for the visible VC (fbcon_do_set_font -> ... -> vc_do_resize -> update_screen). This relies on the con_should_update() check performed before every update_region().

However, the ESC # 8 path (do_con_trol -> do_update_region) omits the con_should_update() check. After changing the font size of an invisible VC, do_update_region() fills using the new font size against a buffer that was never resized, causing an out-of-bounds access.

[FIX]
Only push the update when the console is visible and not blanked, add the con_should_update() check in the do_con_trol() like every other call site of do_update_region() (update_region(), invert_screen(), ...).

---
 drivers/tty/vt/vt.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/tty/vt/vt.c +2 -1
@@ -2688,7 +2688,8 @@ static void do_con_trol(struct tty_struc
 			csi_J(vc, CSI_J_VISIBLE);
 			vc->vc_video_erase_char =
 				(vc->vc_video_erase_char & 0xff00) | ' ';
-			do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2);
+			if (con_should_update(vc))
+				do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2);
 		}
 		return;
 	case ESsetG0:	/* ESC ( */
author maintainer
#40 lore raw

PATCH 40/497 wifi: wlcore: Fix runtime PM leak in wlcore_remove()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Wentao Liang <[email protected]>

commit a8b8881d0c1aff544fae190469d86db7b07f43a9 upstream.

pm_runtime_get_sync() keeps the runtime PM usage counter elevated even when it returns an error, so the reference taken at the beginning of wlcore_remove() has to be dropped on every exit path. When the device was not initialized the function returned early without doing so, leaking the reference.

Release it with pm_runtime_put_noidle() as done on the other early error paths of this driver.

---
 drivers/net/wireless/ti/wlcore/main.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/ti/wlcore/main.c +3 -1
@@ -6831,8 +6831,10 @@ void wlcore_remove(struct platform_devic
 
 	if (pdev_data->family && pdev_data->family->nvs_name)
 		wait_for_completion(&wl->nvs_loading_complete);
-	if (!wl->initialized)
+	if (!wl->initialized) {
+		pm_runtime_put_noidle(wl->dev);
 		return;
+	}
 
 	if (wl->wakeirq >= 0) {
 		dev_pm_clear_wake_irq(wl->dev);
author maintainer
#41 lore raw

PATCH 41/497 ALSA: caiaq: unregister the input device when probe fails

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Nguyen Ngoc Thang <[email protected]>

commit 0b7bd20f6379bc5e431fd74d866390f5b5b63f3c upstream.

setup_card() registers the input device, whose name and phys point into struct snd_usb_caiaqdev, and then goes on to snd_card_register() and snd_usb_caiaq_control_init(). If either fails, snd_probe() calls snd_card_free(), which frees the device state but leaves the input device registered: card_free() only clears the pointer, and the input device is unregistered from snd_disconnect() alone. Reading its "uevent" attribute afterwards dereferences freed memory:

  BUG: KASAN: slab-use-after-free in string+0x4a9/0x4f0
  Read of size 1 at addr ffff8880208f5043 by task caiaq/4967
   add_uevent_var+0x183/0x3a0
   input_dev_uevent+0x162/0x900
   dev_uevent+0x2f1/0x870
   uevent_show+0x1ca/0x3a0
   ...

Unregister the input device on the probe error path, as snd_disconnect() does. snd_usb_caiaq_input_disconnect() is a no-op when no input device was registered.

Reproduced with a raw-gadget Audio Kontrol 1 and a temporary hack that makes snd_usb_caiaq_control_init() fail.

---
 sound/usb/caiaq/device.c |    3 +++
 1 file changed, 3 insertions(+)
sound/usb/caiaq/device.c +3 -0
@@ -562,6 +562,9 @@ static int snd_probe(struct usb_interfac
 	ret = init_card(caiaqdev(card));
 	if (ret < 0) {
 		dev_err(&usb_dev->dev, "unable to init card! (ret=%d)\n", ret);
+#ifdef CONFIG_SND_USB_CAIAQ_INPUT
+		snd_usb_caiaq_input_disconnect(caiaqdev(card));
+#endif
 		snd_card_free(card);
 		return ret;
 	}
author maintainer
#42 lore raw

PATCH 42/497 ALSA: line6: reject oversized playback packets

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Xiang Mei <[email protected]>

commit 61b0a5a114fa4552892da5c0ff2f42e63bf08c6b upstream.

Each playback URB is handed a slice of out.buffer that is exactly LINE6_ISO_PACKETS * max_packet_size_out bytes, sized from the OUT endpoint, but the number of bytes written into that slice is never compared against it.

submit_audio_out_urb() takes the frame count from prev_fsize, which audio_in_callback() derived from the *IN* endpoint's received packet length, and rescales it with the playback frame size; when prev_fsize is still zero it synthesizes a length from the sample rate instead. On a device declaring a large IN wMaxPacketSize and a small OUT wMaxPacketSize, the resulting memcpy(), or the memset() when the playback stream is idle, runs past its slice and, as the reproducer below shows, beyond the allocation.

usb_submit_urb() is not a backstop. max_packet_size_out comes from usb_maxpacket(), which returns only the low 11 bits of wMaxPacketSize, while USB core validates a high-speed isochronous length against that base scaled by usb_endpoint_maxp_mult(). A length of up to three times the allocated slice is therefore accepted, and even a rejected URB is only rejected after the write.

Reject a packet that does not fit the slice the driver allocated for it. Clamping it instead would silently shorten the capture-derived rate feedback and desynchronize the two streams.

  BUG: KASAN: slab-out-of-bounds in submit_audio_out_urb (sound/usb/line6/playback.c:229)
  Write of size 1024 at addr ffff888100bbd400 by task kworker/1:2/5002
  Workqueue: events line6_startup_work
  Call Trace:
   __asan_memcpy (mm/kasan/shadow.c:106)
   submit_audio_out_urb (sound/usb/line6/playback.c:229)
   line6_submit_audio_out_all_urbs (sound/usb/line6/playback.c:291)
   line6_stream_start (sound/usb/line6/pcm.c:194)
   line6_pcm_acquire (sound/usb/line6/pcm.c:337)
   line6_startup_work (sound/usb/line6/driver.c:728)
   process_one_work (kernel/workqueue.c:3396)
   worker_thread (kernel/workqueue.c:3479 kernel/workqueue.c:3560)
   kthread (kernel/kthread.c:436)
   ret_from_fork (arch/x86/kernel/process.c:158)
   ret_from_fork_asm (arch/x86/entry/entry_64.S:245)

  The buggy address belongs to the object at ffff888100bbd400
   which belongs to the cache kmalloc-256 of size 256
  The buggy address is located 0 bytes inside of
   allocated 256-byte region [ffff888100bbd400, ffff888100bbd500)
Fixes 7a0f55aeeb8f ("ALSA: line6: Support assymetrical in/out configurations")
Assisted-by LLM
---
 sound/usb/line6/playback.c |    7 +++++++
 1 file changed, 7 insertions(+)
sound/usb/line6/playback.c +7 -0
@@ -182,6 +182,13 @@ static int submit_audio_out_urb(struct s
 
 		fsize *= bytes_per_frame;
 
+		if (fsize > line6pcm->max_packet_size_out) {
+			dev_err(line6pcm->line6->ifcdev,
+				"playback packet too large: %d > %d\n",
+				fsize, line6pcm->max_packet_size_out);
+			return -EMSGSIZE;
+		}
+
 		fout->offset = urb_size;
 		fout->length = fsize;
 		urb_size += fsize;
author maintainer
#43 lore raw

PATCH 43/497 mm/secretmem: properly account locked pages

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Lorenzo Stoakes (ARM) <[email protected]>

[ Upstream commit 97d34aa65c29cca85e3e9050f4c936389b38a054 ]

secretmem accounts folios by treating memory as if it were mlock()'d and thus limited by the RLIMIT_MEMLOCK limit.

However the folios are unevictable and remain so until the inode is evicted, eliminating usual mlock() semantics - mapping folios then unmapping them does not clear their unevictable state, since it depends on AS_UNEVICTABLE, not PG_mlocked.

A user can therefore easily work around the RLIMIT_MEMLOCK limit - simply map then unmap and VmLck no longer counts the secretmem range. Worse, folios are not accounted in the process's RSS, meaning the OOM killer won't know to kill the process.

Repeatedly mapping/unmapping (or forking) can then result in the consumption of all available system memory with unevictable folios and cause system instability.

A secretmem fd can be passed between processes and over fork so a per-process limit simply does not make sense, so follow the precedent set by io_uring, perf, skbuff, iommufd and xdp by tracking the number of locked pages in user_struct->locked_vm.

Since the scope tracked is actually inode lifetime, the RLIMIT_MEMLOCK applies per-user not per-process, so it doesn't make sense to bypass for users with CAP_IPC_LOCK, therefore remove this bypass.

There is simply no reason to carry on marking the mapping as mlock()'d since it's misleading and the lifecycle is now correctly handled, so remove this too.

Note that secretmem does not support any form of truncation (including hole punching) and the folios are unreclaimable, so the folios need only be accounted on fault and unaccounted on inode destruction.

__secretmem_account_pages() is more or less a duplicate of the code that io_uring etc. use, but since this is a bug fix that needs backporting, defer any de-duplication efforts to a follow-up.

test_mlock_limit() asserts mlock_future_ok() on mmap(), however this has been removed, so remove the test altogether for the fix. A new test will be sent separately for upstream.

Fixes 1507f51255c9 ("mm: introduce memfd_secret system call to create "secret" memory areas")
Cc Alexei Starovoitov <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc David S. Miller <[email protected]>
Cc Hagen Paul Pfeifer <[email protected]>
Cc Jakub Kacinski <[email protected]>
Cc James Bottomley <[email protected]>
Cc Jesper Dangaard Brouer <[email protected]>
Cc John Fastabend <[email protected]>
Cc Liam R. Howlett <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Stanislav Fomichev <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
Cc Vlastimil Babka <[email protected]>
[ adapted secretmem changes to Linux 6.12’s page-based fault handling and legacy mmap interface. ]
---
 include/linux/sched/user.h                |   3 +-
 mm/secretmem.c                            | 117 ++++++++++++++++++++--
 tools/testing/selftests/mm/memfd_secret.c |  30 +-----
 3 files changed, 110 insertions(+), 40 deletions(-)
include/linux/sched/user.h +2 -1
index 4cc52698e214e..8d7e5521f7cdd 100644
@@ -25,7 +25,8 @@ struct user_struct {
 
 #if defined(CONFIG_PERF_EVENTS) || defined(CONFIG_BPF_SYSCALL) || \
 	defined(CONFIG_NET) || defined(CONFIG_IO_URING) || \
-	defined(CONFIG_VFIO_PCI_ZDEV_KVM) || IS_ENABLED(CONFIG_IOMMUFD)
+	defined(CONFIG_VFIO_PCI_ZDEV_KVM) || IS_ENABLED(CONFIG_IOMMUFD) || \
+	defined(CONFIG_SECRETMEM)
 	atomic_long_t locked_vm;
 #endif
 #ifdef CONFIG_WATCH_QUEUE
mm/secretmem.c +107 -10

191 lines not on this page · raw message

tools/testing/selftests/mm/memfd_secret.c +1 -29
index 9a0597310a765..06cffbc3fd77f 100644
@@ -57,33 +57,6 @@ static void test_file_apis(int fd)
 		pass("file IO is blocked as expected\n");
 }
 
-static void test_mlock_limit(int fd)
-{
-	size_t len;
-	char *mem;
-
-	len = mlock_limit_cur;
-	if (len % page_size != 0)
-		len = (len/page_size) * page_size;
-
-	mem = mmap(NULL, len, prot, mode, fd, 0);
-	if (mem == MAP_FAILED) {
-		fail("unable to mmap secret memory\n");
-		return;
-	}
-	munmap(mem, len);
-
-	len = mlock_limit_max * 2;
-	mem = mmap(NULL, len, prot, mode, fd, 0);
-	if (mem != MAP_FAILED) {
-		fail("unexpected mlock limit violation\n");
-		munmap(mem, len);
-		return;
-	}
-
-	pass("mlock limit is respected\n");
-}
-
 static void test_vmsplice(int fd, const char *desc)
 {
 	ssize_t transferred;
@@ -297,7 +270,7 @@ static void prepare(void)
 				   strerror(errno));
 }
 
-#define NUM_TESTS 6
+#define NUM_TESTS 5
 
 int main(int argc, char *argv[])
 {
@@ -319,7 +292,6 @@ int main(int argc, char *argv[])
 	if (ftruncate(fd, page_size))
 		ksft_exit_fail_msg("ftruncate failed: %s\n", strerror(errno));
 
-	test_mlock_limit(fd);
 	test_file_apis(fd);
 	/*
 	 * We have to run the first vmsplice test before any secretmem page was
Signature · 1 line
2.53.0
author maintainer
#44 lore raw

PATCH 44/497 perf/core: Fix WARN in perf_sigtrap()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Tetsuo Handa <[email protected]>

[ Upstream commit 3da6bb419750f3ad834786d6ba7c9d5d062c770b ]

Since exit_task_work() runs after perf_event_exit_task_context() updated ctx->task to TASK_TOMBSTONE, perf_sigtrap() from perf_pending_task() might observe event->ctx->task == TASK_TOMBSTONE.

Swap the early exit tests in order not to hit WARN_ON_ONCE().

---
 kernel/events/core.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
kernel/events/core.c +7 -7
index dfbd217fd20c0..ab18d02dd959c 100644
@@ -6907,18 +6907,18 @@ void perf_event_wakeup(struct perf_event *event)
 static void perf_sigtrap(struct perf_event *event)
 {
 	/*
-	 * We'd expect this to only occur if the irq_work is delayed and either
-	 * ctx->task or current has changed in the meantime. This can be the
-	 * case on architectures that do not implement arch_irq_work_raise().
+	 * Both perf_pending_task() and perf_pending_irq() can race with the
+	 * task exiting.
 	 */
-	if (WARN_ON_ONCE(event->ctx->task != current))
+	if (current->flags & PF_EXITING)
 		return;
 
 	/*
-	 * Both perf_pending_task() and perf_pending_irq() can race with the
-	 * task exiting.
+	 * We'd expect this to only occur if the irq_work is delayed and either
+	 * ctx->task or current has changed in the meantime. This can be the
+	 * case on architectures that do not implement arch_irq_work_raise().
 	 */
-	if (current->flags & PF_EXITING)
+	if (WARN_ON_ONCE(event->ctx->task != current))
 		return;
 
 	send_sig_perf((void __user *)event->pending_addr,
Signature · 1 line
2.53.0
author maintainer
#45 lore raw

PATCH 45/497 random: vDSO: avoid call to memset() when zeroing reserved parameter

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Nathan Chancellor <[email protected]>

commit eb13a1ff271b0d180687eebb30611b0b276d5193 upstream.

After a recent change in LLVM [1], builds with the random vDSO implementation, such as PowerPC and RISC-V, fail when checking the vDSO:

arch/powerpc/kernel/vdso/vdso32.so.dbg: dynamic relocations are not supported arch/riscv/kernel/vdso/vdso.so.dbg: dynamic relocations are not supported

memset() is now generated when zeroing params->reserved for some builds because LLVM has an optimization (now run in more instances) that can recognize at compile time when it is assigning a static value to a contiguous area of memory and turn that into a call to memset(). Both clang and GCC assume memset() is always available [2].

Clang has an internal fiddly hook, -max-store-memset, which we can set to a high number, to disable generating out of line memset calls [3]. Similarly, GCC has -finline-stringops=memset to do the same [4], should this issue ever hit future version of GCC. While these options wouldn't make sense for normal kernel code, it is fine for the extremely limited and intentionally compact vDSO code.

---
 arch/arm64/kernel/vdso/Makefile   | 2 +-
 arch/loongarch/vdso/Makefile      | 1 +
 arch/powerpc/kernel/vdso/Makefile | 1 +
 arch/s390/kernel/vdso64/Makefile  | 1 +
 arch/x86/entry/vdso/Makefile      | 1 +
 init/Kconfig                      | 5 +++++
 6 files changed, 10 insertions(+), 1 deletion(-)
arch/arm64/kernel/vdso/Makefile +1 -1
index 35685c0360441..c4934b22d5e95 100644
@@ -40,7 +40,7 @@ CC_FLAGS_REMOVE_VDSO := $(CC_FLAGS_FTRACE) -Os $(CC_FLAGS_SCS) \
 			$(CC_FLAGS_LTO) $(CC_FLAGS_CFI) \
 			-Wmissing-prototypes -Wmissing-declarations
 
-CC_FLAGS_ADD_VDSO := -O2 -mcmodel=tiny -fasynchronous-unwind-tables
+CC_FLAGS_ADD_VDSO := -O2 -mcmodel=tiny -fasynchronous-unwind-tables $(CONFIG_CC_OPT_INLINE_MEMSET)
 
 CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_REMOVE_VDSO)
 CFLAGS_REMOVE_vgetrandom.o = $(CC_FLAGS_REMOVE_VDSO)
arch/loongarch/vdso/Makefile +1 -0
index b37cda6346443..60fa1a8d80e66 100644
@@ -13,6 +13,7 @@ ccflags-vdso := \
 	$(filter -E%,$(KBUILD_CFLAGS)) \
 	$(filter -march=%,$(KBUILD_CFLAGS)) \
 	$(filter -m%-float,$(KBUILD_CFLAGS)) \
+	$(CONFIG_CC_OPT_INLINE_MEMSET) \
 	$(CLANG_FLAGS) \
 	-D__VDSO__
 
arch/powerpc/kernel/vdso/Makefile +1 -0
index 6ba68b28ed870..0d29880e3b155 100644
@@ -43,6 +43,7 @@ ccflags-y := -fno-common -fno-builtin -DBUILD_VDSO
 ccflags-y += $(DISABLE_LATENT_ENTROPY_PLUGIN)
 ccflags-y += $(call cc-option, -fno-stack-protector)
 ccflags-y += -DDISABLE_BRANCH_PROFILING
+ccflags-y += $(CONFIG_CC_OPT_INLINE_MEMSET)
 ccflags-y += -ffreestanding -fasynchronous-unwind-tables
 ccflags-remove-y := $(CC_FLAGS_FTRACE)
 ldflags-y := -Wl,--hash-style=both -nostdlib -shared -z noexecstack $(CLANG_FLAGS)
arch/s390/kernel/vdso64/Makefile +1 -0
index 37bb4b7612297..1f0fdb785ca71 100644
@@ -32,6 +32,7 @@ KBUILD_CFLAGS_64 := $(filter-out -mno-pic-data-is-text-relative,$(KBUILD_CFLAGS_
 KBUILD_CFLAGS_64 := $(filter-out -munaligned-symbols,$(KBUILD_CFLAGS_64))
 KBUILD_CFLAGS_64 := $(filter-out -fno-asynchronous-unwind-tables,$(KBUILD_CFLAGS_64))
 KBUILD_CFLAGS_64 += -m64 -fPIC -fno-common -fno-builtin -fasynchronous-unwind-tables
+KBUILD_CFLAGS_64 += $(CONFIG_CC_OPT_INLINE_MEMSET)
 ldflags-y := -shared -soname=linux-vdso64.so.1 \
 	     --hash-style=both --build-id=sha1 -T
 
arch/x86/entry/vdso/Makefile +1 -0
index c9216ac4fb1eb..e5ade5e89e7e0 100644
@@ -54,6 +54,7 @@ $(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE
 CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \
        $(filter -g%,$(KBUILD_CFLAGS)) -fno-stack-protector \
        -fno-omit-frame-pointer -foptimize-sibling-calls \
+       $(CONFIG_CC_OPT_INLINE_MEMSET) \
        -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO
 
 ifdef CONFIG_MITIGATION_RETPOLINE
init/Kconfig +5 -0
index f0e708b4226de..7b3d72f3a14d1 100644
@@ -132,6 +132,11 @@ config CC_HAS_COUNTED_BY
 	# https://github.com/llvm/llvm-project/pull/112636
 	depends on !(CC_IS_CLANG && CLANG_VERSION < 190103)
 
+config CC_OPT_INLINE_MEMSET
+	string
+	default "-finline-stringops=memset" if $(cc-option,-finline-stringops=memset)
+	default "-mllvm -max-store-memset=4294967294" if $(cc-option,-mllvm -max-store-memset=4294967294)
+
 config LD_CAN_USE_KEEP_IN_OVERLAY
 	# ld.lld prior to 21.0.0 did not support KEEP within an overlay description
 	# https://github.com/llvm/llvm-project/pull/130661
Signature · 1 line
2.53.0
author maintainer
#46 lore raw

PATCH 46/497 mm/damon/core: dont skip damos_adjust_quota() while esz is not zero

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: SJ Park <[email protected]>

[ Upstream commit 52ae167ce16609c7e6fffef588b3c2c26de2db19 ]

DAMOS could unexpectedly stop working when a user disables quota using the online parameters commit feature. Fix it by correcting a wrong quota unset check in damos_adjust_quota().

DAMON users could disable all quotas by unsetting time and size quotas, and removing all quota goals. The intention of disabling quotas would be making DAMOS run at full speed. When such quota disabled setup is detected, damos_adjust_quota() skips all its work. The skipped works include effective size quota (damos_quota->esz) updates and charged quota amount (damos_quota->charged_sz) resets. The intention is to avoid doing unnecessary work when quotas are disabled.

However, users could do the setup while effective size quota is non-zero, by doing the disabling with the online DAMON parameters commit feature. In this case, because the effective size quota exists, DAMOS will keep working with the quota until it is fully charged. After the effective quota is fully charged, the charged quota amount (damos_quota->charged_sz) cannot be reset because damos_adjust_quota() skips it. Then, DAMOS stops working until the quota is newly set or DAMON is entirely restarted.

The problem happens because damos_adjust_quota() assumes the user setup for disabling quota immediately disabled it. In reality, the quota is still working until the effective size quota is also updated to zero. Other logic for catching that uses damos_quota_is_set(), which understands the fact and therefore checks the effective size quota in addition to the user setup. Fix the issue by using damos_quota_is_set() in damos_adjust_quota() to determine if its works should be skipped.

The user impact is a non-deterministic and unexpected DAMOS stop behavior. That is, users would disable quotas using the online parameters commit feature, expecting DAMOS will run at full speed. However, depending on the timing, the setup can be updated while the effective size quota is non-zero. Due to the above mentioned internal mechanism, DAMOS stops working instead of running at full speed. It is unexpected behavior. It is also non-deterministic because sometimes the setup is done when the effective size quota is zero, depending on the timing. It doesn't cause critical issues like crashes or leaks. Users can simply set a reasonable quota again, or restart DAMON. But definitely it is an unexpected and non-deterministic behavior that makes it difficult to reliably use. Also investigating the root cause of the behavior would be quite difficult.

Fixes da87878010e5 ("mm/damon/sysfs: support online inputs update")
Cc <[email protected]> # 5.19.x
---
 mm/damon/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
mm/damon/core.c +2 -1
index 32737cc5f877b..2f6d60b9ca0f4 100644
@@ -1677,7 +1677,8 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s)
 	unsigned long cumulated_sz;
 	unsigned int score, max_score = 0;
 
-	if (!quota->ms && !quota->sz && list_empty(&quota->goals))
+	if (!quota->esz && !quota->ms && !quota->sz &&
+			list_empty(&quota->goals))
 		return;
 
 	/* First charge window */
Signature · 1 line
2.53.0
author maintainer
#47 lore raw

PATCH 47/497 iio: accel: kionix-kx022a: Fix array boundary check

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Matti Vaittinen <[email protected]>

[ Upstream commit 0e65412aee4f651d2c9785f542a13e4b44002a75 ]

The driver performs a sanity check for an array size, when converting a register value to an array index. The check incorrectly accepts the sizeof(array) as a last index, when last valid index should be sizeof(array) - 1.

Fix the check by bailing out when index >= sizeof(array).

Fixes 7c1d1677b322 ("iio: accel: Support Kionix/ROHM KX022A accelerometer")
---
 drivers/iio/accel/kionix-kx022a.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/kionix-kx022a.c +1 -1
index b6a828a6df934..db78a1945956d 100644
@@ -626,7 +626,7 @@ static int kx022a_read_raw(struct iio_dev *idev,
 		if (ret)
 			return ret;
 
-		if ((regval & KX022A_MASK_ODR) >
+		if ((regval & KX022A_MASK_ODR) >=
 		    ARRAY_SIZE(kx022a_accel_samp_freq_table)) {
 			dev_err(data->dev, "Invalid ODR\n");
 			return -EINVAL;
Signature · 1 line
2.53.0
author maintainer
#48 lore raw

PATCH 48/497 mtd: core: call _get_device() with the master MTD

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Karl Mehltretter <[email protected]>

[ Upstream commit 12b31d1acd20b3185bb5f0748db0cf6874c8e9d1 ]

__get_mtd_device() calls the master's _get_device() callback with mtd, which may be a partition. __put_mtd_device() passes the master.

This breaks gluebi partitions because gluebi_get_device() uses container_of() and therefore requires the master MTD. Pass the master to _get_device(), matching _put_device().

Fixes 46b5889cc2c5 ("mtd: implement proper partition handling")
Assisted-by Codex:gpt-5.6-sol
---
 drivers/mtd/mtdcore.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/mtdcore.c +1 -1
index 0c8e8eb5f0f3d..12d31ed27b4ec 100644
@@ -1259,7 +1259,7 @@ int __get_mtd_device(struct mtd_info *mtd)
 	int err;
 
 	if (master->_get_device) {
-		err = master->_get_device(mtd);
+		err = master->_get_device(master);
 		if (err)
 			return err;
 	}
Signature · 1 line
2.53.0
author maintainer
#49 lore raw

PATCH 49/497 nvmet: preserve device path on allocation failure

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Julian Sun <[email protected]>

[ Upstream commit 2f271b812170d4cad578bae1f91db72f3c2e36e7 ]

nvmet_ns_device_path_store() frees the old path before allocating its replacement, losing the existing configuration if allocation fails. Allocate the new path before freeing the old one.

Fixes a07b4970f464 ("nvmet: add a generic NVMe target")
---
 drivers/nvme/target/configfs.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/nvme/target/configfs.c +6 -3
index cfbab198693b0..1bec5dc7fc452 100644
@@ -505,6 +505,7 @@ static ssize_t nvmet_ns_device_path_store(struct config_item *item,
 	struct nvmet_subsys *subsys = ns->subsys;
 	size_t len;
 	int ret;
+	char *new_path = NULL;
 
 	mutex_lock(&subsys->lock);
 	ret = -EBUSY;
@@ -516,12 +517,14 @@ static ssize_t nvmet_ns_device_path_store(struct config_item *item,
 	if (!len)
 		goto out_unlock;
 
-	kfree(ns->device_path);
 	ret = -ENOMEM;
-	ns->device_path = kmemdup_nul(page, len, GFP_KERNEL);
-	if (!ns->device_path)
+	new_path = kmemdup_nul(page, len, GFP_KERNEL);
+	if (!new_path)
 		goto out_unlock;
 
+	kfree(ns->device_path);
+	ns->device_path = new_path;
+
 	mutex_unlock(&subsys->lock);
 	return count;
 
Signature · 1 line
2.53.0
author maintainer
#50 lore raw

PATCH 50/497 random: fix vgetrandom_opaque_params kernel-doc

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Karl Mehltretter <[email protected]>

[ Upstream commit 703749b069d53b55f92499e088b30b031e47b8f9 ]

struct vgetrandom_opaque_params contains size_of_opaque_state, but its kernel-doc describes size_per_opaque_state. This leaves the real member undescribed and adds a nonexistent member to the generated documentation.

Use the member's actual name.

Fixes 4ad10a5f5f78 ("random: introduce generic vDSO getrandom() implementation")
---
 include/uapi/linux/random.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/random.h +1 -1
index 1dd047ec98a12..ef6614d9c7049 100644
@@ -58,7 +58,7 @@ struct rand_pool_info {
 /**
  * struct vgetrandom_opaque_params - arguments for allocating memory for vgetrandom
  *
- * @size_per_opaque_state:	Size of each state that is to be passed to vgetrandom().
+ * @size_of_opaque_state:	Size of each state passed to vgetrandom().
  * @mmap_prot:			Value of the prot argument in mmap(2).
  * @mmap_flags:			Value of the flags argument in mmap(2).
  * @reserved:			Reserved for future use.
Signature · 1 line
2.53.0
author maintainer
#51 lore raw

PATCH 51/497 of/overlay: dont leak fragment references when changeset init fails

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Abdurrahman Hussain <[email protected]>

[ Upstream commit 1d62f0f2bc7edb12ed09f71203df0e47fa4efca4 ]

init_overlay_changeset() stores the number of initialized fragments in ovcs->count only on full success. When find_target() or the __symbols__ lookup fails partway through, the target and overlay references taken for the fragments initialized so far are never
dropped: free_overlay_changeset() bounds its cleanup loop by ovcs->count, which is still 0.

Store the running count on the error path so free_overlay_changeset() puts whatever was set up. The store is guarded by ovcs->fragments because on the allocation-failure path cnt still holds the counting pass total while there is no fragments array; everywhere else cnt only counts fully-initialized fragments.

Fixes 61b4de4e0b38 ("of: overlay: minor restructuring")
Assisted-by Claude:claude-opus-4-8 [Claude Code]
---
 drivers/of/overlay.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/of/overlay.c +4 -0
index 2118f11718d39..c4a8e925754d4 100644
@@ -849,6 +849,10 @@ static int init_overlay_changeset(struct overlay_changeset *ovcs,
 err_out:
 	pr_err("%s() failed, ret = %d\n", __func__, ret);
 
+	/* let free_overlay_changeset() put the fragments set up so far */
+	if (ovcs->fragments)
+		ovcs->count = cnt;
+
 	return ret;
 }
 
Signature · 1 line
2.53.0
author maintainer
#52 lore raw

PATCH 52/497 of/overlay: dont create "//" paths for fragments targeting the root

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Abdurrahman Hussain <[email protected]>

[ Upstream commit 21c89ff1fc86ffa517f3a9ca1ba5c48e9e37c1ba ]

dup_and_fixup_symbol_prop() rewrites a symbol value by replacing its "/fragment/__overlay__" prefix with the fragment's target path. When the fragment targets the root node the target path is "/" and the result starts with "//", which __of_find_node_by_full_path() cannot
resolve: symbols pointing into such fragments silently stop resolving.

Drop the target path when it is the root and the tail is non-empty. A value naming the fragment root itself (empty tail) keeps the "/".

Fixes d1651b03c2df ("of: overlay: add overlay symbols to live device tree")
Assisted-by Claude:claude-fable-5 [Claude Code]
---
 drivers/of/overlay.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/of/overlay.c +3 -0
index c4a8e925754d4..adc6a0277d6b7 100644
@@ -250,6 +250,9 @@ static struct property *dup_and_fixup_symbol_prop(
 	if (!target_path)
 		return NULL;
 	target_path_len = strlen(target_path);
+	/* a root target renders as "/"; drop it to avoid "//" results */
+	if (target_path_len == 1 && target_path[0] == '/' && path_tail_len)
+		target_path_len = 0;
 
 	new_prop = kzalloc(sizeof(*new_prop), GFP_KERNEL);
 	if (!new_prop)
Signature · 1 line
2.53.0
author maintainer
#53 lore raw

PATCH 53/497 ASoC: wm8903: Move the DRC QR threshold to the register that holds it

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: HyeongJun An <[email protected]>

[ Upstream commit e31ae4aeb049983fe3be0cf1e12c8074811a7685 ]

The DRC_THRESH_QR field is bits 7 and 6 of DRC_1, but the control sits on DRC_0. Its shift and max are right for the field, only the register is wrong.

Those bits of DRC_0 belong to DRC_STARTUP_GAIN, which "DRC Startup Volume" claims as bits 10 to 6. So the two controls share bits 7 and 6. Writing either one moves the other, and the quick release threshold is never reached at all.

The six fields of DRC_1 tile it exactly, so there is nowhere else the threshold could live. Point the control at DRC_1.

Found by a sweep for two controls claiming the same bits of one register. No board with this codec was to hand, the register map is the driver's own wm8903.h.

Fixes f1c0a02f32f8 ("ALSA: ASoC: Add WM8903 CODEC driver")
Assisted-by Claude:claude-opus-5
---
 sound/soc/codecs/wm8903.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8903.c +1 -1
index c643b5377d3a1..b2e0f5dd481cc 100644
@@ -677,7 +677,7 @@ SOC_ENUM("DRC Decay Rate", drc_decay),
 SOC_ENUM("DRC FF Delay", drc_ff_delay),
 SOC_SINGLE("DRC Anticlip Switch", WM8903_DRC_0, 1, 1, 0),
 SOC_SINGLE("DRC QR Switch", WM8903_DRC_0, 2, 1, 0),
-SOC_SINGLE_TLV("DRC QR Threshold Volume", WM8903_DRC_0, 6, 3, 0, drc_tlv_max),
+SOC_SINGLE_TLV("DRC QR Threshold Volume", WM8903_DRC_1, 6, 3, 0, drc_tlv_max),
 SOC_ENUM("DRC QR Decay Rate", drc_qr_decay),
 SOC_SINGLE("DRC Smoothing Switch", WM8903_DRC_0, 3, 1, 0),
 SOC_SINGLE("DRC Smoothing Hysteresis Switch", WM8903_DRC_0, 0, 1, 0),
Signature · 1 line
2.53.0
author maintainer
#54 lore raw

PATCH 54/497 wifi: wfx: validate MIB read length before copying to caller

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Aamir Ahmed <[email protected]>

[ Upstream commit ce67ebe9d8629776ce38e6995ae72fb903c828db ]

wfx_hif_read_mib() copies reply->length bytes from the firmware response into the caller-provided buffer without checking that reply->length does not exceed val_len. A firmware response with a length field larger than expected overruns the caller buffer and reads past the end of the reply allocation.

Replace the dead -ENOMEM check with an active validation that reply->length fits within val_len before the memcpy.

---
 drivers/net/wireless/silabs/wfx/hif_tx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/silabs/wfx/hif_tx.c +3 -1
index 9f403d275cb13..9efb108bd877d 100644
@@ -207,9 +207,11 @@ int wfx_hif_read_mib(struct wfx_dev *wdev, int vif_id, u16 mib_id, void *val, si
 		dev_warn(wdev->dev, "%s: confirmation mismatch request\n", __func__);
 		ret = -EIO;
 	}
-	if (ret == -ENOMEM)
+	if (!ret && le16_to_cpu(reply->length) > val_len) {
 		dev_err(wdev->dev, "buffer is too small to receive %s (%zu < %d)\n",
 			wfx_get_mib_name(mib_id), val_len, le16_to_cpu(reply->length));
+		ret = -EIO;
+	}
 	if (!ret)
 		memcpy(val, &reply->mib_data, le16_to_cpu(reply->length));
 	else
Signature · 1 line
2.53.0
author maintainer
#55 lore raw

PATCH 55/497 ASoC: tegra: Fix ASRC Stream6 input threshold control

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Sheetal <[email protected]>

[ Upstream commit 75fc8a3ee5aee72f2fea3b6436170fae175f7f19 ]

The Stream6 Input Threshold control points at stream index 4, which is already used by Stream5. The threshold get and put callbacks derive the lane ID from the register offset, so the duplicate index makes Stream6 operate on lane 4 and leaves lane 5 inaccessible from userspace.

Use stream index 5 for Stream6.

Fixes a2df8c2d5b36 ("ASoC: tegra: Add Tegra186 based ASRC driver")
---
 sound/soc/tegra/tegra186_asrc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/tegra/tegra186_asrc.c +1 -1
index d914dba560135..2b6c4ab26d6c1 100644
@@ -830,7 +830,7 @@ static const struct snd_kcontrol_new tegra186_asrc_controls[] = {
 		       tegra186_asrc_put_input_threshold),
 
 	SOC_SINGLE_EXT("Stream6 Input Threshold",
-		       ASRC_STREAM_REG(TEGRA186_ASRC_RX_THRESHOLD, 4), 0, 3, 0,
+		       ASRC_STREAM_REG(TEGRA186_ASRC_RX_THRESHOLD, 5), 0, 3, 0,
 		       tegra186_asrc_get_input_threshold,
 		       tegra186_asrc_put_input_threshold),
 
Signature · 1 line
2.53.0
author maintainer
#56 lore raw

PATCH 56/497 wifi: ath11k: reset ar->num_stations on hardware start

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Nicolas Escande <[email protected]>

[ Upstream commit 7e0ad05ebc72fffba2bdf2400400902d94ed7272 ]

When (multiple) hw restart occurs, we end up in a situation where we cannot accept new stations / mesh peers. This seems to be the 'num_stations' in 'struct ath11k' that did not get reset properly in this case. In ath11k_mac_op_start(), it was indeed the only accounting var that did not get reset so let's clear it too.

This avoids problems like those:

	[1248828.088023] WARNING: CPU: 0 PID: 12281 at net/mac80211/util.c:1682 ieee80211_reconfig_stations+0x98/0xc0
	[1248828.088115] Call trace:
	[1248828.088116]  ieee80211_reconfig_stations+0x98/0xc0 (P)
	[1248828.088119]  ieee80211_reconfig+0x774/0x1438
	[1248828.088123]  ieee80211_restart_work+0x10c/0x178
	[1248828.088127]  process_one_work+0x178/0x3c0
	[1248828.088130]  worker_thread+0x280/0x440
	[1248828.088133]  kthread+0xe0/0xf8
	[1248828.088137]  ret_from_fork+0x10/0x20
	[1248828.088141] ---[ end trace 0000000000000000 ]---
	[1248836.686604] ath11k_pci 0000:04:00.0: refusing to associate station: too many connected already (128)
	[1248836.686609] ath11k_pci 0000:04:00.0: Failed to add station: xx:xx:xx:xx:xx:xx for VDEV: 1

Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.9.0.1-01977-QCAHKSWPL_SILICONZ-1

---
 drivers/net/wireless/ath/ath11k/mac.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/wireless/ath/ath11k/mac.c +1 -0
index 53bc1b90bab3c..2d0c6f9f3f763 100644
@@ -6396,6 +6396,7 @@ static int ath11k_mac_op_start(struct ieee80211_hw *hw)
 	ar->num_started_vdevs = 0;
 	ar->num_created_vdevs = 0;
 	ar->num_peers = 0;
+	ar->num_stations = 0;
 	ar->allocated_vdev_map = 0;
 
 	/* Configure monitor status ring with default rx_filter to get rx status
Signature · 1 line
2.53.0
author maintainer
#57 lore raw

PATCH 57/497 wifi: ath9k: reject short WMI command responses

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Pengpeng Hou <[email protected]>

[ Upstream commit 93ce8ea70451e800601bc9444aa33043de15d67b ]

ath9k_wmi_rsp_callback() removes the validated WMI header and copies the number of bytes expected by the waiting command into its response buffer. A device response shorter than that expectation can therefore be read beyond the skb payload.

Record -EMSGSIZE for a short response, complete the waiter, and return the stored status from the command path. This also prevents callers from consuming stale response bytes as a successful reply.

Fixes fb9987d0f748 ("ath9k_htc: Support for AR9271 chipset.")
Assisted-by LLM
---
 drivers/net/wireless/ath/ath9k/wmi.c | 16 ++++++++++++++--
 drivers/net/wireless/ath/ath9k/wmi.h |  1 +
 2 files changed, 15 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/wmi.c +14 -2
index 805ad31edba2b..610717fb83f57 100644
@@ -206,9 +206,16 @@ static void ath9k_wmi_rsp_callback(struct wmi *wmi, struct sk_buff *skb)
 {
 	skb_pull(skb, sizeof(struct wmi_cmd_hdr));
 
-	if (wmi->cmd_rsp_buf != NULL && wmi->cmd_rsp_len != 0)
+	if (wmi->cmd_rsp_buf && wmi->cmd_rsp_len) {
+		if (skb->len < wmi->cmd_rsp_len) {
+			wmi->cmd_rsp_status = -EMSGSIZE;
+			goto complete;
+		}
 		memcpy(wmi->cmd_rsp_buf, skb->data, wmi->cmd_rsp_len);
+	}
+	wmi->cmd_rsp_status = 0;
 
+complete:
 	complete(&wmi->cmd_wait);
 }
 
@@ -300,6 +307,7 @@ static int ath9k_wmi_cmd_issue(struct wmi *wmi,
 	/* record the rsp buffer and length */
 	wmi->cmd_rsp_buf = rsp_buf;
 	wmi->cmd_rsp_len = rsp_len;
+	wmi->cmd_rsp_status = 0;
 
 	wmi->last_seq_id = wmi->tx_seq_id;
 	spin_unlock_irqrestore(&wmi->wmi_lock, flags);
@@ -356,9 +364,13 @@ int ath9k_wmi_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id,
 		return -ETIMEDOUT;
 	}
 
+	spin_lock_irqsave(&wmi->wmi_lock, flags);
+	ret = wmi->cmd_rsp_status;
+	spin_unlock_irqrestore(&wmi->wmi_lock, flags);
+
 	mutex_unlock(&wmi->op_mutex);
 
-	return 0;
+	return ret;
 
 out:
 	ath_dbg(common, WMI, "WMI failure for: %s\n", wmi_cmd_to_name(cmd_id));
drivers/net/wireless/ath/ath9k/wmi.h +1 -0
index 5c3b710b8f319..0bb9d31f1a1cc 100644
@@ -157,6 +157,7 @@ struct wmi {
 	u16 tx_seq_id;
 	u8 *cmd_rsp_buf;
 	u32 cmd_rsp_len;
+	int cmd_rsp_status;
 	bool stopped;
 
 	struct list_head pending_tx_events;
Signature · 1 line
2.53.0
author maintainer
#58 lore raw

PATCH 58/497 wifi: ath9k_htc: bound TX aggregation to MAX_TX_BUF_SIZE

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Georgios Karantzas <[email protected]>

[ Upstream commit aeaca27c1db3106967ffbb2b517d98c835f6d500 ]

__hif_usb_tx() dequeues up to MAX_TX_AGGR_NUM (20) frames into a single tx_buf of MAX_TX_BUF_SIZE (32768) bytes, limiting the batch by record count but never by cumulative byte length.

With large frames (MTU 2304), 20 aggregated frames of 2292 bytes each exceed the allocation (20 * 2296 = 45920 bytes), so the memcpy() in the loop writes up to 13152 bytes past tx_buf->buf before usb_submit_urb().

Peek the queue head and stop before copying any record that would cross MAX_TX_BUF_SIZE, then dispatch the current batch. Leftover skbs remain queued and are drained on the next URB completion.

The byte bound changes the loop's exit semantics: it can now exit before i == tx_skb_cnt - 1. Stock only finalized tx_buf->len on that last index (len += offset), so an early break would submit a URB holding only the last record's length while every dequeued skb is freed on completion, silently dropping frames. Make tx_buf->len a running total and advance tx_buf->offset per record instead; the stride round_up(nskb->len + 4, 4) is identical to the stock stride when the loop runs to completion.

Tested on hardware with an MTU 2304 flood: the loop stops at record 15 (len = 32144, offset = 32144, within 32768), no oversized URB is submitted, and MTU 1500 pings pass 20/20.

---
 drivers/net/wireless/ath/ath9k/hif_usb.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/net/wireless/ath/ath9k/hif_usb.c +9 -10
index f9396bf30a617..b1282efd897a4 100644
@@ -14,6 +14,7 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include <linux/math.h>
 #include <linux/unaligned.h>
 #include "htc.h"
 
@@ -328,11 +329,14 @@ static int __hif_usb_tx(struct hif_device_usb *hif_dev)
 	tx_skb_cnt = min_t(u16, hif_dev->tx.tx_skb_cnt, MAX_TX_AGGR_NUM);
 
 	for (i = 0; i < tx_skb_cnt; i++) {
-		nskb = __skb_dequeue(&hif_dev->tx.tx_skb_queue);
+		nskb = skb_peek(&hif_dev->tx.tx_skb_queue);
+		if (!nskb)
+			break;
 
-		/* Should never be NULL */
-		BUG_ON(!nskb);
+		if (tx_buf->offset + nskb->len + 4 > MAX_TX_BUF_SIZE)
+			break;
 
+		nskb = __skb_dequeue(&hif_dev->tx.tx_skb_queue);
 		hif_dev->tx.tx_skb_cnt--;
 
 		buf = tx_buf->buf;
@@ -342,13 +346,8 @@ static int __hif_usb_tx(struct hif_device_usb *hif_dev)
 		*hdr++ = cpu_to_le16(ATH_USB_TX_STREAM_MODE_TAG);
 		buf += 4;
 		memcpy(buf, nskb->data, nskb->len);
-		tx_buf->len = nskb->len + 4;
-
-		if (i < (tx_skb_cnt - 1))
-			tx_buf->offset += (((tx_buf->len - 1) / 4) + 1) * 4;
-
-		if (i == (tx_skb_cnt - 1))
-			tx_buf->len += tx_buf->offset;
+		tx_buf->len = tx_buf->offset + nskb->len + 4;
+		tx_buf->offset += round_up(nskb->len + 4, 4);
 
 		__skb_queue_tail(&tx_buf->skb_queue, nskb);
 		TX_STAT_INC(hif_dev, skb_queued);
Signature · 1 line
2.53.0
author maintainer
#59 lore raw

PATCH 59/497 rtc: dev: zero-initialize struct rtc_wkalrm to prevent information leak

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Liu Dalin <[email protected]>

[ Upstream commit 0ee5c5d804d592a8328a425b9274487d393d3a05 ]

The struct rtc_wkalrm has padding holes after the 'pending' member. When returned to userspace via the RTC_WKALRM_RD ioctl, uninitialized kernel stack data residing in these holes may be leaked.

Zero-initialize the struct at declaration to eliminate this information leak risk.

Fixes smatch warnings:
- drivers/rtc/dev.c:392 rtc_dev_ioctl() warn: check that 'alarm' doesn't leak information (struct has a hole after 'pending')

---
 drivers/rtc/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/dev.c +1 -1
index c4a3ab53dcd4b..747408244424a 100644
@@ -207,7 +207,7 @@ static long rtc_dev_ioctl(struct file *file,
 	struct rtc_device *rtc = file->private_data;
 	const struct rtc_class_ops *ops = rtc->ops;
 	struct rtc_time tm;
-	struct rtc_wkalrm alarm;
+	struct rtc_wkalrm alarm = { 0 };
 	struct rtc_param param;
 	void __user *uarg = (void __user *)arg;
 
Signature · 1 line
2.53.0
author maintainer
#60 lore raw

PATCH 60/497 rtc: Switch back to struct platform_driver::remove()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Uwe Kleine-König <[email protected]>

[ Upstream commit e5eab1aeae765c30bd2ef50156dc9698c239ad31 ]

After commit 0edb555a65d1 ("platform: Make platform_driver::remove() return void") .remove() is (again) the right callback to implement for platform drivers.

Convert all platform drivers below drivers/rtc to use .remove(), with the eventual goal to drop struct platform_driver::remove_new(). As .remove() and .remove_new() have the same prototypes, conversion is done by just changing the structure member name in the driver initializer.

Stable-dep-of: fcf0b58e976e ("rtc: ac100: Fix clock provider use-after-free on probe failure")

---
 drivers/rtc/rtc-88pm80x.c           | 2 +-
 drivers/rtc/rtc-88pm860x.c          | 2 +-
 drivers/rtc/rtc-ab8500.c            | 2 +-
 drivers/rtc/rtc-ac100.c             | 2 +-
 drivers/rtc/rtc-asm9260.c           | 2 +-
 drivers/rtc/rtc-at91rm9200.c        | 2 +-
 drivers/rtc/rtc-at91sam9.c          | 2 +-
 drivers/rtc/rtc-brcmstb-waketimer.c | 2 +-
 drivers/rtc/rtc-cadence.c           | 2 +-
 drivers/rtc/rtc-cmos.c              | 2 +-
 drivers/rtc/rtc-cros-ec.c           | 2 +-
 drivers/rtc/rtc-ds1685.c            | 2 +-
 drivers/rtc/rtc-ftrtc010.c          | 2 +-
 drivers/rtc/rtc-hid-sensor-time.c   | 2 +-
 drivers/rtc/rtc-imxdi.c             | 2 +-
 drivers/rtc/rtc-loongson.c          | 2 +-
 drivers/rtc/rtc-lpc24xx.c           | 2 +-
 drivers/rtc/rtc-max77686.c          | 2 +-
 drivers/rtc/rtc-mc13xxx.c           | 2 +-
 drivers/rtc/rtc-mpc5121.c           | 2 +-
 drivers/rtc/rtc-mpfs.c              | 2 +-
 drivers/rtc/rtc-mt7622.c            | 2 +-
 drivers/rtc/rtc-mv.c                | 2 +-
 drivers/rtc/rtc-mxc_v2.c            | 2 +-
 drivers/rtc/rtc-omap.c              | 2 +-
 drivers/rtc/rtc-palmas.c            | 2 +-
 drivers/rtc/rtc-pcf50633.c          | 2 +-
 drivers/rtc/rtc-pic32.c             | 2 +-
 drivers/rtc/rtc-pm8xxx.c            | 2 +-
 drivers/rtc/rtc-pxa.c               | 2 +-
 drivers/rtc/rtc-rc5t583.c           | 2 +-
 drivers/rtc/rtc-rtd119x.c           | 2 +-
 drivers/rtc/rtc-rzn1.c              | 2 +-
 drivers/rtc/rtc-s3c.c               | 2 +-
 drivers/rtc/rtc-sa1100.c            | 2 +-
 drivers/rtc/rtc-sh.c                | 2 +-
 drivers/rtc/rtc-spear.c             | 2 +-
 drivers/rtc/rtc-stm32.c             | 2 +-
 drivers/rtc/rtc-stmp3xxx.c          | 2 +-
 drivers/rtc/rtc-sunplus.c           | 2 +-
 drivers/rtc/rtc-tegra.c             | 2 +-
 drivers/rtc/rtc-tps6586x.c          | 2 +-
 drivers/rtc/rtc-twl.c               | 2 +-
 drivers/rtc/rtc-vt8500.c            | 2 +-
 drivers/rtc/rtc-wm8350.c            | 2 +-
 drivers/rtc/rtc-xgene.c             | 2 +-
 drivers/rtc/rtc-zynqmp.c            | 2 +-
 47 files changed, 47 insertions(+), 47 deletions(-)
drivers/rtc/rtc-88pm80x.c +1 -1
index f40cc06b09797..5c39cf252392d 100644
@@ -329,7 +329,7 @@ static struct platform_driver pm80x_rtc_driver = {
 		   .pm = &pm80x_rtc_pm_ops,
 		   },
 	.probe = pm80x_rtc_probe,
-	.remove_new = pm80x_rtc_remove,
+	.remove = pm80x_rtc_remove,
 };
 
 module_platform_driver(pm80x_rtc_driver);
drivers/rtc/rtc-88pm860x.c +1 -1
index 0f124ed5b3e56..814230d618427 100644
@@ -371,7 +371,7 @@ static struct platform_driver pm860x_rtc_driver = {
 		.pm	= &pm860x_rtc_pm_ops,
 	},
 	.probe		= pm860x_rtc_probe,
-	.remove_new	= pm860x_rtc_remove,
+	.remove		= pm860x_rtc_remove,
 };
 
 module_platform_driver(pm860x_rtc_driver);
drivers/rtc/rtc-ab8500.c +1 -1
index 75bb2ac9005c2..2dcda96f4a8ef 100644
@@ -403,7 +403,7 @@ static struct platform_driver ab8500_rtc_driver = {
 		.name = "ab8500-rtc",
 	},
 	.probe	= ab8500_rtc_probe,
-	.remove_new = ab8500_rtc_remove,
+	.remove = ab8500_rtc_remove,
 	.id_table = ab85xx_rtc_ids,
 };
 
drivers/rtc/rtc-ac100.c +1 -1
index 90338dba457a4..9917cd67f4c6d 100644
@@ -629,7 +629,7 @@ MODULE_DEVICE_TABLE(of, ac100_rtc_match);
 
 static struct platform_driver ac100_rtc_driver = {
 	.probe		= ac100_rtc_probe,
-	.remove_new	= ac100_rtc_remove,
+	.remove		= ac100_rtc_remove,
 	.driver		= {
 		.name		= "ac100-rtc",
 		.of_match_table	= of_match_ptr(ac100_rtc_match),
drivers/rtc/rtc-asm9260.c +1 -1
index a83b47e0d8f53..705470ae84280 100644
@@ -325,7 +325,7 @@ MODULE_DEVICE_TABLE(of, asm9260_dt_ids);
 
 static struct platform_driver asm9260_rtc_driver = {
 	.probe		= asm9260_rtc_probe,
-	.remove_new	= asm9260_rtc_remove,
+	.remove		= asm9260_rtc_remove,
 	.driver		= {
 		.name	= "asm9260-rtc",
 		.of_match_table = asm9260_dt_ids,
drivers/rtc/rtc-at91rm9200.c +1 -1
index c16fe711a0d94..9b3898b8de7cf 100644
@@ -640,7 +640,7 @@ static SIMPLE_DEV_PM_OPS(at91_rtc_pm_ops, at91_rtc_suspend, at91_rtc_resume);
  * triggering a section mismatch warning.
  */
 static struct platform_driver at91_rtc_driver __refdata = {
-	.remove_new	= __exit_p(at91_rtc_remove),
+	.remove		= __exit_p(at91_rtc_remove),
 	.shutdown	= at91_rtc_shutdown,
 	.driver		= {
 		.name	= "at91_rtc",
drivers/rtc/rtc-at91sam9.c +1 -1
index 993c0878fb660..15b21da2788f6 100644
@@ -530,7 +530,7 @@ MODULE_DEVICE_TABLE(of, at91_rtc_dt_ids);
 
 static struct platform_driver at91_rtc_driver = {
 	.probe		= at91_rtc_probe,
-	.remove_new	= at91_rtc_remove,
+	.remove		= at91_rtc_remove,
 	.shutdown	= at91_rtc_shutdown,
 	.driver		= {
 		.name	= "rtc-at91sam9",
drivers/rtc/rtc-brcmstb-waketimer.c +1 -1
index 1a65a4e0dc003..b108e75042eb7 100644
@@ -417,7 +417,7 @@ static const __maybe_unused struct of_device_id brcmstb_waketmr_of_match[] = {
 
 static struct platform_driver brcmstb_waketmr_driver = {
 	.probe			= brcmstb_waketmr_probe,
-	.remove_new		= brcmstb_waketmr_remove,
+	.remove			= brcmstb_waketmr_remove,
 	.driver = {
 		.name		= "brcmstb-waketimer",
 		.pm		= &brcmstb_waketmr_pm_ops,
drivers/rtc/rtc-cadence.c +1 -1
index 4ca60b5198365..bf2a9a1fdea74 100644
@@ -402,7 +402,7 @@ static struct platform_driver cdns_rtc_driver = {
 		.pm = &cdns_rtc_pm_ops,
 	},
 	.probe = cdns_rtc_probe,
-	.remove_new = cdns_rtc_remove,
+	.remove = cdns_rtc_remove,
 };
 module_platform_driver(cdns_rtc_driver);
 
drivers/rtc/rtc-cmos.c +1 -1
index e06f3b9cab2c8..79ef0d8164788 100644
@@ -1535,7 +1535,7 @@ static void cmos_platform_shutdown(struct platform_device *pdev)
 MODULE_ALIAS("platform:rtc_cmos");
 
 static struct platform_driver cmos_platform_driver = {
-	.remove_new	= cmos_platform_remove,
+	.remove		= cmos_platform_remove,
 	.shutdown	= cmos_platform_shutdown,
 	.driver = {
 		.name		= driver_name,
drivers/rtc/rtc-cros-ec.c +1 -1
index f57462c7b2c64..60a48c3ba3ca5 100644
@@ -401,7 +401,7 @@ MODULE_DEVICE_TABLE(platform, cros_ec_rtc_id);
 
 static struct platform_driver cros_ec_rtc_driver = {
 	.probe = cros_ec_rtc_probe,
-	.remove_new = cros_ec_rtc_remove,
+	.remove = cros_ec_rtc_remove,
 	.driver = {
 		.name = DRV_NAME,
 		.pm = &cros_ec_rtc_pm_ops,
drivers/rtc/rtc-ds1685.c +1 -1
index 04dbf35cf3b70..38e25f63597ab 100644
@@ -1354,7 +1354,7 @@ static struct platform_driver ds1685_rtc_driver = {
 		.name	= "rtc-ds1685",
 	},
 	.probe		= ds1685_rtc_probe,
-	.remove_new	= ds1685_rtc_remove,
+	.remove		= ds1685_rtc_remove,
 };
 module_platform_driver(ds1685_rtc_driver);
 /* ----------------------------------------------------------------------- */
drivers/rtc/rtc-ftrtc010.c +1 -1
index 8bfe7378f6533..cb4a5d101f537 100644
@@ -214,7 +214,7 @@ static struct platform_driver ftrtc010_rtc_driver = {
 		.of_match_table = ftrtc010_rtc_dt_match,
 	},
 	.probe		= ftrtc010_rtc_probe,
-	.remove_new	= ftrtc010_rtc_remove,
+	.remove		= ftrtc010_rtc_remove,
 };
 
 module_platform_driver_probe(ftrtc010_rtc_driver, ftrtc010_rtc_probe);
drivers/rtc/rtc-hid-sensor-time.c +1 -1
index b81cea505ee93..e30f80dc93199 100644
@@ -319,7 +319,7 @@ static struct platform_driver hid_time_platform_driver = {
 		.name	= KBUILD_MODNAME,
 	},
 	.probe		= hid_time_probe,
-	.remove_new	= hid_time_remove,
+	.remove		= hid_time_remove,
 };
 module_platform_driver(hid_time_platform_driver);
 
drivers/rtc/rtc-imxdi.c +1 -1
index 284011c419db9..ca4a0af95e8c5 100644
@@ -860,7 +860,7 @@ static struct platform_driver dryice_rtc_driver __refdata = {
 		   .name = "imxdi_rtc",
 		   .of_match_table = dryice_dt_ids,
 		   },
-	.remove_new = __exit_p(dryice_rtc_remove),
+	.remove = __exit_p(dryice_rtc_remove),
 };
 
 module_platform_driver_probe(dryice_rtc_driver, dryice_rtc_probe);
drivers/rtc/rtc-loongson.c +1 -1
index c9d5b91a6544d..7eba6350d8f7c 100644
@@ -392,7 +392,7 @@ MODULE_DEVICE_TABLE(acpi, loongson_rtc_acpi_match);
 
 static struct platform_driver loongson_rtc_driver = {
 	.probe		= loongson_rtc_probe,
-	.remove_new	= loongson_rtc_remove,
+	.remove		= loongson_rtc_remove,
 	.driver		= {
 		.name	= "loongson-rtc",
 		.of_match_table = loongson_rtc_of_match,
drivers/rtc/rtc-lpc24xx.c +1 -1
index df17c48ff086e..2dcdc77ff646c 100644
@@ -285,7 +285,7 @@ MODULE_DEVICE_TABLE(of, lpc24xx_rtc_match);
 
 static struct platform_driver lpc24xx_rtc_driver = {
 	.probe	= lpc24xx_rtc_probe,
-	.remove_new = lpc24xx_rtc_remove,
+	.remove = lpc24xx_rtc_remove,
 	.driver	= {
 		.name = "lpc24xx-rtc",
 		.of_match_table	= lpc24xx_rtc_match,
drivers/rtc/rtc-max77686.c +1 -1
index 35a6021d9ba4c..a8f4b645c09d2 100644
@@ -875,7 +875,7 @@ static struct platform_driver max77686_rtc_driver = {
 		.pm	= &max77686_rtc_pm_ops,
 	},
 	.probe		= max77686_rtc_probe,
-	.remove_new	= max77686_rtc_remove,
+	.remove		= max77686_rtc_remove,
 	.id_table	= rtc_id,
 };
 
drivers/rtc/rtc-mc13xxx.c +1 -1
index 763a42f422eb2..e7b87130e6248 100644
@@ -350,7 +350,7 @@ MODULE_DEVICE_TABLE(platform, mc13xxx_rtc_idtable);
 
 static struct platform_driver mc13xxx_rtc_driver = {
 	.id_table = mc13xxx_rtc_idtable,
-	.remove_new = mc13xxx_rtc_remove,
+	.remove = mc13xxx_rtc_remove,
 	.driver = {
 		.name = DRIVER_NAME,
 	},
drivers/rtc/rtc-mpc5121.c +1 -1
index 71eafe4fbc72b..6003281316031 100644
@@ -398,7 +398,7 @@ static struct platform_driver mpc5121_rtc_driver = {
 		.of_match_table = of_match_ptr(mpc5121_rtc_match),
 	},
 	.probe = mpc5121_rtc_probe,
-	.remove_new = mpc5121_rtc_remove,
+	.remove = mpc5121_rtc_remove,
 };
 
 module_platform_driver(mpc5121_rtc_driver);
drivers/rtc/rtc-mpfs.c +1 -1
index aa724a945c088..f4f1b845e23d6 100644
@@ -288,7 +288,7 @@ MODULE_DEVICE_TABLE(of, mpfs_rtc_of_match);
 
 static struct platform_driver mpfs_rtc_driver = {
 	.probe = mpfs_rtc_probe,
-	.remove_new = mpfs_rtc_remove,
+	.remove = mpfs_rtc_remove,
 	.driver	= {
 		.name = "mpfs_rtc",
 		.of_match_table = mpfs_rtc_of_match,
drivers/rtc/rtc-mt7622.c +1 -1
index 094c649fc137f..4cf0cbb31a313 100644
@@ -394,7 +394,7 @@ static SIMPLE_DEV_PM_OPS(mtk_rtc_pm_ops, mtk_rtc_suspend, mtk_rtc_resume);
 
 static struct platform_driver mtk_rtc_driver = {
 	.probe	= mtk_rtc_probe,
-	.remove_new = mtk_rtc_remove,
+	.remove = mtk_rtc_remove,
 	.driver = {
 		.name = MTK_RTC_DEV,
 		.of_match_table = mtk_rtc_match,
drivers/rtc/rtc-mv.c +1 -1
index 55fa937f9f709..285075ee8aae4 100644
@@ -330,7 +330,7 @@ static SIMPLE_DEV_PM_OPS(mv_rtc_pm_ops, mv_rtc_suspend, mv_rtc_resume);
  * triggering a section mismatch warning.
  */
 static struct platform_driver mv_rtc_driver __refdata = {
-	.remove_new	= __exit_p(mv_rtc_remove),
+	.remove		= __exit_p(mv_rtc_remove),
 	.driver		= {
 		.name	= "rtc-mv",
 		.of_match_table = of_match_ptr(rtc_mv_of_match_table),
drivers/rtc/rtc-mxc_v2.c +1 -1
index 6934bce4b29fd..13c041bb79f16 100644
@@ -381,7 +381,7 @@ static struct platform_driver mxc_rtc_driver = {
 		.of_match_table = mxc_ids,
 	},
 	.probe = mxc_rtc_probe,
-	.remove_new = mxc_rtc_remove,
+	.remove = mxc_rtc_remove,
 };
 
 module_platform_driver(mxc_rtc_driver);
drivers/rtc/rtc-omap.c +1 -1
index e6b2a9c15b542..c123778e2d9bc 100644
@@ -1014,7 +1014,7 @@ static void omap_rtc_shutdown(struct platform_device *pdev)
 
 static struct platform_driver omap_rtc_driver = {
 	.probe		= omap_rtc_probe,
-	.remove_new	= omap_rtc_remove,
+	.remove		= omap_rtc_remove,
 	.shutdown	= omap_rtc_shutdown,
 	.driver		= {
 		.name	= "omap_rtc",
drivers/rtc/rtc-palmas.c +1 -1
index 6971e47c6021e..7256a88b490c9 100644
@@ -346,7 +346,7 @@ MODULE_DEVICE_TABLE(of, of_palmas_rtc_match);
 
 static struct platform_driver palmas_rtc_driver = {
 	.probe		= palmas_rtc_probe,
-	.remove_new	= palmas_rtc_remove,
+	.remove		= palmas_rtc_remove,
 	.driver		= {
 		.name	= "palmas-rtc",
 		.pm	= &palmas_rtc_pm_ops,
drivers/rtc/rtc-pcf50633.c +1 -1
index 23edd11aa40c5..c019c4d91c7d7 100644
@@ -273,7 +273,7 @@ static struct platform_driver pcf50633_rtc_driver = {
 		.name = "pcf50633-rtc",
 	},
 	.probe = pcf50633_rtc_probe,
-	.remove_new = pcf50633_rtc_remove,
+	.remove = pcf50633_rtc_remove,
 };
 
 module_platform_driver(pcf50633_rtc_driver);
drivers/rtc/rtc-pic32.c +1 -1
index 4f85e0c3d7572..bed3c27e665f3 100644
@@ -371,7 +371,7 @@ MODULE_DEVICE_TABLE(of, pic32_rtc_dt_ids);
 
 static struct platform_driver pic32_rtc_driver = {
 	.probe		= pic32_rtc_probe,
-	.remove_new	= pic32_rtc_remove,
+	.remove		= pic32_rtc_remove,
 	.driver		= {
 		.name	= "pic32-rtc",
 		.of_match_table	= of_match_ptr(pic32_rtc_dt_ids),
drivers/rtc/rtc-pm8xxx.c +1 -1
index c32fba550c8e0..2f32187ecc8d3 100644
@@ -537,7 +537,7 @@ static void pm8xxx_remove(struct platform_device *pdev)
 
 static struct platform_driver pm8xxx_rtc_driver = {
 	.probe		= pm8xxx_rtc_probe,
-	.remove_new	= pm8xxx_remove,
+	.remove		= pm8xxx_remove,
 	.driver	= {
 		.name		= "rtc-pm8xxx",
 		.of_match_table	= pm8xxx_id_table,
drivers/rtc/rtc-pxa.c +1 -1
index cdb39fc4cab52..34d8545c8e155 100644
@@ -409,7 +409,7 @@ static SIMPLE_DEV_PM_OPS(pxa_rtc_pm_ops, pxa_rtc_suspend, pxa_rtc_resume);
  * triggering a section mismatch warning.
  */
 static struct platform_driver pxa_rtc_driver __refdata = {
-	.remove_new	= __exit_p(pxa_rtc_remove),
+	.remove		= __exit_p(pxa_rtc_remove),
 	.driver		= {
 		.name	= "pxa-rtc",
 		.of_match_table = of_match_ptr(pxa_rtc_dt_ids),
drivers/rtc/rtc-rc5t583.c +1 -1
index 115c46f862f95..eecb49bab56ad 100644
@@ -298,7 +298,7 @@ static SIMPLE_DEV_PM_OPS(rc5t583_rtc_pm_ops, rc5t583_rtc_suspend,
 
 static struct platform_driver rc5t583_rtc_driver = {
 	.probe		= rc5t583_rtc_probe,
-	.remove_new	= rc5t583_rtc_remove,
+	.remove		= rc5t583_rtc_remove,
 	.driver		= {
 		.name	= "rtc-rc5t583",
 		.pm	= &rc5t583_rtc_pm_ops,
drivers/rtc/rtc-rtd119x.c +1 -1
index 29662dfd56fef..85a138db81d78 100644
@@ -228,7 +228,7 @@ static void rtd119x_rtc_remove(struct platform_device *pdev)
 
 static struct platform_driver rtd119x_rtc_driver = {
 	.probe = rtd119x_rtc_probe,
-	.remove_new = rtd119x_rtc_remove,
+	.remove = rtd119x_rtc_remove,
 	.driver = {
 		.name = "rtd1295-rtc",
 		.of_match_table	= rtd119x_rtc_dt_ids,
drivers/rtc/rtc-rzn1.c +1 -1
index 668935dbcefec..bdc041e9498a2 100644
@@ -413,7 +413,7 @@ MODULE_DEVICE_TABLE(of, rzn1_rtc_of_match);
 
 static struct platform_driver rzn1_rtc_driver = {
 	.probe = rzn1_rtc_probe,
-	.remove_new = rzn1_rtc_remove,
+	.remove = rzn1_rtc_remove,
 	.driver = {
 		.name	= "rzn1-rtc",
 		.of_match_table = rzn1_rtc_of_match,
drivers/rtc/rtc-s3c.c +1 -1
index 282238818f63b..c0ac3bdb2f427 100644
@@ -597,7 +597,7 @@ MODULE_DEVICE_TABLE(of, s3c_rtc_dt_match);
 
 static struct platform_driver s3c_rtc_driver = {
 	.probe		= s3c_rtc_probe,
-	.remove_new	= s3c_rtc_remove,
+	.remove		= s3c_rtc_remove,
 	.driver		= {
 		.name	= "s3c-rtc",
 		.pm	= &s3c_rtc_pm_ops,
drivers/rtc/rtc-sa1100.c +1 -1
index 0b2cfa8ca05bf..13799b1abca1a 100644
@@ -341,7 +341,7 @@ MODULE_DEVICE_TABLE(of, sa1100_rtc_dt_ids);
 
 static struct platform_driver sa1100_rtc_driver = {
 	.probe		= sa1100_rtc_probe,
-	.remove_new	= sa1100_rtc_remove,
+	.remove		= sa1100_rtc_remove,
 	.driver		= {
 		.name	= "sa1100-rtc",
 		.pm	= &sa1100_rtc_pm_ops,
drivers/rtc/rtc-sh.c +1 -1
index e66c9c6fd3724..fdda458a97582 100644
@@ -684,7 +684,7 @@ static struct platform_driver sh_rtc_platform_driver __refdata = {
 		.pm	= &sh_rtc_pm_ops,
 		.of_match_table = sh_rtc_of_match,
 	},
-	.remove_new	= __exit_p(sh_rtc_remove),
+	.remove		= __exit_p(sh_rtc_remove),
 };
 
 module_platform_driver_probe(sh_rtc_platform_driver, sh_rtc_probe);
drivers/rtc/rtc-spear.c +1 -1
index 14b84d297f4b5..935ef66cd8ede 100644
@@ -476,7 +476,7 @@ MODULE_DEVICE_TABLE(of, spear_rtc_id_table);
 
 static struct platform_driver spear_rtc_driver = {
 	.probe = spear_rtc_probe,
-	.remove_new = spear_rtc_remove,
+	.remove = spear_rtc_remove,
 	.shutdown = spear_rtc_shutdown,
 	.driver = {
 		.name = "rtc-spear",
drivers/rtc/rtc-stm32.c +1 -1
index 3e4f2ee22b0bc..9f1a019ec8afa 100644
@@ -1287,7 +1287,7 @@ static const struct dev_pm_ops stm32_rtc_pm_ops = {
 
 static struct platform_driver stm32_rtc_driver = {
 	.probe		= stm32_rtc_probe,
-	.remove_new	= stm32_rtc_remove,
+	.remove		= stm32_rtc_remove,
 	.driver		= {
 		.name	= DRIVER_NAME,
 		.pm	= &stm32_rtc_pm_ops,
drivers/rtc/rtc-stmp3xxx.c +1 -1
index 7566d0a44af82..7afcd14aeee56 100644
@@ -403,7 +403,7 @@ MODULE_DEVICE_TABLE(of, rtc_dt_ids);
 
 static struct platform_driver stmp3xxx_rtcdrv = {
 	.probe		= stmp3xxx_rtc_probe,
-	.remove_new	= stmp3xxx_rtc_remove,
+	.remove		= stmp3xxx_rtc_remove,
 	.driver		= {
 		.name	= "stmp3xxx-rtc",
 		.pm	= &stmp3xxx_rtc_pm_ops,
drivers/rtc/rtc-sunplus.c +1 -1
index 20c7e97c2fc81..9b1ce0e8ba27e 100644
@@ -344,7 +344,7 @@ static SIMPLE_DEV_PM_OPS(sp_rtc_pm_ops, sp_rtc_suspend, sp_rtc_resume);
 
 static struct platform_driver sp_rtc_driver = {
 	.probe   = sp_rtc_probe,
-	.remove_new = sp_rtc_remove,
+	.remove = sp_rtc_remove,
 	.driver  = {
 		.name	= "sp7021-rtc",
 		.of_match_table = sp_rtc_of_match,
drivers/rtc/rtc-tegra.c +1 -1
index 441e0a66b215b..79a3102c83549 100644
@@ -399,7 +399,7 @@ static void tegra_rtc_shutdown(struct platform_device *pdev)
 
 static struct platform_driver tegra_rtc_driver = {
 	.probe = tegra_rtc_probe,
-	.remove_new = tegra_rtc_remove,
+	.remove = tegra_rtc_remove,
 	.shutdown = tegra_rtc_shutdown,
 	.driver = {
 		.name = "tegra_rtc",
drivers/rtc/rtc-tps6586x.c +1 -1
index 20faf08c254cc..e796729fc817c 100644
@@ -317,7 +317,7 @@ static struct platform_driver tps6586x_rtc_driver = {
 		.pm	= &tps6586x_pm_ops,
 	},
 	.probe	= tps6586x_rtc_probe,
-	.remove_new = tps6586x_rtc_remove,
+	.remove = tps6586x_rtc_remove,
 };
 module_platform_driver(tps6586x_rtc_driver);
 
drivers/rtc/rtc-twl.c +1 -1
index 4e24c12004f16..794429182b348 100644
@@ -673,7 +673,7 @@ MODULE_DEVICE_TABLE(of, twl_rtc_of_match);
 
 static struct platform_driver twl4030rtc_driver = {
 	.probe		= twl_rtc_probe,
-	.remove_new	= twl_rtc_remove,
+	.remove		= twl_rtc_remove,
 	.shutdown	= twl_rtc_shutdown,
 	.driver		= {
 		.name		= "twl_rtc",
drivers/rtc/rtc-vt8500.c +1 -1
index ccfa76513a2ca..c8b568498016f 100644
@@ -251,7 +251,7 @@ MODULE_DEVICE_TABLE(of, wmt_dt_ids);
 
 static struct platform_driver vt8500_rtc_driver = {
 	.probe		= vt8500_rtc_probe,
-	.remove_new	= vt8500_rtc_remove,
+	.remove		= vt8500_rtc_remove,
 	.driver		= {
 		.name	= "vt8500-rtc",
 		.of_match_table = wmt_dt_ids,
drivers/rtc/rtc-wm8350.c +1 -1
index 3c773cff2b393..6797eb4d2e493 100644
@@ -459,7 +459,7 @@ static SIMPLE_DEV_PM_OPS(wm8350_rtc_pm_ops, wm8350_rtc_suspend,
 
 static struct platform_driver wm8350_rtc_driver = {
 	.probe = wm8350_rtc_probe,
-	.remove_new = wm8350_rtc_remove,
+	.remove = wm8350_rtc_remove,
 	.driver = {
 		.name = "wm8350-rtc",
 		.pm = &wm8350_rtc_pm_ops,
drivers/rtc/rtc-xgene.c +1 -1
index f78efc9760c0e..0813ea1a03c27 100644
@@ -263,7 +263,7 @@ MODULE_DEVICE_TABLE(of, xgene_rtc_of_match);
 
 static struct platform_driver xgene_rtc_driver = {
 	.probe		= xgene_rtc_probe,
-	.remove_new	= xgene_rtc_remove,
+	.remove		= xgene_rtc_remove,
 	.driver		= {
 		.name	= "xgene-rtc",
 		.pm = &xgene_rtc_pm_ops,
drivers/rtc/rtc-zynqmp.c +1 -1
index e77fb1433401d..3239afab41461 100644
@@ -384,7 +384,7 @@ MODULE_DEVICE_TABLE(of, xlnx_rtc_of_match);
 
 static struct platform_driver xlnx_rtc_driver = {
 	.probe		= xlnx_rtc_probe,
-	.remove_new	= xlnx_rtc_remove,
+	.remove		= xlnx_rtc_remove,
 	.driver		= {
 		.name	= KBUILD_MODNAME,
 		.pm	= &xlnx_rtc_pm_ops,
Signature · 1 line
2.53.0
author maintainer
#61 lore raw

PATCH 61/497 rtc: ac100: Fix clock provider use-after-free on probe failure

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Aamir Ahmed <[email protected]>

[ Upstream commit fcf0b58e976e83adf246b014518e49c662b96f5e ]

ac100_rtc_register_clks() registers the RTC-32k clock with clk_hw_register_fixed_rate() and the clock provider with of_clk_add_hw_provider(). Neither is device managed, and both are released only from ac100_rtc_remove(). The driver core does not call remove() when probe() fails: really_probe() reaches probe_failed below the device_remove() call and goes straight to releasing the device's managed resources.

ac100_rtc_probe() ends with

	return devm_rtc_register_device(chip->rtc);

so if that fails after the clocks have been registered, the provider is left on the global of_clk_providers list holding chip->clk_data, which was allocated with devm_kzalloc() and is freed while probe() unwinds. A later lookup on this device tree node then reads freed memory in of_clk_hw_onecell_get(). Consumers that do exactly that exist in tree:
the wifi power sequence nodes on sun8i-a83t-bananapi-m3 and sun8i-a83t-cubietruck-plus take <&ac100_rtc 1>, and the sun9i-a80 boards route osc32k through <&ac100_rtc 0>. The window is narrow, as devm_rtc_register_device() can only fail with -ENOMEM here, but the provider is left dangling whenever it does.

The RTC-32k clock is leaked on the same path. Since clk_core_lookup() searches a global list that is not scoped per device, __clk_register() rejects the duplicate name with -EEXIST, so the leak also makes a later probe of the same device fail.

The error path that returns -EINVAL when the ADDA 4M parent clock cannot be found leaks the RTC-32k clock in the same way. No provider has been registered at that point, so that one is a leak rather than a use-after-free.

Register both with devm_clk_hw_register_fixed_rate() and devm_of_clk_add_hw_provider() so that they are released whenever the device goes away, on a failed probe as well as on unbind. Devres releases in reverse order of acquisition, so the provider is removed before chip->clk_data is freed, and the clkout children are now unregistered before their parent rather than after it. ac100_rtc_unregister_clks() and the remove callback then have nothing left to do and are removed.

---
 drivers/rtc/rtc-ac100.c | 36 +++++++-----------------------------
 1 file changed, 7 insertions(+), 29 deletions(-)
drivers/rtc/rtc-ac100.c +7 -29
index 9917cd67f4c6d..ef6a9368c63f2 100644
@@ -318,10 +318,10 @@ static int ac100_rtc_register_clks(struct ac100_rtc_dev *chip)
 
 	chip->clk_data->num = AC100_CLKOUT_NUM;
 
-	chip->rtc_32k_clk = clk_hw_register_fixed_rate(chip->dev,
-						       AC100_RTC_32K_NAME,
-						       NULL, 0,
-						       AC100_RTC_32K_RATE);
+	chip->rtc_32k_clk = devm_clk_hw_register_fixed_rate(chip->dev,
+							    AC100_RTC_32K_NAME,
+							    NULL, 0,
+							    AC100_RTC_32K_RATE);
 	if (IS_ERR(chip->rtc_32k_clk)) {
 		ret = PTR_ERR(chip->rtc_32k_clk);
 		dev_err(chip->dev, "Failed to register RTC-32k clock: %d\n",
@@ -355,28 +355,14 @@ static int ac100_rtc_register_clks(struct ac100_rtc_dev *chip)
 		if (ret) {
 			dev_err(chip->dev, "Failed to register clk '%s': %d\n",
 				init.name, ret);
-			goto err_unregister_rtc_32k;
+			return ret;
 		}
 
 		chip->clk_data->hws[i] = &clk->hw;
 	}
 
-	ret = of_clk_add_hw_provider(np, of_clk_hw_onecell_get, chip->clk_data);
-	if (ret)
-		goto err_unregister_rtc_32k;
-
-	return 0;
-
-err_unregister_rtc_32k:
-	clk_unregister_fixed_rate(chip->rtc_32k_clk->clk);
-
-	return ret;
-}
-
-static void ac100_rtc_unregister_clks(struct ac100_rtc_dev *chip)
-{
-	of_clk_del_provider(chip->dev->of_node);
-	clk_unregister_fixed_rate(chip->rtc_32k_clk->clk);
+	return devm_of_clk_add_hw_provider(chip->dev, of_clk_hw_onecell_get,
+					   chip->clk_data);
 }
 
 /*
@@ -614,13 +600,6 @@ static int ac100_rtc_probe(struct platform_device *pdev)
 	return devm_rtc_register_device(chip->rtc);
 }
 
-static void ac100_rtc_remove(struct platform_device *pdev)
-{
-	struct ac100_rtc_dev *chip = platform_get_drvdata(pdev);
-
-	ac100_rtc_unregister_clks(chip);
-}
-
 static const struct of_device_id ac100_rtc_match[] = {
 	{ .compatible = "x-powers,ac100-rtc" },
 	{ },
@@ -629,7 +608,6 @@ MODULE_DEVICE_TABLE(of, ac100_rtc_match);
 
 static struct platform_driver ac100_rtc_driver = {
 	.probe		= ac100_rtc_probe,
-	.remove		= ac100_rtc_remove,
 	.driver		= {
 		.name		= "ac100-rtc",
 		.of_match_table	= of_match_ptr(ac100_rtc_match),
Signature · 1 line
2.53.0
author maintainer
#62 lore raw

PATCH 62/497 rtc: mpfs: fix unchecked devm_clk_get() error pointer in probe()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Manush Prajwal <[email protected]>

[ Upstream commit ac41b05d15db3134e839148290d67415ee0bdb58 ]

devm_clk_get(&pdev->dev, "rtcref")'s return value was passed straight into clk_get_rate() without checking it for an error first, unlike the "rtc" clock a few lines above which is correctly checked with IS_ERR(). clk_get_rate() only guards against a NULL clk, not an error pointer:

	if (!clk)
		return 0;
	...
	rate = clk_core_get_rate_recalc(clk->core);

so if devm_clk_get() ever returns an error pointer here (for example ERR_PTR(-EPROBE_DEFER), which is the normal, expected outcome if the clkcfg clock-provider this RTC depends on has not registered its clocks yet by the time this driver probes), clk_get_rate() dereferences that error pointer instead of returning 0, crashing instead of letting probe defer.

Capture the clock in the existing 'clk' local and check it with IS_ERR() before calling clk_get_rate(), matching the handling already used for the "rtc" clock in this same function.

---
 drivers/rtc/rtc-mpfs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/rtc/rtc-mpfs.c +5 -1
index f4f1b845e23d6..119f37386eb5c 100644
@@ -256,8 +256,12 @@ static int mpfs_rtc_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	clk = devm_clk_get(&pdev->dev, "rtcref");
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+
 	/* prescaler hardware adds 1 to reg value */
-	prescaler = clk_get_rate(devm_clk_get(&pdev->dev, "rtcref")) - 1;
+	prescaler = clk_get_rate(clk) - 1;
 	if (prescaler > MAX_PRESCALER_COUNT) {
 		dev_dbg(&pdev->dev, "invalid prescaler %lu\n", prescaler);
 		return -EINVAL;
Signature · 1 line
2.53.0
author maintainer
#63 lore raw

PATCH 63/497 wifi: cfg80211: preserve hidden-group beacon IE ownership

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Zhao Li <[email protected]>

[ Upstream commit cc45f313d85533d647ce619326302aad6f797c14 ]

A hidden-group probe-response entry borrows its beacon IEs from the group's beacon entry. cfg80211_update_assoc_bss_entry() can pass such an entry to cfg80211_update_known_bss() when merging scan entries after a channel switch.

Copying the borrowed beacon_ies into the associated entry gives the same allocation two owners. Releasing the group's beacon entry can then leave the associated entry pointing to freed IEs, which are freed again when that entry is released.

Skip beacon IE replacement when the source entry belongs to a hidden group. Preserve probe-response processing, the subsequent metadata updates, and the existing rejection path for conflicting hidden beacon updates.

Fixes 0afd425b1b64 ("cfg80211: fix duplicated scan entries after channel switch")
Assisted-by Codex:gpt-6-astra
---
 net/wireless/scan.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
net/wireless/scan.c +12 -10
index a7d704d0a282a..6fab9abb47b2b 100644
@@ -1874,20 +1874,22 @@ cfg80211_update_known_bss(struct cfg80211_registered_device *rdev,
 			return false;
 		}
 
-		old = rcu_access_pointer(known->pub.beacon_ies);
+		if (!new->pub.hidden_beacon_bss) {
+			old = rcu_access_pointer(known->pub.beacon_ies);
 
-		rcu_assign_pointer(known->pub.beacon_ies, new->pub.beacon_ies);
+			rcu_assign_pointer(known->pub.beacon_ies, new->pub.beacon_ies);
 
-		/* Override IEs if they were from a beacon before */
-		if (old == rcu_access_pointer(known->pub.ies))
-			rcu_assign_pointer(known->pub.ies, new->pub.beacon_ies);
+			/* Override IEs if they were from a beacon before */
+			if (old == rcu_access_pointer(known->pub.ies))
+				rcu_assign_pointer(known->pub.ies, new->pub.beacon_ies);
 
-		cfg80211_update_hidden_bsses(known,
-					     rcu_access_pointer(new->pub.beacon_ies),
-					     old);
+			cfg80211_update_hidden_bsses(known,
+						     rcu_access_pointer(new->pub.beacon_ies),
+						     old);
 
-		if (old)
-			kfree_rcu((struct cfg80211_bss_ies *)old, rcu_head);
+			if (old)
+				kfree_rcu((struct cfg80211_bss_ies *)old, rcu_head);
+		}
 	}
 
 	known->pub.beacon_interval = new->pub.beacon_interval;
Signature · 1 line
2.53.0
author maintainer
#64 lore raw

PATCH 64/497 wifi: mac80211: Add multicast to unicast support for 802.3 path

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Tamizh Chelvam Raja <[email protected]>

[ Upstream commit 2307b36ce34fd2166509ea2aeef0de5768ed03b7 ]

mac80211 already supports multicast-to-unicast conversion for native 802.11 TX paths, but this handling is missing for the 802.3 transmit path. Due to that the packet never converted to unicast and directly pass it to 802.11 Tx path by checking the destination address as multicast.

Extend ieee80211_subif_start_xmit_8023() to honor the multicast_to_unicast setting by cloning and converting multicast Ethernet frames into per-station unicast transmissions, following the same behavior of the native 802.11 TX path and allow it to take 802.3 path.

Stable-dep-of: 7f93ca31f7fd ("wifi: mac80211: prevent AP VLAN tx from other interfaces")

---
 net/mac80211/tx.c | 33 ++++++++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 7 deletions(-)
net/mac80211/tx.c +26 -7
index 228c717ea314b..10bf11aba2e02 100644
@@ -4735,19 +4735,14 @@ static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata,
 	kfree_skb(skb);
 }
 
-netdev_tx_t ieee80211_subif_start_xmit_8023(struct sk_buff *skb,
-					    struct net_device *dev)
+static void __ieee80211_subif_start_xmit_8023(struct sk_buff *skb,
+					      struct net_device *dev)
 {
 	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 	struct ethhdr *ehdr = (struct ethhdr *)skb->data;
 	struct ieee80211_key *key;
 	struct sta_info *sta;
 
-	if (unlikely(!ieee80211_sdata_running(sdata) || skb->len < ETH_HLEN)) {
-		kfree_skb(skb);
-		return NETDEV_TX_OK;
-	}
-
 	rcu_read_lock();
 
 	if (ieee80211_lookup_ra_sta(sdata, skb, &sta)) {
@@ -4776,6 +4771,30 @@ netdev_tx_t ieee80211_subif_start_xmit_8023(struct sk_buff *skb,
 	ieee80211_subif_start_xmit(skb, dev);
 out:
 	rcu_read_unlock();
+}
+
+netdev_tx_t ieee80211_subif_start_xmit_8023(struct sk_buff *skb,
+					    struct net_device *dev)
+{
+	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+	struct ethhdr *ehdr = (struct ethhdr *)skb->data;
+
+	if (unlikely(!ieee80211_sdata_running(sdata) || skb->len < ETH_HLEN)) {
+		kfree_skb(skb);
+		return NETDEV_TX_OK;
+	}
+
+	if (unlikely(is_multicast_ether_addr(ehdr->h_dest) &&
+		     ieee80211_multicast_to_unicast(skb, dev))) {
+		struct sk_buff_head queue;
+
+		__skb_queue_head_init(&queue);
+		ieee80211_convert_to_unicast(skb, dev, &queue);
+		while ((skb = __skb_dequeue(&queue)))
+			__ieee80211_subif_start_xmit_8023(skb, dev);
+	} else {
+		__ieee80211_subif_start_xmit_8023(skb, dev);
+	}
 
 	return NETDEV_TX_OK;
 }
Signature · 1 line
2.53.0
author maintainer
#65 lore raw

PATCH 65/497 wifi: mac80211: Add 802.3 multicast encapsulation offload support

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Tamizh Chelvam Raja <[email protected]>

[ Upstream commit 4cc0cc0b297c17c2b106d6892bd13d9c32fe66ce ]

mac80211 converts 802.3 multicast packets to 802.11 format before driver TX, even when Ethernet encapsulation offload is enabled. This prevents drivers that support multicast Ethernet encapsulation offload from receiving frames in native 802.3 format.

Introduce the IEEE80211_OFFLOAD_ENCAP_MCAST flag to bypass the 802.11 encapsulation step and pass the multicast packet to the driver in 802.3 format. Drivers that support multicast Ethernet encapsulation offload can advertise this flag.

Disable multicast encapsulation offload in MLO case for drivers not advertising MLO_MCAST_MULTI_LINK_TX support for AP mode and for 3-address AP_VLAN multicast packets.

Stable-dep-of: 7f93ca31f7fd ("wifi: mac80211: prevent AP VLAN tx from other interfaces")

---
 include/net/mac80211.h |  4 ++++
 net/mac80211/tx.c      | 51 ++++++++++++++++++++++++++++++++++++------
 2 files changed, 48 insertions(+), 7 deletions(-)
include/net/mac80211.h +4 -0
index 41ae682015fc0..ecbba77cca853 100644
@@ -1865,12 +1865,16 @@ enum ieee80211_vif_flags {
  * @IEEE80211_OFFLOAD_DECAP_ENABLED: rx encapsulation offload is enabled
  *	The driver supports passing received 802.11 frames as 802.3 frames to
  *	mac80211.
+ * @IEEE80211_OFFLOAD_ENCAP_MCAST: tx multicast encapsulation offload is enabled
+ *	The driver supports sending multicast frames passed as 802.3 frames
+ *	by mac80211.
  */
 
 enum ieee80211_offload_flags {
 	IEEE80211_OFFLOAD_ENCAP_ENABLED		= BIT(0),
 	IEEE80211_OFFLOAD_ENCAP_4ADDR		= BIT(1),
 	IEEE80211_OFFLOAD_DECAP_ENABLED		= BIT(2),
+	IEEE80211_OFFLOAD_ENCAP_MCAST		= BIT(3),
 };
 
 /**
net/mac80211/tx.c +44 -7

69 lines not on this page · raw message

Signature · 1 line
2.53.0
author maintainer
#66 lore raw

PATCH 66/497 wifi: mac80211: prevent AP VLAN tx from other interfaces

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Felix Fietkau <[email protected]>

[ Upstream commit 7f93ca31f7fd9b42e7d692f59514436d448ac908 ]

Since the station lookup was factored out of ieee80211_build_hdr(), ieee80211_lookup_ra_sta() uses sta_info_get_bss() for all AP and AP VLAN frames, not only for control port frames. A unicast frame sent on one interface thus matches a station of a different VLAN of the same BSS and is transmitted to it.

Only match stations of the interface the frame is sent on, except for control port frames, since those may be sent for VLAN stations directly on the BSS interface.

Fixes 97ffe75791b3 ("mac80211: factor out station lookup from ieee80211_build_hdr()")
---
 net/mac80211/ieee80211_i.h |  2 +-
 net/mac80211/tx.c          | 24 +++++++++++++++---------
 2 files changed, 16 insertions(+), 10 deletions(-)
net/mac80211/ieee80211_i.h +1 -1
index 3486f3d55c42e..c0e7db6fbec38 100644
@@ -2325,7 +2325,7 @@ void __ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
 /* sta_out needs to be checked for ERR_PTR() before using */
 int ieee80211_lookup_ra_sta(struct ieee80211_sub_if_data *sdata,
 			    struct sk_buff *skb,
-			    struct sta_info **sta_out);
+			    struct sta_info **sta_out, bool bss);
 
 static inline void
 ieee80211_tx_skb_tid_band(struct ieee80211_sub_if_data *sdata,
net/mac80211/tx.c +15 -9
index 9fa30980a3802..e07bf5ba9b7a7 100644
@@ -2501,7 +2501,7 @@ static inline bool ieee80211_is_tdls_setup(struct sk_buff *skb)
 
 int ieee80211_lookup_ra_sta(struct ieee80211_sub_if_data *sdata,
 			    struct sk_buff *skb,
-			    struct sta_info **sta_out)
+			    struct sta_info **sta_out, bool bss)
 {
 	struct sta_info *sta;
 
@@ -2522,7 +2522,10 @@ int ieee80211_lookup_ra_sta(struct ieee80211_sub_if_data *sdata,
 			*sta_out = ERR_PTR(-ENOENT);
 			return 0;
 		}
-		sta = sta_info_get_bss(sdata, skb->data);
+		if (bss)
+			sta = sta_info_get_bss(sdata, skb->data);
+		else
+			sta = sta_info_get(sdata, skb->data);
 		break;
 #ifdef CONFIG_MAC80211_MESH
 	case NL80211_IFTYPE_MESH_POINT:
@@ -4340,7 +4343,8 @@ void __ieee80211_subif_start_xmit(struct sk_buff *skb,
 	    ieee80211_mesh_xmit_fast(sdata, skb, ctrl_flags))
 		goto out;
 
-	if (ieee80211_lookup_ra_sta(sdata, skb, &sta))
+	if (ieee80211_lookup_ra_sta(sdata, skb, &sta,
+				    skb->protocol == sdata->control_port_protocol))
 		goto out_free;
 
 	if (IS_ERR(sta))
@@ -4766,7 +4770,10 @@ static void __ieee80211_subif_start_xmit_8023(struct sk_buff *skb,
 
 	rcu_read_lock();
 
-	if (ieee80211_lookup_ra_sta(sdata, skb, &sta)) {
+	if (unlikely(sdata->control_port_protocol == ehdr->h_proto))
+		goto skip_offload;
+
+	if (ieee80211_lookup_ra_sta(sdata, skb, &sta, false)) {
 		kfree_skb(skb);
 		goto out;
 	}
@@ -4787,8 +4794,7 @@ static void __ieee80211_subif_start_xmit_8023(struct sk_buff *skb,
 		link = &sdata->deflink;
 		key = rcu_dereference(link->default_multicast_key);
 	} else if (unlikely(IS_ERR_OR_NULL(sta) || !sta->uploaded ||
-		   !test_sta_flag(sta, WLAN_STA_AUTHORIZED) ||
-	    sdata->control_port_protocol == ehdr->h_proto)) {
+		   !test_sta_flag(sta, WLAN_STA_AUTHORIZED))) {
 		goto skip_offload;
 	} else {
 		key = rcu_dereference(sta->ptk[sta->ptk_idx]);
@@ -4849,7 +4855,7 @@ ieee80211_build_data_template(struct ieee80211_sub_if_data *sdata,
 
 	rcu_read_lock();
 
-	if (ieee80211_lookup_ra_sta(sdata, skb, &sta)) {
+	if (ieee80211_lookup_ra_sta(sdata, skb, &sta, false)) {
 		kfree_skb(skb);
 		skb = ERR_PTR(-EINVAL);
 		goto out;
@@ -4920,7 +4926,7 @@ static bool ieee80211_tx_pending_skb(struct ieee80211_local *local,
 		}
 		result = ieee80211_tx(sdata, NULL, skb, true);
 	} else if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) {
-		if (ieee80211_lookup_ra_sta(sdata, skb, &sta)) {
+		if (ieee80211_lookup_ra_sta(sdata, skb, &sta, true)) {
 			dev_kfree_skb(skb);
 			return true;
 		}
@@ -6327,7 +6333,7 @@ int ieee80211_tx_control_port(struct wiphy *wiphy, struct net_device *dev,
 	 * AF_PACKET
 	 */
 	rcu_read_lock();
-	err = ieee80211_lookup_ra_sta(sdata, skb, &sta);
+	err = ieee80211_lookup_ra_sta(sdata, skb, &sta, true);
 	if (err) {
 		dev_kfree_skb(skb);
 		rcu_read_unlock();
Signature · 1 line
2.53.0
author maintainer
#67 lore raw

PATCH 67/497 ASoC: codecs: rt286: Revert delay value for jack setup

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Cezary Rojewski <[email protected]>

[ Upstream commit d30fba93ebfc11e4604a7fcc73fdf28684191dde ]

Fat fingered the change when reorganizing the jack-detect initialization. Equivalent changes for rt274 and rt298:

Commit a43b4394bb35 ("ASoC: codecs: rt274: Always init jack_detect_work") Commit 1eb73102da28 ("ASoC: codecs: rt298: Reorganize jack detect handling")

carry no update to the delay value.

Quoted 1 line

From user perspective, no difference has been observed between 1250 and

50 values on Intel's SkyLake, KabyLake and AmberLake configurations.

Fixes 3082afe097cc ("ASoC: codecs: rt286: Reorganize jack detect handling")
---
 sound/soc/codecs/rt286.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/rt286.c +1 -1
index d0f533120c330..1af00b7f8415d 100644
@@ -951,7 +951,7 @@ static int rt286_probe(struct snd_soc_component *component)
 
 	if (rt286->i2c->irq)
 		schedule_delayed_work(&rt286->jack_detect_work,
-				      msecs_to_jiffies(50));
+				      msecs_to_jiffies(1250));
 	return 0;
 }
 
Signature · 1 line
2.53.0
author maintainer
#68 lore raw

PATCH 68/497 ASoC: codecs: rt274: Fix format setting for 44100 rate

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Cezary Rojewski <[email protected]>

[ Upstream commit 6eda8938a790f65bd24fcfaae7b40ad4613fb7a2 ]

As per specification, Sample Base Rate (bit 14) shall be set to 1 for 44.1 kHz.

---
 sound/soc/codecs/rt274.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/codecs/rt274.c +3 -1
index bd61a257d7b58..fd3fcacbb84bb 100644
@@ -619,9 +619,11 @@ static int rt274_hw_params(struct snd_pcm_substream *substream,
 	unsigned int val = 0;
 	int d_len_code = 0, c_len_code = 0;
 
+	/* bit 14 Sample Rate Base, 0: 48kHz 1: 44.1kHz */
 	switch (params_rate(params)) {
-	/* bit 14 0:48K 1:44.1K */
 	case 44100:
+		val |= BIT(14);
+		break;
 	case 48000:
 		break;
 	default:
Signature · 1 line
2.53.0
author maintainer
#69 lore raw

PATCH 69/497 Bluetooth: hci_core: free the HCI ID if naming fails

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Sang-Hoon Choi <[email protected]>

[ Upstream commit d1ac915fb4184faad1b62148be50f317de7c24b5 ]

hci_register_dev() allocates an ID before calling dev_set_name(). If naming fails, it returns without releasing that ID. The device has not been registered and hdev->id has not been assigned, so the normal unregister path cannot release it.

Free the allocated ID before returning the naming error.

Fixes dcda165706b9 ("Bluetooth: hci_core: Fix build warnings")
Assisted-by LLM
---
 net/bluetooth/hci_core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/bluetooth/hci_core.c +3 -1
index a85c77ed4a13e..9f152db1e627d 100644
@@ -2615,8 +2615,10 @@ int hci_register_dev(struct hci_dev *hdev)
 		return id;
 
 	error = dev_set_name(&hdev->dev, "hci%u", id);
-	if (error)
+	if (error) {
+		ida_free(&hci_index_ida, id);
 		return error;
+	}
 
 	hdev->name = dev_name(&hdev->dev);
 	hdev->id = id;
Signature · 1 line
2.53.0
author maintainer
#70 lore raw

PATCH 70/497 Bluetooth: btintel: validate DDC record lengths

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Sai Teja Aluvala <[email protected]>

[ Upstream commit c9c15d4d8956df8c564f7c210e4dc5b9b820d97a ]

Parse DDC record lengths in unsigned storage so 0xFF does not wrap. Reject records smaller than the mandatory three-byte header, records exceeding U8_MAX, and records exceeding remaining firmware bytes before issuing Intel_Write_DDC.

This issue was reported by Claude Mythos.

Fixes 145f2368c5fd ("Bluetooth: btintel: Add Device Configuration support")
---
 drivers/bluetooth/btintel.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/bluetooth/btintel.c +10 -2
index daec8a65c4915..d60756a6968c7 100644
@@ -387,8 +387,16 @@ int btintel_load_ddc_config(struct hci_dev *hdev, const char *ddc_name)
 	/* DDC file contains one or more DDC structure which has
 	 * Length (1 byte), DDC ID (2 bytes), and DDC value (Length - 2).
 	 */
-	while (fw->size > fw_ptr - fw->data) {
-		u8 cmd_plen = fw_ptr[0] + sizeof(u8);
+	while (fw->size > (size_t)(fw_ptr - fw->data)) {
+		size_t remaining = fw->size - (fw_ptr - fw->data);
+		unsigned int cmd_plen = fw_ptr[0] + 1U;
+
+		if (cmd_plen < 3 || cmd_plen > U8_MAX || cmd_plen > remaining) {
+			bt_dev_err(hdev, "Malformed DDC record (plen=%u, remaining=%zu)",
+				   cmd_plen, remaining);
+			release_firmware(fw);
+			return -EINVAL;
+		}
 
 		skb = __hci_cmd_sync(hdev, 0xfc8b, cmd_plen, fw_ptr,
 				     HCI_INIT_TIMEOUT);
Signature · 1 line
2.53.0
author maintainer
#71 lore raw

PATCH 71/497 net/mctp: publish the mctp_dev only after it is initialised

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Binbin Deng <[email protected]>

[ Upstream commit aadf655e8ea9a8ffa24bb8d69f504572e8d18181 ]

mctp_add_dev() links the new mctp_dev into dev->mctp_ptr before mdev->dev is assigned, so a reader that picks the device up in that window dereferences a net_device pointer that is still NULL:

KASAN: null-ptr-deref in range [0x00000000000000b0-0x00000000000000b7]
Call Trace:
 <TASK>
 ? __pfx_mctp_sendmsg (./include/linux/sockptr.h:49)
 ? __pfx_mctp_dst_output (net/mctp/route.c:41)
 ? selinux_socket_sendmsg (security/selinux/hooks.c:5278)
 ____sys_sendmsg (net/socket.c:775 (discriminator 1) net/socket.c:790
 (discriminator 1) net/socket.c:2684 (discriminator 1))
 ? __pfx_____sys_sendmsg (net/socket.c:1131)
 ? __pfx_copy_msghdr_from_user (net/socket.c:2590)
 ? update_cfs_rq_load_avg (kernel/sched/fair.c:5478)
 ___sys_sendmsg (net/socket.c:2738)
 ? __pfx____sys_sendmsg (net/socket.c:2625)
 ? perf_event_task_tick (./include/linux/rcupdate.h:838)
 ? sched_tick (kernel/sched/core.c:5818)
 ? clockevents_program_event (kernel/time/clockevents.c:372)
 ? fdget (./include/linux/rcupdate.h:873 fs/file.c:1100)
 __sys_sendmsg (net/socket.c:2770)
 ? __pfx___sys_sendmsg (net/socket.c:2751)
 do_syscall_64 (arch/x86/entry/syscall_64.c:63)
 entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
 </TASK>

Fix by publishing only once the object is fully initialised:
__mctp_dev_get() runs under rcu_read_lock() only and hands this object to readers as soon as mctp_ptr is assigned, so they must never observe mdev->dev == NULL.

Fixes 583be982d934 ("mctp: Add device handling and netlink interface")
---
 net/mctp/device.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
net/mctp/device.c +3 -3
index 67576cb2728ec..ee430b73b0976 100644
@@ -344,13 +344,13 @@ static struct mctp_dev *mctp_add_dev(struct net_device *dev)
 
 	mdev->net = mctp_default_net(dev_net(dev));
 
-	/* associate to net_device */
 	refcount_set(&mdev->refs, 1);
-	rcu_assign_pointer(dev->mctp_ptr, mdev);
-
 	dev_hold(dev);
 	mdev->dev = dev;
 
+	/* Associate to net_device, publish the mdev. */
+	rcu_assign_pointer(dev->mctp_ptr, mdev);
+
 	return mdev;
 }
 
Signature · 1 line
2.53.0
author maintainer
#72 lore raw

PATCH 72/497 net/sched: cls_api: reclaim an empty proto on the error path

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jamal Hadi Salim <[email protected]>

[ Upstream commit 0bb8eab29b55045281a4963d4557f2776cdf8cfa ]

Two racing tc filter add requests on the same chain/prio of an unlocked classifier both run change() on the shared proto and both can fail: the winner's tcf_chain_tp_delete_empty() attempt gives up because the loser's handle is still in the idr, and the loser's error path drops only its own reference without a second reclamation attempt. The empty proto stays linked in the chain, holding the chain reference, a block reference and the classifier module reference until the chain or block is torn down.

Reclaim the proto on the error path of any failed request that holds a proto reference. The reclamation is emptiness-gated:
tcf_chain_tp_delete_empty() unlinks the proto only when delete_empty() admits it is empty, so a live shared proto is never unlinked. A proto the request created is reclaimed unconditionally - it is the only owner, so marking it for deletion is safe even without a delete_empty callback. Classifiers without one (the check marks the proto unconditionally) are rtnl-serialized, so the raced window this guard closes cannot arise for them.

This is a follow-up to commit d4e359b3608a ("net/sched: cls_api: fix teardown of an adopted proto on insert-race loss"), which stopped the loser of the insert race from unlinking the winner's live proto but left the empty-proto residual in place.

Conditions to recreate:
- CONFIG_NET_CLS_FLOWER=y; veth pair
- tc qdisc add dev veth0 ingress
- two concurrent tc filter add dev veth0 ingress protocol ip pref 1 flower skip_sw ... action drop (both fail in fl_hw_replace_filter after publishing their handle in the idr); repeat in a loop
- an empty flower tp stays linked after both requests fail; visible as a bare filter protocol ip pref 1 flower chain 0 header in tc filter show with no filter entries
- CAP_NET_ADMIN (namespace-local via unshare -Urn suffices)

---
 net/sched/cls_api.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
net/sched/cls_api.c +14 -1
index 4754139691382..748be0e76a49d 100644
@@ -2458,7 +2458,20 @@ static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
 	}
 
 errout:
-	if (err && tp_state == TP_CREATED)
+	if (err && !IS_ERR_OR_NULL(tp) &&
+	    (tp_state == TP_CREATED || tp->ops->delete_empty))
+		/*
+		 * The request is dropping its reference to tp. If it was
+		 * the last user (the idr is empty now), reclaim the proto.
+		 * A tp this request created is reclaimed unconditionally:
+		 * it is the only owner, so marking it for deletion is
+		 * safe. Otherwise only classifiers with a delete_empty
+		 * callback are reclaimed -- the callback admits an empty
+		 * proto only, so a live shared proto is never unlinked.
+		 * Classifiers without one (deleting is set
+		 * unconditionally) are rtnl-serialized, so the raced
+		 * window this guard closes cannot arise for them.
+		 */
 		tcf_chain_tp_delete_empty(chain, tp, rtnl_held, NULL);
 errout_tp:
 	if (chain) {
Signature · 1 line
2.53.0
author maintainer
#73 lore raw

PATCH 73/497 ipv6: fix prefix route expiry in modify_prefix_route()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Qishuai Liu <[email protected]>

[ Upstream commit a7bfaba4823e3c165bb2004c74eff7c096672bc7 ]

modify_prefix_route() is given the lifetime in clock_t relative to now, but fib6_set_expires() wants an absolute jiffies value. So when a permanent address is changed to a finite valid_lft, the prefix route ends up already expired and GC removes it.

Steps to reproduce:

ip link add dummy9 type dummy
ip link set dummy9 up
ip -6 addr add 2001:db8:9::1/64 dev dummy9
ip -6 addr change 2001:db8:9::1/64 dev dummy9 valid_lft 3600 preferred_lft 3600
ip -6 route show dev dummy9 # expires is negative

Fixes 8308f3ff1753 ("net/ipv6: Add support for specifying metric of connected routes")
---
 net/ipv6/addrconf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/addrconf.c +1 -1
index fb239e8f83593..33439672b071b 100644
@@ -4873,7 +4873,7 @@ static int modify_prefix_route(struct net *net, struct inet6_ifaddr *ifp,
 			fib6_clean_expires(f6i);
 			fib6_may_remove_gc_list(net, f6i);
 		} else {
-			fib6_set_expires(f6i, expires);
+			fib6_set_expires(f6i, jiffies + clock_t_to_jiffies(expires));
 			fib6_add_gc_list(f6i);
 		}
 
Signature · 1 line
2.53.0
author maintainer
#74 lore raw

PATCH 74/497 netfilter: ipset: do not update comments from kernel-side adds

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Florian Westphal <[email protected]>

[ Upstream commit a442c8a89fb9c531f9d6ab86120c31decd778d51 ]

'Fixes' commit stopped calling ip_set_init_comment() for hash types from kernel-side-adds (xtables .. -j SET). ip_set_init_comment() says:

"The kadt functions don't use the comment extensions in any way."

But bitmap set type calls the function from kadt cb too.

While this appears to be safe (serialized via the set spinlock), it seems better to not call the init function either, least of all to keep behaviour consistent.

ip_set_list calls ip_set_init_comment() only from uadt cb, it can be kept as-is.

This was triggered by yet another LLM review, hinting that the existing rcu_dereference_protected() cannot be downgraded to only check if the nfnl mutex is held.

Fixes f30415929be8 ("netfilter: ipset: do not update comments from kernel-side hash adds")
---
 net/netfilter/ipset/ip_set_bitmap_gen.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/ipset/ip_set_bitmap_gen.h +1 -1
index e6a092cea011e..edbba3b5752cc 100644
@@ -159,7 +159,7 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext,
 
 	if (SET_WITH_COUNTER(set))
 		ip_set_init_counter(ext_counter(x, set), ext);
-	if (SET_WITH_COMMENT(set))
+	if (SET_WITH_COMMENT(set) && !ext->target)
 		ip_set_init_comment(set, ext_comment(x, set), ext);
 	if (SET_WITH_SKBINFO(set))
 		ip_set_init_skbinfo(ext_skbinfo(x, set), ext);
Signature · 1 line
2.53.0
author maintainer
#75 lore raw

PATCH 75/497 Bluetooth: hci_sync: dont drain cmd_sync backlog on unregister

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Nguyen Ngoc Thang <[email protected]>

[ Upstream commit b1f24c1ab52345e810c42a1a81286cb5a7c92252 ]

hci_unregister_dev() disables cmd_work and cmd_timer, then calls hci_cmd_sync_clear(), whose cancel_work_sync() waits for hci_cmd_sync_work() to return. That worker dequeues and runs every entry on cmd_sync_work_list. With cmd_work disabled nothing reaches the controller, so each queued HCI command waits the full HCI_CMD_TIMEOUT (2s).

The backlog has no bound. Userspace can keep queuing MGMT commands such as MGMT_OP_GET_CLOCK_INFO against a controller that doesn't answer. Closing /dev/vhci then blocks in vhci_release() for backlog * 2s:

  INFO: task syz-executor:5749 blocked for more than 143 seconds.
   cancel_work_sync
   hci_cmd_sync_clear
   hci_unregister_dev
   vhci_release

In a local reproduction the backlog held more than 5000 entries, which comes to hours of hang.

Stop the worker from taking new entries once HCI_UNREGISTER is set, and wake any request still waiting with -ENODEV before cancelling the work. The entries left over are destroyed with -ECANCELED by the existing sweep in hci_cmd_sync_clear(). They stay on the list until the work has stopped, so hci_cmd_sync_dequeue() and friends still see them. A callback already running may still issue another command, which delays unregister by at most one timeout per remaining command, not by the whole backlog.

Fixes 008ee9eb8a11 ("Bluetooth: hci_sync: Fix not processing all entries on cmd_sync_work")
Reported-by [email protected]
---
 net/bluetooth/hci_sync.c | 6 ++++++
 1 file changed, 6 insertions(+)
net/bluetooth/hci_sync.c +6 -0
index 78d9623f5faef..4505dc25f77c8 100644
@@ -312,6 +312,10 @@ static void hci_cmd_sync_work(struct work_struct *work)
 	while (1) {
 		struct hci_cmd_sync_work_entry *entry;
 
+		/* Leave the backlog to hci_cmd_sync_clear() */
+		if (hci_dev_test_flag(hdev, HCI_UNREGISTER))
+			break;
+
 		mutex_lock(&hdev->cmd_sync_work_lock);
 		entry = list_first_entry_or_null(&hdev->cmd_sync_work_list,
 						 struct hci_cmd_sync_work_entry,
@@ -658,6 +662,8 @@ void hci_cmd_sync_clear(struct hci_dev *hdev)
 {
 	struct hci_cmd_sync_work_entry *entry, *tmp;
 
+	/* cmd_work is disabled, the pending request can only time out */
+	hci_cmd_sync_cancel_sync(hdev, ENODEV);
 	cancel_work_sync(&hdev->cmd_sync_work);
 	cancel_work_sync(&hdev->reenable_adv_work);
 
Signature · 1 line
2.53.0
author maintainer
#76 lore raw

PATCH 76/497 net: systemport: Fix buffer overflow in bcm_sysport_get_stats()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Florian Fainelli <[email protected]>

[ Upstream commit eb7b84af0ec5c71b4920e999611b466b3784496c ]

When running on SYSTEMPORT Lite, certain statistics are unsupported and skipped during bcm_sysport_get_stats(). The variable 'j' tracks the compacted index into the destination data buffer, whereas 'i' iterates over all elements in bcm_sysport_gstrings_stats.

Because the buffer allocated by ethtool is sized only according to bcm_sysport_get_sset_count(), storing values at data[i] instead of data[j] writes past the allocated array bounds, leading to memory corruption.

Fix this by writing to data[j] instead of data[i].

---
 drivers/net/ethernet/broadcom/bcmsysport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bcmsysport.c +2 -2
index 2b784ced06451..c0af40cdfd165 100644
@@ -516,10 +516,10 @@ static void bcm_sysport_get_stats(struct net_device *dev,
 		    s->type == BCM_SYSPORT_STAT_NETDEV64) {
 			do {
 				start = u64_stats_fetch_begin(syncp);
-				data[i] = *(u64 *)p;
+				data[j] = *(u64 *)p;
 			} while (u64_stats_fetch_retry(syncp, start));
 		} else
-			data[i] = *(u32 *)p;
+			data[j] = *(u32 *)p;
 		j++;
 	}
 
Signature · 1 line
2.53.0
author maintainer
#77 lore raw

PATCH 77/497 net: systemport: Fix RUNT MIB counter register offset calculation

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Florian Fainelli <[email protected]>

[ Upstream commit 242935adfeb096f09b29fb2cfcf12f9eb2911fc6 ]

In UniMAC hardware, there is a 0xC byte gap between the RX MIB counters and the TX MIB counters, and a second 0xC byte gap between the TX MIB counters and the RX RUNT MIB counters.

In bcm_sysport_update_mib_counters(), 'offset' was only set to UMAC_MIB_STAT_OFFSET (0xC) for all non-RX counters, omitting the second 0xC gap for BCM_SYSPORT_STAT_RUNT counters. As a result, all 4 RUNT MIB counters were read from unmapped gap register space.

Fix this by setting offset to 2 * UMAC_MIB_STAT_OFFSET (0x18) when reading BCM_SYSPORT_STAT_RUNT counters.

Fixes 80105befdb4b ("net: systemport: add Broadcom SYSTEMPORT Ethernet MAC driver")
---
 drivers/net/ethernet/broadcom/bcmsysport.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bcmsysport.c +3 -1
index c0af40cdfd165..2cb3693080744 100644
@@ -425,8 +425,10 @@ static void bcm_sysport_update_mib_counters(struct bcm_sysport_priv *priv)
 			if (priv->is_lite)
 				continue;
 
-			if (s->type != BCM_SYSPORT_STAT_MIB_RX)
+			if (s->type == BCM_SYSPORT_STAT_MIB_TX)
 				offset = UMAC_MIB_STAT_OFFSET;
+			else if (s->type == BCM_SYSPORT_STAT_RUNT)
+				offset = 2 * UMAC_MIB_STAT_OFFSET;
 			val = umac_readl(priv, UMAC_MIB_START + j + offset);
 			break;
 		case BCM_SYSPORT_STAT_RXCHK:
Signature · 1 line
2.53.0
author maintainer
#78 lore raw

PATCH 78/497 net/mlx5: LAG, Refactor lag logic

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Rongwei Liu <[email protected]>

[ Upstream commit ddbb5ddc43ad000a984149db5af1133433938404 ]

Wrap the lag pf access into two new macros:
1. ldev_for_each()
2. ldev_for_each_reverse()
The maximum number of lag ports and the index to natvie_port_num mapping will be handled by the two new macros.
Users shouldn't use the for loop anymore.

Stable-dep-of: 04c824940d52 ("net/mlx5: Fix slab-out-of-bounds when handling team device events")

---
 .../ethernet/mellanox/mlx5/core/lag/debugfs.c |  13 +-
 .../net/ethernet/mellanox/mlx5/core/lag/lag.c | 181 +++++++++---------
 .../net/ethernet/mellanox/mlx5/core/lag/lag.h |  14 +-
 .../net/ethernet/mellanox/mlx5/core/lag/mp.c  |  24 ++-
 .../ethernet/mellanox/mlx5/core/lag/mpesw.c   |  10 +-
 .../mellanox/mlx5/core/lag/port_sel.c         |  16 +-
 6 files changed, 137 insertions(+), 121 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/lag/debugfs.c +5 -8
index 41ddca52e9547..b8d5f6a44d26a 100644
@@ -105,20 +105,20 @@ static int mapping_show(struct seq_file *file, void *priv)
 	struct mlx5_lag *ldev;
 	bool hash = false;
 	bool lag_active;
+	int i, idx = 0;
 	int num_ports;
-	int i;
 
 	ldev = mlx5_lag_dev(dev);
 	mutex_lock(&ldev->lock);
 	lag_active = __mlx5_lag_is_active(ldev);
 	if (lag_active) {
 		if (test_bit(MLX5_LAG_MODE_FLAG_HASH_BASED, &ldev->mode_flags)) {
-			mlx5_infer_tx_enabled(&ldev->tracker, ldev->ports, ports,
+			mlx5_infer_tx_enabled(&ldev->tracker, ldev, ports,
 					      &num_ports);
 			hash = true;
 		} else {
-			for (i = 0; i < ldev->ports; i++)
-				ports[i] = ldev->v2p_map[i];
+			mlx5_ldev_for_each(i, 0, ldev)
+				ports[idx++] = ldev->v2p_map[i];
 			num_ports = ldev->ports;
 		}
 	}
@@ -144,11 +144,8 @@ static int members_show(struct seq_file *file, void *priv)
 
 	ldev = mlx5_lag_dev(dev);
 	mutex_lock(&ldev->lock);
-	for (i = 0; i < ldev->ports; i++) {
-		if (!ldev->pf[i].dev)
-			continue;
+	mlx5_ldev_for_each(i, 0, ldev)
 		seq_printf(file, "%s\n", dev_name(ldev->pf[i].dev->device));
-	}
 	mutex_unlock(&ldev->lock);
 
 	return 0;
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c +91 -90

507 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h +13 -1
index 48a5f3e7b91a8..99232bca610c7 100644
@@ -104,7 +104,7 @@ int mlx5_lag_dev_get_netdev_idx(struct mlx5_lag *ldev,
 				struct net_device *ndev);
 
 char *mlx5_get_str_port_sel_mode(enum mlx5_lag_mode mode, unsigned long flags);
-void mlx5_infer_tx_enabled(struct lag_tracker *tracker, u8 num_ports,
+void mlx5_infer_tx_enabled(struct lag_tracker *tracker, struct mlx5_lag *ldev,
 			   u8 *ports, int *num_enabled);
 
 void mlx5_ldev_add_debugfs(struct mlx5_core_dev *dev);
@@ -120,9 +120,21 @@ static inline bool mlx5_lag_is_supported(struct mlx5_core_dev *dev)
 	if (!MLX5_CAP_GEN(dev, vport_group_manager) ||
 	    !MLX5_CAP_GEN(dev, lag_master) ||
 	    MLX5_CAP_GEN(dev, num_lag_ports) < 2 ||
+	    mlx5_get_dev_index(dev) >= MLX5_MAX_PORTS ||
 	    MLX5_CAP_GEN(dev, num_lag_ports) > MLX5_MAX_PORTS)
 		return false;
 	return true;
 }
 
+#define mlx5_ldev_for_each(i, start_index, ldev) \
+	for (int tmp = start_index; tmp = mlx5_get_next_ldev_func(ldev, tmp), \
+	     i = tmp, tmp < MLX5_MAX_PORTS; tmp++)
+
+#define mlx5_ldev_for_each_reverse(i, start_index, end_index, ldev)      \
+	for (int tmp = start_index, tmp1 = end_index; \
+	     tmp = mlx5_get_pre_ldev_func(ldev, tmp, tmp1), \
+	     i = tmp, tmp >= tmp1; tmp--)
+
+int mlx5_get_pre_ldev_func(struct mlx5_lag *ldev, int start_idx, int end_idx);
+int mlx5_get_next_ldev_func(struct mlx5_lag *ldev, int start_idx);
 #endif /* __MLX5_LAG_H__ */
drivers/net/ethernet/mellanox/mlx5/core/lag/mp.c +16 -8
index b1aa494c76ba8..40406d04adc98 100644
@@ -153,6 +153,7 @@ static void mlx5_lag_fib_route_event(struct mlx5_lag *ldev, unsigned long event,
 	struct net_device *nh_dev0, *nh_dev1;
 	struct fib_info *fi = fen_info->fi;
 	struct lag_mp *mp = &ldev->lag_mp;
+	int i, dev_idx = 0;
 
 	/* Handle delete event */
 	if (event == FIB_EVENT_ENTRY_DEL) {
@@ -186,10 +187,12 @@ static void mlx5_lag_fib_route_event(struct mlx5_lag *ldev, unsigned long event,
 
 	if (!nh_dev1) {
 		if (__mlx5_lag_is_active(ldev)) {
-			int i = mlx5_lag_dev_get_netdev_idx(ldev, nh_dev0);
-
-			i++;
-			mlx5_lag_set_port_affinity(ldev, i);
+			mlx5_ldev_for_each(i, 0, ldev) {
+				dev_idx++;
+				if (ldev->pf[i].netdev == nh_dev0)
+					break;
+			}
+			mlx5_lag_set_port_affinity(ldev, dev_idx);
 			mlx5_lag_fib_set(mp, fi, fen_info->dst, fen_info->dst_len);
 		}
 
@@ -214,6 +217,7 @@ static void mlx5_lag_fib_nexthop_event(struct mlx5_lag *ldev,
 				       struct fib_info *fi)
 {
 	struct lag_mp *mp = &ldev->lag_mp;
+	int i, dev_idx = 0;
 
 	/* Check the nh event is related to the route */
 	if (!mp->fib.mfi || mp->fib.mfi != fi)
@@ -221,11 +225,15 @@ static void mlx5_lag_fib_nexthop_event(struct mlx5_lag *ldev,
 
 	/* nh added/removed */
 	if (event == FIB_EVENT_NH_DEL) {
-		int i = mlx5_lag_dev_get_netdev_idx(ldev, fib_nh->fib_nh_dev);
+		mlx5_ldev_for_each(i, 0, ldev) {
+			if (ldev->pf[i].netdev == fib_nh->fib_nh_dev)
+				break;
+			dev_idx++;
+		}
 
-		if (i >= 0) {
-			i = (i + 1) % 2 + 1; /* peer port */
-			mlx5_lag_set_port_affinity(ldev, i);
+		if (dev_idx >= 0) {
+			dev_idx = (dev_idx + 1) % 2 + 1; /* peer port */
+			mlx5_lag_set_port_affinity(ldev, dev_idx);
 		}
 	} else if (event == FIB_EVENT_NH_ADD &&
 		   fib_info_num_path(fi) == 2) {
drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c +5 -5
index c433d29a62f25..b0a60d2433e50 100644
@@ -15,7 +15,7 @@ static void mlx5_mpesw_metadata_cleanup(struct mlx5_lag *ldev)
 	u32 pf_metadata;
 	int i;
 
-	for (i = 0; i < ldev->ports; i++) {
+	mlx5_ldev_for_each(i, 0, ldev) {
 		dev = ldev->pf[i].dev;
 		esw = dev->priv.eswitch;
 		pf_metadata = ldev->lag_mpesw.pf_metadata[i];
@@ -36,7 +36,7 @@ static int mlx5_mpesw_metadata_set(struct mlx5_lag *ldev)
 	u32 pf_metadata;
 	int i, err;
 
-	for (i = 0; i < ldev->ports; i++) {
+	mlx5_ldev_for_each(i, 0, ldev) {
 		dev = ldev->pf[i].dev;
 		esw = dev->priv.eswitch;
 		pf_metadata = mlx5_esw_match_metadata_alloc(esw);
@@ -52,7 +52,7 @@ static int mlx5_mpesw_metadata_set(struct mlx5_lag *ldev)
 			goto err_metadata;
 	}
 
-	for (i = 0; i < ldev->ports; i++) {
+	mlx5_ldev_for_each(i, 0, ldev) {
 		dev = ldev->pf[i].dev;
 		mlx5_notifier_call_chain(dev->priv.events, MLX5_DEV_EVENT_MULTIPORT_ESW,
 					 (void *)0);
@@ -99,7 +99,7 @@ static int enable_mpesw(struct mlx5_lag *ldev)
 
 	dev0->priv.flags &= ~MLX5_PRIV_FLAGS_DISABLE_IB_ADEV;
 	mlx5_rescan_drivers_locked(dev0);
-	for (i = 0; i < ldev->ports; i++) {
+	mlx5_ldev_for_each(i, 0, ldev) {
 		err = mlx5_eswitch_reload_ib_reps(ldev->pf[i].dev->priv.eswitch);
 		if (err)
 			goto err_rescan_drivers;
@@ -113,7 +113,7 @@ static int enable_mpesw(struct mlx5_lag *ldev)
 	mlx5_deactivate_lag(ldev);
 err_add_devices:
 	mlx5_lag_add_devices(ldev);
-	for (i = 0; i < ldev->ports; i++)
+	mlx5_ldev_for_each(i, 0, ldev)
 		mlx5_eswitch_reload_ib_reps(ldev->pf[i].dev->priv.eswitch);
 	mlx5_mpesw_metadata_cleanup(ldev);
 	return err;
drivers/net/ethernet/mellanox/mlx5/core/lag/port_sel.c +7 -9
index 39e80704b1c42..ba8c2bddde484 100644
@@ -44,9 +44,7 @@ static int mlx5_lag_create_port_sel_table(struct mlx5_lag *ldev,
 	struct mlx5_flow_destination dest = {};
 	MLX5_DECLARE_FLOW_ACT(flow_act);
 	struct mlx5_flow_namespace *ns;
-	int err, i;
-	int idx;
-	int j;
+	int err, i, j, k, idx;
 
 	ft_attr.max_fte = ldev->ports * ldev->buckets;
 	ft_attr.level = MLX5_LAG_FT_LEVEL_DEFINER;
@@ -74,7 +72,7 @@ static int mlx5_lag_create_port_sel_table(struct mlx5_lag *ldev,
 	dest.type = MLX5_FLOW_DESTINATION_TYPE_UPLINK;
 	dest.vport.flags |= MLX5_FLOW_DEST_VPORT_VHCA_ID;
 	flow_act.flags |= FLOW_ACT_NO_APPEND;
-	for (i = 0; i < ldev->ports; i++) {
+	mlx5_ldev_for_each(i, 0, ldev) {
 		for (j = 0; j < ldev->buckets; j++) {
 			u8 affinity;
 
@@ -88,13 +86,13 @@ static int mlx5_lag_create_port_sel_table(struct mlx5_lag *ldev,
 								      &dest, 1);
 			if (IS_ERR(lag_definer->rules[idx])) {
 				err = PTR_ERR(lag_definer->rules[idx]);
-				do {
+				mlx5_ldev_for_each_reverse(k, i, 0, ldev) {
 					while (j--) {
-						idx = i * ldev->buckets + j;
+						idx = k * ldev->buckets + j;
 						mlx5_del_flow_rules(lag_definer->rules[idx]);
 					}
 					j = ldev->buckets;
-				} while (i--);
+				};
 				goto destroy_fg;
 			}
 		}
@@ -346,7 +344,7 @@ static void mlx5_lag_destroy_definer(struct mlx5_lag *ldev,
 	int i;
 	int j;
 
-	for (i = 0; i < ldev->ports; i++) {
+	mlx5_ldev_for_each(i, 0, ldev) {
 		for (j = 0; j < ldev->buckets; j++) {
 			idx = i * ldev->buckets + j;
 			mlx5_del_flow_rules(lag_definer->rules[idx]);
@@ -567,7 +565,7 @@ static int __mlx5_lag_modify_definers_destinations(struct mlx5_lag *ldev,
 	dest.type = MLX5_FLOW_DESTINATION_TYPE_UPLINK;
 	dest.vport.flags |= MLX5_FLOW_DEST_VPORT_VHCA_ID;
 
-	for (i = 0; i < ldev->ports; i++) {
+	mlx5_ldev_for_each(i, 0, ldev) {
 		for (j = 0; j < ldev->buckets; j++) {
 			idx = i * ldev->buckets + j;
 			if (ldev->v2p_map[idx] == ports[idx])
Signature · 1 line
2.53.0
author maintainer
#79 lore raw

PATCH 79/497 net/mlx5: Fix slab-out-of-bounds when handling team device events

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Anirudh Virdi <[email protected]>

[ Upstream commit 04c824940d52871c49866a4ac67b504146f7cf35 ]

The mlx5_handle_changeupper_event() and mlx5_handle_changeinfodata_event() functions check for LAG masters (which includes both bonding and team devices) but only call bonding-specific APIs. When processing team device events, calling bond_slave_get_rcu() and bond_is_slave_inactive() on team_port structures causes KASAN to detect an out-of-bounds memory access since team_port is smaller than bond slave.

Fix this by wrapping the bond-specific API calls with a check for bonding devices. This allows the function to still process LAG events for both bonding and teams but only calls bond-specific functions when dealing with actual bonding devices.

For mlx5_handle_changeinfodata_event(), keep the explicit bond check as mlx5 doesn't handle state information for team ports anyway.

Tested with Mellanox ConnectX-5 on Linux 7.2.0-rc6:
- Bonding: PASS (no regressions)
- Team device: PASS (no KASAN errors)

Fixes 54493a08e21f ("net/mlx5: Lag, record inactive state of bond device")
---
 drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c +6 -4
index 8f6c8a60a1dd3..f055aac1b436a 100644
@@ -1076,9 +1076,11 @@ static int mlx5_handle_changeupper_event(struct mlx5_lag *ldev,
 			}
 		}
 		if (i < MLX5_MAX_PORTS) {
-			slave = bond_slave_get_rcu(ndev_tmp);
-			if (slave)
-				has_inactive |= bond_is_slave_inactive(slave);
+			if (netif_is_bond_master(upper)) {
+				slave = bond_slave_get_rcu(ndev_tmp);
+				if (slave)
+					has_inactive |= bond_is_slave_inactive(slave);
+			}
 			bond_status |= (1 << idx);
 		}
 
@@ -1162,7 +1164,7 @@ static int mlx5_handle_changeinfodata_event(struct mlx5_lag *ldev,
 	bool has_inactive = 0;
 	int idx;
 
-	if (!netif_is_lag_master(ndev))
+	if (!netif_is_bond_master(ndev))
 		return 0;
 
 	rcu_read_lock();
Signature · 1 line
2.53.0
author maintainer
#80 lore raw

PATCH 80/497 octeontx2-af: mcs: Fix SC resource cleanup loop

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Baha Mesleh <[email protected]>

[ Upstream commit cdef07f3002f708a345392ee28d0d9bfac8383a1 ]

The SC resource cleanup and statistics loops were incorrectly iterating over secy.max instead of sc.max, so the highest SC id could be left allocated across teardown or FLR. Use sc.max as the loop bound.

Fixes cfc14181d497 ("octeontx2-af: cn10k: mcs: Manage the MCS block hardware resources")
---
 drivers/net/ethernet/marvell/octeontx2/af/mcs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mcs.c +2 -2
index 211c10aa5880f..30c672d526a0c 100644
@@ -314,7 +314,7 @@ int mcs_clear_all_stats(struct mcs *mcs, u16 pcifunc, int dir)
 	}
 
 	/* Clear SC stats */
-	for (id = 0; id < map->secy.max; id++) {
+	for (id = 0; id < map->sc.max; id++) {
 		if (map->sc2pf_map[id] != pcifunc)
 			continue;
 		mcs_clear_stats(mcs, MCS_SC_STATS, id, dir);
@@ -738,7 +738,7 @@ int mcs_free_all_rsrc(struct mcs *mcs, int dir, u16 pcifunc)
 	}
 
 	/* free sc entries */
-	for (id = 0; id < map->secy.max; id++) {
+	for (id = 0; id < map->sc.max; id++) {
 		if (map->sc2pf_map[id] != pcifunc)
 			continue;
 		mcs_free_rsrc(&map->sc, map->sc2pf_map, id, pcifunc);
Signature · 1 line
2.53.0
author maintainer
#81 lore raw

PATCH 81/497 tipc: prevent GCM nonce reuse on peer key changes

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jérémy Jean <[email protected]>

[ Upstream commit 512ccd3d0e91e791fb37442aa0a2599aca19783d ]

TIPC can encrypt traffic between nodes using a different transmit key for each node. In this mode, the AES-GCM nonce for a packet sent to a known peer consists of a 32-bit prefix (a per-key salt XOR the peer's address) followed by a 64-bit counter. That counter is stored in the peer's RX crypto object. When the peer reports a change in which key it uses to receive packets, TIPC resets this counter. The sender can still be using the same TX key and salt, so subsequent packets reuse earlier nonces. This nonce reuse breaks confidentiality and exposes GCM's authentication key. This makes forgeries trivial: an attacker can exploit CTR malleability to alter captured ciphertexts and use the recovered authentication key to compute a valid tag for the modified ciphertext, under the same key and nonce.

Use the TX key's existing aead->seqno counter instead. All encryptions using that key object share the same atomic counter, so concurrent encryptions get distinct nonce counter values. The counter survives key activation and peer reconnection, and peer key-status reports cannot reset it. This prevents those transitions from causing nonce reuse while the same TX key remains installed.

The nonce format is unchanged, and receivers do not require consecutive counter values, so sharing the counter across peers remains compatible with existing receivers. A pre-existing check still invokes key revocation in the unlikely event that the counter wraps to zero.

Fixes fc1b6d6de220 ("tipc: introduce TIPC encryption & authentication")
---
 net/tipc/crypto.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)
net/tipc/crypto.c +5 -15
index d58db40d6c036..9c3ef67eb5f41 100644
@@ -144,7 +144,7 @@ struct tipc_tfm {
  * @rcu: struct rcu_head
  * @key: the aead key
  * @gen: the key's generation
- * @seqno: the key seqno (cluster scope)
+ * @seqno: the per-key TX nonce counter
  * @refcnt: the key reference counter
  */
 struct tipc_aead {
@@ -190,7 +190,6 @@ struct tipc_crypto_stats {
  * @rekeying_intv: rekeying interval (in minutes)
  * @stats: the crypto statistics
  * @name: the crypto name
- * @sndnxt: the per-peer sndnxt (TX)
  * @timer1: general timer 1 (jiffies)
  * @timer2: general timer 2 (jiffies)
  * @working: the crypto is working or not
@@ -219,7 +218,6 @@ struct tipc_crypto {
 	struct tipc_crypto_stats __percpu *stats;
 	char name[48];
 
-	atomic64_t sndnxt ____cacheline_aligned;
 	unsigned long timer1;
 	unsigned long timer2;
 	union {
@@ -1060,14 +1058,11 @@ static int tipc_ehdr_build(struct net *net, struct tipc_aead *aead,
 	WARN_ON(skb_headroom(skb) < ehsz);
 	ehdr = (struct tipc_ehdr *)skb_push(skb, ehsz);
 
-	/* Obtain a seqno first:
-	 * Use the key seqno (= cluster wise) if dest is unknown or we're in
-	 * cluster key mode, otherwise it's better for a per-peer seqno!
+	/*
+	 * Keep the nonce unique for the lifetime of the TX key,
+	 * including key state changes and peer reconnection.
 	 */
-	if (!__rx || aead->mode == CLUSTER_KEY)
-		seqno = atomic64_inc_return(&aead->seqno);
-	else
-		seqno = atomic64_inc_return(&__rx->sndnxt);
+	seqno = atomic64_inc_return(&aead->seqno);
 
 	/* Revoke the key if seqno is wrapped around */
 	if (unlikely(!seqno))
@@ -1246,7 +1241,6 @@ void tipc_crypto_key_flush(struct tipc_crypto *c)
 	tipc_crypto_key_set_state(c, 0, 0, 0);
 	for (k = KEY_MIN; k <= KEY_MAX; k++)
 		tipc_crypto_key_detach(c->aead[k], &c->lock);
-	atomic64_set(&c->sndnxt, 0);
 	spin_unlock_bh(&c->lock);
 }
 
@@ -1393,8 +1387,6 @@ static struct tipc_aead *tipc_crypto_key_pick_tx(struct tipc_crypto *tx,
  * It also considers if peer has no key, then we need to make own master key
  * (if any) taking over i.e. starting grace period and also trigger key
  * distributing process.
- *
- * The "per-peer" sndnxt is also reset when the peer key has switched.
  */
 static void tipc_crypto_key_synch(struct tipc_crypto *rx, struct sk_buff *skb)
 {
@@ -1445,7 +1437,6 @@ static void tipc_crypto_key_synch(struct tipc_crypto *rx, struct sk_buff *skb)
 		if (cur)
 			tipc_aead_users_dec(tx->aead[cur], 0);
 
-		atomic64_set(&rx->sndnxt, 0);
 		/* Mark the point TX key users changed */
 		tx->timer1 = jiffies;
 
@@ -1510,7 +1501,6 @@ int tipc_crypto_start(struct tipc_crypto **crypto, struct net *net,
 	tipc_crypto_key_set_state(c, 0, 0, 0);
 	atomic_set(&c->key_distr, 0);
 	atomic_set(&c->peer_rx_active, 0);
-	atomic64_set(&c->sndnxt, 0);
 	c->timer1 = jiffies;
 	c->timer2 = jiffies;
 	c->rekeying_intv = TIPC_REKEYING_INTV_DEF;
Signature · 1 line
2.53.0
author maintainer
#82 lore raw

PATCH 82/497 memcg: convert memcg->socket_pressure to u64

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Kuniyuki Iwashima <[email protected]>

[ Upstream commit 378bdb97405a00bf03d8d993435c83add1688e36 ]

memcg->socket_pressure is initialised with jiffies when the memcg is created.

Once vmpressure detects that the cgroup is under memory pressure, the field is updated with jiffies + HZ to signal the fact to the socket layer and suppress memory allocation for one second.

Otherwise, the field is not updated.

mem_cgroup_under_socket_pressure() uses time_before() to check if jiffies is less than memcg->socket_pressure, and this has a bug on 32-bit kernel.

if (time_before(jiffies, memcg->socket_pressure))

          return true;

As time_before() casts the final result to long, the acceptable delta between two timestamps is 2 ^ (BITS_PER_LONG - 1).

On 32-bit kernel with CONFIG_HZ=1000, this is about 24 days.

Quoted 1 line
Quoted 1 line
Quoted 1 line

(2 ** 31) / 1000 / 60 / 60 / 24

24.855134814814818

Once 24 days have passed since the last update of socket_pressure, mem_cgroup_under_socket_pressure() starts to lie until the next 24 days pass.

We don't need to worry about this on 64-bit machines unless they serve for 300 million years.

Quoted 1 line
Quoted 1 line
Quoted 1 line

(2 ** 63) / 1000 / 60 / 60 / 24 / 365

292471208.6775361

Let's convert memcg->socket_pressure to u64.

Performance teting:

I don't have a real 32-bit machine so this is a result on QEMU, but with/without the u64 jiffie patch, the time spent in mem_cgroup_under_socket_pressure() was 1~5us and I didn't see any measurable delta.

no patch applied:
iperf3 273 [000] 137.296248:
probe:mem_cgroup_under_socket_pressure: (c13660d0)

                c13660d1 mem_cgroup_under_socket_pressure+0x1

([kernel.kallsyms])
iperf3 273 [000] 137.296249:
probe:mem_cgroup_under_socket_pressure__return: (c13660d0 <- c1d8fd7f)
iperf3 273 [000] 137.296251:
probe:mem_cgroup_under_socket_pressure: (c13660d0)

                c13660d1 mem_cgroup_under_socket_pressure+0x1

([kernel.kallsyms])
iperf3 273 [000] 137.296253:
probe:mem_cgroup_under_socket_pressure__return: (c13660d0 <- c1d8fd7f)

u64 jiffies patch applied:
iperf3 308 [001] 330.669370:
probe:mem_cgroup_under_socket_pressure: (c12ddba0)

                c12ddba1 mem_cgroup_under_socket_pressure+0x1

([kernel.kallsyms])
iperf3 308 [001] 330.669371:
probe:mem_cgroup_under_socket_pressure__return: (c12ddba0 <- c1ce98bf)
iperf3 308 [001] 330.669382:
probe:mem_cgroup_under_socket_pressure: (c12ddba0)

                c12ddba1 mem_cgroup_under_socket_pressure+0x1

([kernel.kallsyms])
iperf3 308 [001] 330.669384:
probe:mem_cgroup_under_socket_pressure__return: (c12ddba0 <- c1ce98bf)

So the u64 approach is good enough.

Fixes 8e8ae645249b ("mm: memcontrol: hook up vmpressure to socket pressure")
Cc David S. Miller <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Vladimir Davydov <[email protected]>

Stable-dep-of: 37e02c42a00b ("net: restrict SO_RESERVE_MEM to TCP sockets and cap max value")

---
 include/linux/memcontrol.h | 44 +++++++++++++++++++++++++++++++++++---
 mm/memcontrol.c            |  5 ++++-
 mm/vmpressure.c            |  2 +-
 3 files changed, 46 insertions(+), 5 deletions(-)
include/linux/memcontrol.h +41 -3
index e4c24c94b9ef0..659ee811c9c2f 100644
@@ -241,8 +241,10 @@ struct mem_cgroup {
 	 * that this indicator should NOT be used in legacy cgroup mode
 	 * where socket memory is accounted/charged separately.
 	 */
-	unsigned long		socket_pressure;
-
+	u64			socket_pressure;
+#if BITS_PER_LONG < 64
+	seqlock_t		socket_pressure_seqlock;
+#endif
 	int kmemcg_id;
 	/*
 	 * memcg->objcg is wiped out as a part of the objcg repaprenting
@@ -1667,6 +1669,42 @@ extern struct static_key_false memcg_sockets_enabled_key;
 #define mem_cgroup_sockets_enabled static_branch_unlikely(&memcg_sockets_enabled_key)
 void mem_cgroup_sk_alloc(struct sock *sk);
 void mem_cgroup_sk_free(struct sock *sk);
+
+#if BITS_PER_LONG < 64
+static inline void mem_cgroup_set_socket_pressure(struct mem_cgroup *memcg)
+{
+	u64 val = get_jiffies_64() + HZ;
+	unsigned long flags;
+
+	write_seqlock_irqsave(&memcg->socket_pressure_seqlock, flags);
+	memcg->socket_pressure = val;
+	write_sequnlock_irqrestore(&memcg->socket_pressure_seqlock, flags);
+}
+
+static inline u64 mem_cgroup_get_socket_pressure(struct mem_cgroup *memcg)
+{
+	unsigned int seq;
+	u64 val;
+
+	do {
+		seq = read_seqbegin(&memcg->socket_pressure_seqlock);
+		val = memcg->socket_pressure;
+	} while (read_seqretry(&memcg->socket_pressure_seqlock, seq));
+
+	return val;
+}
+#else
+static inline void mem_cgroup_set_socket_pressure(struct mem_cgroup *memcg)
+{
+	WRITE_ONCE(memcg->socket_pressure, jiffies + HZ);
+}
+
+static inline u64 mem_cgroup_get_socket_pressure(struct mem_cgroup *memcg)
+{
+	return READ_ONCE(memcg->socket_pressure);
+}
+#endif
+
 static inline bool mem_cgroup_under_socket_pressure(struct mem_cgroup *memcg)
 {
 #ifdef CONFIG_MEMCG_V1
@@ -1674,7 +1712,7 @@ static inline bool mem_cgroup_under_socket_pressure(struct mem_cgroup *memcg)
 		return !!memcg->tcpmem_pressure;
 #endif /* CONFIG_MEMCG_V1 */
 	do {
-		if (time_before(jiffies, READ_ONCE(memcg->socket_pressure)))
+		if (time_before64(get_jiffies_64(), mem_cgroup_get_socket_pressure(memcg)))
 			return true;
 	} while ((memcg = parent_mem_cgroup(memcg)));
 	return false;
mm/memcontrol.c +4 -1
index ca5694828c292..6592857d53721 100644
@@ -3542,7 +3542,10 @@ static struct mem_cgroup *mem_cgroup_alloc(struct mem_cgroup *parent)
 	INIT_LIST_HEAD(&memcg->memory_peaks);
 	INIT_LIST_HEAD(&memcg->swap_peaks);
 	spin_lock_init(&memcg->peaks_lock);
-	memcg->socket_pressure = jiffies;
+	memcg->socket_pressure = get_jiffies_64();
+#if BITS_PER_LONG < 64
+	seqlock_init(&memcg->socket_pressure_seqlock);
+#endif
 	memcg1_memcg_init(memcg);
 	memcg->kmemcg_id = -1;
 	INIT_LIST_HEAD(&memcg->objcg_list);
mm/vmpressure.c +1 -1
index bd5183dfd8791..c197ed47bcc45 100644
@@ -316,7 +316,7 @@ void vmpressure(gfp_t gfp, struct mem_cgroup *memcg, bool tree,
 			 * asserted for a second in which subsequent
 			 * pressure events can occur.
 			 */
-			WRITE_ONCE(memcg->socket_pressure, jiffies + HZ);
+			mem_cgroup_set_socket_pressure(memcg);
 		}
 	}
 }
Signature · 1 line
2.53.0
author maintainer
#83 lore raw

PATCH 83/497 mptcp: Fix up subflows memcg when CONFIG_SOCK_CGROUP_DATA=n.

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Kuniyuki Iwashima <[email protected]>

[ Upstream commit 68889dfd547bd8eabc5a98b58475d7b901cf5129 ]

When sk_alloc() allocates a socket, mem_cgroup_sk_alloc() sets sk->sk_memcg based on the current task.

MPTCP subflow socket creation is triggered from userspace or an in-kernel worker.

In the latter case, sk->sk_memcg is not what we want. So, we fix it up from the parent socket's sk->sk_memcg in mptcp_attach_cgroup().

Although the code is placed under #ifdef CONFIG_MEMCG, it is buried under #ifdef CONFIG_SOCK_CGROUP_DATA.

The two configs are orthogonal. If CONFIG_MEMCG is enabled without CONFIG_SOCK_CGROUP_DATA, the subflow's memory usage is not charged correctly.

Let's move the code out of the wrong ifdef guard.

Note that sk->sk_memcg is freed in sk_prot_free() and the parent sk holds the refcnt of memcg->css here, so we don't need to use css_tryget().

Stable-dep-of: 37e02c42a00b ("net: restrict SO_RESERVE_MEM to TCP sockets and cap max value")

---
 include/linux/memcontrol.h |  6 ++++++
 mm/memcontrol.c            | 13 +++++++++++++
 net/mptcp/subflow.c        | 11 +++--------
 3 files changed, 22 insertions(+), 8 deletions(-)
include/linux/memcontrol.h +6 -0
index 659ee811c9c2f..8dab6c755e107 100644
@@ -1669,6 +1669,7 @@ extern struct static_key_false memcg_sockets_enabled_key;
 #define mem_cgroup_sockets_enabled static_branch_unlikely(&memcg_sockets_enabled_key)
 void mem_cgroup_sk_alloc(struct sock *sk);
 void mem_cgroup_sk_free(struct sock *sk);
+void mem_cgroup_sk_inherit(const struct sock *sk, struct sock *newsk);
 
 #if BITS_PER_LONG < 64
 static inline void mem_cgroup_set_socket_pressure(struct mem_cgroup *memcg)
@@ -1726,6 +1727,11 @@ void reparent_shrinker_deferred(struct mem_cgroup *memcg);
 #define mem_cgroup_sockets_enabled 0
 static inline void mem_cgroup_sk_alloc(struct sock *sk) { };
 static inline void mem_cgroup_sk_free(struct sock *sk) { };
+
+static inline void mem_cgroup_sk_inherit(const struct sock *sk, struct sock *newsk)
+{
+}
+
 static inline bool mem_cgroup_under_socket_pressure(struct mem_cgroup *memcg)
 {
 	return false;
mm/memcontrol.c +13 -0
index 6592857d53721..473e9696e47c6 100644
@@ -4850,6 +4850,19 @@ void mem_cgroup_sk_free(struct sock *sk)
 		css_put(&sk->sk_memcg->css);
 }
 
+void mem_cgroup_sk_inherit(const struct sock *sk, struct sock *newsk)
+{
+	if (sk->sk_memcg == newsk->sk_memcg)
+		return;
+
+	mem_cgroup_sk_free(newsk);
+
+	if (sk->sk_memcg)
+		css_get(&sk->sk_memcg->css);
+
+	newsk->sk_memcg = sk->sk_memcg;
+}
+
 /**
  * mem_cgroup_charge_skmem - charge socket memory
  * @memcg: memcg to charge
net/mptcp/subflow.c +3 -8
index 2b2d0369009b1..1d0deac2c0fee 100644
@@ -1717,19 +1717,14 @@ static void mptcp_attach_cgroup(struct sock *parent, struct sock *child)
 	/* only the additional subflows created by kworkers have to be modified */
 	if (cgroup_id(sock_cgroup_ptr(parent_skcd)) !=
 	    cgroup_id(sock_cgroup_ptr(child_skcd))) {
-#ifdef CONFIG_MEMCG
-		struct mem_cgroup *memcg = parent->sk_memcg;
-
-		mem_cgroup_sk_free(child);
-		if (memcg && css_tryget(&memcg->css))
-			child->sk_memcg = memcg;
-#endif /* CONFIG_MEMCG */
-
 		cgroup_sk_free(child_skcd);
 		*child_skcd = *parent_skcd;
 		cgroup_sk_clone(child_skcd);
 	}
 #endif /* CONFIG_SOCK_CGROUP_DATA */
+
+	if (mem_cgroup_sockets_enabled)
+		mem_cgroup_sk_inherit(parent, child);
 }
 
 static void mptcp_subflow_ops_override(struct sock *ssk)
Signature · 1 line
2.53.0
author maintainer
#84 lore raw

PATCH 84/497 net: Clean up __sk_mem_raise_allocated().

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Kuniyuki Iwashima <[email protected]>

[ Upstream commit bd4aa2337374dd04b8627efd26227ebd49f69285 ]

In __sk_mem_raise_allocated(), charged is initialised as true due to the weird condition removed in the previous patch.

It makes the variable unreliable by itself, so we have to check another variable, memcg, in advance.

Also, we will factorise the common check below for memcg later.

    if (mem_cgroup_sockets_enabled && sk->sk_memcg)

As a prep, let's initialise charged as false and memcg as NULL.

Stable-dep-of: 37e02c42a00b ("net: restrict SO_RESERVE_MEM to TCP sockets and cap max value")

---
 net/core/sock.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
net/core/sock.c +5 -4
index ef8faa6bddf98..e226ebae9a599 100644
@@ -3208,15 +3208,16 @@ EXPORT_SYMBOL(sk_wait_data);
  */
 int __sk_mem_raise_allocated(struct sock *sk, int size, int amt, int kind)
 {
-	struct mem_cgroup *memcg = mem_cgroup_sockets_enabled ? sk->sk_memcg : NULL;
 	struct proto *prot = sk->sk_prot;
-	bool charged = true;
+	struct mem_cgroup *memcg = NULL;
+	bool charged = false;
 	long allocated;
 
 	sk_memory_allocated_add(sk, amt);
 	allocated = sk_memory_allocated(sk);
 
-	if (memcg) {
+	if (mem_cgroup_sockets_enabled && sk->sk_memcg) {
+		memcg = sk->sk_memcg;
 		charged = mem_cgroup_charge_skmem(memcg, amt, gfp_memcg_charge());
 		if (!charged)
 			goto suppress_allocation;
@@ -3303,7 +3304,7 @@ int __sk_mem_raise_allocated(struct sock *sk, int size, int amt, int kind)
 
 	sk_memory_allocated_sub(sk, amt);
 
-	if (memcg && charged)
+	if (charged)
 		mem_cgroup_uncharge_skmem(memcg, amt);
 
 	return 0;
Signature · 1 line
2.53.0
author maintainer
#85 lore raw

PATCH 85/497 net-memcg: Introduce mem_cgroup_from_sk().

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Kuniyuki Iwashima <[email protected]>

[ Upstream commit f7161b234f2ec7f18999009c4becc04eeb6b12a7 ]

We will store a flag in the lowest bit of sk->sk_memcg.

Then, directly dereferencing sk->sk_memcg will be illegal, and we do not want to allow touching the raw sk->sk_memcg in many places.

Let's introduce mem_cgroup_from_sk().

Other places accessing the raw sk->sk_memcg will be converted later.

Note that we cannot define the helper as an inline function in memcontrol.h as we cannot access any fields of struct sock there due to circular dependency, so it is placed in sock.h.

Stable-dep-of: 37e02c42a00b ("net: restrict SO_RESERVE_MEM to TCP sockets and cap max value")

---
 include/net/sock.h              | 12 ++++++++++++
 mm/memcontrol.c                 | 13 +++++++++----
 net/ipv4/inet_connection_sock.c |  2 +-
 3 files changed, 22 insertions(+), 5 deletions(-)
include/net/sock.h +12 -0
index 73353ee313ad2..6738c6cd3ff5a 100644
@@ -2582,6 +2582,18 @@ static inline gfp_t gfp_memcg_charge(void)
 	return in_softirq() ? GFP_ATOMIC : GFP_KERNEL;
 }
 
+#ifdef CONFIG_MEMCG
+static inline struct mem_cgroup *mem_cgroup_from_sk(const struct sock *sk)
+{
+	return sk->sk_memcg;
+}
+#else
+static inline struct mem_cgroup *mem_cgroup_from_sk(const struct sock *sk)
+{
+	return NULL;
+}
+#endif
+
 static inline long sock_rcvtimeo(const struct sock *sk, bool noblock)
 {
 	return noblock ? 0 : sk->sk_rcvtimeo;
mm/memcontrol.c +9 -4
index 473e9696e47c6..50a1fd9087fae 100644
@@ -4846,19 +4846,24 @@ void mem_cgroup_sk_alloc(struct sock *sk)
 
 void mem_cgroup_sk_free(struct sock *sk)
 {
-	if (sk->sk_memcg)
-		css_put(&sk->sk_memcg->css);
+	struct mem_cgroup *memcg = mem_cgroup_from_sk(sk);
+
+	if (memcg)
+		css_put(&memcg->css);
 }
 
 void mem_cgroup_sk_inherit(const struct sock *sk, struct sock *newsk)
 {
+	struct mem_cgroup *memcg;
+
 	if (sk->sk_memcg == newsk->sk_memcg)
 		return;
 
 	mem_cgroup_sk_free(newsk);
 
-	if (sk->sk_memcg)
-		css_get(&sk->sk_memcg->css);
+	memcg = mem_cgroup_from_sk(sk);
+	if (memcg)
+		css_get(&memcg->css);
 
 	newsk->sk_memcg = sk->sk_memcg;
 }
net/ipv4/inet_connection_sock.c +1 -1
index bd671653273e7..eeee6f7583376 100644
@@ -707,7 +707,7 @@ struct sock *inet_csk_accept(struct sock *sk, struct proto_accept_arg *arg)
 		lock_sock(newsk);
 
 		mem_cgroup_sk_alloc(newsk);
-		if (newsk->sk_memcg) {
+		if (mem_cgroup_from_sk(newsk)) {
 			/* The socket has not been accepted yet, no need
 			 * to look at newsk->sk_wmem_queued.
 			 */
Signature · 1 line
2.53.0
author maintainer
#86 lore raw

PATCH 86/497 net-memcg: Introduce mem_cgroup_sk_enabled().

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Kuniyuki Iwashima <[email protected]>

[ Upstream commit 43049b0db03823c2cd003ca7d3dddcd3924da8dc ]

The socket memcg feature is enabled by a static key and only works for non-root cgroup.

We check both conditions in many places.

Let's factorise it as a helper function.

Stable-dep-of: 37e02c42a00b ("net: restrict SO_RESERVE_MEM to TCP sockets and cap max value")

---
 include/net/proto_memory.h |  2 +-
 include/net/sock.h         | 10 ++++++++++
 include/net/tcp.h          |  2 +-
 net/core/sock.c            |  6 +++---
 net/ipv4/tcp_output.c      |  2 +-
 5 files changed, 16 insertions(+), 6 deletions(-)
include/net/proto_memory.h +1 -1
index a6ab2f4f5e28a..859e63de81c49 100644
@@ -31,7 +31,7 @@ static inline bool sk_under_memory_pressure(const struct sock *sk)
 	if (!sk->sk_prot->memory_pressure)
 		return false;
 
-	if (mem_cgroup_sockets_enabled && sk->sk_memcg &&
+	if (mem_cgroup_sk_enabled(sk) &&
 	    mem_cgroup_under_socket_pressure(sk->sk_memcg))
 		return true;
 
include/net/sock.h +10 -0
index 6738c6cd3ff5a..efa549885b7f8 100644
@@ -2587,11 +2587,21 @@ static inline struct mem_cgroup *mem_cgroup_from_sk(const struct sock *sk)
 {
 	return sk->sk_memcg;
 }
+
+static inline bool mem_cgroup_sk_enabled(const struct sock *sk)
+{
+	return mem_cgroup_sockets_enabled && mem_cgroup_from_sk(sk);
+}
 #else
 static inline struct mem_cgroup *mem_cgroup_from_sk(const struct sock *sk)
 {
 	return NULL;
 }
+
+static inline bool mem_cgroup_sk_enabled(const struct sock *sk)
+{
+	return false;
+}
 #endif
 
 static inline long sock_rcvtimeo(const struct sock *sk, bool noblock)
include/net/tcp.h +1 -1
index 85f8102aa9da3..ad9af706085ab 100644
@@ -275,7 +275,7 @@ extern unsigned long tcp_memory_pressure;
 /* optimized version of sk_under_memory_pressure() for TCP sockets */
 static inline bool tcp_under_memory_pressure(const struct sock *sk)
 {
-	if (mem_cgroup_sockets_enabled && sk->sk_memcg &&
+	if (mem_cgroup_sk_enabled(sk) &&
 	    mem_cgroup_under_socket_pressure(sk->sk_memcg))
 		return true;
 
net/core/sock.c +3 -3
index e226ebae9a599..5790d18ef2348 100644
@@ -1016,7 +1016,7 @@ static int sock_reserve_memory(struct sock *sk, int bytes)
 	bool charged;
 	int pages;
 
-	if (!mem_cgroup_sockets_enabled || !sk->sk_memcg || !sk_has_account(sk))
+	if (!mem_cgroup_sk_enabled(sk) || !sk_has_account(sk))
 		return -EOPNOTSUPP;
 
 	if (!bytes)
@@ -3216,7 +3216,7 @@ int __sk_mem_raise_allocated(struct sock *sk, int size, int amt, int kind)
 	sk_memory_allocated_add(sk, amt);
 	allocated = sk_memory_allocated(sk);
 
-	if (mem_cgroup_sockets_enabled && sk->sk_memcg) {
+	if (mem_cgroup_sk_enabled(sk)) {
 		memcg = sk->sk_memcg;
 		charged = mem_cgroup_charge_skmem(memcg, amt, gfp_memcg_charge());
 		if (!charged)
@@ -3343,7 +3343,7 @@ void __sk_mem_reduce_allocated(struct sock *sk, int amount)
 {
 	sk_memory_allocated_sub(sk, amount);
 
-	if (mem_cgroup_sockets_enabled && sk->sk_memcg)
+	if (mem_cgroup_sk_enabled(sk))
 		mem_cgroup_uncharge_skmem(sk->sk_memcg, amount);
 
 	if (sk_under_global_memory_pressure(sk) &&
net/ipv4/tcp_output.c +1 -1
index aa00a9fb2506c..feb94fd45c594 100644
@@ -3583,7 +3583,7 @@ void sk_forced_mem_schedule(struct sock *sk, int size)
 	sk_forward_alloc_add(sk, amt << PAGE_SHIFT);
 	sk_memory_allocated_add(sk, amt);
 
-	if (mem_cgroup_sockets_enabled && sk->sk_memcg)
+	if (mem_cgroup_sk_enabled(sk))
 		mem_cgroup_charge_skmem(sk->sk_memcg, amt,
 					gfp_memcg_charge() | __GFP_NOFAIL);
 }
Signature · 1 line
2.53.0
author maintainer
#87 lore raw

PATCH 87/497 net: restrict SO_RESERVE_MEM to TCP sockets and cap max value

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Eric Dumazet <[email protected]>

[ Upstream commit 37e02c42a00be692c06343e11779aadc45f45971 ]

Commit 2bb2f5fb21b0 ("net: add new socket option SO_RESERVE_MEM") and commit d00c8ee31729 ("net: fix possible NULL deref in sock_reserve_memory") only checked sk_has_account(sk), which is true for both TCP and UDP sockets.

However, SO_RESERVE_MEM and sk_unused_reserved_mem() are currently only supported by TCP:
- On UDP sockets, sk->sk_forward_alloc is protected by sk->sk_receive_queue.lock, whereas sock_reserve_memory() and sock_release_reserved_memory() only acquire lock_sock(sk). Concurrent UDP packet reception/release and setsockopt(SO_RESERVE_MEM) corrupt sk_forward_alloc and memcg accounting.
- udp_rmem_release() reclaims excess sk_forward_alloc without accounting for sk_unused_reserved_mem(sk).

Restrict sock_reserve_memory() to TCP sockets (sk_is_tcp(sk)) for now. Supporting SO_RESERVE_MEM for UDP (acquiring sk_receive_queue.lock and honoring sk_unused_reserved_mem() in udp_rmem_release()) can be done in a future net-next series if needed.

In addition, reject val > SZ_1G with -EINVAL in sk_setsockopt(SO_RESERVE_MEM). Without an upper bound, values near INT_MAX cause sk_mem_pages(delta) and (pages << PAGE_SHIFT) to overflow 32-bit signed int, corrupting sk->sk_forward_alloc and sk->sk_reserved_mem. Using a page-aligned cap (SZ_1G) ensures that the page-rounded sk->sk_reserved_mem reported by getsockopt(SO_RESERVE_MEM) can always be passed back to setsockopt(SO_RESERVE_MEM).

---
 net/core/sock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/sock.c +2 -2
index 5790d18ef2348..75db38fdfd35f 100644
@@ -1016,7 +1016,7 @@ static int sock_reserve_memory(struct sock *sk, int bytes)
 	bool charged;
 	int pages;
 
-	if (!mem_cgroup_sk_enabled(sk) || !sk_has_account(sk))
+	if (!mem_cgroup_sk_enabled(sk) || !sk_is_tcp(sk))
 		return -EOPNOTSUPP;
 
 	if (!bytes)
@@ -1619,7 +1619,7 @@ int sk_setsockopt(struct sock *sk, int level, int optname,
 	{
 		int delta;
 
-		if (val < 0) {
+		if (val < 0 || val > SZ_1G) {
 			ret = -EINVAL;
 			break;
 		}
Signature · 1 line
2.53.0
author maintainer
#88 lore raw

PATCH 88/497 net/sched: fq_codel: match the no-drop threshold to the packet size

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jamal Hadi Salim <[email protected]>

[ Upstream commit d031465acc362866f27e4f8f79cfecf1037fe2e5 ]

commit d9ebd8f9aa8b ("net/sched: fq_codel: clamp default quantum and mtu") clamped both q->quantum and q->cparams.mtu to [256, FQ_CODEL_QUANTUM_MAX]. The two fields mean different things: quantum is a DRR credit that wants the 256 floor, but cparams.mtu is the CoDel no-drop threshold (codel_impl.h "*backlog <= params->mtu"). On a link whose maximum transmitted packet size is below 256, the floor extends CoDel's minimum-backlog exemption beyond one packet and delays drop or mark eligibility by several small packets.

Split the clamp. quantum keeps [256, FQ_CODEL_QUANTUM_MAX]; cparams.mtu tracks psched_mtu() (the device MTU plus its hard-header length) with only the upper bound that guards the original overflow (psched_mtu() wrapping to ~2 GiB on a huge-MTU device).

Conditions to recreate the bug: attach an fq_codel qdisc on a link whose MTU plus hard_header_len is below 256 (e.g. a CAN interface). At that MTU the no-drop threshold must equal the device MTU plus its hard-header length; before this patch it was forced to 256. Basic Testing done: with dev->mtu=100 and hard_header_len=14, a return probe on fq_codel_init() observed cparams.mtu change from 256 to 114

---
 net/sched/sch_fq_codel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/sched/sch_fq_codel.c +2 -2
index dc07e77df5a89..4b0196eed7a9c 100644
@@ -512,8 +512,8 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt,
 	q->flows_cnt = 1024;
 	q->memory_limit = 32 << 20; /* 32 MBytes */
 	q->drop_batch_size = 64;
-	mtu = clamp_t(u32, psched_mtu(qdisc_dev(sch)), 256, FQ_CODEL_QUANTUM_MAX);
-	q->quantum = mtu;
+	mtu = min_t(u32, psched_mtu(qdisc_dev(sch)), FQ_CODEL_QUANTUM_MAX);
+	q->quantum = clamp_t(u32, mtu, 256, FQ_CODEL_QUANTUM_MAX);
 	INIT_LIST_HEAD(&q->new_flows);
 	INIT_LIST_HEAD(&q->old_flows);
 	codel_params_init(&q->cparams);
Signature · 1 line
2.53.0
author maintainer
#89 lore raw

PATCH 89/497 net/sched: sch_codel: match the no-drop threshold to the packet size

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jamal Hadi Salim <[email protected]>

[ Upstream commit 54518e0e827f4ca9229ae657022c60bf60f5c1bf ]

commit 6439461f1618 ("net/sched: sch_codel: clamp default mtu to avoid disabling CoDel") clamped q->params.mtu to [256, 1 << 20]. The value is the CoDel no-drop threshold (codel_impl.h "*backlog <= params->mtu"), so on a link whose maximum transmitted packet size is below 256 the floor extends CoDel's minimum-backlog exemption beyond one packet and delays drop or mark eligibility by several small packets.

Keep the upper bound that guards the original overflow (psched_mtu() wrapping to ~2 GiB on a huge-MTU device) but drop the 256 floor, so the threshold tracks the real device packet size.

Conditions to recreate the bug: attach a codel qdisc on a link whose MTU plus hard_header_len is below 256 (e.g. a CAN interface). At that MTU the no-drop threshold must equal the device MTU plus its hard-header length; before this patch it was forced to 256. Requires CAP_NET_ADMIN in a user namespace.

---
 net/sched/sch_codel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_codel.c +1 -1
index d6819c4e41982..f12a8f491108e 100644
@@ -203,7 +203,7 @@ static int codel_init(struct Qdisc *sch, struct nlattr *opt,
 	codel_params_init(&q->params);
 	codel_vars_init(&q->vars);
 	codel_stats_init(&q->stats);
-	q->params.mtu = clamp_t(u32, psched_mtu(qdisc_dev(sch)), 256, 1 << 20);
+	q->params.mtu = min_t(u32, psched_mtu(qdisc_dev(sch)), 1 << 20);
 
 	if (opt) {
 		int err = codel_change(sch, opt, extack);
Signature · 1 line
2.53.0
author maintainer
#90 lore raw

PATCH 90/497 virtio_blk: set the zone write granularity

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Niklas Cassel <[email protected]>

[ Upstream commit 684b413b5483f57c890c171b9400076a0143b918 ]

virtblk_read_zoned_limits() reads the write granularity that the device reports in virtio_blk_zoned_characteristics and assigns it to the physical block size and to io_min, but never to the limit that is named after it. queue_limits.zone_write_granularity is left at zero, so blk_validate_zoned_limits() raises it to the logical block size:

	if (lim->zone_write_granularity < lim->logical_block_size)
		lim->zone_write_granularity = lim->logical_block_size;

A device that reports a granularity coarser than its logical block size, which is what the field exists to express, therefore has it silently reduced. A 512e host managed disk passed through to a guest reports a logical block size of 512 and a write granularity of 4096, and the guest ends up with a zone write granularity of 512.

bio_split_alignment() returns lim->zone_write_granularity if it is non-zero and bio_split_io_at() may split a bio with as per bio_split_alignment(). This can real to the write getting rejected by the host drive, as the write is not aligned to the physical block size.

zonefs also takes its block size from bdev_zone_write_granularity(), so it would incorrectly use 512 on a disk that requires 4096.

sd_zbc_read_zones() sets the limit from the physical block size for the same reason. NVMe ZNS and null_blk leave it unset, but the fallback gives the right answer for them, as their write granularity is the logical block size. virtio carries a separate value that may exceed it.

Set the zone write granularity from the value that the device reports.

Fixes 95bfec41bd3d ("virtio-blk: add support for zoned block devices")
---
 drivers/block/virtio_blk.c | 1 +
 1 file changed, 1 insertion(+)
drivers/block/virtio_blk.c +1 -0
index 4bedcb49a73a7..789890f3c5ff4 100644
@@ -741,6 +741,7 @@ static int virtblk_read_zoned_limits(struct virtio_blk *vblk,
 		dev_warn(&vdev->dev, "zero write granularity reported\n");
 		return -ENODEV;
 	}
+	lim->zone_write_granularity = wg;
 	lim->physical_block_size = wg;
 	lim->io_min = wg;
 
Signature · 1 line
2.53.0
author maintainer
#91 lore raw

PATCH 91/497 net: bcmgenet: fix NULL dereference in set_coalesce before first open

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Nicolai Buchwitz <[email protected]>

[ Upstream commit 19419faf58dfe5bcc8a9e60e622976c5f8e3ddc1 ]

The Rx ring priv and index are only set in bcmgenet_init_rx_ring(), which runs at open. Setting the Rx coalescing parameters on an interface that was never opened, e.g. "ethtool -C eth0 rx-usecs 50", dereferences a NULL ring->priv. The oops happens with RTNL held, so networking stays stuck until a reboot:

  Unable to handle kernel paging request at virtual address 0000000000002788
  pc : bcmgenet_set_rx_coalesce.isra.0+0x10/0x88
  lr : bcmgenet_set_coalesce+0xe8/0x180
  Call trace:
   bcmgenet_set_rx_coalesce.isra.0+0x10/0x88 (P)
   __ethnl_set_coalesce.isra.0+0x490/0x570
   ethnl_set_coalesce+0x48/0xc0
   ethnl_default_set_doit+0xf4/0x230
   genl_family_rcv_msg_doit+0xe8/0x160
   genl_rcv_msg+0x220/0x2a0
   netlink_rcv_skb+0x68/0x140
   genl_rcv+0x40/0x60
   netlink_unicast+0x338/0x3c0
   netlink_sendmsg+0x19c/0x3f8
   __sock_sendmsg+0x64/0xc0
   __sys_sendto+0x124/0x198
   __arm64_sys_sendto+0x30/0x48

Set priv and index at probe. Writing the registers while the interface is down is harmless because open resets the MAC and bcmgenet_init_rx_coalesce() reapplies the stored values.

It was observed on a Raspberry Pi CM4, but should apply to all other genet devices.

Fixes 9f4ca05827a2 ("net: bcmgenet: Add support for adaptive RX coalescing")
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +4 -1
index 14e891db97ea8..7da4a2114a771 100644
@@ -4075,8 +4075,11 @@ static int bcmgenet_probe(struct platform_device *pdev)
 	netif_set_real_num_rx_queues(priv->dev, priv->hw_params->rx_queues + 1);
 
 	/* Set default coalescing parameters */
-	for (i = 0; i <= priv->hw_params->rx_queues; i++)
+	for (i = 0; i <= priv->hw_params->rx_queues; i++) {
+		priv->rx_rings[i].priv = priv;
+		priv->rx_rings[i].index = i;
 		priv->rx_rings[i].rx_max_coalesced_frames = 1;
+	}
 
 	/* Initialize u64 stats seq counter for 32bit machines */
 	for (i = 0; i <= GENET_MAX_MQ_CNT; i++) {
Signature · 1 line
2.53.0
author maintainer
#92 lore raw

PATCH 92/497 net: cap skb->queue_mapping when the tx queue is picked

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jamal Hadi Salim <[email protected]>

[ Upstream commit ea4d4b5dddb5121e64f56fd8e0720bd8b447b63d ]

skbedit can set skb->queue_mapping and raise the per-CPU skip_txqueue flag so __dev_queue_xmit() honours the mapping. __dev_queue_xmit() cleared the flag before sch_handle_egress() and only read it afterwards, so the flag was not confined to the xmit that set it: a nested xmit (mirred redirect or mirror, or a drop after skbedit) could set the flag and the outer xmit would consume it for an skb that never went through skbedit.

A forwarded packet still carries the ingress NIC's rx_queue + 1 in skb->queue_mapping, so the outer device then indexes its tx queue state with that stale value. Taprio's child array q->qdiscs[] is sized to the device's queue count, so taprio_enqueue() indexes past its allocation and dereferences the result as a struct Qdisc *.

We (ab)use the skb->nf_skip_egress which means "skip netfilter egress for this packet" to tag to "am I in tc egress?". Despite the overload I dont see it as a conflict since the marker is set only around the single sch_handle_egress() call and ingress path is guarded by tc_at_ingress.
I will send a followup(net-next) patch once this hits net-next to rename the skb->nf_skip_egress bit/flag to skb->skip_egress

Arm the flag only from the egress classifier that can use it: raise skip_txqueue from tcf_skbedit_act() only when it runs inside sch_handle_egress(), thanks to skb->nf_skip_egress. An egress qdisc classifier runs in q->enqueue(), after the tx queue has been picked, so a mapping it sets cannot affect the current packet; arming the flag there only pollutes it for a later xmit. Then own the flag for the xmit frame the egress hook runs in: save the incoming value and clear it just before sch_handle_egress(), and restore it after the hook - on the consumed (drop) path, or, in the same call that reads it, on the surviving path. The save and the restores stay inside the egress_needed_key static branch, so a packet pays for them only when egress hooks are active (2f1e85b1aee4).

Store the value netdev_cap_txqueue() selected back into skb->queue_mapping in netdev_tx_queue_mapping(), as netdev_core_pick_tx() already does, so the skip_txqueue path never hands a later reader on the xmit path a mapping the device cannot serve. A store made still later in the same frame, by a tc BPF program attached to a transmit qdisc, is outside this path and is not re-capped; a separate followup will resolve that path.

netdev_xmit_skip_txqueue() returns the previous flag value so the save-and-clear is one call, and a no-op stub is provided when CONFIG_NET_EGRESS is disabled. skb->nf_skip_egress is compiled under CONFIG_NET_EGRESS rather than CONFIG_NETFILTER_SKIP_EGRESS, so skb_at_tc_egress() is valid whenever the egress path is built.

A local user in a network namespace can redirect a packet from a device with more TX queues to one with fewer after setting a mapping valid only on the larger device. That reaches these reads and, under KASAN, faults with "slab-out-of-bounds in taprio_enqueue".

Conditions to recreate the bug: the report's own trigger is a local user with CAP_NET_ADMIN in a network namespace, so no eBPF program is needed. With CONFIG_NET_SCH_TAPRIO=y, CONFIG_NET_ACT_SKBEDIT=y, CONFIG_NET_ACT_MIRRED=y, CONFIG_NET_CLS_MATCHALL=y, CONFIG_NET_SCH_PRIO=y and KASAN enabled, create qa (3 queues), qb (2 queues) and qc (1 queue) as dummy devices; put a taprio root on qb (num_tc 1, queues 2@0) and clsact on all three; then add an egress matchall filter on every device. On qa: "action skbedit queue_mapping 2 pipe action mirred egress redirect dev qb". On qb: "action mirred egress mirror dev qc". On qc: "action skbedit queue_mapping 0 pipe". Send one packet out qa. qc's skbedit sets the flag while qb's outer xmit is in flight; without the fix qb consumes it and reads its two-entry taprio child array with the forwarded packet's stale mapping. A qc whose skbedit is instead installed in a transmit-qdisc classifier (a matchall filter on the qc root qdisc) reaches the same code path the same way without the fix.

Testing: on a KASAN build with panic_on_warn=1 the unfixed kernel panics with "BUG: KASAN: slab-out-of-bounds in taprio_enqueue", a read 0 bytes past a 16-byte taprio_init() allocation, for the clsact-setter and the transmit-qdisc-classifier reproducers and for a clsact skbedit-then-tc-BPF store; the fixed kernel runs all three with no report, and the BPF store variant additionally shows the expected "selects TX queue" clamp notice from the write-back.

---
 include/linux/netfilter_netdev.h |  2 +-
 include/linux/rtnetlink.h        |  7 ++++++-
 include/linux/skbuff.h           |  2 +-
 include/net/sch_generic.h        |  9 +++++++++
 net/core/dev.c                   | 31 ++++++++++++++++++++++++-------
 net/sched/act_skbedit.c          |  5 ++---
 6 files changed, 43 insertions(+), 13 deletions(-)
include/linux/netfilter_netdev.h +1 -1
index 8676316547cc4..f2496ea52754b 100644
@@ -132,7 +132,7 @@ static inline struct sk_buff *nf_hook_egress(struct sk_buff *skb, int *rc,
 
 static inline void nf_skip_egress(struct sk_buff *skb, bool skip)
 {
-#ifdef CONFIG_NETFILTER_SKIP_EGRESS
+#ifdef CONFIG_NET_EGRESS
 	skb->nf_skip_egress = skip;
 #endif
 }
include/linux/rtnetlink.h +6 -1
index f1d8f59640284..91eaee7cd5e38 100644
@@ -174,7 +174,12 @@ void net_dec_ingress_queue(void);
 #ifdef CONFIG_NET_EGRESS
 void net_inc_egress_queue(void);
 void net_dec_egress_queue(void);
-void netdev_xmit_skip_txqueue(bool skip);
+bool netdev_xmit_skip_txqueue(bool skip);
+#else
+static inline bool netdev_xmit_skip_txqueue(bool skip)
+{
+	return false;
+}
 #endif
 
 void rtnetlink_init(void);
include/linux/skbuff.h +1 -1
index 84f2f6f112799..df548a3d60657 100644
@@ -1001,7 +1001,7 @@ struct sk_buff {
 #ifdef CONFIG_NET_REDIRECT
 	__u8			from_ingress:1;
 #endif
-#ifdef CONFIG_NETFILTER_SKIP_EGRESS
+#ifdef CONFIG_NET_EGRESS
 	__u8			nf_skip_egress:1;
 #endif
 #ifdef CONFIG_SKB_DECRYPTED
include/net/sch_generic.h +9 -0
index 2c1bb37c929ee..4f38a7a5dd6a6 100644
@@ -772,6 +772,15 @@ static inline bool skb_at_tc_ingress(const struct sk_buff *skb)
 #endif
 }
 
+static inline bool skb_at_tc_egress(const struct sk_buff *skb)
+{
+#ifdef CONFIG_NET_EGRESS
+	return skb->nf_skip_egress && !skb_at_tc_ingress(skb);
+#else
+	return false;
+#endif
+}
+
 static inline bool skb_skip_tc_classify(struct sk_buff *skb)
 {
 #ifdef CONFIG_NET_CLS_ACT
net/core/dev.c +24 -7
index 97be4f9dfa771..a4554020076f4 100644
@@ -4063,9 +4063,14 @@ EXPORT_SYMBOL(dev_loopback_xmit);
 static struct netdev_queue *
 netdev_tx_queue_mapping(struct net_device *dev, struct sk_buff *skb)
 {
-	int qm = skb_get_queue_mapping(skb);
+	int queue = skb_get_queue_mapping(skb);
+	int capped;
 
-	return netdev_get_tx_queue(dev, netdev_cap_txqueue(dev, qm));
+	capped = netdev_cap_txqueue(dev, queue);
+	if (unlikely(capped != queue))
+		skb_set_queue_mapping(skb, capped);
+
+	return netdev_get_tx_queue(dev, capped);
 }
 
 #ifndef CONFIG_PREEMPT_RT
@@ -4074,9 +4079,13 @@ static bool netdev_xmit_txqueue_skipped(void)
 	return __this_cpu_read(softnet_data.xmit.skip_txqueue);
 }
 
-void netdev_xmit_skip_txqueue(bool skip)
+bool netdev_xmit_skip_txqueue(bool skip)
 {
+	bool prev = netdev_xmit_txqueue_skipped();
+
 	__this_cpu_write(softnet_data.xmit.skip_txqueue, skip);
+
+	return prev;
 }
 EXPORT_SYMBOL_GPL(netdev_xmit_skip_txqueue);
 
@@ -4086,9 +4095,13 @@ static bool netdev_xmit_txqueue_skipped(void)
 	return current->net_xmit.skip_txqueue;
 }
 
-void netdev_xmit_skip_txqueue(bool skip)
+bool netdev_xmit_skip_txqueue(bool skip)
 {
+	bool prev = netdev_xmit_txqueue_skipped();
+
 	current->net_xmit.skip_txqueue = skip;
+
+	return prev;
 }
 EXPORT_SYMBOL_GPL(netdev_xmit_skip_txqueue);
 #endif
@@ -4475,21 +4488,25 @@ int __dev_queue_xmit(struct sk_buff *skb, struct net_device *sb_dev)
 	tcx_set_ingress(skb, false);
 #ifdef CONFIG_NET_EGRESS
 	if (static_branch_unlikely(&egress_needed_key)) {
+		bool skip_txq;
+
 		if (nf_hook_egress_active()) {
 			skb = nf_hook_egress(skb, &rc, dev);
 			if (!skb)
 				goto out;
 		}
 
-		netdev_xmit_skip_txqueue(false);
+		skip_txq = netdev_xmit_skip_txqueue(false);
 
 		nf_skip_egress(skb, true);
 		skb = sch_handle_egress(skb, &rc, dev);
-		if (!skb)
+		if (!skb) {
+			netdev_xmit_skip_txqueue(skip_txq);
 			goto out;
+		}
 		nf_skip_egress(skb, false);
 
-		if (netdev_xmit_txqueue_skipped())
+		if (netdev_xmit_skip_txqueue(skip_txq))
 			txq = netdev_tx_queue_mapping(dev, skb);
 	}
 #endif
net/sched/act_skbedit.c +2 -3
index 5450c1293eb50..4cddf2674373f 100644
@@ -72,9 +72,8 @@ TC_INDIRECT_SCOPE int tcf_skbedit_act(struct sk_buff *skb,
 	}
 	if (params->flags & SKBEDIT_F_QUEUE_MAPPING &&
 	    skb->dev->real_num_tx_queues > params->queue_mapping) {
-#ifdef CONFIG_NET_EGRESS
-		netdev_xmit_skip_txqueue(true);
-#endif
+		if (skb_at_tc_egress(skb))
+			netdev_xmit_skip_txqueue(true);
 		skb_set_queue_mapping(skb, tcf_skbedit_hash(params, skb));
 	}
 	if (params->flags & SKBEDIT_F_MARK) {
Signature · 1 line
2.53.0
author maintainer
#93 lore raw

PATCH 93/497 net: ethernet: mtk_eth_soc: allocate dummy netdev sooner

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Sandeep Haemoon <[email protected]>

[ Upstream commit 6f0c2c4f5e7143eba75153ecc8af3a03f7b6a98b ]

The RX rings and the shared NAPI are carried by an internal "dummy" netdev (eth->dummy_dev). mtk_probe() creates that dummy device, and adds the shared tx/rx NAPI to it, only after the MAC netdevs have been registered. That order has been there since the MT7623 support was added and leaves a window in which the netdevs are visible to the network core before the shared NAPI and the dummy device exist.

If anything brings the first netdev up during that window (e.g. netifd opening the WAN link the instant the interface is registered), the first-open path runs without them. On NETSYS v2 and later SoCs mtk_rx_alloc() -> __xdp_rxq_info_reg() then dereferences eth->dummy_dev == NULL:

  WARNING: CPU: ... Missing net_device from driver

in net/core/xdp.c and mtk_open() fails with -ENODEV. On NETSYS v1 SoCs (MT7621/MT7622/MT7623/MT7629) there is no page pool, so the same open instead calls napi_enable() on a napi_struct that netif_napi_add() has not initialised yet and dereferences a NULL napi->dev.

Allocate the dummy netdev and add the shared tx/rx NAPI to it before the register_netdev() loop. Both the dummy-allocation failure and a register_netdev() failure now unwind through mtk_unreg_dev(), which unregisters the net_device notifiers and the netdevs registered so far, stopping a concurrently-opened netdev (ndo_stop) and its NAPI before the dummy carrier is freed.

A netdev that opened during the window can also have queued the frame-engine reset worker (via the tx watchdog or phylink), so the probe error path now cancels eth->pending_work before freeing the shared state, as mtk_cleanup() already does on remove.

Fixes 656e705243fd ("net-next: mediatek: add support for MT7623 ethernet")
---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 38 ++++++++++++++-------
 1 file changed, 26 insertions(+), 12 deletions(-)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +26 -12
index 4c9ebbb1b4f18..489c909e7327f 100644
@@ -5125,6 +5125,22 @@ static int mtk_probe(struct platform_device *pdev)
 		}
 	}
 
+	/* we run 2 devices on the same DMA ring so we need a dummy device
+	 * for NAPI to work. Allocate it before registering the netdevs so a
+	 * concurrent ndo_open (e.g. netifd bringing the first netdev up the
+	 * instant it is registered) never observes eth->dummy_dev == NULL in
+	 * mtk_dma_init() -> mtk_rx_alloc() -> __xdp_rxq_info_reg() (net/core/xdp.c
+	 * "Missing net_device from driver") and fails the first open.
+	 */
+	eth->dummy_dev = alloc_netdev_dummy(0);
+	if (!eth->dummy_dev) {
+		err = -ENOMEM;
+		dev_err(eth->dev, "failed to allocated dummy device\n");
+		goto err_unreg_netdev;
+	}
+	netif_napi_add(eth->dummy_dev, &eth->tx_napi, mtk_napi_tx);
+	netif_napi_add(eth->dummy_dev, &eth->rx_napi, mtk_napi_rx);
+
 	for (i = 0; i < MTK_MAX_DEVS; i++) {
 		if (!eth->netdev[i])
 			continue;
@@ -5139,18 +5155,6 @@ static int mtk_probe(struct platform_device *pdev)
 				   eth->netdev[i]->base_addr, eth->irq[MTK_FE_IRQ_SHARED]);
 	}
 
-	/* we run 2 devices on the same DMA ring so we need a dummy device
-	 * for NAPI to work
-	 */
-	eth->dummy_dev = alloc_netdev_dummy(0);
-	if (!eth->dummy_dev) {
-		err = -ENOMEM;
-		dev_err(eth->dev, "failed to allocated dummy device\n");
-		goto err_unreg_netdev;
-	}
-	netif_napi_add(eth->dummy_dev, &eth->tx_napi, mtk_napi_tx);
-	netif_napi_add(eth->dummy_dev, &eth->rx_napi, mtk_napi_rx);
-
 	platform_set_drvdata(pdev, eth);
 	schedule_delayed_work(&eth->reset.monitor_work,
 			      MTK_DMA_MONITOR_TIMEOUT);
@@ -5160,6 +5164,16 @@ static int mtk_probe(struct platform_device *pdev)
 err_unreg_netdev:
 	mtk_unreg_dev(eth);
 err_deinit_ppe:
+	/* A netdev opened while probe was still registering can have queued
+	 * the frame-engine reset worker, which takes rtnl and drives the
+	 * hardware; cancel it before anything below is torn down.
+	 */
+	cancel_work_sync(&eth->pending_work);
+	if (eth->dummy_dev) {
+		netif_napi_del(&eth->tx_napi);
+		netif_napi_del(&eth->rx_napi);
+		free_netdev(eth->dummy_dev);
+	}
 	mtk_ppe_deinit(eth);
 	mtk_mdio_cleanup(eth);
 err_free_dev:
Signature · 1 line
2.53.0
author maintainer
#94 lore raw

PATCH 94/497 tcp: refresh TS.Recent for accepted old ACKs

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jeff Jo <[email protected]>

[ Upstream commit 1b92780ae4fc3be64f05d97ed8833c445e73b0cf ]

A TCP packet can carry new data while acknowledging traffic in the opposite direction. With overlapping traffic in both directions, a delayed packet's acknowledgment can be older than one Linux has already accepted, even when that packet fills a gap in the received data.

Linux accepts the data, but tcp_ack() takes the old_ack path and skips updating TS.Recent, the timestamp saved for outgoing acknowledgments. The reply therefore echoes an older timestamp. If the sender uses this echo to measure round-trip time after a long idle period, its estimate includes the idle time and can reduce its sending rate.

Update TS.Recent in old_ack using tcp_replace_ts_recent(), before SACK processing can trigger a transmission. This reuses the existing timestamp and sequence checks, including PAWS protection against old duplicate packets. ACK validation already rejects old ACKs in SYN_RECV before this path, so no additional state check is needed.

Echoing the timestamp of the packet that fills the receive gap follows RFC 7323 section 4.3. In a socket reproduction with 300 seconds idle, controlled reordering and retransmission to exercise timestamp-based RTT sampling, the sender's smoothed round-trip time was 37.5 seconds without the fix and 15.5 ms with it.

Fixes 12fb3dd9dc3c ("tcp: call tcp_replace_ts_recent() from tcp_ack()")
Assisted-by LLM sparse
---
 net/ipv4/tcp_input.c | 6 ++++++
 1 file changed, 6 insertions(+)
net/ipv4/tcp_input.c +6 -0
index c3aeb985f819d..5c581d4821c1d 100644
@@ -4134,6 +4134,12 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
 	return 1;
 
 old_ack:
+	/* An old ACK can carry new data. Update TS.Recent before SACK
+	 * processing can trigger a retransmission.
+	 */
+	if (flag & FLAG_UPDATE_TS_RECENT)
+		tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq);
+
 	/* If data was SACKed, tag it and see if we should send more data.
 	 * If data was DSACKed, see if we can undo a cwnd reduction.
 	 */
Signature · 1 line
2.53.0
author maintainer
#95 lore raw

PATCH 95/497 ipvs: fix missing counter decrement in lblc

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Julian Anastasov <[email protected]>

[ Upstream commit bdac17779f46817f60103baf09f0370546c3f023 ]

LBLC may delete cache entries for destinations that are removed or overloaded and replace them with available ones. But ip_vs_lblc_new() forgets to decrement the tbl->entries counter after calling ip_vs_lblc_del(). This can lead to increased shrinking of the cache with every new garbage collection.

---
 net/netfilter/ipvs/ip_vs_lblc.c | 1 +
 1 file changed, 1 insertion(+)
net/netfilter/ipvs/ip_vs_lblc.c +1 -0
index d22f8154ff949..b8bab41ee6ff5 100644
@@ -204,6 +204,7 @@ ip_vs_lblc_new(struct ip_vs_lblc_table *tbl, const union nf_inet_addr *daddr,
 		if (en->dest == dest)
 			return en;
 		ip_vs_lblc_del(en);
+		atomic_dec(&tbl->entries);
 	}
 	en = kmalloc(sizeof(*en), GFP_ATOMIC);
 	if (!en)
Signature · 1 line
2.53.0
author maintainer
#96 lore raw

PATCH 96/497 ipvs: do not create invisible templates

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Julian Anastasov <[email protected]>

[ Upstream commit 616cf5c06934364ab1002b420ebe975850b4b208 ]

The IP_VS_CONN_F_ONE_PACKET flag was implemented for normal connections. When conn template inherits this flag from dest->conn_flags it will not be hashed. As result, we will create new template for every new normal connection.

Fix it to allow one template to be used by many normal connections.

---
 net/netfilter/ipvs/ip_vs_conn.c | 3 +++
 1 file changed, 3 insertions(+)
net/netfilter/ipvs/ip_vs_conn.c +3 -0
index d7a7e26e9c697..1dbb61fff18b0 100644
@@ -591,6 +591,9 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
 	if (cp->protocol != IPPROTO_UDP)
 		conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
 	flags = cp->flags;
+	/* Only visible templates can control multiple connections */
+	if (flags & IP_VS_CONN_F_TEMPLATE)
+		conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
 	/* Bind with the destination and its corresponding transmitter */
 	if (flags & IP_VS_CONN_F_SYNC) {
 		/* Synced conns are hashed, so they can not get this flag */
Signature · 1 line
2.53.0
author maintainer
#97 lore raw

PATCH 97/497 ipvs: filter some flags received in the backup server

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Julian Anastasov <[email protected]>

[ Upstream commit f96e91748f6304668fe647e686d199d7207d36f1 ]

While the IPVS SYNC protocol is not secure by design we can still protect the backup server from messages that can wreak havoc.

This commit addresses problems from received connection flags or their combinations. We now drop messages as follows:

1. the NO_CPORT+TEMPLATE combination allows lookups for normal connections to hit template which can break in many ways. While the master does not sync connections with NO_CPORT flag, i.e. before they are established, we still accept NO_CPORT without TEMPLATE.

2. ONE_PACKET: it is not sent by master, so we do not expect it in backup. Before now it was ignored by IP_VS_CONN_F_BACKUP_MASK for protocol v1 while protocol v0 created connections that are not hashed and dropped immediately. Better to apply the IP_VS_CONN_F_BACKUP_MASK also to the flags from v0 messages for consistency with v1.

Fixes 87375ab47cd0 ("[IPVS]: ip_vs_ftp breaks connections using persistence")
---
 net/netfilter/ipvs/ip_vs_sync.c | 33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)
net/netfilter/ipvs/ip_vs_sync.c +30 -3
index 699651e84d832..b835f61886d6d 100644
@@ -950,6 +950,21 @@ static void ip_vs_proc_conn(struct netns_ipvs *ipvs, struct ip_vs_conn_param *pa
 	ip_vs_conn_put(cp);
 }
 
+/* Check for incompatible flags */
+static bool ip_vs_sync_validate_flags(u32 flags)
+{
+	/* We do not expect NO_CPORT, especially to allow lookups
+	 * to hit templates
+	 */
+	if (flags & IP_VS_CONN_F_NO_CPORT) {
+		if (flags & IP_VS_CONN_F_TEMPLATE)
+			return false;
+	}
+	if (flags & IP_VS_CONN_F_ONE_PACKET)
+		return false;
+	return true;
+}
+
 /*
  *  Process received multicast message for Version 0
  */
@@ -973,8 +988,7 @@ static void ip_vs_process_message_v0(struct netns_ipvs *ipvs, const char *buffer
 			return;
 		}
 		s = (struct ip_vs_sync_conn_v0 *) p;
-		flags = ntohs(s->flags) | IP_VS_CONN_F_SYNC;
-		flags &= ~IP_VS_CONN_F_HASHED;
+		flags = ntohs(s->flags);
 		if (flags & IP_VS_CONN_F_SEQ_MASK) {
 			opt = (struct ip_vs_sync_conn_options *)&s[1];
 			p += FULL_CONN_SIZE;
@@ -987,6 +1001,13 @@ static void ip_vs_process_message_v0(struct netns_ipvs *ipvs, const char *buffer
 			p += SIMPLE_CONN_SIZE;
 		}
 
+		if (!ip_vs_sync_validate_flags(flags)) {
+			IP_VS_DBG(2, "BACKUP v0, Invalid flags 0x%X\n", flags);
+			continue;
+		}
+		flags &= IP_VS_CONN_F_BACKUP_MASK;
+		flags |= IP_VS_CONN_F_SYNC;
+
 		state = ntohs(s->state);
 		if (!(flags & IP_VS_CONN_F_TEMPLATE)) {
 			pp = ip_vs_proto_get(s->protocol);
@@ -1142,7 +1163,13 @@ static inline int ip_vs_proc_sync_conn(struct netns_ipvs *ipvs, __u8 *p, __u8 *m
 	}
 
 	/* Get flags and Mask off unsupported */
-	flags  = ntohl(s->v4.flags) & IP_VS_CONN_F_BACKUP_MASK;
+	flags = ntohl(s->v4.flags);
+	if (!ip_vs_sync_validate_flags(flags)) {
+		IP_VS_DBG(3, "BACKUP, Invalid flags 0x%X\n", flags);
+		retc = 25;
+		goto out;
+	}
+	flags &= IP_VS_CONN_F_BACKUP_MASK;
 	flags |= IP_VS_CONN_F_SYNC;
 	state = ntohs(s->v4.state);
 
Signature · 1 line
2.53.0
author maintainer
#98 lore raw

PATCH 98/497 netfilter: bpf: reject invalid NAT manipulation types

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Fernando Fernandez Mancera <[email protected]>

[ Upstream commit 16d464013ec2267b00a83f4bfbb97b3ecc63bfa7 ]

As bpf_ct_set_nat_info() is not validating the NAT manipulation type a wrong value can be passed directly to nf_nat_setup_info(). This triggers the WARN_ON() at nf_nat_setup_info() and if panic_on_warn isn't set, then IPS_SRC_NAT_DONE is set without adding nat_bysource and conntrack cleanup tries to unlink an uninitialized hlist node.

Fix this by checking that NAT manipulation type is correct before calling nf_nat_setup_info(). In addition, if the WARN_ON is hit, return NF_DROP instead of continuing with the processing to avoid similar situations in the future.

Fixes 0fabd2aa199f ("net: netfilter: add bpf_ct_set_nat_info kfunc helper")
---
 net/netfilter/nf_nat_bpf.c  | 3 +++
 net/netfilter/nf_nat_core.c | 5 +++--
 2 files changed, 6 insertions(+), 2 deletions(-)
net/netfilter/nf_nat_bpf.c +3 -0
index 481be15609b16..ed01633c9289d 100644
@@ -39,6 +39,9 @@ __bpf_kfunc int bpf_ct_set_nat_info(struct nf_conn___init *nfct,
 	if (proto != NFPROTO_IPV4 && proto != NFPROTO_IPV6)
 		return -EINVAL;
 
+	if (manip != NF_NAT_MANIP_SRC && manip != NF_NAT_MANIP_DST)
+		return -EINVAL;
+
 	memset(&range, 0, sizeof(struct nf_nat_range2));
 	range.flags = NF_NAT_RANGE_MAP_IPS;
 	range.min_addr = *addr;
net/netfilter/nf_nat_core.c +3 -2
index 041ab3733baa3..34e1ff930e28d 100644
@@ -785,8 +785,9 @@ nf_nat_setup_info(struct nf_conn *ct,
 	if (nf_ct_is_confirmed(ct))
 		return NF_ACCEPT;
 
-	WARN_ON(maniptype != NF_NAT_MANIP_SRC &&
-		maniptype != NF_NAT_MANIP_DST);
+	if (WARN_ON(maniptype != NF_NAT_MANIP_SRC &&
+		    maniptype != NF_NAT_MANIP_DST))
+		return NF_DROP;
 
 	if (WARN_ON(nf_nat_initialized(ct, maniptype)))
 		return NF_DROP;
Signature · 1 line
2.53.0
author maintainer
#99 lore raw

PATCH 99/497 netfilter: conntrack: remove skb argument from nf_ct_refresh

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Florian Westphal <[email protected]>

[ Upstream commit 31768596b15aa8c9c55f078acad29d0238c8269b ]

Its not used (and could be NULL), so remove it.
This allows to use nf_ct_refresh in places where we don't have an skb without having to double-check that skb == NULL would be safe.

Stable-dep-of: 7c549fb7eecd ("netfilter: flowtable: generalize pending status bit")

---
 include/net/netfilter/nf_conntrack.h   | 8 +++-----
 net/netfilter/nf_conntrack_amanda.c    | 2 +-
 net/netfilter/nf_conntrack_broadcast.c | 2 +-
 net/netfilter/nf_conntrack_core.c      | 7 +++----
 net/netfilter/nf_conntrack_h323_main.c | 4 ++--
 net/netfilter/nf_conntrack_sip.c       | 4 ++--
 net/netfilter/nft_ct.c                 | 2 +-
 7 files changed, 13 insertions(+), 16 deletions(-)
include/net/netfilter/nf_conntrack.h +3 -5
index 3d938a19d332a..91599d3ecc8a8 100644
@@ -209,8 +209,7 @@ bool nf_ct_get_tuplepr(const struct sk_buff *skb, unsigned int nhoff,
 		       struct nf_conntrack_tuple *tuple);
 
 void __nf_ct_refresh_acct(struct nf_conn *ct, enum ip_conntrack_info ctinfo,
-			  const struct sk_buff *skb,
-			  u32 extra_jiffies, bool do_acct);
+			  u32 extra_jiffies, unsigned int bytes);
 
 /* Refresh conntrack for this many jiffies and do accounting */
 static inline void nf_ct_refresh_acct(struct nf_conn *ct,
@@ -218,15 +217,14 @@ static inline void nf_ct_refresh_acct(struct nf_conn *ct,
 				      const struct sk_buff *skb,
 				      u32 extra_jiffies)
 {
-	__nf_ct_refresh_acct(ct, ctinfo, skb, extra_jiffies, true);
+	__nf_ct_refresh_acct(ct, ctinfo, extra_jiffies, skb->len);
 }
 
 /* Refresh conntrack for this many jiffies */
 static inline void nf_ct_refresh(struct nf_conn *ct,
-				 const struct sk_buff *skb,
 				 u32 extra_jiffies)
 {
-	__nf_ct_refresh_acct(ct, 0, skb, extra_jiffies, false);
+	__nf_ct_refresh_acct(ct, 0, extra_jiffies, 0);
 }
 
 /* kill conntrack and do accounting */
net/netfilter/nf_conntrack_amanda.c +1 -1
index d011d2eb08486..7be4c35e4795e 100644
@@ -106,7 +106,7 @@ static int amanda_help(struct sk_buff *skb,
 
 	/* increase the UDP timeout of the master connection as replies from
 	 * Amanda clients to the server can be quite delayed */
-	nf_ct_refresh(ct, skb, master_timeout * HZ);
+	nf_ct_refresh(ct, master_timeout * HZ);
 
 	/* No data? */
 	dataoff = protoff + sizeof(struct udphdr);
net/netfilter/nf_conntrack_broadcast.c +1 -1
index 93c501d9d399c..75e53fde6b297 100644
@@ -80,7 +80,7 @@ int nf_conntrack_broadcast_help(struct sk_buff *skb,
 	nf_ct_expect_related(exp, 0);
 	nf_ct_expect_put(exp);
 
-	nf_ct_refresh(ct, skb, timeout * HZ);
+	nf_ct_refresh(ct, timeout * HZ);
 out:
 	return NF_ACCEPT;
 }
net/netfilter/nf_conntrack_core.c +3 -4
index 77a445a59af3e..da9367047baf4 100644
@@ -2065,9 +2065,8 @@ EXPORT_SYMBOL_GPL(nf_conntrack_in);
 /* Refresh conntrack for this many jiffies and do accounting if do_acct is 1 */
 void __nf_ct_refresh_acct(struct nf_conn *ct,
 			  enum ip_conntrack_info ctinfo,
-			  const struct sk_buff *skb,
 			  u32 extra_jiffies,
-			  bool do_acct)
+			  unsigned int bytes)
 {
 	/* Only update if this is not a fixed timeout */
 	if (test_bit(IPS_FIXED_TIMEOUT_BIT, &ct->status))
@@ -2080,8 +2079,8 @@ void __nf_ct_refresh_acct(struct nf_conn *ct,
 	if (READ_ONCE(ct->timeout) != extra_jiffies)
 		WRITE_ONCE(ct->timeout, extra_jiffies);
 acct:
-	if (do_acct)
-		nf_ct_acct_update(ct, CTINFO2DIR(ctinfo), skb->len);
+	if (bytes)
+		nf_ct_acct_update(ct, CTINFO2DIR(ctinfo), bytes);
 }
 EXPORT_SYMBOL_GPL(__nf_ct_refresh_acct);
 
net/netfilter/nf_conntrack_h323_main.c +2 -2
index c42547284f351..a116c6629e2b8 100644
@@ -1385,7 +1385,7 @@ static int process_rcf(struct sk_buff *skb, struct nf_conn *ct,
 	if (info->timeout > 0) {
 		pr_debug("nf_ct_ras: set RAS connection timeout to "
 			 "%u seconds\n", info->timeout);
-		nf_ct_refresh(ct, skb, info->timeout * HZ);
+		nf_ct_refresh(ct, info->timeout * HZ);
 
 		/* Set expect timeout */
 		spin_lock_bh(&nf_conntrack_expect_lock);
@@ -1433,7 +1433,7 @@ static int process_urq(struct sk_buff *skb, struct nf_conn *ct,
 	info->sig_port[!dir] = 0;
 
 	/* Give it 30 seconds for UCF or URJ */
-	nf_ct_refresh(ct, skb, 30 * HZ);
+	nf_ct_refresh(ct, 30 * HZ);
 
 	return 0;
 }
net/netfilter/nf_conntrack_sip.c +2 -2
index 2b5f807436e2c..5b75e9bc99e9f 100644
@@ -1646,7 +1646,7 @@ static int sip_help_tcp(struct sk_buff *skb, unsigned int protoff,
 	if (dataoff >= skb->len)
 		return NF_ACCEPT;
 
-	nf_ct_refresh(ct, skb, sip_timeout * HZ);
+	nf_ct_refresh(ct, sip_timeout * HZ);
 
 	if (unlikely(skb_linearize(skb)))
 		return NF_DROP;
@@ -1720,7 +1720,7 @@ static int sip_help_udp(struct sk_buff *skb, unsigned int protoff,
 	if (dataoff >= skb->len)
 		return NF_ACCEPT;
 
-	nf_ct_refresh(ct, skb, sip_timeout * HZ);
+	nf_ct_refresh(ct, sip_timeout * HZ);
 
 	if (unlikely(skb_linearize(skb)))
 		return NF_DROP;
net/netfilter/nft_ct.c +1 -1
index 8feea8b2422b0..c238c97a90536 100644
@@ -884,7 +884,7 @@ static void nft_ct_timeout_obj_eval(struct nft_object *obj,
 	 */
 	values = nf_ct_timeout_data(timeout);
 	if (values)
-		nf_ct_refresh(ct, pkt->skb, values[0]);
+		nf_ct_refresh(ct, values[0]);
 }
 
 static int nft_ct_timeout_obj_init(const struct nft_ctx *ctx,
Signature · 1 line
2.53.0
author maintainer
#100 lore raw

PATCH 100/497 netfilter: conntrack: rework offload nf_conn timeout extension logic

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Florian Westphal <[email protected]>

[ Upstream commit 03428ca5cee9f0792edc996c06ce4514816af1fb ]

Offload nf_conn entries may not see traffic for a very long time.

To prevent incorrect 'ct is stale' checks during nf_conntrack table lookup, the gc worker extends the timeout nf_conn entries marked for offload to a large value.

The existing logic suffers from a few problems.

Garbage collection runs without locks, its unlikely but possible that @ct is removed right after the 'offload' bit test.

In that case, the timeout of a new/reallocated nf_conn entry will be increased.

Prevent this by obtaining a reference count on the ct object and re-check of the confirmed and offload bits.

If those are not set, the ct is being removed, skip the timeout extension in this case.

Parallel teardown is also problematic:
cpu1 cpu2
gc_worker
calls flow_offload_teardown()
tests OFFLOAD bit, set
clear OFFLOAD bit
ct->timeout is repaired (e.g. set to timeout[UDP_CT_REPLIED])
nf_ct_offload_timeout() called
expire value is fetched
<INTERRUPT>
-> NF_CT_DAY timeout for flow that isn't offloaded
(and might not see any further packets).

Use cmpxchg: if ct->timeout was repaired after the 2nd 'offload bit' test passed, then ct->timeout will only be updated of ct->timeout was not altered in between.

As we already have a gc worker for flowtable entries, ct->timeout repair can be handled from the flowtable gc worker.

This avoids having flowtable specific logic in the conntrack core and avoids checking entries that were never offloaded.

This allows to remove the nf_ct_offload_timeout helper. Its safe to use in the add case, but not on teardown.

Stable-dep-of: 7c549fb7eecd ("netfilter: flowtable: generalize pending status bit")

---
 include/net/netfilter/nf_conntrack.h |  10 ---
 net/netfilter/nf_conntrack_core.c    |   6 --
 net/netfilter/nf_flow_table_core.c   | 105 ++++++++++++++++++++++++++-
 3 files changed, 103 insertions(+), 18 deletions(-)
include/net/netfilter/nf_conntrack.h +0 -10
index 91599d3ecc8a8..77a09bc88611e 100644
@@ -328,16 +328,6 @@ static inline bool nf_ct_should_gc(const struct nf_conn *ct)
 
 #define	NF_CT_DAY	(86400 * HZ)
 
-/* Set an arbitrary timeout large enough not to ever expire, this save
- * us a check for the IPS_OFFLOAD_BIT from the packet path via
- * nf_ct_is_expired().
- */
-static inline void nf_ct_offload_timeout(struct nf_conn *ct)
-{
-	if (nf_ct_expires(ct) < NF_CT_DAY / 2)
-		WRITE_ONCE(ct->timeout, nfct_time_stamp + NF_CT_DAY);
-}
-
 struct kernel_param;
 
 int nf_conntrack_set_hashsize(const char *val, const struct kernel_param *kp);
net/netfilter/nf_conntrack_core.c +0 -6
index da9367047baf4..f9a60576d119f 100644
@@ -1515,12 +1515,6 @@ static void gc_worker(struct work_struct *work)
 
 			tmp = nf_ct_tuplehash_to_ctrack(h);
 
-			if (test_bit(IPS_OFFLOAD_BIT, &tmp->status)) {
-				nf_ct_offload_timeout(tmp);
-				if (!nf_conntrack_max95)
-					continue;
-			}
-
 			if (expired_count > GC_SCAN_EXPIRED_MAX) {
 				rcu_read_unlock();
 
net/netfilter/nf_flow_table_core.c +103 -2

125 lines not on this page · raw message

Signature · 1 line
2.53.0
author maintainer
#101 lore raw

PATCH 101/497 netfilter: flowtable: generalize pending status bit

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Pablo Neira Ayuso <[email protected]>

[ Upstream commit 7c549fb7eecd01fdba7c0d12c01da876ef8a3214 ]

Rename NF_FLOW_HW_PENDING to NF_FLOW_PENDING and use it to inhibit the flowtable GC worker until pending hw offload work has been completed.

Apparently, nf_flow_offload_stats() can schedule work to retrieve stats while the flow is being removed by GC.

And this bit can also be used in a follow up patch to disable GC until the flow has been fully added in both directions.

Revert the reordering done in commit d644b23afe1e ("netfilter:
flowtable: publish HW_DEAD after worker is done") to prevent a race between GC and hw offload handler.

Fixes 2c8897953f3b ("netfilter: flowtable: Add pending bit for offload work")
---
 include/net/netfilter/nf_flow_table.h |  2 +-
 net/netfilter/nf_flow_table_core.c    |  7 ++++++-
 net/netfilter/nf_flow_table_offload.c | 14 +++++---------
 net/sched/act_ct.c                    |  2 +-
 4 files changed, 13 insertions(+), 12 deletions(-)
include/net/netfilter/nf_flow_table.h +1 -1
index 1a6fca0131653..714330cf9ca76 100644
@@ -164,10 +164,10 @@ enum nf_flow_flags {
 	NF_FLOW_SNAT,
 	NF_FLOW_DNAT,
 	NF_FLOW_TEARDOWN,
+	NF_FLOW_PENDING,
 	NF_FLOW_HW,
 	NF_FLOW_HW_DYING,
 	NF_FLOW_HW_DEAD,
-	NF_FLOW_HW_PENDING,
 	NF_FLOW_HW_BIDIRECTIONAL,
 	NF_FLOW_HW_ESTABLISHED,
 };
net/netfilter/nf_flow_table_core.c +6 -1
index 0b02b8a2e0dcb..87399eecbbc35 100644
@@ -522,7 +522,12 @@ static void nf_flow_table_extend_ct_timeout(struct nf_conn *ct)
 static void nf_flow_offload_gc_step(struct nf_flowtable *flow_table,
 				    struct flow_offload *flow, void *data)
 {
-	bool teardown = test_bit(NF_FLOW_TEARDOWN, &flow->flags);
+	bool teardown;
+
+	if (test_bit(NF_FLOW_PENDING, &flow->flags))
+		return;
+
+	teardown = test_bit(NF_FLOW_TEARDOWN, &flow->flags);
 
 	if (nf_flow_has_expired(flow) ||
 	    nf_ct_is_dying(flow->ct) ||
net/netfilter/nf_flow_table_offload.c +5 -9
index 8e3edc7c37b38..2af7d64696044 100644
@@ -993,6 +993,7 @@ static void flow_offload_work_del(struct flow_offload_work *offload)
 	flow_offload_tuple_del(offload, FLOW_OFFLOAD_DIR_ORIGINAL);
 	if (test_bit(NF_FLOW_HW_BIDIRECTIONAL, &offload->flow->flags))
 		flow_offload_tuple_del(offload, FLOW_OFFLOAD_DIR_REPLY);
+	set_bit(NF_FLOW_HW_DEAD, &offload->flow->flags);
 }
 
 static void flow_offload_tuple_stats(struct flow_offload_work *offload,
@@ -1054,13 +1055,8 @@ static void flow_offload_work_handler(struct work_struct *work)
 		default:
 			WARN_ON_ONCE(1);
 	}
-
-	clear_bit(NF_FLOW_HW_PENDING, &offload->flow->flags);
-	if (offload->cmd == FLOW_CLS_DESTROY) {
-		/* Publish after the worker's last flow access. */
-		smp_mb__before_atomic();
-		set_bit(NF_FLOW_HW_DEAD, &offload->flow->flags);
-	}
+	smp_mb__before_atomic();
+	clear_bit(NF_FLOW_PENDING, &offload->flow->flags);
 
 	kfree(offload);
 }
@@ -1087,12 +1083,12 @@ nf_flow_offload_work_alloc(struct nf_flowtable *flowtable,
 {
 	struct flow_offload_work *offload;
 
-	if (test_and_set_bit(NF_FLOW_HW_PENDING, &flow->flags))
+	if (test_and_set_bit(NF_FLOW_PENDING, &flow->flags))
 		return NULL;
 
 	offload = kmalloc(sizeof(struct flow_offload_work), GFP_ATOMIC);
 	if (!offload) {
-		clear_bit(NF_FLOW_HW_PENDING, &flow->flags);
+		clear_bit(NF_FLOW_PENDING, &flow->flags);
 		return NULL;
 	}
 
net/sched/act_ct.c +1 -1
index 154be631b038a..9c7e089f55d39 100644
@@ -287,7 +287,7 @@ static bool tcf_ct_flow_is_outdated(const struct flow_offload *flow)
 {
 	return test_bit(IPS_SEEN_REPLY_BIT, &flow->ct->status) &&
 	       test_bit(IPS_HW_OFFLOAD_BIT, &flow->ct->status) &&
-	       !test_bit(NF_FLOW_HW_PENDING, &flow->flags) &&
+	       !test_bit(NF_FLOW_PENDING, &flow->flags) &&
 	       !test_bit(NF_FLOW_HW_ESTABLISHED, &flow->flags);
 }
 
Signature · 1 line
2.53.0
author maintainer
#102 lore raw

PATCH 102/497 net: microchip: vcap: stop scanning after deleting key field

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Harshit Mogalapalli <[email protected]>

[ Upstream commit 99b43ede9e355ba35244cc9470bf1819774ce39d ]

The only call outside the KUnit tests is in sparx5_tc_add_rule_copy(), which passes a fixed key list with no duplicate entries. Therefore, the potential double-free is not currently reachable in tree.

However, vcap_filter_rule_keys() is exported and does not require its key list entries to be unique. If a future or external caller supplies the same key at another position that the inner loop visits, it calls list_del() and kfree() a second time on the freed field, leading to a potential double-free.

Break the inner loop after removing a matching field. The outer safe list traversal continues to process the remaining rule fields.

Fixes 465a38a269e9 ("net: microchip: sparx5: Support for copying and modifying rules in the API")
---
 drivers/net/ethernet/microchip/vcap/vcap_api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/microchip/vcap/vcap_api.c +1 -1
index 49eef025d2900..4c55ff842ed7b 100644
@@ -3524,8 +3524,8 @@ int vcap_filter_rule_keys(struct vcap_rule *rule,
 				if (key == keylist[idx]) {
 					list_del(&ckf->ctrl.list);
 					kfree(ckf);
-					idx++;
 					err = 0;
+					break;
 				}
 		}
 	}
Signature · 1 line
2.53.0
author maintainer
#103 lore raw

PATCH 103/497 net: sparx5: make ports inherit the switch base mac address type

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Quentin Freimanis <[email protected]>

[ Upstream commit 5642b1648d5c4561d8ed7a410d0a7017f706604d ]

When the switch uses a random base MAC address it does not mark each port's address as random:

  $ dmesg | grep "MAC addr"
  sparx5-switch e00c0000.switch: MAC addr was not set, use random MAC
  $ cat /sys/class/net/eth0/addr_assign_type
  0

0 is NET_ADDR_PERM, so userspace thinks this is a stable address.

With a random MAC reported as NET_ADDR_PERM, systemd's MACAddressPolicy=persistent [1] leaves it unchanged, so a DHCP client gets a new IP address every boot and a static reservation can't be used. Reporting it as NET_ADDR_RANDOM makes systemd replace it with a stable address derived from the interface name and machine-id.

---
 drivers/net/ethernet/microchip/sparx5/sparx5_main.c   | 1 +
 drivers/net/ethernet/microchip/sparx5/sparx5_main.h   | 1 +
 drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c | 1 +
 3 files changed, 3 insertions(+)
drivers/net/ethernet/microchip/sparx5/sparx5_main.c +1 -0
index 0c4c75b3682fa..5b83cd4b6270b 100644
@@ -843,6 +843,7 @@ static int mchp_sparx5_probe(struct platform_device *pdev)
 		dev_info(sparx5->dev, "MAC addr was not set, use random MAC\n");
 		eth_random_addr(sparx5->base_mac);
 		sparx5->base_mac[5] = 0;
+		sparx5->base_mac_assign_type = NET_ADDR_RANDOM;
 	}
 
 	sparx5->fdma_irq = platform_get_irq_byname(sparx5->pdev, "fdma");
drivers/net/ethernet/microchip/sparx5/sparx5_main.h +1 -0
index 3309060b1e4c6..fde3e3d686d17 100644
@@ -252,6 +252,7 @@ struct sparx5 {
 	struct notifier_block switchdev_blocking_nb;
 	/* Switch state */
 	u8 base_mac[ETH_ALEN];
+	u8 base_mac_assign_type;
 	/* Associated bridge device (when bridged) */
 	struct net_device *hw_bridge_dev;
 	/* Bridged interfaces */
drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c +1 -0
index 705a004b324fd..62025aba558cd 100644
@@ -281,6 +281,7 @@ struct net_device *sparx5_create_netdev(struct sparx5 *sparx5, u32 portno)
 	ndev->ethtool_ops = &sparx5_ethtool_ops;
 
 	eth_hw_addr_gen(ndev, sparx5->base_mac, portno + 1);
+	ndev->addr_assign_type = sparx5->base_mac_assign_type;
 
 	return ndev;
 }
Signature · 1 line
2.53.0
author maintainer
#104 lore raw

PATCH 104/497 net/mlx5e: Fix AF_XDP TX timestamp teardown NULL dereference

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Prathamesh Deshpande <[email protected]>

[ Upstream commit 7b97273cbebe9dd4fddc457f0c4f2a124d0e3996 ]

During XSK TX queue teardown, outstanding descriptors are completed without a CQE. If one requested a TX timestamp, the completion path passes that NULL CQE to mlx5e_xsk_fill_timestamp(), which dereferences it.

Return zero when no CQE is available, indicating that teardown did not produce a TX timestamp.

Fixes ec706a860eba ("net/mlx5e: Implement AF_XDP TX timestamp and checksum offload")
---
 drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c +3 -0
index d4d2de017a504..1f56141616233 100644
@@ -292,6 +292,9 @@ static u64 mlx5e_xsk_fill_timestamp(void *_priv)
 	struct mlx5e_xsk_tx_complete *priv = _priv;
 	u64 ts;
 
+	if (!priv->cqe)
+		return 0;
+
 	ts = get_cqe_ts(priv->cqe);
 
 	if (mlx5_is_real_time_rq(priv->cq->mdev) || mlx5_is_real_time_sq(priv->cq->mdev))
Signature · 1 line
2.53.0
author maintainer
#105 lore raw

PATCH 105/497 ipv6: sr: use skb_get_hash_net() in seg6_make_flowlabel()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Eric Dumazet <[email protected]>

[ Upstream commit 8ec454dcd00ce3375119111c6394964455b36d0d ]

Since commit d58e468b1112 ("flow_dissector: implements flow dissector BPF hook") __skb_flow_dissect() needs a net pointer, either from skb->dev, skb->sk, or since commit 3cbf4ffba5ee ("net: plumb network namespace into __skb_flow_dissect") a caller provided pointer.

syzbot was able to reach seg6_make_flowlabel() with an skb having neither skb->dev nor skb->sk set: a TIPC UDP bearer sends a discovery message through an IPv4 route using seg6 encap, while net.ipv6.seg6_flowlabel is set to 1.

seg6_make_flowlabel() already has a net pointer, use skb_get_hash_net().

WARNING: net/core/flow_dissector.c:1131 at __skb_flow_dissect+0x910/0x5368 net/core/flow_dissector.c:1126, CPU#0: syz.0.17/4930
Call trace:
  __skb_flow_dissect+0x910/0x5368 net/core/flow_dissector.c:1126 (P)
  __skb_get_hash_net+0xe0/0x29c net/core/flow_dissector.c:1903
  skb_get_hash include/linux/skbuff.h:1663 [inline]
  seg6_make_flowlabel+0xcc/0x1ec net/ipv6/seg6_iptunnel.c:132
  __seg6_do_srh_encap+0x320/0xbf4 net/ipv6/seg6_iptunnel.c:161
  seg6_do_srh+0x4b4/0xa44 net/ipv6/seg6_iptunnel.c:431
  seg6_output_core+0x164/0x688 net/ipv6/seg6_iptunnel.c:681
  seg6_output+0x44/0x1ac net/ipv6/seg6_iptunnel.c:744
  lwtunnel_output+0x3d0/0x664 net/core/lwtunnel.c:356
  dst_output include/net/dst.h:470 [inline]
  ip_local_out+0x110/0x148 net/ipv4/ip_output.c:131
  iptunnel_xmit+0x50c/0xd38 net/ipv4/ip_tunnel_core.c:97
  udp_tunnel_xmit_skb+0x220/0x348 net/ipv4/udp_tunnel_core.c:187
  tipc_udp_xmit+0x75c/0x9c0 net/tipc/udp_media.c:202
  tipc_udp_send_msg+0x214/0x374 net/tipc/udp_media.c:274
  tipc_bearer_xmit_skb+0x260/0x3b0 net/tipc/bearer.c:576
  tipc_enable_bearer net/tipc/bearer.c:366 [inline]
  __tipc_nl_bearer_enable+0xc90/0xfb0 net/tipc/bearer.c:1048
  tipc_nl_bearer_enable+0x2c/0x48 net/tipc/bearer.c:1057
  genl_family_rcv_msg_doit+0x1e4/0x2d4 net/netlink/genetlink.c:1114
---
 net/ipv6/seg6_iptunnel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/seg6_iptunnel.c +1 -1
index ead677bca4901..d18f73ccf3d4a 100644
@@ -116,7 +116,7 @@ static __be32 seg6_make_flowlabel(struct net *net, struct sk_buff *skb,
 	u32 hash;
 
 	if (do_flowlabel > 0) {
-		hash = skb_get_hash(skb);
+		hash = skb_get_hash_net(net, skb);
 		hash = rol32(hash, 16);
 		flowlabel = (__force __be32)hash & IPV6_FLOWLABEL_MASK;
 	} else if (!do_flowlabel && skb->protocol == htons(ETH_P_IPV6)) {
Signature · 1 line
2.53.0
author maintainer
#106 lore raw

PATCH 106/497 xdp, xsk: constify read-only arguments of some static inline helpers

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Alexander Lobakin <[email protected]>

[ Upstream commit dcf3827cde8621d2317a7f98e069adbdc2112982 ]

Lots of read-only helpers for &xdp_buff and &xdp_frame, such as getting the frame length, skb_shared_info etc., don't have their arguments marked with const for no reason. Add the missing annotations to leave less place for mistakes and more for optimization.

Stable-dep-of: 8f1c2a10500a ("net: mvneta: clear XDP pfmemalloc flag between frames")

---
 include/net/xdp.h           | 29 +++++++++++++++++------------
 include/net/xdp_sock_drv.h  | 11 ++++++-----
 include/net/xsk_buff_pool.h |  2 +-
 3 files changed, 24 insertions(+), 18 deletions(-)
include/net/xdp.h +17 -12
index 05be2de2fd472..73599857f0847 100644
@@ -88,7 +88,7 @@ struct xdp_buff {
 	u32 flags; /* supported values defined in xdp_buff_flags */
 };
 
-static __always_inline bool xdp_buff_has_frags(struct xdp_buff *xdp)
+static __always_inline bool xdp_buff_has_frags(const struct xdp_buff *xdp)
 {
 	return !!(xdp->flags & XDP_FLAGS_HAS_FRAGS);
 }
@@ -103,7 +103,8 @@ static __always_inline void xdp_buff_clear_frags_flag(struct xdp_buff *xdp)
 	xdp->flags &= ~XDP_FLAGS_HAS_FRAGS;
 }
 
-static __always_inline bool xdp_buff_is_frag_pfmemalloc(struct xdp_buff *xdp)
+static __always_inline bool
+xdp_buff_is_frag_pfmemalloc(const struct xdp_buff *xdp)
 {
 	return !!(xdp->flags & XDP_FLAGS_FRAGS_PF_MEMALLOC);
 }
@@ -149,15 +150,16 @@ xdp_prepare_buff(struct xdp_buff *xdp, unsigned char *hard_start,
 	 SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
 
 static inline struct skb_shared_info *
-xdp_get_shared_info_from_buff(struct xdp_buff *xdp)
+xdp_get_shared_info_from_buff(const struct xdp_buff *xdp)
 {
 	return (struct skb_shared_info *)xdp_data_hard_end(xdp);
 }
 
-static __always_inline unsigned int xdp_get_buff_len(struct xdp_buff *xdp)
+static __always_inline unsigned int
+xdp_get_buff_len(const struct xdp_buff *xdp)
 {
 	unsigned int len = xdp->data_end - xdp->data;
-	struct skb_shared_info *sinfo;
+	const struct skb_shared_info *sinfo;
 
 	if (likely(!xdp_buff_has_frags(xdp)))
 		goto out;
@@ -182,12 +184,13 @@ struct xdp_frame {
 	u32 flags; /* supported values defined in xdp_buff_flags */
 };
 
-static __always_inline bool xdp_frame_has_frags(struct xdp_frame *frame)
+static __always_inline bool xdp_frame_has_frags(const struct xdp_frame *frame)
 {
 	return !!(frame->flags & XDP_FLAGS_HAS_FRAGS);
 }
 
-static __always_inline bool xdp_frame_is_frag_pfmemalloc(struct xdp_frame *frame)
+static __always_inline bool
+xdp_frame_is_frag_pfmemalloc(const struct xdp_frame *frame)
 {
 	return !!(frame->flags & XDP_FLAGS_FRAGS_PF_MEMALLOC);
 }
@@ -206,7 +209,7 @@ static __always_inline void xdp_frame_bulk_init(struct xdp_frame_bulk *bq)
 }
 
 static inline struct skb_shared_info *
-xdp_get_shared_info_from_frame(struct xdp_frame *frame)
+xdp_get_shared_info_from_frame(const struct xdp_frame *frame)
 {
 	void *data_hard_start = frame->data - frame->headroom - sizeof(*frame);
 
@@ -254,7 +257,8 @@ int xdp_alloc_skb_bulk(void **skbs, int n_skb, gfp_t gfp);
 struct xdp_frame *xdpf_clone(struct xdp_frame *xdpf);
 
 static inline
-void xdp_convert_frame_to_buff(struct xdp_frame *frame, struct xdp_buff *xdp)
+void xdp_convert_frame_to_buff(const struct xdp_frame *frame,
+			       struct xdp_buff *xdp)
 {
 	xdp->data_hard_start = frame->data - frame->headroom - sizeof(*frame);
 	xdp->data = frame->data;
@@ -265,7 +269,7 @@ void xdp_convert_frame_to_buff(struct xdp_frame *frame, struct xdp_buff *xdp)
 }
 
 static inline
-int xdp_update_frame_from_buff(struct xdp_buff *xdp,
+int xdp_update_frame_from_buff(const struct xdp_buff *xdp,
 			       struct xdp_frame *xdp_frame)
 {
 	int metasize, headroom;
@@ -322,9 +326,10 @@ void xdp_flush_frame_bulk(struct xdp_frame_bulk *bq);
 void xdp_return_frame_bulk(struct xdp_frame *xdpf,
 			   struct xdp_frame_bulk *bq);
 
-static __always_inline unsigned int xdp_get_frame_len(struct xdp_frame *xdpf)
+static __always_inline unsigned int
+xdp_get_frame_len(const struct xdp_frame *xdpf)
 {
-	struct skb_shared_info *sinfo;
+	const struct skb_shared_info *sinfo;
 	unsigned int len = xdpf->len;
 
 	if (likely(!xdp_frame_has_frags(xdpf)))
include/net/xdp_sock_drv.h +6 -5
index 075bc09046463..8d254e4b35716 100644
@@ -127,7 +127,7 @@ static inline struct xdp_buff *xsk_buff_alloc(struct xsk_buff_pool *pool)
 	return xp_alloc(pool);
 }
 
-static inline bool xsk_is_eop_desc(struct xdp_desc *desc)
+static inline bool xsk_is_eop_desc(const struct xdp_desc *desc)
 {
 	return !xp_mb_desc(desc);
 }
@@ -169,7 +169,7 @@ static inline void xsk_buff_add_frag(struct xdp_buff *xdp)
 	list_add_tail(&frag->list_node, &frag->pool->xskb_list);
 }
 
-static inline struct xdp_buff *xsk_buff_get_frag(struct xdp_buff *first)
+static inline struct xdp_buff *xsk_buff_get_frag(const struct xdp_buff *first)
 {
 	struct xdp_buff_xsk *xskb = container_of(first, struct xdp_buff_xsk, xdp);
 	struct xdp_buff *ret = NULL;
@@ -226,7 +226,8 @@ static inline void *xsk_buff_raw_get_data(struct xsk_buff_pool *pool, u64 addr)
 		XDP_TXMD_FLAGS_CHECKSUM | \
 	0)
 
-static inline bool xsk_buff_valid_tx_metadata(struct xsk_tx_metadata *meta)
+static inline bool
+xsk_buff_valid_tx_metadata(const struct xsk_tx_metadata *meta)
 {
 	return !(meta->flags & ~XDP_TXMD_FLAGS_VALID);
 }
@@ -368,7 +369,7 @@ static inline struct xdp_buff *xsk_buff_alloc(struct xsk_buff_pool *pool)
 	return NULL;
 }
 
-static inline bool xsk_is_eop_desc(struct xdp_desc *desc)
+static inline bool xsk_is_eop_desc(const struct xdp_desc *desc)
 {
 	return false;
 }
@@ -391,7 +392,7 @@ static inline void xsk_buff_add_frag(struct xdp_buff *xdp)
 {
 }
 
-static inline struct xdp_buff *xsk_buff_get_frag(struct xdp_buff *first)
+static inline struct xdp_buff *xsk_buff_get_frag(const struct xdp_buff *first)
 {
 	return NULL;
 }
include/net/xsk_buff_pool.h +1 -1
index 53da7697d0096..42e9058d85687 100644
@@ -184,7 +184,7 @@ static inline bool xp_desc_crosses_non_contig_pg(struct xsk_buff_pool *pool,
 	       !(pool->dma_pages[addr >> PAGE_SHIFT] & XSK_NEXT_PG_CONTIG_MASK);
 }
 
-static inline bool xp_mb_desc(struct xdp_desc *desc)
+static inline bool xp_mb_desc(const struct xdp_desc *desc)
 {
 	return desc->options & XDP_PKT_CONTD;
 }
Signature · 1 line
2.53.0
author maintainer
#107 lore raw

PATCH 107/497 net: mvneta: clear XDP pfmemalloc flag between frames

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Lorenzo Bianconi <[email protected]>

[ Upstream commit 8f1c2a10500a84a621ff13073f96deea0753ed42 ]

mvneta_swbm_add_rx_fragment() sets XDP_FLAGS_FRAGS_PF_MEMALLOC on the xdp_buff when a fragment page is a pfmemalloc one (page under memory pressure). The xdp_buff is reused for the next frame, but only the XDP_FLAGS_HAS_FRAGS bit was cleared at frame start, so the pfmemalloc bit leaked from one frame into the following ones. mvneta_swbm_build_skb() propagates the flag to skb->pfmemalloc through xdp_update_skb_frags_info(), so the skb of a subsequent fragmented frame could be wrongly marked as pfmemalloc even if none of its pages are under pressure.

Clear all the xdp_buff flags in mvneta_swbm_rx_frame(), which is invoked for each new frame, instead of just the XDP_FLAGS_HAS_FRAGS bit.

---
 drivers/net/ethernet/marvell/mvneta.c | 2 +-
 include/net/xdp.h                     | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/mvneta.c +1 -1
index a20a02b7926b8..48a0286b4012f 100644
@@ -2340,7 +2340,7 @@ mvneta_swbm_rx_frame(struct mvneta_port *pp,
 
 	/* Prefetch header */
 	prefetch(data);
-	xdp_buff_clear_frags_flag(xdp);
+	xdp_reinit_buff(xdp);
 	xdp_prepare_buff(xdp, data, pp->rx_offset_correction + MVNETA_MH_SIZE,
 			 data_len, false);
 }
include/net/xdp.h +5 -0
index 73599857f0847..9427c796ac79d 100644
@@ -88,6 +88,11 @@ struct xdp_buff {
 	u32 flags; /* supported values defined in xdp_buff_flags */
 };
 
+static __always_inline void xdp_reinit_buff(struct xdp_buff *xdp)
+{
+	xdp->flags = 0;
+}
+
 static __always_inline bool xdp_buff_has_frags(const struct xdp_buff *xdp)
 {
 	return !!(xdp->flags & XDP_FLAGS_HAS_FRAGS);
Signature · 1 line
2.53.0
author maintainer
#108 lore raw

PATCH 108/497 i2c: at91: release DMA channels when probe defers

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Hongjian Dai <[email protected]>

[ Upstream commit c98bf3b86609a18ab16d067280257326e557c636 ]

at91_twi_probe_master() can return -EPROBE_DEFER from at91_init_twi_recovery_info() after at91_twi_configure_dma() has already claimed the tx/rx DMA channels. at91_twi_probe() then returns without releasing them, and since dma_request_chan() is not devres-managed the channels leak on every deferred probe attempt.

Release the channels before deferring the probe.

Fixes f7eeb1af8537 ("i2c: at91: release DMA channels on remove and probe error")
Assisted-by LLM
---
 drivers/i2c/busses/i2c-at91-master.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-at91-master.c +7 -1
index f265a41cf31f6..5d901fd773df7 100644
@@ -921,8 +921,14 @@ int at91_twi_probe_master(struct platform_device *pdev,
 	at91_calc_twi_clock(dev);
 
 	rc = at91_init_twi_recovery_info(pdev, dev);
-	if (rc == -EPROBE_DEFER)
+	if (rc == -EPROBE_DEFER) {
+		/*
+		 * The DMA channels were already set up above, release them
+		 * before deferring the probe so they are not leaked.
+		 */
+		at91_twi_dma_release(dev);
 		return rc;
+	}
 
 	dev->adapter.algo = &at91_twi_algorithm;
 	dev->adapter.quirks = &at91_twi_quirks;
Signature · 1 line
2.53.0
author maintainer
#109 lore raw

PATCH 109/497 perf: Fix race between perf_event_exit_task() and perf_pending_task()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Luo Gengkun <[email protected]>

[ Upstream commit ffb684f2aa141eeb0caa6308422e7e05d1ded7c4 ]

A race condition exists between perf_event_exit_task() and perf_pending_task() during begin_new_exec().

During begin_new_exec(), perf_event_exit_task() may be called, and the PF_EXITING flag is not set on task. So perf_sigtrap() continues to execute and triggers WARN_ON_ONCE(event->ctx->task != current).

Since both task exit and exec paths can call perf_event_exit_task() which sets ctx->task to TASK_TOMBSTONE, fix this by explicitly checking if event->ctx->task equals TASK_TOMBSTONE and dropping the redundant PF_EXITING check.

Fixes 97ba62b27867 ("perf: Add support for SIGTRAP on perf events")
---
 kernel/events/core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/events/core.c +4 -2
index ab18d02dd959c..bcd870658b295 100644
@@ -6908,9 +6908,11 @@ static void perf_sigtrap(struct perf_event *event)
 {
 	/*
 	 * Both perf_pending_task() and perf_pending_irq() can race with the
-	 * task exiting.
+	 * task exiting or exec-ing. We can determine if such a race has
+	 * occurred by checking if perf_event_exit_task(), which will set
+	 * ctx->task to TASK_TOMBSTONE, has already been called.
 	 */
-	if (current->flags & PF_EXITING)
+	if (event->ctx->task == TASK_TOMBSTONE)
 		return;
 
 	/*
Signature · 1 line
2.53.0
author maintainer
#110 lore raw

PATCH 110/497 ALSA: core: Define auto-cleanup for snd_card_free()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Takashi Iwai <[email protected]>

[ Upstream commit f1d565dc92955f05383794e0fa27e61ee0555027 ]

For the errors at the probe time, we'd need to call rather snd_card_free() instead of the snd_card_unref() -- the former calls explicitly snd_card_disconnect() that cleans up the registered devices, etc, while the latter may leak in corner cases.

For convenience, define a new auto-clean with snd_card_free.

Stable-dep-of: e6229c0402ea ("ALSA: ice1712: Fix the error handling via auto-cleanup at probe")

---
 include/sound/core.h | 9 +++++++++
 1 file changed, 9 insertions(+)
include/sound/core.h +9 -0
index 0fcaa1cda1663..0b7aa6755e2be 100644
@@ -316,6 +316,15 @@ static inline void snd_card_unref(struct snd_card *card)
 
 DEFINE_FREE(snd_card_unref, struct snd_card *, if (_T) snd_card_unref(_T))
 
+/*
+ * For automatic error handling at probe time, assign the card like:
+ *	struct snd_card *card __free(snd_card_free) = NULL;
+ * then create and process as usual.
+ * But, don't forget to clear to NULL at successful return for avoiding
+ * the unexpected cleanup!
+ */
+DEFINE_FREE(snd_card_free, struct snd_card *, if (_T) snd_card_free(_T))
+
 #define snd_card_set_dev(card, devptr) ((card)->dev = (devptr))
 
 /* device.c */
Signature · 1 line
2.53.0
author maintainer
#111 lore raw

PATCH 111/497 ALSA: ice1712: Fix the error handling via auto-cleanup at probe

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Takashi Iwai <[email protected]>

[ Upstream commit e6229c0402ea4863ec74802d79d5b52b9398d66c ]

We used the auto-cleanup via snd_card_unref() for errors at probe of ice1712 driver, but this may be problematic in a subtle way when an error happens at snd_card_register(); since snd_card_unref() skips the snd_card_disconnect() call, it may miss some resource clearance.

For fixing the issue, use the new __free(snd_card_free) instead, which does call snd_card_free() explicitly at errors for avoiding such a pitfall.

Fixes d736eba9c453 ("ALSA: ice1712: Fix the card leak at probe error with the auto-cleanup")
---
 sound/pci/ice1712/ice1712.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/ice1712/ice1712.c +1 -1
index 45cb3e7b8d214..ce1758ad7200c 100644
@@ -2549,7 +2549,7 @@ static int snd_ice1712_probe(struct pci_dev *pci,
 			     const struct pci_device_id *pci_id)
 {
 	static int dev;
-	struct snd_card *card __free(snd_card_unref) = NULL;
+	struct snd_card *card __free(snd_card_free) = NULL;
 	struct snd_ice1712 *ice;
 	int pcm_dev = 0, err;
 	const struct snd_ice1712_card_info * const *tbl, *c;
Signature · 1 line
2.53.0
author maintainer
#112 lore raw

PATCH 112/497 PCI: Accept AtomicOps already enabled by the hypervisor

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Nikola Prica <[email protected]>

[ Upstream commit 40cce45b921f7930886bcba43069edc579725457 ]

pci_enable_atomic_ops_to_root() currently fails when no Root Port is visible. That is common in passthrough guests (ESXi, Hyper-V): the Endpoint is assigned to the VM, but the Root Port above it is not visible in the guest topology.

In those setups the hypervisor may already have enabled AtomicOp Requester Enable on the device. If PCI_EXP_DEVCTL2_ATOMIC_REQ is set, treat AtomicOps as already enabled and return success instead of failing the Root Port walk.

After 1ae8c4ce1570 ("PCI: Enable AtomicOps only if Root Port supports them"), pci_enable_atomic_ops_to_root() always returns failure if the Root Port is not visible, so drivers don't use atomics when they could. On systems where the Root Port is not visible but *does* support AtomicOps, this is a regression: prior to 1ae8c4ce1570, it enabled AtomicOps in the endpoint and returned success.

Fixes 1ae8c4ce1570 ("PCI: Enable AtomicOps only if Root Port supports them")
[bhelgaas: commit log, code comment]
---
 drivers/pci/pci.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/pci/pci.c +14 -1
index 4364ed7cdc27b..0d33b30ec2f67 100644
@@ -3764,8 +3764,21 @@ int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask)
 	}
 
 	root = pcie_find_root_port(dev);
-	if (!root)
+	if (!root) {
+
+		/*
+		 * A hypervisor may expose a topology with the root port
+		 * not visible to the guest.  If the hypervisor has already
+		 * set AtomicOp Requester Enable in the endpoint, we assume
+		 * it has verified support in the root port, so it is safe
+		 * for the driver to use AtomicOps.
+		 */
+		pcie_capability_read_dword(dev, PCI_EXP_DEVCTL2, &ctl2);
+		if (ctl2 & PCI_EXP_DEVCTL2_ATOMIC_REQ)
+			return 0;
+
 		return -EINVAL;
+	}
 
 	pcie_capability_read_dword(root, PCI_EXP_DEVCAP2, &cap);
 	if ((cap & cap_mask) != cap_mask)
Signature · 1 line
2.53.0
#113 lore raw

Re: [PATCH 6.12 112/497] PCI: Accept AtomicOps already enabled by the hypervisor

Hi Greg/Sasha,

Quoted 52 lines · Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Nikola Prica <[email protected]>

[ Upstream commit 40cce45b921f7930886bcba43069edc579725457 ]

pci_enable_atomic_ops_to_root() currently fails when no Root Port is visible. That is common in passthrough guests (ESXi, Hyper-V): the Endpoint is assigned to the VM, but the Root Port above it is not visible in the guest topology.

In those setups the hypervisor may already have enabled AtomicOp Requester Enable on the device. If PCI_EXP_DEVCTL2_ATOMIC_REQ is set, treat AtomicOps as already enabled and return success instead of failing the Root Port walk.

After 1ae8c4ce1570 ("PCI: Enable AtomicOps only if Root Port supports them"), pci_enable_atomic_ops_to_root() always returns failure if the Root Port is not visible, so drivers don't use atomics when they could. On systems where the Root Port is not visible but *does* support AtomicOps, this is a regression: prior to 1ae8c4ce1570, it enabled AtomicOps in the endpoint and returned success.

Fixes 1ae8c4ce1570 ("PCI: Enable AtomicOps only if Root Port supports them")
[bhelgaas: commit log, code comment]
---
  drivers/pci/pci.c | 15 ++++++++++++++-
  1 file changed, 14 insertions(+), 1 deletion(-)
drivers/pci/pci.c +5 -1
index 4364ed7cdc27b..0d33b30ec2f67 100644
@@ -3764,8 +3764,21 @@ int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask)
  	}
 
  	root = pcie_find_root_port(dev);
-	if (!root)
+	if (!root) {
+
+		/*
+		 * A hypervisor may expose a topology with the root port
+		 * not visible to the guest.  If the hypervisor has already

drivers/pci/pci.c int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask) · line 3781

Quoted 10 lines
drivers/pci/pci.c +9 -0
+		 * set AtomicOp Requester Enable in the endpoint, we assume
+		 * it has verified support in the root port, so it is safe
+		 * for the driver to use AtomicOps.
+		 */
+		pcie_capability_read_dword(dev, PCI_EXP_DEVCTL2, &ctl2);
+		if (ctl2 & PCI_EXP_DEVCTL2_ATOMIC_REQ)
+			return 0;
+
  		return -EINVAL;
+	}

^^^

An AI-assisted backport review highlighted a missing device-type restriction in original 6.12.113-rc1 patch 112, e57cb3788563. I confirmed the difference by checking upstream against the 6.12.y tip f4ffa8dc360b. It remains in rc2 at 4a8beb0f1e36 (replacement 4f0ed08a1994), in drivers/pci/pci.c:pci_enable_atomic_ops_to_root().

Downstream accepts RCiEP requesters (whitespace normalized):

    switch (pci_pcie_type(dev)) {
    case PCI_EXP_TYPE_ENDPOINT:
    case PCI_EXP_TYPE_LEG_END:
    case PCI_EXP_TYPE_RC_END:
        break;

Upstream 40cce45b921f and current 0fcb05b72344 reject that type:

    switch (pci_pcie_type(dev)) {
    case PCI_EXP_TYPE_ENDPOINT:
    case PCI_EXP_TYPE_LEG_END:
        break;
    default:
        return -EINVAL;
    }

The new no-Root-Port branch returns success when Requester Enable is set. An RCiEP can now reach that return downstream, whereas the parent rejected it. Callers can consequently advertise atomic support for a requester type upstream excludes. The restriction comes from 03ec922f0025 ("PCI: Do not enable AtomicOps by RCiEPs"), which precedes the upstream patch and has no equivalent at either endpoint.

So we need to backport this prereq before this patch I think.

Thanks,
Harshit>

Quoted 2 lines
drivers/pci/pci.c +0 -0
  	pcie_capability_read_dword(root, PCI_EXP_DEVCAP2, &cap);
  	if ((cap & cap_mask) != cap_mask)
#114 lore raw

Re: [PATCH 6.12 112/497] PCI: Accept AtomicOps already enabled by the hypervisor

Quoted 11 lines · Harshit Mogalapalli

Hi Greg/Sasha,

Quoted 8 lines · Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Nikola Prica <[email protected]>

[ Upstream commit 40cce45b921f7930886bcba43069edc579725457 ]

[ snip ]

Hi Harshit,

Quoted 31 lines

An AI-assisted backport review highlighted a missing device-type restriction in original 6.12.113-rc1 patch 112, e57cb3788563. I confirmed the difference by checking upstream against the 6.12.y tip f4ffa8dc360b. It remains in rc2 at 4a8beb0f1e36 (replacement 4f0ed08a1994), in drivers/pci/pci.c:pci_enable_atomic_ops_to_root().

Downstream accepts RCiEP requesters (whitespace normalized):

     switch (pci_pcie_type(dev)) {
     case PCI_EXP_TYPE_ENDPOINT:
     case PCI_EXP_TYPE_LEG_END:
     case PCI_EXP_TYPE_RC_END:
         break;

Upstream 40cce45b921f and current 0fcb05b72344 reject that type:

     switch (pci_pcie_type(dev)) {
     case PCI_EXP_TYPE_ENDPOINT:
     case PCI_EXP_TYPE_LEG_END:
         break;
     default:
         return -EINVAL;
     }

The new no-Root-Port branch returns success when Requester Enable is set. An RCiEP can now reach that return downstream, whereas the parent rejected it. Callers can consequently advertise atomic support for a requester type upstream excludes. The restriction comes from 03ec922f0025 ("PCI: Do not enable AtomicOps by RCiEPs"), which precedes the upstream patch and has no equivalent at either endpoint.

Quoted 4 lines

So we need to backport this prereq before this patch I think.

Thanks,
Harshit

the topic of excluding RCiEPs was discussed for the upstream patch here:
https://lore.kernel.org/linux-pci/20260326164002.GA1325368@bhelgaas/
At that time the conclusion was (in my simplified words): The logic in pci_enable_atomic_ops_to_root() cannot determine if AtomicOps are to be enabled or disabled for RCiEPs. So I made that decision explicit with commit 03ec922f0025 ("PCI: Do not enable AtomicOps by RCiEPs").

Now Nikola's commit 40cce45b921f ("PCI: Accept AtomicOps already enabled by the hypervisor") provides an override (allowing a hypervisor to provide the "quirk" that Bjorn talked about in the email thread). And I agree, depending on wheter commit 03ec922f0025 ("PCI: Do not enable AtomicOps by RCiEPs") is present, this override/quirk applies to RCiEPs or not.

I see two options now:
1. Pick commit 03ec922f0025 ("PCI: Do not enable AtomicOps by RCiEPs") for stable, too - so the behavior of the two is consistent.
2. Revert commit 03ec922f0025 ("PCI: Do not enable AtomicOps by RCiEPs") upstream - to allow RCiEPs benefit from the override, too.

Or maybe a combination of both?

At least in the discussion about RCiEPs
https://lore.kernel.org/linux-pci/[email protected]/
pci_enable_atomic_ops_to_root() did not appear to have any uses in drivers for RCiEPs.

Thanks,
Gerd