6.18.54-rc1 review
Subsystems (6)
Greg Kroah-Hartman
maintainerPATCH 1/398 Revert "perf annotate: Fix build with NO_SLANG=1"
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit e97bd4417010c648acf9b1e509cfb77fc506e09e.
--- tools/perf/util/hist.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
tools/perf/util/hist.h +2 -6
@@ -709,8 +709,6 @@ struct block_hist {struct hist_entry he; }; -#define NO_ADDR 0 -#ifdef HAVE_SLANG_SUPPORT #include "../ui/keysyms.h" void attr_to_script (char *buf,struct perf_event_attr *attr);
@@ -748,16 +746,14 @@ int evlist__tui_browse_hists(struct evlist *evlist __maybe_unused,static inline int __hist_entry__tui_annotate (struct hist_entry *he__maybe_unused ,struct map_symbol *ms__maybe_unused ,struct evsel *evsel__maybe_unused , -struct hist_browser_timer *hbt__maybe_unused , -u64 al_addr__maybe_unused ) +struct hist_browser_timer *hbt__maybe_unused ) {return 0 ; }static inline int hist_entry__tui_annotate (struct hist_entry *he__maybe_unused ,struct evsel *evsel__maybe_unused , -struct hist_browser_timer *hbt__maybe_unused , -u64 al_addr__maybe_unused ) +struct hist_browser_timer *hbt__maybe_unused ) {return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainercover 6.18.54-rc1 review
This is the start of the stable review cycle for the 6.18.54 release. There are 398 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 Fri, 25 Sep 2026 14:05:48 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.18.54-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.18.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 6.18.54-rc1
April Cardenas <[email protected]>
smb/client: send lease break ACKs thru correct session for multiuser mounts
Namjae Jeon <[email protected]>
Revert "ksmbd: Fix to handle removal of rfc1002 header from smb_hdr"
Zijun Hu <[email protected]>
Bluetooth: hci_qca: fix NULL pointer dereference in qca_setup() for non-serdev device
Bard Liao <[email protected]>
ASoC: sdw_utils: subtract the endpoint that is not present
Dmitry Antipov <[email protected]>
wifi: mac80211: fix list iteration in ieee80211_add_virtual_monitor()
Namjae Jeon <[email protected]>
ksmbd: fix partial normalized name responses
Maoyi Xie <[email protected]>
time/namespace: Export init_time_ns and do_timens_ktime_to_host()
Frank Sorenson <[email protected]>
smb: client: fix reparse buffer bounds in cifs_query_reparse_point()
Daehyeon Ko <[email protected]>
wifi: libipw: reject TKIP frames without a full MIC
Eric Biggers <[email protected]>
wifi: ipw2x00: Use michael_mic() from cfg80211
Eric Biggers <[email protected]>
wifi: mac80211, cfg80211: Export michael_mic() and move it to cfg80211
Eric Biggers <[email protected]>
wifi: ipw2x00: Rename michael_mic() to libipw_michael_mic()
Mike Lothian <[email protected]>
drm/amdgpu: hold a runtime PM reference for P2P dma-buf attachments
Pierre-Eric Pelloux-Prayer <[email protected]>
drm/amdgpu: lock bo before calling amdgpu_vm_bo_update_shared
Darrick J. Wong <[email protected]>
xfs: fix under-reservation of blocks when repairing sf directories
Christoph Hellwig <[email protected]>
xfs: remove the i_ino field in struct xfs_inode
Christoph Hellwig <[email protected]>
xfs: convert xchk_inode_xref_set_corrupt to xchk_ip_xref_set_corrupt
Christoph Hellwig <[email protected]>
xfs: add a xfs_rmap_inode_owner helper
Fan Wu <[email protected]>
smb: client: fix cifsFileInfo reference leak in deferred close
Arun Easi <[email protected]>
scsi: fnic: Fix missed link-up when critical IRQ targets offline CPU
Karan Tilak Kumar <[email protected]>
scsi: fnic: Bump up version number again
Karan Tilak Kumar <[email protected]>
scsi: fnic: Make debug logging protocol independent
Karan Tilak Kumar <[email protected]>
scsi: fnic: Bump up version number
Karan Tilak Kumar <[email protected]>
scsi: fnic: Rename fnic_scsi_fcpio_reset()
Devin Wittmayer <[email protected]>
wifi: mac80211: refuse to make a monitor active when it has no queue
Benjamin Berg <[email protected]>
wifi: mac80211: track MU-MIMO configuration on disabled interfaces
Lorenzo Stoakes (ARM) <[email protected]>
mm/vma: correctly unaccount on mmap_prepare() failure
David Howells <[email protected]>
9p: Fix v9fs_issue_write() to update i_size and remote_i_size
David Howells <[email protected]>
cifs: Fix specification of function pointers
Lorenzo Stoakes (ARM) <[email protected]>
mm/huge_memory: bypass THP tuneables for huge pfnmap mappings
David Hildenbrand (Arm) <[email protected]>
mm: move vma_kernel_pagesize() from hugetlb to mm.h
Zhiling Zou <[email protected]>
xfrm: save input state data before secpath resets
Dong Chenchen <[email protected]>
xfrm: Fix dev use-after-free in xfrm async resumption
Jianbo Liu <[email protected]>
xfrm: Refactor xfrm_input lock to reduce contention with RSS
Thomas Gleixner <[email protected]>
signal: Prevent exec() race
Thomas Gleixner <[email protected]>
signal: Move MMCID exit out of sighand lock
Xiang Mei <[email protected]>
ALSA: usb-audio: Clamp implicit feedback packet count to URB capacity
Takashi Iwai <[email protected]>
ALSA: usb-audio: Optimize the copy of packet sizes for implicit fb handling
Zizhi Wo <[email protected]>
smb: client: fix busy dentry warning on unmount after DIO
Iván Ezequiel Rodriguez <[email protected]>
ntsync: reject wait ioctls with zero owner
Maoyi Xie <[email protected]>
ntsync: Honour caller's time namespace for absolute MONOTONIC timeouts
Antheas Kapenekakis <[email protected]>
HID: asus: fortify keyboard handshake
Frank Sorenson <[email protected]>
smb: client: fix missing iov bounds check in parse_posix_sids()
Frank Sorenson <[email protected]>
smb: client: fix missing lower-bound check on DFS referral string offsets
Frank Sorenson <[email protected]>
smb: client: fix server->total_read for compound encrypted PDUs
Frank Sorenson <[email protected]>
smb: client: fix potential OOB read in smb3_enum_snapshots()
Frank Sorenson <[email protected]>
smb: client: fix OOB struct field reads in move_smb2_ea_to_cifs()
Frank Sorenson <[email protected]>
smb: client: fix next_buffer UAF and NextCommand bounds in compound PDUs
Paulo Alcantara <[email protected]>
smb: client: fix unaligned access in WSL reparse point parser
Paulo Alcantara <[email protected]>
smb: client: fix smbd_connection leak on cifs_get_tcp_session() error
Frank Sorenson <[email protected]>
smb: client: reject short Next offsets in parse_server_interfaces()
Joseph Qi <[email protected]>
smb: client: fix use-after-free of iface in cifs_try_adding_channels()
Paulo Alcantara <[email protected]>
smb: client: fix rlist race and missing initialization
Paulo Alcantara <[email protected]>
smb: client: cancel reconnect work in clean_demultiplex_info()
Chengjun Yao <[email protected]>
drm/amdgpu: fix rmmio iounmap skipped on device removal
Jonghyuk Kim(MalHyuk) <[email protected]>
drm/msm: RCU-free the scheduler-containing ring and VM objects
Guangshuo Li <[email protected]>
drm/msm/hdmi_phy: fix runtime PM cleanup on probe failure
Saim Shujah <[email protected]>
drm/msm/dpu: clear pending peripheral flush state
Guangshuo Li <[email protected]>
drm/msm/adreno: fix autosuspend cleanup during teardown
Sophie D <[email protected]>
drm/gud: Ignore damage clips in full update mode
Sajal Gupta <[email protected]>
drm/gud: fix out-of-bounds write in gud_plane_atomic_check()
Rik van Riel <[email protected]>
wifi: mac80211: avoid WARN in set_bitrate_mask when sdata not in driver
Zhao Li <[email protected]>
wifi: mwifiex: validate action frame fixed fields
Linmao Li <[email protected]>
wifi: mwifiex: prevent authentication frame length truncation
Pengpeng Hou <[email protected]>
wifi: mwifiex: validate scan response extents
Doruk Tan Ozturk <[email protected]>
wifi: mwifiex: bound the pairwise-cipher OUI walk to the IE length
Shengzhuo Wei <[email protected]>
wifi: p54: require a full exp_if record in PDR_INTERFACE_LIST
Shengzhuo Wei <[email protected]>
wifi: p54: validate curve data length in the calibration curve converters
Tianchu Chen <[email protected]>
wifi: wilc1000: fix RX buffer OOB-write in wilc_wlan_handle_isr_ext()
Ali Ahmet Memis <[email protected]>
wifi: wilc1000: fix out-of-bounds read in P2P public action frames
Runyu Xiao <[email protected]>
wifi: wlcore: release runtime PM ref on regdomain config failure
Fan Wu <[email protected]>
wifi: wcn36xx: Fix potential use-after-free in TX ack timer teardown
Tianchu Chen <[email protected]>
wifi: rsi: fix heap OOB write on key removal
Jiangshan Yi <[email protected]>
wifi: libertas_tf: fix UAF in lbtf_free_adapter()
Stanislaw Gruszka <[email protected]>
wifi: iwlegacy: fix broadcast stations deallocation
Jiangshan Yi <[email protected]>
wifi: brcmsmac: fix UAF in brcms_free_timer()
Wentao Liang <[email protected]>
watchdog: starfive-wdt: Fix runtime PM leak in starfive_wdt_pm_start()
Wentao Liang <[email protected]>
watchdog: sp5100_tco: Fix pci_dev reference leak in sp5100_tco_init()
Tzung-Bi Shih <[email protected]>
watchdog: rzv2h: Avoid division by zero
Tzung-Bi Shih <[email protected]>
watchdog: rtd119x: Avoid division by zero
Tzung-Bi Shih <[email protected]>
watchdog: msc313e: Propagate error code in resume()
Tzung-Bi Shih <[email protected]>
watchdog: msc313e: Fix premature reset during timeout update
Tzung-Bi Shih <[email protected]>
watchdog: digicolor: Avoid division by zero
Li Jun <[email protected]>
watchdog: da9063: fix suspend/resume handling of HW_RUNNING watchdog
Thomas Richard (congatec GmbH) <[email protected]>
hwmon: (cgbc-hwmon) Add missing sensors
Thomas Richard (congatec GmbH) <[email protected]>
hwmon: (cgbc-hwmon) Fix current sensors ID lookup
Guangshuo Li <[email protected]>
hwmon: (w83793) release probe data through kref
Guangshuo Li <[email protected]>
hwmon: (w83791d) remove fan/pwm 4-5 sysfs group on remove
Yibo Tan <[email protected]>
hwmon: (pwm-fan) Stop RPM timer before freeing tach data
Sanman Pradhan <[email protected]>
hwmon: (pmbus/tps53679) Select page 0 for single-page TPS53676
Sanman Pradhan <[email protected]>
hwmon: (pmbus/tps53679) Fix TPS53676 phase page decoding
Nuno Sá <[email protected]>
hwmon: (pmbus/core) increase number of phases and add new mask
Muhammad Bilal <[email protected]>
hwmon: (hp-wmi-sensors) Fix use-after-free in fungible_show()
Iván Ezequiel Rodriguez <[email protected]>
Input: zero ff_effect before compat copy in input_ff_effect_from_user
Dmitry Torokhov <[email protected]>
Input: synaptics-rmi4 - fix GPF in suspend and resume when unbound
Raphaël Larocque <[email protected]>
Input: synaptics - disable InterTouch on ThinkPad T440p (board id 2722)
Hans de Goede <[email protected]>
Input: soc_button_array - check btns_desc->package.count
Hans de Goede <[email protected]>
Input: soc_button_array - fix MS Surface Pro 11 probe failure
Dmitry Torokhov <[email protected]>
Input: rmi_smbus - fix out-of-bounds read in rmi_smb_write_block()
Chris Sommers <[email protected]>
Input: i8042 - add quirk for Acer Aspire Go 15 AG15-42P
Runyu Xiao <[email protected]>
Input: hp_sdc - shut down kicker timer on module exit
Iván Ezequiel Rodriguez <[email protected]>
Input: evdev - zero absinfo before partial copy in EVIOCSABS
Linkai Gong <[email protected]>
Input: cyttsp5 - clamp the HID report size before memcpy
Alexei Turtanov <[email protected]>
Input: atkbd - skip deactivate for Xiaomi Redmi Book Pro 16 2026
Alvin Šipraga <[email protected]>
Input: adp5588-keys - cache GPIO state before registering the gpiochip
Diogo Ivo (Schneider Electric) <[email protected]>
mmc: sdhci_am654: Fallback to DT-provided itap delay on DDR50 tuning failure
Diogo Ivo (Schneider Electric) <[email protected]>
mmc: sdhci_am654: Clear ITAPDLY on tuning failure
Diogo Ivo (Schneider Electric) <[email protected]>
mmc: sdhci_am654: Reset command and data lines on failed tuning
Diogo Ivo (Schneider Electric) <[email protected]>
mmc: sdhci_am654: Move tuning_loop to local variable
Xu Rao <[email protected]>
mmc: spi: reset bytes_xfered before retrying CRC failures
Runyu Xiao <[email protected]>
mmc: sh_mmcif: initialize IRQ-thread mutex before requesting interrupt
Felix Gu <[email protected]>
mmc: sdio_uart: fix xmit_fifo leak when the port table is full
Myeonghun Pak <[email protected]>
mmc: sdhci-of-aspeed: Remove children before releasing SDC resources
Florian Maillard <[email protected]>
mmc: rtsx_pci_sdmmc: ignore broken write-protect on ThinkPad X260
Fan Wu <[email protected]>
mmc: mxcmmc: cancel data work and watchdog on remove
Fan Wu <[email protected]>
mmc: mmci: Fix use-after-free in busy-timeout work
Fan Wu <[email protected]>
mmc: hsq: Fix use-after-free in retry work
Zhu Ling <[email protected]>
mmc: core: Fix OF node reference leak on card add failure
Fan Wu <[email protected]>
mmc: core: Cancel SDIO IRQ work before freeing host
Bartosz Golaszewski <[email protected]>
power: sequencing: fix NULL-pointer dereference in pwrseq_device_register()
Bartosz Golaszewski <[email protected]>
power: sequencing: fix NULL-pointer dereference in pwrseq_unit_new()
Bartosz Golaszewski <[email protected]>
power: sequencing: don't call .post_enable() if pwrseq_unit_enable() failed
Christian Göttsche <[email protected]>
selinux: always fill AVC decision in avc_has_perm_noaudit()
Karl Mehltretter <[email protected]>
selinux: recheck intermediate backing files on mprotect()
Karl Mehltretter <[email protected]>
selinux: preserve user SID across nested backing files
Shuhei Takeshita <[email protected]>
IB/hfi1: Fix the PIO_CRED credit-return mmap
Shuhei Takeshita <[email protected]>
IB/hfi1: Resolve the credit-return buffer through the send context's node
Shuangpeng Bai <[email protected]>
IB/mlx4: Fix use-after-free on pkey sysfs registration failure
Guangshuo Li <[email protected]>
i2c: imx: disable autosuspend on remove
Shengzhuo Wei <[email protected]>
i2c: imx: release DMA channels on probe error
Liu Zhenlong <[email protected]>
i2c: qcom-cci: fix device_node refcount leak in cci_probe()/cci_remove()
Linkai Gong <[email protected]>
i2c: atr: fix dangling adapter pointer on add failure
Shengzhuo Wei <[email protected]>
i2c: at91: release DMA channels on remove and probe error
Jarkko Sakkinen <[email protected]>
KEYS: trusted: Fix tpm2_load_cmd() boundary check
Maoyi Xie <[email protected]>
keys: translate request_key_auth pid for the reading procfs instance
Cen Zhang <[email protected]>
KEYS: encrypted: fix integer overflow of datablob_len
Wenjie Qi <[email protected]>
mm: filemap: retain mapped dropbehind folios
Lorenzo Stoakes (ARM) <[email protected]>
mm/mremap: account mm->locked_vm correctly for MREMAP_DONTUNMAP
Shakeel Butt <[email protected]>
mm/mlock: use the IRQ-safe accessor for NR_MLOCK in __munlock_folio()
Nhat Pham <[email protected]>
mm, swap: fix SWAP_USAGE_OFFLIST_BIT collision with real usage count
Yifei Gao <[email protected]>
memstick: ms_block: destroy io_queue workqueue on removal
Shakeel Butt <[email protected]>
memcg: avoid charging the root memcg from obj_cgroup_charge_pages()
Alexey Klimov <[email protected]>
soc: samsung: exynos-pmu: fix use-after-free of interrupt generator node
Siwei Zhang <[email protected]>
xfrm: use hlist_del_init_rcu for state_cache and state_cache_input
Chengfeng Ye <[email protected]>
xfrm: serialize state GC with device state flush
Alberto Carboneri <[email protected]>
scsi: core: Validate MODE SENSE lengths in scsi_cdl_enable()
Mark Amirkan <[email protected]>
net/packet: avoid truncating TPACKET_V3 private size
Mark Amirkan <[email protected]>
net/packet: clear RX owner on VNET header error
Jamal Hadi Salim <[email protected]>
net/sched: hhf: cap hh_flows_limit at change time
Xuanqiang Luo <[email protected]>
net/sched: act_api: release tail references on DELACTION failure
Guanglei Zhu <[email protected]>
net: wwan: mhi_wwan_mbim: check skb_copy_bits() return value
Guanglei Zhu <[email protected]>
net: wwan: mhi_wwan_mbim: guard against a cyclic NDP chain
Guanglei Zhu <[email protected]>
net: wwan: t7xx: validate the netif index in t7xx_ccmni_recv_skb()
Ahmed Naseef <[email protected]>
net: phy: mediatek: do not report link and per-speed LED rules together
Mark Amirkan <[email protected]>
net: lan743x: fix RX checksum use-after-free
Gris Ge <[email protected]>
net: ip_tunnel: initialize options_len before referencing options
Zhiling Zou <[email protected]>
ipv6: xfrm: use full sockets in local error paths
Alexander Chesnokov <[email protected]>
dmaengine: ti: k3-udma-glue: fix NULL dereference in k3_udma_glue_release_rx_chn()
Christian Lugnberg <[email protected]>
dmaengine: sun6i: fix undefined behaviour in sun6i_dma_tx_status
Christian Lugnberg <[email protected]>
dmaengine: sun6i: fix non-atomic read of DMA position registers
Guanghui Yang <[email protected]>
btrfs: clear free space tree creation state on rebuild failure
Hongling Zeng <[email protected]>
btrfs: take commit root semaphore when iterating in mark_block_group_to_copy()
Chengfeng Ye <[email protected]>
Bluetooth: hci_sync: Serialize local codec list cleanup
Laxman Acharya Padhya <[email protected]>
Bluetooth: hci_codec: validate vendor codec count length
Aamir Ahmed <[email protected]>
Bluetooth: eir: validate service data length before reading UUID
Nicolas Thibert <[email protected]>
Bluetooth: btusb: fix NXP IW610 composite device handling
Mark Rutland <[email protected]>
arm64: percpu: Fix LSE operations on {8,16}-bit types
Mark Rutland <[email protected]>
arm64: percpu: Fix this_cpu_and() mask generation
Mark Rutland <[email protected]>
arm64: percpu: Fix this_cpu_write() casting
Koichiro Den <[email protected]>
arm64: dts: renesas: r8a779f0: Set UFS lane count
Bradley Morgan <[email protected]>
arm64: hibernate: pass HVC_SET_VECTORS args to the resume hvc
Thomas Huth <[email protected]>
kselftest/arm64: Fix size of thread_data values for pthread_join()
Benoît Sevens <[email protected]>
HID: logitech-hidpp: fix race condition when accessing stale stack pointer
Wyatt Feng <[email protected]>
net: xfrm: reject unrepresentable espintcp transport headers
Zhiling Zou <[email protected]>
openvswitch: avoid reallocating confirmed conntrack labels
Jeffin Philip <[email protected]>
RDMA/core: fix refcount bug in iwpm_get_nlmsg_request()
Quanye Yang <[email protected]>
RDMA/ucma: Serialize join and leave on copy_to_user failure
Hao-Qun Huang <[email protected]>
spi: virtio: Use the per-transfer bits per word
Itai Handler <[email protected]>
spi: spi-zynqmp-gqspi: stop the controller on shutdown
Frieder Schrempf <[email protected]>
spi: fsl-qspi: Reprogram the clock rate when the operation frequency changes
Donggeun Yoo <[email protected]>
swiotlb: use the adjusted address for the highmem page lookup
Inbal Schussheim <[email protected]>
tcp: exclude old ACKs from tcp fast path
Chang S. Bae <[email protected]>
x86/microcode/intel: Reject problematic loading on Granite Rapids systems
Chang S. Bae <[email protected]>
x86/build/64: Prevent native builds from generating EGPR use
Lyude Paul <[email protected]>
drm/nouveau/gsp/r570: Enable S/R Display workaround in GSP
Lyude Paul <[email protected]>
drm/nouveau/gsp/r570: Set GcOff = 0 in fbsr
Lyude Paul <[email protected]>
drm/nouveau/gsp: Increase delay for magic sleep in r535_gsp_fini()
Lyude Paul <[email protected]>
Revert "nouveau/gsp: fix suspend/resume regression on r570 firmware"
Chunfeng Song <[email protected]>
rust: net: phy: fix off-by-one bit positions in device status accessors
Aohan Mei <[email protected]>
rds: ib: use rds_conn_drop() on protocol version mismatch
Thomas Gleixner <[email protected]>
posix-cpu-timers: Prevent freeing a timer which is queued on the expiry list
Claudiu Beznea <[email protected]>
phy: renesas: rcar-gen3-usb2: Avoid long delay in atomic context
Seunguk Shin <[email protected]>
fs/dax: check zero or empty entry before converting xarray entry
Hyunwoo Kim <[email protected]>
exec: Cleanup POSIX timers right after de_thread()
Wentao Liang <[email protected]>
cifs: Fix server use-after-free in cifs_chan_skip_or_disable()
Wentao Liang <[email protected]>
ata: libahci_platform: Fix device reference leak in ahci_platform_get_resources()
Niklas Cassel <[email protected]>
ata: libahci: clear PxCLBU and PxFBU for AHCI_HFLAG_32BIT_ONLY
Jiangshan Yi <[email protected]>
ASoC: codecs: rt712-sdca-dmic: fix uninitialized stream_config->type
Yuho Choi <[email protected]>
ALSA: virtio: reset device before deleting virtqueues
Takashi Iwai <[email protected]>
ALSA: core: Fix potential UAF after asynchronous card release
Jeremy Nyberg <[email protected]>
Input: xpad - fix PDP Marvel Xbox 360 controller
Roberts Kursitis <[email protected]>
Input: xpad - add support for Azeron devices
Erich Sartison <[email protected]>
Input: xpad - add support for Victrix Pro BFG Controller
Bitterblue Smith <[email protected]>
wifi: rtw88: TX QOS Null data the same way as Null data
Rafael J. Wysocki <[email protected]>
ACPI: processor: Update cpuidle driver check in __acpi_processor_start()
Li Jun <[email protected]>
watchdog: da9062: fix suspend/resume handling of HW_RUNNING watchdog
James Seo <[email protected]>
hwmon: (hp-wmi-sensors) Improve raw WMI string handling
Cong Nguyen <[email protected]>
hwmon: (gpio-fan) return IRQ_HANDLED from the shared alarm IRQ handler
hpp.iscas <[email protected]>
Input: eeti_ts - publish the OF module alias
Matthew Schwartz <[email protected]>
x86/fred: Reconstruct the #GP context for rejected INT instructions
Filipe Manana <[email protected]>
btrfs: check if there is space for chunk item when validating sys chunk array
Filipe Manana <[email protected]>
btrfs: abort transaction on failure to update inode for hole punching and reflinking
Dmitriy Chumachenko <[email protected]>
drm/amdgpu: check ras and obj before dereference
Eric Dumazet <[email protected]>
net: skbuff: do not leave stale header offsets after pskb_carve()
Dmitriy Okunev <[email protected]>
net: mvpp2: prevent buffer overflow in page_pool allocation
James Clark <[email protected]>
net: macb: fix ordering around PTP timestamp read
Jinke Han <[email protected]>
x86/kprobes: Fix crash when probing CS CALL instructions
Josh Poimboeuf <[email protected]>
x86/alternative: Refactor INT3 call emulation selftest
Daniel Zahka <[email protected]>
net: psp: avoid conflicts with skb->decrypted and sk_validate_xmit_skb()
Lorenzo Bianconi <[email protected]>
net: stmmac: propagate FPE preemption-class mapping errors
Linus Walleij <[email protected]>
net: ethernet: cortina: Ack RX overrun interrupt correctly
Eric Dumazet <[email protected]>
net: lock the socket in sock_gettstamp()
Jakub Kicinski <[email protected]>
eth: fbnic: ring the doorbell if a burst ends in a drop
Yige Jiang <[email protected]>
net: netsec: fix device_node reference leak on phy_np
Vijendar Mukunda <[email protected]>
ASoC: amd: acp: fix ffs() operator precedence for SoundWire link ID
Vijendar Mukunda <[email protected]>
ASoC: amd: acp: refactor codec config count in SOF SoundWire machine driver
Kuninori Morimoto <[email protected]>
ASoC: sdw_utils: tidyup asoc_sdw_parse_sdw_endpoints()
Kuninori Morimoto <[email protected]>
ASoC: sdw_utils: tidyup .count_sidecar
Charles Keepax <[email protected]>
ASoC: intel: sof_sdw: Add ability to have auxiliary devices
Charles Keepax <[email protected]>
ASoC: sdw_utils: Add codec_conf for every DAI
Vijendar Mukunda <[email protected]>
ASoC: amd: acp: bounds-check SoundWire link ID in machine drivers
HyeongJun An <[email protected]>
ASoC: hdmi-codec: Report a change when the channel status moves
Sasha Levin <[email protected]>
ASoC: ux500: Parenthesize MSP_{RX,TX}_CLKPOL_BIT() arguments
Daniel Linjama <[email protected]>
btrfs: handle lack of space when cleaning up verity items
Sun YangKai <[email protected]>
btrfs: more trivial BTRFS_PATH_AUTO_FREE conversions
Peter Zijlstra <[email protected]>
futex: Also allocate private hash on vfork()
Shivaprasad G Bhat <[email protected]>
powerpc/iommu: Fix the overflow validation in iommu_tce_check_ioba
Amit Machhiwal <[email protected]>
KVM: PPC: Book3S HV: fix secure device page leak on uv_page_in() failure
Amit Machhiwal <[email protected]>
KVM: PPC: Book3S HV: fix use-after-free in kvmhv_emulate_tlbie_all_lpid()
Lorenzo Bianconi <[email protected]>
net: stmmac: do not overwrite phc_index when no PTP clock is registered
Eric Dumazet <[email protected]>
drop_monitor: fix out-of-bounds write in reset_per_cpu_data()
Eric Dumazet <[email protected]>
drop_monitor: use timer_shutdown_sync() to prevent timer rearming during teardown
Eric Dumazet <[email protected]>
drop_monitor: synchronize tracepoint unregistration on error path
Eric Dumazet <[email protected]>
pppoatm: ensure a writable skb header and linear data
Kuniyuki Iwashima <[email protected]>
af_unix: Unify scc_index when finalising SCC in __unix_walk_scc().
Juan Perdomo <[email protected]>
Bluetooth: RFCOMM: avoid socket lock inversion in listener cleanup
Sai Teja Aluvala <[email protected]>
Bluetooth: btintel_pcie: fix off-by-one bounds check in RX submit
Tzung-Bi Shih <[email protected]>
Bluetooth: btmtksdio: Fix PM runtime reference leak in shutdown
Chris Lu <[email protected]>
Bluetooth: btmtk: fix wrong status for short WMT FUNC_CTRL events
Luiz Augusto von Dentz <[email protected]>
Bluetooth: ISO: set BT_LISTEN before requesting a BIG sync
Luiz Augusto von Dentz <[email protected]>
Bluetooth: ISO: Fix parent socket leak in iso_conn_ready()
Ibrahim Abdelkader <[email protected]>
Bluetooth: hci_qca: Do not write to the serial port after it is closed
Dmitry Baryshkov <[email protected]>
Bluetooth: qca: enable pwrseq support for WCN39xx devices
Vivek Sahu <[email protected]>
Bluetooth: qca: Refactor code on the basis of chipset names
Mengshi Wu <[email protected]>
Bluetooth: hci_qca: Refactor HFP hardware offload capability handling
Weiming Shi <[email protected]>
Bluetooth: coredump: Quiesce dump work on unregister
Chandrashekar Devegowda <[email protected]>
Bluetooth: btintel_pcie: validate TX skb length in send_sync
ThangNN99 <[email protected]>
Bluetooth: hci_core: Fix queuing tx_work after workqueue is drained
Baineng Shou <[email protected]>
dmaengine: mmp_pdma: fix wrong sg length in mmp_pdma_prep_slave_sg()
Namjae Jeon <[email protected]>
ksmbd: keep compound responses on query info errors
Namjae Jeon <[email protected]>
ksmbd: fix partial file information responses
Namjae Jeon <[email protected]>
ksmbd: return buffer overflow for partial filesystem info
Eric Dumazet <[email protected]>
tcp: do not let tcp_rmem be set below 4096
Kuniyuki Iwashima <[email protected]>
tcp: Don't call skb_clone_and_charge_r() for close()d listener in tcp_v6_do_rcv().
Nikolay Aleksandrov <[email protected]>
net: bridge: mst: move switchdev call outside rcu
Karl Mehltretter <[email protected]>
wifi: brcmfmac: fix lost 802.1x TX completion wakeup
Hohyun Sim <[email protected]>
net: fddi: skfp: fix NULL deref when setting the MAC address while down
Dong Chenchen <[email protected]>
ipv4: icmp: reject RTN_UNREACHABLE input routes in icmp_route_lookup
Nicolai Buchwitz <[email protected]>
net: bcmgenet: restore the hardware filters on open
Nicolai Buchwitz <[email protected]>
net: bcmgenet: convert RX path to page_pool
Andrea Mayer <[email protected]>
seg6: set IPSKB_L3SLAVE from IP6SKB_L3SLAVE on IPIP decapsulation
Dmitry Baryshkov <[email protected]>
drm/msm/dsi: round the byte clock rate after reparenting to the PHY PLL
Filipe Manana <[email protected]>
btrfs: tree-checker: print dev extent offset in error message
Nicolas Escande <[email protected]>
wifi: ath11k: cleanup arsta in ath11k_mac_peer_cleanup_all()
Slavin Liu <[email protected]>
ALSA: hda: trace PCM open only after assigning a stream
Karl Mehltretter <[email protected]>
drm/vc4: Use managed KMS polling to fix UAF on unbind
Shuicheng Lin <[email protected]>
drm/xe/shrinker: Return the freed page count through a parameter
Shuicheng Lin <[email protected]>
drm/xe/mmio_gem: Revoke drm_vma_node on xe_mmio_gem destroy
Ilia Levi <[email protected]>
drm/xe/mmio_gem: use write-back mapping for dummy page
Ilia Levi <[email protected]>
drm/xe/mmio_gem: forbid VMA split
Zihan Xi <[email protected]>
wifi: virt_wifi: don't transfer operstate before register
Xiang Mei <[email protected]>
ALSA: 6fire: fix OOB write from device-reported iso length
Takashi Iwai <[email protected]>
ALSA: usb: 6fire: Avoid embedded URBs
Runyu Xiao <[email protected]>
gpio: virtuser: skip free_irq when no IRQ is installed
Karl Mehltretter <[email protected]>
Input: trackpoint - fix the inertia attribute name in the ABI document
Gabor Juhos <[email protected]>
spi: spi-qpic-snand: avoid writing QPIC_EBI2_ECC_BUF_CFG register
Richard Fitzgerald <[email protected]>
ASoC: soc-pcm: Apply snd_soc_dai_link_ch_map.codec_ch_mask to codec params
Richard Fitzgerald <[email protected]>
ASoC: Add codec_ch_mask to snd_soc_dai_link_ch_map
Richard Fitzgerald <[email protected]>
ASoC: Rename snd_soc_dai_link_ch_map.ch_mask to cpu_ch_mask
William Bright <[email protected]>
drm/msm/dp: fix link bandwidth check when wide bus is enabled
Jesse Casco <[email protected]>
drm/msm/dp: skip PUSH_IDLE when the link was never enabled
Nguyen Ngoc Thang <[email protected]>
ALSA: pcm: set timer->private_data before registering the PCM timer
AngeloGioacchino Del Regno <[email protected]>
phy: mediatek: phy-mtk-hdmi-mt8195: Fix TMDS clk bit ratio setting
AngeloGioacchino Del Regno <[email protected]>
phy: mediatek: phy-mtk-hdmi-mt8195: Fix PLL calc divisor overflow
Takashi Iwai <[email protected]>
ALSA: bcd2000: Fix race between rawmidi and disconnect
Kuniyuki Iwashima <[email protected]>
neighbour: Skip default parms when resumed in neightbl_dump_info().
Kuniyuki Iwashima <[email protected]>
neighbour: Add missing RCU annotation for neightbl_dump_info().
Kuniyuki Iwashima <[email protected]>
neighbour: Convert RTM_GETNEIGHTBL to RCU.
Kuniyuki Iwashima <[email protected]>
neighbour: Enforce min/max to NDTPA_INTERVAL_PROBE_TIME_MS.
Karl Mehltretter <[email protected]>
keys: fix lost wakeup when reaping a dead key type
Thadeu Lima de Souza Cascardo <[email protected]>
drm: Fix drm_pending_vblank_event leak in error path for out_fence_ptr
Breno Leitao <[email protected]>
arm64: hibernate: clone only the linear map that exists at runtime
Shouping Wang <[email protected]>
perf/arm-cmn: Fix wp_dev_sel2 setting for multi-DTM configurations
Pablo Neira Ayuso <[email protected]>
netfilter: flowtable: hold reference on ct until flow is released
Pablo Neira Ayuso <[email protected]>
netfilter: nf_nat: unregister and release hooks on error
Fernando Fernandez Mancera <[email protected]>
netfilter: nf_tables: fix device name and prefix match in hook lookup
Theodor Arsenij Larionov Trichkine <[email protected]>
netfilter: nft_nat: fully initialise new_addr in netmap setup
Karl Mehltretter <[email protected]>
drm/msm/adreno: Fix the skip_gpu parameter description
Karl Mehltretter <[email protected]>
drm/msm: Fix the separate_gpu_kms parameter description
Jérémy Jean <[email protected]>
RDMA/siw: Bound fragmented header copies by the remaining length
Leon Romanovsky <[email protected]>
RDMA/efa: Keep EQ resources alive while IRQ is registered
Leon Romanovsky <[email protected]>
RDMA/efa: Keep admin queues alive while IRQ is registered
Alex Bereza <[email protected]>
dmaengine: xilinx_dma: Fix hardware buffer descriptor chain after cyclic DMA
Alex Bereza <[email protected]>
dmaengine: xilinx_dma: Fix hardware buffer descriptor reuse order
Karl Mehltretter <[email protected]>
scsi: qla2xxx: Fix the ql2xfc2target parameter description
Meijing Zhao <[email protected]>
mm: memblock: show all region flags in debugfs
Johannes Berg <[email protected]>
wifi: mac80211: set up the TX info early to fix failure paths
Johannes Berg <[email protected]>
wifi: mac80211: mesh: release the channel if start fails
Johannes Berg <[email protected]>
wifi: mac80211: mesh: reset the CSA state when leaving
Johannes Berg <[email protected]>
wifi: mac80211: add HE 6 GHz capability in the scan elems len
Johannes Berg <[email protected]>
wifi: mac80211: don't access the TSF of a down interface
Johannes Berg <[email protected]>
wifi: mac80211: don't RCU-dereference the mesh CSA settings we just set
Johannes Berg <[email protected]>
wifi: mac80211: don't allow link changes when iface is down
Johannes Berg <[email protected]>
wifi: mac80211: require a peer station for TDLS setup confirm
Johannes Berg <[email protected]>
wifi: mac80211: reset the AP_VLAN tailroom counter on ifdown
Johannes Berg <[email protected]>
wifi: mac80211: don't allow injecting frames wider than the chanctx
Johannes Berg <[email protected]>
wifi: mac80211_hwsim: don't hand frames to mac80211 while stopping
Johannes Berg <[email protected]>
wifi: cfg80211: get the wiphy out of a dying network namespace
Johannes Berg <[email protected]>
wifi: mac80211: unlist vifs when their netdev is unregistered
Johannes Berg <[email protected]>
wifi: cfg80211: undo netns switch if renaming the wiphy fails
Johannes Berg <[email protected]>
wifi: cfg80211: restore netns_immutable on failures
Johannes Berg <[email protected]>
wifi: mac80211: reset state when starting AP fails
Johannes Berg <[email protected]>
wifi: mac80211: abort chanswitch when leaving a mesh
Johannes Berg <[email protected]>
wifi: mac80211: suppress chanctx warning for debugfs reset
Johannes Berg <[email protected]>
wifi: mac80211: don't offload TC setup on AP_VLAN interfaces
Johannes Berg <[email protected]>
wifi: mac80211: don't warn when an IBSS has no channel to scan
Johannes Berg <[email protected]>
wifi: mac80211: don't start a ROC while scanning
Johannes Berg <[email protected]>
wifi: cfg80211: don't filter by BSS type when removing stale entries
Johannes Berg <[email protected]>
wifi: cfg80211: only group hidden BSSes with beacon entries
Johannes Berg <[email protected]>
wifi: cfg80211: don't free driver-owned scan requests
Shivank Garg <[email protected]>
dmaengine: wait for RCU readers before releasing dma_device
Shivank Garg <[email protected]>
dmaengine: fix use-after-free in dma_chan_put() and dma_release_channel()
Shivank Garg <[email protected]>
dmaengine: Fix device kref underflow in dma_chan_put()
Donggeun Yoo <[email protected]>
dma-coherent: report a failed reserved memory assignment
Orgad Shaneh <[email protected]>
MIPS: Octeon: apply USB FDT fixups also when USB is modular
Bard Liao <[email protected]>
soundwire: cadence_master: wait and cancel cdns->work before clock stop
Johannes Berg <[email protected]>
wifi: cfg80211: check IP header size in cfg80211_classify8021d()
Johannes Berg <[email protected]>
wifi: cfg80211: don't get the radio mask for netdev-less wdevs
Carolina Jubran <[email protected]>
IB/IPoIB: Avoid restoring OPER_UP after multicast flush
Shmulik Cohen <[email protected]>
wifi: libipw: reject too-short association responses
Shmulik Cohen <[email protected]>
wifi: libipw: reject too-short beacon and probe responses
Bogdan Nicolae <[email protected]>
wifi: brcmfmac: cyw: pass PMKID to firmware if present
Peng Hao <[email protected]>
wifi: mwifiex: fix IRQ leak using wrong index in MSI-X error path
Mariano Baragiola <[email protected]>
wifi: virt_wifi: free skb when disconnected
Lachlan Hodges <[email protected]>
wifi: mac80211: include TIM bitmap control for buffered S1G mcast traffic
Ruoyu Wang <[email protected]>
dmaengine: sprd: Fix runtime PM reference leak in probe
Quanye Yang <[email protected]>
RDMA/rtrs-clt: Fix CQ pool leak when connect is interrupted
Jacob Moroni <[email protected]>
RDMA/irdma: Enforce local fence for IB_WR_REG_MR
Li RongQing <[email protected]>
RDMA/mad: Fix receive buffer leak when PKey enforcement fails
Linkai Gong <[email protected]>
RDMA/bnxt_re: check create_singlethread_workqueue() in DCB setup
Yehyeong Lee <[email protected]>
IB/isert: wait for deferred control PDU completions before releasing the connection
Yehyeong Lee <[email protected]>
IB/iser: reject a remote invalidation of an unregistered direction
Ovidiu Panait <[email protected]>
arm64: dts: renesas: r9a09g047: Switch GBETH TX queue scheduling to WRR
Ovidiu Panait <[email protected]>
arm64: dts: renesas: r9a09g056: Switch GBETH TX queue scheduling to WRR
Ovidiu Panait <[email protected]>
arm64: dts: renesas: r9a09g057: Switch GBETH TX queue scheduling to WRR
Biju Das <[email protected]>
power: sequencing: Fix build issue with COMPILE_TEST
Krystian Kaniewski <[email protected]>
RDMA/core: Reject unregistering netdevs in ib_get_eth_speed
Or Har-Toov <[email protected]>
RDMA/mlx5: Remove warn on missing representor in query_port_speed
Michael Bommarito <[email protected]>
RDMA/rxe: insert mcg into mcg_tree only after rxe_mcast_add() succeeds
Weiming Shi <[email protected]>
RDMA/rxe: Restore HMM_PFN_WRITE check in ODP write paths
Xixin Liu <[email protected]>
clk: scpi: bound-check DVFS index in scpi_dvfs_recalc_rate
Xixin Liu <[email protected]>
firmware: arm_scpi: reject DVFS OPP count above MAX_DVFS_OPPS
Gang Yan <[email protected]>
RDMA/rxe: Fix integer overflow in mr_check_range() leading to OOB access
Norbert Szetei <[email protected]>
RDMA/rxe: validate access flags before swapping the MR's PD
Guoqing Jiang <[email protected]>
RDMA/siw: Clear association under lock if siw_qp_modify fails in siw_accept
Pengpeng Hou <[email protected]>
ARM: socfpga: select the PL310 erratum 753970 workaround
Maher Azzouzi <[email protected]>
esp: downgrade zerocopy managed frags before mutating skb frags
Eric Dumazet <[email protected]>
xfrm: add missing rcu_read_lock(), skb_dst_force() and dev_hold() for xfrm_trans_reinject()
Kyle Zeng <[email protected]>
xfrm: fix compat ALLOCSPI request use-after-free
Sabrina Dubroca <[email protected]>
xfrm: avoid RCU warnings around the per-netns netlink socket
Henry Martin <[email protected]>
xfrm: iptfs: fix runt reassembly panic from short inner tot_len
Roshan Kumar <[email protected]>
xfrm: iptfs: fix stack OOB read in iptfs_skb_reset_frag_walk()
Ido Schimmel <[email protected]>
ipv6: Honor oif when choosing nexthop for locally generated traffic
Ido Schimmel <[email protected]>
ipv6: Select best matching nexthop object in fib6_table_lookup()
Arash Golgol <[email protected]>
media: video-i2c: fix buffer queue ordering
Jens Axboe <[email protected]>
sunvdc: fix -EIO issue due to lack of retries
Günther Noack <[email protected]>
selftests/landlock: Add audit test for whiteout object creation
Günther Noack <[email protected]>
selftests/landlock: Add tests for whiteout object creation
Günther Noack <[email protected]>
selftests/landlock: Use an actual chardev for MAKE_CHAR audit test
Mickaël Salaün <[email protected]>
selftests/landlock: Add disconnected leafs and branch test suites
Tingmao Wang <[email protected]>
selftests/landlock: Add tests for access through disconnected paths
Maximilian Heyne <[email protected]>
selftests/landlock: Explicitly disable audit in teardowns
Mickaël Salaün <[email protected]>
selftests/landlock: Increase default audit socket timeout
Mickaël Salaün <[email protected]>
selftests/landlock: Fix socket file descriptor leaks in audit helpers
Matthieu Buffet <[email protected]>
selftests/landlock: Add missing connect(minimal AF_UNSPEC) test
Matthieu Buffet <[email protected]>
selftests/landlock: Add test for TCP fast open
Matthieu Buffet <[email protected]>
landlock: Fix TCP Fast Open connection bypass
Sasha Levin <[email protected]>
Revert "perf annotate: Fix build with NO_SLANG=1"
-------------
Diffstat:
.../ABI/testing/sysfs-devices-platform-trackpoint | 2 +-
Documentation/hwmon/cgbc-hwmon.rst | 42 +-
Documentation/netlink/specs/rt-neigh.yaml | 3 +
Documentation/networking/ip-sysctl.rst | 4 +-
Makefile | 4 +-
arch/arm/mach-socfpga/Kconfig | 2 +-
arch/arm64/boot/dts/renesas/r8a779f0.dtsi | 1 +
arch/arm64/boot/dts/renesas/r9a09g047.dtsi | 10 +
arch/arm64/boot/dts/renesas/r9a09g056.dtsi | 10 +
arch/arm64/boot/dts/renesas/r9a09g057.dtsi | 10 +
arch/arm64/include/asm/percpu.h | 20 +-
arch/arm64/kernel/hibernate-asm.S | 2 +
arch/arm64/kernel/hibernate.c | 4 +-
arch/mips/cavium-octeon/octeon-platform.c | 4 +-
arch/powerpc/kernel/iommu.c | 2 +-
arch/powerpc/kvm/book3s_hv_nested.c | 2 +
arch/powerpc/kvm/book3s_hv_uvmem.c | 5 +-
arch/x86/Kconfig.cpu | 11 +
arch/x86/Makefile | 5 +
arch/x86/entry/entry_fred.c | 11 +-
arch/x86/include/asm/text-patching.h | 4 +-
arch/x86/kernel/alternative.c | 55 +-
arch/x86/kernel/cpu/microcode/intel.c | 26 +
arch/x86/kernel/kprobes/core.c | 5 +-
drivers/acpi/processor_driver.c | 2 +-
drivers/ata/libahci.c | 15 +-
drivers/ata/libahci_platform.c | 2 +-
drivers/block/sunvdc.c | 9 +-
drivers/bluetooth/btintel_pcie.c | 8 +-
drivers/bluetooth/btmtk.c | 7 +-
drivers/bluetooth/btmtksdio.c | 4 +-
drivers/bluetooth/btqca.c | 37 +-
drivers/bluetooth/btusb.c | 17 +
drivers/bluetooth/hci_qca.c | 80 +-
drivers/clk/clk-scpi.c | 2 +-
drivers/dma/dmaengine.c | 10 +-
drivers/dma/mmp_pdma.c | 2 +-
drivers/dma/sprd-dma.c | 3 +-
drivers/dma/sun6i-dma.c | 9 +-
drivers/dma/ti/k3-udma-glue.c | 5 +-
drivers/dma/xilinx/xilinx_dma.c | 26 +-
drivers/firmware/arm_scpi.c | 4 +-
drivers/gpio/gpio-virtuser.c | 3 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 48 +
drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c | 2 +-
drivers/gpu/drm/drm_atomic_uapi.c | 13 +-
drivers/gpu/drm/gud/gud_pipe.c | 7 +-
drivers/gpu/drm/msm/adreno/adreno_device.c | 2 +-
drivers/gpu/drm/msm/adreno/adreno_gpu.c | 2 +
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c | 1 +
drivers/gpu/drm/msm/dp/dp_display.c | 21 +-
drivers/gpu/drm/msm/dsi/dsi_host.c | 36 +-
drivers/gpu/drm/msm/hdmi/hdmi_phy.c | 8 +-
drivers/gpu/drm/msm/msm_drv.c | 2 +-
drivers/gpu/drm/msm/msm_gem.h | 3 +
drivers/gpu/drm/msm/msm_gem_vma.c | 2 +-
drivers/gpu/drm/msm/msm_ringbuffer.c | 2 +-
drivers/gpu/drm/msm/msm_ringbuffer.h | 1 +
.../gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/fbsr.c | 2 +-
.../gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/gsp.c | 8 +-
.../gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/fbsr.c | 8 +-
.../gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/gsp.c | 3 +-
.../drm/nouveau/nvkm/subdev/gsp/rm/r570/nvrm/gsp.h | 8 +
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/rm.h | 2 +-
drivers/gpu/drm/vc4/vc4_kms.c | 2 +-
drivers/gpu/drm/xe/xe_mmio_gem.c | 33 +-
drivers/gpu/drm/xe/xe_mmio_gem.h | 2 +-
drivers/gpu/drm/xe/xe_shrinker.c | 62 +-
drivers/hid/hid-asus.c | 34 +-
drivers/hid/hid-logitech-hidpp.c | 24 +-
drivers/hwmon/cgbc-hwmon.c | 129 +-
drivers/hwmon/gpio-fan.c | 4 +-
drivers/hwmon/hp-wmi-sensors.c | 32 +-
drivers/hwmon/pmbus/pmbus.h | 3 +-
drivers/hwmon/pmbus/tps53679.c | 11 +-
drivers/hwmon/pwm-fan.c | 13 +-
drivers/hwmon/w83791d.c | 1 +
drivers/hwmon/w83793.c | 4 +-
drivers/i2c/busses/i2c-at91-core.c | 3 +
drivers/i2c/busses/i2c-at91-master.c | 12 +-
drivers/i2c/busses/i2c-at91.h | 1 +
drivers/i2c/busses/i2c-imx.c | 3 +
drivers/i2c/busses/i2c-qcom-cci.c | 20 +-
drivers/i2c/i2c-atr.c | 1 +
drivers/infiniband/core/iwpm_util.c | 9 +-
drivers/infiniband/core/mad.c | 3 +-
drivers/infiniband/core/ucma.c | 7 +-
drivers/infiniband/core/verbs.c | 12 +-
drivers/infiniband/hw/bnxt_re/main.c | 10 +-
drivers/infiniband/hw/efa/efa_com.c | 7 +-
drivers/infiniband/hw/efa/efa_com.h | 1 +
drivers/infiniband/hw/efa/efa_main.c | 35 +-
drivers/infiniband/hw/hfi1/file_ops.c | 23 +-
drivers/infiniband/hw/irdma/verbs.c | 2 +-
drivers/infiniband/hw/mlx4/sysfs.c | 4 +
drivers/infiniband/hw/mlx5/main.c | 7 +-
drivers/infiniband/sw/rxe/rxe_mcast.c | 50 +-
drivers/infiniband/sw/rxe/rxe_mr.c | 3 +-
drivers/infiniband/sw/rxe/rxe_odp.c | 16 +-
drivers/infiniband/sw/rxe/rxe_verbs.c | 13 +-
drivers/infiniband/sw/siw/siw_cm.c | 7 +-
drivers/infiniband/sw/siw/siw_qp_rx.c | 2 +-
drivers/infiniband/ulp/ipoib/ipoib.h | 7 +
drivers/infiniband/ulp/ipoib/ipoib_ib.c | 12 +-
drivers/infiniband/ulp/ipoib/ipoib_multicast.c | 16 +-
drivers/infiniband/ulp/iser/iser_initiator.c | 16 +-
drivers/infiniband/ulp/isert/ib_isert.c | 22 +
drivers/infiniband/ulp/isert/ib_isert.h | 2 +
drivers/infiniband/ulp/rtrs/rtrs-clt.c | 8 +
drivers/infiniband/ulp/rtrs/rtrs-clt.h | 2 +
drivers/input/evdev.c | 2 +
drivers/input/input-compat.c | 2 +
drivers/input/joystick/xpad.c | 10 +-
drivers/input/keyboard/adp5588-keys.c | 12 +-
drivers/input/keyboard/atkbd.c | 8 +
drivers/input/misc/soc_button_array.c | 16 +-
drivers/input/mouse/synaptics.c | 8 +
drivers/input/rmi4/rmi_driver.c | 13 +
drivers/input/rmi4/rmi_smbus.c | 10 +-
drivers/input/serio/hp_sdc.c | 2 +-
drivers/input/serio/i8042-acpipnpio.h | 7 +
drivers/input/touchscreen/cyttsp5.c | 1 +
drivers/input/touchscreen/eeti_ts.c | 1 +
drivers/media/i2c/video-i2c.c | 5 +-
drivers/memstick/core/ms_block.c | 2 +
drivers/misc/ntsync.c | 6 +
drivers/mmc/core/bus.c | 2 +-
drivers/mmc/core/host.c | 1 +
drivers/mmc/core/sdio_uart.c | 3 +
drivers/mmc/host/mmc_hsq.c | 8 +-
drivers/mmc/host/mmc_spi.c | 1 +
drivers/mmc/host/mmci.c | 3 +
drivers/mmc/host/mxcmmc.c | 4 +
drivers/mmc/host/rtsx_pci_sdmmc.c | 5 +
drivers/mmc/host/sdhci-of-aspeed.c | 5 +-
drivers/mmc/host/sdhci_am654.c | 43 +-
drivers/mmc/host/sh_mmcif.c | 3 +-
drivers/net/ethernet/broadcom/Kconfig | 1 +
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 245 +--
drivers/net/ethernet/broadcom/genet/bcmgenet.h | 5 +-
drivers/net/ethernet/cadence/macb_ptp.c | 9 +
drivers/net/ethernet/cortina/gemini.c | 2 +-
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 3 +-
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 42 +-
drivers/net/ethernet/meta/fbnic/fbnic_txrx.h | 9 +-
drivers/net/ethernet/microchip/lan743x_main.c | 2 +-
drivers/net/ethernet/socionext/netsec.c | 2 +
drivers/net/ethernet/stmicro/stmmac/hwif.h | 2 +-
.../net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 2 -
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 19 +-
drivers/net/fddi/skfp/skfddi.c | 3 +-
drivers/net/phy/mediatek/mtk-phy-lib.c | 27 +-
drivers/net/wireless/ath/ath11k/mac.c | 25 +-
drivers/net/wireless/ath/wcn36xx/dxe.c | 2 +-
.../wireless/broadcom/brcm80211/brcmfmac/core.c | 2 +
.../broadcom/brcm80211/brcmfmac/cyw/core.c | 5 +-
.../broadcom/brcm80211/brcmsmac/mac80211_if.c | 4 +
drivers/net/wireless/intel/ipw2x00/Kconfig | 1 -
.../wireless/intel/ipw2x00/libipw_crypto_tkip.c | 130 +-
drivers/net/wireless/intel/ipw2x00/libipw_rx.c | 6 +
drivers/net/wireless/intel/iwlegacy/common.c | 2 +-
drivers/net/wireless/intersil/p54/eeprom.c | 22 +-
drivers/net/wireless/marvell/libertas_tf/main.c | 2 +-
drivers/net/wireless/marvell/mwifiex/cfg80211.c | 12 +-
drivers/net/wireless/marvell/mwifiex/pcie.c | 2 +-
drivers/net/wireless/marvell/mwifiex/scan.c | 54 +-
drivers/net/wireless/marvell/mwifiex/util.c | 10 +-
drivers/net/wireless/microchip/wilc1000/cfg80211.c | 14 +
drivers/net/wireless/microchip/wilc1000/wlan.c | 9 +
drivers/net/wireless/realtek/rtw88/tx.c | 2 +-
drivers/net/wireless/rsi/rsi_91x_mgmt.c | 2 -
drivers/net/wireless/ti/wlcore/main.c | 4 +-
drivers/net/wireless/virtual/mac80211_hwsim.c | 39 +-
drivers/net/wireless/virtual/virt_wifi.c | 4 +-
drivers/net/wwan/mhi_wwan_mbim.c | 28 +-
drivers/net/wwan/t7xx/t7xx_netdev.c | 4 +
drivers/perf/arm-cmn.c | 10 +-
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c | 4 +-
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.h | 3 +
drivers/phy/renesas/phy-rcar-gen3-usb2.c | 310 +++-
drivers/power/sequencing/Kconfig | 3 +-
drivers/power/sequencing/core.c | 11 +-
drivers/scsi/fnic/fdls_disc.c | 730 ++++-----
drivers/scsi/fnic/fip.c | 119 +-
drivers/scsi/fnic/fip.h | 2 +-
drivers/scsi/fnic/fnic.h | 69 +-
drivers/scsi/fnic/fnic_fcs.c | 166 +-
drivers/scsi/fnic/fnic_fdls.h | 2 +-
drivers/scsi/fnic/fnic_isr.c | 41 +-
drivers/scsi/fnic/fnic_main.c | 89 +-
drivers/scsi/fnic/fnic_scsi.c | 264 ++-
drivers/scsi/qla2xxx/qla_os.c | 2 +-
drivers/scsi/scsi.c | 24 +-
drivers/soc/samsung/exynos-pmu.c | 7 +-
drivers/soundwire/cadence_master.c | 7 +
drivers/spi/spi-fsl-qspi.c | 5 +-
drivers/spi/spi-qpic-snand.c | 4 -
drivers/spi/spi-virtio.c | 2 +-
drivers/spi/spi-zynqmp-gqspi.c | 34 +
drivers/watchdog/da9062_wdt.c | 4 +-
drivers/watchdog/da9063_wdt.c | 4 +-
drivers/watchdog/digicolor_wdt.c | 13 +-
drivers/watchdog/msc313e_wdt.c | 16 +-
drivers/watchdog/rtd119x_wdt.c | 7 +-
drivers/watchdog/rzv2h_wdt.c | 7 +-
drivers/watchdog/sp5100_tco.c | 6 +-
drivers/watchdog/starfive-wdt.c | 2 +-
fs/9p/vfs_addr.c | 29 +-
fs/btrfs/dev-replace.c | 1 +
fs/btrfs/disk-io.c | 4 +
fs/btrfs/file.c | 4 +-
fs/btrfs/free-space-tree.c | 14 +-
fs/btrfs/inode.c | 3 +-
fs/btrfs/tree-checker.c | 2 +-
fs/btrfs/uuid-tree.c | 120 +-
fs/btrfs/verity.c | 47 +-
fs/btrfs/volumes.c | 153 +-
fs/btrfs/xattr.c | 36 +-
fs/dax.c | 9 +-
fs/exec.c | 29 +-
fs/smb/client/cifs_fs_sb.h | 1 +
fs/smb/client/cifsfs.c | 12 +
fs/smb/client/cifsglob.h | 12 +-
fs/smb/client/cifsproto.h | 8 +-
fs/smb/client/cifssmb.c | 2 +-
fs/smb/client/connect.c | 10 +
fs/smb/client/file.c | 28 +-
fs/smb/client/misc.c | 12 +-
fs/smb/client/reparse.c | 4 +-
fs/smb/client/reparse.h | 7 +-
fs/smb/client/sess.c | 104 +-
fs/smb/client/smb2inode.c | 11 +
fs/smb/client/smb2ops.c | 51 +-
fs/smb/client/smb2pdu.c | 13 +-
fs/smb/client/trace.h | 1 +
fs/smb/client/transport.c | 4 +-
fs/smb/server/server.c | 2 +-
fs/smb/server/smb2pdu.c | 89 +-
fs/smb/server/smb2pdu.h | 1 +
fs/smb/server/smb_common.c | 20 +-
fs/xfs/libxfs/xfs_bmap.c | 2 +-
fs/xfs/libxfs/xfs_da_btree.c | 2 +-
fs/xfs/libxfs/xfs_da_btree.h | 2 +
fs/xfs/libxfs/xfs_rmap.h | 2 +
fs/xfs/scrub/attr_repair.c | 4 +-
fs/xfs/scrub/bmap.c | 6 +-
fs/xfs/scrub/common.c | 6 +-
fs/xfs/scrub/common.h | 4 +-
fs/xfs/scrub/dir_repair.c | 4 +-
fs/xfs/scrub/dirtree.c | 4 +-
fs/xfs/scrub/inode.c | 6 +-
fs/xfs/scrub/nlinks.c | 2 +-
fs/xfs/scrub/reap.c | 3 +-
fs/xfs/scrub/rtbitmap.c | 4 +-
fs/xfs/scrub/rtsummary.c | 4 +-
fs/xfs/scrub/tempfile.c | 29 +-
fs/xfs/xfs_inode.h | 3 +
include/keys/request_key_auth-type.h | 2 +-
include/linux/hugetlb.h | 7 -
include/linux/ieee80211.h | 5 +
include/linux/mm.h | 24 +-
include/net/bluetooth/coredump.h | 2 +
include/net/mac80211.h | 5 +-
include/net/netns/xfrm.h | 2 +-
include/net/sock.h | 2 +
include/sound/soc.h | 3 +-
include/sound/soc_sdw_utils.h | 42 +-
kernel/dma/coherent.c | 3 +-
kernel/dma/swiotlb.c | 4 +-
kernel/exit.c | 12 +-
kernel/fork.c | 4 +-
kernel/sched/core.c | 6 +-
kernel/signal.c | 119 +-
kernel/time/namespace.c | 2 +
kernel/time/posix-cpu-timers.c | 40 +-
mm/filemap.c | 2 +-
mm/huge_memory.c | 86 +-
mm/hugetlb.c | 17 -
mm/memblock.c | 18 +-
mm/memcontrol.c | 2 +-
mm/mlock.c | 2 +-
mm/mremap.c | 9 +-
mm/swapfile.c | 2 +-
mm/vma.c | 6 +-
net/atm/pppoatm.c | 42 +-
net/bluetooth/coredump.c | 65 +-
net/bluetooth/eir.c | 10 +-
net/bluetooth/hci_codec.c | 36 +-
net/bluetooth/hci_core.c | 18 +-
net/bluetooth/hci_sync.c | 2 +
net/bluetooth/iso.c | 53 +-
net/bluetooth/rfcomm/sock.c | 13 +-
net/bridge/br_mst.c | 20 +-
net/core/drop_monitor.c | 12 +-
net/core/neighbour.c | 56 +-
net/core/skbuff.c | 32 +-
net/core/sock.c | 16 +-
net/ipv4/esp4.c | 6 +
net/ipv4/icmp.c | 17 +-
net/ipv4/ip_tunnel_core.c | 16 +-
net/ipv4/sysctl_net_ipv4.c | 4 +-
net/ipv4/tcp_input.c | 3 +-
net/ipv4/tcp_ulp.c | 4 +
net/ipv4/xfrm4_input.c | 2 -
net/ipv6/esp6.c | 6 +
net/ipv6/route.c | 22 +-
net/ipv6/seg6_local.c | 3 +
net/ipv6/tcp_ipv6.c | 3 +-
net/ipv6/xfrm6_input.c | 2 -
net/ipv6/xfrm6_output.c | 10 +-
net/mac80211/Makefile | 1 -
net/mac80211/cfg.c | 63 +-
net/mac80211/debugfs.c | 2 +-
net/mac80211/debugfs_netdev.c | 9 +
net/mac80211/ieee80211_i.h | 5 +-
net/mac80211/iface.c | 79 +-
net/mac80211/main.c | 4 +
net/mac80211/mesh.c | 34 +-
net/mac80211/michael.h | 22 -
net/mac80211/offchannel.c | 7 +
net/mac80211/pm.c | 8 +-
net/mac80211/scan.c | 2 +-
net/mac80211/tdls.c | 19 +-
net/mac80211/tx.c | 107 +-
net/mac80211/util.c | 3 +-
net/mac80211/wpa.c | 1 -
net/netfilter/nf_flow_table_core.c | 12 +-
net/netfilter/nf_nat_core.c | 46 +-
net/netfilter/nf_tables_api.c | 22 +-
net/netfilter/nft_nat.c | 2 +-
net/openvswitch/conntrack.c | 2 +-
net/packet/af_packet.c | 4 +-
net/packet/internal.h | 2 +-
net/psp/psp_sock.c | 4 +
net/rds/ib_cm.c | 2 +-
net/sched/act_api.c | 11 +-
net/sched/sch_hhf.c | 9 +-
net/unix/garbage.c | 17 +-
net/wireless/Makefile | 2 +-
net/wireless/core.c | 150 +-
net/wireless/core.h | 10 +
net/{mac80211/michael.c => wireless/michael-mic.c} | 5 +-
net/wireless/rdev-ops.h | 3 +
net/wireless/scan.c | 43 +-
net/wireless/util.c | 35 +-
net/xfrm/espintcp.c | 6 +-
net/xfrm/xfrm_input.c | 65 +-
net/xfrm/xfrm_iptfs.c | 12 +-
net/xfrm/xfrm_state.c | 9 +-
net/xfrm/xfrm_user.c | 37 +-
rust/kernel/net/phy.rs | 38 +-
scripts/generate_rust_target.rs | 5 +
security/keys/encrypted-keys/encrypted.c | 20 +-
security/keys/gc.c | 4 +-
security/keys/request_key_auth.c | 12 +-
security/keys/trusted-keys/trusted_tpm2.c | 12 +-
security/landlock/net.c | 14 +
security/selinux/avc.c | 5 +-
security/selinux/hooks.c | 158 +-
security/selinux/include/objsec.h | 10 +-
sound/core/init.c | 3 +-
sound/core/pcm_timer.c | 7 +-
sound/hda/common/controller.c | 2 +-
sound/soc/amd/acp/acp-sdw-legacy-mach.c | 33 +-
sound/soc/amd/acp/acp-sdw-sof-mach.c | 31 +-
sound/soc/codecs/hdmi-codec.c | 6 +-
sound/soc/codecs/rt712-sdca-dmic.c | 14 +-
sound/soc/intel/boards/sof_sdw.c | 21 +-
sound/soc/sdw_utils/soc_sdw_bridge_cs35l56.c | 4 +-
sound/soc/sdw_utils/soc_sdw_utils.c | 59 +-
sound/soc/soc-pcm.c | 18 +-
sound/soc/ux500/ux500_msp_i2s.h | 4 +-
sound/usb/6fire/comm.c | 42 +-
sound/usb/6fire/comm.h | 2 +-
sound/usb/6fire/midi.c | 43 +-
sound/usb/6fire/midi.h | 2 +-
sound/usb/6fire/pcm.c | 138 +-
sound/usb/6fire/pcm.h | 5 +-
sound/usb/bcd2000/bcd2000.c | 33 +-
sound/usb/card.h | 3 +-
sound/usb/endpoint.c | 16 +-
sound/virtio/virtio_card.c | 4 +-
tools/perf/util/hist.h | 8 +-
.../selftests/arm64/mte/check_gcr_el1_cswitch.c | 2 +-
tools/testing/selftests/landlock/audit.h | 119 +-
tools/testing/selftests/landlock/audit_test.c | 4 +-
tools/testing/selftests/landlock/fs_test.c | 1694 +++++++++++++++++++-
tools/testing/selftests/landlock/net_test.c | 169 +-
389 files changed, 6902 insertions(+), 2843 deletions(-)Greg Kroah-Hartman
maintainerPATCH 2/398 landlock: Fix TCP Fast Open connection bypass
6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Buffet <[email protected]>
[ Upstream commit 33cb713db0161b54f04fe830e062c9e102c29a04 ]
The documentation of the socket_connect() LSM hook states that it controls connecting a socket to a remote address. It has not been the case since the addition of TCP Fast Open (RFC 7413) support, which allows opening a TCP connection (thus, setting a socket's destination address) via the MSG_FASTOPEN flag passed to sendto()/sendmsg()/sendmmsg(). The problem then got duplicated into MPTCP.
Landlock did not take it into account when its TCP support was added, leaving a bypass of TCP connect policy.
Ideally a call to the LSM hook would be added in the fastopen code path, in order to fix this generically. But connect() hooks are designed to run with the socket locked, unlike sendmsg() hooks.
[mic: Backport: adapt the TCP Fast Open check to the TCP-only network hooks]
--- security/landlock/net.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
security/landlock/net.c +14 -0
@@ -235,9 +235,23 @@ static int hook_socket_connect(struct socket *const sock, LANDLOCK_ACCESS_NET_CONNECT_TCP); } +static int hook_socket_sendmsg (struct socket *const sock, +struct msghdr *const msg,const int size) +{ +struct sockaddr *const address = msg->msg_name; + +if ((msg->msg_flags &MSG_FASTOPEN ) && address) +return current_check_access_socket ( + sock, address, msg->msg_namelen, +LANDLOCK_ACCESS_NET_CONNECT_TCP ); + +return 0 ; +} +static struct security_hook_list landlock_hooks[]__ro_after_init = {LSM_HOOK_INIT (socket_bind, hook_socket_bind),LSM_HOOK_INIT (socket_connect, hook_socket_connect), +LSM_HOOK_INIT (socket_sendmsg, hook_socket_sendmsg), };__init void landlock_add_net_hooks (void )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 4/398 selftests/landlock: Add missing connect(minimal AF_UNSPEC) test
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Buffet <[email protected]>
[ Upstream commit 6685201ebfacff0c889bcd569181fa6e8af5575e ]
connect_variant(unspec_any0) is called twice. Both calls end up in connect_variant_addrlen() with an address length of get_addrlen(minimal=false).
However, the connect() syscall and its variants (e.g. iouring/compat) accept much shorter addresses of 4 bytes and that behaviour was not tested.
Replace one of these calls with one using a minimal address length (just a bare sa_family=AF_UNSPEC field with no actual address). Also add a call using a truncated address for good measure.
--- tools/testing/selftests/landlock/net_test.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
tools/testing/selftests/landlock/net_test.c +13 -1
@@ -964,7 +964,19 @@ TEST_F(protocol, connect_unspec)EXPECT_EQ (0 ,close (ruleset_fd)); } - ret =connect_variant (connect_fd, &self->unspec_any0); +/* Try to re-disconnect with a truncated address struct. */ +EXPECT_EQ (-EINVAL , +connect_variant_addrlen ( + connect_fd, &self->unspec_any0, +get_addrlen (&self->unspec_any0, true) -1 )); + +/* +* Re-disconnect, with a minimal sockaddr struct (just a +* bare af_family=AF_UNSPEC field). +*/ + ret =connect_variant_addrlen (connect_fd, &self->unspec_any0, +get_addrlen (&self->unspec_any0, + true));if (self->srv0.protocol.domain ==AF_UNIX && self->srv0.protocol.type ==SOCK_STREAM ) {EXPECT_EQ (-EINVAL , ret);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 5/398 selftests/landlock: Fix socket file descriptor leaks in audit helpers
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mickaël Salaün <[email protected]>
[ Upstream commit 9143d790337a0d066c2d632c802f69b981e6c23a ]
audit_init() opens a netlink socket and configures it, but leaks the file descriptor if audit_set_status() or setsockopt() fails. Fix this by jumping to an error path that closes the socket before returning.
Apply the same fix to audit_init_with_exe_filter(), which leaks the file descriptor from audit_init() if audit_init_filter_exe() or audit_filter_exe() fails, and to audit_cleanup(), which leaks it if audit_init_filter_exe() fails in FIXTURE_TEARDOWN_PARENT().
--- tools/testing/selftests/landlock/audit.h | 26 +++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
tools/testing/selftests/landlock/audit.h +19 -7
@@ -443,17 +443,19 @@ static int audit_init(void) err =audit_set_status (fd,AUDIT_STATUS_ENABLED ,1 );if (err) -return err; + goto err_close; err =audit_set_status (fd,AUDIT_STATUS_PID ,getpid ());if (err) -return err; + goto err_close;/* Sets a timeout for negative tests. */ err =setsockopt (fd,SOL_SOCKET ,SO_RCVTIMEO , &audit_tv_default,sizeof (audit_tv_default)); -if (err) -return -errno; +if (err) { + err = -errno; + goto err_close; + }/* * Drains stale audit records that accumulated in the kernel backlog
@@ -466,6 +468,10 @@ static int audit_init(void) ;return fd; + +err_close: +close (fd); +return err; }static int audit_init_filter_exe (struct audit_filter *filter,const char *path)
@@ -515,8 +521,10 @@ static int audit_cleanup(int audit_fd, struct audit_filter *filter) filter = &new_filter; err =audit_init_filter_exe (filter,NULL ); -if (err) +if (err) { +close (audit_fd);return err; + } }/* Filters might not be in place. */
@@ -542,11 +550,15 @@ static int audit_init_with_exe_filter(struct audit_filter *filter) err =audit_init_filter_exe (filter,NULL );if (err) -return err; + goto err_close; err =audit_filter_exe (fd, filter,AUDIT_ADD_RULE );if (err) -return err; + goto err_close;return fd; + +err_close: +close (fd); +return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 6/398 selftests/landlock: Increase default audit socket timeout
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mickaël Salaün <[email protected]>
[ Upstream commit d8dfb4c7faa87c3e41a8678f38f136c2c7c036fa ]
matches_log_fs() and other audit_match_record() callers intermittently return -EAGAIN under heavy debug configs (KASAN, lockdep). The audit record delivery pipeline is asynchronous: landlock_log_denial() queues the record to audit_queue, and kauditd_thread dequeues and delivers via netlink. Under debug configs, kauditd scheduling between audit_log_end() and netlink_unicast() can exceed a syscall round trip (more than 1 usec), which was the value of the socket timeout used for the recvfrom() calls.
The observed failure [1] is an EAGAIN error code (-11) which means that the access record had not arrived within the 1 usec timeout of recvfrom(). The expected record does arrive, but only after matches_log_fs() has already returned. It is then consumed by a later audit_count_records() call, making records.access == 1 instead of 0.
Switch the default socket timeout to the slow value (1 second) so all audit_match_record() callers wait long enough for kauditd delivery, and lower it to the fast value (1 usec) only on the two paths that expect no
record: audit_count_records() and the expected_domain_id == 0 probe in matches_log_domain_deallocated(). audit_init() drains stale records with the fast timeout (terminating on -EAGAIN once the backlog is empty) and switches to the patient default before returning. 1 second gives ~10x margin over the observed maximum (~100 ms, while the happy path is ~23 us).
Rename the timeval constants to reflect their new roles:
- audit_tv_dom_drop (1 second) -> audit_tv_default: default socket timeout, patient enough for asynchronous kauditd delivery.
- audit_tv_default (1 usec) -> audit_tv_fast: fast timeout for paths that expect no record (drain, audit_count_records(), probes).
Invert the conditional in matches_log_domain_deallocated(). Check setsockopt returns on both the lower and restore paths; preserve the first error via !err when the restore fails after a prior error so the actionable return code is not masked by a bookkeeping failure.
Cc: Günther Noack <[email protected]>
Cc: Thomas Weißschuh <[email protected]>
Cc: [email protected]
Depends-on: 07c2572a8757 ("selftests/landlock: Skip stale records in audit_match_record()")
--- tools/testing/selftests/landlock/audit.h | 80 +++++++++++++++++++----- 1 file changed, 63 insertions(+), 17 deletions(-)
tools/testing/selftests/landlock/audit.h +63 -17
@@ -45,17 +45,25 @@ struct audit_message { }; }; -static const struct timeval audit_tv_dom_drop = { +static const struct timeval audit_tv_default = {/* -* Because domain deallocation is tied to asynchronous credential -* freeing, receiving such event may take some time. In practice, -* on a small VM, it should not exceed 100k usec, but let's wait up -* to 1 second to be safe. +* Default socket timeout for audit_match_record() callers that expect a +* record to arrive. Asynchronous kauditd delivery can exceed 1 usec +* under heavy debug configs (KASAN, lockdep), where kauditd_thread +* scheduling between audit_log_end() and netlink_unicast() takes longer +* than the previous 1 usec timeout. 1 second is a generous ceiling: on +* the happy path, kauditd delivers within dozens of usec. */ .tv_sec =1 , }; -static const struct timeval audit_tv_default = { +static const struct timeval audit_tv_fast = { +/* +* Fast timeout for paths that expect no record (audit_init() drain, +* audit_count_records(), probes). Causes audit_recv() to return +* -EAGAIN once the socket buffer is empty, naturally terminating the +* read loop. +*/ .tv_usec =1 , };
@@ -334,8 +342,13 @@ static int __maybe_unused matches_log_domain_allocated(int audit_fd, pid_t pid,* Matches a domain deallocation record. When expected_domain_id is non-zero, * the pattern includes the specific domain ID so that stale deallocation * records from a previous test (with a different domain ID) are skipped by -* audit_match_record(), and the socket timeout is temporarily increased to -* audit_tv_dom_drop to wait for the asynchronous kworker deallocation. +* audit_match_record(), waiting for the asynchronous kworker deallocation with +* the default patient timeout. +* +* When expected_domain_id is zero, the caller is probing for any dealloc record +* that may or may not arrive. Temporarily lowers the socket timeout to +* audit_tv_fast for this probe so it returns promptly when no record is +* pending; restores audit_tv_default after. */ static int __maybe_unused matches_log_domain_deallocated(int audit_fd, unsigned int num_denials,
@@ -361,16 +374,21 @@ matches_log_domain_deallocated(int audit_fd, unsigned int num_denials,if (log_match_len >=sizeof (log_match))return -E2BIG ; -if (expected_domain_id) -setsockopt (audit_fd,SOL_SOCKET ,SO_RCVTIMEO , - &audit_tv_dom_drop,sizeof (audit_tv_dom_drop)); +if (!expected_domain_id) { +if (setsockopt (audit_fd,SOL_SOCKET ,SO_RCVTIMEO , + &audit_tv_fast,sizeof (audit_tv_fast))) +return -errno; + } err =audit_match_record (audit_fd,AUDIT_LANDLOCK_DOMAIN , log_match, domain_id); -if (expected_domain_id) -setsockopt (audit_fd,SOL_SOCKET ,SO_RCVTIMEO , &audit_tv_default, -sizeof (audit_tv_default)); +if (!expected_domain_id) { +if (setsockopt (audit_fd,SOL_SOCKET ,SO_RCVTIMEO , + &audit_tv_default,sizeof (audit_tv_default)) && + !err) + err = -errno; + }return err; }
@@ -387,6 +405,11 @@ struct audit_records {* audit_init() and after the preceding audit_match_record() call. Allocation * records are emitted synchronously during landlock_log_denial() in the current * test's syscall context, so only those are counted in records->domain. +* +* Temporarily lowers SO_RCVTIMEO to audit_tv_fast for the read loop: this is a +* "no record expected" path that should terminate on the first -EAGAIN. The +* default patient timeout is restored on exit for subsequent +* audit_match_record() callers. */ static int audit_count_records (int audit_fd,struct audit_records *records) {
@@ -403,6 +426,12 @@ static int audit_count_records(int audit_fd, struct audit_records *records) records->access =0 ; records->domain =0 ; +if (setsockopt (audit_fd,SOL_SOCKET ,SO_RCVTIMEO , &audit_tv_fast, +sizeof (audit_tv_fast))) { + err = -errno; + goto out; + } + do { memset(&msg, 0, sizeof(msg)); err = audit_recv(audit_fd, &msg);
@@ -429,6 +458,10 @@ static int audit_count_records(int audit_fd, struct audit_records *records) }while (true); out: +if (setsockopt (audit_fd,SOL_SOCKET ,SO_RCVTIMEO , &audit_tv_default, +sizeof (audit_tv_default)) && + !err) + err = -errno;regfree (&dealloc_re);return err; }
@@ -449,9 +482,9 @@ static int audit_init(void)if (err) goto err_close; -/* Sets a timeout for negative tests. */ - err =setsockopt (fd,SOL_SOCKET ,SO_RCVTIMEO , &audit_tv_default, -sizeof (audit_tv_default)); +/* Uses the fast timeout to drain stale records below. */ + err =setsockopt (fd,SOL_SOCKET ,SO_RCVTIMEO , &audit_tv_fast, +sizeof (audit_tv_fast));if (err) { err = -errno; goto err_close;
@@ -467,6 +500,19 @@ static int audit_init(void)while (audit_recv (fd,NULL ) ==0 ) ; +/* +* Restores the default timeout for audit_match_record() callers that +* expect a record to arrive. Paths that expect no record restore the +* fast timeout locally (audit_count_records(), the expected_domain_id +* == 0 probe in matches_log_domain_deallocated()). +*/ + err =setsockopt (fd,SOL_SOCKET ,SO_RCVTIMEO , &audit_tv_default, +sizeof (audit_tv_default)); +if (err) { + err = -errno; + goto err_close; + } +return fd; err_close:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 3/398 selftests/landlock: Add test for TCP fast open
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Buffet <[email protected]>
[ Upstream commit f4b30e0b1d488e7ffd8ea28d1365b9ba8e551edb ]
Enforce that TCP Fast Open is controlled by LANDLOCK_ACCESS_NET_CONNECT_TCP. Semantics of connect() and sendmsg(MSG_FASTOPEN) should be identical from Landlock's perspective. Also enforce error code consistency, since UDP sockets ignore the MSG_FASTOPEN flag while Unix sockets reject it.
[mic: Backport: adapt the test to the older network fixture and add the required send helper]
--- tools/testing/selftests/landlock/net_test.c | 155 ++++++++++++++++++++ 1 file changed, 155 insertions(+)
tools/testing/selftests/landlock/net_test.c +155 -0
@@ -258,6 +258,64 @@ static int connect_variant(const int sock_fd,return connect_variant_addrlen (sock_fd, srv,get_addrlen (srv, false)); } +static int sendto_variant_addrlen (const int sock_fd, +const struct service_fixture *const srv, +const socklen_t addrlen,void *buf, +size_t len,size_t flags) +{ +const struct sockaddr *dst =NULL ; +ssize_t ret; + +/* +* We never want our processes to be killed by SIGPIPE: we check return +* codes and errno, so that we have actual error messages. +*/ + flags |=MSG_NOSIGNAL ; + +if (srv !=NULL ) { +switch (srv->protocol.domain) { +case AF_UNSPEC : +case AF_INET : + dst = (const struct sockaddr *)&srv->ipv4_addr; +break ; + +case AF_INET6 : + dst = (const struct sockaddr *)&srv->ipv6_addr; +break ; + +case AF_UNIX : + dst = (const struct sockaddr *)&srv->unix_addr; +break ; + +default : + errno =EAFNOSUPPORT ; +return -errno; + } + } + + ret =sendto (sock_fd, buf, len, flags, dst, addrlen); +if (ret <0 ) +return -errno; + +/* errno is not set in cases of partial writes. */ +if (ret != len) +return -EINTR ; + +return 0 ; +} + +static int sendto_variant (const int sock_fd, +const struct service_fixture *const srv,void *buf, +size_t len,size_t flags) +{ +socklen_t addrlen =0 ; + +if (srv !=NULL ) + addrlen =get_addrlen (srv, false); + +return sendto_variant_addrlen (sock_fd, srv, addrlen, buf, len, flags); +} +FIXTURE (protocol) {struct service_fixture srv0, srv1, srv2, unspec_any0, unspec_srv0;
@@ -938,6 +996,103 @@ TEST_F(protocol, connect_unspec)EXPECT_EQ (0 ,close (bind_fd)); } +TEST_F(protocol, tcp_fastopen) +{ +const bool restricted = variant->sandbox ==TCP_SANDBOX && + variant->prot.type ==SOCK_STREAM && + (variant->prot.protocol ==IPPROTO_TCP || + variant->prot.protocol ==IPPROTO_IP ) && + (variant->prot.domain ==AF_INET || + variant->prot.domain ==AF_INET6 ); +const struct landlock_ruleset_attr ruleset_attr = { + .handled_access_net =LANDLOCK_ACCESS_NET_CONNECT_TCP , + }; +int bind_fd, client_fd, status; +char buf; +pid_t child; + + bind_fd =socket_variant (&self->srv0); +ASSERT_LE (0 , bind_fd); +EXPECT_EQ (0 ,bind_variant (bind_fd, &self->srv0)); +if (self->srv0.protocol.type ==SOCK_STREAM ) +EXPECT_EQ (0 ,listen (bind_fd, backlog)); + + child =fork (); +ASSERT_LE (0 , child); +if (child ==0 ) { +int connect_fd, ret; + +/* Closes listening socket for the child. */ +EXPECT_EQ (0 ,close (bind_fd)); + + connect_fd =socket_variant (&self->srv0); +ASSERT_LE (0 , connect_fd); + +if (variant->sandbox ==TCP_SANDBOX ) { +const int ruleset_fd =landlock_create_ruleset ( + &ruleset_attr,sizeof (ruleset_attr),0 ); +ASSERT_LE (0 , ruleset_fd); + +enforce_ruleset (_metadata, ruleset_fd); +EXPECT_EQ (0 ,close (ruleset_fd)); + } + +/* Fast Open with no address. */ + ret =sendto_variant (connect_fd,NULL ,NULL ,0 ,MSG_FASTOPEN ); +if (self->srv0.protocol.domain ==AF_UNIX ) { +EXPECT_EQ (-ENOTCONN , ret); + }else if (self->srv0.protocol.type ==SOCK_DGRAM ) { +EXPECT_EQ (-EDESTADDRREQ , ret); + }else { +EXPECT_EQ (-EINVAL , ret); + } + +/* Fast Open to a denied address. */ + ret =sendto_variant (connect_fd, &self->srv0,"A" ,1 , +MSG_FASTOPEN ); +if (restricted) { +EXPECT_EQ (-EACCES , ret); + }else if (self->srv0.protocol.domain ==AF_UNIX && + self->srv0.protocol.type ==SOCK_STREAM ) { +EXPECT_EQ (-EOPNOTSUPP , ret); + }else { +EXPECT_EQ (0 , ret); + } + +EXPECT_EQ (0 ,close (connect_fd)); +_exit (_metadata->exit_code); +return ; + } + + client_fd = bind_fd; +if (!restricted && self->srv0.protocol.type ==SOCK_STREAM && + self->srv0.protocol.domain !=AF_UNIX ) { + client_fd =accept (bind_fd,NULL ,0 ); +ASSERT_LE (0 , client_fd); + } + +if (restricted) { +EXPECT_EQ (-1 ,read (client_fd, &buf,1 )); +EXPECT_EQ (ENOTCONN , errno); + }else if (self->srv0.protocol.domain ==AF_UNIX && + self->srv0.protocol.type ==SOCK_STREAM ) { +EXPECT_EQ (-1 ,read (client_fd, &buf,1 )); +EXPECT_EQ (EINVAL , errno); + }else { +EXPECT_EQ (1 ,read (client_fd, &buf,1 )); +EXPECT_EQ ('A' , buf); + } + +EXPECT_EQ (child,waitpid (child, &status,0 )); +EXPECT_EQ (1 ,WIFEXITED (status)); +EXPECT_EQ (EXIT_SUCCESS ,WEXITSTATUS (status)); + +if (client_fd != bind_fd) +EXPECT_LE (0 ,close (client_fd)); + +EXPECT_EQ (0 ,close (bind_fd)); +} +FIXTURE (ipv4) {struct service_fixture srv0, srv1;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 8/398 selftests/landlock: Add tests for access through disconnected paths
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tingmao Wang <[email protected]>
[ Upstream commit a18ee3f31fd714173a62515d049d77e76ab55649 ]
This adds tests for the edge case discussed in [1], with specific ones for rename and link operations when the operands are through disconnected paths, as that go through a separate code path in Landlock.
This has resulted in a warning, due to collect_domain_accesses() not expecting to reach a different root from path->mnt:
# RUN layout1_bind.path_disconnected ...
# OK layout1_bind.path_disconnected
ok 96 layout1_bind.path_disconnected
# RUN layout1_bind.path_disconnected_rename ...
[..] ------------[ cut here ]------------
[..] WARNING: CPU: 3 PID: 385 at security/landlock/fs.c:1065 collect_domain_accesses
[..] ...
[..] RIP: 0010:collect_domain_accesses (security/landlock/fs.c:1065 (discriminator 2) security/landlock/fs.c:1031 (discriminator 2)) [..] current_check_refer_path (security/landlock/fs.c:1205)
[..] ...
[..] hook_path_rename (security/landlock/fs.c:1526)
[..] security_path_rename (security/security.c:2026 (discriminator 1))
[..] do_renameat2 (fs/namei.c:5264)
# OK layout1_bind.path_disconnected_rename
ok 97 layout1_bind.path_disconnected_rename
Move the const char definitions a bit above so that we can use the path for s4d1 in cleanup code.
--- tools/testing/selftests/landlock/fs_test.c | 423 ++++++++++++++++++++- 1 file changed, 415 insertions(+), 8 deletions(-)
tools/testing/selftests/landlock/fs_test.c +415 -8
@@ -4559,6 +4559,18 @@ TEST_F_FORK(ioctl, handle_file_access_file)FIXTURE (layout1_bind) {};/* clang-format on */ +static const char bind_dir_s1d3[] =TMP_DIR "/s2d1/s2d2/s1d3" ; +static const char bind_file1_s1d3[] =TMP_DIR "/s2d1/s2d2/s1d3/f1" ; + +/* Move targets for disconnected path tests. */ +static const char dir_s4d1[] =TMP_DIR "/s4d1" ; +static const char file1_s4d1[] =TMP_DIR "/s4d1/f1" ; +static const char file2_s4d1[] =TMP_DIR "/s4d1/f2" ; +static const char dir_s4d2[] =TMP_DIR "/s4d1/s4d2" ; +static const char file1_s4d2[] =TMP_DIR "/s4d1/s4d2/f1" ; +static const char file1_name[] ="f1" ; +static const char file2_name[] ="f2" ; +FIXTURE_SETUP (layout1_bind) {prepare_layout (_metadata);
@@ -4574,14 +4586,14 @@ FIXTURE_TEARDOWN_PARENT(layout1_bind) {/* umount(dir_s2d2)) is handled by namespace lifetime. */ +remove_path (file1_s4d1); +remove_path (file2_s4d1); +remove_layout1 (_metadata);cleanup_layout (_metadata); } -static const char bind_dir_s1d3[] =TMP_DIR "/s2d1/s2d2/s1d3" ; -static const char bind_file1_s1d3[] =TMP_DIR "/s2d1/s2d2/s1d3/f1" ; -/* * layout1_bind hierarchy: *
@@ -4592,20 +4604,25 @@ static const char bind_file1_s1d3[] = TMP_DIR "/s2d1/s2d2/s1d3/f1";* │ └── s1d2 * │ ├── f1 * │ ├── f2 -* │ └── s1d3 +* │ └── s1d3 [disconnected by path_disconnected] * │ ├── f1 * │ └── f2 * ├── s2d1 * │ ├── f1 -* │ └── s2d2 +* │ └── s2d2 [bind mount from s1d2] * │ ├── f1 * │ ├── f2 * │ └── s1d3 * │ ├── f1 * │ └── f2 -* └── s3d1 -* └── s3d2 -* └── s3d3 +* ├── s3d1 +* │ └── s3d2 +* │ └── s3d3 +* └── s4d1 [renamed from s1d3 by path_disconnected] +* ├── f1 +* ├── f2 +* └── s4d2 +* └── f1 */ TEST_F_FORK (layout1_bind, no_restriction)
@@ -4804,6 +4821,396 @@ TEST_F_FORK(layout1_bind, reparent_cross_mount)ASSERT_EQ (0 ,rename (bind_file1_s1d3, file1_s2d2)); } +/* +* Make sure access to file through a disconnected path works as expected. +* This test moves s1d3 to s4d1. +*/ +TEST_F_FORK(layout1_bind, path_disconnected) +{ +const struct rule layer1_allow_all[] = { + { + .path =TMP_DIR , + .access =ACCESS_ALL , + }, + {}, + }; +const struct rule layer2_allow_just_f1[] = { + { + .path = file1_s1d3, + .access =LANDLOCK_ACCESS_FS_READ_FILE , + }, + {}, + }; +const struct rule layer3_only_s1d2[] = { + { + .path = dir_s1d2, + .access =LANDLOCK_ACCESS_FS_READ_FILE , + }, + {}, + }; + +/* Landlock should not deny access just because it is disconnected. */ +int ruleset_fd_l1 = +create_ruleset (_metadata,ACCESS_ALL , layer1_allow_all); + +/* Creates the new ruleset now before we move the dir containing the file. */ +int ruleset_fd_l2 = +create_ruleset (_metadata,ACCESS_RW , layer2_allow_just_f1); +int ruleset_fd_l3 = +create_ruleset (_metadata,ACCESS_RW , layer3_only_s1d2); +int bind_s1d3_fd; + +ASSERT_LE (0 , ruleset_fd_l1); +ASSERT_LE (0 , ruleset_fd_l2); +ASSERT_LE (0 , ruleset_fd_l3); + +enforce_ruleset (_metadata, ruleset_fd_l1); +EXPECT_EQ (0 ,close (ruleset_fd_l1)); + + bind_s1d3_fd =open (bind_dir_s1d3,O_PATH |O_CLOEXEC ); +ASSERT_LE (0 , bind_s1d3_fd); + +/* Tests access is possible before we move. */ +EXPECT_EQ (0 ,test_open_rel (bind_s1d3_fd, file1_name,O_RDONLY )); +EXPECT_EQ (0 ,test_open_rel (bind_s1d3_fd, file2_name,O_RDONLY )); +EXPECT_EQ (0 ,test_open_rel (bind_s1d3_fd,".." ,O_RDONLY |O_DIRECTORY )); + +/* Makes it disconnected. */ + ASSERT_EQ(0, rename(dir_s1d3, dir_s4d1)) + { +TH_LOG ("Failed to rename %s to %s: %s" , dir_s1d3, dir_s4d1, +strerror (errno)); + } + +/* Tests that access is still possible. */ +EXPECT_EQ (0 ,test_open_rel (bind_s1d3_fd, file1_name,O_RDONLY )); +EXPECT_EQ (0 ,test_open_rel (bind_s1d3_fd, file2_name,O_RDONLY )); + +/* +* Tests that ".." is not possible (not because of Landlock, but just +* because it's disconnected). +*/ +EXPECT_EQ (ENOENT , +test_open_rel (bind_s1d3_fd,".." ,O_RDONLY |O_DIRECTORY )); + +/* This should still work with a narrower rule. */ +enforce_ruleset (_metadata, ruleset_fd_l2); +EXPECT_EQ (0 ,close (ruleset_fd_l2)); + +EXPECT_EQ (0 ,test_open (file1_s4d1,O_RDONLY )); +/* +* Accessing a file through a disconnected file descriptor can still be +* allowed by a rule tied to this file, even if it is no longer visible in +* its mount point. +*/ +EXPECT_EQ (0 ,test_open_rel (bind_s1d3_fd, file1_name,O_RDONLY )); +EXPECT_EQ (EACCES ,test_open_rel (bind_s1d3_fd, file2_name,O_RDONLY )); + +enforce_ruleset (_metadata, ruleset_fd_l3); +EXPECT_EQ (0 ,close (ruleset_fd_l3)); + +EXPECT_EQ (EACCES ,test_open (file1_s4d1,O_RDONLY )); +/* +* Accessing a file through a disconnected file descriptor can still be +* allowed by a rule tied to the original mount point, even if it is no +* longer visible in its mount point. +*/ +EXPECT_EQ (0 ,test_open_rel (bind_s1d3_fd, file1_name,O_RDONLY )); +EXPECT_EQ (EACCES ,test_open_rel (bind_s1d3_fd, file2_name,O_RDONLY )); +} + +/* +* Test that renameat with disconnected paths works under Landlock. This test +* moves s1d3 to s4d2, so that we can have a rule allowing refers on the move +* target's immediate parent. +*/ +TEST_F_FORK(layout1_bind, path_disconnected_rename) +{ +const struct rule layer1[] = { + { + .path = dir_s1d2, + .access =LANDLOCK_ACCESS_FS_REFER | +LANDLOCK_ACCESS_FS_MAKE_DIR | +LANDLOCK_ACCESS_FS_REMOVE_DIR | +LANDLOCK_ACCESS_FS_MAKE_REG | +LANDLOCK_ACCESS_FS_REMOVE_FILE | +LANDLOCK_ACCESS_FS_READ_FILE , + }, + { + .path = dir_s4d1, + .access =LANDLOCK_ACCESS_FS_REFER | +LANDLOCK_ACCESS_FS_MAKE_DIR | +LANDLOCK_ACCESS_FS_REMOVE_DIR | +LANDLOCK_ACCESS_FS_MAKE_REG | +LANDLOCK_ACCESS_FS_REMOVE_FILE | +LANDLOCK_ACCESS_FS_READ_FILE , + }, + {} + }; + +/* This layer only handles LANDLOCK_ACCESS_FS_READ_FILE. */ +const struct rule layer2_only_s1d2[] = { + { + .path = dir_s1d2, + .access =LANDLOCK_ACCESS_FS_READ_FILE , + }, + {}, + }; +int ruleset_fd_l1, ruleset_fd_l2; +pid_t child_pid; +int bind_s1d3_fd, status; + + ASSERT_EQ(0, mkdir(dir_s4d1, 0755)) + { +TH_LOG ("Failed to create %s: %s" , dir_s4d1,strerror (errno)); + } + ruleset_fd_l1 =create_ruleset (_metadata,ACCESS_ALL , layer1); + ruleset_fd_l2 =create_ruleset (_metadata,LANDLOCK_ACCESS_FS_READ_FILE , + layer2_only_s1d2); +ASSERT_LE (0 , ruleset_fd_l1); +ASSERT_LE (0 , ruleset_fd_l2); + +enforce_ruleset (_metadata, ruleset_fd_l1); +EXPECT_EQ (0 ,close (ruleset_fd_l1)); + + bind_s1d3_fd =open (bind_dir_s1d3,O_PATH |O_CLOEXEC ); +ASSERT_LE (0 , bind_s1d3_fd); +EXPECT_EQ (0 ,test_open_rel (bind_s1d3_fd, file1_name,O_RDONLY )); + +/* Tests ENOENT priority over EACCES for disconnected directory. */ +EXPECT_EQ (EACCES ,test_open_rel (bind_s1d3_fd,".." ,O_DIRECTORY )); + ASSERT_EQ(0, rename(dir_s1d3, dir_s4d2)) + { +TH_LOG ("Failed to rename %s to %s: %s" , dir_s1d3, dir_s4d2, +strerror (errno)); + } +EXPECT_EQ (ENOENT ,test_open_rel (bind_s1d3_fd,".." ,O_DIRECTORY )); + +/* +* The file is no longer under s1d2 but we should still be able to access it +* with layer 2 because its mount point is evaluated as the first valid +* directory because it was initially a parent. Do a fork to test this so +* we don't prevent ourselves from renaming it back later. +*/ + child_pid =fork (); +ASSERT_LE (0 , child_pid); +if (child_pid ==0 ) { +enforce_ruleset (_metadata, ruleset_fd_l2); +EXPECT_EQ (0 ,close (ruleset_fd_l2)); +EXPECT_EQ (0 ,test_open_rel (bind_s1d3_fd, file1_name,O_RDONLY )); +EXPECT_EQ (EACCES ,test_open (file1_s4d2,O_RDONLY )); + +/* +* Tests that access widening checks indeed prevents us from renaming it +* back. +*/ +EXPECT_EQ (-1 ,rename (dir_s4d2, dir_s1d3)); +EXPECT_EQ (EXDEV , errno); + +/* +* Including through the now disconnected fd (but it should return +* EXDEV). +*/ +EXPECT_EQ (-1 ,renameat (bind_s1d3_fd, file1_name,AT_FDCWD , + file1_s2d2)); +EXPECT_EQ (EXDEV , errno); +_exit (_metadata->exit_code); +return ; + } + +EXPECT_EQ (child_pid,waitpid (child_pid, &status,0 )); +EXPECT_EQ (1 ,WIFEXITED (status)); +EXPECT_EQ (EXIT_SUCCESS ,WEXITSTATUS (status)); + + ASSERT_EQ(0, rename(dir_s4d2, dir_s1d3)) + { +TH_LOG ("Failed to rename %s back to %s: %s" , dir_s4d1, dir_s1d3, +strerror (errno)); + } + +/* Now checks that we can access it under l2. */ + child_pid =fork (); +ASSERT_LE (0 , child_pid); +if (child_pid ==0 ) { +enforce_ruleset (_metadata, ruleset_fd_l2); +EXPECT_EQ (0 ,close (ruleset_fd_l2)); +EXPECT_EQ (0 ,test_open_rel (bind_s1d3_fd, file1_name,O_RDONLY )); +EXPECT_EQ (0 ,test_open (file1_s1d3,O_RDONLY )); +_exit (_metadata->exit_code); +return ; + } + +EXPECT_EQ (child_pid,waitpid (child_pid, &status,0 )); +EXPECT_EQ (1 ,WIFEXITED (status)); +EXPECT_EQ (EXIT_SUCCESS ,WEXITSTATUS (status)); + +/* +* Also test that we can rename via a disconnected path. We move the +* dir back to the disconnected place first, then we rename file1 to +* file2 through our dir fd. +*/ + ASSERT_EQ(0, rename(dir_s1d3, dir_s4d2)) + { +TH_LOG ("Failed to rename %s to %s: %s" , dir_s1d3, dir_s4d2, +strerror (errno)); + } +ASSERT_EQ (0 , + renameat(bind_s1d3_fd, file1_name, bind_s1d3_fd, file2_name)) + { +TH_LOG ("Failed to rename %s to %s within disconnected %s: %s" , + file1_name, file2_name, bind_dir_s1d3,strerror (errno)); + } +EXPECT_EQ (0 ,test_open_rel (bind_s1d3_fd, file2_name,O_RDONLY )); + ASSERT_EQ(0, renameat(bind_s1d3_fd, file2_name, AT_FDCWD, file1_s2d2)) + { +TH_LOG ("Failed to rename %s to %s through disconnected %s: %s" , + file2_name, file1_s2d2, bind_dir_s1d3,strerror (errno)); + } +EXPECT_EQ (0 ,test_open (file1_s2d2,O_RDONLY )); +EXPECT_EQ (0 ,test_open (file1_s1d2,O_RDONLY )); + +/* Move it back using the disconnected path as the target. */ + ASSERT_EQ(0, renameat(AT_FDCWD, file1_s2d2, bind_s1d3_fd, file1_name)) + { +TH_LOG ("Failed to rename %s to %s through disconnected %s: %s" , + file1_s1d2, file1_name, bind_dir_s1d3,strerror (errno)); + } + +/* Now make it connected again. */ + ASSERT_EQ(0, rename(dir_s4d2, dir_s1d3)) + { +TH_LOG ("Failed to rename %s back to %s: %s" , dir_s4d2, dir_s1d3, +strerror (errno)); + } + +/* Checks again that we can access it under l2. */ +enforce_ruleset (_metadata, ruleset_fd_l2); +EXPECT_EQ (0 ,close (ruleset_fd_l2)); +EXPECT_EQ (0 ,test_open_rel (bind_s1d3_fd, file1_name,O_RDONLY )); +EXPECT_EQ (0 ,test_open (file1_s1d3,O_RDONLY )); +} + +/* +* Test that linkat(2) with disconnected paths works under Landlock. This +* test moves s1d3 to s4d1. +*/ +TEST_F_FORK(layout1_bind, path_disconnected_link) +{ +/* Ruleset to be applied after renaming s1d3 to s4d1. */ +const struct rule layer1[] = { + { + .path = dir_s4d1, + .access =LANDLOCK_ACCESS_FS_REFER | +LANDLOCK_ACCESS_FS_READ_FILE | +LANDLOCK_ACCESS_FS_MAKE_REG | +LANDLOCK_ACCESS_FS_REMOVE_FILE , + }, + { + .path = dir_s2d2, + .access =LANDLOCK_ACCESS_FS_REFER | +LANDLOCK_ACCESS_FS_READ_FILE | +LANDLOCK_ACCESS_FS_MAKE_REG | +LANDLOCK_ACCESS_FS_REMOVE_FILE , + }, + {} + }; +int ruleset_fd, bind_s1d3_fd; + +/* Removes unneeded files created by layout1, otherwise it will EEXIST. */ +ASSERT_EQ (0 ,unlink (file1_s1d2)); +ASSERT_EQ (0 ,unlink (file2_s1d3)); + + bind_s1d3_fd =open (bind_dir_s1d3,O_PATH |O_CLOEXEC ); +ASSERT_LE (0 , bind_s1d3_fd); +EXPECT_EQ (0 ,test_open_rel (bind_s1d3_fd, file1_name,O_RDONLY )); + +/* Disconnects bind_s1d3_fd. */ + ASSERT_EQ(0, rename(dir_s1d3, dir_s4d1)) + { +TH_LOG ("Failed to rename %s to %s: %s" , dir_s1d3, dir_s4d1, +strerror (errno)); + } + +/* Need this later to test different parent link. */ + ASSERT_EQ(0, mkdir(dir_s4d2, 0755)) + { +TH_LOG ("Failed to create %s: %s" , dir_s4d2,strerror (errno)); + } + + ruleset_fd =create_ruleset (_metadata,ACCESS_ALL , layer1); +ASSERT_LE (0 , ruleset_fd); +enforce_ruleset (_metadata, ruleset_fd); +EXPECT_EQ (0 ,close (ruleset_fd)); + +/* From disconnected to connected. */ + ASSERT_EQ(0, linkat(bind_s1d3_fd, file1_name, AT_FDCWD, file1_s2d2, 0)) + { +TH_LOG ("Failed to link %s to %s via disconnected %s: %s" , + file1_name, file1_s2d2, bind_dir_s1d3,strerror (errno)); + } + +/* Tests that we can access via the new link... */ + EXPECT_EQ(0, test_open(file1_s2d2, O_RDONLY)) + { +TH_LOG ("Failed to open newly linked %s: %s" , file1_s2d2, +strerror (errno)); + } + +/* ...as well as the old one. */ + EXPECT_EQ(0, test_open(file1_s4d1, O_RDONLY)) + { +TH_LOG ("Failed to open original %s: %s" , file1_s4d1, +strerror (errno)); + } + +/* From connected to disconnected. */ +ASSERT_EQ (0 ,unlink (file1_s4d1)); + ASSERT_EQ(0, linkat(AT_FDCWD, file1_s2d2, bind_s1d3_fd, file2_name, 0)) + { +TH_LOG ("Failed to link %s to %s via disconnected %s: %s" , + file1_s2d2, file2_name, bind_dir_s1d3,strerror (errno)); + } +EXPECT_EQ (0 ,test_open (file2_s4d1,O_RDONLY )); +ASSERT_EQ (0 ,unlink (file1_s2d2)); + +/* From disconnected to disconnected (same parent). */ +ASSERT_EQ (0 , + linkat(bind_s1d3_fd, file2_name, bind_s1d3_fd, file1_name, 0)) + { +TH_LOG ("Failed to link %s to %s within disconnected %s: %s" , + file2_name, file1_name, bind_dir_s1d3,strerror (errno)); + } + EXPECT_EQ(0, test_open(file1_s4d1, O_RDONLY)) + { +TH_LOG ("Failed to open newly linked %s: %s" , file1_s4d1, +strerror (errno)); + } + EXPECT_EQ(0, test_open_rel(bind_s1d3_fd, file1_name, O_RDONLY)) + { +TH_LOG ("Failed to open %s through newly created link under disconnected path: %s" , + file1_name,strerror (errno)); + } +ASSERT_EQ (0 ,unlink (file2_s4d1)); + +/* From disconnected to disconnected (different parent). */ +ASSERT_EQ (0 , + linkat(bind_s1d3_fd, file1_name, bind_s1d3_fd, "s4d2/f1", 0)) + { +TH_LOG ("Failed to link %s to %s within disconnected %s: %s" , + file1_name,"s4d2/f1" , bind_dir_s1d3,strerror (errno)); + } + EXPECT_EQ(0, test_open(file1_s4d2, O_RDONLY)) + { +TH_LOG ("Failed to open %s after link: %s" , file1_s4d2, +strerror (errno)); + } + EXPECT_EQ(0, test_open_rel(bind_s1d3_fd, "s4d2/f1", O_RDONLY)) + { +TH_LOG ("Failed to open %s through disconnected path after link: %s" , +"s4d2/f1" ,strerror (errno)); + } +} +#define LOWER_BASE TMP_DIR "/lower"#define LOWER_DATA LOWER_BASE "/data"static const char lower_fl1[] =LOWER_DATA "/fl1" ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 9/398 selftests/landlock: Add disconnected leafs and branch test suites
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mickaël Salaün <[email protected]>
[ Upstream commit 54f9baf537b0a091adad860ec92e3e18e0a0754c ]
Test disconnected directories with two test suites (layout4_disconnected_leafs and layout5_disconnected_branch) and 43 variants to cover the main corner cases.
These tests are complementary to the previous commit.
Add test_renameat() and test_exchangeat() helpers.
Test coverage for security/landlock is 92.1% of 1927 lines according to LLVM 20.
--- tools/testing/selftests/landlock/fs_test.c | 1051 ++++++++++++++++++++ 1 file changed, 1051 insertions(+)
tools/testing/selftests/landlock/fs_test.c +1051 -0
@@ -2267,6 +2267,22 @@ static int test_exchange(const char *const oldpath, const char *const newpath)return 0 ; } +static int test_renameat (int olddirfd,const char *oldpath,int newdirfd, +const char *newpath) +{ +if (renameat2 (olddirfd, oldpath, newdirfd, newpath,0 )) +return errno; +return 0 ; +} + +static int test_exchangeat (int olddirfd,const char *oldpath,int newdirfd, +const char *newpath) +{ +if (renameat2 (olddirfd, oldpath, newdirfd, newpath,RENAME_EXCHANGE )) +return errno; +return 0 ; +} + TEST_F_FORK(layout1, rename_file) {const struct rule rules[] = {
@@ -5211,6 +5227,1041 @@ TEST_F_FORK(layout1_bind, path_disconnected_link) } } +/* +* layout4_disconnected_leafs with bind mount and renames: +* +* tmp +* ├── s1d1 +* │ └── s1d2 [source of the bind mount] +* │ ├── s1d31 +* │ │ └── s1d41 [now renamed beneath s3d1] +* │ │ ├── f1 +* │ │ └── f2 +* │ └── s1d32 +* │ └── s1d42 [now renamed beneath s4d1] +* │ ├── f3 +* │ └── f4 +* ├── s2d1 +* │ └── s2d2 [bind mount of s1d2] +* │ ├── s1d31 +* │ │ └── s1d41 [opened FD, now renamed beneath s3d1] +* │ │ ├── f1 +* │ │ └── f2 +* │ └── s1d32 +* │ └── s1d42 [opened FD, now renamed beneath s4d1] +* │ ├── f3 +* │ └── f4 +* ├── s3d1 +* │ └── s1d41 [renamed here] +* │ ├── f1 +* │ └── f2 +* └── s4d1 +* └── s1d42 [renamed here] +* ├── f3 +* └── f4 +*/ +/* clang-format off */ +FIXTURE (layout4_disconnected_leafs) { +int s2d2_fd; +}; +/* clang-format on */ + +FIXTURE_SETUP (layout4_disconnected_leafs) +{ +prepare_layout (_metadata); + +create_file (_metadata,TMP_DIR "/s1d1/s1d2/s1d31/s1d41/f1" ); +create_file (_metadata,TMP_DIR "/s1d1/s1d2/s1d31/s1d41/f2" ); +create_file (_metadata,TMP_DIR "/s1d1/s1d2/s1d32/s1d42/f3" ); +create_file (_metadata,TMP_DIR "/s1d1/s1d2/s1d32/s1d42/f4" ); +create_directory (_metadata,TMP_DIR "/s2d1/s2d2" ); +create_directory (_metadata,TMP_DIR "/s3d1" ); +create_directory (_metadata,TMP_DIR "/s4d1" ); + + self->s2d2_fd = +open (TMP_DIR "/s2d1/s2d2" ,O_DIRECTORY |O_PATH |O_CLOEXEC ); +ASSERT_LE (0 , self->s2d2_fd); + +set_cap (_metadata,CAP_SYS_ADMIN ); +ASSERT_EQ (0 ,mount (TMP_DIR "/s1d1/s1d2" ,TMP_DIR "/s2d1/s2d2" ,NULL , +MS_BIND ,NULL )); +clear_cap (_metadata,CAP_SYS_ADMIN ); +} + +FIXTURE_TEARDOWN_PARENT (layout4_disconnected_leafs) +{ +/* umount(TMP_DIR "/s2d1") is handled by namespace lifetime. */ + +/* Removes files after renames. */ +remove_path (TMP_DIR "/s3d1/s1d41/f1" ); +remove_path (TMP_DIR "/s3d1/s1d41/f2" ); +remove_path (TMP_DIR "/s4d1/s1d42/f1" ); +remove_path (TMP_DIR "/s4d1/s1d42/f3" ); +remove_path (TMP_DIR "/s4d1/s1d42/f4" ); +remove_path (TMP_DIR "/s4d1/s1d42/f5" ); + +cleanup_layout (_metadata); +} + +FIXTURE_VARIANT (layout4_disconnected_leafs) +{ +/* +* Parent of the bind mount source. It should always be ignored when +* testing against files under the s1d41 or s1d42 disconnected directories. +*/ +const __u64 allowed_s1d1; +/* +* Source of bind mount (to s2d2). It should always be enforced when +* testing against files under the s1d41 or s1d42 disconnected directories. +*/ +const __u64 allowed_s1d2; +/* +* Original parent of s1d41. It should always be ignored when testing +* against files under the s1d41 disconnected directory. +*/ +const __u64 allowed_s1d31; +/* +* Original parent of s1d42. It should always be ignored when testing +* against files under the s1d42 disconnected directory. +*/ +const __u64 allowed_s1d32; +/* +* Opened and disconnected source directory. It should always be enforced +* when testing against files under the s1d41 disconnected directory. +*/ +const __u64 allowed_s1d41; +/* +* Opened and disconnected source directory. It should always be enforced +* when testing against files under the s1d42 disconnected directory. +*/ +const __u64 allowed_s1d42; +/* +* File in the s1d41 disconnected directory. It should always be enforced +* when testing against itself under the s1d41 disconnected directory. +*/ +const __u64 allowed_f1; +/* +* File in the s1d41 disconnected directory. It should always be enforced +* when testing against itself under the s1d41 disconnected directory. +*/ +const __u64 allowed_f2; +/* +* File in the s1d42 disconnected directory. It should always be enforced +* when testing against itself under the s1d42 disconnected directory. +*/ +const __u64 allowed_f3; +/* +* Parent of the bind mount destination. It should always be enforced when +* testing against files under the s1d41 or s1d42 disconnected directories. +*/ +const __u64 allowed_s2d1; +/* +* Directory covered by the bind mount. It should always be ignored when +* testing against files under the s1d41 or s1d42 disconnected directories. +*/ +const __u64 allowed_s2d2; +/* +* New parent of the renamed s1d41. It should always be ignored when +* testing against files under the s1d41 disconnected directory. +*/ +const __u64 allowed_s3d1; +/* +* New parent of the renamed s1d42. It should always be ignored when +* testing against files under the s1d42 disconnected directory. +*/ +const __u64 allowed_s4d1; + +/* Expected result of the call to open([fd:s1d41]/f1, O_RDONLY). */ +const int expected_read_result; +/* Expected result of the call to renameat([fd:s1d41]/f1, [fd:s1d42]/f1). */ +const int expected_rename_result; +/* +* Expected result of the call to renameat([fd:s1d41]/f2, [fd:s1d42]/f3, +* RENAME_EXCHANGE). +*/ +const int expected_exchange_result; +/* Expected result of the call to renameat([fd:s1d42]/f4, [fd:s1d42]/f5). */ +const int expected_same_dir_rename_result; +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout4_disconnected_leafs, s1d1_mount_src_parent) { +/* clang-format on */ + .allowed_s1d1 =LANDLOCK_ACCESS_FS_REFER | +LANDLOCK_ACCESS_FS_READ_FILE | +LANDLOCK_ACCESS_FS_EXECUTE | + LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = EACCES, + .expected_same_dir_rename_result = EACCES, + .expected_rename_result = EACCES, + .expected_exchange_result =EACCES , +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout4_disconnected_leafs, s1d2_mount_src_refer) { +/* clang-format on */ + .allowed_s1d2 =LANDLOCK_ACCESS_FS_REFER |LANDLOCK_ACCESS_FS_READ_FILE , + .expected_read_result = 0, + .expected_same_dir_rename_result = EACCES, + .expected_rename_result = EACCES, + .expected_exchange_result = EACCES, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout4_disconnected_leafs, s1d2_mount_src_create) { +/* clang-format on */ + .allowed_s1d2 =LANDLOCK_ACCESS_FS_READ_FILE | + LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = 0, + .expected_same_dir_rename_result = 0, + .expected_rename_result = EXDEV, + .expected_exchange_result =EXDEV , +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout4_disconnected_leafs, s1d2_mount_src_rename) { +/* clang-format on */ + .allowed_s1d2 =LANDLOCK_ACCESS_FS_REFER |LANDLOCK_ACCESS_FS_MAKE_REG , + .expected_read_result = EACCES, + .expected_same_dir_rename_result = 0, + .expected_rename_result = 0, + .expected_exchange_result = 0, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout4_disconnected_leafs, s1d31_s1d32_old_parent) { +/* clang-format on */ + .allowed_s1d31 =LANDLOCK_ACCESS_FS_REFER | +LANDLOCK_ACCESS_FS_READ_FILE | +LANDLOCK_ACCESS_FS_EXECUTE | + LANDLOCK_ACCESS_FS_MAKE_REG, + .allowed_s1d32 =LANDLOCK_ACCESS_FS_REFER | +LANDLOCK_ACCESS_FS_READ_FILE | +LANDLOCK_ACCESS_FS_EXECUTE | + LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = EACCES, + .expected_same_dir_rename_result = EACCES, + .expected_rename_result = EACCES, + .expected_exchange_result =EACCES , +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout4_disconnected_leafs, s1d41_s1d42_disconnected_refer) { +/* clang-format on */ + .allowed_s1d41 =LANDLOCK_ACCESS_FS_REFER | +LANDLOCK_ACCESS_FS_READ_FILE , + .allowed_s1d42 = LANDLOCK_ACCESS_FS_REFER | +LANDLOCK_ACCESS_FS_READ_FILE , + .expected_read_result = 0, + .expected_same_dir_rename_result = EACCES, + .expected_rename_result = EACCES, + .expected_exchange_result = EACCES, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout4_disconnected_leafs, s1d41_s1d42_disconnected_create) { +/* clang-format on */ + .allowed_s1d41 =LANDLOCK_ACCESS_FS_READ_FILE | + LANDLOCK_ACCESS_FS_MAKE_REG, + .allowed_s1d42 =LANDLOCK_ACCESS_FS_READ_FILE | + LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = 0, + .expected_same_dir_rename_result = 0, + .expected_rename_result = EXDEV, + .expected_exchange_result =EXDEV , +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout4_disconnected_leafs, s1d41_s1d42_disconnected_rename_even) { +/* clang-format on */ + .allowed_s1d41 =LANDLOCK_ACCESS_FS_REFER |LANDLOCK_ACCESS_FS_MAKE_REG , + .allowed_s1d42 = LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = EACCES, + .expected_same_dir_rename_result = 0, + .expected_rename_result = 0, + .expected_exchange_result = 0, +}; + +/* The destination directory has more access right. */ +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout4_disconnected_leafs, s1d41_s1d42_disconnected_rename_more) { +/* clang-format on */ + .allowed_s1d41 = LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_MAKE_REG, + .allowed_s1d42 =LANDLOCK_ACCESS_FS_REFER | +LANDLOCK_ACCESS_FS_MAKE_REG | + LANDLOCK_ACCESS_FS_EXECUTE, + .expected_read_result = EACCES, + .expected_same_dir_rename_result = 0, +/* Access denied. */ + .expected_rename_result = EXDEV, + .expected_exchange_result = EXDEV, +}; + +/* The destination directory has less access right. */ +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout4_disconnected_leafs, s1d41_s1d42_disconnected_rename_less) { +/* clang-format on */ + .allowed_s1d41 =LANDLOCK_ACCESS_FS_REFER | +LANDLOCK_ACCESS_FS_MAKE_REG | + LANDLOCK_ACCESS_FS_EXECUTE, + .allowed_s1d42 = LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = EACCES, + .expected_same_dir_rename_result = 0, +/* Access allowed. */ + .expected_rename_result = 0, + .expected_exchange_result =EXDEV , +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout4_disconnected_leafs, s2d1_mount_dst_parent_create) { +/* clang-format on */ + .allowed_s2d1 =LANDLOCK_ACCESS_FS_READ_FILE | +LANDLOCK_ACCESS_FS_MAKE_REG , + .expected_read_result = 0, + .expected_same_dir_rename_result = 0, + .expected_rename_result = EXDEV, + .expected_exchange_result = EXDEV, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout4_disconnected_leafs, s2d1_mount_dst_parent_refer) { +/* clang-format on */ + .allowed_s2d1 = LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_READ_FILE, + .expected_read_result = 0, + .expected_same_dir_rename_result = EACCES, + .expected_rename_result = EACCES, + .expected_exchange_result =EACCES , +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout4_disconnected_leafs, s2d1_mount_dst_parent_mini) { +/* clang-format on */ + .allowed_s2d1 =LANDLOCK_ACCESS_FS_REFER | +LANDLOCK_ACCESS_FS_READ_FILE | +LANDLOCK_ACCESS_FS_MAKE_REG , + .expected_read_result = 0, + .expected_same_dir_rename_result = 0, + .expected_rename_result = 0, + .expected_exchange_result = 0, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout4_disconnected_leafs, s2d2_covered_by_mount) { +/* clang-format on */ + .allowed_s2d2 =LANDLOCK_ACCESS_FS_REFER | +LANDLOCK_ACCESS_FS_READ_FILE | +LANDLOCK_ACCESS_FS_EXECUTE | + LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = EACCES, + .expected_same_dir_rename_result = EACCES, + .expected_rename_result = EACCES, + .expected_exchange_result = EACCES, +}; + +/* Tests collect_domain_accesses(). */ +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout4_disconnected_leafs, s3d1_s4d1_new_parent_refer) { +/* clang-format on */ + .allowed_s3d1 = LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_READ_FILE, + .allowed_s4d1 = LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_READ_FILE, + .expected_read_result = 0, + .expected_same_dir_rename_result = EACCES, + .expected_rename_result = EACCES, + .expected_exchange_result =EACCES , +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout4_disconnected_leafs, s3d1_s4d1_new_parent_create) { +/* clang-format on */ + .allowed_s3d1 =LANDLOCK_ACCESS_FS_READ_FILE | +LANDLOCK_ACCESS_FS_MAKE_REG , + .allowed_s4d1 = LANDLOCK_ACCESS_FS_READ_FILE | +LANDLOCK_ACCESS_FS_MAKE_REG , + .expected_read_result = 0, + .expected_same_dir_rename_result = 0, + .expected_rename_result = EXDEV, + .expected_exchange_result = EXDEV, +}; + +FIXTURE_VARIANT_ADD (layout4_disconnected_leafs, + s3d1_s4d1_disconnected_rename_even){ +/* clang-format on */ + .allowed_s3d1 =LANDLOCK_ACCESS_FS_REFER |LANDLOCK_ACCESS_FS_MAKE_REG , + .allowed_s4d1 = LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = EACCES, + .expected_same_dir_rename_result = 0, + .expected_rename_result = 0, + .expected_exchange_result = 0, +}; + +/* The destination directory has more access right. */ +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout4_disconnected_leafs, s3d1_s4d1_disconnected_rename_more) { +/* clang-format on */ + .allowed_s3d1 = LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_MAKE_REG, + .allowed_s4d1 =LANDLOCK_ACCESS_FS_REFER |LANDLOCK_ACCESS_FS_MAKE_REG | + LANDLOCK_ACCESS_FS_EXECUTE, + .expected_read_result = EACCES, + .expected_same_dir_rename_result = 0, +/* Access denied. */ + .expected_rename_result = EXDEV, + .expected_exchange_result = EXDEV, +}; + +/* The destination directory has less access right. */ +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout4_disconnected_leafs, s3d1_s4d1_disconnected_rename_less) { +/* clang-format on */ + .allowed_s3d1 =LANDLOCK_ACCESS_FS_REFER |LANDLOCK_ACCESS_FS_MAKE_REG | + LANDLOCK_ACCESS_FS_EXECUTE, + .allowed_s4d1 = LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = EACCES, + .expected_same_dir_rename_result = 0, +/* Access allowed. */ + .expected_rename_result = 0, + .expected_exchange_result =EXDEV , +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout4_disconnected_leafs, f1_f2_f3) { +/* clang-format on */ + .allowed_f1 =LANDLOCK_ACCESS_FS_READ_FILE , + .allowed_f2 = LANDLOCK_ACCESS_FS_READ_FILE, + .allowed_f3 = LANDLOCK_ACCESS_FS_READ_FILE, + .expected_read_result = 0, + .expected_same_dir_rename_result = EACCES, + .expected_rename_result = EACCES, + .expected_exchange_result = EACCES, +}; + +TEST_F_FORK(layout4_disconnected_leafs, read_rename_exchange) +{ + const __u64 handled_access = +LANDLOCK_ACCESS_FS_REFER |LANDLOCK_ACCESS_FS_READ_FILE | +LANDLOCK_ACCESS_FS_EXECUTE |LANDLOCK_ACCESS_FS_MAKE_REG ; +const struct rule rules[] = { + { + .path =TMP_DIR "/s1d1" , + .access = variant->allowed_s1d1, + }, + { + .path =TMP_DIR "/s1d1/s1d2" , + .access = variant->allowed_s1d2, + }, + { + .path =TMP_DIR "/s1d1/s1d2/s1d31" , + .access = variant->allowed_s1d31, + }, + { + .path =TMP_DIR "/s1d1/s1d2/s1d32" , + .access = variant->allowed_s1d32, + }, + { + .path =TMP_DIR "/s1d1/s1d2/s1d31/s1d41" , + .access = variant->allowed_s1d41, + }, + { + .path =TMP_DIR "/s1d1/s1d2/s1d32/s1d42" , + .access = variant->allowed_s1d42, + }, + { + .path =TMP_DIR "/s1d1/s1d2/s1d31/s1d41/f1" , + .access = variant->allowed_f1, + }, + { + .path =TMP_DIR "/s1d1/s1d2/s1d31/s1d41/f2" , + .access = variant->allowed_f2, + }, + { + .path =TMP_DIR "/s1d1/s1d2/s1d32/s1d42/f3" , + .access = variant->allowed_f3, + }, + { + .path =TMP_DIR "/s2d1" , + .access = variant->allowed_s2d1, + }, +/* s2d2_fd */ + { + .path =TMP_DIR "/s3d1" , + .access = variant->allowed_s3d1, + }, + { + .path =TMP_DIR "/s4d1" , + .access = variant->allowed_s4d1, + }, + {}, + }; +int ruleset_fd, s1d41_bind_fd, s1d42_bind_fd; + + ruleset_fd =create_ruleset (_metadata, handled_access, rules); +ASSERT_LE (0 , ruleset_fd); + +/* Adds rule for the covered directory. */ +if (variant->allowed_s2d2) { +ASSERT_EQ (0 ,landlock_add_rule ( + ruleset_fd,LANDLOCK_RULE_PATH_BENEATH , + &(struct landlock_path_beneath_attr ){ + .parent_fd = self->s2d2_fd, + .allowed_access = + variant->allowed_s2d2, + }, +0 )); + } +EXPECT_EQ (0 ,close (self->s2d2_fd)); + + s1d41_bind_fd =open (TMP_DIR "/s2d1/s2d2/s1d31/s1d41" , +O_DIRECTORY |O_PATH |O_CLOEXEC ); +ASSERT_LE (0 , s1d41_bind_fd); + s1d42_bind_fd =open (TMP_DIR "/s2d1/s2d2/s1d32/s1d42" , +O_DIRECTORY |O_PATH |O_CLOEXEC ); +ASSERT_LE (0 , s1d42_bind_fd); + +/* Disconnects and checks source and destination directories. */ +EXPECT_EQ (0 ,test_open_rel (s1d41_bind_fd,".." ,O_DIRECTORY )); +EXPECT_EQ (0 ,test_open_rel (s1d42_bind_fd,".." ,O_DIRECTORY )); +/* Renames to make it accessible through s3d1/s1d41 */ +ASSERT_EQ (0 ,test_renameat (AT_FDCWD ,TMP_DIR "/s1d1/s1d2/s1d31/s1d41" , +AT_FDCWD ,TMP_DIR "/s3d1/s1d41" )); +/* Renames to make it accessible through s4d1/s1d42 */ +ASSERT_EQ (0 ,test_renameat (AT_FDCWD ,TMP_DIR "/s1d1/s1d2/s1d32/s1d42" , +AT_FDCWD ,TMP_DIR "/s4d1/s1d42" )); +EXPECT_EQ (ENOENT ,test_open_rel (s1d41_bind_fd,".." ,O_DIRECTORY )); +EXPECT_EQ (ENOENT ,test_open_rel (s1d42_bind_fd,".." ,O_DIRECTORY )); + +enforce_ruleset (_metadata, ruleset_fd); +EXPECT_EQ (0 ,close (ruleset_fd)); + +EXPECT_EQ (variant->expected_read_result, +test_open_rel (s1d41_bind_fd,"f1" ,O_RDONLY )); + +EXPECT_EQ (variant->expected_rename_result, +test_renameat (s1d41_bind_fd,"f1" , s1d42_bind_fd,"f1" )); +EXPECT_EQ (variant->expected_exchange_result, +test_exchangeat (s1d41_bind_fd,"f2" , s1d42_bind_fd,"f3" )); + +EXPECT_EQ (variant->expected_same_dir_rename_result, +test_renameat (s1d42_bind_fd,"f4" , s1d42_bind_fd,"f5" )); +} + +/* +* layout5_disconnected_branch before rename: +* +* tmp +* ├── s1d1 +* │ └── s1d2 [source of the first bind mount] +* │ └── s1d3 +* │ ├── s1d41 +* │ │ ├── f1 +* │ │ └── f2 +* │ └── s1d42 +* │ ├── f3 +* │ └── f4 +* ├── s2d1 +* │ └── s2d2 [source of the second bind mount] +* │ └── s2d3 +* │ └── s2d4 [first s1d2 bind mount] +* │ └── s1d3 +* │ ├── s1d41 +* │ │ ├── f1 +* │ │ └── f2 +* │ └── s1d42 +* │ ├── f3 +* │ └── f4 +* ├── s3d1 +* │ └── s3d2 [second s2d2 bind mount] +* │ └── s2d3 +* │ └── s2d4 [first s1d2 bind mount] +* │ └── s1d3 +* │ ├── s1d41 +* │ │ ├── f1 +* │ │ └── f2 +* │ └── s1d42 +* │ ├── f3 +* │ └── f4 +* └── s4d1 +* +* After rename: +* +* tmp +* ├── s1d1 +* │ └── s1d2 [source of the first bind mount] +* │ └── s1d3 +* │ ├── s1d41 +* │ │ ├── f1 +* │ │ └── f2 +* │ └── s1d42 +* │ ├── f3 +* │ └── f4 +* ├── s2d1 +* │ └── s2d2 [source of the second bind mount] +* ├── s3d1 +* │ └── s3d2 [second s2d2 bind mount] +* └── s4d1 +* └── s2d3 [renamed here] +* └── s2d4 [first s1d2 bind mount] +* └── s1d3 +* ├── s1d41 +* │ ├── f1 +* │ └── f2 +* └── s1d42 +* ├── f3 +* └── f4 +* +* Decision path for access from the s3d1/s3d2/s2d3/s2d4/s1d3 file descriptor: +* 1. first bind mount: s1d3 -> s1d2 +* 2. second bind mount: s2d3 +* 3. tmp mount: s4d1 -> tmp [disconnected branch] +* 4. second bind mount: s2d2 +* 5. tmp mount: s3d1 -> tmp +* 6. parent mounts: [...] -> / +* +* The s4d1 directory is evaluated even if it is not in the s2d2 mount. +*/ + +/* clang-format off */ +FIXTURE (layout5_disconnected_branch) { +int s2d4_fd, s3d2_fd; +}; +/* clang-format on */ + +FIXTURE_SETUP (layout5_disconnected_branch) +{ +prepare_layout (_metadata); + +create_file (_metadata,TMP_DIR "/s1d1/s1d2/s1d3/s1d41/f1" ); +create_file (_metadata,TMP_DIR "/s1d1/s1d2/s1d3/s1d41/f2" ); +create_file (_metadata,TMP_DIR "/s1d1/s1d2/s1d3/s1d42/f3" ); +create_file (_metadata,TMP_DIR "/s1d1/s1d2/s1d3/s1d42/f4" ); +create_directory (_metadata,TMP_DIR "/s2d1/s2d2/s2d3/s2d4" ); +create_directory (_metadata,TMP_DIR "/s3d1/s3d2" ); +create_directory (_metadata,TMP_DIR "/s4d1" ); + + self->s2d4_fd =open (TMP_DIR "/s2d1/s2d2/s2d3/s2d4" , +O_DIRECTORY |O_PATH |O_CLOEXEC ); +ASSERT_LE (0 , self->s2d4_fd); + + self->s3d2_fd = +open (TMP_DIR "/s3d1/s3d2" ,O_DIRECTORY |O_PATH |O_CLOEXEC ); +ASSERT_LE (0 , self->s3d2_fd); + +set_cap (_metadata,CAP_SYS_ADMIN ); +ASSERT_EQ (0 ,mount (TMP_DIR "/s1d1/s1d2" ,TMP_DIR "/s2d1/s2d2/s2d3/s2d4" , +NULL ,MS_BIND ,NULL )); +ASSERT_EQ (0 ,mount (TMP_DIR "/s2d1/s2d2" ,TMP_DIR "/s3d1/s3d2" ,NULL , +MS_BIND |MS_REC ,NULL )); +clear_cap (_metadata,CAP_SYS_ADMIN ); +} + +FIXTURE_TEARDOWN_PARENT (layout5_disconnected_branch) +{ +/* Bind mounts are handled by namespace lifetime. */ + +/* Removes files after renames. */ +remove_path (TMP_DIR "/s1d1/s1d2/s1d3/s1d41/f1" ); +remove_path (TMP_DIR "/s1d1/s1d2/s1d3/s1d41/f2" ); +remove_path (TMP_DIR "/s1d1/s1d2/s1d3/s1d42/f1" ); +remove_path (TMP_DIR "/s1d1/s1d2/s1d3/s1d42/f3" ); +remove_path (TMP_DIR "/s1d1/s1d2/s1d3/s1d42/f4" ); +remove_path (TMP_DIR "/s1d1/s1d2/s1d3/s1d42/f5" ); + +cleanup_layout (_metadata); +} + +FIXTURE_VARIANT (layout5_disconnected_branch) +{ +/* +* Parent of all files. It should always be enforced when testing against +* files under the s1d41 or s1d42 disconnected directories. +*/ +const __u64 allowed_base; +/* +* Parent of the first bind mount source. It should always be ignored when +* testing against files under the s1d41 or s1d42 disconnected directories. +*/ +const __u64 allowed_s1d1; +const __u64 allowed_s1d2; +const __u64 allowed_s1d3; +const __u64 allowed_s2d1; +const __u64 allowed_s2d2; +const __u64 allowed_s2d3; +const __u64 allowed_s2d4; +const __u64 allowed_s3d1; +const __u64 allowed_s3d2; +const __u64 allowed_s4d1; + +/* Expected result of the call to open([fd:s1d3]/s1d41/f1, O_RDONLY). */ +const int expected_read_result; +/* +* Expected result of the call to renameat([fd:s1d3]/s1d41/f1, +* [fd:s1d3]/s1d42/f1). +*/ +const int expected_rename_result; +/* +* Expected result of the call to renameat([fd:s1d3]/s1d41/f2, +* [fd:s1d3]/s1d42/f3, RENAME_EXCHANGE). +*/ +const int expected_exchange_result; +/* +* Expected result of the call to renameat([fd:s1d3]/s1d42/f4, +* [fd:s1d3]/s1d42/f5). +*/ +const int expected_same_dir_rename_result; +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout5_disconnected_branch, s1d1_mount1_src_parent) { +/* clang-format on */ + .allowed_s1d1 =LANDLOCK_ACCESS_FS_REFER | +LANDLOCK_ACCESS_FS_READ_FILE | +LANDLOCK_ACCESS_FS_EXECUTE | + LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = EACCES, + .expected_same_dir_rename_result = EACCES, + .expected_rename_result = EACCES, + .expected_exchange_result = EACCES, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout5_disconnected_branch, s1d2_mount1_src_refer) { +/* clang-format on */ + .allowed_s1d2 = LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_READ_FILE, + .expected_read_result = 0, + .expected_same_dir_rename_result = EACCES, + .expected_rename_result = EACCES, + .expected_exchange_result = EACCES, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout5_disconnected_branch, s1d2_mount1_src_create) { +/* clang-format on */ + .allowed_s1d2 =LANDLOCK_ACCESS_FS_READ_FILE | + LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = 0, + .expected_same_dir_rename_result = 0, + .expected_rename_result = EXDEV, + .expected_exchange_result = EXDEV, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout5_disconnected_branch, s1d2_mount1_src_rename) { +/* clang-format on */ + .allowed_s1d2 = LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = EACCES, + .expected_same_dir_rename_result = 0, + .expected_rename_result = 0, + .expected_exchange_result = 0, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout5_disconnected_branch, s1d3_fd_refer) { +/* clang-format on */ + .allowed_s1d3 = LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_READ_FILE, + .expected_read_result = 0, + .expected_same_dir_rename_result = EACCES, + .expected_rename_result = EACCES, + .expected_exchange_result = EACCES, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout5_disconnected_branch, s1d3_fd_create) { +/* clang-format on */ + .allowed_s1d3 =LANDLOCK_ACCESS_FS_READ_FILE | + LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = 0, + .expected_same_dir_rename_result = 0, + .expected_rename_result = EXDEV, + .expected_exchange_result = EXDEV, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout5_disconnected_branch, s1d3_fd_rename) { +/* clang-format on */ + .allowed_s1d3 = LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = EACCES, + .expected_same_dir_rename_result = 0, + .expected_rename_result = 0, + .expected_exchange_result = 0, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout5_disconnected_branch, s1d3_fd_full) { +/* clang-format on */ + .allowed_s1d3 =LANDLOCK_ACCESS_FS_REFER | +LANDLOCK_ACCESS_FS_READ_FILE | +LANDLOCK_ACCESS_FS_EXECUTE | + LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = 0, + .expected_same_dir_rename_result = 0, + .expected_rename_result = 0, + .expected_exchange_result = 0, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout5_disconnected_branch, s2d1_mount2_src_parent) { +/* clang-format on */ + .allowed_s2d1 =LANDLOCK_ACCESS_FS_REFER | +LANDLOCK_ACCESS_FS_READ_FILE | +LANDLOCK_ACCESS_FS_EXECUTE | + LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = EACCES, + .expected_same_dir_rename_result = EACCES, + .expected_rename_result = EACCES, + .expected_exchange_result = EACCES, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout5_disconnected_branch, s2d2_mount2_src_refer) { +/* clang-format on */ + .allowed_s2d2 = LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_READ_FILE, + .expected_read_result = 0, + .expected_same_dir_rename_result = EACCES, + .expected_rename_result = EACCES, + .expected_exchange_result = EACCES, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout5_disconnected_branch, s2d2_mount2_src_create) { +/* clang-format on */ + .allowed_s2d2 =LANDLOCK_ACCESS_FS_READ_FILE | + LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = 0, + .expected_same_dir_rename_result = 0, + .expected_rename_result = EXDEV, + .expected_exchange_result = EXDEV, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout5_disconnected_branch, s2d2_mount2_src_rename) { +/* clang-format on */ + .allowed_s2d2 = LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = EACCES, + .expected_same_dir_rename_result = 0, + .expected_rename_result = 0, + .expected_exchange_result = 0, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout5_disconnected_branch, s2d3_mount1_dst_parent_refer) { +/* clang-format on */ + .allowed_s2d3 = LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_READ_FILE, + .expected_read_result = 0, + .expected_same_dir_rename_result = EACCES, + .expected_rename_result = EACCES, + .expected_exchange_result = EACCES, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout5_disconnected_branch, s2d3_mount1_dst_parent_create) { +/* clang-format on */ + .allowed_s2d3 =LANDLOCK_ACCESS_FS_READ_FILE | + LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = 0, + .expected_same_dir_rename_result = 0, + .expected_rename_result = EXDEV, + .expected_exchange_result = EXDEV, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout5_disconnected_branch, s2d3_mount1_dst_parent_rename) { +/* clang-format on */ + .allowed_s2d3 = LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = EACCES, + .expected_same_dir_rename_result = 0, + .expected_rename_result = 0, + .expected_exchange_result = 0, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout5_disconnected_branch, s2d4_mount1_dst) { +/* clang-format on */ + .allowed_s2d4 =LANDLOCK_ACCESS_FS_REFER | +LANDLOCK_ACCESS_FS_READ_FILE | +LANDLOCK_ACCESS_FS_EXECUTE | + LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = EACCES, + .expected_same_dir_rename_result = EACCES, + .expected_rename_result = EACCES, + .expected_exchange_result = EACCES, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout5_disconnected_branch, s3d1_mount2_dst_parent_refer) { +/* clang-format on */ + .allowed_s3d1 = LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_READ_FILE, + .expected_read_result = 0, + .expected_same_dir_rename_result = EACCES, + .expected_rename_result = EACCES, + .expected_exchange_result = EACCES, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout5_disconnected_branch, s3d1_mount2_dst_parent_create) { +/* clang-format on */ + .allowed_s3d1 =LANDLOCK_ACCESS_FS_READ_FILE | + LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = 0, + .expected_same_dir_rename_result = 0, + .expected_rename_result = EXDEV, + .expected_exchange_result = EXDEV, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout5_disconnected_branch, s3d1_mount2_dst_parent_rename) { +/* clang-format on */ + .allowed_s3d1 = LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = EACCES, + .expected_same_dir_rename_result = 0, + .expected_rename_result = 0, + .expected_exchange_result = 0, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout5_disconnected_branch, s3d2_mount1_dst) { +/* clang-format on */ + .allowed_s3d2 =LANDLOCK_ACCESS_FS_REFER | +LANDLOCK_ACCESS_FS_READ_FILE | +LANDLOCK_ACCESS_FS_EXECUTE | + LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = EACCES, + .expected_same_dir_rename_result = EACCES, + .expected_rename_result = EACCES, + .expected_exchange_result = EACCES, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout5_disconnected_branch, s4d1_rename_parent_refer) { +/* clang-format on */ + .allowed_s4d1 = LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_READ_FILE, + .expected_read_result = 0, + .expected_same_dir_rename_result = EACCES, + .expected_rename_result = EACCES, + .expected_exchange_result = EACCES, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout5_disconnected_branch, s4d1_rename_parent_create) { +/* clang-format on */ + .allowed_s4d1 =LANDLOCK_ACCESS_FS_READ_FILE | + LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = 0, + .expected_same_dir_rename_result = 0, + .expected_rename_result = EXDEV, + .expected_exchange_result = EXDEV, +}; + +/* clang-format off */ +FIXTURE_VARIANT_ADD(layout5_disconnected_branch, s4d1_rename_parent_rename) { +/* clang-format on */ + .allowed_s4d1 = LANDLOCK_ACCESS_FS_REFER | LANDLOCK_ACCESS_FS_MAKE_REG, + .expected_read_result = EACCES, + .expected_same_dir_rename_result = 0, + .expected_rename_result = 0, + .expected_exchange_result = 0, +}; + +TEST_F_FORK(layout5_disconnected_branch, read_rename_exchange) +{ +const __u64 handled_access = +LANDLOCK_ACCESS_FS_REFER |LANDLOCK_ACCESS_FS_READ_FILE | +LANDLOCK_ACCESS_FS_EXECUTE |LANDLOCK_ACCESS_FS_MAKE_REG ; +const struct rule rules[] = { + { + .path =TMP_DIR "/s1d1" , + .access = variant->allowed_s1d1, + }, + { + .path =TMP_DIR "/s1d1/s1d2" , + .access = variant->allowed_s1d2, + }, + { + .path =TMP_DIR "/s1d1/s1d2/s1d3" , + .access = variant->allowed_s1d3, + }, + { + .path =TMP_DIR "/s2d1" , + .access = variant->allowed_s2d1, + }, + { + .path =TMP_DIR "/s2d1/s2d2" , + .access = variant->allowed_s2d2, + }, + { + .path =TMP_DIR "/s2d1/s2d2/s2d3" , + .access = variant->allowed_s2d3, + }, +/* s2d4_fd */ + { + .path =TMP_DIR "/s3d1" , + .access = variant->allowed_s3d1, + }, +/* s3d2_fd */ + { + .path =TMP_DIR "/s4d1" , + .access = variant->allowed_s4d1, + }, + {}, + }; +int ruleset_fd, s1d3_bind_fd; + + ruleset_fd =create_ruleset (_metadata, handled_access, rules); +ASSERT_LE (0 , ruleset_fd); + +/* Adds rules for the covered directories. */ +if (variant->allowed_s2d4) { +ASSERT_EQ (0 ,landlock_add_rule ( + ruleset_fd,LANDLOCK_RULE_PATH_BENEATH , + &(struct landlock_path_beneath_attr ){ + .parent_fd = self->s2d4_fd, + .allowed_access = + variant->allowed_s2d4, + }, +0 )); + } +EXPECT_EQ (0 ,close (self->s2d4_fd)); + +if (variant->allowed_s3d2) { +ASSERT_EQ (0 ,landlock_add_rule ( + ruleset_fd,LANDLOCK_RULE_PATH_BENEATH , + &(struct landlock_path_beneath_attr ){ + .parent_fd = self->s3d2_fd, + .allowed_access = + variant->allowed_s3d2, + }, +0 )); + } +EXPECT_EQ (0 ,close (self->s3d2_fd)); + + s1d3_bind_fd =open (TMP_DIR "/s3d1/s3d2/s2d3/s2d4/s1d3" , +O_DIRECTORY |O_PATH |O_CLOEXEC ); +ASSERT_LE (0 , s1d3_bind_fd); + +/* Disconnects and checks source and destination directories. */ +EXPECT_EQ (0 ,test_open_rel (s1d3_bind_fd,".." ,O_DIRECTORY )); +EXPECT_EQ (0 ,test_open_rel (s1d3_bind_fd,"../.." ,O_DIRECTORY )); +/* Renames to make it accessible through s3d1/s1d41 */ +ASSERT_EQ (0 ,test_renameat (AT_FDCWD ,TMP_DIR "/s2d1/s2d2/s2d3" , +AT_FDCWD ,TMP_DIR "/s4d1/s2d3" )); +EXPECT_EQ (0 ,test_open_rel (s1d3_bind_fd,".." ,O_DIRECTORY )); +EXPECT_EQ (ENOENT ,test_open_rel (s1d3_bind_fd,"../.." ,O_DIRECTORY )); + +enforce_ruleset (_metadata, ruleset_fd); +EXPECT_EQ (0 ,close (ruleset_fd)); + +EXPECT_EQ (variant->expected_read_result, +test_open_rel (s1d3_bind_fd,"s1d41/f1" ,O_RDONLY )); + +EXPECT_EQ (variant->expected_rename_result, +test_renameat (s1d3_bind_fd,"s1d41/f1" , s1d3_bind_fd, +"s1d42/f1" )); +EXPECT_EQ (variant->expected_exchange_result, +test_exchangeat (s1d3_bind_fd,"s1d41/f2" , s1d3_bind_fd, +"s1d42/f3" )); + +EXPECT_EQ (variant->expected_same_dir_rename_result, +test_renameat (s1d3_bind_fd,"s1d42/f4" , s1d3_bind_fd, +"s1d42/f5" )); +} +#define LOWER_BASE TMP_DIR "/lower"#define LOWER_DATA LOWER_BASE "/data"static const char lower_fl1[] =LOWER_DATA "/fl1" ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 10/398 selftests/landlock: Use an actual chardev for MAKE_CHAR audit test
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Günther Noack <[email protected]>
[ Upstream commit 173b1bd8730825e1f6862dbd07856e7d68447a41 ]
By passing a (0, 0) device number, the audit test for LANDLOCK_ACCESS_FS_MAKE_CHAR was accidentally creating a whiteout object rather than a char device. In preparation to treating whiteout objects differently, use an actual character device instead.
--- tools/testing/selftests/landlock/fs_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/landlock/fs_test.c +1 -1
@@ -7315,7 +7315,7 @@ TEST_F(audit_layout1, make_char) .handled_access_fs = access_fs_16, }); -EXPECT_EQ (-1 ,mknod (file1_s1d3,S_IFCHR |0644 ,0 )); +EXPECT_EQ (-1 ,mknod (file1_s1d3,S_IFCHR |0644 ,makedev (7 ,0 )));EXPECT_EQ (EACCES , errno);EXPECT_EQ (0 ,matches_log_fs (_metadata, self->audit_fd,"fs\\.make_char" , dir_s1d3));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 11/398 selftests/landlock: Add tests for whiteout object creation
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Günther Noack <[email protected]>
[ Upstream commit ee890889b30b22f9a21636061def7a04e4f89380 ]
Add tests to check that whiteout object creation is guarded by LANDLOCK_ACCESS_FS_MAKE_REG, in the cases where these are created from userspace:
* Conventional creation with mknod()
* Linking or renaming an existing whiteout object
* renameat2() with RENAME_WHITEOUT,
which creates a new whiteout object in the source location
* renameat2() with RENAME_EXCHANGE,
with one of the renamed objects being a whiteout object
--- tools/testing/selftests/landlock/fs_test.c | 197 +++++++++++++++++++++ 1 file changed, 197 insertions(+)
tools/testing/selftests/landlock/fs_test.c +197 -0
@@ -791,6 +791,27 @@ static int create_ruleset(struct __test_metadata *const _metadata,return ruleset_fd; } +static void enforce_fs (struct __test_metadata *const _metadata, +const __u64 access_fs,const struct rule rules[]) +{ +int ruleset_fd; + +if (rules) { + ruleset_fd =create_ruleset (_metadata, access_fs, rules); + }else { +const struct landlock_ruleset_attr ruleset_attr = { + .handled_access_fs = access_fs, + }; + + ruleset_fd =landlock_create_ruleset (&ruleset_attr, +sizeof (ruleset_attr),0 ); +ASSERT_LE (0 , ruleset_fd); + } + +enforce_ruleset (_metadata, ruleset_fd); +EXPECT_EQ (0 ,close (ruleset_fd)); +} + TEST_F_FORK(layout0, proc_nsfs) {const struct rule rules[] = {
@@ -2365,6 +2386,170 @@ TEST_F_FORK(layout1, rename_file) RENAME_EXCHANGE)); } +TEST_F_FORK(layout1, rename_whiteout_denied) +{ +/* The affected file is a FIFO. */ +ASSERT_EQ (0 ,unlink (file1_s3d3)); +ASSERT_EQ (0 ,mknod (file1_s3d3,S_IFIFO |0600 ,0 )); + +/* Deny MAKE_REG, but allow MAKE_FIFO. */ +enforce_fs (_metadata,LANDLOCK_ACCESS_FS_MAKE_REG ,NULL ); + +/* +* Try to rename a file with RENAME_WHITEOUT. +* file1_s3d3 is in dir_s3d2 (tmpfs), so it supports RENAME_WHITEOUT. +* Denied, because whiteout creation is guarded with MAKE_REG. +*/ +EXPECT_EQ (-1 ,renameat2 (AT_FDCWD , file1_s3d3,AT_FDCWD , +TMP_DIR "/s3d1/s3d2/s3d3/f2" ,RENAME_WHITEOUT )); +EXPECT_EQ (EACCES , errno); +} + +static bool is_whiteout (const char *const path) +{ +struct stat st; + +if (stat (path, &st) ==-1 ) +return false; + +return S_ISCHR (st.st_mode) && st.st_rdev ==makedev (0 ,0 ); +} + +static bool is_fifo (const char *const path) +{ +struct stat st; + +return stat (path, &st) ==0 &&S_ISFIFO (st.st_mode); +} + +TEST_F_FORK(layout1, rename_whiteout_allowed) +{ +const struct rule rules[] = { + { + .path = dir_s3d3, + .access =LANDLOCK_ACCESS_FS_MAKE_REG , + }, + {}, + }; + +/* The affected file is a FIFO. */ +ASSERT_EQ (0 ,unlink (file1_s3d3)); +ASSERT_EQ (0 ,mknod (file1_s3d3,S_IFIFO |0600 ,0 )); + +/* Allow MAKE_REG below dir_s3d3. */ +enforce_fs (_metadata,LANDLOCK_ACCESS_FS_MAKE_REG , rules); + +/* +* Rename a file with RENAME_WHITEOUT within the same directory. +* Allowed, because MAKE_REG is granted for the whiteout object which +* gets created in the source location. +*/ +EXPECT_EQ (0 ,renameat2 (AT_FDCWD , file1_s3d3,AT_FDCWD , +TMP_DIR "/s3d1/s3d2/s3d3/f2" ,RENAME_WHITEOUT )); + +/* A whiteout object took the place of the moved FIFO. */ +EXPECT_TRUE (is_whiteout (file1_s3d3)); +EXPECT_TRUE (is_fifo (TMP_DIR "/s3d1/s3d2/s3d3/f2" )); +} + +TEST_F_FORK(layout1, rename_whiteout_reparenting) +{ +const struct rule rules[] = { + { + .path = dir_s3d2, + .access =LANDLOCK_ACCESS_FS_REFER , + }, + { + .path = dir_s3d3, + .access =LANDLOCK_ACCESS_FS_MAKE_REG , + }, + {}, + }; + +/* The moved files are FIFOs. */ +ASSERT_EQ (0 ,unlink (file1_s3d3)); +ASSERT_EQ (0 ,mknod (file1_s3d3,S_IFIFO |0600 ,0 )); +ASSERT_EQ (0 ,unlink (file1_s3d4)); +ASSERT_EQ (0 ,mknod (file1_s3d4,S_IFIFO |0600 ,0 )); + +/* Allow REFER below dir_s3d2, but MAKE_REG only below dir_s3d3. */ +enforce_fs (_metadata, +LANDLOCK_ACCESS_FS_MAKE_REG |LANDLOCK_ACCESS_FS_REFER , + rules); + +/* +* The whiteout object is created in the source directory: Moving the +* FIFO out of dir_s3d4 is denied because MAKE_REG is not granted +* there, even though it is granted in the destination directory +* dir_s3d3. +*/ +EXPECT_EQ (-1 ,renameat2 (AT_FDCWD , file1_s3d4,AT_FDCWD , +TMP_DIR "/s3d1/s3d2/s3d3/f2" ,RENAME_WHITEOUT )); +EXPECT_EQ (EACCES , errno); + +/* +* Moving the FIFO out of dir_s3d3 is allowed, because MAKE_REG is +* granted there for the created whiteout object. +*/ +EXPECT_EQ (0 ,renameat2 (AT_FDCWD , file1_s3d3,AT_FDCWD , +TMP_DIR "/s3d1/s3d2/s3d4/f2" ,RENAME_WHITEOUT )); + +/* A whiteout object took the place of the moved FIFO. */ +EXPECT_TRUE (is_whiteout (file1_s3d3)); +EXPECT_TRUE (is_fifo (TMP_DIR "/s3d1/s3d2/s3d4/f2" )); +} + +TEST_F_FORK(layout1, rename_whiteout_exchange) +{ +const char *const whiteout_s3d3 =TMP_DIR "/s3d1/s3d2/s3d3/f2" ; +const struct rule rules[] = { + { + .path = dir_s3d2, + .access =LANDLOCK_ACCESS_FS_REFER , + }, + { + .path = dir_s3d3, + .access =LANDLOCK_ACCESS_FS_MAKE_REG , + }, + {}, + }; + +/* The exchanged files are FIFOs and an existing whiteout object. */ +ASSERT_EQ (0 ,unlink (file1_s3d3)); +ASSERT_EQ (0 ,mknod (file1_s3d3,S_IFIFO |0600 ,0 )); +ASSERT_EQ (0 ,mknod (whiteout_s3d3,S_IFCHR |0600 ,makedev (0 ,0 ))); +ASSERT_EQ (0 ,unlink (file1_s3d4)); +ASSERT_EQ (0 ,mknod (file1_s3d4,S_IFIFO |0600 ,0 )); + +/* Allow REFER below dir_s3d2, but MAKE_REG only below dir_s3d3. */ +enforce_fs (_metadata, +LANDLOCK_ACCESS_FS_MAKE_REG |LANDLOCK_ACCESS_FS_REFER , + rules); + +/* +* With RENAME_EXCHANGE, the whiteout object moves into the source +* directory of the rename: Exchanging the FIFO in dir_s3d4 with the +* whiteout object is denied because MAKE_REG is not granted in +* dir_s3d4, even though it is granted in the whiteout object's own +* directory dir_s3d3. +*/ +EXPECT_EQ (-1 ,renameat2 (AT_FDCWD , file1_s3d4,AT_FDCWD , whiteout_s3d3, +RENAME_EXCHANGE )); +EXPECT_EQ (EACCES , errno); + +/* +* Exchanging the FIFO in dir_s3d3 with the whiteout object is +* allowed, because MAKE_REG is granted in the directory into which +* the whiteout object moves. +*/ +EXPECT_EQ (0 ,renameat2 (AT_FDCWD , file1_s3d3,AT_FDCWD , whiteout_s3d3, +RENAME_EXCHANGE )); + +/* The FIFO and the whiteout object swapped places. */ +EXPECT_TRUE (is_whiteout (file1_s3d3)); +EXPECT_TRUE (is_fifo (whiteout_s3d3)); +} + TEST_F_FORK(layout1, rename_dir) {const struct rule rules[] = {
@@ -3456,6 +3641,18 @@ TEST_F_FORK(layout1, make_char) makedev(1, 3)); } +TEST_F_FORK(layout1, make_whiteout) +{ +/* +* Creates a whiteout object (creation guarded by MAKE_REG). +* +* Contrary to the other character devices, this does not require +* CAP_MKNOD, cf. vfs_mknod(). +*/ +test_make_file (_metadata,LANDLOCK_ACCESS_FS_MAKE_REG ,S_IFCHR , +makedev (0 ,0 )); +} + TEST_F_FORK(layout1, make_block) {/* Creates a /dev/loop0 device. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 7/398 selftests/landlock: Explicitly disable audit in teardowns
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maximilian Heyne <[email protected]>
[ Upstream commit 0302cd72fe196aee933e3fb76f6d175d1ab0e843 ]
I'm seeing sporadic selftest failures, such as
# RUN scoped_audit.connect_to_child ...
# scoped_abstract_unix_test.c:314:connect_to_child:Expected 0 (0) == records.access (8) # connect_to_child: Test failed
# FAIL scoped_audit.connect_to_child
not ok 19 scoped_audit.connect_to_child
This seems similar to what commit 3647a4977fb73d ("selftests/landlock:
Drain stale audit records on init") tried to fix. However, the added drain loop is not effective. When setting the AUDIT_STATUS_PID, the kauditd_thread is woken up starting to send messages from the hold queue to the netlink. Depending on scheduling of this kthread not all messages might be send via the netlink in the 1 us interval.
Therefore, instead of trying to drain the queue, let's just disable audit when running non-audit tests or more precisely disable it after audit-tests. This way we won't generate any new audit message that could interfere with the other tests.
The comment saying that on process exit audit will be disabled is wrong. The closed file descriptor just causes an auditd_reset(), not a disablement. So future messages will be queued in the hold queue.
--- tools/testing/selftests/landlock/audit.h | 21 +++++++------------ tools/testing/selftests/landlock/audit_test.c | 4 +--- 2 files changed, 9 insertions(+), 16 deletions(-)
tools/testing/selftests/landlock/audit.h +8 -13
@@ -553,10 +553,9 @@ static int audit_init_filter_exe(struct audit_filter *filter, const char *path)static int audit_cleanup (int audit_fd,struct audit_filter *filter) {struct audit_filter new_filter; +int err =0 ;if (audit_fd <0 || !filter) { -int err; -/* * Simulates audit_init_with_exe_filter() when called from * FIXTURE_TEARDOWN_PARENT().
@@ -567,23 +566,19 @@ static int audit_cleanup(int audit_fd, struct audit_filter *filter) filter = &new_filter; err =audit_init_filter_exe (filter,NULL ); -if (err) { -close (audit_fd); -return err; - } +if (err) + goto err_close; }/* Filters might not be in place. */ audit_filter_exe (audit_fd, filter,AUDIT_DEL_RULE );audit_filter_drop (audit_fd,AUDIT_DEL_RULE ); -/* -* Because audit_cleanup() might not be called by the test auditd -* process, it might not be possible to explicitly set it. Anyway, -* AUDIT_STATUS_ENABLED will implicitly be set to 0 when the auditd -* process will exit. -*/ -return close (audit_fd); + err =audit_set_status (audit_fd,AUDIT_STATUS_ENABLED ,0 ); + +err_close: +close (audit_fd); +return err; }static int audit_init_with_exe_filter (struct audit_filter *filter)
tools/testing/selftests/landlock/audit_test.c +1 -3
@@ -617,10 +617,8 @@ FIXTURE_SETUP(audit_exec)FIXTURE_TEARDOWN (audit_exec) {set_cap (_metadata,CAP_AUDIT_CONTROL ); -EXPECT_EQ (0 ,audit_filter_exe (self->audit_fd, &self->audit_filter, -AUDIT_DEL_RULE )); +EXPECT_EQ (0 ,audit_cleanup (self->audit_fd, &self->audit_filter));clear_cap (_metadata,CAP_AUDIT_CONTROL ); -EXPECT_EQ (0 ,close (self->audit_fd)); }TEST_F (audit_exec, signal_and_open)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 12/398 selftests/landlock: Add audit test for whiteout object creation
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Günther Noack <[email protected]>
[ Upstream commit 8c46c6acbebe0d8544fd1b55e5ddf36828d7b9ea ]
Add audit_layout1.make_whiteout: This test looks similar to audit_layout1.make_char, but creates a whiteout object through mknod(). Since whiteout object creation is now guarded with LANDLOCK_ACCESS_FS_MAKE_REG rather than LANDLOCK_ACCESS_FS_MAKE_CHAR, it also needs to log the matching denial to audit.
--- tools/testing/selftests/landlock/fs_test.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
tools/testing/selftests/landlock/fs_test.c +21 -0
@@ -7522,6 +7522,27 @@ TEST_F(audit_layout1, make_char)EXPECT_EQ (1 , records.domain); } +TEST_F(audit_layout1, make_whiteout) +{ +struct audit_records records; + +EXPECT_EQ (0 ,unlink (file1_s1d3)); + +drop_access_rights (_metadata, &(struct landlock_ruleset_attr ){ + .handled_access_fs = access_fs_16, + }); + +/* Whiteout creation is denied and logged as fs.make_reg. */ +EXPECT_EQ (-1 ,mknod (file1_s1d3,S_IFCHR |0644 ,makedev (0 ,0 ))); +EXPECT_EQ (EACCES , errno); +EXPECT_EQ (0 ,matches_log_fs (_metadata, self->audit_fd,"fs\\.make_reg" , + dir_s1d3)); + +EXPECT_EQ (0 ,audit_count_records (self->audit_fd, &records)); +EXPECT_EQ (0 , records.access); +EXPECT_EQ (1 , records.domain); +} + TEST_F(audit_layout1, make_dir) {struct audit_records records;
Signature · 1 line
2.53.0
PATCH 14/398 media: video-i2c: fix buffer queue ordering
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arash Golgol <[email protected]>
[ Upstream commit bc4574c265ed738849e46d942617100580fcedd2 ]
Queued buffers are added to the tail of vid_cap_active in buffer_queue(), but the capture kthread also retrieves buffers from the tail of the list.
This makes the queue behave as LIFO instead of FIFO when multiple buffers are queued.
Fix this by retrieving buffers from the head of the list.
--- drivers/media/i2c/video-i2c.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/i2c/video-i2c.c +3 -2
@@ -454,8 +454,9 @@ static int video_i2c_thread_vid_cap(void *priv)spin_lock (&data->slock);if (!list_empty (&data->vid_cap_active)) { - vid_cap_buf =list_last_entry (&data->vid_cap_active, - struct video_i2c_buffer, list); + vid_cap_buf =list_first_entry (&data->vid_cap_active, + struct video_i2c_buffer, + list);list_del (&vid_cap_buf->list); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 23/398 ARM: socfpga: select the PL310 erratum 753970 workaround
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit cfc1e9a543e3589ba200795b6e7fd8ef4314efdf ]
ARCH_INTEL_SOCFPGA selects CACHE_L2X0 and several PL310 erratum workarounds. The 753970 workaround is still conditioned on PL310, but that Kconfig symbol no longer exists, so this one selection is always disabled.
Select PL310_ERRATA_753970 directly, consistently with the other PL310 workarounds required by the platform.
--- arch/arm/mach-socfpga/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-socfpga/Kconfig +1 -1
@@ -16,7 +16,7 @@ menuconfig ARCH_INTEL_SOCFPGA select ARM_ERRATA_775420 select PL310_ERRATA_588369 select PL310_ERRATA_727915 - select PL310_ERRATA_753970 if PL310 + select PL310_ERRATA_753970 select PL310_ERRATA_769419 select RESET_CONTROLLER
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 24/398 RDMA/siw: Clear association under lock if siw_qp_modify fails in siw_accept
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guoqing Jiang <[email protected]>
[ Upstream commit 32cd87f54dd1070020e664ccb0312a9f0fea79b4 ]
We need to clear cep before release state_lock as siw_qp_llp_close and siw_qp_modify->siw_qp_llp_close did.
Otherwise if siw_qp_modify() fails in siw_accept(), the QP's state_lock is released before the error path cleanup. A concurrent ibv_modify_qp() transitioning the QP to ERROR can race in this window:
siw_accept() ibv_modify_qp(ERROR)
---------------------- ----------------------
siw_qp_modify() fails
up_write(&qp->state_lock)
down_write(&qp->state_lock)
nextstate_from_idle():
if (qp->cep)
siw_cep_put(qp->cep) <- frees cep
qp->cep = NULL
goto error
cep->qp = NULL <- UAFClear qp->cep and drop the association reference taken by siw_cep_get(), all under the write lock held from the initial down_write(&qp->state_lock). Thread B therefore sees qp->cep == NULL, skips its own put, and cannot free the cep before siw_accept() is done with it.
--- drivers/infiniband/sw/siw/siw_cm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/infiniband/sw/siw/siw_cm.c +5 -2
@@ -1669,9 +1669,12 @@ int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params)SIW_QP_ATTR_STATE |SIW_QP_ATTR_LLP_HANDLE |SIW_QP_ATTR_ORD |SIW_QP_ATTR_IRD | SIW_QP_ATTR_MPA); +if (rv) { + qp->cep =NULL ; +siw_cep_put (cep); + goto error_unlock; + }up_write (&qp->state_lock); -if (rv) - goto error;siw_dbg_cep (cep,"[QP %u]: send mpa reply, %d byte pdata\n" ,qp_id (qp), params->private_data_len);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 25/398 RDMA/rxe: validate access flags before swapping the MRs PD
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Norbert Szetei <[email protected]>
[ Upstream commit ae36a5b609ae79f4de966328b78d2584be9719a4 ]
rxe_rereg_user_mr() reassigns mr->ibmr.pd first and only then validates the IB_MR_REREG_ACCESS argument:
if (flags & IB_MR_REREG_PD) {
rxe_put(old_pd);
rxe_get(pd);
mr->ibmr.pd = ibpd;
}
if (flags & IB_MR_REREG_ACCESS) {
if (access & ~RXE_ACCESS_SUPPORTED_MR)
return ERR_PTR(-EOPNOTSUPP);
mr->access = access;
}Both flags pass the entry check because RXE_MR_REREG_SUPPORTED is IB_MR_REREG_PD | IB_MR_REREG_ACCESS, so a caller can reach the access check with mr->ibmr.pd already reassigned.
mr->ibmr.pd is owned by the core, which adjusts pd->usecnt only on the success path: ib_uverbs_rereg_mr() jumps to put_new_uobj on a driver error without undoing the reassignment, so mr->pd == new_pd while the usecnts still charge the MR to orig_pd. ib_dereg_mr_user() then decrements new_pd, whose count can reach zero while a memory window still references it; uverbs_free_pd() frees the PD on that count alone and rxe_mw_cleanup() writes to freed memory:
BUG: KASAN: slab-use-after-free in __rxe_put+0x31/0xa0 Write of size 4 at addr ffff8881301dd690 by task rxe_poc/591 __rxe_put+0x31/0xa0 rxe_mw_cleanup+0x42/0x200 __rxe_cleanup+0x115/0x370 rxe_dealloc_mw+0x4c/0x80 Allocated by task 591: ib_uverbs_alloc_pd+0x258/0x540 Freed by task 591: ib_dealloc_pd_user+0x174/0x210 uverbs_free_pd+0x8d/0xc0 ib_uverbs_dealloc_pd+0x18e/0x1d0
Validate the access flags before mutating any state so the callback either applies every requested change or none.
--- drivers/infiniband/sw/rxe/rxe_verbs.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/infiniband/sw/rxe/rxe_verbs.c +7 -6
@@ -1346,19 +1346,20 @@ static struct ib_mr *rxe_rereg_user_mr(struct ib_mr *ibmr, int flags,if (err)return ERR_PTR (err); +if ((flags &IB_MR_REREG_ACCESS ) && + (access & ~RXE_ACCESS_SUPPORTED_MR )) { +rxe_err_mr (mr,"access = %#x not supported\n" , access); +return ERR_PTR (-EOPNOTSUPP ); + } +if (flags &IB_MR_REREG_PD ) {rxe_put (old_pd);rxe_get (pd); mr->ibmr.pd = ibpd; } -if (flags &IB_MR_REREG_ACCESS ) { -if (access & ~RXE_ACCESS_SUPPORTED_MR ) { -rxe_err_mr (mr,"access = %#x not supported\n" , access); -return ERR_PTR (-EOPNOTSUPP ); - } +if (flags &IB_MR_REREG_ACCESS ) mr->access = access; - }return NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 26/398 RDMA/rxe: Fix integer overflow in mr_check_range() leading to OOB access
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gang Yan <[email protected]>
[ Upstream commit d10e2a08799e858d3e71ea4169bcd018f216d444 ]
mr_check_range() validates that [iova, iova+length) falls within the registered MR range using wraparound-prone arithmetic:
if (iova < mr->ibmr.iova ||
iova + length > mr->ibmr.iova + mr->ibmr.length)A remote peer can craft an RDMA-Write/Read RETH so that iova + length wraps to 0 (e.g. iova=0xfffffffffffffff8, length=8), bypassing the check. rxe_mr_iova_to_index() then computes a huge index (int idx, only guarded by WARN_ON) and rxe_mr_copy_xarray() dereferences mr->page_info[huge], causing an out-of-bounds read/write and a kernel oops that is triggerable by an unauthenticated remote peer.
Rewrite the check in overflow-safe form; the first two clauses guarantee that the subsequent subtractions do not underflow:
if (iova < mr->ibmr.iova ||
length > mr->ibmr.length ||
iova - mr->ibmr.iova > mr->ibmr.length - length)With the fix, mr_check_range() returns -EINVAL for the crafted iova and the responder reports REMOTE_ACCESS_ERROR instead of triggering the OOB.
--- drivers/infiniband/sw/rxe/rxe_mr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_mr.c +2 -1
@@ -33,7 +33,8 @@ int mr_check_range(struct rxe_mr *mr, u64 iova, size_t length)case IB_MR_TYPE_USER :case IB_MR_TYPE_MEM_REG :if (iova < mr->ibmr.iova || - iova + length > mr->ibmr.iova + mr->ibmr.length) { + length > mr->ibmr.length || + iova - mr->ibmr.iova > mr->ibmr.length - length) {rxe_dbg_mr (mr,"iova/length out of range\n" );return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 27/398 firmware: arm_scpi: reject DVFS OPP count above MAX_DVFS_OPPS
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xixin Liu <[email protected]>
[ Upstream commit 32471d84a487c7fd74532bc96be56f8028cf4a3f ]
scpi_dvfs_get_info() already rejected a zero opp_count, but still trusted any larger value from the SCP firmware. The shared-memory reply only holds MAX_DVFS_OPPS entries in buf.opps[]; a bigger count over-reads that array and then sizes the allocated OPP table incorrectly (garbage OPPs / OOB). The missing upper bound dates back to the original SCPI DVFS support.
Reject zero and out-of-range counts in one check and return -EINVAL.
--- drivers/firmware/arm_scpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/firmware/arm_scpi.c +2 -2
@@ -631,8 +631,8 @@ static struct scpi_dvfs_info *scpi_dvfs_get_info(u8 domain)if (ret)return ERR_PTR (ret); -if (!buf.opp_count) -return ERR_PTR (-ENOENT ); +if (!buf.opp_count || buf.opp_count >MAX_DVFS_OPPS ) +return ERR_PTR (-EINVAL ); info =kmalloc (sizeof (*info),GFP_KERNEL );if (!info)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 28/398 clk: scpi: bound-check DVFS index in scpi_dvfs_recalc_rate
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xixin Liu <[email protected]>
[ Upstream commit 70f4b78d560e592cbf3325b162424737d032fc1d ]
dvfs_get_idx() may return an out-of-range index if the SCP firmware is buggy or returns a stale value. Only negative indexes were rejected, so a large index walked past info->opps and could treat garbage as a clock rate (KASAN OOB / wrong frequency to consumers). The missing upper bound dates back to the original SCPI clock driver.
Treat indexes >= opp count as invalid and return 0, same as idx < 0.
--- drivers/clk/clk-scpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk-scpi.c +1 -1
@@ -85,7 +85,7 @@ static unsigned long scpi_dvfs_recalc_rate(struct clk_hw *hw,int idx = clk->scpi_ops->dvfs_get_idx (clk->id);const struct scpi_opp *opp; -if (idx <0 ) +if (idx <0 || idx >= clk->info->count)return 0 ; opp = clk->info->opps + idx;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 29/398 RDMA/rxe: Restore HMM_PFN_WRITE check in ODP write paths
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit 769001ce838d907ecaa95f1d0a4e8fc86f761f9f ]
Commit 0b261d7c1cd3 ("RDMA/rxe: Break endless pagefault loop for RO pages") dropped the access permission test from rxe_check_pagefault() and left only HMM_PFN_VALID. A page faulted in read-only, for example a page-cache folio behind a PROT_READ file mapping, then satisfies the check and ODP write operations (RDMA WRITE, RDMA READ response, SEND payload, atomics) modify it through kmap without ever breaking CoW.
An unprivileged user can register an ODP MR over such a mapping and have incoming RDMA traffic overwrite the page cache of a file it only holds O_RDONLY, including /etc/passwd or setuid binaries. This is the same primitive class as Dirty COW and CVE-2022-2590.
mlx5 has the missing invariant: its ODP path sets the device write bit only for pfns that carry HMM_PFN_WRITE. Restore it in rxe by requiring HMM_PFN_WRITE in rxe_check_pagefault() for every operation except RXE_PAGEFAULT_RDONLY. A write to a non-writable VMA now fails the one fault attempt with -EPERM from hmm_vma_fault() instead of re-faulting forever. For a writable VMA the fault breaks CoW and the write lands in the private page.
Keep pmem flushes on the read-only check. arch_wb_cache_pmem() never modifies memory, and the FLUSH access bits do not make the umem writable, so classifying flushes as writes would make every flush against a flush-only MR fail.
--- drivers/infiniband/sw/rxe/rxe_odp.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/infiniband/sw/rxe/rxe_odp.c +11 -5
@@ -126,19 +126,23 @@ int rxe_odp_mr_init_user(struct rxe_dev *rxe, u64 start, u64 length, }static inline bool rxe_check_pagefault (struct ib_umem_odp *umem_odp,u64 iova, -int length) +int length,bool write) {bool need_fault = false; +u64 access =HMM_PFN_VALID ;u64 addr;int idx; +if (write) + access |=HMM_PFN_WRITE ; + addr = iova & (~(BIT (umem_odp->page_shift) -1 ));/* Skim through all pages that are to be accessed. */ while (addr < iova + length) { idx = (addr -ib_umem_start (umem_odp)) >> umem_odp->page_shift; -if (!(umem_odp->map.pfn_list[idx] &HMM_PFN_VALID )) { +if ((umem_odp->map.pfn_list[idx] & access) != access) { need_fault = true;break ; }
@@ -161,6 +165,7 @@ static unsigned long rxe_odp_iova_to_page_offset(struct ib_umem_odp *umem_odp, ustatic int rxe_odp_map_range_and_lock (struct rxe_mr *mr,u64 iova,int length,u32 flags) {struct ib_umem_odp *umem_odp =to_ib_umem_odp (mr->umem); +bool write = !(flags &RXE_PAGEFAULT_RDONLY );bool need_fault;int err;
@@ -169,7 +174,7 @@ static int rxe_odp_map_range_and_lock(struct rxe_mr *mr, u64 iova, int length, umutex_lock (&umem_odp->umem_mutex); - need_fault =rxe_check_pagefault (umem_odp, iova, length); + need_fault =rxe_check_pagefault (umem_odp, iova, length, write);if (need_fault) {mutex_unlock (&umem_odp->umem_mutex);
@@ -179,7 +184,7 @@ static int rxe_odp_map_range_and_lock(struct rxe_mr *mr, u64 iova, int length, uif (err <0 )return err; - need_fault =rxe_check_pagefault (umem_odp, iova, length); + need_fault =rxe_check_pagefault (umem_odp, iova, length, write);if (need_fault) {mutex_unlock (&umem_odp->umem_mutex);return -EFAULT ;
@@ -341,8 +346,9 @@ int rxe_odp_flush_pmem_iova(struct rxe_mr *mr, u64 iova,int err;u8 *va; +/* A flush never modifies memory; read-only access suffices. */ err =rxe_odp_map_range_and_lock (mr, iova, length, -RXE_PAGEFAULT_DEFAULT ); +RXE_PAGEFAULT_RDONLY );if (err)return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 30/398 RDMA/rxe: insert mcg into mcg_tree only after rxe_mcast_add() succeeds
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
[ Upstream commit 1caceeb2d74bbe88223aea55eb8626b4c5f076fd ]
rxe_get_mcg() publishes a newly allocated multicast group in rxe->mcg_tree before programming the backing Ethernet multicast address with rxe_mcast_add(), which runs outside mcg_lock. A local userspace RDMA client reaches this path with ATTACH_MCAST on a UD QP; if rxe_mcast_add() then returns an error (for example -ENODEV when the backing netdev has been removed, or a propagated dev_mc_add() error), the unwind frees the published group without removing it from the tree. A later lookup of the same MGID dereferences the freed struct rxe_mcg from __rxe_lookup_mcg().
Fix this by keeping the new mcg private until rxe_mcast_add() succeeds. Split the tree publication into __rxe_publish_mcg(), call rxe_mcast_add() before taking the tree reference, and free the still-private mcg on failure. Because the group is never visible in mcg_tree until the multicast address is programmed, no concurrent caller can look it up or attach a QP to a group that is about to be torn down, so the error path needs no conditional unwind. If another caller publishes the same MGID while the address is being programmed, the post-add re-check under mcg_lock finds the winner; this caller then drops its private object and balances its own rxe_mcast_add() with rxe_mcast_del() before returning the winner.
Reproduced by forcing the rxe_mcast_add() error return under KASAN:
without the change the next attach to the same MGID reports a slab-use-after-free in __rxe_lookup_mcg(); with it the forced failure returns cleanly. A no-injection attach/detach regression, including a two-QP shared join/leave and re-attach, stays KASAN- and leak-clean.
--- drivers/infiniband/sw/rxe/rxe_mcast.c | 50 +++++++++++++++++++-------- 1 file changed, 36 insertions(+), 14 deletions(-)
drivers/infiniband/sw/rxe/rxe_mcast.c +36 -14
@@ -175,7 +175,9 @@ struct rxe_mcg *rxe_lookup_mcg(struct rxe_dev *rxe, union ib_gid *mgid)* @mgid: multicast address as a gid * @mcg: new mcg object * -* Context: caller should hold rxe->mcg lock +* Initializes the mcg fields. The mcg is private and not yet visible in +* mcg_tree, so this may run without rxe->mcg_lock; __rxe_publish_mcg() +* makes it visible under the lock once it is ready. */ static void __rxe_init_mcg (struct rxe_dev *rxe,union ib_gid *mgid,struct rxe_mcg *mcg)
@@ -184,13 +186,22 @@ static void __rxe_init_mcg(struct rxe_dev *rxe, union ib_gid *mgid,memcpy (&mcg->mgid, mgid,sizeof (mcg->mgid));INIT_LIST_HEAD (&mcg->qp_list); mcg->rxe = rxe; +} -/* caller holds a ref on mcg but that will be -* dropped when mcg goes out of scope. We need to take a ref -* on the pointer that will be saved in the red-black tree -* by __rxe_insert_mcg and used to lookup mcg from mgid later. -* Inserting mcg makes it visible to outside so this should -* be done last after the object is ready. +/** +* __rxe_publish_mcg - make a fully initialized mcg visible in mcg_tree +* @mcg: the mcg object +* +* Context: caller must hold rxe->mcg_lock and a reference on mcg +*/ +static void __rxe_publish_mcg (struct rxe_mcg *mcg) +{ +/* caller holds a ref on mcg but that will be dropped when mcg goes +* out of scope. We need to take a ref on the pointer that will be +* saved in the red-black tree by __rxe_insert_mcg and used to lookup +* mcg from mgid later. Inserting mcg makes it visible to outside so +* this is done last after the object is ready and the multicast +* address has been programmed. */ kref_get (&mcg->ref_cnt);__rxe_insert_mcg (mcg);
@@ -228,26 +239,37 @@ static struct rxe_mcg *rxe_get_mcg(struct rxe_dev *rxe, union ib_gid *mgid) err = -ENOMEM ; goto err_dec; } +__rxe_init_mcg (rxe, mgid, mcg); + +/* program the multicast address while mcg is still private, before +* it is inserted into mcg_tree. dev_mc_add() may sleep so this must +* run outside mcg_lock. On failure mcg was never published, so a +* plain free is correct and the tree is untouched. +*/ + err =rxe_mcast_add (rxe, mgid); +if (err) { +kfree (mcg); + goto err_dec; + }spin_lock_bh (&rxe->mcg_lock); -/* re-check to see if someone else just added it */ +/* re-check to see if someone else just added it while we were adding +* the multicast address; if so use theirs and drop ours +*/ tmp =__rxe_lookup_mcg (rxe, mgid);if (tmp) {spin_unlock_bh (&rxe->mcg_lock); +rxe_mcast_del (rxe, mgid);atomic_dec (&rxe->mcg_num);kfree (mcg);return tmp; } -__rxe_init_mcg (rxe, mgid, mcg); +__rxe_publish_mcg (mcg);spin_unlock_bh (&rxe->mcg_lock); -/* add mcast address outside of lock */ - err =rxe_mcast_add (rxe, mgid); -if (!err) -return mcg; +return mcg; -kfree (mcg); err_dec:atomic_dec (&rxe->mcg_num);return ERR_PTR (err);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 31/398 RDMA/mlx5: Remove warn on missing representor in query_port_speed
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Or Har-Toov <[email protected]>
[ Upstream commit 2be77295316c2dff0a33c0dc3a65abdab4ccf796 ]
The representor ib_device's phys_port_cnt is set to the total vport count when the uplink vport rep loads. Individual port[i].rep entries are populated only as each VF/SF vport rep registers. A NULL .rep for a given port index is therefore expected while VF reps are still loading or haven't been enabled yet.
Tools like ibstat and ibv_devinfo iterate over all ports of all RDMA devices. Some ports may not have an eswitch representor, causing repeated dmesg warnings when these tools run without a device argument. This causes dmesg to be flooded with this message on every ibstat invocation.
Remove the warning and return -ENODEV when no representor exists for the queried port.
--- drivers/infiniband/hw/mlx5/main.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/infiniband/hw/mlx5/main.c +2 -5
@@ -1669,11 +1669,8 @@ static int mlx5_ib_query_port_speed_rep(struct mlx5_ib_dev *dev, u32 port_num,struct mlx5_core_dev *mdev;u16 op_mod; -if (!dev->port[port_num -1 ].rep) { -mlx5_ib_warn (dev,"Representor doesn't exist for port %u\n" , - port_num); -return -EINVAL ; - } +if (!dev->port[port_num -1 ].rep) +return -ENODEV ; rep = dev->port[port_num -1 ].rep; mdev =mlx5_eswitch_get_core_dev (rep->esw);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 32/398 RDMA/core: Reject unregistering netdevs in ib_get_eth_speed
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krystian Kaniewski <[email protected]>
[ Upstream commit ef9fbe1b93f3b617b96e86d5cd76b3fa44514cb5 ]
ib_device_get_netdev() intentionally returns a referenced net_device even when it is unregistering, so matching and cleanup callers can still find the association. The reference keeps struct net_device allocated, but does not guarantee that the device remains operational.
ib_get_eth_speed() uses the returned device operationally by invoking its ethtool callback. Although that call is made under RTNL, the function does not verify the registration state first. An asynchronous RDMA port query can therefore call into a netdev after NETDEV_UNREGISTER and ndo_uninit have completed.
Check for NETREG_REGISTERED while holding RTNL and return -ENODEV for a device which is being unregistered. Keeping RTNL across the check and the ethtool operation prevents unregister from starting between them.
Keep the speed fallback and warning under RTNL as well, so the warning can safely read netdev->name. Drop the netdev reference before releasing RTNL once all accesses to the device are complete.
--- drivers/infiniband/core/verbs.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/infiniband/core/verbs.c +8 -4
@@ -2051,11 +2051,13 @@ int ib_get_eth_speed(struct ib_device *dev, u32 port_num, u16 *speed, u8 *width)return -ENODEV ;rtnl_lock (); - rc =__ethtool_get_link_ksettings (netdev, &lksettings); -rtnl_unlock (); - -dev_put (netdev); +if (READ_ONCE (netdev->reg_state) !=NETREG_REGISTERED ) { +dev_put (netdev); +rtnl_unlock (); +return -ENODEV ; + } + rc =__ethtool_get_link_ksettings (netdev, &lksettings);if (!rc && lksettings.base.speed != (u32 )SPEED_UNKNOWN ) { netdev_speed = lksettings.base.speed; }else {
@@ -2064,6 +2066,8 @@ int ib_get_eth_speed(struct ib_device *dev, u32 port_num, u16 *speed, u8 *width)pr_warn ("%s speed is unknown, defaulting to %u\n" , netdev->name, netdev_speed); } +dev_put (netdev); +rtnl_unlock ();ib_get_width_and_speed (netdev_speed, lksettings.lanes, speed, width);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 15/398 ipv6: Select best matching nexthop object in fib6_table_lookup()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
[ Upstream commit 484bb9d164df397a53e0f533b262b27b1590efcb ]
Currently, when using multipath routes without nexthop objects, fib6_table_lookup() selects the nexthop with the highest score. This means that when both a source address and an oif are specified, the nexthop that is chosen is the one that matches in terms of oif:
# sysctl -wq net.ipv6.conf.all.forwarding=1 # ip address add 2001:db8:2::1/64 dev lo # ip route add 2001:db8:10::/64 nexthop via fe80::1 dev dummy1 nexthop via fe80::2 dev dummy2
# perf record -e fib6:fib6_table_lookup -- bash -c "for i in {1..100}; do ip route get 2001:db8:10::${i} from 2001:db8:2::1 oif dummy1; done > /dev/null"
# perf script | grep -o dummy[0-9] | sort | uniq -c
100 dummy1
# perf record -e fib6:fib6_table_lookup -- bash -c "for i in {1..100}; do ip route get 2001:db8:10::${i} from 2001:db8:2::1 oif dummy2; done > /dev/null"
# perf script | grep -o dummy[0-9] | sort | uniq -c
100 dummy2When using nexthop objects, fib6_table_lookup() selects the first matching nexthop and not necessarily the one with the highest score:
# ip nexthop add id 1 via fe80::1 dev dummy1 # ip nexthop add id 2 via fe80::2 dev dummy2 # ip nexthop add id 3 group 1/2 # ip route add 2001:db8:20::/64 nhid 3
# perf record -e fib6:fib6_table_lookup -- bash -c "for i in {1..100}; do ip route get 2001:db8:20::${i} from 2001:db8:2::1 oif dummy1; done > /dev/null"
# perf script | grep -o dummy[0-9] | sort | uniq -c
100 dummy1
# perf record -e fib6:fib6_table_lookup -- bash -c "for i in {1..100}; do ip route get 2001:db8:20::${i} from 2001:db8:2::1 oif dummy2; done > /dev/null"
# perf script | grep -o dummy[0-9] | sort | uniq -c
100 dummy1This is not very significant right now because the nexthop is later overwritten during path selection in fib6_select_path(). However, the next patch is going to skip path selection when we have an oif match during output route lookup.
As a preparation for this change, align the nexthop object behavior with the legacy one and make sure that fib6_table_lookup() always selects the best matching nexthop. Do that by always returning 0 from rt6_nh_find_match() in order not to terminate the loop in nexthop_for_each_fib6_nh() and storing in arg->nh the best matching nexthop so far.
Behavior after the change:
# perf record -e fib6:fib6_table_lookup -- bash -c "for i in {1..100}; do ip route get 2001:db8:20::${i} from 2001:db8:2::1 oif dummy1; done > /dev/null"
# perf script | grep -o dummy[0-9] | sort | uniq -c
100 dummy1
# perf record -e fib6:fib6_table_lookup -- bash -c "for i in {1..100}; do ip route get 2001:db8:20::${i} from 2001:db8:2::1 oif dummy2; done > /dev/null"
# perf script | grep -o dummy[0-9] | sort | uniq -c
100 dummy2--- net/ipv6/route.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
net/ipv6/route.c +9 -8
@@ -819,9 +819,11 @@ static int rt6_nh_find_match(struct fib6_nh *nh, void *_arg) {struct fib6_nh_frl_arg *arg = _arg; - arg->nh = nh; -return find_match (nh, arg->flags, arg->oif, arg->strict, - arg->mpri, arg->do_rr); +if (find_match (nh, arg->flags, arg->oif, arg->strict, arg->mpri, + arg->do_rr)) + arg->nh = nh; + +return 0 ; } static void __find_rr_leaf(struct fib6_info *f6i_start,
@@ -861,11 +863,10 @@ static void __find_rr_leaf(struct fib6_info *f6i_start, res->nh =nexthop_fib6_nh (f6i->nh);return ; } -if (nexthop_for_each_fib6_nh (f6i->nh, rt6_nh_find_match, - &arg)) { - matched = true; - nh = arg.nh; - } +nexthop_for_each_fib6_nh (f6i->nh, rt6_nh_find_match, + &arg); + matched = !!arg.nh; + nh = arg.nh; }else { nh = f6i->fib6_nh; if (find_match(nh, f6i->fib6_flags, oif, strict,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 33/398 power: sequencing: Fix build issue with COMPILE_TEST
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
[ Upstream commit 3b54dbd119805361695cb50ca6a875f4c7518b74 ]
The POWER_SEQUENCING_TH1520_GPU driver depends on (ARCH_THEAD && AUXILIARY_BUS) || COMPILE_TEST. This means when COMPILE_TEST=y and ARCH_THEAD is not set, the driver can still be built even though it requires AUXILIARY_BUS, which may not be selected in that configuration, leading to a build failure.
Fix this by dropping AUXILIARY_BUS from the dependency and instead selecting it directly, so the dependency is satisfied regardless of whether COMPILE_TEST or ARCH_THEAD is enabled.
--- drivers/power/sequencing/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/power/sequencing/Kconfig +2 -1
@@ -29,7 +29,8 @@ config POWER_SEQUENCING_QCOM_WCN config POWER_SEQUENCING_TH1520_GPU tristate "T-HEAD TH1520 GPU power sequencing driver" - depends on (ARCH_THEAD && AUXILIARY_BUS) || COMPILE_TEST + depends on ARCH_THEAD || COMPILE_TEST + select AUXILIARY_BUS help Say Y here to enable the power sequencing driver for the TH1520 SoC GPU. This driver handles the complex clock and reset sequence
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 16/398 ipv6: Honor oif when choosing nexthop for locally generated traffic
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
[ Upstream commit d25e7e9d8a6c1e2afb854613e417c6aa1a28ce6f ]
Commit 741a11d9e410 ("net: ipv6: Add RT6_LOOKUP_F_IFACE flag if oif is set") made the kernel honor the oif parameter when specified as part of output route lookup:
# ip route add 2001:db8:1::/64 dev dummy1 # ip route add ::/0 dev dummy2 # ip route get 2001:db8:1::1 oif dummy2 fibmatch default dev dummy2 metric 1024 pref medium
Due to regression reports, the behavior was partially reverted in commit d46a9d678e4c ("net: ipv6: Dont add RT6_LOOKUP_F_IFACE flag if saddr set") to only honor the oif if source address is not specified:
# ip route get 2001:db8:1::1 from 2001:db8:2::1 oif dummy2 fibmatch 2001:db8:1::/64 dev dummy1 metric 1024 pref medium
That is, when source address is specified, the kernel will choose the most specific route even if its nexthop device does not match the specified oif.
This creates a problem for multipath routes. After looking up a route, when source address is not specified, the kernel will choose a nexthop whose nexthop device matches the specified oif:
# sysctl -wq net.ipv6.conf.all.forwarding=1
# ip route add 2001:db8:10::/64 nexthop via fe80::1 dev dummy1 nexthop via fe80::2 dev dummy2
# for i in {1..100}; do ip route get 2001:db8:10::${i} oif dummy2; done | grep -o dummy[0-9] | sort | uniq -c
100 dummy2But will disregard the oif when source address is specified despite the fact that a matching nexthop exists:
# for i in {1..100}; do ip route get 2001:db8:10::${i} from 2001:db8:2::1 oif dummy2; done | grep -o dummy[0-9] | sort | uniq -c
53 dummy1
47 dummy2This behavior differs from IPv4:
# ip address add 192.0.2.1/32 dev lo
# ip route add 198.51.100.0/24 nexthop via inet6 fe80::1 dev dummy1 nexthop via inet6 fe80::2 dev dummy2
# for i in {1..100}; do ip route get 198.51.100.${i} from 192.0.2.1 oif dummy2; done | grep -o dummy[0-9] | sort | uniq -c
100 dummy2What happens is that fib6_table_lookup() returns a route with a matching nexthop device (assuming it exists):
# perf record -e fib6:fib6_table_lookup -- bash -c "for i in {1..100}; do ip route get 2001:db8:10::${i} from 2001:db8:2::1 oif dummy2; done > /dev/null"
# perf script | grep -o dummy[0-9] | sort | uniq -c
100 dummy2But it is later overwritten during path selection in fib6_select_path() which instead chooses a nexthop according to the calculated hash.
Solve this by telling fib6_select_path() to skip path selection if we have an oif match during output route lookup (iif being LOOPBACK_IFINDEX).
Behavior after the change:
# sysctl -wq net.ipv6.conf.all.forwarding=1
# ip route add 2001:db8:10::/64 nexthop via fe80::1 dev dummy1 nexthop via fe80::2 dev dummy2
# for i in {1..100}; do ip route get 2001:db8:10::${i} from 2001:db8:2::1 oif dummy2; done | grep -o dummy[0-9] | sort | uniq -c
100 dummy2Note that enabling forwarding is only needed because we did not add neighbor entries for the gateway addresses. When forwarding is disabled and CONFIG_IPV6_ROUTER_PREF is not enabled in kernel config, the kernel will treat non-existing neighbor entries as errors and perform round-robin between the nexthops:
# sysctl -wq net.ipv6.conf.all.forwarding=0
# for i in {1..100}; do ip route get 2001:db8:10::${i} from 2001:db8:2::1 oif dummy2; done | grep -o dummy[0-9] | sort | uniq -c
50 dummy1
50 dummy2--- net/ipv6/route.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/ipv6/route.c +4 -1
@@ -2272,6 +2272,7 @@ struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table, {struct fib6_result res = {};struct rt6_info *rt =NULL ; +bool have_oif_match;int strict =0 ; WARN_ON_ONCE((flags & RT6_LOOKUP_F_DST_NOREF) &&
@@ -2288,7 +2289,9 @@ struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table,if (res.f6i == net->ipv6.fib6_null_entry) goto out; -fib6_select_path (net, &res, fl6, oif, false, skb, strict); + have_oif_match = fl6->flowi6_iif ==LOOPBACK_IFINDEX && + oif == res.nh->fib_nh_dev->ifindex; +fib6_select_path (net, &res, fl6, oif, have_oif_match, skb, strict);/*Search through exception table */ rt =rt6_find_cached_rt (&res, &fl6->daddr, &fl6->saddr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 17/398 xfrm: iptfs: fix stack OOB read in iptfs_skb_reset_frag_walk()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roshan Kumar <[email protected]>
[ Upstream commit d042487dc118e494db2e2c1382310255c90ff544 ]
iptfs_skb_reset_frag_walk() advances to the fragment containing @offset with an unbounded loop:
while (offset >= walk->past + walk->frags[walk->fragi].len) walk->past += walk->frags[walk->fragi++].len;
walk->fragi is advanced and walk->frags[walk->fragi] is dereferenced without ever checking fragi against walk->nr_frags. When the requested offset is at or beyond the total length spanned by the walk's fragments, fragi runs past nr_frags and off the end of the fixed-size on-stack frags[MAX_SKB_FRAGS + 1] array, reading out-of-bounds stack memory.
The two callers behave differently: iptfs_skb_add_frags() already guards against this with
if (!walk->nr_frags || offset >= walk->total + walk->initial_offset) return len;
but iptfs_skb_can_add_frags() has no such guard and calls iptfs_skb_reset_frag_walk() unconditionally, so it performs the out-of-range walk. Its own "fragi < walk->nr_frags" bound check runs only afterwards, too late to prevent the read.
This is reachable from the receive path: a crafted IP-TFS (AGGFRAG) payload delivered to an IPTFS SA drives iptfs_reassem_cont() -> iptfs_skb_can_add_frags() with an offset past the fragment total, e.g.:
BUG: KASAN: stack-out-of-bounds in iptfs_skb_reset_frag_walk+0x235/0x250 Read of size 4 at addr ffff888008ad7210 by task repro/345 iptfs_skb_reset_frag_walk+0x235/0x250 net/xfrm/xfrm_iptfs.c:392 iptfs_skb_can_add_frags+0x155/0x310 net/xfrm/xfrm_iptfs.c:420 iptfs_reassem_cont+0xcf8/0x1140 net/xfrm/xfrm_iptfs.c:902 iptfs_input_ordered+0x552/0x670 net/xfrm/xfrm_iptfs.c:1280 iptfs_input+0x3d6/0xde0 net/xfrm/xfrm_iptfs.c:1741 xfrm_input+0x282f/0x6140 net/xfrm/xfrm_input.c:700 xfrm4_esp_rcv+0x93/0x120 net/ipv4/xfrm4_protocol.c:104 ip_rcv+0x278/0x2d0 net/ipv4/ip_input.c:612
Give iptfs_skb_can_add_frags() the same up-front guard that iptfs_skb_add_frags() already has, so the walk is never entered with an out-of-range offset. When it triggers, the caller falls back to the existing linearize-and-copy path, which is safe.
--- net/xfrm/xfrm_iptfs.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/xfrm/xfrm_iptfs.c +8 -0
@@ -416,6 +416,14 @@ static bool iptfs_skb_can_add_frags(const struct sk_buff *skb,if (skb_has_frag_list (skb) || skb->pp_recycle != walk->pp_recycle)return false; +/* Reject an @offset that is at or beyond the end of the walk's data +* before calling iptfs_skb_reset_frag_walk(), whose fragment-advance +* loop is otherwise unbounded and would index past walk->frags[]. +* This mirrors the guard already present in iptfs_skb_add_frags(). +*/ +if (!walk->nr_frags || offset >= walk->total + walk->initial_offset) +return false; +/* Make offset relative to current frag after setting that */ offset =iptfs_skb_reset_frag_walk (walk, offset);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 18/398 xfrm: iptfs: fix runt reassembly panic from short inner tot_len
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Martin <[email protected]>
[ Upstream commit dc33262be1fe43d0eb0b84fb58c6ed42e2f64a8c ]
When the start of an inner packet is split across two outer packets such that fewer than 4 bytes land at the end of the first one, __input_process_payload() saves those bytes as a runt and skips the iplen/iphlen validation performed for in-place packets. When the continuation packet arrives, iptfs_reassem_cont() only requires the declared inner length to be >= sizeof(ra_runt) (6) before allocating the reassembly skb with that attacker-controlled length.
However, __iptfs_iphlen() always returns the fixed minimum IP header size (20 for IPv4, 40 for IPv6), so for an inner IPv4 tot_len in [6, 19] the header-completion copy writes past the declared packet length, and the subsequent "ipremain -= copylen" underflows to ~4GB, leaving the payload copy length bounded only by blkoff (up to 64KB). At runtime the skb_put() tailroom check turns this into skb_over_panic(), i.e. an unprivileged kernel panic (DoS), reachable locally via userns+netns IPTFS SAs and remotely against IPTFS VPN gateways when the decrypted outer skb is linear (e.g. AF_PACKET taps, tun/tap delivery).
Align the runt path with the normal path by requiring the declared inner length to cover at least the IP header size. This also subsumes the previous >= sizeof(ra_runt) check, since the minimum IP header is always larger than the runt buffer.
This issue was found by the autokbug dynamic kernel fuzzer at Tencent Yunding Lab.
--- net/xfrm/xfrm_iptfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/xfrm/xfrm_iptfs.c +2 -2
@@ -828,8 +828,8 @@ static u32 iptfs_reassem_cont(struct xfrm_iptfs_data *xtfs, u64 seq,* allocate an in progress skb */ ipremain =__iptfs_iplen (xtfs->ra_runt); -if (ipremain <sizeof (xtfs->ra_runt)) { -/* length has to be at least runtsize large */ +if (ipremain <__iptfs_iphlen (xtfs->ra_runt)) { +/* length has to be at least the IP header size */ XFRM_INC_STATS (xs_net (xtfs->x),LINUX_MIB_XFRMINIPTFSERROR ); goto abandon;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 19/398 xfrm: avoid RCU warnings around the per-netns netlink socket
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
[ Upstream commit d87f8bc47fbf012a7f115e311d0603d97e47c34c ]
net->xfrm.nlsk is used in 2 types of contexts:
- fully under RCU, with rcu_read_lock + rcu_dereference and a NULL check
- in the netlink handlers, with requests coming from a userspace socket
In the 2nd case, net->xfrm.nlsk is guaranteed to stay non-NULL and the object is alive, since we can't enter the netns destruction path while the user socket holds a reference on the netns.
After adding the __rcu annotation to netns_xfrm.nlsk (which silences sparse warnings in the RCU users and __net_init code), we need to tell sparse that the 2nd case is safe. Add a helper for that.
Stable-dep-of: d1ebd9081879 ("xfrm: fix compat ALLOCSPI request use-after-free")
--- include/net/netns/xfrm.h | 2 +- net/xfrm/xfrm_user.c | 25 +++++++++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-)
include/net/netns/xfrm.h +1 -1
@@ -59,7 +59,7 @@ struct netns_xfrm {struct list_head inexact_bins; -struct sock *nlsk; +struct sock __rcu *nlsk;struct sock *nlsk_stash;u32 sysctl_aevent_etime;
net/xfrm/xfrm_user.c +17 -8
@@ -35,6 +35,15 @@#endif #include <linux/unaligned.h> +static struct sock *xfrm_net_nlsk (const struct net *net,const struct sk_buff *skb) +{ +/* get the source of this request, see netlink_unicast_kernel */ +const struct sock *sk =NETLINK_CB (skb).sk; + +/* sk is refcounted, the netns stays alive and nlsk with it */ +return rcu_dereference_protected (net->xfrm.nlsk, sk->sk_net_refcnt); +} +static int verify_one_alg (struct nlattr **attrs,enum xfrm_attr_type_t type,struct netlink_ext_ack *extack) {
@@ -1727,7 +1736,7 @@ static int xfrm_get_spdinfo(struct sk_buff *skb, struct nlmsghdr *nlh, err =build_spdinfo (r_skb, net, sportid, seq, *flags);BUG_ON (err <0 ); -return nlmsg_unicast (net->xfrm.nlsk, r_skb, sportid); +return nlmsg_unicast (xfrm_net_nlsk (net, skb), r_skb, sportid); }static inline unsigned int xfrm_sadinfo_msgsize (void )
@@ -1787,7 +1796,7 @@ static int xfrm_get_sadinfo(struct sk_buff *skb, struct nlmsghdr *nlh, err =build_sadinfo (r_skb, net, sportid, seq, *flags);BUG_ON (err <0 ); -return nlmsg_unicast (net->xfrm.nlsk, r_skb, sportid); +return nlmsg_unicast (xfrm_net_nlsk (net, skb), r_skb, sportid); } static int xfrm_get_sa(struct sk_buff *skb, struct nlmsghdr *nlh,
@@ -1807,7 +1816,7 @@ static int xfrm_get_sa(struct sk_buff *skb, struct nlmsghdr *nlh,if (IS_ERR (resp_skb)) { err =PTR_ERR (resp_skb); }else { - err =nlmsg_unicast (net->xfrm.nlsk, resp_skb,NETLINK_CB (skb).portid); + err =nlmsg_unicast (xfrm_net_nlsk (net, skb), resp_skb,NETLINK_CB (skb).portid); }xfrm_state_put (x); out_noput:
@@ -1898,7 +1907,7 @@ static int xfrm_alloc_userspi(struct sk_buff *skb, struct nlmsghdr *nlh, } } - err =nlmsg_unicast (net->xfrm.nlsk, resp_skb,NETLINK_CB (skb).portid); + err =nlmsg_unicast (xfrm_net_nlsk (net, skb), resp_skb,NETLINK_CB (skb).portid); out:xfrm_state_put (x);
@@ -2542,7 +2551,7 @@ static int xfrm_get_default(struct sk_buff *skb, struct nlmsghdr *nlh, r_up->out =READ_ONCE (net->xfrm.policy_default[XFRM_POLICY_OUT ]);nlmsg_end (r_skb, r_nlh); -return nlmsg_unicast (net->xfrm.nlsk, r_skb, portid); +return nlmsg_unicast (xfrm_net_nlsk (net, skb), r_skb, portid); } static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh,
@@ -2608,7 +2617,7 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh,if (IS_ERR (resp_skb)) { err =PTR_ERR (resp_skb); }else { - err =nlmsg_unicast (net->xfrm.nlsk, resp_skb, + err =nlmsg_unicast (xfrm_net_nlsk (net, skb), resp_skb,NETLINK_CB (skb).portid); } }else {
@@ -2787,7 +2796,7 @@ static int xfrm_get_ae(struct sk_buff *skb, struct nlmsghdr *nlh,return err; } - err =nlmsg_unicast (net->xfrm.nlsk, r_skb,NETLINK_CB (skb).portid); + err =nlmsg_unicast (xfrm_net_nlsk (net, skb), r_skb,NETLINK_CB (skb).portid);spin_unlock_bh (&x->lock);xfrm_state_put (x);return err;
@@ -3491,7 +3500,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, goto err; } - err =netlink_dump_start (net->xfrm.nlsk, skb, nlh, &c); + err =netlink_dump_start (xfrm_net_nlsk (net, skb), skb, nlh, &c); goto err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 20/398 xfrm: fix compat ALLOCSPI request use-after-free
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
[ Upstream commit d1ebd9081879fd9ae9c8fb7e8928f19cc88ae320 ]
xfrm_state_netlink() builds the ALLOCSPI response with dump_one_state(), which already calls alloc_compat() with the response skb and header.
xfrm_alloc_userspi() then calls alloc_compat() again, but passes the original request skb and its header. For a compat request, the translator therefore interprets the 228-byte compat xfrm_userspi_info as the 232-byte native layout and reads four bytes past the declared payload. It also publishes the translated child through the request's frag_list.
A multicast clone of the request shares skb_shared_info and can observe that child. xfrm_user_rcv_msg() frees it after the request handler returns, racing a compat receiver which may still be copying from it and resulting in a use-after-free.
Remove the redundant conversion. The response keeps its correct compat translation from dump_one_state(), and no child is attached to the inbound request.
--- net/xfrm/xfrm_user.c | 12 ------------ 1 file changed, 12 deletions(-)
net/xfrm/xfrm_user.c +0 -12
@@ -1830,7 +1830,6 @@ static int xfrm_alloc_userspi(struct sk_buff *skb, struct nlmsghdr *nlh,struct net *net =sock_net (skb->sk);struct xfrm_state *x;struct xfrm_userspi_info *p; -struct xfrm_translator *xtr;struct sk_buff *resp_skb;xfrm_address_t *daddr;int family;
@@ -1896,17 +1895,6 @@ static int xfrm_alloc_userspi(struct sk_buff *skb, struct nlmsghdr *nlh, goto out; } - xtr =xfrm_get_translator (); -if (xtr) { - err = xtr->alloc_compat (skb,nlmsg_hdr (skb)); - -xfrm_put_translator (xtr); -if (err) { -kfree_skb (resp_skb); - goto out; - } - } - err =nlmsg_unicast (xfrm_net_nlsk (net, skb), resp_skb,NETLINK_CB (skb).portid); out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 21/398 xfrm: add missing rcu_read_lock(), skb_dst_force() and dev_hold() for xfrm_trans_reinject()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit d2f5082f9e84653fa1a9e8aebaaff23e688f5e19 ]
syzbot reported a suspicious RCU usage warning in ip6_pkt_drop():
WARNING: suspicious RCU usage in ip6_pkt_drop include/net/addrconf.h:389 suspicious rcu_dereference_check() usage!
Call Trace: __in6_dev_get_safely include/net/addrconf.h:389 [inline] ip6_pkt_drop+0x596/0x610 net/ipv6/route.c:4620 ip6_pkt_discard+0x1c/0x30 net/ipv6/route.c:4651 xfrm_trans_reinject+0x324/0x630 net/xfrm/xfrm_input.c:806 process_one_work kernel/workqueue.c:3322 [inline] process_scheduled_works+0xa8e/0x14e0 kernel/workqueue.c:3405 worker_thread+0xa47/0xfb0 kernel/workqueue.c:3486
When commit 4f4920669d21 ("xfrm: Reinject transport-mode packets through workqueue") converted xfrm_trans_reinject from a tasklet to a workqueue, the reinjection loop ceased running in softirq context. Workqueue workers run in process context where local_bh_disable() does not enter an RCU read-side critical section under CONFIG_PREEMPT_RCU.
Because finish callbacks (such as ip6_rcv_finish) expect to run under an RCU read lock (performing route lookups, l3mdev lookups, and accessing RCU-protected data structures), invoking them in workqueue context without rcu_read_lock() triggers RCU lockdep warnings.
Furthermore, packets queued to the workqueue via xfrm_trans_queue_net() may carry non-refcounted (noref) dst entries (e.g. from ip_route_input_noref). Additionally, on netdevice unregistration, dst_dev_put() replaces dst->dev with blackhole_netdev, so dst entries do not keep skb->dev alive while queued in the workqueue.
Fix these issues by:
1. Calling skb_dst_force(skb) in xfrm_trans_queue_net() while still in the caller's RCU section to ensure dst is reference-counted before queuing.
2. Holding a reference on skb->dev via dev_hold()/dev_put() across workqueue deferral so skb->dev remains valid during finish() callback processing.
3. Acquiring rcu_read_lock() around the finish callback invocation loop in xfrm_trans_reinject().
--- net/xfrm/xfrm_input.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
net/xfrm/xfrm_input.c +11 -0
@@ -794,12 +794,17 @@ static void xfrm_trans_reinject(struct work_struct *work)spin_unlock_bh (&trans->queue_lock);local_bh_disable (); +rcu_read_lock ();while ((skb =__skb_dequeue (&queue))) {struct net *net =XFRM_TRANS_SKB_CB (skb)->net; +struct net_device *dev = skb->dev;XFRM_TRANS_SKB_CB (skb)->finish (net,NULL , skb); +if (dev) +dev_put (dev);put_net (net); } +rcu_read_unlock ();local_bh_enable (); }
@@ -815,12 +820,18 @@ int xfrm_trans_queue_net(struct net *net, struct sk_buff *skb,if (skb_queue_len (&trans->queue) >=READ_ONCE (net_hotdata.max_backlog))return -ENOBUFS ; +if (skb_dst (skb) && !skb_dst_force (skb)) +return -EHOSTUNREACH ; +BUILD_BUG_ON (sizeof (struct xfrm_trans_cb ) >sizeof (skb->cb)); hold_net =maybe_get_net (net);if (!hold_net)return -ENODEV ; +if (skb->dev) +dev_hold (skb->dev); +XFRM_TRANS_SKB_CB (skb)->finish = finish;XFRM_TRANS_SKB_CB (skb)->net = hold_net;spin_lock_bh (&trans->queue_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 22/398 esp: downgrade zerocopy managed frags before mutating skb frags
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maher Azzouzi <[email protected]>
[ Upstream commit f89416eb3db151170a6f3c6dfc5239d26cdce4d2 ]
On the out-of-place output path (esp->inplace == false) ESP rewrites the skb frag array: esp_output_head() appends a trailer frag and esp_output_tail() replaces the frags with a destination page, both referenced with get_page().
When the skb carries zerocopy managed frags (SKBFL_MANAGED_FRAG_REFS) the payload frags are owned by the ubuf and must not be referenced or unreferenced individually, but ESP mutates the frag array without ever downgrading the skb. This breaks the managed-frag invariant two ways:
- esp_ssg_unref() walks the source scatterlist and drops a page reference for every frag, including the ubuf-owned payload frags, pushing their refcount below the GUP pin bias while the pages are still pinned, i.e. a use-after-free of the zerocopy pages;
- esp_output_tail() installs its destination page as frag 0 with get_page() but leaves SKBFL_MANAGED_FRAG_REFS set, so skb_release_data() takes the skip_unref branch and never drops that reference, leaking the x->xfrag page at packet rate.
Fix this the way every other frag-mutating site does (__ip_append_data(), __ip6_append_data(), tcp_sendmsg_locked()) and call skb_zcopy_downgrade_managed() before ESP touches the frag array: it takes a real reference on each existing frag and clears SKBFL_MANAGED_FRAG_REFS, so the per-frag unref in esp_ssg_unref() and the frag release in skb_release_data() are both balanced and no mixed-ownership frag array is left behind.
--- net/ipv4/esp4.c | 6 ++++++ net/ipv6/esp6.c | 6 ++++++ 2 files changed, 12 insertions(+)
net/ipv4/esp4.c +6 -0
@@ -438,6 +438,12 @@ int esp_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info * esp->inplace = false; +/* Take real page refs and clear SKBFL_MANAGED_FRAG_REFS before +* we mutate the frag array, so the per-frag unref stays balanced +* for zerocopy managed frags (see __ip_append_data()). +*/ +skb_zcopy_downgrade_managed (skb); + allocsize =ALIGN (tailen,L1_CACHE_BYTES );spin_lock_bh (&x->lock);
net/ipv6/esp6.c +6 -0
@@ -467,6 +467,12 @@ int esp6_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info esp->inplace = false; +/* Take real page refs and clear SKBFL_MANAGED_FRAG_REFS before +* we mutate the frag array, so the per-frag unref stays balanced +* for zerocopy managed frags (see __ip_append_data()). +*/ +skb_zcopy_downgrade_managed (skb); + allocsize =ALIGN (tailen,L1_CACHE_BYTES );spin_lock_bh (&x->lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 13/398 sunvdc: fix -EIO issue due to lack of retries
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
[ Upstream commit 5067d4ba713961d8ccea1e06cd4c453793f3121e ]
John reports that since commit:
a11f6ca9aef9 ("sunvdc: Do not spin in an infinite loop when vio_ldc_send() returns EAGAIN")
users of Linux inside Solaris ldom see occasional -EIO errors because the request send loop now times out. The current loop does 10 retries, and inside vio_ldc_send() a further 1000 1usec retries are done as well. Even with 10.5 msec of busy loop retries that's apparently not enough to always succeed.
Rather than introduce continued busy looping, requeue the request and have the delayed queue kicking retry the request after another 10ms. This obviously isn't ideal, but there's seemingly no way to wait for this type of event. And if 10ms of busy looping was not enough to make progress, then presumably this is an edge condition and we just need to guarantee to make forward progress at some later point in time. That's more suitably done through letting the CPU tend to other work, rather than sitting in a tight loop retrying.
[stian: rebased on top of the cookie-unmap fix, without which every
requeued attempt leaks LDC map table entries; tested on an UltraSPARC T4 LDOM where the vdc_tx_trigger failure condition was reproduced and absorbed by the requeue with no I/O error]
--- drivers/block/sunvdc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/block/sunvdc.c +8 -1
@@ -556,6 +556,7 @@ static blk_status_t vdc_queue_rq(struct blk_mq_hw_ctx *hctx,struct vdc_port *port = hctx->queue->queuedata;struct vio_dring_state *dr;unsigned long flags; +int ret; dr = &port->vio.drings[VIO_DRIVER_TX_RING ];
@@ -577,7 +578,13 @@ static blk_status_t vdc_queue_rq(struct blk_mq_hw_ctx *hctx,return BLK_STS_DEV_RESOURCE ; } -if (__send_request (bd->rq) <0 ) { + ret =__send_request (bd->rq); +if (ret == -EAGAIN ) { +spin_unlock_irqrestore (&port->vio.lock, flags); +/* already spun for 10msec, defer 10msec and retry */ +blk_mq_delay_kick_requeue_list (hctx->queue,10 ); +return BLK_STS_DEV_RESOURCE ; + }else if (ret <0 ) {spin_unlock_irqrestore (&port->vio.lock, flags);return BLK_STS_IOERR ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 35/398 arm64: dts: renesas: r9a09g056: Switch GBETH TX queue scheduling to WRR
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ovidiu Panait <[email protected]>
[ Upstream commit 66fcbdbeca0118b8aeac218b33fa18c394513543 ]
The GBETH ethernet nodes don't specify a TX scheduling policy, so stmmac falls back to Strict Priority. In this configuration the queue with the highest priority gets all the traffic, starving the others under load.
Under sustained UDP TX load with multiple data streams, this starvation triggers spurious adapter resets due to TX queue timeouts:
iperf3 -c <ip> -i0 -t60 --bind-dev end0 -u -b0 -P4
end0: NETDEV WATCHDOG: CPU: 1: transmit queue 1 timed out 5228 ms
end0: Reset adapter.
Investigation shows that only the highest priority queue is advancing while the others stall for more than 5 seconds, causing a netdev watchdog reset.
Switch the TX scheduling policy to Weighted-Round-Robin (WRR) so that traffic is processed across all queues, eliminating the stalls.
--- arch/arm64/boot/dts/renesas/r9a09g056.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/arm64/boot/dts/renesas/r9a09g056.dtsi +10 -0
@@ -827,23 +827,28 @@ queue3 { mtl_tx_setup0: tx-queues-config { snps,tx-queues-to-use = <4>; + snps,tx-sched-wrr; queue0 { + snps,weight = <0x10>; snps,dcb-algorithm; snps,priority = <0x1>; }; queue1 { + snps,weight = <0x12>; snps,dcb-algorithm; snps,priority = <0x2>; }; queue2 { + snps,weight = <0x14>; snps,dcb-algorithm; snps,priority = <0x4>; }; queue3 { + snps,weight = <0x18>; snps,dcb-algorithm; snps,priority = <0x8>; };
@@ -928,23 +933,28 @@ queue3 { mtl_tx_setup1: tx-queues-config { snps,tx-queues-to-use = <4>; + snps,tx-sched-wrr; queue0 { + snps,weight = <0x10>; snps,dcb-algorithm; snps,priority = <0x1>; }; queue1 { + snps,weight = <0x12>; snps,dcb-algorithm; snps,priority = <0x2>; }; queue2 { + snps,weight = <0x14>; snps,dcb-algorithm; snps,priority = <0x4>; }; queue3 { + snps,weight = <0x18>; snps,dcb-algorithm; snps,priority = <0x8>; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 44/398 wifi: mac80211: include TIM bitmap control for buffered S1G mcast traffic
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lachlan Hodges <[email protected]>
[ Upstream commit af72b5946d493cecced27d0951ea37c1d178601e ]
Currently when building the S1G TIM element, we only build the bitmap control if we have buffered unicast traffic. Since AID 0 sits within the bitmap control if we have buffered multicast traffic with no buffered unicast traffic the bitmap control won't be emitted and dozing stations will be unaware of buffered multicast.
To fix, only exclude the bitmap control byte when we don't have both buffered unicast and multicast traffic.
--- net/mac80211/tx.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-)
net/mac80211/tx.c +22 -19
@@ -4954,10 +4954,18 @@ static void ieee80211_beacon_add_tim_pvb(struct ps_data *ps,*/ static void ieee80211_s1g_beacon_add_tim_pvb (struct ps_data *ps,struct sk_buff *skb, -bool mcast_traffic) +bool mcast_traffic, +bool ucast_traffic) {int blk; +/* +* if no unicast and multicast traffic don't emit a bitmap control +* or pvb +*/ +if (!mcast_traffic && !ucast_traffic) +return ; +/* * Emit a bitmap control block with a page slice number of 31 and a * page index of 0 which indicates as per IEEE80211-2024 9.4.2.5.1
@@ -4966,6 +4974,10 @@ static void ieee80211_s1g_beacon_add_tim_pvb(struct ps_data *ps,*/ skb_put_u8 (skb, mcast_traffic | (31 <<1 )); +/* If there's no unicast traffic we don't need to include a PVB. */ +if (!ucast_traffic) +return ; +/* Emit an encoded block for each non-zero sub-block */ for (blk =0 ; blk <IEEE80211_MAX_SUPPORTED_S1G_TIM_BLOCKS ; blk++) {u8 blk_bmap =0 ;
@@ -5047,25 +5059,16 @@ static void __ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata, ps->dtim_bc_mc = mcast_traffic; -if (have_bits) { -if (s1g) -ieee80211_s1g_beacon_add_tim_pvb (ps, skb, - mcast_traffic); -else -ieee80211_beacon_add_tim_pvb (ps, skb, mcast_traffic); +if (s1g) { +ieee80211_s1g_beacon_add_tim_pvb (ps, skb, mcast_traffic, + have_bits); + }else if (have_bits) { +ieee80211_beacon_add_tim_pvb (ps, skb, mcast_traffic); }else { -/* -* If there is no buffered unicast traffic for an S1G -* interface, we can exclude the bitmap control. This is in -* contrast to other phy types as they do include the bitmap -* control and pvb even when there is no buffered traffic. -*/ -if (!s1g) { -/* Bitmap control */ -skb_put_u8 (skb, mcast_traffic); -/* Part Virt Bitmap */ -skb_put_u8 (skb,0 ); - } +/* Bitmap control */ +skb_put_u8 (skb, mcast_traffic); +/* Part Virt Bitmap */ +skb_put_u8 (skb,0 ); } tim->datalen =skb_tail_pointer (skb) - tim->data;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 45/398 wifi: virt_wifi: free skb when disconnected
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mariano Baragiola <[email protected]>
[ Upstream commit f9edf7cf63b96d2b776fca8d258d3c5256e40c8e ]
When the simulated link is disconnected, virt_wifi_start_xmit() returns NET_XMIT_DROP without freeing the skb. dev_hard_start_xmit() treats this return value as consumed, so every packet sent while disconnected leaks its skb.
Free the skb before returning the drop status.
--- drivers/net/wireless/virtual/virt_wifi.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/virtual/virt_wifi.c +1 -0
@@ -432,6 +432,7 @@ static netdev_tx_t virt_wifi_start_xmit(struct sk_buff *skb, priv->tx_packets++;if (!priv->is_connected) { priv->tx_failed++; +dev_kfree_skb_any (skb);return NET_XMIT_DROP ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 46/398 wifi: mwifiex: fix IRQ leak using wrong index in MSI-X error path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peng Hao <[email protected]>
[ Upstream commit a3d722190cdef18da4878b5efc27c3c386dda248 ]
mwifiex_pcie_request_irq() registers each MSI-X vector with a per-index dev_id (&card->msix_ctx[i]). On a request_irq() failure the cleanup loop "for (j = 0; j < i; j++)" frees msix_entries[j].vector but passes the failed index's &card->msix_ctx[i] as the dev_id. free_irq() matches on (irq, dev_id), so it fails to find the action registered with &card->msix_ctx[j]: the already-requested IRQ j is not freed (leaked) and free_irq() warns about freeing a non-existent IRQ. Use &card->msix_ctx[j].
--- drivers/net/wireless/marvell/mwifiex/pcie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/marvell/mwifiex/pcie.c +1 -1
@@ -3068,7 +3068,7 @@ static int mwifiex_pcie_request_irq(struct mwifiex_adapter *adapter) ret);for (j =0 ; j < i; j++)free_irq (card->msix_entries[j].vector, - &card->msix_ctx[i]); + &card->msix_ctx[j]);pci_disable_msix (pdev); }else {mwifiex_dbg (adapter,MSG ,"MSIx enabled!" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 47/398 wifi: brcmfmac: cyw: pass PMKID to firmware if present
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bogdan Nicolae <[email protected]>
[ Upstream commit e2de8d5eb2984416affdd9559e55f37c7f1bbf47 ]
Zero out auth_status on initialization. Otherwise, garbage will leak from the stack to the firmware (when ssid is less than 32 bytes and/or when params->pmkid is set). Then, pass the params->pmkid to the firmware (without it, the firmware caches a garbage PMKID on successful authentication and denies a subsequent association request that includes the PMKID).
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/core.c +4 -1
@@ -201,7 +201,7 @@ brcmf_cyw_external_auth(struct wiphy *wiphy, struct net_device *dev, {struct brcmf_if *ifp;struct brcmf_pub *drvr; -struct brcmf_auth_req_status_le auth_status; +struct brcmf_auth_req_status_le auth_status = {};int ret =0 ;brcmf_dbg (TRACE ,"Enter\n" );
@@ -209,6 +209,9 @@ brcmf_cyw_external_auth(struct wiphy *wiphy, struct net_device *dev, ifp =netdev_priv (dev); drvr = ifp->drvr;if (params->status ==WLAN_STATUS_SUCCESS ) { +if (params->pmkid) +memcpy (auth_status.pmkid, params->pmkid, +WLAN_PMKID_LEN ); auth_status.flags =cpu_to_le16 (BRCMF_EXTAUTH_SUCCESS ); }else { bphy_err(drvr, "External authentication failed: status=%d\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 48/398 wifi: libipw: reject too-short beacon and probe responses
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shmulik Cohen <[email protected]>
[ Upstream commit 5ce5721e8cbe3e80db8f43851cc2a2a92485ef4b ]
libipw_process_probe_response() and the libipw_network_init() call it makes assume the frame contains the full 36-byte beacon and probe response prefix, but the ipw2100 and ipw2200 receive paths only establish that a management frame carries the generic 24-byte three-address header.
libipw_network_init() then computes the information element length as
stats->len - sizeof(*beacon)
stats->len is a u16 and sizeof() has type size_t, so the subtraction is evaluated as size_t and wraps instead of going negative. Truncating that to the u16 length parameter of libipw_parse_info_param() yields 65524 for a 24-byte beacon, and the parser then walks the receive buffer as if it held almost 64 KiB of information elements, reading past the allocation.
Reject the frame before any fixed field is touched.
Found by an AI-assisted review of length arithmetic in management frame parsers. Verified with a KUnit case under Generic KASAN on arm64 under QEMU; I do not have the hardware, so it is not tested on a real device.
--- drivers/net/wireless/intel/ipw2x00/libipw_rx.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/intel/ipw2x00/libipw_rx.c +3 -0
@@ -1421,6 +1421,9 @@ static void libipw_process_probe_response(struct libipw_device#endif unsigned long flags; +if (stats->len <sizeof (*beacon)) +return ; + LIBIPW_DEBUG_SCAN("'%*pE' (%pM): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n", info_element->len, info_element->data, beacon->header.addr3,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 49/398 wifi: libipw: reject too-short association responses
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shmulik Cohen <[email protected]>
[ Upstream commit adb7118b7d2cfd7e8213c17d7d2829f353017754 ]
libipw_handle_assoc_resp() reads the capability, status and aid fields of the 30-byte association response prefix and then computes the information element length as
stats->len - sizeof(*frame)
stats->len is a u16 and sizeof() has type size_t, so the subtraction is evaluated as size_t and wraps instead of going negative. Truncating that to the u16 length parameter of libipw_parse_info_param() turns a frame shorter than the fixed fields into a length near 64 KiB, and the parser then reads past the receive buffer.
Both the ipw2100 and ipw2200 management receive paths reach this function having established only that the frame carries the generic 24-byte three-address header.
Reject the frame before any fixed field is touched.
Found by an AI-assisted review of length arithmetic in management frame parsers. Verified with a KUnit case under Generic KASAN on arm64 under QEMU; I do not have the hardware, so it is not tested on a real device.
--- drivers/net/wireless/intel/ipw2x00/libipw_rx.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/intel/ipw2x00/libipw_rx.c +3 -0
@@ -1209,6 +1209,9 @@ static int libipw_handle_assoc_resp(struct libipw_device *ieee, struct libipw_asstruct libipw_network *network = &network_resp;struct net_device *dev = ieee->dev; +if (stats->len <sizeof (*frame)) +return 1 ; + network->flags =0 ; network->qos_data.active =0 ; network->qos_data.supported =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 50/398 IB/IPoIB: Avoid restoring OPER_UP after multicast flush
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carolina Jubran <[email protected]>
[ Upstream commit 9a141d3dc869d18b2eab35e999f4790a9b84e40f ]
ipoib_ib_dev_flush_light() temporarily clears IPOIB_FLAG_OPER_UP to prevent multicast joins while ipoib_mcast_dev_flush() is running, and restores the flag afterwards if it was previously set.
This restore races with ipoib_ib_dev_down(). If the interface is brought down while the flush is in progress, ipoib_ib_dev_down() clears IPOIB_FLAG_OPER_UP, but the flush path may set it again after the device has already gone down.
Since commit 894021a75291 ("IB/ipoib: Make the carrier_on_task race aware"), ipoib_mcast_carrier_on_task() relies on IPOIB_FLAG_OPER_UP being cleared to terminate its rtnl_trylock() retry loop. If the flag is left set after shutdown, the workqueue retries forever, causing teardown to deadlock when ipoib_ndo_uninit() waits in destroy_workqueue() while holding RTNL.
Instead of overloading IPOIB_FLAG_OPER_UP to block multicast joins during a light flush, introduce a dedicated IPOIB_FLAG_MCAST_FLUSH flag. Use it together with IPOIB_FLAG_OPER_UP to determine whether multicast joins are allowed, avoiding the race with device shutdown.
--- drivers/infiniband/ulp/ipoib/ipoib.h | 7 +++++++ drivers/infiniband/ulp/ipoib/ipoib_ib.c | 12 +++++++----- drivers/infiniband/ulp/ipoib/ipoib_multicast.c | 16 ++++++++-------- 3 files changed, 22 insertions(+), 13 deletions(-)
drivers/infiniband/ulp/ipoib/ipoib.h +7 -0
@@ -87,6 +87,7 @@ enum {IPOIB_FLAG_INITIALIZED =1 ,IPOIB_FLAG_ADMIN_UP =2 ,IPOIB_PKEY_ASSIGNED =3 , +IPOIB_FLAG_MCAST_FLUSH =4 ,IPOIB_FLAG_SUBINTERFACE =5 ,IPOIB_STOP_REAPER =7 , IPOIB_FLAG_ADMIN_CM = 9,
@@ -414,6 +415,12 @@ struct ipoib_dev_priv {const struct net_device_ops *rn_ops; }; +static inline bool ipoib_mcast_allowed (struct ipoib_dev_priv *priv) +{ +return test_bit (IPOIB_FLAG_OPER_UP , &priv->flags) && + !test_bit (IPOIB_FLAG_MCAST_FLUSH , &priv->flags); +} +struct ipoib_ah {struct net_device *dev;struct ib_ah *ah;
drivers/infiniband/ulp/ipoib/ipoib_ib.c +7 -5
@@ -1227,17 +1227,19 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, }if (level ==IPOIB_FLUSH_LIGHT ) { -int oper_up;ipoib_mark_paths_invalid (dev); -/* Set IPoIB operation as down to prevent races between: +/* Set MCAST_FLUSH to prevent races between: * the flush flow which leaves MCG and on the fly joins * which can happen during that time. mcast restart task * should deal with join requests we missed. +* +* Do not clear OPER_UP for this; restoring it races with +* ipoib_ib_dev_down() and can leave OPER_UP set after the +* device is down. */ - oper_up =test_and_clear_bit (IPOIB_FLAG_OPER_UP , &priv->flags); +set_bit (IPOIB_FLAG_MCAST_FLUSH , &priv->flags);ipoib_mcast_dev_flush (dev); -if (oper_up) -set_bit (IPOIB_FLAG_OPER_UP , &priv->flags); +clear_bit (IPOIB_FLAG_MCAST_FLUSH , &priv->flags);ipoib_reap_dead_ahs (priv); }
drivers/infiniband/ulp/ipoib/ipoib_multicast.c +8 -8
@@ -74,7 +74,7 @@ static void __ipoib_mcast_schedule_join_thread(struct ipoib_dev_priv *priv, struct ipoib_mcast *mcast, bool delay) { -if (!test_bit (IPOIB_FLAG_OPER_UP , &priv->flags)) +if (!ipoib_mcast_allowed (priv))return ;/*
@@ -469,7 +469,7 @@ static int ipoib_mcast_join(struct net_device *dev, struct ipoib_mcast *mcast)int ret =0 ;if (!priv->broadcast || - !test_bit (IPOIB_FLAG_OPER_UP , &priv->flags)) + !ipoib_mcast_allowed (priv))return -EINVAL ;init_completion (&mcast->done);
@@ -555,7 +555,7 @@ void ipoib_mcast_join_task(struct work_struct *work)unsigned long delay_until =0 ;struct ipoib_mcast *mcast =NULL ; -if (!test_bit (IPOIB_FLAG_OPER_UP , &priv->flags)) +if (!ipoib_mcast_allowed (priv))return ;if (ib_query_port (priv->ca, priv->port, &port_attr)) {
@@ -577,7 +577,7 @@ void ipoib_mcast_join_task(struct work_struct *work)netif_addr_unlock_bh (dev);spin_lock_irq (&priv->lock); -if (!test_bit (IPOIB_FLAG_OPER_UP , &priv->flags)) +if (!ipoib_mcast_allowed (priv)) goto out;if (!priv->broadcast) {
@@ -749,7 +749,7 @@ void ipoib_mcast_send(struct net_device *dev, u8 *daddr, struct sk_buff *skb)spin_lock_irqsave (&priv->lock, flags); -if (!test_bit (IPOIB_FLAG_OPER_UP , &priv->flags) || +if (!ipoib_mcast_allowed (priv) || !priv->broadcast || !test_bit (IPOIB_MCAST_FLAG_ATTACHED , &priv->broadcast->flags)) { ++dev->stats.tx_dropped;
@@ -871,7 +871,7 @@ void ipoib_mcast_restart_task(struct work_struct *work)LIST_HEAD (remove_list);struct ib_sa_mcmember_rec rec; -if (!test_bit (IPOIB_FLAG_OPER_UP , &priv->flags)) +if (!ipoib_mcast_allowed (priv))/* * shortcut...on shutdown flush is called next, just * let it do all the work
@@ -965,9 +965,9 @@ void ipoib_mcast_restart_task(struct work_struct *work)ipoib_mcast_remove_list (&remove_list);/* -* Double check that we are still up +* Double check that we are still up and not flushing */ -if (test_bit (IPOIB_FLAG_OPER_UP , &priv->flags)) { +if (ipoib_mcast_allowed (priv)) {spin_lock_irq (&priv->lock);__ipoib_mcast_schedule_join_thread (priv,NULL ,0 );spin_unlock_irq (&priv->lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 51/398 wifi: cfg80211: dont get the radio mask for netdev-less wdevs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit a7783e585360ee05dfe21d3173dbbe985c94f29e ]
cfg80211_calculate_bi_data() calls rdev_get_radio_mask() with wdev->netdev, which can be NULL and then crashes in mac80211.
To avoid that, invert the order of checks since wdev->netdev is always valid for beaconing interfaces.
--- net/wireless/util.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
net/wireless/util.c +4 -5
@@ -2385,16 +2385,15 @@ static void cfg80211_calculate_bi_data(struct wiphy *wiphy, u32 new_beacon_int,if (wdev->valid_links)continue ; + wdev_bi =cfg80211_wdev_bi (wdev); +if (!wdev_bi) +continue ; +/* skip wdevs not active on the given wiphy radio */ if (radio_idx >=0 && !(rdev_get_radio_mask (rdev, wdev->netdev) &BIT (radio_idx)))continue ; - wdev_bi =cfg80211_wdev_bi (wdev); - -if (!wdev_bi) -continue ; -if (!*beacon_int_gcd) { *beacon_int_gcd = wdev_bi;continue ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 52/398 wifi: cfg80211: check IP header size in cfg80211_classify8021d()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 48b2c5c628b09cf36cbeca53e0432fc2a7518be7 ]
A frame that looks like IP can be transmitted, but be too short, so the DS field is read incorrectly:
BUG: KMSAN: uninit-value in cfg80211_classify8021d+0x99d/0x12b0 net/wireless/util.c:1027 cfg80211_classify8021d+0x99d/0x12b0 net/wireless/util.c:1027 ieee80211_select_queue+0x37a/0x9e0 net/mac80211/wme.c:180 __ieee80211_subif_start_xmit+0x60f/0x1d90 net/mac80211/tx.c:4304 ieee80211_subif_start_xmit+0xa8/0x6d0 net/mac80211/tx.c:4538 ... packet_sendmsg+0x9173/0xa2a0 net/packet/af_packet.c:3108
Use skb_header_pointer() like the MPLS case.
--- net/wireless/util.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)
net/wireless/util.c +22 -4
@@ -962,12 +962,30 @@ unsigned int cfg80211_classify8021d(struct sk_buff *skb, }switch (skb->protocol) { -case htons (ETH_P_IP ): - dscp =ipv4_get_dsfield (ip_hdr (skb)) &0xfc ; +case htons (ETH_P_IP ): { +const struct iphdr *iph; +struct iphdr _iph; + + iph =skb_header_pointer (skb,sizeof (struct ethhdr ), +sizeof (*iph), &_iph); +if (!iph) +return 0 ; + + dscp =ipv4_get_dsfield (iph) &0xfc ;break ; -case htons (ETH_P_IPV6 ): - dscp =ipv6_get_dsfield (ipv6_hdr (skb)) &0xfc ; + } +case htons (ETH_P_IPV6 ): { +const struct ipv6hdr *ip6h; +struct ipv6hdr _ip6h; + + ip6h =skb_header_pointer (skb,sizeof (struct ethhdr ), +sizeof (*ip6h), &_ip6h); +if (!ip6h) +return 0 ; + + dscp =ipv6_get_dsfield (ip6h) &0xfc ;break ; + }case htons (ETH_P_MPLS_UC ):case htons (ETH_P_MPLS_MC ): {struct mpls_label mpls_tmp, *mpls;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 53/398 soundwire: cadence_master: wait and cancel cdns->work before clock stop
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bard Liao <[email protected]>
[ Upstream commit aba7b41faeecb7692458095ce6fafc341fe0b80e ]
A peripheral event could happen during the clock stop process. We need to wait for the event be handled before stopping the bus clock. Otherwise, we will get the IO transfer timed out issue.
--- drivers/soundwire/cadence_master.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/soundwire/cadence_master.c +7 -0
@@ -1702,6 +1702,13 @@ int sdw_cdns_clock_stop(struct sdw_cdns *cdns, bool block_wake)return 0 ; } +/* +* wait for any in-flight peripheral event handling to complete before stopping the clock. +* No need to disable peripheral interrupts before canceling the work, as the peripheral +* interrupts are already masked before the work is scheduled. +*/ +cancel_work_sync (&cdns->work); +/* * Before entering clock stop we mask the Slave * interrupts. This helps avoid having to deal with e.g. a
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 36/398 arm64: dts: renesas: r9a09g047: Switch GBETH TX queue scheduling to WRR
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ovidiu Panait <[email protected]>
[ Upstream commit 63016c3a91f2c458ca75869c8c782e899591f22d ]
The GBETH ethernet nodes don't specify a TX scheduling policy, so stmmac falls back to Strict Priority. In this configuration the queue with the highest priority gets all the traffic, starving the others under load.
Under sustained UDP TX load with multiple data streams, this starvation triggers spurious adapter resets due to TX queue timeouts:
iperf3 -c <ip> -i0 -t60 --bind-dev end0 -u -b0 -P4
end0: NETDEV WATCHDOG: CPU: 1: transmit queue 1 timed out 5228 ms
end0: Reset adapter.
Investigation shows that only the highest priority queue is advancing while the others stall for more than 5 seconds, causing a netdev watchdog reset.
Switch the TX scheduling policy to Weighted-Round-Robin (WRR) so that traffic is processed across all queues, eliminating the stalls.
--- arch/arm64/boot/dts/renesas/r9a09g047.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/arm64/boot/dts/renesas/r9a09g047.dtsi +10 -0
@@ -973,23 +973,28 @@ queue3 { mtl_tx_setup0: tx-queues-config { snps,tx-queues-to-use = <4>; + snps,tx-sched-wrr; queue0 { + snps,weight = <0x10>; snps,dcb-algorithm; snps,priority = <0x1>; }; queue1 { + snps,weight = <0x12>; snps,dcb-algorithm; snps,priority = <0x2>; }; queue2 { + snps,weight = <0x14>; snps,dcb-algorithm; snps,priority = <0x4>; }; queue3 { + snps,weight = <0x18>; snps,dcb-algorithm; snps,priority = <0x8>; };
@@ -1073,23 +1078,28 @@ queue3 { mtl_tx_setup1: tx-queues-config { snps,tx-queues-to-use = <4>; + snps,tx-sched-wrr; queue0 { + snps,weight = <0x10>; snps,dcb-algorithm; snps,priority = <0x1>; }; queue1 { + snps,weight = <0x12>; snps,dcb-algorithm; snps,priority = <0x2>; }; queue2 { + snps,weight = <0x14>; snps,dcb-algorithm; snps,priority = <0x4>; }; queue3 { + snps,weight = <0x18>; snps,dcb-algorithm; snps,priority = <0x8>; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 54/398 MIPS: Octeon: apply USB FDT fixups also when USB is modular
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Orgad Shaneh <[email protected]>
[ Upstream commit 126f16e0a1b353c2ba5c7e2c8626cfa865934f9f ]
The uctl/usbn device-tree fixups in octeon_prune_device_tree() - which set the board's USB reference-clock frequency and type from __cvmx_helper_board_usb_get_clock_type() - are guarded by "#ifdef CONFIG_USB", which is false when USB is built as a module. The fixups then silently disappear and octeon-hcd sees whatever default the DTS carries (12MHz crystal in octeon_3xxx.dts), leaving the PHY dead or the bus erroring on boards with a different reference clock.
Use IS_ENABLED() so USB=m gets the same fixups as USB=y.
--- arch/mips/cavium-octeon/octeon-platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/cavium-octeon/octeon-platform.c +2 -2
@@ -18,7 +18,7 @@#include <asm/octeon/octeon.h> #include <asm/octeon/cvmx-helper-board.h> -#ifdef CONFIG_USB +#if IS_ENABLED (CONFIG_USB )#include <linux/usb/ehci_def.h> #include <linux/usb/ehci_pdriver.h> #include <linux/usb/ohci_pdriver.h>
@@ -1080,7 +1080,7 @@ int __init octeon_prune_device_tree(void) ; } -#ifdef CONFIG_USB +#if IS_ENABLED (CONFIG_USB )/* OHCI/UHCI USB */ alias_prop =fdt_getprop (initial_boot_params, aliases,"uctl" ,NULL );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 55/398 dma-coherent: report a failed reserved memory assignment
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Donggeun Yoo <[email protected]>
[ Upstream commit 504981db4f69bdd28054fb98c96a3a67f7248dde ]
rmem_dma_device_init() drops the return value of dma_assign_coherent_memory() and always reports success. That call fails with -EBUSY when the device already has a coherent pool, and the file allows only "*one* such region of memory" per device.
of_reserved_mem_device_init_by_idx() reads the zero as success. It logs "assigned reserved memory node" for a region that was not assigned and records the pairing, so of_reserved_mem_device_release() later runs rmem_dma_device_release() for it. That clears dev->dma_mem without looking at which region it was called for, dropping the pool the device did get and leaving it on ordinary memory.
dma_declare_coherent_memory() checks the same call and releases the memory on failure, and rmem_swiotlb_device_init() propagates its own errors. Return the error here as well, so a device tree that assigns two pools to one device fails the probe instead of half working.
--- kernel/dma/coherent.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/dma/coherent.c +1 -2
@@ -351,8 +351,7 @@ static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev) min_not_zero(dev->coherent_dma_mask, dev->bus_dma_limit))dev_warn (dev,"reserved memory is beyond device's set DMA address range\n" ); -dma_assign_coherent_memory (dev, mem); -return 0 ; +return dma_assign_coherent_memory (dev, mem); } static void rmem_dma_device_release(struct reserved_mem *rmem,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 56/398 dmaengine: Fix device kref underflow in dma_chan_put()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shivank Garg <[email protected]>
[ Upstream commit 44dab659064eb5c10adb0306510eebe848ed592d ]
dma_chan_get() takes chan->device->ref only on the slow path:
/* no kref on fast path */
if (chan->client_count) {
__module_get(owner);
chan->client_count++;
return 0;
}
if (!try_module_get(owner))
return -ENODEV;
if (!dma_device_get(chan->device)) { // calls kref_get_unless_zero()dma_chan_put() drops the ref unconditionally, so every fast-path get/put pair drops one extra device reference.
The bug fires when two conditions hold together: a non-private provider has a persistent client holding chan->client_count > 0 and another client cycles dmaengine_get()/dmaengine_put(). When the kref hits zero, the subsequent dma_find_channel() returns NULL even though the provider module is still loaded.
Fix this by dropping device->ref only on the last put, matching the single slow-path get.
--- drivers/dma/dmaengine.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/dma/dmaengine.c +3 -1
@@ -515,7 +515,9 @@ static void dma_chan_put(struct dma_chan *chan) chan->route_data =NULL ; } -dma_device_put (chan->device); +/* This channel is not in use anymore, drop the device ref */ +if (!chan->client_count) +dma_device_put (chan->device);module_put (dma_chan_to_owner (chan)); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 57/398 dmaengine: fix use-after-free in dma_chan_put() and dma_release_channel()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shivank Garg <[email protected]>
[ Upstream commit e873c74132f0c5f1452816cd9bb26208f0bba1e1 ]
When dma_device_put() drops the last reference on chan->device->ref, dma_device_release() runs and may free the dma_device along with its channels.
dma_chan_put() then still reads chan->device->owner via dma_chan_to_owner() for the trailing module_put(). KASAN catches it:
slab-use-after-free in dma_chan_put+0x3e6/0x4c0 Read of size 8 by task insmod/6319 Freed by task 6319: kfree+0x225/0x470 dma_chan_put+0x395/0x4c0 dmaengine_put+0xf8/0x160
Cache the module owner in dma_chan_put() before the put so the trailing module_put() does not need chan->device.
--- drivers/dma/dmaengine.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/dma/dmaengine.c +4 -1
@@ -495,10 +495,13 @@ static int dma_chan_get(struct dma_chan *chan)*/ static void dma_chan_put (struct dma_chan *chan) { +struct module *owner; +/* This channel is not in use, bail out */ if (!chan->client_count)return ; + owner =dma_chan_to_owner (chan); chan->client_count--;/* This channel is not in use anymore, free it */
@@ -518,7 +521,7 @@ static void dma_chan_put(struct dma_chan *chan)/* This channel is not in use anymore, drop the device ref */ if (!chan->client_count)dma_device_put (chan->device); -module_put (dma_chan_to_owner (chan)); +module_put (owner); }enum dma_status dma_sync_wait (struct dma_chan *chan,dma_cookie_t cookie)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 58/398 dmaengine: wait for RCU readers before releasing dma_device
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shivank Garg <[email protected]>
[ Upstream commit dc750422170a563c7a81f6e49d36bb02c62ae37f ]
dma_issue_pending_all() walks the dma_device_list with list_for_each_entry_rcu() under rcu_read_lock(). dma_device_release() unlinks the device with list_del_rcu() and then calls device->device_release() (which in many drivers, such as plx_dma.c, directly calls kfree()).
Because there is no grace period between unlinking the device and freeing it, concurrent RCU readers in dma_issue_pending_all() can access the device after it has been freed.
The lockless walk originally relied on clients holding a dmaengine reference to pin the provider module, and therefore the device, for as long as they might traverse the list. Commit 8ad342a86359 ("dmaengine:
Add reference counting to dma_device struct") decoupled the dma_device lifetime from the module reference, so the device can now be released while a reader is still walking the list.
Add synchronize_rcu() before the device is freed, so RCU readers are guaranteed to have finished. Keep it unconditional: providers that do not implement device_release() free the device themselves once dma_async_device_unregister() returns. This call will delay for a grace period with dma_list_mutex held, which is safe and only teardown path is delayed.
--- drivers/dma/dmaengine.c | 1 + 1 file changed, 1 insertion(+)
drivers/dma/dmaengine.c +1 -0
@@ -428,6 +428,7 @@ static void dma_device_release(struct kref *ref)list_del_rcu (&device->global_node);dma_channel_rebalance (); +synchronize_rcu ();if (device->device_release) device->device_release (device);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 59/398 wifi: cfg80211: dont free driver-owned scan requests
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit dab68a74e90b8e07f08ed9deaa5884857a3cfe89 ]
When an interface goes down while a scan is running, cfg80211 completes the scan towards userspace and frees the scan request. However, the driver can be convinced that it owns the request, since the cancellation is (intended to be) asynchronous.
The WARN_ON() in the netdev notifier was meant to catch this, but it's not actually avoidable, so it triggers and we get a UAF in scan_done().
There doesn't seem to be a great way around it, so just track that the driver is still convinced it owns the request, and then just free it on completion if it was already cancelled. Also remove the warnings since they can trigger in the intended architecture.
--- net/wireless/core.c | 11 +++++------ net/wireless/core.h | 10 ++++++++++ net/wireless/rdev-ops.h | 3 +++ net/wireless/scan.c | 31 +++++++++++++++++++++++++++++-- 4 files changed, 47 insertions(+), 8 deletions(-)
net/wireless/core.c +5 -6
@@ -241,9 +241,8 @@ void cfg80211_stop_p2p_device(struct cfg80211_registered_device *rdev, rdev->opencount--;if (rdev->scan_req && rdev->scan_req->req.wdev == wdev) { -if (WARN_ON (!rdev->scan_req->notified && - (!rdev->int_scan_req || - !rdev->int_scan_req->notified))) +if (!rdev->scan_req->notified && + (!rdev->int_scan_req || !rdev->int_scan_req->notified)) rdev->scan_req->info.aborted = true;___cfg80211_scan_done (rdev, false); }
@@ -1660,9 +1659,9 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,wiphy_lock (&rdev->wiphy);cfg80211_update_iface_num (rdev, wdev->iftype,-1 );if (rdev->scan_req && rdev->scan_req->req.wdev == wdev) { -if (WARN_ON (!rdev->scan_req->notified && - (!rdev->int_scan_req || - !rdev->int_scan_req->notified))) +if (!rdev->scan_req->notified && + (!rdev->int_scan_req || + !rdev->int_scan_req->notified)) rdev->scan_req->info.aborted = true;___cfg80211_scan_done (rdev, false); }
net/wireless/core.h +10 -0
@@ -24,6 +24,16 @@struct cfg80211_scan_request_int {struct cfg80211_scan_info info;bool notified; +/* +* set while the request is handed to the driver, i.e. between +* rdev_scan() and cfg80211_scan_done() +*/ +bool driver_owns; +/* +* set when cfg80211 is done with the request but the driver still +* owns it, so that cfg80211_scan_done() knows to just free it +*/ +bool stale;/* must be last - variable members */ struct cfg80211_scan_request req; };
net/wireless/rdev-ops.h +3 -0
@@ -464,7 +464,10 @@ static inline int rdev_scan(struct cfg80211_registered_device *rdev,return -EINVAL ;trace_rdev_scan (&rdev->wiphy, request); + request->driver_owns = true; ret = rdev->ops->scan (&rdev->wiphy, &request->req); +if (ret) + request->driver_owns = false;trace_rdev_return_int (&rdev->wiphy, ret);return ret; }
net/wireless/scan.c +29 -2
@@ -1115,6 +1115,21 @@ int cfg80211_scan(struct cfg80211_registered_device *rdev)return 0 ; } +/* +* Release the scan request, but free it only if the driver is also done, +* e.g. mac80211 may cancel it asynchronously and still use it. +*/ +static void cfg80211_put_scan_req (struct cfg80211_scan_request_int *req) +{ +if (!req) +return ; + +if (req->driver_owns) + req->stale = true; +else +kfree (req); +} +void ___cfg80211_scan_done (struct cfg80211_registered_device *rdev,bool send_message) {
@@ -1174,10 +1189,10 @@ void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev,dev_put (wdev->netdev); -kfree (rdev->int_scan_req); +cfg80211_put_scan_req (rdev->int_scan_req); rdev->int_scan_req =NULL ; -kfree (rdev->scan_req); +cfg80211_put_scan_req (rdev->scan_req); rdev->scan_req =NULL ;if (!send_message)
@@ -1200,6 +1215,18 @@ void cfg80211_scan_done(struct cfg80211_scan_request *request,struct cfg80211_scan_info old_info = intreq->info;trace_cfg80211_scan_done (intreq, info); + + intreq->driver_owns = false; + +if (intreq->stale) { +/* +* The scan is already completed as far as we're concerned, +* it was just kept around for the driver - done now, free it. +*/ +kfree (intreq); +return ; + } +WARN_ON (intreq != rdev->scan_req && intreq != rdev->int_scan_req);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 60/398 wifi: cfg80211: only group hidden BSSes with beacon entries
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 068843ed0902c552a13860c5ec6b2ca65b57a065 ]
When a probe response for an unknown BSS comes in, __cfg80211_bss_update() looks for an existing entry with the same BSSID and a hidden (zero-length or NUL-filled) SSID, and if it finds one it groups them, using the beacon IEs from the existing entry.
But that could find another entry without a beacon, if it was also from a probe response (with SSID), so there's a group without beacon elements.
If a beacon with a hidden SSID for that BSSID arrives later, cfg80211_combine_bsses() goes looking for the probe response entries that belong to it - i.e. entries with the same BSSID and channel that have no beacon IEs - and finds those two. They are already grouped with each other, so it hits its
WARN_ON_ONCE(bss->pub.hidden_beacon_bss)
WARN_ON_ONCE(!list_empty(&bss->hidden_list))
which are there because an entry without beacon elements is not supposed to be part of a group yet.
Only combine entries when a beacon was already received, ones that are kept separate will be combined when a beacon arrives.
--- net/wireless/scan.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/wireless/scan.c +7 -0
@@ -2050,6 +2050,13 @@ __cfg80211_bss_update(struct cfg80211_registered_device *rdev,if (!hidden) hidden =rb_find_bss (rdev, tmp,BSS_CMP_HIDE_NUL ); +/* +* Only group with an entry with beacon data, otherwise +* beacon data can never be filled/updated. +*/ +if (hidden && + !rcu_access_pointer (hidden->pub.beacon_ies)) + hidden =NULL ;if (hidden) { new->pub.hidden_beacon_bss = &hidden->pub; list_add(&new->hidden_list,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 61/398 wifi: cfg80211: dont filter by BSS type when removing stale entries
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit b377e1000d963e7182a987082b4b06580bd7ac84 ]
When an assoc AP switches to a channel that already has a BSS entry, cfg80211_update_assoc_bss_entry() removes that entry before rehashing the real one, since the two would otherwise collide in the BSS rbtree.
The lookup for that entry also required it to match the connection's BSS type, so an entry advertising e.g. the IBSS capability bit was left in place, and the following cfg80211_rehash_bss() then ran into it:
WARN_ON(!cmp)
Changing the type shouldn't really happen, but can be triggered by a rogue AP/device, so drop the check and remove any entries matching the comparison.
--- net/wireless/scan.c | 5 ----- 1 file changed, 5 deletions(-)
net/wireless/scan.c +0 -5
@@ -3491,11 +3491,6 @@ void cfg80211_update_assoc_bss_entry(struct wireless_dev *wdev, cbss->pub.channel = chan;list_for_each_entry (bss, &rdev->bss_list, list) { -if (!cfg80211_bss_type_match (bss->pub.capability, - bss->pub.channel->band, - wdev->conn_bss_type)) -continue ; -if (bss == cbss)continue ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 62/398 wifi: mac80211: dont start a ROC while scanning
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 733f0fde95392ed5f61a4e36aee661ea8d0e8581 ]
The ROC work can be pending when a scan starts (which requires ROC list to be empty, but that's possible), and then a new ROC can be added to the list and the work will pick it up.
Avoid starting that ROC if a scan made it between things, as otherwise we'll hit a warning later:
WARNING: net/mac80211/offchannel.c:404 at ieee80211_start_next_roc+0x256/0x2d0 Workqueue: events_unbound cfg80211_wiphy_work Call Trace: __ieee80211_scan_completed+0x4fd/0xe40 net/mac80211/scan.c:537 ieee80211_scan_work+0x472/0x1ff0 net/mac80211/scan.c:1193 cfg80211_wiphy_work+0x410/0x570 net/wireless/core.c:513
--- net/mac80211/offchannel.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/mac80211/offchannel.c +7 -0
@@ -462,6 +462,13 @@ static void __ieee80211_roc_work(struct ieee80211_local *local)return ;if (!roc->started) { +/* +* The work can be started by a previous ROC work, but a scan +* can get between things; scan finish will retrigger us. +*/ +if (local->scanning) +return ; +WARN_ON (!local->emulate_chanctx);_ieee80211_start_next_roc (local); }else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 63/398 wifi: mac80211: dont warn when an IBSS has no channel to scan
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit a7491b7efbd9136b120a12ed72af9c12121dd134 ]
ieee80211_request_ibss_scan() warns when regulatory leaves no allowed channel, but that can happen as the regdomain can change while IBSS is operating, and it can continue to operate briefly during the 60s grace period until it's shut down.
Just remove the warning in this case.
--- net/mac80211/scan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/scan.c +1 -1
@@ -1238,7 +1238,7 @@ int ieee80211_request_ibss_scan(struct ieee80211_sub_if_data *sdata, } } -if (WARN_ON_ONCE (n_ch ==0 )) +if (n_ch ==0 )return -EINVAL ; local->int_scan_req->n_channels = n_ch;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 37/398 IB/iser: reject a remote invalidation of an unregistered direction
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yehyeong Lee <[email protected]>
[ Upstream commit d85f0f0a7c85756fc992c70d869706f19dac9259 ]
A write command whose data is sent entirely as immediate data is not registered. iser_reg_mem_fastreg() takes the DMA key path and leaves rdma_reg[ISER_DIR_OUT].desc at NULL, while iser_dma_map_task_data() has already set dir[ISER_DIR_OUT].
iser_check_remote_inv() looks at dir[] alone and hands the descriptor to iser_inv_desc(), which reads desc->sig_protected. A target that answers such a command with IB_WR_SEND_WITH_INV faults the initiator. Leaving those commands unregistered is deliberate.
The same function already terminates the connection when a target sends a remote invalidation the initiator did not ask for. A target that invalidates a direction that was never registered is in the same class, so give it the same answer.
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000004: 0000 [#1] SMP KASAN NOPTI KASAN: null-ptr-deref in range [0x0000000000000020-0x0000000000000027] CPU: 0 UID: 0 PID: 40 Comm: kworker/u8:2 Not tainted 7.2.0-rc5-ISERHOST-gf5098b6bae76-dirty #3 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 Workqueue: rxe_wq do_work RIP: 0010:iser_task_rsp+0x6d6/0xec0 Code: 48 c1 ea 03 80 3c 02 00 0f 85 ba 06 00 00 48 8b 9b 78 01 00 00 48 b8 00 00 00 00 00 fc ff df 48 8d 7b 20 48 89 fa 48 c1 ea 03 <0f> b6 04 02 84 c0 74 06 0f 8e 76 06 00 00 80 7b 20 00 0f 84 3d 04 RSP: 0018:ffff88811b008db8 EFLAGS: 00010202 RAX: dffffc0000000000 RBX: 0000000000000000 RCX: 0000000000001848 RDX: 0000000000000004 RSI: 1ffff11021587b12 RDI: 0000000000000020 RBP: ffff88810adc1ae4 R08: ffff888109b7f860 R09: ffffffff90a922c0 R10: ffff88810adc1a1c R11: 000000000000003c R12: ffff888109b7f800 R13: ffff88810adc1acc R14: ffff888109b7f820 R15: 0000000000000000 FS: 0000000000000000(0000) GS:ffff88818a676000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000005afe2b CR3: 000000010af23005 CR4: 0000000000770ef0 PKRU: 55555554 Call Trace: <IRQ> __ib_process_cq+0xe1/0x390 ib_poll_handler+0x6e/0x200 irq_poll_softirq+0x1df/0x480 ? clockevents_program_event+0x2ba/0x860 ? __pfx_irq_poll_softirq+0x10/0x10 handle_softirqs+0x18e/0x590 ? __pfx_handle_softirqs+0x10/0x10 ? __hrtimer_rearm_deferred+0x156/0x450 do_softirq+0x3b/0x60 </IRQ> <TASK> __local_bh_enable_ip+0x61/0x70 __alloc_skb+0x732/0x890 ? _raw_spin_lock_irqsave+0x85/0xe0 ? __pfx___alloc_skb+0x10/0x10 ? _raw_read_unlock_irqrestore+0x16/0x50 rxe_init_packet+0x16b/0x4f0 prepare_ack_packet+0xb8/0x830 rxe_receiver+0x499/0x9980 ? __pfx_rxe_receiver+0x10/0x10 ? rxe_completer+0x29e5/0x38c0 ? hrtimer_start_range_ns_common+0x75f/0x1730 ? hrtimer_start_range_ns+0xa6/0x2c0 ? __pfx__raw_spin_lock_irqsave+0x10/0x10 ? __pfx_rxe_receiver+0x10/0x10 do_work+0x144/0x470 process_one_work+0x633/0x1030 ? assign_work+0x11d/0x370 worker_thread+0x45b/0xd10 ? __pfx_worker_thread+0x10/0x10 kthread+0x2c6/0x3b0 ? recalc_sigpending+0x15c/0x1e0 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x36e/0x5a0 ? __pfx_ret_from_fork+0x10/0x10 ? __switch_to+0x572/0xdd0 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30 </TASK> Modules linked in: ---[ end trace 0000000000000000 ]---
--- drivers/infiniband/ulp/iser/iser_initiator.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/infiniband/ulp/iser/iser_initiator.c +11 -5
@@ -599,11 +599,8 @@ static int iser_check_remote_inv(struct iser_conn *iser_conn, struct ib_wc *wc,iser_dbg ("conn %p: remote invalidation for rkey %#x\n" , iser_conn, rkey); -if (unlikely (!iser_conn->snd_w_inv)) { -iser_err ("conn %p: unexpected remote invalidation, terminating connection\n" , - iser_conn); -return -EPROTO ; - } +if (unlikely (!iser_conn->snd_w_inv)) + goto bad_inv; task =iscsi_itt_to_ctask (iser_conn->iscsi_conn, hdr->itt);if (likely (task)) {
@@ -612,12 +609,16 @@ static int iser_check_remote_inv(struct iser_conn *iser_conn, struct ib_wc *wc,if (iser_task->dir[ISER_DIR_IN ]) { desc = iser_task->rdma_reg[ISER_DIR_IN ].desc; +if (unlikely (!desc)) + goto bad_inv;if (unlikely (iser_inv_desc (desc, rkey)))return -EINVAL ; }if (iser_task->dir[ISER_DIR_OUT ]) { desc = iser_task->rdma_reg[ISER_DIR_OUT ].desc; +if (unlikely (!desc)) + goto bad_inv;if (unlikely (iser_inv_desc (desc, rkey)))return -EINVAL ; }
@@ -628,6 +629,11 @@ static int iser_check_remote_inv(struct iser_conn *iser_conn, struct ib_wc *wc, }return 0 ; + +bad_inv: +iser_err ("conn %p: unexpected remote invalidation, terminating connection\n" , + iser_conn); +return -EPROTO ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 64/398 wifi: mac80211: dont offload TC setup on AP_VLAN interfaces
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 362bd5bce29ed0f6fd3d39a7065567777d70606e ]
AP_VLAN interfaces are purely virtual, so don't try to offload TC setup to drivers. We can't really use the AP interface either since we may not know it all the time, and it could technically even change.
Just reject the TC offload so things get done in software.
--- net/mac80211/iface.c | 3 +++ 1 file changed, 3 insertions(+)
net/mac80211/iface.c +3 -0
@@ -896,6 +896,9 @@ static int ieee80211_netdev_setup_tc(struct net_device *dev,struct ieee80211_sub_if_data *sdata =IEEE80211_DEV_TO_SUB_IF (dev);struct ieee80211_local *local = sdata->local; +if (sdata->vif.type ==NL80211_IFTYPE_AP_VLAN ) +return -EOPNOTSUPP ; +return drv_net_setup_tc (local, sdata, dev, type, type_data); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 65/398 wifi: mac80211: suppress chanctx warning for debugfs reset
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit bf29d085e0eba92388518719d044f4702a8c6644 ]
Before suspend all the channel contexts should removed, so the warning makes sense and should be there, but during reset the same code is called without first removing. Limit the check to the real suspend case.
--- net/mac80211/cfg.c | 2 +- net/mac80211/debugfs.c | 2 +- net/mac80211/ieee80211_i.h | 2 +- net/mac80211/pm.c | 8 +++++--- 4 files changed, 8 insertions(+), 6 deletions(-)
net/mac80211/cfg.c +1 -1
@@ -3094,7 +3094,7 @@ static int ieee80211_set_txq_params(struct wiphy *wiphy,static int ieee80211_suspend (struct wiphy *wiphy,struct cfg80211_wowlan *wowlan) { -return __ieee80211_suspend (wiphy_priv (wiphy), wowlan); +return __ieee80211_suspend (wiphy_priv (wiphy), wowlan, false); }static int ieee80211_resume (struct wiphy *wiphy)
net/mac80211/debugfs.c +1 -1
@@ -409,7 +409,7 @@ static ssize_t reset_write(struct file *file, const char __user *user_buf,rtnl_lock ();wiphy_lock (local->hw.wiphy); -__ieee80211_suspend (&local->hw,NULL ); +__ieee80211_suspend (&local->hw,NULL , true); ret =__ieee80211_resume (&local->hw);wiphy_unlock (local->hw.wiphy);
net/mac80211/ieee80211_i.h +1 -1
@@ -2365,7 +2365,7 @@ int ieee80211_reconfig(struct ieee80211_local *local);void ieee80211_stop_device (struct ieee80211_local *local,bool suspend);int __ieee80211_suspend (struct ieee80211_hw *hw, -struct cfg80211_wowlan *wowlan); +struct cfg80211_wowlan *wowlan,bool reset);static inline int __ieee80211_resume (struct ieee80211_hw *hw) {
net/mac80211/pm.c +5 -3
@@ -18,7 +18,8 @@ static void ieee80211_sched_scan_cancel(struct ieee80211_local *local)cfg80211_sched_scan_stopped_locked (local->hw.wiphy,0 ); } -int __ieee80211_suspend (struct ieee80211_hw *hw,struct cfg80211_wowlan *wowlan) +int __ieee80211_suspend (struct ieee80211_hw *hw,struct cfg80211_wowlan *wowlan, +bool reset) {struct ieee80211_local *local =hw_to_local (hw);struct ieee80211_sub_if_data *sdata;
@@ -166,9 +167,10 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)/* * We disconnected on all interfaces before suspend, all channel -* contexts should be released. +* contexts should be released, but on 'reset' debugfs that's +* not true so don't check there. */ -WARN_ON (!list_empty (&local->chanctx_list)); +WARN_ON (!reset && !list_empty (&local->chanctx_list));/* stop hardware - this must stop RX */ ieee80211_stop_device (local, true);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 38/398 IB/isert: wait for deferred control PDU completions before releasing the connection
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yehyeong Lee <[email protected]>
[ Upstream commit a8fe3dfce8c0d8a76dc3d8486a5bff5feebe156f ]
isert_send_done() hands ISTATE_SEND_TASKMGTRSP, ISTATE_SEND_REJECT and ISTATE_SEND_TEXTRSP completions off to isert_comp_wq and returns. The work item then runs isert_completion_put() -> isert_put_cmd(), which reads isert_conn->conn and takes conn->cmd_lock.
Nothing orders that work item against teardown. isert_wait_conn() queues isert_release_work, which frees isert_conn, and iscsit_close_connection() frees the iscsit_conn right after it returns, so the queued work can run against freed memory.
Count the deferred control PDU completions per connection and let isert_wait_conn() wait for them before the release work is queued.
ISTATE_SEND_LOGOUTRSP is deliberately not counted: that branch runs iscsit_logout_post_handler(), which ends up waiting for conn->conn_wait_comp, and that completion is only sent by iscsit_close_connection() after it has called iscsit_wait_conn(). Waiting for it here would deadlock. Its wait stays the existing isert_wait4logout().
The splat below is from a kernel with tracing printk()s and an msleep(200) injected into isert_do_control_comp() to widen the window:
BUG: KASAN: slab-use-after-free in isert_put_cmd+0x53d/0x620 Read of size 8 at addr ffff8881054f1038 by task kworker/u17:1/182 CPU: 0 UID: 0 PID: 182 Comm: kworker/u17:1 Tainted: G B 7.2.0-rc5-TWIDE-gb8babf08acc7 #1 PREEMPT(lazy) Tainted: [B]=BAD_PAGE 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 Workqueue: isert_comp_wq isert_do_control_comp Call Trace: <TASK> dump_stack_lvl+0x53/0x70 print_report+0xd0/0x630 ? __pfx__raw_spin_lock_irqsave+0x10/0x10 ? _raw_spin_unlock_irqrestore+0x3e/0x70 ? isert_put_cmd+0x53d/0x620 kasan_report+0xce/0x100 ? isert_put_cmd+0x53d/0x620 isert_put_cmd+0x53d/0x620 ? isert_completion_put+0x305/0x330 ? isert_do_control_comp+0x2ef/0x310 process_one_work+0x633/0x1030 ? assign_work+0x11d/0x370 worker_thread+0x45b/0xd10 ? __pfx_worker_thread+0x10/0x10 ? __pfx_worker_thread+0x10/0x10 kthread+0x2c6/0x3b0 ? recalc_sigpending+0x15c/0x1e0 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x36e/0x5a0 ? __pfx_ret_from_fork+0x10/0x10 ? __switch_to+0x572/0xdd0 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30 </TASK> Allocated by task 48: kasan_save_stack+0x33/0x60 kasan_save_track+0x14/0x30 __kasan_kmalloc+0x8f/0xa0 __kmalloc_cache_noprof+0x158/0x370 isert_cma_handler+0x1e3/0x2ae0 cma_cm_event_handler+0x3e/0x240 cma_ib_req_handler+0x17d9/0x4490 cm_process_work+0x41/0x330 cm_work_handler+0x5727/0xc160 process_one_work+0x633/0x1030 worker_thread+0x45b/0xd10 kthread+0x2c6/0x3b0 ret_from_fork+0x36e/0x5a0 ret_from_fork_asm+0x1a/0x30 Freed by task 184: kasan_save_stack+0x33/0x60 kasan_save_track+0x14/0x30 kasan_save_free_info+0x3b/0x60 __kasan_slab_free+0x43/0x70 kfree+0x121/0x380 iscsit_close_connection+0x7cf/0x1e60 iscsit_take_action_for_connection_exit+0x1b6/0x360 iscsi_target_tx_thread+0x472/0x690 kthread+0x2c6/0x3b0 ret_from_fork+0x36e/0x5a0 ret_from_fork_asm+0x1a/0x30
--- drivers/infiniband/ulp/isert/ib_isert.c | 22 ++++++++++++++++++++++ drivers/infiniband/ulp/isert/ib_isert.h | 2 ++ 2 files changed, 24 insertions(+)
drivers/infiniband/ulp/isert/ib_isert.c +22 -0
@@ -21,6 +21,7 @@#include <target/target_core_fabric.h> #include <target/iscsi/iscsi_transport.h> #include <linux/semaphore.h> +#include <linux/wait_bit.h> #include "ib_isert.h"
@@ -311,6 +312,7 @@ isert_init_conn(struct isert_conn *isert_conn)init_completion (&isert_conn->login_req_comp);init_waitqueue_head (&isert_conn->rem_wait);kref_init (&isert_conn->kref); +atomic_set (&isert_conn->ctrl_comp_cnt,0 );mutex_init (&isert_conn->mutex);INIT_WORK (&isert_conn->release_work, isert_release_work); }
@@ -1697,6 +1699,8 @@ isert_do_control_comp(struct work_struct *work)struct isert_conn *isert_conn = isert_cmd->conn;struct ib_device *ib_dev = isert_conn->cm_id->device;struct iscsit_cmd *cmd = isert_cmd->iscsit_cmd; +/* The switch below may free isert_cmd. */ +bool counted = isert_cmd->ctrl_counted;isert_dbg ("Cmd %p i_state %d\n" , isert_cmd, cmd->i_state);
@@ -1718,6 +1722,14 @@ isert_do_control_comp(struct work_struct *work)dump_stack ();break ; } + +/* +* The count is what keeps isert_conn alive, so drop it last. The wait +* queue lives in the global hash table, not in isert_conn, so this is +* safe even if the waiter has already freed the connection. +*/ +if (counted &&atomic_dec_and_test (&isert_conn->ctrl_comp_cnt)) +wake_up_var (&isert_conn->ctrl_comp_cnt); } static void
@@ -1761,6 +1773,12 @@ isert_send_done(struct ib_cq *cq, struct ib_wc *wc)case ISTATE_SEND_TEXTRSP :isert_unmap_tx_desc (tx_desc, ib_dev); +/* Paired with the wait in isert_wait_conn(). */ + isert_cmd->ctrl_counted = + isert_cmd->iscsit_cmd->i_state !=ISTATE_SEND_LOGOUTRSP ; +if (isert_cmd->ctrl_counted) +atomic_inc (&isert_conn->ctrl_comp_cnt); +INIT_WORK (&isert_cmd->comp_work, isert_do_control_comp);queue_work (isert_comp_wq, &isert_cmd->comp_work);return ;
@@ -2605,6 +2623,10 @@ static void isert_wait_conn(struct iscsit_conn *conn)isert_wait4cmds (conn);isert_wait4logout (isert_conn); +/* Paired with the count taken in isert_send_done(). */ +wait_var_event (&isert_conn->ctrl_comp_cnt, + !atomic_read (&isert_conn->ctrl_comp_cnt)); +queue_work (isert_release_wq, &isert_conn->release_work); }
drivers/infiniband/ulp/isert/ib_isert.h +2 -0
@@ -153,6 +153,7 @@ struct isert_cmd {struct work_struct comp_work;struct scatterlist sg;bool ctx_init_done; +bool ctrl_counted; };static inline struct isert_cmd *tx_desc_to_cmd (struct iser_tx_desc *desc)
@@ -187,6 +188,7 @@ struct isert_conn {struct mutex mutex;struct kref kref;struct work_struct release_work; +atomic_t ctrl_comp_cnt;bool logout_posted;bool snd_w_inv;wait_queue_head_t rem_wait;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 39/398 RDMA/bnxt_re: check create_singlethread_workqueue() in DCB setup
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linkai Gong <[email protected]>
[ Upstream commit 6c368f7baaea63c1c7c28c6df271511f2a1562c9 ]
bnxt_re_init_dcb_wq() ignores a failed allocation. The async DCB handler later calls queue_work() on the NULL pointer.
--- drivers/infiniband/hw/bnxt_re/main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/infiniband/hw/bnxt_re/main.c +8 -2
@@ -356,9 +356,13 @@ static int bnxt_re_update_qp1_tos_dscp(struct bnxt_re_dev *rdev)return bnxt_qplib_modify_qp (&rdev->qplib_res, &qp->qplib_qp); } -static void bnxt_re_init_dcb_wq (struct bnxt_re_dev *rdev) +static int bnxt_re_init_dcb_wq (struct bnxt_re_dev *rdev) { rdev->dcb_wq =create_singlethread_workqueue ("bnxt_re_dcb_wq" ); +if (!rdev->dcb_wq) +return -ENOMEM ; + +return 0 ; }static void bnxt_re_uninit_dcb_wq (struct bnxt_re_dev *rdev)
@@ -2340,7 +2344,9 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 op_type)bnxt_re_debugfs_add_pdev (rdev); -bnxt_re_init_dcb_wq (rdev); + rc =bnxt_re_init_dcb_wq (rdev); +if (rc) + goto fail;bnxt_re_net_register_async_event (rdev);if (!rdev->is_virtfn)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 40/398 RDMA/mad: Fix receive buffer leak when PKey enforcement fails
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit 3476c28c9addfa253f505e6bd87f1f5598b961d0 ]
ib_mad_complete_recv() initializes mad_recv_wc->rmpp_list and then runs ib_mad_enforce_security() before linking recv_buf onto that list. On failure it calls ib_free_recv_mad(), which only walks rmpp_list and frees the ib_mad_private of every buffer found there. As the list is still empty at that point, nothing is freed at all.
The caller cannot clean up either: ib_mad_recv_done() sets recv to NULL right after ib_mad_complete_recv() returns, assuming the MAD layer took ownership of the buffer. Every MAD that fails the PKey check therefore leaks one ib_mad_private (about 300 bytes per IB port MAD, ~2K for OPA), and a remote node can trigger this repeatedly by sending MADs with a wrong PKey.
Link recv_buf onto rmpp_list right after the list is initialized, so the error path has something to free.
--- drivers/infiniband/core/mad.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/core/mad.c +2 -1
@@ -2059,6 +2059,8 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv,int ret;INIT_LIST_HEAD (&mad_recv_wc->rmpp_list); +list_add (&mad_recv_wc->recv_buf.list, &mad_recv_wc->rmpp_list); + ret =ib_mad_enforce_security (mad_agent_priv, mad_recv_wc->wc->pkey_index);if (ret) {
@@ -2067,7 +2069,6 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv,return ; } -list_add (&mad_recv_wc->recv_buf.list, &mad_recv_wc->rmpp_list);if (is_kernel_rmpp_data_response (mad_agent_priv, mad_recv_wc)) {spin_lock_irqsave (&mad_agent_priv->lock, flags); mad_send_wr =ib_find_send_mad (mad_agent_priv, mad_recv_wc);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 41/398 RDMA/irdma: Enforce local fence for IB_WR_REG_MR
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jacob Moroni <[email protected]>
[ Upstream commit 3fb905f07ea45b31c8f67ba6e4668de46f527e65 ]
Enforce local fence for IB_WR_REG_MR to avoid spurious FASTREG_VALID_MKEY async events during heavy invalidation and registration activity.
Commit 69e8e429bca2 ("RDMA/irdma: Enforce local fence for LOCAL_INV WRs") was very similar, but was not sufficient to prevent all occurrences of these async events.
--- drivers/infiniband/hw/irdma/verbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/irdma/verbs.c +1 -1
@@ -4165,7 +4165,7 @@ static int irdma_post_send(struct ib_qp *ibqp, stag_info.total_len = iwmr->ibmr.length; stag_info.reg_addr_pa = *palloc->level1.addr; stag_info.first_pm_pbl_index = palloc->level1.idx; - stag_info.local_fence = ib_wr->send_flags &IB_SEND_FENCE ; + stag_info.local_fence = true;if (iwmr->npages >IRDMA_MIN_PAGES_PER_FMR ) stag_info.chunk_size =1 ; err = irdma_sc_mr_fast_register(&iwqp->sc_qp, &stag_info,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 42/398 RDMA/rtrs-clt: Fix CQ pool leak when connect is interrupted
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quanye Yang <[email protected]>
[ Upstream commit 2ae16aaa78b5edc6e6d0904c84fd9cdfb762bcda ]
The client borrows shared CQ credits in the ADDR_RESOLVED handler via ib_cq_pool_get(), before the peer is connected. create_cm() can return -ERESTARTSYS from wait_event_interruptible_timeout() without destroying the CM ID. The init_conns() and stop-and-destroy paths then call destroy_con_cq_qp() while cq is still NULL (no PUT) and only afterwards rdma_destroy_id().
CMA serializes the handler against rdma_destroy_id() with handler_mutex, but that does not order the GET against destroy_con_cq_qp(). If ADDR_RESOLVED has already passed the DESTROYING check, it can take con_mutex, GET credits, and then lose the con to kfree. Device unregister later hits WARN_ON(cq->cqe_used) in ib_cq_pool_cleanup().
Set a per-connection flag under con_mutex before CQ/QP teardown so a racing ADDR_RESOLVED cannot borrow credits after teardown has begun.
--- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 8 ++++++++ drivers/infiniband/ulp/rtrs/rtrs-clt.h | 2 ++ 2 files changed, 10 insertions(+)
drivers/infiniband/ulp/rtrs/rtrs-clt.c +8 -0
@@ -1738,6 +1738,8 @@ static void destroy_con_cq_qp(struct rtrs_clt_con *con)/* * Be careful here: destroy_con_cq_qp() can be called even * create_con_cq_qp() failed, see comments there. +* Caller must set con->destroyed under this lock first so a +* racing ADDR_RESOLVED cannot ib_cq_pool_get() after we PUT/SKIP. */ lockdep_assert_held (&con->con_mutex);rtrs_cq_qp_destroy (&con->c);
@@ -1772,6 +1774,10 @@ static int rtrs_rdma_addr_resolved(struct rtrs_clt_con *con)int err;mutex_lock (&con->con_mutex); +if (con->destroyed) { +mutex_unlock (&con->con_mutex); +return -ECONNABORTED ; + } err =create_con_cq_qp (con);mutex_unlock (&con->con_mutex);if (err) {
@@ -2202,6 +2208,7 @@ static void rtrs_clt_stop_and_destroy_conns(struct rtrs_clt_path *clt_path)break ; con =to_clt_con (clt_path->s.con[cid]);mutex_lock (&con->con_mutex); + con->destroyed = true;destroy_con_cq_qp (con);mutex_unlock (&con->con_mutex);destroy_cm (con);
@@ -2368,6 +2375,7 @@ static int init_conns(struct rtrs_clt_path *clt_path)if (con->c.cm_id) {stop_cm (con);mutex_lock (&con->con_mutex); + con->destroyed = true;destroy_con_cq_qp (con);mutex_unlock (&con->con_mutex);destroy_cm (con);
drivers/infiniband/ulp/rtrs/rtrs-clt.h +2 -0
@@ -75,6 +75,8 @@ struct rtrs_clt_con {unsigned int cpu;struct mutex con_mutex;int cm_err; +/* Set under con_mutex before CQ/QP teardown. */ +bool destroyed; };/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 43/398 dmaengine: sprd: Fix runtime PM reference leak in probe
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit a7df136ec529ee49a789c5029bc37b98b0d4bedd ]
pm_runtime_get_sync() increments a device's usage counter even when it fails. sprd_dma_probe() currently jumps directly to controller clock cleanup on that error, bypassing both pm_runtime_put_noidle() and pm_runtime_disable(). This can happen if the preceding unchecked pm_runtime_set_active() fails and the following runtime-resume attempt also returns an error.
Enter the existing runtime-PM unwind path instead. This drops the reference without idling the partially initialized device, disables runtime PM, and then releases the controller clocks. The success path and propagated error code are unchanged.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/dma/sprd-dma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/dma/sprd-dma.c +1 -2
@@ -1212,7 +1212,7 @@ static int sprd_dma_probe(struct platform_device *pdev) ret =pm_runtime_get_sync (&pdev->dev);if (ret <0 ) - goto err_rpm; + goto err_register; ret =dma_async_device_register (&sdev->dma_dev);if (ret <0 ) {
@@ -1234,7 +1234,6 @@ static int sprd_dma_probe(struct platform_device *pdev) err_register:pm_runtime_put_noidle (&pdev->dev);pm_runtime_disable (&pdev->dev); -err_rpm:sprd_dma_disable (sdev);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 34/398 arm64: dts: renesas: r9a09g057: Switch GBETH TX queue scheduling to WRR
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ovidiu Panait <[email protected]>
[ Upstream commit 33da68f61d25ef8411489d06514ff627c1f88152 ]
The GBETH ethernet nodes don't specify a TX scheduling policy, so stmmac falls back to Strict Priority. In this configuration the queue with the highest priority gets all the traffic, starving the others under load.
Under sustained UDP TX load with multiple data streams, this starvation triggers spurious adapter resets due to TX queue timeouts:
iperf3 -c <ip> -i0 -t60 --bind-dev end0 -u -b0 -P4
end0: NETDEV WATCHDOG: CPU: 1: transmit queue 1 timed out 5228 ms
end0: Reset adapter.
Investigation shows that only the highest priority queue is advancing while the others stall for more than 5 seconds, causing a netdev watchdog reset.
Switch the TX scheduling policy to Weighted-Round-Robin (WRR) so that traffic is processed across all queues, eliminating the stalls.
--- arch/arm64/boot/dts/renesas/r9a09g057.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/arm64/boot/dts/renesas/r9a09g057.dtsi +10 -0
@@ -1160,23 +1160,28 @@ queue3 { mtl_tx_setup0: tx-queues-config { snps,tx-queues-to-use = <4>; + snps,tx-sched-wrr; queue0 { + snps,weight = <0x10>; snps,dcb-algorithm; snps,priority = <0x1>; }; queue1 { + snps,weight = <0x12>; snps,dcb-algorithm; snps,priority = <0x2>; }; queue2 { + snps,weight = <0x14>; snps,dcb-algorithm; snps,priority = <0x4>; }; queue3 { + snps,weight = <0x18>; snps,dcb-algorithm; snps,priority = <0x8>; };
@@ -1261,23 +1266,28 @@ queue3 { mtl_tx_setup1: tx-queues-config { snps,tx-queues-to-use = <4>; + snps,tx-sched-wrr; queue0 { + snps,weight = <0x10>; snps,dcb-algorithm; snps,priority = <0x1>; }; queue1 { + snps,weight = <0x12>; snps,dcb-algorithm; snps,priority = <0x2>; }; queue2 { + snps,weight = <0x14>; snps,dcb-algorithm; snps,priority = <0x4>; }; queue3 { + snps,weight = <0x18>; snps,dcb-algorithm; snps,priority = <0x8>; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 67/398 wifi: mac80211: reset state when starting AP fails
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 3f28551d0241254a75626d868041c6340285088b ]
ieee80211_start_ap() can set enable_beacon (and beacon_int) and fail later, leaving it set forever. Scanning can then attempt to restore beaconing on such an interface, leading to:
Oops: divide error: 0000 [#1] SMP KASAN NOPTI RIP: 0010:mac80211_hwsim_link_info_changed+0xca7/0xf00 Call Trace: drv_link_info_changed+0x413/0x860 net/mac80211/driver-ops.c:495 ieee80211_link_info_change_notify+0x24b/0x3c0 net/mac80211/main.c:427 ieee80211_offchannel_return+0x381/0x580 net/mac80211/offchannel.c:160 __ieee80211_scan_completed+0x993/0xe30 net/mac80211/scan.c:519 ieee80211_scan_work+0x472/0x2010 net/mac80211/scan.c:1193 cfg80211_wiphy_work+0x2b7/0x550 net/wireless/core.c:538
in hwsim. Also, cfg80211 then allows changing the interface type, and the off-channel path getgs confused about beaconing as well, leading to another warning:
WARNING: net/mac80211/driver-ops.c:468 at drv_link_info_changed+0x583/0x880 ieee80211_link_info_change_notify+0x24b/0x3c0 net/mac80211/main.c:427 ieee80211_offchannel_stop_vifs+0x328/0x5c0 net/mac80211/offchannel.c:122 ieee80211_start_sw_scan net/mac80211/scan.c:583 [inline] __ieee80211_start_scan+0xfb6/0x1af0 net/mac80211/scan.c:882
Reset the state on failures to always have it correct.
--- net/mac80211/cfg.c | 3 +++ 1 file changed, 3 insertions(+)
net/mac80211/cfg.c +3 -0
@@ -1717,6 +1717,9 @@ static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,return 0 ; error: + link_conf->enable_beacon = false; + link_conf->beacon_int = prev_beacon_int; + sdata->vif.cfg.ssid_len =0 ;ieee80211_link_release_channel (link);return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 76/398 wifi: mac80211: dont allow link changes when iface is down
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 370872d30349d81dec519e15ea2949fd63511cf7 ]
ieee80211_set_active_links() only checks that the interface is running in the inner __ieee80211_set_active_links(), after drv_can_activate_links() was already called, so using active_links on an interface that's down triggers the check-sdata-in-driver warning.
Add the missing check in the debugfs file.
--- net/mac80211/debugfs_netdev.c | 3 +++ 1 file changed, 3 insertions(+)
net/mac80211/debugfs_netdev.c +3 -0
@@ -728,6 +728,9 @@ static ssize_t ieee80211_if_parse_active_links(struct ieee80211_sub_if_data *sdaif (kstrtou16 (buf,0 , &active_links) || !active_links)return -EINVAL ; +if (!ieee80211_sdata_running (sdata)) +return -ENETDOWN ; +return ieee80211_set_active_links (&sdata->vif, active_links) ?: buflen; }IEEE80211_IF_FILE_RW (active_links);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 77/398 wifi: mac80211: dont RCU-dereference the mesh CSA settings we just set
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit b481e64e4498e2c053d5954f546ee02338f6ab63 ]
In the error path of ieee80211_mesh_csa_beacon() the settings that were just assigned are read back with rcu_dereference(), which lockdep then complains about.
There's no need to read the pointer at all, tmp_csa_settings still is the right value anyway.
--- net/mac80211/mesh.c | 1 - 1 file changed, 1 deletion(-)
net/mac80211/mesh.c +0 -1
@@ -1575,7 +1575,6 @@ int ieee80211_mesh_csa_beacon(struct ieee80211_sub_if_data *sdata, ret =ieee80211_mesh_rebuild_beacon (sdata);if (ret) { - tmp_csa_settings =rcu_dereference (ifmsh->csa);RCU_INIT_POINTER (ifmsh->csa,NULL );kfree_rcu (tmp_csa_settings, rcu_head);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 78/398 wifi: mac80211: dont access the TSF of a down interface
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 0b1de9feeb8651f7a3bb53ed7c9006e3b5298c01 ]
The tsf debugfs files call the driver even if the interface isn't up, tgriggering check-sdata-in-driver warnings.
Reject the access in that case.
--- net/mac80211/debugfs_netdev.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/mac80211/debugfs_netdev.c +6 -0
@@ -656,6 +656,9 @@ static ssize_t ieee80211_if_fmt_tsf(struct ieee80211_local *local = sdata->local;u64 tsf; +if (!ieee80211_sdata_running ((struct ieee80211_sub_if_data *)sdata)) +return -ENETDOWN ; + tsf =drv_get_tsf (local, (struct ieee80211_sub_if_data *)sdata);return scnprintf (buf, buflen,"0x%016llx\n" , (unsigned long long ) tsf);
@@ -669,6 +672,9 @@ static ssize_t ieee80211_if_parse_tsf(int ret;int tsf_is_delta =0 ; +if (!ieee80211_sdata_running (sdata)) +return -ENETDOWN ; +if (strncmp (buf,"reset" ,5 ) ==0 ) {if (local->ops->reset_tsf) {drv_reset_tsf (local, sdata);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 79/398 wifi: mac80211: add HE 6 GHz capability in the scan elems len
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit cd54bf333f5631d3630bab0a832e9ae648f73515 ]
The HE 6 GHz Band Capability element is in the probe request for every band if 6 GHz is supported, so add the size to scan_ies_len.
Otherwise, building probe request elements can fail, triggering the WARN_ON in __ieee80211_start_scan().
--- net/mac80211/main.c | 4 ++++ 1 file changed, 4 insertions(+)
net/mac80211/main.c +4 -0
@@ -1431,6 +1431,10 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)sizeof (struct ieee80211_he_mcs_nss_supp ) +IEEE80211_HE_PPE_THRES_MAX_LEN ; +if (local->hw.wiphy->bands[NL80211_BAND_6GHZ ]) + local->scan_ies_len += +3 +sizeof (struct ieee80211_he_6ghz_capa ); +if (supp_eht) local->scan_ies_len += 3 + sizeof(struct ieee80211_eht_cap_elem) +
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 80/398 wifi: mac80211: mesh: reset the CSA state when leaving
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 860134b3af77970e006feab7e5decb8c84771c7f ]
ifmsh->csa is allocated in ieee80211_mesh_csa_beacon() and only freed in ieee80211_mesh_finish_csa(), i.e. when the channel switch completes. Leaving the mesh while a switch is still pending therefore leaks it.
Additionally, ifmsh->csa_role and ifmsh->chsw_ttl have their state leak in this case, so things can get mixed up in addition to the memory leak.
Refactor the reset and call it in ieee80211_stop_mesh() to fix it all.
--- net/mac80211/mesh.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-)
net/mac80211/mesh.c +18 -11
@@ -1215,6 +1215,21 @@ int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)return 0 ; } +static void ieee80211_mesh_reset_csa (struct ieee80211_sub_if_data *sdata) +{ +struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; +struct mesh_csa_settings *csa; + +/* Reset the TTL value and Initiator flag */ + ifmsh->csa_role =IEEE80211_MESH_CSA_ROLE_NONE ; + ifmsh->chsw_ttl =0 ; + +/* Remove the CSA and MCSP elements from the beacon */ + csa =sdata_dereference (ifmsh->csa, sdata); +RCU_INIT_POINTER (ifmsh->csa,NULL ); +kfree_rcu (csa, rcu_head); +} +void ieee80211_stop_mesh (struct ieee80211_sub_if_data *sdata) {struct ieee80211_local *local = sdata->local;
@@ -1225,6 +1240,7 @@ void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata)/* abort any running channel switch */ sdata->vif.bss_conf.csa_active = false; +ieee80211_mesh_reset_csa (sdata);ieee80211_vif_unblock_queues_csa (sdata);/* flush STAs and mpaths on this iface */
@@ -1529,19 +1545,10 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata,int ieee80211_mesh_finish_csa (struct ieee80211_sub_if_data *sdata,u64 *changed) { -struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; -struct mesh_csa_settings *tmp_csa_settings; -int ret =0 ; +int ret; -/* Reset the TTL value and Initiator flag */ - ifmsh->csa_role =IEEE80211_MESH_CSA_ROLE_NONE ; - ifmsh->chsw_ttl =0 ; +ieee80211_mesh_reset_csa (sdata); -/* Remove the CSA and MCSP elements from the beacon */ - tmp_csa_settings =sdata_dereference (ifmsh->csa, sdata); -RCU_INIT_POINTER (ifmsh->csa,NULL ); -if (tmp_csa_settings) -kfree_rcu (tmp_csa_settings, rcu_head); ret =ieee80211_mesh_rebuild_beacon (sdata);if (ret)return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 81/398 wifi: mac80211: mesh: release the channel if start fails
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit ae97fff6495a8764bc0ef281cfe5444f701e527f ]
ieee80211_join_mesh() acquires a channel context and then calls ieee80211_start_mesh(), which can fail. In that case, the chanctx isn't released then interface removal will attempt to unassign it after it's removed from the driver, hitting:
wlan0: Failed check-sdata-in-driver check, flags: 0x0
WARNING: net/mac80211/driver-ops.c:366 at drv_unassign_vif_chanctx ieee80211_assign_link_chanctx __ieee80211_link_release_channel ieee80211_link_release_channel ieee80211_teardown_sdata unregister_netdevice_many_notify _cfg80211_unregister_wdev ieee80211_remove_interfaces ieee80211_unregister_hw mac80211_hwsim_del_radio hwsim_exit_net
Correctly release the channel on start failures.
--- net/mac80211/cfg.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/mac80211/cfg.c +5 -1
@@ -2941,7 +2941,11 @@ static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,if (err)return err; -return ieee80211_start_mesh (sdata); + err =ieee80211_start_mesh (sdata); +if (err) +ieee80211_link_release_channel (&sdata->deflink); + +return err; }static int ieee80211_leave_mesh (struct wiphy *wiphy,struct net_device *dev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 82/398 wifi: mac80211: set up the TX info early to fix failure paths
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 50d3d79dc0743b616afb00d01a626c76758721f7 ]
The previous commit 2c51457d930f ("wifi: mac80211: free ack status frame on TX header build failure") cleaned up the leak, but still left the code a bit messy and the failed SKB didn't get reported to userspace.
Fix this up by initialising skb->cb[] earlier, which allows using ieee80211_free_txskb() and therefore reports it for the failure in ieee80211_build_hdr(), and unifies the ieee80211_skb_resize() failure path with it.
--- net/mac80211/tx.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-)
net/mac80211/tx.c +20 -18
@@ -2926,10 +2926,23 @@ static struct sk_buff *ieee80211_build_hdr(struct ieee80211_sub_if_data *sdata,*/ skb =skb_share_check (skb,GFP_ATOMIC );if (unlikely (!skb)) { - ret = -ENOMEM ; - goto free; +/* skb_share_check() already freed the skb */ +if (info_id) +ieee80211_remove_ack_skb (local, info_id); +return ERR_PTR (-ENOMEM ); } +/* set this up so failure paths can clean up ack skb */ + info =IEEE80211_SKB_CB (skb); +memset (info,0 ,sizeof (*info)); + + info->flags = info_flags; +if (info_id) { + info->status_data = info_id; + info->status_data_idr =1 ; + } + info->band = band; + hdr.frame_control = fc; hdr.duration_id =0 ; hdr.seq_ctrl =0 ;
@@ -2968,10 +2981,8 @@ static struct sk_buff *ieee80211_build_hdr(struct ieee80211_sub_if_data *sdata, head_need += local->tx_headroom; head_need =max_t (int,0 , head_need);if (ieee80211_skb_resize (sdata, skb, head_need,ENCRYPT_DATA )) { -ieee80211_free_txskb (&local->hw, skb); - skb =NULL ; ret = -ENOMEM ; - goto free; + goto free_txskb; } }
@@ -2998,16 +3009,6 @@ static struct sk_buff *ieee80211_build_hdr(struct ieee80211_sub_if_data *sdata,skb_reset_mac_header (skb); - info =IEEE80211_SKB_CB (skb); -memset (info,0 ,sizeof (*info)); - - info->flags = info_flags; -if (info_id) { - info->status_data = info_id; - info->status_data_idr =1 ; - } - info->band = band; -if (likely (!cookie)) { ctrl_flags |=u32_encode_bits (link_id,IEEE80211_TX_CTRL_MLO_LINK );
@@ -3031,16 +3032,17 @@ static struct sk_buff *ieee80211_build_hdr(struct ieee80211_sub_if_data *sdata, pre_conf_link_id, link_id);#endif ret = -EINVAL ; - goto free; + goto free_txskb; } } info->control.flags = ctrl_flags;return skb; + free_txskb: +ieee80211_free_txskb (&local->hw, skb); +return ERR_PTR (ret); free: -if (info_id) -ieee80211_remove_ack_skb (local, info_id);kfree_skb (skb);return ERR_PTR (ret); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 83/398 mm: memblock: show all region flags in debugfs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Meijing Zhao <[email protected]>
[ Upstream commit e2d5b01f878d76bd1142e512a0b979a1d3cd0abf ]
Commit 493f349e38d0 ("memblock: Add flags and nid info in memblock debugfs") made memblock_debug_show() stop after finding the first set flag. A memblock region can carry multiple flags, so the remaining flags are hidden from debugfs.
Walk all bits in the region flags and print every set flag separated by "|". Keep walking beyond flagname[] so that a set flag without a known name is reported as UNKNOWN rather than silently ignored.
--- mm/memblock.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
mm/memblock.c +11 -7
@@ -2727,14 +2727,18 @@ static int memblock_debug_show(struct seq_file *m, void *private)else seq_printf (m,"%4c " ,'x' );if (reg->flags) { -for (j =0 ; j < count; j++) { -if (reg->flags & (1U << j)) { -seq_printf (m,"%s\n" , flagname[j]); -break ; - } +unsigned int flags = reg->flags; +bool first = true; + +for (j =0 ; flags; j++, flags >>=1 ) { +if (!(flags &1 )) +continue ; +if (!first) +seq_putc (m,'|' ); +seq_puts (m, j < count ? flagname[j] :"UNKNOWN" ); + first = false; } -if (j == count) -seq_printf (m,"%s\n" ,"UNKNOWN" ); +seq_putc (m,'\n' ); }else {seq_printf (m,"%s\n" ,"NONE" ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 84/398 scsi: qla2xxx: Fix the ql2xfc2target parameter description
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 779f202a92ef10a426efc07d0f4267918cb07ca3 ]
The module parameter is ql2xfc2target, but its MODULE_PARM_DESC() names qla2xfc2target, so modinfo describes a parameter that does not exist and shows no description for the real one.
Use the parameter name in the description.
--- drivers/scsi/qla2xxx/qla_os.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_os.c +1 -1
@@ -351,7 +351,7 @@ MODULE_PARM_DESC(ql2xnvme_queues,int ql2xfc2target =1 ;module_param (ql2xfc2target, int,0444 ); -MODULE_PARM_DESC (qla2xfc2target, +MODULE_PARM_DESC (ql2xfc2target,"Enables FC2 Target support. " "0 - FC2 Target support is disabled. " "1 - FC2 Target support is enabled (default)." );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 85/398 dmaengine: xilinx_dma: Fix hardware buffer descriptor reuse order
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Bereza <[email protected]>
[ Upstream commit cee9c863ee68cb27d66745eb03f60e357f4f8ad2 ]
xilinx_dma_alloc_chan_resources() builds a static ring of hardware buffer descriptors once and the driver uses this ring throughout the lifetime of a channel. This requires the allocation order of hardware buffer descriptors from chan->free_seg_list to stay in sync with the hardware buffer descriptor ring built at channel allocation time by returning oldest descriptors to chan->free_seg_list first.
When chan->pending_list is not empty e.g. during xilinx_dma_terminate_all() the chan->free_seg_list and the order of the static hardware buffer descriptor ring get out of sync. Descriptors age in this order: pending -> active -> done. So freeing pending_list first returns the newest buffer descriptors to the chan->free_seg_list first and thus breaks the order required by the static hardware buffer descriptor ring. Then when the channel is reused, after a wrap around of the free_seg_list the DMA will find a hardware buffer descriptor with a length field that is still zeroed and stop with something like this:
xilinx-vdma 86000000.dma: Channel 000000003a21d7b8 has errors 10, cdr 6de4c000 tdr 6de4c000
After this no more descriptors are completed and a consumer potentially blocks and waits forever. The only way to get out of this error state is to rebuild the static hardware buffer descriptor ring and the free_seg_list by releasing and re-acquiring the channel.
Fix the order in which hardware buffer descriptors are returned to free_seg_list to ensure the mentioned requirement holds.
--- drivers/dma/xilinx/xilinx_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/xilinx/xilinx_dma.c +1 -1
@@ -918,9 +918,9 @@ static void xilinx_dma_free_descriptors(struct xilinx_dma_chan *chan)spin_lock_irqsave (&chan->lock, flags); -xilinx_dma_free_desc_list (chan, &chan->pending_list);xilinx_dma_free_desc_list (chan, &chan->done_list);xilinx_dma_free_desc_list (chan, &chan->active_list); +xilinx_dma_free_desc_list (chan, &chan->pending_list);spin_unlock_irqrestore (&chan->lock, flags); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 68/398 wifi: cfg80211: restore netns_immutable on failures
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit eeee52cfd1d639774c9812e8890631404a057dd2 ]
Switching a wiphy's netns has to clear netns_immutable before moving interfaces, but then if any of the interfaces fails to move, it gets netns_immutable cleared forever. Then userspace can move it by itself, breaking the assumption that they all move together.
Fix the order here and always reset netns_immutable after attempting the move.
--- net/wireless/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/wireless/core.c +1 -1
@@ -164,9 +164,9 @@ int cfg80211_switch_netns(struct cfg80211_registered_device *rdev,continue ; wdev->netdev->netns_immutable = false; err =dev_change_net_namespace (wdev->netdev, net,"wlan%d" ); + wdev->netdev->netns_immutable = true;if (err)break ; - wdev->netdev->netns_immutable = true; }if (err) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 86/398 dmaengine: xilinx_dma: Fix hardware buffer descriptor chain after cyclic DMA
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Bereza <[email protected]>
[ Upstream commit 7ed1e3070c9b4bbd67d5519e14711038dd53ab13 ]
Using the DMA in cyclic mode modifies the hardware buffer descriptor chain in xilinx_dma_prep_dma_cyclic so that the last descriptor used by the cyclic transfer points back to the first descriptor, but it never restores the original descriptor ring. This breaks using non-cyclic mode after cyclic mode with an error like:
xilinx-vdma 86000000.dma: Channel 00000000354d5c8d has errors 100, cdr 6de40000 tdr 6de40400
The only way to get out of this error state is to rebuild the hardware buffer descriptor ring by releasing and re-acquiring the channel.
Fix using non-cyclic mode after cyclic mode by always restoring the original buffer descriptor ring in the same manner as it is set up by xilinx_dma_alloc_chan_resources().
--- drivers/dma/xilinx/xilinx_dma.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)
drivers/dma/xilinx/xilinx_dma.c +17 -7
@@ -754,15 +754,25 @@ xilinx_aximcdma_alloc_tx_segment(struct xilinx_dma_chan *chan)return segment; } -static void xilinx_dma_clean_hw_desc (struct xilinx_axidma_desc_hw *hw) +static void xilinx_dma_clean_hw_desc (struct xilinx_dma_chan *chan, +struct xilinx_axidma_tx_segment *segment) { -u32 next_desc = hw->next_desc; -u32 next_desc_msb = hw->next_desc_msb; +dma_addr_t next; +u32 i; -memset (hw,0 ,sizeof (struct xilinx_axidma_desc_hw )); +/* +* Restore the buffer descriptor's next descriptor pointer to the value +* set up in xilinx_dma_alloc_chan_resources(). Otherwise using the DMA +* in cyclic mode leaves the next descriptor pointer altered and +* prevents subsequent non-cyclic transfers. +*/ + i = segment - chan->seg_v; + next = chan->seg_p + +sizeof (*chan->seg_v) * ((i +1 ) %XILINX_DMA_NUM_DESCS ); - hw->next_desc = next_desc; - hw->next_desc_msb = next_desc_msb; +memset (&segment->hw,0 ,sizeof (segment->hw)); + segment->hw.next_desc =lower_32_bits (next); + segment->hw.next_desc_msb =upper_32_bits (next); }static void xilinx_mcdma_clean_hw_desc (struct xilinx_aximcdma_desc_hw *hw)
@@ -784,7 +794,7 @@ static void xilinx_mcdma_clean_hw_desc(struct xilinx_aximcdma_desc_hw *hw)static void xilinx_dma_free_tx_segment (struct xilinx_dma_chan *chan,struct xilinx_axidma_tx_segment *segment) { -xilinx_dma_clean_hw_desc (&segment->hw); +xilinx_dma_clean_hw_desc (chan, segment);list_add_tail (&segment->node, &chan->free_seg_list); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 87/398 RDMA/efa: Keep admin queues alive while IRQ is registered
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit e08aca85c02ff290f785f07acae758f0daf5f49e ]
The management IRQ handler accesses both the admin completion queue and the async event queue. The driver registered the IRQ before constructing these queues and destroyed them before freeing the IRQ, so the handler's lifetime was not contained by the resources it accesses.
Initialize the queues with interrupts masked, request the IRQ, and then switch to interrupt mode. On removal, reset the device and free the IRQ before destroying the queues. Also reset the device before destroying the queues if IRQ registration fails, because the device already has their DMA addresses.
--- drivers/infiniband/hw/efa/efa_com.c | 4 +--- drivers/infiniband/hw/efa/efa_main.c | 15 +++++++++------ 2 files changed, 10 insertions(+), 9 deletions(-)
drivers/infiniband/hw/efa/efa_com.c +1 -3
@@ -750,7 +750,7 @@ int efa_com_admin_init(struct efa_com_dev *edev, aq->dmadev = edev->dmadev; aq->efa_dev = edev->efa_dev; -set_bit (EFA_AQ_STATE_POLLING_BIT , &aq->state); +efa_com_set_admin_polling_mode (edev, true);sema_init (&aq->avail_cmds, aq->depth);
@@ -768,8 +768,6 @@ int efa_com_admin_init(struct efa_com_dev *edev,if (err) goto err_destroy_sq; -efa_com_set_admin_polling_mode (edev, false); - err =efa_com_admin_init_aenq (edev, aenq_handlers);if (err) goto err_destroy_cq;
drivers/infiniband/hw/efa/efa_main.c +9 -6
@@ -611,18 +611,21 @@ static struct efa_dev *efa_probe_device(struct pci_dev *pdev) edev->aq.msix_vector_idx = dev->admin_msix_vector_idx; edev->aenq.msix_vector_idx = dev->admin_msix_vector_idx; - err =efa_set_mgmnt_irq (dev); + err =efa_com_admin_init (edev, &aenq_handlers);if (err) goto err_disable_msix; - err =efa_com_admin_init (edev, &aenq_handlers); + err =efa_set_mgmnt_irq (dev);if (err) - goto err_free_mgmnt_irq; + goto err_destroy_admin; + +efa_com_set_admin_polling_mode (edev, false);return dev; -err_free_mgmnt_irq: -efa_free_irq (dev, &dev->admin_irq); +err_destroy_admin: +efa_com_dev_reset (edev,EFA_REGS_RESET_INIT_ERR ); +efa_com_admin_destroy (edev); err_disable_msix:efa_disable_msix (dev); err_reg_read_destroy:
@@ -646,8 +649,8 @@ static void efa_remove_device(struct pci_dev *pdev, edev = &dev->edev;efa_com_dev_reset (edev, reset_reason); -efa_com_admin_destroy (edev);efa_free_irq (dev, &dev->admin_irq); +efa_com_admin_destroy (edev);efa_disable_msix (dev);efa_com_mmio_reg_read_destroy (edev);devm_iounmap (&pdev->dev, edev->reg_bar);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 88/398 RDMA/efa: Keep EQ resources alive while IRQ is registered
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit e22a3627b7151754f07f90ea3d1ab6e85f5d93f4 ]
The completion IRQ handler accesses the EQ state and DMA buffer. Its IRQ was registered before that state was initialized, while teardown released the buffer before free_irq() synchronized the handler.
Initialize the EQ without arming it, register the IRQ, and then arm it. Reverse the resource order during teardown by freeing the IRQ before destroying the EQ.
--- drivers/infiniband/hw/efa/efa_com.c | 3 +-- drivers/infiniband/hw/efa/efa_com.h | 1 + drivers/infiniband/hw/efa/efa_main.c | 18 ++++++++++-------- 3 files changed, 12 insertions(+), 10 deletions(-)
drivers/infiniband/hw/efa/efa_com.c +1 -2
@@ -1156,7 +1156,7 @@ static void efa_com_destroy_eq(struct efa_com_dev *edev, err); } -static void efa_com_arm_eq (struct efa_com_dev *edev,struct efa_com_eq *eeq) +void efa_com_arm_eq (struct efa_com_dev *edev,struct efa_com_eq *eeq) {u32 val =0 ;
@@ -1245,7 +1245,6 @@ int efa_com_eq_init(struct efa_com_dev *edev, struct efa_com_eq *eeq, eeq->phase =1 ; eeq->depth = params.depth; eeq->cb = cb; -efa_com_arm_eq (edev, eeq);return 0 ;
drivers/infiniband/hw/efa/efa_com.h +1 -0
@@ -157,6 +157,7 @@ int efa_com_admin_init(struct efa_com_dev *edev,void efa_com_admin_destroy (struct efa_com_dev *edev);int efa_com_eq_init (struct efa_com_dev *edev,struct efa_com_eq *eeq,efa_eqe_handler cb,u16 depth,u8 msix_vec); +void efa_com_arm_eq (struct efa_com_dev *edev,struct efa_com_eq *eeq);void efa_com_eq_destroy (struct efa_com_dev *edev,struct efa_com_eq *eeq);int efa_com_dev_reset (struct efa_com_dev *edev,enum efa_regs_reset_reason_types reset_reason);
drivers/infiniband/hw/efa/efa_main.c +10 -8
@@ -300,28 +300,30 @@ static void efa_set_host_info(struct efa_dev *dev)static void efa_destroy_eq (struct efa_dev *dev,struct efa_eq *eq) { -efa_com_eq_destroy (&dev->edev, &eq->eeq);efa_free_irq (dev, &eq->irq); +efa_com_eq_destroy (&dev->edev, &eq->eeq); }static int efa_create_eq (struct efa_dev *dev,struct efa_eq *eq,u32 msix_vec) {int err; -efa_setup_comp_irq (dev, eq, msix_vec); - err =efa_request_irq (dev, &eq->irq); + err =efa_com_eq_init (&dev->edev, &eq->eeq, efa_process_eqe, + dev->dev_attr.max_eq_depth, msix_vec);if (err)return err; - err =efa_com_eq_init (&dev->edev, &eq->eeq, efa_process_eqe, - dev->dev_attr.max_eq_depth, msix_vec); +efa_setup_comp_irq (dev, eq, msix_vec); + err =efa_request_irq (dev, &eq->irq);if (err) - goto err_free_comp_irq; + goto err_destroy_eq; + +efa_com_arm_eq (&dev->edev, &eq->eeq);return 0 ; -err_free_comp_irq: -efa_free_irq (dev, &eq->irq); +err_destroy_eq: +efa_com_eq_destroy (&dev->edev, &eq->eeq);return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 89/398 RDMA/siw: Bound fragmented header copies by the remaining length
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
[ Upstream commit 9ff797e516dbc1ecb73701ec4c24055712d44411 ]
siw_get_hdr() can receive an extended DDP/RDMAP header across more than one TCP callback. The first callback may receive most of the header, while the next one still limits the copy to hdrlen - MIN_DDP_HDR instead of the number of missing bytes. This makes the destination move past the end of the header and overwrite the receive state, including fpdu_part_rcvd. A later callback can then use a negative fpdu_part_rcvd value as a copy offset, which creates an OOB write.
Use the number of header bytes already received when calculating the next copy length.
--- drivers/infiniband/sw/siw/siw_qp_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/siw/siw_qp_rx.c +1 -1
@@ -1079,7 +1079,7 @@ static int siw_get_hdr(struct siw_rx_stream *srx)if (iwarp_pktinfo[opcode].hdr_len >sizeof (struct iwarp_ctrl_tagged )) {int hdrlen = iwarp_pktinfo[opcode].hdr_len; - bytes =min_t (int, hdrlen -MIN_DDP_HDR , srx->skb_new); + bytes =min_t (int, hdrlen - srx->fpdu_part_rcvd, srx->skb_new);skb_copy_bits (skb, srx->skb_offset, (char *)c_hdr + srx->fpdu_part_rcvd, bytes);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 90/398 drm/msm: Fix the separate_gpu_kms parameter description
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit adf5967331318bcb436fc80069915231ec039352 ]
The module parameter is separate_gpu_kms, but its MODULE_PARM_DESC() names separate_gpu_drm, so modinfo describes a parameter that does not exist and shows no description for the real one.
Use the parameter name in the description.
Patchwork: https://patchwork.freedesktop.org/patch/751407/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/msm_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_drv.c +1 -1
@@ -55,7 +55,7 @@ MODULE_PARM_DESC(modeset, "Use kernel modesetting [KMS] (1=on (default), 0=disabmodule_param (modeset, bool,0600 );static bool separate_gpu_kms; -MODULE_PARM_DESC (separate_gpu_drm,"Use separate DRM device for the GPU (0=single DRM device for both GPU and display (default), 1=two DRM devices)" ); +MODULE_PARM_DESC (separate_gpu_kms,"Use separate DRM device for the GPU (0=single DRM device for both GPU and display (default), 1=two DRM devices)" );module_param (separate_gpu_kms, bool,0400 );DECLARE_FAULT_ATTR (fail_gem_alloc);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 91/398 drm/msm/adreno: Fix the skip_gpu parameter description
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 8061ee61b9426fe38350fa9eead2d9c50b03deb6 ]
The module parameter is skip_gpu, but its MODULE_PARM_DESC() names no_gpu, so modinfo describes a parameter that does not exist and shows no description for the real one.
Use the parameter name in the description.
Patchwork: https://patchwork.freedesktop.org/patch/751406/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/adreno/adreno_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/adreno_device.c +1 -1
@@ -25,7 +25,7 @@ MODULE_PARM_DESC(disable_acd, "Forcefully disable GPU ACD");module_param_unsafe (disable_acd, bool,0400 );static bool skip_gpu; -MODULE_PARM_DESC (no_gpu,"Disable GPU driver register (0=enable GPU driver register (default), 1=skip GPU driver register" ); +MODULE_PARM_DESC (skip_gpu,"Disable GPU driver register (0=enable GPU driver register (default), 1=skip GPU driver register" );module_param (skip_gpu, bool,0400 );extern const struct adreno_gpulist a2xx_gpulist;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 92/398 netfilter: nft_nat: fully initialise new_addr in netmap setup
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodor Arsenij Larionov Trichkine <[email protected]>
[ Upstream commit d313499df66159b4b7971d760d16729598ab7e5a ]
nft_nat_setup_netmap() builds the mapped address in an on-stack union nf_inet_addr. For an IPv4 mapping it writes only the 4-byte .ip member and the loop runs a single 32-bit iteration, but it then copies the whole 16-byte union into range->min_addr and range->max_addr, so the upper 12 bytes reach nf_nat_setup_info() uninitialised.
KMSAN reports an uninit-value in nf_nat_setup_info() reached from nft_nat_eval(). The IPv6 path fills all 16 bytes and is not affected.
Zero-initialise new_addr.
--- net/netfilter/nft_nat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nft_nat.c +1 -1
@@ -64,8 +64,8 @@ static void nft_nat_setup_netmap(struct nf_nat_range2 *range,const struct nft_pktinfo *pkt, const struct nft_nat *priv) { + union nf_inet_addr new_addr = {};struct sk_buff *skb = pkt->skb; -union nf_inet_addr new_addr;__be32 netmask;int i, len =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 93/398 netfilter: nf_tables: fix device name and prefix match in hook lookup
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fernando Fernandez Mancera <[email protected]>
[ Upstream commit 444e4c88c9c62a3d823069006563513fe7d5aa66 ]
Currently, a netdev chain or flowtable hooked to a device prefix can be unintentionally deleted by a control-plane request targeting an exact device name or even a shorter one due to the usage of min() to calculate the length to match.
Fix this by making sure an exact device match never matches a prefix and that both the target and the candidate have the same length during delete operation. The add and update paths retain the existing overlap matching to prevent a single device from matching multiple hooks.
--- net/netfilter/nf_tables_api.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
net/netfilter/nf_tables_api.c +13 -9
@@ -2343,11 +2343,14 @@ static struct nft_hook *nft_netdev_hook_alloc(struct net *net, }static struct nft_hook *nft_hook_list_find (struct list_head *hook_list, -const struct nft_hook *this) +const struct nft_hook *this, +bool strict) {struct nft_hook *hook;list_for_each_entry (hook, hook_list, list) { +if (strict && hook->ifnamelen != this->ifnamelen) +continue ;if (!strncmp (hook->ifname, this->ifname,min (hook->ifnamelen, this->ifnamelen)))return hook;
@@ -2385,7 +2388,7 @@ static int nf_tables_parse_netdev_hooks(struct net *net, err =PTR_ERR (hook); goto err_hook; } -if (nft_hook_list_find (hook_list, hook)) { +if (nft_hook_list_find (hook_list, hook, false)) {NL_SET_BAD_ATTR (extack, tmp);nft_netdev_hook_free (hook); err = -EEXIST ;
@@ -2842,7 +2845,7 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy, ops->hook = basechain->ops.hook; } -if (nft_hook_list_find (&basechain->hook_list, h)) { +if (nft_hook_list_find (&basechain->hook_list, h, false)) {list_del (&h->list);nft_netdev_hook_free (h);continue ;
@@ -2855,7 +2858,8 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy, !nft_trans_chain_update(trans))continue ; -if (nft_hook_list_find (&nft_trans_chain_hooks (trans), h)) { +if (nft_hook_list_find (&nft_trans_chain_hooks (trans), + h, false)) {nft_chain_release_hook (&hook);return -EEXIST ; }
@@ -3130,7 +3134,7 @@ static int nft_delchain_hook(struct nft_ctx *ctx,return err;list_for_each_entry (this, &chain_hook.list, list) { - hook =nft_hook_list_find (&basechain->hook_list, this); + hook =nft_hook_list_find (&basechain->hook_list, this, true);if (!hook) { err = -ENOENT ; goto err_chain_del_hook;
@@ -8921,7 +8925,7 @@ static int nft_register_flowtable_net_hooks(struct net *net,if (!nft_is_active_next (net, ft))continue ; -if (nft_hook_list_find (&ft->hook_list, hook)) { +if (nft_hook_list_find (&ft->hook_list, hook, false)) { err = -EEXIST ; goto err_unregister_net_hooks; }
@@ -8980,7 +8984,7 @@ static int nft_flowtable_update(struct nft_ctx *ctx, const struct nlmsghdr *nlh,return err;list_for_each_entry_safe (hook, next, &flowtable_hook.list, list) { -if (nft_hook_list_find (&flowtable->hook_list, hook)) { +if (nft_hook_list_find (&flowtable->hook_list, hook, false)) {list_del (&hook->list);nft_netdev_hook_free (hook);continue ;
@@ -8993,7 +8997,7 @@ static int nft_flowtable_update(struct nft_ctx *ctx, const struct nlmsghdr *nlh, !nft_trans_flowtable_update(trans))continue ; -if (nft_hook_list_find (&nft_trans_flowtable_hooks (trans), hook)) { +if (nft_hook_list_find (&nft_trans_flowtable_hooks (trans), hook, false)) { err = -EEXIST ; goto err_flowtable_update_hook; }
@@ -9213,7 +9217,7 @@ static int nft_delflowtable_hook(struct nft_ctx *ctx,return err;list_for_each_entry (this, &flowtable_hook.list, list) { - hook =nft_hook_list_find (&flowtable->hook_list, this); + hook =nft_hook_list_find (&flowtable->hook_list, this, true);if (!hook) { err = -ENOENT ; goto err_flowtable_del_hook;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 94/398 netfilter: nf_nat: unregister and release hooks on error
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit cbdd39ce42530a193c56beb206a3356cb6d01016 ]
If nf_hook_entries_insert_raw() fails, the NAT hooks get never released, resulting in a memleak.
Postpone setting nat_proto_net->nat_hook_ops when the hooks are registered to simplify the error path to decide whether the nat hooks need unwinding.
--- net/netfilter/nf_nat_core.c | 46 ++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 16 deletions(-)
net/netfilter/nf_nat_core.c +30 -16
@@ -1236,31 +1236,45 @@ int nf_nat_register_fn(struct net *net, u8 pf, const struct nf_hook_ops *ops, } ret =nf_register_net_hooks (net, nat_ops, ops_count); -if (ret <0 ) { -mutex_unlock (&nf_nat_proto_mutex); -for (i =0 ; i < ops_count; i++) { - priv = nat_ops[i].priv; -kfree_rcu (priv, rcu_head); - } -kfree_rcu (nat_ops, rcu); -return ret; - } - - nat_proto_net->nat_hook_ops = nat_ops; +if (ret <0 ) + goto err_free_hooks; + }else { + nat_ops = nat_proto_net->nat_hook_ops; } - nat_ops = nat_proto_net->nat_hook_ops; priv = nat_ops[hooknum].priv;if (WARN_ON_ONCE (!priv)) { -mutex_unlock (&nf_nat_proto_mutex); -return -EOPNOTSUPP ; + ret = -EOPNOTSUPP ; + goto err_unregister_hooks; } ret =nf_hook_entries_insert_raw (&priv->entries, ops); -if (ret ==0 ) - nat_proto_net->users++; +if (ret) + goto err_unregister_hooks; + +if (!nat_proto_net->nat_hook_ops) + nat_proto_net->nat_hook_ops = nat_ops; + + nat_proto_net->users++;mutex_unlock (&nf_nat_proto_mutex); + +return 0 ; + +err_unregister_hooks: +if (nat_proto_net->nat_hook_ops) { +mutex_unlock (&nf_nat_proto_mutex); +return ret; + } +nf_unregister_net_hooks (net, nat_ops, ops_count); +err_free_hooks: +mutex_unlock (&nf_nat_proto_mutex); +for (i =0 ; i < ops_count; i++) { + priv = nat_ops[i].priv; +kfree_rcu (priv, rcu_head); + } +kfree_rcu (nat_ops, rcu); +return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 95/398 netfilter: flowtable: hold reference on ct until flow is released
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit e75a9fa1d44bcbd66ea02e8781bcca6ea4076e0d ]
nf_ct_put() releases the ct->ext area inmediately, the rcu typesafe semantics also allow to refer to the wrong conntrack from the flowtable datapath. Hold reference on ct until flow is released after rcu grace period.
Add rcu_barrier() on module exit path, to ensure pending flow entries are release before module goes away.
--- net/netfilter/nf_flow_table_core.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
net/netfilter/nf_flow_table_core.c +10 -2
@@ -250,6 +250,14 @@ static void flow_offload_route_release(struct flow_offload *flow)nft_flow_dst_release (flow,FLOW_OFFLOAD_DIR_REPLY ); } +static void flow_offload_free_rcu (struct rcu_head *rcu_head) +{ + struct flow_offload *flow = container_of(rcu_head, struct flow_offload, rcu_head); + +nf_ct_put (flow->ct); +kfree (flow); +} +void flow_offload_free (struct flow_offload *flow) {switch (flow->type) {
@@ -259,8 +267,7 @@ void flow_offload_free(struct flow_offload *flow)default :break ; } -nf_ct_put (flow->ct); -kfree_rcu (flow, rcu_head); +call_rcu (&flow->rcu_head, flow_offload_free_rcu); }EXPORT_SYMBOL_GPL (flow_offload_free);
@@ -839,6 +846,7 @@ static int __init nf_flow_table_module_init(void) static void __exit nf_flow_table_module_exit(void) { +rcu_barrier ();nf_flow_table_offload_exit ();unregister_pernet_subsys (&nf_flow_table_net_ops); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 69/398 wifi: cfg80211: undo netns switch if renaming the wiphy fails
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit a41bd1938a9bfe226d444172a7e20e4bd5097960 ]
Once all the interfaces have been moved, cfg80211_switch_netns() moves the wiphy itself by setting its network namespace and then renaming it, which makes sysfs move it. The rename can fail (but only on allocation failures), leaving things mixed up and hitting the warning there.
Ignoring it isn't great, undo the move and let the change fail in this case. If undo fails then WARN, then things would again be stuck in two different network namespaces.
--- net/wireless/core.c | 88 +++++++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 38 deletions(-)
net/wireless/core.c +50 -38
@@ -150,9 +150,25 @@ int cfg80211_dev_rename(struct cfg80211_registered_device *rdev,return 0 ; } +static int cfg80211_switch_wdev_netns (struct wireless_dev *wdev, +struct net *net) +{ +int err; + +if (!wdev->netdev) +return 0 ; + + wdev->netdev->netns_immutable = false; + err =dev_change_net_namespace (wdev->netdev, net,"wlan%d" ); + wdev->netdev->netns_immutable = true; + +return err; +} +int cfg80211_switch_netns (struct cfg80211_registered_device *rdev,struct net *net) { +struct net *old_net =wiphy_net (&rdev->wiphy);struct wireless_dev *wdev;int err =0 ;
@@ -160,58 +176,54 @@ int cfg80211_switch_netns(struct cfg80211_registered_device *rdev,return -EOPNOTSUPP ;list_for_each_entry (wdev, &rdev->wiphy.wdev_list, list) { -if (!wdev->netdev) -continue ; - wdev->netdev->netns_immutable = false; - err =dev_change_net_namespace (wdev->netdev, net,"wlan%d" ); - wdev->netdev->netns_immutable = true; + err =cfg80211_switch_wdev_netns (wdev, net);if (err) -break ; + goto undo; } -if (err) { -/* failed -- clean up to old netns */ - net =wiphy_net (&rdev->wiphy); - -list_for_each_entry_continue_reverse (wdev, - &rdev->wiphy.wdev_list, - list) { + scoped_guard(wiphy, &rdev->wiphy) { +list_for_each_entry (wdev, &rdev->wiphy.wdev_list, list) {if (!wdev->netdev)continue ; - wdev->netdev->netns_immutable = false; - err =dev_change_net_namespace (wdev->netdev, net, -"wlan%d" ); -WARN_ON (err); - wdev->netdev->netns_immutable = true; +nl80211_notify_iface (rdev, wdev, +NL80211_CMD_DEL_INTERFACE ); } -return err; - } +nl80211_notify_wiphy (rdev,NL80211_CMD_DEL_WIPHY ); -guard (wiphy)(&rdev->wiphy); +wiphy_net_set (&rdev->wiphy, net); -list_for_each_entry (wdev, &rdev->wiphy.wdev_list, list) { -if (!wdev->netdev) -continue ; -nl80211_notify_iface (rdev, wdev,NL80211_CMD_DEL_INTERFACE ); - } - -nl80211_notify_wiphy (rdev,NL80211_CMD_DEL_WIPHY ); +/* this only fails on allocation failure */ + err =device_rename (&rdev->wiphy.dev, +dev_name (&rdev->wiphy.dev)); +if (err) +wiphy_net_set (&rdev->wiphy, old_net); -wiphy_net_set (&rdev->wiphy, net); +nl80211_notify_wiphy (rdev,NL80211_CMD_NEW_WIPHY ); - err =device_rename (&rdev->wiphy.dev,dev_name (&rdev->wiphy.dev)); -WARN_ON (err); +list_for_each_entry (wdev, &rdev->wiphy.wdev_list, list) { +if (!wdev->netdev) +continue ; +nl80211_notify_iface (rdev, wdev, +NL80211_CMD_NEW_INTERFACE ); + } + } -nl80211_notify_wiphy (rdev,NL80211_CMD_NEW_WIPHY ); +if (!err) +return 0 ; -list_for_each_entry (wdev, &rdev->wiphy.wdev_list, list) { -if (!wdev->netdev) -continue ; -nl80211_notify_iface (rdev, wdev,NL80211_CMD_NEW_INTERFACE ); - } +/* set to the last one to undo all of them */ + wdev =list_entry (&rdev->wiphy.wdev_list,typeof (*wdev), list); +undo: +/* +* Move back everything, if this fails again (allocation failures) +* then things get stuck in different network namespaces. +*/ +list_for_each_entry_continue_reverse (wdev, &rdev->wiphy.wdev_list, + list) +WARN_ON (cfg80211_switch_wdev_netns (wdev, old_net)); -return 0 ; +return err; }static void cfg80211_rfkill_poll (struct rfkill *rfkill,void *data)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 96/398 perf/arm-cmn: Fix wp_dev_sel2 setting for multi-DTM configurations
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shouping Wang <[email protected]>
[ Upstream commit 49daa3d668b69a5454b5aba0078848a479f79f1c ]
When MXP_MULTIPLE_DTM_EN is TRUE, each DTM will monitor at most two device ports. In this case, {wp_dev_sel2, wp_dev_sel} will only use values 2'b00 and 2'b01 per DTM.
Previously the setting allowed values beyond the supported range per DTM, which could cause each DTM to select invalid ports when MXP_MULTIPLE_DTM_EN is TRUE.
Fix this by only setting CMN_DTM_WPn_CONFIG_WP_DEV_SEL2 when !multi_dtm.
--- drivers/perf/arm-cmn.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/perf/arm-cmn.c +7 -3
@@ -1393,13 +1393,14 @@ static void arm_cmn_claim_wp_idx(struct arm_cmn_dtm *dtm,static u32 arm_cmn_wp_config (struct perf_event *event,int wp_idx) { +struct arm_cmn *cmn =to_cmn (event->pmu);u32 config;u32 dev =CMN_EVENT_WP_DEV_SEL (event);u32 chn =CMN_EVENT_WP_CHN_SEL (event);u32 grp =CMN_EVENT_WP_GRP (event);u32 exc =CMN_EVENT_WP_EXCLUSIVE (event);u32 combine =CMN_EVENT_WP_COMBINE (event); -bool is_cmn600 =to_cmn (event->pmu)->part ==PART_CMN600 ; +bool is_cmn600 = cmn->part ==PART_CMN600 ;/* CMN-600 supports only primary and secondary matching groups */ if (is_cmn600)
@@ -1407,8 +1408,11 @@ static u32 arm_cmn_wp_config(struct perf_event *event, int wp_idx) config =FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_DEV_SEL, dev) |FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_CHN_SEL, chn) | -FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_GRP, grp) | -FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_DEV_SEL2, dev >>1 ); +FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_GRP, grp); + +if (!cmn->multi_dtm) + config |=FIELD_PREP (CMN_DTM_WPn_CONFIG_WP_DEV_SEL2, dev >>1 ); +if (exc) config |= is_cmn600 ? CMN600_WPn_CONFIG_WP_EXCLUSIVE : CMN_DTM_WPn_CONFIG_WP_EXCLUSIVE;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 97/398 arm64: hibernate: clone only the linear map that exists at runtime
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit e4a6f57d22e079e23fafac51057fad534160b269 ]
This is similar to commit 1537e55728ec2 ("arm64: trans_pgd: clone only the linear map that exists at runtime"), but in a different place.
swsusp_arch_resume() clones the kernel linear map with trans_pgd_create_copy(..., PAGE_OFFSET, PAGE_END). PAGE_OFFSET comes from the compile-time VA_BITS, so a CONFIG_ARM64_VA_BITS_52 kernel booting on hardware without LPA2 -- vabits_actual is 48 and the fifth level is folded -- hands the walk a 3.9PB window while its linear map only spans the top 128TB.
On a VA_BITS_52 4k kernel with CONFIG_KASAN_GENERIC in a 4GB VM, I see:
swapper/0: page allocation failure: order:0, mode:0x920(GFP_ATOMIC|__GFP_ZERO)
hibernate_page_alloc+0x10/0x1c swsusp_arch_resume+0x70/0x320 hibernation_restore+0xa4/0x138 software_resume+0x15c/0x270 PM: hibernation: Failed to load image, recovering. PM: hibernation: resume failed (-12)
Fix it by copying the linear map that is the actual one, not the compiled one.
--- arch/arm64/kernel/hibernate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kernel/hibernate.c +2 -2
@@ -423,8 +423,8 @@ int __nocfi swsusp_arch_resume(void)* Create a second copy of just the linear map, and use this when * restoring. */ - rc =trans_pgd_create_copy (&trans_info, &tmp_pg_dir,PAGE_OFFSET , -PAGE_END ); + rc =trans_pgd_create_copy (&trans_info, &tmp_pg_dir, +_PAGE_OFFSET (vabits_actual),PAGE_END );if (rc)return rc;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 98/398 drm: Fix drm_pending_vblank_event leak in error path for out_fence_ptr
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thadeu Lima de Souza Cascardo <[email protected]>
[ Upstream commit 9eb1a393c89a79c4210230d23e7d88d239c61d7b ]
When an out_fence_ptr is provided but DRM_MODE_PAGE_FLIP_EVENT is not set, a drm_pending_vblank_event will be allocated. If later, there is an allocation failure or another failure at setup_out_fence(), that event will not have base.fence set and it will not be released at complete_signaling().
Release the event and set crtc_state->event to NULL just like in the DRM_MODE_PAGE_FLIP_EVENT case when there is a failure at drm_event_reserve_init(). That is, prepare_signaling() releases the event and there is nothing to be done at complete_signaling(). Use drm_event_cancel_free() as that will also undo drm_event_reserve_init() in case it has been called.
--- drivers/gpu/drm/drm_atomic_uapi.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_atomic_uapi.c +10 -3
@@ -1244,10 +1244,12 @@ static int prepare_signaling(struct drm_device *dev,struct dma_fence *fence;struct drm_out_fence_state *f; + ret = -ENOMEM ; + f =krealloc (*fence_state,sizeof (**fence_state) * (*num_fences +1 ),GFP_KERNEL );if (!f) -return -ENOMEM ; + goto err_free_event;memset (&f[*num_fences],0 ,sizeof (*f));
@@ -1256,12 +1258,12 @@ static int prepare_signaling(struct drm_device *dev, fence =drm_crtc_create_fence (crtc);if (!fence) -return -ENOMEM ; + goto err_free_event; ret =setup_out_fence (&f[(*num_fences)++], fence);if (ret) {dma_fence_put (fence); -return ret; + goto err_free_event; } crtc_state->event->base.fence = fence;
@@ -1317,6 +1319,11 @@ static int prepare_signaling(struct drm_device *dev, }return 0 ; + +err_free_event: +drm_event_cancel_free (dev, &crtc_state->event->base); + crtc_state->event =NULL ; +return ret; } static void complete_signaling(struct drm_device *dev,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 99/398 keys: fix lost wakeup when reaping a dead key type
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 2725ab3f5ad1c5f375c7c9fee4af02a9b138f701 ]
clear_bit() is atomic with respect to the word it modifies, but it is an unordered operation: it implies no memory barrier on either side (Documentation/atomic_bitops.txt).
key_garbage_collector() clears KEY_GC_REAPING_KEYTYPE with clear_bit() and calls wake_up_bit() after reaping a dead key type. wake_up_bit() uses a lockless waitqueue check and requires a full barrier after the clear.
The existing smp_mb() is before clear_bit(), so nothing orders the clear against that check. The GC can see an empty waitqueue while unregister_key_type() still sees the bit set. The final wakeup is then lost, leaving module unload stuck in wait_on_bit().
Use clear_and_wake_up_bit(). Its clear_bit_unlock() has RELEASE semantics, so the completed GC work stays ordered before the clear, and its smp_mb__after_atomic() orders the clear before the waitqueue check.
--- security/keys/gc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
security/keys/gc.c +1 -3
@@ -318,9 +318,7 @@ static void key_garbage_collector(struct work_struct *work)if (unlikely (gc_state &KEY_GC_REAPING_DEAD_3 )) {kdebug ("dead wake" ); -smp_mb (); -clear_bit (KEY_GC_REAPING_KEYTYPE , &key_gc_flags); -wake_up_bit (&key_gc_flags,KEY_GC_REAPING_KEYTYPE ); +clear_and_wake_up_bit (KEY_GC_REAPING_KEYTYPE , &key_gc_flags); }if (gc_state &KEY_GC_REAP_AGAIN )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 70/398 wifi: mac80211: unlist vifs when their netdev is unregistered
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit eee2efd82867b623982ac51925b5a1812a74c50d ]
mac80211 only removes vifs from the local->interfaces list when an interface is removed via ieee80211_if_remove(), before it unregisters the netdev. However, it's possible for a netdev to be unregistered without going through that: When the netns that holds the wiphy is destroyed, the wiphy is supposed to move to the init_ns, but that can run into allocation failures.
Then, mac80211 has an interface listed that doesn't exist, and will eventually hit
BUG: failure at net/wireless/core.h:141/wiphy_to_rdev()! ... _cfg80211_unregister_wdev+0x24/0x36a [cfg80211] cfg80211_unregister_wdev+0x15/0x1d [cfg80211] ieee80211_remove_interfaces+0x1ff/0x257 [mac80211] ieee80211_unregister_hw+0x73/0x1d1 [mac80211] mac80211_hwsim_del_radio+0x114/0x166 [mac80211_hwsim]
Remove the interface from the list in ->ndo_uninit if it's still around to avoid this.
--- net/mac80211/iface.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
net/mac80211/iface.c +25 -1
@@ -885,9 +885,33 @@ static void ieee80211_teardown_sdata(struct ieee80211_sub_if_data *sdata)ieee80211_link_stop (&sdata->deflink); } +/* +* The netdev can be unregistered without mac80211 doing it, e.g. by the netdev +* core when cfg80211 couldn't move it out of a network namespace that's being +* destroyed. Drop it from the interface list either way. +*/ +static void ieee80211_unlist_sdata (struct ieee80211_sub_if_data *sdata) +{ +struct ieee80211_local *local = sdata->local; +struct ieee80211_sub_if_data *iter; + +ASSERT_RTNL (); + +list_for_each_entry (iter, &local->interfaces, list) { +if (iter != sdata) +continue ; +guard (mutex)(&local->iflist_mtx); +list_del_rcu (&sdata->list); +return ; + } +} +static void ieee80211_uninit (struct net_device *dev) { -ieee80211_teardown_sdata (IEEE80211_DEV_TO_SUB_IF (dev)); +struct ieee80211_sub_if_data *sdata =IEEE80211_DEV_TO_SUB_IF (dev); + +ieee80211_unlist_sdata (sdata); +ieee80211_teardown_sdata (sdata); } static int ieee80211_netdev_setup_tc(struct net_device *dev,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 71/398 wifi: cfg80211: get the wiphy out of a dying network namespace
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 4635b1a1c1d693178a537446a6e09963f0fdae52 ]
When a network namespace is destroyed, cfg80211_pernet_exit() moves any wiphy back to the initial namespace, and just warns if that fails. But moving an interface can fail (due to allocation failures), and then the wiphy is left behind with a garbage netns pointer:
Kernel mode fault at addr 0x30
genlmsg_multicast_netns.constprop.0+0x46/0xcf [cfg80211] nl80211_notify_wiphy+0xcd/0xe8 [cfg80211] wiphy_unregister+0x169/0x3fc [cfg80211]
Note that commit debac3a20dec ("net: Remove conflicting altnames for dying netns in __dev_change_net_namespace().") fixed another path that could reach it without allocation failures.
Remove interfaces that cannot be moved instead of failing the switch, so that the wiphy always ends up in the initial namespace. In this case the netdev core will unregister the interfaces anyway.
--- net/wireless/core.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-)
net/wireless/core.c +25 -12
@@ -165,20 +165,24 @@ static int cfg80211_switch_wdev_netns(struct wireless_dev *wdev,return err; } -int cfg80211_switch_netns (struct cfg80211_registered_device *rdev, -struct net *net) +static int __cfg80211_switch_netns (struct cfg80211_registered_device *rdev, +struct net *net,bool force) {struct net *old_net =wiphy_net (&rdev->wiphy); -struct wireless_dev *wdev; +struct wireless_dev *wdev, *tmp;int err =0 ; -if (!(rdev->wiphy.flags &WIPHY_FLAG_NETNS_OK )) -return -EOPNOTSUPP ; - -list_for_each_entry (wdev, &rdev->wiphy.wdev_list, list) { +list_for_each_entry_safe (wdev, tmp, &rdev->wiphy.wdev_list, list) { err =cfg80211_switch_wdev_netns (wdev, net); -if (err) +if (!err) +continue ; +if (!force) goto undo; +/* remove interfaces that fail to allow wiphy switching */ +dev_close (wdev->netdev); + scoped_guard(wiphy, &rdev->wiphy) +cfg80211_unregister_wdev (wdev); + err =0 ; } scoped_guard(wiphy, &rdev->wiphy) {
@@ -196,7 +200,7 @@ int cfg80211_switch_netns(struct cfg80211_registered_device *rdev,/* this only fails on allocation failure */ err =device_rename (&rdev->wiphy.dev,dev_name (&rdev->wiphy.dev)); -if (err) +if (err && !force)wiphy_net_set (&rdev->wiphy, old_net);nl80211_notify_wiphy (rdev,NL80211_CMD_NEW_WIPHY );
@@ -209,8 +213,8 @@ int cfg80211_switch_netns(struct cfg80211_registered_device *rdev, } } -if (!err) -return 0 ; +if (!err || force) +return err;/* set to the last one to undo all of them */ wdev =list_entry (&rdev->wiphy.wdev_list,typeof (*wdev), list);
@@ -226,6 +230,15 @@ int cfg80211_switch_netns(struct cfg80211_registered_device *rdev,return err; } +int cfg80211_switch_netns (struct cfg80211_registered_device *rdev, +struct net *net) +{ +if (!(rdev->wiphy.flags &WIPHY_FLAG_NETNS_OK )) +return -EOPNOTSUPP ; + +return __cfg80211_switch_netns (rdev, net, false); +} +static void cfg80211_rfkill_poll (struct rfkill *rfkill,void *data) {struct cfg80211_registered_device *rdev = data;
@@ -1764,7 +1777,7 @@ static void __net_exit cfg80211_pernet_exit(struct net *net)rtnl_lock ();for_each_rdev (rdev) {if (net_eq (wiphy_net (&rdev->wiphy), net)) -WARN_ON (cfg80211_switch_netns (rdev, &init_net)); +WARN_ON (__cfg80211_switch_netns (rdev, &init_net, true)); }rtnl_unlock (); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 72/398 wifi: mac80211_hwsim: dont hand frames to mac80211 while stopping
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 87840d4a3a21b1c19b867a80e16ba69dff284de2 ]
The code checks ->started for frames coming from wmediumd, but the radio can be stopped after the check and before frame delivery, causing mac80211 to hit the WARN_ON(!local->started).
Expand the mutex for this case and synchronise against it when the radio is stopped to avoid being able to hit the warning with hwsim.
Drop the error print that would've complicated the error path, it only triggers for allocation failures (already noisy) and malformed frames anyway.
--- drivers/net/wireless/virtual/mac80211_hwsim.c | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-)
drivers/net/wireless/virtual/mac80211_hwsim.c +24 -15
@@ -2162,7 +2162,12 @@ static void mac80211_hwsim_stop(struct ieee80211_hw *hw, bool suspend)struct sk_buff *skb;int i; - data->started = false; +/* +* Serialise against wmediumd userspace, so no more frames +* can be handed to mac80211 after this returns. +*/ +scoped_guard (mutex, &data->mutex) + data->started = false;for (i =0 ; i <ARRAY_SIZE (data->link_data); i++)hrtimer_cancel (&data->link_data[i].beacon_timer);
@@ -6136,12 +6141,12 @@ static int hwsim_cloned_frame_received_nl(struct sk_buff *skb_2,if (frame_data_len <sizeof (struct ieee80211_hdr_3addr ) || frame_data_len >IEEE80211_MAX_DATA_LEN ) - goto err; + goto out;/* Allocate new skb here */ skb =alloc_skb (frame_data_len,GFP_KERNEL );if (skb ==NULL ) - goto err; + goto out;/* Copy the data */ skb_put_data (skb, frame_data, frame_data_len);
@@ -6166,10 +6171,17 @@ static int hwsim_cloned_frame_received_nl(struct sk_buff *skb_2, goto out; } +/* +* Serialise against mac80211_hwsim_stop() - mac80211 doesn't allow +* frames reported while the HW is down, hence the ->started check +* must be under mutex. +*/ +mutex_lock (&data2->mutex); +/* check if radio is configured properly */ if ((data2->idle && !data2->tmp_chan) || !data2->started) - goto out; + goto out_unlock;/* A frame is received from user space */ memset (&rx_status,0 ,sizeof (rx_status));
@@ -6185,22 +6197,18 @@ static int hwsim_cloned_frame_received_nl(struct sk_buff *skb_2, iter_data.channel =ieee80211_get_channel (data2->hw->wiphy, rx_status.freq);if (!iter_data.channel) - goto out; + goto out_unlock; rx_status.band = iter_data.channel->band; -mutex_lock (&data2->mutex);if (!hwsim_chans_compat (iter_data.channel, channel)) {ieee80211_iterate_active_interfaces_atomic ( data2->hw,IEEE80211_IFACE_ITER_NORMAL , mac80211_hwsim_tx_iter, &iter_data); -if (!iter_data.receive) { -mutex_unlock (&data2->mutex); - goto out; - } +if (!iter_data.receive) + goto out_unlock; } -mutex_unlock (&data2->mutex); }else if (!channel) { - goto out; + goto out_unlock; }else { rx_status.freq = channel->center_freq; rx_status.band = channel->band;
@@ -6208,7 +6216,7 @@ static int hwsim_cloned_frame_received_nl(struct sk_buff *skb_2, rx_status.rate_idx =nla_get_u32 (info->attrs[HWSIM_ATTR_RX_RATE ]);if (rx_status.rate_idx >= data2->hw->wiphy->bands[rx_status.band]->n_bitrates) - goto out; + goto out_unlock; rx_status.signal =nla_get_u32 (info->attrs[HWSIM_ATTR_SIGNAL ]); hdr = (void *)skb->data;
@@ -6218,10 +6226,11 @@ static int hwsim_cloned_frame_received_nl(struct sk_buff *skb_2, rx_status.boottime_ns =ktime_get_boottime_ns ();mac80211_hwsim_rx (data2, &rx_status, skb); +mutex_unlock (&data2->mutex);return 0 ; -err: -pr_debug ("mac80211_hwsim: error occurred in %s\n" , __func__); +out_unlock: +mutex_unlock (&data2->mutex); out:dev_kfree_skb (skb);return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 73/398 wifi: mac80211: dont allow injecting frames wider than the chanctx
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit e14bf37bb2b3853012ff160131d1c6233f7a9cc9 ]
Frames injected on a monitor interface can carry a radiotap field requesting a bandwidth, which mac80211 passes down to the driver regardless of the the actual operational bandwidth.
If the bandwidth requested is too wide, that triggers a warning in hwsim:
WARN_ON(hwsim_get_chanwidth(bw) > hwsim_get_chanwidth(confbw))
Drop such frames entirely instead since they cannot be sent.
--- include/net/mac80211.h | 5 ++++- net/mac80211/iface.c | 2 +- net/mac80211/tx.c | 28 ++++++++++++++++++++++++++-- 3 files changed, 31 insertions(+), 4 deletions(-)
include/net/mac80211.h +4 -1
@@ -7309,11 +7309,14 @@ bool ieee80211_tx_prepare_skb(struct ieee80211_hw *hw,* * @skb: packet injected by userspace * @dev: the &struct device of this 802.11 device +* @chandef: the channel definition the frame will be transmitted on, or +* %NULL to skip the bandwidth checks * * Return: %true if the radiotap header was parsed, %false otherwise */ bool ieee80211_parse_tx_radiotap (struct sk_buff *skb, -struct net_device *dev); +struct net_device *dev, +const struct cfg80211_chan_def *chandef);/** * struct ieee80211_noa_data - holds temporary data for tracking P2P NoA state
net/mac80211/iface.c +1 -1
@@ -952,7 +952,7 @@ static u16 ieee80211_monitor_select_queue(struct net_device *dev,/* reset flags and info before parsing radiotap header */ memset (info,0 ,sizeof (*info)); -if (!ieee80211_parse_tx_radiotap (skb, dev)) +if (!ieee80211_parse_tx_radiotap (skb, dev,NULL ))return 0 ;/* doesn't matter, frame will be dropped */ len_rthdr =ieee80211_get_radiotap_len (skb->data);
net/mac80211/tx.c +26 -2
@@ -2084,8 +2084,29 @@ static bool ieee80211_validate_radiotap_len(struct sk_buff *skb)return true; } +static bool ieee80211_rate_bw_usable (u16 rate_flags, +const struct cfg80211_chan_def *chandef) +{ +int width; + +if (!chandef) +return true; + +if (rate_flags &IEEE80211_TX_RC_160_MHZ_WIDTH ) + width =160 ; +else if (rate_flags &IEEE80211_TX_RC_80_MHZ_WIDTH ) + width =80 ; +else if (rate_flags &IEEE80211_TX_RC_40_MHZ_WIDTH ) + width =40 ; +else +return true; + +return width <=cfg80211_chandef_get_width (chandef); +} +bool ieee80211_parse_tx_radiotap (struct sk_buff *skb, -struct net_device *dev) +struct net_device *dev, +const struct cfg80211_chan_def *chandef) {struct ieee80211_local *local =wdev_priv (dev->ieee80211_ptr);struct ieee80211_radiotap_iterator iterator;
@@ -2259,6 +2280,9 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb,struct ieee80211_supported_band *sband = local->hw.wiphy->bands[info->band]; +if (!ieee80211_rate_bw_usable (rate_flags, chandef)) +return false; + info->control.flags |=IEEE80211_TX_CTRL_RATE_INJECT ;for (i =0 ; i <IEEE80211_TX_MAX_RATES ; i++) {
@@ -2448,7 +2472,7 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,* selected chandef above to accurately set injection rates and * retransmissions. */ -if (!ieee80211_parse_tx_radiotap (skb, dev)) +if (!ieee80211_parse_tx_radiotap (skb, dev, chandef)) goto fail_rcu;/* remove the injection radiotap header */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 74/398 wifi: mac80211: reset the AP_VLAN tailroom counter on ifdown
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 4504f3960dc4501c73be9f99eabda2e26e9db41e ]
On ifup, AP_VLAN interfaces get crypto_tx_tailroom_needed_cnt from the AP interface, but it's never decremented again unless the AP is also brought down. Thus, bringing the same AP_VLAN up again will increment the counter again and eventually hit the sanity check:
WARN_ON_ONCE(sdata->crypto_tx_tailroom_needed_cnt !=
master->crypto_tx_tailroom_needed_cnt);
Reset it on ifdown to avoid that.
--- net/mac80211/iface.c | 2 ++ 1 file changed, 2 insertions(+)
net/mac80211/iface.c +2 -0
@@ -609,6 +609,8 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_doRCU_INIT_POINTER (sdata->vif.bss_conf.chanctx_conf,NULL );/* see comment in the default case below */ ieee80211_free_keys (sdata, true); +/* increased by AP value on ifup, so reset on ifdown */ + sdata->crypto_tx_tailroom_needed_cnt =0 ;/* no need to tell driver */ break ;case NL80211_IFTYPE_MONITOR :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 75/398 wifi: mac80211: require a peer station for TDLS setup confirm
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 038e1d126304fd25d507fd4e671232df57bd1799 ]
It's nonsense for the setup confirm to go to station that doesn't even exist, and it hits a warning when building the frame:
WARN_ON_ONCE(!sta || !ap_sta)
Only accept WLAN_TDLS_SETUP_CONFIRM when the station is already there as a TDLS station. Need to copy the call to ieee80211_tdls_prep_mgmt_packet() since the existing WLAN_TDLS_DISCOVERY_REQUEST already falls through to it.
--- net/mac80211/tdls.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
net/mac80211/tdls.c +18 -1
@@ -1285,6 +1285,24 @@ int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, peer_capability, initiator, extra_ies, extra_ies_len);break ; +case WLAN_TDLS_SETUP_CONFIRM : { +struct sta_info *sta; + + sta =sta_info_get (sdata, peer); +if (!sta || !sta->sta.tdls) { + ret = -ENOLINK ; +break ; + } + + ret =ieee80211_tdls_prep_mgmt_packet (wiphy, dev, peer, + link_id, action_code, + dialog_token, + status_code, + peer_capability, + initiator, extra_ies, + extra_ies_len,0 ,NULL ); +break ; + }case WLAN_TDLS_DISCOVERY_REQUEST :/* * Protect the discovery so we can hear the TDLS discovery
@@ -1293,7 +1311,6 @@ int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,*/ drv_mgd_protect_tdls_discover (sdata->local, sdata, link_id); fallthrough; -case WLAN_TDLS_SETUP_CONFIRM :case WLAN_PUB_ACTION_TDLS_DISCOVER_RES :/* no special handling */ ret = ieee80211_tdls_prep_mgmt_packet(wiphy, dev, peer,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 66/398 wifi: mac80211: abort chanswitch when leaving a mesh
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit ac7472a24bd433b81c06582835dd1d5547c10da9 ]
The code in ieee80211_stop_mesh() leaves CSA active, but leaving the mesh released the channel context, so the CSA finalize work crashes:
Oops: general protection fault, probably for non-canonical address
0xdffffc0000000003
KASAN: null-ptr-deref in range [0x0000000000000018-0x000000000000001f]
RIP: 0010:ieee80211_put_srates_elem+0x42/0x640 net/mac80211/util.c:3272
Call Trace:
ieee80211_mesh_build_beacon+0xa83/0x1b50 net/mac80211/mesh.c:1093
ieee80211_mesh_rebuild_beacon+0xc7/0x170 net/mac80211/mesh.c:1147
ieee80211_mesh_finish_csa+0x131/0x210 net/mac80211/mesh.c:1542
ieee80211_set_after_csa_beacon net/mac80211/cfg.c:4085 [inline]
__ieee80211_csa_finalize net/mac80211/cfg.c:4133 [inline]
ieee80211_csa_finalize+0x633/0x1150 net/mac80211/cfg.c:4155
cfg80211_wiphy_work+0x2ab/0x450 net/wireless/core.c:438Abort the channel switch properly.
--- net/mac80211/mesh.c | 4 ++++ 1 file changed, 4 insertions(+)
net/mac80211/mesh.c +4 -0
@@ -1223,6 +1223,10 @@ void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata)netif_carrier_off (sdata->dev); +/* abort any running channel switch */ + sdata->vif.bss_conf.csa_active = false; +ieee80211_vif_unblock_queues_csa (sdata); +/* flush STAs and mpaths on this iface */ sta_info_flush (sdata,-1 );ieee80211_free_keys (sdata, true);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 101/398 neighbour: Convert RTM_GETNEIGHTBL to RCU.
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 4ae34be500649ec452ac1fc2748958683ad9b55d ]
neightbl_dump_info() calls these functions for each neigh_tables[] entry:
1. neightbl_fill_info() for tbl->parms
2. neightbl_fill_param_info() for tbl->parms_list (except tbl->parms)
Both functions rely on the table lock (read_lock_bh(&tbl->lock)) and RTNL is not needed.
Let's fetch the table under RCU and convert RTM_GETNEIGHTBL to RCU.
Note that the first entry of tbl->parms_list is tbl->parms.list and embedded in neigh_table, so list_next_entry() is safe.
Stable-dep-of: 979aabdad8dd ("neighbour: Skip default parms when resumed in neightbl_dump_info().")
--- net/core/neighbour.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-)
net/core/neighbour.c +9 -14
@@ -2180,7 +2180,7 @@ static int neightbl_fill_parms(struct sk_buff *skb, struct neigh_parms *parms)return -ENOBUFS ; if ((parms->dev && - nla_put_u32(skb, NDTPA_IFINDEX, parms->dev->ifindex)) || + nla_put_u32(skb, NDTPA_IFINDEX, READ_ONCE(parms->dev->ifindex))) || nla_put_u32(skb, NDTPA_REFCNT, refcount_read(&parms->refcnt)) || nla_put_u32(skb, NDTPA_QUEUE_LENBYTES, NEIGH_VAR(parms, QUEUE_LEN_BYTES)) ||
@@ -2232,8 +2232,6 @@ static int neightbl_fill_info(struct sk_buff *skb, struct neigh_table *tbl,return -EMSGSIZE ; ndtmsg =nlmsg_data (nlh); - -read_lock_bh (&tbl->lock); ndtmsg->ndtm_family = tbl->family; ndtmsg->ndtm_pad1 =0 ; ndtmsg->ndtm_pad2 =0 ;
@@ -2259,11 +2257,9 @@ static int neightbl_fill_info(struct sk_buff *skb, struct neigh_table *tbl, .ndtc_proxy_qlen = READ_ONCE(tbl->proxy_queue.qlen), }; -rcu_read_lock (); nht =rcu_dereference (tbl->nht); ndc.ndtc_hash_rnd = nht->hash_rnd[0 ]; ndc.ndtc_hash_mask = ((1 << nht->hash_shift) -1 ); -rcu_read_unlock ();if (nla_put (skb,NDTA_CONFIG ,sizeof (ndc), &ndc)) goto nla_put_failure;
@@ -2301,12 +2297,10 @@ static int neightbl_fill_info(struct sk_buff *skb, struct neigh_table *tbl,if (neightbl_fill_parms (skb, &tbl->parms) <0 ) goto nla_put_failure; -read_unlock_bh (&tbl->lock);nlmsg_end (skb, nlh);return 0 ; nla_put_failure: -read_unlock_bh (&tbl->lock);nlmsg_cancel (skb, nlh);return -EMSGSIZE ; }
@@ -2325,8 +2319,6 @@ static int neightbl_fill_param_info(struct sk_buff *skb,return -EMSGSIZE ; ndtmsg =nlmsg_data (nlh); - -read_lock_bh (&tbl->lock); ndtmsg->ndtm_family = tbl->family; ndtmsg->ndtm_pad1 =0 ; ndtmsg->ndtm_pad2 =0 ;
@@ -2335,11 +2327,9 @@ static int neightbl_fill_param_info(struct sk_buff *skb, neightbl_fill_parms(skb, parms) < 0) goto errout; -read_unlock_bh (&tbl->lock);nlmsg_end (skb, nlh);return 0 ; errout: -read_unlock_bh (&tbl->lock);nlmsg_cancel (skb, nlh);return -EMSGSIZE ; }
@@ -2588,10 +2578,12 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb) family = ((struct rtgenmsg *)nlmsg_data (nlh))->rtgen_family; +rcu_read_lock (); +for (tidx =0 ; tidx <NEIGH_NR_TABLES ; tidx++) {struct neigh_parms *p; - tbl =rcu_dereference_rtnl (neigh_tables[tidx]); + tbl =rcu_dereference (neigh_tables[tidx]);if (!tbl)continue ;
@@ -2605,7 +2597,7 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb) nidx =0 ; p =list_next_entry (&tbl->parms, list); -list_for_each_entry_from (p, &tbl->parms_list, list) { +list_for_each_entry_from_rcu (p, &tbl->parms_list, list) {if (!net_eq (neigh_parms_net (p), net))continue ;
@@ -2625,6 +2617,8 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb) neigh_skip =0 ; } out: +rcu_read_unlock (); + cb->args[0 ] = tidx; cb->args[1 ] = nidx;
@@ -3928,7 +3922,8 @@ static const struct rtnl_msg_handler neigh_rtnl_msg_handlers[] __initconst = { {.msgtype = RTM_DELNEIGH, .doit = neigh_delete}, {.msgtype = RTM_GETNEIGH, .doit = neigh_get, .dumpit = neigh_dump_info, .flags = RTNL_FLAG_DOIT_UNLOCKED | RTNL_FLAG_DUMP_UNLOCKED}, - {.msgtype = RTM_GETNEIGHTBL, .dumpit = neightbl_dump_info}, + {.msgtype = RTM_GETNEIGHTBL, .dumpit = neightbl_dump_info, + .flags = RTNL_FLAG_DUMP_UNLOCKED}, {.msgtype = RTM_SETNEIGHTBL, .doit = neightbl_set}, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 110/398 ASoC: Rename snd_soc_dai_link_ch_map.ch_mask to cpu_ch_mask
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Fitzgerald <[email protected]>
[ Upstream commit 4d855d747521505b54457c96bc73577bf74b2374 ]
Rename the ch_mask member of snd_soc_dai_link_ch_map to cpu_ch_mask, as that is what it is used for.
The CPU and codec channel masks are not necessarily the same, and are quite likely different. SoundWire and I2S/TDM both support assigning different sample slots to each codec, so for example channel 0 on each codec could map to different channels at the CPU. So it's quite normal that the channel mask at the CPU end is different for each codec, but the codec channel masks are the same for each codec.
Stable-dep-of: 6b382bdfe26a ("ASoC: soc-pcm: Apply snd_soc_dai_link_ch_map.codec_ch_mask to codec params")
--- include/sound/soc.h | 2 +- sound/soc/sdw_utils/soc_sdw_utils.c | 2 +- sound/soc/soc-pcm.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
include/sound/soc.h +1 -1
@@ -682,7 +682,7 @@ struct snd_soc_dai_link_component {struct snd_soc_dai_link_ch_map {unsigned int cpu;unsigned int codec; -unsigned int ch_mask; +unsigned int cpu_ch_mask; };struct snd_soc_dai_link {
sound/soc/sdw_utils/soc_sdw_utils.c +1 -1
@@ -974,7 +974,7 @@ int asoc_sdw_hw_params(struct snd_pcm_substream *substream,* ASoC will set the corresponding channel numbers for each cpu dai. */ for_each_link_ch_maps (rtd->dai_link, i, ch_maps) - ch_maps->ch_mask = ch_mask << (i * step); + ch_maps->cpu_ch_mask = ch_mask << (i * step);return 0 ; }
sound/soc/soc-pcm.c +1 -1
@@ -1133,7 +1133,7 @@ static int __soc_pcm_hw_params(struct snd_pcm_substream *substream,*/ for_each_rtd_ch_maps (rtd, j, ch_maps)if (ch_maps->cpu == i) - ch_mask |= ch_maps->ch_mask; + ch_mask |= ch_maps->cpu_ch_mask;/* fixup cpu channel number */ if (ch_mask)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 111/398 ASoC: Add codec_ch_mask to snd_soc_dai_link_ch_map
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Fitzgerald <[email protected]>
[ Upstream commit 88b14c0d0bab5c0f3e7c641f274e3c70210c0e36 ]
Add a codec_ch_mask member to snd_soc_dai_link_ch_map.
The CPU and codec channel masks are not necessarily the same, and are quite likely different. SoundWire and I2S/TDM both support assigning different sample slots to each codec, so for example channel 0 on each codec could map to different channels at the CPU.
It is also possible for one TX channel to map to multiple RX channels. So it isn't _always_ safe to assume that the total number of set bits in the CPU ch_mask is the same as the total number of enabled channels on the codec.
For example consider this mapping on a capture stream:
CPU0 CODEC0 cpu_ch_mask = 0x03
CPU1 CODEC0 cpu_ch_mask = 0x03
This could be either four TX channels on the codec split across two receiving CPUs, or two TX channels on the codec duplicated to two CPUs.
Stable-dep-of: 6b382bdfe26a ("ASoC: soc-pcm: Apply snd_soc_dai_link_ch_map.codec_ch_mask to codec params")
--- include/sound/soc.h | 1 + 1 file changed, 1 insertion(+)
include/sound/soc.h +1 -0
@@ -683,6 +683,7 @@ struct snd_soc_dai_link_ch_map {unsigned int cpu;unsigned int codec;unsigned int cpu_ch_mask; +unsigned int codec_ch_mask; };struct snd_soc_dai_link {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 112/398 ASoC: soc-pcm: Apply snd_soc_dai_link_ch_map.codec_ch_mask to codec params
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Fitzgerald <[email protected]>
[ Upstream commit 6b382bdfe26a2232091bf743e454e6794295783e ]
In __soc_pcm_hw_params() if there is a snd_soc_dai_link_ch_map with non-zero codec_ch_mask, use that channel mask to restrict which channels are enabled on the codec. But only if there isn't a TDM mask.
It is possible that a snd_soc_dai_link_ch_map could include the same codec multiple times on different CPUs so the for_each_rtd_ch_maps() loop accumulates the channel masks for all entries of that codec.
If a TDM mask was also set, it takes priority and is used instead of any possible snd_soc_dai_link_ch_map entries. (They cannot be ANDed together because the bit positions are indicating different things: TDM is a bit for each TDM slot, codec_ch_mask is a bit for each codec channel.)
This fixes a problem of incorrect TX channels enabled on the codec when multiple codecs are aggregated on a single capture link. For example:
- Two CPUs with six 4-channel codecs.
- The machine driver chooses to assign one channel from each codec to one channel on the CPU
- But the codec hw_params() would be passed a channel count of 6, which
(a) is more channels than the codec has and (b) allows enabling channels that should not be driving the audio bus.
--- sound/soc/soc-pcm.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
sound/soc/soc-pcm.c +12 -4
@@ -1075,7 +1075,9 @@ static int __soc_pcm_hw_params(struct snd_pcm_substream *substream, goto out;for_each_rtd_codec_dais (rtd, i, codec_dai) { -unsigned int tdm_mask =snd_soc_dai_tdm_mask_get (codec_dai, substream->stream); +unsigned int ch_mask =snd_soc_dai_tdm_mask_get (codec_dai, substream->stream); +struct snd_soc_dai_link_ch_map *ch_maps; +int j;/* * Skip CODECs which don't support the current stream type,
@@ -1097,9 +1099,15 @@ static int __soc_pcm_hw_params(struct snd_pcm_substream *substream,/* copy params for each codec */ tmp_params = *params; -/* fixup params based on TDM slot masks */ -if (tdm_mask) -soc_pcm_codec_params_fixup (&tmp_params, tdm_mask); +/* fixup params based on TDM or ch_map masks */ +if (!ch_mask) { +for_each_rtd_ch_maps (rtd, j, ch_maps) +if (ch_maps->codec == i) + ch_mask |= ch_maps->codec_ch_mask; + } + +if (ch_mask) +soc_pcm_codec_params_fixup (&tmp_params, ch_mask); ret =snd_soc_dai_hw_params (codec_dai, substream, &tmp_params);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 113/398 spi: spi-qpic-snand: avoid writing QPIC_EBI2_ECC_BUF_CFG register
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabor Juhos <[email protected]>
[ Upstream commit 930a7312c946bf4731721cadd82bb9a2ada496ca ]
The description of commit bfb34eced559 ("mtd: rawnand: qcom: avoid writing to obsolete register") says this:
"QPIC_EBI2_ECC_BUF_CFG register got obsolete from QPIC V2.0 onwards. Avoid writing this register if QPIC version is V2.0 or newer."
Although the referenced commit is related to the 'qcom-nandc' driver, however the hardware supported by the current driver is also based on QPIC v2.0 so we should avoid writing that register here as well.
Remove the register writing code to avoid undefined behaviour.
--- drivers/spi/spi-qpic-snand.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/spi/spi-qpic-snand.c +0 -4
@@ -740,8 +740,6 @@ static int qcom_spi_read_cw_raw(struct qcom_nand_controller *snandc, u8 *data_buqcom_write_reg_dma (snandc, &snandc->regs->addr0,NAND_ADDR0 ,2 ,0 );qcom_write_reg_dma (snandc, &snandc->regs->cfg0,NAND_DEV0_CFG0 ,3 ,0 ); -qcom_write_reg_dma (snandc, &snandc->regs->ecc_buf_cfg,NAND_EBI2_ECC_BUF_CFG ,1 ,0 ); -qcom_write_reg_dma (snandc, &snandc->regs->erased_cw_detect_cfg_clr,NAND_ERASED_CW_DETECT_CFG ,1 ,0 ); qcom_write_reg_dma(snandc, &snandc->regs->erased_cw_detect_cfg_set,
@@ -1012,8 +1010,6 @@ static void qcom_spi_config_page_write(struct qcom_nand_controller *snandc) {qcom_write_reg_dma (snandc, &snandc->regs->addr0,NAND_ADDR0 ,2 ,0 );qcom_write_reg_dma (snandc, &snandc->regs->cfg0,NAND_DEV0_CFG0 ,3 ,0 ); -qcom_write_reg_dma (snandc, &snandc->regs->ecc_buf_cfg,NAND_EBI2_ECC_BUF_CFG , -1 ,NAND_BAM_NEXT_SGL ); }static void qcom_spi_config_cw_write (struct qcom_nand_controller *snandc)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 114/398 Input: trackpoint - fix the inertia attribute name in the ABI document
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 45b0037899704caf9078be2be4de69361ca7d933 ]
The attribute is created as "inertia" (TRACKPOINT_INT_ATTR(inertia, ...) in drivers/input/mouse/trackpoint.c); the ABI file spells the path "intertia". The description below it already says inertia.
Fix the spelling.
--- Documentation/ABI/testing/sysfs-devices-platform-trackpoint | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-devices-platform-trackpoint +1 -1
@@ -5,7 +5,7 @@ Contact: [email protected] Description: (RW) Trackpoint sensitivity. -What: /sys/devices/platform/i8042/.../intertia +What: /sys/devices/platform/i8042/.../inertia Date: Aug, 2005 KernelVersion: 2.6.14 Contact: [email protected]
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 115/398 gpio: virtuser: skip free_irq when no IRQ is installed
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 50fd0ada8d37587223001600933270b59cb30e19 ]
Disabling interrupt monitoring uses atomic_xchg() to clear the stored IRQ. When monitoring is already disabled, atomic_xchg() returns 0. It must not be passed to free_irq().
The bug is reproducible on an x86_64 QEMU guest with CONFIG_GPIO_VIRTUSER=y and CONFIG_GPIO_SIM=y. Configure a live gpio-virtuser device through configfs. Its input lookup must refer to a live gpio-sim bank, such as key gpio-sim-test with offset 0. The consumer's dev_name attribute is shown as <dev> below; then run:
echo 0 > /sys/kernel/debug/gpio-virtuser/<dev>/gpiod:input:0/interrupts
On an unpatched kernel, this reaches gpio_virtuser_interrupts_set() with ld->irq still at its initial value 0, and free_irq() reports:
Trying to free already-free IRQ 0
The same reproducer completes without the warning on the patched kernel.
--- drivers/gpio/gpio-virtuser.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpio/gpio-virtuser.c +2 -1
@@ -697,7 +697,8 @@ static int gpio_virtuser_interrupts_set(void *data, u64 val)atomic_set (&ld->irq, irq); }else { irq =atomic_xchg (&ld->irq,0 ); -free_irq (irq, ld); +if (irq) +free_irq (irq, ld); }return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 116/398 ALSA: usb: 6fire: Avoid embedded URBs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 9fe49dbc023e82dfaee7b245997d820d01742a9a ]
The USB 6fire driver uses URBs embedded in different structs for PCM, MIDI and communication, and this is basically a buggy implementation nowadays; since a URB is managed with a refcount, this may lead to a UAF when the URB is released asynchronously.
For addressing the problem, this patch converts those embedded URBs to ones that are properly allocated via usb_alloc_urb(). The pcm_urb.packets[] is gone, as it's allocated by usb_alloc_urb(), hence it's found in urb.iso_frame_desc[] instead.
The conversions are rather straightforward; each embedded struct urb is changed to a pointer, and its callers are updated accordingly. The resource for those structs are released in the common destructor functions (usb6fire_comm_free(), etc), which are called at both the init error path and the disconnect.
No functional changes, only compile-tested.
Stable-dep-of: 1589afe2d099 ("ALSA: 6fire: fix OOB write from device-reported iso length")
--- sound/usb/6fire/comm.c | 42 +++++++++----- sound/usb/6fire/comm.h | 2 +- sound/usb/6fire/midi.c | 43 +++++++++----- sound/usb/6fire/midi.h | 2 +- sound/usb/6fire/pcm.c | 128 ++++++++++++++++++++++++----------------- sound/usb/6fire/pcm.h | 5 +- 6 files changed, 136 insertions(+), 86 deletions(-)
sound/usb/6fire/comm.c +28 -14
@@ -21,7 +21,6 @@ enum {static void usb6fire_comm_init_urb (struct comm_runtime *rt,struct urb *urb,u8 *buffer,void *context,void (*handler)(struct urb *urb)) { -usb_init_urb (urb); urb->transfer_buffer = buffer; urb->pipe =usb_sndintpipe (rt->chip->dev,COMM_EP ); urb->complete = handler;
@@ -142,6 +141,19 @@ static int usb6fire_comm_write16(struct comm_runtime *rt, u8 request,return ret; } +static void usb6fire_comm_free (struct comm_runtime *rt) +{ +if (!rt) +return ; + +if (rt->chip) + rt->chip->comm =NULL ; + +usb_free_urb (rt->receiver); +kfree (rt->receiver_buffer); +kfree (rt); +} +int usb6fire_comm_init (struct sfire_chip *chip) { struct comm_runtime *rt = kzalloc(sizeof(struct comm_runtime),
@@ -154,14 +166,18 @@ int usb6fire_comm_init(struct sfire_chip *chip) rt->receiver_buffer =kzalloc (COMM_RECEIVER_BUFSIZE ,GFP_KERNEL );if (!rt->receiver_buffer) { -kfree (rt); -return -ENOMEM ; + ret = -ENOMEM ; + goto error; } - urb = &rt->receiver; + urb =usb_alloc_urb (0 ,GFP_KERNEL ); +if (!urb) { + ret = -ENOMEM ; + goto error; + } + rt->receiver = urb; rt->serial =1 ; rt->chip = chip; -usb_init_urb (urb); rt->init_urb = usb6fire_comm_init_urb; rt->write8 = usb6fire_comm_write8; rt->write16 = usb6fire_comm_write16;
@@ -176,13 +192,15 @@ int usb6fire_comm_init(struct sfire_chip *chip) urb->interval =1 ; ret =usb_submit_urb (urb,GFP_KERNEL );if (ret <0 ) { -kfree (rt->receiver_buffer); -kfree (rt);dev_err (&chip->dev->dev,"cannot create comm data receiver." ); -return ret; + goto error; } chip->comm = rt;return 0 ; + + error: +usb6fire_comm_free (rt); +return ret; }void usb6fire_comm_abort (struct sfire_chip *chip)
@@ -190,14 +208,10 @@ void usb6fire_comm_abort(struct sfire_chip *chip)struct comm_runtime *rt = chip->comm;if (rt) -usb_poison_urb (&rt->receiver); +usb_poison_urb (rt->receiver); }void usb6fire_comm_destroy (struct sfire_chip *chip) { -struct comm_runtime *rt = chip->comm; - -kfree (rt->receiver_buffer); -kfree (rt); - chip->comm =NULL ; +usb6fire_comm_free (chip->comm); }
sound/usb/6fire/comm.h +1 -1
@@ -19,7 +19,7 @@ enum /* settings for comm */struct comm_runtime {struct sfire_chip *chip; -struct urb receiver; +struct urb *receiver;u8 *receiver_buffer;u8 serial;/* urb serial */
sound/usb/6fire/midi.c +30 -13
86 lines not on this page · raw message
sound/usb/6fire/midi.h +1 -1
@@ -22,7 +22,7 @@ struct midi_runtime {spinlock_t in_lock;spinlock_t out_lock;struct snd_rawmidi_substream *out; -struct urb out_urb; +struct urb *out_urb;u8 out_serial;/* serial number of out packet */ u8 *out_buffer;int buffer_offset;
sound/usb/6fire/pcm.c +75 -53
267 lines not on this page · raw message
sound/usb/6fire/pcm.h +1 -4
@@ -24,10 +24,7 @@ enum /* settings for pcm */struct pcm_urb {struct sfire_chip *chip; -/* BEGIN DO NOT SEPARATE */ -struct urb instance; -struct usb_iso_packet_descriptor packets[PCM_N_PACKETS_PER_URB ]; -/* END DO NOT SEPARATE */ +struct urb *instance;u8 *buffer;struct pcm_urb *peer;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 117/398 ALSA: 6fire: fix OOB write from device-reported iso length
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit 1589afe2d099d3e817873bc474676968d7080410 ]
usb6fire_pcm_in_urb_handler() sizes each outgoing isochronous packet as (actual_length - 4) / (in_n_analog << 2) * (out_n_analog << 2) + 4, where actual_length is the unsigned length the device reported for the matching IN packet. A packet completed with status 0 and actual_length < 4 wraps the subtraction to 0x7fffffec; a zero-length isochronous packet is legal on the bus, and the preceding loop rejects only non-zero status. The sum reaches memset() on out_urb->buffer, a 4832-byte object from kcalloc(PCM_MAX_PACKET_SIZE, PCM_N_PACKETS_PER_URB).
Even without the wrap the result is out of bounds: at 88.2/96 kHz the 4-in/6-out scaling turns a full 420-byte IN packet into 628, so eight packets span 5024 bytes of that buffer. usb_submit_urb() rejects an over-long descriptor only after the memset() and the usb6fire_pcm_playback() copy of user PCM data have run.
Guard the subtraction as the sibling usb6fire_pcm_capture() already does, and limit the frame count to what fits in rt->out_packet_size, the OUT endpoint's wMaxPacketSize. This bounds total_length by the buffer size while keeping each packet length aligned to a whole output frame.
BUG: KASAN: out-of-bounds in usb6fire_pcm_in_urb_handler (sound/usb/6fire/pcm.c:338) Write of size 18446744073709551456 at addr ffff88802a3d0000 by task vhci_rx/5018 Call Trace: dump_stack_lvl (lib/dump_stack.c:94 lib/dump_stack.c:120) print_report (mm/kasan/report.c:378 mm/kasan/report.c:482) kasan_report (mm/kasan/report.c:595) kasan_check_range (mm/kasan/generic.c:186 mm/kasan/generic.c:200) __asan_memset (mm/kasan/shadow.c:84) usb6fire_pcm_in_urb_handler (sound/usb/6fire/pcm.c:338) __usb_hcd_giveback_urb (drivers/usb/core/hcd.c:1657) usb_hcd_giveback_urb (drivers/usb/core/hcd.c:1741) vhci_rx_loop (drivers/usb/usbip/vhci_rx.c:107 drivers/usb/usbip/vhci_rx.c:242) kthread (kernel/kthread.c:436) ret_from_fork (arch/x86/kernel/process.c:158) ret_from_fork_asm (arch/x86/entry/entry_64.S:245) Allocated by task 10: __kmalloc_cache_noprof (mm/slub.c:5563) usb6fire_pcm_init (sound/usb/6fire/pcm.c:560 sound/usb/6fire/pcm.c:595) usb6fire_chip_probe (sound/usb/6fire/chip.c:133) usb_probe_interface (drivers/usb/core/driver.c:399) The buggy address belongs to the object at ffff88802a3d0000 which belongs to the cache kmalloc-8k of size 8192 The buggy address is located 0 bytes inside of 4832-byte region [ffff88802a3d0000, ffff88802a3d12e0) Kernel panic - not syncing: Fatal exception in interrupt
--- sound/usb/6fire/pcm.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
sound/usb/6fire/pcm.c +10 -2
@@ -335,11 +335,19 @@ static void usb6fire_pcm_in_urb_handler(struct urb *usb_urb)/* setup out urb structure */ for (i =0 ; i <PCM_N_PACKETS_PER_URB ; i++) { +unsigned int frames =0 ; + isoc_out = &out_urb->instance->iso_frame_desc[i]; isoc_in = &in_urb->instance->iso_frame_desc[i]; +if (isoc_in->actual_length >4 ) + frames = (isoc_in->actual_length -4 ) + / (rt->in_n_analog <<2 ); + frames = min_t(unsigned int, frames, + (rt->out_packet_size -4 ) + / (rt->out_n_analog <<2 )); + isoc_out->offset = total_length; - isoc_out->length = (isoc_in->actual_length -4 ) / (rt->in_n_analog <<2 ) - * (rt->out_n_analog <<2 ) +4 ; + isoc_out->length = frames * (rt->out_n_analog <<2 ) +4 ; isoc_out->status =0 ; total_length += isoc_out->length; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 118/398 wifi: virt_wifi: dont transfer operstate before register
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zihan Xi <[email protected]>
[ Upstream commit e5c8d7acd31b27057ea42cd405d0b3ece097bc89 ]
virt_wifi_newlink() calls netif_stacked_transfer_operstate() before register_netdevice(). If the lower device is dormant, that queues the new netdev on lweventlist while it is still uninitialized. If registration fails after that, for example because of an invalid name such as "bad/name", free_netdev() immediately frees the object. A later linkwatch_fire_event() then use-after-frees the list entry.
Move the transfer to after netdev_upper_dev_link(), as macvlan and ipvlan already do.
--- drivers/net/wireless/virtual/virt_wifi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/virtual/virt_wifi.c +2 -1
@@ -556,7 +556,6 @@ static int virt_wifi_newlink(struct net_device *dev, }eth_hw_addr_inherit (dev, priv->lowerdev); -netif_stacked_transfer_operstate (priv->lowerdev, dev); dev->ieee80211_ptr =kzalloc (sizeof (*dev->ieee80211_ptr),GFP_KERNEL );
@@ -582,6 +581,8 @@ static int virt_wifi_newlink(struct net_device *dev, goto unregister_netdev; } +netif_stacked_transfer_operstate (priv->lowerdev, dev); + dev->priv_destructor = virt_wifi_net_device_destructor; priv->being_deleted = false; priv->is_connected = false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 119/398 drm/xe/mmio_gem: forbid VMA split
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilia Levi <[email protected]>
[ Upstream commit 247a82da6f563dcfd9074a68f99a0c0997d0679c ]
The fault handler assumes it always operates on a VMA spanning the entire GEM object. This does not hold when the VMA has been split, e.g. by a partial munmap or mprotect. In that case the handler may map wrong physical pages or cause SIGBUS.
Handle this by forbidding VMA split, as partial unmaps are not deemed useful for MMIO GEMs.
--- drivers/gpu/drm/xe/xe_mmio_gem.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/gpu/drm/xe/xe_mmio_gem.c +10 -0
@@ -39,10 +39,20 @@ struct xe_mmio_gem {phys_addr_t phys_addr; }; +static int xe_mmio_gem_vm_may_split (struct vm_area_struct *area,unsigned long addr) +{ +/* +* Forbid splitting. Together with VM_DONTEXPAND, this keeps the VMA +* matching the GEM object exactly. +*/ +return -EINVAL ; +} +static const struct vm_operations_struct vm_ops = { .open = drm_gem_vm_open, .close = drm_gem_vm_close, .fault = xe_mmio_gem_vm_fault, + .may_split = xe_mmio_gem_vm_may_split, };static const struct drm_gem_object_funcs xe_mmio_gem_funcs = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 102/398 neighbour: Add missing RCU annotation for neightbl_dump_info().
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 764dcebb033764633700a036c7351a7c6350eec6 ]
neightbl_dump_info() fetches the first non-default neigh_parms with list_next_entry(&tbl->parms, ...) and iterates through the list with list_for_each_entry_from_rcu().
However, list_next_entry() does not use RCU helper.
Let's use list_for_each_entry_rcu() and skip the default parms.
Stable-dep-of: 979aabdad8dd ("neighbour: Skip default parms when resumed in neightbl_dump_info().")
--- net/core/neighbour.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/core/neighbour.c +5 -2
@@ -2596,11 +2596,14 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb)break ; nidx =0 ; - p =list_next_entry (&tbl->parms, list); -list_for_each_entry_from_rcu (p, &tbl->parms_list, list) { + +list_for_each_entry_rcu (p, &tbl->parms_list, list) {if (!net_eq (neigh_parms_net (p), net))continue ; +if (!p->dev) +continue ; +if (nidx < neigh_skip) goto next;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 120/398 drm/xe/mmio_gem: use write-back mapping for dummy page
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilia Levi <[email protected]>
[ Upstream commit 819f189265a5955da743e78e20a713a038982e89 ]
Currently vmf_insert_pfn() maps the dummy page as UC, inheriting the VMA's page protection which was set for the real MMIO region. This conflicts with the direct map's WB mapping of the same page, creating a cache type alias which is architecturally undefined on some platforms.
Use vmf_insert_pfn_prot() with a WB pgprot instead. Also simplify to fault in the requested page instead of the whole VMA.
--- drivers/gpu/drm/xe/xe_mmio_gem.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)
drivers/gpu/drm/xe/xe_mmio_gem.c +5 -14
@@ -172,14 +172,13 @@ static void xe_mmio_gem_release_dummy_page(struct drm_device *dev, void *res)__free_page ((struct page *)res); } -static vm_fault_t xe_mmio_gem_vm_fault_dummy_page (struct vm_area_struct *vma) +static vm_fault_t xe_mmio_gem_vm_fault_dummy_page (struct vm_fault *vmf) { +struct vm_area_struct *vma = vmf->vma;struct drm_gem_object *base = vma->vm_private_data;struct drm_device *dev = base->dev; -vm_fault_t ret =VM_FAULT_NOPAGE ;struct page *page;unsigned long pfn; -unsigned long i; page =alloc_page (GFP_KERNEL | __GFP_ZERO);if (!page)
@@ -190,16 +189,8 @@ static vm_fault_t xe_mmio_gem_vm_fault_dummy_page(struct vm_area_struct *vma) pfn =page_to_pfn (page); -/* Map the entire VMA to the same dummy page */ -for (i =0 ; i < base->size; i +=PAGE_SIZE ) { -unsigned long addr = vma->vm_start + i; - - ret =vmf_insert_pfn (vma, addr, pfn); -if (ret &VM_FAULT_ERROR ) -break ; - } - -return ret; +return vmf_insert_pfn_prot (vma, vmf->address, pfn, +vm_get_page_prot (vma->vm_flags)); }static vm_fault_t xe_mmio_gem_vm_fault (struct vm_fault *vmf)
@@ -219,7 +210,7 @@ static vm_fault_t xe_mmio_gem_vm_fault(struct vm_fault *vmf)* It is assumed the userspace will receive the notification via some * other channel (e.g. drm uevent). */ -return xe_mmio_gem_vm_fault_dummy_page (vma); +return xe_mmio_gem_vm_fault_dummy_page (vmf); }for (i =0 ; i < base->size; i +=PAGE_SIZE ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 121/398 drm/xe/mmio_gem: Revoke drm_vma_node on xe_mmio_gem destroy
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuicheng Lin <[email protected]>
[ Upstream commit 37fcbd7b2f8996d783932dab11bc668e169b0de6 ]
xe_mmio_gem_create() calls drm_vma_node_allow() but nothing ever calls drm_vma_node_revoke(). The drm_vma_offset_file rb-tree entry allocated by drm_vma_node_allow() is not freed by drm_gem_object_release(), so it is leaked on every create/destroy cycle.
Add a struct drm_file * parameter to xe_mmio_gem_destroy() and call drm_vma_node_revoke() from there, mirroring the drm_vma_node_allow() call in xe_mmio_gem_create().
--- drivers/gpu/drm/xe/xe_mmio_gem.c | 4 +++- drivers/gpu/drm/xe/xe_mmio_gem.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_mmio_gem.c +3 -1
@@ -138,14 +138,16 @@ static void xe_mmio_gem_free(struct drm_gem_object *base)/** * xe_mmio_gem_destroy - Destroy the GEM object that exposes an MMIO region * @gem: the GEM object to destroy +* @file: DRM file descriptor previously passed to xe_mmio_gem_create() * * This function releases resources associated with the GEM object created by * xe_mmio_gem_create(). * * See: "Exposing MMIO regions to userspace" */ -void xe_mmio_gem_destroy (struct xe_mmio_gem *gem) +void xe_mmio_gem_destroy (struct xe_mmio_gem *gem,struct drm_file *file) { +drm_vma_node_revoke (&gem->base.vma_node, file);xe_mmio_gem_free (&gem->base); }
drivers/gpu/drm/xe/xe_mmio_gem.h +1 -1
@@ -15,6 +15,6 @@ struct xe_mmio_gem;struct xe_mmio_gem *xe_mmio_gem_create (struct xe_device *xe,struct drm_file *file,phys_addr_t phys_addr,size_t size);u64 xe_mmio_gem_mmap_offset (struct xe_mmio_gem *gem); -void xe_mmio_gem_destroy (struct xe_mmio_gem *gem); +void xe_mmio_gem_destroy (struct xe_mmio_gem *gem,struct drm_file *file);#endif /* _XE_MMIO_GEM_H_ */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 122/398 drm/xe/shrinker: Return the freed page count through a parameter
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuicheng Lin <[email protected]>
[ Upstream commit 3c90e42a01426262f0cd166bc01b45c05562640d ]
__xe_shrinker_walk() and xe_shrinker_walk() return either the number of pages freed or a negative error, so the two cannot be reported at once. On error the pages already freed are dropped, and since xe_shrinker_scan() only accumulates non-negative returns while *scanned is updated by pointer, the shrinker tells mm that it scanned without freeing.
Accumulate the count into a caller-provided counter and return only the status, so an error no longer discards what the walk had freed.
--- drivers/gpu/drm/xe/xe_shrinker.c | 62 ++++++++++++++------------------ 1 file changed, 26 insertions(+), 36 deletions(-)
drivers/gpu/drm/xe/xe_shrinker.c +26 -36
@@ -54,13 +54,14 @@ xe_shrinker_mod_pages(struct xe_shrinker *shrinker, long shrinkable, long purgeawrite_unlock (&shrinker->lock); } -static s64 __xe_shrinker_walk (struct xe_device *xe, +static int __xe_shrinker_walk (struct xe_device *xe,struct ttm_operation_ctx *ctx,const struct xe_bo_shrink_flags flags, -unsigned long to_scan,unsigned long *scanned) +unsigned long to_scan,unsigned long *scanned, +unsigned long *freed) {unsigned int mem_type; -s64 freed =0 , lret; +s64 lret;for (mem_type =XE_PL_SYSTEM ; mem_type <=XE_PL_TT ; ++mem_type) {struct ttm_resource_manager *man =ttm_manager_type (&xe->ttm, mem_type);
@@ -82,7 +83,7 @@ static s64 __xe_shrinker_walk(struct xe_device *xe,if (lret <0 )return lret; - freed += lret; + *freed += lret;if (*scanned >= to_scan)break ; }
@@ -90,7 +91,7 @@ static s64 __xe_shrinker_walk(struct xe_device *xe,xe_assert (xe, !IS_ERR (ttm_bo)); } -return freed; +return 0 ; }/*
@@ -99,40 +100,35 @@ static s64 __xe_shrinker_walk(struct xe_device *xe,* add writeback. This avoids stalls and explicit writebacks with light or * moderate memory pressure. */ -static s64 xe_shrinker_walk (struct xe_device *xe, +static int xe_shrinker_walk (struct xe_device *xe,struct ttm_operation_ctx *ctx,const struct xe_bo_shrink_flags flags, -unsigned long to_scan,unsigned long *scanned) +unsigned long to_scan,unsigned long *scanned, +unsigned long *freed) {bool no_wait_gpu = true;struct xe_bo_shrink_flags save_flags = flags; -s64 lret, freed; +int ret;swap (no_wait_gpu, ctx->no_wait_gpu); save_flags.writeback = false; - lret =__xe_shrinker_walk (xe, ctx, save_flags, to_scan, scanned); + ret =__xe_shrinker_walk (xe, ctx, save_flags, to_scan, scanned, freed);swap (no_wait_gpu, ctx->no_wait_gpu); -if (lret <0 || *scanned >= to_scan) -return lret; +if (ret || *scanned >= to_scan) +return ret; - freed = lret;if (!ctx->no_wait_gpu) { - lret =__xe_shrinker_walk (xe, ctx, save_flags, to_scan, scanned); -if (lret <0 ) -return lret; - freed += lret; -if (*scanned >= to_scan) -return freed; + ret =__xe_shrinker_walk (xe, ctx, save_flags, to_scan, scanned, + freed); +if (ret || *scanned >= to_scan) +return ret; } -if (flags.writeback) { - lret =__xe_shrinker_walk (xe, ctx, flags, to_scan, scanned); -if (lret <0 ) -return lret; - freed += lret; - } +if (flags.writeback) + ret =__xe_shrinker_walk (xe, ctx, flags, to_scan, scanned, + freed); -return freed; +return ret; } static unsigned long
@@ -214,7 +210,6 @@ static unsigned long xe_shrinker_scan(struct shrinker *shrink, struct shrink_conbool runtime_pm;bool purgeable;bool can_backup = !!(sc->gfp_mask & __GFP_FS); -s64 lret; nr_to_scan = sc->nr_to_scan;
@@ -225,12 +220,9 @@ static unsigned long xe_shrinker_scan(struct shrinker *shrink, struct shrink_con/* Might need runtime PM. Try to wake early if it looks like it. */ runtime_pm =xe_shrinker_runtime_pm_get (shrinker, false, nr_to_scan, can_backup); -if (purgeable && nr_scanned < nr_to_scan) { - lret =xe_shrinker_walk (shrinker->xe, &ctx, shrink_flags, - nr_to_scan, &nr_scanned); -if (lret >=0 ) - freed += lret; - } +if (purgeable && nr_scanned < nr_to_scan) +xe_shrinker_walk (shrinker->xe, &ctx, shrink_flags, + nr_to_scan, &nr_scanned, &freed); sc->nr_scanned = nr_scanned;if (nr_scanned >= nr_to_scan || !can_backup)
@@ -242,10 +234,8 @@ static unsigned long xe_shrinker_scan(struct shrinker *shrink, struct shrink_con shrink_flags.purge = false; - lret =xe_shrinker_walk (shrinker->xe, &ctx, shrink_flags, - nr_to_scan, &nr_scanned); -if (lret >=0 ) - freed += lret; +xe_shrinker_walk (shrinker->xe, &ctx, shrink_flags, + nr_to_scan, &nr_scanned, &freed); sc->nr_scanned = nr_scanned; out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 123/398 drm/vc4: Use managed KMS polling to fix UAF on unbind
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 073a30d75f309812ed61af134f24ffef4107b13a ]
vc4_kms_load() calls drm_kms_helper_poll_init() but the driver provides no matching drm_kms_helper_poll_fini(). The output poll work stays scheduled after unbind and runs on the freed drm_device:
# modprobe vc4; rmmod vc4; sleep 10 BUG: KASAN: slab-use-after-free in delayed_work_timer_fn BUG: KASAN: slab-use-after-free in drm_client_dev_hotplug [drm] Workqueue: events output_poll_execute [drm_kms_helper] Allocated by task 171: __devm_drm_dev_alloc Freed by task 262 (rmmod): drm_dev_put / component_del
Use drmm_kms_helper_poll_init() so polling is finalized with the device, as other drivers do.
--- drivers/gpu/drm/vc4/vc4_kms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_kms.c +1 -1
@@ -1162,7 +1162,7 @@ int vc4_kms_load(struct drm_device *dev)drm_mode_config_reset (dev); -drm_kms_helper_poll_init (dev); +drmm_kms_helper_poll_init (dev);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 124/398 ALSA: hda: trace PCM open only after assigning a stream
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Slavin Liu <[email protected]>
[ Upstream commit c9e6e5f38bf75276605f1952b22285f5f3abcaff ]
Stream assignment can fail when hardware streams are exhausted. Move the tracepoint after the NULL check because its payload accesses the assigned stream tag.
Detected by static analysis and reviewed with AI-assisted source auditing.
--- sound/hda/common/controller.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/hda/common/controller.c +1 -1
@@ -584,11 +584,11 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)snd_hda_codec_pcm_get (apcm->info);mutex_lock (&chip->open_mutex); azx_dev =azx_assign_device (chip, substream); -trace_azx_pcm_open (chip, azx_dev);if (azx_dev ==NULL ) { err = -EBUSY ; goto unlock; } +trace_azx_pcm_open (chip, azx_dev); runtime->private_data = azx_dev; runtime->hw = azx_pcm_hw;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 125/398 wifi: ath11k: cleanup arsta in ath11k_mac_peer_cleanup_all()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Escande <[email protected]>
[ Upstream commit 820b8cff81c796ba20573e04722ab62500713f97 ]
When mac80211 removes a sta, it calls .sta_state() which in turn calls ath11k_mac_station_remove(). In that function we clean up both peers & arsta related resources.
But when the firmware crashes, ath11k calls ieee80211_restart_hw(), which assumes that all driver related resources are cleaned up beforehand. This cleanup is supposedly done by ath11k_mac_peer_cleanup_all() but does not in fact free arsta->rx_stats / tx_stats.
Extract the arsta cleanup from ath11k_mac_station_remove() into a new ath11k_mac_station_cleanup() and call it from both there and ath11k_mac_peer_cleanup_all().
This should handle kmemleaks reports like:
unreferenced object 0xffffff801ae66400 (size 1024): comm "hostapd", pid 1306, jiffies 4295011565 hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace (crc d61c08ec): kmemleak_alloc+0x3c/0x50 __kmalloc_cache_noprof+0x2b0/0x3e0 ath11k_mac_op_sta_state+0x1dc/0xb10 drv_sta_state+0xac/0x6f8 sta_info_insert_rcu+0x314/0x5e0 sta_info_insert+0x14/0x38 ieee80211_add_station+0x10c/0x1a0 nl80211_new_station+0x3e8/0x680 genl_family_rcv_msg_doit+0xc0/0x120 genl_rcv_msg+0x1b4/0x258 netlink_rcv_skb+0x4c/0x108 genl_rcv+0x38/0x60 netlink_unicast+0x190/0x278 netlink_sendmsg+0x15c/0x370 ____sys_sendmsg+0x120/0x290 ___sys_sendmsg+0x70/0xa0
Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.9.0.1-01977-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/mac.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath11k/mac.c +18 -7
@@ -873,6 +873,22 @@ static int ath11k_mac_set_kickout(struct ath11k_vif *arvif)return 0 ; } +static void ath11k_mac_station_cleanup (struct ieee80211_sta *sta) +{ +struct ath11k_sta *arsta; + +if (!sta) +return ; + + arsta =ath11k_sta_to_arsta (sta); + +kfree (arsta->tx_stats); + arsta->tx_stats =NULL ; + +kfree (arsta->rx_stats); + arsta->rx_stats =NULL ; +} +void ath11k_mac_peer_cleanup_all (struct ath11k *ar) {struct ath11k_peer *peer, *tmp;
@@ -885,6 +901,7 @@ void ath11k_mac_peer_cleanup_all(struct ath11k *ar)list_for_each_entry_safe (peer, tmp, &ab->peers, list) {ath11k_peer_rx_tid_cleanup (ar, peer);ath11k_peer_rhash_delete (ab, peer); +ath11k_mac_station_cleanup (peer->sta);list_del (&peer->list);kfree (peer); }
@@ -9720,7 +9737,6 @@ static int ath11k_mac_station_remove(struct ath11k *ar, {struct ath11k_base *ab = ar->ab;struct ath11k_vif *arvif =ath11k_vif_to_arvif (vif); -struct ath11k_sta *arsta =ath11k_sta_to_arsta (sta);int ret; if (ab->hw_params.vdev_start_delay &&
@@ -9744,12 +9760,7 @@ static int ath11k_mac_station_remove(struct ath11k *ar, sta->addr, arvif->vdev_id);ath11k_mac_dec_num_stations (arvif, sta); - -kfree (arsta->tx_stats); - arsta->tx_stats =NULL ; - -kfree (arsta->rx_stats); - arsta->rx_stats =NULL ; +ath11k_mac_station_cleanup (sta);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 126/398 btrfs: tree-checker: print dev extent offset in error message
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit a1167d9420474ab9ed9efca99d86aeb6217c0265 ]
If a dev extent's offset is not sector size aligned, the error message is printing the dev extent's objectid instead of the offset. This is a copy paste error, as before this check we check the objectid field.
--- fs/btrfs/tree-checker.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/tree-checker.c +1 -1
@@ -1925,7 +1925,7 @@ static int check_dev_extent_item(const struct extent_buffer *leaf, sectorsize))) {generic_err (leaf, slot,"invalid dev extent chunk offset, has %llu not aligned to %u" , -btrfs_dev_extent_chunk_objectid (leaf, de), +btrfs_dev_extent_chunk_offset (leaf, de), sectorsize);return -EUCLEAN ; }
Signature · 1 line
2.53.0