4.14.315-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainercover 4.14.315-rc1 review
This is the start of the stable review cycle for the 4.14.315 release. There are 116 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 17 May 2023 16:16:37 +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/v4.x/stable-review/patch-4.14.315-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-4.14.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 4.14.315-rc1
Tetsuo Handa <[email protected]>
mm/page_alloc: fix potential deadlock on zonelist_update_seq seqlock
Tetsuo Handa <[email protected]>
printk: declare printk_deferred_{enter,safe}() in include/linux/printk.h
Christoph Böhmwalder <[email protected]>
drbd: correctly submit flush bio on barrier
Ilpo Järvinen <[email protected]>
serial: 8250: Fix serial8250_tx_empty() race with DMA Tx
Ilpo Järvinen <[email protected]>
tty: Prevent writing chars during tcsetattr TCSADRAIN/FLUSH
Arnaldo Carvalho de Melo <[email protected]>
perf bench: Share some global variables to fix build with gcc 10
Theodore Ts'o <[email protected]>
ext4: fix invalid free tracking in ext4_xattr_move_to_block()
Theodore Ts'o <[email protected]>
ext4: remove a BUG_ON in ext4_mb_release_group_pa()
Theodore Ts'o <[email protected]>
ext4: bail out of ext4_xattr_ibody_get() fails for any reason
Theodore Ts'o <[email protected]>
ext4: add bounds checking in get_max_inline_xattr_value_size()
Theodore Ts'o <[email protected]>
ext4: improve error recovery code paths in __ext4_remount()
Tudor Ambarus <[email protected]>
ext4: avoid a potential slab-out-of-bounds in ext4_group_desc_csum
Ping Cheng <[email protected]>
HID: wacom: Set a default resolution for older tablets
Krzysztof Kozlowski <[email protected]>
ARM: dts: s5pv210: correct MIPI CSIS clock name
Krzysztof Kozlowski <[email protected]>
ARM: dts: exynos: fix WM8960 clock name in Itop Elite
Randy Dunlap <[email protected]>
sh: nmi_debug: fix return value of __setup handler
Randy Dunlap <[email protected]>
sh: math-emu: fix macro redefined warning
Pawel Witek <[email protected]>
cifs: fix pcchunk length type in smb2_copychunk_range
Anastasia Belova <[email protected]>
btrfs: print-tree: parent bytenr must be aligned to sector size
Filipe Manana <[email protected]>
btrfs: fix btrfs_prev_leaf() to not return the same key twice
Yang Jihong <[email protected]>
perf symbols: Fix return incorrect build_id size in elf_read_build_id()
Markus Elfring <[email protected]>
perf map: Delete two variable initialisations before null pointer checks in sort__sym_from_cmp()
Kajol Jain <[email protected]>
perf vendor events power9: Remove UTF-8 characters from JSON files
Ruliang Lin <[email protected]>
ALSA: caiaq: input: Add error handling for unsupported input methods in snd_usb_caiaq_input_init
Kuniyuki Iwashima <[email protected]>
af_packet: Don't send zero-byte data in packet_sendmsg_spkt().
Victor Nogueira <[email protected]>
net/sched: act_mirred: Add carrier check
Maxim Korotkov <[email protected]>
writeback: fix call of incorrect macro
Cong Wang <[email protected]>
sit: update dev->needed_headroom in ipip6_tunnel_bind_dev()
Pablo Neira Ayuso <[email protected]>
netfilter: nf_tables: deactivate anonymous set from preparation phase
Pablo Neira Ayuso <[email protected]>
netfilter: nf_tables: bogus EBUSY when deleting set after flush
Pablo Neira Ayuso <[email protected]>
netfilter: nf_tables: use-after-free in failing rule with bound set
Pablo Neira Ayuso <[email protected]>
netfilter: nft_hash: fix nft_hash_deactivate
Pablo Neira Ayuso <[email protected]>
netfilter: nf_tables: unbind set in rule from commit path
Florian Westphal <[email protected]>
netfilter: nf_tables: split set destruction in deactivate and destroy phase
Adrian Hunter <[email protected]>
perf auxtrace: Fix address filter entire kernel size
Mike Snitzer <[email protected]>
dm ioctl: fix nested locking in table_clear() to remove deadlock concern
Mikulas Patocka <[email protected]>
dm flakey: fix a crash with invalid table line
Mike Snitzer <[email protected]>
dm integrity: call kmem_cache_destroy() in dm_integrity_init() error path
Stefan Haberland <[email protected]>
s390/dasd: fix hanging blockdevice after request requeue
Qu Wenruo <[email protected]>
btrfs: scrub: reject unsupported scrub flags
Quentin Schulz <[email protected]>
clk: rockchip: rk3399: allow clk_cifout to force clk_cifout_src to reparent
Bitterblue Smith <[email protected]>
wifi: rtl8xxxu: RTL8192EU always needs full init
Ryusuke Konishi <[email protected]>
nilfs2: fix infinite loop in nilfs_mdt_get_block()
Ryusuke Konishi <[email protected]>
nilfs2: do not write dirty data after degenerating to read-only
Helge Deller <[email protected]>
parisc: Fix argument pointer in real64_call_asm()
Claudiu Beznea <[email protected]>
dmaengine: at_xdmac: do not enable all cyclic channels
Gaosheng Cui <[email protected]>
phy: tegra: xusb: Add missing tegra_xusb_port_unregister for usb2_port and ulpi_port
Dai Ngo <[email protected]>
SUNRPC: remove the maximum number of retries in call_bind_status
Trond Myklebust <[email protected]>
NFSv4.1: Always send a RECLAIM_COMPLETE after establishing lease
Patrick Kelsey <[email protected]>
IB/hfi1: Fix SDMA mmu_rb_node not being evicted in LRU order
Clément Léger <[email protected]>
clk: add missing of_node_put() in "assigned-clocks" property parsing
Sebastian Reichel <[email protected]>
power: supply: generic-adc-battery: fix unit scaling
Natalia Petrova <[email protected]>
RDMA/rdmavt: Delete unnecessary NULL check
Yang Jihong <[email protected]>
perf/core: Fix hardlockup failure caused by perf throttle
Nathan Lynch <[email protected]>
powerpc/rtas: use memmove for potentially overlapping buffer copy
Randy Dunlap <[email protected]>
macintosh: via-pmu-led: requires ATA to be set
Randy Dunlap <[email protected]>
powerpc/sysdev/tsi108: fix resource printk format warnings
Randy Dunlap <[email protected]>
powerpc/wii: fix resource printk format warnings
Randy Dunlap <[email protected]>
powerpc/mpc512x: fix resource printk format warning
Liang He <[email protected]>
macintosh/windfarm_smu_sat: Add missing of_node_put()
Jishnu Prakash <[email protected]>
spmi: Add a check for remove callback when removing a SPMI driver
Philipp Hortmann <[email protected]>
staging: rtl8192e: Fix W_DISABLE# does not work after stop/start
Florian Fainelli <[email protected]>
serial: 8250: Add missing wakeup event reporting
Shenwei Wang <[email protected]>
tty: serial: fsl_lpuart: adjust buffer length to the intended size
Yinhao Hu <[email protected]>
usb: chipidea: fix missing goto in ci_hdrc_probe
John Paul Adrian Glaubitz <[email protected]>
sh: sq: Fix incorrect element size for allocating bitmap buffer
Kevin Brodsky <[email protected]>
uapi/linux/const.h: prefer ISO-friendly __typeof__
Randy Dunlap <[email protected]>
ia64: mm/contig: fix section mismatch warning/error
Miquel Raynal <[email protected]>
of: Fix modalias string generation
Christophe Leroy <[email protected]>
spi: fsl-spi: Fix CPM/QE mode Litte Endian
Randy Dunlap <[email protected]>
linux/vt_buffer.h: allow either builtin or modular for macros
John Stultz <[email protected]>
pstore: Revert pmsg_lock back to a normal mutex
Kuniyuki Iwashima <[email protected]>
tcp/udp: Fix memleaks of sk and zerocopy skbs with TX timestamp.
Gencen Gan <[email protected]>
net: amd: Fix link leak when verifying config failed
Liu Jian <[email protected]>
Revert "Bluetooth: btsdio: fix use after free bug in btsdio_remove due to unfinished work"
Ziyang Xuan <[email protected]>
ipv4: Fix potential uninit variable access bug in __ip_make_skb()
Joe Damato <[email protected]>
ixgbe: Enable setting RSS table to default values
Joe Damato <[email protected]>
ixgbe: Allow flow hash to be set via ethtool
Johannes Berg <[email protected]>
wifi: iwlwifi: mvm: check firmware response size
Emmanuel Grumbach <[email protected]>
wifi: iwlwifi: make the loop for card preparation effective
Yu Kuai <[email protected]>
md/raid10: fix leak of 'r10bio->remaining' for recovery
Danila Chernetsov <[email protected]>
scsi: megaraid: Fix mega_cmd_done() CMDID_INT_CMDS
Mike Christie <[email protected]>
scsi: target: iscsit: Fix TAS handling during conn cleanup
Eric Dumazet <[email protected]>
net/packet: convert po->auxdata to an atomic flag
Eric Dumazet <[email protected]>
net/packet: convert po->origdev to an atomic flag
Vadim Fedorenko <[email protected]>
vlan: partially enable SIOCSHWTSTAMP in container
Alexander Mikhalitsyn <[email protected]>
scm: fix MSG_CTRUNC setting condition for SO_PASSSEC
Fedor Pchelkin <[email protected]>
wifi: ath6kl: reduce WARN to dev_dbg() in callback
Dan Carpenter <[email protected]>
wifi: ath5k: fix an off by one check in ath5k_eeprom_read_freq_list()
Alexey V. Vissarionov <[email protected]>
wifi: ath6kl: minor fix for allocation size
Sumit Garg <[email protected]>
arm64: kgdb: Set PSTATE.SS to 1 to re-enable single-step
Saurabh Sengar <[email protected]>
x86/ioapic: Don't return 0 from arch_dynirq_lower_bound()
Zheng Wang <[email protected]>
media: dm1105: Fix use after free bug in dm1105_remove due to race condition
Uros Bizjak <[email protected]>
x86/apic: Fix atomic update of offset in reserve_eilvt_offset()
Dan Carpenter <[email protected]>
media: av7110: prevent underflow in write_ts_to_decoder()
Jiasheng Jiang <[email protected]>
media: bdisp: Add missing check for create_workqueue
Dom Cobley <[email protected]>
drm/probe-helper: Cancel previous job before starting new one
Maíra Canal <[email protected]>
drm/vgem: add missing mutex_destroy
Rob Clark <[email protected]>
drm/rockchip: Drop unbalanced obj unref
Paul Moore <[email protected]>
selinux: ensure av_permissions.h is built when needed
Ondrej Mosnacek <[email protected]>
selinux: fix Makefile dependencies of flask.h
Mårten Lindahl <[email protected]>
ubifs: Free memory for tmpfile name
Wang YanQing <[email protected]>
ubi: Fix return value overwrite issue in try_write_vid_and_data()
Zhihao Cheng <[email protected]>
Revert "ubifs: dirty_cow_znode: Fix memleak in error handling path"
Reid Tonking <[email protected]>
i2c: omap: Fix standard mode false ACK readings
Roberto Sassu <[email protected]>
reiserfs: Add security prefix to xattr name in reiserfs_security_write()
Johannes Berg <[email protected]>
ring-buffer: Sync IRQ works before buffer destruction
Jiaxun Yang <[email protected]>
MIPS: fw: Allow firmware to pass a empty env
Nuno Sá <[email protected]>
staging: iio: resolver: ads1210: fix config mode
Arnaldo Carvalho de Melo <[email protected]>
perf sched: Cast PTHREAD_STACK_MIN to int as it may turn into sysconf(__SC_THREAD_STACK_MIN_VALUE)
Johan Hovold <[email protected]>
USB: dwc3: fix runtime pm imbalance on unbind
Randy Dunlap <[email protected]>
IMA: allow/fix UML builds
Patrik Dahlström <[email protected]>
iio: adc: palmas_gpadc: fix NULL dereference on rmmod
Arınç ÜNAL <[email protected]>
USB: serial: option: add UNISOC vendor and TOZED LT70C product
Ruihan Li <[email protected]>
bluetooth: Perform careful capability checks in hci_sock_ioctl()
Jisoo Jang <[email protected]>
wifi: brcmfmac: slab-out-of-bounds read in brcmf_get_assoc_ies()
-------------
Diffstat:
Makefile | 4 +- arch/arm/boot/dts/exynos4412-itop-elite.dts | 2 +- arch/arm/boot/dts/s5pv210.dtsi | 2 +- arch/arm64/include/asm/debug-monitors.h | 1 + arch/arm64/kernel/debug-monitors.c | 5 + arch/arm64/kernel/kgdb.c | 2 + arch/ia64/mm/contig.c | 2 +- arch/mips/fw/lib/cmdline.c | 2 +- arch/parisc/kernel/real2.S | 5 +- arch/powerpc/kernel/rtas.c | 2 +- arch/powerpc/platforms/512x/clock-commonclk.c | 2 +- arch/powerpc/platforms/embedded6xx/flipper-pic.c | 2 +- arch/powerpc/platforms/embedded6xx/hlwd-pic.c | 2 +- arch/powerpc/platforms/embedded6xx/wii.c | 4 +- arch/powerpc/sysdev/tsi108_pci.c | 5 +- arch/sh/kernel/cpu/sh4/sq.c | 2 +- arch/sh/kernel/nmi_debug.c | 4 +- arch/sh/math-emu/sfp-util.h | 4 - arch/x86/kernel/apic/apic.c | 5 +- arch/x86/kernel/apic/io_apic.c | 14 ++- drivers/block/drbd/drbd_receiver.c | 2 +- drivers/bluetooth/btsdio.c | 1 - drivers/clk/clk-conf.c | 12 +- drivers/clk/rockchip/clk-rk3399.c | 2 +- drivers/dma/at_xdmac.c | 5 +- drivers/gpu/drm/drm_probe_helper.c | 5 +- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 3 - drivers/gpu/drm/vgem/vgem_fence.c | 1 + drivers/hid/wacom_wac.c | 12 +- drivers/i2c/busses/i2c-omap.c | 2 +- drivers/iio/adc/palmas_gpadc.c | 2 +- drivers/infiniband/hw/hfi1/mmu_rb.c | 13 +- drivers/infiniband/sw/rdmavt/qp.c | 2 - drivers/macintosh/Kconfig | 1 + drivers/macintosh/windfarm_smu_sat.c | 1 + drivers/md/dm-flakey.c | 4 +- drivers/md/dm-integrity.c | 8 +- drivers/md/dm-ioctl.c | 7 +- drivers/md/raid10.c | 23 ++-- drivers/media/pci/dm1105/dm1105.c | 1 + drivers/media/pci/ttpci/av7110_av.c | 4 +- drivers/media/platform/sti/bdisp/bdisp-v4l2.c | 2 + drivers/mtd/ubi/eba.c | 19 ++- drivers/net/ethernet/amd/nmclan_cs.c | 2 +- drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 23 ++-- drivers/net/wireless/ath/ath5k/eeprom.c | 2 +- drivers/net/wireless/ath/ath6kl/bmi.c | 2 +- drivers/net/wireless/ath/ath6kl/htc_pipe.c | 4 +- .../broadcom/brcm80211/brcmfmac/cfg80211.c | 5 + drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | 10 ++ drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 3 +- .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c | 1 + drivers/of/device.c | 7 +- drivers/phy/tegra/xusb.c | 2 + drivers/power/supply/generic-adc-battery.c | 3 + drivers/s390/block/dasd.c | 2 +- drivers/scsi/megaraid.c | 1 + drivers/spi/spi-fsl-spi.c | 12 +- drivers/spmi/spmi.c | 3 +- drivers/staging/iio/resolver/ad2s1210.c | 2 +- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 1 + drivers/target/iscsi/iscsi_target.c | 16 +-- drivers/tty/serial/8250/8250.h | 12 ++ drivers/tty/serial/8250/8250_port.c | 16 ++- drivers/tty/serial/fsl_lpuart.c | 2 +- drivers/tty/tty_io.c | 4 +- drivers/tty/tty_ioctl.c | 47 +++++-- drivers/usb/chipidea/core.c | 2 +- drivers/usb/dwc3/core.c | 1 + drivers/usb/serial/option.c | 6 + fs/btrfs/ctree.c | 32 ++++- fs/btrfs/ioctl.c | 5 + fs/btrfs/print-tree.c | 6 +- fs/cifs/smb2ops.c | 2 +- fs/ext4/inline.c | 14 ++- fs/ext4/mballoc.c | 6 +- fs/ext4/super.c | 19 +-- fs/ext4/xattr.c | 5 +- fs/fs-writeback.c | 2 +- fs/nfs/nfs4state.c | 4 + fs/nilfs2/bmap.c | 16 ++- fs/nilfs2/segment.c | 5 +- fs/pstore/pmsg.c | 7 +- fs/reiserfs/xattr_security.c | 8 +- fs/ubifs/dir.c | 1 + fs/ubifs/tnc.c | 9 +- include/linux/printk.h | 19 +++ include/linux/sunrpc/sched.h | 3 +- include/linux/tty.h | 2 + include/linux/vt_buffer.h | 2 +- include/net/netfilter/nf_tables.h | 30 ++++- include/net/scm.h | 13 +- include/uapi/linux/btrfs.h | 1 + include/uapi/linux/const.h | 2 +- kernel/events/core.c | 4 +- kernel/trace/ring_buffer.c | 4 + mm/page_alloc.c | 16 +++ net/8021q/vlan_dev.c | 2 +- net/bluetooth/hci_sock.c | 9 +- net/core/skbuff.c | 3 + net/ipv4/ip_output.c | 16 ++- net/ipv6/sit.c | 8 +- net/netfilter/nf_tables_api.c | 139 +++++++++++++++------ net/netfilter/nft_dynset.c | 22 +++- net/netfilter/nft_immediate.c | 6 +- net/netfilter/nft_lookup.c | 21 +++- net/netfilter/nft_objref.c | 21 +++- net/netfilter/nft_set_hash.c | 2 +- net/packet/af_packet.c | 20 ++- net/packet/diag.c | 4 +- net/packet/internal.h | 26 +++- net/sched/act_mirred.c | 2 +- net/sunrpc/clnt.c | 3 - net/sunrpc/sched.c | 1 - security/integrity/ima/Kconfig | 2 +- security/selinux/Makefile | 4 +- sound/usb/caiaq/input.c | 1 + tools/perf/bench/bench.h | 4 + tools/perf/bench/futex-hash.c | 12 +- tools/perf/bench/futex-lock-pi.c | 11 +- tools/perf/builtin-sched.c | 2 +- .../perf/pmu-events/arch/powerpc/power9/other.json | 4 +- .../pmu-events/arch/powerpc/power9/pipeline.json | 2 +- tools/perf/util/auxtrace.c | 5 +- tools/perf/util/sort.c | 3 +- tools/perf/util/symbol-elf.c | 2 +- 126 files changed, 708 insertions(+), 280 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/116 wifi: brcmfmac: slab-out-of-bounds read in brcmf_get_assoc_ies()
From: Jisoo Jang <[email protected]>
commit 0da40e018fd034d87c9460123fa7f897b69fdee7 upstream.
Fix a slab-out-of-bounds read that occurs in kmemdup() called from brcmf_get_assoc_ies().
The bug could occur when assoc_info->req_len, data from a URB provided by a USB device, is bigger than the size of buffer which is defined as WL_EXTRA_BUF_MAX.
Add the size check for req_len/resp_len of assoc_info.
Found by a modified version of syzkaller.
[ 46.592467][ T7] ================================================================== [ 46.594687][ T7] BUG: KASAN: slab-out-of-bounds in kmemdup+0x3e/0x50 [ 46.596572][ T7] Read of size 3014656 at addr ffff888019442000 by task kworker/0:1/7 [ 46.598575][ T7] [ 46.599157][ T7] CPU: 0 PID: 7 Comm: kworker/0:1 Tainted: G O 5.14.0+ #145 [ 46.601333][ T7] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014 [ 46.604360][ T7] Workqueue: events brcmf_fweh_event_worker [ 46.605943][ T7] Call Trace: [ 46.606584][ T7] dump_stack_lvl+0x8e/0xd1 [ 46.607446][ T7] print_address_description.constprop.0.cold+0x93/0x334 [ 46.608610][ T7] ? kmemdup+0x3e/0x50 [ 46.609341][ T7] kasan_report.cold+0x79/0xd5 [ 46.610151][ T7] ? kmemdup+0x3e/0x50 [ 46.610796][ T7] kasan_check_range+0x14e/0x1b0 [ 46.611691][ T7] memcpy+0x20/0x60 [ 46.612323][ T7] kmemdup+0x3e/0x50 [ 46.612987][ T7] brcmf_get_assoc_ies+0x967/0xf60 [ 46.613904][ T7] ? brcmf_notify_vif_event+0x3d0/0x3d0 [ 46.614831][ T7] ? lock_chain_count+0x20/0x20 [ 46.615683][ T7] ? mark_lock.part.0+0xfc/0x2770 [ 46.616552][ T7] ? lock_chain_count+0x20/0x20 [ 46.617409][ T7] ? mark_lock.part.0+0xfc/0x2770 [ 46.618244][ T7] ? lock_chain_count+0x20/0x20 [ 46.619024][ T7] brcmf_bss_connect_done.constprop.0+0x241/0x2e0 [ 46.620019][ T7] ? brcmf_parse_configure_security.isra.0+0x2a0/0x2a0 [ 46.620818][ T7] ? __lock_acquire+0x181f/0x5790 [ 46.621462][ T7] brcmf_notify_connect_status+0x448/0x1950 [ 46.622134][ T7] ? rcu_read_lock_bh_held+0xb0/0xb0 [ 46.622736][ T7] ? brcmf_cfg80211_join_ibss+0x7b0/0x7b0 [ 46.623390][ T7] ? find_held_lock+0x2d/0x110 [ 46.623962][ T7] ? brcmf_fweh_event_worker+0x19f/0xc60 [ 46.624603][ T7] ? mark_held_locks+0x9f/0xe0 [ 46.625145][ T7] ? lockdep_hardirqs_on_prepare+0x3e0/0x3e0 [ 46.625871][ T7] ? brcmf_cfg80211_join_ibss+0x7b0/0x7b0 [ 46.626545][ T7] brcmf_fweh_call_event_handler.isra.0+0x90/0x100 [ 46.627338][ T7] brcmf_fweh_event_worker+0x557/0xc60 [ 46.627962][ T7] ? brcmf_fweh_call_event_handler.isra.0+0x100/0x100 [ 46.628736][ T7] ? rcu_read_lock_sched_held+0xa1/0xd0 [ 46.629396][ T7] ? rcu_read_lock_bh_held+0xb0/0xb0 [ 46.629970][ T7] ? lockdep_hardirqs_on_prepare+0x273/0x3e0 [ 46.630649][ T7] process_one_work+0x92b/0x1460 [ 46.631205][ T7] ? pwq_dec_nr_in_flight+0x330/0x330 [ 46.631821][ T7] ? rwlock_bug.part.0+0x90/0x90 [ 46.632347][ T7] worker_thread+0x95/0xe00 [ 46.632832][ T7] ? __kthread_parkme+0x115/0x1e0 [ 46.633393][ T7] ? process_one_work+0x1460/0x1460 [ 46.633957][ T7] kthread+0x3a1/0x480 [ 46.634369][ T7] ? set_kthread_struct+0x120/0x120 [ 46.634933][ T7] ret_from_fork+0x1f/0x30 [ 46.635431][ T7] [ 46.635687][ T7] Allocated by task 7: [ 46.636151][ T7] kasan_save_stack+0x1b/0x40 [ 46.636628][ T7] __kasan_kmalloc+0x7c/0x90 [ 46.637108][ T7] kmem_cache_alloc_trace+0x19e/0x330 [ 46.637696][ T7] brcmf_cfg80211_attach+0x4a0/0x4040 [ 46.638275][ T7] brcmf_attach+0x389/0xd40 [ 46.638739][ T7] brcmf_usb_probe+0x12de/0x1690 [ 46.639279][ T7] usb_probe_interface+0x2aa/0x760 [ 46.639820][ T7] really_probe+0x205/0xb70 [ 46.640342][ T7] __driver_probe_device+0x311/0x4b0 [ 46.640876][ T7] driver_probe_device+0x4e/0x150 [ 46.641445][ T7] __device_attach_driver+0x1cc/0x2a0 [ 46.642000][ T7] bus_for_each_drv+0x156/0x1d0 [ 46.642543][ T7] __device_attach+0x23f/0x3a0 [ 46.643065][ T7] bus_probe_device+0x1da/0x290 [ 46.643644][ T7] device_add+0xb7b/0x1eb0 [ 46.644130][ T7] usb_set_configuration+0xf59/0x16f0 [ 46.644720][ T7] usb_generic_driver_probe+0x82/0xa0 [ 46.645295][ T7] usb_probe_device+0xbb/0x250 [ 46.645786][ T7] really_probe+0x205/0xb70 [ 46.646258][ T7] __driver_probe_device+0x311/0x4b0 [ 46.646804][ T7] driver_probe_device+0x4e/0x150 [ 46.647387][ T7] __device_attach_driver+0x1cc/0x2a0 [ 46.647926][ T7] bus_for_each_drv+0x156/0x1d0 [ 46.648454][ T7] __device_attach+0x23f/0x3a0 [ 46.648939][ T7] bus_probe_device+0x1da/0x290 [ 46.649478][ T7] device_add+0xb7b/0x1eb0 [ 46.649936][ T7] usb_new_device.cold+0x49c/0x1029 [ 46.650526][ T7] hub_event+0x1c98/0x3950 [ 46.650975][ T7] process_one_work+0x92b/0x1460 [ 46.651535][ T7] worker_thread+0x95/0xe00 [ 46.651991][ T7] kthread+0x3a1/0x480 [ 46.652413][ T7] ret_from_fork+0x1f/0x30 [ 46.652885][ T7] [ 46.653131][ T7] The buggy address belongs to the object at ffff888019442000 [ 46.653131][ T7] which belongs to the cache kmalloc-2k of size 2048 [ 46.654669][ T7] The buggy address is located 0 bytes inside of [ 46.654669][ T7] 2048-byte region [ffff888019442000, ffff888019442800) [ 46.656137][ T7] The buggy address belongs to the page: [ 46.656720][ T7] page:ffffea0000651000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x19440 [ 46.657792][ T7] head:ffffea0000651000 order:3 compound_mapcount:0 compound_pincount:0 [ 46.658673][ T7] flags: 0x100000000010200(slab|head|node=0|zone=1) [ 46.659422][ T7] raw: 0100000000010200 0000000000000000 dead000000000122 ffff888100042000 [ 46.660363][ T7] raw: 0000000000000000 0000000000080008 00000001ffffffff 0000000000000000 [ 46.661236][ T7] page dumped because: kasan: bad access detected [ 46.661956][ T7] page_owner tracks the page as allocated [ 46.662588][ T7] page last allocated via order 3, migratetype Unmovable, gfp_mask 0x52a20(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 7, ts 31136961085, free_ts 0 [ 46.664271][ T7] prep_new_page+0x1aa/0x240 [ 46.664763][ T7] get_page_from_freelist+0x159a/0x27c0 [ 46.665340][ T7] __alloc_pages+0x2da/0x6a0 [ 46.665847][ T7] alloc_pages+0xec/0x1e0 [ 46.666308][ T7] allocate_slab+0x380/0x4e0 [ 46.666770][ T7] ___slab_alloc+0x5bc/0x940 [ 46.667264][ T7] __slab_alloc+0x6d/0x80 [ 46.667712][ T7] kmem_cache_alloc_trace+0x30a/0x330 [ 46.668299][ T7] brcmf_usbdev_qinit.constprop.0+0x50/0x470 [ 46.668885][ T7] brcmf_usb_probe+0xc97/0x1690 [ 46.669438][ T7] usb_probe_interface+0x2aa/0x760 [ 46.669988][ T7] really_probe+0x205/0xb70 [ 46.670487][ T7] __driver_probe_device+0x311/0x4b0 [ 46.671031][ T7] driver_probe_device+0x4e/0x150 [ 46.671604][ T7] __device_attach_driver+0x1cc/0x2a0 [ 46.672192][ T7] bus_for_each_drv+0x156/0x1d0 [ 46.672739][ T7] page_owner free stack trace missing [ 46.673335][ T7] [ 46.673620][ T7] Memory state around the buggy address: [ 46.674213][ T7] ffff888019442700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 46.675083][ T7] ffff888019442780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 46.675994][ T7] >ffff888019442800: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [ 46.676875][ T7] ^ [ 46.677323][ T7] ffff888019442880: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [ 46.678190][ T7] ffff888019442900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [ 46.679052][ T7] ================================================================== [ 46.679945][ T7] Disabling lock debugging due to kernel taint [ 46.680725][ T7] Kernel panic - not syncing:
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +5 -0
@@ -5458,6 +5458,11 @@ static s32 brcmf_get_assoc_ies(struct br (struct brcmf_cfg80211_assoc_ielen_le *)cfg->extra_buf; req_len =le32_to_cpu (assoc_info->req_len); resp_len =le32_to_cpu (assoc_info->resp_len); +if (req_len >WL_EXTRA_BUF_MAX || resp_len >WL_EXTRA_BUF_MAX ) { +brcmf_err ("invalid lengths in assoc info: req %u resp %u\n" , + req_len, resp_len); +return -EINVAL ; + }if (req_len) { err = brcmf_fil_iovar_data_get(ifp, "assoc_req_ies", cfg->extra_buf,
Greg Kroah-Hartman
maintainerPATCH 2/116 bluetooth: Perform careful capability checks in hci_sock_ioctl()
In reply to Greg Kroah-HartmanFrom: Ruihan Li <[email protected]>
commit 25c150ac103a4ebeed0319994c742a90634ddf18 upstream.
Previously, capability was checked using capable(), which verified that the caller of the ioctl system call had the required capability. In addition, the result of the check would be stored in the HCI_SOCK_TRUSTED flag, making it persistent for the socket.
However, malicious programs can abuse this approach by deliberately sharing an HCI socket with a privileged task. The HCI socket will be marked as trusted when the privileged task occasionally makes an ioctl call.
This problem can be solved by using sk_capable() to check capability, which ensures that not only the current task but also the socket opener has the specified capability, thus reducing the risk of privilege escalation through the previously identified vulnerability.
--- net/bluetooth/hci_sock.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
net/bluetooth/hci_sock.c +8 -1
@@ -984,7 +984,14 @@ static int hci_sock_ioctl(struct socketif (hci_sock_gen_cookie (sk)) {struct sk_buff *skb; -if (capable (CAP_NET_ADMIN )) +/* Perform careful checks before setting the HCI_SOCK_TRUSTED +* flag. Make sure that not only the current task but also +* the socket opener has the required capability, since +* privileged programs can be tricked into making ioctl calls +* on HCI sockets, and the socket should not be marked as +* trusted simply because the ioctl caller is privileged. +*/ +if (sk_capable (sk,CAP_NET_ADMIN ))hci_sock_set_flag (sk,HCI_SOCK_TRUSTED );/* Send event to monitor */
Greg Kroah-Hartman
maintainerPATCH 3/116 USB: serial: option: add UNISOC vendor and TOZED LT70C product
In reply to Greg Kroah-HartmanFrom: Arınç ÜNAL <[email protected]>
commit a095edfc15f0832e046ae23964e249ef5c95af87 upstream.
Add UNISOC vendor ID and TOZED LT70-C modem which is based from UNISOC SL8563. The modem supports the NCM mode. Interface 0 is used for running the AT commands. Interface 12 is the ADB interface.
T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 6 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=1782 ProdID=4055 Rev=04.04 S: Manufacturer=Unisoc Phone S: Product=Unisoc Phone S: SerialNumber=<redacted> C: #Ifs=14 Cfg#= 1 Atr=c0 MxPwr=500mA I: If#= 0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=0d Prot=00 Driver=cdc_ncm E: Ad=82(I) Atr=03(Int.) MxPS= 16 Ivl=32ms I: If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=01 Driver=cdc_ncm E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I: If#=10 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=07(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=8b(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I: If#=11 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=08(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=8c(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I: If#=12 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=(none) E: Ad=09(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=8d(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I: If#=13 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=0a(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=8e(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I: If#= 2 Alt= 0 #EPs= 1 Cls=02(commc) Sub=0d Prot=00 Driver=cdc_ncm E: Ad=84(I) Atr=03(Int.) MxPS= 16 Ivl=32ms I: If#= 3 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=01 Driver=cdc_ncm E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I: If#= 4 Alt= 0 #EPs= 1 Cls=02(commc) Sub=0d Prot=00 Driver=cdc_ncm E: Ad=86(I) Atr=03(Int.) MxPS= 16 Ivl=32ms I: If#= 5 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=01 Driver=cdc_ncm E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I: If#= 6 Alt= 0 #EPs= 1 Cls=02(commc) Sub=0d Prot=00 Driver=cdc_ncm E: Ad=88(I) Atr=03(Int.) MxPS= 16 Ivl=32ms I: If#= 7 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=01 Driver=cdc_ncm E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=87(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I: If#= 8 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=89(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I: If#= 9 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=06(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=8a(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
--- drivers/usb/serial/option.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/usb/serial/option.c +6 -0
@@ -598,6 +598,11 @@ static void option_instat_callback(struc#define SIERRA_VENDOR_ID 0x1199#define SIERRA_PRODUCT_EM9191 0x90d3 +/* UNISOC (Spreadtrum) products */ +#define UNISOC_VENDOR_ID 0x1782 +/* TOZED LT70-C based on UNISOC SL8563 uses UNISOC's vendor ID */ +#define TOZED_PRODUCT_LT70C 0x4055 +/* Device flags */ /* Highest interface number which can be used with NCTRL() and RSVD() */
@@ -2227,6 +2232,7 @@ static const struct usb_device_id option { USB_DEVICE_AND_INTERFACE_INFO(OPPO_VENDOR_ID, OPPO_PRODUCT_R11, 0xff, 0xff, 0x30) }, { USB_DEVICE_AND_INTERFACE_INFO(SIERRA_VENDOR_ID, SIERRA_PRODUCT_EM9191, 0xff, 0xff, 0x30) }, { USB_DEVICE_AND_INTERFACE_INFO(SIERRA_VENDOR_ID, SIERRA_PRODUCT_EM9191, 0xff, 0, 0) }, + { USB_DEVICE_AND_INTERFACE_INFO(UNISOC_VENDOR_ID, TOZED_PRODUCT_LT70C, 0xff, 0, 0) }, { } /* Terminating entry */ };MODULE_DEVICE_TABLE (usb, option_ids);
Greg Kroah-Hartman
maintainerPATCH 4/116 iio: adc: palmas_gpadc: fix NULL dereference on rmmod
In reply to Greg Kroah-HartmanFrom: Patrik Dahlström <[email protected]>
[ Upstream commit 49f76c499d38bf67803438eee88c8300d0f6ce09 ]
Calling dev_to_iio_dev() on a platform device pointer is undefined and will make adc NULL.
--- drivers/iio/adc/palmas_gpadc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/palmas_gpadc.c +1 -1
@@ -634,7 +634,7 @@ static int palmas_gpadc_probe(struct platform_device *pdev)static int palmas_gpadc_remove (struct platform_device *pdev) { -struct iio_dev *indio_dev =dev_to_iio_dev (&pdev->dev); +struct iio_dev *indio_dev =dev_get_drvdata (&pdev->dev);struct palmas_gpadc *adc =iio_priv (indio_dev);if (adc->wakeup1_enable || adc->wakeup2_enable)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 5/116 IMA: allow/fix UML builds
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
commit 644f17412f5acf01a19af9d04a921937a2bc86c6 upstream.
UML supports HAS_IOMEM since 0bbadafdc49d (um: allow disabling NO_IOMEM).
Current IMA build on UML fails on allmodconfig (with TCG_TPM=m):
ld: security/integrity/ima/ima_queue.o: in function `ima_add_template_entry':
ima_queue.c:(.text+0x2d9): undefined reference to `tpm_pcr_extend'
ld: security/integrity/ima/ima_init.o: in function `ima_init':
ima_init.c:(.init.text+0x43f): undefined reference to `tpm_default_chip'
ld: security/integrity/ima/ima_crypto.o: in function `ima_calc_boot_aggregate_tfm':
ima_crypto.c:(.text+0x1044): undefined reference to `tpm_pcr_read'
ld: ima_crypto.c:(.text+0x10d8): undefined reference to `tpm_pcr_read'
Modify the IMA Kconfig entry so that it selects TCG_TPM if HAS_IOMEM is set, regardless of the UML Kconfig setting.
This updates TCG_TPM from =m to =y and fixes the linker errors.
--- security/integrity/ima/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/integrity/ima/Kconfig +1 -1
@@ -8,7 +8,7 @@ config IMA select CRYPTO_MD5 select CRYPTO_SHA1 select CRYPTO_HASH_INFO - select TCG_TPM if HAS_IOMEM && !UML + select TCG_TPM if HAS_IOMEM select TCG_TIS if TCG_TPM && X86 select TCG_CRB if TCG_TPM && ACPI select TCG_IBMVTPM if TCG_TPM && PPC_PSERIES
Greg Kroah-Hartman
maintainerPATCH 6/116 USB: dwc3: fix runtime pm imbalance on unbind
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 44d257e9012ee8040e41d224d0e5bfb5ef5427ea upstream.
Make sure to balance the runtime PM usage count on driver unbind by adding back the pm_runtime_allow() call that had been erroneously removed.
--- drivers/usb/dwc3/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/dwc3/core.c +1 -0
@@ -1348,6 +1348,7 @@ static int dwc3_remove(struct platform_ddwc3_core_exit (dwc);dwc3_ulpi_exit (dwc); +pm_runtime_allow (&pdev->dev);pm_runtime_disable (&pdev->dev);pm_runtime_put_noidle (&pdev->dev);pm_runtime_set_suspended (&pdev->dev);
Greg Kroah-Hartman
maintainerPATCH 7/116 perf sched: Cast PTHREAD_STACK_MIN to int as it may turn into sysconf(__SC_THREAD_STACK_MIN_VALUE)
In reply to Greg Kroah-HartmanFrom: Arnaldo Carvalho de Melo <[email protected]>
commit d08c84e01afa7a7eee6badab25d5420fa847f783 upstream.
In fedora rawhide the PTHREAD_STACK_MIN define may end up expanded to a sysconf() call, and that will return 'long int', breaking the build:
45 fedora:rawhide : FAIL gcc version 11.1.1 20210623 (Red Hat 11.1.1-6) (GCC)
builtin-sched.c: In function 'create_tasks':
/git/perf-5.14.0-rc1/tools/include/linux/kernel.h:43:24: error: comparison of distinct pointer types lacks a cast [-Werror]
43 | (void) (&_max1 == &_max2); \
| ^~
builtin-sched.c:673:34: note: in expansion of macro 'max'
673 | (size_t) max(16 * 1024, PTHREAD_STACK_MIN));
| ^~~
cc1: all warnings being treated as errors
$ grep __sysconf /usr/include/*/*.h /usr/include/bits/pthread_stack_min-dynamic.h:extern long int __sysconf (int __name) __THROW; /usr/include/bits/pthread_stack_min-dynamic.h:# define PTHREAD_STACK_MIN __sysconf (__SC_THREAD_STACK_MIN_VALUE) /usr/include/bits/time.h:extern long int __sysconf (int); /usr/include/bits/time.h:# define CLK_TCK ((__clock_t) __sysconf (2)) /* 2 is _SC_CLK_TCK */ $
So cast it to int to cope with that.
--- tools/perf/builtin-sched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-sched.c +1 -1
@@ -655,7 +655,7 @@ static void create_tasks(struct perf_sch err =pthread_attr_init (&attr);BUG_ON (err); err =pthread_attr_setstacksize (&attr, - (size_t )max (16 *1024 ,PTHREAD_STACK_MIN )); + (size_t )max (16 *1024 , (int )PTHREAD_STACK_MIN ));BUG_ON (err); err =pthread_mutex_lock (&sched->start_work_mutex);BUG_ON (err);
Greg Kroah-Hartman
maintainerPATCH 8/116 staging: iio: resolver: ads1210: fix config mode
In reply to Greg Kroah-HartmanFrom: Nuno Sá <[email protected]>
commit 16313403d873ff17a587818b61f84c8cb4971cef upstream.
As stated in the device datasheet [1], bits a0 and a1 have to be set to 1 for the configuration mode.
[1]: https://www.analog.com/media/en/technical-documentation/data-sheets/ad2s1210.pdf
--- drivers/staging/iio/resolver/ad2s1210.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/resolver/ad2s1210.c +1 -1
@@ -96,7 +96,7 @@ struct ad2s1210_state {static const int ad2s1210_mode_vals[4 ][2 ] = { [MOD_POS ] = {0 ,0 }, [MOD_VEL ] = {0 ,1 }, - [MOD_CONFIG ] = {1 ,0 }, + [MOD_CONFIG ] = {1 ,1 }, }; static inline void ad2s1210_set_mode(enum ad2s1210_mode mode,
Greg Kroah-Hartman
maintainerPATCH 9/116 MIPS: fw: Allow firmware to pass a empty env
In reply to Greg Kroah-HartmanFrom: Jiaxun Yang <[email protected]>
commit ee1809ed7bc456a72dc8410b475b73021a3a68d5 upstream.
fw_getenv will use env entry to determine style of env, however it is legal for firmware to just pass a empty list.
Check if first entry exist before running strchr to avoid null pointer dereference.
--- arch/mips/fw/lib/cmdline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/fw/lib/cmdline.c +1 -1
@@ -51,7 +51,7 @@ char *fw_getenv(char *envname) {char *result =NULL ; -if (_fw_envp !=NULL ) { +if (_fw_envp !=NULL &&fw_envp (0 ) !=NULL ) {/* * Return a pointer to the given environment variable. * YAMON uses "name", "value" pairs, while U-Boot uses
Greg Kroah-Hartman
maintainerPATCH 10/116 ring-buffer: Sync IRQ works before buffer destruction
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
commit 675751bb20634f981498c7d66161584080cc061e upstream.
If something was written to the buffer just before destruction, it may be possible (maybe not in a real system, but it did happen in ARCH=um with time-travel) to destroy the ringbuffer before the IRQ work ran, leading this KASAN report (or a crash without KASAN):
BUG: KASAN: slab-use-after-free in irq_work_run_list+0x11a/0x13a
Read of size 8 at addr 000000006d640a48 by task swapper/0
CPU: 0 PID: 0 Comm: swapper Tainted: G W O 6.3.0-rc1 #7
Stack:
60c4f20f 0c203d48 41b58ab3 60f224fc
600477fa 60f35687 60c4f20f 601273dd
00000008 6101eb00 6101eab0 615be548
Call Trace:
[<60047a58>] show_stack+0x25e/0x282
[<60c609e0>] dump_stack_lvl+0x96/0xfd
[<60c50d4c>] print_report+0x1a7/0x5a8
[<603078d3>] kasan_report+0xc1/0xe9
[<60308950>] __asan_report_load8_noabort+0x1b/0x1d
[<60232844>] irq_work_run_list+0x11a/0x13a
[<602328b4>] irq_work_tick+0x24/0x34
[<6017f9dc>] update_process_times+0x162/0x196
[<6019f335>] tick_sched_handle+0x1a4/0x1c3
[<6019fd9e>] tick_sched_timer+0x79/0x10c
[<601812b9>] __hrtimer_run_queues.constprop.0+0x425/0x695
[<60182913>] hrtimer_interrupt+0x16c/0x2c4
[<600486a3>] um_timer+0x164/0x183
[...]
Allocated by task 411:
save_stack_trace+0x99/0xb5
stack_trace_save+0x81/0x9b
kasan_save_stack+0x2d/0x54
kasan_set_track+0x34/0x3e
kasan_save_alloc_info+0x25/0x28
____kasan_kmalloc+0x8b/0x97
__kasan_kmalloc+0x10/0x12
__kmalloc+0xb2/0xe8
load_elf_phdrs+0xee/0x182
[...]
The buggy address belongs to the object at 000000006d640800
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 584 bytes inside of
freed 1024-byte region [000000006d640800, 000000006d640c00)Add the appropriate irq_work_sync() so the work finishes before the buffers are destroyed.
Prior to the commit in the Fixes tag below, there was only a single global IRQ work, so this issue didn't exist.
--- kernel/trace/ring_buffer.c | 4 ++++ 1 file changed, 4 insertions(+)
kernel/trace/ring_buffer.c +4 -0
@@ -1269,6 +1269,8 @@ static void rb_free_cpu_buffer(struct ristruct list_head *head = cpu_buffer->pages;struct buffer_page *bpage, *tmp; +irq_work_sync (&cpu_buffer->irq_work.work); +free_buffer_page (cpu_buffer->reader_page);if (head) {
@@ -1374,6 +1376,8 @@ ring_buffer_free(struct ring_buffer *bufcpuhp_state_remove_instance (CPUHP_TRACE_RB_PREPARE , &buffer->node); +irq_work_sync (&buffer->irq_work.work); +for_each_buffer_cpu (buffer, cpu)rb_free_cpu_buffer (buffer->buffers[cpu]);
Greg Kroah-Hartman
maintainerPATCH 11/116 reiserfs: Add security prefix to xattr name in reiserfs_security_write()
In reply to Greg Kroah-HartmanFrom: Roberto Sassu <[email protected]>
commit d82dcd9e21b77d338dc4875f3d4111f0db314a7c upstream.
Reiserfs sets a security xattr at inode creation time in two stages: first, it calls reiserfs_security_init() to obtain the xattr from active LSMs; then, it calls reiserfs_security_write() to actually write that xattr.
Unfortunately, it seems there is a wrong expectation that LSMs provide the full xattr name in the form 'security.<suffix>'. However, LSMs always provided just the suffix, causing reiserfs to not write the xattr at all (if the suffix is shorter than the prefix), or to write an xattr with the wrong name.
Add a temporary buffer in reiserfs_security_write(), and write to it the full xattr name, before passing it to reiserfs_xattr_set_handle().
Also replace the name length check with a check that the full xattr name is not larger than XATTR_NAME_MAX.
--- fs/reiserfs/xattr_security.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/reiserfs/xattr_security.c +6 -2
@@ -81,11 +81,15 @@ int reiserfs_security_write(struct reisestruct inode *inode, struct reiserfs_security_handle *sec) { + char xattr_name[XATTR_NAME_MAX + 1] = XATTR_SECURITY_PREFIX;int error; -if (strlen (sec->name) <sizeof (XATTR_SECURITY_PREFIX )) + +if (XATTR_SECURITY_PREFIX_LEN +strlen (sec->name) >XATTR_NAME_MAX )return -EINVAL ; - error =reiserfs_xattr_set_handle (th, inode, sec->name, sec->value, +strlcat (xattr_name, sec->name,sizeof (xattr_name)); + + error =reiserfs_xattr_set_handle (th, inode, xattr_name, sec->value, sec->length,XATTR_CREATE );if (error == -ENODATA || error == -EOPNOTSUPP ) error =0 ;
Greg Kroah-Hartman
maintainerPATCH 12/116 i2c: omap: Fix standard mode false ACK readings
In reply to Greg Kroah-HartmanFrom: Reid Tonking <[email protected]>
commit c770657bd2611b077ec1e7b1fe6aa92f249399bd upstream.
Using standard mode, rare false ACK responses were appearing with i2cdetect tool. This was happening due to NACK interrupt triggering ISR thread before register access interrupt was ready. Removing the NACK interrupt's ability to trigger ISR thread lets register access ready interrupt do this instead.
--- drivers/i2c/busses/i2c-omap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-omap.c +1 -1
@@ -1030,7 +1030,7 @@ omap_i2c_isr(int irq, void *dev_id)u16 stat; stat =omap_i2c_read_reg (omap,OMAP_I2C_STAT_REG ); - mask =omap_i2c_read_reg (omap,OMAP_I2C_IE_REG ); + mask =omap_i2c_read_reg (omap,OMAP_I2C_IE_REG ) & ~OMAP_I2C_STAT_NACK ;if (stat & mask) ret =IRQ_WAKE_THREAD ;
Greg Kroah-Hartman
maintainerPATCH 13/116 Revert "ubifs: dirty_cow_znode: Fix memleak in error handling path"
In reply to Greg Kroah-HartmanFrom: Zhihao Cheng <[email protected]>
commit 7d01cb27f6aebc54efbe28d8961a973b8f795b13 upstream.
This reverts commit 122deabfe1428 (ubifs: dirty_cow_znode: Fix memleak in error handling path).
After commit 122deabfe1428 applied, if insert_old_idx() failed, old index neither exists in TNC nor in old-index tree. Which means that old index node could be overwritten in layout_leb_in_gaps(), then ubifs image will be corrupted in power-cut.
--- fs/ubifs/tnc.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
fs/ubifs/tnc.c +1 -8
@@ -279,18 +279,11 @@ static struct ubifs_znode *dirty_cow_znoif (zbr->len) { err =insert_old_idx (c, zbr->lnum, zbr->offs);if (unlikely (err)) -/* -* Obsolete znodes will be freed by tnc_destroy_cnext() -* or free_obsolete_znodes(), copied up znodes should -* be added back to tnc and freed by -* ubifs_destroy_tnc_subtree(). -*/ - goto out; +return ERR_PTR (err); err =add_idx_dirt (c, zbr->lnum, zbr->len); }else err =0 ; -out: zbr->znode = zn; zbr->lnum =0 ; zbr->offs =0 ;
Greg Kroah-Hartman
maintainerPATCH 14/116 ubi: Fix return value overwrite issue in try_write_vid_and_data()
In reply to Greg Kroah-HartmanFrom: Wang YanQing <[email protected]>
commit 31a149d5c13c4cbcf97de3435817263a2d8c9d6e upstream.
The commit 2d78aee426d8 ("UBI: simplify LEB write and atomic LEB change code") adds helper function, try_write_vid_and_data(), to simplify the code, but this helper function has bug, it will return 0 (success) when ubi_io_write_vid_hdr() or the ubi_io_write_data() return error number (-EIO, etc), because the return value of ubi_wl_put_peb() will overwrite the original return value.
This issue will cause unexpected data loss issue, because the caller of this function and UBIFS willn't know the data is lost.
--- drivers/mtd/ubi/eba.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
drivers/mtd/ubi/eba.c +14 -5
@@ -943,7 +943,7 @@ static int try_write_vid_and_data(struct int offset, int len) {struct ubi_device *ubi = vol->ubi; -int pnum, opnum, err, vol_id = vol->vol_id; +int pnum, opnum, err, err2, vol_id = vol->vol_id; pnum =ubi_wl_get_peb (ubi);if (pnum <0 ) {
@@ -978,10 +978,19 @@ static int try_write_vid_and_data(struct out_put:up_read (&ubi->fm_eba_sem); -if (err && pnum >=0 ) - err =ubi_wl_put_peb (ubi, vol_id, lnum, pnum,1 ); -else if (!err && opnum >=0 ) - err =ubi_wl_put_peb (ubi, vol_id, lnum, opnum,0 ); +if (err && pnum >=0 ) { + err2 =ubi_wl_put_peb (ubi, vol_id, lnum, pnum,1 ); +if (err2) { +ubi_warn (ubi,"failed to return physical eraseblock %d, error %d" , + pnum, err2); + } + }else if (!err && opnum >=0 ) { + err2 =ubi_wl_put_peb (ubi, vol_id, lnum, opnum,0 ); +if (err2) { +ubi_warn (ubi,"failed to return physical eraseblock %d, error %d" , + opnum, err2); + } + }return err; }
Greg Kroah-Hartman
maintainerPATCH 15/116 ubifs: Free memory for tmpfile name
In reply to Greg Kroah-HartmanFrom: Mårten Lindahl <[email protected]>
commit 1fb815b38bb31d6af9bd0540b8652a0d6fe6cfd3 upstream.
When opening a ubifs tmpfile on an encrypted directory, function fscrypt_setup_filename allocates memory for the name that is to be stored in the directory entry, but after the name has been copied to the directory entry inode, the memory is not freed.
When running kmemleak on it we see that it is registered as a leak. The report below is triggered by a simple program 'tmpfile' just opening a tmpfile:
unreferenced object 0xffff88810178f380 (size 32):
comm "tmpfile", pid 509, jiffies 4294934744 (age 1524.742s)
backtrace:
__kmem_cache_alloc_node
__kmalloc
fscrypt_setup_filename
ubifs_tmpfile
vfs_tmpfile
path_openatFree this memory after it has been copied to the inode.
--- fs/ubifs/dir.c | 1 + 1 file changed, 1 insertion(+)
fs/ubifs/dir.c +1 -0
@@ -462,6 +462,7 @@ static int do_tmpfile(struct inode *dir,mutex_unlock (&dir_ui->ui_mutex);ubifs_release_budget (c, &req); +fscrypt_free_filename (&nm);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 16/116 selinux: fix Makefile dependencies of flask.h
In reply to Greg Kroah-HartmanFrom: Ondrej Mosnacek <[email protected]>
[ Upstream commit bcab1adeaad4b39a1e04cb98979a367d08253f03 ]
Make the flask.h target depend on the genheaders binary instead of classmap.h to ensure that it is rebuilt if any of the dependencies of genheaders are changed.
Notably this fixes flask.h not being rebuilt wheninitial_sid_to_string.h is modified.
--- security/selinux/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
security/selinux/Makefile +2 -2
@@ -19,8 +19,8 @@ ccflags-y := -I$(srctree)/security/selinux -I$(srctree)/security/selinux/include $(addprefix $(obj)/,$(selinux-y)): $(obj)/flask.h quiet_cmd_flask = GEN $(obj)/flask.h $(obj)/av_permissions.h - cmd_flask = scripts/selinux/genheaders/genheaders $(obj)/flask.h $(obj)/av_permissions.h + cmd_flask = $< $(obj)/flask.h $(obj)/av_permissions.h targets += flask.h av_permissions.h -$(obj)/flask.h: $(src)/include/classmap.h FORCE +$(obj)/flask.h: scripts/selinux/genheaders/genheaders FORCE $(call if_changed,flask)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 17/116 selinux: ensure av_permissions.h is built when needed
In reply to Greg Kroah-HartmanFrom: Paul Moore <[email protected]>
[ Upstream commit 4ce1f694eb5d8ca607fed8542d32a33b4f1217a5 ]
The Makefile rule responsible for building flask.h and av_permissions.h only lists flask.h as a target which means that av_permissions.h is only generated when flask.h needs to be generated. This patch fixes this by adding av_permissions.h as a target to the rule.
--- security/selinux/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/selinux/Makefile +1 -1
@@ -22,5 +22,5 @@ quiet_cmd_flask = GEN $(obj)/flask.h $(obj)/av_permissions.h cmd_flask = $< $(obj)/flask.h $(obj)/av_permissions.h targets += flask.h av_permissions.h -$(obj)/flask.h: scripts/selinux/genheaders/genheaders FORCE +$(obj)/flask.h $(obj)/av_permissions.h &: scripts/selinux/genheaders/genheaders FORCE $(call if_changed,flask)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 18/116 drm/rockchip: Drop unbalanced obj unref
In reply to Greg Kroah-HartmanFrom: Rob Clark <[email protected]>
[ Upstream commit 8ee3b0e85f6ccd9e6c527bc50eaba774c3bb18d0 ]
In the error path, rockchip_drm_gem_object_mmap() is dropping an obj reference that it doesn't own.
--- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 3 --- 1 file changed, 3 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_gem.c +0 -3
@@ -268,9 +268,6 @@ static int rockchip_drm_gem_object_mmap(struct drm_gem_object *obj,else ret =rockchip_drm_gem_object_mmap_dma (obj, vma); -if (ret) -drm_gem_vm_close (vma); -return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 19/116 drm/vgem: add missing mutex_destroy
In reply to Greg Kroah-HartmanFrom: Maíra Canal <[email protected]>
[ Upstream commit 7c18189b14b33c1fbf76480b1bd217877c086e67 ]
vgem_fence_open() instantiates a mutex for a particular fence instance, but never destroys it by calling mutex_destroy() in vgem_fence_close().
So, add the missing mutex_destroy() to guarantee proper resource destruction.
--- drivers/gpu/drm/vgem/vgem_fence.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/vgem/vgem_fence.c +1 -0
@@ -280,4 +280,5 @@ void vgem_fence_close(struct vgem_file *vfile) {idr_for_each (&vfile->fence_idr, __vgem_fence_idr_fini, vfile);idr_destroy (&vfile->fence_idr); +mutex_destroy (&vfile->fence_mutex); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 20/116 drm/probe-helper: Cancel previous job before starting new one
In reply to Greg Kroah-HartmanFrom: Dom Cobley <[email protected]>
[ Upstream commit a8e47884f1906cd7440fafa056adc8817568e73e ]
Currently we schedule a call to output_poll_execute from drm_kms_helper_poll_enable for 10s in future. Later we try to replace that in drm_helper_probe_single_connector_modes with a 0s schedule with delayed_event set.
But as there is already a job in the queue this fails, and the immediate job we wanted with delayed_event set doesn't occur until 10s later.
And that call acts as if connector state has changed, reprobing modes. This has a side effect of waking up a display that has been blanked.
Make sure we cancel the old job before submitting the immediate one.
--- drivers/gpu/drm/drm_probe_helper.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_probe_helper.c +3 -2
@@ -465,8 +465,9 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,*/ dev->mode_config.delayed_event = true;if (dev->mode_config.poll_enabled) -schedule_delayed_work (&dev->mode_config.output_poll_work, -0 ); +mod_delayed_work (system_wq, + &dev->mode_config.output_poll_work, +0 ); }/* Re-enable polling in case the global poll config changed. */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 21/116 media: bdisp: Add missing check for create_workqueue
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 2371adeab717d8fe32144a84f3491a03c5838cfb ]
Add the check for the return value of the create_workqueue in order to avoid NULL pointer dereference.
--- drivers/media/platform/sti/bdisp/bdisp-v4l2.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/sti/bdisp/bdisp-v4l2.c +2 -0
@@ -1308,6 +1308,8 @@ static int bdisp_probe(struct platform_device *pdev)init_waitqueue_head (&bdisp->irq_queue);INIT_DELAYED_WORK (&bdisp->timeout_work, bdisp_irq_timeout); bdisp->work_queue =create_workqueue (BDISP_NAME ); +if (!bdisp->work_queue) +return -ENOMEM ;spin_lock_init (&bdisp->slock);mutex_init (&bdisp->lock);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 22/116 media: av7110: prevent underflow in write_ts_to_decoder()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit eed9496a0501357aa326ddd6b71408189ed872eb ]
The buf[4] value comes from the user via ts_play(). It is a value in the u8 range. The final length we pass to av7110_ipack_instant_repack() is "len - (buf[4] + 1) - 4" so add a check to ensure that the length is not negative. It's not clear that passing a negative len value does anything bad necessarily, but it's not best practice.
With the new bounds checking the "if (!len)" condition is no longer possible or required so remove that.
--- drivers/media/pci/ttpci/av7110_av.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/pci/ttpci/av7110_av.c +2 -2
@@ -836,10 +836,10 @@ static int write_ts_to_decoder(struct av7110 *av7110, int type, const u8 *buf, sav7110_ipack_flush (ipack);if (buf[3 ] &ADAPT_FIELD ) { +if (buf[4 ] > len -1 -4 ) +return 0 ; len -= buf[4 ] +1 ; buf += buf[4 ] +1 ; -if (!len) -return 0 ; }av7110_ipack_instant_repack (buf +4 , len -4 , ipack);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 23/116 x86/apic: Fix atomic update of offset in reserve_eilvt_offset()
In reply to Greg Kroah-HartmanFrom: Uros Bizjak <[email protected]>
[ Upstream commit f96fb2df3eb31ede1b34b0521560967310267750 ]
The detection of atomic update failure in reserve_eilvt_offset() is not correct. The value returned by atomic_cmpxchg() should be compared to the old value from the location to be updated.
If these two are the same, then atomic update succeeded and "eilvt_offsets[offset]" location is updated to "new" in an atomic way.
Otherwise, the atomic update failed and it should be retried with the value from "eilvt_offsets[offset]" - exactly what atomic_try_cmpxchg() does in a correct and more optimal way.
--- arch/x86/kernel/apic/apic.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/kernel/apic/apic.c +2 -3
@@ -411,10 +411,9 @@ static unsigned int reserve_eilvt_offset(int offset, unsigned int new)if (vector && !eilvt_entry_is_changeable (vector, new))/* may not change if vectors are different */ return rsvd; - rsvd =atomic_cmpxchg (&eilvt_offsets[offset], rsvd, new); - }while (rsvd != new); + }while (!atomic_try_cmpxchg (&eilvt_offsets[offset], &rsvd, new)); - rsvd &= ~APIC_EILVT_MASKED ; + rsvd = new & ~APIC_EILVT_MASKED ;if (rsvd && rsvd != vector)pr_info ("LVT offset %d assigned for vector 0x%02x\n" , offset, rsvd);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 24/116 media: dm1105: Fix use after free bug in dm1105_remove due to race condition
In reply to Greg Kroah-HartmanFrom: Zheng Wang <[email protected]>
[ Upstream commit 5abda7a16698d4d1f47af1168d8fa2c640116b4a ]
In dm1105_probe, it called dm1105_ir_init and bound &dm1105->ir.work with dm1105_emit_key.
When it handles IRQ request with dm1105_irq, it may call schedule_work to start the work.
When we call dm1105_remove to remove the driver, there may be a sequence as follows:
Fix it by finishing the work before cleanup in dm1105_remove
CPU0 CPU1
|dm1105_emit_key
dm1105_remove |
dm1105_ir_exit |
rc_unregister_device |
rc_free_device |
rc_dev_release |
kfree(dev); |
|
| rc_keydown
| //use--- drivers/media/pci/dm1105/dm1105.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/pci/dm1105/dm1105.c +1 -0
@@ -1185,6 +1185,7 @@ static void dm1105_remove(struct pci_dev *pdev)struct dvb_demux *dvbdemux = &dev->demux;struct dmx_demux *dmx = &dvbdemux->dmx; +cancel_work_sync (&dev->ir.work);dm1105_ir_exit (dev); dmx->close (dmx);dvb_net_release (&dev->dvbnet);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 25/116 x86/ioapic: Dont return 0 from arch_dynirq_lower_bound()
In reply to Greg Kroah-HartmanFrom: Saurabh Sengar <[email protected]>
[ Upstream commit 5af507bef93c09a94fb8f058213b489178f4cbe5 ]
arch_dynirq_lower_bound() is invoked by the core interrupt code to retrieve the lowest possible Linux interrupt number for dynamically allocated interrupts like MSI.
The x86 implementation uses this to exclude the IO/APIC GSI space. This works correctly as long as there is an IO/APIC registered, but returns 0 if not. This has been observed in VMs where the BIOS does not advertise an IO/APIC.
0 is an invalid interrupt number except for the legacy timer interrupt on x86. The return value is unchecked in the core code, so it ends up to allocate interrupt number 0 which is subsequently considered to be invalid by the caller, e.g. the MSI allocation code.
The function has already a check for 0 in the case that an IO/APIC is registered, as ioapic_dynirq_base is 0 in case of device tree setups.
Consolidate this and zero check for both ioapic_dynirq_base and gsi_top, which is used in the case that no IO/APIC is registered.
--- arch/x86/kernel/apic/io_apic.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
arch/x86/kernel/apic/io_apic.c +9 -5
@@ -2357,17 +2357,21 @@ static int io_apic_get_redir_entries(int ioapic)unsigned int arch_dynirq_lower_bound (unsigned int from) { +unsigned int ret; +/* * dmar_alloc_hwirq() may be called before setup_IO_APIC(), so use * gsi_top if ioapic_dynirq_base hasn't been initialized yet. */ -if (!ioapic_initialized) -return gsi_top; + ret = ioapic_dynirq_base ? : gsi_top; +/* -* For DT enabled machines ioapic_dynirq_base is irrelevant and not -* updated. So simply return @from if ioapic_dynirq_base == 0. +* For DT enabled machines ioapic_dynirq_base is irrelevant and +* always 0. gsi_top can be 0 if there is no IO/APIC registered. +* 0 is an invalid interrupt number for dynamic allocations. Return +* @from instead. */ -return ioapic_dynirq_base ? : from; +return ret ? : from; }#ifdef CONFIG_X86_32
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 26/116 arm64: kgdb: Set PSTATE.SS to 1 to re-enable single-step
In reply to Greg Kroah-HartmanFrom: Sumit Garg <[email protected]>
[ Upstream commit af6c0bd59f4f3ad5daad2f7b777954b1954551d5 ]
Currently only the first attempt to single-step has any effect. After that all further stepping remains "stuck" at the same program counter value.
Refer to the ARM Architecture Reference Manual (ARM DDI 0487E.a) D2.12, PSTATE.SS=1 should be set at each step before transferring the PE to the 'Active-not-pending' state. The problem here is PSTATE.SS=1 is not set since the second single-step.
After the first single-step, the PE transferes to the 'Inactive' state, with PSTATE.SS=0 and MDSCR.SS=1, thus PSTATE.SS won't be set to 1 due to kernel_active_single_step()=true. Then the PE transferes to the 'Active-pending' state when ERET and returns to the debugger by step exception.
Before this patch:
==================
Entering kdb (current=0xffff3376039f0000, pid 1) on processor 0 due to Keyboard Entry [0]kdb>
[0]kdb>
[0]kdb> bp write_sysrq_trigger
Instruction(i) BP #0 at 0xffffa45c13d09290 (write_sysrq_trigger)
is enabled addr at ffffa45c13d09290, hardtype=0 installed=0
[0]kdb> go
$ echo h > /proc/sysrq-trigger
Entering kdb (current=0xffff4f7e453f8000, pid 175) on processor 1 due to Breakpoint @ 0xffffad651a309290 [1]kdb> ss
Entering kdb (current=0xffff4f7e453f8000, pid 175) on processor 1 due to SS trap @ 0xffffad651a309294 [1]kdb> ss
Entering kdb (current=0xffff4f7e453f8000, pid 175) on processor 1 due to SS trap @ 0xffffad651a309294 [1]kdb>
After this patch:
=================
Entering kdb (current=0xffff6851c39f0000, pid 1) on processor 0 due to Keyboard Entry [0]kdb> bp write_sysrq_trigger
Instruction(i) BP #0 at 0xffffc02d2dd09290 (write_sysrq_trigger)
is enabled addr at ffffc02d2dd09290, hardtype=0 installed=0
[0]kdb> go
$ echo h > /proc/sysrq-trigger
Entering kdb (current=0xffff6851c53c1840, pid 174) on processor 1 due to Breakpoint @ 0xffffc02d2dd09290 [1]kdb> ss
Entering kdb (current=0xffff6851c53c1840, pid 174) on processor 1 due to SS trap @ 0xffffc02d2dd09294 [1]kdb> ss
Entering kdb (current=0xffff6851c53c1840, pid 174) on processor 1 due to SS trap @ 0xffffc02d2dd09298 [1]kdb> ss
Entering kdb (current=0xffff6851c53c1840, pid 174) on processor 1 due to SS trap @ 0xffffc02d2dd0929c [1]kdb>
--- arch/arm64/include/asm/debug-monitors.h | 1 + arch/arm64/kernel/debug-monitors.c | 5 +++++ arch/arm64/kernel/kgdb.c | 2 ++ 3 files changed, 8 insertions(+)
arch/arm64/include/asm/debug-monitors.h +1 -0
@@ -125,6 +125,7 @@ void user_regs_reset_single_step(struct user_pt_regs *regs,void kernel_enable_single_step (struct pt_regs *regs);void kernel_disable_single_step (void );int kernel_active_single_step (void ); +void kernel_rewind_single_step (struct pt_regs *regs);#ifdef CONFIG_HAVE_HW_BREAKPOINT int reinstall_suspended_bps (struct pt_regs *regs);
arch/arm64/kernel/debug-monitors.c +5 -0
@@ -434,6 +434,11 @@ int kernel_active_single_step(void) }NOKPROBE_SYMBOL (kernel_active_single_step); +void kernel_rewind_single_step (struct pt_regs *regs) +{ +set_regs_spsr_ss (regs); +} +/* ptrace API */ void user_enable_single_step (struct task_struct *task) {
arch/arm64/kernel/kgdb.c +2 -0
@@ -223,6 +223,8 @@ int kgdb_arch_handle_exception(int exception_vector, int signo,*/ if (!kernel_active_single_step ())kernel_enable_single_step (linux_regs); +else +kernel_rewind_single_step (linux_regs); err =0 ;break ;default :
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 27/116 wifi: ath6kl: minor fix for allocation size
In reply to Greg Kroah-HartmanFrom: Alexey V. Vissarionov <[email protected]>
[ Upstream commit 778f83f889e7fca37780d9640fcbd0229ae38eaa ]
Although the "param" pointer occupies more or equal space compared to "*param", the allocation size should use the size of variable itself.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/net/wireless/ath/ath6kl/bmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath6kl/bmi.c +1 -1
@@ -246,7 +246,7 @@ int ath6kl_bmi_execute(struct ath6kl *ar, u32 addr, u32 *param)return -EACCES ; } - size =sizeof (cid) +sizeof (addr) +sizeof (param); + size =sizeof (cid) +sizeof (addr) +sizeof (*param);if (size > ar->bmi.max_cmd_size) {WARN_ON (1 );return -EINVAL ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 28/116 wifi: ath5k: fix an off by one check in ath5k_eeprom_read_freq_list()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 4c856ee12df85aabd437c3836ed9f68d94268358 ]
This loop checks that i < max at the start of loop but then it does i++ which could put it past the end of the array. It's harmless to check again and prevent a potential out of bounds.
--- drivers/net/wireless/ath/ath5k/eeprom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath5k/eeprom.c +1 -1
@@ -529,7 +529,7 @@ ath5k_eeprom_read_freq_list(struct ath5k_hw *ah, int *offset, int max, ee->ee_n_piers[mode]++; freq2 = (val >>8 ) &0xff ; -if (!freq2) +if (!freq2 || i >= max)break ; pc[i++].freq = ath5k_eeprom_bin2freq(ee,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 29/116 wifi: ath6kl: reduce WARN to dev_dbg() in callback
In reply to Greg Kroah-HartmanFrom: Fedor Pchelkin <[email protected]>
[ Upstream commit 75c4a8154cb6c7239fb55d5550f481f6765fb83c ]
The warn is triggered on a known race condition, documented in the code above the test, that is correctly handled. Using WARN() hinders automated testing. Reducing severity.
--- drivers/net/wireless/ath/ath6kl/htc_pipe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath6kl/htc_pipe.c +2 -2
@@ -969,8 +969,8 @@ static int ath6kl_htc_pipe_rx_complete(struct ath6kl *ar, struct sk_buff *skb,* Thus the possibility of ar->htc_target being NULL * via ath6kl_recv_complete -> ath6kl_usb_io_comp_work. */ -if (WARN_ON_ONCE (!target)) { -ath6kl_err ("Target not yet initialized\n" ); +if (!target) { +ath6kl_dbg (ATH6KL_DBG_HTC ,"Target not yet initialized\n" ); status = -EINVAL ; goto free_skb; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 30/116 scm: fix MSG_CTRUNC setting condition for SO_PASSSEC
In reply to Greg Kroah-HartmanFrom: Alexander Mikhalitsyn <[email protected]>
[ Upstream commit a02d83f9947d8f71904eda4de046630c3eb6802c ]
Currently, kernel would set MSG_CTRUNC flag if msg_control buffer wasn't provided and SO_PASSCRED was set or if there was pending SCM_RIGHTS.
For some reason we have no corresponding check for SO_PASSSEC.
In the recvmsg(2) doc we have:
MSG_CTRUNC
indicates that some control data was discarded due to lack of space in the buffer for ancillary data.
So, we need to set MSG_CTRUNC flag for all types of SCM.
This change can break applications those don't check MSG_CTRUNC flag.
v2:
- commit message was rewritten according to Eric's suggestion
--- include/net/scm.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
include/net/scm.h +12 -1
@@ -104,16 +104,27 @@ static inline void scm_passec(struct socket *sock, struct msghdr *msg, struct sc } } } + +static inline bool scm_has_secdata (struct socket *sock) +{ +return test_bit (SOCK_PASSSEC , &sock->flags); +}#else static inline void scm_passec (struct socket *sock,struct msghdr *msg,struct scm_cookie *scm) { } + +static inline bool scm_has_secdata (struct socket *sock) +{ +return false; +}#endif /* CONFIG_SECURITY_NETWORK */ static __inline__void scm_recv (struct socket *sock,struct msghdr *msg,struct scm_cookie *scm,int flags) {if (!msg->msg_control) { -if (test_bit (SOCK_PASSCRED , &sock->flags) || scm->fp) +if (test_bit (SOCK_PASSCRED , &sock->flags) || scm->fp || +scm_has_secdata (sock)) msg->msg_flags |=MSG_CTRUNC ;scm_destroy (scm);return ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 31/116 vlan: partially enable SIOCSHWTSTAMP in container
In reply to Greg Kroah-HartmanFrom: Vadim Fedorenko <[email protected]>
[ Upstream commit 731b73dba359e3ff00517c13aa0daa82b34ff466 ]
Setting timestamp filter was explicitly disabled on vlan devices in containers because it might affect other processes on the host. But it's absolutely legit in case when real device is in the same namespace.
--- net/8021q/vlan_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/8021q/vlan_dev.c +1 -1
@@ -367,7 +367,7 @@ static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)switch (cmd) {case SIOCSHWTSTAMP : -if (!net_eq (dev_net (dev), &init_net)) +if (!net_eq (dev_net (dev),dev_net (real_dev)))break ;case SIOCGMIIPHY :case SIOCGMIIREG :
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 32/116 net/packet: convert po->origdev to an atomic flag
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit ee5675ecdf7a4e713ed21d98a70c2871d6ebed01 ]
syzbot/KCAN reported that po->origdev can be read
while another thread is changing its value.
We can avoid this splat by converting this field
to an actual bit.
Following patches will convert remaining 1bit fields.
--- net/packet/af_packet.c | 10 ++++------ net/packet/diag.c | 2 +- net/packet/internal.h | 22 +++++++++++++++++++++- 3 files changed, 26 insertions(+), 8 deletions(-)
net/packet/af_packet.c +4 -6
@@ -2144,7 +2144,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, sll = &PACKET_SKB_CB (skb)->sa.ll; sll->sll_hatype = dev->type; sll->sll_pkttype = skb->pkt_type; -if (unlikely (po->origdev)) +if (unlikely (packet_sock_flag (po,PACKET_SOCK_ORIGDEV ))) sll->sll_ifindex = orig_dev->ifindex;else sll->sll_ifindex = dev->ifindex;
@@ -2410,7 +2410,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, sll->sll_hatype = dev->type; sll->sll_protocol = skb->protocol; sll->sll_pkttype = skb->pkt_type; -if (unlikely (po->origdev)) +if (unlikely (packet_sock_flag (po,PACKET_SOCK_ORIGDEV ))) sll->sll_ifindex = orig_dev->ifindex;else sll->sll_ifindex = dev->ifindex;
@@ -3879,9 +3879,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optvif (copy_from_user (&val, optval,sizeof (val)))return -EFAULT ; -lock_sock (sk); - po->origdev = !!val; -release_sock (sk); +packet_sock_flag_set (po,PACKET_SOCK_ORIGDEV , val);return 0 ; }case PACKET_VNET_HDR :
@@ -4014,7 +4012,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname, val = po->auxdata;break ;case PACKET_ORIGDEV : - val = po->origdev; + val =packet_sock_flag (po,PACKET_SOCK_ORIGDEV );break ;case PACKET_VNET_HDR : val = po->has_vnet_hdr;
net/packet/diag.c +1 -1
@@ -24,7 +24,7 @@ static int pdiag_put_info(const struct packet_sock *po, struct sk_buff *nlskb) pinfo.pdi_flags |=PDI_RUNNING ;if (po->auxdata) pinfo.pdi_flags |=PDI_AUXDATA ; -if (po->origdev) +if (packet_sock_flag (po,PACKET_SOCK_ORIGDEV )) pinfo.pdi_flags |=PDI_ORIGDEV ;if (po->has_vnet_hdr) pinfo.pdi_flags |=PDI_VNETHDR ;
net/packet/internal.h +21 -1
@@ -115,9 +115,9 @@ struct packet_sock {int copy_thresh;spinlock_t bind_lock;struct mutex pg_vec_lock; +unsigned long flags;unsigned int running;/* bind_lock must be held */ unsigned int auxdata:1, /* writer must hold sock lock */ - origdev:1, has_vnet_hdr:1, tp_loss:1, tp_tx_has_off:1;
@@ -142,4 +142,24 @@ static struct packet_sock *pkt_sk(struct sock *sk) return (struct packet_sock *)sk; } +enum packet_sock_flags { +PACKET_SOCK_ORIGDEV , +}; + +static inline void packet_sock_flag_set (struct packet_sock *po, +enum packet_sock_flags flag, +bool val) +{ +if (val) +set_bit (flag, &po->flags); +else +clear_bit (flag, &po->flags); +} + +static inline bool packet_sock_flag (const struct packet_sock *po, +enum packet_sock_flags flag) +{ +return test_bit (flag, &po->flags); +} +#endif
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 33/116 net/packet: convert po->auxdata to an atomic flag
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit fd53c297aa7b077ae98a3d3d2d3aa278a1686ba6 ]
po->auxdata can be read while another thread is changing its value, potentially raising KCSAN splat.
Convert it to PACKET_SOCK_AUXDATA flag.
--- net/packet/af_packet.c | 8 +++----- net/packet/diag.c | 2 +- net/packet/internal.h | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-)
net/packet/af_packet.c +3 -5
@@ -3480,7 +3480,7 @@ static int packet_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,memcpy (msg->msg_name, &PACKET_SKB_CB (skb)->sa, copy_len); } -if (pkt_sk (sk)->auxdata) { +if (packet_sock_flag (pkt_sk (sk),PACKET_SOCK_AUXDATA )) {struct tpacket_auxdata aux; aux.tp_status =TP_STATUS_USER ;
@@ -3865,9 +3865,7 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optvif (copy_from_user (&val, optval,sizeof (val)))return -EFAULT ; -lock_sock (sk); - po->auxdata = !!val; -release_sock (sk); +packet_sock_flag_set (po,PACKET_SOCK_AUXDATA , val);return 0 ; }case PACKET_ORIGDEV :
@@ -4009,7 +4007,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,break ;case PACKET_AUXDATA : - val = po->auxdata; + val =packet_sock_flag (po,PACKET_SOCK_AUXDATA );break ;case PACKET_ORIGDEV : val =packet_sock_flag (po,PACKET_SOCK_ORIGDEV );
net/packet/diag.c +1 -1
@@ -22,7 +22,7 @@ static int pdiag_put_info(const struct packet_sock *po, struct sk_buff *nlskb) pinfo.pdi_flags =0 ;if (po->running) pinfo.pdi_flags |=PDI_RUNNING ; -if (po->auxdata) +if (packet_sock_flag (po,PACKET_SOCK_AUXDATA )) pinfo.pdi_flags |=PDI_AUXDATA ;if (packet_sock_flag (po,PACKET_SOCK_ORIGDEV )) pinfo.pdi_flags |=PDI_ORIGDEV ;
net/packet/internal.h +2 -2
@@ -117,8 +117,7 @@ struct packet_sock {struct mutex pg_vec_lock;unsigned long flags;unsigned int running;/* bind_lock must be held */ - unsigned int auxdata:1, /* writer must hold sock lock */ - has_vnet_hdr:1, + unsigned int has_vnet_hdr:1, /* writer must hold sock lock */ tp_loss:1, tp_tx_has_off:1;int pressure;
@@ -144,6 +143,7 @@ static struct packet_sock *pkt_sk(struct sock *sk)enum packet_sock_flags {PACKET_SOCK_ORIGDEV , +PACKET_SOCK_AUXDATA , }; static inline void packet_sock_flag_set(struct packet_sock *po,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 34/116 scsi: target: iscsit: Fix TAS handling during conn cleanup
In reply to Greg Kroah-HartmanFrom: Mike Christie <[email protected]>
[ Upstream commit cc79da306ebb2edb700c3816b90219223182ac3c ]
Fix a bug added in commit f36199355c64 ("scsi: target: iscsi: Fix cmd abort fabric stop race").
If CMD_T_TAS is set on the se_cmd we must call iscsit_free_cmd() to do the last put on the cmd and free it, because the connection is down and we will not up sending the response and doing the put from the normal I/O path.
Add a check for CMD_T_TAS in iscsit_release_commands_from_conn() so we now detect this case and run iscsit_free_cmd().
--- drivers/target/iscsi/iscsi_target.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/target/iscsi/iscsi_target.c +9 -7
@@ -4088,9 +4088,12 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn)list_for_each_entry_safe (cmd, cmd_tmp, &tmp_list, i_conn_node) {struct se_cmd *se_cmd = &cmd->se_cmd; -if (se_cmd->se_tfo !=NULL ) { -spin_lock_irq (&se_cmd->t_state_lock); -if (se_cmd->transport_state &CMD_T_ABORTED ) { +if (!se_cmd->se_tfo) +continue ; + +spin_lock_irq (&se_cmd->t_state_lock); +if (se_cmd->transport_state &CMD_T_ABORTED ) { +if (!(se_cmd->transport_state &CMD_T_TAS ))/* * LIO's abort path owns the cleanup for this, * so put it back on the list and let
@@ -4098,11 +4101,10 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn)*/ list_move_tail (&cmd->i_conn_node, &conn->conn_cmd_list); - }else { - se_cmd->transport_state |=CMD_T_FABRIC_STOP ; - } -spin_unlock_irq (&se_cmd->t_state_lock); + }else { + se_cmd->transport_state |=CMD_T_FABRIC_STOP ; } +spin_unlock_irq (&se_cmd->t_state_lock); }spin_unlock_bh (&conn->cmd_lock);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 35/116 scsi: megaraid: Fix mega_cmd_done() CMDID_INT_CMDS
In reply to Greg Kroah-HartmanFrom: Danila Chernetsov <[email protected]>
[ Upstream commit 75cb113cd43f06aaf4f1bda0069cfd5b98e909eb ]
When cmdid == CMDID_INT_CMDS, the 'cmds' pointer is NULL but is dereferenced below.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/scsi/megaraid.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/megaraid.c +1 -0
@@ -1443,6 +1443,7 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)*/ if (cmdid ==CMDID_INT_CMDS ) { scb = &adapter->int_scb; + cmd = scb->cmd;list_del_init (&scb->list); scb->state =SCB_FREE ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 36/116 md/raid10: fix leak of r10bio->remaining for recovery
In reply to Greg Kroah-HartmanFrom: Yu Kuai <[email protected]>
[ Upstream commit 26208a7cffd0c7cbf14237ccd20c7270b3ffeb7e ]
raid10_sync_request() will add 'r10bio->remaining' for both rdev and replacement rdev. However, if the read io fails, recovery_request_write() returns without issuing the write io, in this case, end_sync_request() is only called once and 'remaining' is leaked, cause an io hang.
Fix the problem by decreasing 'remaining' according to if 'bio' and 'repl_bio' is valid.
--- drivers/md/raid10.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/md/raid10.c +13 -10
@@ -2234,11 +2234,22 @@ static void recovery_request_write(struct mddev *mddev, struct r10bio *r10_bio) {struct r10conf *conf = mddev->private;int d; -struct bio *wbio, *wbio2; +struct bio *wbio = r10_bio->devs[1 ].bio; +struct bio *wbio2 = r10_bio->devs[1 ].repl_bio; + +/* Need to test wbio2->bi_end_io before we call +* generic_make_request as if the former is NULL, +* the latter is free to free wbio2. +*/ +if (wbio2 && !wbio2->bi_end_io) + wbio2 =NULL ;if (!test_bit (R10BIO_Uptodate, &r10_bio->state)) {fix_recovery_read_error (r10_bio); -end_sync_request (r10_bio); +if (wbio->bi_end_io) +end_sync_request (r10_bio); +if (wbio2) +end_sync_request (r10_bio);return ; }
@@ -2247,14 +2258,6 @@ static void recovery_request_write(struct mddev *mddev, struct r10bio *r10_bio)* and submit the write request */ d = r10_bio->devs[1 ].devnum; - wbio = r10_bio->devs[1 ].bio; - wbio2 = r10_bio->devs[1 ].repl_bio; -/* Need to test wbio2->bi_end_io before we call -* generic_make_request as if the former is NULL, -* the latter is free to free wbio2. -*/ -if (wbio2 && !wbio2->bi_end_io) - wbio2 =NULL ;if (wbio->bi_end_io) {atomic_inc (&conf->mirrors[d].rdev->nr_pending);md_sync_acct (conf->mirrors[d].rdev->bdev,bio_sectors (wbio));
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 37/116 wifi: iwlwifi: make the loop for card preparation effective
In reply to Greg Kroah-HartmanFrom: Emmanuel Grumbach <[email protected]>
[ Upstream commit 28965ec0b5d9112585f725660e2ff13218505ace ]
Since we didn't reset t to 0, only the first iteration of the loop did checked the ready bit several times.
Quoted 1 line
From the second iteration and on, we just tested the bit once and
continued to the next iteration.
--- drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/pcie/trans.c +2 -1
@@ -562,7 +562,6 @@ static int iwl_pcie_set_hw_ready(struct iwl_trans *trans)int iwl_pcie_prepare_card_hw (struct iwl_trans *trans) {int ret; -int t =0 ;int iter;IWL_DEBUG_INFO (trans,"iwl_trans_prepare_card_hw enter\n" );
@@ -577,6 +576,8 @@ int iwl_pcie_prepare_card_hw(struct iwl_trans *trans)usleep_range (1000 ,2000 );for (iter =0 ; iter <10 ; iter++) { +int t =0 ; +/* If HW is not ready, prepare the conditions to check again */ iwl_set_bit (trans,CSR_HW_IF_CONFIG_REG ,CSR_HW_IF_CONFIG_REG_PREPARE );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 38/116 wifi: iwlwifi: mvm: check firmware response size
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 13513cec93ac9902d0b896976d8bab3758a9881c ]
Check the firmware response size for responses to the memory read/write command in debugfs before using it.
--- drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c +10 -0
@@ -1721,6 +1721,11 @@ static ssize_t iwl_dbgfs_mem_read(struct file *file, char __user *user_buf,if (ret <0 )return ret; +if (iwl_rx_packet_payload_len (hcmd.resp_pkt) <sizeof (*rsp)) { + ret = -EIO ; + goto out; + } + rsp = (void *)hcmd.resp_pkt->data;if (le32_to_cpu (rsp->status) !=DEBUG_MEM_STATUS_SUCCESS ) { ret = -ENXIO ;
@@ -1798,6 +1803,11 @@ static ssize_t iwl_dbgfs_mem_write(struct file *file,if (ret <0 )return ret; +if (iwl_rx_packet_payload_len (hcmd.resp_pkt) <sizeof (*rsp)) { + ret = -EIO ; + goto out; + } + rsp = (void *)hcmd.resp_pkt->data;if (rsp->status !=DEBUG_MEM_STATUS_SUCCESS ) { ret = -ENXIO ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 39/116 ixgbe: Allow flow hash to be set via ethtool
In reply to Greg Kroah-HartmanFrom: Joe Damato <[email protected]>
[ Upstream commit 4f3ed1293feb9502dc254b05802faf1ad3317ac6 ]
ixgbe currently returns EINVAL whenever the flowhash it set by ethtool because the ethtool code in the kernel passes a non-zero value for hfunc that ixgbe should allow.
When ethtool is called with ETHTOOL_SRXFHINDIR, ethtool_set_rxfh_indir will call ixgbe's set_rxfh function with ETH_RSS_HASH_NO_CHANGE. This value should be accepted.
When ethtool is called with ETHTOOL_SRSSH, ethtool_set_rxfh will call ixgbe's set_rxfh function with rxfh.hfunc, which appears to be hardcoded in ixgbe to always be ETH_RSS_HASH_TOP. This value should also be accepted.
Before this patch:
$ sudo ethtool -L eth1 combined 10 $ sudo ethtool -X eth1 default Cannot set RX flow hash configuration: Invalid argument
After this patch:
$ sudo ethtool -L eth1 combined 10
$ sudo ethtool -X eth1 default
$ sudo ethtool -x eth1
RX flow hash indirection table for eth1 with 10 RX ring(s):
0: 0 1 2 3 4 5 6 7
8: 8 9 0 1 2 3 4 5
16: 6 7 8 9 0 1 2 3
24: 4 5 6 7 8 9 0 1
...--- drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +2 -2
@@ -3020,8 +3020,8 @@ static int ixgbe_set_rxfh(struct net_device *netdev, const u32 *indir,int i;u32 reta_entries =ixgbe_rss_indir_tbl_entries (adapter); -if (hfunc) -return -EINVAL ; +if (hfunc !=ETH_RSS_HASH_NO_CHANGE && hfunc !=ETH_RSS_HASH_TOP ) +return -EOPNOTSUPP ;/* Fill out the redirection table */ if (indir) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 40/116 ixgbe: Enable setting RSS table to default values
In reply to Greg Kroah-HartmanFrom: Joe Damato <[email protected]>
[ Upstream commit e85d3d55875f7a1079edfbc4e4e98d6f8aea9ac7 ]
ethtool uses ETHTOOL_GRXRINGS to compute how many queues are supported by RSS. The driver should return the smaller of either:
- The maximum number of RSS queues the device supports, OR
- The number of RX queues configured
Prior to this change, running ethtool -X $iface default fails if the number of queues configured is larger than the number supported by RSS, even though changing the queue count correctly resets the flowhash to use all supported queues.
Other drivers (for example, i40e) will succeed but the flow hash will reset to support the maximum number of queues supported by RSS, even if that amount is smaller than the configured amount.
Prior to this change:
$ sudo ethtool -L eth1 combined 20
$ sudo ethtool -x eth1
RX flow hash indirection table for eth1 with 20 RX ring(s):
0: 0 1 2 3 4 5 6 7
8: 8 9 10 11 12 13 14 15
16: 0 1 2 3 4 5 6 7
24: 8 9 10 11 12 13 14 15
32: 0 1 2 3 4 5 6 7
...You can see that the flowhash was correctly set to use the maximum number of queues supported by the driver (16).
However, asking the NIC to reset to "default" fails:
$ sudo ethtool -X eth1 default Cannot set RX flow hash configuration: Invalid argument
After this change, the flowhash can be reset to default which will use all of the available RSS queues (16) or the configured queue count, whichever is smaller.
Starting with eth1 which has 10 queues and a flowhash distributing to all 10 queues:
$ sudo ethtool -x eth1
RX flow hash indirection table for eth1 with 10 RX ring(s):
0: 0 1 2 3 4 5 6 7
8: 8 9 0 1 2 3 4 5
16: 6 7 8 9 0 1 2 3
...Increasing the queue count to 48 resets the flowhash to distribute to 16 queues, as it did before this patch:
$ sudo ethtool -L eth1 combined 48
$ sudo ethtool -x eth1
RX flow hash indirection table for eth1 with 16 RX ring(s):
0: 0 1 2 3 4 5 6 7
8: 8 9 10 11 12 13 14 15
16: 0 1 2 3 4 5 6 7
...Due to the other bugfix in this series, the flowhash can be set to use queues 0-5:
$ sudo ethtool -X eth1 equal 5
$ sudo ethtool -x eth1
RX flow hash indirection table for eth1 with 16 RX ring(s):
0: 0 1 2 3 4 0 1 2
8: 3 4 0 1 2 3 4 0
16: 1 2 3 4 0 1 2 3
...Due to this bugfix, the flowhash can be reset to default and use 16 queues:
$ sudo ethtool -X eth1 default
$ sudo ethtool -x eth1
RX flow hash indirection table for eth1 with 16 RX ring(s):
0: 0 1 2 3 4 5 6 7
8: 8 9 10 11 12 13 14 15
16: 0 1 2 3 4 5 6 7
...--- .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +10 -9
@@ -2554,6 +2554,14 @@ static int ixgbe_get_rss_hash_opts(struct ixgbe_adapter *adapter,return 0 ; } +static int ixgbe_rss_indir_tbl_max (struct ixgbe_adapter *adapter) +{ +if (adapter->hw.mac.type < ixgbe_mac_X550) +return 16 ; +else +return 64 ; +} +static int ixgbe_get_rxnfc (struct net_device *dev,struct ethtool_rxnfc *cmd,u32 *rule_locs) {
@@ -2562,7 +2570,8 @@ static int ixgbe_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,switch (cmd->cmd) {case ETHTOOL_GRXRINGS : - cmd->data = adapter->num_rx_queues; + cmd->data =min_t (int, adapter->num_rx_queues, +ixgbe_rss_indir_tbl_max (adapter)); ret =0 ;break ;case ETHTOOL_GRXCLSRLCNT :
@@ -2964,14 +2973,6 @@ static int ixgbe_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)return ret; } -static int ixgbe_rss_indir_tbl_max (struct ixgbe_adapter *adapter) -{ -if (adapter->hw.mac.type < ixgbe_mac_X550) -return 16 ; -else -return 64 ; -} -static u32 ixgbe_get_rxfh_key_size (struct net_device *netdev) {return IXGBE_RSS_KEY_SIZE ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 41/116 ipv4: Fix potential uninit variable access bug in __ip_make_skb()
In reply to Greg Kroah-HartmanFrom: Ziyang Xuan <[email protected]>
[ Upstream commit 99e5acae193e369b71217efe6f1dad42f3f18815 ]
Like commit ea30388baebc ("ipv6: Fix an uninit variable access bug in __ip6_make_skb()"). icmphdr does not in skb linear region under the scenario of SOCK_RAW socket. Access icmp_hdr(skb)->type directly will trigger the uninit variable access bug.
Use a local variable icmp_type to carry the correct value in different scenarios.
--- net/ipv4/ip_output.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
net/ipv4/ip_output.c +13 -3
@@ -1415,9 +1415,19 @@ struct sk_buff *__ip_make_skb(struct sock *sk, cork->dst =NULL ;skb_dst_set (skb, &rt->dst); -if (iph->protocol ==IPPROTO_ICMP ) -icmp_out_count (net, ((struct icmphdr *) -skb_transport_header (skb))->type); +if (iph->protocol ==IPPROTO_ICMP ) { +u8 icmp_type; + +/* For such sockets, transhdrlen is zero when do ip_append_data(), +* so icmphdr does not in skb linear region and can not get icmp_type +* by icmp_hdr(skb)->type. +*/ +if (sk->sk_type ==SOCK_RAW && !inet_sk (sk)->hdrincl) + icmp_type = fl4->fl4_icmp_type; +else + icmp_type =icmp_hdr (skb)->type; +icmp_out_count (net, icmp_type); + }ip_cork_release (cork); out:
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 42/116 Revert "Bluetooth: btsdio: fix use after free bug in btsdio_remove due to unfinished work"
In reply to Greg Kroah-HartmanFrom: Liu Jian <[email protected]>
[ Upstream commit db2bf510bd5d57f064d9e1db395ed86a08320c54 ]
This reverts commit 1e9ac114c4428fdb7ff4635b45d4f46017e8916f.
This patch introduces a possible null-ptr-def problem. Revert it. And the fixed bug by this patch have resolved by commit 73f7b171b7c0 ("Bluetooth:
btsdio: fix use after free bug in btsdio_remove due to race condition").
--- drivers/bluetooth/btsdio.c | 1 - 1 file changed, 1 deletion(-)
drivers/bluetooth/btsdio.c +0 -1
@@ -353,7 +353,6 @@ static void btsdio_remove(struct sdio_func *func)BT_DBG ("func %p" , func); -cancel_work_sync (&data->work);if (!data)return ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 43/116 net: amd: Fix link leak when verifying config failed
In reply to Greg Kroah-HartmanFrom: Gencen Gan <[email protected]>
[ Upstream commit d325c34d9e7e38d371c0a299d415e9b07f66a1fb ]
After failing to verify configuration, it returns directly without releasing link, which may cause memory leak.
Paolo Abeni thinks that the whole code of this driver is quite "suboptimal" and looks unmainatained since at least ~15y, so he suggests that we could simply remove the whole driver, please take it into consideration.
Simon Horman suggests that the fix label should be set to "Linux-2.6.12-rc2" considering that the problem has existed since the driver was introduced and the commit above doesn't seem to exist in net/net-next.
--- drivers/net/ethernet/amd/nmclan_cs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/amd/nmclan_cs.c +1 -1
@@ -652,7 +652,7 @@ static int nmclan_config(struct pcmcia_device *link) }else {pr_notice ("mace id not found: %x %x should be 0x40 0x?9\n" , sig[0 ], sig[1 ]); -return -ENODEV ; + goto failed; } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 44/116 tcp/udp: Fix memleaks of sk and zerocopy skbs with TX timestamp.
In reply to Greg Kroah-HartmanFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 50749f2dd6854a41830996ad302aef2ffaf011d8 ]
syzkaller reported [0] memory leaks of an UDP socket and ZEROCOPY skbs. We can reproduce the problem with these sequences:
sk = socket(AF_INET, SOCK_DGRAM, 0) sk.setsockopt(SOL_SOCKET, SO_TIMESTAMPING, SOF_TIMESTAMPING_TX_SOFTWARE) sk.setsockopt(SOL_SOCKET, SO_ZEROCOPY, 1)
sk.sendto(b'', MSG_ZEROCOPY, ('127.0.0.1', 53))
sk.close()
sendmsg() calls msg_zerocopy_alloc(), which allocates a skb, sets skb->cb->ubuf.refcnt to 1, and calls sock_hold(). Here, struct ubuf_info_msgzc indirectly holds a refcnt of the socket. When the skb is sent, __skb_tstamp_tx() clones it and puts the clone into the socket's error queue with the TX timestamp.
When the original skb is received locally, skb_copy_ubufs() calls skb_unclone(), and pskb_expand_head() increments skb->cb->ubuf.refcnt. This additional count is decremented while freeing the skb, but struct ubuf_info_msgzc still has a refcnt, so __msg_zerocopy_callback() is not called.
The last refcnt is not released unless we retrieve the TX timestamped skb by recvmsg(). Since we clear the error queue in inet_sock_destruct() after the socket's refcnt reaches 0, there is a circular dependency. If we close() the socket holding such skbs, we never call sock_put() and leak the count, sk, and skb.
TCP has the same problem, and commit e0c8bccd40fc ("net: stream:
purge sk_error_queue in sk_stream_kill_queues()") tried to fix it by calling skb_queue_purge() during close(). However, there is a small chance that skb queued in a qdisc or device could be put into the error queue after the skb_queue_purge() call.
In __skb_tstamp_tx(), the cloned skb should not have a reference to the ubuf to remove the circular dependency, but skb_clone() does not call skb_copy_ubufs() for zerocopy skb. So, we need to call skb_orphan_frags_rx() for the cloned skb to call skb_copy_ubufs().
[0]:
BUG: memory leak
unreferenced object 0xffff88800c6d2d00 (size 1152):
comm "syz-executor392", pid 264, jiffies 4294785440 (age 13.044s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 cd af e8 81 00 00 00 00 ................
02 00 07 40 00 00 00 00 00 00 00 00 00 00 00 00 ...@............
backtrace:
[<0000000055636812>] sk_prot_alloc+0x64/0x2a0 net/core/sock.c:2024
[<0000000054d77b7a>] sk_alloc+0x3b/0x800 net/core/sock.c:2083
[<0000000066f3c7e0>] inet_create net/ipv4/af_inet.c:319 [inline]
[<0000000066f3c7e0>] inet_create+0x31e/0xe40 net/ipv4/af_inet.c:245
[<000000009b83af97>] __sock_create+0x2ab/0x550 net/socket.c:1515
[<00000000b9b11231>] sock_create net/socket.c:1566 [inline]
[<00000000b9b11231>] __sys_socket_create net/socket.c:1603 [inline]
[<00000000b9b11231>] __sys_socket_create net/socket.c:1588 [inline]
[<00000000b9b11231>] __sys_socket+0x138/0x250 net/socket.c:1636
[<000000004fb45142>] __do_sys_socket net/socket.c:1649 [inline]
[<000000004fb45142>] __se_sys_socket net/socket.c:1647 [inline]
[<000000004fb45142>] __x64_sys_socket+0x73/0xb0 net/socket.c:1647
[<0000000066999e0e>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
[<0000000066999e0e>] do_syscall_64+0x38/0x90 arch/x86/entry/common.c:80
[<0000000017f238c1>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
BUG: memory leak
unreferenced object 0xffff888017633a00 (size 240):
comm "syz-executor392", pid 264, jiffies 4294785440 (age 13.044s)
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 2d 6d 0c 80 88 ff ff .........-m.....
backtrace:
[<000000002b1c4368>] __alloc_skb+0x229/0x320 net/core/skbuff.c:497
[<00000000143579a6>] alloc_skb include/linux/skbuff.h:1265 [inline]
[<00000000143579a6>] sock_omalloc+0xaa/0x190 net/core/sock.c:2596
[<00000000be626478>] msg_zerocopy_alloc net/core/skbuff.c:1294 [inline]
[<00000000be626478>] msg_zerocopy_realloc+0x1ce/0x7f0 net/core/skbuff.c:1370
[<00000000cbfc9870>] __ip_append_data+0x2adf/0x3b30 net/ipv4/ip_output.c:1037
[<0000000089869146>] ip_make_skb+0x26c/0x2e0 net/ipv4/ip_output.c:1652
[<00000000098015c2>] udp_sendmsg+0x1bac/0x2390 net/ipv4/udp.c:1253
[<0000000045e0e95e>] inet_sendmsg+0x10a/0x150 net/ipv4/af_inet.c:819
[<000000008d31bfde>] sock_sendmsg_nosec net/socket.c:714 [inline]
[<000000008d31bfde>] sock_sendmsg+0x141/0x190 net/socket.c:734
[<0000000021e21aa4>] __sys_sendto+0x243/0x360 net/socket.c:2117
[<00000000ac0af00c>] __do_sys_sendto net/socket.c:2129 [inline]
[<00000000ac0af00c>] __se_sys_sendto net/socket.c:2125 [inline]
[<00000000ac0af00c>] __x64_sys_sendto+0xe1/0x1c0 net/socket.c:2125
[<0000000066999e0e>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
[<0000000066999e0e>] do_syscall_64+0x38/0x90 arch/x86/entry/common.c:80
[<0000000017f238c1>] entry_SYSCALL_64_after_hwframe+0x63/0xcd--- net/core/skbuff.c | 3 +++ 1 file changed, 3 insertions(+)
net/core/skbuff.c +3 -0
@@ -4420,6 +4420,9 @@ void __skb_tstamp_tx(struct sk_buff *orig_skb, skb =alloc_skb (0 ,GFP_ATOMIC ); }else { skb =skb_clone (orig_skb,GFP_ATOMIC ); + +if (skb_orphan_frags_rx (skb,GFP_ATOMIC )) +return ; }if (!skb)return ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 45/116 pstore: Revert pmsg_lock back to a normal mutex
In reply to Greg Kroah-HartmanFrom: John Stultz <[email protected]>
[ Upstream commit 5239a89b06d6b199f133bf0ffea421683187f257 ]
This reverts commit 76d62f24db07f22ccf9bc18ca793c27d4ebef721.
So while priority inversion on the pmsg_lock is an occasional problem that an rt_mutex would help with, in uses where logging is writing to pmsg heavily from multiple threads, the pmsg_lock can be heavily contended.
After this change landed, it was reported that cases where the mutex locking overhead was commonly adding on the order of 10s of usecs delay had suddenly jumped to ~msec delay with rtmutex.
It seems the slight differences in the locks under this level of contention causes the normal mutexes to utilize the spinning optimizations, while the rtmutexes end up in the sleeping slowpath (which allows additional threads to pile on trying to take the lock).
In this case, it devolves to a worse case senerio where the lock acquisition and scheduling overhead dominates, and each thread is waiting on the order of ~ms to do ~us of work.
Obviously, having tons of threads all contending on a single lock for logging is non-optimal, so the proper fix is probably reworking pstore pmsg to have per-cpu buffers so we don't have contention.
Additionally, Steven Rostedt has provided some furhter optimizations for rtmutexes that improves the rtmutex spinning path, but at least in my testing, I still see the test tripping into the sleeping path on rtmutexes while utilizing the spinning path with mutexes.
But in the short term, lets revert the change to the rt_mutex and go back to normal mutexes to avoid a potentially major performance regression. And we can work on optimizations to both rtmutexes and finer-grained locking for pstore pmsg in the future.
--- fs/pstore/pmsg.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/pstore/pmsg.c +3 -4
@@ -15,10 +15,9 @@#include <linux/device.h> #include <linux/fs.h> #include <linux/uaccess.h> -#include <linux/rtmutex.h> #include "internal.h" -static DEFINE_RT_MUTEX (pmsg_lock); +static DEFINE_MUTEX (pmsg_lock);static ssize_t write_pmsg (struct file *file,const char __user *buf,size_t count,loff_t *ppos)
@@ -37,9 +36,9 @@ static ssize_t write_pmsg(struct file *file, const char __user *buf,if (!access_ok (VERIFY_READ , buf, count))return -EFAULT ; -rt_mutex_lock (&pmsg_lock); +mutex_lock (&pmsg_lock); ret = psinfo->write_user (&record, buf); -rt_mutex_unlock (&pmsg_lock); +mutex_unlock (&pmsg_lock);return ret ? ret : count; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 46/116 linux/vt_buffer.h: allow either builtin or modular for macros
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 2b76ffe81e32afd6d318dc4547e2ba8c46207b77 ]
Fix build errors on ARCH=alpha when CONFIG_MDA_CONSOLE=m. This allows the ARCH macros to be the only ones defined.
In file included from ../drivers/video/console/mdacon.c:37:../arch/alpha/include/asm/vga.h:17:40: error: expected identifier or '(' before 'volatile'
17 | static inline void scr_writew(u16 val, volatile u16 *addr)
| ^~~~~~~~../include/linux/vt_buffer.h:24:34: note: in definition of macro 'scr_writew'
24 | #define scr_writew(val, addr) (*(addr) = (val))
| ^~~~../include/linux/vt_buffer.h:24:40: error: expected ')' before '=' token
24 | #define scr_writew(val, addr) (*(addr) = (val))
| ^../arch/alpha/include/asm/vga.h:17:20: note: in expansion of macro 'scr_writew'
17 | static inline void scr_writew(u16 val, volatile u16 *addr)
| ^~~~~~~~~~
../arch/alpha/include/asm/vga.h:25:29: error: expected identifier or '(' before 'volatile'
25 | static inline u16 scr_readw(volatile const u16 *addr)
| ^~~~~~~~
--- include/linux/vt_buffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/vt_buffer.h +1 -1
@@ -16,7 +16,7 @@#include <linux/string.h> -#if defined(CONFIG_VGA_CONSOLE ) || defined(CONFIG_MDA_CONSOLE ) +#if IS_ENABLED (CONFIG_VGA_CONSOLE ) ||IS_ENABLED (CONFIG_MDA_CONSOLE )#include <asm/vga.h> #endif
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 47/116 spi: fsl-spi: Fix CPM/QE mode Litte Endian
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
[ Upstream commit c20c57d9868d7f9fd1b2904c7801b07e128f6322 ]
CPM has the same problem as QE so for CPM also use the fix added by commit 0398fb70940e ("spi/spi_mpc8xxx: Fix QE mode Litte Endian"):
CPM mode uses Little Endian so words > 8 bits are byte swapped. Workaround this by always enforcing wordsize 8 for 16 and 32 bits words. Unfortunately this will not work for LSB transfers where wordsize is > 8 bits so disable these for now.
Also limit the workaround to 16 and 32 bits words because it can only work for multiples of 8-bits.
--- drivers/spi/spi-fsl-spi.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/spi/spi-fsl-spi.c +7 -5
@@ -205,8 +205,8 @@ static int mspi_apply_qe_mode_quirks(struct spi_mpc8xxx_cs *cs,struct spi_device *spi, int bits_per_word) { -/* QE uses Little Endian for words > 8 -* so transform all words > 8 into 8 bits +/* CPM/QE uses Little Endian for words > 8 +* so transform 16 and 32 bits words into 8 bits * Unfortnatly that doesn't work for LSB so * reject these for now */ /* Note: 32 bits word, LSB works iff
@@ -214,9 +214,11 @@ static int mspi_apply_qe_mode_quirks(struct spi_mpc8xxx_cs *cs,if (spi->mode &SPI_LSB_FIRST && bits_per_word >8 )return -EINVAL ; -if (bits_per_word >8 ) +if (bits_per_word <=8 ) +return bits_per_word; +if (bits_per_word ==16 || bits_per_word ==32 )return 8 ;/* pretend its 8 bits */ -return bits_per_word; +return -EINVAL ; } static int fsl_spi_setup_transfer(struct spi_device *spi,
@@ -246,7 +248,7 @@ static int fsl_spi_setup_transfer(struct spi_device *spi, bits_per_word =mspi_apply_cpu_mode_quirks (cs, spi, mpc8xxx_spi, bits_per_word); - else if (mpc8xxx_spi->flags & SPI_QE) + else bits_per_word =mspi_apply_qe_mode_quirks (cs, spi, bits_per_word);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 48/116 of: Fix modalias string generation
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
[ Upstream commit b19a4266c52de78496fe40f0b37580a3b762e67d ]
The helper generating an OF based modalias (of_device_get_modalias()) works fine, but due to the use of snprintf() internally it needs a buffer one byte longer than what should be needed just for the entire string (excluding the '\0'). Most users of this helper are sysfs hooks providing the modalias string to users. They all provide a PAGE_SIZE buffer which is way above the number of bytes required to fit the modalias string and hence do not suffer from this issue.
There is another user though, of_device_request_module(), which is only called by drivers/usb/common/ulpi.c. This request module function is faulty, but maybe because in most cases there is an alternative, ULPI driver users have not noticed it.
In this function, of_device_get_modalias() is called twice. The first time without buffer just to get the number of bytes required by the modalias string (excluding the null byte), and a second time, after buffer allocation, to fill the buffer. The allocation asks for an additional byte, in order to store the trailing '\0'. However, the buffer *length* provided to of_device_get_modalias() excludes this extra byte. The internal use of snprintf() with a length that is exactly the number of bytes to be written has the effect of using the last available byte to store a '\0', which then smashes the last character of the modalias string.
Provide the actual size of the buffer to of_device_get_modalias() to fix this issue.
Note: the "str[size - 1] = '\0';" line is not really needed as snprintf will anyway end the string with a null byte, but there is a possibility that this function might be called on a struct device_node without compatible, in this case snprintf() would not be executed. So we keep it just to avoid possible unbounded strings.
--- drivers/of/device.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/of/device.c +5 -2
@@ -257,12 +257,15 @@ int of_device_request_module(struct device *dev)if (size <0 )return size; - str =kmalloc (size +1 ,GFP_KERNEL ); +/* Reserve an additional byte for the trailing '\0' */ + size++; + + str =kmalloc (size,GFP_KERNEL );if (!str)return -ENOMEM ;of_device_get_modalias (dev, str, size); - str[size] ='\0' ; + str[size -1 ] ='\0' ; ret =request_module (str);kfree (str);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 49/116 ia64: mm/contig: fix section mismatch warning/error
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 58deeb4ef3b054498747d0929d94ac53ab90981f ]
alloc_per_cpu_data() is called by find_memory(), which is marked as __init. Therefore alloc_per_cpu_data() can also be marked as __init to remedy this modpost problem.
WARNING: modpost: vmlinux.o: section mismatch in reference: alloc_per_cpu_data (section: .text) -> memblock_alloc_try_nid (section: .init.text)
--- arch/ia64/mm/contig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/ia64/mm/contig.c +1 -1
@@ -129,7 +129,7 @@ void *per_cpu_init(void)return __per_cpu_start + __per_cpu_offset[smp_processor_id ()]; } -static inline void +static inline __init void alloc_per_cpu_data (void ) { cpu_data = __alloc_bootmem(PERCPU_PAGE_SIZE * num_possible_cpus(),
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 50/116 uapi/linux/const.h: prefer ISO-friendly __typeof__
In reply to Greg Kroah-HartmanFrom: Kevin Brodsky <[email protected]>
[ Upstream commit 31088f6f7906253ef4577f6a9b84e2d42447dba0 ]
typeof is (still) a GNU extension, which means that it cannot be used when building ISO C (e.g. -std=c99). It should therefore be avoided in uapi headers in favour of the ISO-friendly __typeof__.
Unfortunately this issue could not be detected by CONFIG_UAPI_HEADER_TEST=y as the __ALIGN_KERNEL() macro is not expanded in any uapi header.
This matters from a userspace perspective, not a kernel one. uapi headers and their contents are expected to be usable in a variety of situations, and in particular when building ISO C applications (with -std=c99 or similar).
This particular problem can be reproduced by trying to use the __ALIGN_KERNEL macro directly in application code, say:
#include <linux/const.h>
int align(int x, int a)
{
return __KERNEL_ALIGN(x, a);
}and trying to build that with -std=c99.
--- include/uapi/linux/const.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/const.h +1 -1
@@ -28,7 +28,7 @@#define _BITUL (x) (_AC(1,UL) << (x))#define _BITULL (x) (_AC(1,ULL) << (x)) -#define __ALIGN_KERNEL (x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1) +#define __ALIGN_KERNEL (x, a) __ALIGN_KERNEL_MASK(x, (__typeof__(x))(a) - 1)#define __ALIGN_KERNEL_MASK (x, mask) (((x) + (mask)) & ~(mask))#define __KERNEL_DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 51/116 sh: sq: Fix incorrect element size for allocating bitmap buffer
In reply to Greg Kroah-HartmanFrom: John Paul Adrian Glaubitz <[email protected]>
[ Upstream commit 80f746e2bd0e1da3fdb49a53570e54a1a225faac ]
The Store Queue code allocates a bitmap buffer with the size of multiple of sizeof(long) in sq_api_init(). While the buffer size is calculated correctly, the code uses the wrong element size to allocate the buffer which results in the allocated bitmap buffer being too small.
Fix this by allocating the buffer with kcalloc() with element size sizeof(long) instead of kzalloc() whose elements size defaults to sizeof(char).
--- arch/sh/kernel/cpu/sh4/sq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sh/kernel/cpu/sh4/sq.c +1 -1
@@ -383,7 +383,7 @@ static int __init sq_api_init(void)if (unlikely (!sq_cache))return ret; - sq_bitmap =kzalloc (size,GFP_KERNEL ); + sq_bitmap =kcalloc (size,sizeof (long ),GFP_KERNEL );if (unlikely (!sq_bitmap)) goto out;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 52/116 usb: chipidea: fix missing goto in `ci_hdrc_probe`
In reply to Greg Kroah-HartmanFrom: Yinhao Hu <[email protected]>
[ Upstream commit d6f712f53b79f5017cdcefafb7a5aea9ec52da5d ]
Quoted 1 line
From the comment of
ci_usb_phy_init, it returns an error code if
usb_phy_init has failed, and it should do some clean up, not just return directly.
Fix this by goto the error handling.
--- drivers/usb/chipidea/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/chipidea/core.c +1 -1
@@ -987,7 +987,7 @@ static int ci_hdrc_probe(struct platform_device *pdev) ret =ci_usb_phy_init (ci);if (ret) {dev_err (dev,"unable to init phy: %d\n" , ret); -return ret; + goto ulpi_exit; } ci->hw_bank.phys = res->start;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 53/116 tty: serial: fsl_lpuart: adjust buffer length to the intended size
In reply to Greg Kroah-HartmanFrom: Shenwei Wang <[email protected]>
[ Upstream commit f73fd750552524b06b5d77ebfdd106ccc8fcac61 ]
Based on the fls function definition provided below, we should not subtract 1 to obtain the correct buffer length:
fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
--- drivers/tty/serial/fsl_lpuart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/fsl_lpuart.c +1 -1
@@ -998,7 +998,7 @@ static inline int lpuart_start_rx_dma(struct lpuart_port *sport)* 10ms at any baud rate. */ sport->rx_dma_rng_buf_len = (DMA_RX_TIMEOUT * baud / bits /1000 ) *2 ; - sport->rx_dma_rng_buf_len = (1 << (fls (sport->rx_dma_rng_buf_len) -1 )); + sport->rx_dma_rng_buf_len = (1 <<fls (sport->rx_dma_rng_buf_len));if (sport->rx_dma_rng_buf_len <16 ) sport->rx_dma_rng_buf_len =16 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 54/116 serial: 8250: Add missing wakeup event reporting
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit 0ba9e3a13c6adfa99e32b2576d20820ab10ad48a ]
An 8250 UART configured as a wake-up source would not have reported itself through sysfs as being the source of wake-up, correct that.
--- drivers/tty/serial/8250/8250_port.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/tty/serial/8250/8250_port.c +4 -0
@@ -23,6 +23,7 @@#include <linux/moduleparam.h> #include <linux/ioport.h> #include <linux/init.h> +#include <linux/irq.h> #include <linux/console.h> #include <linux/sysrq.h> #include <linux/delay.h>
@@ -1886,6 +1887,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir)unsigned char status;unsigned long flags;struct uart_8250_port *up =up_to_u8250p (port); +struct tty_port *tport = &port->state->port;bool skip_rx = false;if (iir &UART_IIR_NO_INT )
@@ -1909,6 +1911,8 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) skip_rx = true;if (status & (UART_LSR_DR |UART_LSR_BI ) && !skip_rx) { +if (irqd_is_wakeup_set (irq_get_irq_data (port->irq))) +pm_wakeup_event (tport->tty->dev,0 );if (!up->dma ||handle_rx_dma (up, iir)) status =serial8250_rx_chars (up, status); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 55/116 staging: rtl8192e: Fix W_DISABLE# does not work after stop/start
In reply to Greg Kroah-HartmanFrom: Philipp Hortmann <[email protected]>
[ Upstream commit 3fac2397f562eb669ddc2f45867a253f3fc26184 ]
When loading the driver for rtl8192e, the W_DISABLE# switch is working as intended. But when the WLAN is turned off in software and then turned on again the W_DISABLE# does not work anymore. Reason for this is that in the function _rtl92e_dm_check_rf_ctrl_gpio() the bfirst_after_down is checked and returned when true. bfirst_after_down is set true when switching the WLAN off in software. But it is not set to false again when WLAN is turned on again.
Add bfirst_after_down = false in _rtl92e_sta_up to reset bit and fix above described bug.
--- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/rtl8192e/rtl8192e/rtl_core.c +1 -0
@@ -778,6 +778,7 @@ static int _rtl92e_sta_up(struct net_device *dev, bool is_silent_reset)else netif_wake_queue (dev); + priv->bfirst_after_down = false;return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 56/116 spmi: Add a check for remove callback when removing a SPMI driver
In reply to Greg Kroah-HartmanFrom: Jishnu Prakash <[email protected]>
[ Upstream commit b56eef3e16d888883fefab47425036de80dd38fc ]
When removing a SPMI driver, there can be a crash due to NULL pointer dereference if it does not have a remove callback defined. This is one such call trace observed when removing the QCOM SPMI PMIC driver:
dump_backtrace.cfi_jt+0x0/0x8 dump_stack_lvl+0xd8/0x16c panic+0x188/0x498 __cfi_slowpath+0x0/0x214 __cfi_slowpath+0x1dc/0x214 spmi_drv_remove+0x16c/0x1e0 device_release_driver_internal+0x468/0x79c driver_detach+0x11c/0x1a0 bus_remove_driver+0xc4/0x124 driver_unregister+0x58/0x84 cleanup_module+0x1c/0xc24 [qcom_spmi_pmic] __do_sys_delete_module+0x3ec/0x53c __arm64_sys_delete_module+0x18/0x28 el0_svc_common+0xdc/0x294 el0_svc+0x38/0x9c el0_sync_handler+0x8c/0xf0 el0_sync+0x1b4/0x1c0
If a driver has all its resources allocated through devm_() APIs and does not need any other explicit cleanup, it would not require a remove callback to be defined. Hence, add a check for remove callback presence before calling it when removing a SPMI driver.
--- drivers/spmi/spmi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/spmi/spmi.c +2 -1
@@ -356,7 +356,8 @@ static int spmi_drv_remove(struct device *dev)const struct spmi_driver *sdrv =to_spmi_driver (dev->driver);pm_runtime_get_sync (dev); - sdrv->remove (to_spmi_device (dev)); +if (sdrv->remove) + sdrv->remove (to_spmi_device (dev));pm_runtime_put_noidle (dev);pm_runtime_disable (dev);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 57/116 macintosh/windfarm_smu_sat: Add missing of_node_put()
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit 631cf002826007ab7415258ee647dcaf8845ad5a ]
We call of_node_get() in wf_sat_probe() after sat is created, so we need the of_node_put() before *kfree(sat)*.
--- drivers/macintosh/windfarm_smu_sat.c | 1 + 1 file changed, 1 insertion(+)
drivers/macintosh/windfarm_smu_sat.c +1 -0
@@ -172,6 +172,7 @@ static void wf_sat_release(struct kref *ref)if (sat->nr >=0 ) sats[sat->nr] =NULL ; +of_node_put (sat->node);kfree (sat); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 58/116 powerpc/mpc512x: fix resource printk format warning
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 7538c97e2b80ff6b7a8ea2ecf16a04355461b439 ]
Use "%pa" format specifier for resource_size_t to avoid a compiler printk format warning.
../arch/powerpc/platforms/512x/clock-commonclk.c: In function 'mpc5121_clk_provide_backwards_compat':../arch/powerpc/platforms/512x/clock-commonclk.c:989:44: error: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'resource_size_t' {aka 'long long unsigned int'} [-Werror=format=]
989 | snprintf(devname, sizeof(devname), "%08x.%s", res.start, np->name); \
| ^~~~~~~~~ ~~~~~~~~~
| |
| resource_size_t {aka long long unsigned int}Prevents 24 such warnings.
--- arch/powerpc/platforms/512x/clock-commonclk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/512x/clock-commonclk.c +1 -1
@@ -985,7 +985,7 @@ static void mpc5121_clk_provide_migration_support(void)#define NODE_PREP do { \ of_address_to_resource(np, 0, &res); \ - snprintf(devname, sizeof(devname), "%08x.%s", res.start, np->name); \ + snprintf(devname, sizeof(devname), "%pa.%s", &res.start, np->name); \ } while (0)#define NODE_CHK (clkname, clkitem, regnode, regflag) do { \
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 59/116 powerpc/wii: fix resource printk format warnings
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 7b69600d4da0049244e9be2f5ef5a2f8e04fcd9a ]
Use "%pa" format specifier for resource_size_t to avoid compiler printk format warnings.
../arch/powerpc/platforms/embedded6xx/flipper-pic.c: In function 'flipper_pic_init':../include/linux/kern_levels.h:5:25: error: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'resource_size_t' {aka 'long long unsigned int'} [-Werror=format=] ../arch/powerpc/platforms/embedded6xx/flipper-pic.c:148:9: note: in expansion of macro 'pr_info'
148 | pr_info("controller at 0x%08x mapped to 0x%p\n", res.start, io_base);
| ^~~~~~~../arch/powerpc/platforms/embedded6xx/hlwd-pic.c: In function 'hlwd_pic_init':../include/linux/kern_levels.h:5:25: error: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'resource_size_t' {aka 'long long unsigned int'} [-Werror=format=] ../arch/powerpc/platforms/embedded6xx/hlwd-pic.c:174:9: note: in expansion of macro 'pr_info'
174 | pr_info("controller at 0x%08x mapped to 0x%p\n", res.start, io_base);
| ^~~~~~~../arch/powerpc/platforms/embedded6xx/wii.c: In function 'wii_ioremap_hw_regs':../include/linux/kern_levels.h:5:25: error: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'resource_size_t' {aka 'long long unsigned int'} [-Werror=format=] ../arch/powerpc/platforms/embedded6xx/wii.c:77:17: note: in expansion of macro 'pr_info'
77 | pr_info("%s at 0x%08x mapped to 0x%p\n", name,
| ^~~~~~~--- arch/powerpc/platforms/embedded6xx/flipper-pic.c | 2 +- arch/powerpc/platforms/embedded6xx/hlwd-pic.c | 2 +- arch/powerpc/platforms/embedded6xx/wii.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/platforms/embedded6xx/flipper-pic.c +1 -1
@@ -157,7 +157,7 @@ struct irq_domain * __init flipper_pic_init(struct device_node *np) } io_base =ioremap (res.start,resource_size (&res)); -pr_info ("controller at 0x%08x mapped to 0x%p\n" , res.start, io_base); +pr_info ("controller at 0x%pa mapped to 0x%p\n" , &res.start, io_base);__flipper_quiesce (io_base);
arch/powerpc/platforms/embedded6xx/hlwd-pic.c +1 -1
@@ -178,7 +178,7 @@ struct irq_domain *hlwd_pic_init(struct device_node *np)return NULL ; } -pr_info ("controller at 0x%08x mapped to 0x%p\n" , res.start, io_base); +pr_info ("controller at 0x%pa mapped to 0x%p\n" , &res.start, io_base);__hlwd_quiesce (io_base);
arch/powerpc/platforms/embedded6xx/wii.c +2 -2
@@ -143,8 +143,8 @@ static void __iomem *wii_ioremap_hw_regs(char *name, char *compatible) hw_regs =ioremap (res.start,resource_size (&res));if (hw_regs) { -pr_info ("%s at 0x%08x mapped to 0x%p\n" , name, - res.start, hw_regs); +pr_info ("%s at 0x%pa mapped to 0x%p\n" , name, + &res.start, hw_regs); } out_put:
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 60/116 powerpc/sysdev/tsi108: fix resource printk format warnings
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 55d8bd02cc1b9f1063993b5c42c9cabf4af67dea ]
Use "%pa" format specifier for resource_size_t to avoid a compiler printk format warning.
arch/powerpc/sysdev/tsi108_pci.c: In function 'tsi108_setup_pci':
include/linux/kern_levels.h:5:25: error: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'resource_size_t'
--- arch/powerpc/sysdev/tsi108_pci.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/powerpc/sysdev/tsi108_pci.c +2 -3
@@ -229,9 +229,8 @@ int __init tsi108_setup_pci(struct device_node *dev, u32 cfg_phys, int primary) (hose)->ops = &tsi108_direct_pci_ops; -printk (KERN_INFO "Found tsi108 PCI host bridge at 0x%08x. " -"Firmware bus number: %d->%d\n" , - rsrc.start, hose->first_busno, hose->last_busno); +pr_info ("Found tsi108 PCI host bridge at 0x%pa. Firmware bus number: %d->%d\n" , + &rsrc.start, hose->first_busno, hose->last_busno);/* Interpret the "ranges" property */ /* This also maps the I/O region and sets isa_io/mem_base */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 61/116 macintosh: via-pmu-led: requires ATA to be set
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 05dce4ba125336875cd3eed3c1503fa81cd2f691 ]
LEDS_TRIGGER_DISK depends on ATA, so selecting LEDS_TRIGGER_DISK when ATA is not set/enabled causes a Kconfig warning:
WARNING: unmet direct dependencies detected for LEDS_TRIGGER_DISK
Depends on [n]: NEW_LEDS [=y] && LEDS_TRIGGERS [=y] && ATA [=n]
Selected by [y]:
- ADB_PMU_LED_DISK [=y] && MACINTOSH_DRIVERS [=y] && ADB_PMU_LED [=y] && LEDS_CLASS [=y]
Fix this by making ADB_PMU_LED_DISK depend on ATA.
Seen on both PPC32 and PPC64.
--- drivers/macintosh/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/macintosh/Kconfig +1 -0
@@ -94,6 +94,7 @@ config ADB_PMU_LED config ADB_PMU_LED_DISK bool "Use front LED as DISK LED by default" + depends on ATA depends on ADB_PMU_LED depends on LEDS_CLASS select LEDS_TRIGGERS
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 62/116 powerpc/rtas: use memmove for potentially overlapping buffer copy
In reply to Greg Kroah-HartmanFrom: Nathan Lynch <[email protected]>
[ Upstream commit 271208ee5e335cb1ad280d22784940daf7ddf820 ]
Using memcpy() isn't safe when buf is identical to rtas_err_buf, which can happen during boot before slab is up. Full context which may not be obvious from the diff:
if (altbuf) {
buf = altbuf;
} else {
buf = rtas_err_buf;
if (slab_is_available())
buf = kmalloc(RTAS_ERROR_LOG_MAX, GFP_ATOMIC);
}
if (buf)
memcpy(buf, rtas_err_buf, RTAS_ERROR_LOG_MAX);This was found by inspection and I'm not aware of it causing problems in practice. It appears to have been introduced by commit 033ef338b6e0 ("powerpc: Merge rtas.c into arch/powerpc/kernel"); the old ppc64 version of this code did not have this problem.
Use memmove() instead.
--- arch/powerpc/kernel/rtas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/rtas.c +1 -1
@@ -400,7 +400,7 @@ static char *__fetch_rtas_last_error(char *altbuf) buf =kmalloc (RTAS_ERROR_LOG_MAX ,GFP_ATOMIC ); }if (buf) -memcpy (buf, rtas_err_buf,RTAS_ERROR_LOG_MAX ); +memmove (buf, rtas_err_buf,RTAS_ERROR_LOG_MAX ); }return buf;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 63/116 perf/core: Fix hardlockup failure caused by perf throttle
In reply to Greg Kroah-HartmanFrom: Yang Jihong <[email protected]>
[ Upstream commit 15def34e2635ab7e0e96f1bc32e1b69609f14942 ]
commit e050e3f0a71bf ("perf: Fix broken interrupt rate throttling") introduces a change in throttling threshold judgment. Before this, compare hwc->interrupts and max_samples_per_tick, then increase hwc->interrupts by 1, but this commit reverses order of these two behaviors, causing the semantics of max_samples_per_tick to change. In literal sense of "max_samples_per_tick", if hwc->interrupts == max_samples_per_tick, it should not be throttled, therefore, the judgment condition should be changed to "hwc->interrupts > max_samples_per_tick".
In fact, this may cause the hardlockup to fail, The minimum value of max_samples_per_tick may be 1, in this case, the return value of __perf_event_account_interrupt function is 1.
As a result, nmi_watchdog gets throttled, which would stop PMU (Use x86 architecture as an example, see x86_pmu_handle_irq).
--- kernel/events/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/events/core.c +2 -2
@@ -7490,8 +7490,8 @@ __perf_event_account_interrupt(struct perf_event *event, int throttle) hwc->interrupts =1 ; }else { hwc->interrupts++; -if (unlikely (throttle - && hwc->interrupts >= max_samples_per_tick)) { +if (unlikely (throttle && + hwc->interrupts > max_samples_per_tick)) {__this_cpu_inc (perf_throttled_count);tick_dep_set_cpu (smp_processor_id (),TICK_DEP_BIT_PERF_EVENTS ); hwc->interrupts =MAX_INTERRUPTS ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 64/116 RDMA/rdmavt: Delete unnecessary NULL check
In reply to Greg Kroah-HartmanFrom: Natalia Petrova <[email protected]>
[ Upstream commit b73a0b80c69de77d8d4942abb37066531c0169b2 ]
There is no need to check 'rdi->qp_dev' for NULL. The field 'qp_dev' is created in rvt_register_device() which will fail if the 'qp_dev' allocation fails in rvt_driver_qp_init(). Overwise this pointer doesn't changed and passed to rvt_qp_exit() by the next step.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/infiniband/sw/rdmavt/qp.c | 2 -- 1 file changed, 2 deletions(-)
drivers/infiniband/sw/rdmavt/qp.c +0 -2
@@ -318,8 +318,6 @@ void rvt_qp_exit(struct rvt_dev_info *rdi)if (qps_inuse)rvt_pr_err (rdi,"QP memory leak! %u still in use\n" , qps_inuse); -if (!rdi->qp_dev) -return ;kfree (rdi->qp_dev->qp_table);free_qpn_table (&rdi->qp_dev->qpn_table);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 65/116 power: supply: generic-adc-battery: fix unit scaling
In reply to Greg Kroah-HartmanFrom: Sebastian Reichel <[email protected]>
[ Upstream commit 44263f50065969f2344808388bd589740f026167 ]
power-supply properties are reported in µV, µA and µW. The IIO API provides mV, mA, mW, so the values need to be multiplied by 1000.
--- drivers/power/supply/generic-adc-battery.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/power/supply/generic-adc-battery.c +3 -0
@@ -138,6 +138,9 @@ static int read_channel(struct gab *adc_bat, enum power_supply_property psp, result);if (ret <0 )pr_err ("read channel error\n" ); +else + *result *=1000 ; +return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 66/116 clk: add missing of_node_put() in "assigned-clocks" property parsing
In reply to Greg Kroah-HartmanFrom: Clément Léger <[email protected]>
[ Upstream commit 27a6e1b09a782517fddac91259970ac466a3f7b6 ]
When returning from of_parse_phandle_with_args(), the np member of the of_phandle_args structure should be put after usage. Add missing of_node_put() calls in both __set_clk_parents() and __set_clk_rates().
--- drivers/clk/clk-conf.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/clk/clk-conf.c +10 -2
@@ -36,9 +36,12 @@ static int __set_clk_parents(struct device_node *node, bool clk_supplier)else return rc; } -if (clkspec.np == node && !clk_supplier) +if (clkspec.np == node && !clk_supplier) { +of_node_put (clkspec.np);return 0 ; + } pclk =of_clk_get_from_provider (&clkspec); +of_node_put (clkspec.np);if (IS_ERR (pclk)) {if (PTR_ERR (pclk) != -EPROBE_DEFER ) pr_warn("clk: couldn't get parent clock %d for %pOF\n",
@@ -51,10 +54,12 @@ static int __set_clk_parents(struct device_node *node, bool clk_supplier)if (rc <0 ) goto err;if (clkspec.np == node && !clk_supplier) { +of_node_put (clkspec.np); rc =0 ; goto err; } clk =of_clk_get_from_provider (&clkspec); +of_node_put (clkspec.np);if (IS_ERR (clk)) {if (PTR_ERR (clk) != -EPROBE_DEFER ) pr_warn("clk: couldn't get assigned clock %d for %pOF\n",
@@ -96,10 +101,13 @@ static int __set_clk_rates(struct device_node *node, bool clk_supplier)else return rc; } -if (clkspec.np == node && !clk_supplier) +if (clkspec.np == node && !clk_supplier) { +of_node_put (clkspec.np);return 0 ; + } clk =of_clk_get_from_provider (&clkspec); +of_node_put (clkspec.np);if (IS_ERR (clk)) {if (PTR_ERR (clk) != -EPROBE_DEFER ) pr_warn("clk: couldn't get clock %d for %pOF\n",
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 67/116 IB/hfi1: Fix SDMA mmu_rb_node not being evicted in LRU order
In reply to Greg Kroah-HartmanFrom: Patrick Kelsey <[email protected]>
[ Upstream commit 9fe8fec5e43d5a80f43cbf61aaada1b047a1eb61 ]
hfi1_mmu_rb_remove_unless_exact() did not move mmu_rb_node objects in mmu_rb_handler->lru_list after getting a cache hit on an mmu_rb_node.
As a result, hfi1_mmu_rb_evict() was not guaranteed to evict truly least-recently used nodes.
This could be a performance issue for an application when that application:
- Uses some long-lived buffers frequently.
- Uses a large number of buffers once.
- Hits the mmu_rb_handler cache size or pinned-page limits, forcing mmu_rb_handler cache entries to be evicted.
In this case, the one-time use buffers cause the long-lived buffer entries to eventually filter to the end of the LRU list where hfi1_mmu_rb_evict() will consider evicting a frequently-used long-lived entry instead of evicting one of the one-time use entries.
Fix this by inserting new mmu_rb_node at the tail of mmu_rb_handler->lru_list and move mmu_rb_ndoe to the tail of mmu_rb_handler->lru_list when the mmu_rb_node is a hit in hfi1_mmu_rb_remove_unless_exact(). Change hfi1_mmu_rb_evict() to evict from the head of mmu_rb_handler->lru_list instead of the tail.
--- drivers/infiniband/hw/hfi1/mmu_rb.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/infiniband/hw/hfi1/mmu_rb.c +6 -7
@@ -177,7 +177,7 @@ int hfi1_mmu_rb_insert(struct mmu_rb_handler *handler, goto unlock; }__mmu_int_rb_insert (mnode, &handler->root); -list_add (&mnode->list, &handler->lru_list); +list_add_tail (&mnode->list, &handler->lru_list); ret = handler->ops->insert (handler->ops_arg, mnode);if (ret) {
@@ -224,8 +224,10 @@ bool hfi1_mmu_rb_remove_unless_exact(struct mmu_rb_handler *handler,spin_lock_irqsave (&handler->lock, flags); node =__mmu_rb_search (handler, addr, len);if (node) { -if (node->addr == addr && node->len == len) +if (node->addr == addr && node->len == len) { +list_move_tail (&node->list, &handler->lru_list); goto unlock; + }__mmu_int_rb_remove (node, &handler->root);list_del (&node->list);/* remove from LRU list */ ret = true;
@@ -246,8 +248,7 @@ void hfi1_mmu_rb_evict(struct mmu_rb_handler *handler, void *evict_arg)INIT_LIST_HEAD (&del_list);spin_lock_irqsave (&handler->lock, flags); -list_for_each_entry_safe_reverse (rbnode, ptr, &handler->lru_list, - list) { +list_for_each_entry_safe (rbnode, ptr, &handler->lru_list, list) {if (handler->ops->evict (handler->ops_arg, rbnode, evict_arg, &stop)) {__mmu_int_rb_remove (rbnode, &handler->root);
@@ -259,9 +260,7 @@ void hfi1_mmu_rb_evict(struct mmu_rb_handler *handler, void *evict_arg) }spin_unlock_irqrestore (&handler->lock, flags); -while (!list_empty (&del_list)) { - rbnode = list_first_entry(&del_list, struct mmu_rb_node, list); -list_del (&rbnode->list); +list_for_each_entry_safe (rbnode, ptr, &del_list, list) { handler->ops->remove (handler->ops_arg, rbnode); } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 68/116 NFSv4.1: Always send a RECLAIM_COMPLETE after establishing lease
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 40882deb83c29d8df4470d4e5e7f137b6acf7ad1 ]
The spec requires that we always at least send a RECLAIM_COMPLETE when we're done establishing the lease and recovering any state.
--- fs/nfs/nfs4state.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/nfs/nfs4state.c +4 -0
@@ -65,6 +65,8 @@#define OPENOWNER_POOL_SIZE 8 +static void nfs4_state_start_reclaim_reboot (struct nfs_client *clp); +const nfs4_stateid zero_stateid = { { .data = {0 } }, .type =NFS4_SPECIAL_STATEID_TYPE ,
@@ -321,6 +323,8 @@ int nfs41_init_clientid(struct nfs_client *clp, struct rpc_cred *cred) status =nfs4_proc_create_session (clp, cred);if (status !=0 ) goto out; +if (!(clp->cl_exchange_flags &EXCHGID4_FLAG_CONFIRMED_R )) +nfs4_state_start_reclaim_reboot (clp);nfs41_finish_session_reset (clp);nfs_mark_client_ready (clp,NFS_CS_READY ); out:
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 69/116 SUNRPC: remove the maximum number of retries in call_bind_status
In reply to Greg Kroah-HartmanFrom: Dai Ngo <[email protected]>
[ Upstream commit 691d0b782066a6eeeecbfceb7910a8f6184e6105 ]
Currently call_bind_status places a hard limit of 3 to the number of retries on EACCES error. This limit was done to prevent NLM unlock requests from being hang forever when the server keeps returning garbage. However this change causes problem for cases when NLM service takes longer than 9 seconds to register with the port mapper after a restart.
This patch removes this hard coded limit and let the RPC handles the retry based on the standard hard/soft task semantics.
--- include/linux/sunrpc/sched.h | 3 +-- net/sunrpc/clnt.c | 3 --- net/sunrpc/sched.c | 1 - 3 files changed, 1 insertion(+), 6 deletions(-)
include/linux/sunrpc/sched.h +1 -2
@@ -88,8 +88,7 @@ struct rpc_task {#endif unsigned char tk_priority : 2,/* Task priority */ tk_garb_retry : 2, - tk_cred_retry : 2, - tk_rebind_retry : 2; + tk_cred_retry : 2; };typedef void (*rpc_action )(struct rpc_task *);
net/sunrpc/clnt.c +0 -3
@@ -1827,9 +1827,6 @@ call_bind_status(struct rpc_task *task) status = -EOPNOTSUPP ;break ; } -if (task->tk_rebind_retry ==0 ) -break ; - task->tk_rebind_retry--;rpc_delay (task,3 *HZ ); goto retry_timeout;case -ETIMEDOUT :
net/sunrpc/sched.c +0 -1
@@ -697,7 +697,6 @@ rpc_init_task_statistics(struct rpc_task *task)/* Initialize retry counters */ task->tk_garb_retry =2 ; task->tk_cred_retry =2 ; - task->tk_rebind_retry =2 ;/* starting timestamp */ task->tk_start =ktime_get ();
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 70/116 phy: tegra: xusb: Add missing tegra_xusb_port_unregister for usb2_port and ulpi_port
In reply to Greg Kroah-HartmanFrom: Gaosheng Cui <[email protected]>
[ Upstream commit e024854048e733391b31fe5a398704b31b9af803 ]
The tegra_xusb_port_unregister should be called when usb2_port and ulpi_port map fails in tegra_xusb_add_usb2_port() or in tegra_xusb_add_ulpi_port(), fix it.
--- drivers/phy/tegra/xusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/phy/tegra/xusb.c +2 -0
@@ -596,6 +596,7 @@ static int tegra_xusb_add_usb2_port(struct tegra_xusb_padctl *padctl, usb2->base.lane = usb2->base.ops->map (&usb2->base);if (IS_ERR (usb2->base.lane)) { err =PTR_ERR (usb2->base.lane); +tegra_xusb_port_unregister (&usb2->base); goto out; }
@@ -648,6 +649,7 @@ static int tegra_xusb_add_ulpi_port(struct tegra_xusb_padctl *padctl, ulpi->base.lane = ulpi->base.ops->map (&ulpi->base);if (IS_ERR (ulpi->base.lane)) { err =PTR_ERR (ulpi->base.lane); +tegra_xusb_port_unregister (&ulpi->base); goto out; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 71/116 dmaengine: at_xdmac: do not enable all cyclic channels
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit f8435befd81dd85b7b610598551fadf675849bc1 ]
Do not global enable all the cyclic channels in at_xdmac_resume(). Instead save the global status in at_xdmac_suspend() and re-enable the cyclic channel only if it was active before suspend.
--- drivers/dma/at_xdmac.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/dma/at_xdmac.c +4 -1
@@ -223,6 +223,7 @@ struct at_xdmac {int irq;struct clk *clk;u32 save_gim; +u32 save_gs;struct dma_pool *at_xdmac_desc_pool;struct at_xdmac_chan chan[0 ]; };
@@ -1880,6 +1881,7 @@ static int atmel_xdmac_suspend(struct device *dev) } } atxdmac->save_gim =at_xdmac_read (atxdmac,AT_XDMAC_GIM ); + atxdmac->save_gs =at_xdmac_read (atxdmac,AT_XDMAC_GS );at_xdmac_off (atxdmac);clk_disable_unprepare (atxdmac->clk);
@@ -1917,7 +1919,8 @@ static int atmel_xdmac_resume(struct device *dev)at_xdmac_chan_write (atchan,AT_XDMAC_CNDC , atchan->save_cndc);at_xdmac_chan_write (atchan,AT_XDMAC_CIE , atchan->save_cim);wmb (); -at_xdmac_write (atxdmac,AT_XDMAC_GE , atchan->mask); +if (atxdmac->save_gs & atchan->mask) +at_xdmac_write (atxdmac,AT_XDMAC_GE , atchan->mask); } }return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 72/116 parisc: Fix argument pointer in real64_call_asm()
In reply to Greg Kroah-HartmanFrom: Helge Deller <[email protected]>
commit 6e3220ba3323a2c24be834aebf5d6e9f89d0993f upstream.
Fix the argument pointer (ap) to point to real-mode memory instead of virtual memory.
It's interesting that this issue hasn't shown up earlier, as this could have happened with any 64-bit PDC ROM code.
I just noticed it because I suddenly faced a HPMC while trying to execute the 64-bit STI ROM code of an Visualize-FXe graphics card for the STI text console.
--- arch/parisc/kernel/real2.S | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/parisc/kernel/real2.S +2 -3
@@ -254,9 +254,6 @@ ENTRY_CFI(real64_call_asm) /* save fn */ copy %arg2, %r31 - /* set up the new ap */ - ldo 64(%arg1), %r29 - /* load up the arg registers from the saved arg area */ /* 32-bit calling convention passes first 4 args in registers */ ldd 0*REG_SZ(%arg1), %arg0 /* note overwriting arg0 */
@@ -268,7 +265,9 @@ ENTRY_CFI(real64_call_asm) ldd 7*REG_SZ(%arg1), %r19 ldd 1*REG_SZ(%arg1), %arg1 /* do this one last! */ + /* set up real-mode stack and real-mode ap */ tophys_r1 %sp + ldo -16(%sp), %r29 /* Reference param save area */ b,l rfi_virt2real,%r2 nop
Greg Kroah-Hartman
maintainerPATCH 73/116 nilfs2: do not write dirty data after degenerating to read-only
In reply to Greg Kroah-HartmanFrom: Ryusuke Konishi <[email protected]>
commit 28a65b49eb53e172d23567005465019658bfdb4d upstream.
According to syzbot's report, mark_buffer_dirty() called from nilfs_segctor_do_construct() outputs a warning with some patterns after nilfs2 detects metadata corruption and degrades to read-only mode.
After such read-only degeneration, page cache data may be cleared through nilfs_clear_dirty_page() which may also clear the uptodate flag for their buffer heads. However, even after the degeneration, log writes are still performed by unmount processing etc., which causes mark_buffer_dirty() to be called for buffer heads without the "uptodate" flag and causes the warning.
Since any writes should not be done to a read-only file system in the first place, this fixes the warning in mark_buffer_dirty() by letting nilfs_segctor_do_construct() abort early if in read-only mode.
This also changes the retry check of nilfs_segctor_write_out() to avoid unnecessary log write retries if it detects -EROFS that nilfs_segctor_do_construct() returned.
--- fs/nilfs2/segment.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/nilfs2/segment.c +4 -1
@@ -2052,6 +2052,9 @@ static int nilfs_segctor_do_construct(ststruct the_nilfs *nilfs = sci->sc_super->s_fs_info;int err; +if (sb_rdonly (sci->sc_super)) +return -EROFS ; +nilfs_sc_cstage_set (sci,NILFS_ST_INIT ); sci->sc_cno = nilfs->ns_cno;
@@ -2738,7 +2741,7 @@ static void nilfs_segctor_write_out(struflush_work (&sci->sc_iput_work); - }while (ret && retrycount-- >0 ); + }while (ret && ret != -EROFS && retrycount-- >0 ); }/**
Greg Kroah-Hartman
maintainerPATCH 74/116 nilfs2: fix infinite loop in nilfs_mdt_get_block()
In reply to Greg Kroah-HartmanFrom: Ryusuke Konishi <[email protected]>
commit a6a491c048882e7e424d407d32cba0b52d9ef2bf upstream.
If the disk image that nilfs2 mounts is corrupted and a virtual block address obtained by block lookup for a metadata file is invalid, nilfs_bmap_lookup_at_level() may return the same internal return code as -ENOENT, meaning the block does not exist in the metadata file.
This duplication of return codes confuses nilfs_mdt_get_block(), causing it to read and create a metadata block indefinitely.
In particular, if this happens to the inode metadata file, ifile, semaphore i_rwsem can be left held, causing task hangs in lock_mount.
Fix this issue by making nilfs_bmap_lookup_at_level() treat virtual block address translation failures with -ENOENT as metadata corruption instead of returning the error code.
--- fs/nilfs2/bmap.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
fs/nilfs2/bmap.c +12 -4
@@ -76,20 +76,28 @@ int nilfs_bmap_lookup_at_level(struct nidown_read (&bmap->b_sem); ret = bmap->b_ops->bop_lookup (bmap, key, level, ptrp); -if (ret <0 ) { - ret =nilfs_bmap_convert_error (bmap, __func__, ret); +if (ret <0 ) goto out; - } +if (NILFS_BMAP_USE_VBN (bmap)) { ret =nilfs_dat_translate (nilfs_bmap_get_dat (bmap), *ptrp, &blocknr);if (!ret) *ptrp = blocknr; +else if (ret == -ENOENT ) { +/* +* If there was no valid entry in DAT for the block +* address obtained by b_ops->bop_lookup, then pass +* internal code -EINVAL to nilfs_bmap_convert_error +* to treat it as metadata corruption. +*/ + ret = -EINVAL ; + } } out:up_read (&bmap->b_sem); -return ret; +return nilfs_bmap_convert_error (bmap, __func__, ret); } int nilfs_bmap_lookup_contig(struct nilfs_bmap *bmap, __u64 key, __u64 *ptrp,
Greg Kroah-Hartman
maintainerPATCH 75/116 wifi: rtl8xxxu: RTL8192EU always needs full init
In reply to Greg Kroah-HartmanFrom: Bitterblue Smith <[email protected]>
commit d46e04ccd40457a0119b76e11ab64a2ad403e138 upstream.
Always run the entire init sequence (rtl8xxxu_init_device()) for RTL8192EU. It's what the vendor driver does too.
This fixes a bug where the device is unable to connect after rebooting:
wlp3s0f3u2: send auth to ... (try 1/3)
wlp3s0f3u2: send auth to ... (try 2/3)
wlp3s0f3u2: send auth to ... (try 3/3)
wlp3s0f3u2: authentication with ... timed out
Rebooting leaves the device powered on (partially? at least the firmware is still running), but not really in a working state.
--- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c +1 -0
@@ -1660,6 +1660,7 @@ struct rtl8xxxu_fileops rtl8192eu_fops = .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc24), .has_s0s1 = 0, .gen2_thermal_meter = 1, + .needs_full_init = 1, .adda_1t_init = 0x0fc01616, .adda_1t_path_on = 0x0fc01616, .adda_2t_path_on_a = 0x0fc01616,
Greg Kroah-Hartman
maintainerPATCH 76/116 clk: rockchip: rk3399: allow clk_cifout to force clk_cifout_src to reparent
In reply to Greg Kroah-HartmanFrom: Quentin Schulz <[email protected]>
commit 933bf364e152cd60902cf9585c2ba310d593e69f upstream.
clk_cifout is derived from clk_cifout_src through an integer divider limited to 32. clk_cifout_src is a child of either cpll, gpll or npll without any possibility of a divider of any sort. The default clock parent is cpll.
Let's allow clk_cifout to ask its parent clk_cifout_src to reparent in order to find the real closest possible rate for clk_cifout and not one derived from cpll only.
--- drivers/clk/rockchip/clk-rk3399.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk-rk3399.c +1 -1
@@ -1266,7 +1266,7 @@ static struct rockchip_clk_branch rk3399 RK3399_CLKSEL_CON(56), 6, 2, MFLAGS, RK3399_CLKGATE_CON(10), 7, GFLAGS), -COMPOSITE_NOGATE (SCLK_CIF_OUT ,"clk_cifout" , mux_clk_cif_p,0 , +COMPOSITE_NOGATE (SCLK_CIF_OUT ,"clk_cifout" , mux_clk_cif_p,CLK_SET_RATE_PARENT , RK3399_CLKSEL_CON(56), 5, 1, MFLAGS, 0, 5, DFLAGS),/* gic */
Greg Kroah-Hartman
maintainerPATCH 77/116 btrfs: scrub: reject unsupported scrub flags
In reply to Greg Kroah-HartmanFrom: Qu Wenruo <[email protected]>
commit 604e6681e114d05a2e384c4d1e8ef81918037ef5 upstream.
Since the introduction of scrub interface, the only flag that we support is BTRFS_SCRUB_READONLY. Thus there is no sanity checks, if there are some undefined flags passed in, we just ignore them.
This is problematic if we want to introduce new scrub flags, as we have no way to determine if such flags are supported.
Address the problem by introducing a check for the flags, and if unsupported flags are set, return -EOPNOTSUPP to inform the user space.
This check should be backported for all supported kernels before any new scrub flags are introduced.
--- fs/btrfs/ioctl.c | 5 +++++ include/uapi/linux/btrfs.h | 1 + 2 files changed, 6 insertions(+)
fs/btrfs/ioctl.c +5 -0
@@ -4442,6 +4442,11 @@ static long btrfs_ioctl_scrub(struct filif (IS_ERR (sa))return PTR_ERR (sa); +if (sa->flags & ~BTRFS_SCRUB_SUPPORTED_FLAGS ) { + ret = -EOPNOTSUPP ; + goto out; + } +if (!(sa->flags &BTRFS_SCRUB_READONLY )) { ret =mnt_want_write_file (file);if (ret)
include/uapi/linux/btrfs.h +1 -0
@@ -161,6 +161,7 @@ struct btrfs_scrub_progress { };#define BTRFS_SCRUB_READONLY 1 +#define BTRFS_SCRUB_SUPPORTED_FLAGS (BTRFS_SCRUB_READONLY)struct btrfs_ioctl_scrub_args {__u64 devid;/* in */ __u64 start;/* in */
Greg Kroah-Hartman
maintainerPATCH 78/116 s390/dasd: fix hanging blockdevice after request requeue
In reply to Greg Kroah-HartmanFrom: Stefan Haberland <[email protected]>
commit d8898ee50edecacdf0141f26fd90acf43d7e9cd7 upstream.
The DASD driver does not kick the requeue list when requeuing IO requests to the blocklayer. This might lead to hanging blockdevice when there is no other trigger for this.
Fix by automatically kick the requeue list when requeuing DASD requests to the blocklayer.
--- drivers/s390/block/dasd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/block/dasd.c +1 -1
@@ -2899,7 +2899,7 @@ static int _dasd_requeue_request(structreturn 0 ;spin_lock_irq (&cqr->dq->lock); req = (struct request *) cqr->callback_data; -blk_mq_requeue_request (req, false); +blk_mq_requeue_request (req, true);spin_unlock_irq (&cqr->dq->lock);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 79/116 dm integrity: call kmem_cache_destroy() in dm_integrity_init() error path
In reply to Greg Kroah-HartmanFrom: Mike Snitzer <[email protected]>
commit 6b79a428c02769f2a11f8ae76bf866226d134887 upstream.
Otherwise the journal_io_cache will leak if dm_register_target() fails.
--- drivers/md/dm-integrity.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/md/dm-integrity.c +5 -3
@@ -3274,11 +3274,13 @@ int __init dm_integrity_init(void) } r =dm_register_target (&integrity_target); - -if (r <0 ) +if (r <0 ) {DMERR ("register failed %d" , r); +kmem_cache_destroy (journal_io_cache); +return r; + } -return r; +return 0 ; }void dm_integrity_exit (void )
Greg Kroah-Hartman
maintainerPATCH 80/116 dm flakey: fix a crash with invalid table line
In reply to Greg Kroah-HartmanFrom: Mikulas Patocka <[email protected]>
commit 98dba02d9a93eec11bffbb93c7c51624290702d2 upstream.
This command will crash with NULL pointer dereference:
dmsetup create flakey --table \
"0 blockdev --getsize /dev/ram0 flakey /dev/ram0 0 0 1 2 corrupt_bio_byte 512"
Fix the crash by checking if arg_name is non-NULL before comparing it.
--- drivers/md/dm-flakey.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/dm-flakey.c +2 -2
@@ -124,9 +124,9 @@ static int parse_features(struct dm_arg_* Direction r or w? */ arg_name =dm_shift_arg (as); -if (!strcasecmp (arg_name,"w" )) +if (arg_name && !strcasecmp (arg_name,"w" )) fc->corrupt_bio_rw =WRITE ; -else if (!strcasecmp (arg_name,"r" )) +else if (arg_name && !strcasecmp (arg_name,"r" )) fc->corrupt_bio_rw =READ ;else { ti->error ="Invalid corrupt bio direction (r or w)" ;
Greg Kroah-Hartman
maintainerPATCH 81/116 dm ioctl: fix nested locking in table_clear() to remove deadlock concern
In reply to Greg Kroah-HartmanFrom: Mike Snitzer <[email protected]>
commit 3d32aaa7e66d5c1479a3c31d6c2c5d45dd0d3b89 upstream.
syzkaller found the following problematic rwsem locking (with write lock already held):
down_read+0x9d/0x450 kernel/locking/rwsem.c:1509 dm_get_inactive_table+0x2b/0xc0 drivers/md/dm-ioctl.c:773 __dev_status+0x4fd/0x7c0 drivers/md/dm-ioctl.c:844 table_clear+0x197/0x280 drivers/md/dm-ioctl.c:1537
In table_clear, it first acquires a write lock
https://elixir.bootlin.com/linux/v6.2/source/drivers/md/dm-ioctl.c#L1520down_write(&_hash_lock);
Then before the lock is released at L1539, there is a path shown above:table_clear -> __dev_status -> dm_get_inactive_table -> down_read
https://elixir.bootlin.com/linux/v6.2/source/drivers/md/dm-ioctl.c#L773down_read(&_hash_lock);
It tries to acquire the same read lock again, resulting in the deadlock problem.
Fix this by moving table_clear()'s __dev_status() call to after its up_write(&_hash_lock);
--- drivers/md/dm-ioctl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/md/dm-ioctl.c +4 -3
@@ -1409,11 +1409,12 @@ static int table_clear(struct file *filp hc->new_map =NULL ; } - param->flags &= ~DM_INACTIVE_PRESENT_FLAG ; - -__dev_status (hc->md, param); md = hc->md;up_write (&_hash_lock); + + param->flags &= ~DM_INACTIVE_PRESENT_FLAG ; +__dev_status (md, param); +if (old_map) {dm_sync_table (md);dm_table_destroy (old_map);
Greg Kroah-Hartman
maintainerPATCH 82/116 perf auxtrace: Fix address filter entire kernel size
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
commit 1f9f33ccf0320be21703d9195dd2b36a1c9a07cb upstream.
kallsyms is not completely in address order.
In find_entire_kern_cb(), calculate the kernel end from the maximum address not the last symbol.
Example:
Before:
$ sudo cat /proc/kallsyms | grep ' [twTw] ' | tail -1
ffffffffc00b8bd0 t bpf_prog_6deef7357e7b4530 [bpf]
$ sudo cat /proc/kallsyms | grep ' [twTw] ' | sort | tail -1
ffffffffc15e0cc0 t iwl_mvm_exit [iwlmvm]
$ perf.d093603a05aa record -v --kcore -e intel_pt// --filter 'filter *' -- uname |& grep filter
Address filter: filter 0xffffffff93200000/0x2ceba000After:
$ perf.8fb0f7a01f8e record -v --kcore -e intel_pt// --filter 'filter *' -- uname |& grep filter
Address filter: filter 0xffffffff93200000/0x2e3e2000--- tools/perf/util/auxtrace.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/auxtrace.c +4 -1
@@ -1776,6 +1776,7 @@ static int find_entire_kern_cb(void *arg char type, u64 start) {struct sym_args *args = arg; +u64 size;if (!symbol_type__is_a (type,MAP__FUNCTION ))return 0 ;
@@ -1785,7 +1786,9 @@ static int find_entire_kern_cb(void *arg args->start = start; }/* Don't know exactly where the kernel ends, so we add a page */ - args->size =round_up (start, page_size) + page_size - args->start; + size =round_up (start, page_size) + page_size - args->start; +if (size > args->size) + args->size = size;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 83/116 netfilter: nf_tables: split set destruction in deactivate and destroy phase
In reply to Greg Kroah-HartmanFrom: Florian Westphal <[email protected]>
[ backport for 4.14 of cd5125d8f51882279f50506bb9c7e5e89dc9bef3 ]
Splits unbind_set into destroy_set and unbinding operation.
Unbinding removes set from lists (so new transaction would not find it anymore) but keeps memory allocated (so packet path continues to work).
Rebind function is added to allow unrolling in case transaction that wants to remove set is aborted.
Destroy function is added to free the memory, but this could occur outside of transaction in the future.
--- include/net/netfilter/nf_tables.h | 7 +++++- net/netfilter/nf_tables_api.c | 36 +++++++++++++++++++++---------- net/netfilter/nft_dynset.c | 21 +++++++++++++++++- net/netfilter/nft_lookup.c | 20 ++++++++++++++++- net/netfilter/nft_objref.c | 20 ++++++++++++++++- 5 files changed, 89 insertions(+), 15 deletions(-)
include/net/netfilter/nf_tables.h +6 -1
@@ -463,6 +463,9 @@ int nf_tables_bind_set(const struct nft_ctx *ctx, struct nft_set *set, struct nft_set_binding *binding);void nf_tables_unbind_set (const struct nft_ctx *ctx,struct nft_set *set,struct nft_set_binding *binding); +void nf_tables_rebind_set (const struct nft_ctx *ctx,struct nft_set *set, +struct nft_set_binding *binding); +void nf_tables_destroy_set (const struct nft_ctx *ctx,struct nft_set *set);/** * enum nft_set_extensions - set extension type IDs
@@ -716,7 +719,9 @@ struct nft_expr_type {* @eval: Expression evaluation function * @size: full expression size, including private data size * @init: initialization function -* @destroy: destruction function +* @activate: activate expression in the next generation +* @deactivate: deactivate expression in next generation +* @destroy: destruction function, called after synchronize_rcu * @dump: function to dump parameters * @type: expression type * @validate: validate expression, called during loop detection
net/netfilter/nf_tables_api.c +25 -11
@@ -327,7 +327,7 @@ static int nft_delrule_by_chain(struct nft_ctx *ctx)return 0 ; } -static int nft_trans_set_add (struct nft_ctx *ctx,int msg_type, +static int nft_trans_set_add (const struct nft_ctx *ctx,int msg_type,struct nft_set *set) {struct nft_trans *trans;
@@ -347,7 +347,7 @@ static int nft_trans_set_add(struct nft_ctx *ctx, int msg_type,return 0 ; } -static int nft_delset (struct nft_ctx *ctx,struct nft_set *set) +static int nft_delset (const struct nft_ctx *ctx,struct nft_set *set) {int err;
@@ -3311,13 +3311,6 @@ static void nft_set_destroy(struct nft_set *set)kvfree (set); } -static void nf_tables_set_destroy (const struct nft_ctx *ctx,struct nft_set *set) -{ -list_del_rcu (&set->list); -nf_tables_set_notify (ctx, set,NFT_MSG_DELSET ,GFP_ATOMIC ); -nft_set_destroy (set); -} - static int nf_tables_delset(struct net *net, struct sock *nlsk, struct sk_buff *skb, const struct nlmsghdr *nlh, const struct nlattr * const nla[],
@@ -3400,17 +3393,38 @@ int nf_tables_bind_set(const struct nft_ctx *ctx, struct nft_set *set, }EXPORT_SYMBOL_GPL (nf_tables_bind_set); -void nf_tables_unbind_set (const struct nft_ctx *ctx,struct nft_set *set, +void nf_tables_rebind_set (const struct nft_ctx *ctx,struct nft_set *set,struct nft_set_binding *binding) +{ +if (list_empty (&set->bindings) && set->flags &NFT_SET_ANONYMOUS && +nft_is_active (ctx->net, set)) +list_add_tail_rcu (&set->list, &ctx->table->sets); + +list_add_tail_rcu (&binding->list, &set->bindings); +} +EXPORT_SYMBOL_GPL (nf_tables_rebind_set); + +void nf_tables_unbind_set (const struct nft_ctx *ctx,struct nft_set *set, +struct nft_set_binding *binding) {list_del_rcu (&binding->list);if (list_empty (&set->bindings) && set->flags &NFT_SET_ANONYMOUS &&nft_is_active (ctx->net, set)) -nf_tables_set_destroy (ctx, set); +list_del_rcu (&set->list); }EXPORT_SYMBOL_GPL (nf_tables_unbind_set); +void nf_tables_destroy_set (const struct nft_ctx *ctx,struct nft_set *set) +{ +if (list_empty (&set->bindings) && set->flags &NFT_SET_ANONYMOUS && +nft_is_active (ctx->net, set)) { +nf_tables_set_notify (ctx, set,NFT_MSG_DELSET ,GFP_ATOMIC ); +nft_set_destroy (set); + } +} +EXPORT_SYMBOL_GPL (nf_tables_destroy_set); +const struct nft_set_ext_type nft_set_ext_types[] = { [NFT_SET_EXT_KEY ] = { .align = __alignof__(u32 ),
net/netfilter/nft_dynset.c +20 -1
@@ -223,14 +223,31 @@ static int nft_dynset_init(const struct nft_ctx *ctx,return err; } +static void nft_dynset_activate (const struct nft_ctx *ctx, +const struct nft_expr *expr) +{ +struct nft_dynset *priv =nft_expr_priv (expr); + +nf_tables_rebind_set (ctx, priv->set, &priv->binding); +} + +static void nft_dynset_deactivate (const struct nft_ctx *ctx, +const struct nft_expr *expr) +{ +struct nft_dynset *priv =nft_expr_priv (expr); + +nf_tables_unbind_set (ctx, priv->set, &priv->binding); +} +static void nft_dynset_destroy (const struct nft_ctx *ctx,const struct nft_expr *expr) {struct nft_dynset *priv =nft_expr_priv (expr); -nf_tables_unbind_set (ctx, priv->set, &priv->binding);if (priv->expr !=NULL )nft_expr_destroy (ctx, priv->expr); + +nf_tables_destroy_set (ctx, priv->set); }static int nft_dynset_dump (struct sk_buff *skb,const struct nft_expr *expr)
@@ -267,6 +284,8 @@ static const struct nft_expr_ops nft_dynset_ops = { .eval = nft_dynset_eval, .init = nft_dynset_init, .destroy = nft_dynset_destroy, + .activate = nft_dynset_activate, + .deactivate = nft_dynset_deactivate, .dump = nft_dynset_dump, };
net/netfilter/nft_lookup.c +19 -1
@@ -118,12 +118,28 @@ static int nft_lookup_init(const struct nft_ctx *ctx,return 0 ; } +static void nft_lookup_activate (const struct nft_ctx *ctx, +const struct nft_expr *expr) +{ +struct nft_lookup *priv =nft_expr_priv (expr); + +nf_tables_rebind_set (ctx, priv->set, &priv->binding); +} + +static void nft_lookup_deactivate (const struct nft_ctx *ctx, +const struct nft_expr *expr) +{ +struct nft_lookup *priv =nft_expr_priv (expr); + +nf_tables_unbind_set (ctx, priv->set, &priv->binding); +} +static void nft_lookup_destroy (const struct nft_ctx *ctx,const struct nft_expr *expr) {struct nft_lookup *priv =nft_expr_priv (expr); -nf_tables_unbind_set (ctx, priv->set, &priv->binding); +nf_tables_destroy_set (ctx, priv->set); }static int nft_lookup_dump (struct sk_buff *skb,const struct nft_expr *expr)
@@ -151,6 +167,8 @@ static const struct nft_expr_ops nft_lookup_ops = { .size = NFT_EXPR_SIZE(sizeof(struct nft_lookup)), .eval = nft_lookup_eval, .init = nft_lookup_init, + .activate = nft_lookup_activate, + .deactivate = nft_lookup_deactivate, .destroy = nft_lookup_destroy, .dump = nft_lookup_dump, };
net/netfilter/nft_objref.c +19 -1
@@ -154,12 +154,28 @@ static int nft_objref_map_dump(struct sk_buff *skb, const struct nft_expr *expr)return -1 ; } +static void nft_objref_map_activate (const struct nft_ctx *ctx, +const struct nft_expr *expr) +{ +struct nft_objref_map *priv =nft_expr_priv (expr); + +nf_tables_rebind_set (ctx, priv->set, &priv->binding); +} + +static void nft_objref_map_deactivate (const struct nft_ctx *ctx, +const struct nft_expr *expr) +{ +struct nft_objref_map *priv =nft_expr_priv (expr); + +nf_tables_unbind_set (ctx, priv->set, &priv->binding); +} +static void nft_objref_map_destroy (const struct nft_ctx *ctx,const struct nft_expr *expr) {struct nft_objref_map *priv =nft_expr_priv (expr); -nf_tables_unbind_set (ctx, priv->set, &priv->binding); +nf_tables_destroy_set (ctx, priv->set); }static struct nft_expr_type nft_objref_type;
@@ -168,6 +184,8 @@ static const struct nft_expr_ops nft_objref_map_ops = { .size = NFT_EXPR_SIZE(sizeof(struct nft_objref_map)), .eval = nft_objref_map_eval, .init = nft_objref_map_init, + .activate = nft_objref_map_activate, + .deactivate = nft_objref_map_deactivate, .destroy = nft_objref_map_destroy, .dump = nft_objref_map_dump, };
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 84/116 netfilter: nf_tables: unbind set in rule from commit path
In reply to Greg Kroah-HartmanFrom: Pablo Neira Ayuso <[email protected]>
[ backport for 4.14 of f6ac8585897684374a19863fff21186a05805286 ]
Anonymous sets that are bound to rules from the same transaction trigger a kernel splat from the abort path due to double set list removal and double free.
This patch updates the logic to search for the transaction that is responsible for creating the set and disable the set list removal and release, given the rule is now responsible for this. Lookup is reverse since the transaction that adds the set is likely to be at the tail of the list.
Moreover, this patch adds the unbind step to deliver the event from the commit path. This should not be done from the worker thread, since we have no guarantees of in-order delivery to the listener.
This patch removes the assumption that both activate and deactivate callbacks need to be provided.
--- include/net/netfilter/nf_tables.h | 17 +++++-- net/netfilter/nf_tables_api.c | 85 +++++++++++++++---------------- net/netfilter/nft_dynset.c | 18 +++---- net/netfilter/nft_immediate.c | 6 ++- net/netfilter/nft_lookup.c | 18 +++---- net/netfilter/nft_objref.c | 18 +++---- 6 files changed, 80 insertions(+), 82 deletions(-)
include/net/netfilter/nf_tables.h +13 -4
@@ -462,9 +462,7 @@ struct nft_set_binding {int nf_tables_bind_set (const struct nft_ctx *ctx,struct nft_set *set,struct nft_set_binding *binding);void nf_tables_unbind_set (const struct nft_ctx *ctx,struct nft_set *set, -struct nft_set_binding *binding); -void nf_tables_rebind_set (const struct nft_ctx *ctx,struct nft_set *set, -struct nft_set_binding *binding); +struct nft_set_binding *binding,bool commit);void nf_tables_destroy_set (const struct nft_ctx *ctx,struct nft_set *set);/**
@@ -713,6 +711,13 @@ struct nft_expr_type {#define NFT_EXPR_STATEFUL 0x1 +enum nft_trans_phase { +NFT_TRANS_PREPARE , +NFT_TRANS_ABORT , +NFT_TRANS_COMMIT , +NFT_TRANS_RELEASE +}; +/** * struct nft_expr_ops - nf_tables expression operations *
@@ -742,7 +747,8 @@ struct nft_expr_ops {void (*activate)(const struct nft_ctx *ctx,const struct nft_expr *expr);void (*deactivate)(const struct nft_ctx *ctx, -const struct nft_expr *expr); +const struct nft_expr *expr, +enum nft_trans_phase phase);void (*destroy)(const struct nft_ctx *ctx,const struct nft_expr *expr); int (*dump)(struct sk_buff *skb,
@@ -1290,12 +1296,15 @@ struct nft_trans_rule {struct nft_trans_set {struct nft_set *set;u32 set_id; +bool bound; };#define nft_trans_set (trans) \ (((struct nft_trans_set *)trans->data)->set)#define nft_trans_set_id (trans) \ (((struct nft_trans_set *)trans->data)->set_id) +#define nft_trans_set_bound (trans) \ + (((struct nft_trans_set *)trans->data)->bound)struct nft_trans_chain {bool update;
net/netfilter/nf_tables_api.c +41 -44
178 lines not on this page · raw message
net/netfilter/nft_dynset.c +7 -11
@@ -223,20 +223,17 @@ static int nft_dynset_init(const struct nft_ctx *ctx,return err; } -static void nft_dynset_activate (const struct nft_ctx *ctx, -const struct nft_expr *expr) -{ -struct nft_dynset *priv =nft_expr_priv (expr); - -nf_tables_rebind_set (ctx, priv->set, &priv->binding); -} -static void nft_dynset_deactivate (const struct nft_ctx *ctx, -const struct nft_expr *expr) +const struct nft_expr *expr, +enum nft_trans_phase phase) {struct nft_dynset *priv =nft_expr_priv (expr); -nf_tables_unbind_set (ctx, priv->set, &priv->binding); +if (phase ==NFT_TRANS_PREPARE ) +return ; + +nf_tables_unbind_set (ctx, priv->set, &priv->binding, + phase ==NFT_TRANS_COMMIT ); } static void nft_dynset_destroy(const struct nft_ctx *ctx,
@@ -284,7 +281,6 @@ static const struct nft_expr_ops nft_dynset_ops = { .eval = nft_dynset_eval, .init = nft_dynset_init, .destroy = nft_dynset_destroy, - .activate = nft_dynset_activate, .deactivate = nft_dynset_deactivate, .dump = nft_dynset_dump, };
net/netfilter/nft_immediate.c +5 -1
@@ -78,10 +78,14 @@ static void nft_immediate_activate(const struct nft_ctx *ctx, }static void nft_immediate_deactivate (const struct nft_ctx *ctx, -const struct nft_expr *expr) +const struct nft_expr *expr, +enum nft_trans_phase phase) {const struct nft_immediate_expr *priv =nft_expr_priv (expr); +if (phase ==NFT_TRANS_COMMIT ) +return ; +return nft_data_release (&priv->data,nft_dreg_to_type (priv->dreg)); }
net/netfilter/nft_lookup.c +7 -11
@@ -118,20 +118,17 @@ static int nft_lookup_init(const struct nft_ctx *ctx,return 0 ; } -static void nft_lookup_activate (const struct nft_ctx *ctx, -const struct nft_expr *expr) -{ -struct nft_lookup *priv =nft_expr_priv (expr); - -nf_tables_rebind_set (ctx, priv->set, &priv->binding); -} -static void nft_lookup_deactivate (const struct nft_ctx *ctx, -const struct nft_expr *expr) +const struct nft_expr *expr, +enum nft_trans_phase phase) {struct nft_lookup *priv =nft_expr_priv (expr); -nf_tables_unbind_set (ctx, priv->set, &priv->binding); +if (phase ==NFT_TRANS_PREPARE ) +return ; + +nf_tables_unbind_set (ctx, priv->set, &priv->binding, + phase ==NFT_TRANS_COMMIT ); } static void nft_lookup_destroy(const struct nft_ctx *ctx,
@@ -167,7 +164,6 @@ static const struct nft_expr_ops nft_lookup_ops = { .size = NFT_EXPR_SIZE(sizeof(struct nft_lookup)), .eval = nft_lookup_eval, .init = nft_lookup_init, - .activate = nft_lookup_activate, .deactivate = nft_lookup_deactivate, .destroy = nft_lookup_destroy, .dump = nft_lookup_dump,
net/netfilter/nft_objref.c +7 -11
@@ -154,20 +154,17 @@ static int nft_objref_map_dump(struct sk_buff *skb, const struct nft_expr *expr)return -1 ; } -static void nft_objref_map_activate (const struct nft_ctx *ctx, -const struct nft_expr *expr) -{ -struct nft_objref_map *priv =nft_expr_priv (expr); - -nf_tables_rebind_set (ctx, priv->set, &priv->binding); -} -static void nft_objref_map_deactivate (const struct nft_ctx *ctx, -const struct nft_expr *expr) +const struct nft_expr *expr, +enum nft_trans_phase phase) {struct nft_objref_map *priv =nft_expr_priv (expr); -nf_tables_unbind_set (ctx, priv->set, &priv->binding); +if (phase ==NFT_TRANS_PREPARE ) +return ; + +nf_tables_unbind_set (ctx, priv->set, &priv->binding, + phase ==NFT_TRANS_COMMIT ); } static void nft_objref_map_destroy(const struct nft_ctx *ctx,
@@ -184,7 +181,6 @@ static const struct nft_expr_ops nft_objref_map_ops = { .size = NFT_EXPR_SIZE(sizeof(struct nft_objref_map)), .eval = nft_objref_map_eval, .init = nft_objref_map_init, - .activate = nft_objref_map_activate, .deactivate = nft_objref_map_deactivate, .destroy = nft_objref_map_destroy, .dump = nft_objref_map_dump,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 85/116 netfilter: nft_hash: fix nft_hash_deactivate
In reply to Greg Kroah-HartmanFrom: Pablo Neira Ayuso <[email protected]>
[ backport for 4.14 of 7f4dae2d7f03d2aaf3b7d8343d4509c8d9d7ca9b ]
Jindřich Makovička says:
The logical OR looks fishy to me. Shouldn't be && there instead?
--- net/netfilter/nft_set_hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nft_set_hash.c +1 -1
@@ -520,7 +520,7 @@ static void *nft_hash_deactivate(const struct net *net, hash =nft_jhash (set, priv, &this->ext);hlist_for_each_entry (he, &priv->table[hash], node) {if (!memcmp (nft_set_ext_key (&this->ext), &elem->key.val, - set->klen) || + set->klen) &&nft_set_elem_active (&he->ext, genmask)) {nft_set_elem_change_active (net, set, &he->ext);return he;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 86/116 netfilter: nf_tables: use-after-free in failing rule with bound set
In reply to Greg Kroah-HartmanFrom: Pablo Neira Ayuso <[email protected]>
[ backport for 4.14 of 6a0a8d10a3661a036b55af695542a714c429ab7c ]
If a rule that has already a bound anonymous set fails to be added, the preparation phase releases the rule and the bound set. However, the transaction object from the abort path still has a reference to the set object that is stale, leading to a use-after-free when checking for the set->bound field. Add a new field to the transaction that specifies if the set is bound, so the abort path can skip releasing it since the rule command owns it and it takes care of releasing it. After this update, the set->bound field is removed.
[ 24.649883] Unable to handle kernel paging request at virtual address 0000000000040434 [ 24.657858] Mem abort info: [ 24.660686] ESR = 0x96000004 [ 24.663769] Exception class = DABT (current EL), IL = 32 bits [ 24.669725] SET = 0, FnV = 0 [ 24.672804] EA = 0, S1PTW = 0 [ 24.675975] Data abort info: [ 24.678880] ISV = 0, ISS = 0x00000004 [ 24.682743] CM = 0, WnR = 0 [ 24.685723] user pgtable: 4k pages, 48-bit VAs, pgdp=0000000428952000 [ 24.692207] [0000000000040434] pgd=0000000000000000 [ 24.697119] Internal error: Oops: 96000004 [#1] SMP [...] [ 24.889414] Call trace: [ 24.891870] __nf_tables_abort+0x3f0/0x7a0 [ 24.895984] nf_tables_abort+0x20/0x40 [ 24.899750] nfnetlink_rcv_batch+0x17c/0x588 [ 24.904037] nfnetlink_rcv+0x13c/0x190 [ 24.907803] netlink_unicast+0x18c/0x208 [ 24.911742] netlink_sendmsg+0x1b0/0x350 [ 24.915682] sock_sendmsg+0x4c/0x68 [ 24.919185] ___sys_sendmsg+0x288/0x2c8 [ 24.923037] __sys_sendmsg+0x7c/0xd0 [ 24.926628] __arm64_sys_sendmsg+0x2c/0x38 [ 24.930744] el0_svc_common.constprop.0+0x94/0x158 [ 24.935556] el0_svc_handler+0x34/0x90 [ 24.939322] el0_svc+0x8/0xc [ 24.942216] Code: 37280300 f9404023 91014262 aa1703e0 (f9401863) [ 24.948336] ---[ end trace cebbb9dcbed3b56f ]---
--- include/net/netfilter/nf_tables.h | 3 +++ net/netfilter/nf_tables_api.c | 22 +++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-)
include/net/netfilter/nf_tables.h +3 -0
@@ -1335,12 +1335,15 @@ struct nft_trans_table {struct nft_trans_elem {struct nft_set *set;struct nft_set_elem elem; +bool bound; };#define nft_trans_elem_set (trans) \ (((struct nft_trans_elem *)trans->data)->set)#define nft_trans_elem (trans) \ (((struct nft_trans_elem *)trans->data)->elem) +#define nft_trans_elem_set_bound (trans) \ + (((struct nft_trans_elem *)trans->data)->bound)struct nft_trans_obj {struct nft_object *obj;
net/netfilter/nf_tables_api.c +17 -5
@@ -149,9 +149,14 @@ static void nft_set_trans_bind(const struct nft_ctx *ctx, struct nft_set *set)return ;list_for_each_entry_reverse (trans, &net->nft.commit_list, list) { -if (trans->msg_type ==NFT_MSG_NEWSET && -nft_trans_set (trans) == set) { -nft_trans_set_bound (trans) = true; +switch (trans->msg_type) { +case NFT_MSG_NEWSET : +if (nft_trans_set (trans) == set) +nft_trans_set_bound (trans) = true; +break ; +case NFT_MSG_NEWSETELEM : +if (nft_trans_elem_set (trans) == set) +nft_trans_elem_set_bound (trans) = true;break ; } }
@@ -5340,8 +5345,11 @@ static int nf_tables_abort(struct net *net, struct sk_buff *skb)break ;case NFT_MSG_NEWSET : trans->ctx.table->use--; -if (!nft_trans_set_bound (trans)) -list_del_rcu (&nft_trans_set (trans)->list); +if (nft_trans_set_bound (trans)) { +nft_trans_destroy (trans); +break ; + } +list_del_rcu (&nft_trans_set (trans)->list);break ;case NFT_MSG_DELSET : trans->ctx.table->use++;
@@ -5349,6 +5357,10 @@ static int nf_tables_abort(struct net *net, struct sk_buff *skb)nft_trans_destroy (trans);break ;case NFT_MSG_NEWSETELEM : +if (nft_trans_elem_set_bound (trans)) { +nft_trans_destroy (trans); +break ; + } te = (struct nft_trans_elem *)trans->data; te->set->ops->remove (net, te->set, &te->elem);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 87/116 netfilter: nf_tables: bogus EBUSY when deleting set after flush
In reply to Greg Kroah-HartmanFrom: Pablo Neira Ayuso <[email protected]>
[ backport for 4.14 of 273fe3f1006ea5ebc63d6729e43e8e45e32b256a ]
Set deletion after flush coming in the same batch results in EBUSY. Add set use counter to track the number of references to this set from rules. We cannot rely on the list of bindings for this since such list is still populated from the preparation phase.
--- include/net/netfilter/nf_tables.h | 6 ++++++ net/netfilter/nf_tables_api.c | 28 +++++++++++++++++++++++++++- net/netfilter/nft_dynset.c | 13 +++++++++---- net/netfilter/nft_lookup.c | 13 +++++++++---- net/netfilter/nft_objref.c | 13 +++++++++---- 5 files changed, 60 insertions(+), 13 deletions(-)
include/net/netfilter/nf_tables.h +6 -0
@@ -383,6 +383,7 @@ void nft_unregister_set(struct nft_set_type *type);* @dtype: data type (verdict or numeric type defined by userspace) * @objtype: object type (see NFT_OBJECT_* definitions) * @size: maximum set size +* @use: number of rules references to this set * @nelems: number of elements * @ndeact: number of deactivated elements queued for removal * @timeout: default timeout value in jiffies
@@ -405,6 +406,7 @@ struct nft_set {u32 dtype;u32 objtype;u32 size; +u32 use;atomic_t nelems;u32 ndeact;u64 timeout;
@@ -459,6 +461,10 @@ struct nft_set_binding {u32 flags; }; +enum nft_trans_phase ; +void nf_tables_deactivate_set (const struct nft_ctx *ctx,struct nft_set *set, +struct nft_set_binding *binding, +enum nft_trans_phase phase);int nf_tables_bind_set (const struct nft_ctx *ctx,struct nft_set *set,struct nft_set_binding *binding); void nf_tables_unbind_set(const struct nft_ctx *ctx, struct nft_set *set,
net/netfilter/nf_tables_api.c +27 -1
@@ -3309,6 +3309,9 @@ static int nf_tables_newset(struct net *net, struct sock *nlsk,static void nft_set_destroy (struct nft_set *set) { +if (WARN_ON (set->use >0 )) +return ; + set->ops->destroy (set);module_put (set->ops->type->owner);kfree (set->name);
@@ -3339,7 +3342,7 @@ static int nf_tables_delset(struct net *net, struct sock *nlsk,if (IS_ERR (set))return PTR_ERR (set); -if (!list_empty (&set->bindings) || +if (set->use || (nlh->nlmsg_flags &NLM_F_NONREC &&atomic_read (&set->nelems) >0 ))return -EBUSY ;
@@ -3367,6 +3370,9 @@ int nf_tables_bind_set(const struct nft_ctx *ctx, struct nft_set *set,struct nft_set_binding *i;struct nft_set_iter iter; +if (set->use ==UINT_MAX ) +return -EOVERFLOW ; +if (!list_empty (&set->bindings) && set->flags &NFT_SET_ANONYMOUS )return -EBUSY ;
@@ -3394,6 +3400,7 @@ int nf_tables_bind_set(const struct nft_ctx *ctx, struct nft_set *set, binding->chain = ctx->chain;list_add_tail_rcu (&binding->list, &set->bindings);nft_set_trans_bind (ctx, set); + set->use++;return 0 ; }
@@ -3413,6 +3420,25 @@ void nf_tables_unbind_set(const struct nft_ctx *ctx, struct nft_set *set, }EXPORT_SYMBOL_GPL (nf_tables_unbind_set); +void nf_tables_deactivate_set (const struct nft_ctx *ctx,struct nft_set *set, +struct nft_set_binding *binding, +enum nft_trans_phase phase) +{ +switch (phase) { +case NFT_TRANS_PREPARE : + set->use--; +return ; +case NFT_TRANS_ABORT : +case NFT_TRANS_RELEASE : + set->use--; +/* fall through */ +default : +nf_tables_unbind_set (ctx, set, binding, + phase ==NFT_TRANS_COMMIT ); + } +} +EXPORT_SYMBOL_GPL (nf_tables_deactivate_set); +void nf_tables_destroy_set (const struct nft_ctx *ctx,struct nft_set *set) {if (list_empty (&set->bindings) && set->flags &NFT_SET_ANONYMOUS )
net/netfilter/nft_dynset.c +9 -4
@@ -229,11 +229,15 @@ static void nft_dynset_deactivate(const struct nft_ctx *ctx, {struct nft_dynset *priv =nft_expr_priv (expr); -if (phase ==NFT_TRANS_PREPARE ) -return ; +nf_tables_deactivate_set (ctx, priv->set, &priv->binding, phase); +} + +static void nft_dynset_activate (const struct nft_ctx *ctx, +const struct nft_expr *expr) +{ +struct nft_dynset *priv =nft_expr_priv (expr); -nf_tables_unbind_set (ctx, priv->set, &priv->binding, - phase ==NFT_TRANS_COMMIT ); + priv->set->use++; } static void nft_dynset_destroy(const struct nft_ctx *ctx,
@@ -281,6 +285,7 @@ static const struct nft_expr_ops nft_dynset_ops = { .eval = nft_dynset_eval, .init = nft_dynset_init, .destroy = nft_dynset_destroy, + .activate = nft_dynset_activate, .deactivate = nft_dynset_deactivate, .dump = nft_dynset_dump, };
net/netfilter/nft_lookup.c +9 -4
@@ -124,11 +124,15 @@ static void nft_lookup_deactivate(const struct nft_ctx *ctx, {struct nft_lookup *priv =nft_expr_priv (expr); -if (phase ==NFT_TRANS_PREPARE ) -return ; +nf_tables_deactivate_set (ctx, priv->set, &priv->binding, phase); +} + +static void nft_lookup_activate (const struct nft_ctx *ctx, +const struct nft_expr *expr) +{ +struct nft_lookup *priv =nft_expr_priv (expr); -nf_tables_unbind_set (ctx, priv->set, &priv->binding, - phase ==NFT_TRANS_COMMIT ); + priv->set->use++; } static void nft_lookup_destroy(const struct nft_ctx *ctx,
@@ -164,6 +168,7 @@ static const struct nft_expr_ops nft_lookup_ops = { .size = NFT_EXPR_SIZE(sizeof(struct nft_lookup)), .eval = nft_lookup_eval, .init = nft_lookup_init, + .activate = nft_lookup_activate, .deactivate = nft_lookup_deactivate, .destroy = nft_lookup_destroy, .dump = nft_lookup_dump,
net/netfilter/nft_objref.c +9 -4
@@ -160,11 +160,15 @@ static void nft_objref_map_deactivate(const struct nft_ctx *ctx, {struct nft_objref_map *priv =nft_expr_priv (expr); -if (phase ==NFT_TRANS_PREPARE ) -return ; +nf_tables_deactivate_set (ctx, priv->set, &priv->binding, phase); +} + +static void nft_objref_map_activate (const struct nft_ctx *ctx, +const struct nft_expr *expr) +{ +struct nft_objref_map *priv =nft_expr_priv (expr); -nf_tables_unbind_set (ctx, priv->set, &priv->binding, - phase ==NFT_TRANS_COMMIT ); + priv->set->use++; } static void nft_objref_map_destroy(const struct nft_ctx *ctx,
@@ -181,6 +185,7 @@ static const struct nft_expr_ops nft_objref_map_ops = { .size = NFT_EXPR_SIZE(sizeof(struct nft_objref_map)), .eval = nft_objref_map_eval, .init = nft_objref_map_init, + .activate = nft_objref_map_activate, .deactivate = nft_objref_map_deactivate, .destroy = nft_objref_map_destroy, .dump = nft_objref_map_dump,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 88/116 netfilter: nf_tables: deactivate anonymous set from preparation phase
In reply to Greg Kroah-HartmanFrom: Pablo Neira Ayuso <[email protected]>
[ backport for 4.14 of c1592a89942e9678f7d9c8030efa777c0d57edab ]
Toggle deleted anonymous sets as inactive in the next generation, so users cannot perform any update on it. Clear the generation bitmask in case the transaction is aborted.
The following KASAN splat shows a set element deletion for a bound anonymous set that has been already removed in the same transaction.
[ 64.921510] ================================================================== [ 64.923123] BUG: KASAN: wild-memory-access in nf_tables_commit+0xa24/0x1490 [nf_tables] [ 64.924745] Write of size 8 at addr dead000000000122 by task test/890 [ 64.927903] CPU: 3 PID: 890 Comm: test Not tainted 6.3.0+ #253 [ 64.931120] Call Trace: [ 64.932699] <TASK> [ 64.934292] dump_stack_lvl+0x33/0x50 [ 64.935908] ? nf_tables_commit+0xa24/0x1490 [nf_tables] [ 64.937551] kasan_report+0xda/0x120 [ 64.939186] ? nf_tables_commit+0xa24/0x1490 [nf_tables] [ 64.940814] nf_tables_commit+0xa24/0x1490 [nf_tables] [ 64.942452] ? __kasan_slab_alloc+0x2d/0x60 [ 64.944070] ? nf_tables_setelem_notify+0x190/0x190 [nf_tables] [ 64.945710] ? kasan_set_track+0x21/0x30 [ 64.947323] nfnetlink_rcv_batch+0x709/0xd90 [nfnetlink] [ 64.948898] ? nfnetlink_rcv_msg+0x480/0x480 [nfnetlink]
--- include/net/netfilter/nf_tables.h | 1 + net/netfilter/nf_tables_api.c | 12 ++++++++++++ net/netfilter/nft_dynset.c | 2 +- net/netfilter/nft_lookup.c | 2 +- net/netfilter/nft_objref.c | 2 +- 5 files changed, 16 insertions(+), 3 deletions(-)
include/net/netfilter/nf_tables.h +1 -0
@@ -462,6 +462,7 @@ struct nft_set_binding { };enum nft_trans_phase ; +void nf_tables_activate_set (const struct nft_ctx *ctx,struct nft_set *set);void nf_tables_deactivate_set (const struct nft_ctx *ctx,struct nft_set *set,struct nft_set_binding *binding,enum nft_trans_phase phase);
net/netfilter/nf_tables_api.c +12 -0
@@ -3420,12 +3420,24 @@ void nf_tables_unbind_set(const struct nft_ctx *ctx, struct nft_set *set, }EXPORT_SYMBOL_GPL (nf_tables_unbind_set); +void nf_tables_activate_set (const struct nft_ctx *ctx,struct nft_set *set) +{ +if (set->flags &NFT_SET_ANONYMOUS ) +nft_clear (ctx->net, set); + + set->use++; +} +EXPORT_SYMBOL_GPL (nf_tables_activate_set); +void nf_tables_deactivate_set (const struct nft_ctx *ctx,struct nft_set *set,struct nft_set_binding *binding,enum nft_trans_phase phase) {switch (phase) {case NFT_TRANS_PREPARE : +if (set->flags &NFT_SET_ANONYMOUS ) +nft_deactivate_next (ctx->net, set); + set->use--;return ;case NFT_TRANS_ABORT :
net/netfilter/nft_dynset.c +1 -1
@@ -237,7 +237,7 @@ static void nft_dynset_activate(const struct nft_ctx *ctx, {struct nft_dynset *priv =nft_expr_priv (expr); - priv->set->use++; +nf_tables_activate_set (ctx, priv->set); } static void nft_dynset_destroy(const struct nft_ctx *ctx,
net/netfilter/nft_lookup.c +1 -1
@@ -132,7 +132,7 @@ static void nft_lookup_activate(const struct nft_ctx *ctx, {struct nft_lookup *priv =nft_expr_priv (expr); - priv->set->use++; +nf_tables_activate_set (ctx, priv->set); } static void nft_lookup_destroy(const struct nft_ctx *ctx,
net/netfilter/nft_objref.c +1 -1
@@ -168,7 +168,7 @@ static void nft_objref_map_activate(const struct nft_ctx *ctx, {struct nft_objref_map *priv =nft_expr_priv (expr); - priv->set->use++; +nf_tables_activate_set (ctx, priv->set); } static void nft_objref_map_destroy(const struct nft_ctx *ctx,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 89/116 sit: update dev->needed_headroom in ipip6_tunnel_bind_dev()
In reply to Greg Kroah-HartmanFrom: Cong Wang <[email protected]>
[ Upstream commit c88f8d5cd95fd039cff95d682b8e71100c001df0 ]
When a tunnel device is bound with the underlying device, its dev->needed_headroom needs to be updated properly. IPv4 tunnels already do the same in ip_tunnel_bind_dev(). Otherwise we may not have enough header room for skb, especially after commit b17f709a2401 ("gue: TX support for using remote checksum offload option").
--- net/ipv6/sit.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
net/ipv6/sit.c +5 -3
@@ -1039,12 +1039,13 @@ static netdev_tx_t sit_tunnel_xmit(struct sk_buff *skb,static void ipip6_tunnel_bind_dev (struct net_device *dev) { +struct ip_tunnel *tunnel =netdev_priv (dev); +int t_hlen = tunnel->hlen +sizeof (struct iphdr );struct net_device *tdev =NULL ; -struct ip_tunnel *tunnel; +int hlen =LL_MAX_HEADER ;const struct iphdr *iph;struct flowi4 fl4; - tunnel =netdev_priv (dev); iph = &tunnel->parms.iph;if (iph->daddr) {
@@ -1067,14 +1068,15 @@ static void ipip6_tunnel_bind_dev(struct net_device *dev) tdev =__dev_get_by_index (tunnel->net, tunnel->parms.link);if (tdev && !netif_is_l3_master (tdev)) { -int t_hlen = tunnel->hlen +sizeof (struct iphdr );int mtu; mtu = tdev->mtu - t_hlen;if (mtu <IPV6_MIN_MTU ) mtu =IPV6_MIN_MTU ;WRITE_ONCE (dev->mtu, mtu); + hlen = tdev->hard_header_len + tdev->needed_headroom; } + dev->needed_headroom = t_hlen + hlen; } static void ipip6_tunnel_update(struct ip_tunnel *t, struct ip_tunnel_parm *p,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 90/116 writeback: fix call of incorrect macro
In reply to Greg Kroah-HartmanFrom: Maxim Korotkov <[email protected]>
[ Upstream commit 3e46c89c74f2c38e5337d2cf44b0b551adff1cb4 ]
the variable 'history' is of type u16, it may be an error that the hweight32 macro was used for it
I guess macro hweight16 should be used
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- fs/fs-writeback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fs-writeback.c +1 -1
@@ -702,7 +702,7 @@ void wbc_detach_inode(struct writeback_control *wbc)* is okay. The main goal is avoiding keeping an inode on * the wrong wb for an extended period of time. */ -if (hweight32 (history) >WB_FRN_HIST_THR_SLOTS ) +if (hweight16 (history) >WB_FRN_HIST_THR_SLOTS )inode_switch_wbs (inode, max_id); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 91/116 net/sched: act_mirred: Add carrier check
In reply to Greg Kroah-HartmanFrom: Victor Nogueira <[email protected]>
[ Upstream commit 526f28bd0fbdc699cda31426928802650c1528e5 ]
There are cases where the device is adminstratively UP, but operationally down. For example, we have a physical device (Nvidia ConnectX-6 Dx, 25Gbps) who's cable was pulled out, here is its ip link output:
5: ens2f1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
link/ether b8:ce:f6:4b:68:35 brd ff:ff:ff:ff:ff:ff
altname enp179s0f1np1As you can see, it's administratively UP but operationally down. In this case, sending a packet to this port caused a nasty kernel hang (so nasty that we were unable to capture it). Aborting a transmit based on operational status (in addition to administrative status) fixes the issue.
v1->v2: Add fixes tagv2->v3: Remove blank line between tags + add change log, suggested by Leon
--- net/sched/act_mirred.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/act_mirred.c +1 -1
@@ -181,7 +181,7 @@ static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a, goto out; } -if (unlikely (!(dev->flags &IFF_UP ))) { +if (unlikely (!(dev->flags &IFF_UP )) || !netif_carrier_ok (dev)) {net_notice_ratelimited ("tc mirred to Houston: device %s is down\n" , dev->name); goto out;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 92/116 af_packet: Dont send zero-byte data in packet_sendmsg_spkt().
In reply to Greg Kroah-HartmanFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 6a341729fb31b4c5df9f74f24b4b1c98410c9b87 ]
syzkaller reported a warning below [0].
We can reproduce it by sending 0-byte data from the (AF_PACKET, SOCK_PACKET) socket via some devices whose dev->hard_header_len is 0.
struct sockaddr_pkt addr = {
.spkt_family = AF_PACKET,
.spkt_device = "tun0",
};
int fd;
fd = socket(AF_PACKET, SOCK_PACKET, 0);
sendto(fd, NULL, 0, 0, (struct sockaddr *)&addr, sizeof(addr));We have a similar fix for the (AF_PACKET, SOCK_RAW) socket as commit dc633700f00f ("net/af_packet: check len when min_header_len equals to 0").
Let's add the same test for the SOCK_PACKET socket.
[0]:skb_assert_len
WARNING: CPU: 1 PID: 19945 at include/linux/skbuff.h:2552 skb_assert_len include/linux/skbuff.h:2552 [inline] WARNING: CPU: 1 PID: 19945 at include/linux/skbuff.h:2552 __dev_queue_xmit+0x1f26/0x31d0 net/core/dev.c:4159 Modules linked in: CPU: 1 PID: 19945 Comm: syz-executor.0 Not tainted 6.3.0-rc7-02330-gca6270c12e20 #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 RIP: 0010:skb_assert_len include/linux/skbuff.h:2552 [inline] RIP: 0010:__dev_queue_xmit+0x1f26/0x31d0 net/core/dev.c:4159 Code: 89 de e8 1d a2 85 fd 84 db 75 21 e8 64 a9 85 fd 48 c7 c6 80 2a 1f 86 48 c7 c7 c0 06 1f 86 c6 05 23 cf 27 04 01 e8 fa ee 56 fd <0f> 0b e8 43 a9 85 fd 0f b6 1d 0f cf 27 04 31 ff 89 de e8 e3 a1 85 RSP: 0018:ffff8880217af6e0 EFLAGS: 00010282 RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffc90001133000 RDX: 0000000000040000 RSI: ffffffff81186922 RDI: 0000000000000001 RBP: ffff8880217af8b0 R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000001 R11: 0000000000000001 R12: ffff888030045640 R13: ffff8880300456b0 R14: ffff888030045650 R15: ffff888030045718 FS: 00007fc5864da640(0000) GS:ffff88806cd00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000020005740 CR3: 000000003f856003 CR4: 0000000000770ee0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: <TASK> dev_queue_xmit include/linux/netdevice.h:3085 [inline] packet_sendmsg_spkt+0xc4b/0x1230 net/packet/af_packet.c:2066 sock_sendmsg_nosec net/socket.c:724 [inline] sock_sendmsg+0x1b4/0x200 net/socket.c:747 ____sys_sendmsg+0x331/0x970 net/socket.c:2503 ___sys_sendmsg+0x11d/0x1c0 net/socket.c:2557 __sys_sendmmsg+0x18c/0x430 net/socket.c:2643 __do_sys_sendmmsg net/socket.c:2672 [inline] __se_sys_sendmmsg net/socket.c:2669 [inline] __x64_sys_sendmmsg+0x9c/0x100 net/socket.c:2669 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3c/0x90 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x72/0xdc RIP: 0033:0x7fc58791de5d Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 73 9f 1b 00 f7 d8 64 89 01 48 RSP: 002b:00007fc5864d9cc8 EFLAGS: 00000246 ORIG_RAX: 0000000000000133 RAX: ffffffffffffffda RBX: 00000000004bbf80 RCX: 00007fc58791de5d RDX: 0000000000000001 RSI: 0000000020005740 RDI: 0000000000000004 RBP: 00000000004bbf80 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 000000000000000b R14: 00007fc58797e530 R15: 0000000000000000 </TASK> ---[ end trace 0000000000000000 ]---
skb len=0 headroom=16 headlen=0 tailroom=304 mac=(16,0) net=(16,-1) trans=-1 shinfo(txflags=0 nr_frags=0 gso(size=0 type=0 segs=0)) csum(0x0 ip_summed=0 complete_sw=0 valid=0 level=0) hash(0x0 sw=0 l4=0) proto=0x0000 pkttype=0 iif=0 dev name=sit0 feat=0x00000006401d7869
sk family=17 type=10 proto=0
--- net/packet/af_packet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/packet/af_packet.c +1 -1
@@ -1995,7 +1995,7 @@ static int packet_sendmsg_spkt(struct socket *sock, struct msghdr *msg, goto retry; } -if (!dev_validate_header (dev, skb->data, len)) { +if (!dev_validate_header (dev, skb->data, len) || !skb->len) { err = -EINVAL ; goto out_unlock; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 93/116 ALSA: caiaq: input: Add error handling for unsupported input methods in `snd_usb_caiaq_input_init`
In reply to Greg Kroah-HartmanFrom: Ruliang Lin <[email protected]>
[ Upstream commit 0d727e1856ef22dd9337199430258cb64cbbc658 ]
Smatch complains that:snd_usb_caiaq_input_init() warn: missing error code 'ret'
This patch adds a new case to handle the situation where the device does not support any input methods in the snd_usb_caiaq_input_init function. It returns an -EINVAL error code to indicate that no input methods are supported on the device.
--- sound/usb/caiaq/input.c | 1 + 1 file changed, 1 insertion(+)
sound/usb/caiaq/input.c +1 -0
@@ -808,6 +808,7 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *cdev)default :/* no input methods supported on this device */ + ret = -EINVAL ; goto exit_free_idev; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 94/116 perf vendor events power9: Remove UTF-8 characters from JSON files
In reply to Greg Kroah-HartmanFrom: Kajol Jain <[email protected]>
[ Upstream commit 5d9df8731c0941f3add30f96745a62586a0c9d52 ]
Commit 3c22ba5243040c13 ("perf vendor events powerpc: Update POWER9 events") added and updated power9 PMU JSON events. However some of the JSON events which are part of other.json and pipeline.json files, contains UTF-8 characters in their brief description. Having UTF-8 character could breaks the perf build on some distros.
Fix this issue by removing the UTF-8 characters from other.json and pipeline.json files.
Result without the fix:
[command]# file -i pmu-events/arch/powerpc/power9/*
pmu-events/arch/powerpc/power9/cache.json: application/json; charset=us-ascii
pmu-events/arch/powerpc/power9/floating-point.json: application/json; charset=us-ascii
pmu-events/arch/powerpc/power9/frontend.json: application/json; charset=us-ascii pmu-events/arch/powerpc/power9/marked.json: application/json; charset=us-ascii pmu-events/arch/powerpc/power9/memory.json: application/json; charset=us-ascii pmu-events/arch/powerpc/power9/metrics.json: application/json; charset=us-ascii pmu-events/arch/powerpc/power9/nest_metrics.json: application/json; charset=us-ascii pmu-events/arch/powerpc/power9/other.json: application/json; charset=utf-8 pmu-events/arch/powerpc/power9/pipeline.json: application/json; charset=utf-8 pmu-events/arch/powerpc/power9/pmc.json: application/json; charset=us-ascii pmu-events/arch/powerpc/power9/translation.json: application/json; charset=us-ascii
[command]#
Result with the fix:
[command]# file -i pmu-events/arch/powerpc/power9/*
pmu-events/arch/powerpc/power9/cache.json: application/json; charset=us-ascii
pmu-events/arch/powerpc/power9/floating-point.json: application/json; charset=us-ascii
pmu-events/arch/powerpc/power9/frontend.json: application/json; charset=us-ascii pmu-events/arch/powerpc/power9/marked.json: application/json; charset=us-ascii pmu-events/arch/powerpc/power9/memory.json: application/json; charset=us-ascii pmu-events/arch/powerpc/power9/metrics.json: application/json; charset=us-ascii pmu-events/arch/powerpc/power9/nest_metrics.json: application/json; charset=us-ascii pmu-events/arch/powerpc/power9/other.json: application/json; charset=us-ascii pmu-events/arch/powerpc/power9/pipeline.json: application/json; charset=us-ascii pmu-events/arch/powerpc/power9/pmc.json: application/json; charset=us-ascii pmu-events/arch/powerpc/power9/translation.json: application/json; charset=us-ascii
[command]#
--- tools/perf/pmu-events/arch/powerpc/power9/other.json | 4 ++-- tools/perf/pmu-events/arch/powerpc/power9/pipeline.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
tools/perf/pmu-events/arch/powerpc/power9/other.json +2 -2
@@ -1452,7 +1452,7 @@ {, "EventCode": "0x45054", "EventName": "PM_FMA_CMPL", - "BriefDescription": "two flops operation completed (fmadd, fnmadd, fmsub, fnmsub) Scalar instructions only. " + "BriefDescription": "two flops operation completed (fmadd, fnmadd, fmsub, fnmsub) Scalar instructions only." }, {, "EventCode": "0x5090",
@@ -2067,7 +2067,7 @@ {, "EventCode": "0xC0BC", "EventName": "PM_LSU_FLUSH_OTHER", - "BriefDescription": "Other LSU flushes including: Sync (sync ack from L2 caused search of LRQ for oldest snooped load, This will either signal a Precise Flush of the oldest snooped loa or a Flush Next PPC); Data Valid Flush Next (several cases of this, one example is store and reload are lined up such that a store-hit-reload scenario exists and the CDF has already launched and has gotten bad/stale data); Bad Data Valid Flush Next (might be a few cases of this, one example is a larxa (D$ hit) return data and dval but can't allocate to LMQ (LMQ full or other reason). Already gave dval but can't watch it for snoop_hit_larx. Need to take the “bad dval” back and flush all younger ops)" + "BriefDescription": "Other LSU flushes including: Sync (sync ack from L2 caused search of LRQ for oldest snooped load, This will either signal a Precise Flush of the oldest snooped loa or a Flush Next PPC); Data Valid Flush Next (several cases of this, one example is store and reload are lined up such that a store-hit-reload scenario exists and the CDF has already launched and has gotten bad/stale data); Bad Data Valid Flush Next (might be a few cases of this, one example is a larxa (D$ hit) return data and dval but can't allocate to LMQ (LMQ full or other reason). Already gave dval but can't watch it for snoop_hit_larx. Need to take the 'bad dval' back and flush all younger ops)" }, {, "EventCode": "0x5094",
tools/perf/pmu-events/arch/powerpc/power9/pipeline.json +1 -1
@@ -462,7 +462,7 @@ {, "EventCode": "0x4D052", "EventName": "PM_2FLOP_CMPL", - "BriefDescription": "DP vector version of fmul, fsub, fcmp, fsel, fabs, fnabs, fres ,fsqrte, fneg " + "BriefDescription": "DP vector version of fmul, fsub, fcmp, fsel, fabs, fnabs, fres ,fsqrte, fneg" }, {, "EventCode": "0x1F142",
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 95/116 perf map: Delete two variable initialisations before null pointer checks in sort__sym_from_cmp()
In reply to Greg Kroah-HartmanFrom: Markus Elfring <[email protected]>
[ Upstream commit c160118a90d4acf335993d8d59b02ae2147a524e ]
Addresses of two data structure members were determined before corresponding null pointer checks in the implementation of the function “sort__sym_from_cmp”.
Thus avoid the risk for undefined behaviour by removing extra initialisations for the local variables “from_l” and “from_r” (also because they were already reassigned with the same value behind this pointer check).
This issue was detected by using the Coccinelle software.
--- tools/perf/util/sort.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/sort.c +1 -2
@@ -753,8 +753,7 @@ static int hist_entry__dso_to_filter(struct hist_entry *he, int type,static int64_t sort__sym_from_cmp (struct hist_entry *left,struct hist_entry *right) { -struct addr_map_symbol *from_l = &left->branch_info->from; -struct addr_map_symbol *from_r = &right->branch_info->from; +struct addr_map_symbol *from_l, *from_r;if (!left->branch_info || !right->branch_info)return cmp_null (left->branch_info, right->branch_info);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 96/116 perf symbols: Fix return incorrect build_id size in elf_read_build_id()
In reply to Greg Kroah-HartmanFrom: Yang Jihong <[email protected]>
[ Upstream commit 1511e4696acb715a4fe48be89e1e691daec91c0e ]
In elf_read_build_id(), if gnu build_id is found, should return the size of the actually copied data. If descsz is greater thanBuild_ID_SIZE, write_buildid data access may occur.
--- tools/perf/util/symbol-elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/symbol-elf.c +1 -1
@@ -504,7 +504,7 @@ static int elf_read_build_id(Elf *elf, vsize_t sz =min (size, descsz);memcpy (bf, ptr, sz);memset (bf + sz,0 , size - sz); - err = descsz; + err = sz;break ; } }
Greg Kroah-Hartman
maintainerPATCH 97/116 btrfs: fix btrfs_prev_leaf() to not return the same key twice
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit 6f932d4ef007d6a4ae03badcb749fbb8f49196f6 upstream.
A call to btrfs_prev_leaf() may end up returning a path that points to the same item (key) again. This happens if while btrfs_prev_leaf(), after we release the path, a concurrent insertion happens, which moves items off from a sibling into the front of the previous leaf, and an item with the computed previous key does not exists.
For example, suppose we have the two following leaves:
Leaf A
-------------------------------------------------------------
| ... key (300 96 10) key (300 96 15) key (300 96 16) |
-------------------------------------------------------------
slot 20 slot 21 slot 22
Leaf B
-------------------------------------------------------------
| key (300 96 20) key (300 96 21) key (300 96 22) ... |
-------------------------------------------------------------
slot 0 slot 1 slot 2
If we call btrfs_prev_leaf(), from btrfs_previous_item() for example, with a path pointing to leaf B and slot 0 and the following happens:
1) At btrfs_prev_leaf() we compute the previous key to search as:
(300 96 19), which is a key that does not exists in the tree;
2) Then we call btrfs_release_path() at btrfs_prev_leaf();
3) Some other task inserts a key at leaf A, that sorts before the key at slot 20, for example it has an objectid of 299. In order to make room for the new key, the key at slot 22 is moved to the front of leaf B. This happens at push_leaf_right(), called from split_leaf().
After this leaf B now looks like:
--------------------------------------------------------------------------------
| key (300 96 16) key (300 96 20) key (300 96 21) key (300 96 22) ... |
--------------------------------------------------------------------------------
slot 0 slot 1 slot 2 slot 3
4) At btrfs_prev_leaf() we call btrfs_search_slot() for the computed previous key: (300 96 19). Since the key does not exists, btrfs_search_slot() returns 1 and with a path pointing to leaf B and slot 1, the item with key (300 96 20);
5) This makes btrfs_prev_leaf() return a path that points to slot 1 of leaf B, the same key as before it was called, since the key at slot 0 of leaf B (300 96 16) is less than the computed previous key, which is (300 96 19);
6) As a consequence btrfs_previous_item() returns a path that points again to the item with key (300 96 20).
For some users of btrfs_prev_leaf() or btrfs_previous_item() this may not be functional a problem, despite not making sense to return a new path pointing again to the same item/key. However for a caller such as tree-log.c:log_dir_items(), this has a bad consequence, as it can result in not logging some dir index deletions in case the directory is being logged without holding the inode's VFS lock (logging triggered while logging a child inode for example) - for the example scenario above, in case the dir index keys 17, 18 and 19 were deleted in the current transaction.
--- fs/btrfs/ctree.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-)
fs/btrfs/ctree.c +31 -1
@@ -5106,10 +5106,12 @@ int btrfs_del_items(struct btrfs_trans_hint btrfs_prev_leaf (struct btrfs_root *root,struct btrfs_path *path) {struct btrfs_key key; +struct btrfs_key orig_key;struct btrfs_disk_key found_key;int ret;btrfs_item_key_to_cpu (path->nodes[0 ], &key,0 ); + orig_key = key;if (key.offset >0 ) { key.offset--;
@@ -5126,8 +5128,36 @@ int btrfs_prev_leaf(struct btrfs_root *rbtrfs_release_path (path); ret =btrfs_search_slot (NULL , root, &key, path,0 ,0 ); -if (ret <0 ) +if (ret <=0 )return ret; + +/* +* Previous key not found. Even if we were at slot 0 of the leaf we had +* before releasing the path and calling btrfs_search_slot(), we now may +* be in a slot pointing to the same original key - this can happen if +* after we released the path, one of more items were moved from a +* sibling leaf into the front of the leaf we had due to an insertion +* (see push_leaf_right()). +* If we hit this case and our slot is > 0 and just decrement the slot +* so that the caller does not process the same key again, which may or +* may not break the caller, depending on its logic. +*/ +if (path->slots[0 ] <btrfs_header_nritems (path->nodes[0 ])) { +btrfs_item_key (path->nodes[0 ], &found_key, path->slots[0 ]); + ret =comp_keys (&found_key, &orig_key); +if (ret ==0 ) { +if (path->slots[0 ] >0 ) { + path->slots[0 ]--; +return 0 ; + } +/* +* At slot 0, same key as before, it means orig_key is +* the lowest, leftmost, key in the tree. We're done. +*/ +return 1 ; + } + } +btrfs_item_key (path->nodes[0 ], &found_key,0 ); ret =comp_keys (&found_key, &key);/*
Greg Kroah-Hartman
maintainerPATCH 98/116 btrfs: print-tree: parent bytenr must be aligned to sector size
In reply to Greg Kroah-HartmanFrom: Anastasia Belova <[email protected]>
commit c87f318e6f47696b4040b58f460d5c17ea0280e6 upstream.
Check nodesize to sectorsize in alignment check in print_extent_item. The comment states that and this is correct, similar check is done elsewhere in the functions.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- fs/btrfs/print-tree.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/btrfs/print-tree.c +3 -3
@@ -130,10 +130,10 @@ static void print_extent_item(struct extpr_cont ("shared data backref parent %llu count %u\n" , offset,btrfs_shared_data_ref_count (eb, sref));/* -* offset is supposed to be a tree block which -* must be aligned to nodesize. +* Offset is supposed to be a tree block which must be +* aligned to sectorsize. */ -if (!IS_ALIGNED (offset, eb->fs_info->nodesize)) +if (!IS_ALIGNED (offset, eb->fs_info->sectorsize))pr_info ("\t\t\t(parent %llu not aligned to sectorsize %u)\n" , offset, eb->fs_info->sectorsize);
Greg Kroah-Hartman
maintainerPATCH 99/116 cifs: fix pcchunk length type in smb2_copychunk_range
In reply to Greg Kroah-HartmanFrom: Pawel Witek <[email protected]>
commit d66cde50c3c868af7abddafce701bb86e4a93039 upstream.
Change type of pcchunk->Length from u32 to u64 to match smb2_copychunk_range arguments type. Fixes the problem where performing server-side copy with CIFS_IOC_COPYCHUNK_FILE ioctl resulted in incomplete copy of large files while returning -EINVAL.
--- fs/cifs/smb2ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/smb2ops.c +1 -1
@@ -891,7 +891,7 @@ smb2_copychunk_range(const unsigned int pcchunk->SourceOffset =cpu_to_le64 (src_off); pcchunk->TargetOffset =cpu_to_le64 (dest_off); pcchunk->Length = -cpu_to_le32 (min_t (u32, len, tcon->max_bytes_chunk)); +cpu_to_le32 (min_t (u64, len, tcon->max_bytes_chunk));/* Request server copy to target from src identified by key */ kfree (retbuf);
Greg Kroah-Hartman
maintainerPATCH 100/116 sh: math-emu: fix macro redefined warning
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
commit 58a49ad90939386a8682e842c474a0d2c00ec39c upstream.
Fix a warning that was reported by the kernel test robot:
In file included from ../include/math-emu/soft-fp.h:27,
from ../arch/sh/math-emu/math.c:22:
../arch/sh/include/asm/sfp-machine.h:17: warning: "__BYTE_ORDER" redefined
17 | #define __BYTE_ORDER __BIG_ENDIAN
In file included from ../arch/sh/math-emu/math.c:21:../arch/sh/math-emu/sfp-util.h:71: note: this is the location of the previous definition
71 | #define __BYTE_ORDER __LITTLE_ENDIAN
--- arch/sh/math-emu/sfp-util.h | 4 ---- 1 file changed, 4 deletions(-)
arch/sh/math-emu/sfp-util.h +0 -4
@@ -67,7 +67,3 @@ } while (0)#define abort () return 0 - -#define __BYTE_ORDER __LITTLE_ENDIAN - -
Greg Kroah-Hartman
maintainerPATCH 101/116 sh: nmi_debug: fix return value of __setup handler
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
commit d1155e4132de712a9d3066e2667ceaad39a539c5 upstream.
__setup() handlers should return 1 to obsolete_checksetup() in init/main.c to indicate that the boot option has been handled. A return of 0 causes the boot option/value to be listed as an Unknown kernel parameter and added to init's (limited) argument or environment strings. Also, error return codes don't mean anything to obsolete_checksetup() -- only non-zero (usually 1) or zero. So return 1 from nmi_debug_setup().
--- arch/sh/kernel/nmi_debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/sh/kernel/nmi_debug.c +2 -2
@@ -52,7 +52,7 @@ static int __init nmi_debug_setup(char *register_die_notifier (&nmi_debug_nb);if (*str !='=' ) -return 0 ; +return 1 ;for (p = str +1 ; *p; p = sep +1 ) { sep =strchr (p,',' );
@@ -73,6 +73,6 @@ static int __init nmi_debug_setup(char *break ; } -return 0 ; +return 1 ; }__setup ("nmi_debug" , nmi_debug_setup);
Greg Kroah-Hartman
maintainerPATCH 102/116 ARM: dts: exynos: fix WM8960 clock name in Itop Elite
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit 6c950c20da38debf1ed531e0b972bd8b53d1c11f upstream.
The WM8960 Linux driver expects the clock to be named "mclk". Otherwise the clock will be ignored and not prepared/enabled by the driver.
--- arch/arm/boot/dts/exynos4412-itop-elite.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/exynos4412-itop-elite.dts +1 -1
@@ -187,7 +187,7 @@ compatible = "wlf,wm8960"; reg = <0x1a>; clocks = <&pmu_system_controller 0>; - clock-names = "MCLK1"; + clock-names = "mclk"; wlf,shared-lrclk; #sound-dai-cells = <0>; };
Greg Kroah-Hartman
maintainerPATCH 103/116 ARM: dts: s5pv210: correct MIPI CSIS clock name
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit 665b9459bb53b8f19bd1541567e1fe9782c83c4b upstream.
The Samsung S5P/Exynos MIPI CSIS bindings and Linux driver expect first clock name to be "csis". Otherwise the driver fails to probe.
--- arch/arm/boot/dts/s5pv210.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/s5pv210.dtsi +1 -1
@@ -563,7 +563,7 @@ interrupts = <29>; clocks = <&clocks CLK_CSIS>, <&clocks SCLK_CSIS>; - clock-names = "clk_csis", + clock-names = "csis", "sclk_csis"; bus-width = <4>; status = "disabled";
Greg Kroah-Hartman
maintainerPATCH 104/116 HID: wacom: Set a default resolution for older tablets
In reply to Greg Kroah-HartmanFrom: Ping Cheng <[email protected]>
commit 08a46b4190d345544d04ce4fe2e1844b772b8535 upstream.
Some older tablets may not report physical maximum for X/Y coordinates. Set a default to prevent undefined resolution.
--- drivers/hid/wacom_wac.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/hid/wacom_wac.c +10 -2
@@ -1734,6 +1734,7 @@ static void wacom_map_usage(struct inputint fmax = field->logical_maximum;unsigned int equivalent_usage =wacom_equivalent_usage (usage->hid);int resolution_code = code; +int resolution =hidinput_calc_abs_res (field, resolution_code);if (equivalent_usage ==HID_DG_TWIST ) { resolution_code =ABS_RZ ;
@@ -1756,8 +1757,15 @@ static void wacom_map_usage(struct inputswitch (type) {case EV_ABS :input_set_abs_params (input, code, fmin, fmax, fuzz,0 ); -input_abs_set_res (input, code, -hidinput_calc_abs_res (field, resolution_code)); + +/* older tablet may miss physical usage */ +if ((code ==ABS_X || code ==ABS_Y ) && !resolution) { + resolution =WACOM_INTUOS_RES ; +hid_warn (input, +"Wacom usage (%d) missing resolution \n" , + code); + } +input_abs_set_res (input, code, resolution);break ;case EV_KEY :input_set_capability (input,EV_KEY , code);
Greg Kroah-Hartman
maintainerPATCH 105/116 ext4: avoid a potential slab-out-of-bounds in ext4_group_desc_csum
In reply to Greg Kroah-HartmanFrom: Tudor Ambarus <[email protected]>
commit 4f04351888a83e595571de672e0a4a8b74f4fb31 upstream.
When modifying the block device while it is mounted by the filesystem, syzbot reported the following:
BUG: KASAN: slab-out-of-bounds in crc16+0x206/0x280 lib/crc16.c:58 Read of size 1 at addr ffff888075f5c0a8 by task syz-executor.2/15586 CPU: 1 PID: 15586 Comm: syz-executor.2 Not tainted 6.2.0-rc5-syzkaller-00205-gc96618275234 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/12/2023 Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1b1/0x290 lib/dump_stack.c:106 print_address_description+0x74/0x340 mm/kasan/report.c:306 print_report+0x107/0x1f0 mm/kasan/report.c:417 kasan_report+0xcd/0x100 mm/kasan/report.c:517 crc16+0x206/0x280 lib/crc16.c:58 ext4_group_desc_csum+0x81b/0xb20 fs/ext4/super.c:3187 ext4_group_desc_csum_set+0x195/0x230 fs/ext4/super.c:3210 ext4_mb_clear_bb fs/ext4/mballoc.c:6027 [inline] ext4_free_blocks+0x191a/0x2810 fs/ext4/mballoc.c:6173 ext4_remove_blocks fs/ext4/extents.c:2527 [inline] ext4_ext_rm_leaf fs/ext4/extents.c:2710 [inline] ext4_ext_remove_space+0x24ef/0x46a0 fs/ext4/extents.c:2958 ext4_ext_truncate+0x177/0x220 fs/ext4/extents.c:4416 ext4_truncate+0xa6a/0xea0 fs/ext4/inode.c:4342 ext4_setattr+0x10c8/0x1930 fs/ext4/inode.c:5622 notify_change+0xe50/0x1100 fs/attr.c:482 do_truncate+0x200/0x2f0 fs/open.c:65 handle_truncate fs/namei.c:3216 [inline] do_open fs/namei.c:3561 [inline] path_openat+0x272b/0x2dd0 fs/namei.c:3714 do_filp_open+0x264/0x4f0 fs/namei.c:3741 do_sys_openat2+0x124/0x4e0 fs/open.c:1310 do_sys_open fs/open.c:1326 [inline] __do_sys_creat fs/open.c:1402 [inline] __se_sys_creat fs/open.c:1396 [inline] __x64_sys_creat+0x11f/0x160 fs/open.c:1396 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f72f8a8c0c9 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f72f97e3168 EFLAGS: 00000246 ORIG_RAX: 0000000000000055 RAX: ffffffffffffffda RBX: 00007f72f8bac050 RCX: 00007f72f8a8c0c9 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000020000280 RBP: 00007f72f8ae7ae9 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffd165348bf R14: 00007f72f97e3300 R15: 0000000000022000
Replace
le16_to_cpu(sbi->s_es->s_desc_size) with sbi->s_desc_size
It reduces ext4's compiled text size, and makes the code more efficient (we remove an extra indirect reference and a potential byte swap on big endian systems), and there is no downside. It also avoids the potential KASAN / syzkaller failure, as a bonus.
--- fs/ext4/super.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/ext4/super.c +2 -4
@@ -2343,11 +2343,9 @@ static __le16 ext4_group_desc_csum(struc crc =crc16 (crc, (__u8 *)gdp, offset); offset +=sizeof (gdp->bg_checksum);/* skip checksum */ /* for checksum of struct ext4_group_desc do the rest...*/ -if (ext4_has_feature_64bit (sb) && - offset <le16_to_cpu (sbi->s_es->s_desc_size)) +if (ext4_has_feature_64bit (sb) && offset < sbi->s_desc_size) crc =crc16 (crc, (__u8 *)gdp + offset, -le16_to_cpu (sbi->s_es->s_desc_size) - - offset); + sbi->s_desc_size - offset); out:return cpu_to_le16 (crc);
Greg Kroah-Hartman
maintainerPATCH 106/116 ext4: improve error recovery code paths in __ext4_remount()
In reply to Greg Kroah-HartmanFrom: Theodore Ts'o <[email protected]>
commit 4c0b4818b1f636bc96359f7817a2d8bab6370162 upstream.
If there are failures while changing the mount options in __ext4_remount(), we need to restore the old mount options.
This commit fixes two problem. The first is there is a chance that we will free the old quota file names before a potential failure leading to a use-after-free. The second problem addressed in this commit is if there is a failed read/write to read-only transition, if the quota has already been suspended, we need to renable quota handling.
--- fs/ext4/super.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
fs/ext4/super.c +10 -3
@@ -5390,9 +5390,6 @@ static int ext4_remount(struct super_bloext4_commit_super (sb,1 );#ifdef CONFIG_QUOTA -/* Release old quota file names */ -for (i =0 ; i <EXT4_MAXQUOTAS ; i++) -kfree (old_opts.s_qf_names[i]);if (enable_quota) {if (sb_any_quota_suspended (sb))dquot_resume (sb,-1 );
@@ -5402,6 +5399,9 @@ static int ext4_remount(struct super_blo goto restore_opts; } } +/* Release old quota file names */ +for (i =0 ; i <EXT4_MAXQUOTAS ; i++) +kfree (old_opts.s_qf_names[i]);#endif *flags = (*flags & ~MS_LAZYTIME ) | (sb->s_flags &MS_LAZYTIME );
@@ -5410,6 +5410,13 @@ static int ext4_remount(struct super_bloreturn 0 ; restore_opts: +/* +* If there was a failing r/w to ro transition, we may need to +* re-enable quota +*/ +if ((sb->s_flags &SB_RDONLY ) && !(old_sb_flags &SB_RDONLY ) && +sb_any_quota_suspended (sb)) +dquot_resume (sb,-1 ); sb->s_flags = old_sb_flags; sbi->s_mount_opt = old_opts.s_mount_opt; sbi->s_mount_opt2 = old_opts.s_mount_opt2;
Greg Kroah-Hartman
maintainerPATCH 107/116 ext4: add bounds checking in get_max_inline_xattr_value_size()
In reply to Greg Kroah-HartmanFrom: Theodore Ts'o <[email protected]>
commit 2220eaf90992c11d888fe771055d4de330385f01 upstream.
Normally the extended attributes in the inode body would have been checked when the inode is first opened, but if someone is writing to the block device while the file system is mounted, it's possible for the inode table to get corrupted. Add bounds checking to avoid reading beyond the end of allocated memory if this happens.
--- fs/ext4/inline.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
fs/ext4/inline.c +11 -1
@@ -38,6 +38,7 @@ static int get_max_inline_xattr_value_sistruct ext4_xattr_ibody_header *header;struct ext4_xattr_entry *entry;struct ext4_inode *raw_inode; +void *end;int free, min_offs;if (!EXT4_INODE_HAS_XATTR_SPACE (inode))
@@ -61,14 +62,23 @@ static int get_max_inline_xattr_value_si raw_inode =ext4_raw_inode (iloc); header =IHDR (inode, raw_inode); entry =IFIRST (header); + end = (void *)raw_inode +EXT4_SB (inode->i_sb)->s_inode_size;/* Compute min_offs. */ -for (; !IS_LAST_ENTRY (entry); entry =EXT4_XATTR_NEXT (entry)) { +while (!IS_LAST_ENTRY (entry)) { +void *next =EXT4_XATTR_NEXT (entry); + +if (next >= end) { +EXT4_ERROR_INODE (inode, +"corrupt xattr in inline inode" ); +return 0 ; + }if (!entry->e_value_inum && entry->e_value_size) {size_t offs =le16_to_cpu (entry->e_value_offs);if (offs < min_offs) min_offs = offs; } + entry = next; } free = min_offs - ((void *)entry - (void *)IFIRST (header)) -sizeof (__u32);
Greg Kroah-Hartman
maintainerPATCH 108/116 ext4: bail out of ext4_xattr_ibody_get() fails for any reason
In reply to Greg Kroah-HartmanFrom: Theodore Ts'o <[email protected]>
commit 2a534e1d0d1591e951f9ece2fb460b2ff92edabd upstream.
In ext4_update_inline_data(), if ext4_xattr_ibody_get() fails for any reason, it's best if we just fail as opposed to stumbling on, especially if the failure is EFSCORRUPTED.
--- fs/ext4/inline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/inline.c +1 -1
@@ -364,7 +364,7 @@ static int ext4_update_inline_data(handl error =ext4_xattr_ibody_get (inode, i.name_index, i.name, value, len); -if (error == -ENODATA ) +if (error <0 ) goto out;BUFFER_TRACE (is.iloc.bh,"get_write_access" );
Greg Kroah-Hartman
maintainerPATCH 109/116 ext4: remove a BUG_ON in ext4_mb_release_group_pa()
In reply to Greg Kroah-HartmanFrom: Theodore Ts'o <[email protected]>
commit 463808f237cf73e98a1a45ff7460c2406a150a0b upstream.
If a malicious fuzzer overwrites the ext4 superblock while it is mounted such that the s_first_data_block is set to a very large number, the calculation of the block group can underflow, and trigger a BUG_ON check. Change this to be an ext4_warning so that we don't crash the kernel.
--- fs/ext4/mballoc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/ext4/mballoc.c +5 -1
@@ -3921,7 +3921,11 @@ ext4_mb_release_group_pa(struct ext4_budtrace_ext4_mb_release_group_pa (sb, pa);BUG_ON (pa->pa_deleted ==0 );ext4_get_group_no_and_offset (sb, pa->pa_pstart, &group, &bit); -BUG_ON (group != e4b->bd_group && pa->pa_len !=0 ); +if (unlikely (group != e4b->bd_group && pa->pa_len !=0 )) { +ext4_warning (sb,"bad group: expected %u, group %u, pa_start %llu" , + e4b->bd_group, group, pa->pa_pstart); +return 0 ; + }mb_free_blocks (pa->pa_inode, e4b, bit, pa->pa_len);atomic_add (pa->pa_len, &EXT4_SB (sb)->s_mb_discarded);trace_ext4_mballoc_discard (sb,NULL , group, bit, pa->pa_len);
Greg Kroah-Hartman
maintainerPATCH 110/116 ext4: fix invalid free tracking in ext4_xattr_move_to_block()
In reply to Greg Kroah-HartmanFrom: Theodore Ts'o <[email protected]>
commit b87c7cdf2bed4928b899e1ce91ef0d147017ba45 upstream.
In ext4_xattr_move_to_block(), the value of the extended attribute which we need to move to an external block may be allocated by kvmalloc() if the value is stored in an external inode. So at the end of the function the code tried to check if this was the case by testing entry->e_value_inum.
However, at this point, the pointer to the xattr entry is no longer valid, because it was removed from the original location where it had been stored. So we could end up calling kvfree() on a pointer which was not allocated by kvmalloc(); or we could also potentially leak memory by not freeing the buffer when it should be freed. Fix this by storing whether it should be freed in a separate variable.
--- fs/ext4/xattr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/ext4/xattr.c +3 -2
@@ -2559,6 +2559,7 @@ static int ext4_xattr_move_to_block(hand .in_inode = !!entry->e_value_inum, };struct ext4_xattr_ibody_header *header =IHDR (inode, raw_inode); +int needs_kvfree =0 ;int error; is =kzalloc (sizeof (struct ext4_xattr_ibody_find ),GFP_NOFS );
@@ -2581,7 +2582,7 @@ static int ext4_xattr_move_to_block(hand error = -ENOMEM ; goto out; } - + needs_kvfree =1 ; error =ext4_xattr_inode_get (inode, entry, buffer, value_size);if (error) goto out;
@@ -2620,7 +2621,7 @@ static int ext4_xattr_move_to_block(hand out:kfree (b_entry_name); -if (entry->e_value_inum && buffer) +if (needs_kvfree && buffer)kvfree (buffer);if (is)brelse (is->iloc.bh);
Greg Kroah-Hartman
maintainerPATCH 111/116 perf bench: Share some global variables to fix build with gcc 10
In reply to Greg Kroah-HartmanFrom: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit e4d9b04b973b2dbce7b42af95ea70d07da1c936d ]
Noticed with gcc 10 (fedora rawhide) that those variables were not being declared as static, so end up with:
ld: /tmp/build/perf/bench/epoll-wait.o:/git/perf/tools/perf/bench/epoll-wait.c:93: multiple definition of `end'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here
ld: /tmp/build/perf/bench/epoll-wait.o:/git/perf/tools/perf/bench/epoll-wait.c:93: multiple definition of `start'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here
ld: /tmp/build/perf/bench/epoll-wait.o:/git/perf/tools/perf/bench/epoll-wait.c:93: multiple definition of `runtime'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here
ld: /tmp/build/perf/bench/epoll-ctl.o:/git/perf/tools/perf/bench/epoll-ctl.c:38: multiple definition of `end'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here
ld: /tmp/build/perf/bench/epoll-ctl.o:/git/perf/tools/perf/bench/epoll-ctl.c:38: multiple definition of `start'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here
ld: /tmp/build/perf/bench/epoll-ctl.o:/git/perf/tools/perf/bench/epoll-ctl.c:38: multiple definition of `runtime'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here make[4]: *** [/git/perf/tools/build/Makefile.build:145: /tmp/build/perf/bench/perf-in.o] Error 1
Prefix those with bench__ and add them to bench/bench.h, so that we can share those on the tools needing to access those variables from signal handlers.
--- tools/perf/bench/bench.h | 4 ++++ tools/perf/bench/futex-hash.c | 12 ++++++------ tools/perf/bench/futex-lock-pi.c | 11 +++++------ 3 files changed, 15 insertions(+), 12 deletions(-)
tools/perf/bench/bench.h +4 -0
@@ -2,6 +2,10 @@#ifndef BENCH_H #define BENCH_H +#include <sys/time.h> + +extern struct timeval bench__start, bench__end, bench__runtime; +/* * The madvise transparent hugepage constants were added in glibc * 2.13. For compatibility with older versions of glibc, define these
tools/perf/bench/futex-hash.c +6 -6
@@ -35,7 +35,7 @@ static unsigned int nfutexes = 1024;static bool fshared = false, done = false, silent = false;static int futex_flag =0 ; -struct timeval start, end, runtime; +struct timeval bench__start, bench__end, bench__runtime;static pthread_mutex_t thread_lock;static unsigned int threads_starting;static struct stats throughput_stats;
@@ -101,8 +101,8 @@ static void toggle_done(int sig __maybe_ {/* inform all threads that we're done for the day */ done = true; -gettimeofday (&end,NULL ); -timersub (&end, &start, &runtime); +gettimeofday (&bench__end,NULL ); +timersub (&bench__end, &bench__start, &bench__runtime); }static void print_summary (void )
@@ -112,7 +112,7 @@ static void print_summary(void)printf ("%sAveraged %ld operations/sec (+- %.2f%%), total secs = %d\n" , !silent ?"\n" :"" , avg,rel_stddev_stats (stddev, avg), - (int ) runtime.tv_sec); + (int )bench__runtime.tv_sec); }int bench_futex_hash (int argc,const char **argv)
@@ -156,7 +156,7 @@ int bench_futex_hash(int argc, const cha threads_starting = nthreads;pthread_attr_init (&thread_attr); -gettimeofday (&start,NULL ); +gettimeofday (&bench__start,NULL );for (i =0 ; i < nthreads; i++) { worker[i].tid = i; worker[i].futex =calloc (nfutexes,sizeof (*worker[i].futex));
@@ -199,7 +199,7 @@ int bench_futex_hash(int argc, const chapthread_mutex_destroy (&thread_lock);for (i =0 ; i < nthreads; i++) { -unsigned long t = worker[i].ops/runtime.tv_sec; +unsigned long t = worker[i].ops / bench__runtime.tv_sec;update_stats (&throughput_stats, t);if (!silent) {if (nfutexes ==1 )
tools/perf/bench/futex-lock-pi.c +5 -6
@@ -34,7 +34,6 @@ static bool silent = false, multi = falsstatic bool done = false, fshared = false;static unsigned int ncpus, nthreads =0 ;static int futex_flag =0 ; -struct timeval start, end, runtime;static pthread_mutex_t thread_lock;static unsigned int threads_starting;static struct stats throughput_stats;
@@ -61,7 +60,7 @@ static void print_summary(void)printf ("%sAveraged %ld operations/sec (+- %.2f%%), total secs = %d\n" , !silent ?"\n" :"" , avg,rel_stddev_stats (stddev, avg), - (int ) runtime.tv_sec); + (int )bench__runtime.tv_sec); } static void toggle_done(int sig __maybe_unused,
@@ -70,8 +69,8 @@ static void toggle_done(int sig __maybe_ {/* inform all threads that we're done for the day */ done = true; -gettimeofday (&end,NULL ); -timersub (&end, &start, &runtime); +gettimeofday (&bench__end,NULL ); +timersub (&bench__end, &bench__start, &bench__runtime); }static void *workerfn (void *arg)
@@ -178,7 +177,7 @@ int bench_futex_lock_pi(int argc, const threads_starting = nthreads;pthread_attr_init (&thread_attr); -gettimeofday (&start,NULL ); +gettimeofday (&bench__start,NULL );create_threads (worker, thread_attr);pthread_attr_destroy (&thread_attr);
@@ -204,7 +203,7 @@ int bench_futex_lock_pi(int argc, constpthread_mutex_destroy (&thread_lock);for (i =0 ; i < nthreads; i++) { -unsigned long t = worker[i].ops/runtime.tv_sec; +unsigned long t = worker[i].ops / bench__runtime.tv_sec;update_stats (&throughput_stats, t);if (!silent)
Greg Kroah-Hartman
maintainerPATCH 112/116 tty: Prevent writing chars during tcsetattr TCSADRAIN/FLUSH
In reply to Greg Kroah-HartmanFrom: "Ilpo J�rvinen" <[email protected]>
If userspace races tcsetattr() with a write, the drained condition might not be guaranteed by the kernel. There is a race window after checking Tx is empty before tty_set_termios() takes termios_rwsem for write. During that race window, more characters can be queued by a racing writer.
Any ongoing transmission might produce garbage during HW's ->set_termios() call. The intent of TCSADRAIN/FLUSH seems to be preventing such a character corruption. If those flags are set, take tty's write lock to stop any writer before performing the lower layer Tx empty check and wait for the pending characters to be sent (if any).
The initial wait for all-writers-done must be placed outside of tty's write lock to avoid deadlock which makes it impossible to use tty_wait_until_sent(). The write lock is retried if a racing write is detected.
--- drivers/tty/tty_io.c | 4 ++-- drivers/tty/tty_ioctl.c | 45 +++++++++++++++++++++++++++++++++------------ include/linux/tty.h | 2 ++ 3 files changed, 37 insertions(+), 14 deletions(-)
drivers/tty/tty_io.c +2 -2
@@ -874,13 +874,13 @@ static ssize_t tty_read(struct file *filreturn i; } -static void tty_write_unlock (struct tty_struct *tty) +void tty_write_unlock (struct tty_struct *tty) {mutex_unlock (&tty->atomic_write_lock);wake_up_interruptible_poll (&tty->write_wait,POLLOUT ); } -static int tty_write_lock (struct tty_struct *tty,int ndelay) +int tty_write_lock (struct tty_struct *tty,int ndelay) {if (!mutex_trylock (&tty->atomic_write_lock)) {if (ndelay)
drivers/tty/tty_ioctl.c +33 -12
54 lines not on this page · raw message
include/linux/tty.h +2 -0
@@ -479,6 +479,8 @@ extern void __stop_tty(struct tty_structextern void stop_tty (struct tty_struct *tty);extern void __start_tty (struct tty_struct *tty);extern void start_tty (struct tty_struct *tty); +void tty_write_unlock (struct tty_struct *tty); +int tty_write_lock (struct tty_struct *tty,int ndelay);extern int tty_register_driver (struct tty_driver *driver);extern int tty_unregister_driver (struct tty_driver *driver); extern struct device *tty_register_device(struct tty_driver *driver,
Greg Kroah-Hartman
maintainerPATCH 113/116 serial: 8250: Fix serial8250_tx_empty() race with DMA Tx
In reply to Greg Kroah-HartmanFrom: "Ilpo J�rvinen" <[email protected]>
There's a potential race before THRE/TEMT deasserts when DMA Tx is starting up (or the next batch of continuous Tx is being submitted). This can lead to misdetecting Tx empty condition.
It is entirely normal for THRE/TEMT to be set for some time after the DMA Tx had been setup in serial8250_tx_dma(). As Tx side is definitely not empty at that point, it seems incorrect for serial8250_tx_empty() claim Tx is empty.
Fix the race by also checking in serial8250_tx_empty() whether there's DMA Tx active.
Note: This fix only addresses in-kernel race mainly to make using TCSADRAIN/FLUSH robust. Userspace can still cause other races but they seem userspace concurrency control problems.
--- drivers/tty/serial/8250/8250.h | 12 ++++++++++++ drivers/tty/serial/8250/8250_port.c | 12 +++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-)
drivers/tty/serial/8250/8250.h +12 -0
@@ -221,6 +221,13 @@ extern int serial8250_rx_dma(struct uartextern void serial8250_rx_dma_flush (struct uart_8250_port *);extern int serial8250_request_dma (struct uart_8250_port *);extern void serial8250_release_dma (struct uart_8250_port *); + +static inline bool serial8250_tx_dma_running (struct uart_8250_port *p) +{ +struct uart_8250_dma *dma = p->dma; + +return dma && dma->tx_running; +}#else static inline int serial8250_tx_dma (struct uart_8250_port *p) {
@@ -236,6 +243,11 @@ static inline int serial8250_request_dma return -1; }static inline void serial8250_release_dma (struct uart_8250_port *p) { } + +static inline bool serial8250_tx_dma_running (struct uart_8250_port *p) +{ +return false; +}#endif static inline int ns16550a_goto_highspeed (struct uart_8250_port *up)
drivers/tty/serial/8250/8250_port.c +9 -3
@@ -1968,19 +1968,25 @@ static int serial8250_tx_threshold_handlstatic unsigned int serial8250_tx_empty (struct uart_port *port) {struct uart_8250_port *up =up_to_u8250p (port); +unsigned int result =0 ;unsigned long flags;unsigned int lsr;serial8250_rpm_get (up);spin_lock_irqsave (&port->lock, flags); - lsr =serial_port_in (port,UART_LSR ); - up->lsr_saved_flags |= lsr &LSR_SAVE_FLAGS ; +if (!serial8250_tx_dma_running (up)) { + lsr =serial_port_in (port,UART_LSR ); + up->lsr_saved_flags |= lsr &LSR_SAVE_FLAGS ; + +if ((lsr &BOTH_EMPTY ) ==BOTH_EMPTY ) + result =TIOCSER_TEMT ; + }spin_unlock_irqrestore (&port->lock, flags);serial8250_rpm_put (up); -return (lsr &BOTH_EMPTY ) ==BOTH_EMPTY ?TIOCSER_TEMT :0 ; +return result; }unsigned int serial8250_do_get_mctrl (struct uart_port *port)
Greg Kroah-Hartman
maintainerPATCH 114/116 drbd: correctly submit flush bio on barrier
In reply to Greg Kroah-HartmanFrom: Christoph Böhmwalder <[email protected]>
commit 3899d94e3831ee07ea6821c032dc297aec80586a upstream.
When we receive a flush command (or "barrier" in DRBD), we currently use a REQ_OP_FLUSH with the REQ_PREFLUSH flag set.
The correct way to submit a flush bio is by using a REQ_OP_WRITE without any data, and set the REQ_PREFLUSH flag.
Since commit b4a6bb3a67aa ("block: add a sanity check for non-write flush/fua bios"), this triggers a warning in the block layer, but this has been broken for quite some time before that.
So use the correct set of flags to actually make the flush happen.
--- drivers/block/drbd/drbd_receiver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/drbd/drbd_receiver.c +1 -1
@@ -1309,7 +1309,7 @@ static void submit_one_flush(struct drbdbio_set_dev (bio, device->ldev->backing_bdev); bio->bi_private = octx; bio->bi_end_io = one_flush_endio; - bio->bi_opf =REQ_OP_FLUSH |REQ_PREFLUSH ; + bio->bi_opf =REQ_OP_WRITE |REQ_PREFLUSH ; device->flush_jif = jiffies;set_bit (FLUSH_PENDING , &device->flags);
Greg Kroah-Hartman
maintainerPATCH 115/116 printk: declare printk_deferred_{enter,safe}() in include/linux/printk.h
In reply to Greg Kroah-HartmanFrom: Tetsuo Handa <[email protected]>
commit 85e3e7fbbb720b9897fba9a99659e31cbd1c082e upstream.
[This patch implements subset of original commit 85e3e7fbbb72 ("printk:
remove NMI tracking") where commit 1007843a9190 ("mm/page_alloc: fix potential deadlock on zonelist_update_seq seqlock") depends on, for commit 3d36424b3b58 ("mm/page_alloc: fix race condition between build_all_zonelists and page allocation") was backported to stable.]
All NMI contexts are handled the same as the safe context: store the message and defer printing. There is no need to have special NMI context tracking for this. Using in_nmi() is enough.
There are several parts of the kernel that are manually calling into the printk NMI context tracking in order to cause general printk deferred printing:
arch/arm/kernel/smp.c
arch/powerpc/kexec/crash.c
kernel/trace/trace.c
For arm/kernel/smp.c and powerpc/kexec/crash.c, provide a new function pair printk_deferred_enter/exit that explicitly achieves the same objective.
For ftrace, remove the printk context manipulation completely. It was added in commit 03fc7f9c99c1 ("printk/nmi: Prevent deadlock when accessing the main log buffer in NMI"). The purpose was to enforce storing messages directly into the ring buffer even in NMI context. It really should have only modified the behavior in NMI context. There is no need for a special behavior any longer. All messages are always stored directly now. The console deferring is handled transparently in vprintk().
[[email protected]: Remove special handling in ftrace.c completely.
--- include/linux/printk.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
include/linux/printk.h +19 -0
@@ -528,4 +528,23 @@ static inline void print_hex_dump_debug( }#endif +#ifdef CONFIG_PRINTK +extern void __printk_safe_enter (void ); +extern void __printk_safe_exit (void ); +/* +* The printk_deferred_enter/exit macros are available only as a hack for +* some code paths that need to defer all printk console printing. Interrupts +* must be disabled for the deferred duration. +*/ +#define printk_deferred_enter __printk_safe_enter +#define printk_deferred_exit __printk_safe_exit +#else +static inline void printk_deferred_enter (void ) +{ +} +static inline void printk_deferred_exit (void ) +{ +} +#endif +#endif
Greg Kroah-Hartman
maintainerPATCH 116/116 mm/page_alloc: fix potential deadlock on zonelist_update_seq seqlock
In reply to Greg Kroah-HartmanFrom: Tetsuo Handa <[email protected]>
commit 1007843a91909a4995ee78a538f62d8665705b66 upstream.
syzbot is reporting circular locking dependency which involves zonelist_update_seq seqlock [1], for this lock is checked by memory allocation requests which do not need to be retried.
One deadlock scenario is kmalloc(GFP_ATOMIC) from an interrupt handler.
CPU0
----
__build_all_zonelists() {
write_seqlock(&zonelist_update_seq); // makes zonelist_update_seq.seqcount odd
// e.g. timer interrupt handler runs at this moment
some_timer_func() {
kmalloc(GFP_ATOMIC) {
__alloc_pages_slowpath() {
read_seqbegin(&zonelist_update_seq) {
// spins forever because zonelist_update_seq.seqcount is odd
}
}
}
}
// e.g. timer interrupt handler finishes
write_sequnlock(&zonelist_update_seq); // makes zonelist_update_seq.seqcount even
}This deadlock scenario can be easily eliminated by not calling read_seqbegin(&zonelist_update_seq) from !__GFP_DIRECT_RECLAIM allocation requests, for retry is applicable to only __GFP_DIRECT_RECLAIM allocation requests. But Michal Hocko does not know whether we should go with this approach.
Another deadlock scenario which syzbot is reporting is a race between kmalloc(GFP_ATOMIC) from tty_insert_flip_string_and_push_buffer() with port->lock held and printk() from __build_all_zonelists() with zonelist_update_seq held.
CPU0 CPU1
---- ----
pty_write() {
tty_insert_flip_string_and_push_buffer() {
__build_all_zonelists() {
write_seqlock(&zonelist_update_seq);
build_zonelists() {
printk() {
vprintk() {
vprintk_default() {
vprintk_emit() {
console_unlock() {
console_flush_all() {
console_emit_next_record() {
con->write() = serial8250_console_write() {
spin_lock_irqsave(&port->lock, flags);
tty_insert_flip_string() {
tty_insert_flip_string_fixed_flag() {
__tty_buffer_request_room() {
tty_buffer_alloc() {
kmalloc(GFP_ATOMIC | __GFP_NOWARN) {
__alloc_pages_slowpath() {
zonelist_iter_begin() {
read_seqbegin(&zonelist_update_seq); // spins forever because zonelist_update_seq.seqcount is odd
spin_lock_irqsave(&port->lock, flags); // spins forever because port->lock is held
}
}
}
}
}
}
}
}
spin_unlock_irqrestore(&port->lock, flags);
// message is printed to console
spin_unlock_irqrestore(&port->lock, flags);
}
}
}
}
}
}
}
}
}
write_sequnlock(&zonelist_update_seq);
}
}
}This deadlock scenario can be eliminated by
preventing interrupt context from calling kmalloc(GFP_ATOMIC)
and
preventing printk() from calling console_flush_all()
while zonelist_update_seq.seqcount is odd.
Since Petr Mladek thinks that __build_all_zonelists() can become a candidate for deferring printk() [2], let's address this problem by
disabling local interrupts in order to avoid kmalloc(GFP_ATOMIC)
and
disabling synchronous printk() in order to avoid console_flush_all()
.
As a side effect of minimizing duration of zonelist_update_seq.seqcount being odd by disabling synchronous printk(), latency at read_seqbegin(&zonelist_update_seq) for both !__GFP_DIRECT_RECLAIM and __GFP_DIRECT_RECLAIM allocation requests will be reduced. Although, from lockdep perspective, not calling read_seqbegin(&zonelist_update_seq) (i.e. do not record unnecessary locking dependency) from interrupt context is still preferable, even if we don't allow calling kmalloc(GFP_ATOMIC) inside write_seqlock(&zonelist_update_seq)/write_sequnlock(&zonelist_update_seq) section...
--- mm/page_alloc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
mm/page_alloc.c +16 -0
@@ -5213,7 +5213,21 @@ static void __build_all_zonelists(void *int nid;int __maybe_unused cpu;pg_data_t *self = data; +unsigned long flags; +/* +* Explicitly disable this CPU's interrupts before taking seqlock +* to prevent any IRQ handler from calling into the page allocator +* (e.g. GFP_ATOMIC) that could hit zonelist_iter_begin and livelock. +*/ +local_irq_save (flags); +/* +* Explicitly disable this CPU's synchronous printk() before taking +* seqlock to prevent any printk() from trying to hold port->lock, for +* tty_insert_flip_string_and_push_buffer() on other CPU might be +* calling kmalloc(GFP_ATOMIC | __GFP_NOWARN) with port->lock held. +*/ +printk_deferred_enter ();write_seqlock (&zonelist_update_seq);#ifdef CONFIG_NUMA
@@ -5248,6 +5262,8 @@ static void __build_all_zonelists(void * }write_sequnlock (&zonelist_update_seq); +printk_deferred_exit (); +local_irq_restore (flags); }static noinline void__init
Hello Greg,
Quoted 10 lines
From: Greg Kroah-Hartman <[email protected]>
Sent: Monday, May 15, 2023 5:25 PMThis is the start of the stable review cycle for the 4.14.315 release. There are 116 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 17 May 2023 16:16:37 +0000. Anything received after that time might be too late.
CIP configurations built and booted with Linux 4.14.315-rc1 (854d9237fbd3):
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/pipelines/867957506
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/commits/linux-4.14.y
Kind regards, Chris
Hi Greg,
Quoted 5 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.315 release. There are 116 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.
No problems seen on aarch64.
Thanks,
Harshit
Quoted 12 lines
Responses should be made by Wed, 17 May 2023 16:16:37 +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/v4.x/stable-review/patch-4.14.315-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.14.y
and the diffstat can be found below.thanks,
greg k-h
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.315 release. There are 116 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 17 May 2023 16:16:37 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.315-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.14.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
Regressions on arm64, arm, x86_64 and i386.
We have recently upgraded our selftest sources to stable-rc 6.3 and running on stable rc 6.1, 5.15, 5.10, 5.4, 4.19 and 4.14 kernels.
List of test regressions:
========
ltp-syscalls
- fallocate06 - FAILS on arm and arm64.
kselftest-kvm
- kvm_xapic_state_test - FAILS on x86.
======
ltp-syscalls
- fallocate06 - FAILS on arm and arm64.
fallocate06.c:155: TFAIL: fallocate(FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE) failed unexpectedly: ENOSPC (28)
Test log links,
========
- https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-4.14.y/build/v4.14.314-117-g854d9237fbd3/testrun/17026942/suite/ltp-syscalls/test/fallocate06/history/
- https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-4.14.y/build/v4.14.314-117-g854d9237fbd3/testrun/17026942/suite/ltp-syscalls/test/fallocate06/log
=========
kselftest-kvm
- kvm_xapic_state_test - - FAILS on x86.
# selftests: kvm: xapic_state_test
# ==== Test Assertion Failure ====
# x86_64/xapic_state_test.c:147: apic_id == expected
# pid=4581 tid=4581 errno=4 - Interrupted system call
# 1 0x0000000000402bac: ?? ??:0 # 2 0x00000000004025ba: ?? ??:0 # 3 0x00007f8bc10e557a: ?? ??:0 # 4 0x00007f8bc10e562f: ?? ??:0 # 5 0x0000000000402624: ?? ??:0
# APIC_ID not set back to xAPIC format; wanted = 1000000, got = 1
not ok 46 selftests: kvm: xapic_state_test # exit=254
Test log links,
========
- https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-4.14.y/build/v4.14.314-117-g854d9237fbd3/testrun/17025913/suite/kselftest-kvm/test/kvm_xapic_state_test/history/
- https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-4.14.y/build/v4.14.314-117-g854d9237fbd3/testrun/17025913/suite/kselftest-kvm/test/kvm_xapic_state_test/log
## Build
* kernel: 4.14.315-rc1
* git: https://gitlab.com/Linaro/lkft/mirrors/stable/linux-stable-rc
* git branch: linux-4.14.y
* git commit: 854d9237fbd3cc4b72183256a0fa5edf2f967d88
* git describe: v4.14.314-117-g854d9237fbd3
* test details:
https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-4.14.y/build/v4.14.314-117-g854d9237fbd3
## Test Regressions (compared to v4.14.311-134-g05f80276ba11)
* dragonboard-410c, ltp-syscalls
- fallocate06
* juno-r2, ltp-syscalls
- fallocate06
* juno-r2-kasan, ltp-syscalls
- fallocate06
* x86, kselftest-kvm
- kvm_xapic_state_test
## Metric Regressions (compared to v4.14.311-134-g05f80276ba11)
## Test Fixes (compared to v4.14.311-134-g05f80276ba11)
## Metric Fixes (compared to v4.14.311-134-g05f80276ba11)
## Test result summary
total: 79873, pass: 67657, fail: 2892, skip: 9170, xfail: 154
## Build Summary
* arc: 10 total, 10 passed, 0 failed
* arm: 108 total, 104 passed, 4 failed
* arm64: 35 total, 31 passed, 4 failed
* i386: 21 total, 18 passed, 3 failed
* mips: 21 total, 21 passed, 0 failed
* parisc: 6 total, 6 passed, 0 failed
* powerpc: 8 total, 7 passed, 1 failed
* s390: 6 total, 5 passed, 1 failed
* sh: 12 total, 12 passed, 0 failed
* sparc: 6 total, 6 passed, 0 failed
* x86_64: 27 total, 23 passed, 4 failed
## Test suites summary
* boot
* fwts
* igt-gpu-tools
* kselftest-android
* kselftest-arm64
* kselftest-breakpoints
* kselftest-capabilities
* kselftest-cgroup
* kselftest-clone3
* kselftest-core
* kselftest-cpu-hotplug
* kselftest-cpufreq
* kselftest-drivers-dma-buf
* kselftest-efivarfs
* kselftest-filesystems
* kselftest-filesystems-binderfs
* kselftest-firmware
* kselftest-fpu
* kselftest-ftrace
* kselftest-futex
* kselftest-gpio
* kselftest-intel_pstate
* kselftest-ipc
* kselftest-ir
* kselftest-kcmp
* kselftest-kexec
* kselftest-kvm
* kselftest-lib
* kselftest-livepatch
* kselftest-membarrier
* kselftest-net
* kselftest-net-forwarding
* kselftest-netfilter
* kselftest-nsfs
* kselftest-openat2
* kselftest-pid_namespace
* kselftest-pidfd
* kselftest-proc
* kselftest-pstore
* kselftest-ptrace
* kselftest-rseq
* kselftest-rtc
* kselftest-seccomp
* kselftest-sigaltstack
* kselftest-size
* kselftest-splice
* kselftest-static_keys
* kselftest-sync
* kselftest-sysctl
* kselftest-tc-testing
* kselftest-timens
* kselftest-timers
* kselftest-tmpfs
* kselftest-tpm2
* kselftest-user
* kselftest-x86
* kselftest-zram
* kunit
* kvm-unit-tests
* libhugetlbfs
* log-parser-boot
* log-parser-test
* ltp-cap_bounds
* ltp-commands
* ltp-containers
* ltp-controllers
* ltp-cpuhotplug
* ltp-crypto
* ltp-cve
* ltp-dio
* ltp-fcntl-locktests
* ltp-filecaps
* ltp-fs
* ltp-fs_bind
* ltp-fs_perms_simple
* ltp-fsx
* ltp-hugetlb
* ltp-io
* ltp-ipc
* ltp-math
* ltp-mm
* ltp-nptl
* ltp-pty
* ltp-sched
* ltp-securebits
* ltp-smoke
* ltp-syscalls
* ltp-tracing
* network-basic-tests
* rcutorture
* v4l2-compliance
* vdso
--
Linaro LKFT
https://lkft.linaro.org
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.315 release. There are 116 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 17 May 2023 16:16:37 +0000. Anything received after that time might be too late.
Build results:
total: 168 pass: 168 fail: 0 Qemu test results: total: 430 pass: 430 fail: 0
Guenter
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.315 release. There are 116 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 17 May 2023 16:16:37 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.315-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.14.y
and the diffstat can be found below.thanks,
greg k-h
All tests passing for Tegra ...
Test results for stable-v4.14:
8 builds: 8 pass, 0 fail
16 boots: 16 pass, 0 fail
32 tests: 32 pass, 0 failLinux version: 4.14.315-rc1-g854d9237fbd3
Boards tested: tegra124-jetson-tk1, tegra20-ventana,
tegra210-p2371-2180, tegra30-cardhu-a04
Jon