6.1.156-rc1 review
Subsystems (6)
Greg Kroah-Hartman
maintainercover 6.1.156-rc1 review
This is the start of the stable review cycle for the 6.1.156 release. There are 196 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, 15 Oct 2025 14:42:41 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.1.156-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.1.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 6.1.156-rc1
K Prateek Nayak <[email protected]>
drivers: base: cacheinfo: Update cpu_map_populated during CPU Hotplug
Yicong Yang <[email protected]>
cacheinfo: Fix LLC is not exported through sysfs
Pierre Gondois <[email protected]>
cacheinfo: Initialize variables in fetch_cache_info()
Miaoqian Lin <[email protected]>
usb: cdns3: cdnsp-pci: remove redundant pci_disable_device() call
Sven Peter <[email protected]>
usb: typec: tipd: Clear interrupts first
Oleksij Rempel <[email protected]>
net: usb: asix: hold PM usage ref to avoid PM/MDIO + RTNL deadlock
Salah Triki <[email protected]>
bus: fsl-mc: Check return value of platform_get_resource()
Bartosz Golaszewski <[email protected]>
pinctrl: check the return value of pinmux_ops::get_function_name()
Zhen Ni <[email protected]>
Input: uinput - zero-initialize uinput_ff_upload_compat to avoid info leak
Marek Vasut <[email protected]>
Input: atmel_mxt_ts - allow reset GPIO to sleep
Ling Xu <[email protected]>
misc: fastrpc: Skip reference for DMA handles
Ling Xu <[email protected]>
misc: fastrpc: fix possible map leak in fastrpc_put_args
Ling Xu <[email protected]>
misc: fastrpc: Fix fastrpc_map_lookup operation
Guangshuo Li <[email protected]>
nvdimm: ndtest: Return -ENOMEM if devm_kcalloc() fails in ndtest_probe()
Yang Shi <[email protected]>
mm: hugetlb: avoid soft lockup when mprotect to large memory area
Jan Kara <[email protected]>
ext4: fix checks for orphan inodes
Matvey Kovalev <[email protected]>
ksmbd: fix error code overwriting in smb2_get_info_filesystem()
Zheng Qixing <[email protected]>
dm: fix NULL pointer dereference in __dm_suspend()
Zheng Qixing <[email protected]>
dm: fix queue start/stop imbalance under suspend/load/resume races
Bartosz Golaszewski <[email protected]>
mfd: vexpress-sysreg: Check the return value of devm_gpiochip_add_data()
Deepak Sharma <[email protected]>
net: nfc: nci: Add parameter validation for packet data
Larshin Sergey <[email protected]>
fs: udf: fix OOB read in lengthAllocDescs handling
Naman Jain <[email protected]>
uio_hv_generic: Let userspace take care of interrupt mask
Phillip Lougher <[email protected]>
Squashfs: fix uninit-value in squashfs_get_parent
zhang jiao <[email protected]>
vhost: vringh: Modify the return value check
Jakub Kicinski <[email protected]>
Revert "net/mlx5e: Update and set Xon/Xoff upon MTU set"
Moshe Shemesh <[email protected]>
net/mlx5: fw reset, add reset timeout work
Shay Drory <[email protected]>
net/mlx5: pagealloc: Fix reclaim race during command interface teardown
Moshe Shemesh <[email protected]>
net/mlx5: Stop polling for command response if interface goes down
Yeounsu Moon <[email protected]>
net: dlink: handle copy_thresh allocation failure
Kohei Enju <[email protected]>
net: ena: return 0 in ena_get_rxfh_key_size() when RSS hash key is not configurable
Kohei Enju <[email protected]>
nfp: fix RSS hash key size when RSS is not supported
Erick Karanja <[email protected]>
mtd: rawnand: atmel: Fix error handling path in atmel_nand_controller_add_nands
Donet Tom <[email protected]>
drivers/base/node: fix double free in register_one_node()
Dan Carpenter <[email protected]>
ocfs2: fix double free in user_cluster_connect()
Nishanth Menon <[email protected]>
hwrng: ks-sa - fix division by zero in ks_sa_rng_init
Luiz Augusto von Dentz <[email protected]>
Bluetooth: hci_sync: Fix using random address for BIG/PA advertisements
Pauli Virtanen <[email protected]>
Bluetooth: ISO: don't leak skb in ISO_CONT RX
Luiz Augusto von Dentz <[email protected]>
Bluetooth: ISO: Fix possible UAF on iso_conn_free
Luiz Augusto von Dentz <[email protected]>
Bluetooth: MGMT: Fix not exposing debug UUID on MGMT_OP_READ_EXP_FEATURES_INFO
Michael S. Tsirkin <[email protected]>
vhost: vringh: Fix copy_to_iter return value check
I Viswanath <[email protected]>
net: usb: Remove disruptive netif_wake_queue in rtl8150_set_multicast
Bernard Metzler <[email protected]>
RDMA/siw: Always report immediate post SQ errors
Cristian Ciocaltea <[email protected]>
usb: vhci-hcd: Prevent suspending virtually attached devices
Ranjan Kumar <[email protected]>
scsi: mpt3sas: Fix crash in transport port remove by using ioc_info()
Slavin Liu <[email protected]>
ipvs: Defer ip_vs_ftp unregister during netns cleanup
Anthony Iliopoulos <[email protected]>
NFSv4.1: fix backchannel max_resp_sz verification check
Leo Yan <[email protected]>
coresight: trbe: Return NULL pointer for allocation failures
Yuanfang Zhang <[email protected]>
coresight-etm4x: Conditionally access register TRCEXTINSELR
Stephan Gerhold <[email protected]>
remoteproc: qcom: q6v5: Avoid disabling handover IRQ twice
Nagarjuna Kristam <[email protected]>
PCI: tegra194: Fix duplicate PLL disable in pex_ep_event_pex_rst_assert()
Fedor Pchelkin <[email protected]>
wifi: rtw89: avoid circular locking dependency in ser_state_run()
Chenghai Huang <[email protected]>
crypto: hisilicon/qm - set NULL to qm->debug.qm_diff_regs
Michael Karcher <[email protected]>
sparc: fix accurate exception reporting in copy_{from,to}_user for M7
Michael Karcher <[email protected]>
sparc: fix accurate exception reporting in copy_to_user for Niagara 4
Michael Karcher <[email protected]>
sparc: fix accurate exception reporting in copy_{from_to}_user for Niagara
Michael Karcher <[email protected]>
sparc: fix accurate exception reporting in copy_{from_to}_user for UltraSPARC III
Michael Karcher <[email protected]>
sparc: fix accurate exception reporting in copy_{from_to}_user for UltraSPARC
Aditya Kumar Singh <[email protected]>
wifi: mac80211: fix Rx packet handling when pubsta information is not available
Baochen Qiang <[email protected]>
wifi: ath10k: avoid unnecessary wait for service ready message
Bagas Sanjaya <[email protected]>
Documentation: trace: historgram-design: Separate sched_waking histogram section heading and the following diagram
Vlad Dumitrescu <[email protected]>
IB/sa: Fix sa_local_svc_timeout_ms read race
Parav Pandit <[email protected]>
RDMA/core: Resolve MAC of next-hop device without ARP support
Michal Pecio <[email protected]>
Revert "usb: xhci: Avoid Stop Endpoint retry loop if the endpoint seems Running"
wangzijie <[email protected]>
f2fs: fix zero-sized extent for precache extents
Qianfeng Rong <[email protected]>
scsi: qla2xxx: Fix incorrect sign of error code in START_SP_W_RETRIES()
Qianfeng Rong <[email protected]>
scsi: qla2xxx: edif: Fix incorrect sign of error code
Colin Ian King <[email protected]>
ACPI: NFIT: Fix incorrect ndr_desc being reportedin dev_err message
Abdun Nihaal <[email protected]>
wifi: mt76: fix potential memory leak in mt76_wmac_probe()
Håkon Bugge <[email protected]>
RDMA/cm: Rate limit destroy CM ID timeout error message
Donet Tom <[email protected]>
drivers/base/node: handle error properly in register_one_node()
Christophe Leroy <[email protected]>
watchdog: mpc8xxx_wdt: Reload the watchdog timer when enabling the watchdog
Zhen Ni <[email protected]>
netfilter: ipset: Remove unused htable_bits in macro ahash_region
Hans de Goede <[email protected]>
iio: consumers: Fix offset handling in iio_convert_raw_to_processed()
Vitaly Grigoryev <[email protected]>
fs: ntfs3: Fix integer overflow in run_unpack()
Qianfeng Rong <[email protected]>
drm/msm/dpu: fix incorrect type for ret
Takashi Iwai <[email protected]>
ASoC: Intel: bytcr_rt5651: Fix invalid quirk input mapping
Takashi Iwai <[email protected]>
ASoC: Intel: bytcr_rt5640: Fix invalid quirk input mapping
Takashi Iwai <[email protected]>
ASoC: Intel: bytcht_es8316: Fix invalid quirk input mapping
Wang Liang <[email protected]>
pps: fix warning in pps_register_cdev when register device fail
Colin Ian King <[email protected]>
misc: genwqe: Fix incorrect cmd field being reported in error
William Wu <[email protected]>
usb: gadget: configfs: Correctly set use_os_string at bind
Xichao Zhao <[email protected]>
usb: phy: twl6030: Fix incorrect type for ret
Qianfeng Rong <[email protected]>
drm/amdkfd: Fix error code sign for EINVAL in svm_ioctl()
Eric Dumazet <[email protected]>
tcp: fix __tcp_close() to only send RST when required
Alok Tiwari <[email protected]>
PCI: tegra: Fix devm_kcalloc() argument order for port->phys allocation
Stefan Kerkmann <[email protected]>
wifi: mwifiex: send world regulatory domain to driver
Timur Kristóf <[email protected]>
drm/amd/pm: Disable SCLK switching on Oland with high pixel clocks (v3)
Timur Kristóf <[email protected]>
drm/amd/pm: Disable MCLK switching with non-DC at 120 Hz+ (v2)
Timur Kristóf <[email protected]>
drm/amd/pm: Treat zero vblank time as too short in si_dpm (v3)
Timur Kristóf <[email protected]>
drm/amd/pm: Adjust si_upload_smc_data register programming (v3)
Timur Kristóf <[email protected]>
drm/amd/pm: Fix si_upload_smc_data (v3)
Timur Kristóf <[email protected]>
drm/amd/pm: Disable ULV even if unsupported (v3)
Timur Kristóf <[email protected]>
drm/amdgpu: Power up UVD 3 for FW validation (v2)
Chenghai Huang <[email protected]>
crypto: hisilicon - re-enable address prefetch after device resuming
Chenghai Huang <[email protected]>
crypto: hisilicon/zip - remove unnecessary validation for high-performance mode configurations
Arnd Bergmann <[email protected]>
media: st-delta: avoid excessive stack usage
Qianfeng Rong <[email protected]>
ALSA: lx_core: use int type to store negative error codes
Zhang Shurong <[email protected]>
media: rj54n1cb0c: Fix memleak in rj54n1_probe()
Thomas Fourier <[email protected]>
scsi: myrs: Fix dma_alloc_coherent() error check
Niklas Cassel <[email protected]>
scsi: pm80xx: Fix array-index-out-of-of-bounds on rmmod
Arnd Bergmann <[email protected]>
hwrng: nomadik - add ARM_AMBA dependency
Liao Yuanhong <[email protected]>
drm/amd/display: Remove redundant semicolons
Dan Carpenter <[email protected]>
serial: max310x: Add error checking in probe()
Dan Carpenter <[email protected]>
usb: host: max3421-hcd: Fix error pointer dereference in probe cleanup
Brahmajit Das <[email protected]>
drm/radeon/r600_cs: clean up of dead code in r600_cs
Brigham Campbell <[email protected]>
drm/panel: novatek-nt35560: Fix invalid return value
Daniel Borkmann <[email protected]>
bpf: Enforce expected_attach_type for tailcall compatibility
Kunihiko Hayashi <[email protected]>
i2c: designware: Add disabling clocks when probe fails
Leilk.Liu <[email protected]>
i2c: mediatek: fix potential incorrect use of I2C_MASTER_WRRD
Dmitry Baryshkov <[email protected]>
thermal/drivers/qcom/lmh: Add missing IRQ includes
Dmitry Baryshkov <[email protected]>
thermal/drivers/qcom: Make LMH select QCOM_SCM
Vadim Pasternak <[email protected]>
hwmon: (mlxreg-fan) Separate methods of fan setting coming from different subsystems
Zhouyi Zhou <[email protected]>
tools/nolibc: make time_t robust if __kernel_old_time_t is missing in host headers
Rafael J. Wysocki <[email protected]>
smp: Fix up and expand the smp_call_function_many() kerneldoc
Paul Chaignon <[email protected]>
bpf: Explicitly check accesses to bpf_sock_addr
Akhilesh Patil <[email protected]>
selftests: watchdog: skip ping loop if WDIOF_KEEPALIVEPING not supported
Stanley Chu <[email protected]>
i3c: master: svc: Recycle unused IBI slot
Stanley Chu <[email protected]>
i3c: master: svc: Use manual response for IBI events
Daniel Wagner <[email protected]>
nvmet-fc: move lsop put work to nvmet_fc_ls_req_op
Uwe Kleine-König <[email protected]>
pwm: tiehrpwm: Fix corner case in clock divisor calculation
AngeloGioacchino Del Regno <[email protected]>
arm64: dts: mediatek: mt8516-pumpkin: Fix machine compatible
Johan Hovold <[email protected]>
cpuidle: qcom-spm: fix device and OF node leaks at probe
Johan Hovold <[email protected]>
firmware: firmware: meson-sm: fix compile-test default
Eric Dumazet <[email protected]>
nbd: restrict sockets to TCP and UDP
Genjian Zhang <[email protected]>
null_blk: Fix the description of the cache_size module argument
Qianfeng Rong <[email protected]>
pinctrl: renesas: Use int type to store negative error codes
Andy Yan <[email protected]>
power: supply: cw2015: Fix a alignment coding style issue
Dan Carpenter <[email protected]>
PM / devfreq: mtk-cci: Fix potential error pointer dereference in probe()
Rafael J. Wysocki <[email protected]>
PM: sleep: core: Clear power.must_resume in noirq suspend error path
Qianfeng Rong <[email protected]>
block: use int to store blk_stack_limits() return value
Qianfeng Rong <[email protected]>
regulator: scmi: Use int type to store negative error codes
Nicolas Ferre <[email protected]>
ARM: at91: pm: fix MCKx restore routine
Li Nan <[email protected]>
blk-mq: check kobject state_in_sysfs before deleting in blk_mq_unregister_hctx
Da Xue <[email protected]>
pinctrl: meson-gxl: add missing i2c_d pinmux
Sneh Mankad <[email protected]>
soc: qcom: rpmh-rsc: Unconditionally clear _TRIGGER bit for TCS
Huisong Li <[email protected]>
ACPI: processor: idle: Fix memory leak when register cpuidle device failed
Florian Fainelli <[email protected]>
cpufreq: scmi: Account for malformed DT in scmi_dev_used_by_cpus()
Yureka Lilian <[email protected]>
libbpf: Fix reuse of DEVMAP
Tao Chen <[email protected]>
bpf: Remove migrate_disable in kprobe_multi_link_prog_run
Matt Bobrowski <[email protected]>
bpf/selftests: Fix test_tcpnotify_user
Geert Uytterhoeven <[email protected]>
regmap: Remove superfluous check for !config in __regmap_init()
Biju Das <[email protected]>
arm64: dts: renesas: rzg2lc-smarc: Disable CAN-FD channel0
Uros Bizjak <[email protected]>
x86/vdso: Fix output operand size of RDPID
Stefan Metzmacher <[email protected]>
smb: server: fix IRD/ORD negotiation with the client
Leo Yan <[email protected]>
perf: arm_spe: Prevent overflow in PERF_IDX2OFF()
Leo Yan <[email protected]>
coresight: trbe: Prevent overflow in PERF_IDX2OFF()
Bala-Vignesh-Reddy <[email protected]>
selftests: arm64: Check fread return value in exec_target
Johannes Nixdorf <[email protected]>
seccomp: Fix a race with WAIT_KILLABLE_RECV if the tracer replies too fast
Geert Uytterhoeven <[email protected]>
init: INITRAMFS_PRESERVE_MTIME should depend on BLK_DEV_INITRD
Jeff Layton <[email protected]>
filelock: add FL_RECLAIM to show_fl_flags() macro
Nalivayko Sergey <[email protected]>
net/9p: fix double req put in p9_fd_cancelled
Herbert Xu <[email protected]>
crypto: rng - Ensure set_ent is always present
Rafael J. Wysocki <[email protected]>
driver core/PM: Set power.no_callbacks along with power.no_pm
Ovidiu Panait <[email protected]>
staging: axis-fifo: flush RX FIFO on read errors
Ovidiu Panait <[email protected]>
staging: axis-fifo: fix TX handling on copy_from_user() failure
Ovidiu Panait <[email protected]>
staging: axis-fifo: fix maximum TX packet length check
Raphael Gallais-Pou <[email protected]>
serial: stm32: allow selecting console when the driver is module
Arnaud Lecomte <[email protected]>
hid: fix I2C read buffer overflow in raw_event() for mcp2221
Duy Nguyen <[email protected]>
can: rcar_canfd: Fix controller mode setting
Chen Yufeng <[email protected]>
can: hi311x: fix null pointer dereference when resuming from sleep before interface was enabled
David Sterba <[email protected]>
btrfs: ref-verify: handle damaged extent root tree
Jack Yu <[email protected]>
ASoC: rt5682s: Adjust SAR ADC button mode to fix noise issue
hupu <[email protected]>
perf subcmd: avoid crash in exclude_cmds when excludes is empty
Mikulas Patocka <[email protected]>
dm-integrity: limit MAX_TAG_SIZE to 255
Bitterblue Smith <[email protected]>
wifi: rtlwifi: rtl8192cu: Don't claim USB ID 07b8:8188
Xiaowei Li <[email protected]>
USB: serial: option: add SIMCom 8230C compositions
David Laight <[email protected]>
minmax.h: remove some #defines that are only expanded once
David Laight <[email protected]>
minmax.h: simplify the variants of clamp()
David Laight <[email protected]>
minmax.h: move all the clamp() definitions after the min/max() ones
David Laight <[email protected]>
minmax.h: use BUILD_BUG_ON_MSG() for the lo < hi test in clamp()
David Laight <[email protected]>
minmax.h: reduce the #define expansion of min(), max() and clamp()
David Laight <[email protected]>
minmax.h: update some comments
David Laight <[email protected]>
minmax.h: add whitespace around operators and after commas
Linus Torvalds <[email protected]>
minmax: fix up min3() and max3() too
Linus Torvalds <[email protected]>
minmax: improve macro expansion and type checking
Linus Torvalds <[email protected]>
minmax: simplify min()/max()/clamp() implementation
Linus Torvalds <[email protected]>
minmax: don't use max() in situations that want a C constant expression
Duoming Zhou <[email protected]>
media: i2c: tc358743: Fix use-after-free bugs caused by orphan timer in probe
Duoming Zhou <[email protected]>
media: tuner: xc5000: Fix use-after-free in xc5000_release
Ricardo Ribalda <[email protected]>
media: tunner: xc5000: Refactor firmware load
Will Deacon <[email protected]>
KVM: arm64: Fix softirq masking in FPSIMD register saving sequence
Srinivas Kandagatla <[email protected]>
ASoC: qcom: audioreach: fix potential null pointer dereference
Thadeu Lima de Souza Cascardo <[email protected]>
media: uvcvideo: Mark invalid entities with id UVC_INVALID_ENTITY_ID
Larshin Sergey <[email protected]>
media: rc: fix races with imon_disconnect()
Duoming Zhou <[email protected]>
media: b2c2: Fix use-after-free causing by irq_check_work in flexcop_pci_remove
Wang Haoran <[email protected]>
scsi: target: target_core_configfs: Add length check to avoid buffer overflow
Kees Cook <[email protected]>
gcc-plugins: Remove TODO_verify_il for GCC >= 16
Pierre Gondois <[email protected]>
arch_topology: Build cacheinfo from primary CPU
Pierre Gondois <[email protected]>
ACPI: PPTT: Update acpi_find_last_cache_level() to acpi_get_cache_info()
Pierre Gondois <[email protected]>
ACPI: PPTT: Remove acpi_find_cache_levels()
Pierre Gondois <[email protected]>
cacheinfo: Check 'cache-unified' property to count cache leaves
Pierre Gondois <[email protected]>
cacheinfo: Return error code in init_of_cache_level()
Pierre Gondois <[email protected]>
cacheinfo: Use RISC-V's init_cache_level() as generic OF implementation
Kenta Akagi <[email protected]>
selftests: mptcp: connect: fix build regression caused by backport
Breno Leitao <[email protected]>
crypto: sha256 - fix crash at kexec
-------------
Diffstat:
Documentation/trace/histogram-design.rst | 4 +- Makefile | 4 +- arch/arm/mach-at91/pm_suspend.S | 4 +- arch/arm64/boot/dts/mediatek/mt8516-pumpkin.dts | 2 +- arch/arm64/boot/dts/renesas/rzg2lc-smarc.dtsi | 5 +- arch/arm64/kernel/cacheinfo.c | 11 +- arch/arm64/kernel/fpsimd.c | 8 +- arch/riscv/kernel/cacheinfo.c | 42 ---- arch/sparc/lib/M7memcpy.S | 20 +- arch/sparc/lib/Memcpy_utils.S | 9 + arch/sparc/lib/NG4memcpy.S | 2 +- arch/sparc/lib/NGmemcpy.S | 29 ++- arch/sparc/lib/U1memcpy.S | 19 +- arch/sparc/lib/U3memcpy.S | 2 +- arch/x86/include/asm/segment.h | 8 +- block/blk-mq-sysfs.c | 6 +- block/blk-settings.c | 3 +- crypto/rng.c | 8 + drivers/acpi/nfit/core.c | 2 +- drivers/acpi/pptt.c | 93 ++++---- drivers/acpi/processor_idle.c | 3 + drivers/base/arch_topology.c | 12 +- drivers/base/cacheinfo.c | 168 ++++++++++++--- drivers/base/node.c | 4 + drivers/base/power/main.c | 14 +- drivers/base/regmap/regmap.c | 2 +- drivers/block/nbd.c | 8 + drivers/block/null_blk/main.c | 2 +- drivers/bus/fsl-mc/fsl-mc-bus.c | 3 + drivers/char/hw_random/Kconfig | 1 + drivers/char/hw_random/ks-sa-rng.c | 4 + drivers/cpufreq/scmi-cpufreq.c | 10 + drivers/cpuidle/cpuidle-qcom-spm.c | 7 +- drivers/crypto/hisilicon/debugfs.c | 1 + drivers/crypto/hisilicon/hpre/hpre_main.c | 3 +- drivers/crypto/hisilicon/qm.c | 3 - drivers/crypto/hisilicon/sec2/sec_main.c | 80 +++---- drivers/crypto/hisilicon/zip/zip_main.c | 17 +- drivers/devfreq/mtk-cci-devfreq.c | 3 +- drivers/firmware/meson/Kconfig | 2 +- drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c | 29 ++- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 2 +- .../display/dc/dml/dcn32/display_rq_dlg_calc_32.c | 1 - drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c | 7 + drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 92 +++++--- drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 2 +- .../gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c | 2 +- drivers/gpu/drm/panel/panel-novatek-nt35560.c | 2 +- drivers/gpu/drm/radeon/r600_cs.c | 4 +- drivers/hid/hid-mcp2221.c | 4 + drivers/hwmon/mlxreg-fan.c | 24 ++- drivers/hwtracing/coresight/coresight-etm4x-core.c | 11 +- drivers/hwtracing/coresight/coresight-etm4x.h | 2 + drivers/hwtracing/coresight/coresight-trbe.c | 9 +- drivers/i2c/busses/i2c-designware-platdrv.c | 1 + drivers/i2c/busses/i2c-mt65xx.c | 17 +- drivers/i3c/master/svc-i3c-master.c | 31 ++- drivers/iio/inkern.c | 2 +- drivers/infiniband/core/addr.c | 10 +- drivers/infiniband/core/cm.c | 4 +- drivers/infiniband/core/sa_query.c | 6 +- drivers/infiniband/sw/siw/siw_verbs.c | 25 ++- drivers/input/misc/uinput.c | 1 + drivers/input/touchscreen/atmel_mxt_ts.c | 2 +- drivers/input/touchscreen/cyttsp4_core.c | 2 +- drivers/irqchip/irq-sun6i-r.c | 2 +- drivers/md/dm-core.h | 1 + drivers/md/dm-integrity.c | 4 +- drivers/md/dm.c | 13 +- drivers/media/i2c/rj54n1cb0c.c | 9 +- drivers/media/i2c/tc358743.c | 4 +- drivers/media/pci/b2c2/flexcop-pci.c | 2 +- .../media/platform/st/sti/delta/delta-mjpeg-dec.c | 20 +- drivers/media/rc/imon.c | 27 ++- drivers/media/tuners/xc5000.c | 41 ++-- drivers/media/usb/uvc/uvc_driver.c | 73 ++++--- drivers/media/usb/uvc/uvcvideo.h | 2 + drivers/mfd/vexpress-sysreg.c | 6 +- drivers/misc/fastrpc.c | 62 ++++-- drivers/misc/genwqe/card_ddcb.c | 2 +- drivers/mtd/nand/raw/atmel/nand-controller.c | 4 +- drivers/net/can/rcar/rcar_canfd.c | 7 +- drivers/net/can/spi/hi311x.c | 33 +-- drivers/net/ethernet/amazon/ena/ena_ethtool.c | 5 +- drivers/net/ethernet/dlink/dl2k.c | 7 +- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 6 +- .../ethernet/mellanox/mlx5/core/en/port_buffer.h | 12 -- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 17 +- drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c | 24 +++ .../net/ethernet/mellanox/mlx5/core/pagealloc.c | 7 +- .../net/ethernet/netronome/nfp/nfp_net_ethtool.c | 2 +- drivers/net/usb/asix_devices.c | 29 +++ drivers/net/usb/rtl8150.c | 2 - drivers/net/wireless/ath/ath10k/wmi.c | 39 ++-- drivers/net/wireless/marvell/mwifiex/cfg80211.c | 7 +- drivers/net/wireless/mediatek/mt76/mt7603/soc.c | 2 +- .../net/wireless/realtek/rtlwifi/rtl8192cu/sw.c | 1 - drivers/net/wireless/realtek/rtw89/ser.c | 3 +- drivers/nvme/target/fc.c | 19 +- drivers/pci/controller/dwc/pcie-tegra194.c | 4 +- drivers/pci/controller/pci-tegra.c | 2 +- drivers/perf/arm_spe_pmu.c | 3 +- drivers/pinctrl/meson/pinctrl-meson-gxl.c | 10 + drivers/pinctrl/pinmux.c | 2 +- drivers/pinctrl/renesas/pinctrl.c | 3 +- drivers/power/supply/cw2015_battery.c | 3 +- drivers/pps/kapi.c | 5 +- drivers/pps/pps.c | 5 +- drivers/pwm/pwm-tiehrpwm.c | 4 +- drivers/regulator/scmi-regulator.c | 3 +- drivers/remoteproc/qcom_q6v5.c | 3 - drivers/scsi/mpt3sas/mpt3sas_transport.c | 8 +- drivers/scsi/myrs.c | 8 +- drivers/scsi/pm8001/pm8001_sas.c | 9 +- drivers/scsi/qla2xxx/qla_edif.c | 4 +- drivers/scsi/qla2xxx/qla_init.c | 4 +- drivers/soc/qcom/rpmh-rsc.c | 7 +- drivers/staging/axis-fifo/axis-fifo.c | 68 +++--- drivers/target/target_core_configfs.c | 2 +- drivers/thermal/qcom/Kconfig | 3 +- drivers/thermal/qcom/lmh.c | 2 + drivers/tty/serial/Kconfig | 2 +- drivers/tty/serial/max310x.c | 2 + drivers/uio/uio_hv_generic.c | 7 +- drivers/usb/cdns3/cdnsp-pci.c | 5 +- drivers/usb/gadget/configfs.c | 2 + drivers/usb/host/max3421-hcd.c | 2 +- drivers/usb/host/xhci-ring.c | 11 +- drivers/usb/phy/phy-twl6030-usb.c | 3 +- drivers/usb/serial/option.c | 6 + drivers/usb/typec/tipd/core.c | 24 +-- drivers/usb/usbip/vhci_hcd.c | 22 ++ drivers/vhost/vringh.c | 14 +- drivers/watchdog/mpc8xxx_wdt.c | 2 + fs/btrfs/ref-verify.c | 9 +- fs/btrfs/tree-checker.c | 2 +- fs/ext4/ext4.h | 10 + fs/ext4/file.c | 2 +- fs/ext4/inode.c | 2 +- fs/ext4/orphan.c | 6 +- fs/ext4/super.c | 4 +- fs/f2fs/data.c | 7 +- fs/nfs/nfs4proc.c | 2 +- fs/ntfs3/run.c | 12 +- fs/ocfs2/stack_user.c | 1 + fs/smb/server/smb2pdu.c | 3 +- fs/smb/server/transport_rdma.c | 97 +++++++-- fs/squashfs/inode.c | 7 + fs/squashfs/squashfs_fs_i.h | 2 +- fs/udf/inode.c | 3 + include/crypto/sha256_base.h | 2 +- include/linux/bpf.h | 1 + include/linux/cacheinfo.h | 11 +- include/linux/compiler.h | 9 + include/linux/device.h | 3 + include/linux/minmax.h | 236 ++++++++++++--------- include/trace/events/filelock.h | 3 +- init/Kconfig | 1 + kernel/bpf/core.c | 5 + kernel/seccomp.c | 12 +- kernel/smp.c | 11 +- kernel/trace/bpf_trace.c | 9 +- lib/vsprintf.c | 2 +- mm/hugetlb.c | 2 + net/9p/trans_fd.c | 8 +- net/bluetooth/hci_sync.c | 10 +- net/bluetooth/iso.c | 9 +- net/bluetooth/mgmt.c | 10 +- net/core/filter.c | 16 +- net/ipv4/tcp.c | 9 +- net/mac80211/rx.c | 28 ++- net/netfilter/ipset/ip_set_hash_gen.h | 8 +- net/netfilter/ipvs/ip_vs_ftp.c | 4 +- net/nfc/nci/ntf.c | 135 ++++++++---- scripts/gcc-plugins/gcc-common.h | 7 + sound/pci/lx6464es/lx_core.c | 4 +- sound/soc/codecs/rt5682s.c | 17 +- sound/soc/intel/boards/bytcht_es8316.c | 20 +- sound/soc/intel/boards/bytcr_rt5640.c | 7 +- sound/soc/intel/boards/bytcr_rt5651.c | 26 ++- sound/soc/qcom/qdsp6/topology.c | 4 +- tools/include/nolibc/std.h | 2 +- tools/lib/bpf/libbpf.c | 10 + tools/lib/subcmd/help.c | 3 + tools/testing/nvdimm/test/ndtest.c | 13 +- tools/testing/selftests/arm64/pauth/exec_target.c | 7 +- .../selftests/bpf/progs/test_tcpnotify_kern.c | 1 - tools/testing/selftests/bpf/test_tcpnotify_user.c | 20 +- tools/testing/selftests/net/mptcp/mptcp_connect.c | 2 +- tools/testing/selftests/watchdog/watchdog-test.c | 6 + 190 files changed, 1637 insertions(+), 903 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/196 crypto: sha256 - fix crash at kexec
6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
Loading a large (~2.1G) files with kexec crashes the host with when running:
# kexec --load kernel --initrd initrd_with_2G_or_more
UBSAN: signed-integer-overflow in ./include/crypto/sha256_base.h:64:19 34152083 * 64 cannot be represented in type 'int' ... BUG: unable to handle page fault for address: ff9fffff83b624c0 sha256_update (lib/crypto/sha256.c:137) crypto_sha256_update (crypto/sha256_generic.c:40) kexec_calculate_store_digests (kernel/kexec_file.c:769) __se_sys_kexec_file_load (kernel/kexec_file.c:397 kernel/kexec_file.c:332) ...
(Line numbers based on commit da274362a7bd9 ("Linux 6.12.49")
This started happening after commit f4da7afe07523f ("kexec_file: increase maximum file size to 4G") that landed in v6.0, which increased the file size for kexec.
This is not happening upstream (v6.16+), given that block type was upgraded from "int" to "size_t" in commit 74a43a2cf5e8 ("crypto:
lib/sha256 - Move partial block handling out")
Upgrade the block type similar to the commit above, avoiding hitting the overflow.
This patch is only suitable for the stable tree, and before 6.16, which got commit 74a43a2cf5e8 ("crypto: lib/sha256 - Move partial block handling out"). This is not required before f4da7afe07523f ("kexec_file:
increase maximum file size to 4G"). In other words, this fix is required between versions v6.0 and v6.16.
--- include/crypto/sha256_base.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/crypto/sha256_base.h +1 -1
@@ -46,7 +46,7 @@ static inline int sha256_base_do_update( sctx->count += len;if (unlikely ((partial + len) >=SHA256_BLOCK_SIZE )) { -int blocks; +unsigned int blocks;if (partial) {int p =SHA256_BLOCK_SIZE - partial;
Greg Kroah-Hartman
maintainerPATCH 2/196 selftests: mptcp: connect: fix build regression caused by backport
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kenta Akagi <[email protected]>
Since v6.1.154, mptcp selftests have failed to build with the following errors:
mptcp_connect.c: In function ‘main_loop_s’:
mptcp_connect.c:1040:59: error: ‘winfo’ undeclared (first use in this function)
1040 | err = copyfd_io(fd, remotesock, 1, true, &winfo);
| ^~~~~
mptcp_connect.c:1040:59: note: each undeclared identifier is reported only once for each function it appears in mptcp_connect.c:1040:23: error: too many arguments to function ‘copyfd_io’; expected 4, have 5
1040 | err = copyfd_io(fd, remotesock, 1, true, &winfo);
| ^~~~~~~~~ ~~~~~~
mptcp_connect.c:845:12: note: declared here
845 | static int copyfd_io(int infd, int peerfd, int outfd, bool close_peerfd)
| ^~~~~~~~~
This is caused by commit ff160500c499 ("selftests: mptcp: connect: catch IO errors on listen side"), a backport of upstream 14e22b43df25, which attempts to use the undeclared variable 'winfo' and passes too many arguments to copyfd_io(). Both the winfo variable and the updated copyfd_io() function were introduced in upstream
commit ca7ae8916043 ("selftests: mptcp: mptfo Initiator/Listener"), which is not present in v6.1.y.
The goal of the backport is to stop on errors from copyfd_io. Therefore, the backport does not depend on the changes in upstream commit ca7ae8916043 ("selftests: mptcp: mptfo Initiator/Listener").
This commit simply removes ', &winfo' to fix a build failure.
--- tools/testing/selftests/net/mptcp/mptcp_connect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/mptcp_connect.c +1 -1
@@ -1037,7 +1037,7 @@ again:SOCK_TEST_TCPULP (remotesock,0 ); - err =copyfd_io (fd, remotesock,1 , true, &winfo); + err =copyfd_io (fd, remotesock,1 , true); }else {perror ("accept" );return 1 ;
Greg Kroah-Hartman
maintainerPATCH 3/196 cacheinfo: Use RISC-Vs init_cache_level() as generic OF implementation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pierre Gondois <[email protected]>
commit c3719bd9eeb2edf84bd263d662e36ca0ba262a23 upstream.
RISC-V's implementation of init_of_cache_level() is following the Devicetree Specification v0.3 regarding caches, cf.:
- s3.7.3 'Internal (L1) Cache Properties'
- s3.8 'Multi-level and Shared Cache Nodes'
Allow reusing the implementation by moving it.
Also make 'levels', 'leaves' and 'level' unsigned int.
--- arch/riscv/kernel/cacheinfo.c | 39 ------------------------------------- drivers/base/cacheinfo.c | 44 ++++++++++++++++++++++++++++++++++++++++++ include/linux/cacheinfo.h | 1 3 files changed, 46 insertions(+), 38 deletions(-)
arch/riscv/kernel/cacheinfo.c +1 -38
@@ -115,44 +115,7 @@ static void fill_cacheinfo(struct cacheiint init_cache_level (unsigned int cpu) { -struct cpu_cacheinfo *this_cpu_ci =get_cpu_cacheinfo (cpu); -struct device_node *np =of_cpu_device_node_get (cpu); -struct device_node *prev =NULL ; -int levels =0 , leaves =0 , level; - -if (of_property_read_bool (np,"cache-size" )) - ++leaves; -if (of_property_read_bool (np,"i-cache-size" )) - ++leaves; -if (of_property_read_bool (np,"d-cache-size" )) - ++leaves; -if (leaves >0 ) - levels =1 ; - - prev = np; -while ((np =of_find_next_cache_node (np))) { -of_node_put (prev); - prev = np; -if (!of_device_is_compatible (np,"cache" )) -break ; -if (of_property_read_u32 (np,"cache-level" , &level)) -break ; -if (level <= levels) -break ; -if (of_property_read_bool (np,"cache-size" )) - ++leaves; -if (of_property_read_bool (np,"i-cache-size" )) - ++leaves; -if (of_property_read_bool (np,"d-cache-size" )) - ++leaves; - levels = level; - } - -of_node_put (np); - this_cpu_ci->num_levels = levels; - this_cpu_ci->num_leaves = leaves; - -return 0 ; +return init_of_cache_level (cpu); }int populate_cache_leaves (unsigned int cpu)
drivers/base/cacheinfo.c +44 -0
52 lines not on this page · raw message
include/linux/cacheinfo.h +1 -0
@@ -80,6 +80,7 @@ struct cpu_cacheinfo {struct cpu_cacheinfo *get_cpu_cacheinfo (unsigned int cpu);int init_cache_level (unsigned int cpu); +int init_of_cache_level (unsigned int cpu);int populate_cache_leaves (unsigned int cpu);int cache_setup_acpi (unsigned int cpu);bool last_level_cache_is_valid (unsigned int cpu);
Greg Kroah-Hartman
maintainerPATCH 4/196 cacheinfo: Return error code in init_of_cache_level()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pierre Gondois <[email protected]>
commit 8844c3df001bc1d8397fddea341308da63855d53 upstream.
Make init_of_cache_level() return an error code when the cache information parsing fails to help detecting missing information.
init_of_cache_level() is only called for riscv. Returning an error code instead of 0 will prevent detect_cache_attributes() to allocate memory if an incomplete DT is parsed.
--- drivers/base/cacheinfo.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/base/cacheinfo.c +7 -3
@@ -245,11 +245,11 @@ int init_of_cache_level(unsigned int cpuof_node_put (prev); prev = np;if (!of_device_is_compatible (np,"cache" )) -break ; + goto err_out;if (of_property_read_u32 (np,"cache-level" , &level)) -break ; + goto err_out;if (level <= levels) -break ; + goto err_out;if (of_property_read_bool (np,"cache-size" )) ++leaves;if (of_property_read_bool (np,"i-cache-size" ))
@@ -264,6 +264,10 @@ int init_of_cache_level(unsigned int cpu this_cpu_ci->num_leaves = leaves;return 0 ; + +err_out: +of_node_put (np); + return -EINVAL; }#else
Greg Kroah-Hartman
maintainerPATCH 5/196 cacheinfo: Check cache-unified property to count cache leaves
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pierre Gondois <[email protected]>
commit de0df442ee49cb1f6ee58f3fec5dcb5e5eb70aab upstream.
The DeviceTree Specification v0.3 specifies that the cache node '[d-|i-|]cache-size' property is required. The 'cache-unified' property is specifies whether the cache level is separate or unified.
If the cache-size property is missing, no cache leaves is accounted. This can lead to a 'BUG: KASAN: slab-out-of-bounds' [1] bug.
Check 'cache-unified' property and always account for at least one cache leaf when parsing the device tree.
[1] https://lore.kernel.org/all/[email protected]/
--- drivers/base/cacheinfo.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-)
drivers/base/cacheinfo.c +26 -11
@@ -224,12 +224,9 @@ static int cache_setup_of_node(unsignedreturn 0 ; } -int init_of_cache_level (unsigned int cpu) +static int of_count_cache_leaves (struct device_node *np) { -struct cpu_cacheinfo *this_cpu_ci =get_cpu_cacheinfo (cpu); -struct device_node *np =of_cpu_device_node_get (cpu); -struct device_node *prev =NULL ; -unsigned int levels =0 , leaves =0 , level; +unsigned int leaves =0 ;if (of_property_read_bool (np,"cache-size" )) ++leaves;
@@ -237,6 +234,28 @@ int init_of_cache_level(unsigned int cpu ++leaves;if (of_property_read_bool (np,"d-cache-size" )) ++leaves; + +if (!leaves) { +/* The '[i-|d-|]cache-size' property is required, but +* if absent, fallback on the 'cache-unified' property. +*/ +if (of_property_read_bool (np,"cache-unified" )) +return 1 ; +else +return 2 ; + } + +return leaves; +} + +int init_of_cache_level (unsigned int cpu) +{ +struct cpu_cacheinfo *this_cpu_ci =get_cpu_cacheinfo (cpu); +struct device_node *np =of_cpu_device_node_get (cpu); +struct device_node *prev =NULL ; +unsigned int levels =0 , leaves, level; + + leaves =of_count_cache_leaves (np);if (leaves >0 ) levels =1 ;
@@ -250,12 +269,8 @@ int init_of_cache_level(unsigned int cpu goto err_out;if (level <= levels) goto err_out; -if (of_property_read_bool (np,"cache-size" )) - ++leaves; -if (of_property_read_bool (np,"i-cache-size" )) - ++leaves; -if (of_property_read_bool (np,"d-cache-size" )) - ++leaves; + + leaves +=of_count_cache_leaves (np); levels = level; }
Greg Kroah-Hartman
maintainerPATCH 6/196 ACPI: PPTT: Remove acpi_find_cache_levels()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pierre Gondois <[email protected]>
commit fa4d566a605bc4cf32d69f16ef8cf9696635f75a upstream.
acpi_find_cache_levels() is used at a single place and is short enough to be merged into the calling function. The removal allows an easier renaming of the calling function in the next patch.
Also reorder the local variables in the 'reversed Christmas tree' order.
--- drivers/acpi/pptt.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-)
drivers/acpi/pptt.c +6 -15
@@ -286,19 +286,6 @@ static struct acpi_pptt_processor *acpi_return NULL ; } -static int acpi_find_cache_levels (struct acpi_table_header *table_hdr, -u32 acpi_cpu_id) -{ -int number_of_levels =0 ; -struct acpi_pptt_processor *cpu; - - cpu =acpi_find_processor_node (table_hdr, acpi_cpu_id); -if (cpu) - number_of_levels =acpi_count_levels (table_hdr, cpu); - -return number_of_levels; -} -static u8 acpi_cache_type (enum cache_type type) {switch (type) {
@@ -621,9 +608,10 @@ static int check_acpi_cpu_flag(unsigned*/ int acpi_find_last_cache_level (unsigned int cpu) { -u32 acpi_cpu_id; +struct acpi_pptt_processor *cpu_node;struct acpi_table_header *table;int number_of_levels =0 ; +u32 acpi_cpu_id; table =acpi_get_pptt ();if (!table)
@@ -632,7 +620,10 @@ int acpi_find_last_cache_level(unsignedpr_debug ("Cache Setup find last level CPU=%d\n" , cpu); acpi_cpu_id =get_acpi_id_for_cpu (cpu); - number_of_levels =acpi_find_cache_levels (table, acpi_cpu_id); + cpu_node =acpi_find_processor_node (table, acpi_cpu_id); +if (cpu_node) + number_of_levels =acpi_count_levels (table, cpu_node); +pr_debug ("Cache Setup find last level level=%d\n" , number_of_levels);return number_of_levels;
Greg Kroah-Hartman
maintainerPATCH 7/196 ACPI: PPTT: Update acpi_find_last_cache_level() to acpi_get_cache_info()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pierre Gondois <[email protected]>
commit bd500361a937c03a3da57178287ce543c8f3681b upstream.
acpi_find_last_cache_level() allows to find the last level of cache for a given CPU. The function is only called on arm64 ACPI based platforms to check for cache information that would be missing in the CLIDR_EL1 register.
To allow populating (struct cpu_cacheinfo).num_leaves by only parsing a PPTT, update acpi_find_last_cache_level() to get the 'split_levels', i.e. the number of cache levels being split in data/instruction caches.
It is assumed that there will not be data/instruction caches above a unified cache.
If a split level consist of one data cache and no instruction cache (or opposite), then the missing cache will still be populated by default with minimal cache information, and maximal cpumask (all non-existing caches have the same fw_token).
--- arch/arm64/kernel/cacheinfo.c | 11 +++--- drivers/acpi/pptt.c | 76 +++++++++++++++++++++++++++--------------- include/linux/cacheinfo.h | 9 +++- 3 files changed, 63 insertions(+), 33 deletions(-)
arch/arm64/kernel/cacheinfo.c +7 -4
@@ -46,7 +46,7 @@ static void ci_leaf_init(struct cacheinfint init_cache_level (unsigned int cpu) {unsigned int ctype, level, leaves; -int fw_level; +int fw_level, ret;struct cpu_cacheinfo *this_cpu_ci =get_cpu_cacheinfo (cpu);for (level =1 , leaves =0 ; level <=MAX_CACHE_LEVEL ; level++) {
@@ -59,10 +59,13 @@ int init_cache_level(unsigned int cpu) leaves += (ctype ==CACHE_TYPE_SEPARATE ) ?2 :1 ; } -if (acpi_disabled) +if (acpi_disabled) { fw_level =of_find_last_cache_level (cpu); -else - fw_level =acpi_find_last_cache_level (cpu); + }else { + ret =acpi_get_cache_info (cpu, &fw_level,NULL ); +if (ret <0 ) +return ret; + }if (fw_level <0 )return fw_level;
drivers/acpi/pptt.c +50 -26
157 lines not on this page · raw message
include/linux/cacheinfo.h +6 -3
@@ -88,19 +88,22 @@ bool last_level_cache_is_shared(unsignedint detect_cache_attributes (unsigned int cpu);#ifndef CONFIG_ACPI_PPTT /* -* acpi_find_last_cache_level is only called on ACPI enabled +* acpi_get_cache_info() is only called on ACPI enabled * platforms using the PPTT for topology. This means that if * the platform supports other firmware configuration methods * we need to stub out the call when ACPI is disabled. * ACPI enabled platforms not using PPTT won't be making calls * to this function so we need not worry about them. */ -static inline int acpi_find_last_cache_level (unsigned int cpu) +static inline +int acpi_get_cache_info (unsigned int cpu, +unsigned int *levels,unsigned int *split_levels) {return 0 ; }#else -int acpi_find_last_cache_level (unsigned int cpu); +int acpi_get_cache_info (unsigned int cpu, +unsigned int *levels,unsigned int *split_levels);#endif const struct attribute_group *cache_get_priv_group (struct cacheinfo *this_leaf);
Greg Kroah-Hartman
maintainerPATCH 8/196 arch_topology: Build cacheinfo from primary CPU
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pierre Gondois <[email protected]>
commit 5944ce092b97caed5d86d961e963b883b5c44ee2 upstream.
commit 3fcbf1c77d08 ("arch_topology: Fix cache attributes detection in the CPU hotplug path")
adds a call to detect_cache_attributes() to populate the cacheinfo before updating the siblings mask. detect_cache_attributes() allocates memory and can take the PPTT mutex (on ACPI platforms). On PREEMPT_RT kernels, on secondary CPUs, this triggers a:
'BUG: sleeping function called from invalid context' [1]
as the code is executed with preemption and interrupts disabled.
The primary CPU was previously storing the cache information using the now removed (struct cpu_topology).llc_id:
commit 5b8dc787ce4a ("arch_topology: Drop LLC identifier stash from the CPU topology")
allocate_cache_info() tries to build the cacheinfo from the primary CPU prior secondary CPUs boot, if the DT/ACPI description contains cache information.
If allocate_cache_info() fails, then fallback to the current state for the cacheinfo allocation. [1] will be triggered in such case.
When unplugging a CPU, the cacheinfo memory cannot be freed. If it was, then the memory would be allocated early by the re-plugged CPU and would trigger [1].
Note that populate_cache_leaves() might be called multiple times due to populate_leaves being moved up. This is required since detect_cache_attributes() might be called with per_cpu_cacheinfo(cpu) being allocated but not populated.
[1]:
| BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:46
| in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 0, name: swapper/111
| preempt_count: 1, expected: 0
| RCU nest depth: 1, expected: 1
| 3 locks held by swapper/111/0:
| #0: (&pcp->lock){+.+.}-{3:3}, at: get_page_from_freelist+0x218/0x12c8
| #1: (rcu_read_lock){....}-{1:3}, at: rt_spin_trylock+0x48/0xf0
| #2: (&zone->lock){+.+.}-{3:3}, at: rmqueue_bulk+0x64/0xa80
| irq event stamp: 0
| hardirqs last enabled at (0): 0x0
| hardirqs last disabled at (0): copy_process+0x5dc/0x1ab8
| softirqs last enabled at (0): copy_process+0x5dc/0x1ab8
| softirqs last disabled at (0): 0x0
| Preemption disabled at:
| migrate_enable+0x30/0x130
| CPU: 111 PID: 0 Comm: swapper/111 Tainted: G W 6.0.0-rc4-rt6-[...]
| Call trace:
| __kmalloc+0xbc/0x1e8
| detect_cache_attributes+0x2d4/0x5f0
| update_siblings_masks+0x30/0x368
| store_cpu_topology+0x78/0xb8
| secondary_start_kernel+0xd0/0x198
| __secondary_switched+0xb0/0xb4--- arch/riscv/kernel/cacheinfo.c | 5 -- drivers/base/arch_topology.c | 12 +++++-- drivers/base/cacheinfo.c | 71 +++++++++++++++++++++++++++++++----------- include/linux/cacheinfo.h | 1 4 files changed, 65 insertions(+), 24 deletions(-)
arch/riscv/kernel/cacheinfo.c +0 -5
@@ -113,11 +113,6 @@ static void fill_cacheinfo(struct cachei } } -int init_cache_level (unsigned int cpu) -{ -return init_of_cache_level (cpu); -} -int populate_cache_leaves (unsigned int cpu) {struct cpu_cacheinfo *this_cpu_ci =get_cpu_cacheinfo (cpu);
drivers/base/arch_topology.c +10 -2
@@ -736,7 +736,7 @@ void update_siblings_masks(unsigned int ret =detect_cache_attributes (cpuid);if (ret && ret != -ENOENT ) -pr_info ("Early cacheinfo failed, ret = %d\n" , ret); +pr_info ("Early cacheinfo allocation failed, ret = %d\n" , ret);/* update core and thread sibling masks */ for_each_online_cpu (cpu) {
@@ -825,7 +825,7 @@ __weak int __init parse_acpi_topology(vo#if defined(CONFIG_ARM64 ) || defined(CONFIG_RISCV )void __init init_cpu_topology (void ) { -int ret; +int cpu, ret;reset_cpu_topology (); ret =parse_acpi_topology ();
@@ -840,6 +840,14 @@ void __init init_cpu_topology(void)reset_cpu_topology ();return ; } + +for_each_possible_cpu (cpu) { + ret =fetch_cache_info (cpu); +if (ret) { +pr_err ("Early cacheinfo failed, ret = %d\n" , ret); +break ; + } + } }void store_cpu_topology (unsigned int cpuid)
drivers/base/cacheinfo.c +54 -17
100 lines not on this page · raw message
include/linux/cacheinfo.h +1 -0
@@ -85,6 +85,7 @@ int populate_cache_leaves(unsigned int cint cache_setup_acpi (unsigned int cpu);bool last_level_cache_is_valid (unsigned int cpu);bool last_level_cache_is_shared (unsigned int cpu_x,unsigned int cpu_y); +int fetch_cache_info (unsigned int cpu);int detect_cache_attributes (unsigned int cpu);#ifndef CONFIG_ACPI_PPTT /*
Greg Kroah-Hartman
maintainerPATCH 9/196 gcc-plugins: Remove TODO_verify_il for GCC >= 16
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
commit a40282dd3c484e6c882e93f4680e0a3ef3814453 upstream.
GCC now runs TODO_verify_il automatically[1], so it is no longer exposed to plugins. Only use the flag on GCC < 16.
--- scripts/gcc-plugins/gcc-common.h | 7 +++++++ 1 file changed, 7 insertions(+)
scripts/gcc-plugins/gcc-common.h +7 -0
@@ -196,10 +196,17 @@ inline bool is_a_helper<const gassign *> }#endif +#if BUILDING_GCC_VERSION <16000 #define TODO_verify_ssa TODO_verify_il#define TODO_verify_flow TODO_verify_il#define TODO_verify_stmts TODO_verify_il#define TODO_verify_rtl_sharing TODO_verify_il +#else +#define TODO_verify_ssa 0 +#define TODO_verify_flow 0 +#define TODO_verify_stmts 0 +#define TODO_verify_rtl_sharing 0 +#endif #define INSN_DELETED_P (insn) (insn)->deleted()
Greg Kroah-Hartman
maintainerPATCH 10/196 scsi: target: target_core_configfs: Add length check to avoid buffer overflow
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Haoran <[email protected]>
commit 27e06650a5eafe832a90fd2604f0c5e920857fae upstream.
A buffer overflow arises from the usage of snprintf to write into the buffer "buf" in target_lu_gp_members_show function located in /drivers/target/target_core_configfs.c. This buffer is allocated with size LU_GROUP_NAME_BUF (256 bytes).
snprintf(...) formats multiple strings into buf with the HBA name (hba->hba_group.cg_item), a slash character, a devicename (dev-> dev_group.cg_item) and a newline character, the total formatted string length may exceed the buffer size of 256 bytes.
Since snprintf() returns the total number of bytes that would have been written (the length of %s/%sn ), this value may exceed the buffer length (256 bytes) passed to memcpy(), this will ultimately cause function memcpy reporting a buffer overflow error.
An additional check of the return value of snprintf() can avoid this buffer overflow.
--- drivers/target/target_core_configfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/target/target_core_configfs.c +1 -1
@@ -2691,7 +2691,7 @@ static ssize_t target_lu_gp_members_show config_item_name(&dev->dev_group.cg_item)); cur_len++;/* Extra byte for NULL terminator */ -if ((cur_len + len) >PAGE_SIZE ) { +if ((cur_len + len) >PAGE_SIZE || cur_len >LU_GROUP_NAME_BUF ) {pr_warn ("Ran out of lu_gp_show_attr" "_members buffer\n" );break ;
Greg Kroah-Hartman
maintainerPATCH 11/196 media: b2c2: Fix use-after-free causing by irq_check_work in flexcop_pci_remove
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duoming Zhou <[email protected]>
commit 01e03fb7db419d39e18d6090d4873c1bff103914 upstream.
The original code uses cancel_delayed_work() in flexcop_pci_remove(), which does not guarantee that the delayed work item irq_check_work has fully completed if it was already running. This leads to use-after-free scenarios where flexcop_pci_remove() may free the flexcop_device while irq_check_work is still active and attempts to dereference the device.
A typical race condition is illustrated below:
CPU 0 (remove) | CPU 1 (delayed work callback)
flexcop_pci_remove() | flexcop_pci_irq_check_work()
cancel_delayed_work() |
flexcop_device_kfree(fc_pci->fc_dev) |
| fc = fc_pci->fc_dev; // UAFThis is confirmed by a KASAN report:
==================================================================
BUG: KASAN: slab-use-after-free in __run_timer_base.part.0+0x7d7/0x8c0 Write of size 8 at addr ffff8880093aa8c8 by task bash/135 ... Call Trace: <IRQ> dump_stack_lvl+0x55/0x70 print_report+0xcf/0x610 ? __run_timer_base.part.0+0x7d7/0x8c0 kasan_report+0xb8/0xf0 ? __run_timer_base.part.0+0x7d7/0x8c0 __run_timer_base.part.0+0x7d7/0x8c0 ? __pfx___run_timer_base.part.0+0x10/0x10 ? __pfx_read_tsc+0x10/0x10 ? ktime_get+0x60/0x140 ? lapic_next_event+0x11/0x20 ? clockevents_program_event+0x1d4/0x2a0 run_timer_softirq+0xd1/0x190 handle_softirqs+0x16a/0x550 irq_exit_rcu+0xaf/0xe0 sysvec_apic_timer_interrupt+0x70/0x80 </IRQ>
...
Allocated by task 1: kasan_save_stack+0x24/0x50 kasan_save_track+0x14/0x30 __kasan_kmalloc+0x7f/0x90 __kmalloc_noprof+0x1be/0x460 flexcop_device_kmalloc+0x54/0xe0 flexcop_pci_probe+0x1f/0x9d0 local_pci_probe+0xdc/0x190 pci_device_probe+0x2fe/0x470 really_probe+0x1ca/0x5c0 __driver_probe_device+0x248/0x310 driver_probe_device+0x44/0x120 __driver_attach+0xd2/0x310 bus_for_each_dev+0xed/0x170 bus_add_driver+0x208/0x500 driver_register+0x132/0x460 do_one_initcall+0x89/0x300 kernel_init_freeable+0x40d/0x720 kernel_init+0x1a/0x150 ret_from_fork+0x10c/0x1a0 ret_from_fork_asm+0x1a/0x30 Freed by task 135: kasan_save_stack+0x24/0x50 kasan_save_track+0x14/0x30 kasan_save_free_info+0x3a/0x60 __kasan_slab_free+0x3f/0x50 kfree+0x137/0x370 flexcop_device_kfree+0x32/0x50 pci_device_remove+0xa6/0x1d0 device_release_driver_internal+0xf8/0x210 pci_stop_bus_device+0x105/0x150 pci_stop_and_remove_bus_device_locked+0x15/0x30 remove_store+0xcc/0xe0 kernfs_fop_write_iter+0x2c3/0x440 vfs_write+0x871/0xd70 ksys_write+0xee/0x1c0 do_syscall_64+0xac/0x280 entry_SYSCALL_64_after_hwframe+0x77/0x7f
...
Replace cancel_delayed_work() with cancel_delayed_work_sync() to ensure that the delayed work item is properly canceled and any executing delayed work has finished before the device memory is deallocated.
This bug was initially identified through static analysis. To reproduce and test it, I simulated the B2C2 FlexCop PCI device in QEMU and introduced artificial delays within the flexcop_pci_irq_check_work() function to increase the likelihood of triggering the bug.
--- drivers/media/pci/b2c2/flexcop-pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/b2c2/flexcop-pci.c +1 -1
@@ -411,7 +411,7 @@ static void flexcop_pci_remove(struct pcstruct flexcop_pci *fc_pci =pci_get_drvdata (pdev);if (irq_chk_intv >0 ) -cancel_delayed_work (&fc_pci->irq_check_work); +cancel_delayed_work_sync (&fc_pci->irq_check_work);flexcop_pci_dma_exit (fc_pci);flexcop_device_exit (fc_pci->fc_dev);
Greg Kroah-Hartman
maintainerPATCH 12/196 media: rc: fix races with imon_disconnect()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Larshin Sergey <[email protected]>
commit fa0f61cc1d828178aa921475a9b786e7fbb65ccb upstream.
Syzbot reports a KASAN issue as below:
BUG: KASAN: use-after-free in __create_pipe include/linux/usb.h:1945 [inline] BUG: KASAN: use-after-free in send_packet+0xa2d/0xbc0 drivers/media/rc/imon.c:627 Read of size 4 at addr ffff8880256fb000 by task syz-executor314/4465 CPU: 2 PID: 4465 Comm: syz-executor314 Not tainted 6.0.0-rc1-syzkaller #0 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014 Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:317 [inline] print_report.cold+0x2ba/0x6e9 mm/kasan/report.c:433 kasan_report+0xb1/0x1e0 mm/kasan/report.c:495 __create_pipe include/linux/usb.h:1945 [inline] send_packet+0xa2d/0xbc0 drivers/media/rc/imon.c:627 vfd_write+0x2d9/0x550 drivers/media/rc/imon.c:991 vfs_write+0x2d7/0xdd0 fs/read_write.c:576 ksys_write+0x127/0x250 fs/read_write.c:631 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd
The iMON driver improperly releases the usb_device reference in imon_disconnect without coordinating with active users of the device.
Specifically, the fields usbdev_intf0 and usbdev_intf1 are not protected by the users counter (ictx->users). During probe, imon_init_intf0 or imon_init_intf1 increments the usb_device reference count depending on the interface. However, during disconnect, usb_put_dev is called unconditionally, regardless of actual usage.
As a result, if vfd_write or other operations are still in progress after disconnect, this can lead to a use-after-free of the usb_device pointer.
Thread 1 vfd_write Thread 2 imon_disconnect
...
if
usb_put_dev(ictx->usbdev_intf0)
else
usb_put_dev(ictx->usbdev_intf1)
...
while
send_packet
if
pipe = usb_sndintpipe(
ictx->usbdev_intf0) UAF
else
pipe = usb_sndctrlpipe(
ictx->usbdev_intf0, 0) UAFGuard access to usbdev_intf0 and usbdev_intf1 after disconnect by checking ictx->disconnected in all writer paths. Add early return with -ENODEV in send_packet(), vfd_write(), lcd_write() and display_open() if the device is no longer present.
Set and read ictx->disconnected under ictx->lock to ensure memory synchronization. Acquire the lock in imon_disconnect() before setting the flag to synchronize with any ongoing operations.
Ensure writers exit early and safely after disconnect before the USB core proceeds with cleanup.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- drivers/media/rc/imon.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-)
drivers/media/rc/imon.c +20 -7
@@ -536,7 +536,9 @@ static int display_open(struct inode *inmutex_lock (&ictx->lock); -if (!ictx->display_supported) { +if (ictx->disconnected) { + retval = -ENODEV ; + }else if (!ictx->display_supported) {pr_err ("display not supported by device\n" ); retval = -ENODEV ; }else if (ictx->display_isopen) {
@@ -598,6 +600,9 @@ static int send_packet(struct imon_conteint retval =0 ;struct usb_ctrlrequest *control_req =NULL ; +if (ictx->disconnected) +return -ENODEV ; +/* Check if we need to use control or interrupt urb */ if (!ictx->tx_control) { pipe = usb_sndintpipe(ictx->usbdev_intf0,
@@ -949,12 +954,14 @@ static ssize_t vfd_write(struct file *fistatic const unsigned char vfd_packet6[] = {0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0xFF ,0xFF }; -if (ictx->disconnected) -return -ENODEV ; -if (mutex_lock_interruptible (&ictx->lock))return -ERESTARTSYS ; +if (ictx->disconnected) { + retval = -ENODEV ; + goto exit; + } +if (!ictx->dev_present_intf0) {pr_err_ratelimited ("no iMON device present\n" ); retval = -ENODEV ;
@@ -1029,11 +1036,13 @@ static ssize_t lcd_write(struct file *fiint retval =0 ;struct imon_context *ictx = file->private_data; -if (ictx->disconnected) -return -ENODEV ; -mutex_lock (&ictx->lock); +if (ictx->disconnected) { + retval = -ENODEV ; + goto exit; + } +if (!ictx->display_supported) {pr_err_ratelimited ("no iMON display present\n" ); retval = -ENODEV ;
@@ -2499,7 +2508,11 @@ static void imon_disconnect(struct usb_iint ifnum; ictx =usb_get_intfdata (interface); + +mutex_lock (&ictx->lock); ictx->disconnected = true; +mutex_unlock (&ictx->lock); + dev = ictx->dev; ifnum = interface->cur_altsetting->desc.bInterfaceNumber;
Greg Kroah-Hartman
maintainerPATCH 13/196 media: uvcvideo: Mark invalid entities with id UVC_INVALID_ENTITY_ID
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thadeu Lima de Souza Cascardo <[email protected]>
commit 0e2ee70291e64a30fe36960c85294726d34a103e upstream.
Per UVC 1.1+ specification 3.7.2, units and terminals must have a non-zero unique ID.
``` Each Unit and Terminal within the video function is assigned a unique identification number, the Unit ID (UID) or Terminal ID (TID), contained in the bUnitID or bTerminalID field of the descriptor. The value 0x00 is reserved for undefined ID, ```
If we add a new entity with id 0 or a duplicated ID, it will be marked as UVC_INVALID_ENTITY_ID.
In a previous attempt commit 3dd075fe8ebb ("media: uvcvideo: Require entities to have a non-zero unique ID"), we ignored all the invalid units, this broke a lot of non-compatible cameras. Hopefully we are more lucky this time.
This also prevents some syzkaller reproducers from triggering warnings due to a chain of entities referring to themselves. In one particular case, an Output Unit is connected to an Input Unit, both with the same ID of 1. But when looking up for the source ID of the Output Unit, that same entity is found instead of the input entity, which leads to such warnings.
In another case, a backward chain was considered finished as the source ID was 0. Later on, that entity was found, but its pads were not valid.
Here is a sample stack trace for one of those cases.
[ 20.650953] usb 1-1: new high-speed USB device number 2 using dummy_hcd [ 20.830206] usb 1-1: Using ep0 maxpacket: 8 [ 20.833501] usb 1-1: config 0 descriptor?? [ 21.038518] usb 1-1: string descriptor 0 read error: -71 [ 21.038893] usb 1-1: Found UVC 0.00 device <unnamed> (2833:0201) [ 21.039299] uvcvideo 1-1:0.0: Entity type for entity Output 1 was not initialized! [ 21.041583] uvcvideo 1-1:0.0: Entity type for entity Input 1 was not initialized! [ 21.042218] ------------[ cut here ]------------ [ 21.042536] WARNING: CPU: 0 PID: 9 at drivers/media/mc/mc-entity.c:1147 media_create_pad_link+0x2c4/0x2e0 [ 21.043195] Modules linked in: [ 21.043535] CPU: 0 UID: 0 PID: 9 Comm: kworker/0:1 Not tainted 6.11.0-rc7-00030-g3480e43aeccf #444 [ 21.044101] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.15.0-1 04/01/2014 [ 21.044639] Workqueue: usb_hub_wq hub_event [ 21.045100] RIP: 0010:media_create_pad_link+0x2c4/0x2e0 [ 21.045508] Code: fe e8 20 01 00 00 b8 f4 ff ff ff 48 83 c4 30 5b 41 5c 41 5d 41 5e 41 5f 5d c3 cc cc cc cc 0f 0b eb e9 0f 0b eb 0a 0f 0b eb 06 <0f> 0b eb 02 0f 0b b8 ea ff ff ff eb d4 66 2e 0f 1f 84 00 00 00 00 [ 21.046801] RSP: 0018:ffffc9000004b318 EFLAGS: 00010246 [ 21.047227] RAX: ffff888004e5d458 RBX: 0000000000000000 RCX: ffffffff818fccf1 [ 21.047719] RDX: 000000000000007b RSI: 0000000000000000 RDI: ffff888004313290 [ 21.048241] RBP: ffff888004313290 R08: 0001ffffffffffff R09: 0000000000000000 [ 21.048701] R10: 0000000000000013 R11: 0001888004313290 R12: 0000000000000003 [ 21.049138] R13: ffff888004313080 R14: ffff888004313080 R15: 0000000000000000 [ 21.049648] FS: 0000000000000000(0000) GS:ffff88803ec00000(0000) knlGS:0000000000000000 [ 21.050271] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 21.050688] CR2: 0000592cc27635b0 CR3: 000000000431c000 CR4: 0000000000750ef0 [ 21.051136] PKRU: 55555554 [ 21.051331] Call Trace: [ 21.051480] <TASK> [ 21.051611] ? __warn+0xc4/0x210 [ 21.051861] ? media_create_pad_link+0x2c4/0x2e0 [ 21.052252] ? report_bug+0x11b/0x1a0 [ 21.052540] ? trace_hardirqs_on+0x31/0x40 [ 21.052901] ? handle_bug+0x3d/0x70 [ 21.053197] ? exc_invalid_op+0x1a/0x50 [ 21.053511] ? asm_exc_invalid_op+0x1a/0x20 [ 21.053924] ? media_create_pad_link+0x91/0x2e0 [ 21.054364] ? media_create_pad_link+0x2c4/0x2e0 [ 21.054834] ? media_create_pad_link+0x91/0x2e0 [ 21.055131] ? _raw_spin_unlock+0x1e/0x40 [ 21.055441] ? __v4l2_device_register_subdev+0x202/0x210 [ 21.055837] uvc_mc_register_entities+0x358/0x400 [ 21.056144] uvc_register_chains+0x1fd/0x290 [ 21.056413] uvc_probe+0x380e/0x3dc0 [ 21.056676] ? __lock_acquire+0x5aa/0x26e0 [ 21.056946] ? find_held_lock+0x33/0xa0 [ 21.057196] ? kernfs_activate+0x70/0x80 [ 21.057533] ? usb_match_dynamic_id+0x1b/0x70 [ 21.057811] ? find_held_lock+0x33/0xa0 [ 21.058047] ? usb_match_dynamic_id+0x55/0x70 [ 21.058330] ? lock_release+0x124/0x260 [ 21.058657] ? usb_match_one_id_intf+0xa2/0x100 [ 21.058997] usb_probe_interface+0x1ba/0x330 [ 21.059399] really_probe+0x1ba/0x4c0 [ 21.059662] __driver_probe_device+0xb2/0x180 [ 21.059944] driver_probe_device+0x5a/0x100 [ 21.060170] __device_attach_driver+0xe9/0x160 [ 21.060427] ? __pfx___device_attach_driver+0x10/0x10 [ 21.060872] bus_for_each_drv+0xa9/0x100 [ 21.061312] __device_attach+0xed/0x190 [ 21.061812] device_initial_probe+0xe/0x20 [ 21.062229] bus_probe_device+0x4d/0xd0 [ 21.062590] device_add+0x308/0x590 [ 21.062912] usb_set_configuration+0x7b6/0xaf0 [ 21.063403] usb_generic_driver_probe+0x36/0x80 [ 21.063714] usb_probe_device+0x7b/0x130 [ 21.063936] really_probe+0x1ba/0x4c0 [ 21.064111] __driver_probe_device+0xb2/0x180 [ 21.064577] driver_probe_device+0x5a/0x100 [ 21.065019] __device_attach_driver+0xe9/0x160 [ 21.065403] ? __pfx___device_attach_driver+0x10/0x10 [ 21.065820] bus_for_each_drv+0xa9/0x100 [ 21.066094] __device_attach+0xed/0x190 [ 21.066535] device_initial_probe+0xe/0x20 [ 21.066992] bus_probe_device+0x4d/0xd0 [ 21.067250] device_add+0x308/0x590 [ 21.067501] usb_new_device+0x347/0x610 [ 21.067817] hub_event+0x156b/0x1e30 [ 21.068060] ? process_scheduled_works+0x48b/0xaf0 [ 21.068337] process_scheduled_works+0x5a3/0xaf0 [ 21.068668] worker_thread+0x3cf/0x560 [ 21.068932] ? kthread+0x109/0x1b0 [ 21.069133] kthread+0x197/0x1b0 [ 21.069343] ? __pfx_worker_thread+0x10/0x10 [ 21.069598] ? __pfx_kthread+0x10/0x10 [ 21.069908] ret_from_fork+0x32/0x40 [ 21.070169] ? __pfx_kthread+0x10/0x10 [ 21.070424] ret_from_fork_asm+0x1a/0x30 [ 21.070737] </TASK>
--- drivers/media/usb/uvc/uvc_driver.c | 73 +++++++++++++++++++++++-------------- drivers/media/usb/uvc/uvcvideo.h | 2 + 2 files changed, 48 insertions(+), 27 deletions(-)
drivers/media/usb/uvc/uvc_driver.c +46 -27
@@ -134,6 +134,9 @@ struct uvc_entity *uvc_entity_by_id(stru {struct uvc_entity *entity; +if (id ==UVC_INVALID_ENTITY_ID ) +return NULL ; +list_for_each_entry (entity, &dev->entities, list) {if (entity->id == id)return entity;
@@ -757,14 +760,27 @@ static const u8 uvc_media_transport_inpuUVC_GUID_UVC_MEDIA_TRANSPORT_INPUT ;static const u8 uvc_processing_guid[16 ] =UVC_GUID_UVC_PROCESSING ; -static struct uvc_entity *uvc_alloc_entity (u16 type,u16 id, -unsigned int num_pads,unsigned int extra_size) +static struct uvc_entity *uvc_alloc_new_entity (struct uvc_device *dev,u16 type, +u16 id,unsigned int num_pads, +unsigned int extra_size) {struct uvc_entity *entity;unsigned int num_inputs;unsigned int size;unsigned int i; +/* Per UVC 1.1+ spec 3.7.2, the ID should be non-zero. */ +if (id ==0 ) { +dev_err (&dev->intf->dev,"Found Unit with invalid ID 0\n" ); + id =UVC_INVALID_ENTITY_ID ; + } + +/* Per UVC 1.1+ spec 3.7.2, the ID is unique. */ +if (uvc_entity_by_id (dev, id)) { +dev_err (&dev->intf->dev,"Found multiple Units with ID %u\n" , id); + id =UVC_INVALID_ENTITY_ID ; + } + extra_size =roundup (extra_size,sizeof (*entity->pads));if (num_pads) num_inputs = type &UVC_TERM_OUTPUT ? num_pads : num_pads -1 ;
@@ -774,7 +790,7 @@ static struct uvc_entity *uvc_alloc_enti + num_inputs; entity =kzalloc (size,GFP_KERNEL );if (entity ==NULL ) -return NULL ; +return ERR_PTR (-ENOMEM ); entity->id = id; entity->type = type;
@@ -865,10 +881,10 @@ static int uvc_parse_vendor_control(strubreak ; } - unit =uvc_alloc_entity (UVC_VC_EXTENSION_UNIT , buffer[3 ], - p +1 ,2 *n); -if (unit ==NULL ) -return -ENOMEM ; + unit =uvc_alloc_new_entity (dev,UVC_VC_EXTENSION_UNIT , + buffer[3 ], p +1 ,2 * n); +if (IS_ERR (unit)) +return PTR_ERR (unit);memcpy (unit->guid, &buffer[4 ],16 ); unit->extension.bNumControls = buffer[20 ];
@@ -978,10 +994,10 @@ static int uvc_parse_standard_control(streturn -EINVAL ; } - term =uvc_alloc_entity (type |UVC_TERM_INPUT , buffer[3 ], -1 , n + p); -if (term ==NULL ) -return -ENOMEM ; + term =uvc_alloc_new_entity (dev, type |UVC_TERM_INPUT , + buffer[3 ],1 , n + p); +if (IS_ERR (term)) +return PTR_ERR (term);if (UVC_ENTITY_TYPE (term) ==UVC_ITT_CAMERA ) { term->camera.bControlSize = n;
@@ -1038,10 +1054,10 @@ static int uvc_parse_standard_control(streturn 0 ; } - term =uvc_alloc_entity (type |UVC_TERM_OUTPUT , buffer[3 ], -1 ,0 ); -if (term ==NULL ) -return -ENOMEM ; + term =uvc_alloc_new_entity (dev, type |UVC_TERM_OUTPUT , + buffer[3 ],1 ,0 ); +if (IS_ERR (term)) +return PTR_ERR (term);memcpy (term->baSourceID, &buffer[7 ],1 );
@@ -1062,9 +1078,10 @@ static int uvc_parse_standard_control(streturn -EINVAL ; } - unit =uvc_alloc_entity (buffer[2 ], buffer[3 ], p +1 ,0 ); -if (unit ==NULL ) -return -ENOMEM ; + unit =uvc_alloc_new_entity (dev, buffer[2 ], buffer[3 ], + p +1 ,0 ); +if (IS_ERR (unit)) +return PTR_ERR (unit);memcpy (unit->baSourceID, &buffer[5 ], p);
@@ -1086,9 +1103,9 @@ static int uvc_parse_standard_control(streturn -EINVAL ; } - unit =uvc_alloc_entity (buffer[2 ], buffer[3 ],2 , n); -if (unit ==NULL ) -return -ENOMEM ; + unit =uvc_alloc_new_entity (dev, buffer[2 ], buffer[3 ],2 , n); +if (IS_ERR (unit)) +return PTR_ERR (unit);memcpy (unit->baSourceID, &buffer[4 ],1 ); unit->processing.wMaxMultiplier =
@@ -1117,9 +1134,10 @@ static int uvc_parse_standard_control(streturn -EINVAL ; } - unit =uvc_alloc_entity (buffer[2 ], buffer[3 ], p +1 , n); -if (unit ==NULL ) -return -ENOMEM ; + unit =uvc_alloc_new_entity (dev, buffer[2 ], buffer[3 ], + p +1 , n); +if (IS_ERR (unit)) +return PTR_ERR (unit);memcpy (unit->guid, &buffer[4 ],16 ); unit->extension.bNumControls = buffer[20 ];
@@ -1260,9 +1278,10 @@ static int uvc_gpio_parse(struct uvc_devreturn dev_err_probe (&dev->intf->dev, irq,"No IRQ for privacy GPIO\n" ); - unit =uvc_alloc_entity (UVC_EXT_GPIO_UNIT ,UVC_EXT_GPIO_UNIT_ID ,0 ,1 ); -if (!unit) -return -ENOMEM ; + unit =uvc_alloc_new_entity (dev,UVC_EXT_GPIO_UNIT , +UVC_EXT_GPIO_UNIT_ID ,0 ,1 ); +if (IS_ERR (unit)) +return PTR_ERR (unit); unit->gpio.gpio_privacy = gpio_privacy; unit->gpio.irq = irq;
drivers/media/usb/uvc/uvcvideo.h +2 -0
@@ -41,6 +41,8 @@#define UVC_EXT_GPIO_UNIT 0x7ffe#define UVC_EXT_GPIO_UNIT_ID 0x100 +#define UVC_INVALID_ENTITY_ID 0xffff +/* ------------------------------------------------------------------------ * Driver specific constants. */
Re: [PATCH 6.1 013/196] media: uvcvideo: Mark invalid entities with id UVC_INVALID_ENTITY_ID
Hi Greg,
Quoted 1 line · Greg KH
6.1-stable review patch. If anyone has any objections, please let me know.
This is causing a regression as reported in [1]. Ricardo is trying to get his hands on a device to try and develop a proper fix. In the meantime, can we avoid backporting this patch to any stable tree ?
[1] https://lore.kernel.org/r/CAOzBiVuS7ygUjjhCbyWg-KiNx+HFTYnqH5+GJhd6cYsNLT=DaA@mail.gmail.com
Quoted 306 lines
------------------
From: Thadeu Lima de Souza Cascardo <[email protected]>
commit
0e2ee70291e64a30fe36960c85294726d34a103eupstream.Per UVC 1.1+ specification 3.7.2, units and terminals must have a non-zero unique ID.
``` Each Unit and Terminal within the video function is assigned a unique identification number, the Unit ID (UID) or Terminal ID (TID), contained in the bUnitID or bTerminalID field of the descriptor. The value 0x00 is reserved for undefined ID, ```If we add a new entity with id 0 or a duplicated ID, it will be marked as
UVC_INVALID_ENTITY_ID.In a previous attempt commit
3dd075fe8ebb("media: uvcvideo: Require entities to have a non-zero unique ID"), we ignored all the invalid units, this broke a lot of non-compatible cameras. Hopefully we are more lucky this time.This also prevents some syzkaller reproducers from triggering warnings due to a chain of entities referring to themselves. In one particular case, an Output Unit is connected to an Input Unit, both with the same ID of 1. But when looking up for the source ID of the Output Unit, that same entity is found instead of the input entity, which leads to such warnings.
In another case, a backward chain was considered finished as the source ID was 0. Later on, that entity was found, but its pads were not valid.
Here is a sample stack trace for one of those cases.
[ 20.650953] usb 1-1: new high-speed USB device number 2 using dummy_hcd [ 20.830206] usb 1-1: Using ep0 maxpacket: 8 [ 20.833501] usb 1-1: config 0 descriptor?? [ 21.038518] usb 1-1: string descriptor 0 read error: -71 [ 21.038893] usb 1-1: Found UVC 0.00 device <unnamed> (2833:0201) [ 21.039299] uvcvideo 1-1:0.0: Entity type for entity Output 1 was not initialized! [ 21.041583] uvcvideo 1-1:0.0: Entity type for entity Input 1 was not initialized! [ 21.042218] ------------[ cut here ]------------ [ 21.042536] WARNING: CPU: 0 PID: 9 at drivers/media/mc/mc-entity.c:1147 media_create_pad_link+0x2c4/0x2e0 [ 21.043195] Modules linked in: [ 21.043535] CPU: 0 UID: 0 PID: 9 Comm: kworker/0:1 Not tainted 6.11.0-rc7-00030-g3480e43aeccf #444 [ 21.044101] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.15.0-1 04/01/2014 [ 21.044639] Workqueue: usb_hub_wq hub_event [ 21.045100] RIP: 0010:media_create_pad_link+0x2c4/0x2e0 [ 21.045508] Code: fe e8 20 01 00 00 b8 f4 ff ff ff 48 83 c4 30 5b 41 5c 41 5d 41 5e 41 5f 5d c3 cc cc cc cc 0f 0b eb e9 0f 0b eb 0a 0f 0b eb 06 <0f> 0b eb 02 0f 0b b8 ea ff ff ff eb d4 66 2e 0f 1f 84 00 00 00 00 [ 21.046801] RSP: 0018:ffffc9000004b318 EFLAGS: 00010246 [ 21.047227] RAX: ffff888004e5d458 RBX: 0000000000000000 RCX: ffffffff818fccf1 [ 21.047719] RDX: 000000000000007b RSI: 0000000000000000 RDI: ffff888004313290 [ 21.048241] RBP: ffff888004313290 R08: 0001ffffffffffff R09: 0000000000000000 [ 21.048701] R10: 0000000000000013 R11: 0001888004313290 R12: 0000000000000003 [ 21.049138] R13: ffff888004313080 R14: ffff888004313080 R15: 0000000000000000 [ 21.049648] FS: 0000000000000000(0000) GS:ffff88803ec00000(0000) knlGS:0000000000000000 [ 21.050271] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 21.050688] CR2: 0000592cc27635b0 CR3: 000000000431c000 CR4: 0000000000750ef0 [ 21.051136] PKRU: 55555554 [ 21.051331] Call Trace: [ 21.051480] <TASK> [ 21.051611] ? __warn+0xc4/0x210 [ 21.051861] ? media_create_pad_link+0x2c4/0x2e0 [ 21.052252] ? report_bug+0x11b/0x1a0 [ 21.052540] ? trace_hardirqs_on+0x31/0x40 [ 21.052901] ? handle_bug+0x3d/0x70 [ 21.053197] ? exc_invalid_op+0x1a/0x50 [ 21.053511] ? asm_exc_invalid_op+0x1a/0x20 [ 21.053924] ? media_create_pad_link+0x91/0x2e0 [ 21.054364] ? media_create_pad_link+0x2c4/0x2e0 [ 21.054834] ? media_create_pad_link+0x91/0x2e0 [ 21.055131] ? _raw_spin_unlock+0x1e/0x40 [ 21.055441] ? __v4l2_device_register_subdev+0x202/0x210 [ 21.055837] uvc_mc_register_entities+0x358/0x400 [ 21.056144] uvc_register_chains+0x1fd/0x290 [ 21.056413] uvc_probe+0x380e/0x3dc0 [ 21.056676] ? __lock_acquire+0x5aa/0x26e0 [ 21.056946] ? find_held_lock+0x33/0xa0 [ 21.057196] ? kernfs_activate+0x70/0x80 [ 21.057533] ? usb_match_dynamic_id+0x1b/0x70 [ 21.057811] ? find_held_lock+0x33/0xa0 [ 21.058047] ? usb_match_dynamic_id+0x55/0x70 [ 21.058330] ? lock_release+0x124/0x260 [ 21.058657] ? usb_match_one_id_intf+0xa2/0x100 [ 21.058997] usb_probe_interface+0x1ba/0x330 [ 21.059399] really_probe+0x1ba/0x4c0 [ 21.059662] __driver_probe_device+0xb2/0x180 [ 21.059944] driver_probe_device+0x5a/0x100 [ 21.060170] __device_attach_driver+0xe9/0x160 [ 21.060427] ? __pfx___device_attach_driver+0x10/0x10 [ 21.060872] bus_for_each_drv+0xa9/0x100 [ 21.061312] __device_attach+0xed/0x190 [ 21.061812] device_initial_probe+0xe/0x20 [ 21.062229] bus_probe_device+0x4d/0xd0 [ 21.062590] device_add+0x308/0x590 [ 21.062912] usb_set_configuration+0x7b6/0xaf0 [ 21.063403] usb_generic_driver_probe+0x36/0x80 [ 21.063714] usb_probe_device+0x7b/0x130 [ 21.063936] really_probe+0x1ba/0x4c0 [ 21.064111] __driver_probe_device+0xb2/0x180 [ 21.064577] driver_probe_device+0x5a/0x100 [ 21.065019] __device_attach_driver+0xe9/0x160 [ 21.065403] ? __pfx___device_attach_driver+0x10/0x10 [ 21.065820] bus_for_each_drv+0xa9/0x100 [ 21.066094] __device_attach+0xed/0x190 [ 21.066535] device_initial_probe+0xe/0x20 [ 21.066992] bus_probe_device+0x4d/0xd0 [ 21.067250] device_add+0x308/0x590 [ 21.067501] usb_new_device+0x347/0x610 [ 21.067817] hub_event+0x156b/0x1e30 [ 21.068060] ? process_scheduled_works+0x48b/0xaf0 [ 21.068337] process_scheduled_works+0x5a3/0xaf0 [ 21.068668] worker_thread+0x3cf/0x560 [ 21.068932] ? kthread+0x109/0x1b0 [ 21.069133] kthread+0x197/0x1b0 [ 21.069343] ? __pfx_worker_thread+0x10/0x10 [ 21.069598] ? __pfx_kthread+0x10/0x10 [ 21.069908] ret_from_fork+0x32/0x40 [ 21.070169] ? __pfx_kthread+0x10/0x10 [ 21.070424] ret_from_fork_asm+0x1a/0x30 [ 21.070737] </TASK>Reported-by [email protected]Reported-by [email protected]Reported-by Youngjun Lee <[email protected]>Fixes a3fbc2e6bb05 ("media: mc-entity.c: use WARN_ON, validate link pads")Signed-off-by Thadeu Lima de Souza Cascardo <[email protected]>Co-developed-by Ricardo Ribalda <[email protected]>Signed-off-by Ricardo Ribalda <[email protected]>Reviewed-by Laurent Pinchart <[email protected]>Reviewed-by Hans de Goede <[email protected]>Signed-off-by Hans de Goede <[email protected]>Signed-off-by Laurent Pinchart <[email protected]>Signed-off-by Hans Verkuil <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/media/usb/uvc/uvc_driver.c | 73 +++++++++++++++++++++++-------------- drivers/media/usb/uvc/uvcvideo.h | 2 + 2 files changed, 48 insertions(+), 27 deletions(-)drivers/media/usb/uvc/uvc_driver.c +46
-27@@ -134,6 +134,9 @@ struct uvc_entity *uvc_entity_by_id(stru {struct uvc_entity *entity; +if (id ==UVC_INVALID_ENTITY_ID ) +return NULL ; +list_for_each_entry (entity, &dev->entities, list) {if (entity->id == id)return entity;@@ -757,14 +760,27 @@ static const u8 uvc_media_transport_inpuUVC_GUID_UVC_MEDIA_TRANSPORT_INPUT ;static const u8 uvc_processing_guid[16 ] =UVC_GUID_UVC_PROCESSING ; -static struct uvc_entity *uvc_alloc_entity (u16 type,u16 id, -unsigned int num_pads,unsigned int extra_size) +static struct uvc_entity *uvc_alloc_new_entity (struct uvc_device *dev,u16 type, +u16 id,unsigned int num_pads, +unsigned int extra_size) {struct uvc_entity *entity;unsigned int num_inputs;unsigned int size;unsigned int i; +/* Per UVC 1.1+ spec 3.7.2, the ID should be non-zero. */ +if (id ==0 ) { +dev_err (&dev->intf->dev,"Found Unit with invalid ID 0\n" ); + id =UVC_INVALID_ENTITY_ID ; + } + +/* Per UVC 1.1+ spec 3.7.2, the ID is unique. */ +if (uvc_entity_by_id (dev, id)) { +dev_err (&dev->intf->dev,"Found multiple Units with ID %u\n" , id); + id =UVC_INVALID_ENTITY_ID ; + } + extra_size =roundup (extra_size,sizeof (*entity->pads));if (num_pads) num_inputs = type &UVC_TERM_OUTPUT ? num_pads : num_pads -1 ;@@ -774,7 +790,7 @@ static struct uvc_entity *uvc_alloc_enti + num_inputs; entity =kzalloc (size,GFP_KERNEL );if (entity ==NULL ) -return NULL ; +return ERR_PTR (-ENOMEM ); entity->id = id; entity->type = type;@@ -865,10 +881,10 @@ static int uvc_parse_vendor_control(strubreak ; } - unit =uvc_alloc_entity (UVC_VC_EXTENSION_UNIT , buffer[3 ], - p +1 ,2 *n); -if (unit ==NULL ) -return -ENOMEM ; + unit =uvc_alloc_new_entity (dev,UVC_VC_EXTENSION_UNIT , + buffer[3 ], p +1 ,2 * n); +if (IS_ERR (unit)) +return PTR_ERR (unit);memcpy (unit->guid, &buffer[4 ],16 ); unit->extension.bNumControls = buffer[20 ];@@ -978,10 +994,10 @@ static int uvc_parse_standard_control(streturn -EINVAL ; } - term =uvc_alloc_entity (type |UVC_TERM_INPUT , buffer[3 ], -1 , n + p); -if (term ==NULL ) -return -ENOMEM ; + term =uvc_alloc_new_entity (dev, type |UVC_TERM_INPUT , + buffer[3 ],1 , n + p); +if (IS_ERR (term)) +return PTR_ERR (term);if (UVC_ENTITY_TYPE (term) ==UVC_ITT_CAMERA ) { term->camera.bControlSize = n;@@ -1038,10 +1054,10 @@ static int uvc_parse_standard_control(streturn 0 ; } - term =uvc_alloc_entity (type |UVC_TERM_OUTPUT , buffer[3 ], -1 ,0 ); -if (term ==NULL ) -return -ENOMEM ; + term =uvc_alloc_new_entity (dev, type |UVC_TERM_OUTPUT , + buffer[3 ],1 ,0 ); +if (IS_ERR (term)) +return PTR_ERR (term);memcpy (term->baSourceID, &buffer[7 ],1 );@@ -1062,9 +1078,10 @@ static int uvc_parse_standard_control(streturn -EINVAL ; } - unit =uvc_alloc_entity (buffer[2 ], buffer[3 ], p +1 ,0 ); -if (unit ==NULL ) -return -ENOMEM ; + unit =uvc_alloc_new_entity (dev, buffer[2 ], buffer[3 ], + p +1 ,0 ); +if (IS_ERR (unit)) +return PTR_ERR (unit);memcpy (unit->baSourceID, &buffer[5 ], p);@@ -1086,9 +1103,9 @@ static int uvc_parse_standard_control(streturn -EINVAL ; } - unit =uvc_alloc_entity (buffer[2 ], buffer[3 ],2 , n); -if (unit ==NULL ) -return -ENOMEM ; + unit =uvc_alloc_new_entity (dev, buffer[2 ], buffer[3 ],2 , n); +if (IS_ERR (unit)) +return PTR_ERR (unit);memcpy (unit->baSourceID, &buffer[4 ],1 ); unit->processing.wMaxMultiplier =@@ -1117,9 +1134,10 @@ static int uvc_parse_standard_control(streturn -EINVAL ; } - unit =uvc_alloc_entity (buffer[2 ], buffer[3 ], p +1 , n); -if (unit ==NULL ) -return -ENOMEM ; + unit =uvc_alloc_new_entity (dev, buffer[2 ], buffer[3 ], + p +1 , n); +if (IS_ERR (unit)) +return PTR_ERR (unit);memcpy (unit->guid, &buffer[4 ],16 ); unit->extension.bNumControls = buffer[20 ];@@ -1260,9 +1278,10 @@ static int uvc_gpio_parse(struct uvc_devreturn dev_err_probe (&dev->intf->dev, irq,"No IRQ for privacy GPIO\n" ); - unit =uvc_alloc_entity (UVC_EXT_GPIO_UNIT ,UVC_EXT_GPIO_UNIT_ID ,0 ,1 ); -if (!unit) -return -ENOMEM ; + unit =uvc_alloc_new_entity (dev,UVC_EXT_GPIO_UNIT , +UVC_EXT_GPIO_UNIT_ID ,0 ,1 ); +if (IS_ERR (unit)) +return PTR_ERR (unit); unit->gpio.gpio_privacy = gpio_privacy; unit->gpio.irq = irq;drivers/media/usb/uvc/uvcvideo.h +2
-0@@ -41,6 +41,8 @@#define UVC_EXT_GPIO_UNIT 0x7ffe#define UVC_EXT_GPIO_UNIT_ID 0x100 +#define UVC_INVALID_ENTITY_ID 0xffff +/* ------------------------------------------------------------------------ * Driver specific constants. */
Signature · 3 lines
Regards, Laurent Pinchart
Greg Kroah-Hartman
maintainerRe: [PATCH 6.1 013/196] media: uvcvideo: Mark invalid entities with id UVC_INVALID_ENTITY_ID
Quoted 10 lines · Laurent Pinchart
Hi Greg,
Quoted 1 line · Greg KH
6.1-stable review patch. If anyone has any objections, please let me know.
This is causing a regression as reported in [1]. Ricardo is trying to get his hands on a device to try and develop a proper fix. In the meantime, can we avoid backporting this patch to any stable tree ?
[1] https://lore.kernel.org/r/CAOzBiVuS7ygUjjhCbyWg-KiNx+HFTYnqH5+GJhd6cYsNLT=DaA@mail.gmail.com
I can drop it from this queue, but it's already in the following kernel releases:
6.6.110 6.12.51 6.16.11 6.17.1 6.18-rc1
thanks,
greg k-h
Re: [PATCH 6.1 013/196] media: uvcvideo: Mark invalid entities with id UVC_INVALID_ENTITY_ID
Quoted 8 lines · Greg KH
Quoted 7 lines · Laurent Pinchart
Quoted 1 line · Greg KH
6.1-stable review patch. If anyone has any objections, please let me know.
This is causing a regression as reported in [1]. Ricardo is trying to get his hands on a device to try and develop a proper fix. In the meantime, can we avoid backporting this patch to any stable tree ?
Quoted 5 lines
Quoted 1 line
[1] https://lore.kernel.org/r/CAOzBiVuS7ygUjjhCbyWg-KiNx+HFTYnqH5+GJhd6cYsNLT=DaA@mail.gmail.com
I can drop it from this queue, but it's already in the following kernel releases:
6.6.110 6.12.51 6.16.11 6.17.1 6.18-rc1
Should we merge a revert as a fix for v6.18 and get it backported to stable trees, or can we revert in the stable trees directly ? It will take a couple of weeks to get hold of a device and develop a correct fix.
Signature · 3 lines
Regards, Laurent Pinchart
Greg Kroah-Hartman
maintainerRe: [PATCH 6.1 013/196] media: uvcvideo: Mark invalid entities with id UVC_INVALID_ENTITY_ID
Quoted 11 lines · Laurent Pinchart
Quoted 10 lines · Greg KH
Quoted 8 lines · Laurent Pinchart
Quoted 1 line · Greg KH
6.1-stable review patch. If anyone has any objections, please let me know.
This is causing a regression as reported in [1]. Ricardo is trying to get his hands on a device to try and develop a proper fix. In the meantime, can we avoid backporting this patch to any stable tree ?
[1] https://lore.kernel.org/r/CAOzBiVuS7ygUjjhCbyWg-KiNx+HFTYnqH5+GJhd6cYsNLT=DaA@mail.gmail.com
Quoted 8 lines
Quoted 3 lines
I can drop it from this queue, but it's already in the following kernel releases:
6.6.110 6.12.51 6.16.11 6.17.1 6.18-rc1Should we merge a revert as a fix for v6.18 and get it backported to stable trees, or can we revert in the stable trees directly ? It will take a couple of weeks to get hold of a device and develop a correct fix.
A revert now probably sounds best.
thanks,
greg k-h
Greg Kroah-Hartman
maintainerPATCH 14/196 ASoC: qcom: audioreach: fix potential null pointer dereference
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Kandagatla <[email protected]>
commit 8318e04ab2526b155773313b66a1542476ce1106 upstream.
It is possible that the topology parsing function audioreach_widget_load_module_common() could return NULL or an error pointer. Add missing NULL check so that we do not dereference it.
--- sound/soc/qcom/qdsp6/topology.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/qcom/qdsp6/topology.c +2 -2
@@ -504,8 +504,8 @@ static int audioreach_widget_load_modulereturn PTR_ERR (cont); mod =audioreach_parse_common_tokens (apm, cont, &tplg_w->priv, w); -if (IS_ERR (mod)) -return PTR_ERR (mod); +if (IS_ERR_OR_NULL (mod)) +return mod ?PTR_ERR (mod) : -ENODEV ; dobj = &w->dobj; dobj->private = mod;
Greg Kroah-Hartman
maintainerPATCH 15/196 KVM: arm64: Fix softirq masking in FPSIMD register saving sequence
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
Stable commit 8f4dc4e54eed ("KVM: arm64: Fix kernel BUG() due to bad backport of FPSIMD/SVE/SME fix") fixed a kernel BUG() caused by a bad backport of upstream commit fbc7e61195e2 ("KVM: arm64: Unconditionally save+flush host FPSIMD/SVE/SME state") by ensuring that softirqs are disabled/enabled across the fpsimd register save operation.
Unfortunately, although this fixes the original issue, it can now lead to deadlock when re-enabling softirqs causes pending softirqs to be handled with locks already held:
| BUG: spinlock recursion on CPU#7, CPU 3/KVM/57616 | lock: 0xffff3045ef850240, .magic: dead4ead, .owner: CPU 3/KVM/57616, .owner_cpu: 7 | CPU: 7 PID: 57616 Comm: CPU 3/KVM Tainted: G O 6.1.152 #1 | Hardware name: SoftIron SoftIron Platform Mainboard/SoftIron Platform Mainboard, BIOS 1.31 May 11 2023 | Call trace: | dump_backtrace+0xe4/0x110 | show_stack+0x20/0x30 | dump_stack_lvl+0x6c/0x88 | dump_stack+0x18/0x34 | spin_dump+0x98/0xac | do_raw_spin_lock+0x70/0x128 | _raw_spin_lock+0x18/0x28 | raw_spin_rq_lock_nested+0x18/0x28 | update_blocked_averages+0x70/0x550 | run_rebalance_domains+0x50/0x70 | handle_softirqs+0x198/0x328 | __do_softirq+0x1c/0x28 | ____do_softirq+0x18/0x28 | call_on_irq_stack+0x30/0x48 | do_softirq_own_stack+0x24/0x30 | do_softirq+0x74/0x90 | __local_bh_enable_ip+0x64/0x80 | fpsimd_save_and_flush_cpu_state+0x5c/0x68 | kvm_arch_vcpu_put_fp+0x4c/0x88 | kvm_arch_vcpu_put+0x28/0x88 | kvm_sched_out+0x38/0x58 | __schedule+0x55c/0x6c8 | schedule+0x60/0xa8
Take a tiny step towards the upstream fix in 9b19700e623f ("arm64:
fpsimd: Drop unneeded 'busy' flag") by additionally disabling hardirqs while saving the fpsimd registers.
--- arch/arm64/kernel/fpsimd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/arm64/kernel/fpsimd.c +6 -2
@@ -1848,13 +1848,17 @@ static void fpsimd_flush_cpu_state(void)*/ void fpsimd_save_and_flush_cpu_state (void ) { +unsigned long flags; +if (!system_supports_fpsimd ())return ;WARN_ON (preemptible ()); -get_cpu_fpsimd_context (); +local_irq_save (flags); +__get_cpu_fpsimd_context ();fpsimd_save ();fpsimd_flush_cpu_state (); -put_cpu_fpsimd_context (); +__put_cpu_fpsimd_context (); +local_irq_restore (flags); }#ifdef CONFIG_KERNEL_MODE_NEON
Greg Kroah-Hartman
maintainerPATCH 16/196 media: tunner: xc5000: Refactor firmware load
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Ribalda <[email protected]>
[ Upstream commit 8e1f5da59dd4a1966f859639860b803a7e8b8bfb ]
Make sure the firmware is released when we leavexc_load_fw_and_init_tuner()
This change makes smatch happy:drivers/media/tuners/xc5000.c:1213 xc_load_fw_and_init_tuner() warn: 'fw' from request_firmware() not released on lines: 1213.
Stable-dep-of: 40b7a19f321e ("media: tuner: xc5000: Fix use-after-free in xc5000_release")
--- drivers/media/tuners/xc5000.c | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-)
drivers/media/tuners/xc5000.c +18 -23
@@ -58,7 +58,7 @@ struct xc5000_priv {struct dvb_frontend *fe;struct delayed_work timer_sleep; -const struct firmware *firmware; +bool inited; };/* Misc Defines */
@@ -1110,23 +1110,19 @@ static int xc_load_fw_and_init_tuner(strif (!force &&xc5000_is_firmware_loaded (fe) ==0 )return 0 ; -if (!priv->firmware) { - ret =request_firmware (&fw, desired_fw->name, - priv->i2c_props.adap->dev.parent); -if (ret) { -pr_err ("xc5000: Upload failed. rc %d\n" , ret); -return ret; - } -dprintk (1 ,"firmware read %zu bytes.\n" , fw->size); - -if (fw->size != desired_fw->size) { -pr_err ("xc5000: Firmware file with incorrect size\n" ); -release_firmware (fw); -return -EINVAL ; - } - priv->firmware = fw; - }else - fw = priv->firmware; + ret =request_firmware (&fw, desired_fw->name, + priv->i2c_props.adap->dev.parent); +if (ret) { +pr_err ("xc5000: Upload failed. rc %d\n" , ret); +return ret; + } +dprintk (1 ,"firmware read %zu bytes.\n" , fw->size); + +if (fw->size != desired_fw->size) { +pr_err ("xc5000: Firmware file with incorrect size\n" ); +release_firmware (fw); +return -EINVAL ; + }/* Try up to 5 times to load firmware */ for (i =0 ; i <5 ; i++) {
@@ -1204,6 +1200,7 @@ static int xc_load_fw_and_init_tuner(str } err: +release_firmware (fw);if (!ret)printk (KERN_INFO "xc5000: Firmware %s loaded and running.\n" , desired_fw->name);
@@ -1274,7 +1271,7 @@ static int xc5000_resume(struct dvb_fron/* suspended before firmware is loaded. Avoid firmware load in resume path. */ -if (!priv->firmware) +if (!priv->inited)return 0 ;return xc5000_set_params (fe);
@@ -1293,6 +1290,8 @@ static int xc5000_init(struct dvb_fronteif (debug)xc_debug_dump (priv); + priv->inited = true; +return 0 ; }
@@ -1306,10 +1305,6 @@ static void xc5000_release(struct dvb_frif (priv) {cancel_delayed_work (&priv->timer_sleep); -if (priv->firmware) { -release_firmware (priv->firmware); - priv->firmware =NULL ; - }hybrid_tuner_release_state (priv); }
Greg Kroah-Hartman
maintainerPATCH 17/196 media: tuner: xc5000: Fix use-after-free in xc5000_release
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duoming Zhou <[email protected]>
[ Upstream commit 40b7a19f321e65789612ebaca966472055dab48c ]
The original code uses cancel_delayed_work() in xc5000_release(), which does not guarantee that the delayed work item timer_sleep has fully completed if it was already running. This leads to use-after-free scenarios where xc5000_release() may free the xc5000_priv while timer_sleep is still active and attempts to dereference the xc5000_priv.
A typical race condition is illustrated below:
CPU 0 (release thread) | CPU 1 (delayed work callback)
xc5000_release() | xc5000_do_timer_sleep()
cancel_delayed_work() |
hybrid_tuner_release_state(priv) |
kfree(priv) |
| priv = container_of() // UAFReplace cancel_delayed_work() with cancel_delayed_work_sync() to ensure that the timer_sleep is properly canceled before the xc5000_priv memory is deallocated.
A deadlock concern was considered: xc5000_release() is called in a process context and is not holding any locks that the timer_sleep work item might also need. Therefore, the use of the _sync() variant is safe here.
This bug was initially identified through static analysis.
--- drivers/media/tuners/xc5000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/tuners/xc5000.c +1 -1
@@ -1304,7 +1304,7 @@ static void xc5000_release(struct dvb_frmutex_lock (&xc5000_list_mutex);if (priv) { -cancel_delayed_work (&priv->timer_sleep); +cancel_delayed_work_sync (&priv->timer_sleep);hybrid_tuner_release_state (priv); }
Greg Kroah-Hartman
maintainerPATCH 18/196 media: i2c: tc358743: Fix use-after-free bugs caused by orphan timer in probe
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duoming Zhou <[email protected]>
[ Upstream commit 79d10f4f21a92e459b2276a77be62c59c1502c9d ]
The state->timer is a cyclic timer that schedules work_i2c_poll and delayed_work_enable_hotplug, while rearming itself. Using timer_delete() fails to guarantee the timer isn't still running when destroyed, similarly cancel_delayed_work() cannot ensure delayed_work_enable_hotplug has terminated if already executing. During probe failure after timer initialization, these may continue running as orphans and reference the already-freed tc358743_state object through tc358743_irq_poll_timer.
The following is the trace captured by KASAN.
BUG: KASAN: slab-use-after-free in __run_timer_base.part.0+0x7d7/0x8c0 Write of size 8 at addr ffff88800ded83c8 by task swapper/1/0 ... Call Trace: <IRQ> dump_stack_lvl+0x55/0x70 print_report+0xcf/0x610 ? __pfx_sched_balance_find_src_group+0x10/0x10 ? __run_timer_base.part.0+0x7d7/0x8c0 kasan_report+0xb8/0xf0 ? __run_timer_base.part.0+0x7d7/0x8c0 __run_timer_base.part.0+0x7d7/0x8c0 ? rcu_sched_clock_irq+0xb06/0x27d0 ? __pfx___run_timer_base.part.0+0x10/0x10 ? try_to_wake_up+0xb15/0x1960 ? tmigr_update_events+0x280/0x740 ? _raw_spin_lock_irq+0x80/0xe0 ? __pfx__raw_spin_lock_irq+0x10/0x10 tmigr_handle_remote_up+0x603/0x7e0 ? __pfx_tmigr_handle_remote_up+0x10/0x10 ? sched_balance_trigger+0x98/0x9f0 ? sched_tick+0x221/0x5a0 ? _raw_spin_lock_irq+0x80/0xe0 ? __pfx__raw_spin_lock_irq+0x10/0x10 ? tick_nohz_handler+0x339/0x440 ? __pfx_tmigr_handle_remote_up+0x10/0x10 __walk_groups.isra.0+0x42/0x150 tmigr_handle_remote+0x1f4/0x2e0 ? __pfx_tmigr_handle_remote+0x10/0x10 ? ktime_get+0x60/0x140 ? lapic_next_event+0x11/0x20 ? clockevents_program_event+0x1d4/0x2a0 ? hrtimer_interrupt+0x322/0x780 handle_softirqs+0x16a/0x550 irq_exit_rcu+0xaf/0xe0 sysvec_apic_timer_interrupt+0x70/0x80 </IRQ>
...
Allocated by task 141: kasan_save_stack+0x24/0x50 kasan_save_track+0x14/0x30 __kasan_kmalloc+0x7f/0x90 __kmalloc_node_track_caller_noprof+0x198/0x430 devm_kmalloc+0x7b/0x1e0 tc358743_probe+0xb7/0x610 i2c_device_probe+0x51d/0x880 really_probe+0x1ca/0x5c0 __driver_probe_device+0x248/0x310 driver_probe_device+0x44/0x120 __device_attach_driver+0x174/0x220 bus_for_each_drv+0x100/0x190 __device_attach+0x206/0x370 bus_probe_device+0x123/0x170 device_add+0xd25/0x1470 i2c_new_client_device+0x7a0/0xcd0 do_one_initcall+0x89/0x300 do_init_module+0x29d/0x7f0 load_module+0x4f48/0x69e0 init_module_from_file+0xe4/0x150 idempotent_init_module+0x320/0x670 __x64_sys_finit_module+0xbd/0x120 do_syscall_64+0xac/0x280 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 141: kasan_save_stack+0x24/0x50 kasan_save_track+0x14/0x30 kasan_save_free_info+0x3a/0x60 __kasan_slab_free+0x3f/0x50 kfree+0x137/0x370 release_nodes+0xa4/0x100 devres_release_group+0x1b2/0x380 i2c_device_probe+0x694/0x880 really_probe+0x1ca/0x5c0 __driver_probe_device+0x248/0x310 driver_probe_device+0x44/0x120 __device_attach_driver+0x174/0x220 bus_for_each_drv+0x100/0x190 __device_attach+0x206/0x370 bus_probe_device+0x123/0x170 device_add+0xd25/0x1470 i2c_new_client_device+0x7a0/0xcd0 do_one_initcall+0x89/0x300 do_init_module+0x29d/0x7f0 load_module+0x4f48/0x69e0 init_module_from_file+0xe4/0x150 idempotent_init_module+0x320/0x670 __x64_sys_finit_module+0xbd/0x120 do_syscall_64+0xac/0x280 entry_SYSCALL_64_after_hwframe+0x77/0x7f
...
Replace timer_delete() with timer_delete_sync() and cancel_delayed_work() with cancel_delayed_work_sync() to ensure proper termination of timer and work items before resource cleanup.
This bug was initially identified through static analysis. For reproduction and testing, I created a functional emulation of the tc358743 device via a kernel module and introduced faults through the debugfs interface.
--- drivers/media/i2c/tc358743.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/i2c/tc358743.c +2 -2
@@ -2180,10 +2180,10 @@ static int tc358743_probe(struct i2c_cli err_work_queues:cec_unregister_adapter (state->cec_adap);if (!state->i2c_client->irq) { -del_timer (&state->timer); +timer_delete_sync (&state->timer);flush_work (&state->work_i2c_poll); } -cancel_delayed_work (&state->delayed_work_enable_hotplug); +cancel_delayed_work_sync (&state->delayed_work_enable_hotplug);mutex_destroy (&state->confctl_mutex); err_hdl:media_entity_cleanup (&sd->entity);
Greg Kroah-Hartman
maintainerPATCH 19/196 minmax: dont use max() in situations that want a C constant expression
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <[email protected]>
[ Upstream commit cb04e8b1d2f24c4c2c92f7b7529031fc35a16fed ]
We only had a couple of array[] declarations, and changing them to just use 'MAX()' instead of 'max()' fixes the issue.
This will allow us to simplify our min/max macros enormously, since they can now unconditionally use temporary variables to avoid using the argument values multiple times.
--- drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 2 +- drivers/input/touchscreen/cyttsp4_core.c | 2 +- drivers/irqchip/irq-sun6i-r.c | 2 +- drivers/md/dm-integrity.c | 2 +- fs/btrfs/tree-checker.c | 2 +- lib/vsprintf.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1 -1
@@ -700,7 +700,7 @@ static const char *smu_get_feature_name(size_t smu_cmn_get_pp_feature_mask (struct smu_context *smu,char *buf) { -int8_t sort_feature[max (SMU_FEATURE_COUNT ,SMU_FEATURE_MAX )]; +int8_t sort_feature[MAX (SMU_FEATURE_COUNT ,SMU_FEATURE_MAX )];uint64_t feature_mask;int i, feature_index;uint32_t count =0 ;
drivers/input/touchscreen/cyttsp4_core.c +1 -1
@@ -871,7 +871,7 @@ static void cyttsp4_get_mt_touches(strucstruct cyttsp4_touch tch;int sig;int i, j, t =0 ; -int ids[max (CY_TMA1036_MAX_TCH ,CY_TMA4XX_MAX_TCH )]; +int ids[MAX (CY_TMA1036_MAX_TCH ,CY_TMA4XX_MAX_TCH )];memset (ids,0 , si->si_ofs.tch_abs[CY_TCH_T ].max *sizeof (int ));for (i =0 ; i < num_cur_tch; i++) {
drivers/irqchip/irq-sun6i-r.c +1 -1
@@ -270,7 +270,7 @@ static const struct irq_domain_ops sun6istatic int sun6i_r_intc_suspend (void ) { -u32 buf[BITS_TO_U32 (max (SUN6I_NR_TOP_LEVEL_IRQS ,SUN6I_NR_MUX_BITS ))]; +u32 buf[BITS_TO_U32 (MAX (SUN6I_NR_TOP_LEVEL_IRQS ,SUN6I_NR_MUX_BITS ))];int i;/* Wake IRQs are enabled during system sleep and shutdown. */
drivers/md/dm-integrity.c +1 -1
@@ -1794,7 +1794,7 @@ static void integrity_metadata(struct wostruct bio *bio =dm_bio_from_per_bio_data (dio,sizeof (struct dm_integrity_io ));char *checksums;unsigned int extra_space =unlikely (digest_size > ic->tag_size) ? digest_size - ic->tag_size :0 ; -char checksums_onstack[max ((size_t )HASH_MAX_DIGESTSIZE ,MAX_TAG_SIZE )]; +char checksums_onstack[MAX (HASH_MAX_DIGESTSIZE ,MAX_TAG_SIZE )];sector_t sector;unsigned int sectors_to_process;
fs/btrfs/tree-checker.c +1 -1
@@ -608,7 +608,7 @@ static int check_dir_item(struct extent_*/ if (key->type ==BTRFS_DIR_ITEM_KEY || key->type ==BTRFS_XATTR_ITEM_KEY ) { -char namebuf[max (BTRFS_NAME_LEN ,XATTR_NAME_MAX )]; +char namebuf[MAX (BTRFS_NAME_LEN ,XATTR_NAME_MAX )];read_extent_buffer (leaf, namebuf, (unsigned long )(di +1 ), name_len);
lib/vsprintf.c +1 -1
@@ -1082,7 +1082,7 @@ char *resource_string(char *buf, char *e#define FLAG_BUF_SIZE (2 * sizeof(res->flags))#define DECODED_BUF_SIZE sizeof("[mem - 64bit pref window disabled]")#define RAW_BUF_SIZE sizeof("[mem - flags 0x]") -char sym[max (2 *RSRC_BUF_SIZE +DECODED_BUF_SIZE , +char sym[MAX (2 *RSRC_BUF_SIZE +DECODED_BUF_SIZE ,2 *RSRC_BUF_SIZE +FLAG_BUF_SIZE +RAW_BUF_SIZE )];char *p = sym, *pend = sym +sizeof (sym);
Greg Kroah-Hartman
maintainerPATCH 20/196 minmax: simplify min()/max()/clamp() implementation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <[email protected]>
[ Upstream commit dc1c8034e31b14a2e5e212104ec508aec44ce1b9 ]
Now that we no longer have any C constant expression contexts (ie array size declarations or static initializers) that use min() or max(), we can simpify the implementation by not having to worry about the result staying as a C constant expression.
So now we can unconditionally just use temporary variables of the right type, and get rid of the excessive expansion that used to come from the use of
__builtin_choose_expr(__is_constexpr(...), ..
to pick the specialized code for constant expressions.
Another expansion simplification is to pass the temporary variables (in addition to the original expression) to our __types_ok() macro. That may superficially look like it complicates the macro, but when we only want the type of the expression, expanding the temporary variable names is much simpler and smaller than expanding the potentially complicated original expression.
As a result, on my machine, doing a
$ time make drivers/staging/media/atomisp/pci/isp/kernels/ynr/ynr_1.0/ia_css_ynr.host.i
goes from
real 0m16.621s user 0m15.360s sys 0m1.221s
to
real 0m2.532s user 0m2.091s sys 0m0.452s
because the token expansion goes down dramatically.
In particular, the longest line expansion (which was line 71 of that 'ia_css_ynr.host.c' file) shrinks from 23,338kB (yes, 23MB for one single line) to "just" 1,444kB (now "only" 1.4MB).
And yes, that line is still the line from hell, because it's doing multiple levels of "min()/max()" expansion thanks to some of them being hidden inside the uDIGIT_FITTING() macro.
Lorenzo has a nice cleanup patch that makes that driver use inline functions instead of macros for sDIGIT_FITTING() and uDIGIT_FITTING(), which will fix that line once and for all, but the 16-fold reduction in this case does show why we need to simplify these helpers.
--- include/linux/minmax.h | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-)
include/linux/minmax.h +20 -23
@@ -35,10 +35,10 @@#define __is_noneg_int (x) \ (__builtin_choose_expr(__is_constexpr(x) && __is_signed(x), x, -1) >= 0) -#define __types_ok (x, y) \ - (__is_signed(x) == __is_signed(y) || \ - __is_signed((x) + 0) == __is_signed((y) + 0) || \ - __is_noneg_int(x) || __is_noneg_int(y)) +#define __types_ok (x, y, ux, uy) \ + (__is_signed(ux) == __is_signed(uy) || \ + __is_signed((ux) + 0) == __is_signed((uy) + 0) || \ + __is_noneg_int(x) || __is_noneg_int(y))#define __cmp_op_min <#define __cmp_op_max >
@@ -51,34 +51,31 @@#define __cmp_once (op, type, x, y) \ __cmp_once_unique(op, type, x, y, __UNIQUE_ID(x_), __UNIQUE_ID(y_)) -#define __careful_cmp_once (op, x, y) ({ \ - static_assert(__types_ok(x, y), \ +#define __careful_cmp_once (op, x, y, ux, uy) ({ \ + __auto_type ux = (x); __auto_type uy = (y); \ + static_assert(__types_ok(x, y, ux, uy), \ #op "(" #x ", " #y ") signedness error, fix types or consider u" #op "() before " #op "_t()"); \ - __cmp_once(op, __auto_type, x, y); }) + __cmp(op, ux, uy); }) -#define __careful_cmp (op, x, y) \ - __builtin_choose_expr(__is_constexpr((x) - (y)), \ - __cmp(op, x, y), __careful_cmp_once(op, x, y)) +#define __careful_cmp (op, x, y) \ + __careful_cmp_once(op, x, y, __UNIQUE_ID(x_), __UNIQUE_ID(y_))#define __clamp (val, lo, hi) \ ((val) >= (hi) ? (hi) : ((val) <= (lo) ? (lo) : (val))) -#define __clamp_once (val, lo, hi, unique_val, unique_lo, unique_hi) ({ \ - typeof(val) unique_val = (val); \ - typeof(lo) unique_lo = (lo); \ - typeof(hi) unique_hi = (hi); \ +#define __clamp_once (val, lo, hi, uval, ulo, uhi) ({ \ + __auto_type uval = (val); \ + __auto_type ulo = (lo); \ + __auto_type uhi = (hi); \ static_assert(__builtin_choose_expr(__is_constexpr((lo) > (hi)), \ (lo) <= (hi), true), \ "clamp() low limit " #lo " greater than high limit " #hi); \ - static_assert(__types_ok(val, lo), "clamp() 'lo' signedness error"); \ - static_assert(__types_ok(val, hi), "clamp() 'hi' signedness error"); \ - __clamp(unique_val, unique_lo, unique_hi); }) - -#define __careful_clamp (val, lo, hi) ({ \ - __builtin_choose_expr(__is_constexpr((val) - (lo) + (hi)), \ - __clamp(val, lo, hi), \ - __clamp_once(val, lo, hi, __UNIQUE_ID(__val), \ - __UNIQUE_ID(__lo), __UNIQUE_ID(__hi))); }) + static_assert(__types_ok(uval, lo, uval, ulo), "clamp() 'lo' signedness error"); \ + static_assert(__types_ok(uval, hi, uval, uhi), "clamp() 'hi' signedness error"); \ + __clamp(uval, ulo, uhi); }) + +#define __careful_clamp (val, lo, hi) \ + __clamp_once(val, lo, hi, __UNIQUE_ID(v_), __UNIQUE_ID(l_), __UNIQUE_ID(h_))/** * min - return minimum of two values of the same or compatible types
Greg Kroah-Hartman
maintainerPATCH 21/196 minmax: improve macro expansion and type checking
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <[email protected]>
[ Upstream commit 22f5468731491e53356ba7c028f0fdea20b18e2c ]
This clarifies the rules for min()/max()/clamp() type checking and makes them a much more efficient macro expansion.
In particular, we now look at the type and range of the inputs to see whether they work together, generating a mask of acceptable comparisons, and then just verifying that the inputs have a shared case:
- an expression with a signed type can be used for
(1) signed comparisons
(2) unsigned comparisons if it is statically known to have a non-negative value
- an expression with an unsigned type can be used for
(3) unsigned comparison
(4) signed comparisons if the type is smaller than 'int' and thus the C integer promotion rules will make it signed anyway
Here rule (1) and (3) are obvious, and rule (2) is important in order to allow obvious trivial constants to be used together with unsigned values.
Rule (4) is not necessarily a good idea, but matches what we used to do, and we have extant cases of this situation in the kernel. Notably with bcachefs having an expression like
min(bch2_bucket_sectors_dirty(a), ca->mi.bucket_size)
where bch2_bucket_sectors_dirty() returns an 's64', and 'ca->mi.bucket_size' is of type 'u16'.
Technically that bcachefs comparison is clearly sensible on a C type level, because the 'u16' will go through the normal C integer promotion, and become 'int', and then we're comparing two signed values and everything looks sane.
However, it's not entirely clear that a 'min(s64,u16)' operation makes a lot of conceptual sense, and it's possible that we will remove rule (4). After all, the _reason_ we have these complicated type checks is exactly that the C type promotion rules are not very intuitive.
But at least for now the rule is in place for backwards compatibility.
Also note that rule (2) existed before, but is hugely relaxed by this commit. It used to be true only for the simplest compile-time non-negative integer constants. The new macro model will allow cases where the compiler can trivially see that an expression is non-negative even if it isn't necessarily a constant.
For example, the amdgpu driver does
min_t(size_t, sizeof(fru_info->serial), pia[addr] & 0x3F));
because our old 'min()' macro would see that 'pia[addr] & 0x3F' is of type 'int' and clearly not a C constant expression, so doing a 'min()' with a 'size_t' is a signedness violation.
Our new 'min()' macro still sees that 'pia[addr] & 0x3F' is of type 'int', but is smart enough to also see that it is clearly non-negative, and thus would allow that case without any complaints.
--- include/linux/compiler.h | 9 +++++ include/linux/minmax.h | 78 ++++++++++++++++++++++++++++++++++++----------- 2 files changed, 70 insertions(+), 17 deletions(-)
include/linux/compiler.h +9 -0
@@ -245,6 +245,15 @@ static inline void *offset_to_ptr(const#define is_signed_type (type) (((type)(-1)) < (__force type)1)/* +* Useful shorthand for "is this condition known at compile-time?" +* +* Note that the condition may involve non-constant values, +* but the compiler may know enough about the details of the +* values to determine that the condition is statically true. +*/ +#define statically_true (x) (__builtin_constant_p(x) && (x)) + +/* * This is needed in functions which generate the stack canary, see * arch/x86/kernel/smpboot.c::start_secondary() for an example. */
include/linux/minmax.h +61 -17
96 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 22/196 minmax: fix up min3() and max3() too
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <[email protected]>
[ Upstream commit 21b136cc63d2a9ddd60d4699552b69c214b32964 ]
David Laight pointed out that we should deal with the min3() and max3() mess too, which still does excessive expansion.
And our current macros are actually rather broken.
In particular, the macros did this:
#define min3(x, y, z) min((typeof(x))min(x, y), z) #define max3(x, y, z) max((typeof(x))max(x, y), z)
and that not only is a nested expansion of possibly very complex arguments with all that involves, the typing with that "typeof()" cast is completely wrong.
For example, imagine what happens in max3() if 'x' happens to be a 'unsigned char', but 'y' and 'z' are 'unsigned long'. The types are compatible, and there's no warning - but the result is just random garbage.
No, I don't think we've ever hit that issue in practice, but since we now have sane infrastructure for doing this right, let's just use it. It fixes any excessive expansion, and also avoids these kinds of broken type issues.
--- include/linux/minmax.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
include/linux/minmax.h +10 -2
@@ -152,13 +152,20 @@#define umax (x, y) \ __careful_cmp(max, (x) + 0u + 0ul + 0ull, (y) + 0u + 0ul + 0ull) +#define __careful_op3 (op, x, y, z, ux, uy, uz) ({ \ + __auto_type ux = (x); __auto_type uy = (y);__auto_type uz = (z);\ + BUILD_BUG_ON_MSG(!__types_ok3(x,y,z,ux,uy,uz), \ + #op"3("#x", "#y", "#z") signedness error"); \ + __cmp(op, ux, __cmp(op, uy, uz)); }) +/** * min3 - return minimum of three values * @x: first value * @y: second value * @z: third value */ -#define min3 (x, y, z) min((typeof(x))min(x, y), z) +#define min3 (x, y, z) \ + __careful_op3(min, x, y, z, __UNIQUE_ID(x_), __UNIQUE_ID(y_), __UNIQUE_ID(z_))/** * max3 - return maximum of three values
@@ -166,7 +173,8 @@* @y: second value * @z: third value */ -#define max3 (x, y, z) max((typeof(x))max(x, y), z) +#define max3 (x, y, z) \ + __careful_op3(max, x, y, z, __UNIQUE_ID(x_), __UNIQUE_ID(y_), __UNIQUE_ID(z_))/** * min_not_zero - return the minimum that is _not_ zero, unless both are zero
Greg Kroah-Hartman
maintainerPATCH 23/196 minmax.h: add whitespace around operators and after commas
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Laight <[email protected]>
[ Upstream commit 71ee9b16251ea4bf7c1fe222517c82bdb3220acc ]
Patch series "minmax.h: Cleanups and minor optimisations".
Some tidyups and minor changes to minmax.h.
This patch (of 7):
--- include/linux/minmax.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
include/linux/minmax.h +17 -17
@@ -51,10 +51,10 @@* only need to be careful to not cause warnings for * pointer use. */ -#define __signed_type_use (x,ux) (2+__is_nonneg(x,ux)) -#define __unsigned_type_use (x,ux) (1+2*(sizeof(ux)<4)) -#define __sign_use (x,ux) (is_signed_type(typeof(ux))? \ - __signed_type_use(x,ux):__unsigned_type_use(x,ux)) +#define __signed_type_use (x, ux) (2 + __is_nonneg(x, ux)) +#define __unsigned_type_use (x, ux) (1 + 2 * (sizeof(ux) < 4)) +#define __sign_use (x, ux) (is_signed_type(typeof(ux)) ? \ + __signed_type_use(x, ux) : __unsigned_type_use(x, ux))/* * To avoid warnings about casting pointers to integers
@@ -74,15 +74,15 @@#ifdef CONFIG_64BIT #define __signed_type (ux) long#else -#define __signed_type (ux) typeof(__builtin_choose_expr(sizeof(ux)>4,1LL,1L)) +#define __signed_type (ux) typeof(__builtin_choose_expr(sizeof(ux) > 4, 1LL, 1L))#endif -#define __is_nonneg (x,ux) statically_true((__signed_type(ux))(x)>=0) +#define __is_nonneg (x, ux) statically_true((__signed_type(ux))(x) >= 0) -#define __types_ok (x,y,ux,uy) \ - (__sign_use(x,ux) & __sign_use(y,uy)) +#define __types_ok (x, y, ux, uy) \ + (__sign_use(x, ux) & __sign_use(y, uy)) -#define __types_ok3 (x,y,z,ux,uy,uz) \ - (__sign_use(x,ux) & __sign_use(y,uy) & __sign_use(z,uz)) +#define __types_ok3 (x, y, z, ux, uy, uz) \ + (__sign_use(x, ux) & __sign_use(y, uy) & __sign_use(z, uz))#define __cmp_op_min <#define __cmp_op_max >
@@ -97,7 +97,7 @@#define __careful_cmp_once (op, x, y, ux, uy) ({ \ __auto_type ux = (x); __auto_type uy = (y); \ - BUILD_BUG_ON_MSG(!__types_ok(x,y,ux,uy), \ + BUILD_BUG_ON_MSG(!__types_ok(x, y, ux, uy), \ #op"("#x", "#y") signedness error"); \ __cmp(op, ux, uy); })
@@ -114,7 +114,7 @@ static_assert(__builtin_choose_expr(__is_constexpr((lo) > (hi)), \ (lo) <= (hi), true), \ "clamp() low limit " #lo " greater than high limit " #hi); \ - BUILD_BUG_ON_MSG(!__types_ok3(val,lo,hi,uval,ulo,uhi), \ + BUILD_BUG_ON_MSG(!__types_ok3(val, lo, hi, uval, ulo, uhi), \ "clamp("#val", "#lo", "#hi") signedness error"); \ __clamp(uval, ulo, uhi); })
@@ -154,7 +154,7 @@#define __careful_op3 (op, x, y, z, ux, uy, uz) ({ \ __auto_type ux = (x); __auto_type uy = (y);__auto_type uz = (z);\ - BUILD_BUG_ON_MSG(!__types_ok3(x,y,z,ux,uy,uz), \ + BUILD_BUG_ON_MSG(!__types_ok3(x, y, z, ux, uy, uz), \ #op"3("#x", "#y", "#z") signedness error"); \ __cmp(op, ux, __cmp(op, uy, uz)); })
@@ -326,9 +326,9 @@ static inline bool in_range32(u32 val, u* Use these carefully: no type checking, and uses the arguments * multiple times. Use for obvious constants only. */ -#define MIN (a,b) __cmp(min,a,b) -#define MAX (a,b) __cmp(max,a,b) -#define MIN_T (type,a,b) __cmp(min,(type)(a),(type)(b)) -#define MAX_T (type,a,b) __cmp(max,(type)(a),(type)(b)) +#define MIN (a, b) __cmp(min, a, b) +#define MAX (a, b) __cmp(max, a, b) +#define MIN_T (type, a, b) __cmp(min, (type)(a), (type)(b)) +#define MAX_T (type, a, b) __cmp(max, (type)(a), (type)(b))#endif /* _LINUX_MINMAX_H */
Greg Kroah-Hartman
maintainerPATCH 24/196 minmax.h: update some comments
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Laight <[email protected]>
[ Upstream commit 10666e99204818ef45c702469488353b5bb09ec7 ]
- Change three to several.
- Remove the comment about retaining constant expressions, no longer true.
- Realign to nearer 80 columns and break on major punctiation.
- Add a leading comment to the block before __signed_type() and __is_nonneg() Otherwise the block explaining the cast is a bit 'floating'. Reword the rest of that comment to improve readability.
--- include/linux/minmax.h | 61 ++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 33 deletions(-)
include/linux/minmax.h +28 -33
@@ -8,13 +8,10 @@#include <linux/types.h> /* -* min()/max()/clamp() macros must accomplish three things: +* min()/max()/clamp() macros must accomplish several things: * * - Avoid multiple evaluations of the arguments (so side-effects like * "x++" happen only once) when non-constant. -* - Retain result as a constant expressions when called with only -* constant expressions (to avoid tripping VLA warnings in stack -* allocation usage). * - Perform signed v unsigned type-checking (to generate compile * errors instead of nasty runtime surprises). * - Unsigned char/short are always promoted to signed int and can be
@@ -31,25 +28,23 @@* bit #0 set if ok for unsigned comparisons * bit #1 set if ok for signed comparisons * -* In particular, statically non-negative signed integer -* expressions are ok for both. +* In particular, statically non-negative signed integer expressions +* are ok for both. * -* NOTE! Unsigned types smaller than 'int' are implicitly -* converted to 'int' in expressions, and are accepted for -* signed conversions for now. This is debatable. -* -* Note that 'x' is the original expression, and 'ux' is -* the unique variable that contains the value. -* -* We use 'ux' for pure type checking, and 'x' for when -* we need to look at the value (but without evaluating -* it for side effects! Careful to only ever evaluate it -* with sizeof() or __builtin_constant_p() etc). -* -* Pointers end up being checked by the normal C type -* rules at the actual comparison, and these expressions -* only need to be careful to not cause warnings for -* pointer use. +* NOTE! Unsigned types smaller than 'int' are implicitly converted to 'int' +* in expressions, and are accepted for signed conversions for now. +* This is debatable. +* +* Note that 'x' is the original expression, and 'ux' is the unique variable +* that contains the value. +* +* We use 'ux' for pure type checking, and 'x' for when we need to look at the +* value (but without evaluating it for side effects! +* Careful to only ever evaluate it with sizeof() or __builtin_constant_p() etc). +* +* Pointers end up being checked by the normal C type rules at the actual +* comparison, and these expressions only need to be careful to not cause +* warnings for pointer use. */ #define __signed_type_use (x, ux) (2 + __is_nonneg(x, ux))#define __unsigned_type_use (x, ux) (1 + 2 * (sizeof(ux) < 4))
@@ -57,19 +52,19 @@ __signed_type_use(x, ux) : __unsigned_type_use(x, ux))/* -* To avoid warnings about casting pointers to integers -* of different sizes, we need that special sign type. +* Check whether a signed value is always non-negative. * -* On 64-bit we can just always use 'long', since any -* integer or pointer type can just be cast to that. +* A cast is needed to avoid any warnings from values that aren't signed +* integer types (in which case the result doesn't matter). * -* This does not work for 128-bit signed integers since -* the cast would truncate them, but we do not use s128 -* types in the kernel (we do use 'u128', but they will -* be handled by the !is_signed_type() case). -* -* NOTE! The cast is there only to avoid any warnings -* from when values that aren't signed integer types. +* On 64-bit any integer or pointer type can safely be cast to 'long'. +* But on 32-bit we need to avoid warnings about casting pointers to integers +* of different sizes without truncating 64-bit values so 'long' or 'long long' +* must be used depending on the size of the value. +* +* This does not work for 128-bit signed integers since the cast would truncate +* them, but we do not use s128 types in the kernel (we do use 'u128', +* but they are handled by the !is_signed_type() case). */ #ifdef CONFIG_64BIT #define __signed_type (ux) long
Greg Kroah-Hartman
maintainerPATCH 25/196 minmax.h: reduce the #define expansion of min(), max() and clamp()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Laight <[email protected]>
[ Upstream commit b280bb27a9f7c91ddab730e1ad91a9c18a051f41 ]
Since the test for signed values being non-negative only relies on __builtion_constant_p() (not is_constexpr()) it can use the 'ux' variable instead of the caller supplied expression. This means that the #define parameters are only expanded twice. Once in the code and once quoted in the error message.
--- include/linux/minmax.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
include/linux/minmax.h +12 -12
@@ -46,10 +46,10 @@* comparison, and these expressions only need to be careful to not cause * warnings for pointer use. */ -#define __signed_type_use (x, ux) (2 + __is_nonneg(x, ux)) -#define __unsigned_type_use (x, ux) (1 + 2 * (sizeof(ux) < 4)) -#define __sign_use (x, ux) (is_signed_type(typeof(ux)) ? \ - __signed_type_use(x, ux) : __unsigned_type_use(x, ux)) +#define __signed_type_use (ux) (2 + __is_nonneg(ux)) +#define __unsigned_type_use (ux) (1 + 2 * (sizeof(ux) < 4)) +#define __sign_use (ux) (is_signed_type(typeof(ux)) ? \ + __signed_type_use(ux) : __unsigned_type_use(ux))/* * Check whether a signed value is always non-negative.
@@ -71,13 +71,13 @@#else #define __signed_type (ux) typeof(__builtin_choose_expr(sizeof(ux) > 4, 1LL, 1L))#endif -#define __is_nonneg (x, ux) statically_true((__signed_type(ux))(x) >= 0) +#define __is_nonneg (ux) statically_true((__signed_type(ux))(ux) >= 0) -#define __types_ok (x, y, ux, uy) \ - (__sign_use(x, ux) & __sign_use(y, uy)) +#define __types_ok (ux, uy) \ + (__sign_use(ux) & __sign_use(uy)) -#define __types_ok3 (x, y, z, ux, uy, uz) \ - (__sign_use(x, ux) & __sign_use(y, uy) & __sign_use(z, uz)) +#define __types_ok3 (ux, uy, uz) \ + (__sign_use(ux) & __sign_use(uy) & __sign_use(uz))#define __cmp_op_min <#define __cmp_op_max >
@@ -92,7 +92,7 @@#define __careful_cmp_once (op, x, y, ux, uy) ({ \ __auto_type ux = (x); __auto_type uy = (y); \ - BUILD_BUG_ON_MSG(!__types_ok(x, y, ux, uy), \ + BUILD_BUG_ON_MSG(!__types_ok(ux, uy), \ #op"("#x", "#y") signedness error"); \ __cmp(op, ux, uy); })
@@ -109,7 +109,7 @@ static_assert(__builtin_choose_expr(__is_constexpr((lo) > (hi)), \ (lo) <= (hi), true), \ "clamp() low limit " #lo " greater than high limit " #hi); \ - BUILD_BUG_ON_MSG(!__types_ok3(val, lo, hi, uval, ulo, uhi), \ + BUILD_BUG_ON_MSG(!__types_ok3(uval, ulo, uhi), \ "clamp("#val", "#lo", "#hi") signedness error"); \ __clamp(uval, ulo, uhi); })
@@ -149,7 +149,7 @@#define __careful_op3 (op, x, y, z, ux, uy, uz) ({ \ __auto_type ux = (x); __auto_type uy = (y);__auto_type uz = (z);\ - BUILD_BUG_ON_MSG(!__types_ok3(x, y, z, ux, uy, uz), \ + BUILD_BUG_ON_MSG(!__types_ok3(ux, uy, uz), \ #op"3("#x", "#y", "#z") signedness error"); \ __cmp(op, ux, __cmp(op, uy, uz)); })
Greg Kroah-Hartman
maintainerPATCH 26/196 minmax.h: use BUILD_BUG_ON_MSG() for the lo < hi test in clamp()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Laight <[email protected]>
[ Upstream commit a5743f32baec4728711bbc01d6ac2b33d4c67040 ]
Use BUILD_BUG_ON_MSG(statically_true(ulo > uhi), ...) for the sanity check of the bounds in clamp(). Gives better error coverage and one less expansion of the arguments.
--- include/linux/minmax.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
include/linux/minmax.h +1 -2
@@ -106,8 +106,7 @@__auto_type uval = (val); \__auto_type ulo = (lo); \__auto_type uhi = (hi); \ - static_assert(__builtin_choose_expr(__is_constexpr((lo) > (hi)), \ - (lo) <= (hi), true), \ + BUILD_BUG_ON_MSG(statically_true(ulo > uhi), \ "clamp() low limit " #lo " greater than high limit " #hi); \ BUILD_BUG_ON_MSG(!__types_ok3(uval, ulo, uhi), \ "clamp("#val", "#lo", "#hi") signedness error"); \
Greg Kroah-Hartman
maintainerPATCH 27/196 minmax.h: move all the clamp() definitions after the min/max() ones
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Laight <[email protected]>
[ Upstream commit c3939872ee4a6b8bdcd0e813c66823b31e6e26f7 ]
At some point the definitions for clamp() got added in the middle of the ones for min() and max(). Re-order the definitions so they are more sensibly grouped.
--- include/linux/minmax.h | 109 ++++++++++++++++++++++--------------------------- 1 file changed, 51 insertions(+), 58 deletions(-)
include/linux/minmax.h +51 -58
@@ -99,22 +99,6 @@#define __careful_cmp (op, x, y) \ __careful_cmp_once(op, x, y, __UNIQUE_ID(x_), __UNIQUE_ID(y_)) -#define __clamp (val, lo, hi) \ - ((val) >= (hi) ? (hi) : ((val) <= (lo) ? (lo) : (val))) - -#define __clamp_once (val, lo, hi, uval, ulo, uhi) ({ \ - __auto_type uval = (val); \ - __auto_type ulo = (lo); \ - __auto_type uhi = (hi); \ - BUILD_BUG_ON_MSG(statically_true(ulo > uhi), \ - "clamp() low limit " #lo " greater than high limit " #hi); \ - BUILD_BUG_ON_MSG(!__types_ok3(uval, ulo, uhi), \ - "clamp("#val", "#lo", "#hi") signedness error"); \ - __clamp(uval, ulo, uhi); }) - -#define __careful_clamp (val, lo, hi) \ - __clamp_once(val, lo, hi, __UNIQUE_ID(v_), __UNIQUE_ID(l_), __UNIQUE_ID(h_)) -/** * min - return minimum of two values of the same or compatible types * @x: first value
@@ -171,6 +155,22 @@__careful_op3 (max, x, y, z,__UNIQUE_ID (x_),__UNIQUE_ID (y_),__UNIQUE_ID (z_))/** +* min_t - return minimum of two values, using the specified type +* @type: data type to use +* @x: first value +* @y: second value + */ +#define min_t (type, x, y) __cmp_once(min, type, x, y) + +/** +* max_t - return maximum of two values, using the specified type +* @type: data type to use +* @x: first value +* @y: second value +*/ +#define max_t (type, x, y) __cmp_once(max, type, x, y) + +/** * min_not_zero - return the minimum that is _not_ zero, unless both are zero * @x: value1 * @y: value2
@@ -180,6 +180,22 @@typeof (y) __y = (y); \ __x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); }) +#define __clamp (val, lo, hi) \ + ((val) >= (hi) ? (hi) : ((val) <= (lo) ? (lo) : (val))) + +#define __clamp_once (val, lo, hi, uval, ulo, uhi) ({ \ + __auto_type uval = (val); \ + __auto_type ulo = (lo); \ + __auto_type uhi = (hi); \ + BUILD_BUG_ON_MSG(statically_true(ulo > uhi), \ + "clamp() low limit " #lo " greater than high limit " #hi); \ + BUILD_BUG_ON_MSG(!__types_ok3(uval, ulo, uhi), \ + "clamp("#val", "#lo", "#hi") signedness error"); \ + __clamp(uval, ulo, uhi); }) + +#define __careful_clamp (val, lo, hi) \ + __clamp_once(val, lo, hi, __UNIQUE_ID(v_), __UNIQUE_ID(l_), __UNIQUE_ID(h_)) +/** * clamp - return a value clamped to a given range with strict typechecking * @val: current value
@@ -191,28 +207,30 @@*/ #define clamp (val, lo, hi) __careful_clamp(val, lo, hi) -/* -* ..and if you can't take the strict -* types, you can specify one yourself. -* -* Or not use min/max/clamp at all, of course. -*/ -/** -* min_t - return minimum of two values, using the specified type -* @type: data type to use -* @x: first value -* @y: second value +* clamp_t - return a value clamped to a given range using a given type +* @type: the type of variable to use +* @val: current value +* @lo: minimum allowable value +* @hi: maximum allowable value +* +* This macro does no typechecking and uses temporary variables of type +* @type to make all the comparisons. */ -#define min_t (type, x, y) __cmp_once(min, type, x, y) +#define clamp_t (type, val, lo, hi) __careful_clamp((type)(val), (type)(lo), (type)(hi))/** -* max_t - return maximum of two values, using the specified type -* @type: data type to use -* @x: first value -* @y: second value +* clamp_val - return a value clamped to a given range using val's type +* @val: current value +* @lo: minimum allowable value +* @hi: maximum allowable value +* +* This macro does no typechecking and uses temporary variables of whatever +* type the input argument @val is. This is useful when @val is an unsigned +* type and @lo and @hi are literals that will otherwise be assigned a signed +* integer type. */ -#define max_t (type, x, y) __cmp_once(max, type, x, y) +#define clamp_val (val, lo, hi) clamp_t(typeof(val), val, lo, hi)/* * Do not check the array parameter using __must_be_array().
@@ -257,31 +275,6 @@*/ #define max_array (array, len) __minmax_array(max, array, len) -/** -* clamp_t - return a value clamped to a given range using a given type -* @type: the type of variable to use -* @val: current value -* @lo: minimum allowable value -* @hi: maximum allowable value -* -* This macro does no typechecking and uses temporary variables of type -* @type to make all the comparisons. -*/ -#define clamp_t (type, val, lo, hi) __careful_clamp((type)(val), (type)(lo), (type)(hi)) - -/** -* clamp_val - return a value clamped to a given range using val's type -* @val: current value -* @lo: minimum allowable value -* @hi: maximum allowable value -* -* This macro does no typechecking and uses temporary variables of whatever -* type the input argument @val is. This is useful when @val is an unsigned -* type and @lo and @hi are literals that will otherwise be assigned a signed -* integer type. -*/ -#define clamp_val (val, lo, hi) clamp_t(typeof(val), val, lo, hi) -static inline bool in_range64 (u64 val,u64 start,u64 len) {return (val - start) < len;
Greg Kroah-Hartman
maintainerPATCH 28/196 minmax.h: simplify the variants of clamp()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Laight <[email protected]>
[ Upstream commit 495bba17cdf95e9703af1b8ef773c55ef0dfe703 ]
Always pass a 'type' through to __clamp_once(), pass '__auto_type' from clamp() itself.
The expansion of __types_ok3() is reasonable so it isn't worth the added complexity of avoiding it when a fixed type is used for all three values.
--- include/linux/minmax.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
include/linux/minmax.h +12 -12
@@ -183,29 +183,29 @@#define __clamp (val, lo, hi) \ ((val) >= (hi) ? (hi) : ((val) <= (lo) ? (lo) : (val))) -#define __clamp_once (val, lo, hi, uval, ulo, uhi) ({ \ - __auto_type uval = (val); \ - __auto_type ulo = (lo); \ - __auto_type uhi = (hi); \ +#define __clamp_once (type, val, lo, hi, uval, ulo, uhi) ({ \ + type uval = (val); \ + type ulo = (lo); \ + type uhi = (hi); \ BUILD_BUG_ON_MSG(statically_true(ulo > uhi), \ "clamp() low limit " #lo " greater than high limit " #hi); \ BUILD_BUG_ON_MSG(!__types_ok3(uval, ulo, uhi), \ "clamp("#val", "#lo", "#hi") signedness error"); \ __clamp(uval, ulo, uhi); }) -#define __careful_clamp (val, lo, hi) \ - __clamp_once(val, lo, hi, __UNIQUE_ID(v_), __UNIQUE_ID(l_), __UNIQUE_ID(h_)) +#define __careful_clamp (type, val, lo, hi) \ + __clamp_once(type, val, lo, hi, __UNIQUE_ID(v_), __UNIQUE_ID(l_), __UNIQUE_ID(h_))/** -* clamp - return a value clamped to a given range with strict typechecking +* clamp - return a value clamped to a given range with typechecking * @val: current value * @lo: lowest allowable value * @hi: highest allowable value * -* This macro does strict typechecking of @lo/@hi to make sure they are of the -* same type as @val. See the unnecessary pointer comparisons. +* This macro checks @val/@lo/@hi to make sure they have compatible +* signedness. */ -#define clamp (val, lo, hi) __careful_clamp(val, lo, hi) +#define clamp (val, lo, hi) __careful_clamp(__auto_type, val, lo, hi)/** * clamp_t - return a value clamped to a given range using a given type
@@ -217,7 +217,7 @@* This macro does no typechecking and uses temporary variables of type * @type to make all the comparisons. */ -#define clamp_t (type, val, lo, hi) __careful_clamp((type)(val), (type)(lo), (type)(hi)) +#define clamp_t (type, val, lo, hi) __careful_clamp(type, val, lo, hi)/** * clamp_val - return a value clamped to a given range using val's type
@@ -230,7 +230,7 @@* type and @lo and @hi are literals that will otherwise be assigned a signed * integer type. */ -#define clamp_val (val, lo, hi) clamp_t(typeof(val), val, lo, hi) +#define clamp_val (val, lo, hi) __careful_clamp(typeof(val), val, lo, hi)/* * Do not check the array parameter using __must_be_array().
Greg Kroah-Hartman
maintainerPATCH 29/196 minmax.h: remove some #defines that are only expanded once
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Laight <[email protected]>
[ Upstream commit 2b97aaf74ed534fb838d09867d09a3ca5d795208 ]
The bodies of __signed_type_use() and __unsigned_type_use() are much the same size as their names - so put the bodies in the only line that expands them.
Similarly __signed_type() is defined separately for 64bit and then used exactly once just below.
Change the test for __signed_type from CONFIG_64BIT to one based on gcc defined macros so that the code is valid if it gets used outside of a kernel build.
--- include/linux/minmax.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
include/linux/minmax.h +6 -8
@@ -46,10 +46,8 @@* comparison, and these expressions only need to be careful to not cause * warnings for pointer use. */ -#define __signed_type_use (ux) (2 + __is_nonneg(ux)) -#define __unsigned_type_use (ux) (1 + 2 * (sizeof(ux) < 4))#define __sign_use (ux) (is_signed_type(typeof(ux)) ? \ - __signed_type_use(ux) : __unsigned_type_use(ux)) + (2 + __is_nonneg(ux)) : (1 + 2 * (sizeof(ux) < 4)))/* * Check whether a signed value is always non-negative.
@@ -57,7 +55,7 @@* A cast is needed to avoid any warnings from values that aren't signed * integer types (in which case the result doesn't matter). * -* On 64-bit any integer or pointer type can safely be cast to 'long'. +* On 64-bit any integer or pointer type can safely be cast to 'long long'. * But on 32-bit we need to avoid warnings about casting pointers to integers * of different sizes without truncating 64-bit values so 'long' or 'long long' * must be used depending on the size of the value.
@@ -66,12 +64,12 @@* them, but we do not use s128 types in the kernel (we do use 'u128', * but they are handled by the !is_signed_type() case). */ -#ifdef CONFIG_64BIT -#define __signed_type (ux) long +#if __SIZEOF_POINTER__ == __SIZEOF_LONG_LONG__ +#define __is_nonneg (ux) statically_true((long long)(ux) >= 0)#else -#define __signed_type (ux) typeof(__builtin_choose_expr(sizeof(ux) > 4, 1LL, 1L)) +#define __is_nonneg (ux) statically_true( \ + (typeof(__builtin_choose_expr(sizeof(ux) > 4, 1LL, 1L)))(ux) >= 0)#endif -#define __is_nonneg (ux) statically_true((__signed_type(ux))(ux) >= 0)#define __types_ok (ux, uy) \ (__sign_use(ux) & __sign_use(uy))
Greg Kroah-Hartman
maintainerPATCH 30/196 USB: serial: option: add SIMCom 8230C compositions
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiaowei Li <[email protected]>
commit 0e0ba0ecec3d6e819e0c2348331ff99afe2eb5d5 upstream.
Add support for SIMCom 8230C which is based on Qualcomm SDX35 chip.
USB Device Listings:
0x9071: tty (DM) + tty (NMEA) + tty (AT) + rmnet (QMI mode) + adb
T: Bus=01 Lev=01 Prnt=01 Port=05 Cnt=02 Dev#= 10 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=1e0e ProdID=9071 Rev= 5.15 S: Manufacturer=SIMCOM S: Product=SDXBAAGHA-IDP _SN:D744C4C5 S: SerialNumber=0123456789ABCDEF C:* #Ifs= 5 Cfg#= 1 Atr=a0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=84(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=50 Driver=qmi_wwan E: Ad=86(I) Atr=03(Int.) MxPS= 8 Ivl=32ms E: Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=(none) E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=87(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
0x9078: tty (DM) + tty (NMEA) + tty (AT) + ECM + adb
T: Bus=01 Lev=01 Prnt=01 Port=05 Cnt=02 Dev#= 9 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=1e0e ProdID=9078 Rev= 5.15 S: Manufacturer=SIMCOM S: Product=SDXBAAGHA-IDP _SN:D744C4C5 S: SerialNumber=0123456789ABCDEF C:* #Ifs= 6 Cfg#= 1 Atr=a0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=84(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 3 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=06 Prot=00 Driver=cdc_ether E: Ad=86(I) Atr=03(Int.) MxPS= 16 Ivl=32ms I: If#= 4 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_ether I:* If#= 4 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_ether E: Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=(none) E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=87(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
0x907b: RNDIS + tty (DM) + tty (NMEA) + tty (AT) + adb
T: Bus=01 Lev=01 Prnt=01 Port=05 Cnt=02 Dev#= 8 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=1e0e ProdID=907b Rev= 5.15 S: Manufacturer=SIMCOM S: Product=SDXBAAGHA-IDP _SN:D744C4C5 S: SerialNumber=0123456789ABCDEF
C:* #Ifs= 6 Cfg#= 1 Atr=a0 MxPwr=500mA
A: FirstIf#= 0 IfCount= 2 Cls=ef(misc ) Sub=04 Prot=01
I:* If#= 0 Alt= 0 #EPs= 1 Cls=ef(misc ) Sub=04 Prot=01 Driver=rndis_host
E: Ad=82(I) Atr=03(Int.) MxPS= 8 Ivl=32ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=rndis_host
E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=86(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=(none) E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=87(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
@@ -2114,6 +2114,12 @@ static const struct usb_device_id option { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9003, 0xff) }, /* Simcom SIM7500/SIM7600 MBIM mode */ { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9011, 0xff), /* Simcom SIM7500/SIM7600 RNDIS mode */ .driver_info = RSVD(7) }, + { USB_DEVICE(0x1e0e, 0x9071), /* Simcom SIM8230 RMNET mode */ + .driver_info = RSVD(3) | RSVD(4) }, + { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9078, 0xff), /* Simcom SIM8230 ECM mode */ + .driver_info = RSVD(5) }, + { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x907b, 0xff), /* Simcom SIM8230 RNDIS mode */ + .driver_info = RSVD(5) }, { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9205, 0xff) }, /* Simcom SIM7070/SIM7080/SIM7090 AT+ECM mode */ { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9206, 0xff) }, /* Simcom SIM7070/SIM7080/SIM7090 AT-only mode */ { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S_X200),
Greg Kroah-Hartman
maintainerPATCH 31/196 wifi: rtlwifi: rtl8192cu: Dont claim USB ID 07b8:8188
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bitterblue Smith <[email protected]>
commit e798f2ac6040f46a04795d7de977341fa9aeabae upstream.
This ID appears to be RTL8188SU, not RTL8188CU. This is the wrong driver for RTL8188SU. The r8712u driver from staging used to handle this ID.
--- drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c +0 -1
@@ -296,7 +296,6 @@ static const struct usb_device_id rtl819 {RTL_USB_DEVICE(0x050d, 0x1102, rtl92cu_hal_cfg)}, /*Belkin - Edimax*/ {RTL_USB_DEVICE(0x050d, 0x11f2, rtl92cu_hal_cfg)}, /*Belkin - ISY*/ {RTL_USB_DEVICE(0x06f8, 0xe033, rtl92cu_hal_cfg)}, /*Hercules - Edimax*/ - {RTL_USB_DEVICE(0x07b8, 0x8188, rtl92cu_hal_cfg)}, /*Abocom - Abocom*/ {RTL_USB_DEVICE(0x07b8, 0x8189, rtl92cu_hal_cfg)}, /*Funai - Abocom*/ {RTL_USB_DEVICE(0x0846, 0x9041, rtl92cu_hal_cfg)}, /*NetGear WNA1000M*/ {RTL_USB_DEVICE(0x0846, 0x9043, rtl92cu_hal_cfg)}, /*NG WNA1000Mv2*/
Greg Kroah-Hartman
maintainerPATCH 32/196 dm-integrity: limit MAX_TAG_SIZE to 255
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
[ Upstream commit 77b8e6fbf9848d651f5cb7508f18ad0971f3ffdb ]
MAX_TAG_SIZE was 0x1a8 and it may be truncated in the "bi->metadata_size = ic->tag_size" assignment. We need to limit it to 255.
--- drivers/md/dm-integrity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-integrity.c +1 -1
@@ -128,7 +128,7 @@ struct journal_sector {commit_id_t commit_id; }; -#define MAX_TAG_SIZE (JOURNAL_SECTOR_DATA - JOURNAL_MAC_PER_SECTOR - offsetof(struct journal_entry, last_bytes[MAX_SECTORS_PER_BLOCK])) +#define MAX_TAG_SIZE 255#define METADATA_PADDING_SECTORS 8
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 33/196 perf subcmd: avoid crash in exclude_cmds when excludes is empty
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: hupu <[email protected]>
[ Upstream commit a5edf3550f4260504b7e0ab3d40d13ffe924b773 ]
When cross-compiling the perf tool for ARM64, perf help may crash with the following assertion failure:
help.c:122: exclude_cmds: Assertion `cmds->names[ci] == NULL' failed.
This happens when the perf binary is not named exactly "perf" or when multiple "perf-*" binaries exist in the same directory. In such cases, the excludes command list can be empty, which leads to the final assertion in exclude_cmds() being triggered.
Add a simple guard at the beginning of exclude_cmds() to return early if excludes->cnt is zero, preventing the crash.
--- tools/lib/subcmd/help.c | 3 +++ 1 file changed, 3 insertions(+)
tools/lib/subcmd/help.c +3 -0
@@ -72,6 +72,9 @@ void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes)size_t ci, cj, ei;int cmp; +if (!excludes->cnt) +return ; + ci = cj = ei =0 ;while (ci < cmds->cnt && ei < excludes->cnt) { cmp =strcmp (cmds->names[ci]->name, excludes->names[ei]->name);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 34/196 ASoC: rt5682s: Adjust SAR ADC button mode to fix noise issue
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jack Yu <[email protected]>
[ Upstream commit 1dd28fd86c3fa4e395031dd6f2ba920242107010 ]
Adjust register settings for SAR adc button detection mode to fix noise issue in headset.
--- sound/soc/codecs/rt5682s.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
sound/soc/codecs/rt5682s.c +9 -8
@@ -653,14 +653,15 @@ static void rt5682s_sar_power_mode(struct snd_soc_component *component, int modeswitch (mode) {case SAR_PWR_SAVING :snd_soc_component_update_bits (component,RT5682S_CBJ_CTRL_3 , -RT5682S_CBJ_IN_BUF_MASK ,RT5682S_CBJ_IN_BUF_DIS ); +RT5682S_CBJ_IN_BUF_MASK ,RT5682S_CBJ_IN_BUF_EN );snd_soc_component_update_bits (component,RT5682S_CBJ_CTRL_1 , -RT5682S_MB1_PATH_MASK |RT5682S_MB2_PATH_MASK , -RT5682S_CTRL_MB1_REG |RT5682S_CTRL_MB2_REG ); +RT5682S_MB1_PATH_MASK |RT5682S_MB2_PATH_MASK | +RT5682S_VREF_POW_MASK ,RT5682S_CTRL_MB1_FSM | +RT5682S_CTRL_MB2_FSM |RT5682S_VREF_POW_FSM );snd_soc_component_update_bits (component,RT5682S_SAR_IL_CMD_1 ,RT5682S_SAR_BUTDET_MASK |RT5682S_SAR_BUTDET_POW_MASK |RT5682S_SAR_SEL_MB1_2_CTL_MASK ,RT5682S_SAR_BUTDET_DIS | -RT5682S_SAR_BUTDET_POW_SAV |RT5682S_SAR_SEL_MB1_2_MANU ); +RT5682S_SAR_BUTDET_POW_NORM |RT5682S_SAR_SEL_MB1_2_MANU );usleep_range (5000 ,5500 );snd_soc_component_update_bits (component,RT5682S_SAR_IL_CMD_1 ,RT5682S_SAR_BUTDET_MASK ,RT5682S_SAR_BUTDET_EN );
@@ -688,7 +689,7 @@ static void rt5682s_sar_power_mode(struct snd_soc_component *component, int modesnd_soc_component_update_bits (component,RT5682S_SAR_IL_CMD_1 ,RT5682S_SAR_BUTDET_MASK |RT5682S_SAR_BUTDET_POW_MASK |RT5682S_SAR_SEL_MB1_2_CTL_MASK ,RT5682S_SAR_BUTDET_DIS | -RT5682S_SAR_BUTDET_POW_SAV |RT5682S_SAR_SEL_MB1_2_MANU ); +RT5682S_SAR_BUTDET_POW_NORM |RT5682S_SAR_SEL_MB1_2_MANU );break ;default :dev_err (component->dev,"Invalid SAR Power mode: %d\n" , mode);
@@ -725,7 +726,7 @@ static void rt5682s_disable_push_button_irq(struct snd_soc_component *component)snd_soc_component_update_bits (component,RT5682S_SAR_IL_CMD_1 ,RT5682S_SAR_BUTDET_MASK |RT5682S_SAR_BUTDET_POW_MASK |RT5682S_SAR_SEL_MB1_2_CTL_MASK ,RT5682S_SAR_BUTDET_DIS | -RT5682S_SAR_BUTDET_POW_SAV |RT5682S_SAR_SEL_MB1_2_MANU ); +RT5682S_SAR_BUTDET_POW_NORM |RT5682S_SAR_SEL_MB1_2_MANU ); }/**
@@ -786,7 +787,7 @@ static int rt5682s_headset_detect(struct snd_soc_component *component, int jack_ jack_type =SND_JACK_HEADSET ;snd_soc_component_write (component,RT5682S_SAR_IL_CMD_3 ,0x024c );snd_soc_component_update_bits (component,RT5682S_CBJ_CTRL_1 , -RT5682S_FAST_OFF_MASK ,RT5682S_FAST_OFF_EN ); +RT5682S_FAST_OFF_MASK ,RT5682S_FAST_OFF_DIS );snd_soc_component_update_bits (component,RT5682S_SAR_IL_CMD_1 ,RT5682S_SAR_SEL_MB1_2_MASK , val <<RT5682S_SAR_SEL_MB1_2_SFT );rt5682s_enable_push_button_irq (component);
@@ -966,7 +967,7 @@ static int rt5682s_set_jack_detect(struct snd_soc_component *component,RT5682S_EMB_JD_MASK |RT5682S_DET_TYPE |RT5682S_POL_FAST_OFF_MASK |RT5682S_MIC_CAP_MASK ,RT5682S_EMB_JD_EN |RT5682S_DET_TYPE | - RT5682S_POL_FAST_OFF_HIGH | RT5682S_MIC_CAP_HS); + RT5682S_POL_FAST_OFF_LOW | RT5682S_MIC_CAP_HS);regmap_update_bits (rt5682s->regmap,RT5682S_SAR_IL_CMD_1 ,RT5682S_SAR_POW_MASK ,RT5682S_SAR_POW_EN ); regmap_update_bits(rt5682s->regmap, RT5682S_GPIO_CTRL_1,
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 35/196 btrfs: ref-verify: handle damaged extent root tree
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Sterba <[email protected]>
[ Upstream commit ed4e6b5d644c4dd2bc2872ffec036b7da0ec2e27 ]
Syzbot hits a problem with enabled ref-verify, ignorebadroots and a fuzzed/damaged extent tree. There's no fallback option like in other places that can deal with it so disable the whole ref-verify as it is just a debugging feature.
--- fs/btrfs/ref-verify.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
fs/btrfs/ref-verify.c +8 -1
@@ -987,11 +987,18 @@ int btrfs_build_ref_tree(struct btrfs_fs_info *fs_info)if (!btrfs_test_opt (fs_info,REF_VERIFY ))return 0 ; + extent_root =btrfs_extent_root (fs_info,0 ); +/* If the extent tree is damaged we cannot ignore it (IGNOREBADROOTS). */ +if (IS_ERR (extent_root)) { +btrfs_warn (fs_info,"ref-verify: extent tree not available, disabling" ); +btrfs_clear_opt (fs_info->mount_opt,REF_VERIFY ); +return 0 ; + } + path =btrfs_alloc_path ();if (!path)return -ENOMEM ; - extent_root =btrfs_extent_root (fs_info,0 ); eb =btrfs_read_lock_root_node (extent_root); level =btrfs_header_level (eb); path->nodes[level] = eb;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 36/196 can: hi311x: fix null pointer dereference when resuming from sleep before interface was enabled
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Yufeng <[email protected]>
[ Upstream commit 6b696808472197b77b888f50bc789a3bae077743 ]
This issue is similar to the vulnerability in the mcp251x driver, which was fixed in commit 03c427147b2d ("can: mcp251x: fix resume from sleep before interface was brought up").
In the hi311x driver, when the device resumes from sleep, the driver schedules priv->restart_work. However, if the network interface was not previously enabled, the priv->wq (workqueue) is not allocated and initialized, leading to a null pointer dereference.
To fix this, we move the allocation and initialization of the workqueue from the hi3110_open function to the hi3110_can_probe function. This ensures that the workqueue is properly initialized before it is used during device resume. And added logic to destroy the workqueue in the error handling paths of hi3110_can_probe and in the hi3110_can_remove function to prevent resource leaks.
--- drivers/net/can/spi/hi311x.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-)
drivers/net/can/spi/hi311x.c +17 -16
@@ -545,8 +545,6 @@ static int hi3110_stop(struct net_device *net) priv->force_quit =1 ;free_irq (spi->irq, priv); -destroy_workqueue (priv->wq); - priv->wq =NULL ;mutex_lock (&priv->hi3110_lock);
@@ -771,34 +769,23 @@ static int hi3110_open(struct net_device *net) goto out_close; } - priv->wq =alloc_workqueue ("hi3110_wq" ,WQ_FREEZABLE |WQ_MEM_RECLAIM , -0 ); -if (!priv->wq) { - ret = -ENOMEM ; - goto out_free_irq; - } -INIT_WORK (&priv->tx_work, hi3110_tx_work_handler); -INIT_WORK (&priv->restart_work, hi3110_restart_work_handler); - ret =hi3110_hw_reset (spi);if (ret) - goto out_free_wq; + goto out_free_irq; ret =hi3110_setup (net);if (ret) - goto out_free_wq; + goto out_free_irq; ret =hi3110_set_normal_mode (spi);if (ret) - goto out_free_wq; + goto out_free_irq;netif_wake_queue (net);mutex_unlock (&priv->hi3110_lock);return 0 ; - out_free_wq: -destroy_workqueue (priv->wq); out_free_irq:free_irq (spi->irq, priv);hi3110_hw_sleep (spi);
@@ -915,6 +902,15 @@ static int hi3110_can_probe(struct spi_device *spi)if (ret) goto out_clk; + priv->wq =alloc_workqueue ("hi3110_wq" ,WQ_FREEZABLE |WQ_MEM_RECLAIM , +0 ); +if (!priv->wq) { + ret = -ENOMEM ; + goto out_clk; + } +INIT_WORK (&priv->tx_work, hi3110_tx_work_handler); +INIT_WORK (&priv->restart_work, hi3110_restart_work_handler); + priv->spi = spi;mutex_init (&priv->hi3110_lock);
@@ -950,6 +946,8 @@ static int hi3110_can_probe(struct spi_device *spi)return 0 ; error_probe: +destroy_workqueue (priv->wq); + priv->wq =NULL ;hi3110_power_enable (priv->power,0 ); out_clk:
@@ -970,6 +968,9 @@ static void hi3110_can_remove(struct spi_device *spi)hi3110_power_enable (priv->power,0 ); +destroy_workqueue (priv->wq); + priv->wq =NULL ; +clk_disable_unprepare (priv->clk);free_candev (net);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 37/196 can: rcar_canfd: Fix controller mode setting
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duy Nguyen <[email protected]>
[ Upstream commit 5cff263606a10102a0ea19ff579eaa18fd5577ad ]
Driver configures register to choose controller mode before setting all channels to reset mode leading to failure. The patch corrects operation of mode setting.
--- drivers/net/can/rcar/rcar_canfd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/can/rcar/rcar_canfd.c +4 -3
@@ -717,9 +717,6 @@ static int rcar_canfd_reset_controller(struct rcar_canfd_global *gpriv)/* Reset Global error flags */ rcar_canfd_write (gpriv->base,RCANFD_GERFL ,0x0 ); -/* Set the controller into appropriate mode */ -rcar_canfd_set_mode (gpriv); -/* Transition all Channels to reset mode */ for_each_set_bit (ch, &gpriv->channels_mask, gpriv->max_channels) { rcar_canfd_clear_bit(gpriv->base,
@@ -739,6 +736,10 @@ static int rcar_canfd_reset_controller(struct rcar_canfd_global *gpriv)return err; } } + +/* Set the controller into appropriate mode */ +rcar_canfd_set_mode (gpriv); +return 0 ; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 38/196 hid: fix I2C read buffer overflow in raw_event() for mcp2221
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaud Lecomte <[email protected]>
commit b56cc41a3ae7323aa3c6165f93c32e020538b6d2 upstream.
As reported by syzbot, mcp2221_raw_event lacked validation of incoming I2C read data sizes, risking buffer overflows in mcp->rxbuf during multi-part transfers. As highlighted in the DS20005565B spec, p44, we have:
"The number of read-back data bytes to follow in this packet:
from 0 to a maximum of 60 bytes of read-back bytes." This patch enforces we don't exceed this limit.
--- drivers/hid/hid-mcp2221.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/hid/hid-mcp2221.c +4 -0
@@ -791,6 +791,10 @@ static int mcp2221_raw_event(struct hid_ }if (data[2 ] ==MCP2221_I2C_READ_COMPL || data[2 ] ==MCP2221_I2C_READ_PARTIAL ) { +if (!mcp->rxbuf || mcp->rxbuf_idx <0 || data[3 ] >60 ) { + mcp->status = -EINVAL ; +break ; + } buf = mcp->rxbuf;memcpy (&buf[mcp->rxbuf_idx], &data[4 ], data[3 ]); mcp->rxbuf_idx = mcp->rxbuf_idx + data[3 ];
Greg Kroah-Hartman
maintainerPATCH 39/196 serial: stm32: allow selecting console when the driver is module
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raphael Gallais-Pou <[email protected]>
commit cc4d900d0d6d8dd5c41832a93ff3cfa629a78f9a upstream.
Console can be enabled on the UART compile as module.
Change dependency to allow console mode when the driver is built as module.
--- drivers/tty/serial/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/Kconfig +1 -1
@@ -1410,7 +1410,7 @@ config SERIAL_STM32 config SERIAL_STM32_CONSOLE bool "Support for console on STM32" - depends on SERIAL_STM32=y + depends on SERIAL_STM32 select SERIAL_CORE_CONSOLE select SERIAL_EARLYCON
Greg Kroah-Hartman
maintainerPATCH 40/196 staging: axis-fifo: fix maximum TX packet length check
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ovidiu Panait <[email protected]>
commit 52ff2b840bc723f3be1f096f8017c78e0515858c upstream.
Since commit 2ca34b508774 ("staging: axis-fifo: Correct handling of tx_fifo_depth for size validation"), write() operations with packets larger than 'tx_fifo_depth - 4' words are no longer rejected with -EINVAL.
Fortunately, the packets are not actually getting transmitted to hardware, otherwise they would be raising a 'Transmit Packet Overrun Error' interrupt, which requires a reset of the TX circuit to recover from.
Instead, the request times out inside wait_event_interruptible_timeout() and always returns -EAGAIN, since the wake up condition can never be true for these packets. But still, they unnecessarily block other tasks from writing to the FIFO and the EAGAIN return code signals userspace to retry the write() call, even though it will always fail and time out.
According to the AXI4-Stream FIFO reference manual (PG080), the maximum valid packet length is 'tx_fifo_depth - 4' words, so attempting to send larger packets is invalid and should not be happening in the first place:
Quoted 2 lines
The maximum packet that can be transmitted is limited by the size of the FIFO, which is (C_TX_FIFO_DEPTH–4)*(data interface width/8) bytes.
Therefore, bring back the old behavior and outright reject packets larger than 'tx_fifo_depth - 4' with -EINVAL. Add a comment to explain why the check is necessary. The dev_err() message was removed to avoid cluttering the dmesg log if an invalid packet is received from userspace.
--- drivers/staging/axis-fifo/axis-fifo.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/staging/axis-fifo/axis-fifo.c +10 -4
@@ -493,11 +493,17 @@ static ssize_t axis_fifo_write(struct fireturn -EINVAL ; } -if (words_to_write > fifo->tx_fifo_depth) { -dev_err (fifo->dt_device,"tried to write more words [%u] than slots in the fifo buffer [%u]\n" , - words_to_write, fifo->tx_fifo_depth); +/* +* In 'Store-and-Forward' mode, the maximum packet that can be +* transmitted is limited by the size of the FIFO, which is +* (C_TX_FIFO_DEPTH–4)*(data interface width/8) bytes. +* +* Do not attempt to send a packet larger than 'tx_fifo_depth - 4', +* otherwise a 'Transmit Packet Overrun Error' interrupt will be +* raised, which requires a reset of the TX circuit to recover. +*/ +if (words_to_write > (fifo->tx_fifo_depth -4 ))return -EINVAL ; - }if (fifo->write_flags &O_NONBLOCK ) {/*
Greg Kroah-Hartman
maintainerPATCH 41/196 staging: axis-fifo: fix TX handling on copy_from_user() failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ovidiu Panait <[email protected]>
commit 6d07bee10e4bdd043ec7152cbbb9deb27033c9e2 upstream.
If copy_from_user() fails, write() currently returns -EFAULT, but any partially written data leaves the TX FIFO in an inconsistent state. Subsequent write() calls then fail with "transmit length mismatch" errors.
Once partial data is written to the hardware FIFO, it cannot be removed without a TX reset. Commit c6e8d85fafa7 ("staging: axis-fifo: Remove hardware resets for user errors") removed a full FIFO reset for this case, which fixed a potential RX data loss, but introduced this TX issue.
Fix this by introducing a bounce buffer: copy the full packet from userspace first, and write to the hardware FIFO only if the copy was successful.
--- drivers/staging/axis-fifo/axis-fifo.c | 36 +++++++++------------------------- 1 file changed, 10 insertions(+), 26 deletions(-)
drivers/staging/axis-fifo/axis-fifo.c +10 -26
@@ -44,7 +44,6 @@#define DRIVER_NAME "axis_fifo"#define READ_BUF_SIZE 128U/* read buffer length in words */ -#define WRITE_BUF_SIZE 128U/* write buffer length in words */ /* ---------------------------- * IP register offsets
@@ -473,11 +472,8 @@ static ssize_t axis_fifo_write(struct fi {struct axis_fifo *fifo = (struct axis_fifo *)f->private_data;unsigned int words_to_write; -unsigned int copied; -unsigned int copy; -unsigned int i; +u32 *txbuf;int ret; -u32 tmp_buf[WRITE_BUF_SIZE ];if (len %sizeof (u32)) { dev_err(fifo->dt_device,
@@ -542,32 +538,20 @@ static ssize_t axis_fifo_write(struct fi } } -/* write data from an intermediate buffer into the fifo IP, refilling -* the buffer with userspace data as needed -*/ - copied =0 ; -while (words_to_write >0 ) { - copy =min (words_to_write,WRITE_BUF_SIZE ); - -if (copy_from_user (tmp_buf, buf + copied *sizeof (u32), - copy *sizeof (u32))) { - ret = -EFAULT ; - goto end_unlock; - } - -for (i =0 ; i < copy; i++) -iowrite32 (tmp_buf[i], fifo->base_addr + -XLLF_TDFD_OFFSET ); - - copied += copy; - words_to_write -= copy; + txbuf =vmemdup_user (buf, len); +if (IS_ERR (txbuf)) { + ret =PTR_ERR (txbuf); + goto end_unlock; } - ret = copied *sizeof (u32); +for (int i =0 ; i < words_to_write; ++i) +iowrite32 (txbuf[i], fifo->base_addr +XLLF_TDFD_OFFSET );/* write packet size to fifo */ -iowrite32 (ret, fifo->base_addr +XLLF_TLR_OFFSET ); +iowrite32 (len, fifo->base_addr +XLLF_TLR_OFFSET ); + ret = len; +kvfree (txbuf); end_unlock:mutex_unlock (&fifo->write_lock);
Greg Kroah-Hartman
maintainerPATCH 42/196 staging: axis-fifo: flush RX FIFO on read errors
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ovidiu Panait <[email protected]>
commit 82a051e2553b9e297cba82a975d9c538b882c79e upstream.
Flush stale data from the RX FIFO in case of errors, to avoid reading old data when new packets arrive.
Commit c6e8d85fafa7 ("staging: axis-fifo: Remove hardware resets for user errors") removed full FIFO resets from the read error paths, which fixed potential TX data losses, but introduced this RX issue.
--- drivers/staging/axis-fifo/axis-fifo.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/staging/axis-fifo/axis-fifo.c +11 -7
@@ -398,6 +398,7 @@ static ssize_t axis_fifo_read(struct fil } bytes_available =ioread32 (fifo->base_addr +XLLF_RLR_OFFSET ); + words_available = bytes_available /sizeof (u32);if (!bytes_available) {dev_err (fifo->dt_device,"received a packet of length 0\n" ); ret = -EIO ;
@@ -408,7 +409,7 @@ static ssize_t axis_fifo_read(struct fildev_err (fifo->dt_device,"user read buffer too small (available bytes=%zu user buffer bytes=%zu)\n" , bytes_available, len); ret = -EINVAL ; - goto end_unlock; + goto err_flush_rx; }if (bytes_available %sizeof (u32)) {
@@ -417,11 +418,9 @@ static ssize_t axis_fifo_read(struct fil*/ dev_err (fifo->dt_device,"received a packet that isn't word-aligned\n" ); ret = -EIO ; - goto end_unlock; + goto err_flush_rx; } - words_available = bytes_available /sizeof (u32); -/* read data into an intermediate buffer, copying the contents * to userspace when the buffer is full */
@@ -433,18 +432,23 @@ static ssize_t axis_fifo_read(struct fil tmp_buf[i] =ioread32 (fifo->base_addr +XLLF_RDFD_OFFSET ); } + words_available -= copy;if (copy_to_user (buf + copied *sizeof (u32), tmp_buf, copy *sizeof (u32))) { ret = -EFAULT ; - goto end_unlock; + goto err_flush_rx; } copied += copy; - words_available -= copy; } +mutex_unlock (&fifo->read_lock); + +return bytes_available; - ret = bytes_available; +err_flush_rx: +while (words_available--) +ioread32 (fifo->base_addr +XLLF_RDFD_OFFSET ); end_unlock:mutex_unlock (&fifo->read_lock);
Greg Kroah-Hartman
maintainerPATCH 43/196 driver core/PM: Set power.no_callbacks along with power.no_pm
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
commit c2ce2453413d429e302659abc5ace634e873f6f5 upstream.
Devices with power.no_pm set are not expected to need any power management at all, so modify device_set_pm_not_required() to set power.no_callbacks for them too in case runtime PM will be enabled for any of them (which in principle may be done for convenience if such a device participates in a dependency chain).
Since device_set_pm_not_required() must be called before device_add() or it would not have any effect, it can update power.no_callbacks without locking, unlike pm_runtime_no_callbacks() that can be called after registering the target device.
--- include/linux/device.h | 3 +++ 1 file changed, 3 insertions(+)
include/linux/device.h +3 -0
@@ -813,6 +813,9 @@ static inline bool device_pm_not_requirestatic inline void device_set_pm_not_required (struct device *dev) { dev->power.no_pm = true; +#ifdef CONFIG_PM + dev->power.no_callbacks = true; +#endif }static inline void dev_pm_syscore_device (struct device *dev,bool val)
Greg Kroah-Hartman
maintainerPATCH 44/196 crypto: rng - Ensure set_ent is always present
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
commit c0d36727bf39bb16ef0a67ed608e279535ebf0da upstream.
Ensure that set_ent is always set since only drbg provides it.
--- crypto/rng.c | 8 ++++++++ 1 file changed, 8 insertions(+)
crypto/rng.c +8 -0
@@ -174,6 +174,11 @@ out:EXPORT_SYMBOL_GPL (crypto_del_default_rng);#endif +static void rng_default_set_ent (struct crypto_rng *tfm,const u8 *data, +unsigned int len) +{ +} +int crypto_register_rng (struct rng_alg *alg) {struct crypto_alg *base = &alg->base;
@@ -185,6 +190,9 @@ int crypto_register_rng(struct rng_alg * base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK ; base->cra_flags |=CRYPTO_ALG_TYPE_RNG ; +if (!alg->set_ent) + alg->set_ent = rng_default_set_ent; +return crypto_register_alg (base); }EXPORT_SYMBOL_GPL (crypto_register_rng);
Greg Kroah-Hartman
maintainerPATCH 45/196 net/9p: fix double req put in p9_fd_cancelled
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nalivayko Sergey <[email protected]>
commit 674b56aa57f9379854cb6798c3bbcef7e7b51ab7 upstream.
Syzkaller reports a KASAN issue as below:
general protection fault, probably for non-canonical address 0xfbd59c0000000021: 0000 [#1] PREEMPT SMP KASAN NOPTI KASAN: maybe wild-memory-access in range [0xdead000000000108-0xdead00000000010f] CPU: 0 PID: 5083 Comm: syz-executor.2 Not tainted 6.1.134-syzkaller-00037-g855bd1d7d838 #0 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014 RIP: 0010:__list_del include/linux/list.h:114 [inline] RIP: 0010:__list_del_entry include/linux/list.h:137 [inline] RIP: 0010:list_del include/linux/list.h:148 [inline] RIP: 0010:p9_fd_cancelled+0xe9/0x200 net/9p/trans_fd.c:734 Call Trace: <TASK> p9_client_flush+0x351/0x440 net/9p/client.c:614 p9_client_rpc+0xb6b/0xc70 net/9p/client.c:734 p9_client_version net/9p/client.c:920 [inline] p9_client_create+0xb51/0x1240 net/9p/client.c:1027 v9fs_session_init+0x1f0/0x18f0 fs/9p/v9fs.c:408 v9fs_mount+0xba/0xcb0 fs/9p/vfs_super.c:126 legacy_get_tree+0x108/0x220 fs/fs_context.c:632 vfs_get_tree+0x8e/0x300 fs/super.c:1573 do_new_mount fs/namespace.c:3056 [inline] path_mount+0x6a6/0x1e90 fs/namespace.c:3386 do_mount fs/namespace.c:3399 [inline] __do_sys_mount fs/namespace.c:3607 [inline] __se_sys_mount fs/namespace.c:3584 [inline] __x64_sys_mount+0x283/0x300 fs/namespace.c:3584 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x35/0x80 arch/x86/entry/common.c:81 entry_SYSCALL_64_after_hwframe+0x6e/0xd8
This happens because of a race condition between:
- The 9p client sending an invalid flush request and later cleaning it up;
- The 9p client in p9_read_work() canceled all pending requests.
Thread 1 Thread 2
...
p9_client_create()
...
p9_fd_create()
...
p9_conn_create()
...
// start Thread 2
INIT_WORK(&m->rq, p9_read_work);
p9_read_work()
...
p9_client_rpc()
...
...
p9_conn_cancel()
...
spin_lock(&m->req_lock);
...
p9_fd_cancelled()
...
...
spin_unlock(&m->req_lock);
// status rewrite
p9_client_cb(m->client, req, REQ_STATUS_ERROR)
// first remove
list_del(&req->req_list);
...
spin_lock(&m->req_lock)
...
// second remove
list_del(&req->req_list);
spin_unlock(&m->req_lock)...
Commit 74d6a5d56629 ("9p/trans_fd: Fix concurrency del of req_list in p9_fd_cancelled/p9_read_work") fixes a concurrency issue in the 9p filesystem client where the req_list could be deleted simultaneously by both p9_read_work and p9_fd_cancelled functions, but for the case where req->status equals REQ_STATUS_RCVD.
Update the check for req->status in p9_fd_cancelled to skip processing not just received requests, but anything that is not SENT, as whatever changed the state from SENT also removed the request from its list.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
Message-ID: <[email protected]>
--- net/9p/trans_fd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/9p/trans_fd.c +4 -4
@@ -720,10 +720,10 @@ static int p9_fd_cancelled(struct p9_clip9_debug (P9_DEBUG_TRANS ,"client %p req %p\n" , client, req);spin_lock (&m->req_lock); -/* Ignore cancelled request if message has been received -* before lock. -*/ -if (req->status ==REQ_STATUS_RCVD ) { +/* Ignore cancelled request if status changed since the request was +* processed in p9_client_flush() +*/ +if (req->status !=REQ_STATUS_SENT ) {spin_unlock (&m->req_lock);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 46/196 filelock: add FL_RECLAIM to show_fl_flags() macro
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Layton <[email protected]>
[ Upstream commit c593b9d6c446510684da400833f9d632651942f0 ]
Show the FL_RECLAIM flag symbolically in tracepoints.
--- include/trace/events/filelock.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/trace/events/filelock.h +2 -1
@@ -27,7 +27,8 @@ { FL_SLEEP, "FL_SLEEP" }, \ { FL_DOWNGRADE_PENDING, "FL_DOWNGRADE_PENDING" }, \ { FL_UNLOCK_PENDING, "FL_UNLOCK_PENDING" }, \ - { FL_OFDLCK, "FL_OFDLCK" }) + { FL_OFDLCK, "FL_OFDLCK" }, \ + { FL_RECLAIM, "FL_RECLAIM"}) #define show_fl_type(val) \ __print_symbolic(val, \
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 47/196 init: INITRAMFS_PRESERVE_MTIME should depend on BLK_DEV_INITRD
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit 74792608606a525a0e0df7e8d48acd8000561389 ]
INITRAMFS_PRESERVE_MTIME is only used in init/initramfs.c and init/initramfs_test.c. Hence add a dependency on BLK_DEV_INITRD, to prevent asking the user about this feature when configuring a kernel without initramfs support.
--- init/Kconfig | 1 + 1 file changed, 1 insertion(+)
init/Kconfig +1 -0
@@ -1405,6 +1405,7 @@ config BOOT_CONFIG_EMBED_FILE config INITRAMFS_PRESERVE_MTIME bool "Preserve cpio archive mtimes in initramfs" + depends on BLK_DEV_INITRD default y help Each entry in an initramfs cpio archive carries an mtime value. When
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 48/196 seccomp: Fix a race with WAIT_KILLABLE_RECV if the tracer replies too fast
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Nixdorf <[email protected]>
[ Upstream commit cce436aafc2abad691fdd37de63ec8a4490b42ce ]
Normally the tracee starts in SECCOMP_NOTIFY_INIT, sends an event to the tracer, and starts to wait interruptibly. With SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV, if the tracer receives the message (SECCOMP_NOTIFY_SENT is reached) while the tracee was waiting and is subsequently interrupted, the tracee begins to wait again uninterruptibly (but killable).
This fails if SECCOMP_NOTIFY_REPLIED is reached before the tracee is interrupted, as the check only considered SECCOMP_NOTIFY_SENT as a condition to begin waiting again. In this case the tracee is interrupted even though the tracer already acted on its behalf. This breaks the assumption SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV wanted to ensure, namely that the tracer can be sure the syscall is not interrupted or restarted on the tracee after it is received on the tracer. Fix this by also considering SECCOMP_NOTIFY_REPLIED when evaluating whether to switch to uninterruptible waiting.
With the condition changed the loop in seccomp_do_user_notification() would exit immediately after deciding that noninterruptible waiting is required if the operation already reached SECCOMP_NOTIFY_REPLIED, skipping the code that processes pending addfd commands first. Prevent this by executing the remaining loop body one last time in this case.
--- kernel/seccomp.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
kernel/seccomp.c +5 -7
@@ -1090,7 +1090,7 @@ static void seccomp_handle_addfd(struct seccomp_kaddfd *addfd, struct seccomp_knstatic bool should_sleep_killable (struct seccomp_filter *match,struct seccomp_knotif *n) { -return match->wait_killable_recv && n->state ==SECCOMP_NOTIFY_SENT ; +return match->wait_killable_recv && n->state >=SECCOMP_NOTIFY_SENT ; } static int seccomp_do_user_notification(int this_syscall,
@@ -1134,13 +1134,11 @@ static int seccomp_do_user_notification(int this_syscall,if (err !=0 ) {/* -* Check to see if the notifcation got picked up and -* whether we should switch to wait killable. +* Check to see whether we should switch to wait +* killable. Only return the interrupted error if not. */ -if (!wait_killable &&should_sleep_killable (match, &n)) -continue ; - - goto interrupted; +if (!(!wait_killable &&should_sleep_killable (match, &n))) + goto interrupted; } addfd = list_first_entry_or_null(&n.addfd,
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 49/196 selftests: arm64: Check fread return value in exec_target
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bala-Vignesh-Reddy <[email protected]>
[ Upstream commit a679e5683d3eef22ca12514ff8784b2b914ebedc ]
Fix -Wunused-result warning generated when compiled with gcc 13.3.0, by checking fread's return value and handling errors, preventing potential failures when reading from stdin.
Fixes compiler warning:
warning: ignoring return value of 'fread' declared with attribute 'warn_unused_result' [-Wunused-result]
--- tools/testing/selftests/arm64/pauth/exec_target.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tools/testing/selftests/arm64/pauth/exec_target.c +6 -1
@@ -13,7 +13,12 @@ int main(void)unsigned long hwcaps;size_t val; -fread (&val,sizeof (size_t ),1 , stdin); +size_t size =fread (&val,sizeof (size_t ),1 , stdin); + +if (size !=1 ) { +fprintf (stderr,"Could not read input from stdin\n" ); +return EXIT_FAILURE ; + }/* don't try to execute illegal (unimplemented) instructions) caller * should have checked this and keep worker simple
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 50/196 coresight: trbe: Prevent overflow in PERF_IDX2OFF()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Yan <[email protected]>
[ Upstream commit 105f56877f2d5f82d71e20b45eb7be7c24c3d908 ]
Cast nr_pages to unsigned long to avoid overflow when handling large AUX buffer sizes (>= 2 GiB).
--- drivers/hwtracing/coresight/coresight-trbe.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-trbe.c +2 -1
@@ -21,7 +21,8 @@#include "coresight-self-hosted-trace.h" #include "coresight-trbe.h" -#define PERF_IDX2OFF (idx, buf) ((idx) % ((buf)->nr_pages << PAGE_SHIFT)) +#define PERF_IDX2OFF (idx, buf) \ + ((idx) % ((unsigned long)(buf)->nr_pages << PAGE_SHIFT))/* * A padding packet that will help the user space tools
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 51/196 perf: arm_spe: Prevent overflow in PERF_IDX2OFF()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Yan <[email protected]>
[ Upstream commit a29fea30dd93da16652930162b177941abd8c75e ]
Cast nr_pages to unsigned long to avoid overflow when handling large AUX buffer sizes (>= 2 GiB).
--- drivers/perf/arm_spe_pmu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/perf/arm_spe_pmu.c +2 -1
@@ -95,7 +95,8 @@ struct arm_spe_pmu {#define to_spe_pmu (p) (container_of(p, struct arm_spe_pmu, pmu))/* Convert a free-running index from perf into an SPE buffer offset */ -#define PERF_IDX2OFF (idx, buf) ((idx) % ((buf)->nr_pages << PAGE_SHIFT)) +#define PERF_IDX2OFF (idx, buf) \ + ((idx) % ((unsigned long)(buf)->nr_pages << PAGE_SHIFT))/* Keep track of our dynamic hotplug state */ static enum cpuhp_state arm_spe_pmu_online;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 52/196 smb: server: fix IRD/ORD negotiation with the client
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Metzmacher <[email protected]>
[ Upstream commit fad988a2158d743da7971884b93482a73735b25e ]
Already do real negotiation in smb_direct_handle_connect_request() where we see the requested initiator_depth and responder_resources from the client.
We should detect legacy iwarp clients using MPA v1 with the custom IRD/ORD negotiation.
We need to send the custom IRD/ORD in big endian, but we need to try to let clients with broken requests using little endian (older cifs.ko) to work.
Note the reason why this uses u8 forinitiator_depth and responder_resources is
that the rdma layer also uses it.
--- fs/smb/server/transport_rdma.c | 99 +++++++++++++++++++++++++++++----- 1 file changed, 85 insertions(+), 14 deletions(-)
fs/smb/server/transport_rdma.c +85 -14
@@ -152,6 +152,10 @@ struct smb_direct_transport {struct work_struct disconnect_work;bool negotiation_requested; + +bool legacy_iwarp; +u8 initiator_depth; +u8 responder_resources; };#define KSMBD_TRANS (t) ((struct ksmbd_transport *)&((t)->transport))
@@ -345,6 +349,9 @@ static struct smb_direct_transport *alloc_transport(struct rdma_cm_id *cm_id) t->cm_id = cm_id; cm_id->context = t; + t->initiator_depth =SMB_DIRECT_CM_INITIATOR_DEPTH ; + t->responder_resources =1 ; + t->status =SMB_DIRECT_CS_NEW ;init_waitqueue_head (&t->wait_status);
@@ -1618,21 +1625,21 @@ static int smb_direct_send_negotiate_response(struct smb_direct_transport *t,static int smb_direct_accept_client (struct smb_direct_transport *t) {struct rdma_conn_param conn_param; -struct ib_port_immutable port_immutable; -u32 ird_ord_hdr[2 ]; +__be32 ird_ord_hdr[2 ];int ret; +/* +* smb_direct_handle_connect_request() +* already negotiated t->initiator_depth +* and t->responder_resources +*/ memset (&conn_param,0 ,sizeof (conn_param)); - conn_param.initiator_depth =min_t (u8, t->cm_id->device->attrs.max_qp_rd_atom, -SMB_DIRECT_CM_INITIATOR_DEPTH ); - conn_param.responder_resources =0 ; - - t->cm_id->device->ops.get_port_immutable (t->cm_id->device, - t->cm_id->port_num, - &port_immutable); -if (port_immutable.core_cap_flags &RDMA_CORE_PORT_IWARP ) { - ird_ord_hdr[0 ] = conn_param.responder_resources; - ird_ord_hdr[1 ] =1 ; + conn_param.initiator_depth = t->initiator_depth; + conn_param.responder_resources = t->responder_resources; + +if (t->legacy_iwarp) { + ird_ord_hdr[0 ] =cpu_to_be32 (conn_param.responder_resources); + ird_ord_hdr[1 ] =cpu_to_be32 (conn_param.initiator_depth); conn_param.private_data = ird_ord_hdr; conn_param.private_data_len =sizeof (ird_ord_hdr); }else {
@@ -2018,10 +2025,13 @@ static bool rdma_frwr_is_supported(struct ib_device_attr *attrs)return true; } -static int smb_direct_handle_connect_request (struct rdma_cm_id *new_cm_id) +static int smb_direct_handle_connect_request (struct rdma_cm_id *new_cm_id, +struct rdma_cm_event *event) {struct smb_direct_transport *t;struct task_struct *handler; +u8 peer_initiator_depth; +u8 peer_responder_resources;int ret;if (!rdma_frwr_is_supported (&new_cm_id->device->attrs)) {
@@ -2035,6 +2045,67 @@ static int smb_direct_handle_connect_request(struct rdma_cm_id *new_cm_id)if (!t)return -ENOMEM ; + peer_initiator_depth = event->param.conn.initiator_depth; + peer_responder_resources = event->param.conn.responder_resources; +if (rdma_protocol_iwarp (new_cm_id->device, new_cm_id->port_num) && + event->param.conn.private_data_len ==8 ) { +/* +* Legacy clients with only iWarp MPA v1 support +* need a private blob in order to negotiate +* the IRD/ORD values. +*/ +const __be32 *ird_ord_hdr = event->param.conn.private_data; +u32 ird32 =be32_to_cpu (ird_ord_hdr[0 ]); +u32 ord32 =be32_to_cpu (ird_ord_hdr[1 ]); + +/* +* cifs.ko sends the legacy IRD/ORD negotiation +* event if iWarp MPA v2 was used. +* +* Here we check that the values match and only +* mark the client as legacy if they don't match. +*/ +if ((u32 )event->param.conn.initiator_depth != ird32 || + (u32 )event->param.conn.responder_resources != ord32) { +/* +* There are broken clients (old cifs.ko) +* using little endian and also +* struct rdma_conn_param only uses u8 +* for initiator_depth and responder_resources, +* so we truncate the value to U8_MAX. +* +* smb_direct_accept_client() will then +* do the real negotiation in order to +* select the minimum between client and +* server. +*/ + ird32 =min_t (u32, ird32,U8_MAX ); + ord32 =min_t (u32, ord32,U8_MAX ); + + t->legacy_iwarp = true; + peer_initiator_depth = (u8 )ird32; + peer_responder_resources = (u8 )ord32; + } + } + +/* +* First set what the we as server are able to support +*/ + t->initiator_depth =min_t (u8, t->initiator_depth, + new_cm_id->device->attrs.max_qp_rd_atom); + +/* +* negotiate the value by using the minimum +* between client and server if the client provided +* non 0 values. +*/ +if (peer_initiator_depth !=0 ) + t->initiator_depth =min_t (u8, t->initiator_depth, + peer_initiator_depth); +if (peer_responder_resources !=0 ) + t->responder_resources =min_t (u8, t->responder_resources, + peer_responder_resources); + ret =smb_direct_connect (t);if (ret) goto out_err;
@@ -2059,7 +2130,7 @@ static int smb_direct_listen_handler(struct rdma_cm_id *cm_id, {switch (event->event) {case RDMA_CM_EVENT_CONNECT_REQUEST : { -int ret =smb_direct_handle_connect_request (cm_id); +int ret =smb_direct_handle_connect_request (cm_id, event);if (ret) {pr_err ("Can't create transport: %d\n" , ret);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 53/196 x86/vdso: Fix output operand size of RDPID
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uros Bizjak <[email protected]>
[ Upstream commit ac9c408ed19d535289ca59200dd6a44a6a2d6036 ]
RDPID instruction outputs to a word-sized register (64-bit on x86_64 and 32-bit on x86_32). Use an unsigned long variable to store the correct size.
LSL outputs to 32-bit register, use %k operand prefix to always print the 32-bit name of the register.
Use RDPID insn mnemonic while at it as the minimum binutils version of 2.30 supports it.
[ bp: Merge two patches touching the same function into a single one. ]
--- arch/x86/include/asm/segment.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/x86/include/asm/segment.h +4 -4
@@ -243,7 +243,7 @@ static inline unsigned long vdso_encode_cpunode(int cpu, unsigned long node)static inline void vdso_read_cpunode (unsigned *cpu,unsigned *node) { -unsigned int p; +unsigned long p;/* * Load CPU and node number from the GDT. LSL is faster than RDTSCP
@@ -253,10 +253,10 @@ static inline void vdso_read_cpunode(unsigned *cpu, unsigned *node)* * If RDPID is available, use it. */ -alternative_io ("lsl %[seg],%[p]" , -".byte 0xf3,0x0f,0xc7,0xf8" ,/* RDPID %eax/rax */ +alternative_io ("lsl %[seg],%k[p]" , +"rdpid %[p]" , X86_FEATURE_RDPID, - [p] "=a" (p), [seg] "r" (__CPUNODE_SEG)); + [p] "=r" (p), [seg] "r" (__CPUNODE_SEG)); if (cpu) *cpu = (p & VDSO_CPUNODE_MASK);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 54/196 arm64: dts: renesas: rzg2lc-smarc: Disable CAN-FD channel0
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
[ Upstream commit ae014fbc99c7f986ee785233e7a5336834e39af4 ]
On RZ/G2LC SMARC EVK, CAN-FD channel0 is not populated, and currently we are deleting a wrong and nonexistent node. Fixing the wrong node would invoke a dtb warning message, as channel0 is a required property. Disable CAN-FD channel0 instead of deleting the node.
--- arch/arm64/boot/dts/renesas/rzg2lc-smarc.dtsi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/renesas/rzg2lc-smarc.dtsi +4 -1
@@ -50,7 +50,10 @@ aliases { #if (SW_SCIF_CAN || SW_RSPI_CAN) &canfd { pinctrl-0 = <&can1_pins>; - /delete-node/ channel@0; + + channel0 { + status = "disabled"; + }; }; #else &canfd {
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 55/196 regmap: Remove superfluous check for !config in __regmap_init()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit 5c36b86d2bf68fbcad16169983ef7ee8c537db59 ]
The first thing __regmap_init() do is check if config is non-NULL, so there is no need to check for this again later.
--- drivers/base/regmap/regmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/regmap/regmap.c +1 -1
@@ -880,7 +880,7 @@ struct regmap *__regmap_init(struct device *dev, map->read_flag_mask = bus->read_flag_mask; } -if (config && config->read && config->write) { +if (config->read && config->write) { map->reg_read = _regmap_bus_read;if (config->reg_update_bits) map->reg_update_bits = config->reg_update_bits;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 56/196 bpf/selftests: Fix test_tcpnotify_user
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matt Bobrowski <[email protected]>
[ Upstream commit c80d79720647ed77ebc0198abd5a0807efdaff0b ]
Based on a bisect, it appears that commit 7ee988770326 ("timers:
Implement the hierarchical pull model") has somehow inadvertently broken BPF selftest test_tcpnotify_user. The error that is being generated by this test is as follows:
FAILED: Wrong stats Expected 10 calls, got 8
It looks like the change allows timer functions to be run on CPUs different from the one they are armed on. The test had pinned itself to CPU 0, and in the past the retransmit attempts also occurred on CPU
0. The test had set the max_entries attribute for BPF_MAP_TYPE_PERF_EVENT_ARRAY to 2 and was calling bpf_perf_event_output() with BPF_F_CURRENT_CPU, so the entry was likely to be in range. With the change to allow timers to run on other CPUs, the current CPU tasked with performing the retransmit might be bumped and in turn fall out of range, as the event will be filtered out via __bpf_perf_event_output() using:
if (unlikely(index >= array->map.max_entries))
return -E2BIG;A possible change would be to explicitly set the max_entries attribute for perf_event_map in test_tcpnotify_kern.c to a value that's at least as large as the number of CPUs. As it turns out however, if the field is left unset, then the libbpf will determine the number of CPUs available on the underlying system and update the max_entries attribute accordingly in map_set_def_max_entries().
A further problem with the test is that it has a thread that continues running up until the program exits. The main thread cleans up some LIBBPF data structures, while the other thread continues to use them, which inevitably will trigger a SIGSEGV. This can be dealt with by telling the thread to run for as long as necessary and doing a pthread_join on it before exiting the program.
Finally, I don't think binding the process to CPU 0 is meaningful for this test any more, so get rid of that.
--- .../selftests/bpf/progs/test_tcpnotify_kern.c | 1 - .../selftests/bpf/test_tcpnotify_user.c | 20 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-)
tools/testing/selftests/bpf/progs/test_tcpnotify_kern.c +0 -1
@@ -23,7 +23,6 @@ struct {struct { __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY); - __uint(max_entries, 2); __type(key, int); __type(value, __u32); } perf_event_map SEC(".maps");
tools/testing/selftests/bpf/test_tcpnotify_user.c +10 -10
@@ -15,20 +15,18 @@#include <bpf/libbpf.h> #include <sys/ioctl.h> #include <linux/rtnetlink.h> -#include <signal.h> #include <linux/perf_event.h> -#include <linux/err.h> -#include "bpf_util.h" #include "cgroup_helpers.h" #include "test_tcpnotify.h" -#include "trace_helpers.h" #include "testing_helpers.h" #define SOCKET_BUFFER_SIZE (getpagesize() < 8192L ? getpagesize() : 8192L)pthread_t tid; +static bool exit_thread; +int rx_callbacks;static void dummyfn (void *ctx,int cpu,void *data,__u32 size)
@@ -45,7 +43,7 @@ void tcp_notifier_poller(struct perf_buffer *pb) {int err; -while (1 ) { +while (!exit_thread) { err =perf_buffer__poll (pb,100 );if (err <0 && err != -EINTR ) {printf ("failed perf_buffer__poll: %d\n" , err);
@@ -78,15 +76,10 @@ int main(int argc, char **argv)int error =EXIT_FAILURE ;struct bpf_object *obj;char test_script[80 ]; -cpu_set_t cpuset;__u32 key =0 ;libbpf_set_strict_mode (LIBBPF_STRICT_ALL ); -CPU_ZERO (&cpuset); -CPU_SET (0 , &cpuset); -pthread_setaffinity_np (pthread_self (),sizeof (cpu_set_t), &cpuset); - cg_fd =cgroup_setup_and_join (cg_path);if (cg_fd <0 ) goto err;
@@ -151,6 +144,13 @@ int main(int argc, char **argv)sleep (10 ); + exit_thread = true; +int ret =pthread_join (tid,NULL ); +if (ret) { +printf ("FAILED: pthread_join\n" ); + goto err; + } +if (verify_result (&g)) {printf ("FAILED: Wrong stats Expected %d calls, got %d\n" , g.ncalls, rx_callbacks);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 57/196 bpf: Remove migrate_disable in kprobe_multi_link_prog_run
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tao Chen <[email protected]>
[ Upstream commit abdaf49be5424db74e19d167c10d7dad79a0efc2 ]
Graph tracer framework ensures we won't migrate, kprobe_multi_link_prog_run called all the way from graph tracer, which disables preemption in function_graph_enter_regs, as Jiri and Yonghong suggested, there is no need to use migrate_disable. As a result, some overhead may will be reduced. And add cant_sleep check for __this_cpu_inc_return.
--- kernel/trace/bpf_trace.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
kernel/trace/bpf_trace.c +7 -2
@@ -2636,18 +2636,23 @@ kprobe_multi_link_prog_run(struct bpf_kprobe_multi_link *link,struct bpf_run_ctx *old_run_ctx;int err; +/* +* graph tracer framework ensures we won't migrate, so there is no need +* to use migrate_disable for bpf_prog_run again. The check here just for +* __this_cpu_inc_return. +*/ +cant_sleep (); +if (unlikely (__this_cpu_inc_return (bpf_prog_active) !=1 )) { err =0 ; goto out; } -migrate_disable ();rcu_read_lock (); old_run_ctx =bpf_set_run_ctx (&run_ctx.run_ctx); err =bpf_prog_run (link->link.prog, regs);bpf_reset_run_ctx (old_run_ctx);rcu_read_unlock (); -migrate_enable (); out:__this_cpu_dec (bpf_prog_active);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 58/196 libbpf: Fix reuse of DEVMAP
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yureka Lilian <[email protected]>
[ Upstream commit 6c6b4146deb12d20f42490d5013f2043df942161 ]
Previously, re-using pinned DEVMAP maps would always fail, because get_map_info on a DEVMAP always returns flags with BPF_F_RDONLY_PROG set, but BPF_F_RDONLY_PROG being set on a map during creation is invalid.
Thus, ignore the BPF_F_RDONLY_PROG flag in the flags returned from get_map_info when checking for compatibility with an existing DEVMAP.
The same problem is handled in a third-party ebpf library:
- https://github.com/cilium/ebpf/issues/925
- https://github.com/cilium/ebpf/pull/930
--- tools/lib/bpf/libbpf.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
tools/lib/bpf/libbpf.c +10 -0
@@ -4882,6 +4882,16 @@ static bool map_is_reuse_compat(const struct bpf_map *map, int map_fd)return false; } +/* +* bpf_get_map_info_by_fd() for DEVMAP will always return flags with +* BPF_F_RDONLY_PROG set, but it generally is not set at map creation time. +* Thus, ignore the BPF_F_RDONLY_PROG flag in the flags returned from +* bpf_get_map_info_by_fd() when checking for compatibility with an +* existing DEVMAP. +*/ +if (map->def.type ==BPF_MAP_TYPE_DEVMAP || map->def.type ==BPF_MAP_TYPE_DEVMAP_HASH ) + map_info.map_flags &= ~BPF_F_RDONLY_PROG ; + return (map_info.type == map->def.type && map_info.key_size == map->def.key_size && map_info.value_size == map->def.value_size &&
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 59/196 cpufreq: scmi: Account for malformed DT in scmi_dev_used_by_cpus()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <[email protected]>
[ Upstream commit cd5d4621ba846dad9b2e6b0c2d1518d083fcfa13 ]
Broadcom STB platforms were early adopters (2017) of the SCMI framework and as a result, not all deployed systems have a Device Tree entry where SCMI protocol 0x13 (PERFORMANCE) is declared as a clock provider, nor are the CPU Device Tree node(s) referencing protocol 0x13 as their clock provider. This was clarified in commit e11c480b6df1 ("dt-bindings:
firmware: arm,scmi: Extend bindings for protocol@13") in 2023.
For those platforms, we allow the checks done by scmi_dev_used_by_cpus() to continue, and in the event of not having done an early return, we key off the documented compatible string and give them a pass to continue to use scmi-cpufreq.
--- drivers/cpufreq/scmi-cpufreq.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/cpufreq/scmi-cpufreq.c +10 -0
@@ -15,6 +15,7 @@#include <linux/energy_model.h> #include <linux/export.h> #include <linux/module.h> +#include <linux/of.h> #include <linux/pm_opp.h> #include <linux/slab.h> #include <linux/scmi_protocol.h>
@@ -330,6 +331,15 @@ static bool scmi_dev_used_by_cpus(struct device *scmi_dev)return true; } +/* +* Older Broadcom STB chips had a "clocks" property for CPU node(s) +* that did not match the SCMI performance protocol node, if we got +* there, it means we had such an older Device Tree, therefore return +* true to preserve backwards compatibility. +*/ +if (of_machine_is_compatible ("brcm,brcmstb" )) +return true; +return false; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 60/196 ACPI: processor: idle: Fix memory leak when register cpuidle device failed
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huisong Li <[email protected]>
[ Upstream commit 11b3de1c03fa9f3b5d17e6d48050bc98b3704420 ]
The cpuidle device's memory is leaked when cpuidle device registration fails in acpi_processor_power_init(). Free it as appropriate.
--- drivers/acpi/processor_idle.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/acpi/processor_idle.c +3 -0
@@ -1411,6 +1411,9 @@ int acpi_processor_power_init(struct acpi_processor *pr)if (retval) {if (acpi_processor_registered ==0 )cpuidle_unregister_driver (&acpi_idle_driver); + +per_cpu (acpi_cpuidle_device, pr->id) =NULL ; +kfree (dev);return retval; } acpi_processor_registered++;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 61/196 soc: qcom: rpmh-rsc: Unconditionally clear _TRIGGER bit for TCS
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sneh Mankad <[email protected]>
[ Upstream commit f87412d18edb5b8393eb8cb1c2d4a54f90185a21 ]
Unconditionally clear the TCS_AMC_MODE_TRIGGER bit when a transaction completes. Previously this bit was only cleared when a wake TCS was borrowed as an AMC TCS but not for dedicated AMC TCS. Leaving this bit set for AMC TCS and entering deeper low power modes can generate a false completion IRQ.
Prevent this scenario by always clearing the TCS_AMC_MODE_TRIGGER bit upon receiving a completion IRQ.
--- drivers/soc/qcom/rpmh-rsc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/soc/qcom/rpmh-rsc.c +2 -5
@@ -415,13 +415,10 @@ static irqreturn_t tcs_tx_done(int irq, void *p)trace_rpmh_tx_done (drv, i, req, err); -/* -* If wake tcs was re-purposed for sending active -* votes, clear AMC trigger & enable modes and +/* Clear AMC trigger & enable modes and * disable interrupt for this TCS */ -if (!drv->tcs[ACTIVE_TCS ].num_tcs) -__tcs_set_trigger (drv, i, false); +__tcs_set_trigger (drv, i, false); skip:/* Reclaim the TCS */ write_tcs_reg (drv,RSC_DRV_CMD_ENABLE , i,0 );
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 62/196 pinctrl: meson-gxl: add missing i2c_d pinmux
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Da Xue <[email protected]>
[ Upstream commit d8c2a9edd181f0cc4a66eec954b3d8f6a1d954a7 ]
Amlogic GXL has 4 I2C attached to gpio-periphs. I2C_D is on GPIOX_10/11.
Add the relevant func 3 pinmux per the datasheet for S805X/S905X/S905D.
--- drivers/pinctrl/meson/pinctrl-meson-gxl.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/pinctrl/meson/pinctrl-meson-gxl.c +10 -0
@@ -187,6 +187,9 @@ static const unsigned int i2c_sda_c_pins[] = { GPIODV_28 };static const unsigned int i2c_sck_c_dv19_pins[] = {GPIODV_19 };static const unsigned int i2c_sda_c_dv18_pins[] = {GPIODV_18 }; +static const unsigned int i2c_sck_d_pins[] = {GPIOX_11 }; +static const unsigned int i2c_sda_d_pins[] = {GPIOX_10 }; +static const unsigned int eth_mdio_pins[] = {GPIOZ_0 };static const unsigned int eth_mdc_pins[] = {GPIOZ_1 };static const unsigned int eth_clk_rx_clk_pins[] = {GPIOZ_2 };
@@ -411,6 +414,8 @@ static struct meson_pmx_group meson_gxl_periphs_groups[] = {GPIO_GROUP (GPIO_TEST_N ),/* Bank X */ +GROUP (i2c_sda_d,5 ,5 ), +GROUP (i2c_sck_d,5 ,4 ),GROUP (sdio_d0,5 ,31 ),GROUP (sdio_d1,5 ,30 ), GROUP(sdio_d2, 5, 29),
@@ -651,6 +656,10 @@ static const char * const i2c_c_groups[] = { "i2c_sck_c", "i2c_sda_c", "i2c_sda_c_dv18", "i2c_sck_c_dv19", }; +static const char *const i2c_d_groups[] = { +"i2c_sck_d" ,"i2c_sda_d" , +}; +static const char *const eth_groups[] = {"eth_mdio" ,"eth_mdc" ,"eth_clk_rx_clk" ,"eth_rx_dv" ,"eth_rxd0" ,"eth_rxd1" ,"eth_rxd2" ,"eth_rxd3" ,
@@ -777,6 +786,7 @@ static struct meson_pmx_func meson_gxl_periphs_functions[] = {FUNCTION (i2c_a),FUNCTION (i2c_b),FUNCTION (i2c_c), +FUNCTION (i2c_d),FUNCTION (eth),FUNCTION (pwm_a), FUNCTION(pwm_b),
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 63/196 blk-mq: check kobject state_in_sysfs before deleting in blk_mq_unregister_hctx
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Nan <[email protected]>
[ Upstream commit 4c7ef92f6d4d08a27d676e4c348f4e2922cab3ed ]
In __blk_mq_update_nr_hw_queues() the return value of blk_mq_sysfs_register_hctxs() is not checked. If sysfs creation for hctx fails, later changing the number of hw_queues or removing disk will trigger the following warning:
kernfs: can not remove 'nr_tags', no directory
WARNING: CPU: 2 PID: 637 at fs/kernfs/dir.c:1707 kernfs_remove_by_name_ns+0x13f/0x160 Call Trace: remove_files.isra.1+0x38/0xb0 sysfs_remove_group+0x4d/0x100 sysfs_remove_groups+0x31/0x60 __kobject_del+0x23/0xf0 kobject_del+0x17/0x40 blk_mq_unregister_hctx+0x5d/0x80 blk_mq_sysfs_unregister_hctxs+0x94/0xd0 blk_mq_update_nr_hw_queues+0x124/0x760 nullb_update_nr_hw_queues+0x71/0xf0 [null_blk] nullb_device_submit_queues_store+0x92/0x120 [null_blk]
kobjct_del() was called unconditionally even if sysfs creation failed. Fix it by checkig the kobject creation statusbefore deleting it.
--- block/blk-mq-sysfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
block/blk-mq-sysfs.c +4 -2
@@ -176,9 +176,11 @@ static void blk_mq_unregister_hctx(struct blk_mq_hw_ctx *hctx)return ;hctx_for_each_ctx (hctx, ctx, i) -kobject_del (&ctx->kobj); +if (ctx->kobj.state_in_sysfs) +kobject_del (&ctx->kobj); -kobject_del (&hctx->kobj); +if (hctx->kobj.state_in_sysfs) +kobject_del (&hctx->kobj); }static int blk_mq_register_hctx (struct blk_mq_hw_ctx *hctx)
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 64/196 ARM: at91: pm: fix MCKx restore routine
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Ferre <[email protected]>
[ Upstream commit 296302d3d81360e09fa956e9be9edc8223b69a12 ]
The at91_mckx_ps_restore() assembly function is responsible for setting back MCKx system bus clocks after exiting low power modes.
Fix a typo and use tmp3 variable instead of tmp2 to correctly set MCKx to previously saved state.
Tmp2 was used without the needed changes in CSS and DIV. Moreover the required bit 7, telling that MCR register's content is to be changed (CMD/write), was not set.
Fix function comment to match tmp variables actually used.
--- arch/arm/mach-at91/pm_suspend.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-at91/pm_suspend.S +2 -2
@@ -868,7 +868,7 @@ e_done: /** * at91_mckx_ps_restore: restore MCK1..4 settings * - * Side effects: overwrites tmp1, tmp2 + * Side effects: overwrites tmp1, tmp2 and tmp3 */ .macro at91_mckx_ps_restore #ifdef CONFIG_SOC_SAMA7
@@ -912,7 +912,7 @@ r_ps: bic tmp3, tmp3, #AT91_PMC_MCR_V2_ID_MSK orr tmp3, tmp3, tmp1 orr tmp3, tmp3, #AT91_PMC_MCR_V2_CMD - str tmp2, [pmc, #AT91_PMC_MCR_V2] + str tmp3, [pmc, #AT91_PMC_MCR_V2] wait_mckrdy tmp1
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 65/196 regulator: scmi: Use int type to store negative error codes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qianfeng Rong <[email protected]>
[ Upstream commit 9d35d068fb138160709e04e3ee97fe29a6f8615b ]
Change the 'ret' variable from u32 to int to store negative error codes or zero returned by of_property_read_u32().
Storing the negative error codes in unsigned type, doesn't cause an issue at runtime but it's ugly as pants. Additionally, assigning negative error codes to unsigned type may trigger a GCC warning when the -Wsign-conversion flag is enabled.
No effect on runtime.
--- drivers/regulator/scmi-regulator.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/regulator/scmi-regulator.c +2 -1
@@ -257,7 +257,8 @@ static int process_scmi_regulator_of_node(struct scmi_device *sdev,struct device_node *np, struct scmi_regulator_info *rinfo) { - u32 dom, ret; + u32 dom; +int ret; ret =of_property_read_u32 (np,"reg" , &dom);if (ret)
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 66/196 block: use int to store blk_stack_limits() return value
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qianfeng Rong <[email protected]>
[ Upstream commit b0b4518c992eb5f316c6e40ff186cbb7a5009518 ]
Change the 'ret' variable in blk_stack_limits() from unsigned int to int, as it needs to store negative value -1.
Storing the negative error codes in unsigned type, or performing equality comparisons (e.g., ret == -1), doesn't cause an issue at runtime [1] but can be confusing. Additionally, assigning negative error codes to unsigned type may trigger a GCC warning when the -Wsign-conversion flag is enabled.
No effect on runtime.
--- block/blk-settings.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
block/blk-settings.c +2 -1
@@ -547,7 +547,8 @@ static unsigned int blk_round_down_sectors(unsigned int sectors, unsigned int lbint blk_stack_limits (struct queue_limits *t,struct queue_limits *b,sector_t start) { -unsigned int top, bottom, alignment, ret =0 ; +unsigned int top, bottom, alignment; +int ret =0 ; t->max_sectors =min_not_zero (t->max_sectors, b->max_sectors); t->max_hw_sectors =min_not_zero (t->max_hw_sectors, b->max_hw_sectors);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 67/196 PM: sleep: core: Clear power.must_resume in noirq suspend error path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit be82483d1b60baf6747884bd74cb7de484deaf76 ]
If system suspend is aborted in the "noirq" phase (for instance, due to an error returned by one of the device callbacks), power.is_noirq_suspended will not be set for some devices and device_resume_noirq() will return early for them. Consequently, noirq resume callbacks will not run for them at all because the noirq suspend callbacks have not run for them yet.
If any of them has power.must_resume set and late suspend has been skipped for it (due to power.smart_suspend), early resume should be skipped for it either, or its state may become inconsistent (for instance, if the early resume assumes that it will always follow noirq resume).
Make that happen by clearing power.must_resume in device_resume_noirq() for devices with power.is_noirq_suspended clear that have been left in suspend by device_suspend_late(), which will subsequently cause device_resume_early() to leave the device in suspend and avoid changing its state.
--- drivers/base/power/main.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/base/power/main.c +13 -1
@@ -600,8 +600,20 @@ static void __device_resume_noirq(struct device *dev, pm_message_t state, bool aif (dev->power.syscore || dev->power.direct_complete) goto Out; -if (!dev->power.is_noirq_suspended) +if (!dev->power.is_noirq_suspended) { +/* +* This means that system suspend has been aborted in the noirq +* phase before invoking the noirq suspend callback for the +* device, so if device_suspend_late() has left it in suspend, +* device_resume_early() should leave it in suspend either in +* case the early resume of it depends on the noirq resume that +* has not run. +*/ +if (dev_pm_skip_suspend (dev)) + dev->power.must_resume = false; + goto Out; + }if (!dpm_wait_for_superior (dev, async)) goto Out;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 68/196 PM / devfreq: mtk-cci: Fix potential error pointer dereference in probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit fc33bf0e097c6834646b98a7b3da0ae5b617f0f9 ]
The drv->sram_reg pointer could be set to ERR_PTR(-EPROBE_DEFER) which would lead to a error pointer dereference. Use IS_ERR_OR_NULL() to check that the pointer is valid.
--- drivers/devfreq/mtk-cci-devfreq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/devfreq/mtk-cci-devfreq.c +2 -1
@@ -385,7 +385,8 @@ static int mtk_ccifreq_probe(struct platform_device *pdev) out_free_resources:if (regulator_is_enabled (drv->proc_reg))regulator_disable (drv->proc_reg); -if (drv->sram_reg &®ulator_is_enabled (drv->sram_reg)) +if (!IS_ERR_OR_NULL (drv->sram_reg) && +regulator_is_enabled (drv->sram_reg))regulator_disable (drv->sram_reg);return ret;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 69/196 power: supply: cw2015: Fix a alignment coding style issue
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Yan <[email protected]>
[ Upstream commit def5612170a8c6c4c6a3ea5bd6c3cfc8de6ba4b1 ]
Fix the checkpatch warning:
CHECK: Alignment should match open parenthesis
--- drivers/power/supply/cw2015_battery.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/power/supply/cw2015_battery.c +1 -2
@@ -702,8 +702,7 @@ static int cw_bat_probe(struct i2c_client *client)if (!cw_bat->battery_workqueue)return -ENOMEM ; -devm_delayed_work_autocancel (&client->dev, - &cw_bat->battery_delay_work, cw_bat_work); +devm_delayed_work_autocancel (&client->dev, &cw_bat->battery_delay_work, cw_bat_work);queue_delayed_work (cw_bat->battery_workqueue, &cw_bat->battery_delay_work,msecs_to_jiffies (10 ));return 0 ;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 70/196 pinctrl: renesas: Use int type to store negative error codes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qianfeng Rong <[email protected]>
[ Upstream commit 9f062fc5b0ff44550088912ab89f9da40226a826 ]
Change the 'ret' variable in sh_pfc_pinconf_group_set() from unsigned int to int, as it needs to store either negative error codes or zero returned by sh_pfc_pinconf_set().
No effect on runtime.
--- drivers/pinctrl/renesas/pinctrl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pinctrl/renesas/pinctrl.c +2 -1
@@ -747,7 +747,8 @@ static int sh_pfc_pinconf_group_set(struct pinctrl_dev *pctldev, unsigned group,struct sh_pfc_pinctrl *pmx =pinctrl_dev_get_drvdata (pctldev);const unsigned int *pins;unsigned int num_pins; -unsigned int i, ret; +unsigned int i; +int ret; pins = pmx->pfc->info->groups[group].pins; num_pins = pmx->pfc->info->groups[group].nr_pins;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 71/196 null_blk: Fix the description of the cache_size module argument
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Genjian Zhang <[email protected]>
[ Upstream commit 7942b226e6b84df13b46b76c01d3b6e07a1b349e ]
When executing modinfo null_blk, there is an error in the description of module parameter mbps, and the output information of cache_size is incomplete.The output of modinfo before and after applying this patch is as follows:
Before:
[...]
parm: cache_size:ulong
[...]
parm: mbps:Cache size in MiB for memory-backed device.
Default: 0 (none) (uint)
[...]
After:
[...]
parm: cache_size:Cache size in MiB for memory-backed device.
Default: 0 (none) (ulong)
[...]
parm: mbps:Limit maximum bandwidth (in MiB/s).
Default: 0 (no limit) (uint)
[...]
--- drivers/block/null_blk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/null_blk/main.c +1 -1
@@ -211,7 +211,7 @@ MODULE_PARM_DESC(discard, "Support discard operations (requires memory-backed nustatic unsigned long g_cache_size;module_param_named (cache_size, g_cache_size, ulong,0444 ); -MODULE_PARM_DESC (mbps,"Cache size in MiB for memory-backed device. Default: 0 (none)" ); +MODULE_PARM_DESC (cache_size,"Cache size in MiB for memory-backed device. Default: 0 (none)" );static unsigned int g_mbps;module_param_named (mbps, g_mbps, uint,0444 );
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 72/196 nbd: restrict sockets to TCP and UDP
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 9f7c02e031570e8291a63162c6c046dc15ff85b0 ]
Recently, syzbot started to abuse NBD with all kinds of sockets.
Commit cf1b2326b734 ("nbd: verify socket is supported during setup") made sure the socket supported a shutdown() method.
Explicitely accept TCP and UNIX stream sockets.
--- drivers/block/nbd.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/block/nbd.c +8 -0
@@ -1107,6 +1107,14 @@ static struct socket *nbd_get_socket(struct nbd_device *nbd, unsigned long fd,if (!sock)return NULL ; +if (!sk_is_tcp (sock->sk) && + !sk_is_stream_unix (sock->sk)) { +dev_err (disk_to_dev (nbd->disk),"Unsupported socket: should be TCP or UNIX.\n" ); + *err = -EINVAL ; +sockfd_put (sock); +return NULL ; + } +if (sock->ops->shutdown == sock_no_shutdown) {dev_err (disk_to_dev (nbd->disk),"Unsupported socket: shutdown callout must be supported.\n" ); *err = -EINVAL ;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 73/196 firmware: firmware: meson-sm: fix compile-test default
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit 0454346d1c5f7fccb3ef6e3103985de8ab3469f3 ]
Enabling compile testing should not enable every individual driver (we have "allyesconfig" for that).
--- drivers/firmware/meson/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/meson/Kconfig +1 -1
@@ -5,7 +5,7 @@ config MESON_SM tristate "Amlogic Secure Monitor driver" depends on ARCH_MESON || COMPILE_TEST - default y + default ARCH_MESON depends on ARM64_4K_PAGES help Say y here to enable the Amlogic secure monitor driver
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 74/196 cpuidle: qcom-spm: fix device and OF node leaks at probe
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit cdc06f912670c8c199d5fa9e78b64b7ed8e871d0 ]
Make sure to drop the reference to the saw device taken by of_find_device_by_node() after retrieving its driver data during probe().
Also drop the reference to the CPU node sooner to avoid leaking it in case there is no saw node or device.
--- drivers/cpuidle/cpuidle-qcom-spm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/cpuidle/cpuidle-qcom-spm.c +5 -2
@@ -97,20 +97,23 @@ static int spm_cpuidle_register(struct device *cpuidle_dev, int cpu)return -ENODEV ; saw_node =of_parse_phandle (cpu_node,"qcom,saw" ,0 ); +of_node_put (cpu_node);if (!saw_node)return -ENODEV ; pdev =of_find_device_by_node (saw_node);of_node_put (saw_node); -of_node_put (cpu_node);if (!pdev)return -ENODEV ; data =devm_kzalloc (cpuidle_dev,sizeof (*data),GFP_KERNEL ); -if (!data) +if (!data) { +put_device (&pdev->dev);return -ENOMEM ; + } data->spm =dev_get_drvdata (&pdev->dev); +put_device (&pdev->dev);if (!data->spm)return -EINVAL ;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 75/196 arm64: dts: mediatek: mt8516-pumpkin: Fix machine compatible
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: AngeloGioacchino Del Regno <[email protected]>
[ Upstream commit ffe6a5d1dd4d4d8af0779526cf4e40522647b25f ]
This devicetree contained only the SoC compatible but lacked the machine specific one: add a "mediatek,mt8516-pumpkin" compatible to the list to fix dtbs_check warnings.
--- arch/arm64/boot/dts/mediatek/mt8516-pumpkin.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt8516-pumpkin.dts +1 -1
@@ -11,7 +11,7 @@ / { model = "Pumpkin MT8516"; - compatible = "mediatek,mt8516"; + compatible = "mediatek,mt8516-pumpkin", "mediatek,mt8516"; memory@40000000 { device_type = "memory";
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 76/196 pwm: tiehrpwm: Fix corner case in clock divisor calculation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 00f83f0e07e44e2f1fb94b223e77ab7b18ee2d7d ]
The function set_prescale_div() is responsible for calculating the clock divisor settings such that the input clock rate is divided down such that the required period length is at most 0x10000 clock ticks. If period_cycles is an integer multiple of 0x10000, the divisor period_cycles / 0x10000 is good enough. So round up in the calculation of the required divisor and compare it using >= instead of >.
--- drivers/pwm/pwm-tiehrpwm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pwm/pwm-tiehrpwm.c +2 -2
@@ -167,7 +167,7 @@ static int set_prescale_div(unsigned long rqst_prescaler, u16 *prescale_div, *prescale_div = (1 << clkdiv) * (hspclkdiv ? (hspclkdiv *2 ) :1 ); -if (*prescale_div > rqst_prescaler) { +if (*prescale_div >= rqst_prescaler) { *tb_clk_div = (clkdiv <<TBCTL_CLKDIV_SHIFT ) | (hspclkdiv <<TBCTL_HSPCLKDIV_SHIFT );return 0 ;
@@ -266,7 +266,7 @@ static int ehrpwm_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, pc->period_cycles[pwm->hwpwm] = period_cycles;/* Configure clock prescaler to support Low frequency PWM wave */ -if (set_prescale_div (period_cycles/PERIOD_MAX , &ps_divval, +if (set_prescale_div (DIV_ROUND_UP (period_cycles,PERIOD_MAX ), &ps_divval, &tb_divval)) {dev_err (chip->dev,"Unsupported values\n" );return -EINVAL ;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 77/196 nvmet-fc: move lsop put work to nvmet_fc_ls_req_op
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Wagner <[email protected]>
[ Upstream commit db5a5406fb7e5337a074385c7a3e53c77f2c1bd3 ]
It’s possible for more than one async command to be in flight from __nvmet_fc_send_ls_req. For each command, a tgtport reference is taken.
In the current code, only one put work item is queued at a time, which results in a leaked reference.
To fix this, move the work item to the nvmet_fc_ls_req_op struct, which already tracks all resources related to the command.
--- drivers/nvme/target/fc.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/nvme/target/fc.c +9 -10
@@ -54,6 +54,8 @@ struct nvmet_fc_ls_req_op { /* for an LS RQST XMT */int ls_error;struct list_head lsreq_list;/* tgtport->ls_req_list */ bool req_queued; + +struct work_struct put_work; };
@@ -111,8 +113,6 @@ struct nvmet_fc_tgtport {struct nvmet_fc_port_entry *pe;struct kref ref;u32 max_sg_cnt; - -struct work_struct put_work; };struct nvmet_fc_port_entry {
@@ -236,12 +236,13 @@ static int nvmet_fc_tgt_a_get(struct nvmet_fc_tgt_assoc *assoc);static void nvmet_fc_tgt_q_put (struct nvmet_fc_tgt_queue *queue);static int nvmet_fc_tgt_q_get (struct nvmet_fc_tgt_queue *queue);static void nvmet_fc_tgtport_put (struct nvmet_fc_tgtport *tgtport); -static void nvmet_fc_put_tgtport_work (struct work_struct *work) +static void nvmet_fc_put_lsop_work (struct work_struct *work) { -struct nvmet_fc_tgtport *tgtport = - container_of(work, struct nvmet_fc_tgtport, put_work); +struct nvmet_fc_ls_req_op *lsop = + container_of(work, struct nvmet_fc_ls_req_op, put_work); -nvmet_fc_tgtport_put (tgtport); +nvmet_fc_tgtport_put (lsop->tgtport); +kfree (lsop); }static int nvmet_fc_tgtport_get (struct nvmet_fc_tgtport *tgtport); static void nvmet_fc_handle_fcp_rqst(struct nvmet_fc_tgtport *tgtport,
@@ -368,7 +369,7 @@ __nvmet_fc_finish_ls_req(struct nvmet_fc_ls_req_op *lsop) DMA_BIDIRECTIONAL); out_putwork: -queue_work (nvmet_wq, &tgtport->put_work); +queue_work (nvmet_wq, &lsop->put_work); } static int
@@ -389,6 +390,7 @@ __nvmet_fc_send_ls_req(struct nvmet_fc_tgtport *tgtport, lsreq->done = done; lsop->req_queued = false;INIT_LIST_HEAD (&lsop->lsreq_list); +INIT_WORK (&lsop->put_work, nvmet_fc_put_lsop_work); lsreq->rqstdma = fc_dma_map_single(tgtport->dev, lsreq->rqstaddr, lsreq->rqstlen + lsreq->rsplen,
@@ -448,8 +450,6 @@ nvmet_fc_disconnect_assoc_done(struct nvmefc_ls_req *lsreq, int status)__nvmet_fc_finish_ls_req (lsop);/* fc-nvme target doesn't care about success or failure of cmd */ - -kfree (lsop); }/*
@@ -1407,7 +1407,6 @@ nvmet_fc_register_targetport(struct nvmet_fc_port_info *pinfo,kref_init (&newrec->ref);ida_init (&newrec->assoc_cnt); newrec->max_sg_cnt = template->max_sgl_segments; -INIT_WORK (&newrec->put_work, nvmet_fc_put_tgtport_work); ret =nvmet_fc_alloc_ls_iodlist (newrec);if (ret) {
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 78/196 i3c: master: svc: Use manual response for IBI events
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanley Chu <[email protected]>
[ Upstream commit a7869b0a2540fd122eccec00ae7d4243166b0a60 ]
Driver wants to nack the IBI request when the target is not in the known address list. In below code, svc_i3c_master_nack_ibi() will cause undefined behavior when using AUTOIBI with auto response rule, because hw always auto ack the IBI request.
switch (ibitype) {
case SVC_I3C_MSTATUS_IBITYPE_IBI:
dev = svc_i3c_master_dev_from_addr(master, ibiaddr);
if (!dev || !is_events_enabled(master, SVC_I3C_EVENT_IBI))
svc_i3c_master_nack_ibi(master);
...
break;AutoIBI has another issue that the controller doesn't quit AutoIBI state after IBIWON polling timeout when there is a SDA glitch(high->low->high).
1. SDA high->low: raising an interrupt to execute IBI ISR
2. SDA low->high
3. Driver writes an AutoIBI request
4. AutoIBI process does not start because SDA is not low
5. IBIWON polling times out
6. Controller reamins in AutoIBI state and doesn't accept EmitStop request
Emitting broadcast address with IBIRESP_MANUAL avoids both issues.
--- drivers/i3c/master/svc-i3c-master.c | 30 ++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-)
drivers/i3c/master/svc-i3c-master.c +25 -5
@@ -422,9 +422,24 @@ static void svc_i3c_master_ibi_work(struct work_struct *work)*/ writel (SVC_I3C_MINT_IBIWON , master->regs +SVC_I3C_MSTATUS ); -/* Acknowledge the incoming interrupt with the AUTOIBI mechanism */ -writel (SVC_I3C_MCTRL_REQUEST_AUTO_IBI | -SVC_I3C_MCTRL_IBIRESP_AUTO , +/* +* Write REQUEST_START_ADDR request to emit broadcast address for arbitration, +* instend of using AUTO_IBI. +* +* Using AutoIBI request may cause controller to remain in AutoIBI state when +* there is a glitch on SDA line (high->low->high). +* 1. SDA high->low, raising an interrupt to execute IBI isr. +* 2. SDA low->high. +* 3. IBI isr writes an AutoIBI request. +* 4. The controller will not start AutoIBI process because SDA is not low. +* 5. IBIWON polling times out. +* 6. Controller reamins in AutoIBI state and doesn't accept EmitStop request. +*/ +writel (SVC_I3C_MCTRL_REQUEST_START_ADDR | +SVC_I3C_MCTRL_TYPE_I3C | +SVC_I3C_MCTRL_IBIRESP_MANUAL | +SVC_I3C_MCTRL_DIR (SVC_I3C_MCTRL_DIR_WRITE ) | +SVC_I3C_MCTRL_ADDR (I3C_BROADCAST_ADDR ), master->regs +SVC_I3C_MCTRL );/* Wait for IBIWON, should take approximately 100us */
@@ -444,10 +459,15 @@ static void svc_i3c_master_ibi_work(struct work_struct *work)switch (ibitype) {case SVC_I3C_MSTATUS_IBITYPE_IBI : dev =svc_i3c_master_dev_from_addr (master, ibiaddr); -if (!dev || !is_events_enabled (master,SVC_I3C_EVENT_IBI )) +if (!dev || !is_events_enabled (master,SVC_I3C_EVENT_IBI )) {svc_i3c_master_nack_ibi (master); -else + }else { +if (dev->info.bcr &I3C_BCR_IBI_PAYLOAD ) +svc_i3c_master_ack_ibi (master, true); +else +svc_i3c_master_ack_ibi (master, false);svc_i3c_master_handle_ibi (master, dev); + }break ;case SVC_I3C_MSTATUS_IBITYPE_HOT_JOIN :if (is_events_enabled (master,SVC_I3C_EVENT_HOTJOIN ))
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 79/196 i3c: master: svc: Recycle unused IBI slot
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanley Chu <[email protected]>
[ Upstream commit 3448a934ba6f803911ac084d05a2ffce507ea6c6 ]
In svc_i3c_master_handle_ibi(), an IBI slot is fetched from the pool to store the IBI payload. However, when an error condition is encountered, the function returns without recycling the IBI slot, resulting in an IBI slot leak.
--- drivers/i3c/master/svc-i3c-master.c | 1 + 1 file changed, 1 insertion(+)
drivers/i3c/master/svc-i3c-master.c +1 -0
@@ -361,6 +361,7 @@ static int svc_i3c_master_handle_ibi(struct svc_i3c_master *master, SVC_I3C_MSTATUS_COMPLETE(val), 0, 1000);if (ret) {dev_err (master->dev,"Timeout when polling for COMPLETE\n" ); +i3c_generic_ibi_recycle_slot (data->ibi_pool, slot);return ret; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 80/196 selftests: watchdog: skip ping loop if WDIOF_KEEPALIVEPING not supported
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Akhilesh Patil <[email protected]>
[ Upstream commit e8cfc524eaf3c0ed88106177edb6961e202e6716 ]
Check if watchdog device supports WDIOF_KEEPALIVEPING option before entering keep_alive() ping test loop. Fix watchdog-test silently looping if ioctl based ping is not supported by the device. Exit from test in such case instead of getting stuck in loop executing failing keep_alive()
watchdog_info:
identity: m41t93 rtc Watchdog
firmware_version: 0
Support/Status: Set timeout (in seconds)
Support/Status: Watchdog triggers a management or other external alarm not a reboot
Watchdog card disabled.
Watchdog timeout set to 5 seconds.
Watchdog ping rate set to 2 seconds.
Watchdog card enabled.WDIOC_KEEPALIVE not supported by this device
without this change
Watchdog card disabled.
Watchdog timeout set to 5 seconds.
Watchdog ping rate set to 2 seconds.
Watchdog card enabled.
Watchdog Ticking Away!
(Where test stuck here forver silently)
Updated change log at commit time:
Shuah Khan <[email protected]>
--- tools/testing/selftests/watchdog/watchdog-test.c | 6 ++++++ 1 file changed, 6 insertions(+)
tools/testing/selftests/watchdog/watchdog-test.c +6 -0
@@ -240,6 +240,12 @@ int main(int argc, char *argv[])if (oneshot) goto end; +/* Check if WDIOF_KEEPALIVEPING is supported */ +if (!(info.options &WDIOF_KEEPALIVEPING )) { +printf ("WDIOC_KEEPALIVE not supported by this device\n" ); + goto end; + } +printf ("Watchdog Ticking Away!\n" );/*
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 81/196 bpf: Explicitly check accesses to bpf_sock_addr
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Chaignon <[email protected]>
[ Upstream commit 6fabca2fc94d33cdf7ec102058983b086293395f ]
Syzkaller found a kernel warning on the following sock_addr program:
0: r0 = 0
1: r2 = *(u32 *)(r1 +60)
2: exitwhich triggers:
verifier bug: error during ctx access conversion (0)
This is happening because offset 60 in bpf_sock_addr corresponds to an implicit padding of 4 bytes, right after msg_src_ip4. Access to this padding isn't rejected in sock_addr_is_valid_access and it thus later fails to convert the access.
This patch fixes it by explicitly checking the various fields of bpf_sock_addr in sock_addr_is_valid_access.
I checked the other ctx structures and is_valid_access functions and didn't find any other similar cases. Other cases of (properly handled) padding are covered in new tests in a subsequent patch.
--- net/core/filter.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
net/core/filter.c +10 -6
@@ -9100,13 +9100,17 @@ static bool sock_addr_is_valid_access(int off, int size,return false; info->reg_type =PTR_TO_SOCKET ;break ; -default : -if (type ==BPF_READ ) { -if (size != size_default) -return false; - }else { + case bpf_ctx_range(struct bpf_sock_addr, user_family): + case bpf_ctx_range(struct bpf_sock_addr, family): + case bpf_ctx_range(struct bpf_sock_addr, type): + case bpf_ctx_range(struct bpf_sock_addr, protocol): +if (type !=BPF_READ )return false; - } +if (size != size_default) +return false; +break ; +default : +return false; }return true;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 82/196 smp: Fix up and expand the smp_call_function_many() kerneldoc
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit ccf09357ffef2ab472369ab9cdf470c9bc9b821a ]
The smp_call_function_many() kerneldoc comment got out of sync with the function definition (bool parameter "wait" is incorrectly described as a bitmask in it), so fix it up by copying the "wait" description from the smp_call_function() kerneldoc and add information regarding the handling of the local CPU to it.
--- kernel/smp.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
kernel/smp.c +5 -6
@@ -1005,16 +1005,15 @@ static void smp_call_function_many_cond(const struct cpumask *mask,* @mask: The set of cpus to run on (only runs on online subset). * @func: The function to run. This must be fast and non-blocking. * @info: An arbitrary pointer to pass to the function. -* @wait: Bitmask that controls the operation. If %SCF_WAIT is set, wait -* (atomically) until function has completed on other CPUs. If -* %SCF_RUN_LOCAL is set, the function will also be run locally -* if the local CPU is set in the @cpumask. -* -* If @wait is true, then returns once @func has returned. +* @wait: If true, wait (atomically) until function has completed +* on other CPUs. * * You must not call this function with disabled interrupts or from a * hardware interrupt handler or from a bottom half handler. Preemption * must be disabled when calling this function. +* +* @func is not called on the local CPU even if @mask contains it. Consider +* using on_each_cpu_cond_mask() instead if this is not desirable. */ void smp_call_function_many (const struct cpumask *mask,smp_call_func_t func,void *info,bool wait)
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 83/196 tools/nolibc: make time_t robust if __kernel_old_time_t is missing in host headers
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhouyi Zhou <[email protected]>
[ Upstream commit 0ff52df6b32a6b04a7c9dfe3d7a387aff215b482 ]
Commit d5094bcb5bfd ("tools/nolibc: define time_t in terms of __kernel_old_time_t") made nolibc use the kernel's time type so that time_t matches timespec::tv_sec on all ABIs (notably x32).
But since __kernel_old_time_t is fairly new, notably from 2020 in commit 94c467ddb273 ("y2038: add __kernel_old_timespec and __kernel_old_time_t"), nolibc builds that rely on host headers may fail.
Switch to __kernel_time_t, which is the same as __kernel_old_time_t and has existed for longer.
Tested in PPC VM of Open Source Lab of Oregon State University (./tools/testing/selftests/rcutorture/bin/mkinitrd.sh)
--- tools/include/nolibc/std.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/include/nolibc/std.h +1 -1
@@ -46,6 +46,6 @@ typedef unsigned long nlink_t;typedef signed long off_t ;typedef signed long blksize_t ;typedef signed long blkcnt_t ; -typedef __kernel_old_time_t time_t ; +typedef __kernel_time_t time_t ;#endif /* _NOLIBC_STD_H */
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 84/196 hwmon: (mlxreg-fan) Separate methods of fan setting coming from different subsystems
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vadim Pasternak <[email protected]>
[ Upstream commit c02e4644f8ac9c501077ef5ac53ae7fc51472d49 ]
Distinct between fan speed setting request coming for hwmon and thermal subsystems.
There are fields 'last_hwmon_state' and 'last_thermal_state' in the structure 'mlxreg_fan_pwm', which respectively store the cooling state set by the 'hwmon' and 'thermal' subsystem.
The purpose is to make arbitration of fan speed setting. For example, if fan speed required to be not lower than some limit, such setting is to be performed through 'hwmon' subsystem, thus 'thermal' subsystem will not set fan below this limit.
Currently, the 'last_thermal_state' is also be updated by 'hwmon' causing cooling state to never be set to a lower value.
Eliminate update of 'last_thermal_state', when request is coming from 'hwmon' subsystem.
--- drivers/hwmon/mlxreg-fan.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
drivers/hwmon/mlxreg-fan.c +16 -8
@@ -113,8 +113,8 @@ struct mlxreg_fan {int divider; }; -static int mlxreg_fan_set_cur_state (struct thermal_cooling_device *cdev, -unsigned long state); +static int _mlxreg_fan_set_cur_state (struct thermal_cooling_device *cdev, +unsigned long state,bool thermal); static int mlxreg_fan_read(struct device *dev, enum hwmon_sensor_types type, u32 attr,
@@ -224,8 +224,9 @@ mlxreg_fan_write(struct device *dev, enum hwmon_sensor_types type, u32 attr,* last thermal state. */ if (pwm->last_hwmon_state >= pwm->last_thermal_state) -return mlxreg_fan_set_cur_state (pwm->cdev, - pwm->last_hwmon_state); +return _mlxreg_fan_set_cur_state (pwm->cdev, + pwm->last_hwmon_state, + false);return 0 ; }return regmap_write (fan->regmap, pwm->reg, val);
@@ -347,9 +348,8 @@ static int mlxreg_fan_get_cur_state(struct thermal_cooling_device *cdev,return 0 ; } -static int mlxreg_fan_set_cur_state (struct thermal_cooling_device *cdev, -unsigned long state) - +static int _mlxreg_fan_set_cur_state (struct thermal_cooling_device *cdev, +unsigned long state,bool thermal) {struct mlxreg_fan_pwm *pwm = cdev->devdata;struct mlxreg_fan *fan = pwm->fan;
@@ -359,7 +359,8 @@ static int mlxreg_fan_set_cur_state(struct thermal_cooling_device *cdev,return -EINVAL ;/* Save thermal state. */ - pwm->last_thermal_state = state; +if (thermal) + pwm->last_thermal_state = state; state = max_t(unsigned long, state, pwm->last_hwmon_state); err = regmap_write(fan->regmap, pwm->reg,
@@ -371,6 +372,13 @@ static int mlxreg_fan_set_cur_state(struct thermal_cooling_device *cdev,return 0 ; } +static int mlxreg_fan_set_cur_state (struct thermal_cooling_device *cdev, +unsigned long state) + +{ +return _mlxreg_fan_set_cur_state (cdev, state, true); +} +static const struct thermal_cooling_device_ops mlxreg_fan_cooling_ops = { .get_max_state = mlxreg_fan_get_max_state, .get_cur_state = mlxreg_fan_get_cur_state,
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 85/196 thermal/drivers/qcom: Make LMH select QCOM_SCM
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit 57eda47bd14b0c2876f2db42e757c57b7a671965 ]
The QCOM_SCM symbol is not user-visible, so it makes little sense to depend on it. Make LMH driver select QCOM_SCM as all other drivers do and, as the dependecy is now correctly handled, enable || COMPILE_TEST in order to include the driver into broader set of build tests.
--- drivers/thermal/qcom/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/thermal/qcom/Kconfig +2 -1
@@ -34,7 +34,8 @@ config QCOM_SPMI_TEMP_ALARM config QCOM_LMH tristate "Qualcomm Limits Management Hardware" - depends on ARCH_QCOM && QCOM_SCM + depends on ARCH_QCOM || COMPILE_TEST + select QCOM_SCM help This enables initialization of Qualcomm limits management hardware(LMh). LMh allows for hardware-enforced mitigation for cpus based on
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 86/196 thermal/drivers/qcom/lmh: Add missing IRQ includes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit b50b2c53f98fcdb6957e184eb488c16502db9575 ]
As reported by LKP, the Qualcomm LMH driver needs to include several IRQ-related headers, which decrlare necessary IRQ functionality. Currently driver builds on ARM64 platforms, where the headers are pulled in implicitly by other headers, but fails to build on other platforms.
--- drivers/thermal/qcom/lmh.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/thermal/qcom/lmh.c +2 -0
@@ -5,6 +5,8 @@*/ #include <linux/module.h> #include <linux/interrupt.h> +#include <linux/irq.h> +#include <linux/irqdesc.h> #include <linux/irqdomain.h> #include <linux/err.h> #include <linux/platform_device.h>
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 87/196 i2c: mediatek: fix potential incorrect use of I2C_MASTER_WRRD
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leilk.Liu <[email protected]>
[ Upstream commit b492183652808e0f389272bf63dc836241b287ff ]
The old IC does not support the I2C_MASTER_WRRD (write-then-read) function, but the current code’s handling of i2c->auto_restart may potentially lead to entering the I2C_MASTER_WRRD software flow, resulting in unexpected bugs.
Instead of repurposing the auto_restart flag, add a separate flag to signal I2C_MASTER_WRRD operations.
Also fix handling of msgs. If the operation (i2c->op) is I2C_MASTER_WRRD, then the msgs pointer is incremented by 2. For all other operations, msgs is simply incremented by 1.
--- drivers/i2c/busses/i2c-mt65xx.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/i2c/busses/i2c-mt65xx.c +10 -7
@@ -1218,6 +1218,7 @@ static int mtk_i2c_transfer(struct i2c_adapter *adap, {int ret;int left_num = num; +bool write_then_read_en = false;struct mtk_i2c *i2c =i2c_get_adapdata (adap); ret =clk_bulk_enable (I2C_MT65XX_CLK_MAX , i2c->clocks);
@@ -1231,6 +1232,7 @@ static int mtk_i2c_transfer(struct i2c_adapter *adap,if (!(msgs[0 ].flags &I2C_M_RD ) && (msgs[1 ].flags &I2C_M_RD ) && msgs[0 ].addr == msgs[1 ].addr) { i2c->auto_restart =0 ; + write_then_read_en = true; } }
@@ -1255,12 +1257,10 @@ static int mtk_i2c_transfer(struct i2c_adapter *adap,else i2c->op =I2C_MASTER_WR ; -if (!i2c->auto_restart) { -if (num >1 ) { -/* combined two messages into one transaction */ - i2c->op =I2C_MASTER_WRRD ; - left_num--; - } +if (write_then_read_en) { +/* combined two messages into one transaction */ + i2c->op =I2C_MASTER_WRRD ; + left_num--; }/* always use DMA mode. */
@@ -1268,7 +1268,10 @@ static int mtk_i2c_transfer(struct i2c_adapter *adap,if (ret <0 ) goto err_exit; - msgs++; +if (i2c->op ==I2C_MASTER_WRRD ) + msgs +=2 ; +else + msgs++; }/* the return value is number of executed messages */ ret = num;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 88/196 i2c: designware: Add disabling clocks when probe fails
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kunihiko Hayashi <[email protected]>
[ Upstream commit c149841b069ccc6e480b00e11f35a57b5d88c7bb ]
After an error occurs during probing state, dw_i2c_plat_pm_cleanup() is called. However, this function doesn't disable clocks and the clock-enable count keeps increasing. Should disable these clocks explicitly.
--- drivers/i2c/busses/i2c-designware-platdrv.c | 1 + 1 file changed, 1 insertion(+)
drivers/i2c/busses/i2c-designware-platdrv.c +1 -0
@@ -380,6 +380,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) exit_probe:dw_i2c_plat_pm_cleanup (dev); +i2c_dw_prepare_clk (dev, false); exit_reset:reset_control_assert (dev->rst);return ret;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 89/196 bpf: Enforce expected_attach_type for tailcall compatibility
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit 4540aed51b12bc13364149bf95f6ecef013197c0 ]
Yinhao et al. recently reported:
Our fuzzer tool discovered an uninitialized pointer issue in the bpf_prog_test_run_xdp() function within the Linux kernel's BPF subsystem. This leads to a NULL pointer dereference when a BPF program attempts to deference the txq member of struct xdp_buff object.
The test initializes two programs of BPF_PROG_TYPE_XDP: progA acts as the entry point for bpf_prog_test_run_xdp() and its expected_attach_type can neither be of be BPF_XDP_DEVMAP nor BPF_XDP_CPUMAP. progA calls into a slot of a tailcall map it owns. progB's expected_attach_type must be BPF_XDP_DEVMAP to pass xdp_is_valid_access() validation. The program returns struct xdp_md's egress_ifindex, and the latter is only allowed to be accessed under mentioned expected_attach_type. progB is then inserted into the tailcall which progA calls.
The underlying issue goes beyond XDP though. Another example are programs of type BPF_PROG_TYPE_CGROUP_SOCK_ADDR. sock_addr_is_valid_access() as well as sock_addr_func_proto() have different logic depending on the programs' expected_attach_type. Similarly, a program attached to BPF_CGROUP_INET4_GETPEERNAME should not be allowed doing a tailcall into a program which calls bpf_bind() out of BPF which is only enabled for BPF_CGROUP_INET4_CONNECT.
In short, specifying expected_attach_type allows to open up additional functionality or restrictions beyond what the basic bpf_prog_type enables. The use of tailcalls must not violate these constraints. Fix it by enforcing expected_attach_type in __bpf_prog_map_compatible().
Note that we only enforce this for tailcall maps, but not for BPF devmaps or
cpumaps: There, the programs are invoked through dev_map_bpf_prog_run*() and cpu_map_bpf_prog_run*() which set up a new environment / context and therefore these situations are not prone to this issue.
--- include/linux/bpf.h | 1 + kernel/bpf/core.c | 5 +++++ 2 files changed, 6 insertions(+)
include/linux/bpf.h +1 -0
@@ -228,6 +228,7 @@ struct bpf_map_owner {bool xdp_has_frags;u64 storage_cookie[MAX_BPF_CGROUP_STORAGE_TYPE ];const struct btf_type *attach_func_proto; +enum bpf_attach_type expected_attach_type; };struct bpf_map {
kernel/bpf/core.c +5 -0
@@ -2137,6 +2137,7 @@ bool bpf_prog_map_compatible(struct bpf_map *map, map->owner->type = prog_type; map->owner->jited = fp->jited; map->owner->xdp_has_frags = aux->xdp_has_frags; + map->owner->expected_attach_type = fp->expected_attach_type; map->owner->attach_func_proto = aux->attach_func_proto;for_each_cgroup_storage_type (i) { map->owner->storage_cookie[i] =
@@ -2148,6 +2149,10 @@ bool bpf_prog_map_compatible(struct bpf_map *map, ret = map->owner->type == prog_type && map->owner->jited == fp->jited && map->owner->xdp_has_frags == aux->xdp_has_frags; +if (ret && + map->map_type ==BPF_MAP_TYPE_PROG_ARRAY && + map->owner->expected_attach_type != fp->expected_attach_type) + ret = false;for_each_cgroup_storage_type (i) {if (!ret)break ;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 90/196 drm/panel: novatek-nt35560: Fix invalid return value
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brigham Campbell <[email protected]>
[ Upstream commit 125459e19ec654924e472f3ff5aeea40358dbebf ]
Fix bug in nt35560_set_brightness() which causes the function to erroneously report an error. mipi_dsi_dcs_write() returns either a negative value when an error occurred or a positive number of bytes written when no error occurred. The buggy code reports an error under either condition.
--- drivers/gpu/drm/panel/panel-novatek-nt35560.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/panel/panel-novatek-nt35560.c +1 -1
@@ -162,7 +162,7 @@ static int nt35560_set_brightness(struct backlight_device *bl) par =0x00 ; ret =mipi_dsi_dcs_write (dsi,MIPI_DCS_WRITE_CONTROL_DISPLAY , &par,1 ); -if (ret) { +if (ret <0 ) {dev_err (nt->dev,"failed to disable display backlight (%d)\n" , ret);return ret; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 91/196 drm/radeon/r600_cs: clean up of dead code in r600_cs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brahmajit Das <[email protected]>
[ Upstream commit 260dcf5b06d519bcf27a5dfdb5c626821a55c170 ]
GCC 16 enables -Werror=unused-but-set-variable= which results in build error with the following message.
drivers/gpu/drm/radeon/r600_cs.c: In function ‘r600_texture_size’:drivers/gpu/drm/radeon/r600_cs.c:1411:29: error: variable ‘level’ set but not used [-Werror=unused-but-set-variable=]
1411 | unsigned offset, i, level;
| ^~~~~
cc1: all warnings being treated as errors
make[6]: *** [scripts/Makefile.build:287: drivers/gpu/drm/radeon/r600_cs.o] Error 1
level although is set, but in never used in the function r600_texture_size. Thus resulting in dead code and this error getting triggered.
--- drivers/gpu/drm/radeon/r600_cs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/r600_cs.c +2 -2
@@ -1408,7 +1408,7 @@ static void r600_texture_size(unsigned nfaces, unsigned blevel, unsigned llevel, unsigned block_align, unsigned height_align, unsigned base_align, unsigned *l0_size, unsigned *mipmap_size) { - unsigned offset, i, level; + unsigned offset, i;unsigned width, height, depth, size;unsigned blocksize;unsigned nbx, nby;
@@ -1420,7 +1420,7 @@ static void r600_texture_size(unsigned nfaces, unsigned blevel, unsigned llevel, w0 =r600_mip_minify (w0,0 ); h0 =r600_mip_minify (h0,0 ); d0 =r600_mip_minify (d0,0 ); -for (i =0 , offset =0 , level = blevel; i < nlevels; i++, level++) { +for (i =0 , offset =0 ; i < nlevels; i++) { width =r600_mip_minify (w0, i); nbx =r600_fmt_get_nblocksx (format, width);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 92/196 usb: host: max3421-hcd: Fix error pointer dereference in probe cleanup
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 186e8f2bdba551f3ae23396caccd452d985c23e3 ]
The kthread_run() function returns error pointers so the max3421_hcd->spi_thread pointer can be either error pointers or NULL. Check for both before dereferencing it.
--- drivers/usb/host/max3421-hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/max3421-hcd.c +1 -1
@@ -1925,7 +1925,7 @@ max3421_probe(struct spi_device *spi)if (hcd) {kfree (max3421_hcd->tx);kfree (max3421_hcd->rx); -if (max3421_hcd->spi_thread) +if (!IS_ERR_OR_NULL (max3421_hcd->spi_thread))kthread_stop (max3421_hcd->spi_thread);usb_put_hcd (hcd); }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 93/196 serial: max310x: Add error checking in probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 672a37ba8af1f2ebcedeb94aea2cdd047f805f30 ]
Check if devm_i2c_new_dummy_device() fails.
--- drivers/tty/serial/max310x.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/serial/max310x.c +2 -0
@@ -1656,6 +1656,8 @@ static int max310x_i2c_probe(struct i2c_client *client) port_client =devm_i2c_new_dummy_device (&client->dev, client->adapter, port_addr); +if (IS_ERR (port_client)) +return PTR_ERR (port_client); regmaps[i] =devm_regmap_init_i2c (port_client, ®cfg_i2c); }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 94/196 drm/amd/display: Remove redundant semicolons
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liao Yuanhong <[email protected]>
[ Upstream commit 90b810dd859c0df9db2290da1ac5842e5f031267 ]
Remove unnecessary semicolons.
--- .../gpu/drm/amd/display/dc/dml/dcn32/display_rq_dlg_calc_32.c | 1 - 1 file changed, 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dml/dcn32/display_rq_dlg_calc_32.c +0 -1
@@ -139,7 +139,6 @@ void dml32_rq_dlg_get_rq_reg(display_rq_regs_st *rq_regs,if (dual_plane) {unsigned int p1_pte_row_height_linear =get_dpte_row_height_linear_c (mode_lib, e2e_pipe_param, num_pipes, pipe_idx); - ;if (src->sw_mode == dm_sw_linear)ASSERT (p1_pte_row_height_linear >=8 );
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 95/196 hwrng: nomadik - add ARM_AMBA dependency
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit efaa2d815a0e4d1c06750e587100f6f7f4ee5497 ]
Compile-testing this driver is only possible when the AMBA bus driver is available in the kernel:
x86_64-linux-ld: drivers/char/hw_random/nomadik-rng.o: in function `nmk_rng_remove':
nomadik-rng.c:(.text+0x67): undefined reference to `amba_release_regions'
x86_64-linux-ld: drivers/char/hw_random/nomadik-rng.o: in function `nmk_rng_probe':
nomadik-rng.c:(.text+0xee): undefined reference to `amba_request_regions'
x86_64-linux-ld: nomadik-rng.c:(.text+0x18d): undefined reference to `amba_release_regions'
The was previously implied by the 'depends on ARCH_NOMADIK', but needs to be specified for the COMPILE_TEST case.
--- drivers/char/hw_random/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/char/hw_random/Kconfig +1 -0
@@ -286,6 +286,7 @@ config HW_RANDOM_INGENIC_TRNG config HW_RANDOM_NOMADIK tristate "ST-Ericsson Nomadik Random Number Generator support" depends on ARCH_NOMADIK || COMPILE_TEST + depends on ARM_AMBA default HW_RANDOM help This driver provides kernel-side support for the Random Number
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 96/196 scsi: pm80xx: Fix array-index-out-of-of-bounds on rmmod
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit 251be2f6037fb7ab399f68cd7428ff274133d693 ]
Since commit f7b705c238d1 ("scsi: pm80xx: Set phy_attached to zero when device is gone") UBSAN reports:
UBSAN: array-index-out-of-bounds in drivers/scsi/pm8001/pm8001_sas.c:786:17 index 28 is out of range for type 'pm8001_phy [16]'
on rmmod when using an expander.
For a direct attached device, attached_phy contains the local phy id. For a device behind an expander, attached_phy contains the remote phy id, not the local phy id.
I.e. while pm8001_ha will have pm8001_ha->chip->n_phy local phys, for a device behind an expander, attached_phy can be much larger than pm8001_ha->chip->n_phy (depending on the amount of phys of the expander).
E.g. on my system pm8001_ha has 8 phys with phy ids 0-7. One of the ports has an expander connected. The expander has 31 phys with phy ids 0-30.
The pm8001_ha->phy array only contains the phys of the HBA. It does not contain the phys of the expander. Thus, it is wrong to use attached_phy to index the pm8001_ha->phy array for a device behind an expander.
Thus, we can only clear phy_attached for devices that are directly attached.
--- drivers/scsi/pm8001/pm8001_sas.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/scsi/pm8001/pm8001_sas.c +8 -1
@@ -704,6 +704,7 @@ static void pm8001_dev_gone_notify(struct domain_device *dev)unsigned long flags =0 ;struct pm8001_hba_info *pm8001_ha;struct pm8001_device *pm8001_dev = dev->lldd_dev; +struct domain_device *parent_dev = dev->parent; pm8001_ha =pm8001_find_ha_by_dev (dev);spin_lock_irqsave (&pm8001_ha->lock, flags);
@@ -720,7 +721,13 @@ static void pm8001_dev_gone_notify(struct domain_device *dev)spin_lock_irqsave (&pm8001_ha->lock, flags); }PM8001_CHIP_DISP ->dereg_dev_req (pm8001_ha, device_id); - pm8001_ha->phy[pm8001_dev->attached_phy].phy_attached =0 ; + +/* +* The phy array only contains local phys. Thus, we cannot clear +* phy_attached for a device behind an expander. +*/ +if (!(parent_dev &&dev_is_expander (parent_dev->dev_type))) + pm8001_ha->phy[pm8001_dev->attached_phy].phy_attached =0 ;pm8001_free_dev (pm8001_dev); }else {pm8001_dbg (pm8001_ha,DISC ,"Found dev has gone.\n" );
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 97/196 scsi: myrs: Fix dma_alloc_coherent() error check
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit edb35b1ffc686fd9b5a91902f034eb9f4d2c9f6b ]
Check for NULL return value with dma_alloc_coherent(), because DMA address is not always set by dma_alloc_coherent() on failure.
--- drivers/scsi/myrs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/scsi/myrs.c +4 -4
@@ -498,14 +498,14 @@ static bool myrs_enable_mmio_mbox(struct myrs_hba *cs,/* Temporary dma mapping, used only in the scope of this function */ mbox =dma_alloc_coherent (&pdev->dev,sizeof (union myrs_cmd_mbox ), &mbox_addr,GFP_KERNEL ); -if (dma_mapping_error (&pdev->dev, mbox_addr)) +if (!mbox)return false;/* These are the base addresses for the command memory mailbox array */ cs->cmd_mbox_size =MYRS_MAX_CMD_MBOX *sizeof (union myrs_cmd_mbox ); cmd_mbox =dma_alloc_coherent (&pdev->dev, cs->cmd_mbox_size, &cs->cmd_mbox_addr,GFP_KERNEL ); -if (dma_mapping_error (&pdev->dev, cs->cmd_mbox_addr)) { +if (!cmd_mbox) {dev_err (&pdev->dev,"Failed to map command mailbox\n" ); goto out_free; }
@@ -520,7 +520,7 @@ static bool myrs_enable_mmio_mbox(struct myrs_hba *cs, cs->stat_mbox_size =MYRS_MAX_STAT_MBOX *sizeof (struct myrs_stat_mbox ); stat_mbox =dma_alloc_coherent (&pdev->dev, cs->stat_mbox_size, &cs->stat_mbox_addr,GFP_KERNEL ); -if (dma_mapping_error (&pdev->dev, cs->stat_mbox_addr)) { +if (!stat_mbox) {dev_err (&pdev->dev,"Failed to map status mailbox\n" ); goto out_free; }
@@ -533,7 +533,7 @@ static bool myrs_enable_mmio_mbox(struct myrs_hba *cs, cs->fwstat_buf =dma_alloc_coherent (&pdev->dev,sizeof (struct myrs_fwstat ), &cs->fwstat_addr,GFP_KERNEL ); -if (dma_mapping_error (&pdev->dev, cs->fwstat_addr)) { +if (!cs->fwstat_buf) {dev_err (&pdev->dev,"Failed to map firmware health buffer\n" ); cs->fwstat_buf =NULL ; goto out_free;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 98/196 media: rj54n1cb0c: Fix memleak in rj54n1_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Shurong <[email protected]>
[ Upstream commit fda55673ecdabf25f5ecc61b5ab17239257ac252 ]
rj54n1_probe() won't clean all the allocated resources in fail path, which may causes the memleaks. Add v4l2_ctrl_handler_free() to prevent memleak.
--- drivers/media/i2c/rj54n1cb0c.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/media/i2c/rj54n1cb0c.c +6 -3
@@ -1332,10 +1332,13 @@ static int rj54n1_probe(struct i2c_client *client, V4L2_CID_GAIN, 0, 127, 1, 66);v4l2_ctrl_new_std (&rj54n1->hdl, &rj54n1_ctrl_ops,V4L2_CID_AUTO_WHITE_BALANCE ,0 ,1 ,1 ,1 ); - rj54n1->subdev.ctrl_handler = &rj54n1->hdl; -if (rj54n1->hdl.error) -return rj54n1->hdl.error; +if (rj54n1->hdl.error) { + ret = rj54n1->hdl.error; + goto err_free_ctrl; + } + + rj54n1->subdev.ctrl_handler = &rj54n1->hdl; rj54n1->clk_div = clk_div; rj54n1->rect.left =RJ54N1_COLUMN_SKIP ; rj54n1->rect.top =RJ54N1_ROW_SKIP ;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 99/196 ALSA: lx_core: use int type to store negative error codes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qianfeng Rong <[email protected]>
[ Upstream commit 4ef353d546cda466fc39b7daca558d7bcec21c09 ]
Change the 'ret' variable from u16 to int to store negative error codes or zero returned by lx_message_send_atomic().
Storing the negative error codes in unsigned type, doesn't cause an issue at runtime but it's ugly as pants. Additionally, assigning negative error codes to unsigned type may trigger a GCC warning when the -Wsign-conversion flag is enabled.
No effect on runtime.
--- sound/pci/lx6464es/lx_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/pci/lx6464es/lx_core.c +2 -2
@@ -316,7 +316,7 @@ static int lx_message_send_atomic(struct lx6464es *chip, struct lx_rmh *rmh)/* low-level dsp access */ int lx_dsp_get_version (struct lx6464es *chip,u32 *rdsp_version) { -u16 ret; +int ret;mutex_lock (&chip->msg_lock);
@@ -330,10 +330,10 @@ int lx_dsp_get_version(struct lx6464es *chip, u32 *rdsp_version)int lx_dsp_get_clock_frequency (struct lx6464es *chip,u32 *rfreq) { -u16 ret =0 ;u32 freq_raw =0 ;u32 freq =0 ;u32 frequency =0 ; +int ret;mutex_lock (&chip->msg_lock);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 100/196 media: st-delta: avoid excessive stack usage
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit 5954ad7d1af92cb6244c5f31216e43af55febbb7 ]
Building with a reduced stack warning limit shows that delta_mjpeg_decode() copies a giant structure to the stack each time but only uses three of its members:
drivers/media/platform/st/sti/delta/delta-mjpeg-dec.c: In function 'delta_mjpeg_decode':drivers/media/platform/st/sti/delta/delta-mjpeg-dec.c:427:1: error: the frame size of 1296 bytes is larger than 1280 bytes [-Werror=frame-larger-than=]
Open-code the passing of the structure members that are actually used here.
--- .../platform/st/sti/delta/delta-mjpeg-dec.c | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/media/platform/st/sti/delta/delta-mjpeg-dec.c +11 -9
@@ -239,7 +239,7 @@ static int delta_mjpeg_ipc_open(struct delta_ctx *pctx)return 0 ; } -static int delta_mjpeg_ipc_decode (struct delta_ctx *pctx,struct delta_au *au) +static int delta_mjpeg_ipc_decode (struct delta_ctx *pctx,dma_addr_t pstart,dma_addr_t pend) {struct delta_dev *delta = pctx->dev;struct delta_mjpeg_ctx *ctx =to_ctx (pctx);
@@ -256,8 +256,8 @@ static int delta_mjpeg_ipc_decode(struct delta_ctx *pctx, struct delta_au *au)memset (params,0 ,sizeof (*params)); - params->picture_start_addr_p = (u32)(au->paddr); - params->picture_end_addr_p = (u32)(au->paddr + au->size -1 ); + params->picture_start_addr_p = pstart; + params->picture_end_addr_p = pend;/* * !WARNING!
@@ -374,12 +374,14 @@ static int delta_mjpeg_decode(struct delta_ctx *pctx, struct delta_au *pau)struct delta_dev *delta = pctx->dev;struct delta_mjpeg_ctx *ctx =to_ctx (pctx);int ret; -struct delta_au au = *pau; +void *au_vaddr = pau->vaddr; +dma_addr_t au_dma = pau->paddr; +size_t au_size = pau->size;unsigned int data_offset =0 ;struct mjpeg_header *header = &ctx->header_struct;if (!ctx->header) { - ret =delta_mjpeg_read_header (pctx, au.vaddr, au.size, + ret =delta_mjpeg_read_header (pctx, au_vaddr, au_size, header, &data_offset);if (ret) { pctx->stream_errors++;
@@ -405,17 +407,17 @@ static int delta_mjpeg_decode(struct delta_ctx *pctx, struct delta_au *pau) goto err; } - ret =delta_mjpeg_read_header (pctx, au.vaddr, au.size, + ret =delta_mjpeg_read_header (pctx, au_vaddr, au_size, ctx->header, &data_offset);if (ret) { pctx->stream_errors++; goto err; } - au.paddr += data_offset; - au.vaddr += data_offset; + au_dma += data_offset; + au_vaddr += data_offset; - ret =delta_mjpeg_ipc_decode (pctx, &au); + ret =delta_mjpeg_ipc_decode (pctx, au_dma, au_dma + au_size -1 );if (ret) goto err;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 101/196 crypto: hisilicon/zip - remove unnecessary validation for high-performance mode configurations
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chenghai Huang <[email protected]>
[ Upstream commit d4e081510471e79171c4e0a11f6cb608e49bc082 ]
When configuring the high-performance mode register, there is no need to verify whether the register has been successfully enabled, as there is no possibility of a write failure for this register.
--- drivers/crypto/hisilicon/zip/zip_main.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
drivers/crypto/hisilicon/zip/zip_main.c +2 -12
@@ -470,10 +470,9 @@ bool hisi_zip_alg_support(struct hisi_qm *qm, u32 alg)return false; } -static int hisi_zip_set_high_perf (struct hisi_qm *qm) +static void hisi_zip_set_high_perf (struct hisi_qm *qm) {u32 val; -int ret; val =readl_relaxed (qm->io_base +HZIP_HIGH_PERF_OFFSET );if (perf_mode ==HZIP_HIGH_COMP_PERF )
@@ -483,13 +482,6 @@ static int hisi_zip_set_high_perf(struct hisi_qm *qm)/* Set perf mode */ writel (val, qm->io_base +HZIP_HIGH_PERF_OFFSET ); - ret =readl_relaxed_poll_timeout (qm->io_base +HZIP_HIGH_PERF_OFFSET , - val, val == perf_mode,HZIP_DELAY_1_US , -HZIP_POLL_TIMEOUT_US ); -if (ret) -pci_err (qm->pdev,"failed to set perf mode\n" ); - -return ret; }static void hisi_zip_open_sva_prefetch (struct hisi_qm *qm)
@@ -1181,9 +1173,7 @@ static int hisi_zip_pf_probe_init(struct hisi_zip *hisi_zip)if (ret)return ret; - ret =hisi_zip_set_high_perf (qm); -if (ret) -return ret; +hisi_zip_set_high_perf (qm);hisi_zip_open_sva_prefetch (qm);hisi_qm_dev_err_init (qm);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 102/196 crypto: hisilicon - re-enable address prefetch after device resuming
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chenghai Huang <[email protected]>
[ Upstream commit 0dcd21443d9308ed88909d35aa0490c3fc680a47 ]
When the device resumes from a suspended state, it will revert to its initial state and requires re-enabling. Currently, the address prefetch function is not re-enabled after device resuming. Move the address prefetch enable to the initialization process. In this way, the address prefetch can be enabled when the device resumes by calling the initialization process.
--- drivers/crypto/hisilicon/hpre/hpre_main.c | 3 +- drivers/crypto/hisilicon/qm.c | 3 - drivers/crypto/hisilicon/sec2/sec_main.c | 80 +++++++++++------------ drivers/crypto/hisilicon/zip/zip_main.c | 5 +- 4 files changed, 43 insertions(+), 48 deletions(-)
drivers/crypto/hisilicon/hpre/hpre_main.c +1 -2
@@ -690,6 +690,7 @@ static int hpre_set_user_domain_and_cache(struct hisi_qm *qm)/* Config data buffer pasid needed by Kunpeng 920 */ hpre_config_pasid (qm); +hpre_open_sva_prefetch (qm);hpre_enable_clock_gate (qm);
@@ -1367,8 +1368,6 @@ static int hpre_pf_probe_init(struct hpre *hpre)if (ret)return ret; -hpre_open_sva_prefetch (qm); -hisi_qm_dev_err_init (qm); ret =hpre_show_last_regs_init (qm);if (ret)
drivers/crypto/hisilicon/qm.c +0 -3
@@ -4268,9 +4268,6 @@ static void qm_restart_prepare(struct hisi_qm *qm) {u32 value; -if (qm->err_ini->open_sva_prefetch) - qm->err_ini->open_sva_prefetch (qm); -if (qm->ver >=QM_HW_V3 )return ;
drivers/crypto/hisilicon/sec2/sec_main.c +40 -40
98 lines not on this page · raw message
drivers/crypto/hisilicon/zip/zip_main.c +2 -3
@@ -578,6 +578,7 @@ static int hisi_zip_set_user_domain_and_cache(struct hisi_qm *qm)writel (AXUSER_BASE , base +HZIP_DATA_WUSER_32_63 );writel (AXUSER_BASE , base +HZIP_SGL_RUSER_32_63 ); } +hisi_zip_open_sva_prefetch (qm);/* let's open all compression/decompression cores */ dcomp_bm = qm->cap_tables.dev_cap_table[ZIP_DECOMP_ENABLE_BITMAP_IDX ].cap_val;
@@ -589,6 +590,7 @@ static int hisi_zip_set_user_domain_and_cache(struct hisi_qm *qm)CQC_CACHE_WB_ENABLE |FIELD_PREP (SQC_CACHE_WB_THRD ,1 ) | FIELD_PREP(CQC_CACHE_WB_THRD, 1), base + QM_CACHE_CTL); +hisi_zip_set_high_perf (qm);hisi_zip_enable_clock_gate (qm);return 0 ;
@@ -1173,9 +1175,6 @@ static int hisi_zip_pf_probe_init(struct hisi_zip *hisi_zip)if (ret)return ret; -hisi_zip_set_high_perf (qm); - -hisi_zip_open_sva_prefetch (qm);hisi_qm_dev_err_init (qm);hisi_zip_debug_regs_clear (qm);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 103/196 drm/amdgpu: Power up UVD 3 for FW validation (v2)
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit c661219cd7be75bb5599b525f16a455a058eb516 ]
Unlike later versions, UVD 3 has firmware validation. For this to work, the UVD should be powered up correctly.
When DPM is enabled and the display clock is off, the SMU may choose a power state which doesn't power the UVD, which can result in failure to initialize UVD.
v2:
Add code comments to explain about the UVD power state and how UVD clock is turned on/off.
--- drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c | 29 +++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c +25 -4
@@ -625,7 +625,22 @@ static void uvd_v3_1_enable_mgcg(struct amdgpu_device *adev,* * @handle: handle used to pass amdgpu_device pointer * -* Initialize the hardware, boot up the VCPU and do some testing +* Initialize the hardware, boot up the VCPU and do some testing. +* +* On SI, the UVD is meant to be used in a specific power state, +* or alternatively the driver can manually enable its clock. +* In amdgpu we use the dedicated UVD power state when DPM is enabled. +* Calling amdgpu_dpm_enable_uvd makes DPM select the UVD power state +* for the SMU and afterwards enables the UVD clock. +* This is automatically done by amdgpu_uvd_ring_begin_use when work +* is submitted to the UVD ring. Here, we have to call it manually +* in order to power up UVD before firmware validation. +* +* Note that we must not disable the UVD clock here, as that would +* cause the ring test to fail. However, UVD is powered off +* automatically after the ring test: amdgpu_uvd_ring_end_use calls +* the UVD idle work handler which will disable the UVD clock when +* all fences are signalled. */ static int uvd_v3_1_hw_init (void *handle) {
@@ -635,6 +650,15 @@ static int uvd_v3_1_hw_init(void *handle)int r;uvd_v3_1_mc_resume (adev); +uvd_v3_1_enable_mgcg (adev, true); + +/* Make sure UVD is powered during FW validation. +* It's going to be automatically powered off after the ring test. +*/ +if (adev->pm.dpm_enabled) +amdgpu_dpm_enable_uvd (adev, true); +else +amdgpu_asic_set_uvd_clocks (adev,53300 ,40000 ); r =uvd_v3_1_fw_validate (adev);if (r) {
@@ -642,9 +666,6 @@ static int uvd_v3_1_hw_init(void *handle)return r; } -uvd_v3_1_enable_mgcg (adev, true); -amdgpu_asic_set_uvd_clocks (adev,53300 ,40000 ); -uvd_v3_1_start (adev); r =amdgpu_ring_test_helper (ring);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 104/196 drm/amd/pm: Disable ULV even if unsupported (v3)
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit 3a0c3a4035f995e1f993dfaf4d63dc19e9b4bc1c ]
Always send PPSMC_MSG_DisableULV to the SMC, even if ULV mode is unsupported, to make sure it is properly turned off.
v3:
Simplify si_disable_ulv further.
Always check the return value of amdgpu_si_send_msg_to_smc.
--- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +3 -7
@@ -5617,14 +5617,10 @@ static int si_populate_smc_t(struct amdgpu_device *adev,static int si_disable_ulv (struct amdgpu_device *adev) { -struct si_power_info *si_pi =si_get_pi (adev); -struct si_ulv_param *ulv = &si_pi->ulv; +PPSMC_Result r; -if (ulv->supported) -return (amdgpu_si_send_msg_to_smc (adev, PPSMC_MSG_DisableULV) == PPSMC_Result_OK) ? -0 : -EINVAL ; - -return 0 ; + r =amdgpu_si_send_msg_to_smc (adev, PPSMC_MSG_DisableULV); +return (r == PPSMC_Result_OK) ?0 : -EINVAL ; } static bool si_is_state_ulv_compatible(struct amdgpu_device *adev,
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 105/196 drm/amd/pm: Fix si_upload_smc_data (v3)
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit a43b2cec04b02743338aa78f837ee0bdf066a6d5 ]
The si_upload_smc_data function uses si_write_smc_soft_register to set some register values in the SMC, and expects the result to be PPSMC_Result_OK which is 1.
The PPSMC_Result_OK / PPSMC_Result_Failed values are used for checking the result of a command sent to the SMC. However, the si_write_smc_soft_register actually doesn't send any commands to the SMC and returns zero on success, so this check was incorrect.
Fix that by not checking the return value, just like other calls to si_write_smc_soft_register.
v3:
Additionally, when no display is plugged in, there is no need to restrict MCLK switching, so program the registers to zero.
--- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 43 ++++++++++++---------- 1 file changed, 24 insertions(+), 19 deletions(-)
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +24 -19
@@ -5793,9 +5793,9 @@ static int si_upload_smc_data(struct amdgpu_device *adev) {struct amdgpu_crtc *amdgpu_crtc =NULL ;int i; - -if (adev->pm.dpm.new_active_crtc_count ==0 ) -return 0 ; +u32 crtc_index =0 ; +u32 mclk_change_block_cp_min =0 ; +u32 mclk_change_block_cp_max =0 ;for (i =0 ; i < adev->mode_info.num_crtc; i++) {if (adev->pm.dpm.new_active_crtcs & (1 << i)) {
@@ -5804,26 +5804,31 @@ static int si_upload_smc_data(struct amdgpu_device *adev) } } -if (amdgpu_crtc ==NULL ) -return 0 ; +/* When a display is plugged in, program these so that the SMC +* performs MCLK switching when it doesn't cause flickering. +* When no display is plugged in, there is no need to restrict +* MCLK switching, so program them to zero. +*/ +if (adev->pm.dpm.new_active_crtc_count && amdgpu_crtc) { + crtc_index = amdgpu_crtc->crtc_id; -if (amdgpu_crtc->line_time <=0 ) -return 0 ; +if (amdgpu_crtc->line_time) { + mclk_change_block_cp_min = amdgpu_crtc->wm_high / amdgpu_crtc->line_time; + mclk_change_block_cp_max = amdgpu_crtc->wm_low / amdgpu_crtc->line_time; + } + } -if (si_write_smc_soft_register (adev, - SI_SMC_SOFT_REGISTER_crtc_index, - amdgpu_crtc->crtc_id) != PPSMC_Result_OK) -return 0 ; +si_write_smc_soft_register (adev, + SI_SMC_SOFT_REGISTER_crtc_index, + crtc_index); -if (si_write_smc_soft_register (adev, - SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min, - amdgpu_crtc->wm_high / amdgpu_crtc->line_time) != PPSMC_Result_OK) -return 0 ; +si_write_smc_soft_register (adev, + SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min, + mclk_change_block_cp_min); -if (si_write_smc_soft_register (adev, - SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max, - amdgpu_crtc->wm_low / amdgpu_crtc->line_time) != PPSMC_Result_OK) -return 0 ; +si_write_smc_soft_register (adev, + SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max, + mclk_change_block_cp_max);return 0 ; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 106/196 drm/amd/pm: Adjust si_upload_smc_data register programming (v3)
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit ce025130127437dc884c84c254170e27b2ce9309 ]
Based on some comments in dm_pp_display_configuration above the crtc_index and line_time fields, these values are programmed to the SMC to work around an SMC hang when it switches MCLK.
According to Alex, the Windows driver programs them to:mclk_change_block_cp_min = 200 / line_time mclk_change_block_cp_max = 100 / line_time Let's use the same for the sake of consistency.
Previously we used the watermark values, but it seemed buggy as the code was mixing up low/high and A/B watermarks, and was not saving a low watermark value on DCE 6, so mclk_change_block_cp_max would be always zero previously.
Split this change off from the previous si_upload_smc_data to make it easier to bisect, in case it causes any issues.
--- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +2 -2
@@ -5813,8 +5813,8 @@ static int si_upload_smc_data(struct amdgpu_device *adev) crtc_index = amdgpu_crtc->crtc_id;if (amdgpu_crtc->line_time) { - mclk_change_block_cp_min = amdgpu_crtc->wm_high / amdgpu_crtc->line_time; - mclk_change_block_cp_max = amdgpu_crtc->wm_low / amdgpu_crtc->line_time; + mclk_change_block_cp_min =200 / amdgpu_crtc->line_time; + mclk_change_block_cp_max =100 / amdgpu_crtc->line_time; } }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 107/196 drm/amd/pm: Treat zero vblank time as too short in si_dpm (v3)
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit 9003a0746864f39a0ef72bd45f8e1ad85d930d67 ]
Some parts of the code base expect that MCLK switching is turned off when the vblank time is set to zero.
According to pp_pm_compute_clocks the non-DC code has issues with MCLK switching with refresh rates over 120 Hz.
v3:
Add code comment to explain this better.
Add an if statement instead of changing the switch_limit.
--- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +7 -1
@@ -3066,7 +3066,13 @@ static bool si_dpm_vblank_too_short(void *handle)/* we never hit the non-gddr5 limit so disable it */ u32 switch_limit = adev->gmc.vram_type ==AMDGPU_VRAM_TYPE_GDDR5 ?450 :0 ; -if (vblank_time < switch_limit) +/* Consider zero vblank time too short and disable MCLK switching. +* Note that the vblank time is set to maximum when no displays are attached, +* so we'll still enable MCLK switching in that case. +*/ +if (vblank_time ==0 ) +return true; +else if (vblank_time < switch_limit)return true;else return false;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 108/196 drm/amd/pm: Disable MCLK switching with non-DC at 120 Hz+ (v2)
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit ed3803533c7bf7df88bc3fc9f70bd317e1228ea8 ]
According to pp_pm_compute_clocks the non-DC display code has "issues with mclk switching with refresh rates over 120 hz". The workaround is to disable MCLK switching in this case.
Do the same for legacy DPM.
--- drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/pm/amdgpu_dpm_internal.c +7 -0
@@ -66,6 +66,13 @@ u32 amdgpu_dpm_get_vblank_time(struct amdgpu_device *adev) (amdgpu_crtc->v_border * 2)); vblank_time_us = vblank_in_pixels *1000 / amdgpu_crtc->hw_mode.clock; + +/* we have issues with mclk switching with +* refresh rates over 120 hz on the non-DC code. +*/ +if (drm_mode_vrefresh (&amdgpu_crtc->hw_mode) >120 ) + vblank_time_us =0 ; +break ; } }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 109/196 drm/amd/pm: Disable SCLK switching on Oland with high pixel clocks (v3)
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit 7009e3af0474aca5f64262b3c72fb6e23b232f9b ]
Port of commit 227545b9a08c ("drm/radeon/dpm: Disable sclk switching on Oland when two 4K 60Hz monitors are connected")
This is an ad-hoc DPM fix, necessary because we don't have proper bandwidth calculation for DCE 6.
We define "high pixelclock" for SI as higher than necessary for 4K 30Hz. For example, 4K 60Hz and 1080p 144Hz fall into this category.
When two high pixel clock displays are connected to Oland, additionally disable shader clock switching, which results in a higher voltage, thereby addressing some visible flickering.
v2:
Add more comments.
v3:
Split into two commits for easier review.
--- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+)
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +31 -0
@@ -3430,12 +3430,14 @@ static void si_apply_state_adjust_rules(struct amdgpu_device *adev, {struct si_ps *ps =si_get_ps (rps);struct amdgpu_clock_and_voltage_limits *max_limits; +struct amdgpu_connector *conn;bool disable_mclk_switching = false;bool disable_sclk_switching = false;u32 mclk, sclk;u16 vddc, vddci, min_vce_voltage =0 ;u32 max_sclk_vddc, max_mclk_vddci, max_mclk_vddc;u32 max_sclk =0 , max_mclk =0 ; +u32 high_pixelclock_count =0 ;int i;if (adev->asic_type ==CHIP_HAINAN ) {
@@ -3463,6 +3465,35 @@ static void si_apply_state_adjust_rules(struct amdgpu_device *adev, } } +/* We define "high pixelclock" for SI as higher than necessary for 4K 30Hz. +* For example, 4K 60Hz and 1080p 144Hz fall into this category. +* Find number of such displays connected. +*/ +for (i =0 ; i < adev->mode_info.num_crtc; i++) { +if (!(adev->pm.dpm.new_active_crtcs & (1 << i)) || + !adev->mode_info.crtcs[i]->enabled) +continue ; + + conn =to_amdgpu_connector (adev->mode_info.crtcs[i]->connector); + +if (conn->pixelclock_for_modeset >297000 ) + high_pixelclock_count++; + } + +/* These are some ad-hoc fixes to some issues observed with SI GPUs. +* They are necessary because we don't have something like dce_calcs +* for these GPUs to calculate bandwidth requirements. +*/ +if (high_pixelclock_count) { +/* On Oland, we observe some flickering when two 4K 60Hz +* displays are connected, possibly because voltage is too low. +* Raise the voltage by requiring a higher SCLK. +* (Voltage cannot be adjusted independently without also SCLK.) +*/ +if (high_pixelclock_count >1 && adev->asic_type ==CHIP_OLAND ) + disable_sclk_switching = true; + } +if (rps->vce_active) { rps->evclk = adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].evclk; rps->ecclk = adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].ecclk;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 110/196 wifi: mwifiex: send world regulatory domain to driver
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Kerkmann <[email protected]>
[ Upstream commit 56819d00bc2ebaa6308913c28680da5d896852b8 ]
The world regulatory domain is a restrictive subset of channel configurations which allows legal operation of the adapter all over the world. Changing to this domain should not be prevented.
--- drivers/net/wireless/marvell/mwifiex/cfg80211.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/wireless/marvell/mwifiex/cfg80211.c +3 -4
@@ -659,10 +659,9 @@ static void mwifiex_reg_notifier(struct wiphy *wiphy,return ; } -/* Don't send world or same regdom info to firmware */ -if (strncmp (request->alpha2,"00" ,2 ) && -strncmp (request->alpha2, adapter->country_code, -sizeof (request->alpha2))) { +/* Don't send same regdom info to firmware */ +if (strncmp (request->alpha2, adapter->country_code, +sizeof (request->alpha2)) !=0 ) {memcpy (adapter->country_code, request->alpha2,sizeof (request->alpha2));mwifiex_send_domain_info_cmd_fw (wiphy);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 111/196 PCI: tegra: Fix devm_kcalloc() argument order for port->phys allocation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alok Tiwari <[email protected]>
[ Upstream commit e1a8805e5d263453ad76a4f50ab3b1c18ea07560 ]
Fix incorrect argument order in devm_kcalloc() when allocating port->phys. The original call used sizeof(phy) as the number of elements and port->lanes as the element size, which is reversed. While this happens to produce the correct total allocation size with current pointer size and lane counts, the argument order is wrong.
--- drivers/pci/controller/pci-tegra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/pci-tegra.c +1 -1
@@ -1346,7 +1346,7 @@ static int tegra_pcie_port_get_phys(struct tegra_pcie_port *port)unsigned int i;int err; - port->phys =devm_kcalloc (dev,sizeof (phy), port->lanes,GFP_KERNEL ); + port->phys =devm_kcalloc (dev, port->lanes,sizeof (phy),GFP_KERNEL );if (!port->phys)return -ENOMEM ;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 112/196 tcp: fix __tcp_close() to only send RST when required
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 5f9238530970f2993b23dd67fdaffc552a2d2e98 ]
If the receive queue contains payload that was already received, __tcp_close() can send an unexpected RST.
Refine the code to take tp->copied_seq into account, as we already do in tcp recvmsg().
--- net/ipv4/tcp.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
net/ipv4/tcp.c +5 -4
@@ -2905,8 +2905,8 @@ bool tcp_check_oom(struct sock *sk, int shift)void __tcp_close (struct sock *sk,long timeout) { +bool data_was_unread = false;struct sk_buff *skb; -int data_was_unread =0 ;int state;WRITE_ONCE (sk->sk_shutdown,SHUTDOWN_MASK );
@@ -2925,11 +2925,12 @@ void __tcp_close(struct sock *sk, long timeout)* reader process may not have drained the data yet! */ while ((skb =__skb_dequeue (&sk->sk_receive_queue)) !=NULL ) { -u32 len =TCP_SKB_CB (skb)->end_seq -TCP_SKB_CB (skb)->seq; +u32 end_seq =TCP_SKB_CB (skb)->end_seq;if (TCP_SKB_CB (skb)->tcp_flags &TCPHDR_FIN ) - len--; - data_was_unread += len; + end_seq--; +if (after (end_seq,tcp_sk (sk)->copied_seq)) + data_was_unread = true;__kfree_skb (skb); }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 113/196 drm/amdkfd: Fix error code sign for EINVAL in svm_ioctl()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qianfeng Rong <[email protected]>
[ Upstream commit cbda64f3f58027f68211dda8ea94d52d7e493995 ]
Use negative error code -EINVAL instead of positive EINVAL in the default case of svm_ioctl() to conform to Linux kernel error code conventions.
--- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +1 -1
@@ -4002,7 +4002,7 @@ svm_ioctl(struct kfd_process *p, enum kfd_ioctl_svm_op op, uint64_t start, r =svm_range_get_attr (p, mm, start, size, nattrs, attrs);break ;default : - r =EINVAL ; + r = -EINVAL ;break ; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 114/196 usb: phy: twl6030: Fix incorrect type for ret
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xichao Zhao <[email protected]>
[ Upstream commit b570b346ddd727c4b41743a6a2f49e7217c5317f ]
In the twl6030_usb_probe(), the variable ret is declared as a u32 type. However, since ret may receive -ENODEV when accepting the return value of omap_usb2_set_comparator().Therefore, its type should be changed to int.
--- drivers/usb/phy/phy-twl6030-usb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/phy/phy-twl6030-usb.c +1 -2
@@ -328,9 +328,8 @@ static int twl6030_set_vbus(struct phy_companion *comparator, bool enabled)static int twl6030_usb_probe (struct platform_device *pdev) { -u32 ret;struct twl6030_usb *twl; -int status, err; +int status, err, ret;struct device_node *np = pdev->dev.of_node;struct device *dev = &pdev->dev;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 115/196 usb: gadget: configfs: Correctly set use_os_string at bind
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: William Wu <[email protected]>
[ Upstream commit e271cc0d25015f4be6c88bd7731444644eb352c2 ]
Once the use_os_string flag is set to true for some functions (e.g. adb/mtp) which need to response the OS string, and then if we re-bind the ConfigFS gadget to use the other functions (e.g. hid) which should not to response the OS string, however, because the use_os_string flag is still true, so the usb gadget response the OS string descriptor incorrectly, this can cause the USB device to be unrecognizable on the Windows system.
An example of this as follows:
echo 1 > os_desc/use
ln -s functions/ffs.adb configs/b.1/function0
start adbd
echo "<udc device>" > UDC #succeed
stop adbd
rm configs/b.1/function0
echo 0 > os_desc/use
ln -s functions/hid.gs0 configs/b.1/function0 echo "<udc device>" > UDC #fail to connect on Windows
This patch sets the use_os_string flag to false at bind if the functions not support OS Descriptors.
--- drivers/usb/gadget/configfs.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/gadget/configfs.c +2 -0
@@ -1356,6 +1356,8 @@ static int configfs_composite_bind(struct usb_gadget *gadget, cdev->use_os_string = true; cdev->b_vendor_code = gi->b_vendor_code;memcpy (cdev->qw_sign, gi->qw_sign,OS_STRING_QW_SIGN_LEN ); + }else { + cdev->use_os_string = false; }if (gadget_is_otg (gadget) && !otg_desc[0 ]) {
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 116/196 misc: genwqe: Fix incorrect cmd field being reported in error
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Colin Ian King <[email protected]>
[ Upstream commit 6b26053819dccc664120e07c56f107fb6f72f3fa ]
There is a dev_err message that is reporting the value of cmd->asiv_length when it should be reporting cmd->asv_length instead. Fix this.
--- drivers/misc/genwqe/card_ddcb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/genwqe/card_ddcb.c +1 -1
@@ -923,7 +923,7 @@ int __genwqe_execute_raw_ddcb(struct genwqe_dev *cd, }if (cmd->asv_length >DDCB_ASV_LENGTH ) {dev_err (&pci_dev->dev,"[%s] err: wrong asv_length of %d\n" , - __func__, cmd->asiv_length); + __func__, cmd->asv_length);return -EINVAL ; } rc =__genwqe_enqueue_ddcb (cd, req, f_flags);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 117/196 pps: fix warning in pps_register_cdev when register device fail
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Liang <[email protected]>
[ Upstream commit b0531cdba5029f897da5156815e3bdafe1e9b88d ]
Similar to previous commit 2a934fdb01db ("media: v4l2-dev: fix error handling in __video_register_device()"), the release hook should be set before device_register(). Otherwise, when device_register() return error and put_device() try to callback the release function, the below warning may happen.
------------[ cut here ]------------ WARNING: CPU: 1 PID: 4760 at drivers/base/core.c:2567 device_release+0x1bd/0x240 drivers/base/core.c:2567 Modules linked in: CPU: 1 UID: 0 PID: 4760 Comm: syz.4.914 Not tainted 6.17.0-rc3+ #1 NONE RIP: 0010:device_release+0x1bd/0x240 drivers/base/core.c:2567 Call Trace: <TASK> kobject_cleanup+0x136/0x410 lib/kobject.c:689 kobject_release lib/kobject.c:720 [inline] kref_put include/linux/kref.h:65 [inline] kobject_put+0xe9/0x130 lib/kobject.c:737 put_device+0x24/0x30 drivers/base/core.c:3797 pps_register_cdev+0x2da/0x370 drivers/pps/pps.c:402 pps_register_source+0x2f6/0x480 drivers/pps/kapi.c:108 pps_tty_open+0x190/0x310 drivers/pps/clients/pps-ldisc.c:57 tty_ldisc_open+0xa7/0x120 drivers/tty/tty_ldisc.c:432 tty_set_ldisc+0x333/0x780 drivers/tty/tty_ldisc.c:563 tiocsetd drivers/tty/tty_io.c:2429 [inline] tty_ioctl+0x5d1/0x1700 drivers/tty/tty_io.c:2728 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:598 [inline] __se_sys_ioctl fs/ioctl.c:584 [inline] __x64_sys_ioctl+0x194/0x210 fs/ioctl.c:584 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x5f/0x2a0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x76/0x7e </TASK>
Before commit c79a39dc8d06 ("pps: Fix a use-after-free"), pps_register_cdev() call device_create() to create pps->dev, which will init dev->release to device_create_release(). Now the comment is outdated, just remove it.
Thanks for the reminder from Calvin Owens, 'kfree_pps' should be removed in pps_register_source() to avoid a double free in the failure case.
--- drivers/pps/kapi.c | 5 +---- drivers/pps/pps.c | 5 ++--- 2 files changed, 3 insertions(+), 7 deletions(-)
drivers/pps/kapi.c +1 -4
@@ -109,16 +109,13 @@ struct pps_device *pps_register_source(struct pps_source_info *info,if (err <0 ) {pr_err ("%s: unable to create char device\n" , info->name); - goto kfree_pps; + goto pps_register_source_exit; }dev_dbg (&pps->dev,"new PPS source %s\n" , info->name);return pps; -kfree_pps: -kfree (pps); - pps_register_source_exit:pr_err ("%s: unable to register source\n" , info->name);
drivers/pps/pps.c +2 -3
@@ -375,6 +375,7 @@ int pps_register_cdev(struct pps_device *pps) pps->info.name); err = -EBUSY ; } +kfree (pps); goto out_unlock; } pps->id = err;
@@ -384,13 +385,11 @@ int pps_register_cdev(struct pps_device *pps) pps->dev.devt =MKDEV (pps_major, pps->id);dev_set_drvdata (&pps->dev, pps);dev_set_name (&pps->dev,"pps%d" , pps->id); + pps->dev.release = pps_device_destruct; err =device_register (&pps->dev);if (err) goto free_idr; -/* Override the release function with our own */ - pps->dev.release = pps_device_destruct; -pr_debug ("source %s got cdev (%d:%d)\n" , pps->info.name, pps_major, pps->id);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 118/196 ASoC: Intel: bytcht_es8316: Fix invalid quirk input mapping
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit b20eb0e8de383116f1e1470d74da2a3c83c4e345 ]
When an invalid value is passed via quirk option, currently bytcht_es8316 driver just ignores and leaves as is, which may lead to unepxected results like OOB access.
This patch adds the sanity check and corrects the input mapping to the certain default value if an invalid value is passed.
Message-ID: <[email protected]>
--- sound/soc/intel/boards/bytcht_es8316.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
sound/soc/intel/boards/bytcht_es8316.c +17 -3
@@ -46,7 +46,8 @@ enum { BYT_CHT_ES8316_INTMIC_IN2_MAP, }; -#define BYT_CHT_ES8316_MAP (quirk) ((quirk) & GENMASK(3, 0)) +#define BYT_CHT_ES8316_MAP_MASK GENMASK(3, 0) +#define BYT_CHT_ES8316_MAP (quirk) ((quirk) & BYT_CHT_ES8316_MAP_MASK)#define BYT_CHT_ES8316_SSP0 BIT(16)#define BYT_CHT_ES8316_MONO_SPEAKER BIT(17)#define BYT_CHT_ES8316_JD_INVERTED BIT(18)
@@ -59,10 +60,23 @@ MODULE_PARM_DESC(quirk, "Board-specific quirk override");static void log_quirks (struct device *dev) { -if (BYT_CHT_ES8316_MAP (quirk) ==BYT_CHT_ES8316_INTMIC_IN1_MAP ) +int map; + + map =BYT_CHT_ES8316_MAP (quirk); +switch (map) { +case BYT_CHT_ES8316_INTMIC_IN1_MAP :dev_info (dev,"quirk IN1_MAP enabled" ); -if (BYT_CHT_ES8316_MAP (quirk) ==BYT_CHT_ES8316_INTMIC_IN2_MAP ) +break ; +case BYT_CHT_ES8316_INTMIC_IN2_MAP :dev_info (dev,"quirk IN2_MAP enabled" ); +break ; +default : +dev_warn_once (dev,"quirk sets invalid input map: 0x%x, default to INTMIC_IN1_MAP\n" , map); + quirk &= ~BYT_CHT_ES8316_MAP_MASK ; + quirk |=BYT_CHT_ES8316_INTMIC_IN1_MAP ; +break ; + } +if (quirk &BYT_CHT_ES8316_SSP0 )dev_info (dev,"quirk SSP0 enabled" );if (quirk &BYT_CHT_ES8316_MONO_SPEAKER )
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 119/196 ASoC: Intel: bytcr_rt5640: Fix invalid quirk input mapping
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit fba404e4b4af4f4f747bb0e41e9fff7d03c7bcc0 ]
When an invalid value is passed via quirk option, currently bytcr_rt5640 driver only shows an error message but leaves as is. This may lead to unepxected results like OOB access.
This patch corrects the input mapping to the certain default value if an invalid value is passed.
Message-ID: <[email protected]>
--- sound/soc/intel/boards/bytcr_rt5640.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
sound/soc/intel/boards/bytcr_rt5640.c +5 -2
@@ -68,7 +68,8 @@ enum { BYT_RT5640_OVCD_SF_1P5 = (RT5640_OVCD_SF_1P5 << 13), }; -#define BYT_RT5640_MAP (quirk) ((quirk) & GENMASK(3, 0)) +#define BYT_RT5640_MAP_MASK GENMASK(3, 0) +#define BYT_RT5640_MAP (quirk) ((quirk) & BYT_RT5640_MAP_MASK)#define BYT_RT5640_JDSRC (quirk) (((quirk) & GENMASK(7, 4)) >> 4)#define BYT_RT5640_OVCD_TH (quirk) (((quirk) & GENMASK(12, 8)) >> 8)#define BYT_RT5640_OVCD_SF (quirk) (((quirk) & GENMASK(14, 13)) >> 13)
@@ -140,7 +141,9 @@ static void log_quirks(struct device *dev)dev_info (dev,"quirk NO_INTERNAL_MIC_MAP enabled\n" );break ;default : -dev_err (dev,"quirk map 0x%x is not supported, microphone input will not work\n" , map); +dev_warn_once (dev,"quirk sets invalid input map: 0x%x, default to DMIC1_MAP\n" , map); + byt_rt5640_quirk &= ~BYT_RT5640_MAP_MASK ; + byt_rt5640_quirk |=BYT_RT5640_DMIC1_MAP ;break ; }if (byt_rt5640_quirk &BYT_RT5640_HSMIC2_ON_IN1 )
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 120/196 ASoC: Intel: bytcr_rt5651: Fix invalid quirk input mapping
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 4336efb59ef364e691ef829a73d9dbd4d5ed7c7b ]
When an invalid value is passed via quirk option, currently bytcr_rt5640 driver just ignores and leaves as is, which may lead to unepxected results like OOB access.
This patch adds the sanity check and corrects the input mapping to the certain default value if an invalid value is passed.
Message-ID: <[email protected]>
--- sound/soc/intel/boards/bytcr_rt5651.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
sound/soc/intel/boards/bytcr_rt5651.c +21 -5
@@ -58,7 +58,8 @@ enum { BYT_RT5651_OVCD_SF_1P5 = (RT5651_OVCD_SF_1P5 << 13), }; -#define BYT_RT5651_MAP (quirk) ((quirk) & GENMASK(3, 0)) +#define BYT_RT5651_MAP_MASK GENMASK(3, 0) +#define BYT_RT5651_MAP (quirk) ((quirk) & BYT_RT5651_MAP_MASK)#define BYT_RT5651_JDSRC (quirk) (((quirk) & GENMASK(7, 4)) >> 4)#define BYT_RT5651_OVCD_TH (quirk) (((quirk) & GENMASK(12, 8)) >> 8)#define BYT_RT5651_OVCD_SF (quirk) (((quirk) & GENMASK(14, 13)) >> 13)
@@ -100,14 +101,29 @@ MODULE_PARM_DESC(quirk, "Board-specific quirk override");static void log_quirks (struct device *dev) { -if (BYT_RT5651_MAP (byt_rt5651_quirk) ==BYT_RT5651_DMIC_MAP ) +int map; + + map =BYT_RT5651_MAP (byt_rt5651_quirk); +switch (map) { +case BYT_RT5651_DMIC_MAP :dev_info (dev,"quirk DMIC_MAP enabled" ); -if (BYT_RT5651_MAP (byt_rt5651_quirk) ==BYT_RT5651_IN1_MAP ) +break ; +case BYT_RT5651_IN1_MAP :dev_info (dev,"quirk IN1_MAP enabled" ); -if (BYT_RT5651_MAP (byt_rt5651_quirk) ==BYT_RT5651_IN2_MAP ) +break ; +case BYT_RT5651_IN2_MAP :dev_info (dev,"quirk IN2_MAP enabled" ); -if (BYT_RT5651_MAP (byt_rt5651_quirk) ==BYT_RT5651_IN1_IN2_MAP ) +break ; +case BYT_RT5651_IN1_IN2_MAP :dev_info (dev,"quirk IN1_IN2_MAP enabled" ); +break ; +default : +dev_warn_once (dev,"quirk sets invalid input map: 0x%x, default to DMIC_MAP\n" , map); + byt_rt5651_quirk &= ~BYT_RT5651_MAP_MASK ; + byt_rt5651_quirk |=BYT_RT5651_DMIC_MAP ; +break ; + } +if (BYT_RT5651_JDSRC (byt_rt5651_quirk)) {dev_info (dev,"quirk realtek,jack-detect-source %ld\n" ,BYT_RT5651_JDSRC (byt_rt5651_quirk));
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 121/196 drm/msm/dpu: fix incorrect type for ret
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qianfeng Rong <[email protected]>
[ Upstream commit 88ec0e01a880e3326794e149efae39e3aa4dbbec ]
Change 'ret' from unsigned long to int, as storing negative error codes in an unsigned long makes it never equal to -ETIMEDOUT, causing logical errors.
Patchwork: https://patchwork.freedesktop.org/patch/671100/
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c +1 -1
@@ -452,7 +452,7 @@ static void _dpu_encoder_phys_wb_handle_wbdone_timeout(static int dpu_encoder_phys_wb_wait_for_commit_done (struct dpu_encoder_phys *phys_enc) { -unsigned long ret; +int ret;struct dpu_encoder_wait_info wait_info;struct dpu_encoder_phys_wb *wb_enc =to_dpu_encoder_phys_wb (phys_enc);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 122/196 fs: ntfs3: Fix integer overflow in run_unpack()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vitaly Grigoryev <[email protected]>
[ Upstream commit 736fc7bf5f68f6b74a0925b7e072c571838657d2 ]
The MFT record relative to the file being opened contains its runlist, an array containing information about the file's location on the physical disk. Analysis of all Call Stack paths showed that the values of the runlist array, from which LCNs are calculated, are not validated before run_unpack function.
The run_unpack function decodes the compressed runlist data format from MFT attributes (for example, $DATA), converting them into a runs_tree structure, which describes the mapping of virtual clusters (VCN) to logical clusters (LCN). The NTFS3 subsystem also has a shortcut for deleting files from MFT records - in this case, the RUN_DEALLOCATE command is sent to the run_unpack input, and the function logic provides that all data transferred to the runlist about file or directory is deleted without creating a runs_tree structure.
Substituting the runlist in the $DATA attribute of the MFT record for an arbitrary file can lead either to access to arbitrary data on the disk bypassing access checks to them (since the inode access check occurs above) or to destruction of arbitrary data on the disk.
Add overflow check for addition operation.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- fs/ntfs3/run.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
fs/ntfs3/run.c +9 -3
@@ -9,6 +9,7 @@#include <linux/blkdev.h> #include <linux/fs.h> #include <linux/log2.h> +#include <linux/overflow.h> #include "debug.h" #include "ntfs.h"
@@ -982,12 +983,16 @@ int run_unpack(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino,if (!dlcn)return -EINVAL ; - lcn = prev_lcn + dlcn; + +if (check_add_overflow (prev_lcn, dlcn, &lcn)) +return -EINVAL ; prev_lcn = lcn; }else return -EINVAL ; - next_vcn = vcn64 + len; +if (check_add_overflow (vcn64, len, &next_vcn)) +return -EINVAL ; +/* Check boundary. */ if (next_vcn > evcn +1 )return -EINVAL ;
@@ -1148,7 +1153,8 @@ int run_get_highest_vcn(CLST vcn, const u8 *run_buf, u64 *highest_vcn)return -EINVAL ; run_buf += size_size + offset_size; - vcn64 += len; +if (check_add_overflow (vcn64, len, &vcn64)) +return -EINVAL ;#ifndef CONFIG_NTFS3_64BIT_CLUSTER if (vcn64 >0x100000000ull )
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 123/196 iio: consumers: Fix offset handling in iio_convert_raw_to_processed()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
[ Upstream commit 33f5c69c4daff39c010b3ea6da8ebab285f4277b ]
Fix iio_convert_raw_to_processed() offset handling for channels without a scale attribute.
The offset has been applied to the raw64 value not to the original raw value. Use the raw64 value so that the offset is taken into account.
--- drivers/iio/inkern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/inkern.c +1 -1
@@ -669,7 +669,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,* If no channel scaling is available apply consumer scale to * raw value and return. */ - *processed = raw * scale; + *processed = raw64 * scale;return 0 ; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 124/196 netfilter: ipset: Remove unused htable_bits in macro ahash_region
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhen Ni <[email protected]>
[ Upstream commit ba941796d7cd1e81f51eed145dad1b47240ff420 ]
Since the ahash_region() macro was redefined to calculate the region index solely from HTABLE_REGION_BITS, the htable_bits parameter became unused.
Remove the unused htable_bits argument and its call sites, simplifying the code without changing semantics.
--- net/netfilter/ipset/ip_set_hash_gen.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/netfilter/ipset/ip_set_hash_gen.h +4 -4
@@ -62,7 +62,7 @@ struct hbucket { : jhash_size((htable_bits) - HTABLE_REGION_BITS))#define ahash_sizeof_regions (htable_bits) \ (ahash_numof_locks(htable_bits) * sizeof(struct ip_set_region)) -#define ahash_region (n, htable_bits) \ +#define ahash_region (n) \ ((n) / jhash_size(HTABLE_REGION_BITS))#define ahash_bucket_start (h, htable_bits) \ ((htable_bits) < HTABLE_REGION_BITS ? 0 \
@@ -689,7 +689,7 @@ mtype_resize(struct ip_set *set, bool retried)#endif key =HKEY (data, h->initval, htable_bits); m =__ipset_dereference (hbucket (t, key)); - nr =ahash_region (key, htable_bits); + nr =ahash_region (key);if (!m) { m = kzalloc(sizeof(*m) + AHASH_INIT_SIZE * dsize,
@@ -839,7 +839,7 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext,rcu_read_lock_bh (); t =rcu_dereference_bh (h->table); key =HKEY (value, h->initval, t->htable_bits); - r =ahash_region (key, t->htable_bits); + r =ahash_region (key);atomic_inc (&t->uref); elements = t->hregion[r].elements; maxelem = t->maxelem;
@@ -1037,7 +1037,7 @@ mtype_del(struct ip_set *set, void *value, const struct ip_set_ext *ext,rcu_read_lock_bh (); t =rcu_dereference_bh (h->table); key =HKEY (value, h->initval, t->htable_bits); - r =ahash_region (key, t->htable_bits); + r =ahash_region (key);atomic_inc (&t->uref);rcu_read_unlock_bh ();
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 125/196 watchdog: mpc8xxx_wdt: Reload the watchdog timer when enabling the watchdog
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
[ Upstream commit 7dfd80f70ef00d871df5af7c391133f7ba61ad9b ]
When the watchdog gets enabled with this driver, it leaves enough time for the core watchdog subsystem to start pinging it. But when the watchdog is already started by hardware or by the boot loader, little time remains before it fires and it happens that the core watchdog subsystem doesn't have time to start pinging it.
Until commit 19ce9490aa84 ("watchdog: mpc8xxx: use the core worker function") pinging was managed by the driver itself and the watchdog was immediately pinged by setting the timer expiry to 0.
So restore similar behaviour by pinging it when enabling it so that if it was already enabled the watchdog timer counter is reloaded.
--- drivers/watchdog/mpc8xxx_wdt.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/watchdog/mpc8xxx_wdt.c +2 -0
@@ -100,6 +100,8 @@ static int mpc8xxx_wdt_start(struct watchdog_device *w) ddata->swtc = tmp >>16 ;set_bit (WDOG_HW_RUNNING , &ddata->wdd.status); +mpc8xxx_wdt_keepalive (ddata); +return 0 ; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 126/196 drivers/base/node: handle error properly in register_one_node()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Donet Tom <[email protected]>
[ Upstream commit 786eb990cfb78aab94eb74fb32a030e14723a620 ]
If register_node() returns an error, it is not handled correctly. The function will proceed further and try to register CPUs under the node, which is not correct.
So, in this patch, if register_node() returns an error, we return immediately from the function.
--- drivers/base/node.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/base/node.c +5 -0
@@ -869,6 +869,11 @@ int __register_one_node(int nid) node_devices[nid] = node; error =register_node (node_devices[nid], nid); +if (error) { + node_devices[nid] =NULL ; +kfree (node); +return error; + }/* link cpu under this node */ for_each_present_cpu (cpu) {
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 127/196 RDMA/cm: Rate limit destroy CM ID timeout error message
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Håkon Bugge <[email protected]>
[ Upstream commit 2bbe1255fcf19c5eb300efb6cb5ad98d66fdae2e ]
When the destroy CM ID timeout kicks in, you typically get a storm of them which creates a log flooding. Hence, change pr_err() to pr_err_ratelimited() in cm_destroy_id_wait_timeout().
--- drivers/infiniband/core/cm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/core/cm.c +2 -2
@@ -1032,8 +1032,8 @@ static noinline void cm_destroy_id_wait_timeout(struct ib_cm_id *cm_id,struct cm_id_private *cm_id_priv; cm_id_priv = container_of(cm_id, struct cm_id_private, id); -pr_err ("%s: cm_id=%p timed out. state %d -> %d, refcnt=%d\n" , __func__, - cm_id, old_state, cm_id->state,refcount_read (&cm_id_priv->refcount)); +pr_err_ratelimited ("%s: cm_id=%p timed out. state %d -> %d, refcnt=%d\n" , __func__, + cm_id, old_state, cm_id->state,refcount_read (&cm_id_priv->refcount)); }static void cm_destroy_id (struct ib_cm_id *cm_id,int err)
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 128/196 wifi: mt76: fix potential memory leak in mt76_wmac_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
[ Upstream commit 42754b7de2b1a2cf116c5e3f1e8e78392f4ed700 ]
In mt76_wmac_probe(), when the mt76_alloc_device() call succeeds, memory is allocated for both struct ieee80211_hw and a workqueue. However, on the error path, the workqueue is not freed. Fix that by calling mt76_free_device() on the error path.
--- drivers/net/wireless/mediatek/mt76/mt7603/soc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7603/soc.c +1 -1
@@ -48,7 +48,7 @@ mt76_wmac_probe(struct platform_device *pdev)return 0 ; error: -ieee80211_free_hw (mt76_hw (dev)); +mt76_free_device (mdev);return ret; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 129/196 ACPI: NFIT: Fix incorrect ndr_desc being reportedin dev_err message
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Colin Ian King <[email protected]>
[ Upstream commit d1a599a8136b16522b5afebd122395524496d549 ]
There appears to be a cut-n-paste error with the incorrect field ndr_desc->numa_node being reported for the target node. Fix this by using ndr_desc->target_node instead.
--- drivers/acpi/nfit/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/nfit/core.c +1 -1
@@ -2643,7 +2643,7 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc,if (ndr_desc->target_node ==NUMA_NO_NODE ) { ndr_desc->target_node =phys_to_target_node (spa->address);dev_info (acpi_desc->dev,"changing target node from %d to %d for nfit region [%pa-%pa]" , -NUMA_NO_NODE , ndr_desc->numa_node, &res.start, &res.end); +NUMA_NO_NODE , ndr_desc->target_node, &res.start, &res.end); }/*
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 130/196 scsi: qla2xxx: edif: Fix incorrect sign of error code
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qianfeng Rong <[email protected]>
[ Upstream commit 066b8f3fa85c1be7fb7dbae202231e131d38f7bc ]
Change the error code EAGAIN to -EAGAIN in qla24xx_sadb_update() and qla_edif_process_els() to align with qla2x00_start_sp() returning negative error codes or QLA_SUCCESS, preventing logical errors.
Message-ID: <[email protected]>
--- drivers/scsi/qla2xxx/qla_edif.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_edif.c +2 -2
@@ -1755,7 +1755,7 @@ qla24xx_sadb_update(struct bsg_job *bsg_job)switch (rval) {case QLA_SUCCESS :break ; -case EAGAIN : +case -EAGAIN :msleep (EDIF_MSLEEP_INTERVAL ); cnt++;if (cnt <EDIF_RETRY_COUNT )
@@ -3621,7 +3621,7 @@ int qla_edif_process_els(scsi_qla_host_t *vha, struct bsg_job *bsg_job) p->e.extra_rx_xchg_address, p->e.extra_control_flags, sp->handle, sp->remap.req.len, bsg_job);break ; -case EAGAIN : +case -EAGAIN :msleep (EDIF_MSLEEP_INTERVAL ); cnt++;if (cnt <EDIF_RETRY_COUNT )
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 131/196 scsi: qla2xxx: Fix incorrect sign of error code in START_SP_W_RETRIES()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qianfeng Rong <[email protected]>
[ Upstream commit 1f037e3acda79639a78f096355f2c308a3d45492 ]
Change the error code EAGAIN to -EAGAIN in START_SP_W_RETRIES() to align with qla2x00_start_sp() returning negative error codes or QLA_SUCCESS, preventing logical errors. Additionally, the '_rval' variable should store negative error codes to conform to Linux kernel error code conventions.
Message-ID: <[email protected]>
--- drivers/scsi/qla2xxx/qla_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +2 -2
@@ -2060,11 +2060,11 @@ static void qla_marker_sp_done(srb_t *sp, int res)int cnt =5 ; \ do { \ if (_chip_gen != sp->vha->hw->chip_reset || _login_gen != sp->fcport->login_gen) {\ - _rval = EINVAL; \ + _rval = -EINVAL; \ break; \ } \ _rval = qla2x00_start_sp(_sp); \ - if (_rval == EAGAIN) \ + if (_rval == -EAGAIN) \ msleep(1); \ else \ break; \
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 132/196 f2fs: fix zero-sized extent for precache extents
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: wangzijie <[email protected]>
[ Upstream commit 8175c864391753b210f3dcfae1aeed686a226ebb ]
Script to reproduce:f2fs_io write 1 0 1881 rand dsync testfile f2fs_io fallocate 0 7708672 4096 testfile f2fs_io write 1 1881 1 rand buffered testfile fsync testfile
umount
mountf2fs_io precache_extents testfile
When the data layout is something like this:
dnode1: dnode2: [0] A [0] NEW_ADDR [1] A+1 [1] 0x0
...
[1016] A+1016
[1017] B (B!=A+1017) [1017] 0x0
During precache_extents, we map the last block(valid blkaddr) in dnode1:map->m_flags |= F2FS_MAP_MAPPED;map->m_pblk = blkaddr(valid blkaddr);map->m_len = 1;
then we goto next_dnode, meet the first block in dnode2(hole), goto sync_out:map->m_flags & F2FS_MAP_MAPPED == true, and we make zero-sized extent:
map->m_len = 1
ofs = start_pgofs - map->m_lblk = 1882 - 1881 = 1 ei.fofs = start_pgofs = 1882
ei.len = map->m_len - ofs = 1 - 1 = 0
Rebased on patch[1], this patch can cover these cases to avoid zero-sized extent:
A,B,C is valid blkaddr
case1:
dnode1: dnode2: [0] A [0] NEW_ADDR [1] A+1 [1] 0x0 ... ....
[1016] A+1016
[1017] B (B!=A+1017) [1017] 0x0
case2:
dnode1: dnode2: [0] A [0] C (C!=B+1) [1] A+1 [1] C+1 ... ....
[1016] A+1016
[1017] B (B!=A+1017) [1017] 0x0
case3:
dnode1: dnode2: [0] A [0] C (C!=B+2) [1] A+1 [1] C+1 ... .... [1015] A+1015 [1016] B (B!=A+1016) [1017] B+1 [1017] 0x0
[1] https://lore.kernel.org/linux-f2fs-devel/[email protected]/
--- fs/f2fs/data.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
fs/f2fs/data.c +4 -3
@@ -1737,9 +1737,10 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,if (map->m_flags &F2FS_MAP_MAPPED ) {unsigned int ofs = start_pgofs - map->m_lblk; -f2fs_update_read_extent_cache_range (&dn, - start_pgofs, map->m_pblk + ofs, - map->m_len - ofs); +if (map->m_len > ofs) +f2fs_update_read_extent_cache_range (&dn, + start_pgofs, map->m_pblk + ofs, + map->m_len - ofs); }if (map->m_next_extent) *map->m_next_extent = pgofs +1 ;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 133/196 Revert "usb: xhci: Avoid Stop Endpoint retry loop if the endpoint seems Running"
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Pecio <[email protected]>
[ Upstream commit 08fa726e66039dfa80226dfa112931f60ad4c898 ]
This reverts commit 28a76fcc4c85dd39633fb96edb643c91820133e3.
No actual HW bugs are known where Endpoint Context shows Running state but Stop Endpoint fails repeatedly with Context State Error and leaves the endpoint state unchanged. Stop Endpoint retries on Running EPs have been performed since early 2021 with no such issues reported so far.
Trying to handle this hypothetical case brings a more realistic danger:
if Stop Endpoint fails on an endpoint which hasn't yet started after a doorbell ring and enough latency occurs before this completion event is handled, the driver may time out and begin removing cancelled TDs from a running endpoint, even though one more retry would stop it reliably.
Such high latency is rare but not impossible, and removing TDs from a running endpoint can cause more damage than not giving back a cancelled URB (which wasn't happening anyway). So err on the side of caution and revert to the old policy of always retrying if the EP appears running.
[Remove stable tag as we are dealing with theoretical cases -Mathias]
--- drivers/usb/host/xhci-ring.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/usb/host/xhci-ring.c +4 -7
@@ -1175,19 +1175,16 @@ static void xhci_handle_cmd_stop_ep(struct xhci_hcd *xhci, int slot_id,* Stopped state, but it will soon change to Running. * * Assume this bug on unexpected Stop Endpoint failures. -* Keep retrying until the EP starts and stops again. +* Keep retrying until the EP starts and stops again, on +* chips where this is known to help. Wait for 100ms. */ +if (time_is_before_jiffies (ep->stop_time +msecs_to_jiffies (100 ))) +break ; fallthrough;case EP_STATE_RUNNING :/* Race, HW handled stop ep cmd before ep was running */ xhci_dbg (xhci,"Stop ep completion ctx error, ctx_state %d\n" ,GET_EP_CTX_STATE (ep_ctx)); -/* -* Don't retry forever if we guessed wrong or a defective HC never starts -* the EP or says 'Running' but fails the command. We must give back TDs. -*/ -if (time_is_before_jiffies (ep->stop_time +msecs_to_jiffies (100 ))) -break ; command =xhci_alloc_command (xhci, false,GFP_ATOMIC );if (!command) {
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 134/196 RDMA/core: Resolve MAC of next-hop device without ARP support
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Parav Pandit <[email protected]>
[ Upstream commit 200651b9b8aadfbbec852f0e5d042d9abe75e2ab ]
Currently, if the next-hop netdevice does not support ARP resolution, the destination MAC address is silently set to zero without reporting an error. This leads to incorrect behavior and may result in packet transmission failures.
Fix this by deferring MAC resolution to the IP stack via neighbour lookup, allowing proper resolution or error reporting as appropriate.
--- drivers/infiniband/core/addr.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/infiniband/core/addr.c +3 -7
@@ -460,14 +460,10 @@ static int addr_resolve_neigh(const struct dst_entry *dst, {int ret =0 ; -if (ndev_flags &IFF_LOOPBACK ) { +if (ndev_flags &IFF_LOOPBACK )memcpy (addr->dst_dev_addr, addr->src_dev_addr,MAX_ADDR_LEN ); - }else { -if (!(ndev_flags &IFF_NOARP )) { -/* If the device doesn't do ARP internally */ - ret =fetch_ha (dst, addr, dst_in, seq); - } - } +else + ret =fetch_ha (dst, addr, dst_in, seq);return ret; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 135/196 IB/sa: Fix sa_local_svc_timeout_ms read race
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vlad Dumitrescu <[email protected]>
[ Upstream commit 1428cd764cd708d53a072a2f208d87014bfe05bc ]
When computing the delta, the sa_local_svc_timeout_ms is read without ib_nl_request_lock held. Though unlikely in practice, this can cause a race condition if multiple local service threads are managing the timeout.
--- drivers/infiniband/core/sa_query.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/infiniband/core/sa_query.c +4 -2
@@ -1021,6 +1021,8 @@ int ib_nl_handle_set_timeout(struct sk_buff *skb,if (timeout >IB_SA_LOCAL_SVC_TIMEOUT_MAX ) timeout =IB_SA_LOCAL_SVC_TIMEOUT_MAX ; +spin_lock_irqsave (&ib_nl_request_lock, flags); + delta = timeout - sa_local_svc_timeout_ms;if (delta <0 ) abs_delta = -delta;
@@ -1028,7 +1030,6 @@ int ib_nl_handle_set_timeout(struct sk_buff *skb, abs_delta = delta;if (delta !=0 ) { -spin_lock_irqsave (&ib_nl_request_lock, flags); sa_local_svc_timeout_ms = timeout;list_for_each_entry (query, &ib_nl_request_list, list) {if (delta <0 && abs_delta > query->timeout)
@@ -1046,9 +1047,10 @@ int ib_nl_handle_set_timeout(struct sk_buff *skb,if (delay)mod_delayed_work (ib_nl_wq, &ib_nl_timed_work, (unsigned long )delay); -spin_unlock_irqrestore (&ib_nl_request_lock, flags); } +spin_unlock_irqrestore (&ib_nl_request_lock, flags); + settimeout_out:return 0 ; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 136/196 Documentation: trace: historgram-design: Separate sched_waking histogram section heading and the following diagram
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bagas Sanjaya <[email protected]>
[ Upstream commit 8c716e87ea33519920811338100d6d8a7fb32456 ]
Section heading for sched_waking histogram is shown as normal paragraph instead due to codeblock marker for the following diagram being in the same line as the section underline. Separate them.
Message-ID: <[email protected]>
--- Documentation/trace/histogram-design.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/trace/histogram-design.rst +3 -1
@@ -380,7 +380,9 @@ entry, ts0, corresponding to the ts0 variable in the sched_waking trigger above. sched_waking histogram -----------------------:: +---------------------- + +.. code-block:: +------------------+ | hist_data |<-------------------------------------------------------+
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 137/196 wifi: ath10k: avoid unnecessary wait for service ready message
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baochen Qiang <[email protected]>
[ Upstream commit 51a73f1b2e56b0324b4a3bb8cebc4221b5be4c7a ]
Commit e57b7d62a1b2 ("wifi: ath10k: poll service ready message before failing") works around the failure in waiting for the service ready message by active polling. Note the polling is triggered after initial wait timeout, which means that the wait-till-timeout can not be avoided even the message is ready.
A possible fix is to do polling once before wait as well, however this can not handle the race that the message arrives right after polling. So the solution is to do periodic polling until timeout.
Tested-on: QCA6174 hw3.2 PCI WLAN.RM.4.4.1-00309-QCARMSWPZ-1
--- drivers/net/wireless/ath/ath10k/wmi.c | 39 +++++++++++++-------------- 1 file changed, 19 insertions(+), 20 deletions(-)
drivers/net/wireless/ath/ath10k/wmi.c +19 -20
@@ -1762,33 +1762,32 @@ void ath10k_wmi_put_wmi_channel(struct ath10k *ar, struct wmi_channel *ch,int ath10k_wmi_wait_for_service_ready (struct ath10k *ar) { +unsigned long timeout = jiffies +WMI_SERVICE_READY_TIMEOUT_HZ ;unsigned long time_left, i; - time_left =wait_for_completion_timeout (&ar->wmi.service_ready, -WMI_SERVICE_READY_TIMEOUT_HZ ); -if (!time_left) { -/* Sometimes the PCI HIF doesn't receive interrupt -* for the service ready message even if the buffer -* was completed. PCIe sniffer shows that it's -* because the corresponding CE ring doesn't fires -* it. Workaround here by polling CE rings once. -*/ -ath10k_warn (ar,"failed to receive service ready completion, polling..\n" ); - +/* Sometimes the PCI HIF doesn't receive interrupt +* for the service ready message even if the buffer +* was completed. PCIe sniffer shows that it's +* because the corresponding CE ring doesn't fires +* it. Workaround here by polling CE rings. Since +* the message could arrive at any time, continue +* polling until timeout. +*/ +do {for (i =0 ; i <CE_COUNT ; i++)ath10k_hif_send_complete_check (ar, i,1 ); +/* The 100 ms granularity is a tradeoff considering scheduler +* overhead and response latency +*/ time_left =wait_for_completion_timeout (&ar->wmi.service_ready, -WMI_SERVICE_READY_TIMEOUT_HZ ); -if (!time_left) { -ath10k_warn (ar,"polling timed out\n" ); -return -ETIMEDOUT ; - } - -ath10k_warn (ar,"service ready completion received, continuing normally\n" ); - } +msecs_to_jiffies (100 )); +if (time_left) +return 0 ; + }while (time_before (jiffies, timeout)); -return 0 ; +ath10k_warn (ar,"failed to receive service ready completion\n" ); +return -ETIMEDOUT ; }int ath10k_wmi_wait_for_unified_ready (struct ath10k *ar)
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 138/196 wifi: mac80211: fix Rx packet handling when pubsta information is not available
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aditya Kumar Singh <[email protected]>
[ Upstream commit 32d340ae675800672e1219444a17940a8efe5cca ]
In ieee80211_rx_handle_packet(), if the caller does not provide pubsta information, an attempt is made to find the station using the address 2 (source address) field in the header. Since pubsta is missing, link information such as link_valid and link_id is also unavailable. Now if such a situation comes, and if a matching ML station entry is found based on the source address, currently the packet is dropped due to missing link ID in the status field which is not correct.
Hence, to fix this issue, if link_valid is not set and the station is an ML station, make an attempt to find a link station entry using the source address. If a valid link station is found, derive the link ID and proceed with packet processing. Otherwise, drop the packet as per the existing flow.
--- net/mac80211/rx.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-)
net/mac80211/rx.c +22 -6
@@ -5106,12 +5106,20 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw, } rx.sdata = prev_sta->sdata; +if (!status->link_valid && prev_sta->sta.mlo) { +struct link_sta_info *link_sta; + + link_sta =link_sta_info_get_bss (rx.sdata, + hdr->addr2); +if (!link_sta) +continue ; + + link_id = link_sta->link_id; + } +if (!ieee80211_rx_data_set_sta (&rx, prev_sta, link_id)) goto out; -if (!status->link_valid && prev_sta->sta.mlo) -continue ; -ieee80211_prepare_and_rx_handle (&rx, skb, false); prev_sta = sta;
@@ -5119,10 +5127,18 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,if (prev_sta) { rx.sdata = prev_sta->sdata; -if (!ieee80211_rx_data_set_sta (&rx, prev_sta, link_id)) - goto out; +if (!status->link_valid && prev_sta->sta.mlo) { +struct link_sta_info *link_sta; + + link_sta =link_sta_info_get_bss (rx.sdata, + hdr->addr2); +if (!link_sta) + goto out; -if (!status->link_valid && prev_sta->sta.mlo) + link_id = link_sta->link_id; + } + +if (!ieee80211_rx_data_set_sta (&rx, prev_sta, link_id)) goto out;if (ieee80211_prepare_and_rx_handle (&rx, skb, true))
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 139/196 sparc: fix accurate exception reporting in copy_{from_to}_user for UltraSPARC
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Karcher <[email protected]>
[ Upstream commit 4fba1713001195e59cfc001ff1f2837dab877efb ]
The referenced commit introduced exception handlers on user-space memory references in copy_from_user and copy_to_user. These handlers return from the respective function and calculate the remaining bytes left to copy using the current register contents. This commit fixes a couple of bad calculations. This will fix the return value of copy_from_user and copy_to_user in the faulting case. The behaviour of memcpy stays unchanged.
--- arch/sparc/lib/U1memcpy.S | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
arch/sparc/lib/U1memcpy.S +10 -9
@@ -164,17 +164,18 @@ ENTRY(U1_gs_40_fp) retl add %o0, %o2, %o0 ENDPROC(U1_gs_40_fp) -ENTRY(U1_g3_0_fp) - VISExitHalf - retl - add %g3, %o2, %o0 -ENDPROC(U1_g3_0_fp) ENTRY(U1_g3_8_fp) VISExitHalf add %g3, 8, %g3 retl add %g3, %o2, %o0 ENDPROC(U1_g3_8_fp) +ENTRY(U1_g3_16_fp) + VISExitHalf + add %g3, 16, %g3 + retl + add %g3, %o2, %o0 +ENDPROC(U1_g3_16_fp) ENTRY(U1_o2_0_fp) VISExitHalf retl
@@ -547,18 +548,18 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ 62: FINISH_VISCHUNK(o0, f44, f46) 63: UNEVEN_VISCHUNK_LAST(o0, f46, f0) -93: EX_LD_FP(LOAD(ldd, %o1, %f2), U1_g3_0_fp) +93: EX_LD_FP(LOAD(ldd, %o1, %f2), U1_g3_8_fp) add %o1, 8, %o1 subcc %g3, 8, %g3 faligndata %f0, %f2, %f8 - EX_ST_FP(STORE(std, %f8, %o0), U1_g3_8_fp) + EX_ST_FP(STORE(std, %f8, %o0), U1_g3_16_fp) bl,pn %xcc, 95f add %o0, 8, %o0 - EX_LD_FP(LOAD(ldd, %o1, %f0), U1_g3_0_fp) + EX_LD_FP(LOAD(ldd, %o1, %f0), U1_g3_8_fp) add %o1, 8, %o1 subcc %g3, 8, %g3 faligndata %f2, %f0, %f8 - EX_ST_FP(STORE(std, %f8, %o0), U1_g3_8_fp) + EX_ST_FP(STORE(std, %f8, %o0), U1_g3_16_fp) bge,pt %xcc, 93b add %o0, 8, %o0
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 140/196 sparc: fix accurate exception reporting in copy_{from_to}_user for UltraSPARC III
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Karcher <[email protected]>
[ Upstream commit 47b49c06eb62504075f0f2e2227aee2e2c2a58b3 ]
Anthony Yznaga tracked down that a BUG_ON in ext4 code with large folios enabled resulted from copy_from_user() returning impossibly large values greater than the size to be copied. This lead to __copy_from_iter() returning impossible values instead of the actual number of bytes it was able to copy.
The BUG_ON has been reported in
https://lore.kernel.org/r/b14f55642207e63e907965e209f6323a0df6dcee.camel@physik.fu-berlin.de
The referenced commit introduced exception handlers on user-space memory references in copy_from_user and copy_to_user. These handlers return from the respective function and calculate the remaining bytes left to copy using the current register contents. The exception handlers expect that %o2 has already been masked during the bulk copy loop, but the masking was performed after that loop. This will fix the return value of copy_from_user and copy_to_user in the faulting case. The behaviour of memcpy stays unchanged.
--- arch/sparc/lib/U3memcpy.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sparc/lib/U3memcpy.S +1 -1
@@ -267,6 +267,7 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ faligndata %f10, %f12, %f26 EX_LD_FP(LOAD(ldd, %o1 + 0x040, %f0), U3_retl_o2) + and %o2, 0x3f, %o2 subcc GLOBAL_SPARE, 0x80, GLOBAL_SPARE add %o1, 0x40, %o1 bgu,pt %XCC, 1f
@@ -336,7 +337,6 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ * Also notice how this code is careful not to perform a * load past the end of the src buffer. */ - and %o2, 0x3f, %o2 andcc %o2, 0x38, %g2 be,pn %XCC, 2f subcc %g2, 0x8, %g2
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 141/196 sparc: fix accurate exception reporting in copy_{from_to}_user for Niagara
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Karcher <[email protected]>
[ Upstream commit 0b67c8fc10b13a9090340c5f8a37d308f4e1571c ]
The referenced commit introduced exception handlers on user-space memory references in copy_from_user and copy_to_user. These handlers return from the respective function and calculate the remaining bytes left to copy using the current register contents. This commit fixes a couple of bad calculations and a broken epilogue in the exception handlers. This will prevent crashes and ensure correct return values of copy_from_user and copy_to_user in the faulting case. The behaviour of memcpy stays unchanged.
--- arch/sparc/lib/NGmemcpy.S | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-)
arch/sparc/lib/NGmemcpy.S +18 -11
@@ -79,8 +79,8 @@ #ifndef EX_RETVAL #define EX_RETVAL(x) x __restore_asi: - ret wr %g0, ASI_AIUS, %asi + ret restore ENTRY(NG_ret_i2_plus_i4_plus_1) ba,pt %xcc, __restore_asi
@@ -125,15 +125,16 @@ ENTRY(NG_ret_i2_plus_g1_minus_56) ba,pt %xcc, __restore_asi add %i2, %g1, %i0 ENDPROC(NG_ret_i2_plus_g1_minus_56) -ENTRY(NG_ret_i2_plus_i4) +ENTRY(NG_ret_i2_plus_i4_plus_16) + add %i4, 16, %i4 ba,pt %xcc, __restore_asi add %i2, %i4, %i0 -ENDPROC(NG_ret_i2_plus_i4) -ENTRY(NG_ret_i2_plus_i4_minus_8) - sub %i4, 8, %i4 +ENDPROC(NG_ret_i2_plus_i4_plus_16) +ENTRY(NG_ret_i2_plus_i4_plus_8) + add %i4, 8, %i4 ba,pt %xcc, __restore_asi add %i2, %i4, %i0 -ENDPROC(NG_ret_i2_plus_i4_minus_8) +ENDPROC(NG_ret_i2_plus_i4_plus_8) ENTRY(NG_ret_i2_plus_8) ba,pt %xcc, __restore_asi add %i2, 8, %i0
@@ -160,6 +161,12 @@ ENTRY(NG_ret_i2_and_7_plus_i4) ba,pt %xcc, __restore_asi add %i2, %i4, %i0 ENDPROC(NG_ret_i2_and_7_plus_i4) +ENTRY(NG_ret_i2_and_7_plus_i4_plus_8) + and %i2, 7, %i2 + add %i4, 8, %i4 + ba,pt %xcc, __restore_asi + add %i2, %i4, %i0 +ENDPROC(NG_ret_i2_and_7_plus_i4) #endif .align 64
@@ -405,13 +412,13 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */ andn %i2, 0xf, %i4 and %i2, 0xf, %i2 1: subcc %i4, 0x10, %i4 - EX_LD(LOAD(ldx, %i1, %o4), NG_ret_i2_plus_i4) + EX_LD(LOAD(ldx, %i1, %o4), NG_ret_i2_plus_i4_plus_16) add %i1, 0x08, %i1 - EX_LD(LOAD(ldx, %i1, %g1), NG_ret_i2_plus_i4) + EX_LD(LOAD(ldx, %i1, %g1), NG_ret_i2_plus_i4_plus_16) sub %i1, 0x08, %i1 - EX_ST(STORE(stx, %o4, %i1 + %i3), NG_ret_i2_plus_i4) + EX_ST(STORE(stx, %o4, %i1 + %i3), NG_ret_i2_plus_i4_plus_16) add %i1, 0x8, %i1 - EX_ST(STORE(stx, %g1, %i1 + %i3), NG_ret_i2_plus_i4_minus_8) + EX_ST(STORE(stx, %g1, %i1 + %i3), NG_ret_i2_plus_i4_plus_8) bgu,pt %XCC, 1b add %i1, 0x8, %i1 73: andcc %i2, 0x8, %g0
@@ -468,7 +475,7 @@ FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */ subcc %i4, 0x8, %i4 srlx %g3, %i3, %i5 or %i5, %g2, %i5 - EX_ST(STORE(stx, %i5, %o0), NG_ret_i2_and_7_plus_i4) + EX_ST(STORE(stx, %i5, %o0), NG_ret_i2_and_7_plus_i4_plus_8) add %o0, 0x8, %o0 bgu,pt %icc, 1b sllx %g3, %g1, %g2
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 142/196 sparc: fix accurate exception reporting in copy_to_user for Niagara 4
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Karcher <[email protected]>
[ Upstream commit 5a746c1a2c7980de6c888b6373299f751ad7790b ]
The referenced commit introduced exception handlers on user-space memory references in copy_from_user and copy_to_user. These handlers return from the respective function and calculate the remaining bytes left to copy using the current register contents. This commit fixes a bad calculation. This will fix the return value of copy_to_user in a specific faulting case. The behaviour of memcpy stays unchanged.
--- arch/sparc/lib/NG4memcpy.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sparc/lib/NG4memcpy.S +1 -1
@@ -281,7 +281,7 @@ FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */ subcc %o5, 0x20, %o5 EX_ST(STORE(stx, %g1, %o0 + 0x00), memcpy_retl_o2_plus_o5_plus_32) EX_ST(STORE(stx, %g2, %o0 + 0x08), memcpy_retl_o2_plus_o5_plus_24) - EX_ST(STORE(stx, GLOBAL_SPARE, %o0 + 0x10), memcpy_retl_o2_plus_o5_plus_24) + EX_ST(STORE(stx, GLOBAL_SPARE, %o0 + 0x10), memcpy_retl_o2_plus_o5_plus_16) EX_ST(STORE(stx, %o4, %o0 + 0x18), memcpy_retl_o2_plus_o5_plus_8) bne,pt %icc, 1b add %o0, 0x20, %o0
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 143/196 sparc: fix accurate exception reporting in copy_{from,to}_user for M7
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Karcher <[email protected]>
[ Upstream commit 936fb512752af349fc30ccbe0afe14a2ae6d7159 ]
The referenced commit introduced exception handlers on user-space memory references in copy_from_user and copy_to_user. These handlers return from the respective function and calculate the remaining bytes left to copy using the current register contents. This commit fixes a couple of bad calculations. This will fix the return value of copy_from_user and copy_to_user in the faulting case. The behaviour of memcpy stays unchanged.
--- arch/sparc/lib/M7memcpy.S | 20 ++++++++++---------- arch/sparc/lib/Memcpy_utils.S | 9 +++++++++ 2 files changed, 19 insertions(+), 10 deletions(-)
arch/sparc/lib/M7memcpy.S +10 -10
@@ -696,16 +696,16 @@ FUNC_NAME: EX_LD_FP(LOAD(ldd, %o4+40, %f26), memcpy_retl_o2_plus_o5_plus_40) faligndata %f24, %f26, %f10 EX_ST_FP(STORE(std, %f6, %o0+24), memcpy_retl_o2_plus_o5_plus_40) - EX_LD_FP(LOAD(ldd, %o4+48, %f28), memcpy_retl_o2_plus_o5_plus_40) + EX_LD_FP(LOAD(ldd, %o4+48, %f28), memcpy_retl_o2_plus_o5_plus_32) faligndata %f26, %f28, %f12 - EX_ST_FP(STORE(std, %f8, %o0+32), memcpy_retl_o2_plus_o5_plus_40) + EX_ST_FP(STORE(std, %f8, %o0+32), memcpy_retl_o2_plus_o5_plus_32) add %o4, 64, %o4 - EX_LD_FP(LOAD(ldd, %o4-8, %f30), memcpy_retl_o2_plus_o5_plus_40) + EX_LD_FP(LOAD(ldd, %o4-8, %f30), memcpy_retl_o2_plus_o5_plus_24) faligndata %f28, %f30, %f14 - EX_ST_FP(STORE(std, %f10, %o0+40), memcpy_retl_o2_plus_o5_plus_40) - EX_ST_FP(STORE(std, %f12, %o0+48), memcpy_retl_o2_plus_o5_plus_40) + EX_ST_FP(STORE(std, %f10, %o0+40), memcpy_retl_o2_plus_o5_plus_24) + EX_ST_FP(STORE(std, %f12, %o0+48), memcpy_retl_o2_plus_o5_plus_16) add %o0, 64, %o0 - EX_ST_FP(STORE(std, %f14, %o0-8), memcpy_retl_o2_plus_o5_plus_40) + EX_ST_FP(STORE(std, %f14, %o0-8), memcpy_retl_o2_plus_o5_plus_8) fsrc2 %f30, %f14 bgu,pt %xcc, .Lunalign_sloop prefetch [%o4 + (8 * BLOCK_SIZE)], 20
@@ -728,7 +728,7 @@ FUNC_NAME: add %o4, 8, %o4 faligndata %f0, %f2, %f16 subcc %o5, 8, %o5 - EX_ST_FP(STORE(std, %f16, %o0), memcpy_retl_o2_plus_o5) + EX_ST_FP(STORE(std, %f16, %o0), memcpy_retl_o2_plus_o5_plus_8) fsrc2 %f2, %f0 bgu,pt %xcc, .Lunalign_by8 add %o0, 8, %o0
@@ -772,7 +772,7 @@ FUNC_NAME: subcc %o5, 0x20, %o5 EX_ST(STORE(stx, %o3, %o0 + 0x00), memcpy_retl_o2_plus_o5_plus_32) EX_ST(STORE(stx, %g2, %o0 + 0x08), memcpy_retl_o2_plus_o5_plus_24) - EX_ST(STORE(stx, %g7, %o0 + 0x10), memcpy_retl_o2_plus_o5_plus_24) + EX_ST(STORE(stx, %g7, %o0 + 0x10), memcpy_retl_o2_plus_o5_plus_16) EX_ST(STORE(stx, %o4, %o0 + 0x18), memcpy_retl_o2_plus_o5_plus_8) bne,pt %xcc, 1b add %o0, 0x20, %o0
@@ -804,12 +804,12 @@ FUNC_NAME: brz,pt %o3, 2f sub %o2, %o3, %o2 -1: EX_LD(LOAD(ldub, %o1 + 0x00, %g2), memcpy_retl_o2_plus_g1) +1: EX_LD(LOAD(ldub, %o1 + 0x00, %g2), memcpy_retl_o2_plus_o3) add %o1, 1, %o1 subcc %o3, 1, %o3 add %o0, 1, %o0 bne,pt %xcc, 1b - EX_ST(STORE(stb, %g2, %o0 - 0x01), memcpy_retl_o2_plus_g1_plus_1) + EX_ST(STORE(stb, %g2, %o0 - 0x01), memcpy_retl_o2_plus_o3_plus_1) 2: and %o1, 0x7, %o3 brz,pn %o3, .Lmedium_noprefetch_cp
arch/sparc/lib/Memcpy_utils.S +9 -0
@@ -137,6 +137,15 @@ ENTRY(memcpy_retl_o2_plus_63_8) ba,pt %xcc, __restore_asi add %o2, 8, %o0 ENDPROC(memcpy_retl_o2_plus_63_8) +ENTRY(memcpy_retl_o2_plus_o3) + ba,pt %xcc, __restore_asi + add %o2, %o3, %o0 +ENDPROC(memcpy_retl_o2_plus_o3) +ENTRY(memcpy_retl_o2_plus_o3_plus_1) + add %o3, 1, %o3 + ba,pt %xcc, __restore_asi + add %o2, %o3, %o0 +ENDPROC(memcpy_retl_o2_plus_o3_plus_1) ENTRY(memcpy_retl_o2_plus_o5) ba,pt %xcc, __restore_asi add %o2, %o5, %o0
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 144/196 crypto: hisilicon/qm - set NULL to qm->debug.qm_diff_regs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chenghai Huang <[email protected]>
[ Upstream commit f0cafb02de883b3b413d34eb079c9680782a9cc1 ]
When the initialization of qm->debug.acc_diff_reg fails,
the probe process does not exit. However, after qm->debug.qm_diff_regs is freed, it is not set to NULL. This can lead to a double free when the remove process attempts to free it again. Therefore, qm->debug.qm_diff_regs should be set to NULL after it is freed.
--- drivers/crypto/hisilicon/debugfs.c | 1 + 1 file changed, 1 insertion(+)
drivers/crypto/hisilicon/debugfs.c +1 -0
@@ -815,6 +815,7 @@ static int qm_diff_regs_init(struct hisi_qm *qm,dfx_regs_uninit (qm, qm->debug.qm_diff_regs,ARRAY_SIZE (qm_diff_regs)); ret =PTR_ERR (qm->debug.acc_diff_regs); qm->debug.acc_diff_regs =NULL ; + qm->debug.qm_diff_regs =NULL ;return ret; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 145/196 wifi: rtw89: avoid circular locking dependency in ser_state_run()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fedor Pchelkin <[email protected]>
[ Upstream commit 570f94511766f9236d3462dfb8a3c719c2b54c23 ]
Lockdep gives a splat [1] when ser_hdl_work item is executed. It is scheduled at mac80211 workqueue via ieee80211_queue_work() and takes a wiphy lock inside. However, this workqueue can be flushed when e.g. closing the interface and wiphy lock is already taken in that case.
Choosing wiphy_work_queue() for SER is likely not suitable. Back on to the global workqueue.
[1]:
WARNING: possible circular locking dependency detected
6.17.0-rc2 #17 Not tainted
------------------------------------------------------
kworker/u32:1/61 is trying to acquire lock:
ffff88811bc00768 (&rdev->wiphy.mtx){+.+.}-{4:4}, at: ser_state_run+0x5e/0x180 [rtw89_core]
but task is already holding lock:
ffffc9000048fd30 ((work_completion)(&ser->ser_hdl_work)){+.+.}-{0:0}, at: process_one_work+0x7b5/0x1450
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #2 ((work_completion)(&ser->ser_hdl_work)){+.+.}-{0:0}:
process_one_work+0x7c6/0x1450
worker_thread+0x49e/0xd00
kthread+0x313/0x640
ret_from_fork+0x221/0x300
ret_from_fork_asm+0x1a/0x30-> #1 ((wq_completion)phy0){+.+.}-{0:0}:
touch_wq_lockdep_map+0x8e/0x180
__flush_workqueue+0x129/0x10d0
ieee80211_stop_device+0xa8/0x110
ieee80211_do_stop+0x14ce/0x2880
ieee80211_stop+0x13a/0x2c0
__dev_close_many+0x18f/0x510
__dev_change_flags+0x25f/0x670
netif_change_flags+0x7b/0x160
do_setlink.isra.0+0x1640/0x35d0
rtnl_newlink+0xd8c/0x1d30
rtnetlink_rcv_msg+0x700/0xb80
netlink_rcv_skb+0x11d/0x350
netlink_unicast+0x49a/0x7a0
netlink_sendmsg+0x759/0xc20
____sys_sendmsg+0x812/0xa00
___sys_sendmsg+0xf7/0x180
__sys_sendmsg+0x11f/0x1b0
do_syscall_64+0xbb/0x360
entry_SYSCALL_64_after_hwframe+0x77/0x7f-> #0 (&rdev->wiphy.mtx){+.+.}-{4:4}:
__lock_acquire+0x124c/0x1d20
lock_acquire+0x154/0x2e0
__mutex_lock+0x17b/0x12f0
ser_state_run+0x5e/0x180 [rtw89_core]
rtw89_ser_hdl_work+0x119/0x220 [rtw89_core]
process_one_work+0x82d/0x1450
worker_thread+0x49e/0xd00
kthread+0x313/0x640
ret_from_fork+0x221/0x300
ret_from_fork_asm+0x1a/0x30other info that might help us debug this:
Chain exists of: &rdev->wiphy.mtx --> (wq_completion)phy0 --> (work_completion)(&ser->ser_hdl_work) Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock((work_completion)(&ser->ser_hdl_work));
lock((wq_completion)phy0);
lock((work_completion)(&ser->ser_hdl_work)); lock(&rdev->wiphy.mtx);
*** DEADLOCK ***
2 locks held by kworker/u32:1/61:
#0: ffff888103835148 ((wq_completion)phy0){+.+.}-{0:0}, at: process_one_work+0xefa/0x1450 #1: ffffc9000048fd30 ((work_completion)(&ser->ser_hdl_work)){+.+.}-{0:0}, at: process_one_work+0x7b5/0x1450
stack backtrace: CPU: 0 UID: 0 PID: 61 Comm: kworker/u32:1 Not tainted 6.17.0-rc2 #17 PREEMPT(voluntary) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS edk2-20250523-14.fc42 05/23/2025 Workqueue: phy0 rtw89_ser_hdl_work [rtw89_core] Call Trace: <TASK> dump_stack_lvl+0x5d/0x80 print_circular_bug.cold+0x178/0x1be check_noncircular+0x14c/0x170 __lock_acquire+0x124c/0x1d20 lock_acquire+0x154/0x2e0 __mutex_lock+0x17b/0x12f0 ser_state_run+0x5e/0x180 [rtw89_core] rtw89_ser_hdl_work+0x119/0x220 [rtw89_core] process_one_work+0x82d/0x1450 worker_thread+0x49e/0xd00 kthread+0x313/0x640 ret_from_fork+0x221/0x300 ret_from_fork_asm+0x1a/0x30 </TASK>
Found by Linux Verification Center (linuxtesting.org).
--- drivers/net/wireless/realtek/rtw89/ser.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/wireless/realtek/rtw89/ser.c +1 -2
@@ -204,7 +204,6 @@ static void rtw89_ser_hdl_work(struct work_struct *work)static int ser_send_msg (struct rtw89_ser *ser,u8 event) { - struct rtw89_dev *rtwdev = container_of(ser, struct rtw89_dev, ser);struct ser_msg *msg =NULL ;if (test_bit (RTW89_SER_DRV_STOP_RUN , ser->flags))
@@ -220,7 +219,7 @@ static int ser_send_msg(struct rtw89_ser *ser, u8 event)list_add (&msg->list, &ser->msg_q);spin_unlock_irq (&ser->msg_q_lock); -ieee80211_queue_work (rtwdev->hw, &ser->ser_hdl_work); +schedule_work (&ser->ser_hdl_work);return 0 ; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 146/196 PCI: tegra194: Fix duplicate PLL disable in pex_ep_event_pex_rst_assert()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nagarjuna Kristam <[email protected]>
[ Upstream commit 4f152338e384a3a47dd61909e1457539fa93f5a4 ]
During PERST# assertion tegra_pcie_bpmp_set_pll_state() is currently called twice.
pex_ep_event_pex_rst_assert() should do the opposite of pex_ep_event_pex_rst_deassert(), so it is obvious that the duplicate tegra_pcie_bpmp_set_pll_state() is a mistake, and that the duplicate tegra_pcie_bpmp_set_pll_state() call should instead be a call to tegra_pcie_bpmp_set_ctrl_state().
With this, the uninitialization sequence also matches that of tegra_pcie_unconfig_controller().
--- drivers/pci/controller/dwc/pcie-tegra194.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pcie-tegra194.c +2 -2
@@ -1720,9 +1720,9 @@ static void pex_ep_event_pex_rst_assert(struct tegra_pcie_dw *pcie) ret); } - ret =tegra_pcie_bpmp_set_pll_state (pcie, false); + ret =tegra_pcie_bpmp_set_ctrl_state (pcie, false);if (ret) -dev_err (pcie->dev,"Failed to turn off UPHY: %d\n" , ret); +dev_err (pcie->dev,"Failed to disable controller: %d\n" , ret); pcie->ep_state =EP_STATE_DISABLED ;dev_dbg (pcie->dev,"Uninitialization of endpoint is completed\n" );
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 147/196 remoteproc: qcom: q6v5: Avoid disabling handover IRQ twice
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephan Gerhold <[email protected]>
[ Upstream commit 110be46f5afe27b66caa2d12473a84cd397b1925 ]
enable_irq() and disable_irq() are reference counted, so we must make sure that each enable_irq() is always paired with a single disable_irq(). If we call disable_irq() twice followed by just a single enable_irq(), the IRQ will remain disabled forever.
For the error handling path in qcom_q6v5_wait_for_start(), disable_irq() will end up being called twice, because disable_irq() also happens in qcom_q6v5_unprepare() when rolling back the call to qcom_q6v5_prepare().
Fix this by dropping disable_irq() in qcom_q6v5_wait_for_start(). Since qcom_q6v5_prepare() is the function that calls enable_irq(), it makes more sense to have the rollback handled always by qcom_q6v5_unprepare().
--- drivers/remoteproc/qcom_q6v5.c | 3 --- 1 file changed, 3 deletions(-)
drivers/remoteproc/qcom_q6v5.c +0 -3
@@ -162,9 +162,6 @@ int qcom_q6v5_wait_for_start(struct qcom_q6v5 *q6v5, int timeout)int ret; ret =wait_for_completion_timeout (&q6v5->start_done, timeout); -if (!ret) -disable_irq (q6v5->handover_irq); -return !ret ? -ETIMEDOUT :0 ; }EXPORT_SYMBOL_GPL (qcom_q6v5_wait_for_start);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 148/196 coresight-etm4x: Conditionally access register TRCEXTINSELR
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuanfang Zhang <[email protected]>
[ Upstream commit dcdc42f5dcf9b9197c51246c62966e2d54a033d8 ]
The TRCEXTINSELR is only implemented if TRCIDR5.NUMEXTINSEL > 0. To avoid invalid accesses, introduce a check on numextinsel (derived from TRCIDR5[11:9]) before reading or writing to this register.
--- drivers/hwtracing/coresight/coresight-etm4x-core.c | 11 ++++++++--- drivers/hwtracing/coresight/coresight-etm4x.h | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-)
drivers/hwtracing/coresight/coresight-etm4x-core.c +8 -3
@@ -451,7 +451,8 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata)etm4x_relaxed_write32 (csa, config->seq_rst,TRCSEQRSTEVR );etm4x_relaxed_write32 (csa, config->seq_state,TRCSEQSTR ); } -etm4x_relaxed_write32 (csa, config->ext_inp,TRCEXTINSELR ); +if (drvdata->numextinsel) +etm4x_relaxed_write32 (csa, config->ext_inp,TRCEXTINSELR );for (i =0 ; i < drvdata->nr_cntr; i++) {etm4x_relaxed_write32 (csa, config->cntrldvr[i],TRCCNTRLDVRn (i));etm4x_relaxed_write32 (csa, config->cntr_ctrl[i],TRCCNTCTLRn (i));
@@ -1239,6 +1240,7 @@ static void etm4_init_arch_data(void *info) etmidr5 =etm4x_relaxed_read32 (csa,TRCIDR5 );/* NUMEXTIN, bits[8:0] number of external inputs implemented */ drvdata->nr_ext_inp =FIELD_GET (TRCIDR5_NUMEXTIN_MASK , etmidr5); + drvdata->numextinsel =FIELD_GET (TRCIDR5_NUMEXTINSEL_MASK , etmidr5);/* TRACEIDSIZE, bits[21:16] indicates the trace ID width */ drvdata->trcid_size =FIELD_GET (TRCIDR5_TRACEIDSIZE_MASK , etmidr5);/* ATBTRIG, bit[22] implementation can support ATB triggers? */
@@ -1671,7 +1673,9 @@ static int __etm4_cpu_save(struct etmv4_drvdata *drvdata) state->trcseqrstevr =etm4x_read32 (csa,TRCSEQRSTEVR ); state->trcseqstr =etm4x_read32 (csa,TRCSEQSTR ); } - state->trcextinselr =etm4x_read32 (csa,TRCEXTINSELR ); + +if (drvdata->numextinsel) + state->trcextinselr =etm4x_read32 (csa,TRCEXTINSELR );for (i =0 ; i < drvdata->nr_cntr; i++) { state->trccntrldvr[i] =etm4x_read32 (csa,TRCCNTRLDVRn (i));
@@ -1803,7 +1807,8 @@ static void __etm4_cpu_restore(struct etmv4_drvdata *drvdata)etm4x_relaxed_write32 (csa, state->trcseqrstevr,TRCSEQRSTEVR );etm4x_relaxed_write32 (csa, state->trcseqstr,TRCSEQSTR ); } -etm4x_relaxed_write32 (csa, state->trcextinselr,TRCEXTINSELR ); +if (drvdata->numextinsel) +etm4x_relaxed_write32 (csa, state->trcextinselr,TRCEXTINSELR );for (i =0 ; i < drvdata->nr_cntr; i++) {etm4x_relaxed_write32 (csa, state->trccntrldvr[i],TRCCNTRLDVRn (i));
drivers/hwtracing/coresight/coresight-etm4x.h +2 -0
@@ -162,6 +162,7 @@#define TRCIDR4_NUMVMIDC_MASK GENMASK(31, 28)#define TRCIDR5_NUMEXTIN_MASK GENMASK(8, 0) +#define TRCIDR5_NUMEXTINSEL_MASK GENMASK(11, 9)#define TRCIDR5_TRACEIDSIZE_MASK GENMASK(21, 16)#define TRCIDR5_ATBTRIG BIT(22)#define TRCIDR5_LPOVERRIDE BIT(23)
@@ -995,6 +996,7 @@ struct etmv4_drvdata {u8 nr_cntr;u8 nr_ext_inp;u8 numcidc; +u8 numextinsel;u8 numvmidc;u8 nrseqstate;u8 nr_event;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 149/196 coresight: trbe: Return NULL pointer for allocation failures
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Yan <[email protected]>
[ Upstream commit 8a55c161f7f9c1aa1c70611b39830d51c83ef36d ]
When the TRBE driver fails to allocate a buffer, it currently returns the error code "-ENOMEM". However, the caller etm_setup_aux() only checks for a NULL pointer, so it misses the error. As a result, the driver continues and eventually causes a kernel panic.
Fix this by returning a NULL pointer from arm_trbe_alloc_buffer() on allocation failures. This allows that the callers can properly handle the failure.
--- drivers/hwtracing/coresight/coresight-trbe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/hwtracing/coresight/coresight-trbe.c +3 -3
@@ -743,12 +743,12 @@ static void *arm_trbe_alloc_buffer(struct coresight_device *csdev, buf =kzalloc_node (sizeof (*buf),GFP_KERNEL ,trbe_alloc_node (event));if (!buf) -return ERR_PTR (-ENOMEM ); +return NULL ; pglist =kcalloc (nr_pages,sizeof (*pglist),GFP_KERNEL );if (!pglist) {kfree (buf); -return ERR_PTR (-ENOMEM ); +return NULL ; }for (i =0 ; i < nr_pages; i++)
@@ -758,7 +758,7 @@ static void *arm_trbe_alloc_buffer(struct coresight_device *csdev,if (!buf->trbe_base) {kfree (pglist);kfree (buf); -return ERR_PTR (-ENOMEM ); +return NULL ; } buf->trbe_limit = buf->trbe_base + nr_pages *PAGE_SIZE ; buf->trbe_write = buf->trbe_base;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 150/196 NFSv4.1: fix backchannel max_resp_sz verification check
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anthony Iliopoulos <[email protected]>
[ Upstream commit 191512355e520dfc45c8bc3b56d4de59c3ade33e ]
When the client max_resp_sz is larger than what the server encodes in its reply, the nfs4_verify_back_channel_attrs() check fails and this causes nfs4_proc_create_session() to fail, in cases where the client page size is larger than that of the server and the server does not want to negotiate upwards.
While this is not a problem with the linux nfs server that will reflect the proposed value in its reply irrespective of the local page size, other nfs server implementations may insist on their own max_resp_sz value, which could be smaller.
Fix this by accepting smaller max_resp_sz values from the server, as this does not violate the protocol. The server is allowed to decrease but not increase proposed the size, and as such values smaller than the client-proposed ones are valid.
--- fs/nfs/nfs4proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/nfs4proc.c +1 -1
@@ -9231,7 +9231,7 @@ static int nfs4_verify_back_channel_attrs(struct nfs41_create_session_args *args goto out;if (rcvd->max_rqst_sz > sent->max_rqst_sz)return -EINVAL ; -if (rcvd->max_resp_sz < sent->max_resp_sz) +if (rcvd->max_resp_sz > sent->max_resp_sz)return -EINVAL ;if (rcvd->max_resp_sz_cached > sent->max_resp_sz_cached)return -EINVAL ;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 151/196 ipvs: Defer ip_vs_ftp unregister during netns cleanup
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Slavin Liu <[email protected]>
[ Upstream commit 134121bfd99a06d44ef5ba15a9beb075297c0821 ]
On the netns cleanup path, __ip_vs_ftp_exit() may unregister ip_vs_ftp before connections with valid cp->app pointers are flushed, leading to a use-after-free.
Fix this by introducing a global exiting_module flag, set to true in ip_vs_ftp_exit() before unregistering the pernet subsystem. In __ip_vs_ftp_exit(), skip ip_vs_ftp unregister if called during netns cleanup (when exiting_module is false) and defer it to __ip_vs_cleanup_batch(), which unregisters all apps after all connections are flushed. If called during module exit, unregister ip_vs_ftp immediately.
--- net/netfilter/ipvs/ip_vs_ftp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/netfilter/ipvs/ip_vs_ftp.c +3 -1
@@ -53,6 +53,7 @@ enum { IP_VS_FTP_EPSV, }; +static bool exiting_module;/* * List of ports (up to IP_VS_APP_MAX_PORTS) to be handled by helper * First port is set to the default port.
@@ -605,7 +606,7 @@ static void __ip_vs_ftp_exit(struct net *net) {struct netns_ipvs *ipvs =net_ipvs (net); -if (!ipvs) +if (!ipvs || !exiting_module)return ;unregister_ip_vs_app (ipvs, &ip_vs_ftp);
@@ -627,6 +628,7 @@ static int __init ip_vs_ftp_init(void)*/ static void __exit ip_vs_ftp_exit(void) { + exiting_module = true;unregister_pernet_subsys (&ip_vs_ftp_ops);/* rcu_barrier() is called by netns */ }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 152/196 scsi: mpt3sas: Fix crash in transport port remove by using ioc_info()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ranjan Kumar <[email protected]>
[ Upstream commit 1703fe4f8ae50d1fb6449854e1fcaed1053e3a14 ]
During mpt3sas_transport_port_remove(), messages were logged with dev_printk() against &mpt3sas_port->port->dev. At this point the SAS transport device may already be partially unregistered or freed, leading to a crash when accessing its struct device.
Using ioc_info(), which logs via the PCI device (ioc->pdev->dev), guaranteed to remain valid until driver removal.
[83428.295776] Oops: general protection fault, probably for non-canonical address 0x6f702f323a33312d: 0000 [#1] SMP NOPTI [83428.295785] CPU: 145 UID: 0 PID: 113296 Comm: rmmod Kdump: loaded Tainted: G OE 6.16.0-rc1+ #1 PREEMPT(voluntary) [83428.295792] Tainted: [O]=OOT_MODULE, [E]=UNSIGNED_MODULE [83428.295795] Hardware name: Dell Inc. Precision 7875 Tower/, BIOS 89.1.67 02/23/2024 [83428.295799] RIP: 0010:__dev_printk+0x1f/0x70 [83428.295805] Code: 90 90 90 90 90 90 90 90 90 90 90 0f 1f 44 00 00 49 89 d1 48 85 f6 74 52 4c 8b 46 50 4d 85 c0 74 1f 48 8b 46 68 48 85 c0 74 22 <48> 8b 08 0f b6 7f 01 48 c7 c2 db e8 42 ad 83 ef 30 e9 7b f8 ff ff [83428.295813] RSP: 0018:ff85aeafc3137bb0 EFLAGS: 00010206 [83428.295817] RAX: 6f702f323a33312d RBX: ff4290ee81292860 RCX: 5000cca25103be32 [83428.295820] RDX: ff85aeafc3137bb8 RSI: ff4290eeb1966c00 RDI: ffffffffc1560845 [83428.295823] RBP: ff85aeafc3137c18 R08: 74726f702f303a33 R09: ff85aeafc3137bb8 [83428.295826] R10: ff85aeafc3137b18 R11: ff4290f5bd60fe68 R12: ff4290ee81290000 [83428.295830] R13: ff4290ee6e345de0 R14: ff4290ee81290000 R15: ff4290ee6e345e30 [83428.295833] FS: 00007fd9472a6740(0000) GS:ff4290f5ce96b000(0000) knlGS:0000000000000000 [83428.295837] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [83428.295840] CR2: 00007f242b4db238 CR3: 00000002372b8006 CR4: 0000000000771ef0 [83428.295844] PKRU: 55555554 [83428.295846] Call Trace: [83428.295848] <TASK> [83428.295850] _dev_printk+0x5c/0x80 [83428.295857] ? srso_alias_return_thunk+0x5/0xfbef5 [83428.295863] mpt3sas_transport_port_remove+0x1c7/0x420 [mpt3sas] [83428.295882] _scsih_remove_device+0x21b/0x280 [mpt3sas] [83428.295894] ? _scsih_expander_node_remove+0x108/0x140 [mpt3sas] [83428.295906] ? srso_alias_return_thunk+0x5/0xfbef5 [83428.295910] mpt3sas_device_remove_by_sas_address.part.0+0x8f/0x110 [mpt3sas] [83428.295921] _scsih_expander_node_remove+0x129/0x140 [mpt3sas] [83428.295933] _scsih_expander_node_remove+0x6a/0x140 [mpt3sas] [83428.295944] scsih_remove+0x3f0/0x4a0 [mpt3sas] [83428.295957] pci_device_remove+0x3b/0xb0 [83428.295962] device_release_driver_internal+0x193/0x200 [83428.295968] driver_detach+0x44/0x90 [83428.295971] bus_remove_driver+0x69/0xf0 [83428.295975] pci_unregister_driver+0x2a/0xb0 [83428.295979] _mpt3sas_exit+0x1f/0x300 [mpt3sas] [83428.295991] __do_sys_delete_module.constprop.0+0x174/0x310 [83428.295997] ? srso_alias_return_thunk+0x5/0xfbef5 [83428.296000] ? __x64_sys_getdents64+0x9a/0x110 [83428.296005] ? srso_alias_return_thunk+0x5/0xfbef5 [83428.296009] ? syscall_trace_enter+0xf6/0x1b0 [83428.296014] do_syscall_64+0x7b/0x2c0 [83428.296019] ? srso_alias_return_thunk+0x5/0xfbef5 [83428.296023] entry_SYSCALL_64_after_hwframe+0x76/0x7e
--- drivers/scsi/mpt3sas/mpt3sas_transport.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_transport.c +3 -5
@@ -991,11 +991,9 @@ mpt3sas_transport_port_remove(struct MPT3SAS_ADAPTER *ioc, u64 sas_address,list_for_each_entry_safe (mpt3sas_phy, next_phy, &mpt3sas_port->phy_list, port_siblings) {if ((ioc->logging_level &MPT_DEBUG_TRANSPORT )) -dev_printk (KERN_INFO , &mpt3sas_port->port->dev, -"remove: sas_addr(0x%016llx), phy(%d)\n" , - (unsigned long long ) - mpt3sas_port->remote_identify.sas_address, - mpt3sas_phy->phy_id); +ioc_info (ioc,"remove: sas_addr(0x%016llx), phy(%d)\n" , + (unsigned long long ) mpt3sas_port->remote_identify.sas_address, + mpt3sas_phy->phy_id); mpt3sas_phy->phy_belongs_to_port =0 ;if (!ioc->remove_host) sas_port_delete_phy(mpt3sas_port->port,
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 153/196 usb: vhci-hcd: Prevent suspending virtually attached devices
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cristian Ciocaltea <[email protected]>
[ Upstream commit e40b984b6c4ce3f80814f39f86f87b2a48f2e662 ]
The VHCI platform driver aims to forbid entering system suspend when at least one of the virtual USB ports are bound to an active USB/IP connection.
However, in some cases, the detection logic doesn't work reliably, i.e. when all devices attached to the virtual root hub have been already suspended, leading to a broken suspend state, with unrecoverable resume.
Ensure the virtually attached devices do not enter suspend by setting the syscore PM flag. Note this is currently limited to the client side only, since the server side doesn't implement system suspend prevention.
--- drivers/usb/usbip/vhci_hcd.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/usb/usbip/vhci_hcd.c +22 -0
@@ -764,6 +764,17 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag ctrlreq->wValue, vdev->rhport); vdev->udev =usb_get_dev (urb->dev); +/* +* NOTE: A similar operation has been done via +* USB_REQ_GET_DESCRIPTOR handler below, which is +* supposed to always precede USB_REQ_SET_ADDRESS. +* +* It's not entirely clear if operating on a different +* usb_device instance here is a real possibility, +* otherwise this call and vdev->udev assignment above +* should be dropped. +*/ +dev_pm_syscore_device (&vdev->udev->dev, true);usb_put_dev (old);spin_lock (&vdev->ud.lock);
@@ -784,6 +795,17 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag "Not yet?:Get_Descriptor to device 0 (get max pipe size)\n"); vdev->udev =usb_get_dev (urb->dev); +/* +* Set syscore PM flag for the virtually attached +* devices to ensure they will not enter suspend on +* the client side. +* +* Note this doesn't have any impact on the physical +* devices attached to the host system on the server +* side, hence there is no need to undo the operation +* on disconnect. +*/ +dev_pm_syscore_device (&vdev->udev->dev, true);usb_put_dev (old); goto out;
Signature · 1 line
2.51.0