Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH 6.12 000/555] 6.12.121-rc1 review
@ 2026-12-04 10:00 Greg Kroah-Hartman
  2026-12-04 10:00 ` [PATCH 6.12 001/555] net: ipv6: keep room for the mac header in dst_dev_overhead() Greg Kroah-Hartman
                   ` (554 more replies)
  0 siblings, 555 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, linux-kernel, torvalds, akpm, linux,
	shuah, patches, lkft-triage, pavel, jonathanh, f.fainelli,
	sudipm.mukherjee, rwarsow, conor, hargar, broonie, achill, sr

This is the start of the stable review cycle for the 6.12.121 release.
There are 555 patches in this series, all will be posted as a response
to this one.  If anyone has any issues with these being applied, please
let me know.

Responses should be made by Sun, 06 Dec 2026 10:04:57 +0000.
Anything received after that time might be too late.

The whole patch series can be found in one patch at:
	https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.12.121-rc1.gz
or in the git tree and branch at:
	git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.12.y
and the diffstat can be found below.

thanks,

greg k-h

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

Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Linux 6.12.121-rc1

Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    cpufreq: intel_pstate: Use dedicated lock in set_power_ctl_ee_state()

Ruben Wauters <ruben.wauters@linux.dev>
    drm/gud: fix potential divide error due to optimisation

Adrian Ambrozewicz <aambrozewicz@nvidia.com>
    gpiolib: free the label of lines released after their chip was removed

Adrian Ambrozewicz <aambrozewicz@nvidia.com>
    gpiolib: wait for pending label frees before cleaning up desc_srcu

Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
    gpiolib: don't overwrite the entire flags field in gpiod_free_commit()

Cooper Morgan <ext-github@cwooper.dev>
    drm/amd/display: Saturate refresh rates in v1/v2 FreeSync infopackets

Christoph Hellwig <hch@lst.de>
    direct-io: remove IOCB_NOWAIT support

Martin Belanger <martin.belanger@dell.com>
    nvme-tcp: consume TLS records without application data

Martin Belanger <martin.belanger@dell.com>
    nvme-tcp: move the TLS record read loop into a helper

Martin Belanger <martin.belanger@dell.com>
    nvme-tcp: use an aligned buffer for the TLS record type

Bart Van Assche <bvanassche@acm.org>
    block: Remove queue freezing from several sysfs store callbacks

Nathan Chancellor <nathan@kernel.org>
    rcu/nocb: Avoid unsequenced accesses to jiffies in show_rcu_nocb_state()

Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
    gpiolib: don't overwrite the entire flags field in gpiod_get_direction()

Carlos Bilbao <carlos.bilbao@kernel.org>
    scsi: target: iscsi: reject invalid size Extended CDB AHS

Chris J Arges <carges@cloudflare.com>
    net: prevent receive header offset overflow during decapsulation

Shuai Liu <847807867@qq.com>
    xfrm: interface: drop non-IP packets before pskb_inet_may_pull()

Zhao Gongyi <zhaogongyi@bytedance.com>
    ext4: fix OOB memmove in ext4_xattr_set_entry

Guicai Ma <maguicai@kylinos.cn>
    KEYS: Use kfree_sensitive() in keyctl_pkey_e_d_s()

Jarkko Sakkinen <jarkko@kernel.org>
    KEYS: trusted: Update static calls before init

Sinan Turunc <enscrpt@pm.me>
    KEYS: serialise key instantiation against keyctl_chown_key()

Guicai Ma <maguicai@kylinos.cn>
    KEYS: Fix userspace buffer overflow in keyctl_pkey_e_d_s()

Henry Martin <bsdhenrymartin@gmail.com>
    KEYS: Fix crash on big_key read

Jarkko Sakkinen <jarkko@kernel.org>
    KEYS: Fix asym key overflow in keyctl_pkey_verify()

Takashi Iwai <tiwai@suse.de>
    ALSA: oss: Fix deadlock at unregistering (again)

Suyuan Wang <stevewong@hust.edu.cn>
    ALSA: fireworks: Abort the transaction on a bus reset

Suyuan Wang <stevewong@hust.edu.cn>
    ALSA: firewire-lib: Abort the FCP transaction on a bus reset

Vasileios Almpanis <vasilisalmpanis@gmail.com>
    usb: gadget: f_uac1_legacy: fix double close of the ALSA devices

Dave Airlie <airlied@redhat.com>
    i915/vma: use kfree_rcu to make sure vma are freed after a rcu grace period

Xu Rao <raoxu@uniontech.com>
    vhost/net: Fix receive queue test in busy poll

Brajesh Gupta <brajesh.gupta@imgtec.com>
    drm/imagination: Set scheduler timeout period higher than Firmware timeout

Andrea Righi <arighi@nvidia.com>
    sched_ext: Enable tick for finite slices on nohz_full

Po-Hao Huang <phhuang@realtek.com>
    wifi: rtw89: modify active scan rule for 6GHz band

Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
    ASoC: SOF: Intel: lnl: Enable offload for UAOL link

Kuniyuki Iwashima <kuniyu@google.com>
    ipv6: Flush exception route while replacing nexthop.

Kuniyuki Iwashima <kuniyu@google.com>
    ipv6: Remove FIB6_EXCEPTION_BUCKET_FLUSHED.

David Hildenbrand (Arm) <david@kernel.org>
    mm/gup: limit pagecache folio refcount when grabbing references

David Hildenbrand (Arm) <david@kernel.org>
    mm/mmu_gather: flush pending references early before the folio limit

David Hildenbrand (Arm) <david@kernel.org>
    mm: limit pagecache folio refcount when splicing into pipes

David Hildenbrand (Arm) <david@kernel.org>
    mm: limit pagecache folio refcount when mapping pages

Matthew Wilcox (Oracle) <willy@infradead.org>
    filemap: Add folio_next_pos()

Max Kellermann <max.kellermann@ionos.com>
    mm: constify pagemap related test/getter functions

Kuniyuki Iwashima <kuniyu@google.com>
    ipv6: Prevent rt6_insert_exception() for dying fib6_info.

Jamal Hadi Salim <jhs@mojatatu.com>
    net/sched: codel: bound the dropping loop per dequeue call

Sam James <sam@gentoo.org>
    crypto: nx - fix nx_crypto_ctx_exit argument

Bernard Pidoux <bernard.f6bvp@gmail.com>
    rose: say when we are busy, and leave the busy state on read

Bernard Pidoux <bernard.f6bvp@gmail.com>
    rose: acknowledge delivered data before resetting a call

Bernard Pidoux <bernard.f6bvp@gmail.com>
    ax25: leave the busy state when the application reads

Bernard Pidoux <bernard.f6bvp@gmail.com>
    mkiss: leave the escaped state on any byte after FESC

Bernard Pidoux <bernard.f6bvp@gmail.com>
    netrom: leave the busy state when the application reads

Bernard Pidoux <bernard.f6bvp@gmail.com>
    netrom: bound the resequencing queue while we are busy

Bernard Pidoux <bernard.f6bvp@gmail.com>
    netrom: clear the choke flag on frames sent again

Vincent Donnefort <vdonnefort@google.com>
    tracing: Take trace_access_lock() in tracing_buffers_ioctl()

David Carlier <devnexen@gmail.com>
    tracing: Ignore .function on the function trace event

David Carlier <devnexen@gmail.com>
    tracing: Drop the synthetic event ref when clearing hist triggers

Steven Rostedt <rostedt@goodmis.org>
    tracing: Do not allow user events to add a system name

Jaewon Jung <jaewon8868@gmail.com>
    tracing: Avoid undefined shifts for zero histogram map size

Kyle Zeng <kylebot@openai.com>
    tracing/filters: Treat zero-length dynamic strings as empty

Masami Hiramatsu (Google) <mhiramat@kernel.org>
    tracing/filters: Handle out-of-range CPU for OP_NE in cpumask comparison

Masami Hiramatsu (Google) <mhiramat@kernel.org>
    tracing/filters: Fix MATCH_END_ONLY regex matching for fixed-size strings

Masami Hiramatsu (Google) <mhiramat@kernel.org>
    tracing/filters: Check for missing operand after operator in parse_pred()

David Carlier <devnexen@gmail.com>
    tracing/user_events: Don't free an event that a dynamic event still references

Chaosheng Qu <chaosheng.qu.linux@gmail.com>
    tracing/osnoise: Don't start a kthread in timerlat user-space mode

koraynilay <koray.fra@gmail.com>
    smb: client: fix times assignments in cifs_posix_to_fattr()

koraynilay <koray.fra@gmail.com>
    smb: client: fix negative timestamps being read from smb

Stanley Jhu <stanleyjhu@google.com>
    scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper

Stanley Jhu <stanleyjhu@google.com>
    scsi: ufs: bsg: Abort ufs_bsg_request() when runtime resume fails

Praneeth Balasubramanian <praneeth@ucsb.edu>
    scsi: target: iscsi: Check for existing sessions only after authentication

Shao Mingyin <shao.mingyin@zte.com.cn>
    scsi: target: Fix NULL pointer dereference in target_dev_alua_lu_gp_store()

Shao Mingyin <shao.mingyin@zte.com.cn>
    scsi: target: Fix NULL pointer dereference in core_alua_do_port_transition()

Ciro Iriarte <ciro.iriarte+software@gmail.com>
    scsi: target: core: Parse APTPL res_type and res_scope as hex

Shao Mingyin <shao.mingyin@zte.com.cn>
    nvmet: zns: return the namespace lookup error for Identify

Shao Mingyin <shao.mingyin@zte.com.cn>
    nvmet: use overflow-safe range checks in the file backend

Shao Mingyin <shao.mingyin@zte.com.cn>
    nvmet: handle short reads and writes in the file backend

Shao Mingyin <shao.mingyin@zte.com.cn>
    nvmet-tcp: only wait for in-capsule data for inline SGLs

Shao Mingyin <shao.mingyin@zte.com.cn>
    nvmet-fc: reject duplicate queue IDs on Create Connection

Yaohan Li <shunsheng1218@gmail.com>
    nvme: stop asynchronous event work before ANA teardown

Shao Mingyin <shao.mingyin@zte.com.cn>
    nvme: reject invalid reconnect_delay sysfs values

Shao Mingyin <shao.mingyin@zte.com.cn>
    nvme-tcp: require the R2T offset to match the data sent

Shao Mingyin <shao.mingyin@zte.com.cn>
    nvme-loop: release the target request when SG setup fails

Shao Mingyin <shao.mingyin@zte.com.cn>
    nvme-auth: use the parsed offset for the DH-CHAP key

Joas Antonio dos Santos <joasantonio108@gmail.com>
    net: usb: smsc75xx: reject frames without a full header and FCS

Zxyan Zhu <zxyan0222@gmail.com>
    net: stmmac: re-enable on-chip parity checkers for XGMAC ASP 0x2

Christian Schmidbauer <opensource@grische.xyz>
    net: stmmac: honour Rx checksum errors in the AF_XDP zero-copy path

Christian Schmidbauer <opensource@grische.xyz>
    net: stmmac: dwmac1000: don't discard frames with only a checksum error

Eric Dumazet <edumazet@kernel.org>
    net: openvswitch: use skb_set_transport_header_careful() in parse_ipv6hdr()

Nathan Chancellor <nathan@kernel.org>
    net: microchip: encx24j600: Avoid unsequenced accesses to jiffies in encx24j600_tx()

Anthony Pighin <anthony.pighin@nokia.com>
    net: gianfar: clear the pending Rx skb when freeing the Rx ring

Svyatoslav Nikolenko <nsvatoslav515@gmail.com>
    net: e1000: fix warning in iounmap on probe failure

Daniel Wade <danjwade95@gmail.com>
    net: bridge: fix skb leak of reinjected link-local frames

Daejun Park <daejun7.park@samsung.com>
    xfs: wait for direct I/O before swapping extents

Rik van Riel <riel@surriel.com>
    xfs: keep successful near rt allocations

Daejun Park <daejun7.park@samsung.com>
    xfs: break layouts before swapping extents

Ding Feng <dingf3ng@gmail.com>
    zonefs: ignore RLIMIT_FSIZE above LLONG_MAX in zonefs_write_check_limits()

Krystian Kaniewski <krystianmkaniewski@gmail.com>
    xarray: fix index jumping backwards in xas_find()

Adrian Schlegel <me@adrianschlegel.com>
    x86/mce: Do not treat cache hierarchy errors as memory errors

WeitaoWang-oc <WeitaoWang-oc@zhaoxin.com>
    x86/apic/msi: Fix MSI interrupt affinity configuration

Zhao Feng <zhaofeng2@cmss.chinamobile.com>
    watchdog: npcm: fix sleeping clock call in restart handler

Miklos Szeredi <mszeredi@redhat.com>
    virtiofs: fix use-after-free of fs->tag on device removal

Matt Turner <mattst88@gmail.com>
    vgacon: Fall back to the dummy console if mapping VGA memory fails

Eric Dumazet <edumazet@kernel.org>
    udp: use skb_set_transport_header_careful() in __udp6_lib_err_encap()

Juan Agustin Niccolini <juanagusnicco@gmail.com>
    tcp: Fix the SO_REUSEPORT bind cache admitting a conflicting socket

Sebastian Reichel <sebastian.reichel@collabora.com>
    spi: Fix runtime PM imbalance on pump transfer message error

Stephen Smalley <stephen.smalley.work@gmail.com>
    selinux: check MAP_SHARED_VALIDATE mappings as shared

Günther Noack <gnoack3000@gmail.com>
    selftests/landlock: Test that layering does not break refer

Eric Dumazet <edumazet@kernel.org>
    sctp: use skb_set_transport_header_careful() in sctp_v6_err()

Yves Bieri <yves.bieri@theori.io>
    sctp: do not free a new asoc peeled off while sendmsg slept

Cen Zhang <zzzccc427@gmail.com>
    ocfs2: serialize inode journal access with shutdown

Zhiyuan Zhang <zhiyuanzhang912@gmail.com>
    ocfs2: fix kernel BUG in ocfs2_page_mkwrite() when write_end fails

Cen Zhang <zzzccc427@gmail.com>
    ocfs2: advance locking_state through the live cursor

Cen Zhang <zzzccc427@gmail.com>
    ocfs2/dlmfs: keep the superblock alive during lock work

Miguel Ojeda <ojeda@kernel.org>
    objtool/rust: add more `noreturn` Rust functions for Rust 1.101.0

Karl Mehltretter <kmehltretter@gmail.com>
    parisc: irq: Trace hardirq state in do_cpu_irq_mask()

Karl Mehltretter <kmehltretter@gmail.com>
    parisc: Fix register corruption in 32-bit dynamic ftrace

Boyan Liu <yymhvert@gmail.com>
    scsi: sd_zbc: Cap zone report count by buffer size

Shao Mingyin <shao.mingyin@zte.com.cn>
    scsi: rdac: Keep the error status when controller lookup fails

Milan P. Gandhi <mgandhi@redhat.com>
    scsi: mpi3mr: Validate reply frame size bounds

Jiale Yao <yaojiale02@163.com>
    s390/dcssblk: Initialize device semaphore before sysfs registration

Gerald Schaefer <gerald.schaefer@linux.ibm.com>
    s390/appldata: Fix error handling in appldata_generic_handler()

Yunhui Cui <cuiyunhui@bytedance.com>
    riscv: Fix SR_SUM leakage across context switches

Bradley Morgan <brads@mainlining.org>
    powerpc32/modules: Reserve a PLT entry for ftrace_regs_caller

Nathan Chancellor <nathan@kernel.org>
    powerpc/xmon: Avoid unsequenced accesses to tsk in show_task()

Jiale Yao <yaojiale02@163.com>
    powerpc/eeh: NUL-terminate force recovery input

Paul Moses <p@1g4.org>
    perf record: Reject CPU indices equal to the mask size

Yehyeong Lee <yhlee@isslab.korea.ac.kr>
    RDMA/srpt: widen the indirect RDMA context counters

Yehyeong Lee <yhlee@isslab.korea.ac.kr>
    RDMA/srpt: reject zero-length buffer descriptors

Yehyeong Lee <yhlee@isslab.korea.ac.kr>
    RDMA/srpt: bound the indirect descriptor table to the IU

Deep Shah <deepshah146@gmail.com>
    RDMA/siw: Fix use-after-free in siw_mem_id2obj()

Jaeyeong Lee <lee@jaeyeong.cc>
    RDMA/rtrs: Register client event handler after capability check

Moshe Shemesh <moshe@nvidia.com>
    RDMA/mlx5: Skip vport context query on FW without ib_virt support

Dezhen Lu <dezhen.lu@student.uni-tuebingen.de>
    RDMA/mlx5: Fix DevX umem page size truncation for pages >= 4G

Nathan Chancellor <nathan@kernel.org>
    qca_spi: Avoid unsequenced accesses to jiffies in qcaspi_netdev_tx_timeout()

Shrikanth Hegde <sshegde@linux.ibm.com>
    PPC32: Fix hard_irq_disable to follow tracing and lockdep state

Ridong Chen <chenridong@xiaomi.com>
    mm/migrate: move NR_FILE_THPS on cross-node migration

David Hildenbrand (Arm) <david@kernel.org>
    mm/khugepaged: don't map folios that are not uptodate in MADV_COLLAPSE

Jose Fernandez (Anthropic) <jose.fernandez@linux.dev>
    mm/filemap: stop fault-around when the walk steps back

Wang Xiaolei <xiaoleiwangxiaolei@gmail.com>
    mm/damon/tests/sysfs-kunit: fix leaked pid reference in add_targets test

Aveline Noir <jm5905938@gmail.com>
    mm/damon/core: reset watermark wait state on each iteration

Gautam Menghani <gautam@linux.ibm.com>
    KVM: PPC: Book3S HV: XICS: Update irq_type for cleanup to work

Gautam Menghani <gautam@linux.ibm.com>
    KVM: PPC: Book3S HV: XICS: Avoid NULL ptr deref in kvmppc_xive_cleanup_vcpu()

Gautam Menghani <gautam@linux.ibm.com>
    KVM: PPC: Book3S HV: Take SRCU read lock around kvmppc_h_page_init() call

Gautam Menghani <gautam@linux.ibm.com>
    KVM: PPC: Book3S HV: Ensure that calls to idr_alloc are synchronized

Amit Machhiwal <amachhiw@linux.ibm.com>
    KVM: PPC: Book3S HV: Disable preemption around host-side HPT lock users

Gautam Menghani <gautam@linux.ibm.com>
    KVM: PPC: Book3S HV: Avoid spurious interrupts caused by LPCR_MER bit

Axel Mierczuk <axel.mierczuk@1password.com>
    ipvs: validate cport in received sync records

Zihan Xi <zihanx@nebusec.ai>
    ipvs: reject FTP control ports as data ports

Theodor Arsenij Larionov Trichkine <theodorlarionov@gmail.com>
    ipvs: ftp: skip conntrack templates in ip_vs_ftp_out

Eric Dumazet <edumazet@kernel.org>
    ipv6: mcast: use skb_set_transport_header_careful() in ipv6_mc_check_exthdrs()

Jaeyeong Lee <lee@jaeyeong.cc>
    net/tls: serialize context removal in tls_device_down()

Nathan Chancellor <nathan@kernel.org>
    mptcp: Avoid unsequenced accesses to jiffies in mptcp_reset_tout_timer()

Liam R. Howlett (Google) <liam@infradead.org>
    maple_tree: fix rcu reader NULL dereference after the tree is emptied

Joas Antonio dos Santos <joasantonio108@gmail.com>
    mac802154: llsec: reject secured frames with security level 0

Henry Martin <bsdhenrymartin@gmail.com>
    ip6mr: prevent info-leak in ip6mr_cache_report()

Juan Parrado <jparrado.1817@gmail.com>
    Input: xpad - add support to Hori Real Arcade Pro 4

Yuan Yao <yaoyuan0329os@gmail.com>
    Input: trackpoint - add new TP JYT_NDT device variant id 7

Liu Chao <liuc63@xiaopeng.com>
    Input: goodix - reject a bak_ref length that cannot hold the checksum

Ivan Verbovoy <ivanverbovoy@gmail.com>
    Input: da7280 - do not advertise FF_GAIN

Wentao Liang <vulab@iscas.ac.cn>
    Input: cyapa - fix runtime PM leak in cyapa_update_rt_suspend_scanrate()

Ziheng Wei <zihengw03@163.com>
    hwmon: (w83792d) Fix incorrect struct cast in show_temp1() and store_temp1()

Ziheng Wei <zihengw03@163.com>
    hwmon: (w83791d) Fix incorrect struct cast in show_temp1() and store_temp1()

Wayne Ho <wayneho219@gmail.com>
    hwmon: (sht3x) Fix overflow when writing alert limits

Guenter Roeck <linux@roeck-us.net>
    hwmon: (nct6775) Fix tolerance bitmask when reading REG_FAN_MODE

Guenter Roeck <linux@roeck-us.net>
    hwmon: (nct6775) Fix swapped temperature tolerance register writes

Ziheng Wei <zihengw03@163.com>
    hwmon: (nct6775) Fix incorrect struct cast in beep callbacks

Rosen Penev <rosenp@gmail.com>
    hwmon: (dell-smm) Reject out-of-range pwm values

Rosen Penev <rosenp@gmail.com>
    hwmon: (dell-smm) Reject a fan_max that the BIOS cannot take

Vítor Hugo Silva <vitorhg20080@gmail.com>
    hwmon: (ads7871) Add error handle from spi_setup()

Xuanqiang Luo <luoxuanqiang@kylinos.cn>
    iavf: fix ASQ command buffer leak on init failure

Sung Byeongchan <tjdqudcks0424@naver.com>
    ieee802154: require CAP_NET_ADMIN for SIOCSIFADDR

Lianjie Wang <lian@is.s.u-tokyo.ac.jp>
    gpio: virtio: compute the line names size in a size_t

Lianjie Wang <lian@is.s.u-tokyo.ac.jp>
    gpio: virtio: bound the line names block by its configured size

Alexandre Becholey <alex@becholey.ch>
    gpio: ljca: Validate the pin index of interrupt events

Junyoung Jang <graypanda.inzag@gmail.com>
    fuse: skip dcache instantiation for readdirplus names with embedded NUL

Miklos Szeredi <mszeredi@redhat.com>
    fuse: limit name size in listxattr

Miklos Szeredi <mszeredi@redhat.com>
    fuse: fix possible UAF in fuse_direntplus_link()

Weiming Shi <bestswngs@gmail.com>
    fbdev: vfb: Validate framebuffer geometry and memory size

Tim Douglas <me@timdoug.com>
    fbdev: valkyriefb: keep the framebuffer mapping size fixed

Xue Haolin <xuehaolin@uniontech.com>
    fbdev: sstfb: Error out if pixclock equals zero

YuanZhe Liu <25031212351@stu.xidian.edu.cn>
    fbdev: smscufx: keep the usb_device alive while ufx_data is in use

YuanZhe Liu <25031212351@stu.xidian.edu.cn>
    fbdev: smscufx: don't free registered framebuffer on probe error

YuanZhe Liu <25031212351@stu.xidian.edu.cn>
    fbdev: smscufx: allocate the size advertised in smem_len

Jianqiang Zou <jq.zou@outlook.com>
    fbdev: radeonfb: reject a zero pixclock in radeonfb_check_var()

Tim Douglas <me@timdoug.com>
    fbdev: macmodes: compare the pixel clock of each candidate mode

Steffen A. Mork <linux-dev@morknet.de>
    fbdev: fm2fb: Fix iomem access

Eric Biggers <ebiggers@kernel.org>
    fscrypt: Initialize ->ci_master_key before publication

Aristeu Rozanski <aris@redhat.com>
    EDAC/i5000: Fix slot number passed to determine_mtr()

Marek Szyprowski <m.szyprowski@samsung.com>
    dma: swiotlb: Serialize restricted DMA pool initialization

Marek Szyprowski <m.szyprowski@samsung.com>
    dma: swiotlb: Properly tear down the default pool on exit

Marek Szyprowski <m.szyprowski@samsung.com>
    dma-coherent: serialize reserved memory pool initialization

Sumit Gupta <sumitg@nvidia.com>
    cpufreq: CPPC: Set CPPC Enable register in cpu_init()

Xu Rao <raoxu@uniontech.com>
    Bluetooth: MGMT: Fix runtime config status opcode

Joas Antonio dos Santos <joasantonio108@gmail.com>
    Bluetooth: hci_qca: clear qca_memdump when discarding dump packets

Alex Kazinsky <a.kazinsky@ideco.ru>
    blk-iocost: Fix overflow in donation weight calculation

Niklas Cassel <cassel@kernel.org>
    ata: libata-scsi: fix the INC_512 bit test for SECURITY PROTOCOL IN/OUT

Chen Yuxi <chenyuxi19@huawei.com>
    ASoC: wm8962: Fix broken headset button caused by wrong guard constant

yzddMr6 <yzddmr6@gmail.com>
    ASoC: qcom: q6dsp-lpass-clocks: Set driver data before registering clocks

Julius Bairaktaris <julius@bairaktaris.de>
    ASoC: qcom: q6asm-dai: reject compress rings larger than the DMA buffer

Julius Bairaktaris <julius@bairaktaris.de>
    ASoC: qcom: q6apm-dai: reject compress rings larger than the DMA buffer

Marc Herrero <marcht@proton.me>
    ASoC: qcom: audioreach: only disconnect the route a mixer control owns

Ben Cressey <ben@cressey.dev>
    arm64: kexec: use a typed entry to fix kCFI oops

Vineet Gupta <vgupta@kernel.org>
    ARC: io: work around GCC PR127718 in __raw_write{w,l}()

Ye Weihua <yeweihua4@huawei.com>
    ALSA: pcm: oss: Restore params flag after failed reconfiguration

Aldo Ariel Panzardo <qwe.aldo@gmail.com>
    drm/vmwgfx: close TOCTOU on guest_memory_bo in surface reference ioctl

Zack Rusin <zack.rusin@broadcom.com>
    drm/vmwgfx: validate command body sizes before parsing

Aldo Ariel Panzardo <qwe.aldo@gmail.com>
    drm/vmwgfx: return an error when a shared GB surface has no backup buffer

Zack Rusin <zack.rusin@broadcom.com>
    drm/vmwgfx: reserve dumb buffers while detaching their surfaces

Zack Rusin <zack.rusin@broadcom.com>
    drm/vmwgfx: log MOB limits outside the manager spinlock

Zack Rusin <zack.rusin@broadcom.com>
    drm/vmwgfx: log missing primary planes only once

Vladimir Popov <popov.nkv@gmail.com>
    drm/vmwgfx: fix NULL pointer dereference in vmw_validation_bo_fence()

Jaeyeong Lee <finpiler@protonmail.com>
    drm/vmwgfx: Erase the detached resource entry on resource release

Aldo Ariel Panzardo <qwe.aldo@gmail.com>
    drm/vmwgfx: do not hand the embedded sg_table to the PRIME core

Zack Rusin <zack.rusin@broadcom.com>
    drm/vmwgfx: bound MKSSTAT lengths before rounding to pages

Zack Rusin <zack.rusin@broadcom.com>
    drm/vmwgfx: avoid underflow when stripping short GuestInfo replies

Maíra Canal <mcanal@igalia.com>
    drm/vc4: Start shader code at varying offsets in its BO

Maíra Canal <mcanal@igalia.com>
    drm/vc4: Fix off-by-one in the shader record BO handle check

Maíra Canal <mcanal@igalia.com>
    drm/vc4: Clear the slice caches before resetting a stalled GPU

Maíra Canal <mcanal@igalia.com>
    drm/vc4: Check for a validated shader before reading its thread mode

Maíra Canal <mcanal@igalia.com>
    drm/vc4: Hold a runtime PM reference while allocating the binner BO

Qiang Han <qiangh@amd.com>
    drm/amdkfd: wait for the queue quiesce in concurrent SVM evictions

Jesse Zhang <Jesse.Zhang@amd.com>
    drm/amdkfd: keep the DMA addresses of a range intact if splitting fails

Apurv Mishra <Apurv.Mishra@amd.com>
    drm/amdkfd: Don't reuse a VRAM page that is still referenced

Perry Yuan <perry.yuan@amd.com>
    drm/amdkfd: check CRIU SVM priv data bounds before allocating

David Francis <David.Francis@amd.com>
    drm/amdkfd: Acquire cwsr buffer during CRIU resume

Jiaming Fan <fan.jiaming@hotmail.com>
    drm/amdgpu: only unregister the ATPX handler if we registered it

David Rosca <david.rosca@amd.com>
    drm/amdgpu: Fix VCE buffer size check for DPB and input surface

Andrei Krautsou <an9949an@gmail.com>
    drm/amdgpu: enable MGCG/FGCG/PERF_CLK for GC 11.0.2

Jackie Liu <liuyun01@kylinos.cn>
    drm/amd/display: Fix logger leak on perf trace allocation failure

Wang Jiang <jiangwang@kylinos.cn>
    drm/amdgpu/gfx_v9_0: Add gfxoff quirk for Lenovo Picasso 318F

Joshua Horne <hornejd@etsu.edu>
    drm/amd/pm: send smu8 sclk level indices, not the level mask

Jiaming Fan <fan.jiaming@hotmail.com>
    drm/radeon: only unregister the ATPX handler if we registered it

Andrey Misiurov <amisiurov@cloudlinux.com>
    drm/radeon: Bound GPIO I2C table entry count from VBIOS

Mohamed Ahmed <mohamedahmedegypt2001@gmail.com>
    drm/nouveau: do not return early from a synchronous VM_BIND

Dave Airlie <airlied@redhat.com>
    drm/nouveau/disp: Set drm_mode_config_funcs.atomic_(check|commit) (attempt 2)

Shigeaki Asai <y-asai.0816@docomonet.jp>
    drm/meson: encoder_dsi: load ENCL gamma table while ENCL is disabled

Imre Deak <imre.deak@intel.com>
    drm/i915/pps: Reset PPS state after TypeC port init on resume

YuanZhe Liu <25031212351@stu.xidian.edu.cn>
    drm/gud: avoid divide error in gud_stats_debugfs

Zizhi Wo <wozizhi@huawei.com>
    block: fix BLKSECDISCARD zero-length range causing page cache invalidation

Sechang Lim <rhkrqnwk98@gmail.com>
    bpf, sockmap: Clear the redirect target after the stream parser runs

Rosen Penev <rosenp@gmail.com>
    gpio: mvebu: validate ngpios before use

Sahaj Chaudhari <sahaj123.sc@gmail.com>
    gpio: davinci: use controller-specific MMIO for BINTEN

Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
    gpio: davinci: use generic device properties

Peter Zijlstra <peterz@infradead.org>
    perf: Fix sigtrap vs fast-switch

Peter Zijlstra <peterz@infradead.org>
    perf: Fix sigtrap for software events

Tengda Wu <wutengda@huaweicloud.com>
    perf: Prevent duplicate sigtrap task work enqueue

Shravya KN <shravya.k-n@broadcom.com>
    tg3: Fix heap overflow in unbuffered NVRAM write path

Pavan Chebbi <pavan.chebbi@broadcom.com>
    tg3: Skip management FW version when APE firmware is not ready

Pavan Chebbi <pavan.chebbi@broadcom.com>
    tg3: Don't fail probe if 31-bit coherent DMA mask is unsupported

Linus Torvalds <torvalds@linux-foundation.org>
    net: dpaa2-eth: fix objtool warning and logic bug

Alexei Starovoitov <ast@kernel.org>
    bpf, sockmap: Hold the psock of the work in sk_psock_backlog()

Alexei Starovoitov <ast@kernel.org>
    bpf: Keep the MAC header in bpf_skb_change_tail()

Alexei Starovoitov <ast@kernel.org>
    bpf: Take a neighbour of the L3 master in bpf_redirect_neigh()

Alexei Starovoitov <ast@kernel.org>
    bpf: Clear family and port of a short address for cgroup sockaddr hooks

Alexei Starovoitov <ast@kernel.org>
    bpf: Fail loads from a network header that was not set

Alexei Starovoitov <ast@kernel.org>
    bpf: Clear the data that bpf_msg_push_data() adds

Alexei Starovoitov <ast@kernel.org>
    bpf: Zero bpf_list_head in copies of map values

Alexei Starovoitov <ast@kernel.org>
    bpf: Require CAP_PERFMON for dumps of xlated insns

Altgelt, Max (Nextron) <max.altgelt@nextron-systems.com>
    bpf: don't skip other information if xlated_prog_insns is skipped

Alexei Starovoitov <ast@kernel.org>
    bpf: Give syscall programs without CAP_PERFMON the base helpers only

Alexei Starovoitov <ast@kernel.org>
    bpf: Fix reads past an enum in prints of BTF data

Alexei Starovoitov <ast@kernel.org>
    bpf: Fix NULL dereference in XDP redirect from async callbacks

Alexei Starovoitov <ast@kernel.org>
    bpf: Do not fill jited line info for a hidden subprog

Alexei Starovoitov <ast@kernel.org>
    bpf: Add the symbol of a prog before its id

Alexei Starovoitov <ast@kernel.org>
    bpf: Keep the names in front of a number in delegate options

Alexei Starovoitov <ast@kernel.org>
    bpf: Do not allow bpf_d_path() by an id of another BTF

Kuniyuki Iwashima <kuniyu@google.com>
    tcp: Don't clear saddr before ->put_port().

Eric Dumazet <edumazet@kernel.org>
    ipv6: mcast: do not pass uninitialized bytes to dev_mc_add()

Aristo Chen <aristo.chen@canonical.com>
    net: dsa: felix: fix NULL pointer dereference in felix_port_enable()

Alexei Starovoitov <ast@kernel.org>
    bpf: Save irq flags on the stack when freeing a list head or rb root

Kaitao Cheng <chengkaitao@kylinos.cn>
    bpf: clear list node owner and unlink before drop

Antonio Quartulli <antonio@mandelbit.com>
    tun: bound the NAPI receive queue

Jiayuan Chen <jiayuan.chen@linux.dev>
    ipv4: fix conntrack defrag forwarding after ip_frag_reinit()

Nicolai Buchwitz <nb@tipi-net.de>
    net: systemport: accumulate the DIM packet and byte counters

Nicolai Buchwitz <nb@tipi-net.de>
    net: systemport: restart DIM from the default profile on start

Nicolai Buchwitz <nb@tipi-net.de>
    net: bcmgenet: reset the Rx discard count with the ring

Nicolai Buchwitz <nb@tipi-net.de>
    net: bcmgenet: accumulate the DIM packet and byte counters

Nicolai Buchwitz <nb@tipi-net.de>
    net: bcmgenet: keep DIM from getting stuck after close or suspend

Zak Kemble <zakkemble@gmail.com>
    net: bcmgenet: use napi_complete_done return value

Wang Haoran <wanghr2026@mail.zgclab.edu.cn>
    net: bcmasp: avoid refcount drain on probe

Florian Fainelli <florian.fainelli@broadcom.com>
    net: dsa: b53: fix mirror destination and source state tracking

Florian Fainelli <florian.fainelli@broadcom.com>
    net: dsa: b53: fix mirror port encoding on BCM5325 and BCM5365

Florian Fainelli <florian.fainelli@broadcom.com>
    net: dsa: b53: use the correct override register 2 Gbps bit

Florian Fainelli <florian.fainelli@broadcom.com>
    net: dsa: b53: fix the SRAB grant timeout check

Florian Fainelli <florian.fainelli@broadcom.com>
    net: dsa: b53: initialize the jumbo frame size register offset

Saurabh Sengar <ssengar@linux.microsoft.com>
    workqueue: Skip redundant unbound updates during CPU bringup

Andrea Parri <parri.andrea@gmail.com>
    ftrace: Fix lost recursion records in ftrace_record_recursion()

Patrick Delaunay <patrick.delaunay@foss.st.com>
    arm64: dts: st: mark STM32MP23 timer as stopping in suspend

Patrick Delaunay <patrick.delaunay@foss.st.com>
    arm64: dts: st: add PSCI idle state to STM32MP23 CPU domains

Patrick Delaunay <patrick.delaunay@foss.st.com>
    arm64: dts: st: add PSCI idle state to STM32MP25 CPU domains

Shihuang Liu <shlomojune6@gmail.com>
    net: sock_reuseport: Check program type on the migration path

Alexei Starovoitov <ast@kernel.org>
    bpf: Let the bpf_fastcall boundary cover the longest pattern

Christian Göttsche <cgzones@googlemail.com>
    jbd2: set JBD2_LOADED under j_state_lock

Filipe Manana <fdmanana@suse.com>
    btrfs: fix delayed inode count leak after failure to delete inode ref

Filipe Manana <fdmanana@suse.com>
    btrfs: unfold transaction abort at __btrfs_update_delayed_inode()

Filipe Manana <fdmanana@suse.com>
    btrfs: abort transaction on failure to update inode after hole punching

Filipe Manana <fdmanana@suse.com>
    btrfs: fiemap: deal with inline extent in fiemap_find_last_extent_offset()

Arnav Kapoor <kapoorarnav43@gmail.com>
    ASoC: SOF: control: reject out-of-range enum values

Filipe Manana <fdmanana@suse.com>
    btrfs: fix race between concurrent sync direct IO writes

Boris Burkov <boris@bur.io>
    btrfs: downgrade the reflink source inode lock for tree walking

Boris Burkov <boris@bur.io>
    btrfs: pre-flush reflink source before taking inode locks

David Sterba <dsterba@suse.com>
    btrfs: use struct btrfs_inode inside btrfs_remap_file_range_prep()

David Sterba <dsterba@suse.com>
    btrfs: use struct btrfs_inode inside btrfs_remap_file_range()

David Sterba <dsterba@suse.com>
    btrfs: pass struct btrfs_inode to btrfs_double_mmap_unlock()

David Sterba <dsterba@suse.com>
    btrfs: pass struct btrfs_inode to btrfs_double_mmap_lock()

Cheng Yongkang <teel4res@gmail.com>
    btrfs: remove devid kobject when deleting a missing device

Stefan Ghetu <stefan.ghetu@nxp.com>
    ASoC: fsl_easrc: fix context ownership on repeated hw_params

Stefan Ghetu <stefan.ghetu@nxp.com>
    ASoC: fsl_asrc: fix pair ownership on repeated or failed hw_params

Binbin Deng <18983559317@163.com>
    btrfs: wait for a grace period before freeing a new device

Filipe Manana <fdmanana@suse.com>
    btrfs: send: fix invalid access to inline extents in clone_range()

Filipe Manana <fdmanana@suse.com>
    btrfs: send: fix missing hole punching during incremental send

Eric Dumazet <edumazet@kernel.org>
    tun: flush uc and mc addresses in TUNSETLINK

Randy Dunlap <rdunlap@infradead.org>
    chardev: GPIO common access methods: repair non-kernel-doc comment

Anastasia Eskova <anastasia.eskova@ibm.com>
    s390/cert_store: Only allow the kernel to create cert_store_key keys

Anastasia Eskova <anastasia.eskova@ibm.com>
    s390/cert_store: Allocate keyring with link restriction

Zhu Jun <zhujun2@cmss.chinamobile.com>
    tools: gpio: Return success after monitoring requested events

Zhu Jun <zhujun2@cmss.chinamobile.com>
    tools: gpio: Preserve device listing errors in lsgpio

Zhu Jun <zhujun2@cmss.chinamobile.com>
    tools: gpio-hammer: Accept the maximum number of line offsets

Antonio Quartulli <antonio@mandelbit.com>
    tun: complete the zerocopy buffer of packets consumed by XDP

Eduardo Mucelli Rezende Oliveira <edumucelli@gmail.com>
    tools/bootconfig: Use the registered global tracing parameter names

Kai Vehmanen <kai.vehmanen@linux.intel.com>
    ALSA: hda: intel: Release i915 power also when delayed probe fails

Petr Oros <poros@redhat.com>
    ice: allow reading the last byte of the NVM and Shadow RAM regions

Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
    ice: use global queue index in TC to-queue offload

Uri Dar <udar@nvidia.com>
    net/mlx5: E-Switch, skip vport change work for disabled vports

Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
    net: do not run out of frags in alloc_skb_with_frags()

Han Gao <gaohan@iscas.ac.cn>
    riscv: efi: Map runtime MMIO with device attributes

Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
    net: qrtr: ns: keep notifying local servers after a failed send

Xiangwu Lai <laixiangwu@cmss.chinamobile.com>
    scsi: ufs-mediatek: Restore the M-PHY power state when va09 disable fails

Yevgeny Kliteynik <kliteyn@nvidia.com>
    net/mlx5: DR, Fix out-of-bounds write when sync to HW fails

Eric Dumazet <edumazet@kernel.org>
    net: clear skb->mac_len in skb_unset_mac_header()

Gal Pressman <gal@nvidia.com>
    net/mlx5e: Release FIB event work flows before dropping RTNL

Imre Kaloz <kaloz@kernel.org>
    net: marvell: prestera: disable port before changing its MAC mode

Jiayuan Chen <jiayuan.chen@linux.dev>
    ipv6, calipso: fix data-race in calipso_cache_add() bucketsize check

Takashi Iwai <tiwai@suse.de>
    ALSA: pcm: Fix potential ABBA deadlock at snd_pcm_action_nonatomic()

Thomas de Gruijter <thomasdegruijter@pm.me>
    Bluetooth: MSFT: Only enable the advertisement filter with monitors

Thomas de Gruijter <thomasdegruijter@pm.me>
    Bluetooth: MSFT: Record the filter state on Command Disallowed

Jiale Yao <yaojiale02@163.com>
    usb: cdns3: report endpoint reset timeout

Sang-Hoon Choi <csh0052@gmail.com>
    HID: nintendo: release the player ID when LED setup fails

Eren Çakar <hey@erencakar.com>
    HID: letsketch: skip string descriptors the firmware does not implement

Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
    HID: sensor-hub: Remove clients before stopping hardware

Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
    HID: sensor: custom: Register enable attribute after misc device

Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
    HID: sensor: custom: Serialize misc device reads

Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
    HID: sensor: custom: Fix state lifetime during removal

Shunbo Shi <shishunbo@cmss.chinamobile.com>
    usb: gadget: f_hid: fix get_req leak when usb_gstrings_attach() fails

Shunbo Shi <shishunbo@cmss.chinamobile.com>
    usb: gadget: f_hid: fix race between userspace report update and GET_REPORT response

Shunbo Shi <shishunbo@cmss.chinamobile.com>
    usb: gadget: f_hid: fix report_list entries leak

Koichiro Den <den@valinux.co.jp>
    dmaengine: rcar-dmac: Add missing dma_descriptor_unmap()

Zhang Shurong <zhang_shurong@foxmail.com>
    dmaengine: rcar-dmac: Fix PM usage counter imbalance

SeungUk Nam <tmddnr49449@gmail.com>
    dmaengine: idxd: Free the minor number when cdev setup fails

Xiangwu Lai <laixiangwu@cmss.chinamobile.com>
    dmaengine: stm32-mdma: Fix runtime PM reference leak in pm_suspend

Terrence Adams <tadamsjr@google.com>
    scsi: pm8001: Offset hardware queue index for MSI-X pre-vector

Kordian Chmielewski <kudzo51@gmail.com>
    net: bcm4908_enet: order the TX ring index accesses

Kordian Chmielewski <kudzo51@gmail.com>
    net: bcm4908_enet: publish the buffer address before OWN

Kordian Chmielewski <kudzo51@gmail.com>
    net: bcm4908_enet: unmap RX buffers on stop with their mapped size

Kordian Chmielewski <kudzo51@gmail.com>
    net: bcm4908_enet: unmap the buffer of a dropped RX frame

Kordian Chmielewski <kudzo51@gmail.com>
    net: bcm4908_enet: release the TX ring on stop

Kordian Chmielewski <kudzo51@gmail.com>
    net: bcm4908_enet: drop a TX frame whose DMA mapping failed

Kordian Chmielewski <kudzo51@gmail.com>
    net: bcm4908_enet: fix the TX ring wrap

Artemii Mashanov <ralerrdirsardx@gmail.com>
    cxgb4: allocate the full ethtool filter location array

Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
    HID: sensor: custom: Disable sensor before hub close on removal

Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
    HID: sensor: custom: Set owner for misc device

Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
    HID: sensor-hub: Synchronize callback removal with raw events

Myeonghun Pak <mhun512@gmail.com>
    HID: magicmouse: disable the multitouch work on removal

Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Bluetooth: hci_core: Don't fail removing a monitor unknown to the controller

Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Bluetooth: MSFT: Free the response of the monitor commands

Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Bluetooth: hci_core: Hold hdev->lock when removing advertisement monitors

Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Bluetooth: MSFT: Protect the event prefix with hdev->lock

Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Bluetooth: MGMT: Fix use-after-free in mgmt_powering_down()

Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Bluetooth: mgmt: Fix mesh transmission locking and lifetime

Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Bluetooth: L2CAP: Don't use uninitialized EFS in l2cap_parse_conf_rsp()

Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Bluetooth: mgmt: Reject zero multi advertising rotation duration

Heiko Carstens <hca@linux.ibm.com>
    s390/cert_store: Initialize ism array in query_diag320_subcodes()

Heiko Carstens <hca@linux.ibm.com>
    s390/cert_store: Fix out-of-bounds read in pr_dbf_vce()

Heiko Carstens <hca@linux.ibm.com>
    s390/cert_store: Fix max_vcxe_length output in pr_dbf_vcssb()

Heiko Carstens <hca@linux.ibm.com>
    s390/cert_store: Validate hash length in check_certificate_valid()

Heiko Carstens <hca@linux.ibm.com>
    s390/cert_store: Do not search the process keyrings for the cert_store keyring

Heiko Carstens <hca@linux.ibm.com>
    s390/cert_store: Fix keyring refcount handling in get_user_session_keyring()

Heiko Carstens <hca@linux.ibm.com>
    s390/cert_store: Fix error handling of get_user_session_keyring()

Heiko Carstens <hca@linux.ibm.com>
    s390/cert_store: Remove unnecessary static specifier in create_cs_keyring()

Heiko Carstens <hca@linux.ibm.com>
    s390/cert_store: Fix potential use-after-free caused by find_cs_keyring()

Heiko Carstens <hca@linux.ibm.com>
    s390/cert_store: Fix cs_keyring reference leak in fill_cs_keyring()

Heiko Carstens <hca@linux.ibm.com>
    s390/cert_store: Check key_lookup() return code in invalidate_keyring_keys()

Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Bluetooth: hci_event: Validate sent command length in LE Set Ext Adv Enable

Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Bluetooth: SMP: Don't create the BR/EDR channel while unregistered

Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Bluetooth: SMP: Check smp_data before using SMP_DEV()

Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Bluetooth: SMP: Serialize link key updates from smp_notify_keys()

Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Bluetooth: hci_event: Fix not using key encryption size when its known

Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Bluetooth: hci_sync: Hold hdev->lock in hci_schedule_adv_instance_sync()

Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Bluetooth: hci_sync: Lock the lookup in hci_disable_ext_adv_instance_sync()

Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Bluetooth: hci_core: Take req_sync lock in hci_power_on()

Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Bluetooth: mgmt: Fix read_index_list() buffer overflow

Shawn Lin <shawn.lin@rock-chips.com>
    phy: rockchip: snps-pcie3: Raise the SRAM init timeout

Changyul Lee <lcy8047@gmail.com>
    scsi: ch: Remove the minor from ch_index_idr after device_destroy()

Kyle Mahlkuch <kmahlkuc@linux.ibm.com>
    scsi: lpfc: Fix race conditions in ELS retry handling

Michail Andreas Michalopoulos <mike.michalo@gmail.com>
    ksmbd: sign the last response of a compound that ends early

Hongling Zeng <zenghongling@kylinos.cn>
    phy: ti-pipe3: Fix clock leaks in init/exit error paths

Hongling Zeng <zenghongling@kylinos.cn>
    phy: ti-pipe3: Fix EPROBE_DEFER handling for clock resources

Hongling Zeng <zenghongling@kylinos.cn>
    phy: ti: pipe3: Fix clock resource leak on probe errors

Hongling Zeng <zenghongling@kylinos.cn>
    phy: ti-pipe3: Fix ignored clock enable return value in init

Felix Gu <ustc.gu@gmail.com>
    phy: ingenic: fix unbalanced regulator disable in exit

Sasha Levin <sashal@kernel.org>
    selftests: drivers/s390x: Select uvdevice tests using the target architecture

Bart Van Assche <bvanassche@acm.org>
    drm/msm: Fix a lock leak in msm_ioctl_gem_info_set_metadata()

Colton Lewis <coltonlewis@google.com>
    irqchip/gic-v4: Use a separate lockdep class for vPE doorbell IRQs

Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
    reset: scmi: Set the device for the reset controller

Fuad Tabba <fuad.tabba@linux.dev>
    irqchip/gic-v4: Unwind what its_alloc_vcpu_irqs() allocated on failure

Fuad Tabba <fuad.tabba@linux.dev>
    irqchip/gic-v4: Clear the domain and fwnode pointers after freeing them

Selby Mashiki <mashikiselby@gmail.com>
    memory: tegra: fix device_node leak in tegra186_mc_probe_device()

Myeonghun Pak <mhun512@gmail.com>
    memory: tegra: Shut down Tegra210 EMC timers before teardown

Oleg Keri <okerixx@gmail.com>
    soundwire: qcom: disable the interrupt before gating the clock

Sudeep Holla <sudeep.holla@kernel.org>
    firmware: arm_scmi: Unregister notifier on enable failure

Sudeep Holla <sudeep.holla@kernel.org>
    firmware: arm_scmi: imx: Validate MISC control response size

Zhengping Jiang <jiangzp@google.com>
    HID: vivaldi: avoid redundant feature report reads per usage

Shashikirana H K <shashikiranah@chromium.org>
    HID: vivaldi: Extract feature report value directly in vivaldi_feature_mapping()

Julian Braha <julianbraha@gmail.com>
    firmware: smccc: Provide stubs for HAVE_ARM_SMCCC_DISCOVERY=n

Geert Uytterhoeven <geert+renesas@glider.be>
    firmware: arm_scmi: Update ARM_SCMI_HAVE_TRANSPORT rationale

Jeff Johnson <jeff.johnson@oss.qualcomm.com>
    Revert "wifi: ath10k: Stop unanswered temperature reads"

Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
    iio: inv_sensors: do not compute period estimation when updating odr

Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
    iio: inv_sensors: fix estimated value larger than interrupt timestamp

Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
    iio: inv_sensors: prevent timestamps going back in time in transitions

Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
    iio: inv_sensors: improve period measurement by using a longer delay

Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
    iio: inv_sensors: better timestamp alignment when using watermark

Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
    iio: inv_sensors: convert to kernel types

Shi Hao <i.shihao.999@gmail.com>
    iio: common: fix spelling mistakes in comments

Karan Sanghavi <karansanghvi98@gmail.com>
    iio: invensense: Prevent possible integer overflow while multiplication

Jocelyn Falempe <jfalempe@redhat.com>
    drm/ast: Handle framebuffer from dma-buf

Moksh Panicker <mokshpanicker.7@gmail.com>
    iio: light: apds9306: fix PM reference leak in apds9306_read_data()

Julian Anastasov <ja@ssi.bg>
    ipvs: honor the overload state and do not enter it forever

Julian Anastasov <ja@ssi.bg>
    ipvs: read flags and seqs in master atomically

Myeonghun Pak <mhun512@gmail.com>
    iio: proximity: hx9023s: Allocate trigger before requesting IRQ

Christopher Hoover <ch@murgatroid.com>
    iio: humidity: hid-sensor-humidity: Use per-instance callbacks

Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
    usb: dwc3: xilinx: unwind ZynqMP platform init on probe failure and remove

Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    devres: Add devm_is_action_added() helper

Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    devres: Move devm_*_action*() APIs to devres.h

Danilo Krummrich <dakr@kernel.org>
    devres: add devm_remove_action_nowarn()

Josef Bacik <josef@toxicpanda.com>
    w1: w1_therm: lock the list of slaves for the bulk read

Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
    usb: dwc3: xilinx: re-assert resets on ZynqMP init error paths

Sean Anderson <sean.anderson@linux.dev>
    usb: dwc3: Always deassert xilinx resets

Ihor Urazov <z0rc3r@gmail.com>
    usb: typec: ucsi: acpi: Assume UCSI 1.0 on HP ZBook 8 G2i 14

Josef Bacik <josef@toxicpanda.com>
    serial: core: respect runtime PM when sending x_char

Paulo Alcantara <pc@manguebit.org>
    smb: client: don't fail writeback preparation if the task is dying

Paulo Alcantara <pc@manguebit.org>
    smb: client: don't write back through O_DIRECT handles

Joseph Qi <joseph.qi@linux.alibaba.com>
    smb: client: hold server ref while queueing reconnect work

Daejun Park <daejun7.park@samsung.com>
    ovl: bump the impure dir version when linking a file with origin

Amir Goldstein <amir73il@gmail.com>
    ovl: fix leak of lowerdata redirect on ovl_get_inode() failure

Amir Goldstein <amir73il@gmail.com>
    ovl: do not read the flags of a put upper dentry in lookup

Christian Brauner <brauner@kernel.org>
    ovl: refactor ovl_lookup()

Miklos Szeredi <mszeredi@redhat.com>
    ovl: make redirect/metacopy rejection consistent

Vinicius Costa Gomes <vinicius.gomes@intel.com>
    ovl: use wrapper ovl_revert_creds()

Takashi Iwai <tiwai@suse.de>
    Revert "ALSA: hda/realtek: Fix silent speaker on Higole F9B"

Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    ACPI: PM: Avoid initializing power management for absent devices

Christopher Hoover <ch@murgatroid.com>
    iio: temperature: hid-sensor-temperature: Use per-instance callbacks

Josef Bacik <josef@toxicpanda.com>
    iio: adc: ad7923: add the AD7927 to the SPI ID table

Daejun Park <daejun7.park@samsung.com>
    dm: fail a REQ_PREFLUSH bio with data when its preflush fails

Ming-Hung Tsai <mtsai@redhat.com>
    dm: fix use-after-free when dm_get_device() widens the open mode

Kirtikumar Anandrao Ramchandani <kirtiar15502@gmail.com>
    dm cache: validate the discard block size before narrowing

liuyong <pkfxxxing@gmail.com>
    smb: client: validate descriptor headers before query result allocation

Dan Carpenter <dan.carpenter@linaro.org>
    smb/client: Prevent error pointer dereference

Sasha Levin <sashal@kernel.org>
    selftests: net: reuseport_bpf_numa: include stdbool.h

Sasha Levin <sashal@kernel.org>
    Revert "mm/hugetlb_vmemmap: fix incorrect vmemmap restore in rollback"

Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
    Bluetooth: l2cap: defer conn param update to avoid conn->lock/hdev->lock inversion

Tejun Heo <tj@kernel.org>
    sched_ext: Fix ops.enqueue/dispatch() calls before ops.cpu_online()

Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    cpufreq: Fix updates of cached resolved frequency and index

Viresh Kumar <viresh.kumar@linaro.org>
    cpufreq: Avoid redundant target() calls for unchanged limits

Viresh Kumar <viresh.kumar@linaro.org>
    cpufreq: Introduce policy->boost_supported flag

Eric Dumazet <edumazet@google.com>
    vsock: do not leave dangling sk pointer in vsock_create()

Zihan Xi <zihanx@nebusec.ai>
    netfilter: nf_dup: preserve guard across NFQUEUE reinjection

Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    netfilter: nf_dup{4, 6}: Move duplication check to task_struct

Kuniyuki Iwashima <kuniyu@amazon.com>
    socket: Print pf->create() when it does not clear sock->sk on failure.

Ignat Korchagin <ignat@cloudflare.com>
    net: warn, if pf->create does not clear sock->sk on error

Masami Hiramatsu (Google) <mhiramat@kernel.org>
    kprobes: Switch ftrace ops when adding probe with post_handler

Masami Hiramatsu (Google) <mhiramat@kernel.org>
    kprobes: Use guard() for external locks

Masami Hiramatsu (Google) <mhiramat@kernel.org>
    jump_label: Define guard() for jump_label_lock

Thomas Weißschuh <thomas.weissschuh@linutronix.de>
    kprobes: Reduce preempt disable scope in check_kprobe_access_safe()

Masami Hiramatsu (Google) <mhiramat@kernel.org>
    kprobes: Validate re-registration earlier in register_kretprobe()

Zhao Li <enderaoelyther@gmail.com>
    Bluetooth: L2CAP: Only accept LE responses to outstanding requests

Vlastimil Babka (SUSE) <vbabka@kernel.org>
    mm/page_alloc: remove the zone_spans_pfn() check from get_pfnblock_bitmap_bitidx()

Gregory Price (Meta) <gourry@gourry.net>
    mm/page_alloc: don't undo another isolation in alloc_contig_range

Gregory Price (Meta) <gourry@gourry.net>
    mm/page_alloc: retry alloc_contig_pages() when the zonelist is rebuilt

Gregory Price <gourry@gourry.net>
    page_alloc: allow migration of smaller hugepages during contig_alloc

Masami Hiramatsu (Google) <mhiramat@kernel.org>
    kprobes: Fix error return and slot leak in __register_kprobe()

Gregory Price (Meta) <gourry@gourry.net>
    mm/hugetlb: retry the pool walk when the zonelist is rebuilt

Gregory Price (Meta) <gourry@gourry.net>
    mm/page_alloc: retry allocations that raced with a zonelist rebuild

Gregory Price (Meta) <gourry@gourry.net>
    mm/mmzone: read each zoneref slot once when filtering by nodemask

Wentao Liang <vulab@iscas.ac.cn>
    gpio: keep the chip reference when deferred setup fails

Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
    gpio: mvebu: fix sleeping-while-atomic in mvebu_gpio_level_irq_mask()

Rosen Penev <rosenp@gmail.com>
    gpio: mvebu: name regmaps to fix debugfs collisions

Zhao Li <enderaoelyther@gmail.com>
    wifi: mac80211_hwsim: ignore non-generic netlink releases

Ian Bridges <icb@fastmail.org>
    ksmbd: skip metadata-only opens in sharing checks

Seiji Nishikawa <snishika@redhat.com>
    sched/core: Do not touch SMT siblings that have not joined the core yet

Stefan Haberland <sth@linux.ibm.com>
    s390/dasd: Re-initialize RCD buffer with "V1.0" before every start

Stefan Haberland <sth@linux.ibm.com>
    s390/dasd: Fix typo 'immediatly' -> 'immediately'

Anton Lundin <glance@ac2.se>
    hwmon: (nct6775) Handle dual use registers

Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
    watchdog: rzv2h: Use pm_runtime_put_sync()

Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    watchdog: rz: Discard pm_runtime_put() return values

Tim Menninger <tmenninger@everpuredata.com>
    pNFS: avoid repeatedly cancelling I/O for the same lseg

Uladzislau Zhauniarovich <uladzislau.zhauniarovich@gmail.com>
    arm64: suspend: Only track cpuidle context for idle tasks

Ada Couprie Diaz <ada.coupriediaz@arm.com>
    arm64: suspend: rely on daif helpers to handle PMR

Waiman Long <longman@redhat.com>
    cgroup/cpuset: Correctly set isolated_cpus when switching partition state

Yingjie Wang <x-professor@outlook.com>
    tcp: free saved_syn after an RCU grace period

Eric Dumazet <edumazet@google.com>
    tcp: move __reqsk_free() out of line

Yuansheng Yang <0xbeac@gmail.com>
    KEYS: Protect pkey method checks against type removal

Mohammed EL Kadiri <med08elkadiri@gmail.com>
    keys: keyctl_pkey: replace BUG with return -EOPNOTSUPP

Jarkko Sakkinen <jarkko@kernel.org>
    KEYS: Expand key->{datalen,quotalen} to unsigned int

Arnav Kapoor <kapoorarnav43@gmail.com>
    iio: proximity: sx9360: fix sampling frequency write and available range

Kuniyuki Iwashima <kuniyu@google.com>
    ipv6: Remove IPV6_ADDRFORM.

Eduardo Mucelli Rezende Oliveira <edumucelli@gmail.com>
    tools/bootconfig: Close only opened braces in compact output

YuanZhe Liu <25031212351@stu.xidian.edu.cn>
    Bluetooth: btusb: fix use-after-free in force_poll_sync

Ian Abbott <abbotti@mev.co.uk>
    comedi: comedi_bond: Fix leak of opened device references

Masami Hiramatsu (Google) <mhiramat@kernel.org>
    tracing/probes: Fix BTF bitfield parsing and out-of-bounds buffer write

Wahid Khan <wahidzk0091@gmail.com>
    ksmbd: refuse to read a handle that is not open for reading

Jiwoo Kim <arpe1618@gmail.com>
    ksmbd: pin parent dentries in SMB2 CREATE ACL path

Eric Dumazet <edumazet@kernel.org>
    net: wait for in-flight device unregistrations before netns dismantle

Pin-yen Lin <treapking@google.com>
    gve: Block invalid ring sizes when device options are 0

Pin-yen Lin <treapking@google.com>
    gve: Fix race between stats query and queue reconfig

Tim Menninger <tmenninger@everpuredata.com>
    xprtrdma: serialize unmap_sync with xprt_disconnect

JP Kobryn <jp.kobryn@linux.dev>
    mm/page_alloc: use existing highatomic reserves on the buddy fastpath

Frank van der Linden <fvdl@google.com>
    mm/page_alloc: don't increase highatomic reserve after pcp alloc

Leon Hwang <leon.hwang@linux.dev>
    bpf: Disallow interpreter fallback for BPF_ADDR_PERCPU insn

Leon Hwang <leon.hwang@linux.dev>
    bpf: Disallow interpreter fallback for arena-related insns

Tiezhu Yang <yangtiezhu@loongson.cn>
    bpf: Reject programs with inlined helpers if JIT is not available

Tiezhu Yang <yangtiezhu@loongson.cn>
    bpf: Introduce jit_required flag and remove bpf_prog_has_kfunc_call()

Karl Mehltretter <kmehltretter@gmail.com>
    mtd: core: avoid double-free of OTP NVMEM device

Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Bluetooth: hci_core: Fix not checking skb length on hci_scodata_packet

Cosmin Ratiu <cratiu@nvidia.com>
    xfrm: Don't clobber inner headers when already set

Masami Hiramatsu (Google) <mhiramat@kernel.org>
    tracing/probes: Fix missing BTF kind checks in char pointer/array helpers

Masami Hiramatsu (Google) <mhiramat@kernel.org>
    tracing/probes: Enable newly appended probe when target event is enabled

Zhao Feng <zhaofeng2@cmss.chinamobile.com>
    watchdog: npcm: fix clock prepare leak when setting timeout on a running watchdog

Chen Ni <nichen@iscas.ac.cn>
    watchdog: npcm: Remove unnecessary NULL check before clk_prepare_enable/clk_disable_unprepare

Vishwaroop A <va@nvidia.com>
    spi: tegra210-quad: Track DMA mapping state

Hyunjung Ko <hj351016@gmail.com>
    tpm: flush timeout work outside buffer_mutex to avoid deadlock

Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    cpufreq: Improve suspend-resume synchronization

Rongzheng Wang <testwrzwrz@gmail.com>
    xsk: defer software checksum until the skb is complete

Shashank Mohan Jain <jain.sm@gmail.com>
    errseq: don't let errseq_check_and_advance() hide later errors

Zijun Hu <quic_zijuhu@quicinc.com>
    errseq: eliminate special limitation for macro MAX_ERRNO

Anfernee Cao <anferneemelokc5@gmail.com>
    mmc: sunxi: fix clock and runtime PM leaks on probe failure

Binbin Zhou <zhoubinbin@loongson.cn>
    mmc: sunxi: Use devm_mmc_alloc_host() helper

Runyu Xiao <runyu.xiao@seu.edu.cn>
    mmc: omap: synchronize clock timer before disabling fclk

Masami Hiramatsu (Google) <mhiramat@kernel.org>
    kprobes: Adopt guard() and scoped_guard()

Andrew Davison <andy@dvsn.net>
    ALSA: hda: Fix [codec] ID matching in patch files for IDs with bit 31 set

Olivier Louvignes <olivier@mgcrea.io>
    mmc: jz4740: Remove the host before resetting the controller

Arnav Kapoor <kapoorarnav43@gmail.com>
    iio: imu: inv_mpu6050: fix swapped accel and gyro startup times

Arnav Kapoor <kapoorarnav43@gmail.com>
    iio: proximity: sx9500: ignore event config writes that don't change state

Arnav Kapoor <kapoorarnav43@gmail.com>
    iio: common: scmi_sensors: fix truncating 64-bit divisions

Mark Bundschuh <mkbund@amazon.com>
    dm: fix infinite loop in dm_blk_do_report_zones()

Johannes Berg <johannes.berg@intel.com>
    wifi: mac80211: fix use-after-free on TTLM disconnect

Eric Dumazet <edumazet@kernel.org>
    net: gro: invalidate frag0 after a pull

Hyunwoo Kim <imv4bel@gmail.com>
    tcp: fix request_sock use-after-free during Fast Open accept()

Jeremy Harris <jgh@exim.org>
    tcp: fastopen: note that a child socket was created

Hyunwoo Kim <imv4bel@gmail.com>
    tcp: do not coalesce segments after FIN

Breno Leitao <leitao@debian.org>
    net/mlx5e: Fix queue stats access to queues without stats

Mahanta Jambigi <mjambigi@linux.ibm.com>
    net/smc: fix link group ownership in handshake abort

Chen Linxuan <me@black-desk.cn>
    pidfd: restrict task access ioctls to the caller's pid namespace

Gregory Price (Meta) <gourry@gourry.net>
    mm/page_alloc: snapshot the preferred zone against shrink rebuilds

Denis V. Lunev <den@openvz.org>
    virtio_balloon: quiesce balloon work before device shutdown

Denis V. Lunev <den@openvz.org>
    virtio_balloon: factor out virtballoon_quiesce()

Denis V. Lunev <den@openvz.org>
    virtio: add virtio_device_shutdown() helper

Michael S. Tsirkin <mst@redhat.com>
    virtgpu: don't reset on shutdown

Yuya Kusakabe <yuya.kusakabe@gmail.com>
    net: ipv6: keep room for the mac header in dst_dev_overhead()


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

Diffstat:

 Documentation/trace/boottime-trace.rst             |   8 +-
 Makefile                                           |   4 +-
 arch/arc/include/asm/io.h                          |  13 +-
 arch/arm64/boot/dts/st/stm32mp231.dtsi             |  16 +-
 arch/arm64/boot/dts/st/stm32mp233.dtsi             |   1 +
 arch/arm64/boot/dts/st/stm32mp251.dtsi             |  14 +
 arch/arm64/boot/dts/st/stm32mp253.dtsi             |   1 +
 arch/arm64/include/asm/kexec.h                     |   2 +
 arch/arm64/kernel/machine_kexec.c                  |   7 +-
 arch/arm64/kernel/relocate_kernel.S                |  11 +-
 arch/arm64/kernel/suspend.c                        |  23 +-
 arch/arm64/kernel/vmlinux.lds.S                    |   5 +-
 arch/parisc/kernel/entry.S                         |   4 -
 arch/parisc/kernel/ftrace.c                        |   2 +-
 arch/parisc/kernel/irq.c                           |   4 +-
 arch/powerpc/include/asm/hw_irq.h                  |   2 +-
 arch/powerpc/kernel/eeh.c                          |   6 +-
 arch/powerpc/kernel/module_32.c                    |   3 +
 arch/powerpc/kvm/book3s_64_mmu_hv.c                |  33 +-
 arch/powerpc/kvm/book3s_hv.c                       |   4 +-
 arch/powerpc/kvm/book3s_hv_nested.c                |  34 +-
 arch/powerpc/kvm/book3s_xive.c                     |   5 +-
 arch/powerpc/xmon/xmon.c                           |   3 +-
 arch/riscv/kernel/efi.c                            |   2 +-
 arch/riscv/kernel/entry.S                          |   6 +-
 arch/s390/appldata/appldata_base.c                 |  12 +-
 arch/s390/kernel/cert_store.c                      | 108 ++--
 arch/x86/kernel/apic/msi.c                         |   2 +-
 arch/x86/kernel/cpu/mce/core.c                     |  18 +-
 block/blk-iocost.c                                 |   3 +-
 block/blk-settings.c                               |   2 +-
 block/blk-sysfs.c                                  |  19 +-
 block/ioctl.c                                      |  13 +-
 drivers/acpi/device_pm.c                           |  23 +-
 drivers/acpi/glue.c                                |   8 +-
 drivers/ata/libata-scsi.c                          |   2 +-
 drivers/base/devres.c                              |  50 +-
 drivers/bluetooth/btusb.c                          |  10 +-
 drivers/bluetooth/hci_qca.c                        |   1 +
 drivers/char/tpm/tpm-dev-common.c                  |  12 +-
 drivers/comedi/drivers/comedi_bond.c               |  24 +-
 drivers/cpufreq/cppc_cpufreq.c                     |  14 +-
 drivers/cpufreq/cpufreq.c                          | 147 ++++--
 drivers/cpufreq/freq_table.c                       |   4 +
 drivers/cpufreq/intel_pstate.c                     |  26 +-
 drivers/crypto/nx/nx.c                             |   2 +-
 drivers/dma/idxd/cdev.c                            |   1 +
 drivers/dma/sh/rcar-dmac.c                         |   4 +-
 drivers/dma/stm32/stm32-mdma.c                     |   1 +
 drivers/edac/i5000_edac.c                          |   4 +-
 drivers/firmware/arm_scmi/notify.c                 |   4 +-
 drivers/firmware/arm_scmi/transports/Kconfig       |   2 +-
 .../firmware/arm_scmi/vendors/imx/imx-sm-misc.c    |  16 +-
 drivers/gpio/gpio-davinci.c                        |  12 +-
 drivers/gpio/gpio-ljca.c                           |  11 +-
 drivers/gpio/gpio-mvebu.c                          |  24 +-
 drivers/gpio/gpio-virtio.c                         |  13 +-
 drivers/gpio/gpiolib.c                             |  53 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c   |  13 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c            |  33 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c              |   7 +-
 drivers/gpu/drm/amd/amdgpu/soc21.c                 |   3 +
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c           |   2 +
 drivers/gpu/drm/amd/amdkfd/kfd_migrate.c           |  20 +-
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h              |   5 +
 .../gpu/drm/amd/amdkfd/kfd_process_queue_manager.c |  32 ++
 drivers/gpu/drm/amd/amdkfd/kfd_queue.c             |   4 +-
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c               |  65 ++-
 drivers/gpu/drm/amd/display/dc/core/dc.c           |   2 +
 .../drm/amd/display/modules/freesync/freesync.c    |  12 +-
 .../gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c    |  14 +-
 drivers/gpu/drm/ast/ast_mode.c                     |  11 +-
 drivers/gpu/drm/gud/gud_drv.c                      |  13 +-
 drivers/gpu/drm/i915/display/intel_ddi.c           |   4 +-
 drivers/gpu/drm/i915/i915_vma.c                    |   2 +-
 drivers/gpu/drm/i915/i915_vma_types.h              |   3 +
 drivers/gpu/drm/imagination/pvr_queue.c            |   3 +-
 drivers/gpu/drm/meson/meson_encoder_dsi.c          |   2 +-
 drivers/gpu/drm/msm/msm_drv.c                      |   3 +-
 drivers/gpu/drm/nouveau/nouveau_display.c          |  11 +-
 drivers/gpu/drm/nouveau/nouveau_sched.c            |   6 +-
 drivers/gpu/drm/radeon/radeon_atombios.c           |  22 +-
 drivers/gpu/drm/radeon/radeon_atpx_handler.c       |  13 +-
 drivers/gpu/drm/vc4/vc4_bo.c                       |  43 +-
 drivers/gpu/drm/vc4/vc4_drv.h                      |  15 +-
 drivers/gpu/drm/vc4/vc4_gem.c                      |  20 +-
 drivers/gpu/drm/vc4/vc4_v3d.c                      |   7 +-
 drivers/gpu/drm/vc4/vc4_validate.c                 |  15 +-
 drivers/gpu/drm/vc4/vc4_validate_shaders.c         |   7 +-
 drivers/gpu/drm/virtio/virtgpu_drv.c               |   9 +
 drivers/gpu/drm/vmwgfx/vmwgfx_bo.c                 |   3 +
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c            | 200 ++++++++
 drivers/gpu/drm/vmwgfx/vmwgfx_gem.c                |  11 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c      |  55 ++-
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c                |   5 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_msg.c                |  21 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c           |   1 +
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c            |  28 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_validation.h         |  13 +-
 drivers/hid/hid-letsketch.c                        |  21 +-
 drivers/hid/hid-magicmouse.c                       |   2 +-
 drivers/hid/hid-nintendo.c                         |   2 +-
 drivers/hid/hid-sensor-custom.c                    | 125 +++--
 drivers/hid/hid-sensor-hub.c                       |  27 +-
 drivers/hid/hid-vivaldi-common.c                   |  91 ++--
 drivers/hwmon/ads7871.c                            |   4 +-
 drivers/hwmon/dell-smm-hwmon.c                     |   9 +
 drivers/hwmon/nct6775-core.c                       |  16 +-
 drivers/hwmon/sht3x.c                              |   4 +-
 drivers/hwmon/w83791d.c                            |   4 +-
 drivers/hwmon/w83792d.c                            |   4 +-
 drivers/iio/adc/ad7923.c                           |   1 +
 .../iio/common/cros_ec_sensors/cros_ec_sensors.c   |   2 +-
 .../iio/common/hid-sensors/hid-sensor-attributes.c |   2 +-
 .../iio/common/inv_sensors/inv_sensors_timestamp.c | 134 +++--
 drivers/iio/common/ms_sensors/ms_sensors_i2c.c     |   2 +-
 drivers/iio/common/scmi_sensors/scmi_iio.c         |  27 +-
 drivers/iio/humidity/hid-sensor-humidity.c         |  14 +-
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c         |  80 ++-
 drivers/iio/light/apds9306.c                       |  19 +-
 drivers/iio/proximity/hx9023s.c                    |  16 +-
 drivers/iio/proximity/sx9360.c                     |  29 +-
 drivers/iio/proximity/sx9500.c                     |   6 +
 drivers/iio/temperature/hid-sensor-temperature.c   |  14 +-
 drivers/infiniband/hw/mlx5/devx.c                  |   6 +-
 drivers/infiniband/hw/mlx5/main.c                  |   3 +-
 drivers/infiniband/sw/siw/siw.h                    |   1 +
 drivers/infiniband/sw/siw/siw_mem.c                |   2 +-
 drivers/infiniband/ulp/rtrs/rtrs-clt.c             |   8 +-
 drivers/infiniband/ulp/srpt/ib_srpt.c              |  21 +-
 drivers/infiniband/ulp/srpt/ib_srpt.h              |   4 +-
 drivers/input/joystick/xpad.c                      |   1 +
 drivers/input/misc/da7280.c                        |   1 -
 drivers/input/mouse/cyapa.c                        |   4 +-
 drivers/input/mouse/trackpoint.c                   |   2 +
 drivers/input/mouse/trackpoint.h                   |   1 +
 drivers/input/touchscreen/goodix_fwupload.c        |   4 +-
 drivers/irqchip/irq-gic-v4.c                       |  39 +-
 drivers/md/dm-cache-target.c                       |  14 +-
 drivers/md/dm-ioctl.c                              |   2 +-
 drivers/md/dm-table.c                              | 146 +++---
 drivers/md/dm-zone.c                               |   2 +
 drivers/md/dm.c                                    |   6 +-
 drivers/md/dm.h                                    |  18 +-
 drivers/memory/tegra/tegra186.c                    |   1 +
 drivers/memory/tegra/tegra210-emc-core.c           |  16 +-
 drivers/mmc/host/jz4740_mmc.c                      |   5 +-
 drivers/mmc/host/omap.c                            |   4 +-
 drivers/mmc/host/sunxi-mmc.c                       |  36 +-
 drivers/mtd/mtdcore.c                              |   1 +
 drivers/net/dsa/b53/b53_common.c                   | 205 ++++++--
 drivers/net/dsa/b53/b53_priv.h                     |   4 +
 drivers/net/dsa/b53/b53_regs.h                     |   1 +
 drivers/net/dsa/b53/b53_srab.c                     |   2 +-
 drivers/net/dsa/bcm_sf2.c                          |   4 +
 drivers/net/dsa/ocelot/felix.c                     |  13 +-
 drivers/net/ethernet/broadcom/asp2/bcmasp.c        |   2 +-
 drivers/net/ethernet/broadcom/bcm4908_enet.c       | 143 ++++--
 drivers/net/ethernet/broadcom/bcmsysport.c         |  20 +-
 drivers/net/ethernet/broadcom/genet/bcmgenet.c     |  21 +-
 drivers/net/ethernet/broadcom/tg3.c                |  43 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c |   4 +-
 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c   |  28 +-
 drivers/net/ethernet/freescale/gianfar.c           |   1 +
 drivers/net/ethernet/google/gve/gve.h              |   5 +
 drivers/net/ethernet/google/gve/gve_adminq.c       |   4 +-
 drivers/net/ethernet/google/gve/gve_main.c         |  22 +-
 drivers/net/ethernet/intel/e1000/e1000_main.c      |   3 +-
 drivers/net/ethernet/intel/iavf/iavf_adminq.c      |   1 +
 drivers/net/ethernet/intel/ice/devlink/devlink.c   |   2 +-
 drivers/net/ethernet/intel/ice/ice_tc_lib.c        |   3 +-
 .../net/ethernet/marvell/prestera/prestera_main.c  |  17 +-
 .../ethernet/mellanox/mlx5/core/en/tc_tun_encap.c  |   2 +-
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c  |   5 +-
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c  |   3 +-
 .../mellanox/mlx5/core/steering/dr_icm_pool.c      |  32 +-
 drivers/net/ethernet/microchip/encx24j600.c        |   3 +-
 drivers/net/ethernet/qualcomm/qca_spi.c            |   4 +-
 .../net/ethernet/stmicro/stmmac/dwxgmac2_core.c    |   6 +-
 drivers/net/ethernet/stmicro/stmmac/enh_desc.c     |   8 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  |  14 +-
 drivers/net/hamradio/mkiss.c                       |   8 +
 drivers/net/tun.c                                  |  70 ++-
 drivers/net/usb/smsc75xx.c                         |   8 +
 drivers/net/wireless/ath/ath10k/core.c             |   1 -
 drivers/net/wireless/ath/ath10k/thermal.c          |   9 +-
 drivers/net/wireless/ath/ath10k/thermal.h          |   2 -
 drivers/net/wireless/realtek/rtw89/core.c          |  12 -
 drivers/net/wireless/virtual/mac80211_hwsim.c      |   2 +-
 drivers/nvme/common/auth.c                         |   6 +-
 drivers/nvme/host/core.c                           |   9 +
 drivers/nvme/host/multipath.c                      |   7 +
 drivers/nvme/host/sysfs.c                          |   3 +
 drivers/nvme/host/tcp.c                            | 172 +++++--
 drivers/nvme/target/fc.c                           |  13 +-
 drivers/nvme/target/io-cmd-file.c                  |  47 +-
 drivers/nvme/target/loop.c                         |   1 +
 drivers/nvme/target/tcp.c                          |  42 +-
 drivers/nvme/target/zns.c                          |   3 +-
 drivers/phy/ingenic/phy-ingenic-usb.c              |   1 -
 drivers/phy/rockchip/phy-rockchip-snps-pcie3.c     |   9 +-
 drivers/phy/ti/phy-ti-pipe3.c                      |  63 ++-
 drivers/reset/reset-scmi.c                         |   1 +
 drivers/s390/block/dasd.c                          |   5 +-
 drivers/s390/block/dasd_alias.c                    |   2 +-
 drivers/s390/block/dasd_eckd.c                     |  66 +--
 drivers/s390/block/dasd_int.h                      |  17 +-
 drivers/s390/block/dcssblk.c                       |   3 +-
 drivers/scsi/ch.c                                  |   6 +-
 drivers/scsi/device_handler/scsi_dh_rdac.c         |   6 +-
 drivers/scsi/lpfc/lpfc_els.c                       |  29 +-
 drivers/scsi/lpfc/lpfc_hbadisc.c                   |  11 +-
 drivers/scsi/mpi3mr/mpi3mr.h                       |   1 +
 drivers/scsi/mpi3mr/mpi3mr_fw.c                    |  18 +
 drivers/scsi/pm8001/pm8001_defs.h                  |   1 +
 drivers/scsi/pm8001/pm8001_init.c                  |  15 +-
 drivers/scsi/pm8001/pm80xx_hwi.c                   |  13 +-
 drivers/scsi/sd_zbc.c                              |   9 +-
 drivers/soundwire/qcom.c                           |   2 +
 drivers/spi/spi-tegra210-quad.c                    |  31 +-
 drivers/spi/spi.c                                  |   4 -
 drivers/target/iscsi/iscsi_target.c                |  22 +-
 drivers/target/iscsi/iscsi_target_nego.c           |   6 +-
 drivers/target/target_core_alua.c                  |   7 +
 drivers/target/target_core_configfs.c              |  16 +-
 drivers/tty/serial/serial_core.c                   |  25 +-
 drivers/tty/serial/serial_port.c                   |   4 +-
 drivers/ufs/core/ufs_bsg.c                         |   4 +-
 drivers/ufs/core/ufshcd-priv.h                     |   5 +
 drivers/ufs/core/ufshcd.c                          |   7 +-
 drivers/ufs/host/ufs-mediatek.c                    |  10 +
 drivers/usb/cdns3/cdns3-gadget.c                   |   6 +-
 drivers/usb/dwc3/dwc3-xilinx.c                     | 166 ++++---
 drivers/usb/gadget/function/f_hid.c                |  41 +-
 drivers/usb/gadget/function/f_uac1_legacy.c        |   8 +-
 drivers/usb/gadget/function/u_uac1_legacy.c        |  17 +-
 drivers/usb/typec/ucsi/ucsi.h                      |   1 +
 drivers/usb/typec/ucsi/ucsi_acpi.c                 |  34 ++
 drivers/vhost/net.c                                |   2 +-
 drivers/video/console/vgacon.c                     |   2 +
 drivers/video/fbdev/aty/radeon_base.c              |   3 +
 drivers/video/fbdev/fm2fb.c                        |   2 +-
 drivers/video/fbdev/macmodes.c                     |   2 +-
 drivers/video/fbdev/smscufx.c                      |  26 +-
 drivers/video/fbdev/sstfb.c                        |   3 +
 drivers/video/fbdev/valkyriefb.c                   |   3 +-
 drivers/video/fbdev/vfb.c                          |  18 +-
 drivers/virtio/virtio.c                            |  41 +-
 drivers/virtio/virtio_balloon.c                    |  34 +-
 drivers/w1/slaves/w1_therm.c                       |   8 +
 drivers/watchdog/npcm_wdt.c                        |  35 +-
 drivers/watchdog/rzg2l_wdt.c                       |   4 +-
 drivers/watchdog/rzv2h_wdt.c                       |   4 +-
 fs/btrfs/btrfs_inode.h                             |   6 +
 fs/btrfs/delayed-inode.c                           |  28 +-
 fs/btrfs/direct-io.c                               |  22 +-
 fs/btrfs/fiemap.c                                  |   2 +
 fs/btrfs/file.c                                    |   7 +-
 fs/btrfs/reflink.c                                 |  91 ++--
 fs/btrfs/send.c                                    |  98 +++-
 fs/btrfs/volumes.c                                 |   9 +-
 fs/crypto/keysetup.c                               |  14 +-
 fs/direct-io.c                                     |  15 +-
 fs/ext4/inline.c                                   |   6 +
 fs/ext4/xattr.c                                    |  12 +
 fs/fuse/dev.c                                      |   5 +-
 fs/fuse/readdir.c                                  |  22 +-
 fs/fuse/virtio_fs.c                                |   9 +-
 fs/fuse/xattr.c                                    |   2 +-
 fs/jbd2/journal.c                                  |   3 +
 fs/nfs/flexfilelayout/flexfilelayout.c             |  11 +
 fs/nfs/flexfilelayout/flexfilelayout.h             |   1 +
 fs/ocfs2/alloc.c                                   |   2 +-
 fs/ocfs2/dlmfs/userdlm.c                           |  12 +-
 fs/ocfs2/dlmglue.c                                 |  19 +-
 fs/ocfs2/inode.c                                   |  17 +-
 fs/ocfs2/journal.c                                 |  30 +-
 fs/ocfs2/journal.h                                 |  17 +-
 fs/ocfs2/mmap.c                                    |  12 +-
 fs/ocfs2/ocfs2.h                                   |   1 +
 fs/ocfs2/super.c                                   |   1 +
 fs/overlayfs/copy_up.c                             |   2 +-
 fs/overlayfs/dir.c                                 |  22 +-
 fs/overlayfs/file.c                                |  14 +-
 fs/overlayfs/inode.c                               |  20 +-
 fs/overlayfs/namei.c                               | 390 ++++++++-------
 fs/overlayfs/overlayfs.h                           |   1 +
 fs/overlayfs/readdir.c                             |   8 +-
 fs/overlayfs/util.c                                |   9 +-
 fs/overlayfs/xattrs.c                              |   9 +-
 fs/pidfs.c                                         |   8 +
 fs/smb/client/cifsacl.c                            |  12 +-
 fs/smb/client/cifsacl.h                            |  14 -
 fs/smb/client/cifsglob.h                           |   2 +
 fs/smb/client/file.c                               |  54 +-
 fs/smb/client/netmisc.c                            |   3 +-
 fs/smb/client/readdir.c                            |   3 +-
 fs/smb/client/smb2pdu.c                            |  28 +-
 fs/smb/server/smb2pdu.c                            |  82 +++-
 fs/smb/server/smb_common.c                         |  34 +-
 fs/smb/server/smb_common.h                         |   5 +
 fs/smb/server/smbacl.c                             |   9 +-
 fs/smb/server/vfs.c                                |   4 +
 fs/smb/server/vfs_cache.h                          |   2 +
 fs/xfs/xfs_bmap_util.c                             |  11 +-
 fs/xfs/xfs_rtalloc.c                               |   6 +-
 fs/zonefs/file.c                                   |   9 +-
 include/asm-generic/tlb.h                          |   6 +-
 include/linux/arm-smccc.h                          |   7 +
 include/linux/blkdev.h                             |   2 +-
 include/linux/bpf.h                                |  31 +-
 include/linux/cpufreq.h                            |   9 +
 include/linux/device.h                             |  22 -
 include/linux/device/devres.h                      |  41 ++
 include/linux/filter.h                             |  14 +-
 include/linux/firmware/imx/sm.h                    |   6 +
 include/linux/iio/common/inv_sensors_timestamp.h   |  43 +-
 include/linux/jump_label.h                         |   3 +
 include/linux/key.h                                |   4 +-
 include/linux/mm.h                                 |  91 +++-
 include/linux/net.h                                |   2 +-
 include/linux/netfilter.h                          |  11 -
 include/linux/nsc_gpio.h                           |   2 +-
 include/linux/pagemap.h                            |  66 ++-
 include/linux/perf_event.h                         |   1 +
 include/linux/sched.h                              |   1 +
 include/linux/skbuff.h                             |   2 +
 include/linux/tcp.h                                |   9 +-
 include/linux/virtio.h                             |   4 +
 include/net/ax25.h                                 |   1 +
 include/net/bluetooth/hci_core.h                   |  10 +-
 include/net/bluetooth/l2cap.h                      |   1 +
 include/net/codel.h                                |   5 +
 include/net/codel_impl.h                           |  16 +-
 include/net/dropreason-core.h                      |   6 +
 include/net/dst.h                                  |   3 +-
 include/net/gro.h                                  |  10 +
 include/net/inet_hashtables.h                      |   2 +
 include/net/ip_vs.h                                |   2 +-
 include/net/net_debug.h                            |   4 +-
 include/net/net_namespace.h                        |   1 +
 include/net/netfilter/nf_queue.h                   |   1 +
 include/net/netrom.h                               |   1 +
 include/net/request_sock.h                         |  12 +-
 include/net/rose.h                                 |   1 +
 include/net/tls.h                                  |   2 +
 include/scsi/scsi_proto.h                          |   3 +
 kernel/bpf/btf.c                                   |  26 +-
 kernel/bpf/cgroup.c                                |   4 +
 kernel/bpf/core.c                                  |  12 +-
 kernel/bpf/helpers.c                               |  41 +-
 kernel/bpf/inode.c                                 |   5 +-
 kernel/bpf/syscall.c                               |  33 +-
 kernel/bpf/verifier.c                              |  28 +-
 kernel/cgroup/cpuset.c                             |  19 +-
 kernel/dma/coherent.c                              |  11 +-
 kernel/dma/swiotlb.c                               |  20 +-
 kernel/events/core.c                               |  44 +-
 kernel/kprobes.c                                   | 545 ++++++++++-----------
 kernel/rcu/tree_nocb.h                             |   6 +-
 kernel/sched/core.c                                |   9 +-
 kernel/sched/core_sched.c                          |   3 +-
 kernel/sched/ext.c                                 | 135 ++---
 kernel/sched/sched.h                               |  26 +-
 kernel/trace/bpf_trace.c                           |   4 +
 kernel/trace/trace.c                               |   8 +-
 kernel/trace/trace.h                               |   2 +
 kernel/trace/trace_events_filter.c                 |  81 ++-
 kernel/trace/trace_events_hist.c                   |  25 +-
 kernel/trace/trace_events_trigger.c                |   2 +
 kernel/trace/trace_events_user.c                   |  12 +
 kernel/trace/trace_osnoise.c                       |   8 +
 kernel/trace/trace_probe.c                         |  67 ++-
 kernel/trace/trace_recursion_record.c              |  17 +-
 kernel/trace/trace_uprobe.c                        |  56 ++-
 kernel/workqueue.c                                 |   9 +
 lib/errseq.c                                       |  42 +-
 lib/maple_tree.c                                   | 120 ++++-
 lib/test_xarray.c                                  |  70 +++
 lib/xarray.c                                       |   8 +-
 mm/damon/core.c                                    |   5 +-
 mm/damon/tests/sysfs-kunit.h                       |   9 +
 mm/filemap.c                                       |  36 +-
 mm/gup.c                                           |  32 +-
 mm/huge_memory.c                                   |  10 +
 mm/hugetlb.c                                       |  13 +-
 mm/hugetlb_vmemmap.c                               |  36 +-
 mm/internal.h                                      |  23 +-
 mm/khugepaged.c                                    |   6 +
 mm/memory.c                                        |  39 +-
 mm/migrate.c                                       |  15 +
 mm/mmu_gather.c                                    |  10 +-
 mm/mmzone.c                                        |   9 +-
 mm/page_alloc.c                                    | 212 ++++++--
 mm/shmem.c                                         |   7 +-
 mm/userfaultfd.c                                   |   4 +
 mm/util.c                                          |  26 +
 net/ax25/af_ax25.c                                 |   9 +
 net/ax25/ax25_std_timer.c                          |  11 +-
 net/ax25/ax25_subr.c                               |  27 +
 net/bluetooth/hci_conn.c                           | 129 ++++-
 net/bluetooth/hci_core.c                           |  96 +++-
 net/bluetooth/hci_event.c                          |  82 ++--
 net/bluetooth/hci_sync.c                           |  31 +-
 net/bluetooth/l2cap_core.c                         |  95 ++--
 net/bluetooth/mgmt.c                               | 337 ++++++++++---
 net/bluetooth/mgmt_config.c                        |  10 +-
 net/bluetooth/mgmt_util.c                          |  23 +-
 net/bluetooth/msft.c                               | 118 +++--
 net/bluetooth/smp.c                                |  37 +-
 net/bridge/br_input.c                              |  18 +-
 net/core/dev.c                                     |  42 +-
 net/core/filter.c                                  |  23 +-
 net/core/gro.c                                     |  20 +-
 net/core/skbuff.c                                  |  34 +-
 net/core/skmsg.c                                   |   4 +-
 net/core/sock.c                                    |   4 +-
 net/core/sock_reuseport.c                          |  16 +-
 net/ieee802154/socket.c                            |   4 +
 net/ipv4/af_inet.c                                 |   5 +-
 net/ipv4/esp4_offload.c                            |   1 +
 net/ipv4/inet_connection_sock.c                    |  31 +-
 net/ipv4/ip_fragment.c                             |   2 +
 net/ipv4/ip_input.c                                |   6 +
 net/ipv4/netfilter/ip_tables.c                     |   2 +-
 net/ipv4/netfilter/nf_dup_ipv4.c                   |   6 +-
 net/ipv4/tcp.c                                     |   1 +
 net/ipv4/tcp_fastopen.c                            |   1 +
 net/ipv4/tcp_input.c                               |   6 +-
 net/ipv4/tcp_ipv4.c                                |   2 +
 net/ipv4/udp_offload.c                             |   1 +
 net/ipv6/af_inet6.c                                |   8 +-
 net/ipv6/calipso.c                                 |   5 +-
 net/ipv6/esp6_offload.c                            |   1 +
 net/ipv6/ip6_fib.c                                 |  16 +-
 net/ipv6/ip6_input.c                               |   4 +
 net/ipv6/ip6mr.c                                   |   2 +-
 net/ipv6/ipv6_sockglue.c                           |  95 ----
 net/ipv6/mcast.c                                   |  10 +-
 net/ipv6/mcast_snoop.c                             |   3 +-
 net/ipv6/netfilter/ip6_tables.c                    |   2 +-
 net/ipv6/netfilter/nf_dup_ipv6.c                   |   6 +-
 net/ipv6/route.c                                   |  56 +--
 net/ipv6/udp.c                                     |   7 +-
 net/mac80211/mlme.c                                |  25 +-
 net/mac802154/llsec.c                              |   2 +
 net/mptcp/protocol.c                               |   3 +-
 net/netfilter/core.c                               |   3 -
 net/netfilter/ipvs/ip_vs_conn.c                    |   4 +-
 net/netfilter/ipvs/ip_vs_ctl.c                     |  30 +-
 net/netfilter/ipvs/ip_vs_ftp.c                     |  20 +-
 net/netfilter/ipvs/ip_vs_lblc.c                    |   8 +-
 net/netfilter/ipvs/ip_vs_lblcr.c                   |  13 +-
 net/netfilter/ipvs/ip_vs_sync.c                    |  42 +-
 net/netfilter/nf_queue.c                           |   1 +
 net/netfilter/nfnetlink_queue.c                    |  17 +-
 net/netrom/af_netrom.c                             |   7 +
 net/netrom/nr_in.c                                 | 107 ++--
 net/netrom/nr_out.c                                |  10 +
 net/netrom/nr_timer.c                              |   9 +-
 net/openvswitch/flow.c                             |   3 +-
 net/qrtr/ns.c                                      |  21 +-
 net/rose/af_rose.c                                 |   5 +
 net/rose/rose_in.c                                 |  16 +-
 net/rose/rose_out.c                                |  21 +
 net/rose/rose_timer.c                              |  10 +-
 net/sctp/ipv6.c                                    |   5 +-
 net/sctp/socket.c                                  |  12 +-
 net/smc/af_smc.c                                   |  11 +-
 net/smc/smc_core.c                                 |  78 ++-
 net/smc/smc_core.h                                 |   6 +-
 net/socket.c                                       |   6 +-
 net/sunrpc/xprtrdma/frwr_ops.c                     |  89 ++--
 net/sunrpc/xprtrdma/transport.c                    |   2 +
 net/sunrpc/xprtrdma/verbs.c                        |  16 +-
 net/sunrpc/xprtrdma/xprt_rdma.h                    |  10 +-
 net/tls/tls_device.c                               |  10 +-
 net/vmw_vsock/af_vsock.c                           |   1 +
 net/xdp/xsk.c                                      |  15 +-
 net/xfrm/xfrm_interface_core.c                     |   8 +
 net/xfrm/xfrm_output.c                             |  20 +-
 security/keys/big_key.c                            |  16 +-
 security/keys/key.c                                |   4 +
 security/keys/keyctl_pkey.c                        | 124 +++--
 security/keys/trusted-keys/trusted_core.c          |  15 +-
 security/selinux/hooks.c                           |   5 +-
 sound/core/oss/pcm_oss.c                           |   4 +-
 sound/core/pcm_native.c                            |  63 ++-
 sound/core/sound_oss.c                             |  35 +-
 sound/firewire/fcp.c                               |   5 +-
 sound/firewire/fireworks/fireworks_transaction.c   |   4 +-
 sound/pci/hda/hda_intel.c                          |   5 +-
 sound/pci/hda/hda_sysfs.c                          |   5 +-
 sound/pci/hda/patch_realtek.c                      |   1 -
 sound/soc/codecs/wm8962.c                          |   2 +-
 sound/soc/fsl/fsl_asrc.c                           |  22 +
 sound/soc/fsl/fsl_easrc.c                          |  10 +
 sound/soc/qcom/qdsp6/q6apm-dai.c                   |   3 +
 sound/soc/qcom/qdsp6/q6asm-dai.c                   |   3 +
 sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c          |  14 +-
 sound/soc/qcom/qdsp6/topology.c                    |   4 +-
 sound/soc/sof/control.c                            |   5 +
 sound/soc/sof/intel/lnl.c                          |  17 +-
 tools/bootconfig/main.c                            |  29 +-
 tools/bootconfig/samples/exp-good-mixed-kv1.bconf  |   7 +
 tools/bootconfig/samples/good-mixed-kv1.bconf      |   5 +
 tools/bootconfig/scripts/bconf2ftrace.sh           |  21 +-
 tools/bootconfig/scripts/ftrace2bconf.sh           |   5 +-
 tools/bootconfig/test-bootconfig.sh                |   6 +
 tools/gpio/gpio-event-mon.c                        |   4 +-
 tools/gpio/gpio-hammer.c                           |   4 +-
 tools/gpio/lsgpio.c                                |   3 +-
 tools/objtool/check.c                              |   4 +
 tools/perf/builtin-record.c                        |   4 +-
 tools/testing/selftests/cgroup/test_cpuset_prs.sh  |   7 +
 .../selftests/drivers/s390x/uvdevice/Makefile      |  19 +-
 tools/testing/selftests/landlock/fs_test.c         |  54 ++
 tools/testing/selftests/net/reuseport_bpf_numa.c   |   1 +
 518 files changed, 7652 insertions(+), 3223 deletions(-)



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 001/555] net: ipv6: keep room for the mac header in dst_dev_overhead()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
  2026-12-04 10:00 ` [PATCH 6.12 002/555] virtgpu: dont reset on shutdown Greg Kroah-Hartman
                   ` (553 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Andrea Mayer, Yuya Kusakabe,
	Justin Iurman, Gabriel Goller, Eric Dumazet, Jakub Kicinski,
	Sasha Levin

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

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

From: Yuya Kusakabe <yuya.kusakabe@gmail.com>

[ Upstream commit 87cd6b717e4069dca34e0866e57eaeb44d3b173e ]

The seg6, ioam6 and rpl lwtunnels size their skb_cow_head() request as
the length they are about to push plus dst_dev_overhead(), then push the
new headers and rebuild the mac header below them with
skb_mac_header_rebuild().  That rebuild needs skb->mac_len of headroom,
but dst_dev_overhead() leaves LL_RESERVED_SPACE() of the egress device,
16 bytes for plain Ethernet.

Where the mac header is longer than that, as it is on ingress through a
VLAN device with reorder_hdr off, the rebuild runs out of room:
skb_set_mac_header(skb, -skb->mac_len) computes a negative offset,
stores it unchecked in the u16 skb->mac_header, and the memmove that
follows writes skb->mac_len bytes about 64 KB past skb->head.
Forwarding plain ping6 traffic through such a device reproduces it on
all five seg6 encapsulation modes and on the rpl and ioam6 inline paths;
skb->mac_header comes back as 65534 on a 704-byte head.

Return the larger of the two.  The helper already returns skb->mac_len
when it has no dst, so this only makes the other branch agree, and it
covers every caller rather than each call site in turn.

Fixes: 40475b63761a ("net: ipv6: seg6_iptunnel: mitigate 2-realloc issue")
Fixes: dce525185bc9 ("net: ipv6: ioam6_iptunnel: mitigate 2-realloc issue")
Fixes: 985ec6f5e623 ("net: ipv6: rpl_iptunnel: mitigate 2-realloc issue")
Suggested-by: Andrea Mayer <andrea.mayer@uniroma2.it>
Signed-off-by: Yuya Kusakabe <yuya.kusakabe@gmail.com>
Reviewed-by: Justin Iurman <justin.iurman@gmail.com>
Reviewed-by: Gabriel Goller <g.goller@proxmox.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Andrea Mayer <andrea.mayer@uniroma2.it>
Link: https://patch.msgid.link/20260922-seg6-maclen-headroom-v3-1-7b2f982ef79d@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/net/dst.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/net/dst.h b/include/net/dst.h
index b3ac23e14adab..c5406f6a7f5a0 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -453,7 +453,8 @@ static inline unsigned int dst_dev_overhead(struct dst_entry *dst,
 					    struct sk_buff *skb)
 {
 	if (likely(dst))
-		return LL_RESERVED_SPACE(dst->dev);
+		return max_t(unsigned int, skb->mac_len,
+			     LL_RESERVED_SPACE(dst->dev));
 
 	return skb->mac_len;
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 002/555] virtgpu: dont reset on shutdown
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
  2026-12-04 10:00 ` [PATCH 6.12 001/555] net: ipv6: keep room for the mac header in dst_dev_overhead() Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
  2026-12-04 10:00 ` [PATCH 6.12 003/555] virtio: add virtio_device_shutdown() helper Greg Kroah-Hartman
                   ` (552 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Eric Auger, Eric Auger,
	Jocelyn Falempe, Michael S. Tsirkin, Dickson Wu, Sasha Levin

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

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

From: Michael S. Tsirkin <mst@redhat.com>

commit 183a08715af1491d381b4e22efd61578fbe05fa5 upstream.

It looks like GPUs are used after shutdown is invoked.
Thus, breaking virtio gpu in the shutdown callback is not a good idea -
guest hangs attempting to finish console drawing, with these warnings:

[   20.504464] WARNING: CPU: 0 PID: 568 at drivers/gpu/drm/virtio/virtgpu_vq.c:358 virtio_gpu_queue_ctrl_sgs+0x236/0x290 [virtio_gpu]
[   20.505685] Modules linked in: nft_fib_inet nft_fib_ipv4 nft_fib_ipv6 nft_fib nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_ct nft_chain_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 rfkill ip_set nf_tables nfnetlink vfat fat intel_rapl_msr intel_rapl_common intel_uncore_frequency_common nfit libnvdimm kvm_intel kvm rapl iTCO_wdt iTCO_vendor_support virtio_gpu virtio_dma_buf pcspkr drm_shmem_helper i2c_i801 drm_kms_helper lpc_ich i2c_smbus virtio_balloon joydev drm fuse xfs libcrc32c ahci libahci crct10dif_pclmul crc32_pclmul crc32c_intel libata virtio_net ghash_clmulni_intel net_failover virtio_blk failover serio_raw dm_mirror dm_region_hash dm_log dm_mod
[   20.511847] CPU: 0 PID: 568 Comm: kworker/0:3 Kdump: loaded Tainted: G        W         -------  ---  5.14.0-578.6675_1757216455.el9.x86_64 #1
[   20.513157] Hardware name: Red Hat KVM/RHEL, BIOS edk2-20241117-3.el9 11/17/2024
[   20.513918] Workqueue: events drm_fb_helper_damage_work [drm_kms_helper]
[   20.514626] RIP: 0010:virtio_gpu_queue_ctrl_sgs+0x236/0x290 [virtio_gpu]
[   20.515332] Code: 00 00 48 85 c0 74 0c 48 8b 78 08 48 89 ee e8 51 50 00 00 65 ff 0d 42 e3 74 3f 0f 85 69 ff ff ff 0f 1f 44 00 00 e9 5f ff ff ff <0f> 0b e9 3f ff ff ff 48 83 3c 24 00 74 0e 49 8b 7f 40 48 85 ff 74
[   20.517272] RSP: 0018:ff34f0a8c0787ad8 EFLAGS: 00010282
[   20.517820] RAX: 00000000fffffffb RBX: 0000000000000000 RCX: 0000000000000820
[   20.518565] RDX: 0000000000000000 RSI: ff34f0a8c0787be0 RDI: ff218bef03a26300
[   20.519308] RBP: ff218bef03a26300 R08: 0000000000000001 R09: ff218bef07224360
[   20.520059] R10: 0000000000008dc0 R11: 0000000000000002 R12: ff218bef02630028
[   20.520806] R13: ff218bef0263fb48 R14: ff218bef00cb8000 R15: ff218bef07224360
[   20.521555] FS:  0000000000000000(0000) GS:ff218bef7ba00000(0000) knlGS:0000000000000000
[   20.522397] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   20.522996] CR2: 000055ac4f7871c0 CR3: 000000010b9f2002 CR4: 0000000000771ef0
[   20.523740] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[   20.524477] DR3: 0000000000000000 DR6: 00000000fffe07f0 DR7: 0000000000000400
[   20.525223] PKRU: 55555554
[   20.525515] Call Trace:
[   20.525777]  <TASK>
[   20.526003]  ? show_trace_log_lvl+0x1c4/0x2df
[   20.526464]  ? show_trace_log_lvl+0x1c4/0x2df
[   20.526925]  ? virtio_gpu_queue_fenced_ctrl_buffer+0x82/0x2c0 [virtio_gpu]
[   20.527643]  ? virtio_gpu_queue_ctrl_sgs+0x236/0x290 [virtio_gpu]
[   20.528282]  ? __warn+0x7e/0xd0
[   20.528621]  ? virtio_gpu_queue_ctrl_sgs+0x236/0x290 [virtio_gpu]
[   20.529256]  ? report_bug+0x100/0x140
[   20.529643]  ? handle_bug+0x3c/0x70
[   20.530010]  ? exc_invalid_op+0x14/0x70
[   20.530421]  ? asm_exc_invalid_op+0x16/0x20
[   20.530862]  ? virtio_gpu_queue_ctrl_sgs+0x236/0x290 [virtio_gpu]
[   20.531506]  ? virtio_gpu_queue_ctrl_sgs+0x174/0x290 [virtio_gpu]
[   20.532148]  virtio_gpu_queue_fenced_ctrl_buffer+0x82/0x2c0 [virtio_gpu]
[   20.532843]  virtio_gpu_primary_plane_update+0x3e2/0x460 [virtio_gpu]
[   20.533520]  drm_atomic_helper_commit_planes+0x108/0x320 [drm_kms_helper]
[   20.534233]  drm_atomic_helper_commit_tail+0x45/0x80 [drm_kms_helper]
[   20.534914]  commit_tail+0xd2/0x130 [drm_kms_helper]
[   20.535446]  drm_atomic_helper_commit+0x11b/0x140 [drm_kms_helper]
[   20.536097]  drm_atomic_commit+0xa4/0xe0 [drm]
[   20.536588]  ? __pfx___drm_printfn_info+0x10/0x10 [drm]
[   20.537162]  drm_atomic_helper_dirtyfb+0x192/0x270 [drm_kms_helper]
[   20.537823]  drm_fbdev_shmem_helper_fb_dirty+0x43/0xa0 [drm_shmem_helper]
[   20.538536]  drm_fb_helper_damage_work+0x87/0x160 [drm_kms_helper]
[   20.539188]  process_one_work+0x194/0x380
[   20.539612]  worker_thread+0x2fe/0x410
[   20.540007]  ? __pfx_worker_thread+0x10/0x10
[   20.540456]  kthread+0xdd/0x100
[   20.540791]  ? __pfx_kthread+0x10/0x10
[   20.541190]  ret_from_fork+0x29/0x50
[   20.541566]  </TASK>
[   20.541802] ---[ end trace 0000000000000000 ]---

It looks like the shutdown is called in the middle of console drawing, so
we should either wait for it to finish, or let drm handle the shutdown.

This patch implements this second option:

Add an option for drivers to bypass the common break+reset handling.
As DRM is careful to flush/synchronize outstanding buffers, it looks like
GPU can just have a NOP there.

Reviewed-by: Eric Auger <eric.auger@redhat.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
Fixes: 8bd2fa086a04 ("virtio: break and reset virtio devices on device_shutdown()")
Cc: Eric Auger <eauger@redhat.com>
Cc: Jocelyn Falempe <jfalempe@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <8490dbeb6f79ed039e6c11d121002618972538a3.1744293540.git.mst@redhat.com>
[ adapted to 6.12: no reset_prepare/reset_done in struct virtio_driver, add only .shutdown ]
Signed-off-by: Dickson Wu <dickson.wu@certik.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpu/drm/virtio/virtgpu_drv.c | 9 +++++++++
 drivers/virtio/virtio.c              | 6 ++++++
 include/linux/virtio.h               | 3 +++
 3 files changed, 18 insertions(+)

diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c b/drivers/gpu/drm/virtio/virtgpu_drv.c
index 44d99e89bb9b6..92332f9d17963 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.c
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.c
@@ -126,6 +126,14 @@ static void virtio_gpu_remove(struct virtio_device *vdev)
 	drm_dev_put(dev);
 }
 
+static void virtio_gpu_shutdown(struct virtio_device *vdev)
+{
+	/*
+	 * drm does its own synchronization on shutdown.
+	 * Do nothing here, opt out of device reset.
+	 */
+}
+
 static void virtio_gpu_config_changed(struct virtio_device *vdev)
 {
 	struct drm_device *dev = vdev->priv;
@@ -160,6 +168,7 @@ static struct virtio_driver virtio_gpu_driver = {
 	.id_table = id_table,
 	.probe = virtio_gpu_probe,
 	.remove = virtio_gpu_remove,
+	.shutdown = virtio_gpu_shutdown,
 	.config_changed = virtio_gpu_config_changed
 };
 
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index 078e5483b22f4..8241024f0890b 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -391,6 +391,12 @@ static void virtio_dev_shutdown(struct device *_d)
 	if (!drv)
 		return;
 
+	/* If the driver has its own shutdown method, use that. */
+	if (drv->shutdown) {
+		drv->shutdown(dev);
+		return;
+	}
+
 	/*
 	 * Some devices get wedged if you kick them after they are
 	 * reset. Mark all vqs as broken to make sure we don't.
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index 3ad94d939d281..2759e2c24d6ea 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -204,6 +204,8 @@ size_t virtio_max_dma_size(const struct virtio_device *vdev);
  *    changes; may be called in interrupt context.
  * @freeze: optional function to call during suspend/hibernation.
  * @restore: optional function to call on resume.
+ * @shutdown: synchronize with the device on shutdown. If provided, replaces
+ *    the virtio core implementation.
  */
 struct virtio_driver {
 	struct device_driver driver;
@@ -219,6 +221,7 @@ struct virtio_driver {
 	void (*config_changed)(struct virtio_device *dev);
 	int (*freeze)(struct virtio_device *dev);
 	int (*restore)(struct virtio_device *dev);
+	void (*shutdown)(struct virtio_device *dev);
 };
 
 #define drv_to_virtio(__drv)	container_of_const(__drv, struct virtio_driver, driver)
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 003/555] virtio: add virtio_device_shutdown() helper
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
  2026-12-04 10:00 ` [PATCH 6.12 001/555] net: ipv6: keep room for the mac header in dst_dev_overhead() Greg Kroah-Hartman
  2026-12-04 10:00 ` [PATCH 6.12 002/555] virtgpu: dont reset on shutdown Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
  2026-12-04 10:00 ` [PATCH 6.12 004/555] virtio_balloon: factor out virtballoon_quiesce() Greg Kroah-Hartman
                   ` (551 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Denis V. Lunev,
	David Hildenbrand (Arm), Michael S. Tsirkin, Dickson Wu,
	Sasha Levin

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

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

From: Denis V. Lunev <den@openvz.org>

commit 0d8aebe089b4ba887e792884cf041ce9f1040ff4 upstream.

The generic virtio bus .shutdown handler, virtio_dev_shutdown(), breaks
and resets a device once it has established that the driver has no
.shutdown of its own. A driver that does implement .shutdown, to quiesce
its own activity first, still needs the same break and reset afterwards
and would otherwise have to open code it.

Factor the break + synchronize_cbs + reset sequence out of
virtio_dev_shutdown() into an exported virtio_device_shutdown() helper so
such drivers can reuse it instead of duplicating the core logic.

No functional change.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20260624140846.2616797-2-den@openvz.org>
[ adapted to 6.12: no virtio_irq_get_affinity(), put the helper above virtio_dev_shutdown() ]
Signed-off-by: Dickson Wu <dickson.wu@certik.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/virtio/virtio.c | 41 +++++++++++++++++++++++++++--------------
 include/linux/virtio.h  |  1 +
 2 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index 8241024f0890b..f70ae3a672f72 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -379,6 +379,32 @@ static void virtio_dev_remove(struct device *_d)
 	of_node_put(dev->dev.of_node);
 }
 
+/**
+ * virtio_device_shutdown - break and reset a device on shutdown
+ * @dev: the device
+ *
+ * Drivers with their own .shutdown method should quiesce their activity and
+ * then call this to stop the device the way the generic shutdown path does.
+ */
+void virtio_device_shutdown(struct virtio_device *dev)
+{
+	/*
+	 * Some devices get wedged if you kick them after they are
+	 * reset. Mark all vqs as broken to make sure we don't.
+	 */
+	virtio_break_device(dev);
+	/*
+	 * Guarantee that any callback will see vq->broken as true.
+	 */
+	virtio_synchronize_cbs(dev);
+	/*
+	 * As IOMMUs are reset on shutdown, this will block device access to memory.
+	 * Some devices get wedged if this happens, so reset to make sure it does not.
+	 */
+	dev->config->reset(dev);
+}
+EXPORT_SYMBOL_GPL(virtio_device_shutdown);
+
 static void virtio_dev_shutdown(struct device *_d)
 {
 	struct virtio_device *dev = dev_to_virtio(_d);
@@ -397,20 +423,7 @@ static void virtio_dev_shutdown(struct device *_d)
 		return;
 	}
 
-	/*
-	 * Some devices get wedged if you kick them after they are
-	 * reset. Mark all vqs as broken to make sure we don't.
-	 */
-	virtio_break_device(dev);
-	/*
-	 * Guarantee that any callback will see vq->broken as true.
-	 */
-	virtio_synchronize_cbs(dev);
-	/*
-	 * As IOMMUs are reset on shutdown, this will block device access to memory.
-	 * Some devices get wedged if this happens, so reset to make sure it does not.
-	 */
-	dev->config->reset(dev);
+	virtio_device_shutdown(dev);
 }
 
 static const struct bus_type virtio_bus = {
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index 2759e2c24d6ea..2d8820c0832af 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -180,6 +180,7 @@ int virtio_device_freeze(struct virtio_device *dev);
 int virtio_device_restore(struct virtio_device *dev);
 #endif
 void virtio_reset_device(struct virtio_device *dev);
+void virtio_device_shutdown(struct virtio_device *dev);
 
 size_t virtio_max_dma_size(const struct virtio_device *vdev);
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 004/555] virtio_balloon: factor out virtballoon_quiesce()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (2 preceding siblings ...)
  2026-12-04 10:00 ` [PATCH 6.12 003/555] virtio: add virtio_device_shutdown() helper Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
  2026-12-04 10:00 ` [PATCH 6.12 005/555] virtio_balloon: quiesce balloon work before device shutdown Greg Kroah-Hartman
                   ` (550 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Denis V. Lunev,
	David Hildenbrand (Arm), Michael S. Tsirkin, Dickson Wu,
	Sasha Levin

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

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

From: Denis V. Lunev <den@openvz.org>

commit 29536a923a9412812eb3e378258019b54538a220 upstream.

virtballoon_remove() stops all of the balloon's asynchronous work (the
free page reporting worker, the inflate/deflate and stats workers, the
OOM notifier and the free page shrinker) before tearing the device
down. A following change needs the same teardown from a .shutdown
handler, so move it into a virtballoon_quiesce() helper.

No functional change.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20260624140846.2616797-3-den@openvz.org>
Signed-off-by: Dickson Wu <dickson.wu@certik.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/virtio/virtio_balloon.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 5a093d8786b7f..a3b6e38752ab9 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -1120,26 +1120,39 @@ static void remove_common(struct virtio_balloon *vb)
 	vb->vdev->config->del_vqs(vb->vdev);
 }
 
-static void virtballoon_remove(struct virtio_device *vdev)
+/*
+ * Stop all asynchronous balloon work. The device must still be alive so that
+ * in-flight requests can drain via the host before it is reset or freed.
+ */
+static void virtballoon_quiesce(struct virtio_balloon *vb)
 {
-	struct virtio_balloon *vb = vdev->priv;
+	struct virtio_device *vdev = vb->vdev;
 
-	if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_REPORTING))
+	if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_REPORTING))
 		page_reporting_unregister(&vb->pr_dev_info);
-	if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_DEFLATE_ON_OOM))
+	if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_DEFLATE_ON_OOM))
 		unregister_oom_notifier(&vb->oom_nb);
-	if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT))
+	if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT))
 		virtio_balloon_unregister_shrinker(vb);
+
 	spin_lock_irq(&vb->stop_update_lock);
 	vb->stop_update = true;
 	spin_unlock_irq(&vb->stop_update_lock);
 	cancel_work_sync(&vb->update_balloon_size_work);
 	cancel_work_sync(&vb->update_balloon_stats_work);
 
-	if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) {
+	if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT))
 		cancel_work_sync(&vb->report_free_page_work);
+}
+
+static void virtballoon_remove(struct virtio_device *vdev)
+{
+	struct virtio_balloon *vb = vdev->priv;
+
+	virtballoon_quiesce(vb);
+
+	if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT))
 		destroy_workqueue(vb->balloon_wq);
-	}
 
 	remove_common(vb);
 	kfree(vb);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 005/555] virtio_balloon: quiesce balloon work before device shutdown
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (3 preceding siblings ...)
  2026-12-04 10:00 ` [PATCH 6.12 004/555] virtio_balloon: factor out virtballoon_quiesce() Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
  2026-12-04 10:00 ` [PATCH 6.12 006/555] mm/page_alloc: snapshot the preferred zone against shrink rebuilds Greg Kroah-Hartman
                   ` (549 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Denis V. Lunev,
	David Hildenbrand (Arm), Michael S. Tsirkin, Dickson Wu,
	Sasha Levin

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

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

From: Denis V. Lunev <den@openvz.org>

commit 7e17eef04600c399c7e0f5ce765da5cf9d40d8e1 upstream.

Commit 8bd2fa086a04 ("virtio: break and reset virtio devices on
device_shutdown()") added a generic virtio bus .shutdown handler that
breaks and resets every virtio device during device_shutdown(), i.e. on
reboot and kexec.

virtio_balloon provides no .shutdown of its own, so that generic path
runs while the balloon's asynchronous work is still armed. Once the
device has been broken, virtqueue_add_inbuf() in
virtballoon_free_page_report() returns -EIO and trips its
WARN_ON_ONCE(). On a kernel booted with panic_on_warn that turns an
ordinary reboot, for example a kexec based upgrade, into a fatal panic
in the middle of device_shutdown(), so the machine never reaches the
new kernel.

Relaxing that single WARN_ON_ONCE() would only hide the symptom: the
inflate/deflate and OOM paths do not warn, they call
wait_event(vb->acked, ...) and would instead block forever on a broken
queue that can no longer complete. The device has to be quiesced, not
just kept quiet.

Add a .shutdown handler that quiesces the balloon via the shared
virtballoon_quiesce() helper while the device is still alive, and only
then breaks and resets it via virtio_device_shutdown(). Unlike
virtballoon_remove() the balloon workqueue is not destroyed, as shutdown
does not free the device and cancel_work_sync() together with stop_update
already prevent any further work from being queued.

Fixes: 8bd2fa086a04 ("virtio: break and reset virtio devices on device_shutdown()")
Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20260624140846.2616797-4-den@openvz.org>
Signed-off-by: Dickson Wu <dickson.wu@certik.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/virtio/virtio_balloon.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index a3b6e38752ab9..14443e66d118a 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -1158,6 +1158,12 @@ static void virtballoon_remove(struct virtio_device *vdev)
 	kfree(vb);
 }
 
+static void virtballoon_shutdown(struct virtio_device *vdev)
+{
+	virtballoon_quiesce(vdev->priv);
+	virtio_device_shutdown(vdev);
+}
+
 #ifdef CONFIG_PM_SLEEP
 static int virtballoon_freeze(struct virtio_device *vdev)
 {
@@ -1228,6 +1234,7 @@ static struct virtio_driver virtio_balloon_driver = {
 	.validate =	virtballoon_validate,
 	.probe =	virtballoon_probe,
 	.remove =	virtballoon_remove,
+	.shutdown =	virtballoon_shutdown,
 	.config_changed = virtballoon_changed,
 #ifdef CONFIG_PM_SLEEP
 	.freeze	=	virtballoon_freeze,
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 006/555] mm/page_alloc: snapshot the preferred zone against shrink rebuilds
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (4 preceding siblings ...)
  2026-12-04 10:00 ` [PATCH 6.12 005/555] virtio_balloon: quiesce balloon work before device shutdown Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
  2026-12-04 10:00 ` [PATCH 6.12 007/555] pidfd: restrict task access ioctls to the callers pid namespace Greg Kroah-Hartman
                   ` (548 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Gregory Price (Meta),
	Vlastimil Babka (SUSE), Zi Yan, Sasha Levin

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

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

From: Gregory Price (Meta) <gourry@gourry.net>

[ Upstream commit b3e3a760eb68449e2794ef68ab212173d9c3e8c7 ]

get_page_from_freelist() and alloc_pages_bulk_noprof() reread
ac->preferred_zoneref->zone at every use. Offlining a zone's last block
rebuilds the zonelists in place, and the shrunk list's NULL terminator
can land on the preferred slot mid-walk:

  CPU 0                             CPU 1
  get_page_from_freelist(GFP_KERNEL | __GFP_THISNODE)
    zone = NORMAL (slot 1)
                                    offline_pages()
                                      build_all_zonelists()
                                        [MOVABLE, NORMAL, NULL]
                                        -> [NORMAL, NULL]
    rmqueue(zonelist_zone(slot 1), zone)
      zone_statistics(NULL, zone)

  BUG: kernel NULL pointer dereference, address: 0000000000000060
  RIP: 0010:get_page_from_freelist+0x6a5/0x15f0
  Call Trace:
   __alloc_frozen_pages_noprof+0x125/0x330

Read the slot once. Zones are never freed, so a stale zone is safe, and
a NULL slot fails the same way as walking off the end.

Fixes: 11cd8638c37f ("mm, page_alloc: remove stop_machine from build_all_zonelists")
Cc: stable@vger.kernel.org
Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Link: https://patch.msgid.link/20261101021340.2251928-7-gourry@gourry.net
Acked-by: Zi Yan <ziy@nvidia.com>
Signed-off-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
[ sashal: Dropped the !defrag_mode condition from the NOFRAGMENT locality check since this tree lacks defrag_mode, keeping the preferred_zone replacement. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 mm/page_alloc.c | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index e9aadaf6e91b6..dc4b0d58c4d0d 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3424,10 +3424,19 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags,
 {
 	struct zoneref *z;
 	struct zone *zone;
+	struct zone *preferred_zone;
 	struct pglist_data *last_pgdat = NULL;
 	bool last_pgdat_dirty_ok = false;
 	bool no_fallback;
 
+	/*
+	 * A concurrent zonelist rebuild can NULL or replace this slot. Zones
+	 * are never freed, so reading it once keeps a usable zone.
+	 */
+	preferred_zone = zonelist_zone(ac->preferred_zoneref);
+	if (!preferred_zone)
+		return NULL;
+
 retry:
 	/*
 	 * Scan zonelist, looking for a zone with enough free.
@@ -3474,7 +3483,7 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags,
 		}
 
 		if (no_fallback && nr_online_nodes > 1 &&
-		    zone != zonelist_zone(ac->preferred_zoneref)) {
+		    zone != preferred_zone) {
 			int local_nid;
 
 			/*
@@ -3482,7 +3491,7 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags,
 			 * fragmenting fallbacks. Locality is more important
 			 * than fragmentation avoidance.
 			 */
-			local_nid = zonelist_node_idx(ac->preferred_zoneref);
+			local_nid = zone_to_nid(preferred_zone);
 			if (zone_to_nid(zone) != local_nid) {
 				alloc_flags &= ~ALLOC_NOFRAGMENT;
 				goto retry;
@@ -3533,7 +3542,7 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags,
 				goto try_this_zone;
 
 			if (!node_reclaim_enabled() ||
-			    !zone_allows_reclaim(zonelist_zone(ac->preferred_zoneref), zone))
+			    !zone_allows_reclaim(preferred_zone, zone))
 				continue;
 
 			ret = node_reclaim(zone->zone_pgdat, gfp_mask, order);
@@ -3555,7 +3564,7 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags,
 		}
 
 try_this_zone:
-		page = rmqueue(zonelist_zone(ac->preferred_zoneref), zone, order,
+		page = rmqueue(preferred_zone, zone, order,
 				gfp_mask, alloc_flags, ac->migratetype);
 		if (page) {
 			prep_new_page(page, order, gfp_mask, alloc_flags);
@@ -4678,6 +4687,7 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
 	struct page *page;
 	unsigned long __maybe_unused UP_flags;
 	struct zone *zone;
+	struct zone *preferred_zone;
 	struct zoneref *z;
 	struct per_cpu_pages *pcp;
 	struct list_head *pcp_list;
@@ -4728,6 +4738,11 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
 		goto out;
 	gfp = alloc_gfp;
 
+	/* Read once; see get_page_from_freelist(). */
+	preferred_zone = zonelist_zone(ac.preferred_zoneref);
+	if (!preferred_zone)
+		goto failed;
+
 	/* Find an allowed local zone that meets the low watermark. */
 	z = ac.preferred_zoneref;
 	for_next_zone_zonelist_nodemask(zone, z, ac.highest_zoneidx, ac.nodemask) {
@@ -4738,8 +4753,8 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
 			continue;
 		}
 
-		if (nr_online_nodes > 1 && zone != zonelist_zone(ac.preferred_zoneref) &&
-		    zone_to_nid(zone) != zonelist_node_idx(ac.preferred_zoneref)) {
+		if (nr_online_nodes > 1 && zone != preferred_zone &&
+		    zone_to_nid(zone) != zone_to_nid(preferred_zone)) {
 			goto failed;
 		}
 
@@ -4747,7 +4762,7 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
 retry_this_zone:
 		mark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK) + nr_pages;
 		if (zone_watermark_fast(zone, 0,  mark,
-				zonelist_zone_idx(ac.preferred_zoneref),
+				zone_idx(preferred_zone),
 				alloc_flags, gfp)) {
 			break;
 		}
@@ -4809,7 +4824,7 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
 	pcp_trylock_finish(UP_flags);
 
 	__count_zid_vm_events(PGALLOC, zone_idx(zone), nr_account);
-	zone_statistics(zonelist_zone(ac.preferred_zoneref), zone, nr_account);
+	zone_statistics(preferred_zone, zone, nr_account);
 
 out:
 	return nr_populated;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 007/555] pidfd: restrict task access ioctls to the callers pid namespace
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (5 preceding siblings ...)
  2026-12-04 10:00 ` [PATCH 6.12 006/555] mm/page_alloc: snapshot the preferred zone against shrink rebuilds Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
  2026-12-04 10:00 ` [PATCH 6.12 008/555] net/smc: fix link group ownership in handshake abort Greg Kroah-Hartman
                   ` (547 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jann Horn, Christian Brauner,
	Chen Linxuan, Sasha Levin

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

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

From: Chen Linxuan <me@black-desk.cn>

[ Upstream commit ee8323fdc827c580425644db605a4be776cace57 ]

pidfds can cross pid namespace boundaries: a task may obtain one for a
process outside of its own pid namespace hierarchy through SO_PASSPIDFD
or SO_PEERPIDFD, via SCM_RIGHTS, or through file descriptor inheritance.

The namespace ioctls gate access with a ptrace check against the
target's credentials only. That check does not account for the pid
namespace relationship between the caller and the target, so a task
inside a pid namespace can use a pidfd obtained across that boundary to
acquire namespace file descriptors of a task outside of its hierarchy.

procfs exposes the equivalent information only for tasks visible in the
reader's pid namespace, and PIDFD_GET_INFO already answers with -EREMOTE
for targets outside the caller's hierarchy. Extend that policy to the
namespace ioctls: fail with -EREMOTE unless the target is visible in the
caller's active pid namespace. Callers in ancestor pid namespaces are
unaffected.

Unlike PIDFD_GET_INFO, the visibility check is performed after the task
lookup here, so reaped targets outside of the caller's pid namespace
hierarchy answer -ESRCH instead of -EREMOTE.

Link: https://lore.kernel.org/all/CAG48ez1T5-tUHVK_iHsgUtWa-inVdrZxA3E-ZCW0iENJvasKfg@mail.gmail.com
Link: https://lore.kernel.org/all/20260925-gewischt-auftrag-tierzucht-c153cb3f9f74@brauner
Suggested-by: Jann Horn <jannh@google.com>
Suggested-by: Christian Brauner <brauner@kernel.org>
Fixes: 5b08bd408534 ("pidfs: allow retrieval of namespace file descriptors")
Cc: stable@vger.kernel.org
Signed-off-by: Chen Linxuan <me@black-desk.cn>
Link: https://patch.msgid.link/20261027-pidfd-task-access-v1-1-d46cf0fa4ca1@black-desk.cn
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
[ sashal: Replaced the missing pid_in_current_pidns() helper with an equivalent pid_nr_ns(pid, task_active_pid_ns(current)) check, since that helper isn't in this tree. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/pidfs.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/fs/pidfs.c b/fs/pidfs.c
index b2dc613a64f6f..7a5efe86426bb 100644
--- a/fs/pidfs.c
+++ b/fs/pidfs.c
@@ -131,6 +131,14 @@ static long pidfd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	if (!task)
 		return -ESRCH;
 
+	/*
+	 * Require the target to be visible in the caller's pid namespace
+	 * for operations that grant access to its resources, mirroring
+	 * procfs and PIDFD_GET_INFO.
+	 */
+	if (!pid_nr_ns(pid, task_active_pid_ns(current)))
+		return -EREMOTE;
+
 	/*
 	 * We're trying to open a file descriptor to the namespace so perform a
 	 * filesystem cred ptrace check. Hold @task's exec_update_lock for the
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 008/555] net/smc: fix link group ownership in handshake abort
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (6 preceding siblings ...)
  2026-12-04 10:00 ` [PATCH 6.12 007/555] pidfd: restrict task access ioctls to the callers pid namespace Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
  2026-12-04 10:00 ` [PATCH 6.12 009/555] net/mlx5e: Fix queue stats access to queues without stats Greg Kroah-Hartman
                   ` (546 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Mahanta Jambigi, Jakub Kicinski,
	Sasha Levin

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

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

From: Mahanta Jambigi <mjambigi@linux.ibm.com>

[ Upstream commit e227b511582828c5a6513f70fc6a71211e5efbf0 ]

An aborted first-contact handshake can hang the handshake worker on the
socket lock it already holds, reset the clcsock of a socket that has
fallen back to TCP, or corrupt the alert-node lookup when the handshake
retries with the same connection.

The abort leaves a connection registered in a link group that another
context has already unlinked for termination: smc_conn_free() skips the
unregister when lgr->list is empty, so the alert token and alert node
stay in lgr->conns_all. If the handshake retries another device or SMC
version, smc_conn_create() creates a second link group and
smc_lgr_register_conn() inserts the same alert node into it: the token
loop is skipped, rb_link_node() links a node that is still in the old
tree into the new one, and a second sock_hold() is taken where only one
sock_put() will follow. The old group's terminator then keeps returning
that node from rb_first() and can kill a connection that now belongs to
the new group.

smc_lgr_cleanup_early() also starts a second termination of the link
group that is already being terminated, which takes lock_sock() on the
socket the handshake worker holds; if the termination work wins the race
instead, it later kills the freed connection and aborts the clcsock of a
socket that has fallen back to TCP. Making the unregister unconditional
also lets smc_conn_free() reach the delayed free work on a claimed link
group, where the lockless freeing check can arm it after the owner has
cancelled it.

Always unregister the connection, claim a link group for termination
once under lgr_lock, keep the link group alive across the abort, and arm
the delayed free work only under the same lock and cancel it
synchronously before the teardown. Drop an already freed connection in
smc_conn_kill() without running the connection and socket teardown.

Fixes: 2a0674fffb6b ("net/smc: improve abnormal termination of link groups")
Fixes: f9aab6f2ce57 ("net/smc: immediate freeing in smc_lgr_cleanup_early()")
Cc: stable@vger.kernel.org
Signed-off-by: Mahanta Jambigi <mjambigi@linux.ibm.com>
Link: https://patch.msgid.link/20261106130457.1092203-1-mjambigi@linux.ibm.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/smc/af_smc.c   | 11 ++++---
 net/smc/smc_core.c | 78 +++++++++++++++++++++++++++++++++-------------
 net/smc/smc_core.h |  6 ++--
 3 files changed, 65 insertions(+), 30 deletions(-)

diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 0d00fa56a9002..0adc46c691312 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -1010,14 +1010,15 @@ static void smc_conn_abort(struct smc_sock *smc, int local_first)
 {
 	struct smc_connection *conn = &smc->conn;
 	struct smc_link_group *lgr = conn->lgr;
-	bool lgr_valid = false;
-
-	if (smc_conn_lgr_valid(conn))
-		lgr_valid = true;
+	bool lgr_valid = local_first && smc_conn_lgr_valid(conn);
 
+	if (lgr_valid)
+		smc_lgr_hold(lgr);	/* lgr_put below */
 	smc_conn_free(conn);
-	if (local_first && lgr_valid)
+	if (lgr_valid) {
 		smc_lgr_cleanup_early(lgr);
+		smc_lgr_put(lgr);
+	}
 }
 
 /* check if there is a rdma device available for this connection. */
diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
index 1f340de96ec83..982c9cf39ba6a 100644
--- a/net/smc/smc_core.c
+++ b/net/smc/smc_core.c
@@ -80,16 +80,21 @@ static void smc_ibdev_cnt_dec(struct smc_link *lnk)
 
 static void smc_lgr_schedule_free_work(struct smc_link_group *lgr)
 {
+	spinlock_t *lgr_lock;
+
 	/* client link group creation always follows the server link group
 	 * creation. For client use a somewhat higher removal delay time,
 	 * otherwise there is a risk of out-of-sync link groups.
 	 */
+	smc_lgr_list_head(lgr, &lgr_lock);
+	spin_lock_bh(lgr_lock);
 	if (!lgr->freeing) {
 		mod_delayed_work(system_wq, &lgr->free_work,
 				 (!lgr->is_smcd && lgr->role == SMC_CLNT) ?
 						SMC_LGR_FREE_DELAY_CLNT :
 						SMC_LGR_FREE_DELAY_SERV);
 	}
+	spin_unlock_bh(lgr_lock);
 }
 
 /* Register connection's alert token in our lookup structure.
@@ -679,19 +684,34 @@ int smcd_nl_get_lgr(struct sk_buff *skb, struct netlink_callback *cb)
 	return skb->len;
 }
 
-void smc_lgr_cleanup_early(struct smc_link_group *lgr)
+/* Claim a link group for termination. Only one context can succeed: the
+ * lgr is removed from its list and marked freeing under lgr_lock.
+ * Returns false if @lgr is NULL or another context owns it.
+ */
+static bool smc_lgr_claim(struct smc_link_group *lgr)
 {
 	spinlock_t *lgr_lock;
 
 	if (!lgr)
-		return;
-
+		return false;
 	smc_lgr_list_head(lgr, &lgr_lock);
 	spin_lock_bh(lgr_lock);
+	if (lgr->freeing || lgr->terminating || list_empty(&lgr->list)) {
+		spin_unlock_bh(lgr_lock);
+		return false;
+	}
 	/* do not use this link group for new connections */
-	if (!list_empty(&lgr->list))
-		list_del_init(&lgr->list);
+	list_del_init(&lgr->list);
+	lgr->freeing = 1;
 	spin_unlock_bh(lgr_lock);
+	return true;
+}
+
+/* The caller must keep @lgr alive for the duration of the call. */
+void smc_lgr_cleanup_early(struct smc_link_group *lgr)
+{
+	if (!smc_lgr_claim(lgr))
+		return;	/* another context owns the termination */
 	__smc_lgr_terminate(lgr, true);
 }
 
@@ -1260,10 +1280,12 @@ void smc_conn_free(struct smc_connection *conn)
 		if (current_work() != &conn->abort_work)
 			cancel_work_sync(&conn->abort_work);
 	}
-	if (!list_empty(&lgr->list)) {
+	/* The handshake can retry another device or SMC version with this
+	 * connection, so it must never stay registered in an lgr it left.
+	 */
+	if (!list_empty(&lgr->list))
 		smc_buf_unuse(conn, lgr); /* allow buffer reuse */
-		smc_lgr_unregister_conn(conn);
-	}
+	smc_lgr_unregister_conn(conn);
 
 	if (!lgr->conns_num)
 		smc_lgr_schedule_free_work(lgr);
@@ -1498,6 +1520,15 @@ static void smc_conn_kill(struct smc_connection *conn, bool soft)
 {
 	struct smc_sock *smc = container_of(conn, struct smc_sock, conn);
 
+	if (conn->freed) {
+		/* The connection was already freed, e.g. by a close or
+		 * a handshake that fell back to TCP. Do not abort a socket
+		 * that is no longer part of this link group.
+		 */
+		smc_lgr_unregister_conn(conn);
+		return;
+	}
+
 	if (conn->lgr->is_smcd && conn->lgr->peer_shutdown)
 		conn->local_tx_ctrl.conn_state_flags.peer_conn_abort = 1;
 	else
@@ -1545,12 +1576,20 @@ static void __smc_lgr_terminate(struct smc_link_group *lgr, bool soft)
 	struct smc_connection *conn;
 	struct smc_sock *smc;
 	struct rb_node *node;
+	spinlock_t *lgr_lock;
 
-	if (lgr->terminating)
+	smc_lgr_list_head(lgr, &lgr_lock);
+	spin_lock_bh(lgr_lock);
+	if (lgr->terminating) {
+		spin_unlock_bh(lgr_lock);
 		return;	/* lgr already terminating */
-	/* cancel free_work sync, will terminate when lgr->freeing is set */
-	cancel_delayed_work(&lgr->free_work);
+	}
 	lgr->terminating = 1;
+	spin_unlock_bh(lgr_lock);
+	/* The lgr is claimed, so no new free_work can be armed; wait for
+	 * one that is already queued or running.
+	 */
+	cancel_delayed_work_sync(&lgr->free_work);
 
 	/* kill remaining link group connections */
 	read_lock_bh(&lgr->conns_lock);
@@ -1561,7 +1600,11 @@ static void __smc_lgr_terminate(struct smc_link_group *lgr, bool soft)
 		sock_hold(&smc->sk); /* sock_put below */
 		read_unlock_bh(&lgr->conns_lock);
 		lock_sock(&smc->sk);
-		smc_conn_kill(conn, soft);
+		/* The connection may have been re-registered in another
+		 * link group by a retried handshake in the meantime.
+		 */
+		if (conn->lgr == lgr)
+			smc_conn_kill(conn, soft);
 		release_sock(&smc->sk);
 		sock_put(&smc->sk); /* sock_hold above */
 		read_lock_bh(&lgr->conns_lock);
@@ -1575,17 +1618,8 @@ static void __smc_lgr_terminate(struct smc_link_group *lgr, bool soft)
 /* unlink link group and schedule termination */
 void smc_lgr_terminate_sched(struct smc_link_group *lgr)
 {
-	spinlock_t *lgr_lock;
-
-	smc_lgr_list_head(lgr, &lgr_lock);
-	spin_lock_bh(lgr_lock);
-	if (list_empty(&lgr->list) || lgr->terminating || lgr->freeing) {
-		spin_unlock_bh(lgr_lock);
+	if (!smc_lgr_claim(lgr))
 		return;	/* lgr already terminating */
-	}
-	list_del_init(&lgr->list);
-	lgr->freeing = 1;
-	spin_unlock_bh(lgr_lock);
 	schedule_work(&lgr->terminate_work);
 }
 
diff --git a/net/smc/smc_core.h b/net/smc/smc_core.h
index 69b54ecd65031..bc32e6c08fb56 100644
--- a/net/smc/smc_core.h
+++ b/net/smc/smc_core.h
@@ -288,9 +288,9 @@ struct smc_link_group {
 	struct delayed_work	free_work;	/* delayed freeing of an lgr */
 	struct work_struct	terminate_work;	/* abnormal lgr termination */
 	struct workqueue_struct	*tx_wq;		/* wq for conn. tx workers */
-	u8			sync_err : 1;	/* lgr no longer fits to peer */
-	u8			terminating : 1;/* lgr is terminating */
-	u8			freeing : 1;	/* lgr is being freed */
+	u8			sync_err;	/* lgr no longer fits to peer */
+	u8			terminating;	/* lgr is terminating */
+	u8			freeing;	/* lgr is being freed */
 
 	refcount_t		refcnt;		/* lgr reference count */
 	bool			is_smcd;	/* SMC-R or SMC-D */
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 009/555] net/mlx5e: Fix queue stats access to queues without stats
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (7 preceding siblings ...)
  2026-12-04 10:00 ` [PATCH 6.12 008/555] net/smc: fix link group ownership in handshake abort Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
  2026-12-04 10:00 ` [PATCH 6.12 010/555] tcp: do not coalesce segments after FIN Greg Kroah-Hartman
                   ` (545 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Breno Leitao, Tariq Toukan,
	Jakub Kicinski, Sasha Levin

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

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

From: Breno Leitao <leitao@debian.org>

[ Upstream commit 9a24799e219b1699bb1c144248c8c500b9504db5 ]

I am seeing the following mlx5e crash in the Meta fleet:

  pc : mlx5e_get_queue_stats_rx+0x4c/0xc8
  Call trace:
   mlx5e_get_queue_stats_rx+0x4c/0xc8 (P)
   netdev_stat_queue_sum+0x78/0x480
   netdev_nl_qstats_get_dump_one+0xf0/0x268
   netdev_nl_qstats_get_dumpit+0x7c/0x1f8

When dumping device-wide qstats, the core calls the per-queue callbacks
for every queue below real_num_{rx,tx}_queues, regardless of whether the
netdev is up. Some of those queues have no stats behind them:

 - RX stats live in priv->channel_stats[], which only has entries for
   channels that have been opened (stats_nch). real_num_rx_queues can
   be larger, for example after the channel count is raised while the
   netdev is down, or after opening the channels failed part way.

 - TX stats are looked up in priv->txq2sq_stats[], which is NULL for
   SQs that were never activated and for HTB queues while the channels
   are closed.

In both cases the callback dereferences a NULL pointer. The dump needs
no privileges, so any user can trigger it.

Return early for RX queues at or above stats_nch and for TX queues
without SQ stats.

Fixes: 7b66ae536a78 ("net/mlx5e: Add per queue netdev-genl stats")
Cc: stable@vger.kernel.org
Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20261104-mlx5e-qstats-null-v1-1-a6a003245cec@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[ sashal: Adjusted the patch context for the existing ASSERT_RTNL() in the RX callback and the TX callback ending after packet and byte counters. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 1f46eae73319d..d6152dac2432e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -5291,7 +5291,7 @@ static void mlx5e_get_queue_stats_rx(struct net_device *dev, int i,
 	struct mlx5e_rq_stats *rq_stats;
 
 	ASSERT_RTNL();
-	if (mlx5e_is_uplink_rep(priv) || !mlx5e_stats_nch_read(priv))
+	if (mlx5e_is_uplink_rep(priv) || i >= mlx5e_stats_nch_read(priv))
 		return;
 
 	channel_stats = priv->channel_stats[i];
@@ -5319,6 +5319,9 @@ static void mlx5e_get_queue_stats_tx(struct net_device *dev, int i,
 	 * inactive sqs.
 	 */
 	sq_stats = priv->txq2sq_stats[i];
+	if (!sq_stats)
+		return;
+
 	stats->packets = sq_stats->packets;
 	stats->bytes = sq_stats->bytes;
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 010/555] tcp: do not coalesce segments after FIN
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (8 preceding siblings ...)
  2026-12-04 10:00 ` [PATCH 6.12 009/555] net/mlx5e: Fix queue stats access to queues without stats Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
  2026-12-04 10:00 ` [PATCH 6.12 011/555] tcp: fastopen: note that a child socket was created Greg Kroah-Hartman
                   ` (544 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Hyunwoo Kim, Eric Dumazet,
	Kuniyuki Iwashima, Jakub Kicinski, Sasha Levin

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

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

From: Hyunwoo Kim <imv4bel@gmail.com>

[ Upstream commit 1c46780dec48893b8c25fd5e33a3127e8dc39dd4 ]

A FIN consumes a sequence number. If another FIN segment is coalesced
into an skb that already carries FIN, end_seq advances to account for
the additional FIN, but tcp_flags still contains only one FIN bit.

When the preceding gap is filled and tcp_ofo_queue() processes the
coalesced skb, rcv_nxt advances to the skb's end_seq. When the receive
path consumes all data in the skb, copied_seq advances by the data
length and one sequence number for FIN. If three or more FIN segments
have been coalesced into one skb, tcp_inq() can still return a positive
value after the receive queue becomes empty and the SOCK_DONE adjustment
is applied.

TCP_ZEROCOPY_RECEIVE is another consumer affected by this state.
tcp_zerocopy_receive() takes its length from tcp_inq() and follows
skb->next without checking for the end of the receive queue.

Software kTLS receive is one consumer affected by this state. When
strp->copy_mode is false, tls_strp_msg_consume() calls the TCP helper
tcp_read_done() to consume the current TLS record. In the reproducer,
tcp_read_done() consumed the record data and one FIN before freeing the
receive skb.

When kTLS looked for the next record, tcp_inq() reported at least
TLS_HEADER_SIZE bytes even though the receive queue was empty.
tcp_recv_skb() returned NULL, so tls_strp_load_anchor_with_queue() hit
WARN_ON_ONCE() and returned without updating the anchor.

Since tcp_inq() had reported at least TLS_HEADER_SIZE,
tls_strp_read_sock() proceeded to tls_strp_check_queue_ok().
skb_shinfo(strp->anchor)->frag_list still pointed to the freed receive
skb. tls_strp_check_queue_ok() then read TCP_SKB_CB(first)->seq through
the stale pointer, causing a use-after-free.

The reproducer followed this call path:

  tls_rx_rec_done()
    tls_strp_msg_consume()
      tcp_read_done()                       // frees the receive skb
    tls_strp_check_rcv()
      tls_strp_read_sock()
        tls_strp_load_anchor_with_queue()   // returns after WARN_ON_ONCE()
          tcp_recv_skb() == NULL
        tls_strp_check_queue_ok()
          TCP_SKB_CB(first)->seq            // reads the freed receive skb

KASAN reported:

  BUG: KASAN: slab-use-after-free in tls_strp_check_queue_ok.isra.0+0x5f/0x100
  Read of size 4 at addr ffff888103169ca8 by task ktls-server/71
  ...
  Call Trace:
   <TASK>
   ...
   tls_strp_check_queue_ok.isra.0+0x5f/0x100
   tls_strp_check_rcv+0x2a9/0x400
   ...
   tls_sw_recvmsg+0x3ce/0xa10
   ...
   sock_recvmsg+0xea/0x100
   __sys_recvfrom+0x142/0x1f0
   ...
   __x64_sys_recvfrom+0x76/0x90
   do_syscall_64+0xdd/0x4a0
   entry_SYSCALL_64_after_hwframe+0x77/0x7f
   ...
   </TASK>
  ...
  Freed by task 71:
   ...
   napi_skb_cache_put+0x24/0xf0
   skb_attempt_defer_free+0x183/0x3b0
   tcp_read_done+0x2d4/0x340
   tls_strp_msg_consume+0x45/0x80
   tls_sw_recvmsg+0x3c4/0xa10
   ...

In tcp_try_coalesce(), skip coalescing when the destination skb already
carries FIN. tcp_add_backlog() calls skb_try_coalesce() directly instead
of using this helper, so add the same check there. Since both paths check
only the destination skb, a final segment carrying data and FIN can still
be coalesced into an skb without FIN when the other coalescing checks pass.

Fixes: e93a0435f809 ("tcp: allow segment with FIN in tcp_try_coalesce()")
Fixes: 4f693b55c3d2 ("tcp: implement coalescing on backlog queue")
Cc: stable@vger.kernel.org
Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/au3HMfqNW3_DRMqS@v4bel
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/ipv4/tcp_input.c | 4 ++++
 net/ipv4/tcp_ipv4.c  | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index eb8f824254866..7784ef49037ba 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4943,6 +4943,10 @@ static bool tcp_try_coalesce(struct sock *sk,
 	if (!tcp_skb_can_collapse_rx(to, from))
 		return false;
 
+	/* Nothing follows a FIN. */
+	if (unlikely(TCP_SKB_CB(to)->tcp_flags & TCPHDR_FIN))
+		return false;
+
 	if (!skb_try_coalesce(to, from, fragstolen, &delta))
 		return false;
 
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 293a3b2bdd9e3..7699a99177891 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2060,6 +2060,8 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb,
 	      TCP_SKB_CB(skb)->tcp_flags) & TCPHDR_ACK) ||
 	    ((TCP_SKB_CB(tail)->tcp_flags ^
 	      TCP_SKB_CB(skb)->tcp_flags) & (TCPHDR_ECE | TCPHDR_CWR)) ||
+	    /* Nothing follows a FIN, see tcp_try_coalesce() */
+	    (TCP_SKB_CB(tail)->tcp_flags & TCPHDR_FIN) ||
 	    !tcp_skb_can_collapse_rx(tail, skb) ||
 	    thtail->doff != th->doff ||
 	    memcmp(thtail + 1, th + 1, hdrlen - sizeof(*th)))
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 011/555] tcp: fastopen: note that a child socket was created
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (9 preceding siblings ...)
  2026-12-04 10:00 ` [PATCH 6.12 010/555] tcp: do not coalesce segments after FIN Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
  2026-12-04 10:00 ` [PATCH 6.12 012/555] tcp: fix request_sock use-after-free during Fast Open accept() Greg Kroah-Hartman
                   ` (543 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jeremy Harris, Eric Dumazet,
	Neal Cardwell, Jakub Kicinski, Sasha Levin

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

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

From: Jeremy Harris <jgh@exim.org>

[ Upstream commit bc2550b4e195754fbb24aac1f012d3dd9e3b4edc ]

tcp: fastopen: note that a child socket was created

This uses up the last bit in a field of tcp_sock.

Signed-off-by: Jeremy Harris <jgh@exim.org>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Neal Cardwell <ncardwell@google.com>
Link: https://patch.msgid.link/20250423124334.4916-2-jgh@exim.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Stable-dep-of: 62754aad50d0 ("tcp: fix request_sock use-after-free during Fast Open accept()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/linux/tcp.h     | 3 ++-
 net/ipv4/tcp.c          | 1 +
 net/ipv4/tcp_fastopen.c | 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 00ea96fec2273..ea54a107f307c 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -384,7 +384,8 @@ struct tcp_sock {
 		syn_fastopen:1,	/* SYN includes Fast Open option */
 		syn_fastopen_exp:1,/* SYN includes Fast Open exp. option */
 		syn_fastopen_ch:1, /* Active TFO re-enabling probe */
-		syn_data_acked:1;/* data in SYN is acked by SYN-ACK */
+		syn_data_acked:1,/* data in SYN is acked by SYN-ACK */
+		syn_fastopen_child:1; /* created TFO passive child socket */
 
 	u8	keepalive_probes; /* num of allowed keep alive probes	*/
 	u32	tcp_tx_delay;	/* delay (in usec) added to TX packets */
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 69b4e194ba135..d1999b1cedaa1 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -3400,6 +3400,7 @@ int tcp_disconnect(struct sock *sk, int flags)
 	tp->rack.reo_wnd_persist = 0;
 	tp->rack.dsack_seen = 0;
 	tp->syn_data_acked = 0;
+	tp->syn_fastopen_child = 0;
 	tp->rx_opt.saw_tstamp = 0;
 	tp->rx_opt.dsack = 0;
 	tp->rx_opt.num_sacks = 0;
diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c
index ac4fa51240290..6ccee7480232d 100644
--- a/net/ipv4/tcp_fastopen.c
+++ b/net/ipv4/tcp_fastopen.c
@@ -404,6 +404,7 @@ struct sock *tcp_try_fastopen(struct sock *sk, struct sk_buff *skb,
 				}
 				NET_INC_STATS(sock_net(sk),
 					      LINUX_MIB_TCPFASTOPENPASSIVE);
+				tcp_sk(child)->syn_fastopen_child = 1;
 				return child;
 			}
 			NET_INC_STATS(sock_net(sk),
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 012/555] tcp: fix request_sock use-after-free during Fast Open accept()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (10 preceding siblings ...)
  2026-12-04 10:00 ` [PATCH 6.12 011/555] tcp: fastopen: note that a child socket was created Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
  2026-12-04 10:00 ` [PATCH 6.12 013/555] net: gro: invalidate frag0 after a pull Greg Kroah-Hartman
                   ` (542 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Hyunwoo Kim, Kuniyuki Iwashima,
	Jakub Kicinski, Sasha Levin

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

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

From: Hyunwoo Kim <imv4bel@gmail.com>

[ Upstream commit 62754aad50d0b30938bd8ce30b43474ce502a2af ]

Commit e3d95ad7da4f ("inet: avoid fastopen lock for regular accept()")
made inet_csk_accept() check tfo_listener before taking fastopenq.lock
to avoid taking the lock for connections that did not use Fast Open.

reqsk_fastopen_remove() clears tfo_listener while holding fastopenq.lock,
then reads req->sk. If inet_csk_accept() concurrently observes
tfo_listener after it has been cleared, it skips fastopenq.lock and
drops the last reference to the request_sock. This can free the
request_sock while reqsk_fastopen_remove() is still using it.

If the freed memory is reused for a new request_sock with req->sk ==
NULL, the reset path in reqsk_fastopen_remove() can append the new
request_sock to the original listener's list of requests that caused an
RST. After the new request_sock is freed, the next append writes through
the stale rskq_rst_tail into freed memory.

KASAN reported the following use-after-free when writing
fastopenq->rskq_rst_tail->dl_next = req:

  BUG: KASAN: slab-use-after-free in reqsk_fastopen_remove+0x142/0x210
  Write of size 8 at addr ffff888108230688 by task swapper/5/0
  ...
  Call Trace:
   <IRQ>
   ...
   reqsk_fastopen_remove+0x142/0x210
   tcp_check_req+0x96f/0xdd0
   ...
   tcp_rcv_state_process+0x19c/0x26b0
   ...
   tcp_v4_do_rcv+0x16e/0x490
   tcp_v4_rcv+0x14a0/0x1af0
   ...
   ip_protocol_deliver_rcu+0x39/0x1e0
   ip_local_deliver_finish+0x124/0x1e0
   ip_local_deliver+0xfb/0x1e0
   ...
   </IRQ>

To widen the race windows, mdelay(5) was added after newsk = req->sk,
mdelay(20) after the if (req) reqsk_put(req) block, and mdelay(100)
after tcp_rsk(req)->tfo_listener = false. The KASAN report above was
reproduced with this kernel.

For the lockless check, use tcp_sk(newsk)->syn_fastopen_child instead of
tfo_listener, which reqsk_fastopen_remove() clears.

syn_fastopen_child is a field of the Fast Open child TCP socket
referenced by newsk, not of the request_sock. It is set before the child
socket is added to the accept queue. The paths that call
reqsk_fastopen_remove() in response to a remote ACK or RST do not clear
this field.

inet_csk_accept() uses this field to take fastopenq.lock only for Fast
Open child sockets and rechecks tfo_listener while holding the lock.
Connections that did not use Fast Open continue to avoid the lock.

Fixes: e3d95ad7da4f ("inet: avoid fastopen lock for regular accept()")
Cc: stable@vger.kernel.org
Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/avQKA_YTAThtbsYU@v4bel
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/ipv4/inet_connection_sock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 6b6a195ca7954..7439996bdc0c2 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -683,7 +683,7 @@ struct sock *inet_csk_accept(struct sock *sk, struct proto_accept_arg *arg)
 	newsk = req->sk;
 
 	if (sk->sk_protocol == IPPROTO_TCP &&
-	    tcp_rsk(req)->tfo_listener) {
+	    tcp_sk(newsk)->syn_fastopen_child) {
 		spin_lock_bh(&queue->fastopenq.lock);
 		if (tcp_rsk(req)->tfo_listener) {
 			/* We are still waiting for the final ACK from 3WHS
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 013/555] net: gro: invalidate frag0 after a pull
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (11 preceding siblings ...)
  2026-12-04 10:00 ` [PATCH 6.12 012/555] tcp: fix request_sock use-after-free during Fast Open accept() Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
  2026-12-04 10:00 ` [PATCH 6.12 014/555] wifi: mac80211: fix use-after-free on TTLM disconnect Greg Kroah-Hartman
                   ` (541 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Taesoo Kim, Cen Zhang, Eric Dumazet,
	Jakub Kicinski, Sasha Levin

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

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

From: Eric Dumazet <edumazet@kernel.org>

[ Upstream commit 98d949a15ff9d3fffaa6983223178374aab92db6 ]

Since commit bd56a29c7a4e ("net: gro: change skb_gro_network_header()"),
skb_gro_header_slow() no longer invalidates NAPI_GRO_CB(skb)->frag0
after pskb_may_pull(). skb_gro_may_pull() keeps comparing against the
frag0_len value set in skb_gro_reset_offset(), assuming that after a
slow pull, all later accesses are beyond frag0_len.

This is not true:

- udp4_gro_receive() and udp6_gro_receive() read the network header
  with skb_gro_network_header() after udp_gro_udphdr() pulled the
  UDP header.

- vxlan_gro_receive() calls skb_gro_remcsum_cleanup() at a lower
  offset after the inner handlers pulled their headers.

- skb_gro_remcsum_process() can pull beyond the inner Ethernet header
  before eth_gro_receive() reads it.

- napi_frags_skb() calls __skb_pull(skb, ETH_HLEN) after a slow pull,
  so frag0 still points to the Ethernet header.

If the pull consumed the first page fragment, __skb_pull_tail() released
it. If the head had to grow, pskb_expand_head() freed the old one.
These reads, and the 2-byte write in skb_gro_remcsum_cleanup(), then
access memory the skb no longer holds a reference on.

esp4_gro_receive(), esp6_gro_receive(), skb_gro_receive_list() and
udp_gro_receive_segment() also pull directly and never invalidated
frag0.

Add skb_gro_frag0_invalidate(), which only clears frag0_len, and call
it before each of these pulls. This is a single store in the slow path,
and frag0 stays non NULL, so skb_gro_network_header() does not need
a NULL test.

frag0 must be invalidated even if the pull fails: __pskb_pull_tail()
can return NULL after pskb_expand_head() freed the old head, for
instance if a frag_list member has to be cloned or pulled.

As frag0 is now invalidated before a pull that can fail,
gro_try_pull_from_frag0() can see an skb whose linear part does not
cover skb_gro_offset() while frag0 still points to the start of the
packet, for instance after skb_gro_remcsum_cleanup() pulled a shorter
length. Copying from frag0 would then corrupt the headers: only use
frag0 while frag0_len is not zero, and use pskb_may_pull() otherwise.
If this pull fails, for instance after a failed pskb_pull() in
esp4_gro_receive(), do not hold the packet: later GRO lookups and
gro_complete() handlers expect its headers in the linear part.

This was found by Taesoo Kim and Cen Zhang, using LLM assisted code
analysis, and confirmed with reproducers.

Fixes: bd56a29c7a4e ("net: gro: change skb_gro_network_header()")
Fixes: 9fd1ff5d2ac7 ("udp: Support UDP fraglist GRO/GSO.")
Cc: stable@vger.kernel.org
Reported-by: Taesoo Kim <tsgatesv@gmail.com>
Reported-by: Cen Zhang <cenzhang@linux.microsoft.com>
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Link: https://patch.msgid.link/20261104151042.1157782-3-edumazet@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/net/gro.h       | 10 ++++++++++
 net/core/gro.c          | 20 ++++++++++++++++----
 net/ipv4/esp4_offload.c |  1 +
 net/ipv4/udp_offload.c  |  1 +
 net/ipv6/esp6_offload.c |  1 +
 5 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/include/net/gro.h b/include/net/gro.h
index 8cb718eae5b32..33768091ccf7f 100644
--- a/include/net/gro.h
+++ b/include/net/gro.h
@@ -163,9 +163,19 @@ static inline bool skb_gro_may_pull(const struct sk_buff *skb,
 	return likely(hlen <= NAPI_GRO_CB(skb)->frag0_len);
 }
 
+/* A pull can release the page fragment frag0 points to, or reallocate
+ * skb->head, even if it fails. Call this before the pull, to make sure later
+ * skb_gro_header() and skb_gro_network_header() calls no longer use frag0.
+ */
+static inline void skb_gro_frag0_invalidate(struct sk_buff *skb)
+{
+	NAPI_GRO_CB(skb)->frag0_len = 0;
+}
+
 static inline void *skb_gro_header_slow(struct sk_buff *skb, unsigned int hlen,
 					unsigned int offset)
 {
+	skb_gro_frag0_invalidate(skb);
 	if (!pskb_may_pull(skb, hlen))
 		return NULL;
 
diff --git a/net/core/gro.c b/net/core/gro.c
index 3cf9855991efe..f85b9c4c3fbd7 100644
--- a/net/core/gro.c
+++ b/net/core/gro.c
@@ -249,6 +249,7 @@ int skb_gro_receive_list(struct sk_buff *p, struct sk_buff *skb)
 	if (unlikely(skb->remcsum_offload))
 		return -EINVAL;
 
+	skb_gro_frag0_invalidate(skb);
 	if (!pskb_may_pull(skb, skb_gro_offset(skb))) {
 		NAPI_GRO_CB(skb)->flush = 1;
 		return -ENOMEM;
@@ -463,12 +464,19 @@ static void gro_pull_from_frag0(struct sk_buff *skb, int grow)
 	}
 }
 
-static void gro_try_pull_from_frag0(struct sk_buff *skb)
+static bool gro_try_pull_from_frag0(struct sk_buff *skb)
 {
 	int grow = skb_gro_offset(skb) - skb_headlen(skb);
 
-	if (grow > 0)
+	if (grow <= 0)
+		return true;
+
+	/* frag0 can only be used if no pull happened. */
+	if (likely(NAPI_GRO_CB(skb)->frag0_len)) {
 		gro_pull_from_frag0(skb, grow);
+		return true;
+	}
+	return pskb_may_pull(skb, skb_gro_offset(skb));
 }
 
 static void gro_flush_oldest(struct napi_struct *napi, struct list_head *head)
@@ -569,13 +577,17 @@ static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff
 	if (NAPI_GRO_CB(skb)->flush)
 		goto normal;
 
+	/* Must be called before setting NAPI_GRO_CB(skb)->{age|last}.
+	 * A held packet must have its headers in the linear part.
+	 */
+	if (unlikely(!gro_try_pull_from_frag0(skb)))
+		goto normal;
+
 	if (unlikely(gro_list->count >= MAX_GRO_SKBS))
 		gro_flush_oldest(napi, &gro_list->list);
 	else
 		gro_list->count++;
 
-	/* Must be called before setting NAPI_GRO_CB(skb)->{age|last} */
-	gro_try_pull_from_frag0(skb);
 	NAPI_GRO_CB(skb)->age = jiffies;
 	NAPI_GRO_CB(skb)->last = skb;
 	if (!skb_is_gso(skb))
diff --git a/net/ipv4/esp4_offload.c b/net/ipv4/esp4_offload.c
index abd77162f5e75..2309468cfc3d4 100644
--- a/net/ipv4/esp4_offload.c
+++ b/net/ipv4/esp4_offload.c
@@ -37,6 +37,7 @@ static struct sk_buff *esp4_gro_receive(struct list_head *head,
 	__be32 seq;
 	__be32 spi;
 
+	skb_gro_frag0_invalidate(skb);
 	if (!pskb_pull(skb, offset))
 		return NULL;
 
diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index 24f2cd86bbb5b..7df56d85ccacb 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -603,6 +603,7 @@ static struct sk_buff *udp_gro_receive_segment(struct list_head *head,
 			pp = p;
 		} else {
 			if (NAPI_GRO_CB(skb)->is_flist) {
+				skb_gro_frag0_invalidate(skb);
 				if (!pskb_may_pull(skb, skb_gro_offset(skb))) {
 					NAPI_GRO_CB(skb)->flush = 1;
 					return NULL;
diff --git a/net/ipv6/esp6_offload.c b/net/ipv6/esp6_offload.c
index 22895521a57d0..ca947cb94fb78 100644
--- a/net/ipv6/esp6_offload.c
+++ b/net/ipv6/esp6_offload.c
@@ -64,6 +64,7 @@ static struct sk_buff *esp6_gro_receive(struct list_head *head,
 	if (NAPI_GRO_CB(skb)->proto == IPPROTO_UDP)
 		encap_type = UDP_ENCAP_ESPINUDP;
 
+	skb_gro_frag0_invalidate(skb);
 	if (!pskb_pull(skb, offset))
 		return NULL;
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 014/555] wifi: mac80211: fix use-after-free on TTLM disconnect
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (12 preceding siblings ...)
  2026-12-04 10:00 ` [PATCH 6.12 013/555] net: gro: invalidate frag0 after a pull Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
  2026-12-04 10:00 ` [PATCH 6.12 015/555] dm: fix infinite loop in dm_blk_do_report_zones() Greg Kroah-Hartman
                   ` (540 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Benjamin Berg, Johannes Berg,
	Sasha Levin

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

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

From: Johannes Berg <johannes.berg@intel.com>

[ Upstream commit 4af2b71495a3f12196cbea1c9a502c62ada867be ]

If ieee80211_process_adv_ttlm() disconnects, and some other
changes were also detected in the beacon, the link update
to the driver is still done, leading to use-after-free. Fix
this by returning, like other functions, whether or not the
update was accepted by the function.

Cc: stable@vger.kernel.org
Fixes: 702e80470a33 ("wifi: mac80211: support handling of advertised TID-to-link mapping")
Reviewed-by: Benjamin Berg <benjamin.berg@intel.com>
Link: https://patch.msgid.link/20261102220313.3cf5e709417b.I339967c7e614057253aa68c005d9ae220577f99a@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
[ sashal: Kept this tree's timer API and function placement, applying only the bool return change and the goto free in the beacon handler, since upstream context lines differ. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/mac80211/mlme.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 3a08bb4dfca50..d4c69a68774f8 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -6491,15 +6491,15 @@ ieee80211_parse_adv_t2l(struct ieee80211_sub_if_data *sdata,
 	return 0;
 }
 
-static void ieee80211_process_adv_ttlm(struct ieee80211_sub_if_data *sdata,
-					  struct ieee802_11_elems *elems,
-					  u64 beacon_ts)
+static bool ieee80211_process_adv_ttlm(struct ieee80211_sub_if_data *sdata,
+				       struct ieee802_11_elems *elems,
+				       u64 beacon_ts)
 {
 	u8 i;
 	int ret;
 
 	if (!ieee80211_vif_is_mld(&sdata->vif))
-		return;
+		return true;
 
 	if (!elems->ttlm_num) {
 		if (sdata->u.mgd.ttlm_info.switch_time) {
@@ -6517,14 +6517,14 @@ static void ieee80211_process_adv_ttlm(struct ieee80211_sub_if_data *sdata,
 						      0);
 			if (ret) {
 				sdata_info(sdata, "Failed setting valid/dormant links\n");
-				return;
+				return true;
 			}
 			ieee80211_vif_cfg_change_notify(sdata,
 							BSS_CHANGED_MLD_VALID_LINKS);
 		}
 		memset(&sdata->u.mgd.ttlm_info, 0,
 		       sizeof(sdata->u.mgd.ttlm_info));
-		return;
+		return true;
 	}
 
 	for (i = 0; i < elems->ttlm_num; i++) {
@@ -6536,7 +6536,7 @@ static void ieee80211_process_adv_ttlm(struct ieee80211_sub_if_data *sdata,
 
 		if (res) {
 			__ieee80211_disconnect(sdata);
-			return;
+			return false;
 		}
 
 		if (ttlm_info.switch_time) {
@@ -6561,7 +6561,7 @@ static void ieee80211_process_adv_ttlm(struct ieee80211_sub_if_data *sdata,
 			 * switch the AP will continue to announce it anyway.
 			 */
 			if (delay > IEEE80211_ADV_TTLM_ST_UNDERFLOW)
-				return;
+				return true;
 
 			delay_jiffies = TU_TO_JIFFIES(delay);
 
@@ -6580,9 +6580,11 @@ static void ieee80211_process_adv_ttlm(struct ieee80211_sub_if_data *sdata,
 			wiphy_delayed_work_queue(sdata->local->hw.wiphy,
 						 &sdata->u.mgd.ttlm_work,
 						 delay_jiffies);
-			return;
+			return true;
 		}
 	}
+
+	return true;
 }
 
 static void
@@ -7025,8 +7027,9 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_link_data *link,
 					       elems->cisco_dtpc_elem);
 
 	ieee80211_ml_reconfiguration(sdata, elems);
-	ieee80211_process_adv_ttlm(sdata, elems,
-				      le64_to_cpu(mgmt->u.beacon.timestamp));
+	if (!ieee80211_process_adv_ttlm(sdata, elems,
+					le64_to_cpu(mgmt->u.beacon.timestamp)))
+		goto free;
 
 	ieee80211_link_info_change_notify(sdata, link, changed);
 free:
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 015/555] dm: fix infinite loop in dm_blk_do_report_zones()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (13 preceding siblings ...)
  2026-12-04 10:00 ` [PATCH 6.12 014/555] wifi: mac80211: fix use-after-free on TTLM disconnect Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
  2026-12-04 10:00 ` [PATCH 6.12 016/555] iio: common: scmi_sensors: fix truncating 64-bit divisions Greg Kroah-Hartman
                   ` (539 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Mark Bundschuh, Mikulas Patocka,
	Damien Le Moal, Sasha Levin

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

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

From: Mark Bundschuh <mkbund@amazon.com>

[ Upstream commit 648320de920b30ae1730bbf0e8b86c0df0fb490a ]

If the device underlying a zoned target is removed, its capacity is set
to 0 and blkdev_report_zones() returns 0 without reporting any zones.
The mapped device keeps its old capacity, so args->zone_idx and
args->next_sector never advance and dm_blk_do_report_zones() loops
forever. On non-preemptible kernels this causes soft lockups and RCU
stalls.

The following sequence of commands triggers the hang:

modprobe scsi_debug zbc=managed dev_size_mb=1024 zone_size_mb=64
udevadm settle
echo '0 2097152 linear /dev/sda 0' | dmsetup create lin
echo 1 > /sys/block/sda/device/delete
blkzone report -o 0 -c 1 /dev/mapper/lin

Fix this by returning -EIO when a target reports no zones. The target
always maps args->next_sector, so a zero return means the underlying
device no longer covers that sector.

Fixes: d41003513e61 ("block: rework zone reporting")
Cc: stable@vger.kernel.org
Signed-off-by: Mark Bundschuh <mkbund@amazon.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
[ Context differs due to commit: fdb9aed869f3 ]
Signed-off-by: Mark Bundschuh <mkbund@amazon.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/md/dm-zone.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
index 85777d875cc00..00c3b35ed2901 100644
--- a/drivers/md/dm-zone.c
+++ b/drivers/md/dm-zone.c
@@ -40,6 +40,8 @@ static int dm_blk_do_report_zones(struct mapped_device *md, struct dm_table *t,
 					      nr_zones - args.zone_idx);
 		if (ret < 0)
 			return ret;
+		if (!ret)
+			return -EIO;
 	} while (args.zone_idx < nr_zones &&
 		 args.next_sector < get_capacity(disk));
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 016/555] iio: common: scmi_sensors: fix truncating 64-bit divisions
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (14 preceding siblings ...)
  2026-12-04 10:00 ` [PATCH 6.12 015/555] dm: fix infinite loop in dm_blk_do_report_zones() Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 017/555] iio: proximity: sx9500: ignore event config writes that dont change state Greg Kroah-Hartman
                   ` (538 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, kernel test robot, Arnav Kapoor,
	Andy Shevchenko, Jonathan Cameron, Sasha Levin

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

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

From: Arnav Kapoor <kapoorarnav43@gmail.com>

commit 043ececf147863fbd253687aa0b9edcac358a711 upstream.

do_div() divides a 64-bit dividend by a 32-bit divisor: the divisor is
stored in a uint32_t on all architectures. The driver passes 64-bit
divisors to it in several places, so they are silently truncated:

- scmi_iio_set_odr_val() divides by uHz, which exceeds 32 bits for
  sampling frequencies above ~4294 Hz.
- convert_ns_to_freq() divides by interval_ns, which exceeds 32 bits
  for update intervals of ~4.29 s and above. If its low 32 bits happen
  to be zero, this is a division by zero.
- scmi_iio_get_odr_val(), scmi_iio_convert_interval_to_ns(),
  scmi_iio_sensor_update_cb() and scmi_iio_get_raw_available() divide
  by int_pow(10, n), which returns u64 and exceeds 32 bits for n >= 10.
  The SCMI exponent fields allow values down to -16.

Truncation results in wrong sampling frequency, timestamp and
raw_available values being reported to userspace.

Use div64_u64() and div64_u64_rem(), which take a 64-bit divisor.

Fixes: f774117c96f9 ("iio/scmi: Adding support for IIO SCMI Based Sensors")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202606040245.XfmRpBhA-lkp@intel.com/
Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
[ Use NSEC_PER_SEC instead of HZ_PER_GHZ, which this tree's units.h
doesn't have (same value, and what the old code used). ]
Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/iio/common/scmi_sensors/scmi_iio.c | 27 +++++++++++-----------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/iio/common/scmi_sensors/scmi_iio.c b/drivers/iio/common/scmi_sensors/scmi_iio.c
index ed15dcbf4cf6b..bcd85bdaebbef 100644
--- a/drivers/iio/common/scmi_sensors/scmi_iio.c
+++ b/drivers/iio/common/scmi_sensors/scmi_iio.c
@@ -14,6 +14,7 @@
 #include <linux/iio/sysfs.h>
 #include <linux/kernel.h>
 #include <linux/kthread.h>
+#include <linux/math64.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/scmi_protocol.h>
@@ -71,8 +72,7 @@ static int scmi_iio_sensor_update_cb(struct notifier_block *nb,
 		tstamp_scale = sensor->sensor_info->tstamp_scale +
 			       const_ilog2(NSEC_PER_SEC) / const_ilog2(10);
 		if (tstamp_scale < 0) {
-			do_div(time, int_pow(10, abs(tstamp_scale)));
-			time_ns = time;
+			time_ns = div64_u64(time, int_pow(10, abs(tstamp_scale)));
 		} else {
 			time_ns = time * int_pow(10, tstamp_scale);
 		}
@@ -163,7 +163,7 @@ static int scmi_iio_set_odr_val(struct iio_dev *iio_dev, int val, int val2)
 	mult = scnprintf(buf, sizeof(buf), "%llu", sf) - 1;
 
 	sec = int_pow(10, mult) * MICROHZ_PER_HZ;
-	do_div(sec, uHz);
+	sec = div64_u64(sec, uHz);
 	if (sec == 0) {
 		dev_err(&iio_dev->dev,
 			"Trying to set invalid sensor update value for sensor %s",
@@ -238,13 +238,10 @@ static int scmi_iio_read_avail(struct iio_dev *iio_dev,
 
 static void convert_ns_to_freq(u64 interval_ns, u64 *hz, u64 *uhz)
 {
-	u64 rem, freq;
+	u64 rem;
 
-	freq = NSEC_PER_SEC;
-	rem = do_div(freq, interval_ns);
-	*hz = freq;
-	*uhz = rem * 1000000UL;
-	do_div(*uhz, interval_ns);
+	*hz = div64_u64_rem(NSEC_PER_SEC, interval_ns, &rem);
+	*uhz = div64_u64(rem * MICROHZ_PER_HZ, interval_ns);
 }
 
 static int scmi_iio_get_odr_val(struct iio_dev *iio_dev, int *val, int *val2)
@@ -270,7 +267,8 @@ static int scmi_iio_get_odr_val(struct iio_dev *iio_dev, int *val, int *val2)
 	mult = SCMI_SENS_CFG_GET_UPDATE_EXP(sensor_config);
 	if (mult < 0) {
 		sensor_interval_mult = int_pow(10, abs(mult));
-		do_div(sensor_update_interval, sensor_interval_mult);
+		sensor_update_interval = div64_u64(sensor_update_interval,
+						   sensor_interval_mult);
 	} else {
 		sensor_interval_mult = int_pow(10, mult);
 		sensor_update_interval =
@@ -397,9 +395,9 @@ static ssize_t scmi_iio_get_raw_available(struct iio_dev *iio_dev,
 		 */
 		exponent = exponent - scale;
 		if (exponent < 0) {
-			rem = do_div(resolution,
-				     int_pow(10, abs(exponent))
-				     );
+			resolution = div64_u64_rem(resolution,
+						   int_pow(10, abs(exponent)),
+						   &rem);
 			len = sysfs_emit(buf,
 					"[%lld %llu.%llu %lld]\n", min_range,
 					resolution, rem, max_range);
@@ -504,7 +502,8 @@ static u64 scmi_iio_convert_interval_to_ns(u32 val)
 	mult = SCMI_SENS_INTVL_GET_EXP(val);
 	if (mult < 0) {
 		sensor_interval_mult = int_pow(10, abs(mult));
-		do_div(sensor_update_interval, sensor_interval_mult);
+		sensor_update_interval = div64_u64(sensor_update_interval,
+						   sensor_interval_mult);
 	} else {
 		sensor_interval_mult = int_pow(10, mult);
 		sensor_update_interval =
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 017/555] iio: proximity: sx9500: ignore event config writes that dont change state
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (15 preceding siblings ...)
  2026-12-04 10:00 ` [PATCH 6.12 016/555] iio: common: scmi_sensors: fix truncating 64-bit divisions Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 018/555] iio: imu: inv_mpu6050: fix swapped accel and gyro startup times Greg Kroah-Hartman
                   ` (537 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Arnav Kapoor, Jonathan Cameron,
	Sasha Levin

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

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

From: Arnav Kapoor <kapoorarnav43@gmail.com>

commit b8ed9165906597b69a46fabf39ab41690721ebe8 upstream.

sx9500_write_event_config() adjusts the channel and close/far user
counts on every write, even when the event is already in the requested
state. Writing 0 to a disabled event and then 1 leaves the counts at 0,
so the channel and its interrupts stay off while the event reads as
enabled. As channel_users[] is shared with raw reads, those can then
wait forever for a conversion. Writing 1 twice and then 0 has the
opposite effect.

Return early when the state doesn't change, as
sx_common_write_event_config() does.

Fixes: 4193c0f1d863 ("iio: driver for Semtech SX9500 proximity solution")
Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
[ Context: write_event_config() still takes int state here and tests
state == 1; the added check is unchanged. ]
Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/iio/proximity/sx9500.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
index 3f4eace05cfc6..1041d3defe4e7 100644
--- a/drivers/iio/proximity/sx9500.c
+++ b/drivers/iio/proximity/sx9500.c
@@ -551,6 +551,12 @@ static int sx9500_write_event_config(struct iio_dev *indio_dev,
 
 	mutex_lock(&data->mutex);
 
+	/* The user counts must only change when the state does. */
+	if (data->event_enabled[chan->channel] == state) {
+		ret = 0;
+		goto out_unlock;
+	}
+
 	if (state == 1) {
 		ret = sx9500_inc_chan_users(data, chan->channel);
 		if (ret < 0)
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 018/555] iio: imu: inv_mpu6050: fix swapped accel and gyro startup times
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (16 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 017/555] iio: proximity: sx9500: ignore event config writes that dont change state Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 019/555] mmc: jz4740: Remove the host before resetting the controller Greg Kroah-Hartman
                   ` (536 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Arnav Kapoor, Jean-Baptiste Maneyrol,
	Jonathan Cameron, Sasha Levin

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

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

From: Arnav Kapoor <kapoorarnav43@gmail.com>

commit 3a5e2ca34cadd9d5993064884aa5b9c4f6d71dff upstream.

struct inv_mpu6050_hw declares startup_time as { accel, gyro }, but
every entry of hw_info[] initializes it positionally as
{ *_GYRO_STARTUP_TIME, *_ACCEL_STARTUP_TIME }, so the two values are
swapped for all chips.

inv_mpu6050_switch_engine() waits for startup_time.gyro after enabling
the gyroscope, so it waits for the accelerometer startup time instead,
e.g. 20 ms instead of 60 ms on MPU6050 and 20 ms instead of 100 ms on
ICM20602, and the first gyroscope samples can be read before the sensor
has settled. Enabling only the accelerometer waits longer than needed.

Use designated initializers, so each value is assigned to the member it
is named after.

Fixes: e46a36d92da0 ("Add startup time for each chip using inv_mpu6050 driver")
Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Cc: stable@vger.kernel.org
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
[ This tree has no IAM20380, IAM20680HP or IAM20680HT entries; the 16
entries it has are converted the same way. ]
Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 80 +++++++++++++++++-----
 1 file changed, 64 insertions(+), 16 deletions(-)

diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 19f428ce8ec5d..a303a03fd9be6 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -149,7 +149,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.config = &chip_config_6050,
 		.fifo_size = 1024,
 		.temp = {INV_MPU6050_TEMP_OFFSET, INV_MPU6050_TEMP_SCALE},
-		.startup_time = {INV_MPU6050_GYRO_STARTUP_TIME, INV_MPU6050_ACCEL_STARTUP_TIME},
+		.startup_time = {
+			.accel = INV_MPU6050_ACCEL_STARTUP_TIME,
+			.gyro = INV_MPU6050_GYRO_STARTUP_TIME,
+		},
 	},
 	{
 		.whoami = INV_MPU6500_WHOAMI_VALUE,
@@ -158,7 +161,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.config = &chip_config_6500,
 		.fifo_size = 512,
 		.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
-		.startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
+		.startup_time = {
+			.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
+			.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
+		},
 	},
 	{
 		.whoami = INV_MPU6515_WHOAMI_VALUE,
@@ -167,7 +173,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.config = &chip_config_6500,
 		.fifo_size = 512,
 		.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
-		.startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
+		.startup_time = {
+			.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
+			.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
+		},
 	},
 	{
 		.whoami = INV_MPU6880_WHOAMI_VALUE,
@@ -176,7 +185,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.config = &chip_config_6500,
 		.fifo_size = 4096,
 		.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
-		.startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
+		.startup_time = {
+			.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
+			.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
+		},
 	},
 	{
 		.whoami = INV_MPU6000_WHOAMI_VALUE,
@@ -185,7 +197,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.config = &chip_config_6050,
 		.fifo_size = 1024,
 		.temp = {INV_MPU6050_TEMP_OFFSET, INV_MPU6050_TEMP_SCALE},
-		.startup_time = {INV_MPU6050_GYRO_STARTUP_TIME, INV_MPU6050_ACCEL_STARTUP_TIME},
+		.startup_time = {
+			.accel = INV_MPU6050_ACCEL_STARTUP_TIME,
+			.gyro = INV_MPU6050_GYRO_STARTUP_TIME,
+		},
 	},
 	{
 		.whoami = INV_MPU9150_WHOAMI_VALUE,
@@ -194,7 +209,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.config = &chip_config_6050,
 		.fifo_size = 1024,
 		.temp = {INV_MPU6050_TEMP_OFFSET, INV_MPU6050_TEMP_SCALE},
-		.startup_time = {INV_MPU6050_GYRO_STARTUP_TIME, INV_MPU6050_ACCEL_STARTUP_TIME},
+		.startup_time = {
+			.accel = INV_MPU6050_ACCEL_STARTUP_TIME,
+			.gyro = INV_MPU6050_GYRO_STARTUP_TIME,
+		},
 	},
 	{
 		.whoami = INV_MPU9250_WHOAMI_VALUE,
@@ -203,7 +221,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.config = &chip_config_6500,
 		.fifo_size = 512,
 		.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
-		.startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
+		.startup_time = {
+			.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
+			.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
+		},
 	},
 	{
 		.whoami = INV_MPU9255_WHOAMI_VALUE,
@@ -212,7 +233,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.config = &chip_config_6500,
 		.fifo_size = 512,
 		.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
-		.startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
+		.startup_time = {
+			.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
+			.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
+		},
 	},
 	{
 		.whoami = INV_ICM20608_WHOAMI_VALUE,
@@ -221,7 +245,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.config = &chip_config_6500,
 		.fifo_size = 512,
 		.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
-		.startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
+		.startup_time = {
+			.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
+			.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
+		},
 	},
 	{
 		.whoami = INV_ICM20608D_WHOAMI_VALUE,
@@ -230,7 +257,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.config = &chip_config_6500,
 		.fifo_size = 512,
 		.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
-		.startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
+		.startup_time = {
+			.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
+			.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
+		},
 	},
 	{
 		.whoami = INV_ICM20609_WHOAMI_VALUE,
@@ -239,7 +269,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.config = &chip_config_6500,
 		.fifo_size = 4 * 1024,
 		.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
-		.startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
+		.startup_time = {
+			.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
+			.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
+		},
 	},
 	{
 		.whoami = INV_ICM20689_WHOAMI_VALUE,
@@ -248,7 +281,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.config = &chip_config_6500,
 		.fifo_size = 4 * 1024,
 		.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
-		.startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
+		.startup_time = {
+			.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
+			.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
+		},
 	},
 	{
 		.whoami = INV_ICM20600_WHOAMI_VALUE,
@@ -257,7 +293,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.config = &chip_config_6500,
 		.fifo_size = 1008,
 		.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
-		.startup_time = {INV_ICM20602_GYRO_STARTUP_TIME, INV_ICM20602_ACCEL_STARTUP_TIME},
+		.startup_time = {
+			.accel = INV_ICM20602_ACCEL_STARTUP_TIME,
+			.gyro = INV_ICM20602_GYRO_STARTUP_TIME,
+		},
 	},
 	{
 		.whoami = INV_ICM20602_WHOAMI_VALUE,
@@ -266,7 +305,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.config = &chip_config_6500,
 		.fifo_size = 1008,
 		.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
-		.startup_time = {INV_ICM20602_GYRO_STARTUP_TIME, INV_ICM20602_ACCEL_STARTUP_TIME},
+		.startup_time = {
+			.accel = INV_ICM20602_ACCEL_STARTUP_TIME,
+			.gyro = INV_ICM20602_GYRO_STARTUP_TIME,
+		},
 	},
 	{
 		.whoami = INV_ICM20690_WHOAMI_VALUE,
@@ -275,7 +317,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.config = &chip_config_6500,
 		.fifo_size = 1024,
 		.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
-		.startup_time = {INV_ICM20690_GYRO_STARTUP_TIME, INV_ICM20690_ACCEL_STARTUP_TIME},
+		.startup_time = {
+			.accel = INV_ICM20690_ACCEL_STARTUP_TIME,
+			.gyro = INV_ICM20690_GYRO_STARTUP_TIME,
+		},
 	},
 	{
 		.whoami = INV_IAM20680_WHOAMI_VALUE,
@@ -284,7 +329,10 @@ static const struct inv_mpu6050_hw hw_info[] = {
 		.config = &chip_config_6500,
 		.fifo_size = 512,
 		.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
-		.startup_time = {INV_MPU6500_GYRO_STARTUP_TIME, INV_MPU6500_ACCEL_STARTUP_TIME},
+		.startup_time = {
+			.accel = INV_MPU6500_ACCEL_STARTUP_TIME,
+			.gyro = INV_MPU6500_GYRO_STARTUP_TIME,
+		},
 	},
 };
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 019/555] mmc: jz4740: Remove the host before resetting the controller
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (17 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 018/555] iio: imu: inv_mpu6050: fix swapped accel and gyro startup times Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 020/555] ALSA: hda: Fix [codec] ID matching in patch files for IDs with bit 31 set Greg Kroah-Hartman
                   ` (535 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Olivier Louvignes, Ulf Hansson,
	Sasha Levin

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

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

From: Olivier Louvignes <olivier@mgcrea.io>

[ Upstream commit 6b8b1e8827837bf4cf1f87219038fddae9e81b0b ]

jz4740_mmc_remove() masks every interrupt and resets the controller
before mmc_remove_host(), which removes the card and lets the card's
driver send its last commands. Those commands then run on a controller
that was just reset, and can wait out the driver's 5 s request timeout.

With an SDIO card that cost 5 s on every unbind: on a HiBy R1 (Ingenic
X1600, a BCM43430A1 driven by brcmfmac), the CMD52 that
sdio_release_irq() sends from brcmfmac's remove waited 5.1 s. The
command had finished (END_CMD_RES set in MSC_STAT), but MSC_IMASK read
0xffffffff although the request had unmasked END_CMD_RES. MSC_STAT can
still show IS_RESETTING after jz4740_mmc_reset() returns, so the reset
most likely completed after that write and undid it.

Remove the host first, then quiesce the controller, as other host
drivers do. On the R1, unbinding the Wi-Fi's MSC now takes 0.65 s.

Fixes: 61bfbdb85687 ("MMC: Add support for the controller on JZ4740 SoCs.")
Cc: stable@vger.kernel.org
Signed-off-by: Olivier Louvignes <olivier@mgcrea.io>
Signed-off-by: Ulf Hansson <ulfh@kernel.org>
[ sashal: Kept del_timer_sync() instead of upstream's timer_delete_sync() in the context line, since the older timer API is what this tree uses. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/mmc/host/jz4740_mmc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c
index 6a45991ca056f..9e8be3894e496 100644
--- a/drivers/mmc/host/jz4740_mmc.c
+++ b/drivers/mmc/host/jz4740_mmc.c
@@ -1162,12 +1162,13 @@ static void jz4740_mmc_remove(struct platform_device *pdev)
 {
 	struct jz4740_mmc_host *host = platform_get_drvdata(pdev);
 
+	/* The card's driver may still send commands as it goes */
+	mmc_remove_host(host->mmc);
+
 	del_timer_sync(&host->timeout_timer);
 	jz4740_mmc_set_irq_enabled(host, 0xff, false);
 	jz4740_mmc_reset(host);
 
-	mmc_remove_host(host->mmc);
-
 	free_irq(host->irq, host);
 
 	if (host->use_dma)
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 020/555] ALSA: hda: Fix [codec] ID matching in patch files for IDs with bit 31 set
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (18 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 019/555] mmc: jz4740: Remove the host before resetting the controller Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 021/555] kprobes: Adopt guard() and scoped_guard() Greg Kroah-Hartman
                   ` (534 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Andrew Davison, Takashi Iwai,
	Sasha Levin

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

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

From: Andrew Davison <andy@dvsn.net>

[ Upstream commit fda103c1432f344e1cd548f346d157b1e67ee7c5 ]

parse_codec_mode() reads the vendor and subsystem IDs of a patch file's
[codec] line into an int, and skips the check when the value is zero or
negative, as documented. An ID with bit 31 set, such as SigmaTel's
0x8384xxxx or Intel's 0x8086xxxx, comes out negative, so it is taken as
a wildcard and the section is applied to every codec instead of the one
it names.

This was seen on an OpenPeak OpenFrame 2 with an IDT 92HD75B2X5
(0x111d7608). A patch file written for the STAC9202 (0x83847632) in the
related OpenFrame 1 was applied to it, swapping the headphone and
speaker pin configurations, so auto-mute never muted the speaker.

Read the IDs as long long, so real IDs are compared exactly. Values
written as negative numbers (e.g. -1) still act as wildcards, as
documented; a hex value such as 0xffffffff is now compared as written.

Tested on 6.18.60 on an OpenFrame 2, with a rebuilt snd-hda-codec and
the STAC9202 patch file: user_pin_configs stays empty for the IDT codec,
and the headphone and line-out pins are assigned as the BIOS sets them.
Not tested on a STAC9202 itself.

The bug was tracked down and this fix written with an AI coding
assistant (Claude Code, Claude Opus 5.5), which also ran the tests
above. I have reviewed the change and the tests.

Fixes: ef940b0403d4 ("ALSA: hda - Allow patching with any vendor/subsystem ids")
Cc: stable@vger.kernel.org
Signed-off-by: Andrew Davison <andy@dvsn.net>
Link: https://patch.msgid.link/20261106175518.18629-1-andy@dvsn.net
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 sound/pci/hda/hda_sysfs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sound/pci/hda/hda_sysfs.c b/sound/pci/hda/hda_sysfs.c
index c6081f3c1ccd8..47b29e163ac0c 100644
--- a/sound/pci/hda/hda_sysfs.c
+++ b/sound/pci/hda/hda_sysfs.c
@@ -520,11 +520,12 @@ static inline int strmatch(const char *a, const char *b)
 static void parse_codec_mode(char *buf, struct hda_bus *bus,
 			     struct hda_codec **codecp)
 {
-	int vendorid, subid, caddr;
+	long long vendorid, subid;
+	int caddr;
 	struct hda_codec *codec;
 
 	*codecp = NULL;
-	if (sscanf(buf, "%i %i %i", &vendorid, &subid, &caddr) == 3) {
+	if (sscanf(buf, "%lli %lli %i", &vendorid, &subid, &caddr) == 3) {
 		list_for_each_codec(codec, bus) {
 			if ((vendorid <= 0 || codec->core.vendor_id == vendorid) &&
 			    (subid <= 0 || codec->core.subsystem_id == subid) &&
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 021/555] kprobes: Adopt guard() and scoped_guard()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (19 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 020/555] ALSA: hda: Fix [codec] ID matching in patch files for IDs with bit 31 set Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 022/555] mmc: omap: synchronize clock timer before disabling fclk Greg Kroah-Hartman
                   ` (533 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Masami Hiramatsu (Google),
	Sasha Levin

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

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

From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

[ Upstream commit 587e8e6d640bcf89a4bf29745a3c3fdfe8379ae0 ]

Use guard() or scoped_guard() for critical sections rather than
discrete lock/unlock pairs.

Link: https://lore.kernel.org/all/173289887835.73724.608223217359025939.stgit@devnote2/

Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Stable-dep-of: a553b499f22b ("kprobes: Validate re-registration earlier in register_kretprobe()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/kprobes.c | 205 ++++++++++++++++++++---------------------------
 1 file changed, 89 insertions(+), 116 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 7d0a378b2e44b..585ddaf8a6af4 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -144,10 +144,9 @@ static int collect_garbage_slots(struct kprobe_insn_cache *c);
 kprobe_opcode_t *__get_insn_slot(struct kprobe_insn_cache *c)
 {
 	struct kprobe_insn_page *kip;
-	kprobe_opcode_t *slot = NULL;
 
 	/* Since the slot array is not protected by rcu, we need a mutex */
-	mutex_lock(&c->mutex);
+	guard(mutex)(&c->mutex);
  retry:
 	rcu_read_lock();
 	list_for_each_entry_rcu(kip, &c->pages, list) {
@@ -158,9 +157,8 @@ kprobe_opcode_t *__get_insn_slot(struct kprobe_insn_cache *c)
 				if (kip->slot_used[i] == SLOT_CLEAN) {
 					kip->slot_used[i] = SLOT_USED;
 					kip->nused++;
-					slot = kip->insns + (i * c->insn_size);
 					rcu_read_unlock();
-					goto out;
+					return kip->insns + (i * c->insn_size);
 				}
 			}
 			/* kip->nused is broken. Fix it. */
@@ -177,12 +175,12 @@ kprobe_opcode_t *__get_insn_slot(struct kprobe_insn_cache *c)
 	/* All out of space.  Need to allocate a new page. */
 	kip = kmalloc(KPROBE_INSN_PAGE_SIZE(slots_per_page(c)), GFP_KERNEL);
 	if (!kip)
-		goto out;
+		return NULL;
 
 	kip->insns = c->alloc();
 	if (!kip->insns) {
 		kfree(kip);
-		goto out;
+		return NULL;
 	}
 	INIT_LIST_HEAD(&kip->list);
 	memset(kip->slot_used, SLOT_CLEAN, slots_per_page(c));
@@ -191,14 +189,12 @@ kprobe_opcode_t *__get_insn_slot(struct kprobe_insn_cache *c)
 	kip->ngarbage = 0;
 	kip->cache = c;
 	list_add_rcu(&kip->list, &c->pages);
-	slot = kip->insns;
 
 	/* Record the perf ksymbol register event after adding the page */
 	perf_event_ksymbol(PERF_RECORD_KSYMBOL_TYPE_OOL, (unsigned long)kip->insns,
 			   PAGE_SIZE, false, c->sym);
-out:
-	mutex_unlock(&c->mutex);
-	return slot;
+
+	return kip->insns;
 }
 
 /* Return true if all garbages are collected, otherwise false. */
@@ -259,7 +255,7 @@ void __free_insn_slot(struct kprobe_insn_cache *c,
 	struct kprobe_insn_page *kip;
 	long idx;
 
-	mutex_lock(&c->mutex);
+	guard(mutex)(&c->mutex);
 	rcu_read_lock();
 	list_for_each_entry_rcu(kip, &c->pages, list) {
 		idx = ((long)slot - (long)kip->insns) /
@@ -285,7 +281,6 @@ void __free_insn_slot(struct kprobe_insn_cache *c,
 			collect_one_slot(kip, idx);
 		}
 	}
-	mutex_unlock(&c->mutex);
 }
 
 /*
@@ -643,10 +638,9 @@ static void kprobe_optimizer(struct work_struct *work)
 	mutex_unlock(&kprobe_mutex);
 }
 
-/* Wait for completing optimization and unoptimization */
-void wait_for_kprobe_optimizer(void)
+static void wait_for_kprobe_optimizer_locked(void)
 {
-	mutex_lock(&kprobe_mutex);
+	lockdep_assert_held(&kprobe_mutex);
 
 	while (!list_empty(&optimizing_list) || !list_empty(&unoptimizing_list)) {
 		mutex_unlock(&kprobe_mutex);
@@ -658,8 +652,14 @@ void wait_for_kprobe_optimizer(void)
 
 		mutex_lock(&kprobe_mutex);
 	}
+}
 
-	mutex_unlock(&kprobe_mutex);
+/* Wait for completing optimization and unoptimization */
+void wait_for_kprobe_optimizer(void)
+{
+	guard(mutex)(&kprobe_mutex);
+
+	wait_for_kprobe_optimizer_locked();
 }
 
 bool optprobe_queued_unopt(struct optimized_kprobe *op)
@@ -889,10 +889,10 @@ static void optimize_all_kprobes(void)
 	struct kprobe *p;
 	unsigned int i;
 
-	mutex_lock(&kprobe_mutex);
+	guard(mutex)(&kprobe_mutex);
 	/* If optimization is already allowed, just return. */
 	if (kprobes_allow_optimization)
-		goto out;
+		return;
 
 	cpus_read_lock();
 	kprobes_allow_optimization = true;
@@ -904,8 +904,6 @@ static void optimize_all_kprobes(void)
 	}
 	cpus_read_unlock();
 	pr_info("kprobe jump-optimization is enabled. All kprobes are optimized if possible.\n");
-out:
-	mutex_unlock(&kprobe_mutex);
 }
 
 #ifdef CONFIG_SYSCTL
@@ -915,12 +913,10 @@ static void unoptimize_all_kprobes(void)
 	struct kprobe *p;
 	unsigned int i;
 
-	mutex_lock(&kprobe_mutex);
+	guard(mutex)(&kprobe_mutex);
 	/* If optimization is already prohibited, just return. */
-	if (!kprobes_allow_optimization) {
-		mutex_unlock(&kprobe_mutex);
+	if (!kprobes_allow_optimization)
 		return;
-	}
 
 	cpus_read_lock();
 	kprobes_allow_optimization = false;
@@ -932,10 +928,8 @@ static void unoptimize_all_kprobes(void)
 		}
 	}
 	cpus_read_unlock();
-	mutex_unlock(&kprobe_mutex);
-
 	/* Wait for unoptimizing completion. */
-	wait_for_kprobe_optimizer();
+	wait_for_kprobe_optimizer_locked();
 	pr_info("kprobe jump-optimization is disabled. All kprobes are based on software breakpoint.\n");
 }
 
@@ -947,7 +941,7 @@ static int proc_kprobes_optimization_handler(const struct ctl_table *table,
 {
 	int ret;
 
-	mutex_lock(&kprobe_sysctl_mutex);
+	guard(mutex)(&kprobe_sysctl_mutex);
 	sysctl_kprobes_optimization = kprobes_allow_optimization ? 1 : 0;
 	ret = proc_dointvec_minmax(table, write, buffer, length, ppos);
 
@@ -955,7 +949,6 @@ static int proc_kprobes_optimization_handler(const struct ctl_table *table,
 		optimize_all_kprobes();
 	else
 		unoptimize_all_kprobes();
-	mutex_unlock(&kprobe_sysctl_mutex);
 
 	return ret;
 }
@@ -1030,7 +1023,8 @@ static void __disarm_kprobe(struct kprobe *p, bool reopt)
 #define __arm_kprobe(p)				arch_arm_kprobe(p)
 #define __disarm_kprobe(p, o)			arch_disarm_kprobe(p)
 #define kprobe_disarmed(p)			kprobe_disabled(p)
-#define wait_for_kprobe_optimizer()		do {} while (0)
+#define wait_for_kprobe_optimizer_locked()			\
+	lockdep_assert_held(&kprobe_mutex)
 
 static int reuse_unused_kprobe(struct kprobe *ap)
 {
@@ -1501,6 +1495,7 @@ _kprobe_addr(kprobe_opcode_t *addr, const char *symbol_name,
 static kprobe_opcode_t *kprobe_addr(struct kprobe *p)
 {
 	bool on_func_entry;
+
 	return _kprobe_addr(p->addr, p->symbol_name, p->offset, &on_func_entry);
 }
 
@@ -1535,14 +1530,12 @@ static struct kprobe *__get_valid_kprobe(struct kprobe *p)
  */
 static inline int warn_kprobe_rereg(struct kprobe *p)
 {
-	int ret = 0;
+	guard(mutex)(&kprobe_mutex);
 
-	mutex_lock(&kprobe_mutex);
 	if (WARN_ON_ONCE(__get_valid_kprobe(p)))
-		ret = -EINVAL;
-	mutex_unlock(&kprobe_mutex);
+		return -EINVAL;
 
-	return ret;
+	return 0;
 }
 
 static int check_ftrace_location(struct kprobe *p)
@@ -1631,44 +1624,17 @@ static int check_kprobe_address_safe(struct kprobe *p,
 	return ret;
 }
 
-int register_kprobe(struct kprobe *p)
+static int __register_kprobe(struct kprobe *p)
 {
 	int ret;
 	struct kprobe *old_p;
-	struct module *probed_mod;
-	kprobe_opcode_t *addr;
-	bool on_func_entry;
-
-	/* Adjust probe address from symbol */
-	addr = _kprobe_addr(p->addr, p->symbol_name, p->offset, &on_func_entry);
-	if (IS_ERR(addr))
-		return PTR_ERR(addr);
-	p->addr = addr;
-
-	ret = warn_kprobe_rereg(p);
-	if (ret)
-		return ret;
 
-	/* User can pass only KPROBE_FLAG_DISABLED to register_kprobe */
-	p->flags &= KPROBE_FLAG_DISABLED;
-	p->nmissed = 0;
-	INIT_LIST_HEAD(&p->list);
-
-	ret = check_kprobe_address_safe(p, &probed_mod);
-	if (ret)
-		return ret;
-
-	mutex_lock(&kprobe_mutex);
-
-	if (on_func_entry)
-		p->flags |= KPROBE_FLAG_ON_FUNC_ENTRY;
+	guard(mutex)(&kprobe_mutex);
 
 	old_p = get_kprobe(p->addr);
-	if (old_p) {
+	if (old_p)
 		/* Since this may unoptimize 'old_p', locking 'text_mutex'. */
-		ret = register_aggr_kprobe(old_p, p);
-		goto out;
-	}
+		return register_aggr_kprobe(old_p, p);
 
 	cpus_read_lock();
 	/* Prevent text modification */
@@ -1677,7 +1643,7 @@ int register_kprobe(struct kprobe *p)
 	mutex_unlock(&text_mutex);
 	cpus_read_unlock();
 	if (ret)
-		goto out;
+		return ret;
 
 	INIT_HLIST_NODE(&p->hlist);
 	hlist_add_head_rcu(&p->hlist,
@@ -1688,14 +1654,43 @@ int register_kprobe(struct kprobe *p)
 		if (ret) {
 			hlist_del_rcu(&p->hlist);
 			synchronize_rcu();
-			goto out;
 		}
 	}
 
 	/* Try to optimize kprobe */
 	try_to_optimize_kprobe(p);
-out:
-	mutex_unlock(&kprobe_mutex);
+	return 0;
+}
+
+int register_kprobe(struct kprobe *p)
+{
+	int ret;
+	struct module *probed_mod;
+	kprobe_opcode_t *addr;
+	bool on_func_entry;
+
+	/* Canonicalize probe address from symbol */
+	addr = _kprobe_addr(p->addr, p->symbol_name, p->offset, &on_func_entry);
+	if (IS_ERR(addr))
+		return PTR_ERR(addr);
+	p->addr = addr;
+
+	ret = warn_kprobe_rereg(p);
+	if (ret)
+		return ret;
+
+	/* User can pass only KPROBE_FLAG_DISABLED to register_kprobe */
+	p->flags &= KPROBE_FLAG_DISABLED;
+	if (on_func_entry)
+		p->flags |= KPROBE_FLAG_ON_FUNC_ENTRY;
+	p->nmissed = 0;
+	INIT_LIST_HEAD(&p->list);
+
+	ret = check_kprobe_address_safe(p, &probed_mod);
+	if (ret)
+		return ret;
+
+	ret = __register_kprobe(p);
 
 	if (probed_mod)
 		module_put(probed_mod);
@@ -1870,12 +1865,11 @@ void unregister_kprobes(struct kprobe **kps, int num)
 
 	if (num <= 0)
 		return;
-	mutex_lock(&kprobe_mutex);
-	for (i = 0; i < num; i++)
-		if (__unregister_kprobe_top(kps[i]) < 0)
-			kps[i]->addr = NULL;
-	mutex_unlock(&kprobe_mutex);
-
+	scoped_guard(mutex, &kprobe_mutex) {
+		for (i = 0; i < num; i++)
+			if (__unregister_kprobe_top(kps[i]) < 0)
+				kps[i]->addr = NULL;
+	}
 	synchronize_rcu();
 	for (i = 0; i < num; i++)
 		if (kps[i]->addr)
@@ -2314,8 +2308,9 @@ void unregister_kretprobes(struct kretprobe **rps, int num)
 
 	if (num <= 0)
 		return;
-	mutex_lock(&kprobe_mutex);
 	for (i = 0; i < num; i++) {
+		guard(mutex)(&kprobe_mutex);
+
 		if (__unregister_kprobe_top(&rps[i]->kp) < 0)
 			rps[i]->kp.addr = NULL;
 #ifdef CONFIG_KRETPROBE_ON_RETHOOK
@@ -2324,7 +2319,6 @@ void unregister_kretprobes(struct kretprobe **rps, int num)
 		rcu_assign_pointer(rps[i]->rph->rp, NULL);
 #endif
 	}
-	mutex_unlock(&kprobe_mutex);
 
 	synchronize_rcu();
 	for (i = 0; i < num; i++) {
@@ -2405,18 +2399,14 @@ static void kill_kprobe(struct kprobe *p)
 /* Disable one kprobe */
 int disable_kprobe(struct kprobe *kp)
 {
-	int ret = 0;
 	struct kprobe *p;
 
-	mutex_lock(&kprobe_mutex);
+	guard(mutex)(&kprobe_mutex);
 
 	/* Disable this kprobe */
 	p = __disable_kprobe(kp);
-	if (IS_ERR(p))
-		ret = PTR_ERR(p);
 
-	mutex_unlock(&kprobe_mutex);
-	return ret;
+	return IS_ERR(p) ? PTR_ERR(p) : 0;
 }
 EXPORT_SYMBOL_GPL(disable_kprobe);
 
@@ -2426,20 +2416,16 @@ int enable_kprobe(struct kprobe *kp)
 	int ret = 0;
 	struct kprobe *p;
 
-	mutex_lock(&kprobe_mutex);
+	guard(mutex)(&kprobe_mutex);
 
 	/* Check whether specified probe is valid. */
 	p = __get_valid_kprobe(kp);
-	if (unlikely(p == NULL)) {
-		ret = -EINVAL;
-		goto out;
-	}
+	if (unlikely(p == NULL))
+		return -EINVAL;
 
-	if (kprobe_gone(kp)) {
+	if (kprobe_gone(kp))
 		/* This kprobe has gone, we couldn't enable it. */
-		ret = -EINVAL;
-		goto out;
-	}
+		return -EINVAL;
 
 	if (p != kp)
 		kp->flags &= ~KPROBE_FLAG_DISABLED;
@@ -2453,8 +2439,6 @@ int enable_kprobe(struct kprobe *kp)
 				kp->flags |= KPROBE_FLAG_DISABLED;
 		}
 	}
-out:
-	mutex_unlock(&kprobe_mutex);
 	return ret;
 }
 EXPORT_SYMBOL_GPL(enable_kprobe);
@@ -2642,11 +2626,11 @@ static int kprobes_module_callback(struct notifier_block *nb,
 	unsigned int i;
 	int checkcore = (val == MODULE_STATE_GOING);
 
-	if (val == MODULE_STATE_COMING) {
-		mutex_lock(&kprobe_mutex);
+	guard(mutex)(&kprobe_mutex);
+
+	if (val == MODULE_STATE_COMING)
 		add_module_kprobe_blacklist(mod);
-		mutex_unlock(&kprobe_mutex);
-	}
+
 	if (val != MODULE_STATE_GOING && val != MODULE_STATE_LIVE)
 		return NOTIFY_DONE;
 
@@ -2656,7 +2640,6 @@ static int kprobes_module_callback(struct notifier_block *nb,
 	 * notified, only '.init.text' section would be freed. We need to
 	 * disable kprobes which have been inserted in the sections.
 	 */
-	mutex_lock(&kprobe_mutex);
 	for (i = 0; i < KPROBE_TABLE_SIZE; i++) {
 		head = &kprobe_table[i];
 		hlist_for_each_entry(p, head, hlist)
@@ -2679,7 +2662,6 @@ static int kprobes_module_callback(struct notifier_block *nb,
 	}
 	if (val == MODULE_STATE_GOING)
 		remove_module_kprobe_blacklist(mod);
-	mutex_unlock(&kprobe_mutex);
 	return NOTIFY_DONE;
 }
 
@@ -2707,7 +2689,7 @@ void kprobe_free_init_mem(void)
 	struct kprobe *p;
 	int i;
 
-	mutex_lock(&kprobe_mutex);
+	guard(mutex)(&kprobe_mutex);
 
 	/* Kill all kprobes on initmem because the target code has been freed. */
 	for (i = 0; i < KPROBE_TABLE_SIZE; i++) {
@@ -2717,8 +2699,6 @@ void kprobe_free_init_mem(void)
 				kill_kprobe(p);
 		}
 	}
-
-	mutex_unlock(&kprobe_mutex);
 }
 
 static int __init init_kprobes(void)
@@ -2914,11 +2894,11 @@ static int arm_all_kprobes(void)
 	unsigned int i, total = 0, errors = 0;
 	int err, ret = 0;
 
-	mutex_lock(&kprobe_mutex);
+	guard(mutex)(&kprobe_mutex);
 
 	/* If kprobes are armed, just return */
 	if (!kprobes_all_disarmed)
-		goto already_enabled;
+		return 0;
 
 	/*
 	 * optimize_kprobe() called by arm_kprobe() checks
@@ -2948,8 +2928,6 @@ static int arm_all_kprobes(void)
 	else
 		pr_info("Kprobes globally enabled\n");
 
-already_enabled:
-	mutex_unlock(&kprobe_mutex);
 	return ret;
 }
 
@@ -2960,13 +2938,11 @@ static int disarm_all_kprobes(void)
 	unsigned int i, total = 0, errors = 0;
 	int err, ret = 0;
 
-	mutex_lock(&kprobe_mutex);
+	guard(mutex)(&kprobe_mutex);
 
 	/* If kprobes are already disarmed, just return */
-	if (kprobes_all_disarmed) {
-		mutex_unlock(&kprobe_mutex);
+	if (kprobes_all_disarmed)
 		return 0;
-	}
 
 	kprobes_all_disarmed = true;
 
@@ -2991,11 +2967,8 @@ static int disarm_all_kprobes(void)
 	else
 		pr_info("Kprobes globally disabled\n");
 
-	mutex_unlock(&kprobe_mutex);
-
 	/* Wait for disarming all kprobes by optimizer */
-	wait_for_kprobe_optimizer();
-
+	wait_for_kprobe_optimizer_locked();
 	return ret;
 }
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 022/555] mmc: omap: synchronize clock timer before disabling fclk
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (20 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 021/555] kprobes: Adopt guard() and scoped_guard() Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 023/555] mmc: sunxi: Use devm_mmc_alloc_host() helper Greg Kroah-Hartman
                   ` (532 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Runyu Xiao, Ulf Hansson, Sasha Levin

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

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

From: Runyu Xiao <runyu.xiao@seu.edu.cn>

[ Upstream commit c931c51681e33b24bc8d65c6df35b70e1827daa2 ]

mmc_omap_select_slot() removes clk_timer with timer_delete() before
switching slots and changing the functional clock state.  timer_delete()
only removes a pending timer and does not wait for a callback that is
already running.

If mmc_omap_clk_timer() is already running, it can therefore call
mmc_omap_fclk_enable() while the request or slot-switch path changes the
same clock state.  During host removal, the same window can overlap the
final clock shutdown.

Use timer_delete_sync() so the callback has completed before slot switching
or changing the functional clock state.  Keep the timer restartable for
normal request handling.

Fixes: 0807a9b5739a ("MMC: OMAP: Lazy clock shutdown")
Cc: stable@vger.kernel.org
Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
Signed-off-by: Ulf Hansson <ulfh@kernel.org>
[ sashal: Replaced del_timer(&host->clk_timer) with del_timer_sync(...) in two places, since this tree predates the timer_delete* rename. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/mmc/host/omap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index ee0940d96febf..973e6ab1401cf 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -214,7 +214,7 @@ static void mmc_omap_select_slot(struct mmc_omap_slot *slot, int claimed)
 	host->mmc = slot->mmc;
 	spin_unlock_irqrestore(&host->slot_lock, flags);
 no_claim:
-	del_timer(&host->clk_timer);
+	del_timer_sync(&host->clk_timer);
 	if (host->current_slot != slot || !claimed)
 		mmc_omap_fclk_offdelay(host->current_slot);
 
@@ -273,7 +273,7 @@ static void mmc_omap_release_slot(struct mmc_omap_slot *slot, int clk_enabled)
 		/* Keeps clock running for at least 8 cycles on valid freq */
 		mod_timer(&host->clk_timer, jiffies  + HZ/10);
 	else {
-		del_timer(&host->clk_timer);
+		del_timer_sync(&host->clk_timer);
 		mmc_omap_fclk_offdelay(slot);
 		mmc_omap_fclk_enable(host, 0);
 	}
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 023/555] mmc: sunxi: Use devm_mmc_alloc_host() helper
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (21 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 022/555] mmc: omap: synchronize clock timer before disabling fclk Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 024/555] mmc: sunxi: fix clock and runtime PM leaks on probe failure Greg Kroah-Hartman
                   ` (531 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Chen-Yu Tsai, Jernej Skrabec,
	Samuel Holland, linux-sunxi, Huacai Chen, Binbin Zhou,
	Ulf Hansson, Sasha Levin

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

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

From: Binbin Zhou <zhoubinbin@loongson.cn>

[ Upstream commit 5a8af27596118f3e6a121059ac7ac8c299bee164 ]

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Chen-Yu Tsai <wens@csie.org>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
Cc: Samuel Holland <samuel@sholland.org>
Cc: linux-sunxi@lists.linux.dev
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
Link: https://lore.kernel.org/r/ee7726b1ea37084258a5d8cec67cad12473152c2.1748933789.git.zhoubinbin@loongson.cn
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Stable-dep-of: e35e360bd668 ("mmc: sunxi: fix clock and runtime PM leaks on probe failure")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/mmc/host/sunxi-mmc.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c
index e0ab5fd635e6c..cc7c8594a6cac 100644
--- a/drivers/mmc/host/sunxi-mmc.c
+++ b/drivers/mmc/host/sunxi-mmc.c
@@ -1369,11 +1369,10 @@ static int sunxi_mmc_probe(struct platform_device *pdev)
 	struct mmc_host *mmc;
 	int ret;
 
-	mmc = mmc_alloc_host(sizeof(struct sunxi_mmc_host), &pdev->dev);
-	if (!mmc) {
-		dev_err(&pdev->dev, "mmc alloc host failed\n");
-		return -ENOMEM;
-	}
+	mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(*host));
+	if (!mmc)
+		return dev_err_probe(&pdev->dev, -ENOMEM,
+				     "mmc alloc host failed\n");
 	platform_set_drvdata(pdev, mmc);
 
 	host = mmc_priv(mmc);
@@ -1383,15 +1382,13 @@ static int sunxi_mmc_probe(struct platform_device *pdev)
 
 	ret = sunxi_mmc_resource_request(host, pdev);
 	if (ret)
-		goto error_free_host;
+		return ret;
 
 	host->sg_cpu = dma_alloc_coherent(&pdev->dev, PAGE_SIZE,
 					  &host->sg_dma, GFP_KERNEL);
-	if (!host->sg_cpu) {
-		dev_err(&pdev->dev, "Failed to allocate DMA descriptor mem\n");
-		ret = -ENOMEM;
-		goto error_free_host;
-	}
+	if (!host->sg_cpu)
+		return dev_err_probe(&pdev->dev, -ENOMEM,
+				     "Failed to allocate DMA descriptor mem\n");
 
 	if (host->cfg->ccu_has_timings_switch) {
 		/*
@@ -1481,8 +1478,6 @@ static int sunxi_mmc_probe(struct platform_device *pdev)
 
 error_free_dma:
 	dma_free_coherent(&pdev->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma);
-error_free_host:
-	mmc_free_host(mmc);
 	return ret;
 }
 
@@ -1498,7 +1493,6 @@ static void sunxi_mmc_remove(struct platform_device *pdev)
 		sunxi_mmc_disable(host);
 	}
 	dma_free_coherent(&pdev->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma);
-	mmc_free_host(mmc);
 }
 
 #ifdef CONFIG_PM
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 024/555] mmc: sunxi: fix clock and runtime PM leaks on probe failure
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (22 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 023/555] mmc: sunxi: Use devm_mmc_alloc_host() helper Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 025/555] errseq: eliminate special limitation for macro MAX_ERRNO Greg Kroah-Hartman
                   ` (530 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Anfernee Cao, Ulf Hansson,
	Sasha Levin

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

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

From: Anfernee Cao <anferneemelokc5@gmail.com>

[ Upstream commit e35e360bd66898a977c296ab71fe4bae17ddceb7 ]

sunxi_mmc_resource_request() enables the bus, card, output and sample
clocks before returning. Several failure paths later in
sunxi_mmc_probe() leave them running:

 - If devm_request_threaded_irq() fails, the clocks enabled by
   sunxi_mmc_enable() are never disabled.
 - If dma_alloc_coherent(), mmc_of_parse() or sunxi_mmc_init_host()
   fails, probe only frees the DMA buffer and the mmc_host.
 - If mmc_add_host() fails, runtime PM has already been enabled, but
   pm_runtime_disable() is never called.

Besides leaking the clocks, this leaves the clock enable counts
unbalanced, so a reprobe (for example after -EPROBE_DEFER) calls
clk_prepare_enable() on the same clocks again.

Disable the IRQ and the clocks in the probe error path, and disable
runtime PM on the mmc_add_host() failure path. Also handle a failure of
devm_request_threaded_irq() in sunxi_mmc_resource_request().

Tested with QEMU's orangepi-pc machine: with forced sunxi_mmc_init_host()
and mmc_add_host() failures the MMC clocks stay disabled in clk_summary,
and a normal probe with an emulated SD card still works.

This issue was found by manual code inspection.

Fixes: 3cbcb16095f9 ("mmc: sunxi: Add driver for SD/MMC hosts found on Allwinner sunxi SoCs")
Fixes: 9a8e1e8cc2c0 ("mmc: sunxi: Add runtime_pm support")
Cc: stable@vger.kernel.org # v4.18+
Signed-off-by: Anfernee Cao <anferneemelokc5@gmail.com>
Signed-off-by: Ulf Hansson <ulfh@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/mmc/host/sunxi-mmc.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c
index cc7c8594a6cac..785899eb9f868 100644
--- a/drivers/mmc/host/sunxi-mmc.c
+++ b/drivers/mmc/host/sunxi-mmc.c
@@ -1355,8 +1355,13 @@ static int sunxi_mmc_resource_request(struct sunxi_mmc_host *host,
 		goto error_disable_mmc;
 	}
 
-	return devm_request_threaded_irq(&pdev->dev, host->irq, sunxi_mmc_irq,
-			sunxi_mmc_handle_manual_stop, 0, "sunxi-mmc", host);
+	ret = devm_request_threaded_irq(&pdev->dev, host->irq, sunxi_mmc_irq,
+					sunxi_mmc_handle_manual_stop, 0,
+					"sunxi-mmc", host);
+	if (ret)
+		goto error_disable_mmc;
+
+	return 0;
 
 error_disable_mmc:
 	sunxi_mmc_disable(host);
@@ -1386,9 +1391,11 @@ static int sunxi_mmc_probe(struct platform_device *pdev)
 
 	host->sg_cpu = dma_alloc_coherent(&pdev->dev, PAGE_SIZE,
 					  &host->sg_dma, GFP_KERNEL);
-	if (!host->sg_cpu)
-		return dev_err_probe(&pdev->dev, -ENOMEM,
-				     "Failed to allocate DMA descriptor mem\n");
+	if (!host->sg_cpu) {
+		ret = dev_err_probe(&pdev->dev, -ENOMEM,
+				    "Failed to allocate DMA descriptor mem\n");
+		goto error_disable_mmc;
+	}
 
 	if (host->cfg->ccu_has_timings_switch) {
 		/*
@@ -1468,7 +1475,7 @@ static int sunxi_mmc_probe(struct platform_device *pdev)
 
 	ret = mmc_add_host(mmc);
 	if (ret)
-		goto error_free_dma;
+		goto error_disable_rpm;
 
 	dev_info(&pdev->dev, "initialized, max. request size: %u KB%s\n",
 		 mmc->max_req_size >> 10,
@@ -1476,8 +1483,13 @@ static int sunxi_mmc_probe(struct platform_device *pdev)
 
 	return 0;
 
+error_disable_rpm:
+	pm_runtime_disable(&pdev->dev);
 error_free_dma:
 	dma_free_coherent(&pdev->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma);
+error_disable_mmc:
+	disable_irq(host->irq);
+	sunxi_mmc_disable(host);
 	return ret;
 }
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 025/555] errseq: eliminate special limitation for macro MAX_ERRNO
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (23 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 024/555] mmc: sunxi: fix clock and runtime PM leaks on probe failure Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 026/555] errseq: dont let errseq_check_and_advance() hide later errors Greg Kroah-Hartman
                   ` (529 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Zijun Hu, Jeff Layton, Andrew Morton,
	Sasha Levin

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

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

From: Zijun Hu <quic_zijuhu@quicinc.com>

[ Upstream commit 3eff6a3e574c2f704f9be1f4867c3d0b3d804435 ]

Current errseq implementation depends on a very special precondition that
macro MAX_ERRNO must be (2^n - 1).

Eliminate the limitation by

- redefining macro ERRSEQ_SHIFT
- defining a new macro ERRNO_MASK instead of MAX_ERRNO for errno mask.

There is no plan to change the value of MAX_ERRNO, but this makes the
implementation more generic and eliminates the BUILD_BUG_ON().

Link: https://lkml.kernel.org/r/20250407-improve_errseq-v1-1-7b27cbeb8298@quicinc.com
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Stable-dep-of: 94defd41d80f ("errseq: don't let errseq_check_and_advance() hide later errors")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 lib/errseq.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/lib/errseq.c b/lib/errseq.c
index 93e9b94358dc6..13a2581c5a878 100644
--- a/lib/errseq.c
+++ b/lib/errseq.c
@@ -34,11 +34,14 @@
  */
 
 /* The low bits are designated for error code (max of MAX_ERRNO) */
-#define ERRSEQ_SHIFT		ilog2(MAX_ERRNO + 1)
+#define ERRSEQ_SHIFT		(ilog2(MAX_ERRNO) + 1)
 
 /* This bit is used as a flag to indicate whether the value has been seen */
 #define ERRSEQ_SEEN		(1 << ERRSEQ_SHIFT)
 
+/* Leverage macro ERRSEQ_SEEN to define errno mask macro here */
+#define ERRNO_MASK		(ERRSEQ_SEEN - 1)
+
 /* The lowest bit of the counter */
 #define ERRSEQ_CTR_INC		(1 << (ERRSEQ_SHIFT + 1))
 
@@ -60,8 +63,6 @@ errseq_t errseq_set(errseq_t *eseq, int err)
 {
 	errseq_t cur, old;
 
-	/* MAX_ERRNO must be able to serve as a mask */
-	BUILD_BUG_ON_NOT_POWER_OF_2(MAX_ERRNO + 1);
 
 	/*
 	 * Ensure the error code actually fits where we want it to go. If it
@@ -79,7 +80,7 @@ errseq_t errseq_set(errseq_t *eseq, int err)
 		errseq_t new;
 
 		/* Clear out error bits and set new error */
-		new = (old & ~(MAX_ERRNO|ERRSEQ_SEEN)) | -err;
+		new = (old & ~(ERRNO_MASK | ERRSEQ_SEEN)) | -err;
 
 		/* Only increment if someone has looked at it */
 		if (old & ERRSEQ_SEEN)
@@ -148,7 +149,7 @@ int errseq_check(errseq_t *eseq, errseq_t since)
 
 	if (likely(cur == since))
 		return 0;
-	return -(cur & MAX_ERRNO);
+	return -(cur & ERRNO_MASK);
 }
 EXPORT_SYMBOL(errseq_check);
 
@@ -200,7 +201,7 @@ int errseq_check_and_advance(errseq_t *eseq, errseq_t *since)
 		if (new != old)
 			cmpxchg(eseq, old, new);
 		*since = new;
-		err = -(new & MAX_ERRNO);
+		err = -(new & ERRNO_MASK);
 	}
 	return err;
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 026/555] errseq: dont let errseq_check_and_advance() hide later errors
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (24 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 025/555] errseq: eliminate special limitation for macro MAX_ERRNO Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 027/555] xsk: defer software checksum until the skb is complete Greg Kroah-Hartman
                   ` (528 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Shashank Mohan Jain, Jan Kara,
	Jeff Layton, Christian Brauner (Amutable), Sasha Levin

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

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

From: Shashank Mohan Jain <jain.sm@gmail.com>

[ Upstream commit 94defd41d80f10bbe883c0c8d1b28d1665b6b153 ]

errseq_check_and_advance() reads the errseq_t, sets ERRSEQ_SEEN with a
cmpxchg() and then advances *since to the value it computed, ignoring
whether the cmpxchg() succeeded. When it fails because errseq_set()
recorded a different error in the meantime, *since ends up holding a
value that was never stored in the errseq_t.

errseq_set() only bumps the counter when ERRSEQ_SEEN is set. So as long
as nobody has seen the new error, recording the original errno again
recreates exactly the old value, and once another subscriber marks it
seen, it is equal to the stale *since. The next check through that
cursor then reports nothing, although -ENOSPC was recorded after the
value that check reported, and -EIO was recorded again after it
returned:

  cursor f                writeback              cursor g
  --------                ---------              --------
                          set(-EIO)
  check_and_advance(&f)
    old = [c, EIO]
                          set(-ENOSPC)
                          -> [c, ENOSPC]
    cmpxchg() fails
    f = [c, EIO, SEEN]
    returns -EIO
                          set(-EIO)
                          -> [c, EIO]
                          (no bump: unseen)
                                                 check_and_advance(&g)
                                                 -> [c, EIO, SEEN]
                                                 returns -EIO
  check_and_advance(&f)
    [c, EIO, SEEN] == f
    returns 0             <- -ENOSPC and the second -EIO are lost

For file->f_wb_err this means that fsync() on one descriptor can return
0 although writeback failed after the previous fsync() on that
descriptor returned, when writeback errors race with fsync() on another
descriptor of the same file. The same applies to syncfs() through
sb->s_wb_err, which every file on the filesystem shares, and to the
ext4 and jbd2 cursors on the block device mapping. The kernel-doc
promises "Negative errno if one has been stored, or 0 if no new error
has occurred".

Retry with the value found when the cmpxchg() fails, so that *since is
only ever advanced to a value that was actually stored with ERRSEQ_SEEN
set. Every later errseq_set() then has to bump the counter, and the
error is reported. The retry loop terminates because each iteration
needs a concurrent update, like the loop in errseq_set().

A TLA+ model of errseq_set() and errseq_check_and_advance(), checked
with the TLC model checker, finds the lost error with the current code;
with this change TLC checks that an error recorded after a check
returned is always reported by the next check (exhaustively for two
subscribers with three checks each, and one writer recording four
errors or two writers recording two each). The KUnit race test added
in the next patch misses the error in 1-6% of 2 million rounds on
4-CPU UML before this change (depending on host load), and in none
after it.

Fixes: 84cbadadc6ea ("lib: add errseq_t type and infrastructure for handling it")
Cc: stable@vger.kernel.org
Signed-off-by: Shashank Mohan Jain <jain.sm@gmail.com>
Link: https://patch.msgid.link/20260927051726.71337-2-jain.sm@gmail.com
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 lib/errseq.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/lib/errseq.c b/lib/errseq.c
index 13a2581c5a878..ea4ff9cc21669 100644
--- a/lib/errseq.c
+++ b/lib/errseq.c
@@ -162,7 +162,8 @@ EXPORT_SYMBOL(errseq_check);
  * points to. If it does, then just return 0.
  *
  * If it doesn't, then the value has changed. Set the "seen" flag, and try to
- * swap it into place as the new eseq value. Then, set that value as the new
+ * swap it into place as the new eseq value. If the swap fails because the
+ * value changed, retry with the new value. Then, set that value as the new
  * "since" value, and return whatever the error portion is set to.
  *
  * Note that no locking is provided here for concurrent updates to the "since"
@@ -184,24 +185,30 @@ int errseq_check_and_advance(errseq_t *eseq, errseq_t *since)
 	 * to take the lock that protects the "since" value.
 	 */
 	old = READ_ONCE(*eseq);
-	if (old != *since) {
+	while (old != *since) {
 		/*
 		 * Set the flag and try to swap it into place if it has
 		 * changed.
 		 *
-		 * We don't care about the outcome of the swap here. If the
-		 * swap doesn't occur, then it has either been updated by a
-		 * writer who is altering the value in some way (updating
-		 * counter or resetting the error), or another reader who is
-		 * just setting the "seen" flag. Either outcome is OK, and we
-		 * can advance "since" and return an error based on what we
-		 * have.
+		 * If the swap fails, a writer or another reader changed the
+		 * value under us, so retry with the new value.  "since" must
+		 * only ever be set to a value that was stored with the SEEN
+		 * flag: errseq_set() does not bump the counter while the
+		 * flag is clear, so an unstored value could come back later
+		 * and hide the errors that were recorded in the meantime.
 		 */
 		new = old | ERRSEQ_SEEN;
-		if (new != old)
-			cmpxchg(eseq, old, new);
+		if (new != old) {
+			errseq_t cur = cmpxchg(eseq, old, new);
+
+			if (cur != old) {
+				old = cur;
+				continue;
+			}
+		}
 		*since = new;
 		err = -(new & ERRNO_MASK);
+		break;
 	}
 	return err;
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 027/555] xsk: defer software checksum until the skb is complete
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (25 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 026/555] errseq: dont let errseq_check_and_advance() hide later errors Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 028/555] cpufreq: Improve suspend-resume synchronization Greg Kroah-Hartman
                   ` (527 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Maciej Fijalkowski,
	Stanislav Fomichev, Jason Xing, Rongzheng Wang, Paolo Abeni,
	Sasha Levin

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

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

From: Rongzheng Wang <testwrzwrz@gmail.com>

[ Upstream commit f2eddafbfcc004098425fee7c5664adbe29152d7 ]

When XDP_UMEM_TX_SW_CSUM is used with multi-buffer TX, xsk_skb_metadata()
calls skb_checksum_help() while only the first descriptor has been added to
the skb. The checksum therefore covers just the first fragment, and
skb_checksum_help() sets ip_summed to CHECKSUM_NONE, so the remaining
fragments are never included in the checksum.

Move the software checksum calculation to the point where the last
descriptor has been added to the skb.

On a checksum failure the packet is now dropped instead of being returned
to the application for a retry. This path is not reachable with the
existing metadata validation, but the behavior change is intentional.

Fixes: 11614723af26 ("xsk: Add option to calculate TX checksum in SW")
Cc: stable@vger.kernel.org
Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Reviewed-by: Jason Xing <kerneljasonxing@gmail.com>
Signed-off-by: Rongzheng Wang <testwrzwrz@gmail.com>
Link: https://patch.msgid.link/20261104034809.24545-2-testwrzwrz@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
[ sashal: Open-coded the final-descriptor software checksum call in the xmit loop and removed the early one inline, since there is no metadata helper split, and drop uses cancel-reservation semantics. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/xdp/xsk.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 1bc966669ec96..028791b80fbbc 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -952,12 +952,6 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,
 				skb->csum_start = hr + csum_start;
 				skb->csum_offset = csum_offset;
 				skb->ip_summed = CHECKSUM_PARTIAL;
-
-				if (unlikely(xs->pool->tx_sw_csum)) {
-					err = skb_checksum_help(skb);
-					if (err)
-						goto free_err;
-				}
 			}
 		}
 	}
@@ -1052,6 +1046,15 @@ static int __xsk_generic_xmit(struct sock *sk)
 			continue;
 		}
 
+		if (unlikely(xs->pool->tx_sw_csum &&
+			     skb->ip_summed == CHECKSUM_PARTIAL)) {
+			err = skb_checksum_help(skb);
+			if (unlikely(err)) {
+				xsk_drop_skb(skb);
+				goto out;
+			}
+		}
+
 		err = __dev_direct_xmit(skb, xs->queue_id);
 		if  (err == NETDEV_TX_BUSY) {
 			/* Tell user-space to retry the send */
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 028/555] cpufreq: Improve suspend-resume synchronization
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (26 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 027/555] xsk: defer software checksum until the skb is complete Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 029/555] tpm: flush timeout work outside buffer_mutex to avoid deadlock Greg Kroah-Hartman
                   ` (526 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Rafael J. Wysocki,
	Zak Brighton Knight, Zhongqiu Han, Viresh Kumar, Doug Smythies,
	Christian Loehle, Sasha Levin

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

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

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

[ Upstream commit eee2a44e4e2b41c0699919a550d41cc38daa4f42 ]

The suspend-resume synchronization in the cpufreq core is not perfect
because the global cpufreq_suspended variable is set at the end of
cpufreq_suspend() after stopping governors for all of the active
policies, so the governor .limits() callback may run via
cpufreq_governor_limits() after stopping the governor and before
setting cpufreq_suspended which is questionable.  Likewise, the
governor .limits() callback may run between clearing cpufreq_suspended
in cpufreq_resume() and starting the governor.

Address this by adding a per-policy "suspended" flag that is always
read under the policy rwsem and is updated under it when the governor
is stopped in cpufreq_suspend() and when the governor is restarted in
cpufreq_resume().

Also make cpufreq_resume() use the cpus_read_lock guard to reflect
what is done in cpufreq_suspend() and call cpufreq_exit_governor() for
policies that were suspended during a system suspend transition and
are inactive during the subsequent system resume (to avoid leaking an
inactive policy with a stopped governor that has not exited yet).

Fixes: 8e30444e1530 ("cpufreq: fix cpufreq suspend/resume for intel_pstate")
Fixes: b1b12babe3b7 ("cpufreq: update 'cpufreq_suspended' after stopping governors")
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Zak Brighton Knight <zakbrightonknight@gmail.com>
Reviewed-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Doug Smythies <dsmythies@telus.net>
Tested-by: Christian Loehle <christian.loehle@arm.com>
Link: https://patch.msgid.link/4796894.LvFx2qVVIh@rafael.j.wysocki
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[ sashal: Open-coded down_write()/up_write() with a goto-unlock label replaces the policy write guard, and the cpufreq_policy_refresh() change went into cpufreq_update_policy(); only the suspended field was added to the header. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/cpufreq/cpufreq.c | 89 +++++++++++++++++++++++++++++----------
 include/linux/cpufreq.h   |  3 ++
 2 files changed, 69 insertions(+), 23 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index aee7e081b6c64..f21e28cbecd59 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -34,6 +34,9 @@
 static LIST_HEAD(cpufreq_policy_list);
 
 /* Macros to iterate over CPU policies */
+#define for_each_policy(__policy)	\
+	list_for_each_entry(__policy, &cpufreq_policy_list, policy_list)
+
 #define for_each_suitable_policy(__policy, __active)			 \
 	list_for_each_entry(__policy, &cpufreq_policy_list, policy_list) \
 		if ((__active) == !policy_is_inactive(__policy))
@@ -1944,6 +1947,14 @@ int cpufreq_generic_suspend(struct cpufreq_policy *policy)
 }
 EXPORT_SYMBOL(cpufreq_generic_suspend);
 
+static void cpufreq_suspend_policy(struct cpufreq_policy *policy)
+{
+	down_write(&policy->rwsem);
+	cpufreq_stop_governor(policy);
+	policy->suspended = true;
+	up_write(&policy->rwsem);
+}
+
 /**
  * cpufreq_suspend() - Suspend CPUFreq governors.
  *
@@ -1966,11 +1977,8 @@ void cpufreq_suspend(void)
 	pr_debug("%s: Suspending Governors\n", __func__);
 
 	for_each_active_policy(policy) {
-		if (has_target()) {
-			down_write(&policy->rwsem);
-			cpufreq_stop_governor(policy);
-			up_write(&policy->rwsem);
-		}
+		if (has_target())
+			cpufreq_suspend_policy(policy);
 
 		if (cpufreq_driver->suspend && cpufreq_driver->suspend(policy))
 			pr_err("%s: Failed to suspend driver: %s\n", __func__,
@@ -1982,6 +1990,35 @@ void cpufreq_suspend(void)
 	cpus_read_unlock();
 }
 
+static void cpufreq_resume_policy(struct cpufreq_policy *policy, bool start)
+{
+	down_write(&policy->rwsem);
+
+	if (!policy->suspended)
+		goto unlock;
+
+	policy->suspended = false;
+
+	if (policy_is_inactive(policy)) {
+		/*
+		 * The policy was active when it was suspended, so its governor
+		 * is still there.  Let the governor go.
+		 */
+		cpufreq_exit_governor(policy);
+		goto unlock;
+	}
+
+	if (!start)
+		goto unlock;
+
+	if (cpufreq_start_governor(policy))
+		pr_err("%s: Failed to start governor for CPU%u's policy\n",
+		       __func__, policy->cpu);
+
+unlock:
+	up_write(&policy->rwsem);
+}
+
 /**
  * cpufreq_resume() - Resume CPUFreq governors.
  *
@@ -1991,11 +2028,12 @@ void cpufreq_suspend(void)
 void cpufreq_resume(void)
 {
 	struct cpufreq_policy *policy;
-	int ret;
 
 	if (!cpufreq_driver)
 		return;
 
+	guard(cpus_read_lock)();
+
 	if (unlikely(!cpufreq_suspended))
 		return;
 
@@ -2006,19 +2044,18 @@ void cpufreq_resume(void)
 
 	pr_debug("%s: Resuming Governors\n", __func__);
 
-	for_each_active_policy(policy) {
-		if (cpufreq_driver->resume && cpufreq_driver->resume(policy)) {
-			pr_err("%s: Failed to resume driver: %s\n", __func__,
-				cpufreq_driver->name);
-		} else if (has_target()) {
-			down_write(&policy->rwsem);
-			ret = cpufreq_start_governor(policy);
-			up_write(&policy->rwsem);
+	for_each_policy(policy) {
+		int ret = 0;
 
+		if (cpufreq_driver->resume && !policy_is_inactive(policy)) {
+			ret = cpufreq_driver->resume(policy);
 			if (ret)
-				pr_err("%s: Failed to start governor for CPU%u's policy\n",
-				       __func__, policy->cpu);
+				pr_err("%s: Failed to resume driver: %s\n", __func__,
+				       cpufreq_driver->name);
 		}
+
+		if (has_target())
+			cpufreq_resume_policy(policy, ret == 0);
 	}
 }
 
@@ -2398,12 +2435,17 @@ __weak struct cpufreq_governor *cpufreq_fallback_governor(void)
 	return NULL;
 }
 
+static bool cpufreq_is_suspended(struct cpufreq_policy *policy)
+{
+	return cpufreq_suspended || policy->suspended;
+}
+
 static int cpufreq_init_governor(struct cpufreq_policy *policy)
 {
 	int ret;
 
-	/* Don't start any governor operations if we are entering suspend */
-	if (cpufreq_suspended)
+	/* Don't start any governor operations for suspended policies. */
+	if (cpufreq_is_suspended(policy))
 		return 0;
 	/*
 	 * Governor might not be initiated here if ACPI _PPC changed
@@ -2446,7 +2488,7 @@ static int cpufreq_init_governor(struct cpufreq_policy *policy)
 
 static void cpufreq_exit_governor(struct cpufreq_policy *policy)
 {
-	if (cpufreq_suspended || !policy->governor)
+	if (cpufreq_is_suspended(policy) || !policy->governor)
 		return;
 
 	pr_debug("%s: for CPU %u\n", __func__, policy->cpu);
@@ -2461,7 +2503,7 @@ int cpufreq_start_governor(struct cpufreq_policy *policy)
 {
 	int ret;
 
-	if (cpufreq_suspended)
+	if (cpufreq_is_suspended(policy))
 		return 0;
 
 	if (!policy->governor)
@@ -2486,7 +2528,7 @@ int cpufreq_start_governor(struct cpufreq_policy *policy)
 
 void cpufreq_stop_governor(struct cpufreq_policy *policy)
 {
-	if (cpufreq_suspended || !policy->governor)
+	if (cpufreq_is_suspended(policy) || !policy->governor)
 		return;
 
 	pr_debug("%s: for CPU %u\n", __func__, policy->cpu);
@@ -2497,7 +2539,7 @@ void cpufreq_stop_governor(struct cpufreq_policy *policy)
 
 static void cpufreq_governor_limits(struct cpufreq_policy *policy)
 {
-	if (cpufreq_suspended || !policy->governor)
+	if (cpufreq_is_suspended(policy) || !policy->governor)
 		return;
 
 	pr_debug("%s: for CPU %u\n", __func__, policy->cpu);
@@ -2762,7 +2804,8 @@ void cpufreq_update_policy(unsigned int cpu)
 	 * -> ask driver for current freq and notify governors about a change
 	 */
 	if (cpufreq_driver->get && has_target() &&
-	    (cpufreq_suspended || WARN_ON(!cpufreq_verify_current_freq(policy, false))))
+	    (cpufreq_is_suspended(policy) ||
+	     WARN_ON(!cpufreq_verify_current_freq(policy, false))))
 		goto unlock;
 
 	refresh_frequency_limits(policy);
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 1e87507ea16ff..5947659a4b9d4 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -147,6 +147,9 @@ struct cpufreq_policy {
 	/* Per policy boost enabled flag. */
 	bool			boost_enabled;
 
+	/* The policy has been suspended. */
+	bool			suspended;
+
 	 /* Cached frequency lookup from cpufreq_driver_resolve_freq. */
 	unsigned int cached_target_freq;
 	unsigned int cached_resolved_idx;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 029/555] tpm: flush timeout work outside buffer_mutex to avoid deadlock
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (27 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 028/555] cpufreq: Improve suspend-resume synchronization Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 030/555] spi: tegra210-quad: Track DMA mapping state Greg Kroah-Hartman
                   ` (525 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Hyunjung Ko, Jarkko Sakkinen,
	Sasha Levin

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

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

From: Hyunjung Ko <hj351016@gmail.com>

[ Upstream commit c22052a012698ce56d599d75b669d55778521c7c ]

tpm_common_read() calls flush_work(&priv->timeout_work) under
priv->buffer_mutex, but tpm_timeout_work() also takes buffer_mutex, so a
running timeout work deadlocks the flush. Flush after unlocking; the timer
is deleted under the lock, so no new work can be queued.

Fixes: 9488585b21be ("tpm: add support for partial reads")
Cc: stable@vger.kernel.org
Signed-off-by: Hyunjung Ko <hj351016@gmail.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Link: https://lore.kernel.org/r/20261108165812.676876-1-hj351016@gmail.com
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
[ sashal: Replaced timer_delete_sync() with the older del_timer_sync() name that this tree uses; the rest matches upstream. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/char/tpm/tpm-dev-common.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm-dev-common.c b/drivers/char/tpm/tpm-dev-common.c
index 1bfdcb9794e20..98b35c4e8bc8c 100644
--- a/drivers/char/tpm/tpm-dev-common.c
+++ b/drivers/char/tpm/tpm-dev-common.c
@@ -132,6 +132,7 @@ ssize_t tpm_common_read(struct file *file, char __user *buf,
 {
 	struct file_priv *priv = file->private_data;
 	ssize_t ret_size = 0;
+	bool flush = false;
 	int rc;
 
 	if (!size)
@@ -164,9 +165,18 @@ ssize_t tpm_common_read(struct file *file, char __user *buf,
 	if (!priv->response_length) {
 		*off = 0;
 		del_timer_sync(&priv->user_read_timer);
-		flush_work(&priv->timeout_work);
+		flush = true;
 	}
 	mutex_unlock(&priv->buffer_mutex);
+
+	/*
+	 * tpm_timeout_work() takes buffer_mutex, so flush it after dropping
+	 * the mutex to avoid a deadlock; the timer is deleted above, so no new
+	 * timeout work can be queued once the mutex is released.
+	 */
+	if (flush)
+		flush_work(&priv->timeout_work);
+
 	return ret_size;
 }
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 030/555] spi: tegra210-quad: Track DMA mapping state
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (28 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 029/555] tpm: flush timeout work outside buffer_mutex to avoid deadlock Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 031/555] watchdog: npcm: Remove unnecessary NULL check before clk_prepare_enable/clk_disable_unprepare Greg Kroah-Hartman
                   ` (524 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Mark Brown, Vishwaroop A,
	Sasha Levin

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

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

From: Vishwaroop A <va@nvidia.com>

[ Upstream commit 7b9e6f7bc13c0259b192d0a964e802d4ad53b8b8 ]

tegra_qspi_dma_unmap_xfer() assumes a streaming mapping is always
outstanding and recomputes its length from the live
tqspi->curr_dma_words. Nothing records whether tegra_qspi_dma_map_xfer()
mapped anything, so neither assumption holds.

For a multi-chunk transfer, handle_dma_based_xfer() unmaps the chunk that
just completed, recalculates the parameters for the next chunk, which
overwrites curr_dma_words, and re-arms the hardware. If
tegra_qspi_start_dma_based_transfer() then fails at its
tegra_qspi_dma_map_xfer() call, nothing is mapped. That early return also
sits above the smp_store_release() that clears tqspi->trans_status, so the
previous chunk's QSPI_RDY survives, and the re-arm's return value is never
checked, so handle_dma_based_xfer() returns IRQ_HANDLED without completing
the transfer.

The caller times out, tegra_qspi_handle_timeout() sees the stale QSPI_RDY,
concludes the transfer completed and calls handle_dma_based_xfer() again.
No DMA completion arrives, so num_errors is incremented and
tegra_qspi_dma_unmap_xfer() runs with nothing mapped. t->tx_dma then holds
either the DMA_MAPPING_ERROR sentinel or, if the RX mapping was the one
that failed, the preceding chunk's address that has already been released.
Behind an IOMMU the latter frees an IOVA that may since have been
reallocated.

Record whether a mapping is outstanding and the length that was mapped,
and return early from tegra_qspi_dma_unmap_xfer() when there is nothing to
release. is_dma_mapped is only updated under tqspi->lock, or on the timeout
path after synchronize_irq() and cancel_work_sync() have quiesced the ISR
and the bottom half.

Also skip releasing the TX mapping on the RX failure path unless a TX
mapping was created; t->tx_dma is uninitialised when t->tx_buf is NULL.

Fixes: 921fc1838fb0 ("spi: tegra210-quad: Add support for Tegra210 QSPI controller")
Suggested-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Vishwaroop A <va@nvidia.com>
Link: https://patch.msgid.link/20261026111412.3843954-3-va@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
[ sashal: Replaced the single tqspi->dev DMA device uses for the missing tx_dma_dev/rx_dma_dev split, keeping the upstream mapping-state tracking and unmap logic unchanged. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/spi/spi-tegra210-quad.c | 31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/drivers/spi/spi-tegra210-quad.c b/drivers/spi/spi-tegra210-quad.c
index 14dd98b92bd93..ca91a69ea059e 100644
--- a/drivers/spi/spi-tegra210-quad.c
+++ b/drivers/spi/spi-tegra210-quad.c
@@ -207,6 +207,17 @@ struct tegra_qspi {
 	bool					is_packed;
 	bool					use_dma;
 
+	/*
+	 * Set while a streaming mapping created by
+	 * tegra_qspi_dma_map_xfer() is outstanding, together with the
+	 * length that was handed to dma_map_single(). is_curr_dma_xfer
+	 * only records that the last armed chunk took the DMA path,
+	 * which is not the same thing: a chunk whose mapping failed
+	 * leaves the DMA path flagged with nothing mapped.
+	 */
+	bool					is_dma_mapped;
+	unsigned int				dma_map_len;
+
 	u32					command1_reg;
 	u32					dma_control_reg;
 	u32					def_command1_reg;
@@ -586,22 +597,32 @@ static int tegra_qspi_dma_map_xfer(struct tegra_qspi *tqspi, struct spi_transfer
 	if (t->rx_buf) {
 		t->rx_dma = dma_map_single(tqspi->dev, (void *)rx_buf, len, DMA_FROM_DEVICE);
 		if (dma_mapping_error(tqspi->dev, t->rx_dma)) {
-			dma_unmap_single(tqspi->dev, t->tx_dma, len, DMA_TO_DEVICE);
+			if (t->tx_buf)
+				dma_unmap_single(tqspi->dev, t->tx_dma,
+						 len, DMA_TO_DEVICE);
 			return -ENOMEM;
 		}
 	}
 
+	tqspi->dma_map_len = len;
+	tqspi->is_dma_mapped = true;
+
 	return 0;
 }
 
 static void tegra_qspi_dma_unmap_xfer(struct tegra_qspi *tqspi, struct spi_transfer *t)
 {
-	unsigned int len;
+	if (!tqspi->is_dma_mapped)
+		return;
 
-	len = DIV_ROUND_UP(tqspi->curr_dma_words * tqspi->bytes_per_word, 4) * 4;
+	if (t->tx_buf)
+		dma_unmap_single(tqspi->dev, t->tx_dma,
+				 tqspi->dma_map_len, DMA_TO_DEVICE);
+	if (t->rx_buf)
+		dma_unmap_single(tqspi->dev, t->rx_dma,
+				 tqspi->dma_map_len, DMA_FROM_DEVICE);
 
-	dma_unmap_single(tqspi->dev, t->tx_dma, len, DMA_TO_DEVICE);
-	dma_unmap_single(tqspi->dev, t->rx_dma, len, DMA_FROM_DEVICE);
+	tqspi->is_dma_mapped = false;
 }
 
 static int tegra_qspi_start_dma_based_transfer(struct tegra_qspi *tqspi, struct spi_transfer *t)
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 031/555] watchdog: npcm: Remove unnecessary NULL check before clk_prepare_enable/clk_disable_unprepare
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (29 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 030/555] spi: tegra210-quad: Track DMA mapping state Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 032/555] watchdog: npcm: fix clock prepare leak when setting timeout on a running watchdog Greg Kroah-Hartman
                   ` (523 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Chen Ni, Guenter Roeck,
	Wim Van Sebroeck, Sasha Levin

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

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

From: Chen Ni <nichen@iscas.ac.cn>

[ Upstream commit ad3746700ae238a96a9a4244d02a2e8eb00f157e ]

clk_prepare_enable() and clk_disable_unprepare() already checked
NULL clock parameter.Remove unneeded NULL check for clk here.

Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20250313084420.2481763-1-nichen@iscas.ac.cn
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
Stable-dep-of: 57c7cbe21acc ("watchdog: npcm: fix clock prepare leak when setting timeout on a running watchdog")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/watchdog/npcm_wdt.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/watchdog/npcm_wdt.c b/drivers/watchdog/npcm_wdt.c
index a5dd1c2301374..e62ea054bc618 100644
--- a/drivers/watchdog/npcm_wdt.c
+++ b/drivers/watchdog/npcm_wdt.c
@@ -68,8 +68,7 @@ static int npcm_wdt_start(struct watchdog_device *wdd)
 	struct npcm_wdt *wdt = to_npcm_wdt(wdd);
 	u32 val;
 
-	if (wdt->clk)
-		clk_prepare_enable(wdt->clk);
+	clk_prepare_enable(wdt->clk);
 
 	if (wdd->timeout < 2)
 		val = 0x800;
@@ -105,8 +104,7 @@ static int npcm_wdt_stop(struct watchdog_device *wdd)
 
 	writel(0, wdt->reg);
 
-	if (wdt->clk)
-		clk_disable_unprepare(wdt->clk);
+	clk_disable_unprepare(wdt->clk);
 
 	return 0;
 }
@@ -156,8 +154,7 @@ static int npcm_wdt_restart(struct watchdog_device *wdd,
 	struct npcm_wdt *wdt = to_npcm_wdt(wdd);
 
 	/* For reset, we start the WDT clock and leave it running. */
-	if (wdt->clk)
-		clk_prepare_enable(wdt->clk);
+	clk_prepare_enable(wdt->clk);
 
 	writel(NPCM_WTR | NPCM_WTRE | NPCM_WTE, wdt->reg);
 	udelay(1000);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 032/555] watchdog: npcm: fix clock prepare leak when setting timeout on a running watchdog
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (30 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 031/555] watchdog: npcm: Remove unnecessary NULL check before clk_prepare_enable/clk_disable_unprepare Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 033/555] tracing/probes: Enable newly appended probe when target event is enabled Greg Kroah-Hartman
                   ` (522 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Zhao Feng, Guenter Roeck,
	Sasha Levin

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

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

From: Zhao Feng <zhaofeng2@cmss.chinamobile.com>

[ Upstream commit 57c7cbe21acc77291ec0fbdd4bd72aa259cf4986 ]

npcm_wdt_start() unconditionally prepares and enables the watchdog
clock, and npcm_wdt_stop() is the only place that disables it.
npcm_wdt_set_timeout() calls npcm_wdt_start() again whenever the
watchdog is already active, so every WDIOC_SETTIMEOUT ioctl issued
while the watchdog is running takes one extra clock prepare/enable
reference that is never dropped.

Split the register programming out of npcm_wdt_start() into a
__npcm_wdt_start() helper that assumes the clock is already running,
and call the helper from npcm_wdt_set_timeout() instead; only the
watchdog .start callback (and the restart path, which intentionally
keeps the clock) now acquires the clock.

Fixes: af084fdccfaf ("watchdog: npcm: Enable clock if provided")
Cc: stable@vger.kernel.org
Signed-off-by: Zhao Feng <zhaofeng2@cmss.chinamobile.com>
Link: https://patch.msgid.link/20261109071004.1506-1-zhaofeng2@cmss.chinamobile.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/watchdog/npcm_wdt.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/npcm_wdt.c b/drivers/watchdog/npcm_wdt.c
index e62ea054bc618..aff1ea1e6b62d 100644
--- a/drivers/watchdog/npcm_wdt.c
+++ b/drivers/watchdog/npcm_wdt.c
@@ -63,13 +63,11 @@ static int npcm_wdt_ping(struct watchdog_device *wdd)
 	return 0;
 }
 
-static int npcm_wdt_start(struct watchdog_device *wdd)
+static void __npcm_wdt_start(struct watchdog_device *wdd)
 {
 	struct npcm_wdt *wdt = to_npcm_wdt(wdd);
 	u32 val;
 
-	clk_prepare_enable(wdt->clk);
-
 	if (wdd->timeout < 2)
 		val = 0x800;
 	else if (wdd->timeout < 3)
@@ -94,6 +92,15 @@ static int npcm_wdt_start(struct watchdog_device *wdd)
 	val |= NPCM_WTRE | NPCM_WTE | NPCM_WTR | NPCM_WTIE;
 
 	writel(val, wdt->reg);
+}
+
+static int npcm_wdt_start(struct watchdog_device *wdd)
+{
+	struct npcm_wdt *wdt = to_npcm_wdt(wdd);
+
+	clk_prepare_enable(wdt->clk);
+
+	__npcm_wdt_start(wdd);
 
 	return 0;
 }
@@ -134,7 +141,7 @@ static int npcm_wdt_set_timeout(struct watchdog_device *wdd,
 		wdd->timeout = 2750;
 
 	if (watchdog_active(wdd))
-		npcm_wdt_start(wdd);
+		__npcm_wdt_start(wdd);
 
 	return 0;
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 033/555] tracing/probes: Enable newly appended probe when target event is enabled
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (31 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 032/555] watchdog: npcm: fix clock prepare leak when setting timeout on a running watchdog Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 034/555] tracing/probes: Fix missing BTF kind checks in char pointer/array helpers Greg Kroah-Hartman
                   ` (521 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Masami Hiramatsu (Google),
	Sasha Levin

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

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

From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

[ Upstream commit 72d3a5cb0cd7335553549aaffecc683e3ecc0c43 ]

Unlike kprobe events, fprobe and uprobe events only register their
underlying probes when the trace event is enabled. When a new probe is
appended to an existing multiprobe fprobe or uprobe event that is
already enabled, the appended probe is linked into the event's probe
list without being registered.

As a result, the newly appended probe never fires until the event is
disabled and re-enabled. Moreover, disabling an fprobe event calls
unregister_fprobe() on the unregistered fprobe, and opening or closing a
perf event on an enabled uprobe event dereferences a NULL tu->uprobe in
uprobe_apply().

Register and enable the newly appended fprobe or uprobe immediately when
the target event is already enabled.

Link: https://lore.kernel.org/all/179455849798.403392.135678786198324285.stgit@devnote2/

Fixes: 41af3cf587f4 ("tracing/uprobe: Add multi-probe per uprobe event support")
Fixes: 2db832ec9090 ("tracing: fprobe-events: Register fprobe-events only when it is enabled")
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
[ sashal: Dropped the fprobe hunks, which have no counterpart here, and kept only the uprobe changes, moving trace_uprobe_enable() and filter_func_t earlier with a forward declaration of uprobe_perf_filter. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/trace/trace_uprobe.c | 56 ++++++++++++++++++++++++-------------
 1 file changed, 37 insertions(+), 19 deletions(-)

diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index cf5dc4b456eee..d18669586afab 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -443,6 +443,28 @@ static bool trace_uprobe_has_same_uprobe(struct trace_uprobe *orig,
 	return false;
 }
 
+typedef bool (*filter_func_t)(struct uprobe_consumer *self, struct mm_struct *mm);
+
+#ifdef CONFIG_PERF_EVENTS
+static bool uprobe_perf_filter(struct uprobe_consumer *uc, struct mm_struct *mm);
+#else
+#define uprobe_perf_filter NULL
+#endif
+
+static int trace_uprobe_enable(struct trace_uprobe *tu, filter_func_t filter)
+{
+	struct inode *inode = d_real_inode(tu->path.dentry);
+	struct uprobe *uprobe;
+
+	tu->consumer.filter = filter;
+	uprobe = uprobe_register(inode, tu->offset, tu->ref_ctr_offset, &tu->consumer);
+	if (IS_ERR(uprobe))
+		return PTR_ERR(uprobe);
+
+	tu->uprobe = uprobe;
+	return 0;
+}
+
 static int append_trace_uprobe(struct trace_uprobe *tu, struct trace_uprobe *to)
 {
 	int ret;
@@ -462,10 +484,22 @@ static int append_trace_uprobe(struct trace_uprobe *tu, struct trace_uprobe *to)
 
 	/* Append to existing event */
 	ret = trace_probe_append(&tu->tp, &to->tp);
-	if (!ret)
-		dyn_event_add(&tu->devent, trace_probe_event_call(&tu->tp));
+	if (ret)
+		return ret;
 
-	return ret;
+	if (trace_probe_is_enabled(&tu->tp)) {
+		ret = trace_uprobe_enable(tu,
+			trace_probe_test_flag(&tu->tp, TP_FLAG_PROFILE) ?
+			uprobe_perf_filter : NULL);
+		if (ret) {
+			trace_probe_unlink(&tu->tp);
+			return ret;
+		}
+	}
+
+	dyn_event_add(&tu->devent, trace_probe_event_call(&tu->tp));
+
+	return 0;
 }
 
 /*
@@ -1104,22 +1138,6 @@ print_uprobe_event(struct trace_iterator *iter, int flags, struct trace_event *e
 	return trace_handle_return(s);
 }
 
-typedef bool (*filter_func_t)(struct uprobe_consumer *self, struct mm_struct *mm);
-
-static int trace_uprobe_enable(struct trace_uprobe *tu, filter_func_t filter)
-{
-	struct inode *inode = d_real_inode(tu->path.dentry);
-	struct uprobe *uprobe;
-
-	tu->consumer.filter = filter;
-	uprobe = uprobe_register(inode, tu->offset, tu->ref_ctr_offset, &tu->consumer);
-	if (IS_ERR(uprobe))
-		return PTR_ERR(uprobe);
-
-	tu->uprobe = uprobe;
-	return 0;
-}
-
 static void __probe_event_disable(struct trace_probe *tp)
 {
 	struct trace_uprobe *tu;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 034/555] tracing/probes: Fix missing BTF kind checks in char pointer/array helpers
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (32 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 033/555] tracing/probes: Enable newly appended probe when target event is enabled Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 035/555] xfrm: Dont clobber inner headers when already set Greg Kroah-Hartman
                   ` (520 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Masami Hiramatsu (Google),
	Sasha Levin

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

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

From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

[ Upstream commit c1e2c63e65421068566db3dde44dfd4fe7adb46d ]

In struct btf_type, the type ID and byte size share a union, and only
BTF_KIND_INT types are followed by a 32-bit integer encoding word.
Because btf_type_is_char_ptr() and btf_type_is_char_array() do not
verify that the outer type is BTF_KIND_PTR or that the resolved element
type is a non-NULL BTF_KIND_INT before inspecting it, non-pointer BTF
types can have their byte size misinterpreted as a BTF type ID, and
arrays of non-integer types read out-of-bounds or misinterpret trailing
BTF metadata as BTF_INT_* encoding bits.

Validate the BTF type kinds and NULL pointers before reading inner type
metadata in both helpers.

Link: https://lore.kernel.org/all/179455851632.403392.258264246782960594.stgit@devnote2/

Fixes: 27973e5c64b9 ("tracing/probes: Add string type check with BTF")
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
[ sashal: Kept this branch's existing &tid argument to btf_type_skip_modifiers() where upstream passes NULL, resolving the context conflict in both helpers. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/trace/trace_probe.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index deb47ca572bd7..786552250ac13 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -326,6 +326,9 @@ static bool btf_type_is_char_ptr(struct btf *btf, const struct btf_type *type)
 	u32 intdata;
 	s32 tid;
 
+	if (BTF_INFO_KIND(type->info) != BTF_KIND_PTR)
+		return false;
+
 	real_type = btf_type_skip_modifiers(btf, type->type, &tid);
 	if (!real_type)
 		return false;
@@ -351,6 +354,11 @@ static bool btf_type_is_char_array(struct btf *btf, const struct btf_type *type)
 	array = (const struct btf_array *)(type + 1);
 
 	real_type = btf_type_skip_modifiers(btf, array->type, &tid);
+	if (!real_type)
+		return false;
+
+	if (BTF_INFO_KIND(real_type->info) != BTF_KIND_INT)
+		return false;
 
 	intdata = btf_type_int(real_type);
 	return !(BTF_INT_ENCODING(intdata) & BTF_INT_SIGNED)
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 035/555] xfrm: Dont clobber inner headers when already set
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (33 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 034/555] tracing/probes: Fix missing BTF kind checks in char pointer/array helpers Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 036/555] Bluetooth: hci_core: Fix not checking skb length on hci_scodata_packet Greg Kroah-Hartman
                   ` (519 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Cosmin Ratiu, Steffen Klassert,
	Sasha Levin

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

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

From: Cosmin Ratiu <cratiu@nvidia.com>

[ Upstream commit fa90a3145c0340c3f624206a81637c542254ea1d ]

On VXLAN over IPsec egress, xfrm{4,6}_transport_output() blindly
overwrite inner_transport_header (== the inner TCP header saved in VXLAN
iptunnel_handle_offloads() -> skb_reset_inner_headers()) with the
current transport_header (== the VXLAN outer UDP header set by
udp_tunnel_xmit_skb()).

This was a latent bug, harmless until commit [1] added a doff validation
check in qdisc_pkt_len_segs_init() for encapsulated GSO packets. With
the wrong inner_transport_header set by xfrm, qdisc_pkt_len_segs_init()
interprets inner_transport_header as a TCP header, reads doff=0 from the
upper byte of the VNI and drops the packet with DROP_REASON_SKB_BAD_GSO.

Besides the use in GSO to determine the header size of segmented
packets, inner_transport_header might be used by drivers to set up
inner checksum offloading by pointing the HW to the inner transport
header. A quick browse through available drivers shows that mlx5 uses
skb->csum_start specifically for this scenario, while others either
don't support VXLAN over IPsec crypto offload (ixgbe) or the HW is
capable of parsing the packets itself (nfp, Chelsio).

But in all cases, it is more correct to let the inner_transport_header
point to the innermost header instead of overwriting it in xfrm.

So fix this by guarding all four inner header save sites in
xfrm_output.c (xfrm{4,6}_transport_output, xfrm{4,6}_tunnel_encap_add)
with a check for skb->inner_protocol. When inner_protocol is set, a
tunnel layer (VXLAN, Geneve, GRE, etc.) has already saved the correct
inner header offsets and they must not be overwritten. When
inner_protocol is zero, no prior tunnel encapsulation exists and xfrm
must save the inner headers itself. The tunnel mode checks are only
added for completion, since they aren't strictly required, as
xfrm_output() forces software GSO in tunnel mode before encap.

This makes the previously added test pass:
 # ./tools/testing/selftests/drivers/net/hw/ipsec_vxlan.py
 TAP version 13
 1..4
 ok 1 ipsec_vxlan.test_vxlan_ipsec_crypto_offload.outer_v4_inner_v4
 ok 2 ipsec_vxlan.test_vxlan_ipsec_crypto_offload.outer_v4_inner_v6
 ok 3 ipsec_vxlan.test_vxlan_ipsec_crypto_offload.outer_v6_inner_v4
 ok 4 ipsec_vxlan.test_vxlan_ipsec_crypto_offload.outer_v6_inner_v6
 # Totals: pass:4 fail:0 xfail:0 xpass:0 skip:0 error:0

[1] commit 7fb4c1967011 ("net: pull headers in qdisc_pkt_len_segs_init()")
Fixes: f1bd7d659ef0 ("xfrm: Add encapsulation header offsets while SKB is not encrypted")
Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/xfrm/xfrm_output.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
index 21aa65caf0c69..00d10debec080 100644
--- a/net/xfrm/xfrm_output.c
+++ b/net/xfrm/xfrm_output.c
@@ -67,7 +67,9 @@ static int xfrm4_transport_output(struct xfrm_state *x, struct sk_buff *skb)
 	struct iphdr *iph = ip_hdr(skb);
 	int ihl = iph->ihl * 4;
 
-	skb_set_inner_transport_header(skb, skb_transport_offset(skb));
+	if (!skb->inner_protocol)
+		skb_set_inner_transport_header(skb,
+					       skb_transport_offset(skb));
 
 	skb_set_network_header(skb, -x->props.header_len);
 	skb->mac_header = skb->network_header +
@@ -168,7 +170,9 @@ static int xfrm6_transport_output(struct xfrm_state *x, struct sk_buff *skb)
 	int hdr_len;
 
 	iph = ipv6_hdr(skb);
-	skb_set_inner_transport_header(skb, skb_transport_offset(skb));
+	if (!skb->inner_protocol)
+		skb_set_inner_transport_header(skb,
+					       skb_transport_offset(skb));
 
 	hdr_len = xfrm6_hdr_offset(x, skb, &prevhdr);
 	if (hdr_len < 0)
@@ -277,8 +281,10 @@ static int xfrm4_tunnel_encap_add(struct xfrm_state *x, struct sk_buff *skb)
 	struct iphdr *top_iph;
 	int flags;
 
-	skb_set_inner_network_header(skb, skb_network_offset(skb));
-	skb_set_inner_transport_header(skb, skb_transport_offset(skb));
+	if (!skb->inner_protocol) {
+		skb_set_inner_network_header(skb, skb_network_offset(skb));
+		skb_set_inner_transport_header(skb, skb_transport_offset(skb));
+	}
 
 	skb_set_network_header(skb, -x->props.header_len);
 	skb->mac_header = skb->network_header +
@@ -322,8 +328,10 @@ static int xfrm6_tunnel_encap_add(struct xfrm_state *x, struct sk_buff *skb)
 	struct ipv6hdr *top_iph;
 	int dsfield;
 
-	skb_set_inner_network_header(skb, skb_network_offset(skb));
-	skb_set_inner_transport_header(skb, skb_transport_offset(skb));
+	if (!skb->inner_protocol) {
+		skb_set_inner_network_header(skb, skb_network_offset(skb));
+		skb_set_inner_transport_header(skb, skb_transport_offset(skb));
+	}
 
 	skb_set_network_header(skb, -x->props.header_len);
 	skb->mac_header = skb->network_header +
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 036/555] Bluetooth: hci_core: Fix not checking skb length on hci_scodata_packet
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (34 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 035/555] xfrm: Dont clobber inner headers when already set Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 037/555] mtd: core: avoid double-free of OTP NVMEM device Greg Kroah-Hartman
                   ` (518 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Luiz Augusto von Dentz, Petr Vaganov,
	Sasha Levin

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

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

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

commit 59437cbb5781227567dec226aaa88c66a09ccc5a upstream.

This fixes not checking if skb really contains an SCO header otherwise
the code may attempt to access some uninitilized/invalid memory past the
valid skb->data.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
[ Petr: add Fixes tag ]
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Petr Vaganov <petrvaganoff@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/bluetooth/hci_core.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 1ad2ea661e908..d2fcccdf482e0 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -3931,18 +3931,22 @@ static void hci_acldata_packet(struct hci_dev *hdev, struct sk_buff *skb)
 /* SCO data packet */
 static void hci_scodata_packet(struct hci_dev *hdev, struct sk_buff *skb)
 {
-	struct hci_sco_hdr *hdr = (void *) skb->data;
+	struct hci_sco_hdr *hdr;
 	struct hci_conn *conn;
 	__u16 handle, flags;
 
-	skb_pull(skb, HCI_SCO_HDR_SIZE);
+	hdr = skb_pull_data(skb, sizeof(*hdr));
+	if (!hdr) {
+		bt_dev_err(hdev, "SCO packet too small");
+		goto drop;
+	}
 
 	handle = __le16_to_cpu(hdr->handle);
 	flags  = hci_flags(handle);
 	handle = hci_handle(handle);
 
-	BT_DBG("%s len %d handle 0x%4.4x flags 0x%4.4x", hdev->name, skb->len,
-	       handle, flags);
+	bt_dev_dbg(hdev, "len %d handle 0x%4.4x flags 0x%4.4x", skb->len,
+		   handle, flags);
 
 	hdev->stat.sco_rx++;
 
@@ -3960,6 +3964,7 @@ static void hci_scodata_packet(struct hci_dev *hdev, struct sk_buff *skb)
 				       handle);
 	}
 
+drop:
 	kfree_skb(skb);
 }
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 037/555] mtd: core: avoid double-free of OTP NVMEM device
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (35 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 036/555] Bluetooth: hci_core: Fix not checking skb length on hci_scodata_packet Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 038/555] bpf: Introduce jit_required flag and remove bpf_prog_has_kfunc_call() Greg Kroah-Hartman
                   ` (517 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Karl Mehltretter, Miquel Raynal,
	Sasha Levin

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

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

From: Karl Mehltretter <kmehltretter@gmail.com>

[ Upstream commit 26300879cd8e4612dce66bb8f6ff7cd35fcf3e59 ]

If factory OTP setup fails after the user OTP NVMEM device has been
registered, mtd_otp_nvmem_add() unregisters the user device but leaves
mtd->otp_user_nvmem set. On an error, the caller unregisters it again.
For -EOPNOTSUPP, registration continues and normal teardown unregisters
it again.

Clear mtd->otp_user_nvmem after unregistering it.

Fixes: e0489f6e221f ("mtd: core: fix error path for nvmem provider")
Fixes: fe0b8213c012 ("mtd: core: Don't fail mtd_otp_nvmem_add() if OTP is unsupported")
Assisted-by: Codex:gpt-5.6-sol
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/mtd/mtdcore.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 6bda8b9684920..07f7da2b61034 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -1029,6 +1029,7 @@ static int mtd_otp_nvmem_add(struct mtd_info *mtd)
 
 err:
 	nvmem_unregister(mtd->otp_user_nvmem);
+	mtd->otp_user_nvmem = NULL;
 	/* Don't report error if OTP is not supported. */
 	if (err == -EOPNOTSUPP)
 		return 0;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 038/555] bpf: Introduce jit_required flag and remove bpf_prog_has_kfunc_call()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (36 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 037/555] mtd: core: avoid double-free of OTP NVMEM device Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 039/555] bpf: Reject programs with inlined helpers if JIT is not available Greg Kroah-Hartman
                   ` (516 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, KaFai Wan,
	Leon Hwang, Tiezhu Yang, Eduard Zingerman, Sasha Levin

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

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

From: Tiezhu Yang <yangtiezhu@loongson.cn>

[ Upstream commit 9a6df65d5c6a9947ddab4e563e329720f44b8747 ]

Introduce a 'jit_required' bitfield flag in struct bpf_prog to track
whether a BPF program strictly requires the JIT compiler to run. This
prevents a dangerous runtime fallback to the interpreter for features
that are only implemented in the JIT compiler.

Currently, bpf_prog_has_kfunc_call() is used only for kernel function
calls, replace the kfunc-specific helper with the new 'jit_required'
flag. This makes it easy to support other JIT-only BPF features, such
as inlined helpers.

Suggested-by: Alexei Starovoitov <ast@kernel.org>
Suggested-by: KaFai Wan <kafai.wan@linux.dev>
Suggested-by: Leon Hwang <leon.hwang@linux.dev>
Acked-by: Leon Hwang <leon.hwang@linux.dev>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
[edit]
  Adapt the bpf_fixup_call_args() change to fixup_call_args() in
  kernel/bpf/verifier.c, and the __bpf_prog_select_runtime() change to
  bpf_prog_select_runtime() in kernel/bpf/core.c.
Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/linux/bpf.h   |  9 ++-------
 kernel/bpf/core.c     |  7 ++-----
 kernel/bpf/verifier.c | 12 ++++--------
 3 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 98f816a37d3be..f2df5c47bef74 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -1587,8 +1587,9 @@ struct bpf_prog_aux {
 
 struct bpf_prog {
 	u16			pages;		/* Number of allocated pages */
-	u16			jited:1,	/* Is our filter JIT'ed? */
+	u32			jited:1,	/* Is our filter JIT'ed? */
 				jit_requested:1,/* archs need to JIT the prog */
+				jit_required:1, /* program strictly requires JIT compiler */
 				gpl_compatible:1, /* Is filter GPL compatible? */
 				cb_access:1,	/* Is control block accessed? */
 				dst_needed:1,	/* Do we need dst entry? */
@@ -2694,7 +2695,6 @@ const struct bpf_func_proto *bpf_base_func_proto(enum bpf_func_id func_id,
 						 const struct bpf_prog *prog);
 void bpf_task_storage_free(struct task_struct *task);
 void bpf_cgrp_storage_free(struct cgroup *cgroup);
-bool bpf_prog_has_kfunc_call(const struct bpf_prog *prog);
 const struct btf_func_model *
 bpf_jit_find_kfunc_model(const struct bpf_prog *prog,
 			 const struct bpf_insn *insn);
@@ -2963,11 +2963,6 @@ static inline void bpf_task_storage_free(struct task_struct *task)
 {
 }
 
-static inline bool bpf_prog_has_kfunc_call(const struct bpf_prog *prog)
-{
-	return false;
-}
-
 static inline const struct btf_func_model *
 bpf_jit_find_kfunc_model(const struct bpf_prog *prog,
 			 const struct bpf_insn *insn)
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index de2c0ffb30252..f94524481f27b 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -122,6 +122,7 @@ struct bpf_prog *bpf_prog_alloc_no_stats(unsigned int size, gfp_t gfp_extra_flag
 	fp->aux = aux;
 	fp->aux->prog = fp;
 	fp->jit_requested = ebpf_jit_enabled();
+	fp->jit_required = IS_ENABLED(CONFIG_BPF_JIT_ALWAYS_ON);
 	fp->blinding_requested = bpf_jit_blinding_enabled(fp);
 #ifdef CONFIG_CGROUP_BPF
 	aux->cgroup_atype = CGROUP_BPF_ATTACH_TYPE_INVALID;
@@ -2531,15 +2532,11 @@ struct bpf_prog *bpf_prog_select_runtime(struct bpf_prog *fp, int *err)
 	/* In case of BPF to BPF calls, verifier did all the prep
 	 * work with regards to JITing, etc.
 	 */
-	bool jit_needed = false;
+	bool jit_needed = fp->jit_required;
 
 	if (fp->bpf_func)
 		goto finalize;
 
-	if (IS_ENABLED(CONFIG_BPF_JIT_ALWAYS_ON) ||
-	    bpf_prog_has_kfunc_call(fp))
-		jit_needed = true;
-
 	if (!bpf_prog_select_interpreter(fp))
 		jit_needed = true;
 
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index a5ffecbaa7bf9..f25dfaecb3732 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -2974,6 +2974,8 @@ static int add_kfunc_call(struct bpf_verifier_env *env, u32 func_id, s16 offset)
 		prog_aux->kfunc_tab = tab;
 	}
 
+	env->prog->jit_required = 1;
+
 	/* func_id == 0 is always invalid, but instead of returning an error, be
 	 * conservative and wait until the code elimination pass before returning
 	 * error, so that invalid calls that get pruned out can be in BPF programs
@@ -3082,11 +3084,6 @@ static void sort_kfunc_descs_by_imm_off(struct bpf_prog *prog)
 	     kfunc_desc_cmp_by_imm_off, NULL);
 }
 
-bool bpf_prog_has_kfunc_call(const struct bpf_prog *prog)
-{
-	return !!prog->aux->kfunc_tab;
-}
-
 const struct btf_func_model *
 bpf_jit_find_kfunc_model(const struct bpf_prog *prog,
 			 const struct bpf_insn *insn)
@@ -20970,7 +20967,6 @@ static int fixup_call_args(struct bpf_verifier_env *env)
 #ifndef CONFIG_BPF_JIT_ALWAYS_ON
 	struct bpf_prog *prog = env->prog;
 	struct bpf_insn *insn = prog->insnsi;
-	bool has_kfunc_call = bpf_prog_has_kfunc_call(prog);
 	int i, depth;
 #endif
 	int err = 0;
@@ -20984,8 +20980,8 @@ static int fixup_call_args(struct bpf_verifier_env *env)
 			return err;
 	}
 #ifndef CONFIG_BPF_JIT_ALWAYS_ON
-	if (has_kfunc_call) {
-		verbose(env, "calling kernel functions are not allowed in non-JITed programs\n");
+	if (prog->jit_required) {
+		verbose(env, "program requires BPF JIT compiler but it is not available\n");
 		return -EINVAL;
 	}
 	if (env->subprog_cnt > 1 && env->prog->aux->tail_call_reachable) {
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 039/555] bpf: Reject programs with inlined helpers if JIT is not available
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (37 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 038/555] bpf: Introduce jit_required flag and remove bpf_prog_has_kfunc_call() Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 040/555] bpf: Disallow interpreter fallback for arena-related insns Greg Kroah-Hartman
                   ` (515 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, KaFai Wan,
	Leon Hwang, Tiezhu Yang, Eduard Zingerman, Sasha Levin

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

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

From: Tiezhu Yang <yangtiezhu@loongson.cn>

[ Upstream commit f1c27922576edccb99d0257827d09bd05c0304a6 ]

When an architecture (such as LoongArch, ARM64, and RISC-V) implements
bpf_jit_inlines_helper_call(), the verifier skips rewriting the helper
call offset (insn->imm) in bpf_do_misc_fixups(). This is because the
helper is expected to be inlined by the JIT compiler later. Therefore,
insn->imm remains as the raw helper enum ID.

However, if JIT is disabled at runtime (net.core.bpf_jit_enable=0) or
if JIT compilation fails dynamically (e.g., due to OOM), the program
falls back to the BPF interpreter.

When the interpreter executes (__bpf_call_base + insn->imm) with the
unpatched raw ID, it jumps into an invalid address space, triggering
an instruction alignment fault or a kernel panic.

Although these helpers have valid C implementations in the kernel, the
omission of offset rewriting makes runtime interpreter fallback fatal.

Fix this by setting 'prog->jit_required = 1' when helper call rewriting
is skipped for JIT inlining. This ensures that such programs are safely
rejected if JIT is not available, preventing the runtime kernel panic.

Fixes: 2ddec2c80b44 ("riscv, bpf: inline bpf_get_smp_processor_id()")
Suggested-by: Alexei Starovoitov <ast@kernel.org>
Suggested-by: KaFai Wan <kafai.wan@linux.dev>
Acked-by: Leon Hwang <leon.hwang@linux.dev>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
[edit]
  Apply the bpf_do_misc_fixups() change from kernel/bpf/fixups.c to
  do_misc_fixups() in kernel/bpf/verifier.c.
Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/bpf/verifier.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index f25dfaecb3732..4b1d89ec02a8f 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -21546,8 +21546,10 @@ static int do_misc_fixups(struct bpf_verifier_env *env)
 		}
 
 		/* Skip inlining the helper call if the JIT does it. */
-		if (bpf_jit_inlines_helper_call(insn->imm))
+		if (bpf_jit_inlines_helper_call(insn->imm)) {
+			prog->jit_required = 1;
 			goto next_insn;
+		}
 
 		if (insn->imm == BPF_FUNC_get_route_realm)
 			prog->dst_needed = 1;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 040/555] bpf: Disallow interpreter fallback for arena-related insns
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (38 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 039/555] bpf: Reject programs with inlined helpers if JIT is not available Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 041/555] bpf: Disallow interpreter fallback for BPF_ADDR_PERCPU insn Greg Kroah-Hartman
                   ` (514 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Leon Hwang, Kumar Kartikeya Dwivedi,
	Sasha Levin

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

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

From: Leon Hwang <leon.hwang@linux.dev>

[ Upstream commit 34746b5a84ec37c0ea2bf6808c65c5ed8790eb51 ]

Since the interpreter does not support the arena-related insns,
interpreter fallback should not be allowed for these insns in
core.c::__bpf_prog_select_runtime().

Currently, when the interpreter executes the arena ST/LDX/STX insns,
it would hit the BUG_ON() in ___bpf_prog_run() at run time.

[    2.579196] BPF interpreter: unknown opcode a2 (imm: 0x0)
[    2.579998] ------------[ cut here ]------------
[    2.580652] kernel BUG at kernel/bpf/core.c:2349!
[    2.581314] Oops: invalid opcode: 0000 [#1] SMP PTI

Set jit_required as true when arena map is used in the prog to disallow
interpreter fallback for arena-related insns.

Fixes: 6082b6c328b5 ("bpf: Recognize addr_space_cast instruction in the verifier.")
Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
Link: https://lore.kernel.org/bpf/20260715141122.15783-2-leon.hwang@linux.dev
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
[edit]
  Apply the check_map_prog_compatibility() change in
  resolve_pseudo_ldimm64(), where this branch handles arena maps.
Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/bpf/verifier.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 4b1d89ec02a8f..bcfc23ff3c57a 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -19841,6 +19841,7 @@ static int resolve_pseudo_ldimm64(struct bpf_verifier_env *env)
 					return -EOPNOTSUPP;
 				}
 				env->prog->aux->arena = (void *)map;
+				env->prog->jit_required = true;
 				if (!bpf_arena_get_user_vm_start(env->prog->aux->arena)) {
 					verbose(env, "arena's user address must be set via map_extra or mmap()\n");
 					return -EINVAL;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 041/555] bpf: Disallow interpreter fallback for BPF_ADDR_PERCPU insn
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (39 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 040/555] bpf: Disallow interpreter fallback for arena-related insns Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 042/555] mm/page_alloc: dont increase highatomic reserve after pcp alloc Greg Kroah-Hartman
                   ` (513 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Leon Hwang, Kumar Kartikeya Dwivedi,
	Sasha Levin

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

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

From: Leon Hwang <leon.hwang@linux.dev>

[ Upstream commit 7a0855e73757ee9cf25ba635a1c735018ecba742 ]

The BPF_MOV64_PERCPU_REG insn requires JIT to emit native code to for
'dst_reg = src_reg + <percpu_base_off>'.

However, the interpreter ignores the 'off' at its ALU64_MOV_X label.
The 'off' indicates the insn is BPF_MOV64_PERCPU_REG insn. Then, when
the interpreter loads memory from the register, it will hit a page
fault.

[    2.545572] BUG: unable to handle page fault for address: ffffffffacaaf034
[    2.546485] #PF: supervisor read access in kernel mode
[    2.547167] #PF: error_code(0x0000) - not-present page
[    2.547850] PGD 134e63067 P4D 134e63067 PUD 134e64063 PMD 10021c063 PTE 800ffffeca550062
[    2.548912] Oops: Oops: 0000 [#1] SMP PTI

Set jit_required as true in order to disallow interpreter fallback in
core.c::__bpf_prog_select_runtime(), if any BPF_ADDR_PERCPU insn is
patched to the prog.

BTW, rename the helper bpf_map_supports_cpu_flags() to
bpf_map_is_percpu_map().

Fixes: 7bdbf7446305 ("bpf: add special internal-only MOV instruction to resolve per-CPU addrs")
Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
Link: https://lore.kernel.org/bpf/20260715141122.15783-4-leon.hwang@linux.dev
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
[edit]
  Add bpf_map_is_percpu_map() directly because 6.12.y lacks
  bpf_map_supports_cpu_flags().

  Apply the map lookup and bpf_get_smp_processor_id() changes to
  do_misc_fixups() in kernel/bpf/verifier.c.

  Omit the current-task helper hunk because 6.12.y lacks the verifier
  inlining introduced by commit
  eaedea154eb9 ("bpf, x86: inline bpf_get_current_task() for x86_64").
Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/linux/bpf.h   | 13 +++++++++++++
 kernel/bpf/verifier.c |  4 ++++
 2 files changed, 17 insertions(+)

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index f2df5c47bef74..c8d8663b63915 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -3521,4 +3521,17 @@ static inline bool bpf_is_subprog(const struct bpf_prog *prog)
 	return prog->aux->func_idx != 0;
 }
 
+static inline bool bpf_map_is_percpu_map(enum bpf_map_type map_type)
+{
+	switch (map_type) {
+	case BPF_MAP_TYPE_PERCPU_ARRAY:
+	case BPF_MAP_TYPE_PERCPU_HASH:
+	case BPF_MAP_TYPE_LRU_PERCPU_HASH:
+	case BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE:
+		return true;
+	default:
+		return false;
+	}
+}
+
 #endif /* _LINUX_BPF_H */
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index bcfc23ff3c57a..7ffd073c08423 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -21738,6 +21738,9 @@ static int do_misc_fixups(struct bpf_verifier_env *env)
 					return -EINVAL;
 				}
 
+				if (bpf_map_is_percpu_map(map_ptr->map_type))
+					prog->jit_required = true;
+
 				new_prog = bpf_patch_insn_data(env, i + delta,
 							       insn_buf, cnt);
 				if (!new_prog)
@@ -21842,6 +21845,7 @@ static int do_misc_fixups(struct bpf_verifier_env *env)
 			 * way, it's fine to back out this inlining logic
 			 */
 #ifdef CONFIG_SMP
+			prog->jit_required = true;
 			insn_buf[0] = BPF_MOV32_IMM(BPF_REG_0, (u32)(unsigned long)&pcpu_hot.cpu_number);
 			insn_buf[1] = BPF_MOV64_PERCPU_REG(BPF_REG_0, BPF_REG_0);
 			insn_buf[2] = BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_0, 0);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 042/555] mm/page_alloc: dont increase highatomic reserve after pcp alloc
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (40 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 041/555] bpf: Disallow interpreter fallback for BPF_ADDR_PERCPU insn Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 043/555] mm/page_alloc: use existing highatomic reserves on the buddy fastpath Greg Kroah-Hartman
                   ` (512 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Zhiguo Jiang, Frank van der Linden,
	Vlastimil Babka (SUSE), Brendan Jackman, Johannes Weiner,
	Michal Hocko, Suren Baghdasaryan, Zi Yan, Andrew Morton,
	Sasha Levin

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

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

From: Frank van der Linden <fvdl@google.com>

[ Upstream commit b480cbb071020bd590a0dc0166635b448e9fc46b ]

Higher order GFP_ATOMIC allocations can be served through a PCP list with
ALLOC_HIGHATOMIC set.  Such an allocation can e.g.  happen if a zone is
between the low and min watermarks, and get_page_from_freelist is retried
after the alloc_flags are relaxed.

The call to reserve_highatomic_pageblock() after such a PCP allocation
will result in an increase every single time: the page from the
(unmovable) PCP list will never have migrate type MIGRATE_HIGHATOMIC,
since MIGRATE_HIGHATOMIC pages do not appear on the unmovable PCP list.
So a new pageblock is converted to MIGRATE_HIGHATOMIC.

Eventually that leads to the maximum of 1% of the zone being used up by
(often mostly free) MIGRATE_HIGHATOMIC pageblocks, for no good reason.
Since this space is not available for normal allocations, this wastes
memory and will push things in to reclaim too soon.

This was observed on a system that ran a test with bursts of memory
activity, paired with GFP_ATOMIC SLUB activity.  These would lead to a new
slab being allocated with GFP_ATOMIC, sometimes hitting the
get_page_from_freelist retry path by being below the low watermark.  While
the frequency of those allocations was low, it kept adding up over time,
and the number of MIGRATE_ATOMIC pageblocks kept increasing.

If a higher order atomic allocation can be served by the unmovable PCP
list, there is probably no need yet to extend the reserves.  So, move the
check and possible extension of the highatomic reserves to the buddy case
only, and do not refill the PCP list for ALLOC_HIGHATOMIC if it's empty.
This way, the PCP list is tried for ALLOC_HIGHATOMIC for a fast atomic
allocation.  But it will immediately fall back to rmqueue_buddy() if it's
empty.  In rmqueue_buddy(), the MIGRATE_HIGHATOMIC buddy lists are tried
first (as before), and the reserves are extended only if that fails.

With this change, the test was stable.  Highatomic reserves were built up,
but to a normal level.  No highatomic failures were seen.

This is similar to the patch proposed in [1] by Zhiguo Jiang, but
re-arranged a bit.

Link: https://lkml.kernel.org/r/20260320173426.1831267-1-fvdl@google.com
Link: https://lore.kernel.org/all/20231122013925.1507-1-justinjiang@vivo.com/ [1]
Fixes: 44042b449872 ("mm/page_alloc: allow high-order pages to be stored on the per-cpu lists")
Signed-off-by: Zhiguo Jiang <justinjiang@vivo.com>
Signed-off-by: Frank van der Linden <fvdl@google.com>
Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Cc: Brendan Jackman <jackmanb@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Zhiguo Jiang <justinjiang@vivo.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 mm/page_alloc.c | 30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index dc4b0d58c4d0d..a3d0281897035 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -241,6 +241,8 @@ unsigned int pageblock_order __read_mostly;
 
 static void __free_pages_ok(struct page *page, unsigned int order,
 			    fpi_t fpi_flags);
+static void reserve_highatomic_pageblock(struct page *page, int order,
+					 struct zone *zone);
 
 /*
  * results with 256, 32 in the lowmem_reserve sysctl:
@@ -3014,6 +3016,13 @@ struct page *rmqueue_buddy(struct zone *preferred_zone, struct zone *zone,
 		spin_unlock_irqrestore(&zone->lock, flags);
 	} while (check_new_pages(page, order));
 
+	/*
+	 * If this is a high-order atomic allocation then check
+	 * if the pageblock should be reserved for the future
+	 */
+	if (unlikely(alloc_flags & ALLOC_HIGHATOMIC))
+		reserve_highatomic_pageblock(page, order, zone);
+
 	__count_zid_vm_events(PGALLOC, page_zonenum(page), 1 << order);
 	zone_statistics(preferred_zone, zone, 1);
 
@@ -3085,6 +3094,20 @@ struct page *__rmqueue_pcplist(struct zone *zone, unsigned int order,
 			int batch = nr_pcp_alloc(pcp, zone, order);
 			int alloced;
 
+			/*
+			 * Don't refill the list for a higher order atomic
+			 * allocation under memory pressure, as this would
+			 * not build up any HIGHATOMIC reserves, which
+			 * might be needed soon.
+			 *
+			 * Instead, direct it towards the reserves by
+			 * returning NULL, which will make the caller fall
+			 * back to rmqueue_buddy. This will try to use the
+			 * reserves first and grow them if needed.
+			 */
+			if (alloc_flags & ALLOC_HIGHATOMIC)
+				return NULL;
+
 			alloced = rmqueue_bulk(zone, order,
 					batch, list,
 					migratetype, alloc_flags);
@@ -3569,13 +3592,6 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags,
 		if (page) {
 			prep_new_page(page, order, gfp_mask, alloc_flags);
 
-			/*
-			 * If this is a high-order atomic allocation then check
-			 * if the pageblock should be reserved for the future
-			 */
-			if (unlikely(alloc_flags & ALLOC_HIGHATOMIC))
-				reserve_highatomic_pageblock(page, order, zone);
-
 			return page;
 		} else {
 			if (cond_accept_memory(zone, order))
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 043/555] mm/page_alloc: use existing highatomic reserves on the buddy fastpath
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (41 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 042/555] mm/page_alloc: dont increase highatomic reserve after pcp alloc Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 044/555] xprtrdma: serialize unmap_sync with xprt_disconnect Greg Kroah-Hartman
                   ` (511 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, JP Kobryn, Vlastimil Babka (SUSE),
	Johannes Weiner, Shakeel Butt, Brendan Jackman, David Hildenbrand,
	Frank van der Linden, Liam R. Howlett, Lorenzo Stoakes,
	Michal Hocko, Mike Rapoport, Suren Baghdasaryan, Zi Yan,
	Andrew Morton, Sasha Levin

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

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

From: JP Kobryn <jp.kobryn@linux.dev>

[ Upstream commit 9f2fd03c9bde366c928c9242fc9b2e2c5111a134 ]

ALLOC_HIGHATOMIC currently provides both access to MIGRATE_HIGHATOMIC free
pages and permission to create new highatomic pageblock reserves.  This
makes it unsuitable for the fastpath.

However, the fastpath can reach rmqueue_buddy() while MIGRATE_HIGHATOMIC
reserves have free pages available.  In this situation, the allocation can
fall back to other migratetypes without trying those reserves first.

Allow high-priority non-blocking allocations to use existing
MIGRATE_HIGHATOMIC reserves on the buddy fastpath without growing them.
First tighten the criteria for reserving pageblocks so that growth may
only occur in the slowpath.  Then allow fastpath usage by enabling
ALLOC_HIGHATOMIC when the GFP mask describes a non-blocking high-priority
allocation.  This logic has been factored out from gfp_to_alloc_flags() to
a new function gfp_to_alloc_flags_nonblocking().

A UDP receive workload was run with free MIGRATE_HIGHATOMIC pageblocks
available in the target zone.  Before this patch, the workload did not
consume these blocks.  With this patch, eligible order-1 allocations
reaching the buddy path consumed existing MIGRATE_HIGHATOMIC pageblocks,
with no highatomic misses observed.  The workload did not grow highatomic
reserves and NAPI page-frag allocations remained healthy with no failures
or order-0 fallbacks.

Link: https://lore.kernel.org/20260623004600.113347-1-jp.kobryn@linux.dev
Signed-off-by: JP Kobryn <jp.kobryn@linux.dev>
Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Brendan Jackman <jackmanb@google.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Frank van der Linden <fvdl@google.com>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 mm/page_alloc.c | 44 ++++++++++++++++++++++++++++++--------------
 1 file changed, 30 insertions(+), 14 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index a3d0281897035..c34ec6a7ded68 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3017,10 +3017,11 @@ struct page *rmqueue_buddy(struct zone *preferred_zone, struct zone *zone,
 	} while (check_new_pages(page, order));
 
 	/*
-	 * If this is a high-order atomic allocation then check
-	 * if the pageblock should be reserved for the future
+	 * Slowpath (precarious) high-atomic allocations may reserve
+	 * a pageblock for future use.
 	 */
-	if (unlikely(alloc_flags & ALLOC_HIGHATOMIC))
+	if (unlikely((alloc_flags & ALLOC_HIGHATOMIC) &&
+			((alloc_flags & ALLOC_WMARK_MASK) == ALLOC_WMARK_MIN)))
 		reserve_highatomic_pageblock(page, order, zone);
 
 	__count_zid_vm_events(PGALLOC, page_zonenum(page), 1 << order);
@@ -4101,6 +4102,29 @@ static void wake_all_kswapds(unsigned int order, gfp_t gfp_mask,
 	}
 }
 
+static inline unsigned int
+gfp_to_alloc_flags_nonblocking(gfp_t gfp_mask, unsigned int order)
+{
+	unsigned int alloc_flags = 0;
+
+	if (gfp_mask & __GFP_DIRECT_RECLAIM)
+		return 0;
+
+	/*
+	 * Not worth trying to allocate harder for __GFP_NOMEMALLOC even
+	 * if it can't schedule.
+	 */
+	if (gfp_mask & __GFP_NOMEMALLOC)
+		return 0;
+
+	alloc_flags |= ALLOC_NON_BLOCK;
+
+	if (order > 0 && (gfp_mask & __GFP_HIGH))
+		alloc_flags |= ALLOC_HIGHATOMIC;
+
+	return alloc_flags;
+}
+
 static inline unsigned int
 gfp_to_alloc_flags(gfp_t gfp_mask, unsigned int order)
 {
@@ -4123,18 +4147,9 @@ gfp_to_alloc_flags(gfp_t gfp_mask, unsigned int order)
 	alloc_flags |= (__force int)
 		(gfp_mask & (__GFP_HIGH | __GFP_KSWAPD_RECLAIM));
 
-	if (!(gfp_mask & __GFP_DIRECT_RECLAIM)) {
-		/*
-		 * Not worth trying to allocate harder for __GFP_NOMEMALLOC even
-		 * if it can't schedule.
-		 */
-		if (!(gfp_mask & __GFP_NOMEMALLOC)) {
-			alloc_flags |= ALLOC_NON_BLOCK;
-
-			if (order > 0 && (alloc_flags & ALLOC_MIN_RESERVE))
-				alloc_flags |= ALLOC_HIGHATOMIC;
-		}
+	alloc_flags |= gfp_to_alloc_flags_nonblocking(gfp_mask, order);
 
+	if (!(gfp_mask & __GFP_DIRECT_RECLAIM)) {
 		/*
 		 * Ignore cpuset mems for non-blocking __GFP_HIGH (probably
 		 * GFP_ATOMIC) rather than fail, see the comment for
@@ -4899,6 +4914,7 @@ struct page *__alloc_pages_noprof(gfp_t gfp, unsigned int order,
 	 * memory until all local zones are considered.
 	 */
 	alloc_flags |= alloc_flags_nofragment(zonelist_zone(ac.preferred_zoneref), gfp);
+	alloc_flags |= gfp_to_alloc_flags_nonblocking(gfp, order) & ALLOC_HIGHATOMIC;
 
 	/* First allocation attempt */
 	page = get_page_from_freelist(alloc_gfp, order, alloc_flags, &ac);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 044/555] xprtrdma: serialize unmap_sync with xprt_disconnect
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (42 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 043/555] mm/page_alloc: use existing highatomic reserves on the buddy fastpath Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 045/555] gve: Fix race between stats query and queue reconfig Greg Kroah-Hartman
                   ` (510 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Chuck Lever, Tim Menninger,
	Anna Schumaker, Sasha Levin

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

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

From: Tim Menninger <tmenninger@everpuredata.com>

[ Upstream commit 1fa415883c37b02ff17acdd7977ed591d3d389ee ]

frwr_unmap_sync() posts LOCAL_INV Work Requests to the QP and waits
for the matching CQE. This can race with rpcrdma_xprt_disconnect():

    1. frwr_unmap_sync() samples r_xprt->rx_ep
    2. rpcrdma_xprt_disconnect() drains the QP
    3. frwr_unmap_sync() posts LOCAL_INV WRs after the drain
    4. No CQE arrives, so wait_for_completion() blocks indefinitely

The hung task appears in the rpciod workqueue:

Workqueue: rpciod rpc_async_schedule [sunrpc]
    wait_for_completion()
    frwr_unmap_sync()
    xprt_rdma_free()
    xprt_release()

Serialize synchronous MR invalidation against QP teardown with
rx_unmap_rwsem. frwr_unmap_sync() holds the read side while it builds
and submits the LOCAL_INV chain. Disconnect holds the write side across
QP drain and resource teardown. Drop the read side before waiting so
disconnect can drain the submitted Work Requests and deliver their CQEs.

Disconnect can reset a request while frwr_unmap_sync() waits for the
read side. Recheck rl_registered after acquiring the rwsem and return
without posting if the request has already been reset.

Move the synchronous invalidation completion from the final MR to the
request, whose lifetime covers xprt_rdma_free(). This allows disconnect
to destroy MRs after draining the QP while frwr_unmap_sync() is still
waiting. On a post failure, call rpcrdma_force_disconnect() before
dropping the read side so the endpoint is not dereferenced after
disconnect can run.

frwr_unmap_async() runs inline from Receive completion processing.
rpcrdma_xprt_drain() drains the Receive Queue before the Send Queue, so
asynchronous LOCAL_INV Work Requests are submitted before Send Queue
drain. frwr_unmap_sync(), however, runs from xprt_rdma_free() after the
transport send lock has been released, so it is not ordered against
disconnect.

Tested on v7.4-rc1 under pNFS load with repeated data server restarts
to provoke rapid QP disconnect/reconnect cycling. Without the fix, a
hung task in frwr_unmap_sync() reproduced twice in six attempts. With
the fix, no hang occurred across 200 cycles.

Also observed on v6.8 and v6.18.34.

Fixes: e28ce90083f0 ("xprtrdma: kmalloc rpcrdma_ep separate from rpcrdma_xprt")
Cc: stable@vger.kernel.org
Assisted-by: Claude:opus-4-7
Reviewed-by: Chuck Lever <cel@kernel.org>
Signed-off-by: Tim Menninger <tmenninger@everpuredata.com>
Signed-off-by: Anna Schumaker <anna.schumaker@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/sunrpc/xprtrdma/frwr_ops.c  | 89 ++++++++++++++++++++-------------
 net/sunrpc/xprtrdma/transport.c |  2 +
 net/sunrpc/xprtrdma/verbs.c     | 16 ++++--
 net/sunrpc/xprtrdma/xprt_rdma.h | 10 +++-
 4 files changed, 78 insertions(+), 39 deletions(-)

diff --git a/net/sunrpc/xprtrdma/frwr_ops.c b/net/sunrpc/xprtrdma/frwr_ops.c
index a82eefe5e6b58..90107c4e8317a 100644
--- a/net/sunrpc/xprtrdma/frwr_ops.c
+++ b/net/sunrpc/xprtrdma/frwr_ops.c
@@ -27,13 +27,17 @@
 
 /* Transport recovery
  *
- * frwr_map and frwr_unmap_* cannot run at the same time the transport
- * connect worker is running. The connect worker holds the transport
- * send lock, just as ->send_request does. This prevents frwr_map and
- * the connect worker from running concurrently. When a connection is
- * closed, the Receive completion queue is drained before the allowing
- * the connect worker to get control. This prevents frwr_unmap and the
- * connect worker from running concurrently.
+ * frwr_map() is serialized with the connect worker by the transport
+ * send lock.
+ *
+ * frwr_unmap_async() runs from Receive completion processing.
+ * rpcrdma_xprt_drain() drains the Receive Queue before the Send Queue,
+ * so asynchronous LOCAL_INV Work Requests are submitted before Send
+ * Queue drain.
+ *
+ * frwr_unmap_sync() runs after the transport send lock is released.
+ * rx_unmap_rwsem orders its LOCAL_INV submission before disconnect
+ * drains the QP.
  *
  * When the underlying transport disconnects, MRs that are in flight
  * are flushed and are likely unusable. Thus all MRs are destroyed.
@@ -139,7 +143,6 @@ int frwr_mr_init(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr *mr)
 	mr->mr_ibmr = frmr;
 	mr->mr_device = NULL;
 	INIT_LIST_HEAD(&mr->mr_list);
-	init_completion(&mr->mr_linv_done);
 	frwr_cid_init(ep, mr);
 
 	sg_init_table(sg, depth);
@@ -468,40 +471,60 @@ static void frwr_wc_localinv(struct ib_cq *cq, struct ib_wc *wc)
  * @cq: completion queue
  * @wc: WCE for a completed LocalInv WR
  *
- * Awaken anyone waiting for an MR to finish being fenced.
+ * Wake frwr_unmap_sync() after the final LOCAL_INV completion.
  */
 static void frwr_wc_localinv_wake(struct ib_cq *cq, struct ib_wc *wc)
 {
 	struct ib_cqe *cqe = wc->wr_cqe;
 	struct rpcrdma_mr *mr = container_of(cqe, struct rpcrdma_mr, mr_cqe);
+	struct rpcrdma_req *req = mr->mr_req;
 
 	/* WARNING: Only wr_cqe and status are reliable at this point */
 	trace_xprtrdma_wc_li_wake(wc, &mr->mr_cid);
 	frwr_mr_done(wc, mr);
-	complete(&mr->mr_linv_done);
+	complete(&req->rl_linv_done);
 
 	rpcrdma_flush_disconnect(cq->cq_context, wc);
 }
 
 /**
- * frwr_unmap_sync - invalidate memory regions that were registered for @req
+ * frwr_unmap_sync - synchronously invalidate MRs registered for @req
  * @r_xprt: controlling transport instance
- * @req: rpcrdma_req with a non-empty list of MRs to process
+ * @req: request whose registered MRs are to be invalidated
  *
- * Sleeps until it is safe for the host CPU to access the previously mapped
- * memory regions. This guarantees that registered MRs are properly fenced
- * from the server before the RPC consumer accesses the data in them. It
- * also ensures proper Send flow control: waking the next RPC waits until
- * this RPC has relinquished all its Send Queue entries.
+ * If @req still owns registered MRs after synchronizing with transport
+ * disconnect, post a chain of LOCAL_INV Work Requests and wait for the
+ * final completion. On successful completion, this fences the mapped
+ * regions from remote access and preserves Send Queue flow control.
+ *
+ * A concurrent disconnect can reset @req while this function waits for
+ * the read side. In that case the MRs have already been released and no
+ * LOCAL_INV Work Requests are posted.
+ *
+ * Context: Process context. Takes and releases
+ *	    @r_xprt->rx_unmap_rwsem for read. May sleep.
  */
 void frwr_unmap_sync(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req)
 {
 	struct ib_send_wr *first, **prev, *last;
-	struct rpcrdma_ep *ep = r_xprt->rx_ep;
 	const struct ib_send_wr *bad_wr;
+	struct rpcrdma_ep *ep;
 	struct rpcrdma_mr *mr;
 	int rc;
 
+	/* serialize against rpcrdma_xprt_disconnect() */
+	down_read(&r_xprt->rx_unmap_rwsem);
+
+	/*
+	 * Disconnect can reset this request while we wait for the read side.
+	 * Recheck rl_registered in case rx_ep now refers to a new connection.
+	 */
+	ep = r_xprt->rx_ep;
+	if (!ep || list_empty(&req->rl_registered)) {
+		up_read(&r_xprt->rx_unmap_rwsem);
+		return;
+	}
+
 	/* ORDER: Invalidate all of the MRs first
 	 *
 	 * Chain the LOCAL_INV Work Requests and post them with
@@ -528,37 +551,35 @@ void frwr_unmap_sync(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req)
 		prev = &last->next;
 	} while ((mr = rpcrdma_mr_pop(&req->rl_registered)));
 
-	mr = container_of(last, struct rpcrdma_mr, mr_invwr);
-
 	/* Strong send queue ordering guarantees that when the
 	 * last WR in the chain completes, all WRs in the chain
 	 * are complete.
 	 */
 	last->wr_cqe->done = frwr_wc_localinv_wake;
-	reinit_completion(&mr->mr_linv_done);
+	reinit_completion(&req->rl_linv_done);
 
-	/* Transport disconnect drains the receive CQ before it
-	 * replaces the QP. The RPC reply handler won't call us
-	 * unless re_id->qp is a valid pointer.
+	/*
+	 * The read side prevents disconnect from draining this QP until the
+	 * LOCAL_INV chain has been submitted.
 	 */
 	bad_wr = NULL;
 	rc = ib_post_send(ep->re_id->qp, first, &bad_wr);
+	if (rc) {
+		/* On error, the MRs get destroyed once the QP has drained. */
+		trace_xprtrdma_post_linv_err(req, rc);
+
+		/* Force a connection loss to ensure complete recovery.
+		 */
+		rpcrdma_force_disconnect(ep);
+	}
+	up_read(&r_xprt->rx_unmap_rwsem);
 
 	/* The final LOCAL_INV WR in the chain is supposed to
 	 * do the wake. If it was never posted, the wake will
 	 * not happen, so don't wait in that case.
 	 */
 	if (bad_wr != first)
-		wait_for_completion(&mr->mr_linv_done);
-	if (!rc)
-		return;
-
-	/* On error, the MRs get destroyed once the QP has drained. */
-	trace_xprtrdma_post_linv_err(req, rc);
-
-	/* Force a connection loss to ensure complete recovery.
-	 */
-	rpcrdma_force_disconnect(ep);
+		wait_for_completion(&req->rl_linv_done);
 }
 
 /**
diff --git a/net/sunrpc/xprtrdma/transport.c b/net/sunrpc/xprtrdma/transport.c
index 5ff8e5126a6c2..308fd79e09df3 100644
--- a/net/sunrpc/xprtrdma/transport.c
+++ b/net/sunrpc/xprtrdma/transport.c
@@ -364,6 +364,8 @@ xprt_setup_rdma(struct xprt_create *args)
 	INIT_DELAYED_WORK(&new_xprt->rx_connect_worker,
 			  xprt_rdma_connect_worker);
 
+	init_rwsem(&new_xprt->rx_unmap_rwsem);
+
 	xprt->max_payload = RPCRDMA_MAX_DATA_SEGS << PAGE_SHIFT;
 
 	return xprt;
diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
index 111c415f1aeda..3c44c2c28c4f3 100644
--- a/net/sunrpc/xprtrdma/verbs.c
+++ b/net/sunrpc/xprtrdma/verbs.c
@@ -572,20 +572,24 @@ int rpcrdma_xprt_connect(struct rpcrdma_xprt *r_xprt)
  * rpcrdma_xprt_disconnect - Disconnect underlying transport
  * @r_xprt: controlling transport instance
  *
- * Caller serializes. Either the transport send lock is held,
- * or we're being called to destroy the transport.
+ * Context: Caller serializes. Either the transport send lock is held,
+ *	    or the transport is being destroyed. Takes and releases
+ *	    @r_xprt->rx_unmap_rwsem for write. May sleep.
  *
  * On return, @r_xprt is completely divested of all hardware
  * resources and prepared for the next ->connect operation.
  */
 void rpcrdma_xprt_disconnect(struct rpcrdma_xprt *r_xprt)
 {
-	struct rpcrdma_ep *ep = r_xprt->rx_ep;
+	struct rpcrdma_ep *ep;
 	struct rdma_cm_id *id;
 	int rc;
 
+	down_write(&r_xprt->rx_unmap_rwsem);
+
+	ep = r_xprt->rx_ep;
 	if (!ep)
-		return;
+		goto out_unlock;
 
 	/* Prevent teardown-generated events from requesting another close. */
 	atomic_xchg(&ep->re_force_disconnect, 1);
@@ -604,6 +608,9 @@ void rpcrdma_xprt_disconnect(struct rpcrdma_xprt *r_xprt)
 		rdma_destroy_id(id);
 
 	r_xprt->rx_ep = NULL;
+
+out_unlock:
+	up_write(&r_xprt->rx_unmap_rwsem);
 }
 
 /* Fixed-size circular FIFO queue. This implementation is wait-free and
@@ -912,6 +919,7 @@ struct rpcrdma_req *rpcrdma_req_create(struct rpcrdma_xprt *r_xprt,
 
 	INIT_LIST_HEAD(&req->rl_free_mrs);
 	INIT_LIST_HEAD(&req->rl_registered);
+	init_completion(&req->rl_linv_done);
 	spin_lock(&buffer->rb_lock);
 	list_add(&req->rl_all, &buffer->rb_allreqs);
 	spin_unlock(&buffer->rb_lock);
diff --git a/net/sunrpc/xprtrdma/xprt_rdma.h b/net/sunrpc/xprtrdma/xprt_rdma.h
index ae14f6a526e6e..d8e02a06771f4 100644
--- a/net/sunrpc/xprtrdma/xprt_rdma.h
+++ b/net/sunrpc/xprtrdma/xprt_rdma.h
@@ -46,6 +46,7 @@
 #include <linux/spinlock.h> 		/* spinlock_t, etc */
 #include <linux/atomic.h>		/* atomic_t, etc */
 #include <linux/kref.h>			/* struct kref */
+#include <linux/rwsem.h>		/* struct rw_semaphore */
 #include <linux/workqueue.h>		/* struct work_struct */
 #include <linux/llist.h>
 
@@ -248,7 +249,6 @@ struct rpcrdma_mr {
 	int			mr_nents;
 	enum dma_data_direction	mr_dir;
 	struct ib_cqe		mr_cqe;
-	struct completion	mr_linv_done;
 	union {
 		struct ib_reg_wr	mr_regwr;
 		struct ib_send_wr	mr_invwr;
@@ -331,6 +331,7 @@ struct rpcrdma_req {
 	struct list_head	rl_free_mrs;
 	struct list_head	rl_registered;
 	struct rpcrdma_mr_seg	rl_segments[RPCRDMA_MAX_SEGS];
+	struct completion	rl_linv_done;
 };
 
 static inline struct rpcrdma_req *
@@ -432,6 +433,13 @@ struct rpcrdma_xprt {
 	struct delayed_work	rx_connect_worker;
 	struct rpc_timeout	rx_timeout;
 	struct rpcrdma_stats	rx_stats;
+
+	/*
+	 * Orders frwr_unmap_sync()'s LOCAL_INV submission ahead of the
+	 * QP drain. Disconnect holds the write side across the drain
+	 * and resource teardown.
+	 */
+	struct rw_semaphore	rx_unmap_rwsem;
 };
 
 #define rpcx_to_rdmax(x) container_of(x, struct rpcrdma_xprt, rx_xprt)
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 045/555] gve: Fix race between stats query and queue reconfig
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (43 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 044/555] xprtrdma: serialize unmap_sync with xprt_disconnect Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 046/555] gve: Block invalid ring sizes when device options are 0 Greg Kroah-Hartman
                   ` (509 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Debarghya Kundu, Pin-yen Lin,
	Harshitha Ramamurthy, Jakub Kicinski, Sasha Levin

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

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

From: Pin-yen Lin <treapking@google.com>

[ Upstream commit 7de69da15088ac2add08eb2b5f5c0a79fd461c1e ]

Fix a concurrency bug where network statistics queries race with queue
reconfiguration or interface teardown, causing a Use-After-Free (UAF) or
NULL pointer dereference.

Currently, statistics queries access priv->tx and priv->rx without
locking. When an interface is brought down or reconfigured,
gve_queues_mem_remove() frees these arrays. A concurrent stats query
can dereference freed queue structures and crash the kernel.

This issue was discovered and actually triggered by the
drivers/net/stats.py selftest. When an interface was brought down,
querying per-queue statistics via Netlink caused a kernel NULL pointer
dereference in gve_get_rx_queue_stats():

  BUG: kernel NULL pointer dereference, address: 00000000000000a0
  RIP: 0010:gve_get_rx_queue_stats+0x17/0x50 [gve]
  Call Trace:
   <TASK>
   netdev_stat_queue_sum+0x11c/0x250
   netdev_nl_stats_by_netdev+0x21b/0x2d0
   netdev_nl_qstats_get_dumpit+0xd2/0x220
   genl_dumpit+0x32/0x90
   netlink_dump+0x1d2/0x450
   __netlink_dump_start+0x1db/0x2a0
   genl_family_rcv_msg_dumpit+0x9b/0x100
   ...

The per-queue stats callbacks run under the netdev instance lock, so
this NULL dereference is not a race; it happens on any query while the
interface is down.

Additionally, concurrent stats queries during queue reconfiguration can
race with gve_queues_mem_remove(), causing a Use-After-Free.
This affects gve_get_stats(), which does not hold the instance lock.
gve_handle_report_stats() also runs without it; it is stopped before
queue teardown, but can still read priv->rx[idx] while the single-queue
restart path rewrites it.

Fix this by introducing stats_lock to serialize stats queries against
queue teardown. In gve_queues_mem_remove(), queue pointers are set to
NULL under stats_lock before freeing. Stats readers acquire the lock
and verify pointers are non-NULL before reading counters.
The per-queue stats callbacks already run under the instance lock, but
take stats_lock as well for consistency.
The single-queue restart path also rewrites priv->rx[idx] in place, so
gve_rx_queue_stop() and gve_rx_queue_start() do those writes under
stats_lock as well.

This change was tested using the DQO RDA queue format.

Cc: stable@vger.kernel.org
Fixes: f5cedc84a30d ("gve: Add transmit and receive support")
Fixes: 2e5e0932dff5 ("gve: add support for basic queue stats")
Co-developed-by: Debarghya Kundu <debarghyak@google.com>
Signed-off-by: Debarghya Kundu <debarghyak@google.com>
Signed-off-by: Pin-yen Lin <treapking@google.com>
Signed-off-by: Harshitha Ramamurthy <hramamurthy@google.com>
Link: https://patch.msgid.link/20261109182036.2910559-2-hramamurthy@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[ sashal: Dropped the two per-queue stats callback hunks since that code doesn't exist in this tree, and adjusted context plus the lock span in gve_queues_start() to match the older code. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/google/gve/gve.h      |  5 +++++
 drivers/net/ethernet/google/gve/gve_main.c | 22 ++++++++++++++++++++--
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/google/gve/gve.h b/drivers/net/ethernet/google/gve/gve.h
index e19d722e8e9a1..3e768c64a5776 100644
--- a/drivers/net/ethernet/google/gve/gve.h
+++ b/drivers/net/ethernet/google/gve/gve.h
@@ -802,6 +802,11 @@ struct gve_priv {
 	struct workqueue_struct *gve_wq;
 	struct work_struct service_task;
 	struct work_struct stats_report_task;
+	/* Protects the priv->tx/priv->rx arrays, the in-place rewrite of
+	 * priv->rx[idx] and the queue counts against stats readers that do
+	 * not hold the netdev instance lock.
+	 */
+	spinlock_t stats_lock;
 	unsigned long service_task_flags;
 	unsigned long state_flags;
 
diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
index 974b493d712d2..a620dc6bc52ef 100644
--- a/drivers/net/ethernet/google/gve/gve_main.c
+++ b/drivers/net/ethernet/google/gve/gve_main.c
@@ -112,6 +112,7 @@ static void gve_get_stats(struct net_device *dev, struct rtnl_link_stats64 *s)
 	int num_tx_queues;
 	int ring;
 
+	spin_lock_bh(&priv->stats_lock);
 	num_tx_queues = gve_num_tx_queues(priv);
 	if (priv->rx) {
 		for (ring = 0; ring < priv->rx_cfg.num_queues; ring++) {
@@ -139,6 +140,7 @@ static void gve_get_stats(struct net_device *dev, struct rtnl_link_stats64 *s)
 			s->tx_bytes += bytes;
 		}
 	}
+	spin_unlock_bh(&priv->stats_lock);
 }
 
 static int gve_alloc_flow_rule_caches(struct gve_priv *priv)
@@ -1345,9 +1347,13 @@ static void gve_queues_mem_remove(struct gve_priv *priv)
 	struct gve_rx_alloc_rings_cfg rx_alloc_cfg = {0};
 
 	gve_get_curr_alloc_cfgs(priv, &tx_alloc_cfg, &rx_alloc_cfg);
-	gve_queues_mem_free(priv, &tx_alloc_cfg, &rx_alloc_cfg);
+
+	spin_lock_bh(&priv->stats_lock);
 	priv->tx = NULL;
 	priv->rx = NULL;
+	spin_unlock_bh(&priv->stats_lock);
+
+	gve_queues_mem_free(priv, &tx_alloc_cfg, &rx_alloc_cfg);
 }
 
 /* The passed-in queue memory is stored into priv and the queues are made live.
@@ -1361,6 +1367,7 @@ static int gve_queues_start(struct gve_priv *priv,
 	int err;
 
 	/* Record new resources into priv */
+	spin_lock_bh(&priv->stats_lock);
 	priv->tx = tx_alloc_cfg->tx;
 	priv->rx = rx_alloc_cfg->rx;
 
@@ -1375,9 +1382,11 @@ static int gve_queues_start(struct gve_priv *priv,
 	else
 		priv->num_xdp_queues = 0;
 
+	gve_init_sync_stats(priv);
+	spin_unlock_bh(&priv->stats_lock);
+
 	gve_tx_start_rings(priv, 0, tx_alloc_cfg->num_rings);
 	gve_rx_start_rings(priv, rx_alloc_cfg->qcfg->num_queues);
-	gve_init_sync_stats(priv);
 
 	err = netif_set_real_num_tx_queues(dev, priv->tx_cfg.num_queues);
 	if (err)
@@ -2155,6 +2164,7 @@ void gve_handle_report_stats(struct gve_priv *priv)
 	if (!gve_get_report_stats(priv))
 		return;
 
+	spin_lock_bh(&priv->stats_lock);
 	be64_add_cpu(&priv->stats_report->written_count, 1);
 	/* tx stats */
 	if (priv->tx) {
@@ -2219,6 +2229,7 @@ void gve_handle_report_stats(struct gve_priv *priv)
 			};
 		}
 	}
+	spin_unlock_bh(&priv->stats_lock);
 }
 
 /* Handle NIC status register changes, reset requests and report stats */
@@ -2468,8 +2479,10 @@ static int gve_rx_queue_stop(struct net_device *dev, void *per_q_mem, int idx)
 	gve_turnup_and_check_status(priv);
 
 	gve_per_q_mem = (struct gve_rx_ring *)per_q_mem;
+	spin_lock_bh(&priv->stats_lock);
 	*gve_per_q_mem = priv->rx[idx];
 	memset(&priv->rx[idx], 0, sizeof(priv->rx[idx]));
+	spin_unlock_bh(&priv->stats_lock);
 	return 0;
 }
 
@@ -2520,7 +2533,9 @@ static int gve_rx_queue_start(struct net_device *dev, void *per_q_mem, int idx)
 		return -EAGAIN;
 
 	gve_per_q_mem = (struct gve_rx_ring *)per_q_mem;
+	spin_lock_bh(&priv->stats_lock);
 	priv->rx[idx] = *gve_per_q_mem;
+	spin_unlock_bh(&priv->stats_lock);
 
 	/* Single-queue creation requires quiescence on all queues */
 	gve_turndown(priv);
@@ -2556,7 +2571,9 @@ static int gve_rx_queue_start(struct net_device *dev, void *per_q_mem, int idx)
 	 * which needs the rtnl lock, will not run till this func returns and
 	 * its caller gives up the lock.
 	 */
+	spin_lock_bh(&priv->stats_lock);
 	memset(&priv->rx[idx], 0, sizeof(priv->rx[idx]));
+	spin_unlock_bh(&priv->stats_lock);
 	return err;
 }
 
@@ -2663,6 +2680,7 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	}
 	INIT_WORK(&priv->service_task, gve_service_task);
 	INIT_WORK(&priv->stats_report_task, gve_stats_report_task);
+	spin_lock_init(&priv->stats_lock);
 	priv->tx_cfg.max_queues = max_tx_queues;
 	priv->rx_cfg.max_queues = max_rx_queues;
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 046/555] gve: Block invalid ring sizes when device options are 0
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (44 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 045/555] gve: Fix race between stats query and queue reconfig Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 047/555] net: wait for in-flight device unregistrations before netns dismantle Greg Kroah-Hartman
                   ` (508 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Pin-yen Lin, Joshua Washington,
	Jordan Rhee, Harshitha Ramamurthy, Jakub Kicinski, Sasha Levin

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

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

From: Pin-yen Lin <treapking@google.com>

[ Upstream commit edc9a730ad3c98662047a76db2d7f26ea4350b2e ]

On older device versions, minimum ring sizes in the device option are
reported as 0. The driver imports these 0 values, allowing userspace
(`ethtool -G`) to request invalidly small ring sizes.

This issue was discovered and actually triggered by the
drivers/net/ring_reconfig.py selftest (ringparam test case). Halving the
ring size down to 1 triggered a kernel NULL pointer dereference in
gve_tx_alloc_rings_dqo():

  BUG: kernel NULL pointer dereference, address: 0000000000000002
  RIP: 0010:gve_tx_alloc_rings_dqo+0x1c4/0x510 [gve]
  Call Trace:
   <TASK>
   gve_queues_mem_alloc+0x29/0xa0 [gve]
   gve_adjust_config+0x1b/0x140 [gve]
   gve_set_ringparam+0x1f4/0x250 [gve]
   ethnl_set_rings+0x260/0x440
   ...

Fix this by falling back to the driver's default minimum ring sizes
(GVE_DEFAULT_MIN_RX_RING_SIZE and GVE_DEFAULT_MIN_TX_RING_SIZE) whenever
the device option reports minimum ring sizes as 0.
The device reports either both minimum ring sizes or neither, so a
single fallback for both is sufficient.

This change was tested using the DQO RDA queue format.

Cc: stable@vger.kernel.org
Fixes: ed4fb326947d ("gve: add support to read ring size ranges from the device")
Signed-off-by: Pin-yen Lin <treapking@google.com>
Reviewed-by: Joshua Washington <joshwash@google.com>
Reviewed-by: Jordan Rhee <jordanrhee@google.com>
Signed-off-by: Harshitha Ramamurthy <hramamurthy@google.com>
Link: https://patch.msgid.link/20261109182036.2910559-4-hramamurthy@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[ sashal: Backport adapts the field path to the flat priv->default_min_ring_size and uses option_length < sizeof(**dev_op_modify_ring) instead of == 8 to avoid reading truncated option fields. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/google/gve/gve_adminq.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/google/gve/gve_adminq.c b/drivers/net/ethernet/google/gve/gve_adminq.c
index 36acbcd8f62a4..579c66aae1c70 100644
--- a/drivers/net/ethernet/google/gve/gve_adminq.c
+++ b/drivers/net/ethernet/google/gve/gve_adminq.c
@@ -188,7 +188,9 @@ void gve_parse_device_option(struct gve_priv *priv,
 		*dev_op_modify_ring = (void *)(option + 1);
 
 		/* device has not provided min ring size */
-		if (option_length == GVE_DEVICE_OPTION_NO_MIN_RING_SIZE)
+		if (option_length < sizeof(**dev_op_modify_ring) ||
+		    be16_to_cpu((*dev_op_modify_ring)->min_rx_ring_size) == 0 ||
+		    be16_to_cpu((*dev_op_modify_ring)->min_tx_ring_size) == 0)
 			priv->default_min_ring_size = true;
 		break;
 	case GVE_DEV_OPT_ID_FLOW_STEERING:
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 047/555] net: wait for in-flight device unregistrations before netns dismantle
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (45 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 046/555] gve: Block invalid ring sizes when device options are 0 Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 048/555] ksmbd: pin parent dentries in SMB2 CREATE ACL path Greg Kroah-Hartman
                   ` (507 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, syzbot+1269fe6cc2016008124e,
	Henry Martin, Eric Dumazet, Naman Gulati, Jakub Kicinski,
	Sasha Levin

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

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

From: Eric Dumazet <edumazet@kernel.org>

[ Upstream commit c164a431a646983275d0076ff5b0e4c326fbc10b ]

A device can be unregistered by a context other than the cleanup_net()
of its own netns, for instance a veth whose peer in another netns is
deleted. If references on it are still held, it stays in
netdev_wait_allrefs_any(), which rebroadcasts NETDEV_UNREGISTER every
second.

Meanwhile its netns can be dismantled: default_device_exit_batch()
only takes care of devices still listed in the netns, then pernet exit
handlers free their state, and finally struct net is freed while the
device still points to it.

The rebroadcasts then run notifiers against torn down pernet state, or
freed memory. Three instances were reported so far:

 - netdev_genl_netdevice_event(): net->genl_sock is NULL [1]
 - nh_netdev_event(): net->nexthop.devhash is NULL [2]
 - nf_tables netdevice notifiers: use-after-free of the nftables
   pernet storage [3]

but any notifier using dev_net(dev) is affected, as is
netdev_wait_allrefs_any() itself (__rtnl_net_lock(dev_net(dev)) with
CONFIG_DEBUG_NET_SMALL_RTNL=y).

This was prevented by rtnl_lock_unregistering() until I removed it
in commit 8a4fc54b07d7 ("net: get rid of rtnl_lock_unregistering()"),
considering only the loopback dependency, and missing the notifiers one.

Restore a per-netns counter of devices sitting in netdev_run_todo(),
and make default_device_exit_batch() wait for it to reach zero, after
it has unregistered all devices of the dying netns(es). At this point
no new unregistration can be started for these netns.

Unlike the old barrier, this only waits for devices of the netns being
dismantled and runs after their own devices are gone.

Tested on a KASAN kernel with a debug-only hack holding a reference
on a veth device for 5 seconds after its unregistration: a nexthop
on the veth in netns X, delete its peer from init_net, then delete X.
Without this patch, the nexthop_flush_dev() null-ptr-deref from [2]
triggers. With it, no splat; netns churn and dismantle of a netns
whose own device is held still work.

[1] https://lore.kernel.org/netdev/6adf9f64.6200f071.51519.0ed1.GAE@google.com/
[2] https://lore.kernel.org/netdev/20261105114707.3030737-1-bsdhenrymartin@gmail.com/
[3] https://lore.kernel.org/netdev/20261105114817.3033625-1-bsdhenrymartin@gmail.com/

Fixes: 8a4fc54b07d7 ("net: get rid of rtnl_lock_unregistering()")
Cc: stable@vger.kernel.org
Reported-by: syzbot+1269fe6cc2016008124e@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/netdev/6adf9f64.6200f071.51519.0ed1.GAE@google.com/
Reported-by: Henry Martin <bsdhenrymartin@gmail.com>
Closes: https://lore.kernel.org/netdev/20261105114707.3030737-1-bsdhenrymartin@gmail.com/
Closes: https://lore.kernel.org/netdev/20261105114817.3033625-1-bsdhenrymartin@gmail.com/
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Reviewed-by: Naman Gulati <namangulati@google.com>
Link: https://patch.msgid.link/20261105144543.1624238-1-edumazet@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[ sashal: adjusted context for a missing dev_mc_genid field in struct net, and moved the wait_event placement relative to the rtnl_net_flush_workqueue() call. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/net/net_namespace.h |  1 +
 net/core/dev.c              | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index f659d1efcd3ce..7b53eb6c21798 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -68,6 +68,7 @@ struct net {
 	spinlock_t		rules_mod_lock;
 
 	unsigned int		dev_base_seq;	/* protected by rtnl_mutex */
+	atomic_t		dev_unreg_pending; /* devices in netdev_run_todo() */
 	u32			ifindex;
 
 	spinlock_t		nsid_lock;
diff --git a/net/core/dev.c b/net/core/dev.c
index bd1b0f10d9374..426f6d2e19524 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -10145,6 +10145,14 @@ atomic_t dev_unreg_count = ATOMIC_INIT(0);
 static void net_set_todo(struct net_device *dev)
 {
 	list_add_tail(&dev->todo_list, &net_todo_list);
+	atomic_inc(&dev_net(dev)->dev_unreg_pending);
+}
+
+/* Paired with net_set_todo(). @net must not be used after this call. */
+static void net_unreg_done(struct net *net)
+{
+	if (atomic_dec_and_test(&net->dev_unreg_pending))
+		wake_up(&netdev_unregistering_wq);
 }
 
 static netdev_features_t netdev_sync_upper_features(struct net_device *lower,
@@ -11034,6 +11042,7 @@ void netdev_run_todo(void)
 		if (unlikely(dev->reg_state != NETREG_UNREGISTERING)) {
 			netdev_WARN(dev, "run_todo but not unregistering\n");
 			list_del(&dev->todo_list);
+			net_unreg_done(dev_net(dev));
 			continue;
 		}
 
@@ -11043,8 +11052,11 @@ void netdev_run_todo(void)
 
 	cnt = 0;
 	while (!list_empty(&list)) {
+		struct net *net;
+
 		dev = netdev_wait_allrefs_any(&list);
 		list_del(&dev->todo_list);
+		net = dev_net(dev);
 
 		/* paranoia */
 		BUG_ON(netdev_refcnt_read(dev) != 1);
@@ -11063,6 +11075,8 @@ void netdev_run_todo(void)
 
 		/* Free network device */
 		kobject_put(&dev->dev.kobj);
+
+		net_unreg_done(net);
 	}
 	if (cnt && atomic_sub_and_test(cnt, &dev_unreg_count))
 		wake_up(&netdev_unregistering_wq);
@@ -12298,6 +12312,17 @@ static void __net_exit default_device_exit_net(struct net *net)
 	}
 }
 
+static bool __net_exit netns_dev_unreg_pending(const struct list_head *net_list)
+{
+	struct net *net;
+
+	list_for_each_entry(net, net_list, exit_list) {
+		if (atomic_read(&net->dev_unreg_pending))
+			return true;
+	}
+	return false;
+}
+
 static void __net_exit default_device_exit_batch(struct list_head *net_list)
 {
 	/* At exit all network devices most be removed from a network
@@ -12325,6 +12350,16 @@ static void __net_exit default_device_exit_batch(struct list_head *net_list)
 	}
 	unregister_netdevice_many(&dev_kill_list);
 	rtnl_unlock();
+
+	/* Devices of these netns unregistered from another context
+	 * (e.g. a veth whose peer was deleted) can still be waiting
+	 * in netdev_run_todo() for their last references, while
+	 * NETDEV_UNREGISTER is rebroadcast for them. Wait for them
+	 * before pernet exit handlers tear down the state used by
+	 * netdevice notifiers, and before the netns is freed.
+	 * No new unregistration can start: all devices are unlisted.
+	 */
+	wait_event(netdev_unregistering_wq, !netns_dev_unreg_pending(net_list));
 }
 
 static struct pernet_operations __net_initdata default_device_ops = {
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 048/555] ksmbd: pin parent dentries in SMB2 CREATE ACL path
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (46 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 047/555] net: wait for in-flight device unregistrations before netns dismantle Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 049/555] ksmbd: refuse to read a handle that is not open for reading Greg Kroah-Hartman
                   ` (506 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, stable, Jiwoo Kim, Namjae Jeon,
	Sasha Levin

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

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

From: Jiwoo Kim <arpe1618@gmail.com>

[ Upstream commit 0383a66dabd7aa06237b9b24713c03656abeffe4 ]

smb2_open() and smb_inherit_dacl() read a child's d_parent without a
dentry reference. A concurrent SMB request can move the child and
remove the parent while CREATE uses its inode for permission, status,
and ACL inheritance work. A remote SMB race with concurrent opener and
mover connections on a writable KSMBD acl_xattr share triggered an
8-byte slab-use-after-free read in get_cached_acl on tmpfs and ext4
KASAN guests. With oops=panic, it also caused an Oops and kernel panic
on an ext4 guest.

Take a parent dentry reference around each parent inode or ACL access
in these paths and release it when the operation completes. Treat a
negative parent dentry as -ENOENT for the affected operation.

On a tmpfs KASAN QEMU guest, two 3,000-round reproducer instances
completed without a KASAN report or Oops; SMB remained reachable. On
an ext4 non-KASAN QEMU guest with oops=panic, a 2,000-operation no-race
control and two 5,000-round reproducer instances completed without an
Oops or panic. An SMB health probe still succeeded.

OpenAI Codex assisted with finding the bug, generating the SMB race
reproducer, drafting this fix and changelog, and running the tests.

Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
Cc: stable@kernel.org
Signed-off-by: Jiwoo Kim <arpe1618@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
[ sashal: Dropped the kunit/visibility.h include context and adapted const struct mnt_idmap *idmap to non-const struct mnt_idmap *idmap for the older tree's smbacl.c. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/smb/server/smb2pdu.c | 39 +++++++++++++++++++++++++++++++--------
 fs/smb/server/smbacl.c  |  9 ++++++++-
 2 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 115960cc93994..82d1225dd7e8f 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -3442,16 +3442,32 @@ int smb2_open(struct ksmbd_work *work)
 
 			if ((daccess & FILE_DELETE_LE) ||
 			    (req->CreateOptions & FILE_DELETE_ON_CLOSE_LE)) {
-				rc = inode_permission(idmap,
-						      d_inode(path.dentry->d_parent),
-						      MAY_EXEC | MAY_WRITE);
+				struct dentry *parent = dget_parent(path.dentry);
+				struct inode *parent_inode = d_inode(parent);
+
+				if (parent_inode)
+					rc = inode_permission(idmap, parent_inode,
+							      MAY_EXEC | MAY_WRITE);
+				else
+					rc = -ENOENT;
+				dput(parent);
 				if (rc)
 					goto err_out;
 			}
 		}
 	}
 
-	rc = ksmbd_query_inode_status(path.dentry->d_parent);
+	{
+		struct dentry *parent = dget_parent(path.dentry);
+
+		if (!d_inode(parent)) {
+			dput(parent);
+			rc = -ENOENT;
+			goto err_out;
+		}
+		rc = ksmbd_query_inode_status(parent);
+		dput(parent);
+	}
 	if (rc == KSMBD_INODE_STATUS_PENDING_DELETE) {
 		rc = -EBUSY;
 		goto err_out;
@@ -3505,10 +3521,17 @@ int smb2_open(struct ksmbd_work *work)
 	if (created) {
 		int posix_acl_rc;
 		struct inode *inode = d_inode(path.dentry);
-
-		posix_acl_rc = ksmbd_vfs_inherit_posix_acl(idmap,
-							   &path,
-							   d_inode(path.dentry->d_parent));
+		struct inode *parent_inode;
+		struct dentry *parent;
+
+		parent = dget_parent(path.dentry);
+		parent_inode = d_inode(parent);
+		if (parent_inode)
+			posix_acl_rc = ksmbd_vfs_inherit_posix_acl(idmap, &path,
+								   parent_inode);
+		else
+			posix_acl_rc = -ENOENT;
+		dput(parent);
 		if (posix_acl_rc)
 			ksmbd_debug(SMB, "inherit posix acl failed : %d\n", posix_acl_rc);
 
diff --git a/fs/smb/server/smbacl.c b/fs/smb/server/smbacl.c
index 42a638d1d2b97..1bd816153e542 100644
--- a/fs/smb/server/smbacl.c
+++ b/fs/smb/server/smbacl.c
@@ -7,6 +7,7 @@
  */
 
 #include <linux/fs.h>
+#include <linux/dcache.h>
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/mnt_idmapping.h>
@@ -1200,7 +1201,7 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,
 	struct smb_acl *parent_pdacl;
 	struct smb_ntsd *parent_pntsd = NULL;
 	struct smb_sid owner_sid, group_sid;
-	struct dentry *parent = path->dentry->d_parent;
+	struct dentry *parent;
 	struct mnt_idmap *idmap = mnt_idmap(path->mnt);
 	int inherited_flags = 0, flags = 0, i, nt_size = 0, pdacl_size;
 	int rc = 0, pntsd_type, ppntsd_size, acl_len, aces_size;
@@ -1210,8 +1211,14 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,
 	char *aces_base;
 	bool is_dir = S_ISDIR(d_inode(path->dentry)->i_mode);
 
+	parent = dget_parent(path->dentry);
+	if (!d_inode(parent)) {
+		dput(parent);
+		return -ENOENT;
+	}
 	ppntsd_size = ksmbd_vfs_get_sd_xattr(conn, idmap,
 					    parent, &parent_pntsd);
+	dput(parent);
 	if (ppntsd_size <= 0)
 		return -ENOENT;
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 049/555] ksmbd: refuse to read a handle that is not open for reading
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (47 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 048/555] ksmbd: pin parent dentries in SMB2 CREATE ACL path Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 050/555] tracing/probes: Fix BTF bitfield parsing and out-of-bounds buffer write Greg Kroah-Hartman
                   ` (505 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Wahid Khan, Ian Bridges, Namjae Jeon,
	Sasha Levin

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

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

From: Wahid Khan <wahidzk0091@gmail.com>

[ Upstream commit 2fd145f8865bb1a6c38a3dc68fa44290008789d8 ]

smb2_create_open_flags() picks the open mode from the read and write
bits of the desired access. FILE_EXECUTE and FILE_READ_ATTRIBUTES select
neither, so a request for FILE_WRITE_DATA | FILE_EXECUTE |
FILE_READ_ATTRIBUTES opens the file O_WRONLY.

smb2_read() accepts FILE_READ_ATTRIBUTES and ksmbd_vfs_read() accepts
FILE_EXECUTE, so a later READ on that handle passes both checks and
reaches __kernel_read() on a file that has no FMODE_READ:

  WARNING: fs/read_write.c:518 at __kernel_read
   __kernel_read
   ksmbd_vfs_read
   smb2_read
   handle_ksmbd_work

Any client that can open a file with write access on a share, including
a guest session, can trigger it; with panic_on_warn it takes the machine
down.

Return STATUS_ACCESS_DENIED when the file is not readable.

Fixes: f44158485826 ("cifsd: add file operations")
Cc: stable@vger.kernel.org
Signed-off-by: Wahid Khan <wahidzk0091@gmail.com>
Reviewed-by: Ian Bridges <icb@fastmail.org>
Tested-by: Ian Bridges <icb@fastmail.org>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
[ sashal: adjusted context: the new FMODE_READ check is inserted before this tree's if (!work->tcon->posix_extensions) { line instead of upstream's if (!fp->is_posix_ctxt) {. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/smb/server/vfs.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
index 9aee0214e8fdc..732cb489efd90 100644
--- a/fs/smb/server/vfs.c
+++ b/fs/smb/server/vfs.c
@@ -390,6 +390,10 @@ int ksmbd_vfs_read(struct ksmbd_work *work, struct ksmbd_file *fp, size_t count,
 	if (ksmbd_stream_fd(fp))
 		return ksmbd_vfs_stream_read(fp, rbuf, pos, count);
 
+	/* The access granted on open can include FILE_EXECUTE for a write-only file */
+	if (!(filp->f_mode & FMODE_READ))
+		return -EACCES;
+
 	if (!work->tcon->posix_extensions) {
 		int ret;
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 050/555] tracing/probes: Fix BTF bitfield parsing and out-of-bounds buffer write
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (48 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 049/555] ksmbd: refuse to read a handle that is not open for reading Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 051/555] comedi: comedi_bond: Fix leak of opened device references Greg Kroah-Hartman
                   ` (504 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Masami Hiramatsu (Google),
	Sasha Levin

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

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

From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

[ Upstream commit 9b6e9d6a11090ac34516c45f48663b37ac94a9b1 ]

BTF bitfield parsing in trace_probe.c assumes a 64-bit (8-byte) container
when computing FETCH_OP_MOD_BF shift amounts and basesize, whereas the
preceding store instruction only allocates and writes the field's fetch
type size (which may be 1, 2, or 4 bytes when kflag=1). At runtime,
fetch_apply_bitfield() performs an 8-byte read-modify-write on the
smaller ring buffer slot, corrupting adjacent ring buffer data or writing
past the end of the event record.

In addition, signed bitfields with bit widths other than 8/16/32/64 fail
to resolve a fetch type, bitfields whose width is a multiple of 8 inside
a larger integer or spanning a byte boundary fail to emit FETCH_OP_MOD_BF
or select a container wide enough for bitoffs + bitsize, kflag=0 bitfield
offsets >= 8 bits are not folded into the byte offset, and big-endian
architectures use the little-endian left-shift formula in
parse_btf_bitfield().

Compute the bitfield byte and bit offsets consistently during field
lookup, select the smallest unsigned fetch type that covers the bit
offset and bit width, and calculate the FETCH_OP_MOD_BF parameters from
the selected fetch type size for both big- and little-endian bitfields.

Link: https://lore.kernel.org/all/179455850711.403392.10512730891220678403.stgit@devnote2/

Fixes: c440adfbe302 ("tracing/probes: Support BTF based data structure field access")
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
[ sashal: Inlined the field-walk changes into parse_btf_field() because the get_bitoffset_of_field() helper doesn't exist in this tree. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/trace/trace_probe.c | 61 ++++++++++++++++++++++++++++----------
 1 file changed, 46 insertions(+), 15 deletions(-)

diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index 786552250ac13..72ee17e0a5f7c 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -405,6 +405,18 @@ static const char *fetch_type_from_btf_type(struct btf *btf,
 {
 	u32 intdata;
 
+	if (ctx->last_bitsize) {
+		u32 bits = ctx->last_bitsize + ctx->last_bitoffs;
+
+		if (bits <= 8)
+			return "u8";
+		if (bits <= 16)
+			return "u16";
+		if (bits <= 32)
+			return "u32";
+		return "u64";
+	}
+
 	/* TODO: const char * could be converted as a string */
 	switch (BTF_INFO_KIND(type->info)) {
 	case BTF_KIND_ENUM:
@@ -442,10 +454,6 @@ static const char *fetch_type_from_btf_type(struct btf *btf,
 			case 64:
 				return "u64";
 			}
-			/* bitfield, size is encoded in the type */
-			ctx->last_bitsize = BTF_INT_BITS(intdata);
-			ctx->last_bitoffs += BTF_INT_OFFSET(intdata);
-			return "u64";
 		}
 	}
 	/* TODO: support other types */
@@ -583,6 +591,12 @@ static int parse_btf_field(char *fieldname, const struct btf_type *type,
 			/* Add anonymous structure/union offset */
 			bitoffs += anon_offs;
 
+			type = btf_type_skip_modifiers(ctx->btf, field->type, &tid);
+			if (!type) {
+				trace_probe_log_err(ctx->offset, BAD_BTF_TID);
+				return -EINVAL;
+			}
+
 			/* Accumulate the bit-offsets of the dot-connected fields */
 			if (btf_type_kflag(mtype)) {
 				bitoffs += BTF_MEMBER_BIT_OFFSET(field->offset);
@@ -590,12 +604,15 @@ static int parse_btf_field(char *fieldname, const struct btf_type *type,
 			} else {
 				bitoffs += field->offset;
 				ctx->last_bitsize = 0;
-			}
-
-			type = btf_type_skip_modifiers(ctx->btf, field->type, &tid);
-			if (!type) {
-				trace_probe_log_err(ctx->offset, BAD_BTF_TID);
-				return -EINVAL;
+				if (BTF_INFO_KIND(type->info) == BTF_KIND_INT) {
+					u32 intdata = btf_type_int(type);
+
+					bitoffs += BTF_INT_OFFSET(intdata);
+					if ((bitoffs % 8) ||
+					    BTF_INT_BITS(intdata) != BYTES_TO_BITS(type->size) ||
+					    !is_power_of_2(type->size))
+						ctx->last_bitsize = BTF_INT_BITS(intdata);
+				}
 			}
 
 			ctx->offset += next - fieldname;
@@ -727,13 +744,22 @@ static const struct fetch_type *find_fetch_type_from_btf_type(
 }
 
 static int parse_btf_bitfield(struct fetch_insn **pcode,
+			      const struct fetch_type *t,
 			      struct traceprobe_parse_context *ctx)
 {
 	struct fetch_insn *code = *pcode;
 
-	if ((ctx->last_bitsize % 8 == 0) && ctx->last_bitoffs == 0)
+	if ((ctx->last_bitsize == 0 ||
+	     ctx->last_bitsize == BYTES_TO_BITS(t->size)) &&
+	    ctx->last_bitoffs == 0)
 		return 0;
 
+	if (ctx->last_bitsize == 0 ||
+	    BYTES_TO_BITS(t->size) < (ctx->last_bitsize + ctx->last_bitoffs)) {
+		trace_probe_log_err(ctx->offset, BAD_BITFIELD);
+		return -EINVAL;
+	}
+
 	code++;
 	if (code->op != FETCH_OP_NOP) {
 		trace_probe_log_err(ctx->offset, TOO_MANY_OPS);
@@ -742,9 +768,13 @@ static int parse_btf_bitfield(struct fetch_insn **pcode,
 	*pcode = code;
 
 	code->op = FETCH_OP_MOD_BF;
-	code->lshift = 64 - (ctx->last_bitsize + ctx->last_bitoffs);
-	code->rshift = 64 - ctx->last_bitsize;
-	code->basesize = 64 / 8;
+#ifdef __BIG_ENDIAN_BITFIELD
+	code->lshift = ctx->last_bitoffs;
+#else
+	code->lshift = BYTES_TO_BITS(t->size) - (ctx->last_bitsize + ctx->last_bitoffs);
+#endif
+	code->rshift = BYTES_TO_BITS(t->size) - ctx->last_bitsize;
+	code->basesize = t->size;
 	return 0;
 }
 
@@ -768,6 +798,7 @@ static int parse_btf_arg(char *varname,
 }
 
 static int parse_btf_bitfield(struct fetch_insn **pcode,
+			      const struct fetch_type *t,
 			      struct traceprobe_parse_context *ctx)
 {
 	trace_probe_log_err(ctx->offset, NOSUP_BTFARG);
@@ -1427,7 +1458,7 @@ static int finalize_fetch_insn(struct fetch_insn *code,
 	} else if (IS_ENABLED(CONFIG_PROBE_EVENTS_BTF_ARGS) &&
 		   ctx->last_type) {
 		/* If user not specified the type, try parsing BTF bitfield. */
-		ret = parse_btf_bitfield(&code, ctx);
+		ret = parse_btf_bitfield(&code, parg->type, ctx);
 		if (ret)
 			return ret;
 	}
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 051/555] comedi: comedi_bond: Fix leak of opened device references
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (49 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 050/555] tracing/probes: Fix BTF bitfield parsing and out-of-bounds buffer write Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 052/555] Bluetooth: btusb: fix use-after-free in force_poll_sync Greg Kroah-Hartman
                   ` (503 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, stable, Wentao Liang, Ian Abbott,
	Sasha Levin

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

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

From: Ian Abbott <abbotti@mev.co.uk>

commit fa0858523f07f8dd71d89b221f4422c3b8096d90 upstream.

bonding_attach() calls do_dev_config() to open other comedi devices
specified by the user and tries to make use of them as part of the
'bonding' device.  If it successfully opens the other device but cannot
use it (either because it does not any subdevices of a type the
'bonding' device can use, or because of some error that occurs while
dealing with its subdevices) then it is left in the open state and the
fact that it is open does not get recorded by the 'bonding' device, so
the reference to the opened device gets lost.  Fix it by closing the
opened device if it could not be bound to the 'bonding' device.

To match previous behavior, if the opened device is unsuitable then
ignore it (after closing it).  The opened devices recorded by the
'bonding' device will eventually get closed by bonding_detach() even if
bonding_attach() returns an error.

Fixes: 3cf840f65ad5 ("Staging: comedi: add comedi_bond driver")
Cc: stable <stable@kernel.org>
Reported-by: Wentao Liang <vulab@iscas.ac.cn>
Link: https://lore.kernel.org/lkml/20261103063301.1025860-1-vulab@iscas.ac.cn
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Link: https://patch.msgid.link/20261103173610.89687-1-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit fa0858523f07f8dd71d89b221f4422c3b8096d90)
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/comedi/drivers/comedi_bond.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/comedi/drivers/comedi_bond.c b/drivers/comedi/drivers/comedi_bond.c
index 78c39fa841776..076aecae2c776 100644
--- a/drivers/comedi/drivers/comedi_bond.c
+++ b/drivers/comedi/drivers/comedi_bond.c
@@ -182,7 +182,9 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it)
 		char file[sizeof("/dev/comediXXXXXX")];
 		int minor = it->options[i];
 		struct comedi_device *d;
-		int sdev = -1, nchans;
+		int sdev = -1;
+		int nchans;
+		int nope = 1;
 		struct bonded_device *bdev;
 		struct bonded_device **devs;
 
@@ -221,11 +223,14 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it)
 				dev_err(dev->class_dev,
 					"comedi_get_n_channels() returned %d on minor %u subdev %d!\n",
 					nchans, minor, sdev);
-				return -EINVAL;
+				nope = -EINVAL;
+				break;
 			}
 			bdev = kmalloc(sizeof(*bdev), GFP_KERNEL);
-			if (!bdev)
-				return -ENOMEM;
+			if (!bdev) {
+				nope = -ENOMEM;
+				break;
+			}
 
 			bdev->dev = d;
 			bdev->minor = minor;
@@ -246,10 +251,12 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it)
 				dev_err(dev->class_dev,
 					"Could not allocate memory. Out of memory?\n");
 				kfree(bdev);
-				return -ENOMEM;
+				nope = -ENOMEM;
+				break;
 			}
 			devpriv->devs = devs;
 			devpriv->devs[devpriv->ndevs++] = bdev;
+			nope = 0;	/* keeps the device open */
 			{
 				/* Append dev:subdev to devpriv->name */
 				char buf[20];
@@ -260,6 +267,13 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it)
 					sizeof(devpriv->name));
 			}
 		}
+
+		if (nope) {
+			/* Opened device cannot be used, so close it. */
+			comedi_close(d);
+			if (nope < 0)
+				return nope;
+		}
 	}
 
 	if (!devpriv->nchans) {
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 052/555] Bluetooth: btusb: fix use-after-free in force_poll_sync
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (50 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 051/555] comedi: comedi_bond: Fix leak of opened device references Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 053/555] tools/bootconfig: Close only opened braces in compact output Greg Kroah-Hartman
                   ` (502 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Bin Yu, Cheng Wen,
	Luiz Augusto von Dentz, YuanZhe Liu, Sasha Levin

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

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

From: YuanZhe Liu <25031212351@stu.xidian.edu.cn>

[ Upstream commit 868c886f45f7c10dc888b94c6993352702a84d04 ]

The force_poll_sync debugfs file uses the driver's struct btusb_data as
its private data. The file is created under hdev->debugfs and is removed
only when the HCI device is released, while btusb_disconnect() frees
btusb_data unconditionally. The HCI device can outlive the driver data,
for example when an HCI socket still references it, so reading or
writing the already opened file then dereferences freed memory:

  BUG: KASAN: slab-use-after-free in force_poll_sync_read+0x129/0x140
  Read of size 1 at addr ffff88800cfb7038
  ...
  Freed by task ...:
   kfree
   btusb_disconnect

Remove the debugfs file before the private data is freed.
debugfs_remove() waits for callers that are already inside the file
operations, and any later access fails with -EIO instead of reaching the
driver, so the force_poll_sync file can no longer dereference btusb_data
after it is gone.

Fixes: 800fe5ec302e ("Bluetooth: btusb: Add support for queuing during polling interval")
Cc: stable@vger.kernel.org
Co-developed-by: Bin Yu <byu@xidian.edu.cn>
Signed-off-by: Bin Yu <byu@xidian.edu.cn>
Co-developed-by: Cheng Wen <wencheng@xidian.edu.cn>
Signed-off-by: Cheng Wen <wencheng@xidian.edu.cn>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/bluetooth/btusb.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 6142546c387ee..48ae89803c4fd 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -995,6 +995,8 @@ struct btusb_data {
 	int (*disconnect)(struct hci_dev *hdev);
 
 	int oob_wake_irq;   /* irq for out-of-band wake-on-bt */
+
+	struct dentry *force_poll_sync_dentry;
 	unsigned cmd_timeout_cnt;
 
 	struct qca_dump_info qca_dump;
@@ -4231,8 +4233,9 @@ static int btusb_probe(struct usb_interface *intf,
 
 	usb_set_intfdata(intf, data);
 
-	debugfs_create_file("force_poll_sync", 0644, hdev->debugfs, data,
-			    &force_poll_sync_fops);
+	data->force_poll_sync_dentry =
+		debugfs_create_file("force_poll_sync", 0644, hdev->debugfs,
+				    data, &force_poll_sync_fops);
 
 	return 0;
 
@@ -4268,6 +4271,9 @@ static void btusb_disconnect(struct usb_interface *intf)
 	if (!data)
 		return;
 
+	debugfs_remove(data->force_poll_sync_dentry);
+	data->force_poll_sync_dentry = NULL;
+
 	hdev = data->hdev;
 	usb_set_intfdata(data->intf, NULL);
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 053/555] tools/bootconfig: Close only opened braces in compact output
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (51 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 052/555] Bluetooth: btusb: fix use-after-free in force_poll_sync Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 054/555] ipv6: Remove IPV6_ADDRFORM Greg Kroah-Hartman
                   ` (501 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Masami Hiramatsu (Google),
	Eduardo Mucelli Rezende Oliveira, Sasha Levin

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

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

From: Eduardo Mucelli Rezende Oliveira <edumucelli@gmail.com>

commit 26fa92f351d4993428268afebf6c60c987477af5 upstream.

A key may have both a value and subkeys. When it has only one subkey,
xbc_show_compact_tree() can print that subkey using dotted notation
without opening a brace. During backtracking, however, it treats the
value node followed by a subkey as evidence that a brace was opened.

For example, a.b=v, a.b.c=w and a.z=q are printed with the brace for a
closed before z. Reading that output back changes a.z into the root key
z, silently changing the configuration.

Check the key children when deciding whether to close a brace. Skip the
value child, and account for a sole subkey that itself has both a value
and subkeys, since that combination is not compacted. This follows the
conditions used to open braces without keeping a depth-indexed array.
Extend the mixed-value/subkey sample to cover the lost sibling.

The stable test script only checks whether the good samples can
be attached. Add the compact-output comparison for the extended
mixed-value/subkey sample and add its expected output file.

Link: https://lore.kernel.org/all/6ad67e4cda05238cd173c99e820a85de2c13f5fc.1794337724.git.edumucelli@gmail.com/

Fixes: e5efaeb8a8f5 ("bootconfig: Support mixing a value and subkeys under a key")
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Eduardo Mucelli Rezende Oliveira <edumucelli@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/bootconfig/main.c                       | 29 ++++++++++++++-----
 .../samples/exp-good-mixed-kv1.bconf          |  7 +++++
 tools/bootconfig/samples/good-mixed-kv1.bconf |  5 ++++
 tools/bootconfig/test-bootconfig.sh           |  6 ++++
 4 files changed, 40 insertions(+), 7 deletions(-)
 create mode 100644 tools/bootconfig/samples/exp-good-mixed-kv1.bconf

diff --git a/tools/bootconfig/main.c b/tools/bootconfig/main.c
index 5ccdb9881b5a0..0c73eacd8c1e5 100644
--- a/tools/bootconfig/main.c
+++ b/tools/bootconfig/main.c
@@ -38,6 +38,23 @@ static int xbc_show_value(struct xbc_node *node, bool semicolon)
 	return i;
 }
 
+/* Match the conditions under which the compact formatter opens braces. */
+static bool xbc_node_needs_braces(struct xbc_node *node)
+{
+	struct xbc_node *child = xbc_node_get_child(node);
+
+	if (child && xbc_node_is_value(child))
+		child = xbc_node_get_next(child);
+	if (!child)
+		return false;
+	if (child->next)
+		return true;
+
+	/* A single subkey with both a value and subkeys is not compacted. */
+	child = xbc_node_get_child(child);
+	return child && xbc_node_is_value(child) && child->next;
+}
+
 static void xbc_show_compact_tree(void)
 {
 	struct xbc_node *node, *cnode = NULL, *vnode;
@@ -98,14 +115,12 @@ static void xbc_show_compact_tree(void)
 			node = xbc_node_get_parent(node);
 			if (!node)
 				return;
-			if (!xbc_node_get_child(node)->next)
+			if (!depth || !xbc_node_needs_braces(node))
 				continue;
-			if (depth) {
-				depth--;
-				for (i = 0; i < depth; i++)
-					printf("\t");
-				printf("}\n");
-			}
+			depth--;
+			for (i = 0; i < depth; i++)
+				printf("\t");
+			printf("}\n");
 		}
 		node = xbc_node_get_next(node);
 	}
diff --git a/tools/bootconfig/samples/exp-good-mixed-kv1.bconf b/tools/bootconfig/samples/exp-good-mixed-kv1.bconf
new file mode 100644
index 0000000000000..0b8b2f59da31e
--- /dev/null
+++ b/tools/bootconfig/samples/exp-good-mixed-kv1.bconf
@@ -0,0 +1,7 @@
+key = "value";
+key.subkey = "another-value";
+a {
+	b = "v";
+	b.c = "w";
+	z = "q";
+}
diff --git a/tools/bootconfig/samples/good-mixed-kv1.bconf b/tools/bootconfig/samples/good-mixed-kv1.bconf
index 1761547dd05ca..35442ee62b751 100644
--- a/tools/bootconfig/samples/good-mixed-kv1.bconf
+++ b/tools/bootconfig/samples/good-mixed-kv1.bconf
@@ -1,3 +1,8 @@
 # value -> subkey pattern
 key = value
 key.subkey = another-value
+
+# A valued parent with one subkey must not close its enclosing brace.
+a.b = v
+a.b.c = w
+a.z = q
diff --git a/tools/bootconfig/test-bootconfig.sh b/tools/bootconfig/test-bootconfig.sh
index be8d05833704d..42bac54e74b25 100755
--- a/tools/bootconfig/test-bootconfig.sh
+++ b/tools/bootconfig/test-bootconfig.sh
@@ -199,6 +199,12 @@ for i in samples/good-* ; do
 done
 
 
+echo "Compact output keeps siblings under their parent"
+xpass $BOOTCONF -a samples/good-mixed-kv1.bconf $INITRD
+$BOOTCONF $INITRD > $OUTFILE
+xpass cmp samples/exp-good-mixed-kv1.bconf $OUTFILE
+
+
 echo
 echo "=== Summary ==="
 echo "# of Passed: $(expr $NO - $NG - 1)"
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 054/555] ipv6: Remove IPV6_ADDRFORM.
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (52 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 053/555] tools/bootconfig: Close only opened braces in compact output Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 055/555] iio: proximity: sx9360: fix sampling frequency write and available range Greg Kroah-Hartman
                   ` (500 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Daehyeon Ko, Hyunwoo Kim,
	Kuniyuki Iwashima, Jakub Kicinski, Sasha Levin

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

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

From: Kuniyuki Iwashima <kuniyu@google.com>

[ Upstream commit 31c5ea8a3296e1486ac34bccea452bfe8c0bb1f9 ]

Recently, IPV6_ADDRFORM has received many AI-driven bug reports.
Fixing them properly would needlessly churn the fast paths in TCP
and UDP.

IPV6_ADDRFORM was initially introduced in RFC 2133 in 1997,
but only two years later, it was removed from RFC 2553 in 1999.

In 2026, modern applications natively support dual-stack sockets;
notably, systemd's socket activation does not use IPV6_ADDRFORM.

Also, getsockopt(IPV6_ADDRFORM) can be replaced with SO_DOMAIN.

Let's remove IPV6_ADDRFORM.

Later, we can remove sk->sk_prot_creator and revert commit
c26c192c3d48 ("udp: properly deal with xfrm encap and ADDRFORM").

Reported-by: Daehyeon Ko <4ncienth@gmail.com>
Closes: https://lore.kernel.org/netdev/20260902010408.1057857-1-4ncienth@gmail.com/
Reported-by: Hyunwoo Kim <imv4bel@gmail.com>
Closes: https://lore.kernel.org/netdev/20260824033331.1084971-1-imv4bel@gmail.com/
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20260904033543.2635540-3-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[ Hyunwoo Kim: Remove UDP-Lite handling from the IPV6_ADDRFORM
  set/get branches on 6.12.y. ]
Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/linux/net.h      |  2 +-
 net/core/sock.c          |  4 +-
 net/ipv4/af_inet.c       |  3 --
 net/ipv6/af_inet6.c      |  4 --
 net/ipv6/ipv6_sockglue.c | 95 ----------------------------------------
 5 files changed, 2 insertions(+), 106 deletions(-)

diff --git a/include/linux/net.h b/include/linux/net.h
index c6d92428c71a5..6d2241615532b 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -144,7 +144,7 @@ struct socket {
 
 	struct file		*file;
 	struct sock		*sk;
-	const struct proto_ops	*ops; /* Might change with IPV6_ADDRFORM or MPTCP. */
+	const struct proto_ops	*ops; /* Might change with MPTCP. */
 
 	struct socket_wq	wq;
 };
diff --git a/net/core/sock.c b/net/core/sock.c
index c71b175d13206..b77cb9cfcdb29 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -765,7 +765,7 @@ bool sk_mc_loop(const struct sock *sk)
 	sk = sk_const_to_full_sk(sk);
 	if (!sk)
 		return true;
-	/* IPV6_ADDRFORM can change sk->sk_family under us. */
+
 	switch (READ_ONCE(sk->sk_family)) {
 	case AF_INET:
 		return inet_test_bit(MC_LOOP, sk);
@@ -3849,7 +3849,6 @@ int sock_common_getsockopt(struct socket *sock, int level, int optname,
 {
 	struct sock *sk = sock->sk;
 
-	/* IPV6_ADDRFORM can change sk->sk_prot under us. */
 	return READ_ONCE(sk->sk_prot)->getsockopt(sk, level, optname, optval, optlen);
 }
 EXPORT_SYMBOL(sock_common_getsockopt);
@@ -3876,7 +3875,6 @@ int sock_common_setsockopt(struct socket *sock, int level, int optname,
 {
 	struct sock *sk = sock->sk;
 
-	/* IPV6_ADDRFORM can change sk->sk_prot under us. */
 	return READ_ONCE(sk->sk_prot)->setsockopt(sk, level, optname, optval, optlen);
 }
 EXPORT_SYMBOL(sock_common_setsockopt);
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index b67c20019978a..b61d07620c1fd 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -575,7 +575,6 @@ int inet_dgram_connect(struct socket *sock, struct sockaddr *uaddr,
 	if (addr_len < sizeof(uaddr->sa_family))
 		return -EINVAL;
 
-	/* IPV6_ADDRFORM can change sk->sk_prot under us. */
 	prot = READ_ONCE(sk->sk_prot);
 
 	if (uaddr->sa_family == AF_UNSPEC)
@@ -776,7 +775,6 @@ int inet_accept(struct socket *sock, struct socket *newsock,
 {
 	struct sock *sk1 = sock->sk, *sk2;
 
-	/* IPV6_ADDRFORM can change sk->sk_prot under us. */
 	arg->err = -EINVAL;
 	sk2 = READ_ONCE(sk1->sk_prot)->accept(sk1, arg);
 	if (!sk2)
@@ -861,7 +859,6 @@ void inet_splice_eof(struct socket *sock)
 	if (unlikely(inet_send_prepare(sk)))
 		return;
 
-	/* IPV6_ADDRFORM can change sk->sk_prot under us. */
 	prot = READ_ONCE(sk->sk_prot);
 	if (prot->splice_eof)
 		prot->splice_eof(sock);
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 5cbb20e3788c4..3b701dbb4691d 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -444,7 +444,6 @@ int inet6_bind_sk(struct sock *sk, struct sockaddr *uaddr, int addr_len)
 	const struct proto *prot;
 	int err = 0;
 
-	/* IPV6_ADDRFORM can change sk->sk_prot under us. */
 	prot = READ_ONCE(sk->sk_prot);
 	/* If the socket has its own bind function then use it. */
 	if (prot->bind)
@@ -583,7 +582,6 @@ int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
 	case SIOCSIFDSTADDR:
 		return addrconf_set_dstaddr(net, argp);
 	default:
-		/* IPV6_ADDRFORM can change sk->sk_prot under us. */
 		prot = READ_ONCE(sk->sk_prot);
 		if (!prot->ioctl)
 			return -ENOIOCTLCMD;
@@ -654,7 +652,6 @@ int inet6_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
 	if (unlikely(inet_send_prepare(sk)))
 		return -EAGAIN;
 
-	/* IPV6_ADDRFORM can change sk->sk_prot under us. */
 	prot = READ_ONCE(sk->sk_prot);
 	return INDIRECT_CALL_2(prot->sendmsg, tcp_sendmsg, udpv6_sendmsg,
 			       sk, msg, size);
@@ -673,7 +670,6 @@ int inet6_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
 	if (likely(!(flags & MSG_ERRQUEUE)))
 		sock_rps_record_flow(sk);
 
-	/* IPV6_ADDRFORM can change sk->sk_prot under us. */
 	prot = READ_ONCE(sk->sk_prot);
 	err = INDIRECT_CALL_2(prot->recvmsg, tcp_recvmsg, udpv6_recvmsg,
 			      sk, msg, size, flags, &addr_len);
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 0f1242138d176..df5858ffa058f 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -557,93 +557,7 @@ int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
 		rtnl_lock();
 	sockopt_lock_sock(sk);
 
-	/* Another thread has converted the socket into IPv4 with
-	 * IPV6_ADDRFORM concurrently.
-	 */
-	if (unlikely(sk->sk_family != AF_INET6))
-		goto unlock;
-
 	switch (optname) {
-
-	case IPV6_ADDRFORM:
-		if (optlen < sizeof(int))
-			goto e_inval;
-		if (val == PF_INET) {
-			if (sk->sk_type == SOCK_RAW)
-				break;
-
-			if (sk->sk_protocol == IPPROTO_UDP ||
-			    sk->sk_protocol == IPPROTO_UDPLITE) {
-				struct udp_sock *up = udp_sk(sk);
-				if (up->pending == AF_INET6) {
-					retv = -EBUSY;
-					break;
-				}
-			} else if (sk->sk_protocol == IPPROTO_TCP) {
-				if (sk->sk_prot != &tcpv6_prot) {
-					retv = -EBUSY;
-					break;
-				}
-			} else {
-				break;
-			}
-
-			if (sk->sk_state != TCP_ESTABLISHED) {
-				retv = -ENOTCONN;
-				break;
-			}
-
-			if (ipv6_only_sock(sk) ||
-			    !ipv6_addr_v4mapped(&sk->sk_v6_daddr)) {
-				retv = -EADDRNOTAVAIL;
-				break;
-			}
-
-			__ipv6_sock_mc_close(sk);
-			__ipv6_sock_ac_close(sk);
-
-			if (sk->sk_protocol == IPPROTO_TCP) {
-				struct inet_connection_sock *icsk = inet_csk(sk);
-
-				sock_prot_inuse_add(net, sk->sk_prot, -1);
-				sock_prot_inuse_add(net, &tcp_prot, 1);
-
-				/* Paired with READ_ONCE(sk->sk_prot) in inet6_stream_ops */
-				WRITE_ONCE(sk->sk_prot, &tcp_prot);
-				/* Paired with READ_ONCE() in tcp_(get|set)sockopt() */
-				WRITE_ONCE(icsk->icsk_af_ops, &ipv4_specific);
-				WRITE_ONCE(sk->sk_socket->ops, &inet_stream_ops);
-				WRITE_ONCE(sk->sk_family, PF_INET);
-				tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
-			} else {
-				struct proto *prot = &udp_prot;
-
-				if (sk->sk_protocol == IPPROTO_UDPLITE)
-					prot = &udplite_prot;
-
-				sock_prot_inuse_add(net, sk->sk_prot, -1);
-				sock_prot_inuse_add(net, prot, 1);
-
-				/* Paired with READ_ONCE(sk->sk_prot) in inet6_dgram_ops */
-				WRITE_ONCE(sk->sk_prot, prot);
-				WRITE_ONCE(sk->sk_socket->ops, &inet_dgram_ops);
-				WRITE_ONCE(sk->sk_family, PF_INET);
-			}
-
-			/* Disable all options not to allocate memory anymore,
-			 * but there is still a race.  See the lockless path
-			 * in udpv6_sendmsg() and ipv6_local_rxpmtu().
-			 */
-			np->rxopt.all = 0;
-
-			inet6_cleanup_sock(sk);
-
-			module_put(THIS_MODULE);
-			retv = 0;
-			break;
-		}
-		goto e_inval;
-
 	case IPV6_V6ONLY:
 		if (optlen < sizeof(int) ||
 		    inet_sk(sk)->inet_num)
@@ -1107,15 +1021,6 @@ int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
 	if (copy_from_sockptr(&len, optlen, sizeof(int)))
 		return -EFAULT;
 	switch (optname) {
-	case IPV6_ADDRFORM:
-		if (sk->sk_protocol != IPPROTO_UDP &&
-		    sk->sk_protocol != IPPROTO_UDPLITE &&
-		    sk->sk_protocol != IPPROTO_TCP)
-			return -ENOPROTOOPT;
-		if (sk->sk_state != TCP_ESTABLISHED)
-			return -ENOTCONN;
-		val = sk->sk_family;
-		break;
 	case MCAST_MSFILTER:
 		if (in_compat_syscall())
 			return compat_ipv6_get_msfilter(sk, optval, optlen, len);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 055/555] iio: proximity: sx9360: fix sampling frequency write and available range
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (53 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 054/555] ipv6: Remove IPV6_ADDRFORM Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 056/555] KEYS: Expand key->{datalen,quotalen} to unsigned int Greg Kroah-Hartman
                   ` (499 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Arnav Kapoor, Jonathan Cameron,
	Sasha Levin

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

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

From: Arnav Kapoor <kapoorarnav43@gmail.com>

commit d252425c1533bfacd5940faa3371af82196bff5b upstream.

GNRL_CTRL1/2 hold the scan period in units of 8192 / FOSC, but
sx9360_set_samp_freq() computes freq * 8192 / FOSC and mis-scales val2,
which is in micro units. Any integer frequency then programs a period
of 0, and fractional parts above ~0.26 Hz overflow the int, writing
0x10 to GNRL_CTRL1 outside the SCANPERIOD field.

Compute FOSC / (freq * 8192), rounded to the closest value, and reject
frequencies outside the 1..2047 period range.

The available range doesn't match the limits in the comments next to it
either: 4 MHz / 8192 is 488.28125 Hz, not 448.28125 Hz,
4 MHz / (8192 * 2047) is 0.238535 Hz, and (max - min) / 2047 is
0.238419 Hz. Use those values.

Fixes: 1cdb4c47f7f5 ("iio:proximity:sx9360: Add sx9360 support")
Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
[ Context: <linux/acpi.h> and <linux/mod_devicetable.h> are still
included here. ]
Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/iio/proximity/sx9360.c | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/proximity/sx9360.c b/drivers/iio/proximity/sx9360.c
index 2b90bf45a2012..10ab7aa352f95 100644
--- a/drivers/iio/proximity/sx9360.c
+++ b/drivers/iio/proximity/sx9360.c
@@ -15,11 +15,13 @@
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/log2.h>
+#include <linux/math64.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/pm.h>
 #include <linux/property.h>
 #include <linux/regmap.h>
+#include <linux/units.h>
 
 #include <linux/iio/iio.h>
 
@@ -45,6 +47,7 @@
 #define SX9360_REG_GNRL_CTRL1_SCANPERIOD_MASK GENMASK(2, 0)
 #define SX9360_REG_GNRL_CTRL2		0x12
 #define SX9360_REG_GNRL_CTRL2_PERIOD_102MS	0x32
+#define SX9360_REG_GNRL_SCANPERIOD_MAX		GENMASK(10, 0)
 #define SX9360_REG_GNRL_REG_2_PERIOD_MS(_r)	\
 	(((_r) * 8192) / (SX9360_FOSC_HZ / 1000))
 #define SX9360_REG_GNRL_FREQ_2_REG(_f)  (((_f) * 8192) / SX9360_FOSC_HZ)
@@ -184,9 +187,9 @@ static const struct {
 	int val;
 	int val2;
 } sx9360_samp_freq_interval[] = {
-	{ 0, 281250 },  /* 4MHz / (8192 * 2047) */
-	{ 0, 281250 },
-	{ 448, 281250 },  /* 4MHz / 8192 */
+	{ 0, 238535 },  /* 4MHz / (8192 * 2047) */
+	{ 0, 238419 },
+	{ 488, 281250 },  /* 4MHz / 8192 */
 };
 
 static const struct regmap_range sx9360_writable_reg_ranges[] = {
@@ -378,11 +381,25 @@ static int sx9360_read_avail(struct iio_dev *indio_dev,
 static int sx9360_set_samp_freq(struct sx_common_data *data,
 				int val, int val2)
 {
-	int reg;
+	unsigned int period_ticks;
+	u64 freq_uHz;
 	__be16 buf;
 
-	reg = val * 8192 / SX9360_FOSC_HZ + val2 * 8192 / (SX9360_FOSC_MHZ);
-	buf = cpu_to_be16(reg);
+	if (val < 0 || val2 < 0)
+		return -EINVAL;
+
+	freq_uHz = (u64)val * MICROHZ_PER_HZ + val2;
+	if (!freq_uHz)
+		return -EINVAL;
+
+	/* The register holds the scan period in ticks of 8192 FOSC cycles. */
+	period_ticks = DIV64_U64_ROUND_CLOSEST((u64)SX9360_FOSC_HZ * MICROHZ_PER_HZ,
+					       freq_uHz * 8192);
+	if (!period_ticks || period_ticks > SX9360_REG_GNRL_SCANPERIOD_MAX)
+		return -EINVAL;
+
+	buf = cpu_to_be16(period_ticks);
+
 	guard(mutex)(&data->mutex);
 
 	return regmap_bulk_write(data->regmap, SX9360_REG_GNRL_CTRL1, &buf,
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 056/555] KEYS: Expand key->{datalen,quotalen} to unsigned int
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (54 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 055/555] iio: proximity: sx9360: fix sampling frequency write and available range Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 057/555] keys: keyctl_pkey: replace BUG with return -EOPNOTSUPP Greg Kroah-Hartman
                   ` (498 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, David Howells, Eric Biggers,
	Jarkko Sakkinen, Sasha Levin

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

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

From: Jarkko Sakkinen <jarkko@kernel.org>

[ Upstream commit 4a65eaf146f0d10ebaa88cfaef9c3b24f93766d9 ]

In key_alloc() and key_payload_reserve(), key->quotalen and key->datalen
can receive values larger than USHRT_MAX.

Example:

  keyctl new_session >/dev/null
  owner=$(keyctl newring owner @s)
  keeper=$(keyctl newring keeper @s)

  for ((i=0; i<16384; i++)); do
      key=$(keyctl add user "k$i" x "$keeper")
      keyctl link "$key" "$owner"
  done

  awk -v uid="$(id -u):" '$1 == uid {print $NF}' /proc/key-users
  keyctl clear "$owner"
  awk -v uid="$(id -u):" '$1 == uid {print $NF}' /proc/key-users

Because key->datalen wraps around 65535, the quota refunded upon clearing
is truncated, causing quota bytes to leak in /proc/key-users.

Change the types of key->datalen and key->quotalen from unsigned short to
unsigned int so that they can carry the full payload length without
truncation.

Cc: stable@vger.kernel.org
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reviewed-by: David Howells <dhowells@redhat.com>
Reviewed-by: Eric Biggers <ebiggers@kernel.org>
Link: https://lore.kernel.org/r/20261020174325.2229448-2-jarkko@kernel.org
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
[ sashal: Replaced the smb_EIO1/smb_EIO2 trace helper calls with plain rc = -EIO in the cifsacl.c hunks, since those helpers are missing here. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/smb/client/cifsacl.c | 6 +++---
 include/linux/key.h     | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c
index ac2e09eacabc7..eace735190c63 100644
--- a/fs/smb/client/cifsacl.c
+++ b/fs/smb/client/cifsacl.c
@@ -319,7 +319,7 @@ id_to_sid(unsigned int cid, uint sidtype, struct smb_sid *ssid)
 		goto out_revert_creds;
 	} else if (sidkey->datalen < CIFS_SID_BASE_SIZE) {
 		rc = -EIO;
-		cifs_dbg(FYI, "%s: Downcall contained malformed key (datalen=%hu)\n",
+		cifs_dbg(FYI, "%s: Downcall contained malformed key (datalen=%u)\n",
 			 __func__, sidkey->datalen);
 		goto invalidate_key;
 	}
@@ -336,7 +336,7 @@ id_to_sid(unsigned int cid, uint sidtype, struct smb_sid *ssid)
 	ksid_size = CIFS_SID_BASE_SIZE + (ksid->num_subauth * sizeof(__le32));
 	if (ksid_size > sidkey->datalen) {
 		rc = -EIO;
-		cifs_dbg(FYI, "%s: Downcall contained malformed key (datalen=%hu, ksid_size=%u)\n",
+		cifs_dbg(FYI, "%s: Downcall contained malformed key (datalen=%u, ksid_size=%u)\n",
 			 __func__, sidkey->datalen, ksid_size);
 		goto invalidate_key;
 	}
@@ -431,7 +431,7 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct smb_sid *psid,
 	 */
 	BUILD_BUG_ON(sizeof(uid_t) != sizeof(gid_t));
 	if (sidkey->datalen != sizeof(uid_t)) {
-		cifs_dbg(FYI, "%s: Downcall contained malformed key (datalen=%hu)\n",
+		cifs_dbg(FYI, "%s: Downcall contained malformed key (datalen=%u)\n",
 			 __func__, sidkey->datalen);
 		key_invalidate(sidkey);
 		goto out_key_put;
diff --git a/include/linux/key.h b/include/linux/key.h
index 9b4d3e7e71025..eebc3fe9c5b9b 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -219,8 +219,8 @@ struct key {
 	kuid_t			uid;
 	kgid_t			gid;
 	key_perm_t		perm;		/* access permissions */
-	unsigned short		quotalen;	/* length added to quota */
-	unsigned short		datalen;	/* payload data length
+	unsigned int		quotalen;	/* length added to quota */
+	unsigned int		datalen;	/* payload data length
 						 * - may not match RCU dereferenced payload
 						 * - payload should contain own length
 						 */
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 057/555] keys: keyctl_pkey: replace BUG with return -EOPNOTSUPP
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (55 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 056/555] KEYS: Expand key->{datalen,quotalen} to unsigned int Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 058/555] KEYS: Protect pkey method checks against type removal Greg Kroah-Hartman
                   ` (497 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Mohammed EL Kadiri, Jarkko Sakkinen,
	Sasha Levin

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

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

From: Mohammed EL Kadiri <med08elkadiri@gmail.com>

[ Upstream commit 1b9524250996b1f2f49833a1b2ae21c34e486f85 ]

Replace two BUG() calls in keyctl_pkey_params_get_2() and
keyctl_pkey_e_d_s() default cases with -EOPNOTSUPP, matching
the error style already used in these functions.

Signed-off-by: Mohammed EL Kadiri <med08elkadiri@gmail.com>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Stable-dep-of: bab48a104447 ("KEYS: Protect pkey method checks against type removal")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 security/keys/keyctl_pkey.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/security/keys/keyctl_pkey.c b/security/keys/keyctl_pkey.c
index ba150ee2d4a37..15b6bf6399b59 100644
--- a/security/keys/keyctl_pkey.c
+++ b/security/keys/keyctl_pkey.c
@@ -163,7 +163,7 @@ static int keyctl_pkey_params_get_2(const struct keyctl_pkey_params __user *_par
 		params->out_len = info.max_sig_size;
 		break;
 	default:
-		BUG();
+		return -EOPNOTSUPP;
 	}
 
 	params->in_len  = uparams.in_len;
@@ -245,7 +245,8 @@ long keyctl_pkey_e_d_s(int op,
 		params.op = kernel_pkey_sign;
 		break;
 	default:
-		BUG();
+		ret = -EOPNOTSUPP;
+		goto error_params;
 	}
 
 	in = memdup_user(_in, params.in_len);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 058/555] KEYS: Protect pkey method checks against type removal
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (56 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 057/555] keys: keyctl_pkey: replace BUG with return -EOPNOTSUPP Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 059/555] tcp: move __reqsk_free() out of line Greg Kroah-Hartman
                   ` (496 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Yuansheng Yang, Jarkko Sakkinen,
	Sasha Levin

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

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

From: Yuansheng Yang <0xbeac@gmail.com>

[ Upstream commit bab48a1044475f62d6e910c6d7267ce4bae847f9 ]

keyctl_pkey_query(), keyctl_pkey_e_d_s() and keyctl_pkey_verify() check
that key->type has the ->asym_*() method they need and call it later,
without holding key->sem.  A reference keeps the key alive, but does not
pin the module that provides its type.

When that module is unloaded, unregister_key_type() waits for the key GC
to process every remaining key of the type.  For each such key, the GC
takes key->sem for writing, switches key->type to key_type_dead, whose
->asym_*() methods are NULL, and destroys the payload.  If that happens
between the check and the call, the keyctl calls a NULL method; if it
happens while the method runs, the method returns into freed module text.
In-tree, turris-signing-key provides ->asym_query() and ->asym_eds_op()
and can be built as a module.

Take key->sem for reading around each method call, and check the method
again under it, right before the call.  While the lock is held the GC
cannot switch the key to key_type_dead, so unregister_key_type() and the
module unload cannot complete until the method returns.  If the type is
already gone, the check finds key_type_dead and the keyctl fails with
-EOPNOTSUPP, as it does for any key type without the method.

memdup_user() and copy_to_user() stay outside key->sem, as in
keyctl_read_key(), so no page fault is taken with key->sem held.  The
in-tree ->asym_*() methods do not take key->sem themselves.  Nothing else
in the kernel calls these methods, so these four call sites are the full
coverage:

 - keyctl_pkey_query(): ->asym_query() for KEYCTL_PKEY_QUERY
 - keyctl_pkey_params_get_2(): ->asym_query(), and the op-specific check
   for KEYCTL_PKEY_ENCRYPT, _DECRYPT, _SIGN and _VERIFY
 - keyctl_pkey_e_d_s(): ->asym_eds_op() for _ENCRYPT, _DECRYPT and _SIGN
 - keyctl_pkey_verify(): ->asym_verify_signature() for _VERIFY

This problem was recently fixed for keyctl_read_key() by 925c84e3cc21
("keys: Protect the read method check against type removal") and for
key_update() by aef3a8a4f988 ("KEYS: Protect the update method check
against type removal").

Fixes: 00d60fd3b932 ("KEYS: Provide keyctls to drive the new key type ops for asymmetric keys [ver #2]")
Cc: stable@vger.kernel.org
Signed-off-by: Yuansheng Yang <0xbeac@gmail.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Link: https://lore.kernel.org/r/20261110030252.9979-1-0xbeac@gmail.com
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 security/keys/keyctl_pkey.c | 100 +++++++++++++++++++++++++++---------
 1 file changed, 76 insertions(+), 24 deletions(-)

diff --git a/security/keys/keyctl_pkey.c b/security/keys/keyctl_pkey.c
index 15b6bf6399b59..e7121523b9c9a 100644
--- a/security/keys/keyctl_pkey.c
+++ b/security/keys/keyctl_pkey.c
@@ -129,45 +129,77 @@ static int keyctl_pkey_params_get_2(const struct keyctl_pkey_params __user *_par
 	if (ret < 0)
 		return ret;
 
+	down_read(&params->key->sem);
+
+	if (!params->key->type->asym_query) {
+		ret = -EOPNOTSUPP;
+		goto out_up_key_sem;
+	}
+
 	ret = params->key->type->asym_query(params, &info);
 	if (ret < 0)
-		return ret;
+		goto out_up_key_sem;
 
 	switch (op) {
 	case KEYCTL_PKEY_ENCRYPT:
 		if (uparams.in_len  > info.max_dec_size ||
-		    uparams.out_len > info.max_enc_size)
-			return -EINVAL;
+		    uparams.out_len > info.max_enc_size) {
+			ret = -EINVAL;
+			goto out_up_key_sem;
+		}
 
 		params->out_len = info.max_enc_size;
 		break;
 	case KEYCTL_PKEY_DECRYPT:
 		if (uparams.in_len  > info.max_enc_size ||
-		    uparams.out_len > info.max_dec_size)
-			return -EINVAL;
+		    uparams.out_len > info.max_dec_size) {
+			ret = -EINVAL;
+			goto out_up_key_sem;
+		}
 
 		params->out_len = info.max_dec_size;
 		break;
 	case KEYCTL_PKEY_SIGN:
 		if (uparams.in_len  > info.max_data_size ||
-		    uparams.out_len > info.max_sig_size)
-			return -EINVAL;
+		    uparams.out_len > info.max_sig_size) {
+			ret = -EINVAL;
+			goto out_up_key_sem;
+		}
 
 		params->out_len = info.max_sig_size;
 		break;
 	case KEYCTL_PKEY_VERIFY:
 		if (uparams.in_len  > info.max_data_size ||
-		    uparams.in2_len > info.max_sig_size)
-			return -EINVAL;
+		    uparams.in2_len > info.max_sig_size) {
+			ret = -EINVAL;
+			goto out_up_key_sem;
+		}
 
 		params->out_len = info.max_sig_size;
 		break;
 	default:
-		return -EOPNOTSUPP;
+		ret = -EOPNOTSUPP;
+		goto out_up_key_sem;
 	}
 
 	params->in_len  = uparams.in_len;
-	return 0;
+
+	switch (op) {
+	case KEYCTL_PKEY_VERIFY:
+		if (!params->key->type->asym_verify_signature)
+			ret = -EOPNOTSUPP;
+		break;
+	case KEYCTL_PKEY_ENCRYPT:
+	case KEYCTL_PKEY_DECRYPT:
+	case KEYCTL_PKEY_SIGN:
+		if (!params->key->type->asym_eds_op)
+			ret = -EOPNOTSUPP;
+		break;
+	}
+
+out_up_key_sem:
+	up_read(&params->key->sem);
+	return ret;
 }
 
 /*
@@ -185,7 +217,16 @@ long keyctl_pkey_query(key_serial_t id,
 	if (ret < 0)
 		goto error;
 
+	down_read(&params.key->sem);
+	if (!params.key->type->asym_query) {
+		ret = -EOPNOTSUPP;
+		goto out_up_key_sem;
+	}
+
 	ret = params.key->type->asym_query(&params, &res);
+
+out_up_key_sem:
+	up_read(&params.key->sem);
 	if (ret < 0)
 		goto error;
 
@@ -230,10 +271,6 @@ long keyctl_pkey_e_d_s(int op,
 	if (ret < 0)
 		goto error_params;
 
-	ret = -EOPNOTSUPP;
-	if (!params.key->type->asym_eds_op)
-		goto error_params;
-
 	switch (op) {
 	case KEYCTL_PKEY_ENCRYPT:
 		params.op = kernel_pkey_encrypt;
@@ -260,7 +297,16 @@ long keyctl_pkey_e_d_s(int op,
 	if (!out)
 		goto error_in;
 
+	down_read(&params.key->sem);
+	if (!params.key->type->asym_eds_op) {
+		ret = -EOPNOTSUPP;
+		goto out_up_key_sem;
+	}
+
 	ret = params.key->type->asym_eds_op(&params, in, out);
+
+out_up_key_sem:
+	up_read(&params.key->sem);
 	if (ret < 0)
 		goto error_out;
 
@@ -305,31 +351,37 @@ long keyctl_pkey_verify(const struct keyctl_pkey_params __user *_params,
 	ret = keyctl_pkey_params_get_2(_params, _info, KEYCTL_PKEY_VERIFY,
 				       &params);
 	if (ret < 0)
-		goto error_params;
-
-	ret = -EOPNOTSUPP;
-	if (!params.key->type->asym_verify_signature)
-		goto error_params;
+		goto out_free_params;
 
 	in = memdup_user(_in, params.in_len);
 	if (IS_ERR(in)) {
 		ret = PTR_ERR(in);
-		goto error_params;
+		goto out_free_params;
 	}
 
 	in2 = memdup_user(_in2, params.in2_len);
 	if (IS_ERR(in2)) {
 		ret = PTR_ERR(in2);
-		goto error_in;
+		goto out_free_in;
 	}
 
 	params.op = kernel_pkey_verify;
+	down_read(&params.key->sem);
+	if (!params.key->type->asym_verify_signature) {
+		ret = -EOPNOTSUPP;
+		goto out_up_key_sem;
+	}
+
 	ret = params.key->type->asym_verify_signature(&params, in, in2);
 
+out_up_key_sem:
+	up_read(&params.key->sem);
 	kfree(in2);
-error_in:
+
+out_free_in:
 	kfree(in);
-error_params:
+
+out_free_params:
 	keyctl_pkey_params_free(&params);
 	return ret;
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 059/555] tcp: move __reqsk_free() out of line
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (57 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 058/555] KEYS: Protect pkey method checks against type removal Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 060/555] tcp: free saved_syn after an RCU grace period Greg Kroah-Hartman
                   ` (495 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Eric Dumazet, Kuniyuki Iwashima,
	Jakub Kicinski, Sasha Levin

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

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

From: Eric Dumazet <edumazet@google.com>

[ Upstream commit 22c1264415ef0d4564dd74e3de66e1895d3f7bc0 ]

Inlining __reqsk_free() is overkill, let's reclaim 2 Kbytes of text.

$ scripts/bloat-o-meter -t vmlinux.old vmlinux.new
add/remove: 2/4 grow/shrink: 2/14 up/down: 225/-2338 (-2113)
Function                                     old     new   delta
__reqsk_free                                   -     114    +114
sock_edemux                                   18      82     +64
inet_csk_listen_start                        233     264     +31
__pfx___reqsk_free                             -      16     +16
__pfx_reqsk_queue_alloc                       16       -     -16
__pfx_reqsk_free                              16       -     -16
reqsk_queue_alloc                             46       -     -46
tcp_req_err                                  272     177     -95
reqsk_fastopen_remove                        348     253     -95
cookie_bpf_check                             157      62     -95
cookie_tcp_reqsk_alloc                       387     290     -97
cookie_v4_check                             1568    1465    -103
reqsk_free                                   105       -    -105
cookie_v6_check                             1519    1412    -107
sock_gen_put                                 187      78    -109
sock_pfree                                   212      82    -130
tcp_try_fastopen                            1818    1683    -135
tcp_v4_rcv                                  3478    3294    -184
reqsk_put                                    306      90    -216
tcp_get_cookie_sock                          551     318    -233
tcp_v6_rcv                                  3404    3141    -263
tcp_conn_request                            2677    2384    -293
Total: Before=24887415, After=24885302, chg -0.01%

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20260204055147.1682705-5-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Stable-dep-of: 2b9fd1a0abf0 ("tcp: free saved_syn after an RCU grace period")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/net/request_sock.h      |  9 +--------
 net/ipv4/inet_connection_sock.c | 10 ++++++++++
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/include/net/request_sock.h b/include/net/request_sock.h
index b07b1cd14e9f4..49e69b681ad10 100644
--- a/include/net/request_sock.h
+++ b/include/net/request_sock.h
@@ -128,14 +128,7 @@ static inline struct sock *skb_steal_sock(struct sk_buff *skb,
 	return sk;
 }
 
-static inline void __reqsk_free(struct request_sock *req)
-{
-	req->rsk_ops->destructor(req);
-	if (req->rsk_listener)
-		sock_put(req->rsk_listener);
-	kfree(req->saved_syn);
-	kmem_cache_free(req->rsk_ops->slab, req);
-}
+void __reqsk_free(struct request_sock *req);
 
 static inline void reqsk_free(struct request_sock *req)
 {
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 7439996bdc0c2..71105b155f1d9 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -957,6 +957,16 @@ struct request_sock *inet_reqsk_alloc(const struct request_sock_ops *ops,
 }
 EXPORT_SYMBOL(inet_reqsk_alloc);
 
+void __reqsk_free(struct request_sock *req)
+{
+	req->rsk_ops->destructor(req);
+	if (req->rsk_listener)
+		sock_put(req->rsk_listener);
+	kfree(req->saved_syn);
+	kmem_cache_free(req->rsk_ops->slab, req);
+}
+EXPORT_SYMBOL_GPL(__reqsk_free);
+
 static struct request_sock *inet_reqsk_clone(struct request_sock *req,
 					     struct sock *sk)
 {
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 060/555] tcp: free saved_syn after an RCU grace period
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (58 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 059/555] tcp: move __reqsk_free() out of line Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 061/555] cgroup/cpuset: Correctly set isolated_cpus when switching partition state Greg Kroah-Hartman
                   ` (494 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Yingjie Wang, Kuniyuki Iwashima,
	Eric Dumazet, Jakub Kicinski, Sasha Levin

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

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

From: Yingjie Wang <x-professor@outlook.com>

[ Upstream commit 2b9fd1a0abf0c1c7200be7a33cfeeca1c68089b6 ]

tcp_reqsk_record_syn() allocates saved_syn separately from its request
socket. bpf_sock_ops_get_syn() can load that pointer while processing a
retransmitted SYN under RCU.

There are two ownership transfers which can let another CPU reclaim the
allocation while such a reader is still using it.

First, tcp_move_syn() transfers req->saved_syn to a newly created child
socket. The child can be closed and tcp_saved_syn_free() can reclaim the
allocation before a reader of the old request finishes.

Second, inet_reqsk_clone() shallow-copies request_sock during request
migration. After reqsk_migrate_reset() clears the old request pointer, the
migrated clone owns it. However, a reader which already loaded the pointer
from the old request can still be using it when the clone is released.

I found this through LLM-assisted concurrency fuzzing.

Mark the request-socket saved_syn pointer as RCU protected and use RCU
accessors for its reads and updates. Keep the full-socket pointer plain
because all of its accesses hold the socket lock. Embed an rcu_head in
struct saved_syn and use kfree_rcu() in both teardown paths. This lets a
request-side reader which loaded the object before an ownership transfer
finish.

This follows commit e3f33b0a1d89 ("ipv4: free inet_opt and ireq_opt
after an RCU grace period"), which fixed the same ownership-transfer
pattern for IPv4 options.

The issue was confirmed with KASAN on v7.3-16007-g36aad21d50d1 using
temporary kernel instrumentation to widen the reader and request-migration
window. KASAN reported a slab-use-after-free read in
bpf_sock_ops_get_syn(), with the allocation freed by __reqsk_free() from
reqsk_timer_handler(). The same explicit migration test completed without
a report with deferred reclamation. A patched kernel without the delay
instrumentation also completed a successful migration and seven saved-SYN
reads without a KASAN report.

Fixes: 0813a841566f ("bpf: tcp: Allow bpf prog to write and parse TCP header option")
Fixes: c905dee62232 ("tcp: Migrate TCP_NEW_SYN_RECV requests at retransmitting SYN+ACKs.")
Cc: stable@vger.kernel.org
Signed-off-by: Yingjie Wang <x-professor@outlook.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Link: https://patch.msgid.link/38fa9f2cc476502e9b1c1fef09ebba1df5dd5901.1793795528.git.x-professor@outlook.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/linux/tcp.h             | 6 +++---
 include/net/request_sock.h      | 3 ++-
 net/core/filter.c               | 2 +-
 net/ipv4/inet_connection_sock.c | 6 +++---
 net/ipv4/tcp_input.c            | 2 +-
 5 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index ea54a107f307c..7272cb37b5be9 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -579,13 +579,13 @@ static inline void fastopen_queue_tune(struct sock *sk, int backlog)
 static inline void tcp_move_syn(struct tcp_sock *tp,
 				struct request_sock *req)
 {
-	tp->saved_syn = req->saved_syn;
-	req->saved_syn = NULL;
+	tp->saved_syn = unrcu_pointer(req->saved_syn);
+	RCU_INIT_POINTER(req->saved_syn, NULL);
 }
 
 static inline void tcp_saved_syn_free(struct tcp_sock *tp)
 {
-	kfree(tp->saved_syn);
+	kfree_rcu(tp->saved_syn, rcu);
 	tp->saved_syn = NULL;
 }
 
diff --git a/include/net/request_sock.h b/include/net/request_sock.h
index 49e69b681ad10..ccdbce49f8897 100644
--- a/include/net/request_sock.h
+++ b/include/net/request_sock.h
@@ -44,6 +44,7 @@ struct request_sock_ops {
 int inet_rtx_syn_ack(const struct sock *parent, struct request_sock *req);
 
 struct saved_syn {
+	struct rcu_head rcu;
 	u32 mac_hdrlen;
 	u32 network_hdrlen;
 	u32 tcp_hdrlen;
@@ -73,7 +74,7 @@ struct request_sock {
 	struct timer_list		rsk_timer;
 	const struct request_sock_ops	*rsk_ops;
 	struct sock			*sk;
-	struct saved_syn		*saved_syn;
+	struct saved_syn __rcu		*saved_syn;
 	u32				secid;
 	u32				peer_secid;
 	u32				timeout;
diff --git a/net/core/filter.c b/net/core/filter.c
index 3b8ea2ba5c312..22ea8540f3114 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -5868,7 +5868,7 @@ static int bpf_sock_ops_get_syn(struct bpf_sock_ops_kern *bpf_sock,
 			 * not be available.  It has to resort to
 			 * saved_syn (if it is saved).
 			 */
-			saved_syn = inet_reqsk(sk)->saved_syn;
+			saved_syn = rcu_dereference(inet_reqsk(sk)->saved_syn);
 		else
 			saved_syn = tcp_sk(sk)->saved_syn;
 
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 71105b155f1d9..616df49bbde0d 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -920,7 +920,7 @@ reqsk_alloc_noprof(const struct request_sock_ops *ops, struct sock *sk_listener,
 	req_to_sk(req)->sk_prot = sk_listener->sk_prot;
 	sk_node_init(&req_to_sk(req)->sk_node);
 	sk_tx_queue_clear(req_to_sk(req));
-	req->saved_syn = NULL;
+	RCU_INIT_POINTER(req->saved_syn, NULL);
 	req->syncookie = 0;
 	req->timeout = 0;
 	req->num_timeout = 0;
@@ -962,7 +962,7 @@ void __reqsk_free(struct request_sock *req)
 	req->rsk_ops->destructor(req);
 	if (req->rsk_listener)
 		sock_put(req->rsk_listener);
-	kfree(req->saved_syn);
+	kfree_rcu(unrcu_pointer(req->saved_syn), rcu);
 	kmem_cache_free(req->rsk_ops->slab, req);
 }
 EXPORT_SYMBOL_GPL(__reqsk_free);
@@ -1034,7 +1034,7 @@ static void reqsk_queue_migrated(struct request_sock_queue *queue,
 
 static void reqsk_migrate_reset(struct request_sock *req)
 {
-	req->saved_syn = NULL;
+	RCU_INIT_POINTER(req->saved_syn, NULL);
 #if IS_ENABLED(CONFIG_IPV6)
 	inet_rsk(req)->ipv6_opt = NULL;
 	inet_rsk(req)->pktopts = NULL;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 7784ef49037ba..1674d10a0c6a7 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -7219,7 +7219,7 @@ static void tcp_reqsk_record_syn(const struct sock *sk,
 			saved_syn->network_hdrlen = skb_network_header_len(skb);
 			saved_syn->tcp_hdrlen = tcp_hdrlen(skb);
 			memcpy(saved_syn->data, base, len);
-			req->saved_syn = saved_syn;
+			RCU_INIT_POINTER(req->saved_syn, saved_syn);
 		}
 	}
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 061/555] cgroup/cpuset: Correctly set isolated_cpus when switching partition state
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (59 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 060/555] tcp: free saved_syn after an RCU grace period Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 062/555] arm64: suspend: rely on daif helpers to handle PMR Greg Kroah-Hartman
                   ` (493 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Waiman Long, Ridong Chen, Tejun Heo,
	Sasha Levin

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

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

From: Waiman Long <longman@redhat.com>

[ Upstream commit 56681bc448a80bb2473026b41c44c133766bc38d ]

When update_prstate() is called to switch the partition state from
root to isolated or vice versa, the whole effective_xcpus is passed to
isolated_cpus_update(). However, if there are child partitions present,
some of the effective_xcpus are dedicated to those child partitions
and their partition states will remain the same or get invalidated in
the case of child root partition with isolated parent in the latter
update_cpumasks_hier() call. In the latter case, their exclusive CPUs
will be returned to their parent.

Therefore isolated_cpus may be set incorrectly with child partitions
underneath. Fix that by excluding their exclusive CPUs in computing
the correct cpumask of exclusive CPUs used by that partition alone.

Add new test cases into test_cpuset_prs.sh to test for such cases.

Fixes: 11e5f407b64a ("cgroup/cpuset: Keep track of CPUs in isolated partitions")
Cc: stable@vger.kernel.org # v6.8+
Signed-off-by: Waiman Long <longman@redhat.com>
Reviewed-by: Ridong Chen <ridong.chen@linux.dev>
Tested-by: Ridong Chen <ridong.chen@linux.dev>
Signed-off-by: Tejun Heo <tj@kernel.org>
[ sashal: Adapted to the older helper names and control flow, with no housekeeping error path; test rows use :S+ for nested partitions, and the comment says child CPUs stay dedicated. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/cgroup/cpuset.c                        | 19 ++++++++++++++++++-
 .../selftests/cgroup/test_cpuset_prs.sh       |  7 +++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 7e7ef1469a4d3..a8024feac0bd6 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -2950,7 +2950,24 @@ static int update_prstate(struct cpuset *cs, int new_prs)
 		/*
 		 * A change in load balance state only, no change in cpumasks.
 		 */
+		struct cgroup_subsys_state *css;
+		struct cpuset *child;
+
+		/*
+		 * Need to scan child partitions, if present, and exclude
+		 * their effective_xcpus from cs, as those CPUs remain
+		 * dedicated to the child partitions.
+		 */
 		new_xcpus_state = true;
+		cpumask_copy(tmpmask.new_cpus, cs->effective_xcpus);
+		rcu_read_lock();
+		cpuset_for_each_child(child, css, cs) {
+			if (!is_partition_valid(child))
+				continue;
+			cpumask_andnot(tmpmask.new_cpus, tmpmask.new_cpus,
+				       child->effective_xcpus);
+		}
+		rcu_read_unlock();
 	} else {
 		/*
 		 * Switching back to member is always allowed even if it
@@ -2983,7 +3000,7 @@ static int update_prstate(struct cpuset *cs, int new_prs)
 	if (!is_partition_valid(cs))
 		reset_partition_data(cs);
 	else if (new_xcpus_state)
-		partition_xcpus_newstate(old_prs, new_prs, cs->effective_xcpus);
+		partition_xcpus_newstate(old_prs, new_prs, tmpmask.new_cpus);
 	spin_unlock_irq(&callback_lock);
 	update_unbound_workqueue_cpumask(new_xcpus_state);
 
diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
index f52678bb2efee..c49228c603d96 100755
--- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh
+++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
@@ -406,6 +406,13 @@ TEST_MATRIX=(
 	# affect cpuset.cpus.exclusive.effective.
 	" C1-4:X3:S+ C1:X3  .      .       .     C      .      .     0 A2:1-4|XA2:3"
 
+	# Switch PRS state (root <=> isolated) will properly update cpuset.cpus.isolated
+	# even if child partitions are present.
+	" C1-6:P1:S+ C3-6:P1:S+ C5-6:P2 .  .    P2      .      .     0 A1:1-2|A2:3-4|A3:5-6 \
+								       A1:P1|A2:P2|A3:P2 3-6"
+	" C1-6:P1:S+ C3-6:P2:S+ C5-6:P2 .  .    P1      .      .     0 A1:1-2|A2:3-4|A3:5-6 \
+								       A1:P1|A2:P1|A3:P2 5-6"
+
 	#  old-A1 old-A2 old-A3 old-B1 new-A1 new-A2 new-A3 new-B1 fail ECPUs Pstate ISOLCPUS
 	#  ------ ------ ------ ------ ------ ------ ------ ------ ---- ----- ------ --------
 	# Failure cases:
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 062/555] arm64: suspend: rely on daif helpers to handle PMR
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (60 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 061/555] cgroup/cpuset: Correctly set isolated_cpus when switching partition state Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 063/555] arm64: suspend: Only track cpuidle context for idle tasks Greg Kroah-Hartman
                   ` (492 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Ada Couprie Diaz, Vladimir Murzin,
	Jinjie Ruan, Will Deacon, Sasha Levin

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

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

From: Ada Couprie Diaz <ada.coupriediaz@arm.com>

[ Upstream commit 630ca6c58fcfeaddd96dd46e7b11826013977955 ]

Commit 77345ef70445 ("arm64: suspend: Use cpuidle context helpers
in cpu_suspend()") added cpuidle helpers to handle PMR manipulation
and restoration to ensure that the CPU receives interrupts when suspended
and pseudo-NMIs are enabled.

However, those helpers are called in between a pair of `local_daif_save()`
and `local_daif_restore()`, which already configure the PMR as expected.
Effectively, `arm_cpuidle_save_irq_context()` is a no-op here,
even when using pseudo-NMIs, and `arm_cpuidle_restore_irq_context()`
would not restore proper interrupt masking configuration early enough
if there were unexpected changes during suspend or resume.
(This can be observed with Trusted Firmware A (TF-A) at EL3 handling
suspend through PSCI. Even though it should not be the case, TF-A can
reset `ICC_PMR_EL1` during CPU_SUSPEND, thus resuming the kernel
with an inconsistent priority mask value on hardware implementing
more than the minimum number of priority levels, such as Morello.)

Thus : remove the cpuidle context helpers as they do not do anything,
but keep the comment mentioning the need for interrupts to reach the CPU
if we are using pseudo-NMIs.

Signed-off-by: Ada Couprie Diaz <ada.coupriediaz@arm.com>
Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
Reviewed-by: Jinjie Ruan <ruanjinjie@huawei.com>
Signed-off-by: Will Deacon <will@kernel.org>
Stable-dep-of: ad3fc05c7e65 ("arm64: suspend: Only track cpuidle context for idle tasks")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/arm64/kernel/suspend.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/arch/arm64/kernel/suspend.c b/arch/arm64/kernel/suspend.c
index eaaff94329cdd..c41724a40b756 100644
--- a/arch/arm64/kernel/suspend.c
+++ b/arch/arm64/kernel/suspend.c
@@ -99,7 +99,6 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
 	int ret = 0;
 	unsigned long flags;
 	struct sleep_stack_data state;
-	struct arm_cpuidle_irq_context context;
 
 	/*
 	 * Some portions of CPU state (e.g. PSTATE.{PAN,DIT}) are initialized
@@ -121,6 +120,9 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
 	 * Strictly speaking the trace_hardirqs_off() here is superfluous,
 	 * hardirqs should be firmly off by now. This really ought to use
 	 * something like raw_local_daif_save().
+	 *
+	 * This also unmasks interrupts in PMR in order to reliably
+	 * resume if we're using pseudo-NMIs.
 	 */
 	flags = local_daif_save();
 
@@ -131,12 +133,6 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
 	 */
 	pause_graph_tracing();
 
-	/*
-	 * Switch to using DAIF.IF instead of PMR in order to reliably
-	 * resume if we're using pseudo-NMIs.
-	 */
-	arm_cpuidle_save_irq_context(&context);
-
 	ct_cpuidle_enter();
 
 	if (__cpu_suspend_enter(&state)) {
@@ -159,8 +155,6 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
 		__cpu_suspend_exit();
 	}
 
-	arm_cpuidle_restore_irq_context(&context);
-
 	unpause_graph_tracing();
 
 	/*
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 063/555] arm64: suspend: Only track cpuidle context for idle tasks
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (61 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 062/555] arm64: suspend: rely on daif helpers to handle PMR Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 064/555] pNFS: avoid repeatedly cancelling I/O for the same lseg Greg Kroah-Hartman
                   ` (491 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, syzbot+79883955da3a62652a80,
	Uladzislau Zhauniarovich, Catalin Marinas, Sasha Levin

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

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

From: Uladzislau Zhauniarovich <uladzislau.zhauniarovich@gmail.com>

[ Upstream commit ad3fc05c7e65009355effeea06aa629a687acef2 ]

Commit 19235e472798 ("cpuidle, arm64: Fix the ARM64 cpuidle logic") moved
the calls to ct_cpuidle_enter() and ct_cpuidle_exit() into cpu_suspend() so
that arm64 cpuidle could keep RCU watching longer and manage context
tracking internally. However, cpu_suspend() is called not only by cpuidle
via psci_cpu_suspend_enter() (which runs in the context of the idle task),
but also during system suspend via psci_system_suspend_enter() (which runs
in the context of the task initiating suspend, such as a process writing to
/sys/power/state).

When entering system suspend, current is a non-idle task. Calling
ct_cpuidle_enter() invokes ct_kernel_exit() from kernel space (!user) on a
non-idle task. With CONFIG_RCU_EQS_DEBUG enabled, this violates context
tracking invariants and triggers a warning:

WARNING: kernel/context_tracking.c:120 at ct_kernel_exit+0x1b4/0x1f4
kernel/context_tracking.c:118
Call trace:
 ct_kernel_exit+0x1b4/0x1f4 kernel/context_tracking.c:118
 ct_idle_enter+0x20/0x34 kernel/context_tracking.c:299
 ct_cpuidle_enter include/linux/cpuidle.h:134 [inline]
 cpu_suspend+0x264/0x474 arch/arm64/kernel/suspend.c:136
 psci_system_suspend_enter+0x4c/0x80 drivers/firmware/psci/psci.c:544
 suspend_enter kernel/power/suspend.c:468 [inline]
 suspend_devices_and_enter+0x88c/0xd0c kernel/power/suspend.c:533
 enter_state kernel/power/suspend.c:618 [inline]
 pm_suspend+0x498/0x698 kernel/power/suspend.c:644
 state_store+0x14c/0x1fc kernel/power/main.c:819
 kobj_attr_store+0x6c/0x90 lib/kobject.c:842
 sysfs_kf_write+0xe0/0x108 fs/sysfs/file.c:145
 kernfs_fop_write_iter+0x260/0x3b8 fs/kernfs/file.c:345
 vfs_write+0x51c/0xa0c fs/read_write.c:687
 ksys_write+0x12c/0x228 fs/read_write.c:739

A corresponding warning is subsequently triggered in ct_kernel_enter() via
ct_cpuidle_exit() upon resume.

Fix this by checking is_idle_task(current) in cpu_suspend() and only
invoking ct_cpuidle_enter() and ct_cpuidle_exit() when executing in the
context of an idle task.

Fixes: 19235e472798 ("cpuidle, arm64: Fix the ARM64 cpuidle logic")
Cc: <stable@vger.kernel.org>
Assisted-by: Gemini:gemini-3.8-flash Gemini:gemini-3.1-pro-preview syzbot
Reported-by: syzbot+79883955da3a62652a80@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=79883955da3a62652a80
Link: https://syzkaller.appspot.com/ai_job?id=5359e16f-013b-4850-9cbc-ddfb3bac95e5
Signed-off-by: Uladzislau Zhauniarovich <uladzislau.zhauniarovich@gmail.com>
Tested-by: Uladzislau Zhauniarovich <uladzislau.zhauniarovich@gmail.com>
Link: https://lore.kernel.org/r/3e92ccb0-2952-4317-af4c-45457c15efae@gmail.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/arm64/kernel/suspend.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/kernel/suspend.c b/arch/arm64/kernel/suspend.c
index c41724a40b756..cde0b8c19377e 100644
--- a/arch/arm64/kernel/suspend.c
+++ b/arch/arm64/kernel/suspend.c
@@ -5,6 +5,7 @@
 #include <linux/uaccess.h>
 #include <linux/pgtable.h>
 #include <linux/cpuidle.h>
+#include <linux/sched.h>
 #include <asm/alternative.h>
 #include <asm/cacheflush.h>
 #include <asm/cpufeature.h>
@@ -99,6 +100,7 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
 	int ret = 0;
 	unsigned long flags;
 	struct sleep_stack_data state;
+	bool idle = is_idle_task(current);
 
 	/*
 	 * Some portions of CPU state (e.g. PSTATE.{PAN,DIT}) are initialized
@@ -133,7 +135,8 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
 	 */
 	pause_graph_tracing();
 
-	ct_cpuidle_enter();
+	if (idle)
+		ct_cpuidle_enter();
 
 	if (__cpu_suspend_enter(&state)) {
 		/* Call the suspend finisher */
@@ -149,9 +152,11 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
 		if (!ret)
 			ret = -EOPNOTSUPP;
 
-		ct_cpuidle_exit();
+		if (idle)
+			ct_cpuidle_exit();
 	} else {
-		ct_cpuidle_exit();
+		if (idle)
+			ct_cpuidle_exit();
 		__cpu_suspend_exit();
 	}
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 064/555] pNFS: avoid repeatedly cancelling I/O for the same lseg
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (62 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 063/555] arm64: suspend: Only track cpuidle context for idle tasks Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 065/555] watchdog: rz: Discard pm_runtime_put() return values Greg Kroah-Hartman
                   ` (490 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Tim Menninger, Anna Schumaker,
	Sasha Levin

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

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

From: Tim Menninger <tmenninger@everpuredata.com>

[ Upstream commit 9e28836b480c66cca4c3d391177f5b3a50927f7d ]

Commit b739a5bd9d9f ("NFSv4/flexfiles: Cancel I/O if the layout is
recalled or revoked") added I/O cancellation when a layout segment is
invalidated while outstanding references remain.

The invalid segment stays on the layout's segment list until those
references drain. Subsequent scans can find it again and repeatedly
invoke the layout driver's cancel_io() callback. For flexfiles, this
cancels matching RPC tasks and disconnects data server RPC clients.
During RPC/RDMA data server recovery, repeated cancellation can cause a
reconnect loop that consumes essentially all client CPU and prevents
forward progress.

Record cancellation requests per mirror stripe in the flexfiles layout
segment. Each stripe is cancelled at most once, regardless of how many
times the invalid segment is encountered. A per-stripe bitmap rather
than a single per-segment bit preserves the ability to cancel I/O to a
different device after an earlier device-specific cancellation.

Cancellation is best-effort. An RPC that has already passed the
layout-validity check may not yet be visible to the cancellation
scan. Such I/O retains its lseg reference and remains subject to
the normal RPC completion and recovery paths. Suppress repeated
cancellation and disconnect requests without changing the existing
lseg lifetime and deferred layout-return accounting.

This reproduced on 6.8.0, 7.0.0, and 7.4.0-rc1. It was tested on
7.4.0-rc1 with sustained pNFS/flexfiles I/O over RPC/RDMA while
restarting the NFS service on a data server. Without it, repeated
cancellation led to a reconnect loop and no workload recovery. With it,
the client recovered after the data server returned.

Fixes: b739a5bd9d9f ("NFSv4/flexfiles: Cancel I/O if the layout is recalled or revoked")
Cc: stable@vger.kernel.org
Signed-off-by: Tim Menninger <tmenninger@everpuredata.com>
Signed-off-by: Anna Schumaker <anna.schumaker@hammerspace.com>
[ sashal: Adapted the cancelled-stripes bitmap to the single-stripe layout here: it is sized by mirror count and indexed by mirror idx, since there is no devid argument or per-stripe loop in cancel_io. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/nfs/flexfilelayout/flexfilelayout.c | 11 +++++++++++
 fs/nfs/flexfilelayout/flexfilelayout.h |  1 +
 2 files changed, 12 insertions(+)

diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index 83e78513e2ef1..f5c297893fe56 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -11,6 +11,7 @@
 #include <linux/nfs_mount.h>
 #include <linux/nfs_page.h>
 #include <linux/module.h>
+#include <linux/bitmap.h>
 #include <linux/file.h>
 #include <linux/sched/mm.h>
 
@@ -300,6 +301,7 @@ static void _ff_layout_free_lseg(struct nfs4_ff_layout_segment *fls)
 {
 	if (fls) {
 		ff_layout_free_mirror_array(fls);
+		bitmap_free(fls->cancelled_stripes);
 		kfree(fls);
 	}
 }
@@ -588,6 +590,12 @@ ff_layout_alloc_lseg(struct pnfs_layout_hdr *lh,
 		fls->mirror_array[i]->report_interval = be32_to_cpup(p);
 
 out_sort_mirrors:
+	fls->cancelled_stripes = bitmap_zalloc(fls->mirror_array_cnt,
+					       gfp_flags);
+	if (!fls->cancelled_stripes) {
+		rc = -ENOMEM;
+		goto out_err_free;
+	}
 	ff_layout_sort_mirrors(fls);
 	ret = &fls->generic_hdr;
 	dprintk("<-- %s (success)\n", __func__);
@@ -2254,6 +2262,9 @@ static void ff_layout_cancel_io(struct pnfs_layout_segment *lseg)
 
 	for (idx = 0; idx < flseg->mirror_array_cnt; idx++) {
 		mirror = flseg->mirror_array[idx];
+		/* Do not cancel a stripe again while this lseg drains. */
+		if (test_and_set_bit(idx, flseg->cancelled_stripes))
+			continue;
 		mirror_ds = mirror->dss[0].mirror_ds;
 		if (IS_ERR_OR_NULL(mirror_ds))
 			continue;
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.h b/fs/nfs/flexfilelayout/flexfilelayout.h
index 1561e9ceab534..143c183cb19f2 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.h
+++ b/fs/nfs/flexfilelayout/flexfilelayout.h
@@ -106,6 +106,7 @@ struct nfs4_ff_layout_segment {
 	u64				stripe_unit;
 	u32				flags;
 	u32				mirror_array_cnt;
+	unsigned long			*cancelled_stripes;
 	struct nfs4_ff_layout_mirror	*mirror_array[] __counted_by(mirror_array_cnt);
 };
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 065/555] watchdog: rz: Discard pm_runtime_put() return values
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (63 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 064/555] pNFS: avoid repeatedly cancelling I/O for the same lseg Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 066/555] watchdog: rzv2h: Use pm_runtime_put_sync() Greg Kroah-Hartman
                   ` (489 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Rafael J. Wysocki, Guenter Roeck,
	Sasha Levin

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

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

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

[ Upstream commit f52defa7b830abbba6b26df503ca42c0b2f20abe ]

Failing a watchdog stop due to pm_runtime_put() returning a negative
value is not particularly useful.

Returning an error code from pm_runtime_put() merely means that it has
not queued up a work item to check whether or not the device can be
suspended and there are many perfectly valid situations in which that
can happen, like after writing "on" to the devices' runtime PM "control"
attribute in sysfs for one example.  It also happens when the kernel is
configured with CONFIG_PM unset.

Accordingly, update rzg2l_wdt_stop() and rzv2h_wdt_stop() to simply
discard the return value of pm_runtime_put().

This will facilitate a planned change of the pm_runtime_put() return
type to void in the future.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://patch.msgid.link/3340071.5fSG56mABF@rafael.j.wysocki
Stable-dep-of: ca800e625d18 ("watchdog: rzv2h: Use pm_runtime_put_sync()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/watchdog/rzg2l_wdt.c | 4 +---
 drivers/watchdog/rzv2h_wdt.c | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c
index 11bbe48160ec9..0dfa94f48e2b6 100644
--- a/drivers/watchdog/rzg2l_wdt.c
+++ b/drivers/watchdog/rzg2l_wdt.c
@@ -132,9 +132,7 @@ static int rzg2l_wdt_stop(struct watchdog_device *wdev)
 	if (ret)
 		return ret;
 
-	ret = pm_runtime_put(wdev->parent);
-	if (ret < 0)
-		return ret;
+	pm_runtime_put(wdev->parent);
 
 	return 0;
 }
diff --git a/drivers/watchdog/rzv2h_wdt.c b/drivers/watchdog/rzv2h_wdt.c
index c29c94f0b6295..2342e29962d23 100644
--- a/drivers/watchdog/rzv2h_wdt.c
+++ b/drivers/watchdog/rzv2h_wdt.c
@@ -140,9 +140,7 @@ static int rzv2h_wdt_stop(struct watchdog_device *wdev)
 	if (ret)
 		return ret;
 
-	ret = pm_runtime_put(wdev->parent);
-	if (ret < 0)
-		return ret;
+	pm_runtime_put(wdev->parent);
 
 	return 0;
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 066/555] watchdog: rzv2h: Use pm_runtime_put_sync()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (64 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 065/555] watchdog: rz: Discard pm_runtime_put() return values Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 067/555] hwmon: (nct6775) Handle dual use registers Greg Kroah-Hartman
                   ` (488 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Lad Prabhakar, Guenter Roeck,
	Sasha Levin

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

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

From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

[ Upstream commit ca800e625d18a9f5b19f94ab837ceb3fccdca22f ]

pm_runtime_put() may trigger the idle check after pm_runtime_disable()
is run as part of devm_pm_runtime_enable()'s cleanup action, leaving
runtime PM active.

Use pm_runtime_put_sync() to ensure the idle check runs synchronously.

Fixes: f6febd0a30b6e ("watchdog: Add Watchdog Timer driver for RZ/V2H(P)")
Cc: stable@vger.kernel.org
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://patch.msgid.link/20261001165201.763882-3-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
[ sashal: Replaced pm_runtime_put() with pm_runtime_put_sync() only in rzv2h_wdt_stop(), dropping the RZ/T2H-only hunk and its context lines because that support is absent here. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/watchdog/rzv2h_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/rzv2h_wdt.c b/drivers/watchdog/rzv2h_wdt.c
index 2342e29962d23..1ad1c326084fb 100644
--- a/drivers/watchdog/rzv2h_wdt.c
+++ b/drivers/watchdog/rzv2h_wdt.c
@@ -140,7 +140,7 @@ static int rzv2h_wdt_stop(struct watchdog_device *wdev)
 	if (ret)
 		return ret;
 
-	pm_runtime_put(wdev->parent);
+	pm_runtime_put_sync(wdev->parent);
 
 	return 0;
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 067/555] hwmon: (nct6775) Handle dual use registers
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (65 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 066/555] watchdog: rzv2h: Use pm_runtime_put_sync() Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 068/555] s390/dasd: Fix typo immediatly -> immediately Greg Kroah-Hartman
                   ` (487 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Anton Lundin, Guenter Roeck,
	Sasha Levin

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

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

From: Anton Lundin <glance@ac2.se>

[ Upstream commit ca1abdd1a9b9ce51713a18c8905bf10579533c3b ]

The REG_TARGET register has different meaning, depending on if pwm is in
thermal_cruise or speed_cruise.

This means we can't assume it's always word sized, so we need to handle
it differently depending on which mode we're in.

The code already does this, but the register was configured as word
sized for the speed_cruise mode, which would do the wrong thing in
thermal_cruise mode.

Fixes: 6c009501ff20 ("hwmon: (nct6775) Add support for NCT6102D/6106D")
Fixes: 29c7cb485b32 ("hwmon: (nct6775) Integrate new model nct6116")
Fixes: 437b3c2a4bdc ("hwmon: (nct6775) Add support for NCT6126D")
Cc: stable@vger.kernel.org
Signed-off-by: Anton Lundin <glance@ac2.se>
Link: https://patch.msgid.link/20261109082511.851377-2-glance@ac2.se
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/hwmon/nct6775-core.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/hwmon/nct6775-core.c b/drivers/hwmon/nct6775-core.c
index ce2cf1f229004..ed17b00433109 100644
--- a/drivers/hwmon/nct6775-core.c
+++ b/drivers/hwmon/nct6775-core.c
@@ -1152,14 +1152,12 @@ bool nct6775_reg_is_word_sized(struct nct6775_data *data, u16 reg)
 	case nct6106:
 		return reg == 0x20 || reg == 0x22 || reg == 0x24 ||
 		  (reg >= 0x59 && reg < 0x69 && (reg & 1)) ||
-		  reg == 0xe0 || reg == 0xe2 || reg == 0xe4 ||
-		  reg == 0x111 || reg == 0x121 || reg == 0x131;
+		  reg == 0xe0 || reg == 0xe2 || reg == 0xe4;
 	case nct6116:
 		return reg == 0x20 || reg == 0x22 || reg == 0x24 ||
 		  reg == 0x26 || reg == 0x28 || reg == 0x59 || reg == 0x5b ||
 		  reg == 0xe0 || reg == 0xe2 || reg == 0xe4 || reg == 0xe6 ||
-		  reg == 0xe8 || reg == 0x111 || reg == 0x121 || reg == 0x131 ||
-		  reg == 0x191 || reg == 0x1a1;
+		  reg == 0xe8;
 	case nct6775:
 		return (((reg & 0xff00) == 0x100 ||
 		    (reg & 0xff00) == 0x200) &&
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 068/555] s390/dasd: Fix typo immediatly -> immediately
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (66 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 067/555] hwmon: (nct6775) Handle dual use registers Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 069/555] s390/dasd: Re-initialize RCD buffer with "V1.0" before every start Greg Kroah-Hartman
                   ` (486 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Heiko Carstens, Jan Höppner,
	Stefan Haberland, Jens Axboe, Sasha Levin

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

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

From: Stefan Haberland <sth@linux.ibm.com>

[ Upstream commit ae6f19236b5ae4eef4df2780d51bee19add0eba8 ]

Fix typo in function name dasd_sleep_on_immediatly().

Suggested-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Link: https://patch.msgid.link/20261112102608.1057852-2-sth@linux.ibm.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Stable-dep-of: 25cdc1f63227 ("s390/dasd: Re-initialize RCD buffer with "V1.0" before every start")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/s390/block/dasd.c       |  4 ++--
 drivers/s390/block/dasd_alias.c |  2 +-
 drivers/s390/block/dasd_eckd.c  | 14 +++++++-------
 drivers/s390/block/dasd_int.h   |  2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 12b219b72bd4a..9f5998d5da305 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -2571,7 +2571,7 @@ static inline int _dasd_term_running_cqr(struct dasd_device *device)
 	return rc;
 }
 
-int dasd_sleep_on_immediatly(struct dasd_ccw_req *cqr)
+int dasd_sleep_on_immediately(struct dasd_ccw_req *cqr)
 {
 	struct dasd_device *device;
 	int rc;
@@ -2619,7 +2619,7 @@ int dasd_sleep_on_immediatly(struct dasd_ccw_req *cqr)
 
 	return rc;
 }
-EXPORT_SYMBOL(dasd_sleep_on_immediatly);
+EXPORT_SYMBOL(dasd_sleep_on_immediately);
 
 /*
  * Cancels a request that was started with dasd_sleep_on_req.
diff --git a/drivers/s390/block/dasd_alias.c b/drivers/s390/block/dasd_alias.c
index f7e768d8ca766..2afac13cb79c2 100644
--- a/drivers/s390/block/dasd_alias.c
+++ b/drivers/s390/block/dasd_alias.c
@@ -751,7 +751,7 @@ static int reset_summary_unit_check(struct alias_lcu *lcu,
 	cqr->buildclk = get_tod_clock();
 	cqr->status = DASD_CQR_FILLED;
 
-	rc = dasd_sleep_on_immediatly(cqr);
+	rc = dasd_sleep_on_immediately(cqr);
 	return rc;
 }
 
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index cad655b28c0c1..27f5df6973cdc 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -886,7 +886,7 @@ static int dasd_eckd_read_conf_immediately(struct dasd_device *device,
 	set_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags);
 	cqr->retries = 5;
 	cqr->callback = read_conf_cb;
-	rc = dasd_sleep_on_immediatly(cqr);
+	rc = dasd_sleep_on_immediately(cqr);
 	return rc;
 }
 
@@ -5100,7 +5100,7 @@ dasd_eckd_release(struct dasd_device *device)
 	cqr->buildclk = get_tod_clock();
 	cqr->status = DASD_CQR_FILLED;
 
-	rc = dasd_sleep_on_immediatly(cqr);
+	rc = dasd_sleep_on_immediately(cqr);
 	if (!rc)
 		clear_bit(DASD_FLAG_IS_RESERVED, &device->flags);
 
@@ -5155,7 +5155,7 @@ dasd_eckd_reserve(struct dasd_device *device)
 	cqr->buildclk = get_tod_clock();
 	cqr->status = DASD_CQR_FILLED;
 
-	rc = dasd_sleep_on_immediatly(cqr);
+	rc = dasd_sleep_on_immediately(cqr);
 	if (!rc)
 		set_bit(DASD_FLAG_IS_RESERVED, &device->flags);
 
@@ -5209,7 +5209,7 @@ dasd_eckd_steal_lock(struct dasd_device *device)
 	cqr->buildclk = get_tod_clock();
 	cqr->status = DASD_CQR_FILLED;
 
-	rc = dasd_sleep_on_immediatly(cqr);
+	rc = dasd_sleep_on_immediately(cqr);
 	if (!rc)
 		set_bit(DASD_FLAG_IS_RESERVED, &device->flags);
 
@@ -5272,7 +5272,7 @@ static int dasd_eckd_snid(struct dasd_device *device,
 	cqr->status = DASD_CQR_FILLED;
 	cqr->lpm = usrparm.path_mask;
 
-	rc = dasd_sleep_on_immediatly(cqr);
+	rc = dasd_sleep_on_immediately(cqr);
 	/* verify that I/O processing didn't modify the path mask */
 	if (!rc && usrparm.path_mask && (cqr->lpm != usrparm.path_mask))
 		rc = -EIO;
@@ -5914,7 +5914,7 @@ static int dasd_eckd_read_message_buffer(struct dasd_device *device,
 	cqr->block = NULL;
 	cqr->expires = 10 * HZ;
 	set_bit(DASD_CQR_VERIFY_PATH, &cqr->flags);
-	/* dasd_sleep_on_immediatly does not do complex error
+	/* dasd_sleep_on_immediately does not do complex error
 	 * recovery so clear erp flag and set retry counter to
 	 * do basic erp */
 	clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
@@ -5946,7 +5946,7 @@ static int dasd_eckd_read_message_buffer(struct dasd_device *device,
 
 	cqr->buildclk = get_tod_clock();
 	cqr->status = DASD_CQR_FILLED;
-	rc = dasd_sleep_on_immediatly(cqr);
+	rc = dasd_sleep_on_immediately(cqr);
 	if (rc == 0) {
 		prssdp = (struct dasd_psf_prssd_data *) cqr->data;
 		message_buf = (struct dasd_rssd_messages *)
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index 81cfb5c89681b..99c2534216537 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -857,7 +857,7 @@ void dasd_schedule_device_bh(struct dasd_device *);
 void dasd_schedule_block_bh(struct dasd_block *);
 int  dasd_sleep_on(struct dasd_ccw_req *);
 int  dasd_sleep_on_queue(struct list_head *);
-int  dasd_sleep_on_immediatly(struct dasd_ccw_req *);
+int  dasd_sleep_on_immediately(struct dasd_ccw_req *);
 int  dasd_sleep_on_queue_interruptible(struct list_head *);
 int  dasd_sleep_on_interruptible(struct dasd_ccw_req *);
 void dasd_device_set_timer(struct dasd_device *, int);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 069/555] s390/dasd: Re-initialize RCD buffer with "V1.0" before every start
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (67 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 068/555] s390/dasd: Fix typo immediatly -> immediately Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 070/555] sched/core: Do not touch SMT siblings that have not joined the core yet Greg Kroah-Hartman
                   ` (485 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jan Höppner, Stefan Haberland,
	Jens Axboe, Sasha Levin

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

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

From: Stefan Haberland <sth@linux.ibm.com>

[ Upstream commit 25cdc1f63227a1ea69a1ec823a8a860e33299169 ]

Under z/VM the Read Configuration Data (RCD) buffer has to start with
EBCDIC "V1.0" to request the virtual device SNEQ that carries the
minidisk UIT. The request and the response share the same buffer:
CP evaluates the magic on the way out and the RCD data is written into
the same buffer on the way back.

The magic is only written when the request is built and again in
read_conf_cb() when the original request fails.

Several restart paths do not run that callback:
 - ERP use the same buffer and if the same error occurs again,
   the ERP restarts the existing ERP request;
   if a different error occurs, it adds another ERP request.
   Neither re-initializes the magic.
 - Terminated (timed out) ERP requests, killed requests and requests
   requeued after the last path was gone are restarted without it.
 - dasd_sleep_on_immediately() overwrites cqr->callback, so read_conf_cb()
   never ran for dasd_eckd_read_conf_immediately(), and its fastpath
   retries in dasd_int_handler() do not call a callback either.

If such a restart succeeds, z/VM omits the virtual device SNEQ, the UID
of that path is built without the UIT and the paths are reported as
"Not all channel paths lead to the same device" although they lead to
the same minidisk.

Every start of a request, whatever path led to it, goes through
dasd_start_IO(). Add an optional prepare_io function to the request
that dasd_start_IO() calls before every start of the request and of
its ERP requests, and use it to write the magic for RCD requests.

The ERP handling stays unchanged. read_conf_cb() is no longer needed
and is removed, which also gets rid of its memset() that only cleared
a single byte.

Fixes: 5915a873fcb1 ("[S390] dasd: re-initialize read_conf buffer for retries")
Cc: stable@vger.kernel.org
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Link: https://patch.msgid.link/20261112102608.1057852-3-sth@linux.ibm.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
[ sashal: Placed the new dasd_prepare_cqr_io() helper before the "externals in dasd.c" block in dasd_int.h, since the surrounding context (dasd_req_conflict) is missing in this tree. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/s390/block/dasd.c      |  1 +
 drivers/s390/block/dasd_eckd.c | 52 ++++++++++++----------------------
 drivers/s390/block/dasd_int.h  | 15 ++++++++++
 3 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 9f5998d5da305..8855b2abf7f0a 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -1400,6 +1400,7 @@ int dasd_start_IO(struct dasd_ccw_req *cqr)
 		cqr->status = DASD_CQR_ERROR;
 		return -EIO;
 	}
+	dasd_start_IO_prepare(cqr);
 	cqr->startclk = get_tod_clock();
 	cqr->starttime = jiffies;
 	cqr->retries--;
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 27f5df6973cdc..33aa96439b3a7 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -809,20 +809,29 @@ static int dasd_eckd_compare_path_uid(struct dasd_device *device,
 	return memcmp(&device_uid, &path_uid, sizeof(struct dasd_uid));
 }
 
+/*
+ * The RCD buffer has to start with EBCDIC "V1.0" to show support for
+ * virtual device SNEQ. The RCD data is written into the same buffer, so
+ * a failed attempt may already have overwritten the magic. Re-initialize
+ * it before every start, including restarts by ERP requests.
+ */
+static void dasd_eckd_rcd_prepare_io(struct dasd_ccw_req *cqr)
+{
+	struct ccw1 *ccw = cqr->cpaddr;
+	__u8 *rcd_buffer = dma32_to_virt(ccw->cda);
+
+	rcd_buffer[0] = 0xE5;
+	rcd_buffer[1] = 0xF1;
+	rcd_buffer[2] = 0x4B;
+	rcd_buffer[3] = 0xF0;
+}
+
 static void dasd_eckd_fill_rcd_cqr(struct dasd_device *device,
 				   struct dasd_ccw_req *cqr,
 				   __u8 *rcd_buffer,
 				   __u8 lpm)
 {
 	struct ccw1 *ccw;
-	/*
-	 * buffer has to start with EBCDIC "V1.0" to show
-	 * support for virtual device SNEQ
-	 */
-	rcd_buffer[0] = 0xE5;
-	rcd_buffer[1] = 0xF1;
-	rcd_buffer[2] = 0x4B;
-	rcd_buffer[3] = 0xF0;
 
 	ccw = cqr->cpaddr;
 	ccw->cmd_code = DASD_ECKD_CCW_RCD;
@@ -839,33 +848,10 @@ static void dasd_eckd_fill_rcd_cqr(struct dasd_device *device,
 	cqr->retries = 256;
 	cqr->buildclk = get_tod_clock();
 	cqr->status = DASD_CQR_FILLED;
+	cqr->prepare_io = dasd_eckd_rcd_prepare_io;
 	set_bit(DASD_CQR_VERIFY_PATH, &cqr->flags);
 }
 
-/*
- * Wakeup helper for read_conf
- * if the cqr is not done and needs some error recovery
- * the buffer has to be re-initialized with the EBCDIC "V1.0"
- * to show support for virtual device SNEQ
- */
-static void read_conf_cb(struct dasd_ccw_req *cqr, void *data)
-{
-	struct ccw1 *ccw;
-	__u8 *rcd_buffer;
-
-	if (cqr->status !=  DASD_CQR_DONE) {
-		ccw = cqr->cpaddr;
-		rcd_buffer = dma32_to_virt(ccw->cda);
-		memset(rcd_buffer, 0, sizeof(*rcd_buffer));
-
-		rcd_buffer[0] = 0xE5;
-		rcd_buffer[1] = 0xF1;
-		rcd_buffer[2] = 0x4B;
-		rcd_buffer[3] = 0xF0;
-	}
-	dasd_wakeup_cb(cqr, data);
-}
-
 static int dasd_eckd_read_conf_immediately(struct dasd_device *device,
 					   struct dasd_ccw_req *cqr,
 					   __u8 *rcd_buffer,
@@ -885,7 +871,6 @@ static int dasd_eckd_read_conf_immediately(struct dasd_device *device,
 	clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
 	set_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags);
 	cqr->retries = 5;
-	cqr->callback = read_conf_cb;
 	rc = dasd_sleep_on_immediately(cqr);
 	return rc;
 }
@@ -923,7 +908,6 @@ static int dasd_eckd_read_conf_lpm(struct dasd_device *device,
 		goto out_error;
 	}
 	dasd_eckd_fill_rcd_cqr(device, cqr, rcd_buf, lpm);
-	cqr->callback = read_conf_cb;
 	ret = dasd_sleep_on(cqr);
 	/*
 	 * on success we update the user input parms
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index 99c2534216537..beba87a30e75b 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -147,6 +147,8 @@ struct dasd_ccw_req {
 	void *data;			/* pointer to data area */
 	struct irb irb;			/* device status in case of an error */
 	struct dasd_ccw_req *refers;	/* ERP-chain queueing. */
+	/* optional prepare function called before every start_io, must not sleep */
+	void (*prepare_io)(struct dasd_ccw_req *cqr);
 	void *function; 		/* originating ERP action */
 	void *mem_chunk;
 
@@ -815,6 +817,19 @@ static inline void *dasd_get_callback_data(struct dasd_ccw_req *cqr)
 	return cqr->callback_data;
 }
 
+/*
+ * Walk down the ERP chain to the original CQR and call its
+ * prepare_io function if set.
+ */
+static inline void dasd_start_IO_prepare(struct dasd_ccw_req *cqr)
+{
+	/* ERP requests use the prepare function of the original request */
+	while (cqr->refers)
+		cqr = cqr->refers;
+	if (cqr->prepare_io)
+		cqr->prepare_io(cqr);
+}
+
 /* externals in dasd.c */
 #define DASD_PROFILE_OFF	 0
 #define DASD_PROFILE_ON 	 1
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 070/555] sched/core: Do not touch SMT siblings that have not joined the core yet
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (68 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 069/555] s390/dasd: Re-initialize RCD buffer with "V1.0" before every start Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 071/555] ksmbd: skip metadata-only opens in sharing checks Greg Kroah-Hartman
                   ` (484 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, syzbot+681e729b2cf0d4860042,
	Seiji Nishikawa, Peter Zijlstra (Intel), Ingo Molnar, Sasha Levin

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

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

From: Seiji Nishikawa <snishika@redhat.com>

[ Upstream commit ec6f6731538e0d45872eb279fdeb477bed152d6f ]

When a CPU comes online, it is added to cpu_smt_mask() of its siblings
before sched_core_cpu_starting() sets its rq->core to the core leader.
For example, on x86, ap_starting() calls set_cpu_sibling_map() first,
and calls notify_cpu_starting() after that. This order is intended.

Before sched_core_cpu_starting() runs, rq->core of the new CPU still
points to its own rq. But rq->core_enabled of the new CPU is already
set. __sched_core_flip() sets it for all possible CPUs, also for
offline CPUs, and CPU offline does not clear it. So __rq_lockp() of the
new CPU returns its own rq->__lock. It does not return the core wide
lock.

If a sibling CPU runs pick_next_task() for SCHED_CORE at this time, it
checks all CPUs in cpu_smt_mask(). It calls update_rq_clock() and
pick_task() for the rq of the new CPU. But it holds only its own core
lock, not the lock of the new CPU. Then lockdep shows this warning in
update_rq_clock().

  debug_locks && !(lock_is_held(&(__rq_lockp(rq))->dep_map) != 0)
  WARNING: kernel/sched/sched.h:1666 at update_rq_clock+0x40a/0xd20 kernel/sched/core.c:875, CPU#0: syz-executor251/5712
  Call Trace:
   <TASK>
   pick_next_task kernel/sched/core.c:6375 [inline]
   __schedule+0x1c69/0x6920 kernel/sched/core.c:7199
   preempt_schedule_irq+0x4e/0x90 kernel/sched/core.c:7606

The next loops in pick_next_task() also change rq_i->core_pick of this
rq, and can call resched_curr() for it, without its lock.
resched_curr() has the same lockdep_assert_rq_held() check.
__sched_core_account_forceidle() also checks all CPUs in the same mask.

CPU offline does not have this problem. remove_siblinginfo() and
sched_core_cpu_dying() both run in take_cpu_down() under stop_machine.
So no sibling CPU can be in pick_next_task() at that time.

Fix this. In these loops, skip a sibling CPU if its rq->core is
different from our rq->core. At run time, rq->core of a CPU is changed
by sched_core_cpu_starting(), sched_core_cpu_deactivate() and
sched_core_cpu_dying(). The first two hold sched_core_lock(), and
sched_core_lock() takes the rq locks of all CPUs in the SMT mask. The
last one runs under stop_machine, as written above. So while we hold
our core lock, the result of this check does not change. A CPU that is
not in the core yet will pick its own tasks. The comment in the
reschedule loop of pick_next_task() already expects this case.

I tested this with the syzbot C reproducer in QEMU. The two vCPUs were
SMT siblings (-smp 2,sockets=1,cores=1,threads=2). Without this patch,
the warning came after about 100 seconds. Just before the warning, a
debug print showed that the loop on CPU 0 saw CPU 1 with rq->core
pointing to CPU 1 itself, and cpu_online() was false for CPU 1. With
this patch, the same state still happened, but there was no warning
in more than 2 hours.

Fixes: 3c474b3239f1 ("sched: Fix Core-wide rq->lock for uninitialized CPUs")
Closes: https://syzkaller.appspot.com/bug?extid=681e729b2cf0d4860042
Reported-by: syzbot+681e729b2cf0d4860042@syzkaller.appspotmail.com
Signed-off-by: Seiji Nishikawa <snishika@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261104022004.3810619-1-snishika@redhat.com
[ sashal: adapted to the older pick_next_task() signature (no __must_hold), and context differs: max = NULL initialized at declaration, need_sync assigned with = and no restart label. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/sched/core.c       |  8 +++-----
 kernel/sched/core_sched.c |  3 +--
 kernel/sched/sched.h      | 19 +++++++++++++++++++
 3 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 719186283bf91..a1d0b22e46b7a 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6078,7 +6078,6 @@ static struct task_struct *
 pick_next_task(struct rq *rq, struct rq_flags *rf)
 {
 	struct task_struct *next, *p, *max = NULL;
-	const struct cpumask *smt_mask;
 	bool fi_before = false;
 	bool core_clock_updated = (rq == rq->core);
 	unsigned long cookie;
@@ -6128,7 +6127,6 @@ pick_next_task(struct rq *rq, struct rq_flags *rf)
 
 	prev_balance(rq, rf);
 
-	smt_mask = cpu_smt_mask(cpu);
 	need_sync = !!rq->core->core_cookie;
 
 	/* reset state */
@@ -6184,7 +6182,7 @@ pick_next_task(struct rq *rq, struct rq_flags *rf)
 	 *
 	 * Tie-break prio towards the current CPU
 	 */
-	for_each_cpu_wrap(i, smt_mask, cpu) {
+	for_each_core_cpu_wrap(i, rq) {
 		rq_i = cpu_rq(i);
 
 		/*
@@ -6208,7 +6206,7 @@ pick_next_task(struct rq *rq, struct rq_flags *rf)
 	 * For each thread: try and find a runnable task that matches @max or
 	 * force idle.
 	 */
-	for_each_cpu(i, smt_mask) {
+	for_each_core_cpu(i, rq) {
 		rq_i = cpu_rq(i);
 		p = rq_i->core_pick;
 
@@ -6254,7 +6252,7 @@ pick_next_task(struct rq *rq, struct rq_flags *rf)
 	 * their task. This ensures there is no inter-sibling overlap between
 	 * non-matching user state.
 	 */
-	for_each_cpu(i, smt_mask) {
+	for_each_core_cpu(i, rq) {
 		rq_i = cpu_rq(i);
 
 		/*
diff --git a/kernel/sched/core_sched.c b/kernel/sched/core_sched.c
index 1ef98a93eb1df..8d7d60c970662 100644
--- a/kernel/sched/core_sched.c
+++ b/kernel/sched/core_sched.c
@@ -239,7 +239,6 @@ int sched_core_share_pid(unsigned int cmd, pid_t pid, enum pid_type type,
 /* REQUIRES: rq->core's clock recently updated. */
 void __sched_core_account_forceidle(struct rq *rq)
 {
-	const struct cpumask *smt_mask = cpu_smt_mask(cpu_of(rq));
 	u64 delta, now = rq_clock(rq->core);
 	struct rq *rq_i;
 	struct task_struct *p;
@@ -271,7 +270,7 @@ void __sched_core_account_forceidle(struct rq *rq)
 		delta = div_u64(delta, rq->core->core_forceidle_occupation);
 	}
 
-	for_each_cpu(i, smt_mask) {
+	for_each_core_cpu(i, rq) {
 		rq_i = cpu_rq(i);
 		p = rq_i->core_pick ?: rq_i->curr;
 
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 27de9290235e7..855b7e39ae89d 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1453,6 +1453,25 @@ static inline raw_spinlock_t *__rq_lockp(struct rq *rq)
 	return &rq->__lock;
 }
 
+/*
+ * A CPU coming online is set in cpu_smt_mask() before
+ * sched_core_cpu_starting() links its rq->core to the core leader.
+ * Until then it does not share the core-wide lock, so it must not be
+ * touched as part of the core.
+ */
+static inline bool sched_core_sibling(struct rq *rq, struct rq *rq_i)
+{
+	return rq_i->core == rq->core;
+}
+
+#define for_each_core_cpu(i, rq) \
+	for_each_cpu(i, cpu_smt_mask(rq->cpu)) \
+		if (sched_core_sibling(rq, cpu_rq(i)))
+
+#define for_each_core_cpu_wrap(i, rq) \
+	for_each_cpu_wrap(i, cpu_smt_mask(rq->cpu), rq->cpu) \
+		if (sched_core_sibling(rq, cpu_rq(i)))
+
 extern bool
 cfs_prio_less(const struct task_struct *a, const struct task_struct *b, bool fi);
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 071/555] ksmbd: skip metadata-only opens in sharing checks
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (69 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 070/555] sched/core: Do not touch SMT siblings that have not joined the core yet Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 072/555] wifi: mac80211_hwsim: ignore non-generic netlink releases Greg Kroah-Hartman
                   ` (483 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Ian Bridges, Namjae Jeon,
	Sasha Levin

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

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

From: Ian Bridges <icb@fastmail.org>

[ Upstream commit 81fefb6c635489e71e286d1465b6dd1d0a27ceec ]

A READ_CONTROL open without sharing can block later reads, writes and
deletes even though it holds no data, execute or delete access.

Keep the existing attribute-only exception. For other pairs, require
both effective access masks to hold one of those rights. MS-FSA
2.1.5.1.2 grants FILE_WRITE_DATA when an open overwrites a file or
stream, or creates a named stream on an existing file. Use that granted
access for sharing checks while keeping the requested access on the
returned handle.

The Time Machine AFP_AfpInfo synthesis keeps its requested access.
ksmbd implements FILE_SUPERSEDE by truncating the file, so count it as
a write.

This also prevents an overwrite from truncating a file while another
open that holds data, execute or delete access does not share writing.

Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
Cc: stable@vger.kernel.org
Signed-off-by: Ian Bridges <icb@fastmail.org>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
[ sashal: Added the stream_created and implied_write handling to the 6.12 code, with adjusted context for missing later features, a non-const idmap pointer, and the existing unlock helper. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/smb/server/smb2pdu.c    | 30 ++++++++++++++++++++++--------
 fs/smb/server/smb_common.c | 34 +++++++++++++++++++++++++++++++++-
 fs/smb/server/smb_common.h |  5 +++++
 fs/smb/server/vfs_cache.h  |  2 ++
 4 files changed, 62 insertions(+), 9 deletions(-)

diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 82d1225dd7e8f..d919dd0333624 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -2548,7 +2548,8 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
 
 static noinline int smb2_set_stream_name_xattr(const struct path *path,
 					       struct ksmbd_file *fp,
-					       char *stream_name, int s_type)
+					       char *stream_name, int s_type,
+					       bool *created)
 {
 	struct mnt_idmap *idmap = mnt_idmap(path->mnt);
 	size_t xattr_stream_size;
@@ -2586,6 +2587,8 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,
 	rc = ksmbd_vfs_setxattr(idmap, path, xattr_stream_name, NULL, 0, 0, false);
 	if (rc < 0)
 		pr_err("Failed to store XATTR stream name :%d\n", rc);
+	else
+		*created = true;
 	return 0;
 }
 
@@ -3011,6 +3014,7 @@ int smb2_open(struct ksmbd_work *work)
 	char *name = NULL;
 	char *stream_name = NULL;
 	bool file_present = false, created = false, already_permitted = false;
+	bool stream_created = false;
 	int share_ret, need_truncate = 0;
 	u64 time;
 	umode_t posix_mode = 0;
@@ -3613,7 +3617,8 @@ int smb2_open(struct ksmbd_work *work)
 		rc = smb2_set_stream_name_xattr(&path,
 						fp,
 						stream_name,
-						s_type);
+						s_type,
+						&stream_created);
 		if (rc)
 			goto err_out;
 		file_info = FILE_CREATED;
@@ -3621,10 +3626,22 @@ int smb2_open(struct ksmbd_work *work)
 
 	fp->attrib_only = !(req->DesiredAccess & ~(FILE_READ_ATTRIBUTES_LE |
 			FILE_WRITE_ATTRIBUTES_LE | FILE_SYNCHRONIZE_LE));
+	need_truncate = !S_ISDIR(file_inode(filp)->i_mode) &&
+			open_flags & O_TRUNC && !fp->attrib_only && !stream_name;
+	/*
+	 * Count the FILE_WRITE_DATA that MS-FSA 2.1.5.1.2 grants an overwrite,
+	 * supersede included, or a new named stream on an existing file.
+	 * An attribute-only open of the file is not truncated, and the
+	 * synthesized AFP_AfpInfo stream is not created by the client.
+	 */
+	fp->implied_write = need_truncate ||
+			    (stream_name &&
+			     (open_flags & O_TRUNC ||
+			      (file_present && stream_created)));
 
 	/* fp should be searchable through ksmbd_inode.m_fp_list
-	 * after daccess, saccess, attrib_only, and stream are
-	 * initialized.
+	 * after daccess, saccess, attrib_only, implied_write, and
+	 * stream are initialized.
 	 */
 	down_write(&fp->f_ci->m_lock);
 	list_add(&fp->node, &fp->f_ci->m_fp_list);
@@ -3639,11 +3656,8 @@ int smb2_open(struct ksmbd_work *work)
 	if (file_present || created)
 		ksmbd_vfs_kern_path_unlock(&parent_path, &path);
 
-	if (!S_ISDIR(file_inode(filp)->i_mode) && open_flags & O_TRUNC &&
-	    !fp->attrib_only && !stream_name) {
+	if (need_truncate)
 		smb_break_all_oplock(work, fp);
-		need_truncate = 1;
-	}
 
 	share_ret = ksmbd_smb_check_shared_mode(fp->filp, fp);
 	if (!test_share_config_flag(work->tcon->share_conf, KSMBD_SHARE_FLAG_OPLOCKS) ||
diff --git a/fs/smb/server/smb_common.c b/fs/smb/server/smb_common.c
index a836b117f756f..870e4367da18f 100644
--- a/fs/smb/server/smb_common.c
+++ b/fs/smb/server/smb_common.c
@@ -664,10 +664,24 @@ static void smb_shared_mode_error(int error, struct ksmbd_file *prev_fp,
 		    prev_fp->saccess, curr_fp->daccess);
 }
 
+/*
+ * Sharing checks use fp->daccess plus the FILE_WRITE_DATA that MS-FSA
+ * grants an open that overwrites data or creates a named stream.
+ * fp->daccess keeps the open's own access.
+ */
+__le32 ksmbd_sharing_daccess(const struct ksmbd_file *fp)
+{
+	if (fp->implied_write)
+		return fp->daccess | FILE_WRITE_DATA_LE;
+	return fp->daccess;
+}
+
 int ksmbd_smb_check_shared_mode(struct file *filp, struct ksmbd_file *curr_fp)
 {
 	int rc = 0;
 	struct ksmbd_file *prev_fp;
+	__le32 curr_access = ksmbd_sharing_daccess(curr_fp);
+	__le32 access;
 
 	/*
 	 * Lookup fp in master fp list, and check desired access and
@@ -688,6 +702,24 @@ int ksmbd_smb_check_shared_mode(struct file *filp, struct ksmbd_file *curr_fp)
 		if (prev_fp->attrib_only != curr_fp->attrib_only)
 			continue;
 
+		/*
+		 * MS-FSA checks sharing per stream, so a named stream open's
+		 * implied write is not a write against the primary stream.
+		 * It still decides whether the pair is checked.
+		 */
+		access = curr_access;
+		if (ksmbd_stream_fd(curr_fp) && !ksmbd_stream_fd(prev_fp))
+			access = curr_fp->daccess;
+
+		/*
+		 * Two opens conflict only if both hold a right in
+		 * FILE_SHARE_CHECKED_ACCESS_LE (MS-FSA 2.1.5.1.2.1 and
+		 * 2.1.5.1.2.2)
+		 */
+		if (!(ksmbd_sharing_daccess(prev_fp) & FILE_SHARE_CHECKED_ACCESS_LE) ||
+		    !(curr_access & FILE_SHARE_CHECKED_ACCESS_LE))
+			continue;
+
 		if (!(prev_fp->saccess & FILE_SHARE_DELETE_LE) &&
 		    curr_fp->daccess & FILE_DELETE_LE) {
 			smb_shared_mode_error(SHARE_DELETE_ERROR,
@@ -714,7 +746,7 @@ int ksmbd_smb_check_shared_mode(struct file *filp, struct ksmbd_file *curr_fp)
 		}
 
 		if (!(prev_fp->saccess & FILE_SHARE_WRITE_LE) &&
-		    curr_fp->daccess & (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE)) {
+		    access & (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE)) {
 			smb_shared_mode_error(SHARE_WRITE_ERROR,
 					      prev_fp,
 					      curr_fp);
diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
index 421e187982084..c958a3c37385c 100644
--- a/fs/smb/server/smb_common.h
+++ b/fs/smb/server/smb_common.h
@@ -110,6 +110,10 @@
 #define SMB_COM_NEGOTIATE		0x72
 #define SMB1_CLIENT_GUID_SIZE		(16)
 
+/* Rights that make an open take part in sharing checks */
+#define FILE_SHARE_CHECKED_ACCESS_LE	(FILE_EXECUTE_LE | FILE_READ_DATA_LE | \
+		FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE | FILE_DELETE_LE)
+
 #define SMBFLG_RESPONSE 0x80	/* this PDU is a response from server */
 
 #define SMBFLG2_IS_LONG_NAME	cpu_to_le16(0x40)
@@ -337,6 +341,7 @@ int ksmbd_extract_shortname(struct ksmbd_conn *conn,
 
 int ksmbd_smb_negotiate_common(struct ksmbd_work *work, unsigned int command);
 
+__le32 ksmbd_sharing_daccess(const struct ksmbd_file *fp);
 int ksmbd_smb_check_shared_mode(struct file *filp, struct ksmbd_file *curr_fp);
 int __ksmbd_override_fsids(struct ksmbd_work *work,
 			   struct ksmbd_share_config *share);
diff --git a/fs/smb/server/vfs_cache.h b/fs/smb/server/vfs_cache.h
index c8f457bb41b34..060b758008ceb 100644
--- a/fs/smb/server/vfs_cache.h
+++ b/fs/smb/server/vfs_cache.h
@@ -104,6 +104,8 @@ struct ksmbd_file {
 
 	bool				is_nt_open;
 	bool				attrib_only;
+	/* writes data on open, see ksmbd_sharing_daccess() */
+	bool				implied_write;
 
 	char				client_guid[16];
 	char				create_guid[16];
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 072/555] wifi: mac80211_hwsim: ignore non-generic netlink releases
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (70 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 071/555] ksmbd: skip metadata-only opens in sharing checks Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 073/555] gpio: mvebu: name regmaps to fix debugfs collisions Greg Kroah-Hartman
                   ` (482 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Zhao Li, Johannes Berg, Sasha Levin

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

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

From: Zhao Li <enderaoelyther@gmail.com>

[ Upstream commit 989f47c56e48d442d79497a25ed946d029c4dc53 ]

Closing an unrelated netlink socket can remove mac80211_hwsim radios or
clear the active wmediumd registration when its port ID matches a generic
netlink socket.

mac80211_hwsim_netlink_notify() handles every NETLINK_URELEASE event,
but netlink port IDs are scoped by protocol. The notifier therefore treats
a release from another protocol as a MAC80211_HWSIM socket release.

Ignore release notifications unless they come from NETLINK_GENERIC.

LLM assistance was used to find the bug and review.

Fixes: 7882513bacb1 ("mac80211_hwsim driver support userspace frame tx/rx")
Fixes: e9ed49bf4c2c ("mac80211-hwsim: Add support for HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE")
Cc: stable@vger.kernel.org
Signed-off-by: Zhao Li <enderaoelyther@gmail.com>
Link: https://patch.msgid.link/20261028141751.6728-2-enderaoelyther@gmail.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/wireless/virtual/mac80211_hwsim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/virtual/mac80211_hwsim.c b/drivers/net/wireless/virtual/mac80211_hwsim.c
index 71f07e1a2a972..9f70025fafcc8 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim.c
+++ b/drivers/net/wireless/virtual/mac80211_hwsim.c
@@ -6454,7 +6454,7 @@ static int mac80211_hwsim_netlink_notify(struct notifier_block *nb,
 {
 	struct netlink_notify *notify = _notify;
 
-	if (state != NETLINK_URELEASE)
+	if (state != NETLINK_URELEASE || notify->protocol != NETLINK_GENERIC)
 		return NOTIFY_DONE;
 
 	remove_user_radios(notify->portid, hwsim_net_get_netgroup(notify->net));
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 073/555] gpio: mvebu: name regmaps to fix debugfs collisions
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (71 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 072/555] wifi: mac80211_hwsim: ignore non-generic netlink releases Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 074/555] gpio: mvebu: fix sleeping-while-atomic in mvebu_gpio_level_irq_mask() Greg Kroah-Hartman
                   ` (481 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Rosen Penev, Linus Walleij,
	Bartosz Golaszewski, Sasha Levin

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

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

From: Rosen Penev <rosenp@gmail.com>

[ Upstream commit 4d305c2273123119c27d6e4c822215e650c451e3 ]

Each marvell,armada-370-gpio node provides both 'gpio' and 'pwm'
register windows, and the driver creates one regmap per window on the
same platform device.  The shared regmap_config was unnamed, so both
maps defaulted their debugfs directory to dev_name(), e.g.

  debugfs: 'f1018100.gpio' already exists in 'regmap'

because the PWM regmap (and on Armada XP the per-CPU regmap) claimed
the same directory as the GPIO regmap.

Give each regmap a distinct .name so the debugfs directories become
'<dev>.gpio', '<dev>.percpu' and '<dev>.pwm'.  This only affects
debugfs naming; register access is unchanged.

Assisted-by: opencode:big-pickle
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Link: https://patch.msgid.link/20260905004334.177074-1-rosenp@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Stable-dep-of: 42269cdb3d3b ("gpio: mvebu: fix sleeping-while-atomic in mvebu_gpio_level_irq_mask()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpio/gpio-mvebu.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index 933a335af8c5b..14023051eebe1 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -603,6 +603,21 @@ static void mvebu_gpio_irq_handler(struct irq_desc *desc)
 }
 
 static const struct regmap_config mvebu_gpio_regmap_config = {
+	.name = "gpio",
+	.reg_bits = 32,
+	.reg_stride = 4,
+	.val_bits = 32,
+};
+
+static const struct regmap_config mvebu_gpio_percpu_regmap_config = {
+	.name = "percpu",
+	.reg_bits = 32,
+	.reg_stride = 4,
+	.val_bits = 32,
+};
+
+static const struct regmap_config mvebu_pwm_regmap_config = {
+	.name = "pwm",
 	.reg_bits = 32,
 	.reg_stride = 4,
 	.val_bits = 32,
@@ -845,7 +860,7 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
 			return PTR_ERR(base);
 
 		mvpwm->regs = devm_regmap_init_mmio(&pdev->dev, base,
-						    &mvebu_gpio_regmap_config);
+						    &mvebu_pwm_regmap_config);
 		if (IS_ERR(mvpwm->regs))
 			return PTR_ERR(mvpwm->regs);
 
@@ -1112,7 +1127,7 @@ static int mvebu_gpio_probe_raw(struct platform_device *pdev,
 
 		mvchip->percpu_regs =
 			devm_regmap_init_mmio(&pdev->dev, base,
-					      &mvebu_gpio_regmap_config);
+					      &mvebu_gpio_percpu_regmap_config);
 		if (IS_ERR(mvchip->percpu_regs))
 			return PTR_ERR(mvchip->percpu_regs);
 	}
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 074/555] gpio: mvebu: fix sleeping-while-atomic in mvebu_gpio_level_irq_mask()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (72 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 073/555] gpio: mvebu: name regmaps to fix debugfs collisions Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 075/555] gpio: keep the chip reference when deferred setup fails Greg Kroah-Hartman
                   ` (480 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Linus Walleij, Bartosz Golaszewski,
	Sasha Levin

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

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

From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

[ Upstream commit 42269cdb3d3b46ba6e80f31d0e00d0bdcff1d8d4 ]

mvebu_gpio_write_level_mask() is called with a raw spinlock taken but
the underlying regmap uses a standard spinlock which can sleep on
RT_PREEMPT kernels. Add the .use_raw_spinlock attribute to the
appropriate regmap config.

Cc: stable@vger.kernel.org
Fixes: 2233bf7a92e7 ("gpio: mvebu: switch to regmap for register access")
Fixes: 4d305c227312 ("gpio: mvebu: name regmaps to fix debugfs collisions")
Closes: https://sashiko.dev/#/bug/linux-6bee0c4f-384c-494c-868e-07c420195d13
Reviewed-by: Linus Walleij <linusw@kernel.org>
Link: https://patch.msgid.link/20261109-gpio-mvebu-sleeping-while-atomic-v2-1-41f070421e70@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpio/gpio-mvebu.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index 14023051eebe1..4b482d116d04c 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -607,6 +607,7 @@ static const struct regmap_config mvebu_gpio_regmap_config = {
 	.reg_bits = 32,
 	.reg_stride = 4,
 	.val_bits = 32,
+	.use_raw_spinlock = true,
 };
 
 static const struct regmap_config mvebu_gpio_percpu_regmap_config = {
@@ -614,6 +615,7 @@ static const struct regmap_config mvebu_gpio_percpu_regmap_config = {
 	.reg_bits = 32,
 	.reg_stride = 4,
 	.val_bits = 32,
+	.use_raw_spinlock = true,
 };
 
 static const struct regmap_config mvebu_pwm_regmap_config = {
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 075/555] gpio: keep the chip reference when deferred setup fails
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (73 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 074/555] gpio: mvebu: fix sleeping-while-atomic in mvebu_gpio_level_irq_mask() Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:01 ` [PATCH 6.12 076/555] mm/mmzone: read each zoneref slot once when filtering by nodemask Greg Kroah-Hartman
                   ` (479 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Wentao Liang, Bartosz Golaszewski,
	Sasha Levin

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

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

From: Wentao Liang <vulab@iscas.ac.cn>

[ Upstream commit 7e899fe007d2ffc753e6aa5bc8f2ae0a802b9e07 ]

gpiochip_setup_devs() runs once gpiolib has been initialized and
finishes the registration of the chips that were added before that.
When the registration of such a chip fails, the function drops the
reference taken in gpiochip_add_data_with_key() with
gpio_device_put(), and only then logs the error through &gdev->dev.

For these chips that reference is the last one, so gpiodev_release()
frees gdev: the dev_err() dereferences freed memory, and the chip is
still linked in gpio_devices, so the next lookup walks into the freed
object as well.  Here the registration cannot be undone the way
gpiochip_add_data_with_key() does it, as the driver already got success
from gpiochip_add_data() and will call gpiochip_remove(), which unlinks
the chip and drops the reference.

Keep the reference and only report the failure.

Fixes: 16fdabe143fc ("gpio: Fix resource leaks on errors in gpiochip_add_data_with_key()")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Link: https://patch.msgid.link/20261104025345.1527526-1-vulab@iscas.ac.cn
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
[ sashal: Adjusted the gpiochip_setup_dev() prototype and its call site to take struct gpio_device *gdev instead of struct gpio_chip *gc, since this tree has no per-chip gc lookup in that loop. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpio/gpiolib.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index c9dae5cf4db34..b3a557c41fa91 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -787,7 +787,8 @@ static const struct device_type gpio_dev_type = {
 
 /*
  * An initial reference count has been held in gpiochip_add_data_with_key().
- * The caller should drop the reference via gpio_device_put() on errors.
+ * A caller that tears the chip down on errors must drop the reference via
+ * gpio_device_put().
  */
 static int gpiochip_setup_dev(struct gpio_device *gdev)
 {
@@ -860,12 +861,16 @@ static void gpiochip_setup_devs(void)
 
 	list_for_each_entry_srcu(gdev, &gpio_devices, list,
 				 srcu_read_lock_held(&gpio_devices_srcu)) {
+		/*
+		 * The reference taken in gpiochip_add_data_with_key() is
+		 * dropped by gpiochip_remove(): this chip is still registered
+		 * and its driver has not been told about the failure, so the
+		 * reference must be kept here.
+		 */
 		ret = gpiochip_setup_dev(gdev);
-		if (ret) {
-			gpio_device_put(gdev);
+		if (ret)
 			dev_err(&gdev->dev,
 				"Failed to initialize gpio device (%d)\n", ret);
-		}
 	}
 }
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 076/555] mm/mmzone: read each zoneref slot once when filtering by nodemask
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (74 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 075/555] gpio: keep the chip reference when deferred setup fails Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 077/555] mm/page_alloc: retry allocations that raced with a zonelist rebuild Greg Kroah-Hartman
                   ` (478 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Gregory Price (Meta),
	Vlastimil Babka (SUSE), Zi Yan, Sasha Levin

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

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

From: Gregory Price (Meta) <gourry@gourry.net>

[ Upstream commit e55119ab611a0e47595db7e1d2ac1e69f7a73ff0 ]

__next_zones_zonelist() tests a slot's zone for NULL, then reads the
slot again to look up the zone's node. Offlining a zone's last block
rebuilds the zonelists in place, so the second read can return the
terminator:

  CPU 0                             CPU 1
  __next_zones_zonelist(nodemask)
    zonelist_zone(slot 1) = NORMAL
                                    offline_pages()
                                      build_all_zonelists()
                                        [MOVABLE, NORMAL, NULL]
                                        -> [NORMAL, NULL]
    zref_in_nodemask(slot 1)
      zone_to_nid(NULL)

Current GCC and clang merge the two reads, but nothing requires it.
With mm/mmzone.o built with -fno-inline -fno-ipa-sra, holding a
nodemask allocation between the reads while the node's last movable
block goes offline oopses every time:

  BUG: kernel NULL pointer dereference, address: 0000000000000060
  RIP: 0010:zone_to_nid+0x0/0x10
  Call Trace:
   zref_in_nodemask+0x9/0x20
   __next_zones_zonelist+0x23/0x70
   prepare_alloc_pages.constprop.0+0x16c/0x190
   __alloc_frozen_pages_noprof+0xaf/0x330

Read the slot once and test that zone. A NULL zone still ends the walk.
To achieve that, rename zref_in_nodemask() to zone_in_nodemask() and
pass a zone instead of zoneref pointer.

Fixes: 11cd8638c37f ("mm, page_alloc: remove stop_machine from build_all_zonelists")
Cc: stable@vger.kernel.org
Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Link: https://patch.msgid.link/20261101021340.2251928-8-gourry@gourry.net
Reviewed-by: Zi Yan <ziy@nvidia.com>
Signed-off-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
[ sashal: Helper's parameters stay non-const (struct zone *zone, nodemask_t *nodes) instead of upstream's const-qualified types, because zone_to_nid() here takes a non-const zone. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 mm/mmzone.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/mm/mmzone.c b/mm/mmzone.c
index f9baa8882fbf3..42a00132137de 100644
--- a/mm/mmzone.c
+++ b/mm/mmzone.c
@@ -43,12 +43,13 @@ struct zone *next_zone(struct zone *zone)
 	return zone;
 }
 
-static inline int zref_in_nodemask(struct zoneref *zref, nodemask_t *nodes)
+/* A NULL zone terminates the zonelist, so it ends the search. */
+static inline bool zone_in_nodemask(struct zone *zone, nodemask_t *nodes)
 {
 #ifdef CONFIG_NUMA
-	return node_isset(zonelist_node_idx(zref), *nodes);
+	return !zone || node_isset(zone_to_nid(zone), *nodes);
 #else
-	return 1;
+	return true;
 #endif /* CONFIG_NUMA */
 }
 
@@ -66,7 +67,7 @@ struct zoneref *__next_zones_zonelist(struct zoneref *z,
 			z++;
 	else
 		while (zonelist_zone_idx(z) > highest_zoneidx ||
-				(zonelist_zone(z) && !zref_in_nodemask(z, nodes)))
+		       !zone_in_nodemask(zonelist_zone(z), nodes))
 			z++;
 
 	return z;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 077/555] mm/page_alloc: retry allocations that raced with a zonelist rebuild
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (75 preceding siblings ...)
  2026-12-04 10:01 ` [PATCH 6.12 076/555] mm/mmzone: read each zoneref slot once when filtering by nodemask Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 078/555] mm/hugetlb: retry the pool walk when the zonelist is rebuilt Greg Kroah-Hartman
                   ` (477 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Gregory Price (Meta),
	Vlastimil Babka (SUSE), Sasha Levin

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

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

From: Gregory Price (Meta) <gourry@gourry.net>

[ Upstream commit bcfc8286f0cd5a74c827d502f9f1ad408d7eff30 ]

Onlining the first block of a zone rebuilds every zonelist in place,
shifting the slots after the new zone.  The iterator approves a slot,
then the allocator loads the zone from it, so a GFP_KERNEL request can
land in ZONE_MOVABLE and a nodemask request on a node outside its mask:

  CPU 0                             CPU 1
  prepare_alloc_pages()
    first_zones_zonelist(nodemask {1})
      slot 0 (NORMAL1) approved
                                    online_pages()
                                      build_all_zonelists()
                                        [NORMAL1, NORMAL2, ...]
                                        -> [MOVABLE1, NORMAL1, ...]
  get_page_from_freelist()
    zone = zonelist_zone(slot 0)    /* MOVABLE1 */
    allocates from MOVABLE1

zonelist_update_seq detects the rebuild, but only the slowpath's failure
exits check it.

Check it whenever an allocation succeeds too, and if it changed, free
the page and retry, as the memcg charge failure path does.  Eligible
pages are dropped as well: zonelists only change when memory comes or
goes, and a retry is simpler than rechecking the page.

Freeing the page does not undo a block the allocation claimed.  A
GFP_KERNEL request that lands in a fresh ZONE_MOVABLE converts a free
block to MIGRATE_UNMOVABLE, which stays until the zone's movable free
list runs out and a movable allocation takes it back.

The fast and bulk paths read the seqlock's raw seqcount without waiting:
an ALLOC_NOLOCK caller can be an NMI that interrupted the writer, and on
PREEMPT_RT the seqlock accessor takes the spinlock.  A sample taken
mid-write costs a retry, or NULL under ALLOC_NOLOCK.
check_retry_zonelist() returns 0 when compiled out, so a backport
without the hot-add change stays harmless.

Fixes: 11cd8638c37f ("mm, page_alloc: remove stop_machine from build_all_zonelists")
Cc: stable@vger.kernel.org
Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Link: https://patch.msgid.link/20261101021340.2251928-9-gourry@gourry.net
Signed-off-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
[ sashal: Replaced __free_frozen_pages() with __free_pages() and __alloc_frozen_pages_noprof() with __alloc_pages_noprof(), dropped the ALLOC_NOLOCK handling, and adjusted context for the older bulk-allocator code. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 mm/page_alloc.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index c34ec6a7ded68..461bb53e8b9dc 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4014,12 +4014,25 @@ static unsigned int zonelist_iter_begin(void)
 	return 0;
 }
 
+/*
+ * Never wait for the writer, which an ALLOC_NOLOCK caller in NMI may have
+ * interrupted. Read the raw seqcount: on PREEMPT_RT the seqlock accessor takes
+ * the spinlock while a write is in progress.
+ */
+static unsigned int zonelist_iter_sample(void)
+{
+	if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG))
+		return raw_seqcount_begin(&zonelist_update_seq.seqcount.seqcount);
+
+	return 0;
+}
+
 static unsigned int check_retry_zonelist(unsigned int seq)
 {
 	if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG))
 		return read_seqretry(&zonelist_update_seq, seq);
 
-	return seq;
+	return 0;
 }
 
 /* Perform direct synchronous page reclaim */
@@ -4644,6 +4657,12 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
 	warn_alloc(gfp_mask, ac->nodemask,
 			"page allocation failure: order:%u", order);
 got_pg:
+	/* A rebuild during the walk may have handed out an ineligible zone. */
+	if (page && check_retry_zonelist(zonelist_iter_cookie)) {
+		__free_pages(page, order);
+		page = NULL;
+		goto restart;
+	}
 	return page;
 }
 
@@ -4725,6 +4744,7 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
 	struct alloc_context ac;
 	gfp_t alloc_gfp;
 	unsigned int alloc_flags = ALLOC_WMARK_LOW;
+	unsigned int zonelist_iter_cookie;
 	int nr_populated = 0, nr_account = 0;
 
 	/*
@@ -4765,6 +4785,7 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
 	/* May set ALLOC_NOFRAGMENT, fragmentation will return 1 page. */
 	gfp &= gfp_allowed_mask;
 	alloc_gfp = gfp;
+	zonelist_iter_cookie = zonelist_iter_sample();
 	if (!prepare_alloc_pages(gfp, 0, preferred_nid, nodemask, &ac, &alloc_gfp, &alloc_flags))
 		goto out;
 	gfp = alloc_gfp;
@@ -4815,6 +4836,10 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
 	if (unlikely(!zone))
 		goto failed;
 
+	/* The zone was chosen from a zonelist that a rebuild may have changed. */
+	if (unlikely(check_retry_zonelist(zonelist_iter_cookie)))
+		goto failed;
+
 	/* spin_trylock may fail due to a parallel drain or IRQ reentrancy. */
 	pcp_trylock_prepare(UP_flags);
 	pcp = pcp_spin_trylock(zone->per_cpu_pageset);
@@ -4887,6 +4912,7 @@ struct page *__alloc_pages_noprof(gfp_t gfp, unsigned int order,
 	unsigned int alloc_flags = ALLOC_WMARK_LOW;
 	gfp_t alloc_gfp; /* The gfp_t that was actually used for allocation */
 	struct alloc_context ac = { };
+	unsigned int zonelist_iter_cookie;
 
 	/*
 	 * There are several places where we assume that the order value is sane
@@ -4905,6 +4931,7 @@ struct page *__alloc_pages_noprof(gfp_t gfp, unsigned int order,
 	 */
 	gfp = current_gfp_context(gfp);
 	alloc_gfp = gfp;
+	zonelist_iter_cookie = zonelist_iter_sample();
 	if (!prepare_alloc_pages(gfp, order, preferred_nid, nodemask, &ac,
 			&alloc_gfp, &alloc_flags))
 		return NULL;
@@ -4918,6 +4945,10 @@ struct page *__alloc_pages_noprof(gfp_t gfp, unsigned int order,
 
 	/* First allocation attempt */
 	page = get_page_from_freelist(alloc_gfp, order, alloc_flags, &ac);
+	if (likely(page) && unlikely(check_retry_zonelist(zonelist_iter_cookie))) {
+		__free_pages(page, order);
+		page = NULL;
+	}
 	if (likely(page))
 		goto out;
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 078/555] mm/hugetlb: retry the pool walk when the zonelist is rebuilt
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (76 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 077/555] mm/page_alloc: retry allocations that raced with a zonelist rebuild Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 079/555] kprobes: Fix error return and slot leak in __register_kprobe() Greg Kroah-Hartman
                   ` (476 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Gregory Price (Meta),
	Vlastimil Babka (SUSE), Sasha Levin

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

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

From: Gregory Price (Meta) <gourry@gourry.net>

[ Upstream commit 9f6674f842bbceda8326cf4e494af5ad3a5a05e6 ]

Onlining the first block of a zone rebuilds every zonelist in place,
shifting the slots after the new zone.  dequeue_hugetlb_folio_nodemask()
approves a slot by its node, then loads the zone from it, so a hugetlb
fault bound to one node can take a pool page from another:

  CPU 0                             CPU 1
  dequeue_hugetlb_folio_nodemask(nodemask {2})
    slot 3 (NORMAL2) approved
                                    online_pages()
                                      build_all_zonelists()
                                        [.., NORMAL1, NORMAL2]
                                        -> [.., MOVABLE1, NORMAL1, ...]
    zone = zonelist_zone(slot 3)    /* NORMAL1 */
    dequeue_hugetlb_folio_node_exact(h, 1)

Check zonelist_update_seq before using each zone, and on the way out
with nothing found, and restart the walk if it changed.  Checking before
the dequeue leaves nothing to put back.  Reset the last-tried node on
restart, so it is not skipped.

With kprobes holding the walk across the online, a fault bound to node 2
took a node 1 page in 3 of 3 runs, and a node 2 page in 3 of 3 with this
change.

Fixes: 11cd8638c37f ("mm, page_alloc: remove stop_machine from build_all_zonelists")
Cc: stable@vger.kernel.org
Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
Link: https://patch.msgid.link/20261101021340.2251928-10-gourry@gourry.net
Signed-off-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
[ sashal: moved the zonelist_update_seq declaration and retry helpers into mm/internal.h (page_alloc.h doesn't exist here). ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 mm/hugetlb.c    | 13 ++++++++++---
 mm/internal.h   | 19 +++++++++++++++++++
 mm/page_alloc.c | 18 +-----------------
 3 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 19186b66bbc75..83e81c8d1b2a6 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1372,11 +1372,11 @@ static struct folio *dequeue_hugetlb_folio_node_exact(struct hstate *h,
 static struct folio *dequeue_hugetlb_folio_nodemask(struct hstate *h, gfp_t gfp_mask,
 							int nid, nodemask_t *nmask)
 {
-	unsigned int cpuset_mems_cookie;
+	unsigned int cpuset_mems_cookie, zonelist_cookie;
 	struct zonelist *zonelist;
 	struct zone *zone;
 	struct zoneref *z;
-	int node = NUMA_NO_NODE;
+	int node;
 
 	/* 'nid' should not be NUMA_NO_NODE. Try to catch any misuse of it and rectifiy. */
 	if (nid == NUMA_NO_NODE)
@@ -1385,10 +1385,16 @@ static struct folio *dequeue_hugetlb_folio_nodemask(struct hstate *h, gfp_t gfp_
 	zonelist = node_zonelist(nid, gfp_mask);
 
 retry_cpuset:
+	node = NUMA_NO_NODE;
 	cpuset_mems_cookie = read_mems_allowed_begin();
+	zonelist_cookie = zonelist_iter_begin();
 	for_each_zone_zonelist_nodemask(zone, z, zonelist, gfp_zone(gfp_mask), nmask) {
 		struct folio *folio;
 
+		/* A rebuild may have shifted a node outside @nmask into this slot. */
+		if (unlikely(check_retry_zonelist(zonelist_cookie)))
+			goto retry_cpuset;
+
 		if (!cpuset_zone_allowed(zone, gfp_mask))
 			continue;
 		/*
@@ -1403,7 +1409,8 @@ static struct folio *dequeue_hugetlb_folio_nodemask(struct hstate *h, gfp_t gfp_
 		if (folio)
 			return folio;
 	}
-	if (unlikely(read_mems_allowed_retry(cpuset_mems_cookie)))
+	if (unlikely(read_mems_allowed_retry(cpuset_mems_cookie) ||
+		     check_retry_zonelist(zonelist_cookie)))
 		goto retry_cpuset;
 
 	return NULL;
diff --git a/mm/internal.h b/mm/internal.h
index 41a0b79fd71d3..85f60a77f550b 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -14,6 +14,7 @@
 #include <linux/pagemap.h>
 #include <linux/pagewalk.h>
 #include <linux/rmap.h>
+#include <linux/seqlock.h>
 #include <linux/swap.h>
 #include <linux/swapops.h>
 #include <linux/swap_cgroup.h>
@@ -742,6 +743,24 @@ extern void zone_pcp_disable(struct zone *zone);
 extern void zone_pcp_enable(struct zone *zone);
 extern void zone_pcp_init(struct zone *zone);
 
+extern seqlock_t zonelist_update_seq;
+
+static inline unsigned int zonelist_iter_begin(void)
+{
+	if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG))
+		return read_seqbegin(&zonelist_update_seq);
+
+	return 0;
+}
+
+static inline unsigned int check_retry_zonelist(unsigned int seq)
+{
+	if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG))
+		return read_seqretry(&zonelist_update_seq, seq);
+
+	return 0;
+}
+
 extern void *memmap_alloc(phys_addr_t size, phys_addr_t align,
 			  phys_addr_t min_addr,
 			  int nid, bool exact_nid);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 461bb53e8b9dc..cb8c76ebb8897 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4004,15 +4004,7 @@ EXPORT_SYMBOL_GPL(fs_reclaim_release);
  * retries the allocation if zonelist changes. Writer side is protected by the
  * embedded spin_lock.
  */
-static DEFINE_SEQLOCK(zonelist_update_seq);
-
-static unsigned int zonelist_iter_begin(void)
-{
-	if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG))
-		return read_seqbegin(&zonelist_update_seq);
-
-	return 0;
-}
+DEFINE_SEQLOCK(zonelist_update_seq);
 
 /*
  * Never wait for the writer, which an ALLOC_NOLOCK caller in NMI may have
@@ -4027,14 +4019,6 @@ static unsigned int zonelist_iter_sample(void)
 	return 0;
 }
 
-static unsigned int check_retry_zonelist(unsigned int seq)
-{
-	if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG))
-		return read_seqretry(&zonelist_update_seq, seq);
-
-	return 0;
-}
-
 /* Perform direct synchronous page reclaim */
 static unsigned long
 __perform_reclaim(gfp_t gfp_mask, unsigned int order,
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 079/555] kprobes: Fix error return and slot leak in __register_kprobe()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (77 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 078/555] mm/hugetlb: retry the pool walk when the zonelist is rebuilt Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 080/555] page_alloc: allow migration of smaller hugepages during contig_alloc Greg Kroah-Hartman
                   ` (475 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Masami Hiramatsu (Google),
	Sasha Levin

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

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

From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

[ Upstream commit 6a658cc2d605e5acf35e638c62f480460d5939cd ]

When arm_kprobe() fails in __register_kprobe(), the probe is removed
from kprobe_table and synchronize_rcu() is executed, but the error code
ret was ignored and try_to_optimize_kprobe(p) was executed, returning 0.
Additionally, the instruction slot allocated by prepare_kprobe() was
leaked.

Fix this by releasing the instruction slot via arch_remove_kprobe(p)
and returning ret when arm_kprobe() fails.

Link: https://lore.kernel.org/all/179375030756.247640.10859474201266455798.stgit@devnote2/

Fixes: 587e8e6d640b ("kprobes: Adopt guard() and scoped_guard()")
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/kprobes.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 585ddaf8a6af4..7c684df3110de 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1654,6 +1654,8 @@ static int __register_kprobe(struct kprobe *p)
 		if (ret) {
 			hlist_del_rcu(&p->hlist);
 			synchronize_rcu();
+			arch_remove_kprobe(p);
+			return ret;
 		}
 	}
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 080/555] page_alloc: allow migration of smaller hugepages during contig_alloc
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (78 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 079/555] kprobes: Fix error return and slot leak in __register_kprobe() Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 081/555] mm/page_alloc: retry alloc_contig_pages() when the zonelist is rebuilt Greg Kroah-Hartman
                   ` (474 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Gregory Price, David Hildenbrand,
	Zi Yan, Wei Yang, Michal Hocko, David Hildenbrand (Red Hat),
	Brendan Jackman, Johannes Weiner, Suren Baghdasaryan,
	Vlastimil Babka, Andrew Morton, Sasha Levin

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

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

From: Gregory Price <gourry@gourry.net>

[ Upstream commit 3bb64898f00368cd110d4b31334f93251d56b404 ]

We presently skip regions with hugepages entirely when trying to do
contiguous page allocation.  This will cause otherwise-movable 2MB HugeTLB
pages to be considered unmovable, and makes 1GB gigantic page allocation
less reliable on systems utilizing both.

Commit 4d73ba5fa710 ("mm: page_alloc: skip regions with hugetlbfs pages
when allocating 1G pages") skipped all HugePage containing regions because
it can cause significant delays in 1G allocation (as HugeTLB migrations
may fail for a number of reasons).

Instead, if hugepage migration is enabled, consider regions with hugepages
smaller than the target contiguous allocation request as valid targets for
allocation.

We optimize for the existing behavior by searching for non-hugetlb regions
in a first pass, then retrying the search to include hugetlb only on
failure.  This allows the existing fast-path to remain the default case
with a slow-path fallback to increase reliability.

We only fallback to the slow path if a hugetlb region was detected, and we
do a full re-scan because the zones/blocks may have changed during the
first pass (and it's not worth further complexity).

isolate_migrate_pages_block() has similar hugetlb filter logic, and the
hugetlb code does a migratable check in folio_isolate_hugetlb() during
isolation.  The code servicing the allocation and migration already
supports this exact use case.

To test, allocate a bunch of 2MB HugeTLB pages (in this case 48GB) and
then attempt to allocate some 1G HugeTLB pages (in this case 4GB) (Scale
to your machine's memory capacity).

echo 24576 > .../hugepages-2048kB/nr_hugepages
echo 4 > .../hugepages-1048576kB/nr_hugepages

Prior to this patch, the 1GB page reservation can fail if no contiguous
1GB pages remain.  After this patch, the kernel will try to move 2MB pages
and successfully allocate the 1GB pages (assuming overall sufficient
memory is available).  Also tested this while a program had the 2MB
reservations mapped, and the 1GB reservation still succeeds.

folio_alloc_gigantic() is the primary user of alloc_contig_pages(),
other users are debug or init-time allocations and largely unaffected.
- ppc/memtrace is a debugfs interface
- x86/tdx memory allocation occurs once on module-init
- kfence/core happens once on module (late) init
- THP uses it in debug_vm_pgtable_alloc_huge_page at __init time

Link: https://lkml.kernel.org/r/20251221124656.2362540-1-gourry@gourry.net
Signed-off-by: Gregory Price <gourry@gourry.net>
Suggested-by: David Hildenbrand <david@redhat.com>
Link: https://lore.kernel.org/linux-mm/6fe3562d-49b2-4975-aa86-e139c535ad00@redhat.com/
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: David Hildenbrand (Red Hat) <david@kernel.org>
Cc: Brendan Jackman <jackmanb@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Stable-dep-of: da0d7a895e90 ("mm/page_alloc: retry alloc_contig_pages() when the zonelist is rebuilt")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 mm/page_alloc.c | 59 +++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 55 insertions(+), 4 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index cb8c76ebb8897..a41af77b94c47 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6913,7 +6913,8 @@ static int __alloc_contig_pages(unsigned long start_pfn,
 }
 
 static bool pfn_range_valid_contig(struct zone *z, unsigned long start_pfn,
-				   unsigned long nr_pages)
+				   unsigned long nr_pages, bool skip_hugetlb,
+				   bool *skipped_hugetlb)
 {
 	unsigned long i, end_pfn = start_pfn + nr_pages;
 	struct page *page;
@@ -6929,8 +6930,42 @@ static bool pfn_range_valid_contig(struct zone *z, unsigned long start_pfn,
 		if (PageReserved(page))
 			return false;
 
-		if (PageHuge(page))
-			return false;
+		/*
+		 * Only consider ranges containing hugepages if those pages are
+		 * smaller than the requested contiguous region.  e.g.:
+		 *     Move 2MB pages to free up a 1GB range.
+		 *     Don't move 1GB pages to free up a 2MB range.
+		 *
+		 * This makes contiguous allocation more reliable if multiple
+		 * hugepage sizes are used without causing needless movement.
+		 */
+		if (PageHuge(page)) {
+			unsigned int order;
+
+			if (!IS_ENABLED(CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION))
+				return false;
+
+			if (skip_hugetlb) {
+				*skipped_hugetlb = true;
+				return false;
+			}
+
+			page = compound_head(page);
+			order = compound_order(page);
+			if ((order >= MAX_FOLIO_ORDER) ||
+			    (nr_pages <= (1 << order)))
+				return false;
+
+			/*
+			 * Reaching this point means we've encounted a huge page
+			 * smaller than nr_pages, skip all pfn's for that page.
+			 *
+			 * We can't get here from a tail-PageHuge, as it implies
+			 * we started a scan in the middle of a hugepage larger
+			 * than nr_pages - which the prior check filters for.
+			 */
+			i += (1 << order) - 1;
+		}
 	}
 	return true;
 }
@@ -6973,7 +7008,10 @@ struct page *alloc_contig_pages_noprof(unsigned long nr_pages, gfp_t gfp_mask,
 	struct zonelist *zonelist;
 	struct zone *zone;
 	struct zoneref *z;
+	bool skip_hugetlb = true;
+	bool skipped_hugetlb = false;
 
+retry:
 	zonelist = node_zonelist(nid, gfp_mask);
 	for_each_zone_zonelist_nodemask(zone, z, zonelist,
 					gfp_zone(gfp_mask), nodemask) {
@@ -6981,7 +7019,9 @@ struct page *alloc_contig_pages_noprof(unsigned long nr_pages, gfp_t gfp_mask,
 
 		pfn = ALIGN(zone->zone_start_pfn, nr_pages);
 		while (zone_spans_last_pfn(zone, pfn, nr_pages)) {
-			if (pfn_range_valid_contig(zone, pfn, nr_pages)) {
+			if (pfn_range_valid_contig(zone, pfn, nr_pages,
+						   skip_hugetlb,
+						   &skipped_hugetlb)) {
 				/*
 				 * We release the zone lock here because
 				 * alloc_contig_range() will also lock the zone
@@ -7000,6 +7040,17 @@ struct page *alloc_contig_pages_noprof(unsigned long nr_pages, gfp_t gfp_mask,
 		}
 		spin_unlock_irqrestore(&zone->lock, flags);
 	}
+	/*
+	 * If we failed, retry the search, but treat regions with HugeTLB pages
+	 * as valid targets.  This retains fast-allocations on first pass
+	 * without trying to migrate HugeTLB pages (which may fail). On the
+	 * second pass, we will try moving HugeTLB pages when those pages are
+	 * smaller than the requested contiguous region size.
+	 */
+	if (skip_hugetlb && skipped_hugetlb) {
+		skip_hugetlb = false;
+		goto retry;
+	}
 	return NULL;
 }
 #endif /* CONFIG_CONTIG_ALLOC */
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 081/555] mm/page_alloc: retry alloc_contig_pages() when the zonelist is rebuilt
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (79 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 080/555] page_alloc: allow migration of smaller hugepages during contig_alloc Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 082/555] mm/page_alloc: dont undo another isolation in alloc_contig_range Greg Kroah-Hartman
                   ` (473 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Gregory Price (Meta),
	Vlastimil Babka (SUSE), Zi Yan, Sasha Levin

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

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

From: Gregory Price (Meta) <gourry@gourry.net>

[ Upstream commit da0d7a895e9021dc2cffa90fb6fafd8b9379e544 ]

Onlining the first block of a zone rebuilds every zonelist in place,
shifting the slots after the new zone.
alloc_contig_frozen_pages_noprof() approves a slot by the caller's gfp
and nodemask, then loads the zone from it:

  CPU 0                             CPU 1
  alloc_contig_frozen_pages_noprof(GFP_HIGHUSER | __GFP_THISNODE)
    slot 0 (NORMAL1) approved
                                    online_pages()
                                      build_all_zonelists()
                                        [NORMAL1]
                                        -> [MOVABLE1, NORMAL1]
    zone = zonelist_zone(slot 0)    /* MOVABLE1 */
    alloc_contig_frozen_range(MOVABLE1 pfns)

A gigantic hugetlb page can then land in ZONE_MOVABLE, and a nodemask
caller can get a range from another node.  Gigantic pages are kept out
of ZONE_MOVABLE since commit 79b63f12abcb ("mm, hugetlb: do not allocate
non-migrateable gigantic pages from movable zones").

Check zonelist_update_seq before using each zone, and restart the walk
if it changed, as the hugetlb pool walk does.  Check again before
escalating to the pass that may migrate hugetlb pages, so a pass a
rebuild cut short is redone rather than escalated.

With kprobes holding the walk across the online, the base kernel put the
1G page in ZONE_MOVABLE in 3 of 3 runs, and this change put it in
ZONE_NORMAL in 3 of 3.  Direct GFP_KERNEL calls with nodemask {1} and
{2} got a ZONE_MOVABLE range and a node 1 range on base, 3 of 3 each,
and neither with this change.

Fixes: 5e27a2df03b8 ("mm/page_alloc: add alloc_contig_pages()")
Cc: stable@vger.kernel.org
Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Link: https://patch.msgid.link/20261101021340.2251928-11-gourry@gourry.net
Acked-by: Zi Yan <ziy@nvidia.com>
Signed-off-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 mm/page_alloc.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index a41af77b94c47..6aada2df1a1c0 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -7005,6 +7005,7 @@ struct page *alloc_contig_pages_noprof(unsigned long nr_pages, gfp_t gfp_mask,
 				 int nid, nodemask_t *nodemask)
 {
 	unsigned long ret, pfn, flags;
+	unsigned int zonelist_cookie;
 	struct zonelist *zonelist;
 	struct zone *zone;
 	struct zoneref *z;
@@ -7013,8 +7014,13 @@ struct page *alloc_contig_pages_noprof(unsigned long nr_pages, gfp_t gfp_mask,
 
 retry:
 	zonelist = node_zonelist(nid, gfp_mask);
+	zonelist_cookie = zonelist_iter_begin();
 	for_each_zone_zonelist_nodemask(zone, z, zonelist,
 					gfp_zone(gfp_mask), nodemask) {
+		/* A rebuild may have shifted an ineligible zone into this slot. */
+		if (unlikely(check_retry_zonelist(zonelist_cookie)))
+			goto retry;
+
 		spin_lock_irqsave(&zone->lock, flags);
 
 		pfn = ALIGN(zone->zone_start_pfn, nr_pages);
@@ -7047,6 +7053,9 @@ struct page *alloc_contig_pages_noprof(unsigned long nr_pages, gfp_t gfp_mask,
 	 * second pass, we will try moving HugeTLB pages when those pages are
 	 * smaller than the requested contiguous region size.
 	 */
+	/* Redo a pass that a rebuild cut short before escalating. */
+	if (unlikely(check_retry_zonelist(zonelist_cookie)))
+		goto retry;
 	if (skip_hugetlb && skipped_hugetlb) {
 		skip_hugetlb = false;
 		goto retry;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 082/555] mm/page_alloc: dont undo another isolation in alloc_contig_range
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (80 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 081/555] mm/page_alloc: retry alloc_contig_pages() when the zonelist is rebuilt Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 083/555] mm/page_alloc: remove the zone_spans_pfn() check from get_pfnblock_bitmap_bitidx() Greg Kroah-Hartman
                   ` (472 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Gregory Price (Meta), Zi Yan,
	Vlastimil Babka (SUSE), Sasha Levin

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

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

From: Gregory Price (Meta) <gourry@gourry.net>

[ Upstream commit 7d9c29ed8feec8bfbe5e5f673ba2b5926da11375 ]

An alloc_contig_range() that overlaps a block going offline can leave
the offline spinning until it gets a signal, holding the device hotplug
lock.  When isolation fails, alloc_contig_frozen_range() undoes it over
the whole range, clearing the offline's MIGRATE_ISOLATE too:

  CPU 1 (offline_pages)               CPU 2 (alloc_contig_range)
  start_isolate_page_range()
    blocks are MIGRATE_ISOLATE
                                      start_isolate_page_range()
                                        -EBUSY on CPU 1's blocks
                                      undo_isolate_page_range()
                                        blocks are MIGRATE_MOVABLE
  test_pages_isolated()
    never succeeds again

start_isolate_page_range() fails only on a block someone else isolated,
after undoing its own, so this undo only ever clears another caller's.
Return directly, as before alloc_contig_range() went pageblock granular.

With offline_pages() parked after isolating a DIMM block and a 1G
hugetlb allocation made over it, the offline on base still loops 30s
later in 4 of 4 runs:

  offline_pages+0x5b2/0x1570
  memory_subsys_offline+0x17e/0x470
  device_offline+0x250/0x340
  state_store+0x88/0x110

With this patch the allocation still fails, and the offline completes in
3 of 3 runs.

Fixes: b2c9e2fbba32 ("mm: make alloc_contig_range work at pageblock granularity")
Cc: stable@vger.kernel.org
Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
Link: https://patch.msgid.link/20261027042204.3741307-5-gourry@gourry.net
Reviewed-by: Zi Yan <ziy@nvidia.com>
Signed-off-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
[ sashal: Adjusted the context to match the existing five-argument start_isolate_page_range() call in alloc_contig_range_noprof(). ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 mm/page_alloc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 6aada2df1a1c0..9615e2b3def5b 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6817,9 +6817,13 @@ int alloc_contig_range_noprof(unsigned long start, unsigned long end,
 	 * put back to page allocator so that buddy can use them.
 	 */
 
+	/*
+	 * On failure this has undone its own isolation, and any other
+	 * isolated blocks in the range belong to someone else, e.g. offline.
+	 */
 	ret = start_isolate_page_range(start, end, migratetype, 0, gfp_mask);
 	if (ret)
-		goto done;
+		return ret;
 
 	drain_all_pages(cc.zone);
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 083/555] mm/page_alloc: remove the zone_spans_pfn() check from get_pfnblock_bitmap_bitidx()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (81 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 082/555] mm/page_alloc: dont undo another isolation in alloc_contig_range Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 084/555] Bluetooth: L2CAP: Only accept LE responses to outstanding requests Greg Kroah-Hartman
                   ` (471 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Josef Bacik, Vlastimil Babka (SUSE),
	Sasha Levin

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

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

From: Vlastimil Babka (SUSE) <vbabka@kernel.org>

[ Upstream commit 2122887b04f3f2d76daa80055c2c273926032fa0 ]

Whenever the flags of a pageblock are read or written, a kernel with
CONFIG_DEBUG_VM makes sure that the pfn lies within the zone of the page.
Unlike bad_range(), that check reads zone->zone_start_pfn and
zone->spanned_pages without zone->span_seqlock.

Memory hotplug changes the two fields one after the other. If the lower
end of a zone moves, the zone seems to end before its last pages in
between. A page of that part which is freed at that moment, on another
CPU, ends in

  page dumped because: VM_BUG_ON_PAGE(!zone_spans_pfn(page_zone(page), pfn))
  kernel BUG at mm/page_alloc.c:372!
   free_unref_folios+0x55e/0xed0
   folios_put_refs+0x2b5/0x530

An attempt has been made [1] to fix this with the span seqlock check.
But that can trigger all sorts of problems in restricted contexts, as
noted by sashiko [2].

Since this is just a sanity debug check and anything with BUG_ON is
frowned upon anyway, just remove it altogether.

Reported-by: Josef Bacik <josef@toxicpanda.com>
Closes: https://lore.kernel.org/all/20261027-pgalloc-ai-hotfixes-v1-9-9c7d1aca801e@kernel.org/ [1]
Link: https://lore.kernel.org/all/sashiko-outbox-188081@kernel.org/ [2]
Fixes: 86051ca5eaf5 ("mm: fix usemap initialization")
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261103-pgalloc-ai-hotfixes-v2-5-e0d2890ab74f@kernel.org
Signed-off-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
[ sashal: Retargeted the zone-span assertion removal from get_pfnblock_bitmap_bitidx() to set_pfnblock_flags_mask(). ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 mm/page_alloc.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 9615e2b3def5b..f3383313d6d80 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -435,8 +435,6 @@ void set_pfnblock_flags_mask(struct page *page, unsigned long flags,
 	word_bitidx = bitidx / BITS_PER_LONG;
 	bitidx &= (BITS_PER_LONG-1);
 
-	VM_BUG_ON_PAGE(!zone_spans_pfn(page_zone(page), pfn), page);
-
 	mask <<= bitidx;
 	flags <<= bitidx;
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 084/555] Bluetooth: L2CAP: Only accept LE responses to outstanding requests
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (82 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 083/555] mm/page_alloc: remove the zone_spans_pfn() check from get_pfnblock_bitmap_bitidx() Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 085/555] kprobes: Validate re-registration earlier in register_kretprobe() Greg Kroah-Hartman
                   ` (470 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Zhao Li, Luiz Augusto von Dentz,
	Sasha Levin

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

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

From: Zhao Li <enderaoelyther@gmail.com>

[ Upstream commit f50b32aa233d4687af2d241ddcb572da969e8989 ]

The LE and ECRED response handlers match channels by identifier without
checking whether they sent the request. An incoming channel stores the
identifier chosen by the peer, so an unsolicited response can bypass
deferred setup, delete an established channel, or leave an unaccepted
socket and channel allocated after l2cap_chan_del().

Extend the BR/EDR lookup from commit a518b9a9ef6e ("Bluetooth: L2CAP:
Only accept connection responses to outstanding requests") to LE.
Require the matching connect-request flag and add a reconfigure-request
flag. Check reconfigure identifiers under the channel lock, since
BT_RCVMTU can replace a request without the connection lock. Match all
members of a rejected ECRED request, which share one identifier.

A reconfigure request can outlive close(). Complete it even in
BT_DISCONN, and call the close callback after deletion to release an
orphaned socket. Otherwise deletion cancels the timer and removes the
channel before the disconnect response or the channel timeout can close
it.

AI assistance was used.

Fixes: f1496dee9cbd ("Bluetooth: Add initial code for LE L2CAP Connect Request")
Fixes: 71fb419724fa ("Bluetooth: Fix handling of L2CAP Command Reject over LE")
Fixes: 15f02b910562 ("Bluetooth: L2CAP: Add initial code for Enhanced Credit Based Mode")
Cc: <stable@vger.kernel.org> # 5.7.x: a518b9a9ef6e: Bluetooth: L2CAP: Only accept connection responses to outstanding requests
Cc: <stable@vger.kernel.org> # 5.7.x
Signed-off-by: Zhao Li <enderaoelyther@gmail.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
[ sashal: Dropped the __must_hold(&conn->lock) annotations and lockdep_assert_held() calls, and adjusted context in the reconf and command-reject handlers to match the older tree's code. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/net/bluetooth/l2cap.h |  1 +
 net/bluetooth/l2cap_core.c    | 78 +++++++++++++++++------------------
 2 files changed, 40 insertions(+), 39 deletions(-)

diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 76931a189701d..784f28410298b 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -752,6 +752,7 @@ enum {
 	FLAG_DEFER_SETUP,
 	FLAG_LE_CONN_REQ_SENT,
 	FLAG_ECRED_CONN_REQ_SENT,
+	FLAG_ECRED_RECONF_REQ_SENT,
 	FLAG_PENDING_SECURITY,
 	FLAG_HOLD_HCI_CONN,
 	FLAG_DEL,
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 275454b34366e..0deb94b8b13f2 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -149,23 +149,12 @@ static struct l2cap_chan *l2cap_get_chan_by_dcid(struct l2cap_conn *conn,
 	return c;
 }
 
-static struct l2cap_chan *__l2cap_get_chan_by_ident(struct l2cap_conn *conn,
-						    u8 ident)
-{
-	struct l2cap_chan *c;
-
-	list_for_each_entry(c, &conn->chan_l, list) {
-		if (c->ident == ident)
-			return c;
-	}
-	return NULL;
-}
-
 /* Our connection request has been sent and is still outstanding */
 static bool l2cap_chan_connect_pending(struct l2cap_chan *chan)
 {
 	return chan->state == BT_CONNECT &&
-	       test_bit(CONF_CONNECT_PEND, &chan->conf_state);
+	       (test_bit(CONF_CONNECT_PEND, &chan->conf_state) ||
+		test_bit(FLAG_LE_CONN_REQ_SENT, &chan->flags));
 }
 
 /* Other channels may hold the same ident for a response they still have
@@ -177,7 +166,7 @@ static struct l2cap_chan *__l2cap_get_connect_chan_by_ident(struct l2cap_conn *c
 	struct l2cap_chan *c;
 
 	list_for_each_entry(c, &conn->chan_l, list) {
-		if (c->ident == ident && l2cap_chan_connect_pending(c))
+		if (l2cap_chan_connect_pending(c) && c->ident == ident)
 			return c;
 	}
 	return NULL;
@@ -4887,7 +4876,7 @@ static int l2cap_le_connect_rsp(struct l2cap_conn *conn,
 	BT_DBG("dcid 0x%4.4x mtu %u mps %u credits %u result 0x%2.2x",
 	       dcid, mtu, mps, credits, result);
 
-	chan = __l2cap_get_chan_by_ident(conn, cmd->ident);
+	chan = __l2cap_get_connect_chan_by_ident(conn, cmd->ident);
 	if (!chan)
 		return -EBADSLT;
 
@@ -5429,9 +5418,10 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn,
 		struct l2cap_chan *orig;
 		u16 dcid;
 
-		if (chan->ident != cmd->ident ||
+		if (chan->state != BT_CONNECT ||
 		    chan->mode != L2CAP_MODE_EXT_FLOWCTL ||
-		    chan->state == BT_CONNECTED)
+		    !test_bit(FLAG_ECRED_CONN_REQ_SENT, &chan->flags) ||
+		    chan->ident != cmd->ident)
 			continue;
 
 		l2cap_chan_hold(chan);
@@ -5646,23 +5636,24 @@ static inline int l2cap_ecred_reconf_rsp(struct l2cap_conn *conn,
 
 	BT_DBG("result 0x%4.4x", result);
 
-	if (!result) {
-		list_for_each_entry(chan, &conn->chan_l, list) {
-			if (chan->ident == cmd->ident)
-				chan->ident = 0;
-		}
-		return 0;
-	}
-
 	list_for_each_entry_safe(chan, tmp, &conn->chan_l, list) {
-		if (chan->ident != cmd->ident)
+		/* Reconfiguration updates ident with only chan->lock held. */
+		if (data_race(READ_ONCE(chan->ident)) != cmd->ident)
 			continue;
 
 		if (!l2cap_chan_hold_unless_zero(chan))
 			continue;
 		l2cap_chan_lock(chan);
 
-		l2cap_chan_del(chan, ECONNRESET);
+		if (chan->ident == cmd->ident &&
+		    test_and_clear_bit(FLAG_ECRED_RECONF_REQ_SENT, &chan->flags)) {
+			if (result) {
+				l2cap_chan_del(chan, ECONNRESET);
+				chan->ops->close(chan);
+			} else {
+				chan->ident = 0;
+			}
+		}
 
 		l2cap_chan_unlock(chan);
 		l2cap_chan_put(chan);
@@ -5676,25 +5667,33 @@ static inline int l2cap_le_command_rej(struct l2cap_conn *conn,
 				       u8 *data)
 {
 	struct l2cap_cmd_rej_unk *rej = (struct l2cap_cmd_rej_unk *) data;
-	struct l2cap_chan *chan;
+	struct l2cap_chan *chan, *tmp;
 
 	if (cmd_len < sizeof(*rej))
 		return -EPROTO;
 
-	chan = __l2cap_get_chan_by_ident(conn, cmd->ident);
-	if (!chan)
-		goto done;
+	list_for_each_entry_safe(chan, tmp, &conn->chan_l, list) {
+		/* Reconfiguration updates ident with only chan->lock held. */
+		if (data_race(READ_ONCE(chan->ident)) != cmd->ident)
+			continue;
 
-	chan = l2cap_chan_hold_unless_zero(chan);
-	if (!chan)
-		goto done;
+		if (!l2cap_chan_hold_unless_zero(chan))
+			continue;
 
-	l2cap_chan_lock(chan);
-	l2cap_chan_del(chan, ECONNREFUSED);
-	l2cap_chan_unlock(chan);
-	l2cap_chan_put(chan);
+		l2cap_chan_lock(chan);
+		if (chan->ident == cmd->ident &&
+		    ((chan->state == BT_CONNECT &&
+		      (test_bit(FLAG_LE_CONN_REQ_SENT, &chan->flags) ||
+		       test_bit(FLAG_ECRED_CONN_REQ_SENT, &chan->flags))) ||
+		     test_bit(FLAG_ECRED_RECONF_REQ_SENT, &chan->flags))) {
+			l2cap_chan_del(chan, ECONNREFUSED);
+			chan->ops->close(chan);
+		}
+
+		l2cap_chan_unlock(chan);
+		l2cap_chan_put(chan);
+	}
 
-done:
 	return 0;
 }
 
@@ -7536,6 +7535,7 @@ static void l2cap_ecred_reconfigure(struct l2cap_chan *chan)
 	pdu->scid[0] = cpu_to_le16(chan->scid);
 
 	chan->ident = l2cap_get_ident(conn);
+	set_bit(FLAG_ECRED_RECONF_REQ_SENT, &chan->flags);
 
 	l2cap_send_cmd(conn, chan->ident, L2CAP_ECRED_RECONF_REQ,
 		       struct_size(pdu, scid, 1), pdu);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 085/555] kprobes: Validate re-registration earlier in register_kretprobe()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (83 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 084/555] Bluetooth: L2CAP: Only accept LE responses to outstanding requests Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 086/555] kprobes: Reduce preempt disable scope in check_kprobe_access_safe() Greg Kroah-Hartman
                   ` (469 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Masami Hiramatsu (Google),
	Sasha Levin

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

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

From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

[ Upstream commit a553b499f22bf054964d4fd16d136f3d4f836c23 ]

register_kretprobe() only checked for re-registration if rp->kp.addr was
specified, skipping the check when rp was registered with symbol_name
and rp->kp.addr was NULL. In that scenario, register_kretprobe()
proceeded to allocate a new rethook (or kretprobe holder), and when
register_kprobe(&rp->kp) subsequently failed due to re-registration, the
error path freed and NULL-ed rp->rh (or rp->rph) on the still-active
kretprobe, leading to NULL pointer dereferences when the active probe
was hit.

Resolve the target address via _kprobe_addr() up-front and check whether
the probe is already registered at that address via
check_kprobe_rereg_at() before allocating any resources, and drop the
WARN_ON_ONCE() in the re-registration check now that re-registration is
gracefully detected and rejected.

Link: https://lore.kernel.org/all/179375032568.247640.17429793187163536192.stgit@devnote2/

Fixes: 0188b87899ff ("kretprobe: Avoid re-registration of the same kretprobe earlier")
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/kprobes.c | 72 +++++++++++++++++++++++++++---------------------
 1 file changed, 40 insertions(+), 32 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 7c684df3110de..cfcfb7be5f519 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1492,52 +1492,61 @@ _kprobe_addr(kprobe_opcode_t *addr, const char *symbol_name,
 	return addr;
 }
 
-static kprobe_opcode_t *kprobe_addr(struct kprobe *p)
-{
-	bool on_func_entry;
-
-	return _kprobe_addr(p->addr, p->symbol_name, p->offset, &on_func_entry);
-}
-
 /*
  * Check the 'p' is valid and return the aggregator kprobe
  * at the same address.
  */
-static struct kprobe *__get_valid_kprobe(struct kprobe *p)
+static struct kprobe *__get_valid_kprobe_at(struct kprobe *p, kprobe_opcode_t *addr)
 {
+	struct hlist_head *head;
 	struct kprobe *ap, *list_p;
 
 	lockdep_assert_held(&kprobe_mutex);
 
-	ap = get_kprobe(p->addr);
-	if (unlikely(!ap))
+	if (unlikely(!addr))
 		return NULL;
 
-	if (p == ap)
-		return ap;
-
-	list_for_each_entry(list_p, &ap->list, list)
-		if (list_p == p)
-		/* kprobe p is a valid probe */
+	head = &kprobe_table[hash_ptr(addr, KPROBE_HASH_BITS)];
+	hlist_for_each_entry_rcu(ap, head, hlist,
+				 lockdep_is_held(&kprobe_mutex)) {
+		if (ap == p) {
+			p->addr = addr;
 			return ap;
+		}
+		if (ap->addr == addr && kprobe_aggrprobe(ap)) {
+			list_for_each_entry(list_p, &ap->list, list) {
+				if (list_p == p) {
+					p->addr = addr;
+					return ap;
+				}
+			}
+		}
+	}
 
 	return NULL;
 }
 
-/*
- * Warn and return error if the kprobe is being re-registered since
- * there must be a software bug.
- */
-static inline int warn_kprobe_rereg(struct kprobe *p)
+static inline struct kprobe *__get_valid_kprobe(struct kprobe *p)
+{
+	return __get_valid_kprobe_at(p, p->addr);
+}
+
+/* Return error if the kprobe is being re-registered */
+static inline int check_kprobe_rereg_at(struct kprobe *p, kprobe_opcode_t *addr)
 {
 	guard(mutex)(&kprobe_mutex);
 
-	if (WARN_ON_ONCE(__get_valid_kprobe(p)))
+	if (__get_valid_kprobe_at(p, addr))
 		return -EINVAL;
 
 	return 0;
 }
 
+static inline int check_kprobe_rereg(struct kprobe *p)
+{
+	return check_kprobe_rereg_at(p, p->addr);
+}
+
 static int check_ftrace_location(struct kprobe *p)
 {
 	unsigned long addr = (unsigned long)p->addr;
@@ -1677,7 +1686,7 @@ int register_kprobe(struct kprobe *p)
 		return PTR_ERR(addr);
 	p->addr = addr;
 
-	ret = warn_kprobe_rereg(p);
+	ret = check_kprobe_rereg(p);
 	if (ret)
 		return ret;
 
@@ -2213,20 +2222,19 @@ int register_kretprobe(struct kretprobe *rp)
 	int ret;
 	int i;
 	void *addr;
+	bool on_func_entry;
 
-	ret = kprobe_on_func_entry(rp->kp.addr, rp->kp.symbol_name, rp->kp.offset);
-	if (ret)
-		return ret;
+	addr = _kprobe_addr(rp->kp.addr, rp->kp.symbol_name, rp->kp.offset, &on_func_entry);
+	if (IS_ERR(addr))
+		return PTR_ERR(addr);
 
-	/* If only 'rp->kp.addr' is specified, check reregistering kprobes */
-	if (rp->kp.addr && warn_kprobe_rereg(&rp->kp))
+	if (!on_func_entry)
 		return -EINVAL;
 
-	if (kretprobe_blacklist_size) {
-		addr = kprobe_addr(&rp->kp);
-		if (IS_ERR(addr))
-			return PTR_ERR(addr);
+	if (check_kprobe_rereg_at(&rp->kp, addr))
+		return -EINVAL;
 
+	if (kretprobe_blacklist_size) {
 		for (i = 0; kretprobe_blacklist[i].name != NULL; i++) {
 			if (kretprobe_blacklist[i].addr == addr)
 				return -EINVAL;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 086/555] kprobes: Reduce preempt disable scope in check_kprobe_access_safe()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (84 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 085/555] kprobes: Validate re-registration earlier in register_kretprobe() Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 087/555] jump_label: Define guard() for jump_label_lock Greg Kroah-Hartman
                   ` (468 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Thomas Weißschuh,
	Sebastian Andrzej Siewior, Masami Hiramatsu (Google), Sasha Levin

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

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

From: Thomas Weißschuh <thomas.weissschuh@linutronix.de>

[ Upstream commit 1703abb4dead917ec7e6d9ccb4c13632a6f0994d ]

Commit a189d0350f387 ("kprobes: disable preempt for module_text_address() and kernel_text_address()")
introduced a preempt_disable() region to protect against concurrent
module unloading. However this region also includes the call to
jump_label_text_reserved() which takes a long time;
up to 400us, iterating over approx 6000 jump tables.

The scope protected by preempt_disable() is largen than necessary.
core_kernel_text() does not need to be protected as it does not interact
with module code at all.
Only the scope from __module_text_address() to try_module_get() needs to
be protected.
By limiting the critical section to __module_text_address() and
try_module_get() the function responsible for the latency spike remains
preemptible.

This works fine even when !CONFIG_MODULES as in that case
try_module_get() will always return true and that block can be optimized
away.

Limit the critical section to __module_text_address() and
try_module_get(). Use guard(preempt)() for easier error handling.

While at it also remove a spurious *probed_mod = NULL in an error
path. On errors the output parameter is never inspected by the caller.
Some error paths were clearing the parameters, some didn't.
Align them for clarity.

Link: https://lore.kernel.org/all/20241121-kprobes-preempt-v1-1-fd581ee7fcbb@linutronix.de/

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Stable-dep-of: f60f98881b54 ("kprobes: Switch ftrace ops when adding probe with post_handler")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/kprobes.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index cfcfb7be5f519..064f0866c9c90 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -39,6 +39,7 @@
 #include <linux/static_call.h>
 #include <linux/perf_event.h>
 #include <linux/execmem.h>
+#include <linux/cleanup.h>
 
 #include <asm/sections.h>
 #include <asm/cacheflush.h>
@@ -1581,16 +1582,25 @@ static int check_kprobe_address_safe(struct kprobe *p,
 	if (ret)
 		return ret;
 	jump_label_lock();
-	preempt_disable();
 
 	/* Ensure the address is in a text area, and find a module if exists. */
 	*probed_mod = NULL;
 	if (!core_kernel_text((unsigned long) p->addr)) {
+		guard(preempt)();
 		*probed_mod = __module_text_address((unsigned long) p->addr);
 		if (!(*probed_mod)) {
 			ret = -EINVAL;
 			goto out;
 		}
+
+		/*
+		 * We must hold a refcount of the probed module while updating
+		 * its code to prohibit unexpected unloading.
+		 */
+		if (unlikely(!try_module_get(*probed_mod))) {
+			ret = -ENOENT;
+			goto out;
+		}
 	}
 	/* Ensure it is not in reserved area. */
 	if (in_gate_area_no_mm((unsigned long) p->addr) ||
@@ -1599,21 +1609,13 @@ static int check_kprobe_address_safe(struct kprobe *p,
 	    static_call_text_reserved(p->addr, p->addr) ||
 	    find_bug((unsigned long)p->addr) ||
 	    is_cfi_preamble_symbol((unsigned long)p->addr)) {
+		module_put(*probed_mod);
 		ret = -EINVAL;
 		goto out;
 	}
 
 	/* Get module refcount and reject __init functions for loaded modules. */
 	if (IS_ENABLED(CONFIG_MODULES) && *probed_mod) {
-		/*
-		 * We must hold a refcount of the probed module while updating
-		 * its code to prohibit unexpected unloading.
-		 */
-		if (unlikely(!try_module_get(*probed_mod))) {
-			ret = -ENOENT;
-			goto out;
-		}
-
 		/*
 		 * If the module freed '.init.text', we couldn't insert
 		 * kprobes in there.
@@ -1621,13 +1623,11 @@ static int check_kprobe_address_safe(struct kprobe *p,
 		if (within_module_init((unsigned long)p->addr, *probed_mod) &&
 		    !module_is_coming(*probed_mod)) {
 			module_put(*probed_mod);
-			*probed_mod = NULL;
 			ret = -ENOENT;
 		}
 	}
 
 out:
-	preempt_enable();
 	jump_label_unlock();
 
 	return ret;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 087/555] jump_label: Define guard() for jump_label_lock
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (85 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 086/555] kprobes: Reduce preempt disable scope in check_kprobe_access_safe() Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 088/555] kprobes: Use guard() for external locks Greg Kroah-Hartman
                   ` (467 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Masami Hiramatsu (Google),
	Sasha Levin

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

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

From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

[ Upstream commit e2b6e5e4877ac898b61338dc20491cd837af79b2 ]

Link: https://lore.kernel.org/all/173371207108.480397.12818384744149153972.stgit@devnote2/

Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Stable-dep-of: f60f98881b54 ("kprobes: Switch ftrace ops when adding probe with post_handler")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/linux/jump_label.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index f5a2727ca4a9a..fdb79dd1ebd8c 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -75,6 +75,7 @@
 
 #include <linux/types.h>
 #include <linux/compiler.h>
+#include <linux/cleanup.h>
 
 extern bool static_key_initialized;
 
@@ -347,6 +348,8 @@ static inline void static_key_disable(struct static_key *key)
 
 #endif	/* CONFIG_JUMP_LABEL */
 
+DEFINE_LOCK_GUARD_0(jump_label_lock, jump_label_lock(), jump_label_unlock())
+
 #define STATIC_KEY_INIT STATIC_KEY_INIT_FALSE
 #define jump_label_enabled static_key_enabled
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 088/555] kprobes: Use guard() for external locks
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (86 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 087/555] jump_label: Define guard() for jump_label_lock Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 089/555] kprobes: Switch ftrace ops when adding probe with post_handler Greg Kroah-Hartman
                   ` (466 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Masami Hiramatsu (Google),
	Sasha Levin

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

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

From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

[ Upstream commit 54c79390119d24c1704202a64a997e1c99893b47 ]

Use guard() for text_mutex, cpu_read_lock, and jump_label_lock in
the kprobes.

Link: https://lore.kernel.org/all/173371208663.480397.7535769878667655223.stgit@devnote2/

Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Stable-dep-of: f60f98881b54 ("kprobes: Switch ftrace ops when adding probe with post_handler")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/kprobes.c | 209 ++++++++++++++++++++---------------------------
 1 file changed, 90 insertions(+), 119 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 064f0866c9c90..743d34c1a3349 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -602,41 +602,38 @@ static void kick_kprobe_optimizer(void)
 /* Kprobe jump optimizer */
 static void kprobe_optimizer(struct work_struct *work)
 {
-	mutex_lock(&kprobe_mutex);
-	cpus_read_lock();
-	mutex_lock(&text_mutex);
+	guard(mutex)(&kprobe_mutex);
 
-	/*
-	 * Step 1: Unoptimize kprobes and collect cleaned (unused and disarmed)
-	 * kprobes before waiting for quiesence period.
-	 */
-	do_unoptimize_kprobes();
+	scoped_guard(cpus_read_lock) {
+		guard(mutex)(&text_mutex);
 
-	/*
-	 * Step 2: Wait for quiesence period to ensure all potentially
-	 * preempted tasks to have normally scheduled. Because optprobe
-	 * may modify multiple instructions, there is a chance that Nth
-	 * instruction is preempted. In that case, such tasks can return
-	 * to 2nd-Nth byte of jump instruction. This wait is for avoiding it.
-	 * Note that on non-preemptive kernel, this is transparently converted
-	 * to synchronoze_sched() to wait for all interrupts to have completed.
-	 */
-	synchronize_rcu_tasks();
+		/*
+		 * Step 1: Unoptimize kprobes and collect cleaned (unused and disarmed)
+		 * kprobes before waiting for quiesence period.
+		 */
+		do_unoptimize_kprobes();
 
-	/* Step 3: Optimize kprobes after quiesence period */
-	do_optimize_kprobes();
+		/*
+		 * Step 2: Wait for quiesence period to ensure all potentially
+		 * preempted tasks to have normally scheduled. Because optprobe
+		 * may modify multiple instructions, there is a chance that Nth
+		 * instruction is preempted. In that case, such tasks can return
+		 * to 2nd-Nth byte of jump instruction. This wait is for avoiding it.
+		 * Note that on non-preemptive kernel, this is transparently converted
+		 * to synchronoze_sched() to wait for all interrupts to have completed.
+		 */
+		synchronize_rcu_tasks();
 
-	/* Step 4: Free cleaned kprobes after quiesence period */
-	do_free_cleaned_kprobes();
+		/* Step 3: Optimize kprobes after quiesence period */
+		do_optimize_kprobes();
 
-	mutex_unlock(&text_mutex);
-	cpus_read_unlock();
+		/* Step 4: Free cleaned kprobes after quiesence period */
+		do_free_cleaned_kprobes();
+	}
 
 	/* Step 5: Kick optimizer again if needed */
 	if (!list_empty(&optimizing_list) || !list_empty(&unoptimizing_list))
 		kick_kprobe_optimizer();
-
-	mutex_unlock(&kprobe_mutex);
 }
 
 static void wait_for_kprobe_optimizer_locked(void)
@@ -859,29 +856,24 @@ static void try_to_optimize_kprobe(struct kprobe *p)
 		return;
 
 	/* For preparing optimization, jump_label_text_reserved() is called. */
-	cpus_read_lock();
-	jump_label_lock();
-	mutex_lock(&text_mutex);
+	guard(cpus_read_lock)();
+	guard(jump_label_lock)();
+	guard(mutex)(&text_mutex);
 
 	ap = alloc_aggr_kprobe(p);
 	if (!ap)
-		goto out;
+		return;
 
 	op = container_of(ap, struct optimized_kprobe, kp);
 	if (!arch_prepared_optinsn(&op->optinsn)) {
 		/* If failed to setup optimizing, fallback to kprobe. */
 		arch_remove_optimized_kprobe(op);
 		kfree(op);
-		goto out;
+		return;
 	}
 
 	init_aggr_kprobe(ap, p);
 	optimize_kprobe(ap);	/* This just kicks optimizer thread. */
-
-out:
-	mutex_unlock(&text_mutex);
-	jump_label_unlock();
-	cpus_read_unlock();
 }
 
 static void optimize_all_kprobes(void)
@@ -1166,12 +1158,9 @@ static int arm_kprobe(struct kprobe *kp)
 	if (unlikely(kprobe_ftrace(kp)))
 		return arm_kprobe_ftrace(kp);
 
-	cpus_read_lock();
-	mutex_lock(&text_mutex);
+	guard(cpus_read_lock)();
+	guard(mutex)(&text_mutex);
 	__arm_kprobe(kp);
-	mutex_unlock(&text_mutex);
-	cpus_read_unlock();
-
 	return 0;
 }
 
@@ -1180,12 +1169,9 @@ static int disarm_kprobe(struct kprobe *kp, bool reopt)
 	if (unlikely(kprobe_ftrace(kp)))
 		return disarm_kprobe_ftrace(kp);
 
-	cpus_read_lock();
-	mutex_lock(&text_mutex);
+	guard(cpus_read_lock)();
+	guard(mutex)(&text_mutex);
 	__disarm_kprobe(kp, reopt);
-	mutex_unlock(&text_mutex);
-	cpus_read_unlock();
-
 	return 0;
 }
 
@@ -1302,62 +1288,55 @@ static int register_aggr_kprobe(struct kprobe *orig_p, struct kprobe *p)
 	int ret = 0;
 	struct kprobe *ap = orig_p;
 
-	cpus_read_lock();
-
-	/* For preparing optimization, jump_label_text_reserved() is called */
-	jump_label_lock();
-	mutex_lock(&text_mutex);
-
-	if (!kprobe_aggrprobe(orig_p)) {
-		/* If 'orig_p' is not an 'aggr_kprobe', create new one. */
-		ap = alloc_aggr_kprobe(orig_p);
-		if (!ap) {
-			ret = -ENOMEM;
-			goto out;
+	scoped_guard(cpus_read_lock) {
+		/* For preparing optimization, jump_label_text_reserved() is called */
+		guard(jump_label_lock)();
+		guard(mutex)(&text_mutex);
+
+		if (!kprobe_aggrprobe(orig_p)) {
+			/* If 'orig_p' is not an 'aggr_kprobe', create new one. */
+			ap = alloc_aggr_kprobe(orig_p);
+			if (!ap)
+				return -ENOMEM;
+			init_aggr_kprobe(ap, orig_p);
+		} else if (kprobe_unused(ap)) {
+			/* This probe is going to die. Rescue it */
+			ret = reuse_unused_kprobe(ap);
+			if (ret)
+				return ret;
 		}
-		init_aggr_kprobe(ap, orig_p);
-	} else if (kprobe_unused(ap)) {
-		/* This probe is going to die. Rescue it */
-		ret = reuse_unused_kprobe(ap);
-		if (ret)
-			goto out;
-	}
 
-	if (kprobe_gone(ap)) {
-		/*
-		 * Attempting to insert new probe at the same location that
-		 * had a probe in the module vaddr area which already
-		 * freed. So, the instruction slot has already been
-		 * released. We need a new slot for the new probe.
-		 */
-		ret = arch_prepare_kprobe(ap);
-		if (ret)
+		if (kprobe_gone(ap)) {
 			/*
-			 * Even if fail to allocate new slot, don't need to
-			 * free the 'ap'. It will be used next time, or
-			 * freed by unregister_kprobe().
+			 * Attempting to insert new probe at the same location that
+			 * had a probe in the module vaddr area which already
+			 * freed. So, the instruction slot has already been
+			 * released. We need a new slot for the new probe.
 			 */
-			goto out;
+			ret = arch_prepare_kprobe(ap);
+			if (ret)
+				/*
+				 * Even if fail to allocate new slot, don't need to
+				 * free the 'ap'. It will be used next time, or
+				 * freed by unregister_kprobe().
+				 */
+				return ret;
 
-		/* Prepare optimized instructions if possible. */
-		prepare_optimized_kprobe(ap);
+			/* Prepare optimized instructions if possible. */
+			prepare_optimized_kprobe(ap);
 
-		/*
-		 * Clear gone flag to prevent allocating new slot again, and
-		 * set disabled flag because it is not armed yet.
-		 */
-		ap->flags = (ap->flags & ~KPROBE_FLAG_GONE)
-			    | KPROBE_FLAG_DISABLED;
-	}
-
-	/* Copy the insn slot of 'p' to 'ap'. */
-	copy_kprobe(ap, p);
-	ret = add_new_kprobe(ap, p);
+			/*
+			 * Clear gone flag to prevent allocating new slot again, and
+			 * set disabled flag because it is not armed yet.
+			 */
+			ap->flags = (ap->flags & ~KPROBE_FLAG_GONE)
+					| KPROBE_FLAG_DISABLED;
+		}
 
-out:
-	mutex_unlock(&text_mutex);
-	jump_label_unlock();
-	cpus_read_unlock();
+		/* Copy the insn slot of 'p' to 'ap'. */
+		copy_kprobe(ap, p);
+		ret = add_new_kprobe(ap, p);
+	}
 
 	if (ret == 0 && kprobe_disabled(ap) && !kprobe_disabled(p)) {
 		ap->flags &= ~KPROBE_FLAG_DISABLED;
@@ -1581,26 +1560,23 @@ static int check_kprobe_address_safe(struct kprobe *p,
 	ret = check_ftrace_location(p);
 	if (ret)
 		return ret;
-	jump_label_lock();
+
+	guard(jump_label_lock)();
 
 	/* Ensure the address is in a text area, and find a module if exists. */
 	*probed_mod = NULL;
 	if (!core_kernel_text((unsigned long) p->addr)) {
 		guard(preempt)();
 		*probed_mod = __module_text_address((unsigned long) p->addr);
-		if (!(*probed_mod)) {
-			ret = -EINVAL;
-			goto out;
-		}
+		if (!(*probed_mod))
+			return -EINVAL;
 
 		/*
 		 * We must hold a refcount of the probed module while updating
 		 * its code to prohibit unexpected unloading.
 		 */
-		if (unlikely(!try_module_get(*probed_mod))) {
-			ret = -ENOENT;
-			goto out;
-		}
+		if (unlikely(!try_module_get(*probed_mod)))
+			return -ENOENT;
 	}
 	/* Ensure it is not in reserved area. */
 	if (in_gate_area_no_mm((unsigned long) p->addr) ||
@@ -1610,8 +1586,7 @@ static int check_kprobe_address_safe(struct kprobe *p,
 	    find_bug((unsigned long)p->addr) ||
 	    is_cfi_preamble_symbol((unsigned long)p->addr)) {
 		module_put(*probed_mod);
-		ret = -EINVAL;
-		goto out;
+		return -EINVAL;
 	}
 
 	/* Get module refcount and reject __init functions for loaded modules. */
@@ -1623,14 +1598,11 @@ static int check_kprobe_address_safe(struct kprobe *p,
 		if (within_module_init((unsigned long)p->addr, *probed_mod) &&
 		    !module_is_coming(*probed_mod)) {
 			module_put(*probed_mod);
-			ret = -ENOENT;
+			return -ENOENT;
 		}
 	}
 
-out:
-	jump_label_unlock();
-
-	return ret;
+	return 0;
 }
 
 static int __register_kprobe(struct kprobe *p)
@@ -1645,14 +1617,13 @@ static int __register_kprobe(struct kprobe *p)
 		/* Since this may unoptimize 'old_p', locking 'text_mutex'. */
 		return register_aggr_kprobe(old_p, p);
 
-	cpus_read_lock();
-	/* Prevent text modification */
-	mutex_lock(&text_mutex);
-	ret = prepare_kprobe(p);
-	mutex_unlock(&text_mutex);
-	cpus_read_unlock();
-	if (ret)
-		return ret;
+	scoped_guard(cpus_read_lock) {
+		/* Prevent text modification */
+		guard(mutex)(&text_mutex);
+		ret = prepare_kprobe(p);
+		if (ret)
+			return ret;
+	}
 
 	INIT_HLIST_NODE(&p->hlist);
 	hlist_add_head_rcu(&p->hlist,
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 089/555] kprobes: Switch ftrace ops when adding probe with post_handler
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (87 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 088/555] kprobes: Use guard() for external locks Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 090/555] net: warn, if pf->create does not clear sock->sk on error Greg Kroah-Hartman
                   ` (465 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Masami Hiramatsu (Google),
	Sasha Levin

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

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

From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

[ Upstream commit f60f98881b54b0cf36b61f41c91fbd93b76a2d9c ]

When an ftrace-based kprobe is registered without a post_handler, it is
armed using kprobe_ftrace_ops. If a second probe with a post_handler is
subsequently registered at the same address, register_aggr_kprobe() sets
ap->post_handler to aggr_post_handler, but leaves the probe armed using
kprobe_ftrace_ops.

When the probe is later disarmed or disabled, disarm_kprobe_ftrace()
checks whether p->post_handler is non-NULL and attempts to disarm from
kprobe_ipmodify_ops. This fails with -ENOENT, decrements
kprobe_ipmodify_enabled below zero, leaves the probe armed on
kprobe_ftrace_ops, and aborts unregistration, leading to a use-after-free
if the probe module is unloaded.

Switch the armed probe from kprobe_ftrace_ops to kprobe_ipmodify_ops in
register_aggr_kprobe() outside of text_mutex and cpus_read_lock to avoid
lockdep and deadlock issues when modifying ftrace code. Defer adding the
new probe onto ap->list until the ftrace ops switch completes so that the
new probe's handlers are not published prematurely while ap is still on
kprobe_ftrace_ops, and mark ap disabled if rollback re-arming fails.
Also restore ftrace ops registration and counter if ftrace_set_filter_ip()
fails in __disarm_kprobe_ftrace().

Link: https://lore.kernel.org/all/179440641120.328088.15542754095040659094.stgit@devnote2/

Fixes: 5dd7caf0bdc5 ("kprobes: Skip clearing aggrprobe's post_handler in kprobe-on-ftrace case")
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/kprobes.c | 55 +++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 45 insertions(+), 10 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 743d34c1a3349..e946036a84b54 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1114,9 +1114,14 @@ static int __disarm_kprobe_ftrace(struct kprobe *p, struct ftrace_ops *ops,
 	(*cnt)--;
 
 	ret = ftrace_set_filter_ip(ops, (unsigned long)p->addr, 1, 0);
-	WARN_ONCE(ret < 0, "Failed to disarm kprobe-ftrace at %pS (error %d)\n",
-		  p->addr, ret);
-	return ret;
+	if (WARN_ONCE(ret < 0, "Failed to disarm kprobe-ftrace at %pS (error %d)\n",
+		      p->addr, ret)) {
+		if (*cnt == 0)
+			register_ftrace_function(ops);
+		(*cnt)++;
+		return ret;
+	}
+	return 0;
 }
 
 static int disarm_kprobe_ftrace(struct kprobe *p)
@@ -1245,16 +1250,12 @@ void kprobe_busy_end(void)
 }
 
 /* Add the new probe to 'ap->list'. */
-static int add_new_kprobe(struct kprobe *ap, struct kprobe *p)
+static void add_new_kprobe(struct kprobe *ap, struct kprobe *p)
 {
 	if (p->post_handler)
 		unoptimize_kprobe(ap, true);	/* Fall back to normal kprobe */
 
 	list_add_rcu(&p->list, &ap->list);
-	if (p->post_handler && !ap->post_handler)
-		ap->post_handler = aggr_post_handler;
-
-	return 0;
 }
 
 /*
@@ -1287,6 +1288,8 @@ static int register_aggr_kprobe(struct kprobe *orig_p, struct kprobe *p)
 {
 	int ret = 0;
 	struct kprobe *ap = orig_p;
+	bool reset_post_handler = false;
+	bool ftrace_switch_ops = false;
 
 	scoped_guard(cpus_read_lock) {
 		/* For preparing optimization, jump_label_text_reserved() is called */
@@ -1333,18 +1336,50 @@ static int register_aggr_kprobe(struct kprobe *orig_p, struct kprobe *p)
 					| KPROBE_FLAG_DISABLED;
 		}
 
+		if (p->post_handler && !ap->post_handler) {
+			reset_post_handler = true;
+			if (kprobe_ftrace(ap) && !kprobes_all_disarmed &&
+			    !kprobe_disabled(ap))
+				ftrace_switch_ops = true;
+			else
+				ap->post_handler = aggr_post_handler;
+		}
+
 		/* Copy the insn slot of 'p' to 'ap'. */
 		copy_kprobe(ap, p);
-		ret = add_new_kprobe(ap, p);
+		if (!ftrace_switch_ops)
+			add_new_kprobe(ap, p);
+	}
+
+	if (ftrace_switch_ops) {
+		/*
+		 * Must switch ftrace ops outside of text_mutex and cpus_read_lock
+		 * to prevent deadlocks when ftrace code modification acquires text_mutex.
+		 */
+		ret = disarm_kprobe_ftrace(ap);
+		if (ret)
+			return ret;
+
+		ap->post_handler = aggr_post_handler;
+		ret = arm_kprobe_ftrace(ap);
+		if (ret) {
+			ap->post_handler = NULL;
+			if (arm_kprobe_ftrace(ap))
+				ap->flags |= KPROBE_FLAG_DISABLED;
+			return ret;
+		}
+		add_new_kprobe(ap, p);
 	}
 
-	if (ret == 0 && kprobe_disabled(ap) && !kprobe_disabled(p)) {
+	if (kprobe_disabled(ap) && !kprobe_disabled(p)) {
 		ap->flags &= ~KPROBE_FLAG_DISABLED;
 		if (!kprobes_all_disarmed) {
 			/* Arm the breakpoint again. */
 			ret = arm_kprobe(ap);
 			if (ret) {
 				ap->flags |= KPROBE_FLAG_DISABLED;
+				if (reset_post_handler)
+					ap->post_handler = NULL;
 				list_del_rcu(&p->list);
 				synchronize_rcu();
 			}
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 090/555] net: warn, if pf->create does not clear sock->sk on error
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (88 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 089/555] kprobes: Switch ftrace ops when adding probe with post_handler Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 091/555] socket: Print pf->create() when it does not clear sock->sk on failure Greg Kroah-Hartman
                   ` (464 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Kuniyuki Iwashima, Ignat Korchagin,
	Eric Dumazet, Jakub Kicinski, Sasha Levin

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

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

From: Ignat Korchagin <ignat@cloudflare.com>

[ Upstream commit 48156296a08c615a6baae514096c4b2e543d1157 ]

All pf->create implementations have been fixed now to clear sock->sk on
error, when they deallocate the allocated sk object.

Put a warning in place to make sure we don't break this promise in the
future.

Suggested-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: Ignat Korchagin <ignat@cloudflare.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20241014153808.51894-9-ignat@cloudflare.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Stable-dep-of: 82052e5b5ec3 ("netfilter: nf_dup: preserve guard across NFQUEUE reinjection")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/socket.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/socket.c b/net/socket.c
index a143b8f577bd9..b63029bfdee92 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1559,9 +1559,9 @@ int __sock_create(struct net *net, int family, int type, int protocol,
 	err = pf->create(net, sock, protocol, kern);
 	if (err < 0) {
 		/* ->create should release the allocated sock->sk object on error
-		 * but it may leave the dangling pointer
+		 * and make sure sock->sk is set to NULL to avoid use-after-free
 		 */
-		sock->sk = NULL;
+		DEBUG_NET_WARN_ON_ONCE(sock->sk);
 		goto out_module_put;
 	}
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 091/555] socket: Print pf->create() when it does not clear sock->sk on failure.
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (89 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 090/555] net: warn, if pf->create does not clear sock->sk on error Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 092/555] netfilter: nf_dup{4, 6}: Move duplication check to task_struct Greg Kroah-Hartman
                   ` (463 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Kuniyuki Iwashima, Eric Dumazet,
	Jakub Kicinski, Sasha Levin

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

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

From: Kuniyuki Iwashima <kuniyu@amazon.com>

[ Upstream commit 4bbd360a5084d8f890f814327e1d9fbb1f0f6fa1 ]

I suggested to put DEBUG_NET_WARN_ON_ONCE() in __sock_create() to
catch possible use-after-free.

But the warning itself was not useful because our interest is in
the callee than the caller.

Let's define DEBUG_NET_WARN_ONCE() and print the name of pf->create()
and the socket identifier.

While at it, we enclose DEBUG_NET_WARN_ON_ONCE() in parentheses too
to avoid a checkpatch error.

Note that %pf or %pF were obsoleted and will be removed later as per
comment in lib/vsprintf.c.

Link: https://lore.kernel.org/netdev/202410231427.633734b3-lkp@intel.com/
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20241024201458.49412-1-kuniyu@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Stable-dep-of: 82052e5b5ec3 ("netfilter: nf_dup: preserve guard across NFQUEUE reinjection")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/net/net_debug.h | 4 +++-
 net/socket.c            | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/net/net_debug.h b/include/net/net_debug.h
index 4a79204c8d306..47f7a4a878b9f 100644
--- a/include/net/net_debug.h
+++ b/include/net/net_debug.h
@@ -149,9 +149,11 @@ do {								\
 
 
 #if defined(CONFIG_DEBUG_NET)
-#define DEBUG_NET_WARN_ON_ONCE(cond) (void)WARN_ON_ONCE(cond)
+#define DEBUG_NET_WARN_ON_ONCE(cond) ((void)WARN_ON_ONCE(cond))
+#define DEBUG_NET_WARN_ONCE(cond, format...) ((void)WARN_ONCE(cond, format))
 #else
 #define DEBUG_NET_WARN_ON_ONCE(cond) BUILD_BUG_ON_INVALID(cond)
+#define DEBUG_NET_WARN_ONCE(cond, format...) BUILD_BUG_ON_INVALID(cond)
 #endif
 
 #endif	/* _LINUX_NET_DEBUG_H */
diff --git a/net/socket.c b/net/socket.c
index b63029bfdee92..63d4acccb5f2c 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1561,7 +1561,9 @@ int __sock_create(struct net *net, int family, int type, int protocol,
 		/* ->create should release the allocated sock->sk object on error
 		 * and make sure sock->sk is set to NULL to avoid use-after-free
 		 */
-		DEBUG_NET_WARN_ON_ONCE(sock->sk);
+		DEBUG_NET_WARN_ONCE(sock->sk,
+				    "%ps must clear sock->sk on failure, family: %d, type: %d, protocol: %d\n",
+				    pf->create, family, type, protocol);
 		goto out_module_put;
 	}
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 092/555] netfilter: nf_dup{4, 6}: Move duplication check to task_struct
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (90 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 091/555] socket: Print pf->create() when it does not clear sock->sk on failure Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 093/555] netfilter: nf_dup: preserve guard across NFQUEUE reinjection Greg Kroah-Hartman
                   ` (462 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Ingo Molnar, Peter Zijlstra,
	Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt,
	Ben Segall, Mel Gorman, Valentin Schneider,
	Sebastian Andrzej Siewior, Pablo Neira Ayuso, Sasha Levin

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

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

From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

[ Upstream commit a1f1acb9c5db9b385c9b3eb1f27f897c06df49ae ]

nf_skb_duplicated is a per-CPU variable and relies on disabled BH for its
locking. Without per-CPU locking in local_bh_disable() on PREEMPT_RT
this data structure requires explicit locking.

Due to the recursion involved, the simplest change is to make it a
per-task variable.

Move the per-CPU variable nf_skb_duplicated to task_struct and name it
in_nf_duplicate. Add it to the existing bitfield so it doesn't use
additional memory.

Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ben Segall <bsegall@google.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Valentin Schneider <vschneid@redhat.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Stable-dep-of: 82052e5b5ec3 ("netfilter: nf_dup: preserve guard across NFQUEUE reinjection")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/linux/netfilter.h        | 11 -----------
 include/linux/sched.h            |  1 +
 net/ipv4/netfilter/ip_tables.c   |  2 +-
 net/ipv4/netfilter/nf_dup_ipv4.c |  6 +++---
 net/ipv6/netfilter/ip6_tables.c  |  2 +-
 net/ipv6/netfilter/nf_dup_ipv6.c |  6 +++---
 net/netfilter/core.c             |  3 ---
 7 files changed, 9 insertions(+), 22 deletions(-)

diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index 9b3357d8d8c3e..3ca1996a6daba 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -499,17 +499,6 @@ struct nf_defrag_hook {
 extern const struct nf_defrag_hook __rcu *nf_defrag_v4_hook;
 extern const struct nf_defrag_hook __rcu *nf_defrag_v6_hook;
 
-/*
- * nf_skb_duplicated - TEE target has sent a packet
- *
- * When a xtables target sends a packet, the OUTPUT and POSTROUTING
- * hooks are traversed again, i.e. nft and xtables are invoked recursively.
- *
- * This is used by xtables TEE target to prevent the duplicated skb from
- * being duplicated again.
- */
-DECLARE_PER_CPU(bool, nf_skb_duplicated);
-
 /*
  * Contains bitmask of ctnetlink event subscribers, if any.
  * Can't be pernet due to NETLINK_LISTEN_ALL_NSID setsockopt flag.
diff --git a/include/linux/sched.h b/include/linux/sched.h
index efee6139c6af6..139735e265c5d 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1021,6 +1021,7 @@ struct task_struct {
 	/* delay due to memory thrashing */
 	unsigned                        in_thrashing:1;
 #endif
+	unsigned			in_nf_duplicate:1;
 #ifdef CONFIG_PREEMPT_RT
 	struct netdev_xmit		net_xmit;
 #endif
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 4320f67df7baa..412419a249dad 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -270,7 +270,7 @@ ipt_do_table(void *priv,
 	 * but it is no problem since absolute verdict is issued by these.
 	 */
 	if (static_key_false(&xt_tee_enabled))
-		jumpstack += private->stacksize * __this_cpu_read(nf_skb_duplicated);
+		jumpstack += private->stacksize * current->in_nf_duplicate;
 
 	e = get_entry(table_base, private->hook_entry[hook]);
 
diff --git a/net/ipv4/netfilter/nf_dup_ipv4.c b/net/ipv4/netfilter/nf_dup_ipv4.c
index ec94ee1051c77..d11d7e2e1307b 100644
--- a/net/ipv4/netfilter/nf_dup_ipv4.c
+++ b/net/ipv4/netfilter/nf_dup_ipv4.c
@@ -54,7 +54,7 @@ void nf_dup_ipv4(struct net *net, struct sk_buff *skb, unsigned int hooknum,
 	struct iphdr *iph;
 
 	local_bh_disable();
-	if (this_cpu_read(nf_skb_duplicated))
+	if (current->in_nf_duplicate)
 		goto out;
 	/*
 	 * Copy the skb, and route the copy. Will later return %XT_CONTINUE for
@@ -86,9 +86,9 @@ void nf_dup_ipv4(struct net *net, struct sk_buff *skb, unsigned int hooknum,
 		--iph->ttl;
 
 	if (nf_dup_ipv4_route(net, skb, gw, oif)) {
-		__this_cpu_write(nf_skb_duplicated, true);
+		current->in_nf_duplicate = true;
 		ip_local_out(net, skb->sk, skb);
-		__this_cpu_write(nf_skb_duplicated, false);
+		current->in_nf_duplicate = false;
 	} else {
 		kfree_skb(skb);
 	}
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index fb375ce7f916d..9110392c83f6d 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -292,7 +292,7 @@ ip6t_do_table(void *priv, struct sk_buff *skb,
 	 * but it is no problem since absolute verdict is issued by these.
 	 */
 	if (static_key_false(&xt_tee_enabled))
-		jumpstack += private->stacksize * __this_cpu_read(nf_skb_duplicated);
+		jumpstack += private->stacksize * current->in_nf_duplicate;
 
 	e = get_entry(table_base, private->hook_entry[hook]);
 
diff --git a/net/ipv6/netfilter/nf_dup_ipv6.c b/net/ipv6/netfilter/nf_dup_ipv6.c
index a8bb04bd94cf2..6da3102b7c1b3 100644
--- a/net/ipv6/netfilter/nf_dup_ipv6.c
+++ b/net/ipv6/netfilter/nf_dup_ipv6.c
@@ -48,7 +48,7 @@ void nf_dup_ipv6(struct net *net, struct sk_buff *skb, unsigned int hooknum,
 		 const struct in6_addr *gw, int oif)
 {
 	local_bh_disable();
-	if (this_cpu_read(nf_skb_duplicated))
+	if (current->in_nf_duplicate)
 		goto out;
 	skb = pskb_copy(skb, GFP_ATOMIC);
 	if (skb == NULL)
@@ -64,9 +64,9 @@ void nf_dup_ipv6(struct net *net, struct sk_buff *skb, unsigned int hooknum,
 		--iph->hop_limit;
 	}
 	if (nf_dup_ipv6_route(net, skb, gw, oif)) {
-		__this_cpu_write(nf_skb_duplicated, true);
+		current->in_nf_duplicate = true;
 		ip6_local_out(net, skb->sk, skb);
-		__this_cpu_write(nf_skb_duplicated, false);
+		current->in_nf_duplicate = false;
 	} else {
 		kfree_skb(skb);
 	}
diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index f8346fee36b6b..49694f4b1baa4 100644
--- a/net/netfilter/core.c
+++ b/net/netfilter/core.c
@@ -31,9 +31,6 @@
 const struct nf_ipv6_ops __rcu *nf_ipv6_ops __read_mostly;
 EXPORT_SYMBOL_GPL(nf_ipv6_ops);
 
-DEFINE_PER_CPU(bool, nf_skb_duplicated);
-EXPORT_SYMBOL_GPL(nf_skb_duplicated);
-
 #ifdef CONFIG_JUMP_LABEL
 struct static_key nf_hooks_needed[NFPROTO_NUMPROTO][NF_MAX_HOOKS];
 EXPORT_SYMBOL(nf_hooks_needed);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 093/555] netfilter: nf_dup: preserve guard across NFQUEUE reinjection
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (91 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 092/555] netfilter: nf_dup{4, 6}: Move duplication check to task_struct Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 094/555] vsock: do not leave dangling sk pointer in vsock_create() Greg Kroah-Hartman
                   ` (461 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Vega, Luxing Yin, Zihan Xi,
	Pablo Neira Ayuso, Sasha Levin

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

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

From: Zihan Xi <zihanx@nebusec.ai>

[ Upstream commit 82052e5b5ec36504fe1b9c3c28a711a78fcacf37 ]

NFQUEUE can suspend traversal of a duplicated packet while the task-local
duplication guard is set. The output call then returns and clears the guard
before a later verdict resumes hook traversal.

Save the guard in the queue entry and restore it while reinjection
continues hook traversal. Preserve and restore the verdict task's prior
state, including nested synchronous reinjection.

Fixes: cd58bcd9787e ("netfilter: xt_TEE: have cloned packet travel through Xtables too")
Cc: stable@vger.kernel.org
Reported-by: Vega <vega@nebusec.ai>
Assisted-by: LLM
Co-developed-by: Luxing Yin <root@tr0jan.top>
Signed-off-by: Luxing Yin <root@tr0jan.top>
Signed-off-by: Zihan Xi <zihanx@nebusec.ai>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/net/netfilter/nf_queue.h |  1 +
 net/netfilter/nf_queue.c         |  1 +
 net/netfilter/nfnetlink_queue.c  | 17 ++++++++++++++---
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/include/net/netfilter/nf_queue.h b/include/net/netfilter/nf_queue.h
index fc3e81c07364f..039622d489051 100644
--- a/include/net/netfilter/nf_queue.h
+++ b/include/net/netfilter/nf_queue.h
@@ -23,6 +23,7 @@ struct nf_queue_entry {
 	struct net_device	*physout;
 #endif
 	struct nf_hook_state	state;
+	bool			in_nf_duplicate;
 	bool			nf_ct_is_unconfirmed;
 	u16			size; /* sizeof(entry) + saved route keys */
 
diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c
index c0c9ea5fc4e19..e25966a09fe31 100644
--- a/net/netfilter/nf_queue.c
+++ b/net/netfilter/nf_queue.c
@@ -218,6 +218,7 @@ static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state,
 	*entry = (struct nf_queue_entry) {
 		.skb	= skb,
 		.skb_dev = skb->dev,
+		.in_nf_duplicate = current->in_nf_duplicate,
 		.state	= *state,
 		.hook_index = index,
 		.size	= sizeof(*entry) + route_key_size,
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index 5d10a85a2f73d..1d827858155f9 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -37,6 +37,7 @@
 #include <net/sock.h>
 #include <net/tcp_states.h>
 #include <net/netfilter/nf_queue.h>
+#include <net/net_debug.h>
 #include <net/netns/generic.h>
 
 #include <linux/atomic.h>
@@ -344,21 +345,30 @@ static void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict)
 	const struct nf_hook_entry *hook_entry;
 	const struct nf_hook_entries *hooks;
 	struct sk_buff *skb = entry->skb;
+	bool old_in_nf_duplicate;
 	const struct net *net;
 	unsigned int i;
 	int err;
 	u8 pf;
 
+	DEBUG_NET_WARN_ONCE(current->in_nf_duplicate &&
+			    !entry->in_nf_duplicate,
+			    "%s called with unexpected duplication guard",
+			    __func__);
+	local_bh_disable();
+	old_in_nf_duplicate = current->in_nf_duplicate;
+
 	net = entry->state.net;
 	pf = entry->state.pf;
 
+	current->in_nf_duplicate = entry->in_nf_duplicate;
 	hooks = nf_hook_entries_head(net, pf, entry->state.hook);
 
 	i = entry->hook_index;
 	if (!hooks || i >= hooks->num_hook_entries) {
 		kfree_skb_reason(skb, SKB_DROP_REASON_NETFILTER_DROP);
 		nf_queue_entry_free(entry);
-		return;
+		goto out;
 	}
 
 	hook_entry = &hooks->hooks[i];
@@ -381,9 +391,7 @@ static void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict)
 	switch (verdict & NF_VERDICT_MASK) {
 	case NF_ACCEPT:
 	case NF_STOP:
-		local_bh_disable();
 		entry->state.okfn(entry->state.net, entry->state.sk, skb);
-		local_bh_enable();
 		break;
 	case NF_QUEUE:
 		err = nf_queue(skb, &entry->state, i, verdict);
@@ -397,6 +405,9 @@ static void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict)
 	}
 
 	nf_queue_entry_free(entry);
+out:
+	current->in_nf_duplicate = old_in_nf_duplicate;
+	local_bh_enable();
 }
 
 /* return true if the entry has an unconfirmed conntrack attached that isn't owned by us
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 094/555] vsock: do not leave dangling sk pointer in vsock_create()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (92 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 093/555] netfilter: nf_dup: preserve guard across NFQUEUE reinjection Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 095/555] cpufreq: Introduce policy->boost_supported flag Greg Kroah-Hartman
                   ` (460 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, syzbot, Eric Dumazet,
	Ignat Korchagin, Kuniyuki Iwashima, Stefano Garzarella,
	Jakub Kicinski, Sasha Levin

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

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

From: Eric Dumazet <edumazet@google.com>

[ Upstream commit ba4e469e42fe1a771b5653d179eb12dc4be6b6a8 ]

syzbot was able to trigger the following warning after recent
core network cleanup.

On error vsock_create() frees the allocated sk object, but sock_init_data()
has already attached it to the provided sock object.

We must clear sock->sk to avoid possible use-after-free later.

WARNING: CPU: 0 PID: 5282 at net/socket.c:1581 __sock_create+0x897/0x950 net/socket.c:1581
Modules linked in:
CPU: 0 UID: 0 PID: 5282 Comm: syz.2.43 Not tainted 6.12.0-rc2-syzkaller-00667-g53bac8330865 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
 RIP: 0010:__sock_create+0x897/0x950 net/socket.c:1581
Code: 7f 06 01 65 48 8b 34 25 00 d8 03 00 48 81 c6 b0 08 00 00 48 c7 c7 60 0b 0d 8d e8 d4 9a 3c 02 e9 11 f8 ff ff e8 0a ab 0d f8 90 <0f> 0b 90 e9 82 fd ff ff 89 e9 80 e1 07 fe c1 38 c1 0f 8c c7 f8 ff
RSP: 0018:ffffc9000394fda8 EFLAGS: 00010293
RAX: ffffffff89873c46 RBX: ffff888079f3c818 RCX: ffff8880314b9e00
RDX: 0000000000000000 RSI: 00000000ffffffed RDI: 0000000000000000
RBP: ffffffff8d3337f0 R08: ffffffff8987384e R09: ffffffff8989473a
R10: dffffc0000000000 R11: fffffbfff203a276 R12: 00000000ffffffed
R13: ffff888079f3c8c0 R14: ffffffff898736e7 R15: dffffc0000000000
FS:  00005555680ab500(0000) GS:ffff8880b8600000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f22b11196d0 CR3: 00000000308c0000 CR4: 00000000003526f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
  sock_create net/socket.c:1632 [inline]
  __sys_socket_create net/socket.c:1669 [inline]
  __sys_socket+0x150/0x3c0 net/socket.c:1716
  __do_sys_socket net/socket.c:1730 [inline]
  __se_sys_socket net/socket.c:1728 [inline]
  __x64_sys_socket+0x7a/0x90 net/socket.c:1728
  do_syscall_x64 arch/x86/entry/common.c:52 [inline]
  do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f22b117dff9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fff56aec0e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000029
RAX: ffffffffffffffda RBX: 00007f22b1335f80 RCX: 00007f22b117dff9
RDX: 0000000000000000 RSI: 0000000000000002 RDI: 0000000000000028
RBP: 00007f22b11f0296 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f22b1335f80 R14: 00007f22b1335f80 R15: 00000000000012dd

Fixes: 48156296a08c ("net: warn, if pf->create does not clear sock->sk on error")
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Ignat Korchagin <ignat@cloudflare.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://patch.msgid.link/20241022134819.1085254-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/vmw_vsock/af_vsock.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 4a790db5d01b3..6d821a6b508dc 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -2577,6 +2577,7 @@ static int vsock_create(struct net *net, struct socket *sock,
 	if (sock->type == SOCK_DGRAM) {
 		ret = vsock_assign_transport(vsk, NULL);
 		if (ret < 0) {
+			sock->sk = NULL;
 			sock_put(sk);
 			return ret;
 		}
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 095/555] cpufreq: Introduce policy->boost_supported flag
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (93 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 094/555] vsock: do not leave dangling sk pointer in vsock_create() Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 096/555] cpufreq: Avoid redundant target() calls for unchanged limits Greg Kroah-Hartman
                   ` (459 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Viresh Kumar, Sasha Levin

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

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

From: Viresh Kumar <viresh.kumar@linaro.org>

[ Upstream commit 1f7d1bab50e6ae517f8b6699e56d709d61ae13e5 ]

It is possible to have a scenario where not all cpufreq policies support
boost frequencies. And letting sysfs (or other parts of the kernel)
enable boost feature for that policy isn't correct.

Add a new flag, boost_supported, which will be set to true by the
cpufreq core only if the freq table contains valid boost frequencies.

Some cpufreq drivers though don't have boost frequencies in the
freq-table, they can set this flag from their ->init() callbacks.

Once all the drivers are updated to set the flag correctly, we can check
it before enabling boost feature for a policy.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Stable-dep-of: 75120f31aed0 ("cpufreq: Fix updates of cached resolved frequency and index")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/cpufreq/freq_table.c | 4 ++++
 include/linux/cpufreq.h      | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index 178e17009a16e..9db21ffc11979 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -367,6 +367,10 @@ int cpufreq_table_validate_and_sort(struct cpufreq_policy *policy)
 	if (ret)
 		return ret;
 
+	/* Driver's may have set this field already */
+	if (policy_has_boost_freq(policy))
+		policy->boost_supported = true;
+
 	return set_freq_table_sorted(policy);
 }
 
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 5947659a4b9d4..0f83ae7871d1e 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -147,6 +147,9 @@ struct cpufreq_policy {
 	/* Per policy boost enabled flag. */
 	bool			boost_enabled;
 
+	/* Per policy boost supported flag. */
+	bool			boost_supported;
+
 	/* The policy has been suspended. */
 	bool			suspended;
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 096/555] cpufreq: Avoid redundant target() calls for unchanged limits
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (94 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 095/555] cpufreq: Introduce policy->boost_supported flag Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 097/555] cpufreq: Fix updates of cached resolved frequency and index Greg Kroah-Hartman
                   ` (458 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Viresh Kumar, Lifeng Zheng,
	Zhongqiu Han, Rafael J. Wysocki, Sasha Levin

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

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

From: Viresh Kumar <viresh.kumar@linaro.org>

[ Upstream commit 9801be8bef65dbcbc40c1a9c2f03d70ed67a5d30 ]

Drivers setting CPUFREQ_NEED_UPDATE_LIMITS expect target() to be
invoked even if the target frequency remains unchanged, so they can
update their internal policy limits state.

Currently the core invokes target() unconditionally whenever the
requested frequency matches policy->cur for such drivers, even if
policy->min and policy->max haven't changed since the previous update.

Track pending policy limit updates explicitly and skip redundant
target() invocations when neither the target frequency nor the
effective limits changed.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Lifeng Zheng <zhenglifeng1@huawei.com>
Reviewed-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
Link: https://patch.msgid.link/d0107c364b709abca21acf88072220bc05478594.1779423281.git.viresh.kumar@linaro.org
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Stable-dep-of: 75120f31aed0 ("cpufreq: Fix updates of cached resolved frequency and index")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/cpufreq/cpufreq.c | 31 ++++++++++++++++++++++---------
 include/linux/cpufreq.h   |  3 +++
 2 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index f21e28cbecd59..670f92b782190 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2392,9 +2392,13 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
 	 * exactly same freq is called again and so we can save on few function
 	 * calls.
 	 */
-	if (target_freq == policy->cur &&
-	    !(cpufreq_driver->flags & CPUFREQ_NEED_UPDATE_LIMITS))
-		return 0;
+	if (target_freq == policy->cur) {
+		if (!(cpufreq_driver->flags & CPUFREQ_NEED_UPDATE_LIMITS) ||
+		    !policy->update_limits)
+			return 0;
+
+		policy->update_limits = false;
+	}
 
 	if (cpufreq_driver->target) {
 		/*
@@ -2686,6 +2690,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
 {
 	struct cpufreq_policy_data new_data;
 	struct cpufreq_governor *old_gov;
+	unsigned int freq;
 	int ret;
 
 	memcpy(&new_data.cpuinfo, &policy->cpuinfo, sizeof(policy->cpuinfo));
@@ -2718,12 +2723,20 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
 	 * compiler optimizations around them because they may be accessed
 	 * concurrently by cpufreq_driver_resolve_freq() during the update.
 	 */
-	WRITE_ONCE(policy->max, __resolve_freq(policy, new_data.max,
-					       new_data.min, new_data.max,
-					       CPUFREQ_RELATION_H));
-	new_data.min = __resolve_freq(policy, new_data.min, new_data.min,
-				      new_data.max, CPUFREQ_RELATION_L);
-	WRITE_ONCE(policy->min, new_data.min > policy->max ? policy->max : new_data.min);
+	freq = __resolve_freq(policy, new_data.max, new_data.min, new_data.max,
+			      CPUFREQ_RELATION_H);
+	if (freq != policy->max) {
+		WRITE_ONCE(policy->max, freq);
+		policy->update_limits = true;
+	}
+
+	freq = __resolve_freq(policy, new_data.min, new_data.min, new_data.max,
+			      CPUFREQ_RELATION_L);
+	freq = min(freq, policy->max);
+	if (freq != policy->min) {
+		WRITE_ONCE(policy->min, freq);
+		policy->update_limits = true;
+	}
 
 	trace_cpu_frequency_limits(policy);
 
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 0f83ae7871d1e..5c8fa2aab2fe7 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -150,6 +150,9 @@ struct cpufreq_policy {
 	/* Per policy boost supported flag. */
 	bool			boost_supported;
 
+	/* Pending policy->min/max update for the driver */
+	bool			update_limits;
+
 	/* The policy has been suspended. */
 	bool			suspended;
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 097/555] cpufreq: Fix updates of cached resolved frequency and index
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (95 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 096/555] cpufreq: Avoid redundant target() calls for unchanged limits Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 098/555] sched_ext: Fix ops.enqueue/dispatch() calls before ops.cpu_online() Greg Kroah-Hartman
                   ` (457 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Zhongqiu Han, Rafael J. Wysocki,
	Christian Loehle, Sasha Levin

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

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

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

[ Upstream commit 75120f31aed010c326b28d7c80d22314df34d9a8 ]

The cached resolved frequency and index, cached_target_freq and
cached_resolved_idx, respectively, may be updated concurrently if
cpufreq_driver_resolve_freq() is called by the schedutil governor
while cpufreq_set_policy() is running for the same policy.  Those
concurrent updates are not synchronized in any way and the values
written by cpufreq_set_policy(), if it wins the race, may confuse
drivers using those policy fields [1].

To address this, use the observation that the only place where
cached_target_freq and cached_resolved_idx need to be updated is
cpufreq_driver_resolve_freq() because the only legitimate users of
them are .fast_switch() driver callbacks.  Although cached_resolved_idx
is also used in __cpufreq_driver_target(), that is in fact unnecessary
and it is better to use a local variable for storing the frequency
table index in that function.

Accordingly, rearrange __resolve_freq() and its callers so that
cached_target_freq and cached_resolved_idx are only updated in
cpufreq_driver_resolve_freq().

The cached_target_freq initialization in cpufreq_set_policy() is still
needed, but move it after stopping the old governor and before starting
the new one to avoid racing with cpufreq_driver_resolve_freq().

Fixes: f9ccdec24d91 ("cpufreq: Reuse cpufreq_driver_resolve_freq() in __cpufreq_driver_target()")
Fixes: 151717690694 ("cpufreq: Make policy min/max hard requirements")
Reported-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
Closes: https://lore.kernel.org/linux-pm/20261105140357.1331894-1-zhongqiu.han@oss.qualcomm.com/ [1]
Co-developed-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
Signed-off-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Christian Loehle <christian.loehle@arm.com>
Tested-by: Christian Loehle <christian.loehle@arm.com>
Cc: All applicable <stable@vger.kernel.org> # 342d3a73c5db cpufreq: Force passing target frequency to driver during resume
Cc: All applicable <stable@vger.kernel.org> # 166207cac451 cpufreq: Cache post-resolution target frequency in __resolve_freq()
Link: https://patch.msgid.link/3472677.aeNJFYEL58@rafael.j.wysocki
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/cpufreq/cpufreq.c | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 670f92b782190..a0b603d1e52b7 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -540,7 +540,7 @@ EXPORT_SYMBOL_GPL(cpufreq_disable_fast_switch);
 static unsigned int __resolve_freq(struct cpufreq_policy *policy,
 				   unsigned int target_freq,
 				   unsigned int min, unsigned int max,
-				   unsigned int relation)
+				   unsigned int relation, unsigned int *idx_p)
 {
 	unsigned int idx;
 
@@ -550,9 +550,10 @@ static unsigned int __resolve_freq(struct cpufreq_policy *policy,
 		return target_freq;
 
 	idx = cpufreq_frequency_table_target(policy, target_freq, min, max, relation);
-	policy->cached_resolved_idx = idx;
-	policy->cached_target_freq = policy->freq_table[idx].frequency;
-	return policy->cached_target_freq;
+	if (idx_p)
+		*idx_p = idx;
+
+	return policy->freq_table[idx].frequency;
 }
 
 /**
@@ -583,7 +584,10 @@ unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy,
 	if (unlikely(min > max))
 		min = max;
 
-	return __resolve_freq(policy, target_freq, min, max, CPUFREQ_RELATION_LE);
+	policy->cached_target_freq = __resolve_freq(policy, target_freq, min, max,
+						    CPUFREQ_RELATION_LE,
+						    &policy->cached_resolved_idx);
+	return policy->cached_target_freq;
 }
 EXPORT_SYMBOL_GPL(cpufreq_driver_resolve_freq);
 
@@ -2376,12 +2380,13 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
 			    unsigned int relation)
 {
 	unsigned int old_target_freq = target_freq;
+	unsigned int idx = 0;
 
 	if (cpufreq_disabled())
 		return -ENODEV;
 
 	target_freq = __resolve_freq(policy, target_freq, policy->min,
-				     policy->max, relation);
+				     policy->max, relation, &idx);
 
 	pr_debug("target for CPU %u: %u kHz, relation %u, requested %u kHz\n",
 		 policy->cpu, target_freq, relation, old_target_freq);
@@ -2414,7 +2419,7 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
 	if (!cpufreq_driver->target_index)
 		return -EINVAL;
 
-	return __target_index(policy, policy->cached_resolved_idx);
+	return __target_index(policy, idx);
 }
 EXPORT_SYMBOL_GPL(__cpufreq_driver_target);
 
@@ -2724,14 +2729,14 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
 	 * concurrently by cpufreq_driver_resolve_freq() during the update.
 	 */
 	freq = __resolve_freq(policy, new_data.max, new_data.min, new_data.max,
-			      CPUFREQ_RELATION_H);
+			      CPUFREQ_RELATION_H, NULL);
 	if (freq != policy->max) {
 		WRITE_ONCE(policy->max, freq);
 		policy->update_limits = true;
 	}
 
 	freq = __resolve_freq(policy, new_data.min, new_data.min, new_data.max,
-			      CPUFREQ_RELATION_L);
+			      CPUFREQ_RELATION_L, NULL);
 	freq = min(freq, policy->max);
 	if (freq != policy->min) {
 		WRITE_ONCE(policy->min, freq);
@@ -2742,8 +2747,6 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
 
 	cpufreq_update_pressure(policy);
 
-	policy->cached_target_freq = UINT_MAX;
-
 	pr_debug("new min and max freqs are %u - %u kHz\n",
 		 policy->min, policy->max);
 
@@ -2769,6 +2772,12 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
 		cpufreq_exit_governor(policy);
 	}
 
+	/*
+	 * Initialize cached_target_freq while no governor is running to avoid
+	 * racing with cpufreq_driver_resolve_freq(), which updates it.
+	 */
+	policy->cached_target_freq = UINT_MAX;
+
 	/* start new governor */
 	policy->governor = new_gov;
 	ret = cpufreq_init_governor(policy);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 098/555] sched_ext: Fix ops.enqueue/dispatch() calls before ops.cpu_online()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (96 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 097/555] cpufreq: Fix updates of cached resolved frequency and index Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 099/555] Bluetooth: l2cap: defer conn param update to avoid conn->lock/hdev->lock inversion Greg Kroah-Hartman
                   ` (456 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Tejun Heo, Andrea Righi, Sasha Levin

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

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

From: Tejun Heo <tj@kernel.org>

[ Upstream commit 2227a34ff7bfcf6112931039e3554f4b70b65ab9 ]

ops.cpu_online() documents that the cpu doesn't call ops.enqueue() or
ops.dispatch() before that op. Both are gated on SCX_RQ_ONLINE, which
follows the core's rq online state through the ext class's rq_online and
rq_offline hooks. On a runtime cpu up, sched_cpu_activate() runs:

1. set_cpu_active() marks the cpu active.
2. cpuset_cpu_active() rebuilds the sched domains synchronously, and
   rq_attach_root() puts the rq online as the cpu is active now. The
   rq_online hook sets SCX_RQ_ONLINE.
3. scx_rq_activate() calls the root's ops.cpu_online().

Between 2 and 3, ops.enqueue() can be called for tasks woken or migrated
onto the cpu, and ops.dispatch() can run on it.

The hooks can't call the ops. They run under the rq lock with IRQs off while
the ops can be sleepable BPF programs, and handle_hotplug() needs the
rebuilt sched domains for its idle topology update.

Track SCX_RQ_ONLINE in handle_hotplug() alone. Set it right after the root's
ops.cpu_online(). Clear it and move the cpu's tasks to its local DSQ when
the cpu goes down. Sched domain rebuilds, which take a live cpu's rq offline
and online again, no longer touch the flag, so a remote dispatch can't see
it cleared by a rebuild and bounce to the global DSQ.

Between 2 and 3, tasks that land on the cpu now go to its local DSQ without
ops.enqueue(), and with sub-schedulers a task whose scheduler lacks caps on
the cpu is admitted anyway and counted in SCX_EV_SUB_FORCED_ADMIT. Both
already happen between 1 and 2.

Fixes: 60c27fb59f6c ("sched_ext: Implement sched_ext_ops.cpu_online/offline()")
Cc: stable@vger.kernel.org # v6.12+
Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
[ sashal: added a scx_rq_activate() call to the sched_cpu_deactivate() rollback in core.c, dropped sub-scheduler hunks, inlined the missing drain_offline_rq() helper, and moved the paths to kernel/sched/ext.c. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/sched/core.c  |  1 +
 kernel/sched/ext.c   | 82 +++++++++++++++++++++++---------------------
 kernel/sched/sched.h |  7 ++--
 3 files changed, 47 insertions(+), 43 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index a1d0b22e46b7a..04d09274f0b15 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -8269,6 +8269,7 @@ int sched_cpu_deactivate(unsigned int cpu)
 	if (ret) {
 		sched_smt_present_inc(cpu);
 		sched_set_rq_online(rq, cpu);
+		scx_rq_activate(rq);
 		balance_push_set(cpu, false);
 		set_cpu_active(cpu, true);
 		sched_update_numa(cpu, true);
diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 7a4b23e48cc6f..63e83e55d170f 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -2003,11 +2003,11 @@ static void direct_dispatch(struct task_struct *p, u64 enq_flags)
 static bool scx_rq_online(struct rq *rq)
 {
 	/*
-	 * Test both cpu_active() and %SCX_RQ_ONLINE. %SCX_RQ_ONLINE indicates
-	 * the online state as seen from the BPF scheduler. cpu_active() test
-	 * guarantees that, if this function returns %true, %SCX_RQ_ONLINE will
-	 * stay set until the current scheduling operation is complete even if
-	 * we aren't locking @rq.
+	 * Test both cpu_active() and %SCX_RQ_ONLINE. %SCX_RQ_ONLINE is set
+	 * after ops.cpu_online() and cleared when the cpu goes down.
+	 * cpu_active() test guarantees that, if this function returns %true,
+	 * %SCX_RQ_ONLINE will stay set until the current scheduling operation
+	 * is complete even if we aren't locking @rq.
 	 */
 	return likely((rq->scx.flags & SCX_RQ_ONLINE) && cpu_active(cpu_of(rq)));
 }
@@ -2114,7 +2114,7 @@ static void set_task_runnable(struct rq *rq, struct task_struct *p)
 	}
 
 	/*
-	 * list_add_tail() must be used. scx_ops_bypass() and rq_offline_scx()
+	 * list_add_tail() must be used. scx_ops_bypass() and handle_hotplug()
 	 * depend on tasks being appended to the runnable_list.
 	 */
 	list_add_tail(&p->scx.runnable_node, &rq->scx.runnable_list);
@@ -2831,7 +2831,7 @@ static int balance_one(struct rq *rq, struct task_struct *prev)
 	/*
 	 * scx_rq_online() can't be used. Its cpu_active() test goes false
 	 * before CPU hotplug waits for an RCU grace period, and
-	 * rq_offline_scx() moves this CPU's tasks to the local DSQ only after
+	 * handle_hotplug() moves this CPU's tasks to the local DSQ only after
 	 * the wait. The grace period can depend on those tasks running.
 	 */
 	if (!SCX_HAS_OP(dispatch) || scx_rq_bypassing(rq) ||
@@ -3511,6 +3511,29 @@ static void handle_hotplug(struct rq *rq, bool online)
 {
 	int cpu = cpu_of(rq);
 
+	if (!online) {
+		struct task_struct *p, *n;
+
+		guard(rq_lock_irqsave)(rq);
+		update_rq_clock(rq);
+		rq->scx.flags &= ~SCX_RQ_ONLINE;
+
+		/*
+		 * An offline CPU no longer calls ops.dispatch(). Re-enqueue its
+		 * tasks onto the local DSQ so that they run here and
+		 * balance_push() moves them off.
+		 */
+		list_for_each_entry_safe_reverse(p, n, &rq->scx.runnable_list, scx.runnable_node) {
+			struct sched_enq_and_set_ctx ctx;
+
+			if (p->scx.dsq == &rq->scx.local_dsq)
+				continue;
+
+			sched_deq_and_put_task(p, DEQUEUE_SAVE | DEQUEUE_MOVE | DEQUEUE_NOCLOCK, &ctx);
+			sched_enq_and_set_task(&ctx);
+		}
+	}
+
 	atomic_long_inc(&scx_hotplug_seq);
 
 	if (online && SCX_HAS_OP(cpu_online))
@@ -3521,6 +3544,18 @@ static void handle_hotplug(struct rq *rq, bool online)
 		scx_ops_exit(SCX_ECODE_ACT_RESTART | SCX_ECODE_RSN_HOTPLUG,
 			     "cpu %d going %s, exiting scheduler", cpu,
 			     online ? "online" : "offline");
+
+	if (online) {
+		/*
+		 * The cpu must not call ops.enqueue() or ops.dispatch() before
+		 * ops.cpu_online(). The core's rq online state can't gate them,
+		 * as the sched domain rebuild in sched_cpu_activate() can put
+		 * @rq online before this function runs. Set %SCX_RQ_ONLINE
+		 * here.
+		 */
+		guard(rq_lock_irqsave)(rq);
+		rq->scx.flags |= SCX_RQ_ONLINE;
+	}
 }
 
 void scx_rq_activate(struct rq *rq)
@@ -3533,36 +3568,6 @@ void scx_rq_deactivate(struct rq *rq)
 	handle_hotplug(rq, false);
 }
 
-static void rq_online_scx(struct rq *rq)
-{
-	rq->scx.flags |= SCX_RQ_ONLINE;
-}
-
-static void rq_offline_scx(struct rq *rq)
-{
-	struct task_struct *p, *n;
-
-	rq->scx.flags &= ~SCX_RQ_ONLINE;
-
-	/* sched domain rebuilds call rq_offline with the CPU staying alive */
-	if (cpu_active(cpu_of(rq)))
-		return;
-
-	/*
-	 * An offline CPU no longer calls ops.dispatch(). Re-enqueue its tasks
-	 * onto the local DSQ so that they run here and balance_push() moves
-	 * them off.
-	 */
-	list_for_each_entry_safe_reverse(p, n, &rq->scx.runnable_list, scx.runnable_node) {
-		struct sched_enq_and_set_ctx ctx;
-
-		if (p->scx.dsq == &rq->scx.local_dsq)
-			continue;
-		sched_deq_and_put_task(p, DEQUEUE_SAVE | DEQUEUE_MOVE | DEQUEUE_NOCLOCK, &ctx);
-		sched_enq_and_set_task(&ctx);
-	}
-}
-
 #else	/* CONFIG_SMP */
 
 static bool test_and_clear_cpu_idle(int cpu) { return false; }
@@ -4243,9 +4248,6 @@ DEFINE_SCHED_CLASS(ext) = {
 	.select_task_rq		= select_task_rq_scx,
 	.task_woken		= task_woken_scx,
 	.set_cpus_allowed	= set_cpus_allowed_scx,
-
-	.rq_online		= rq_online_scx,
-	.rq_offline		= rq_offline_scx,
 #endif
 
 	.task_tick		= task_tick_scx,
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 855b7e39ae89d..916d23afb2ae9 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -777,9 +777,10 @@ struct cfs_rq {
 /* scx_rq->flags, protected by the rq lock */
 enum scx_rq_flags {
 	/*
-	 * A hotplugged CPU starts scheduling before rq_online_scx(). Track
-	 * ops.cpu_on/offline() state so that ops.enqueue/dispatch() are called
-	 * only while the BPF scheduler considers the CPU to be online.
+	 * Set right after ops.cpu_online() when a CPU comes up and cleared when
+	 * the CPU goes down, see handle_hotplug(). A hotplugged CPU starts
+	 * scheduling before %SCX_RQ_ONLINE is set. ops.enqueue() and
+	 * ops.dispatch() are called for the CPU only while the flag is set.
 	 */
 	SCX_RQ_ONLINE		= 1 << 0,
 	SCX_RQ_CAN_STOP_TICK	= 1 << 1,
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 099/555] Bluetooth: l2cap: defer conn param update to avoid conn->lock/hdev->lock inversion
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (97 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 098/555] sched_ext: Fix ops.enqueue/dispatch() calls before ops.cpu_online() Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 100/555] Revert "mm/hugetlb_vmemmap: fix incorrect vmemmap restore in rollback" Greg Kroah-Hartman
                   ` (455 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Mikhail Gavrilov, Paul Menzel,
	Luiz Augusto von Dentz, Sasha Levin

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

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

From: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>

[ Upstream commit 91b5a598b5285da794b72619f31777b62dd336f8 ]

When a BLE peripheral sends an L2CAP Connection Parameter Update Request
the processing path is:

  process_pending_rx()          [takes conn->lock]
    l2cap_le_sig_channel()
      l2cap_conn_param_update_req()
        hci_le_conn_update()    [takes hdev->lock]

Meanwhile other code paths take the locks in the opposite order:

  l2cap_chan_connect()          [takes hdev->lock]
    ...
      mutex_lock(&conn->lock)

  l2cap_conn_ready()            [hdev->lock via hci_cb_list_lock]
    ...
      mutex_lock(&conn->lock)

This is a classic AB/BA deadlock which lockdep reports as a circular
locking dependency when connecting a BLE MIDI keyboard (Carry-On FC-49).

Fix this by making hci_le_conn_update() defer the HCI command through
hci_cmd_sync_queue() so it no longer needs to take hdev->lock in the
caller context.  The sync callback uses __hci_cmd_sync_status_sk() to
wait for the HCI_EV_LE_CONN_UPDATE_COMPLETE event, then updates the
stored connection parameters (hci_conn_params) and notifies userspace
(mgmt_new_conn_param) only after the controller has confirmed the update.

A reference on hci_conn is held via hci_conn_get()/hci_conn_put() for
the lifetime of the queued work to prevent use-after-free, and
hci_conn_valid() is checked before proceeding in case the connection was
removed while the work was pending.  The hci_dev_lock is held across
hci_conn_valid() and all conn field accesses to prevent a concurrent
disconnect from invalidating the connection mid-use.

Fixes: f044eb0524a0 ("Bluetooth: Store latency and supervision timeout in connection params")
Signed-off-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/net/bluetooth/hci_core.h |   2 +-
 net/bluetooth/hci_conn.c         | 105 +++++++++++++++++++++++++------
 net/bluetooth/l2cap_core.c       |  12 +---
 3 files changed, 89 insertions(+), 30 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index d247e088ebd01..3dad216418e4d 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -2444,7 +2444,7 @@ void mgmt_adv_monitor_device_lost(struct hci_dev *hdev, u16 handle,
 				  bdaddr_t *bdaddr, u8 addr_type);
 
 int hci_abort_conn(struct hci_conn *conn, u8 reason);
-u8 hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, u16 latency,
+void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, u16 latency,
 		      u16 to_multiplier);
 void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __le64 rand,
 		      __u8 ltk[16], __u8 key_size);
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 56276caf655a6..0f1d7c623f9f1 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -505,40 +505,107 @@ bool hci_setup_sync(struct hci_conn *conn, __u16 handle)
 	return hci_setup_sync_conn(conn, handle);
 }
 
-u8 hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, u16 latency,
-		      u16 to_multiplier)
+struct le_conn_update_data {
+	struct hci_conn *conn;
+	u16	min;
+	u16	max;
+	u16	latency;
+	u16	to_multiplier;
+};
+
+static int le_conn_update_sync(struct hci_dev *hdev, void *data)
 {
-	struct hci_dev *hdev = conn->hdev;
+	struct le_conn_update_data *d = data;
+	struct hci_conn *conn = d->conn;
 	struct hci_conn_params *params;
 	struct hci_cp_le_conn_update cp;
+	u16 timeout;
+	u8 store_hint;
+	int err;
 
+	/* Verify connection is still alive and read conn fields under
+	 * the same lock to prevent a concurrent disconnect from freeing
+	 * or reusing the connection while we build the HCI command.
+	 */
 	hci_dev_lock(hdev);
 
-	params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type);
-	if (params) {
-		params->conn_min_interval = min;
-		params->conn_max_interval = max;
-		params->conn_latency = latency;
-		params->supervision_timeout = to_multiplier;
+	if (!hci_conn_valid(hdev, conn)) {
+		hci_dev_unlock(hdev);
+		return -ECANCELED;
 	}
 
-	hci_dev_unlock(hdev);
-
 	memset(&cp, 0, sizeof(cp));
 	cp.handle		= cpu_to_le16(conn->handle);
-	cp.conn_interval_min	= cpu_to_le16(min);
-	cp.conn_interval_max	= cpu_to_le16(max);
-	cp.conn_latency		= cpu_to_le16(latency);
-	cp.supervision_timeout	= cpu_to_le16(to_multiplier);
+	cp.conn_interval_min	= cpu_to_le16(d->min);
+	cp.conn_interval_max	= cpu_to_le16(d->max);
+	cp.conn_latency		= cpu_to_le16(d->latency);
+	cp.supervision_timeout	= cpu_to_le16(d->to_multiplier);
 	cp.min_ce_len		= cpu_to_le16(0x0000);
 	cp.max_ce_len		= cpu_to_le16(0x0000);
+	timeout			= conn->conn_timeout;
+
+	hci_dev_unlock(hdev);
+
+	err = __hci_cmd_sync_status_sk(hdev, HCI_OP_LE_CONN_UPDATE,
+				       sizeof(cp), &cp,
+				       HCI_EV_LE_CONN_UPDATE_COMPLETE,
+				       timeout, NULL);
+	if (err)
+		return err;
+
+	/* Update stored connection parameters after the controller has
+	 * confirmed the update via the LE Connection Update Complete event.
+	 */
+	hci_dev_lock(hdev);
+
+	params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type);
+	if (params) {
+		params->conn_min_interval = d->min;
+		params->conn_max_interval = d->max;
+		params->conn_latency = d->latency;
+		params->supervision_timeout = d->to_multiplier;
+		store_hint = 0x01;
+	} else {
+		store_hint = 0x00;
+	}
 
-	hci_send_cmd(hdev, HCI_OP_LE_CONN_UPDATE, sizeof(cp), &cp);
+	hci_dev_unlock(hdev);
 
-	if (params)
-		return 0x01;
+	mgmt_new_conn_param(hdev, &conn->dst, conn->dst_type, store_hint,
+			    d->min, d->max, d->latency, d->to_multiplier);
 
-	return 0x00;
+	return 0;
+}
+
+static void le_conn_update_complete(struct hci_dev *hdev, void *data, int err)
+{
+	struct le_conn_update_data *d = data;
+
+	hci_conn_put(d->conn);
+	kfree(d);
+}
+
+void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, u16 latency,
+			u16 to_multiplier)
+{
+	struct le_conn_update_data *d;
+
+	d = kzalloc_obj(*d);
+	if (!d)
+		return;
+
+	hci_conn_get(conn);
+	d->conn = conn;
+	d->min = min;
+	d->max = max;
+	d->latency = latency;
+	d->to_multiplier = to_multiplier;
+
+	if (hci_cmd_sync_queue(conn->hdev, le_conn_update_sync, d,
+			       le_conn_update_complete) < 0) {
+		hci_conn_put(conn);
+		kfree(d);
+	}
 }
 
 void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __le64 rand,
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 0deb94b8b13f2..541986a5cf0f7 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -4835,16 +4835,8 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
 	l2cap_send_cmd(conn, cmd->ident, L2CAP_CONN_PARAM_UPDATE_RSP,
 		       sizeof(rsp), &rsp);
 
-	if (!err) {
-		u8 store_hint;
-
-		store_hint = hci_le_conn_update(hcon, min, max, latency,
-						to_multiplier);
-		mgmt_new_conn_param(hcon->hdev, &hcon->dst, hcon->dst_type,
-				    store_hint, min, max, latency,
-				    to_multiplier);
-
-	}
+	if (!err)
+		hci_le_conn_update(hcon, min, max, latency, to_multiplier);
 
 	return 0;
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 100/555] Revert "mm/hugetlb_vmemmap: fix incorrect vmemmap restore in rollback"
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (98 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 099/555] Bluetooth: l2cap: defer conn param update to avoid conn->lock/hdev->lock inversion Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 101/555] selftests: net: reuseport_bpf_numa: include stdbool.h Greg Kroah-Hartman
                   ` (454 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Sasha Levin

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

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

This reverts commit 4b7920465ee8e19fa0837ef26e64d7b2ee9d0bdd.

Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 mm/hugetlb_vmemmap.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c
index 52e68a7df2c88..1394c13c1516f 100644
--- a/mm/hugetlb_vmemmap.c
+++ b/mm/hugetlb_vmemmap.c
@@ -207,8 +207,6 @@ static void vmemmap_remap_pte(pte_t *pte, unsigned long addr,
 
 	/* Remapping the head page requires r/w */
 	if (unlikely(walk->nr_walked == 0 && walk->vmemmap_head)) {
-		VM_WARN_ON_ONCE(!PageHead((const struct page *)addr));
-
 		list_del(&walk->vmemmap_head->lru);
 
 		/*
@@ -220,8 +218,6 @@ static void vmemmap_remap_pte(pte_t *pte, unsigned long addr,
 
 		entry = mk_pte(walk->vmemmap_head, PAGE_KERNEL);
 	} else {
-		VM_WARN_ON_ONCE(!PageTail((const struct page *)addr));
-
 		/*
 		 * Remap the tail pages as read-only to catch illegal write
 		 * operation to the tail pages.
@@ -236,28 +232,33 @@ static void vmemmap_remap_pte(pte_t *pte, unsigned long addr,
 static void vmemmap_restore_pte(pte_t *pte, unsigned long addr,
 				struct vmemmap_remap_walk *walk)
 {
-	struct page *src = pte_page(ptep_get(pte)), *dst;
+	struct page *page;
+	struct page *from, *to;
+
+	page = list_first_entry(walk->vmemmap_pages, struct page, lru);
+	list_del(&page->lru);
 
 	/*
-	 * When rolling back vmemmap_remap_free(), keep the copied head page
-	 * mapping and restore only PTEs currently pointing at the shared tail
-	 * page.
+	 * Initialize tail pages in the newly allocated vmemmap page.
+	 *
+	 * There is folio-scope metadata that is encoded in the first few
+	 * tail pages.
+	 *
+	 * Use the value last tail page in the page with the head page
+	 * to initialize the rest of tail pages.
 	 */
-	if (walk->vmemmap_tail && walk->vmemmap_tail != src)
-		return;
-
-	VM_WARN_ON_ONCE(PageHead((const struct page *)addr));
-
-	dst = list_first_entry(walk->vmemmap_pages, struct page, lru);
-	list_del(&dst->lru);
-	copy_page(page_to_virt(dst), page_to_virt(src));
+	from = compound_head((struct page *)addr) +
+		PAGE_SIZE / sizeof(struct page) - 1;
+	to = page_to_virt(page);
+	for (int i = 0; i < PAGE_SIZE / sizeof(struct page); i++, to++)
+		*to = *from;
 
 	/*
 	 * Makes sure that preceding stores to the page contents become visible
 	 * before the set_pte_at() write.
 	 */
 	smp_wmb();
-	set_pte_at(&init_mm, addr, pte, mk_pte(dst, PAGE_KERNEL));
+	set_pte_at(&init_mm, addr, pte, mk_pte(page, PAGE_KERNEL));
 }
 
 /**
@@ -323,7 +324,6 @@ static int vmemmap_remap_free(unsigned long start, unsigned long end,
 	 */
 	walk = (struct vmemmap_remap_walk) {
 		.remap_pte	= vmemmap_restore_pte,
-		.vmemmap_tail	= vmemmap_tail,
 		.vmemmap_pages	= vmemmap_pages,
 		.flags		= 0,
 	};
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 101/555] selftests: net: reuseport_bpf_numa: include stdbool.h
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (99 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 100/555] Revert "mm/hugetlb_vmemmap: fix incorrect vmemmap restore in rollback" Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 102/555] smb/client: Prevent error pointer dereference Greg Kroah-Hartman
                   ` (453 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Sasha Levin

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

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

The backport of commit 88b8d85e889e ("selftests: net: reuseport_bpf_numa:
consider cpuless numa node") uses bool, and nothing this file includes
provides it in this tree, so the selftest fails to build with "unknown
type name 'bool'".

Upstream fixed this with commit f2662ec26b26 ("selftests: kselftest:
Create ksft_print_dbg_msg()"), which includes stdbool.h from kselftest.h.
That commit breaks the nolibc selftests that include kselftest.h in this
tree, so include <stdbool.h> here instead.

Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/testing/selftests/net/reuseport_bpf_numa.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/net/reuseport_bpf_numa.c b/tools/testing/selftests/net/reuseport_bpf_numa.c
index b04b511809ad2..627b56f0129c0 100644
--- a/tools/testing/selftests/net/reuseport_bpf_numa.c
+++ b/tools/testing/selftests/net/reuseport_bpf_numa.c
@@ -14,6 +14,7 @@
 #include <linux/in.h>
 #include <linux/unistd.h>
 #include <sched.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 102/555] smb/client: Prevent error pointer dereference
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (100 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 101/555] selftests: net: reuseport_bpf_numa: include stdbool.h Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 103/555] smb: client: validate descriptor headers before query result allocation Greg Kroah-Hartman
                   ` (452 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Dan Carpenter, Bharath SM,
	Steve French, Sasha Levin

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

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

From: Dan Carpenter <dan.carpenter@linaro.org>

[ Upstream commit 7a2158b73c36903e8822dae5442c27d6d0e1014b ]

The cifs_sb_tlink() function can return error pointers, but this code
dereferences it before checking for error pointers.  Re-order the code
to fix that.

Fixes: 0f9b6b045bb2 ("fs/smb/client: implement chmod() for SMB3 POSIX Extensions")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Bharath SM <bharathsm@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Stable-dep-of: ffb59029c0d5 ("smb: client: validate descriptor headers before query result allocation")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/smb/client/cifsacl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c
index eace735190c63..49ef75c4d35a5 100644
--- a/fs/smb/client/cifsacl.c
+++ b/fs/smb/client/cifsacl.c
@@ -1734,14 +1734,16 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode,
 	struct smb_ntsd *pntsd = NULL; /* acl obtained from server */
 	struct smb_ntsd *pnntsd = NULL; /* modified acl to be sent to server */
 	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
-	struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
+	struct tcon_link *tlink;
 	struct smb_version_operations *ops;
 	bool mode_from_sid, id_from_sid;
-	bool posix = tlink_tcon(tlink)->posix_extensions;
 	const u32 info = 0;
+	bool posix;
 
+	tlink = cifs_sb_tlink(cifs_sb);
 	if (IS_ERR(tlink))
 		return PTR_ERR(tlink);
+	posix = tlink_tcon(tlink)->posix_extensions;
 
 	ops = tlink_tcon(tlink)->ses->server->ops;
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 103/555] smb: client: validate descriptor headers before query result allocation
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (101 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 102/555] smb/client: Prevent error pointer dereference Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 104/555] dm cache: validate the discard block size before narrowing Greg Kroah-Hartman
                   ` (451 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, liuyong, Namjae Jeon,
	Paulo Alcantara, Sasha Levin

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

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

From: liuyong <pkfxxxing@gmail.com>

[ Upstream commit ffb59029c0d52bf76fdd2678f5d6fd13e26220dd ]

query_info() uses the server's returned length instead of the caller's
minimum when a dynamic result is requested. A zero-length ACL response
can therefore return ZERO_SIZE_PTR to id_mode_to_cifs_acl(), whose
ownership-change path reads dacloffset before checking the header size.
A KASAN-enabled test shows a read at address 0x20 and a kernel Oops.

Validate the returned range and the caller's minimum before allocating
the dynamic result. Keep the reported length zero if validation fails.

Use the security descriptor header size as the minimum in SMB2_query_acl().
DACL-only and SACL-only xattr queries do not require owner and group SIDs,
so enforcing MIN_SEC_DESC_LEN would reject short descriptors that these
queries could previously return. The rewrite paths validate the required
owner/group SIDs and DACL separately before using their contents.

These issues were discovered and fixed by Qihoo 360's Tulongfeng
multi-agent system.

Fixes: 9ee2afe5207b ("cifs: prevent copying past input buffer boundaries")
Cc: stable@vger.kernel.org
Signed-off-by: liuyong <pkfxxxing@gmail.com>
Reviewed-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/smb/client/cifsacl.h | 14 --------------
 fs/smb/client/smb2pdu.c | 11 ++++++++++-
 2 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/fs/smb/client/cifsacl.h b/fs/smb/client/cifsacl.h
index 31b51a8fc2561..ebc1b7c08c6ad 100644
--- a/fs/smb/client/cifsacl.h
+++ b/fs/smb/client/cifsacl.h
@@ -93,18 +93,4 @@ struct owner_group_sids {
 	struct owner_sid group;
 } __packed;
 
-/*
- * Minimum security identifier can be one for system defined Users
- * and Groups such as NULL SID and World or Built-in accounts such
- * as Administrator and Guest and consists of
- * Revision + Num (Sub)Auths + Authority + Domain (one Subauthority)
- */
-#define MIN_SID_LEN  (1 + 1 + 6 + 4) /* in bytes */
-
-/*
- * Minimum security descriptor can be one without any SACL and DACL and can
- * consist of revision, type, and two sids of minimum size for owner and group
- */
-#define MIN_SEC_DESC_LEN  (sizeof(struct smb_ntsd) + (2 * MIN_SID_LEN))
-
 #endif /* _CIFSACL_H */
diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index a92226e3e6e9b..8bbeaa106287c 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -3931,6 +3931,14 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon,
 				ses->Suid, info_class, (__u32)info_type);
 
 	if (dlen) {
+		rc = smb2_validate_iov(le16_to_cpu(rsp->OutputBufferOffset),
+				       le32_to_cpu(rsp->OutputBufferLength),
+				       &rsp_iov, min_len);
+		if (rc) {
+			*dlen = 0;
+			goto qinf_exit;
+		}
+
 		*dlen = le32_to_cpu(rsp->OutputBufferLength);
 		if (!*data) {
 			*data = kmalloc(*dlen, GFP_KERNEL);
@@ -4004,7 +4012,8 @@ SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon,
 
 	return query_info(xid, tcon, persistent_fid, volatile_fid,
 			  0, SMB2_O_INFO_SECURITY, additional_info,
-			  SMB2_MAX_BUFFER_SIZE, MIN_SEC_DESC_LEN, data, plen);
+			  SMB2_MAX_BUFFER_SIZE, sizeof(struct smb_ntsd),
+			  data, plen);
 }
 
 int
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 104/555] dm cache: validate the discard block size before narrowing
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (102 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 103/555] smb: client: validate descriptor headers before query result allocation Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 105/555] dm: fix use-after-free when dm_get_device() widens the open mode Greg Kroah-Hartman
                   ` (450 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, syzbot+c8564fc0a96e3ecbe4d4,
	Kirtikumar Anandrao Ramchandani, Mikulas Patocka, Sasha Levin

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

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

From: Kirtikumar Anandrao Ramchandani <kirtiar15502@gmail.com>

[ Upstream commit df8daa4d916c88ef7888c738e0eb3b6f11714a6f ]

The discard block size doubles until the origin fits within the discard
bitset limit. too_many_discard_blocks() passes this sector_t size to
sector_div(), whose divisor is only 32 bits. Once the size exceeds that
range, the division uses a truncated divisor, which can become zero.

Use a 64-bit divisor when checking the block count. The selected size is
stored in a u32, so reject sizes that cannot be represented before the
assignment and before calculating the bitset size. This prevents a
truncated zero size from reaching dm_sector_div_up().

An earlier proposal checks whether the mapped length exceeds the origin
device. This fix also covers an origin device whose valid size requires a
discard block size beyond the field's range.

Reported-by: syzbot+c8564fc0a96e3ecbe4d4@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=c8564fc0a96e3ecbe4d4
Cc: stable@vger.kernel.org
Fixes: 08b184514f65 ("dm cache: revert 'prevent corruption caused by discard_block_size > cache_block_size'")
Signed-off-by: Kirtikumar Anandrao Ramchandani <kirtiar15502@gmail.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
[ sashal: Adjusted the include context: added only #include <linux/math64.h> between init.h and mempool.h, since kstrtox.h isn't present in this tree. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/md/dm-cache-target.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index a9e54bdd378bd..a3706ebdd2ac2 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -16,6 +16,7 @@
 #include <linux/dm-kcopyd.h>
 #include <linux/jiffies.h>
 #include <linux/init.h>
+#include <linux/math64.h>
 #include <linux/mempool.h>
 #include <linux/module.h>
 #include <linux/rwsem.h>
@@ -2389,9 +2390,7 @@ static int create_cache_policy(struct cache *cache, struct cache_args *ca,
 static bool too_many_discard_blocks(sector_t discard_block_size,
 				    sector_t origin_size)
 {
-	(void) sector_div(origin_size, discard_block_size);
-
-	return origin_size > MAX_DISCARD_BLOCKS;
+	return div64_u64(origin_size, discard_block_size) > MAX_DISCARD_BLOCKS;
 }
 
 static sector_t calculate_discard_block_size(sector_t cache_block_size,
@@ -2428,6 +2427,7 @@ static int cache_create(struct cache_args *ca, struct cache **result)
 	struct cache *cache;
 	struct dm_target *ti = ca->ti;
 	dm_block_t origin_blocks;
+	sector_t discard_block_size;
 	struct dm_cache_metadata *cmd;
 	bool may_format = ca->features.mode == CM_WRITE;
 
@@ -2527,9 +2527,15 @@ static int cache_create(struct cache_args *ca, struct cache **result)
 	}
 	clear_bitset(cache->dirty_bitset, from_cblock(cache->cache_size));
 
-	cache->discard_block_size =
+	discard_block_size =
 		calculate_discard_block_size(cache->sectors_per_block,
 					     cache->origin_sectors);
+	if (discard_block_size > U32_MAX) {
+		*error = "Discard block size exceeds 32 bits";
+		r = -EOVERFLOW;
+		goto bad;
+	}
+	cache->discard_block_size = discard_block_size;
 	cache->discard_nr_blocks = to_dblock(dm_sector_div_up(cache->origin_sectors,
 							      cache->discard_block_size));
 	cache->discard_bitset = alloc_bitset(from_dblock(cache->discard_nr_blocks));
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 105/555] dm: fix use-after-free when dm_get_device() widens the open mode
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (103 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 104/555] dm cache: validate the discard block size before narrowing Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 106/555] dm: fail a REQ_PREFLUSH bio with data when its preflush fails Greg Kroah-Hartman
                   ` (449 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Ming Hung Tsai, Mikulas Patocka,
	Sasha Levin, Claude Opus 5

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

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

From: Ming-Hung Tsai <mtsai@redhat.com>

[ Upstream commit c834161ded1a141a58d5f03b24f6894291222c96 ]

There's an UAF bug in dm_get_device(): when a table construction calls
dm_get_device() on the same device twice with widen access mode (e.g.,
read-only first then read-write), the second dm_get_device() calls
upgrade_mode(), which reopens the device in upgraded mode, making
previously returned dm_dev* a stale pointer.

Fixing approaches:
- Add per-mode views (dm_dev_ref) from a per-device dm_dev_internal to
  multiple table_devices.
- Keep reusing the dm_dev_ref when the requested mode is included, i.e.,
  a read-only reference can reuse the read-write opened device within a
  table.
- Maintain a canonical block_device pointer in dm_dev_internal for
  handling the DM_TABLE_DEPS ioctl.

Also tweak the way of mode sharing check in find_ref() to
"(x & mask) == mask". The result stays the same to the previous
upgrade_mode() guard "(x | mask) == x".

Pros: keep the relationship between dm_dev_internal and table_device:
one dm_dev_internal per device, regardless the mode, so the output of
DMM_TABLE_DEPS ioctl unchanged.

Cons: extra dm_dev_ref allocation.

Note that now the table_device's count not necessarily mean the number
tables referecing this <dev, mode> pair, since we're allowing multiple
references within a table.

Signed-off-by: Ming Hung Tsai <mtsai@redhat.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Fixes: 86f1152b117a ("dm: allow active and inactive tables to share dm_devs")
Cc: stable@vger.kernel.org
[ sashal: Adapted dm_get_device() and dm_put_device() to the older code, which takes devices_lock and exits through unlock_ret_r/unlock_ret labels instead of returning directly, with kmalloc_obj() context differences. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/md/dm-ioctl.c |   2 +-
 drivers/md/dm-table.c | 142 +++++++++++++++++++++++-------------------
 drivers/md/dm.c       |   2 +-
 drivers/md/dm.h       |  18 +++++-
 4 files changed, 97 insertions(+), 67 deletions(-)

diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index bf547ffb9647e..671cac33b2563 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1685,7 +1685,7 @@ static void retrieve_deps(struct dm_table *table,
 	deps->count = count;
 	count = 0;
 	list_for_each_entry(dd, dm_table_get_devices(table), list)
-		deps->dev[count++] = huge_encode_dev(dd->dm_dev->bdev->bd_dev);
+		deps->dev[count++] = huge_encode_dev(dd->bdev->bd_dev);
 
 	param->data_size = param->data_start + needed;
 
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 505f8a900ec9e..35eac563f016c 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -167,14 +167,16 @@ int dm_table_create(struct dm_table **result, blk_mode_t mode,
 
 static void free_devices(struct list_head *devices, struct mapped_device *md)
 {
-	struct list_head *tmp, *next;
-
-	list_for_each_safe(tmp, next, devices) {
-		struct dm_dev_internal *dd =
-		    list_entry(tmp, struct dm_dev_internal, list);
-		DMWARN("%s: dm_table_destroy: dm_put_device call missing for %s",
-		       dm_device_name(md), dd->dm_dev->name);
-		dm_put_table_device(md, dd->dm_dev);
+	struct dm_dev_internal *dd, *dd_next;
+	struct dm_dev_ref *ref, *ref_next;
+
+	list_for_each_entry_safe(dd, dd_next, devices, list) {
+		list_for_each_entry_safe(ref, ref_next, &dd->refs, list) {
+			DMWARN("%s: dm_table_destroy: dm_put_device call missing for %s",
+			       dm_device_name(md), ref->dm_dev->name);
+			dm_put_table_device(md, ref->dm_dev);
+			kfree(ref);
+		}
 		kfree(dd);
 	}
 }
@@ -220,12 +222,27 @@ static struct dm_dev_internal *find_device(struct list_head *l, dev_t dev)
 	struct dm_dev_internal *dd;
 
 	list_for_each_entry(dd, l, list)
-		if (dd->dm_dev->bdev->bd_dev == dev)
+		if (dd->bdev->bd_dev == dev)
 			return dd;
 
 	return NULL;
 }
 
+/*
+ * See if the device is already open with a mode that covers the
+ * requested one.
+ */
+static struct dm_dev_ref *find_ref(struct dm_dev_internal *dd, blk_mode_t mode)
+{
+	struct dm_dev_ref *ref;
+
+	list_for_each_entry(ref, &dd->refs, list)
+		if ((ref->dm_dev->mode & mode) == mode)
+			return ref;
+
+	return NULL;
+}
+
 /*
  * If possible, this checks an area of a destination device is invalid.
  */
@@ -305,31 +322,6 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
 	return 0;
 }
 
-/*
- * This upgrades the mode on an already open dm_dev, being
- * careful to leave things as they were if we fail to reopen the
- * device and not to touch the existing bdev field in case
- * it is accessed concurrently.
- */
-static int upgrade_mode(struct dm_dev_internal *dd, blk_mode_t new_mode,
-			struct mapped_device *md)
-{
-	int r;
-	struct dm_dev *old_dev, *new_dev;
-
-	old_dev = dd->dm_dev;
-
-	r = dm_get_table_device(md, dd->dm_dev->bdev->bd_dev,
-				dd->dm_dev->mode | new_mode, &new_dev);
-	if (r)
-		return r;
-
-	dd->dm_dev = new_dev;
-	dm_put_table_device(md, old_dev);
-
-	return 0;
-}
-
 /*
  * Note: the __ref annotation is because this function can call the __init
  * marked early_lookup_bdev when called during early boot code from dm-init.c.
@@ -362,7 +354,9 @@ EXPORT_SYMBOL(dm_devt_from_path);
 
 /*
  * Add a device to the list, or just increment the usage count if
- * it's already present.
+ * it's already present with a mode that covers the requested one.
+ * Otherwise open the device again with the requested mode, so the
+ * dm_devs returned earlier stay valid.
  */
 int dm_get_device(struct dm_target *ti, const char *path, blk_mode_t mode,
 		  struct dm_dev **result)
@@ -370,6 +364,7 @@ int dm_get_device(struct dm_target *ti, const char *path, blk_mode_t mode,
 	int r;
 	dev_t dev;
 	struct dm_dev_internal *dd;
+	struct dm_dev_ref *ref;
 	struct dm_table *t = ti->table;
 
 	BUG_ON(!t);
@@ -384,34 +379,48 @@ int dm_get_device(struct dm_target *ti, const char *path, blk_mode_t mode,
 	down_write(&t->devices_lock);
 
 	dd = find_device(&t->devices, dev);
-	if (!dd) {
-		dd = kmalloc(sizeof(*dd), GFP_KERNEL);
+	if (dd) {
+		ref = find_ref(dd, mode);
+		if (ref) {
+			refcount_inc(&ref->count);
+			goto out;
+		}
+	} else {
+		dd = kmalloc_obj(*dd);
 		if (!dd) {
 			r = -ENOMEM;
 			goto unlock_ret_r;
 		}
+		INIT_LIST_HEAD(&dd->refs);
+	}
 
-		r = dm_get_table_device(t->md, dev, mode, &dd->dm_dev);
-		if (r) {
-			kfree(dd);
-			goto unlock_ret_r;
-		}
+	ref = kmalloc_obj(*ref);
+	if (!ref) {
+		r = -ENOMEM;
+		goto bad;
+	}
 
-		refcount_set(&dd->count, 1);
-		list_add(&dd->list, &t->devices);
-		goto out;
+	r = dm_get_table_device(t->md, dev, mode, &ref->dm_dev);
+	if (r) {
+		kfree(ref);
+		goto bad;
+	}
+	refcount_set(&ref->count, 1);
 
-	} else if (dd->dm_dev->mode != (mode | dd->dm_dev->mode)) {
-		r = upgrade_mode(dd, mode, t->md);
-		if (r)
-			goto unlock_ret_r;
+	/* A device in the list always has at least one ref */
+	if (list_empty(&dd->refs)) {
+		dd->bdev = ref->dm_dev->bdev;
+		list_add(&dd->list, &t->devices);
 	}
-	refcount_inc(&dd->count);
+	list_add_tail(&ref->list, &dd->refs);
 out:
 	up_write(&t->devices_lock);
-	*result = dd->dm_dev;
+	*result = ref->dm_dev;
 	return 0;
 
+bad:
+	if (list_empty(&dd->refs))
+		kfree(dd);
 unlock_ret_r:
 	up_write(&t->devices_lock);
 	return r;
@@ -458,26 +467,31 @@ static int dm_set_device_limits(struct dm_target *ti, struct dm_dev *dev,
  */
 void dm_put_device(struct dm_target *ti, struct dm_dev *d)
 {
-	int found = 0;
 	struct dm_table *t = ti->table;
 	struct list_head *devices = &t->devices;
 	struct dm_dev_internal *dd;
+	struct dm_dev_ref *ref;
 
 	down_write(&t->devices_lock);
 
-	list_for_each_entry(dd, devices, list) {
-		if (dd->dm_dev == d) {
-			found = 1;
-			break;
-		}
-	}
-	if (!found) {
-		DMERR("%s: device %s not in table devices list",
-		      dm_device_name(t->md), d->name);
+	list_for_each_entry(dd, devices, list)
+		list_for_each_entry(ref, &dd->refs, list)
+			if (ref->dm_dev == d)
+				goto found;
+
+	DMERR("%s: device %s not in table devices list",
+	      dm_device_name(t->md), d->name);
+	goto unlock_ret;
+
+found:
+	if (!refcount_dec_and_test(&ref->count))
 		goto unlock_ret;
-	}
-	if (refcount_dec_and_test(&dd->count)) {
-		dm_put_table_device(t->md, d);
+
+	dm_put_table_device(t->md, d);
+	list_del(&ref->list);
+	kfree(ref);
+
+	if (list_empty(&dd->refs)) {
 		list_del(&dd->list);
 		kfree(dd);
 	}
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 1df8a808d279e..11facf9a195cb 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1611,7 +1611,7 @@ static void __send_empty_flush(struct clone_info *ci)
 			 */
 			clone = alloc_tio(ci, NULL, 0, &len, GFP_NOIO);
 			atomic_add(1, &ci->io->io_count);
-			bio_set_dev(clone, dd->dm_dev->bdev);
+			bio_set_dev(clone, dd->bdev);
 			clone->bi_end_io = clone_endio;
 			dm_submit_bio_remap(clone, NULL);
 		}
diff --git a/drivers/md/dm.h b/drivers/md/dm.h
index 8887c1f65639d..8160a6993c85b 100644
--- a/drivers/md/dm.h
+++ b/drivers/md/dm.h
@@ -37,10 +37,26 @@
 
 /*
  * List of devices that a metadevice uses and should open/close.
+ * There is one dm_dev_internal per device. It holds one dm_dev_ref
+ * for each mode that the targets opened the device with.
  */
 struct dm_dev_internal {
 	struct list_head list;
-	refcount_t count;
+	struct block_device *bdev;
+	struct list_head refs;
+};
+
+/*
+ * One open of a device with one mode, shared by the targets of a table.
+ * dm_get_device() reuses a dm_dev_ref whose mode covers the requested
+ * mode, and adds a new one only when none does. So the dm_dev_refs of
+ * a device have different modes, and a table holds each table_device
+ * at most once. table_device->count is still the number of tables that
+ * use the table_device.
+ */
+struct dm_dev_ref {
+	struct list_head list;
+	refcount_t count;	/* dm_get_device() calls that returned dm_dev */
 	struct dm_dev *dm_dev;
 };
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 106/555] dm: fail a REQ_PREFLUSH bio with data when its preflush fails
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (104 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 105/555] dm: fix use-after-free when dm_get_device() widens the open mode Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 107/555] iio: adc: ad7923: add the AD7927 to the SPI ID table Greg Kroah-Hartman
                   ` (448 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Daejun Park, Tejun Heo,
	Mikulas Patocka, Sasha Levin

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

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

From: Daejun Park <daejun7.park@samsung.com>

[ Upstream commit e92cd41e8e5ee5616c6c7cd4378661d942f0a7c0 ]

For a bio with REQ_PREFLUSH and data, dm core may send an empty flush
first. If the flush fails, __dm_io_complete() still reissues the bio
without REQ_PREFLUSH and drops the error. When that write succeeds,
the XFS log keeps running and fsync() can return 0.

End the bio with the flush error instead of writing the data, as
blk-mq does.

Fixes: 6a8736d10cb4 ("dm: relax ordering of bio-based flush implementation")
Cc: stable@vger.kernel.org
Signed-off-by: Daejun Park <daejun7.park@samsung.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
[ sashal: adjusted the condition to use bio_is_flush_with_data(bio) directly, since this tree has no requeue_flush_with_data variable. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/md/dm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 11facf9a195cb..403944761d19f 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -983,7 +983,7 @@ static void __dm_io_complete(struct dm_io *io, bool first_stage)
 	if (requeued)
 		return;
 
-	if (bio_is_flush_with_data(bio)) {
+	if (bio_is_flush_with_data(bio) && !io_error) {
 		/*
 		 * Preflush done for flush with data, reissue
 		 * without REQ_PREFLUSH.
@@ -991,7 +991,7 @@ static void __dm_io_complete(struct dm_io *io, bool first_stage)
 		bio->bi_opf &= ~REQ_PREFLUSH;
 		queue_io(md, bio);
 	} else {
-		/* done with normal IO or empty flush */
+		/* done with normal IO, empty flush or failed preflush */
 		if (io_error)
 			bio->bi_status = io_error;
 		bio_endio(bio);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 107/555] iio: adc: ad7923: add the AD7927 to the SPI ID table
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (105 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 106/555] dm: fail a REQ_PREFLUSH bio with data when its preflush fails Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 108/555] iio: temperature: hid-sensor-temperature: Use per-instance callbacks Greg Kroah-Hartman
                   ` (447 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, stable, Josef Bacik, Nuno Sá,
	Jonathan Cameron, Sasha Levin

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

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

From: Josef Bacik <josef@toxicpanda.com>

[ Upstream commit 594157b4f3f64db5833dee679194c33a5968f92e ]

The binding describes the AD7927 as

  compatible = "adi,ad7927", "adi,ad7928";

The OF match takes the second string. The modalias of the SPI device is
made from the first one, "ad7927", which is not in the spi_device_id table:
spi_get_device_id() returns NULL and ad7923_probe() dereferences it for
the chip information. The module is not loaded automatically either, as the
uevent of an SPI device says "spi:ad7927".

Add the name, with the data of the AD7928.

Fixes: 1140f96cd4af ("dt-bindings: iio: adc: ad7923: adjust documentation")
Cc: stable <stable@kernel.org>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
[ sashal: Adapted the spi_device_id entry to the older positional initializer style ({ "ad7927", AD7928 }) instead of designated .name/.driver_data fields. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/iio/adc/ad7923.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
index acc44cb34f824..46e1d64c294af 100644
--- a/drivers/iio/adc/ad7923.c
+++ b/drivers/iio/adc/ad7923.c
@@ -367,6 +367,7 @@ static const struct spi_device_id ad7923_id[] = {
 	{ "ad7924", AD7924 },
 	{ "ad7908", AD7908 },
 	{ "ad7918", AD7918 },
+	{ "ad7927", AD7928 },
 	{ "ad7928", AD7928 },
 	{ }
 };
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 108/555] iio: temperature: hid-sensor-temperature: Use per-instance callbacks
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (106 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 107/555] iio: adc: ad7923: add the AD7927 to the SPI ID table Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 109/555] ACPI: PM: Avoid initializing power management for absent devices Greg Kroah-Hartman
                   ` (446 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Christopher Hoover, Joshua Crofts,
	Srinivas Pandruvada, Jonathan Cameron, Sasha Levin

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

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

From: Christopher Hoover <ch@murgatroid.com>

[ Upstream commit 36eeb26031e90eeb81bbac3d3acad61d23fcbdf3 ]

hid-sensor-temperature keeps a single static struct
hid_sensor_hub_callbacks for all instances and overwrites its pdev in
every probe.  With two temperature sensors, input reports for one are
delivered with the other's platform device; once that device is
removed, platform_get_drvdata() returns NULL and
temperature_capture_sample() dereferences it:

  BUG: kernel NULL pointer dereference, address: 00000000000003a8
  RIP: 0010:temperature_capture_sample+0xd/0x50 [hid_sensor_temperature]

The oops happens in sensor_hub_raw_event() with the hub's spinlock
held, so the hub's removal then hangs.  It reproduces with two uhid
devices that each declare a temperature sensor, one destroyed while
the other still sends input reports.

Keep the callbacks in struct temperature_state, as the other HID
sensor drivers (accel, gyro, als, ...) do.

Fixes: 59d0f2da3569 ("iio: hid: Add temperature sensor support")
Cc: stable@vger.kernel.org
Signed-off-by: Christopher Hoover <ch@murgatroid.com>
Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
[ sashal: adapted to the older tree by using u64 timestamp __aligned(8) instead of aligned_s64 timestamp in the context, with a whitespace difference in the sensor_hub_register_callback argument alignment. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/iio/temperature/hid-sensor-temperature.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/temperature/hid-sensor-temperature.c b/drivers/iio/temperature/hid-sensor-temperature.c
index 3cfd51236e4c8..546f50f0cc6f8 100644
--- a/drivers/iio/temperature/hid-sensor-temperature.c
+++ b/drivers/iio/temperature/hid-sensor-temperature.c
@@ -16,6 +16,7 @@
 struct temperature_state {
 	struct hid_sensor_common common_attributes;
 	struct hid_sensor_hub_attribute_info temperature_attr;
+	struct hid_sensor_hub_callbacks callbacks;
 	struct {
 		s32 temperature_data;
 		u64 timestamp __aligned(8);
@@ -181,11 +182,6 @@ static int temperature_parse_report(struct platform_device *pdev,
 	return ret;
 }
 
-static struct hid_sensor_hub_callbacks temperature_callbacks = {
-	.send_event = &temperature_proc_event,
-	.capture_sample = &temperature_capture_sample,
-};
-
 /* Function to initialize the processing for usage id */
 static int hid_temperature_probe(struct platform_device *pdev)
 {
@@ -237,9 +233,13 @@ static int hid_temperature_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, indio_dev);
 
-	temperature_callbacks.pdev = pdev;
+	temp_st->callbacks = (struct hid_sensor_hub_callbacks) {
+		.send_event = temperature_proc_event,
+		.capture_sample = temperature_capture_sample,
+		.pdev = pdev,
+	};
 	ret = sensor_hub_register_callback(hsdev, HID_USAGE_SENSOR_TEMPERATURE,
-					&temperature_callbacks);
+					   &temp_st->callbacks);
 	if (ret)
 		goto error_remove_trigger;
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 109/555] ACPI: PM: Avoid initializing power management for absent devices
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (107 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 108/555] iio: temperature: hid-sensor-temperature: Use per-instance callbacks Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 110/555] Revert "ALSA: hda/realtek: Fix silent speaker on Higole F9B" Greg Kroah-Hartman
                   ` (445 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Alan Borzeszkowski,
	Rafael J. Wysocki, Mika Westerberg, Sasha Levin

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

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

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

[ Upstream commit b91ad39f29ceeee3e3d37eedff6b7c912855623c ]

Commit 2f4ddf2bd1ba ("ACPI: scan: Stop calling acpi_bus_init_power()
early") removed a device presence check from acpi_bus_init_power() which
in some cases causes power management to be initialized for an ACPI
device object and never used going forward.  That in turn may prevent
power management from working as expected for other devices.

Namely, if a given ACPI device object is not enabled according to its
_STA, find_child_checks() will return an error for it which will prevent
it from being used as an ACPI companion for a PCI device.  Thus if
acpi_device_init_power() initializes power management for it and its
initial power state turns out to be different from D3cold, it may stay
in that power state forever.  If it has power resources and they are
"on" during the initialization, they may be reference-counted and never
turned off.  If they are shared with other devices, they will prevent
power from going down after attempting to put the other devices into
low-power states.

To prevent that from happening, restore the device presence check in
acpi_bus_init_power(), but also adjust find_child_checks() to return
an error for absent devices (instead of doing that for disabled devices)
in accordance with acpi_bus_init_power() and the existing check in
acpi_bus_attach().

Fixes: 2f4ddf2bd1ba ("ACPI: scan: Stop calling acpi_bus_init_power() early")
Reported-by: Alan Borzeszkowski <alan.borzeszkowski@linux.intel.com>
Tested-by: Alan Borzeszkowski <alan.borzeszkowski@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Link: https://patch.msgid.link/13013440.O9o76ZdvQC@rafael.j.wysocki
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/acpi/device_pm.c | 15 +++++++++++++--
 drivers/acpi/glue.c      |  8 ++------
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index fef0ec39b8bb8..8a5662078b6f4 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -365,14 +365,25 @@ int acpi_bus_init_power(struct acpi_device *device)
 	 * fails, ACPI power management will not be used for the device going
 	 * forward.
 	 */
+	if (!acpi_device_is_present(device)) {
+		acpi_handle_debug(device->handle,
+				  "Device not present, ACPI PM disabled\n");
+		result = -ENXIO;
+		goto fail;
+	}
+
 	result = acpi_device_init_power(device);
 	if (result) {
-		device->flags.power_manageable = 0;
-		device->power.state = ACPI_D_STATE_INVALID;
 		acpi_handle_info(device->handle,
 				 "Initial power state undetermined, ACPI PM disabled\n");
+		goto fail;
 	}
 
+	return 0;
+
+fail:
+	device->flags.power_manageable = 0;
+	device->power.state = ACPI_D_STATE_INVALID;
 	return result;
 }
 
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index f915a7c0e7cca..d2c1f969cef27 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -105,14 +105,10 @@ static bool acpi_dev_has_children(struct acpi_device *adev)
 
 static int find_child_checks(struct acpi_device *adev, bool check_children)
 {
-	unsigned long long sta;
-	acpi_status status;
-
 	if (check_children && !acpi_dev_has_children(adev))
 		return -ENODEV;
 
-	status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta);
-	if (status == AE_NOT_FOUND) {
+	if (!acpi_has_method(adev->handle, METHOD_NAME__STA)) {
 		/*
 		 * Special case: backlight device objects without _STA are
 		 * preferred to other objects with the same _ADR value, because
@@ -124,7 +120,7 @@ static int find_child_checks(struct acpi_device *adev, bool check_children)
 		return FIND_CHILD_MIN_SCORE;
 	}
 
-	if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED))
+	if (!acpi_device_is_present(adev))
 		return -ENODEV;
 
 	/*
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 110/555] Revert "ALSA: hda/realtek: Fix silent speaker on Higole F9B"
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (108 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 109/555] ACPI: PM: Avoid initializing power management for absent devices Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 111/555] ovl: use wrapper ovl_revert_creds() Greg Kroah-Hartman
                   ` (444 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Cristian-Marian Fotache,
	Takashi Iwai, Sasha Levin

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

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

From: Takashi Iwai <tiwai@suse.de>

[ Upstream commit b9fd2f07df77076f83a58fe7a5640cbcbc5a61ff ]

This reverts commit 2a8ee6897302ca12ff39e8eb180503956797c60c.

We've received a regression report due to this commit, and it turned
out that the PCI SSID for this quirk entry is too generic (10ec:111e)
that may match with several different models.

Usually a workaround would be to apply the quirk for a more unique ID
such as codec SSID, but in this case, unfortunately, the codec SSID is
also 10ec:111e, so BIOS is in a premature state.

For addressing the regression, revert the change for now.

Fixes: 2a8ee6897302 ("ALSA: hda/realtek: Fix silent speaker on Higole F9B")
Reported-by: Cristian-Marian Fotache <cristianmarianfotache@gmail.com>
Closes: https://lore.kernel.org/CACGjpbf73XdwrG34ffjmYU3ZYuStPpFNXf9w+AGYcTmLyHCN_w@mail.gmail.com
Link: https://patch.msgid.link/20261123093436.48511-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 sound/pci/hda/patch_realtek.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index f2673ed691d73..b99b18b4cf82c 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -11472,7 +11472,6 @@ static const struct hda_quirk alc269_fixup_tbl[] = {
 	SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", ALC269_FIXUP_LIFEBOOK_HP_PIN),
 	SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC),
 	SND_PCI_QUIRK(0x10ec, 0x10f2, "Intel Reference board", ALC700_FIXUP_INTEL_REFERENCE),
-	SND_PCI_QUIRK(0x10ec, 0x111e, "Higole F9B", ALC290_FIXUP_MONO_SPEAKERS),
 	SND_PCI_QUIRK(0x10ec, 0x118c, "Medion EE4254 MD62100", ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE),
 	SND_PCI_QUIRK(0x10ec, 0x119e, "Positivo SU C1400", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
 	SND_PCI_QUIRK(0x10ec, 0x11bc, "VAIO VJFE-IL", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 111/555] ovl: use wrapper ovl_revert_creds()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (109 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 110/555] Revert "ALSA: hda/realtek: Fix silent speaker on Higole F9B" Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 112/555] ovl: make redirect/metacopy rejection consistent Greg Kroah-Hartman
                   ` (443 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Amir Goldstein, Vinicius Costa Gomes,
	Sasha Levin

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

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

From: Vinicius Costa Gomes <vinicius.gomes@intel.com>

[ Upstream commit fc5a1d2287bf23f67da1fc7a178cf26c5e6ba9d0 ]

Introduce ovl_revert_creds() wrapper of revert_creds() to
match callers of ovl_override_creds().

Suggested-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Stable-dep-of: 7031366be218 ("ovl: do not read the flags of a put upper dentry in lookup")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/overlayfs/copy_up.c   |  2 +-
 fs/overlayfs/dir.c       | 10 +++++-----
 fs/overlayfs/file.c      | 14 +++++++-------
 fs/overlayfs/inode.c     | 20 ++++++++++----------
 fs/overlayfs/namei.c     | 10 +++++-----
 fs/overlayfs/overlayfs.h |  1 +
 fs/overlayfs/readdir.c   |  8 ++++----
 fs/overlayfs/util.c      |  9 +++++++--
 fs/overlayfs/xattrs.c    |  9 ++++-----
 9 files changed, 44 insertions(+), 39 deletions(-)

diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index 913e8adc9ea4e..432a6e08d16e1 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -1297,7 +1297,7 @@ static int ovl_copy_up_flags(struct dentry *dentry, int flags)
 		dput(parent);
 		dput(next);
 	}
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 
 	return err;
 }
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 0ff5b4b54e0e8..5426db632179a 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -627,7 +627,7 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
 		err = ovl_create_over_whiteout(dentry, inode, attr);
 
 out_revert_creds:
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 	return err;
 }
 
@@ -708,7 +708,7 @@ static int ovl_set_link_redirect(struct dentry *dentry)
 
 	old_cred = ovl_override_creds(dentry->d_sb);
 	err = ovl_set_redirect(dentry, false);
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 
 	return err;
 }
@@ -918,7 +918,7 @@ static int ovl_do_remove(struct dentry *dentry, bool is_dir)
 		err = ovl_remove_upper(dentry, is_dir, &list);
 	else
 		err = ovl_remove_and_whiteout(dentry, &list);
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 	if (!err) {
 		if (is_dir)
 			clear_nlink(dentry->d_inode);
@@ -1310,7 +1310,7 @@ static int ovl_rename(struct mnt_idmap *idmap, struct inode *olddir,
 out_unlock:
 	unlock_rename(new_upperdir, old_upperdir);
 out_revert_creds:
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 	if (update_nlink)
 		ovl_nlink_end(new);
 	else
@@ -1355,7 +1355,7 @@ static int ovl_create_tmpfile(struct file *file, struct dentry *dentry,
 		fput(realfile);
 	}
 out_revert_creds:
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 	return err;
 }
 
diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
index 3a1f120b2af66..7ecbbf62f170b 100644
--- a/fs/overlayfs/file.c
+++ b/fs/overlayfs/file.c
@@ -50,7 +50,7 @@ static struct file *ovl_open_realfile(const struct file *file,
 		realfile = backing_file_open(file,
 					     flags, realpath, current_cred());
 	}
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 
 	pr_debug("open(%p[%pD2/%c], 0%o) -> (%p, 0%o)\n",
 		 file, file, ovl_whatisit(inode, realinode), file->f_flags,
@@ -214,7 +214,7 @@ static loff_t ovl_llseek(struct file *file, loff_t offset, int whence)
 
 	old_cred = ovl_override_creds(inode->i_sb);
 	ret = vfs_llseek(fd_file(real), offset, whence);
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 
 	file->f_pos = fd_file(real)->f_pos;
 	ovl_inode_unlock(inode);
@@ -406,7 +406,7 @@ static int ovl_fsync(struct file *file, loff_t start, loff_t end, int datasync)
 	if (file_inode(fd_file(real)) == ovl_inode_upper(file_inode(file))) {
 		old_cred = ovl_override_creds(file_inode(file)->i_sb);
 		ret = vfs_fsync_range(fd_file(real), start, end, datasync);
-		revert_creds(old_cred);
+		ovl_revert_creds(old_cred);
 	}
 
 	fdput(real);
@@ -446,7 +446,7 @@ static long ovl_fallocate(struct file *file, int mode, loff_t offset, loff_t len
 
 	old_cred = ovl_override_creds(file_inode(file)->i_sb);
 	ret = vfs_fallocate(fd_file(real), mode, offset, len);
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 
 	/* Update size */
 	ovl_file_modified(file);
@@ -471,7 +471,7 @@ static int ovl_fadvise(struct file *file, loff_t offset, loff_t len, int advice)
 
 	old_cred = ovl_override_creds(file_inode(file)->i_sb);
 	ret = vfs_fadvise(fd_file(real), offset, len, advice);
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 
 	fdput(real);
 
@@ -544,7 +544,7 @@ static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in,
 						flags);
 		break;
 	}
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 
 	/* Update size */
 	ovl_file_modified(file_out);
@@ -607,7 +607,7 @@ static int ovl_flush(struct file *file, fl_owner_t id)
 	if (fd_file(real)->f_op->flush) {
 		old_cred = ovl_override_creds(file_inode(file)->i_sb);
 		err = fd_file(real)->f_op->flush(fd_file(real), id);
-		revert_creds(old_cred);
+		ovl_revert_creds(old_cred);
 	}
 	fdput(real);
 
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 4004edcd1fa85..bd15fd532f7d0 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -80,7 +80,7 @@ int ovl_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
 		inode_lock(upperdentry->d_inode);
 		old_cred = ovl_override_creds(dentry->d_sb);
 		err = ovl_do_notify_change(ofs, upperdentry, attr);
-		revert_creds(old_cred);
+		ovl_revert_creds(old_cred);
 		if (!err)
 			ovl_copyattr(dentry->d_inode);
 		inode_unlock(upperdentry->d_inode);
@@ -280,7 +280,7 @@ int ovl_getattr(struct mnt_idmap *idmap, const struct path *path,
 		stat->nlink = dentry->d_inode->i_nlink;
 
 out:
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 
 	return err;
 }
@@ -317,7 +317,7 @@ int ovl_permission(struct mnt_idmap *idmap,
 		mask |= MAY_READ;
 	}
 	err = inode_permission(mnt_idmap(realpath.mnt), realinode, mask);
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 
 	return err;
 }
@@ -334,7 +334,7 @@ static const char *ovl_get_link(struct dentry *dentry,
 
 	old_cred = ovl_override_creds(dentry->d_sb);
 	p = vfs_get_link(ovl_dentry_real(dentry), done);
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 	return p;
 }
 
@@ -469,7 +469,7 @@ struct posix_acl *do_ovl_get_acl(struct mnt_idmap *idmap,
 
 		old_cred = ovl_override_creds(inode->i_sb);
 		acl = ovl_get_acl_path(&realpath, posix_acl_xattr_name(type), noperm);
-		revert_creds(old_cred);
+		ovl_revert_creds(old_cred);
 	}
 
 	return acl;
@@ -498,7 +498,7 @@ static int ovl_set_or_remove_acl(struct dentry *dentry, struct inode *inode,
 		old_cred = ovl_override_creds(dentry->d_sb);
 		real_acl = vfs_get_acl(mnt_idmap(realpath.mnt), realdentry,
 				       acl_name);
-		revert_creds(old_cred);
+		ovl_revert_creds(old_cred);
 		if (IS_ERR(real_acl)) {
 			err = PTR_ERR(real_acl);
 			goto out;
@@ -523,7 +523,7 @@ static int ovl_set_or_remove_acl(struct dentry *dentry, struct inode *inode,
 		err = ovl_do_set_acl(ofs, realdentry, acl_name, acl);
 	else
 		err = ovl_do_remove_acl(ofs, realdentry, acl_name);
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 	ovl_drop_write(dentry);
 
 	/* copy c/mtime */
@@ -600,7 +600,7 @@ static int ovl_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 
 	old_cred = ovl_override_creds(inode->i_sb);
 	err = realinode->i_op->fiemap(realinode, fieinfo, start, len);
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 
 	return err;
 }
@@ -676,7 +676,7 @@ int ovl_fileattr_set(struct mnt_idmap *idmap,
 		err = ovl_set_protattr(inode, upperpath.dentry, fa);
 		if (!err)
 			err = ovl_real_fileattr_set(&upperpath, fa);
-		revert_creds(old_cred);
+		ovl_revert_creds(old_cred);
 		ovl_drop_write(dentry);
 
 		/*
@@ -738,7 +738,7 @@ int ovl_fileattr_get(struct dentry *dentry, struct fileattr *fa)
 	old_cred = ovl_override_creds(inode->i_sb);
 	err = ovl_real_fileattr_get(&realpath, fa);
 	ovl_fileattr_prot_flags(inode, fa);
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 
 	return err;
 }
diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index 86fab9f051b4f..5a6581fc19da6 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -969,7 +969,7 @@ static int ovl_maybe_validate_verity(struct dentry *dentry)
 		if (err == 0)
 			ovl_set_flag(OVL_VERIFIED_DIGEST, inode);
 
-		revert_creds(old_cred);
+		ovl_revert_creds(old_cred);
 	}
 
 	ovl_inode_unlock(inode);
@@ -1003,7 +1003,7 @@ static int ovl_maybe_lookup_lowerdata(struct dentry *dentry)
 
 	old_cred = ovl_override_creds(dentry->d_sb);
 	err = ovl_lookup_data_layers(dentry, redirect, &datapath);
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 	if (err)
 		goto out_err;
 
@@ -1358,7 +1358,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 
 	ovl_dentry_init_reval(dentry, upperdentry, OVL_I_E(inode));
 
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 	if (origin_path) {
 		dput(origin_path->dentry);
 		kfree(origin_path);
@@ -1382,7 +1382,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 	kfree(upperredirect);
 out:
 	kfree(d.redirect);
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 	return ERR_PTR(err);
 }
 
@@ -1439,7 +1439,7 @@ bool ovl_lower_positive(struct dentry *dentry)
 			dput(this);
 		}
 	}
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 
 	return positive;
 }
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index d96a2baf7620e..a18aacf106d84 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -439,6 +439,7 @@ int ovl_want_write(struct dentry *dentry);
 void ovl_drop_write(struct dentry *dentry);
 struct dentry *ovl_workdir(struct dentry *dentry);
 const struct cred *ovl_override_creds(struct super_block *sb);
+void ovl_revert_creds(const struct cred *old_cred);
 
 static inline const struct cred *ovl_creds(struct super_block *sb)
 {
diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
index d102819622109..0c1344659adf9 100644
--- a/fs/overlayfs/readdir.c
+++ b/fs/overlayfs/readdir.c
@@ -291,7 +291,7 @@ static int ovl_check_whiteouts(const struct path *path, struct ovl_readdir_data
 		}
 		inode_unlock(dir->d_inode);
 	}
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 
 	return err;
 }
@@ -829,7 +829,7 @@ static int ovl_iterate(struct file *file, struct dir_context *ctx)
 	}
 	err = 0;
 out:
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 	return err;
 }
 
@@ -889,7 +889,7 @@ static struct file *ovl_dir_open_realfile(const struct file *file,
 
 	old_cred = ovl_override_creds(file_inode(file)->i_sb);
 	res = ovl_path_open(realpath, flags);
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 
 	return res;
 }
@@ -1017,7 +1017,7 @@ int ovl_check_empty_dir(struct dentry *dentry, struct list_head *list)
 
 	old_cred = ovl_override_creds(dentry->d_sb);
 	err = ovl_dir_read_merged(dentry, list, &root, NULL);
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 	if (err)
 		return err;
 
diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c
index b8adda549c473..1d08393f35df9 100644
--- a/fs/overlayfs/util.c
+++ b/fs/overlayfs/util.c
@@ -68,6 +68,11 @@ const struct cred *ovl_override_creds(struct super_block *sb)
 	return override_creds(ofs->creator_cred);
 }
 
+void ovl_revert_creds(const struct cred *old_cred)
+{
+	revert_creds(old_cred);
+}
+
 /*
  * Check if underlying fs supports file handles and try to determine encoding
  * type, in order to deduce maximum inode number used by fs.
@@ -1198,7 +1203,7 @@ int ovl_nlink_start(struct dentry *dentry)
 	 * value relative to the upper inode nlink in an upper inode xattr.
 	 */
 	err = ovl_set_nlink_upper(dentry);
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 	if (err)
 		goto out_drop_write;
 
@@ -1223,7 +1228,7 @@ void ovl_nlink_end(struct dentry *dentry)
 
 		old_cred = ovl_override_creds(dentry->d_sb);
 		ovl_cleanup_index(dentry);
-		revert_creds(old_cred);
+		ovl_revert_creds(old_cred);
 	}
 
 	ovl_inode_unlock(inode);
diff --git a/fs/overlayfs/xattrs.c b/fs/overlayfs/xattrs.c
index 6ba79ee00f737..c86f1a6c8b937 100644
--- a/fs/overlayfs/xattrs.c
+++ b/fs/overlayfs/xattrs.c
@@ -47,7 +47,7 @@ static int ovl_xattr_set(struct dentry *dentry, struct inode *inode, const char
 		ovl_path_lower(dentry, &realpath);
 		old_cred = ovl_override_creds(dentry->d_sb);
 		err = vfs_getxattr(mnt_idmap(realpath.mnt), realdentry, name, NULL, 0);
-		revert_creds(old_cred);
+		ovl_revert_creds(old_cred);
 		if (err < 0)
 			goto out;
 	}
@@ -72,7 +72,7 @@ static int ovl_xattr_set(struct dentry *dentry, struct inode *inode, const char
 		WARN_ON(flags != XATTR_REPLACE);
 		err = ovl_do_removexattr(ofs, realdentry, name);
 	}
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 	ovl_drop_write(dentry);
 
 	/* copy c/mtime */
@@ -91,7 +91,7 @@ static int ovl_xattr_get(struct dentry *dentry, struct inode *inode, const char
 	ovl_i_path_real(inode, &realpath);
 	old_cred = ovl_override_creds(dentry->d_sb);
 	res = vfs_getxattr(mnt_idmap(realpath.mnt), realpath.dentry, name, value, size);
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 	return res;
 }
 
@@ -121,7 +121,7 @@ ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size)
 
 	old_cred = ovl_override_creds(dentry->d_sb);
 	res = vfs_listxattr(realdentry, list, size);
-	revert_creds(old_cred);
+	ovl_revert_creds(old_cred);
 	if (res <= 0 || size == 0)
 		return res;
 
@@ -268,4 +268,3 @@ const struct xattr_handler * const *ovl_xattr_handlers(struct ovl_fs *ofs)
 	return ofs->config.userxattr ? ovl_user_xattr_handlers :
 		ovl_trusted_xattr_handlers;
 }
-
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 112/555] ovl: make redirect/metacopy rejection consistent
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (110 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 111/555] ovl: use wrapper ovl_revert_creds() Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 113/555] ovl: refactor ovl_lookup() Greg Kroah-Hartman
                   ` (442 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Miklos Szeredi, Sasha Levin

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

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

From: Miklos Szeredi <mszeredi@redhat.com>

[ Upstream commit a6fcfe9bb26df18ba7b5c4d064edd13c80ea2466 ]

When overlayfs finds a file with metacopy and/or redirect attributes and
the metacopy and/or redirect features are not enabled, then it refuses to
act on those attributes while also issuing a warning.

There was an inconsistency in not checking metacopy found from the index.

And also only warning on an upper metacopy if it found the next file on the
lower layer, while always warning for metacopy found on a lower layer.

Fix these inconsistencies and make the logic more straightforward, paving
the way for following patches to change when data redirects are allowed.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Stable-dep-of: 7031366be218 ("ovl: do not read the flags of a put upper dentry in lookup")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/overlayfs/namei.c | 90 +++++++++++++++++++++++++++-----------------
 1 file changed, 55 insertions(+), 35 deletions(-)

diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index 5a6581fc19da6..39ce3b5c8646a 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -18,6 +18,7 @@
 
 struct ovl_lookup_data {
 	struct super_block *sb;
+	struct dentry *dentry;
 	const struct ovl_layer *layer;
 	struct qstr name;
 	bool is_dir;
@@ -26,6 +27,7 @@ struct ovl_lookup_data {
 	bool stop;
 	bool last;
 	char *redirect;
+	char *upperredirect;
 	int metacopy;
 	/* Referring to last redirect xattr */
 	bool absolute_redirect;
@@ -1042,6 +1044,31 @@ int ovl_verify_lowerdata(struct dentry *dentry)
 	return ovl_maybe_validate_verity(dentry);
 }
 
+/*
+ * Following redirects/metacopy can have security consequences: it's like a
+ * symlink into the lower layer without the permission checks.
+ *
+ * This is only a problem if the upper layer is untrusted (e.g comes from an USB
+ * drive).  This can allow a non-readable file or directory to become readable.
+ *
+ * Only following redirects when redirects are enabled disables this attack
+ * vector when not necessary.
+ */
+static bool ovl_check_follow_redirect(struct ovl_lookup_data *d)
+{
+	struct ovl_fs *ofs = OVL_FS(d->sb);
+
+	if (d->metacopy && !ofs->config.metacopy) {
+		pr_warn_ratelimited("refusing to follow metacopy origin for (%pd2)\n", d->dentry);
+		return false;
+	}
+	if ((d->redirect || d->upperredirect) && !ovl_redirect_follow(ofs)) {
+		pr_warn_ratelimited("refusing to follow redirect for (%pd2)\n", d->dentry);
+		return false;
+	}
+	return true;
+}
+
 struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 			  unsigned int flags)
 {
@@ -1057,7 +1084,6 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 	unsigned int ctr = 0;
 	struct inode *inode = NULL;
 	bool upperopaque = false;
-	char *upperredirect = NULL;
 	struct dentry *this;
 	unsigned int i;
 	int err;
@@ -1065,12 +1091,14 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 	int metacopy_size = 0;
 	struct ovl_lookup_data d = {
 		.sb = dentry->d_sb,
+		.dentry = dentry,
 		.name = dentry->d_name,
 		.is_dir = false,
 		.opaque = false,
 		.stop = false,
 		.last = ovl_redirect_follow(ofs) ? false : !ovl_numlower(poe),
 		.redirect = NULL,
+		.upperredirect = NULL,
 		.metacopy = 0,
 	};
 
@@ -1112,8 +1140,8 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 
 		if (d.redirect) {
 			err = -ENOMEM;
-			upperredirect = kstrdup(d.redirect, GFP_KERNEL);
-			if (!upperredirect)
+			d.upperredirect = kstrdup(d.redirect, GFP_KERNEL);
+			if (!d.upperredirect)
 				goto out_put_upper;
 			if (d.redirect[0] == '/')
 				poe = roe;
@@ -1131,6 +1159,11 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 	for (i = 0; !d.stop && i < ovl_numlower(poe); i++) {
 		struct ovl_path lower = ovl_lowerstack(poe)[i];
 
+		if (!ovl_check_follow_redirect(&d)) {
+			err = -EPERM;
+			goto out_put;
+		}
+
 		if (!ovl_redirect_follow(ofs))
 			d.last = i == ovl_numlower(poe) - 1;
 		else if (d.is_dir || !ofs->numdatalayer)
@@ -1144,13 +1177,6 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 		if (!this)
 			continue;
 
-		if ((uppermetacopy || d.metacopy) && !ofs->config.metacopy) {
-			dput(this);
-			err = -EPERM;
-			pr_warn_ratelimited("refusing to follow metacopy origin for (%pd2)\n", dentry);
-			goto out_put;
-		}
-
 		/*
 		 * If no origin fh is stored in upper of a merge dir, store fh
 		 * of lower dir and set upper parent "impure".
@@ -1203,23 +1229,6 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 			ctr++;
 		}
 
-		/*
-		 * Following redirects can have security consequences: it's like
-		 * a symlink into the lower layer without the permission checks.
-		 * This is only a problem if the upper layer is untrusted (e.g
-		 * comes from an USB drive).  This can allow a non-readable file
-		 * or directory to become readable.
-		 *
-		 * Only following redirects when redirects are enabled disables
-		 * this attack vector when not necessary.
-		 */
-		err = -EPERM;
-		if (d.redirect && !ovl_redirect_follow(ofs)) {
-			pr_warn_ratelimited("refusing to follow redirect for (%pd2)\n",
-					    dentry);
-			goto out_put;
-		}
-
 		if (d.stop)
 			break;
 
@@ -1230,6 +1239,11 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 		}
 	}
 
+	if (!ovl_check_follow_redirect(&d)) {
+		err = -EPERM;
+		goto out_put;
+	}
+
 	/* Defer lookup of lowerdata in data-only layers to first access */
 	if (d.metacopy && ctr && ofs->numdatalayer && d.absolute_redirect) {
 		d.metacopy = 0;
@@ -1316,20 +1330,26 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 
 		/*
 		 * It's safe to assign upperredirect here: the previous
-		 * assignment of happens only if upperdentry is non-NULL, and
+		 * assignment happens only if upperdentry is non-NULL, and
 		 * this one only if upperdentry is NULL.
 		 */
-		upperredirect = ovl_get_redirect_xattr(ofs, &upperpath, 0);
-		if (IS_ERR(upperredirect)) {
-			err = PTR_ERR(upperredirect);
-			upperredirect = NULL;
+		d.upperredirect = ovl_get_redirect_xattr(ofs, &upperpath, 0);
+		if (IS_ERR(d.upperredirect)) {
+			err = PTR_ERR(d.upperredirect);
+			d.upperredirect = NULL;
 			goto out_free_oe;
 		}
+
 		err = ovl_check_metacopy_xattr(ofs, &upperpath, NULL);
 		if (err < 0)
 			goto out_free_oe;
-		uppermetacopy = err;
+		d.metacopy = uppermetacopy = err;
 		metacopy_size = err;
+
+		if (!ovl_check_follow_redirect(&d)) {
+			err = -EPERM;
+			goto out_free_oe;
+		}
 	}
 
 	if (upperdentry || ctr) {
@@ -1337,7 +1357,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 			.upperdentry = upperdentry,
 			.oe = oe,
 			.index = index,
-			.redirect = upperredirect,
+			.redirect = d.upperredirect,
 		};
 
 		/* Store lowerdata redirect for lazy lookup */
@@ -1379,7 +1399,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 		kfree(origin_path);
 	}
 	dput(upperdentry);
-	kfree(upperredirect);
+	kfree(d.upperredirect);
 out:
 	kfree(d.redirect);
 	ovl_revert_creds(old_cred);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 113/555] ovl: refactor ovl_lookup()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (111 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 112/555] ovl: make redirect/metacopy rejection consistent Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 114/555] ovl: do not read the flags of a put upper dentry in lookup Greg Kroah-Hartman
                   ` (441 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Amir Goldstein, Christian Brauner,
	Sasha Levin

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

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

From: Christian Brauner <brauner@kernel.org>

[ Upstream commit 15da486ad3bde6119d9b6353bebc2ffb6e9165c1 ]

Split the core into a separate helper in preparation of converting the
caller to the scoped ovl cred guard.

Link: https://patch.msgid.link/20251117-work-ovl-cred-guard-v4-37-b31603935724@kernel.org
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Stable-dep-of: 7031366be218 ("ovl: do not read the flags of a put upper dentry in lookup")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/overlayfs/namei.c | 313 ++++++++++++++++++++++---------------------
 1 file changed, 160 insertions(+), 153 deletions(-)

diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index 39ce3b5c8646a..2eddcaab781ba 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -1069,56 +1069,43 @@ static bool ovl_check_follow_redirect(struct ovl_lookup_data *d)
 	return true;
 }
 
-struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
-			  unsigned int flags)
+struct ovl_lookup_ctx {
+	struct dentry *dentry;
+	struct ovl_entry *oe;
+	struct ovl_path *stack;
+	struct ovl_path *origin_path;
+	struct dentry *upperdentry;
+	struct dentry *index;
+	struct inode *inode;
+	unsigned int ctr;
+};
+
+static int ovl_lookup_layers(struct ovl_lookup_ctx *ctx, struct ovl_lookup_data *d)
 {
-	struct ovl_entry *oe = NULL;
-	const struct cred *old_cred;
+	struct dentry *dentry = ctx->dentry;
 	struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
 	struct ovl_entry *poe = OVL_E(dentry->d_parent);
 	struct ovl_entry *roe = OVL_E(dentry->d_sb->s_root);
-	struct ovl_path *stack = NULL, *origin_path = NULL;
-	struct dentry *upperdir, *upperdentry = NULL;
+	struct dentry *upperdir;
+	struct dentry *this;
 	struct dentry *origin = NULL;
-	struct dentry *index = NULL;
-	unsigned int ctr = 0;
-	struct inode *inode = NULL;
 	bool upperopaque = false;
-	struct dentry *this;
-	unsigned int i;
-	int err;
 	bool uppermetacopy = false;
 	int metacopy_size = 0;
-	struct ovl_lookup_data d = {
-		.sb = dentry->d_sb,
-		.dentry = dentry,
-		.name = dentry->d_name,
-		.is_dir = false,
-		.opaque = false,
-		.stop = false,
-		.last = ovl_redirect_follow(ofs) ? false : !ovl_numlower(poe),
-		.redirect = NULL,
-		.upperredirect = NULL,
-		.metacopy = 0,
-	};
-
-	if (dentry->d_name.len > ofs->namelen)
-		return ERR_PTR(-ENAMETOOLONG);
+	unsigned int i;
+	int err;
 
-	old_cred = ovl_override_creds(dentry->d_sb);
 	upperdir = ovl_dentry_upper(dentry->d_parent);
 	if (upperdir) {
-		d.layer = &ofs->layers[0];
-		err = ovl_lookup_layer(upperdir, &d, &upperdentry, true);
+		d->layer = &ofs->layers[0];
+		err = ovl_lookup_layer(upperdir, d, &ctx->upperdentry, true);
 		if (err)
-			goto out;
+			return err;
 
-		if (upperdentry && upperdentry->d_flags & DCACHE_OP_REAL) {
-			dput(upperdentry);
-			err = -EREMOTE;
-			goto out;
-		}
-		if (upperdentry && !d.is_dir) {
+		if (ctx->upperdentry && ctx->upperdentry->d_flags & DCACHE_OP_REAL)
+			return -EREMOTE;
+
+		if (ctx->upperdentry && !d->is_dir) {
 			/*
 			 * Lookup copy up origin by decoding origin file handle.
 			 * We may get a disconnected dentry, which is fine,
@@ -1129,50 +1116,50 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 			 * number - it's the same as if we held a reference
 			 * to a dentry in lower layer that was moved under us.
 			 */
-			err = ovl_check_origin(ofs, upperdentry, &origin_path);
+			err = ovl_check_origin(ofs, ctx->upperdentry, &ctx->origin_path);
 			if (err)
-				goto out_put_upper;
+				return err;
 
-			if (d.metacopy)
+			if (d->metacopy)
 				uppermetacopy = true;
-			metacopy_size = d.metacopy;
+			metacopy_size = d->metacopy;
 		}
 
-		if (d.redirect) {
+		if (d->redirect) {
 			err = -ENOMEM;
-			d.upperredirect = kstrdup(d.redirect, GFP_KERNEL);
-			if (!d.upperredirect)
-				goto out_put_upper;
-			if (d.redirect[0] == '/')
+			d->upperredirect = kstrdup(d->redirect, GFP_KERNEL);
+			if (!d->upperredirect)
+				return err;
+			if (d->redirect[0] == '/')
 				poe = roe;
 		}
-		upperopaque = d.opaque;
+		upperopaque = d->opaque;
 	}
 
-	if (!d.stop && ovl_numlower(poe)) {
+	if (!d->stop && ovl_numlower(poe)) {
 		err = -ENOMEM;
-		stack = ovl_stack_alloc(ofs->numlayer - 1);
-		if (!stack)
-			goto out_put_upper;
+		ctx->stack = ovl_stack_alloc(ofs->numlayer - 1);
+		if (!ctx->stack)
+			return err;
 	}
 
-	for (i = 0; !d.stop && i < ovl_numlower(poe); i++) {
+	for (i = 0; !d->stop && i < ovl_numlower(poe); i++) {
 		struct ovl_path lower = ovl_lowerstack(poe)[i];
 
-		if (!ovl_check_follow_redirect(&d)) {
+		if (!ovl_check_follow_redirect(d)) {
 			err = -EPERM;
-			goto out_put;
+			return err;
 		}
 
 		if (!ovl_redirect_follow(ofs))
-			d.last = i == ovl_numlower(poe) - 1;
-		else if (d.is_dir || !ofs->numdatalayer)
-			d.last = lower.layer->idx == ovl_numlower(roe);
+			d->last = i == ovl_numlower(poe) - 1;
+		else if (d->is_dir || !ofs->numdatalayer)
+			d->last = lower.layer->idx == ovl_numlower(roe);
 
-		d.layer = lower.layer;
-		err = ovl_lookup_layer(lower.dentry, &d, &this, false);
+		d->layer = lower.layer;
+		err = ovl_lookup_layer(lower.dentry, d, &this, false);
 		if (err)
-			goto out_put;
+			return err;
 
 		if (!this)
 			continue;
@@ -1181,11 +1168,11 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 		 * If no origin fh is stored in upper of a merge dir, store fh
 		 * of lower dir and set upper parent "impure".
 		 */
-		if (upperdentry && !ctr && !ofs->noxattr && d.is_dir) {
-			err = ovl_fix_origin(ofs, dentry, this, upperdentry);
+		if (ctx->upperdentry && !ctx->ctr && !ofs->noxattr && d->is_dir) {
+			err = ovl_fix_origin(ofs, dentry, this, ctx->upperdentry);
 			if (err) {
 				dput(this);
-				goto out_put;
+				return err;
 			}
 		}
 
@@ -1198,23 +1185,23 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 		 * matches the dentry found using path based lookup,
 		 * otherwise error out.
 		 */
-		if (upperdentry && !ctr &&
-		    ((d.is_dir && ovl_verify_lower(dentry->d_sb)) ||
-		     (!d.is_dir && ofs->config.index && origin_path))) {
-			err = ovl_verify_origin(ofs, upperdentry, this, false);
+		if (ctx->upperdentry && !ctx->ctr &&
+		    ((d->is_dir && ovl_verify_lower(dentry->d_sb)) ||
+		     (!d->is_dir && ofs->config.index && ctx->origin_path))) {
+			err = ovl_verify_origin(ofs, ctx->upperdentry, this, false);
 			if (err) {
 				dput(this);
-				if (d.is_dir)
+				if (d->is_dir)
 					break;
-				goto out_put;
+				return err;
 			}
 			origin = this;
 		}
 
-		if (!upperdentry && !d.is_dir && !ctr && d.metacopy)
-			metacopy_size = d.metacopy;
+		if (!ctx->upperdentry && !d->is_dir && !ctx->ctr && d->metacopy)
+			metacopy_size = d->metacopy;
 
-		if (d.metacopy && ctr) {
+		if (d->metacopy && ctx->ctr) {
 			/*
 			 * Do not store intermediate metacopy dentries in
 			 * lower chain, except top most lower metacopy dentry.
@@ -1224,30 +1211,30 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 			dput(this);
 			this = NULL;
 		} else {
-			stack[ctr].dentry = this;
-			stack[ctr].layer = lower.layer;
-			ctr++;
+			ctx->stack[ctx->ctr].dentry = this;
+			ctx->stack[ctx->ctr].layer = lower.layer;
+			ctx->ctr++;
 		}
 
-		if (d.stop)
+		if (d->stop)
 			break;
 
-		if (d.redirect && d.redirect[0] == '/' && poe != roe) {
+		if (d->redirect && d->redirect[0] == '/' && poe != roe) {
 			poe = roe;
 			/* Find the current layer on the root dentry */
 			i = lower.layer->idx - 1;
 		}
 	}
 
-	if (!ovl_check_follow_redirect(&d)) {
+	if (!ovl_check_follow_redirect(d)) {
 		err = -EPERM;
-		goto out_put;
+		return err;
 	}
 
 	/* Defer lookup of lowerdata in data-only layers to first access */
-	if (d.metacopy && ctr && ofs->numdatalayer && d.absolute_redirect) {
-		d.metacopy = 0;
-		ctr++;
+	if (d->metacopy && ctx->ctr && ofs->numdatalayer && d->absolute_redirect) {
+		d->metacopy = 0;
+		ctx->ctr++;
 	}
 
 	/*
@@ -1258,20 +1245,20 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 	 * For metacopy dentry, path based lookup will find lower dentries.
 	 * Just make sure a corresponding data dentry has been found.
 	 */
-	if (d.metacopy || (uppermetacopy && !ctr)) {
+	if (d->metacopy || (uppermetacopy && !ctx->ctr)) {
 		pr_warn_ratelimited("metacopy with no lower data found - abort lookup (%pd2)\n",
 				    dentry);
 		err = -EIO;
-		goto out_put;
-	} else if (!d.is_dir && upperdentry && !ctr && origin_path) {
-		if (WARN_ON(stack != NULL)) {
+		return err;
+	} else if (!d->is_dir && ctx->upperdentry && !ctx->ctr && ctx->origin_path) {
+		if (WARN_ON(ctx->stack != NULL)) {
 			err = -EIO;
-			goto out_put;
+			return err;
 		}
-		stack = origin_path;
-		ctr = 1;
-		origin = origin_path->dentry;
-		origin_path = NULL;
+		ctx->stack = ctx->origin_path;
+		ctx->ctr = 1;
+		origin = ctx->origin_path->dentry;
+		ctx->origin_path = NULL;
 	}
 
 	/*
@@ -1293,38 +1280,39 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 	 * is enabled and if upper had an ORIGIN xattr.
 	 *
 	 */
-	if (!upperdentry && ctr)
-		origin = stack[0].dentry;
+	if (!ctx->upperdentry && ctx->ctr)
+		origin = ctx->stack[0].dentry;
 
 	if (origin && ovl_indexdir(dentry->d_sb) &&
-	    (!d.is_dir || ovl_index_all(dentry->d_sb))) {
-		index = ovl_lookup_index(ofs, upperdentry, origin, true);
-		if (IS_ERR(index)) {
-			err = PTR_ERR(index);
-			index = NULL;
-			goto out_put;
+	    (!d->is_dir || ovl_index_all(dentry->d_sb))) {
+		ctx->index = ovl_lookup_index(ofs, ctx->upperdentry, origin, true);
+		if (IS_ERR(ctx->index)) {
+			err = PTR_ERR(ctx->index);
+			ctx->index = NULL;
+			return err;
 		}
 	}
 
-	if (ctr) {
-		oe = ovl_alloc_entry(ctr);
+	if (ctx->ctr) {
+		ctx->oe = ovl_alloc_entry(ctx->ctr);
 		err = -ENOMEM;
-		if (!oe)
-			goto out_put;
+		if (!ctx->oe)
+			return err;
 
-		ovl_stack_cpy(ovl_lowerstack(oe), stack, ctr);
+		ovl_stack_cpy(ovl_lowerstack(ctx->oe), ctx->stack, ctx->ctr);
 	}
 
 	if (upperopaque)
 		ovl_dentry_set_opaque(dentry);
-	if (d.xwhiteouts)
+	if (d->xwhiteouts)
 		ovl_dentry_set_xwhiteouts(dentry);
 
-	if (upperdentry)
+	if (ctx->upperdentry)
 		ovl_dentry_set_upper_alias(dentry);
-	else if (index) {
+	else if (ctx->index) {
+		char *upperredirect;
 		struct path upperpath = {
-			.dentry = upperdentry = dget(index),
+			.dentry = ctx->upperdentry = dget(ctx->index),
 			.mnt = ovl_upper_mnt(ofs),
 		};
 
@@ -1333,77 +1321,96 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 		 * assignment happens only if upperdentry is non-NULL, and
 		 * this one only if upperdentry is NULL.
 		 */
-		d.upperredirect = ovl_get_redirect_xattr(ofs, &upperpath, 0);
-		if (IS_ERR(d.upperredirect)) {
-			err = PTR_ERR(d.upperredirect);
-			d.upperredirect = NULL;
-			goto out_free_oe;
-		}
+		upperredirect = ovl_get_redirect_xattr(ofs, &upperpath, 0);
+		if (IS_ERR(upperredirect))
+			return PTR_ERR(upperredirect);
+		d->upperredirect = upperredirect;
 
 		err = ovl_check_metacopy_xattr(ofs, &upperpath, NULL);
 		if (err < 0)
-			goto out_free_oe;
-		d.metacopy = uppermetacopy = err;
+			return err;
+		d->metacopy = uppermetacopy = err;
 		metacopy_size = err;
 
-		if (!ovl_check_follow_redirect(&d)) {
+		if (!ovl_check_follow_redirect(d)) {
 			err = -EPERM;
-			goto out_free_oe;
+			return err;
 		}
 	}
 
-	if (upperdentry || ctr) {
+	if (ctx->upperdentry || ctx->ctr) {
+		struct inode *inode;
 		struct ovl_inode_params oip = {
-			.upperdentry = upperdentry,
-			.oe = oe,
-			.index = index,
-			.redirect = d.upperredirect,
+			.upperdentry = ctx->upperdentry,
+			.oe = ctx->oe,
+			.index = ctx->index,
+			.redirect = d->upperredirect,
 		};
 
 		/* Store lowerdata redirect for lazy lookup */
-		if (ctr > 1 && !d.is_dir && !stack[ctr - 1].dentry) {
-			oip.lowerdata_redirect = d.redirect;
-			d.redirect = NULL;
+		if (ctx->ctr > 1 && !d->is_dir && !ctx->stack[ctx->ctr - 1].dentry) {
+			oip.lowerdata_redirect = d->redirect;
+			d->redirect = NULL;
 		}
+
 		inode = ovl_get_inode(dentry->d_sb, &oip);
-		err = PTR_ERR(inode);
 		if (IS_ERR(inode))
-			goto out_free_oe;
-		if (upperdentry && !uppermetacopy)
-			ovl_set_flag(OVL_UPPERDATA, inode);
+			return PTR_ERR(inode);
+
+		ctx->inode = inode;
+		if (ctx->upperdentry && !uppermetacopy)
+			ovl_set_flag(OVL_UPPERDATA, ctx->inode);
 
 		if (metacopy_size > OVL_METACOPY_MIN_SIZE)
-			ovl_set_flag(OVL_HAS_DIGEST, inode);
+			ovl_set_flag(OVL_HAS_DIGEST, ctx->inode);
 	}
 
-	ovl_dentry_init_reval(dentry, upperdentry, OVL_I_E(inode));
+	ovl_dentry_init_reval(dentry, ctx->upperdentry, OVL_I_E(ctx->inode));
+
+	return 0;
+}
+
+struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
+			  unsigned int flags)
+{
+	const struct cred *old_cred;
+	struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
+	struct ovl_entry *poe = OVL_E(dentry->d_parent);
+	int err;
+	struct ovl_lookup_ctx ctx = {
+		.dentry = dentry,
+	};
+	struct ovl_lookup_data d = {
+		.sb	= dentry->d_sb,
+		.dentry = dentry,
+		.name	= dentry->d_name,
+		.last	= ovl_redirect_follow(ofs) ? false : !ovl_numlower(poe),
+	};
+
+	if (dentry->d_name.len > ofs->namelen)
+		return ERR_PTR(-ENAMETOOLONG);
+
+	old_cred = ovl_override_creds(dentry->d_sb);
+
+	err = ovl_lookup_layers(&ctx, &d);
 
 	ovl_revert_creds(old_cred);
-	if (origin_path) {
-		dput(origin_path->dentry);
-		kfree(origin_path);
+	if (ctx.origin_path) {
+		dput(ctx.origin_path->dentry);
+		kfree(ctx.origin_path);
 	}
-	dput(index);
-	ovl_stack_free(stack, ctr);
+	dput(ctx.index);
+	ovl_stack_free(ctx.stack, ctx.ctr);
 	kfree(d.redirect);
-	return d_splice_alias(inode, dentry);
 
-out_free_oe:
-	ovl_free_entry(oe);
-out_put:
-	dput(index);
-	ovl_stack_free(stack, ctr);
-out_put_upper:
-	if (origin_path) {
-		dput(origin_path->dentry);
-		kfree(origin_path);
+	if (err) {
+		ovl_free_entry(ctx.oe);
+		dput(ctx.upperdentry);
+		kfree(d.upperredirect);
+		return ERR_PTR(err);
 	}
-	dput(upperdentry);
-	kfree(d.upperredirect);
-out:
-	kfree(d.redirect);
-	ovl_revert_creds(old_cred);
-	return ERR_PTR(err);
+
+	return d_splice_alias(ctx.inode, dentry);
 }
 
 bool ovl_lower_positive(struct dentry *dentry)
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 114/555] ovl: do not read the flags of a put upper dentry in lookup
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (112 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 113/555] ovl: refactor ovl_lookup() Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 115/555] ovl: fix leak of lowerdata redirect on ovl_get_inode() failure Greg Kroah-Hartman
                   ` (440 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Sashiko, Amir Goldstein, Sasha Levin

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

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

From: Amir Goldstein <amir73il@gmail.com>

[ Upstream commit 7031366be218f291592a7ad38bc34a7cd1459737 ]

ovl_lookup_layers() passes ctx->upperdentry to ovl_get_inode(), which
takes over the reference. If an overlay inode for the upper inode is
already cached, as for a second hard link, ovl_get_inode() puts the
dentry and returns the cached inode. ovl_lookup_layers() then passes
the put dentry to ovl_dentry_init_reval(), which reads its d_flags.

With a local upper fs the put dentry usually stays in the dcache, but
with a FUSE upper whose entry has timed out, dput() kills it, so this
is a use-after-free.

Fix this by taking the revalidate flags from the upper dentry of the
overlay inode, which is the one that ovl_dentry_revalidate_common()
revalidates.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-986db859-840c-479d-944c-b9c43b93377e
Fixes: bccece1ead36 ("ovl: allow remote upper")
Cc: stable@vger.kernel.org
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/overlayfs/namei.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index 2eddcaab781ba..7053a24f42d99 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -1363,9 +1363,17 @@ static int ovl_lookup_layers(struct ovl_lookup_ctx *ctx, struct ovl_lookup_data
 
 		if (metacopy_size > OVL_METACOPY_MIN_SIZE)
 			ovl_set_flag(OVL_HAS_DIGEST, ctx->inode);
-	}
 
-	ovl_dentry_init_reval(dentry, ctx->upperdentry, OVL_I_E(ctx->inode));
+		/*
+		 * ovl_get_inode() puts ctx->upperdentry if it finds a cached
+		 * inode, e.g. for another hard link, so use the upper dentry
+		 * of the inode.
+		 */
+		ovl_dentry_init_reval(dentry, ovl_i_dentry_upper(inode),
+				      OVL_I_E(inode));
+	} else {
+		ovl_dentry_init_reval(dentry, NULL, NULL);
+	}
 
 	return 0;
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 115/555] ovl: fix leak of lowerdata redirect on ovl_get_inode() failure
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (113 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 114/555] ovl: do not read the flags of a put upper dentry in lookup Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 116/555] ovl: bump the impure dir version when linking a file with origin Greg Kroah-Hartman
                   ` (439 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Amir Goldstein, Sasha Levin

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

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

From: Amir Goldstein <amir73il@gmail.com>

[ Upstream commit f1b7e5534854043077bb72afc8d87ad1e0b283e0 ]

ovl_lookup_layers() moves d->redirect into oip.lowerdata_redirect and
clears d->redirect before calling ovl_get_inode().  When ovl_get_inode()
fails, it does not free oip.lowerdata_redirect, and ovl_lookup() frees
the already cleared d->redirect, so the lowerdata redirect string is
leaked.

Clear d->redirect only after ovl_get_inode() has succeeded, like
d->upperredirect, so that ovl_lookup() frees it on failure.

Fixes: 2b21da920866 ("ovl: prepare to store lowerdata redirect for lazy lowerdata lookup")
Closes: https://sashiko.dev/#/bug/linux-dabbd363-9c71-4915-af72-e2b5e75fa58e
Cc: stable@vger.kernel.org
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/overlayfs/namei.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index 7053a24f42d99..c2ae3aed3736b 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -1348,15 +1348,16 @@ static int ovl_lookup_layers(struct ovl_lookup_ctx *ctx, struct ovl_lookup_data
 		};
 
 		/* Store lowerdata redirect for lazy lookup */
-		if (ctx->ctr > 1 && !d->is_dir && !ctx->stack[ctx->ctr - 1].dentry) {
+		if (ctx->ctr > 1 && !d->is_dir && !ctx->stack[ctx->ctr - 1].dentry)
 			oip.lowerdata_redirect = d->redirect;
-			d->redirect = NULL;
-		}
 
 		inode = ovl_get_inode(dentry->d_sb, &oip);
 		if (IS_ERR(inode))
 			return PTR_ERR(inode);
 
+		if (oip.lowerdata_redirect)
+			d->redirect = NULL;
+
 		ctx->inode = inode;
 		if (ctx->upperdentry && !uppermetacopy)
 			ovl_set_flag(OVL_UPPERDATA, ctx->inode);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 116/555] ovl: bump the impure dir version when linking a file with origin
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (114 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 115/555] ovl: fix leak of lowerdata redirect on ovl_get_inode() failure Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 117/555] smb: client: hold server ref while queueing reconnect work Greg Kroah-Hartman
                   ` (438 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sashiko, Daejun Park, Amir Goldstein,
	Sasha Levin

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

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

From: Daejun Park <daejun7.park@samsung.com>

[ Upstream commit 86e2facd8630cc2fdec6ea80c53e370b26b441d9 ]

Linking a file with copy up origin into a non-merge impure dir does
not bump the dir version. readdir then reuses the impure dir cache
built before the link. It reports the upper inode number as d_ino of
the new link, not st_ino.

Pass whether the linked file has an origin to ovl_dir_modified(), as
rename and unlink do.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-98f207b6-3936-48e9-a40f-88f20be4db7b
Fixes: 4edb83bb1041 ("ovl: constant d_ino for non-merge dirs")
Cc: stable@vger.kernel.org
Signed-off-by: Daejun Park <daejun7.park@samsung.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
[ sashal: Added a bool origin parameter to ovl_create_upper() and ovl_create_over_whiteout() and passed it from the direct calls in ovl_create_or_link(), since the upstream ovl_create_handle_whiteouts() wrapper doesn't exist here. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/overlayfs/dir.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 5426db632179a..b47fe22e39ada 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -328,7 +328,7 @@ static bool ovl_type_origin(struct dentry *dentry)
 }
 
 static int ovl_create_upper(struct dentry *dentry, struct inode *inode,
-			    struct ovl_cattr *attr)
+			    struct ovl_cattr *attr, bool origin)
 {
 	struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
 	struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent);
@@ -351,7 +351,7 @@ static int ovl_create_upper(struct dentry *dentry, struct inode *inode,
 		ovl_set_opaque(dentry, newdentry);
 	}
 
-	ovl_dir_modified(dentry->d_parent, false);
+	ovl_dir_modified(dentry->d_parent, origin);
 	err = ovl_instantiate(dentry, inode, newdentry, !!attr->hardlink, NULL);
 	if (err)
 		goto out_cleanup;
@@ -450,7 +450,7 @@ static int ovl_set_upper_acl(struct ovl_fs *ofs, struct dentry *upperdentry,
 }
 
 static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode,
-				    struct ovl_cattr *cattr)
+				    struct ovl_cattr *cattr, bool origin)
 {
 	struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
 	struct dentry *workdir = ovl_workdir(dentry);
@@ -536,7 +536,7 @@ static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode,
 		if (err)
 			goto out_cleanup;
 	}
-	ovl_dir_modified(dentry->d_parent, false);
+	ovl_dir_modified(dentry->d_parent, origin);
 	err = ovl_instantiate(dentry, inode, newdentry, hardlink, NULL);
 	if (err) {
 		ovl_cleanup(ofs, udir, newdentry);
@@ -622,9 +622,9 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
 	}
 
 	if (!ovl_dentry_is_whiteout(dentry))
-		err = ovl_create_upper(dentry, inode, attr);
+		err = ovl_create_upper(dentry, inode, attr, origin);
 	else
-		err = ovl_create_over_whiteout(dentry, inode, attr);
+		err = ovl_create_over_whiteout(dentry, inode, attr, origin);
 
 out_revert_creds:
 	ovl_revert_creds(old_cred);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 117/555] smb: client: hold server ref while queueing reconnect work
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (115 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 116/555] ovl: bump the impure dir version when linking a file with origin Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 118/555] smb: client: dont write back through O_DIRECT handles Greg Kroah-Hartman
                   ` (437 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Joseph Qi, Paulo Alcantara,
	Sasha Levin

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

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

From: Joseph Qi <joseph.qi@linux.alibaba.com>

[ Upstream commit f02d249e9756b78990aaaa1635e47e06deb2cb51 ]

When query_server_interfaces() returns -EOPNOTSUPP on a secondary
channel, smb2_reconnect() calls smb3_update_ses_channels() which for a
channel runs cifs_chan_skip_or_disable().  That clears the channel's
slot in the session and calls cifs_put_tcp_session(), which can drop
the last reference of the channel and tear it down.

smb2_reconnect() then falls through to skip_add_channels and queues
reconnect work on that server, using a server that may already be
freed.  The send path obtained the channel from cifs_pick_channel(),
which does not take a reference, so the session's channel reference is
the only one.

Take our own reference on the channel before calling
smb3_update_ses_channels() and drop it after the reconnect work has
been queued, so the channel cannot be freed while it is still used.

Fixes: f591062bdbf4 ("cifs: handle servers that still advertise multichannel after disabling")
Cc: stable@vger.kernel.org
Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
[ sashal: Replaced the upstream smb3_update_ses_channels() and cifs_queue_server_reconn() calls with this tree's cifs_chan_skip_or_disable() and mod_delayed_work(), and left the local declaration context unchanged. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/smb/client/smb2pdu.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index 8bbeaa106287c..19d3de220e394 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -217,6 +217,7 @@ static int
 smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
 	       struct TCP_Server_Info *server, bool from_reconnect)
 {
+	bool hold_server_ref = false;
 	int rc = 0;
 	struct nls_table *nls_codepage = NULL;
 	struct cifs_ses *ses;
@@ -455,6 +456,20 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
 			 * treat this as server not supporting multichannel
 			 */
 
+			/*
+			 * If server is a secondary channel,
+			 * cifs_chan_skip_or_disable() called below may
+			 * drop its last reference, so hold our own
+			 * reference until the reconnect work below has
+			 * been queued.
+			 */
+			spin_lock(&cifs_tcp_ses_lock);
+			if (server->srv_count) {
+				server->srv_count++;
+				hold_server_ref = true;
+			}
+			spin_unlock(&cifs_tcp_ses_lock);
+
 			rc = cifs_chan_skip_or_disable(ses, server,
 						       from_reconnect);
 			goto skip_add_channels;
@@ -481,6 +496,8 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
 
 	if (smb2_command != SMB2_INTERNAL_CMD)
 		mod_delayed_work(cifsiod_wq, &server->reconnect, 0);
+	if (hold_server_ref)
+		cifs_put_tcp_session(server, from_reconnect);
 
 	atomic_inc(&tconInfoReconnectCount);
 out:
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 118/555] smb: client: dont write back through O_DIRECT handles
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (116 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 117/555] smb: client: hold server ref while queueing reconnect work Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 119/555] smb: client: dont fail writeback preparation if the task is dying Greg Kroah-Hartman
                   ` (436 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, David Howells, Paulo Alcantara,
	Sasha Levin

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

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

From: Paulo Alcantara <pc@manguebit.org>

[ Upstream commit 0e85145af984f7cae2aadaa694cb8612009027ac ]

Writeback uses the first writable handle of the inode, which may have
been opened with O_DIRECT.  Such handles are opened with
FILE_NO_INTERMEDIATE_BUFFERING, for which Windows rejects any unaligned
I/O with STATUS_INVALID_PARAMETER.  Writeback of partly dirty pages and
of the unaligned tail of a file through one of them fails, so netfs ends
it with the folios clean and the data never reaches the server.

xfstests generic/051, where fsstress mixes both kinds of opens, loses
about 1% of its writes this way:

  smb3_write_err: ... offset=0xde90d7 len=0xbd0b rc=-22

All the rejected writes in a network capture were unaligned writes on a
no-buffering handle; none of the aligned ones, and none of the unaligned
ones on regular handles, were.

Prefer a handle that was not opened with O_DIRECT, and use one that was
only if there is no other.

Fixes: 1013e760d10e ("SMB3: Don't ignore O_SYNC/O_DSYNC and O_DIRECT flags")
Reviewed-by: David Howells <dhowells@redhat.com>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Cc: stable@vger.kernel.org
[ sashal: Renamed the FIND_ANY flag to FIND_WR_ANY and added FIND_WR_NO_DIRECT as a #define instead of an enum entry, and dropped the tmpfile hunk since this tree has no tmpfile handling. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/smb/client/cifsglob.h |  1 +
 fs/smb/client/file.c     | 13 +++++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index 27bdb50751852..3fe2144b00d2e 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -1815,6 +1815,7 @@ static inline bool is_replayable_error(int error)
 #define FIND_WR_ANY         0
 #define FIND_WR_FSUID_ONLY  1
 #define FIND_WR_WITH_DELETE 2
+#define FIND_WR_NO_DIRECT   4
 
 #define   MID_FREE 0
 #define   MID_REQUEST_ALLOCATED 1
diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index 4a62787891292..5aaa77ef527ab 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -267,9 +267,15 @@ static void cifs_begin_writeback(struct netfs_io_request *wreq)
 	struct cifs_io_request *req = container_of(wreq, struct cifs_io_request, rreq);
 	int ret;
 
-	ret = cifs_get_writable_file(CIFS_I(wreq->inode), FIND_WR_ANY, &req->cfile);
+	ret = cifs_get_writable_file(CIFS_I(wreq->inode), FIND_WR_NO_DIRECT,
+				     &req->cfile);
 	if (ret) {
-		cifs_dbg(VFS, "No writable handle in writepages ret=%d\n", ret);
+		ret = cifs_get_writable_file(CIFS_I(wreq->inode), FIND_WR_ANY,
+					     &req->cfile);
+	}
+	if (ret) {
+		cifs_dbg(VFS, "%s: couldn't find writable handle: %d\n",
+			 __func__, ret);
 		return;
 	}
 
@@ -2554,6 +2560,9 @@ cifs_get_writable_file(struct cifsInodeInfo *cifs_inode, int flags,
 			continue;
 		if (with_delete && !(open_file->fid.access & DELETE))
 			continue;
+		if ((flags & FIND_WR_NO_DIRECT) &&
+		    (open_file->f_flags & O_DIRECT))
+			continue;
 		if (OPEN_FMODE(open_file->f_flags) & FMODE_WRITE) {
 			if (!open_file->invalidHandle) {
 				/* found a good writable file */
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 119/555] smb: client: dont fail writeback preparation if the task is dying
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (117 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 118/555] smb: client: dont write back through O_DIRECT handles Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 120/555] serial: core: respect runtime PM when sending x_char Greg Kroah-Hartman
                   ` (435 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, David Howells, Paulo Alcantara,
	Sasha Levin

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

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

From: Paulo Alcantara <pc@manguebit.org>

[ Upstream commit 29ead886deaa1344a43ab68b1ea305ea2c86c378 ]

cifs_prepare_write() may need to reopen an invalidated handle and to wait
for credits, both from the context of the task doing writeback.  A dying
task gets the reopen refused at send time and the killable credit wait
interrupted, so the subrequest is failed and, as with refused sends, its
folios end writeback clean and the data is lost.

For writeback in a dying task, skip both and prepare a credit-less
subrequest capped at SMB2_MAX_BUFFER_SIZE, as already done when the
server is low on credits.  It gets issued from cifswritebackd, which
reopens the handle if needed and takes a single credit when sending,
neither of which can be interrupted there.  Do the same when the reopen
or credit wait fails because a fatal signal arrived meanwhile.

cifs_begin_writeback() reopens the handle too when all the writable ones
got invalidated, e.g. by a reconnect.  If that fails, there is no
upload stream, so netfs ends writeback of every folio clean with no
error recorded.  Take an invalidated handle as is there and leave
reopening it to cifs_prepare_write().  If there is no writable handle at
all, record -EIO for the mapping, so that the loss gets reported.

Fixes: 3ee1a1fc3981 ("cifs: Cut over to using netfslib")
Reviewed-by: David Howells <dhowells@redhat.com>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Cc: stable@vger.kernel.org
[ sashal: Adapted the no-reopen flag to the older FIND_WR_* macro scheme, dropped the tmpfile hunk, and moved cifs_writeback_dying() above cifs_prepare_write(). ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/smb/client/cifsglob.h |  1 +
 fs/smb/client/file.c     | 47 ++++++++++++++++++++++++++++++----------
 2 files changed, 36 insertions(+), 12 deletions(-)

diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index 3fe2144b00d2e..c5894fd7d0b50 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -1816,6 +1816,7 @@ static inline bool is_replayable_error(int error)
 #define FIND_WR_FSUID_ONLY  1
 #define FIND_WR_WITH_DELETE 2
 #define FIND_WR_NO_DIRECT   4
+#define FIND_WR_NO_REOPEN   8
 
 #define   MID_FREE 0
 #define   MID_REQUEST_ALLOCATED 1
diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index 5aaa77ef527ab..5c24f05d53fd0 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -40,6 +40,12 @@
 
 static int cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush);
 
+static bool cifs_writeback_dying(struct netfs_io_subrequest *subreq)
+{
+	return subreq->rreq->origin == NETFS_WRITEBACK &&
+		fatal_signal_pending(current);
+}
+
 /*
  * Prepare a subrequest to upload to the server.  We need to allocate credits
  * so that we know the maximum amount of data that we can include in it.
@@ -63,12 +69,17 @@ static void cifs_prepare_write(struct netfs_io_subrequest *subreq)
 	server = cifs_pick_channel(tlink_tcon(open_file->tlink)->ses);
 	wdata->server = server;
 
+	if (cifs_writeback_dying(subreq))
+		goto defer;
+
 retry:
 	if (open_file->invalidHandle) {
 		rc = cifs_reopen_file(open_file, false);
 		if (rc < 0) {
 			if (rc == -EAGAIN)
 				goto retry;
+			if (cifs_writeback_dying(subreq))
+				goto defer;
 			subreq->error = rc;
 			return netfs_prepare_write_failed(subreq);
 		}
@@ -77,10 +88,17 @@ static void cifs_prepare_write(struct netfs_io_subrequest *subreq)
 	rc = server->ops->wait_mtu_credits(server, wsize, &stream->sreq_max_len,
 					   &wdata->credits);
 	if (rc < 0) {
+		if (cifs_writeback_dying(subreq))
+			goto defer;
 		subreq->error = rc;
 		return netfs_prepare_write_failed(subreq);
 	}
+	goto out;
 
+defer:
+	wdata->credits = (struct cifs_credits){};
+	stream->sreq_max_len = min_t(size_t, wsize, SMB2_MAX_BUFFER_SIZE);
+out:
 	wdata->credits.rreq_debug_id = subreq->rreq->debug_id;
 	wdata->credits.rreq_debug_index = subreq->debug_index;
 	wdata->credits.in_flight_check = 1;
@@ -97,12 +115,6 @@ static void cifs_prepare_write(struct netfs_io_subrequest *subreq)
 #endif
 }
 
-static bool cifs_writeback_dying(struct netfs_io_subrequest *subreq)
-{
-	return subreq->rreq->origin == NETFS_WRITEBACK &&
-		fatal_signal_pending(current);
-}
-
 /*
  * Issue a subrequest to upload to the server.
  */
@@ -142,10 +154,15 @@ static void __cifs_issue_write(struct netfs_io_subrequest *subreq)
 
 static void cifs_issue_write_worker(struct work_struct *work)
 {
-	struct netfs_io_subrequest *subreq;
+	struct cifs_io_subrequest *wdata;
+	struct cifsFileInfo *cfile;
 
-	subreq = container_of(work, struct netfs_io_subrequest, work);
-	__cifs_issue_write(subreq);
+	wdata = container_of(work, struct cifs_io_subrequest, subreq.work);
+	cfile = wdata->req->cfile;
+	while (cfile->invalidHandle &&
+	       cifs_reopen_file(cfile, false) == -EAGAIN)
+		;
+	__cifs_issue_write(&wdata->subreq);
 }
 
 static void cifs_issue_write(struct netfs_io_subrequest *subreq)
@@ -267,15 +284,17 @@ static void cifs_begin_writeback(struct netfs_io_request *wreq)
 	struct cifs_io_request *req = container_of(wreq, struct cifs_io_request, rreq);
 	int ret;
 
-	ret = cifs_get_writable_file(CIFS_I(wreq->inode), FIND_WR_NO_DIRECT,
+	ret = cifs_get_writable_file(CIFS_I(wreq->inode),
+				     FIND_WR_NO_REOPEN | FIND_WR_NO_DIRECT,
 				     &req->cfile);
 	if (ret) {
-		ret = cifs_get_writable_file(CIFS_I(wreq->inode), FIND_WR_ANY,
-					     &req->cfile);
+		ret = cifs_get_writable_file(CIFS_I(wreq->inode),
+					     FIND_WR_NO_REOPEN, &req->cfile);
 	}
 	if (ret) {
 		cifs_dbg(VFS, "%s: couldn't find writable handle: %d\n",
 			 __func__, ret);
+		mapping_set_error(wreq->mapping, -EIO);
 		return;
 	}
 
@@ -2590,6 +2609,10 @@ cifs_get_writable_file(struct cifsInodeInfo *cifs_inode, int flags,
 	spin_unlock(&cifs_inode->open_file_lock);
 
 	if (inv_file) {
+		if (flags & FIND_WR_NO_REOPEN) {
+			*ret_file = inv_file;
+			return 0;
+		}
 		rc = cifs_reopen_file(inv_file, false);
 		if (!rc) {
 			*ret_file = inv_file;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 120/555] serial: core: respect runtime PM when sending x_char
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (118 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 119/555] smb: client: dont fail writeback preparation if the task is dying Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 121/555] usb: typec: ucsi: acpi: Assume UCSI 1.0 on HP ZBook 8 G2i 14 Greg Kroah-Hartman
                   ` (434 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, stable, Jiri Slaby, Hugo Villeneuve,
	Johan Hovold, Karl Mehltretter, John Ogness,
	Uwe Kleine-König  , Tony Lindgren, Josef Bacik, Sasha Levin

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

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

From: Josef Bacik <josef@toxicpanda.com>

[ Upstream commit 84da8238f7bd3025fc16da32c4cd9992c95a783b ]

__uart_start() calls the start_tx operation only if the port is runtime
active.  Otherwise it asks for a resume, and
serial_port_runtime_resume() starts the transmitter.

uart_send_xchar() calls start_tx at once, under the port lock, whatever
the state of the device.  With 8250_omap, serial8250_start_tx() then
calls pm_runtime_get_sync() for a suspended device: that sleeps, and
omap8250_runtime_resume() takes the port lock again.  A tcflow(TCIOFF)
on an idle port is enough, if autosuspend has been enabled.  It was
allowed as long as that driver used pm_runtime_irq_safe().

Share the part of __uart_start() that deals with runtime PM.  A stopped
transmission still does not hold up an XON or XOFF character.  Let a
pending x_char count as work for serial_port_runtime_resume(), and keep
the port from being suspended with it.

Fixes: 8700a7ea5519 ("serial: 8250_omap: Drop pm_runtime_irq_safe()")
Cc: stable <stable@kernel.org>
Cc: Jiri Slaby <jirislaby@kernel.org>
Cc: Hugo Villeneuve <hvilleneuve@dimonoff.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: Karl Mehltretter <kmehltretter@gmail.com>
Cc: John Ogness <john.ogness@linutronix.de>
Cc: "Uwe Kleine-König (The Capable Hub)" <u.kleine-koenig@baylibre.com>
Cc: Tony Lindgren <tony.lindgren@linux.intel.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://patch.msgid.link/20261027-tty-llm-v1-2-99b0202ae546@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[ sashal: Kept the tree's explicit uart_port_lock_irqsave/unlock_irqrestore calls in uart_send_xchar() instead of upstream's guard(uart_port_lock_irqsave), with the new uart_port_start_tx() call placed inside the lock. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/tty/serial/serial_core.c | 25 +++++++++++++++----------
 drivers/tty/serial/serial_port.c |  4 ++--
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index c9f32c39d6f2e..cc14b2a109d89 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -134,17 +134,11 @@ static void uart_stop(struct tty_struct *tty)
 	uart_port_unlock_deref(port, flags);
 }
 
-static void __uart_start(struct uart_state *state)
+static void uart_port_start_tx(struct uart_port *port)
 {
-	struct uart_port *port = state->uart_port;
-	struct serial_port_device *port_dev;
+	struct serial_port_device *port_dev = port->port_dev;
 	int err;
 
-	if (!port || port->flags & UPF_DEAD || uart_tx_stopped(port))
-		return;
-
-	port_dev = port->port_dev;
-
 	/* Increment the runtime PM usage count for the active check below */
 	err = pm_runtime_get(&port_dev->dev);
 	if (err < 0 && err != -EINPROGRESS) {
@@ -163,6 +157,16 @@ static void __uart_start(struct uart_state *state)
 	pm_runtime_put_autosuspend(&port_dev->dev);
 }
 
+static void __uart_start(struct uart_state *state)
+{
+	struct uart_port *port = state->uart_port;
+
+	if (!port || port->flags & UPF_DEAD || uart_tx_stopped(port))
+		return;
+
+	uart_port_start_tx(port);
+}
+
 static void uart_start(struct tty_struct *tty)
 {
 	struct uart_state *state = tty->driver_data;
@@ -725,8 +729,9 @@ static void uart_send_xchar(struct tty_struct *tty, u8 ch)
 	else {
 		uart_port_lock_irqsave(port, &flags);
 		port->x_char = ch;
-		if (ch)
-			port->ops->start_tx(port);
+		/* It goes out even if the transmission is stopped */
+		if (ch && !(port->flags & UPF_DEAD))
+			uart_port_start_tx(port);
 		uart_port_unlock_irqrestore(port, flags);
 	}
 	uart_port_deref(port);
diff --git a/drivers/tty/serial/serial_port.c b/drivers/tty/serial/serial_port.c
index 85285c56fabff..b873220862d2e 100644
--- a/drivers/tty/serial/serial_port.c
+++ b/drivers/tty/serial/serial_port.c
@@ -23,8 +23,8 @@
 /* Only considers pending TX for now. Caller must take care of locking */
 static int __serial_port_busy(struct uart_port *port)
 {
-	return !uart_tx_stopped(port) &&
-		!kfifo_is_empty(&port->state->port.xmit_fifo);
+	return port->x_char || (!uart_tx_stopped(port) &&
+		!kfifo_is_empty(&port->state->port.xmit_fifo));
 }
 
 static int serial_port_runtime_resume(struct device *dev)
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 121/555] usb: typec: ucsi: acpi: Assume UCSI 1.0 on HP ZBook 8 G2i 14
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (119 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 120/555] serial: core: respect runtime PM when sending x_char Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 122/555] usb: dwc3: Always deassert xilinx resets Greg Kroah-Hartman
                   ` (433 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, stable, Francesco Orro, Ihor Urazov,
	Heikki Krogerus, Huang Wei, Sasha Levin

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

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

From: Ihor Urazov <z0rc3r@gmail.com>

[ Upstream commit 3ee1e1c3fca6fb5d0abbe0fc91539951ffa60aa7 ]

The HP ZBook 8 G2i 14 (board 8ED9) exposes a working UCSI ACPI PPM, but
its UCSI VERSION field reads zero until the first command completes.
ucsi_register() rejects a zero version with -ENODEV, so no Type-C ports
are registered.

The firmware's _DSM READ function (2) is a stub. The mailbox VERSION
field is written only by the EC response handler, after a command
completes, after which it reads 0x0100 (UCSI 1.0). The mailbox is
48 bytes with 16-byte MESSAGE_IN/MESSAGE_OUT fields, the UCSI 1.x
layout, and _DSM function 5 is not implemented.

Add a DMI-specific read_version for this board that substitutes the
version the firmware itself reports, UCSI 1.0, only when VERSION reads
zero. A non-zero firmware version is used as is.

The same firmware defect on the HP ZBook Fury G1i 16 was discussed in
"[RFC PATCH] usb: typec: ucsi: acpi: bootstrap PPM on HP systems with
empty _DSM func 2" [1]. The defect was reported to HP as case
5166176673.

Tested on an HP ZBook 8 G2i 14 with BIOS Y70 01.02.08, from a fresh
boot where VERSION reads zero: three connectors register, the PD
contract and alternate modes of a Thunderbolt dock are reported, and
its DisplayPort output stays up across the PPM reset in ucsi_init().
Dock unplug/replug and s2idle suspend/resume update the connector
state without errors.

Link: https://lore.kernel.org/linux-usb/f3M_fpjtt8FxDqGKcA84vqXmRbKzCBfpCrIK4-jCWvIscER51zkD8qD8FYpz75qZw51rMDRSkUyYlrBvLvdM8CGRY2l8TFVvr4MC1LdTzbc=@interstellar.eu/ [1]
Fixes: c1b0bc2dabfa ("usb: typec: Add support for UCSI interface")
Cc: stable <stable@kernel.org>
Cc: Francesco Orro <ncesco@interstellar.eu>
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Ihor Urazov <z0rc3r@gmail.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Huang Wei <huangwei@kylinos.cn>
Link: https://patch.msgid.link/20261026-ucsi-hp-zbook-8-g2i-v1-1-91002e9ef073@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[ sashal: Dropped the .write_message_out line from ucsi_hp_ops because the older ops struct lacks that member, added the missing UCSI_VERSION_1_0 define to ucsi.h, and adjusted the insertion context. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/usb/typec/ucsi/ucsi.h      |  1 +
 drivers/usb/typec/ucsi/ucsi_acpi.c | 34 ++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/drivers/usb/typec/ucsi/ucsi.h b/drivers/usb/typec/ucsi/ucsi.h
index 120e5a5703854..d2489d64f0ad8 100644
--- a/drivers/usb/typec/ucsi/ucsi.h
+++ b/drivers/usb/typec/ucsi/ucsi.h
@@ -29,6 +29,7 @@ struct dentry;
 #define UCSIv2_MESSAGE_OUT		272
 
 /* UCSI versions */
+#define UCSI_VERSION_1_0	0x0100
 #define UCSI_VERSION_1_1	0x0110
 #define UCSI_VERSION_1_2	0x0120
 #define UCSI_VERSION_2_0	0x0200
diff --git a/drivers/usb/typec/ucsi/ucsi_acpi.c b/drivers/usb/typec/ucsi/ucsi_acpi.c
index 8c6793361b004..399a55c7d524e 100644
--- a/drivers/usb/typec/ucsi/ucsi_acpi.c
+++ b/drivers/usb/typec/ucsi/ucsi_acpi.c
@@ -131,6 +131,33 @@ static const struct ucsi_operations ucsi_acer_ops = {
 	.async_control = ucsi_acpi_async_control
 };
 
+static int ucsi_hp_read_version(struct ucsi *ucsi, u16 *version)
+{
+	struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi);
+	int ret;
+
+	ret = ucsi_acpi_read_version(ucsi, version);
+	if (ret)
+		return ret;
+
+	/* Firmware fills in VERSION (1.0) only after the first command completes */
+	if (!*version) {
+		dev_warn(ua->dev, "UCSI version is zero, assuming 1.0\n");
+		*version = UCSI_VERSION_1_0;
+	}
+
+	return 0;
+}
+
+static const struct ucsi_operations ucsi_hp_ops = {
+	.read_version = ucsi_hp_read_version,
+	.read_cci = ucsi_acpi_read_cci,
+	.poll_cci = ucsi_acpi_poll_cci,
+	.read_message_in = ucsi_acpi_read_message_in,
+	.sync_control = ucsi_sync_control_common,
+	.async_control = ucsi_acpi_async_control
+};
+
 static int ucsi_gram_read_message_in(struct ucsi *ucsi, void *val, size_t val_len)
 {
 	u16 bogus_change = UCSI_CONSTAT_POWER_LEVEL_CHANGE |
@@ -191,6 +218,13 @@ static const struct dmi_system_id ucsi_acpi_quirks[] = {
 		},
 		.driver_data = (void *)&ucsi_acer_ops,
 	},
+	{
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
+			DMI_MATCH(DMI_BOARD_NAME, "8ED9"),
+		},
+		.driver_data = (void *)&ucsi_hp_ops,
+	},
 	{
 		.matches = {
 			DMI_MATCH(DMI_SYS_VENDOR, "LG Electronics"),
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 122/555] usb: dwc3: Always deassert xilinx resets
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (120 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 121/555] usb: typec: ucsi: acpi: Assume UCSI 1.0 on HP ZBook 8 G2i 14 Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 123/555] usb: dwc3: xilinx: re-assert resets on ZynqMP init error paths Greg Kroah-Hartman
                   ` (432 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sean Anderson, Thinh Nguyen,
	Sasha Levin

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

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

From: Sean Anderson <sean.anderson@linux.dev>

[ Upstream commit ec06c8039d396a1b558cc138f5c5aba17698e175 ]

If we don't have a usb3 phy we don't need to assert the core resets.
Deassert them even if we didn't assert them to support booting when the
bootloader never released the core from reset.

Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Link: https://patch.msgid.link/20260106171018.501612-1-sean.anderson@linux.dev
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Stable-dep-of: f33f0dd2eb01 ("usb: dwc3: xilinx: re-assert resets on ZynqMP init error paths")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/usb/dwc3/dwc3-xilinx.c | 71 ++++++++++++++++------------------
 1 file changed, 34 insertions(+), 37 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-xilinx.c b/drivers/usb/dwc3/dwc3-xilinx.c
index 96ff5789f7f45..135fa9d3c747a 100644
--- a/drivers/usb/dwc3/dwc3-xilinx.c
+++ b/drivers/usb/dwc3/dwc3-xilinx.c
@@ -112,21 +112,6 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
 		goto err;
 	}
 
-	/*
-	 * The following core resets are not required unless a USB3 PHY
-	 * is used, and the subsequent register settings are not required
-	 * unless a core reset is performed (they should be set properly
-	 * by the first-stage boot loader, but may be reverted by a core
-	 * reset). They may also break the configuration if USB3 is actually
-	 * in use but the usb3-phy entry is missing from the device tree.
-	 * Therefore, skip these operations in this case.
-	 */
-	if (!priv_data->usb3_phy) {
-		/* Deselect the PIPE Clock Select bit in FPD PIPE Clock register */
-		writel(PIPE_CLK_DESELECT, priv_data->regs + XLNX_USB_FPD_PIPE_CLK);
-		goto skip_usb3_phy;
-	}
-
 	crst = devm_reset_control_get_exclusive(dev, "usb_crst");
 	if (IS_ERR(crst)) {
 		ret = PTR_ERR(crst);
@@ -151,22 +136,31 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
 		goto err;
 	}
 
-	ret = reset_control_assert(crst);
-	if (ret < 0) {
-		dev_err(dev, "Failed to assert core reset\n");
-		goto err;
-	}
-
-	ret = reset_control_assert(hibrst);
-	if (ret < 0) {
-		dev_err(dev, "Failed to assert hibernation reset\n");
-		goto err;
-	}
-
-	ret = reset_control_assert(apbrst);
-	if (ret < 0) {
-		dev_err(dev, "Failed to assert APB reset\n");
-		goto err;
+	/*
+	 * Asserting the core resets is not required unless a USB3 PHY is used.
+	 * They may also break the configuration if USB3 is actually in use but
+	 * the usb3-phy entry is missing from the device tree. Therefore, skip
+	 * a full reset cycle and just deassert the resets if the phy is
+	 * absent.
+	 */
+	if (priv_data->usb3_phy) {
+		ret = reset_control_assert(crst);
+		if (ret < 0) {
+			dev_err(dev, "Failed to assert core reset\n");
+			goto err;
+		}
+
+		ret = reset_control_assert(hibrst);
+		if (ret < 0) {
+			dev_err(dev, "Failed to assert hibernation reset\n");
+			goto err;
+		}
+
+		ret = reset_control_assert(apbrst);
+		if (ret < 0) {
+			dev_err(dev, "Failed to assert APB reset\n");
+			goto err;
+		}
 	}
 
 	ret = phy_init(priv_data->usb3_phy);
@@ -179,11 +173,15 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
 		goto err_phy_exit;
 	}
 
-	/* Set PIPE Power Present signal in FPD Power Present Register*/
-	writel(FPD_POWER_PRSNT_OPTION, priv_data->regs + XLNX_USB_FPD_POWER_PRSNT);
-
-	/* Set the PIPE Clock Select bit in FPD PIPE Clock register */
-	writel(PIPE_CLK_SELECT, priv_data->regs + XLNX_USB_FPD_PIPE_CLK);
+	if (priv_data->usb3_phy) {
+		/* Set PIPE Power Present signal in FPD Power Present Register*/
+		writel(FPD_POWER_PRSNT_OPTION, priv_data->regs + XLNX_USB_FPD_POWER_PRSNT);
+		/* Set the PIPE Clock Select bit in FPD PIPE Clock register */
+		writel(PIPE_CLK_SELECT, priv_data->regs + XLNX_USB_FPD_PIPE_CLK);
+	} else {
+		/* Deselect the PIPE Clock Select bit in FPD PIPE Clock register */
+		writel(PIPE_CLK_DESELECT, priv_data->regs + XLNX_USB_FPD_PIPE_CLK);
+	}
 
 	ret = reset_control_deassert(crst);
 	if (ret < 0) {
@@ -201,7 +199,6 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
 	if (ret < 0)
 		goto err_phy_exit;
 
-skip_usb3_phy:
 	/* ulpi reset via gpio-modepin or gpio-framework driver */
 	reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
 	if (IS_ERR(reset_gpio)) {
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 123/555] usb: dwc3: xilinx: re-assert resets on ZynqMP init error paths
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (121 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 122/555] usb: dwc3: Always deassert xilinx resets Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 124/555] w1: w1_therm: lock the list of slaves for the bulk read Greg Kroah-Hartman
                   ` (431 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, stable, Radhey Shyam Pandey,
	Thinh Nguyen, Sasha Levin

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

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

From: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>

[ Upstream commit f33f0dd2eb014bffda02ecfd182de3ddab058596 ]

If reset deassert or PHY setup fails partway through
dwc3_xlnx_init_zynqmp(), re-assert the resets that were already
released before unwinding the PHY.

Only undo the reset cycle the function actually performed. The cycle is
skipped when no usb3-phy is present, because asserting the core resets
can break a USB3 configuration that is live but missing from the device
tree, so the error path skips it for the same reason. Asserting an
already asserted reset is harmless, so one block covers however far the
deasserts progressed.

Save the ZynqMP reset handles in driver private data so later probe
teardown can re-assert released resets.

Fixes: 84770f028fab ("usb: dwc3: Add driver for Xilinx platforms")
Cc: stable <stable@kernel.org>
Assisted-by: Claude:claude-opus-5
Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Link: https://patch.msgid.link/20260928120015.3152461-3-radhey.shyam.pandey@amd.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/usb/dwc3/dwc3-xilinx.c | 55 ++++++++++++++++++++++------------
 1 file changed, 36 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-xilinx.c b/drivers/usb/dwc3/dwc3-xilinx.c
index 135fa9d3c747a..103a9e6ef35c4 100644
--- a/drivers/usb/dwc3/dwc3-xilinx.c
+++ b/drivers/usb/dwc3/dwc3-xilinx.c
@@ -45,6 +45,9 @@ struct dwc3_xlnx {
 	void __iomem			*regs;
 	int				(*pltfm_init)(struct dwc3_xlnx *data);
 	struct phy			*usb3_phy;
+	struct reset_control		*usb_crst;
+	struct reset_control		*usb_hibrst;
+	struct reset_control		*usb_apbrst;
 };
 
 static void dwc3_xlnx_mask_phy_rst(struct dwc3_xlnx *priv_data, bool mask)
@@ -99,7 +102,6 @@ static int dwc3_xlnx_init_versal(struct dwc3_xlnx *priv_data)
 static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
 {
 	struct device		*dev = priv_data->dev;
-	struct reset_control	*crst, *hibrst, *apbrst;
 	struct gpio_desc	*reset_gpio;
 	int			ret = 0;
 	u32			reg;
@@ -112,25 +114,25 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
 		goto err;
 	}
 
-	crst = devm_reset_control_get_exclusive(dev, "usb_crst");
-	if (IS_ERR(crst)) {
-		ret = PTR_ERR(crst);
+	priv_data->usb_crst = devm_reset_control_get_exclusive(dev, "usb_crst");
+	if (IS_ERR(priv_data->usb_crst)) {
+		ret = PTR_ERR(priv_data->usb_crst);
 		dev_err_probe(dev, ret,
 			      "failed to get core reset signal\n");
 		goto err;
 	}
 
-	hibrst = devm_reset_control_get_exclusive(dev, "usb_hibrst");
-	if (IS_ERR(hibrst)) {
-		ret = PTR_ERR(hibrst);
+	priv_data->usb_hibrst = devm_reset_control_get_exclusive(dev, "usb_hibrst");
+	if (IS_ERR(priv_data->usb_hibrst)) {
+		ret = PTR_ERR(priv_data->usb_hibrst);
 		dev_err_probe(dev, ret,
 			      "failed to get hibernation reset signal\n");
 		goto err;
 	}
 
-	apbrst = devm_reset_control_get_exclusive(dev, "usb_apbrst");
-	if (IS_ERR(apbrst)) {
-		ret = PTR_ERR(apbrst);
+	priv_data->usb_apbrst = devm_reset_control_get_exclusive(dev, "usb_apbrst");
+	if (IS_ERR(priv_data->usb_apbrst)) {
+		ret = PTR_ERR(priv_data->usb_apbrst);
 		dev_err_probe(dev, ret,
 			      "failed to get APB reset signal\n");
 		goto err;
@@ -144,19 +146,19 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
 	 * absent.
 	 */
 	if (priv_data->usb3_phy) {
-		ret = reset_control_assert(crst);
+		ret = reset_control_assert(priv_data->usb_crst);
 		if (ret < 0) {
 			dev_err(dev, "Failed to assert core reset\n");
 			goto err;
 		}
 
-		ret = reset_control_assert(hibrst);
+		ret = reset_control_assert(priv_data->usb_hibrst);
 		if (ret < 0) {
 			dev_err(dev, "Failed to assert hibernation reset\n");
 			goto err;
 		}
 
-		ret = reset_control_assert(apbrst);
+		ret = reset_control_assert(priv_data->usb_apbrst);
 		if (ret < 0) {
 			dev_err(dev, "Failed to assert APB reset\n");
 			goto err;
@@ -167,7 +169,7 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
 	if (ret < 0)
 		goto err;
 
-	ret = reset_control_deassert(apbrst);
+	ret = reset_control_deassert(priv_data->usb_apbrst);
 	if (ret < 0) {
 		dev_err(dev, "Failed to release APB reset\n");
 		goto err_phy_exit;
@@ -183,21 +185,21 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
 		writel(PIPE_CLK_DESELECT, priv_data->regs + XLNX_USB_FPD_PIPE_CLK);
 	}
 
-	ret = reset_control_deassert(crst);
+	ret = reset_control_deassert(priv_data->usb_crst);
 	if (ret < 0) {
 		dev_err(dev, "Failed to release core reset\n");
-		goto err_phy_exit;
+		goto err_reset_assert;
 	}
 
-	ret = reset_control_deassert(hibrst);
+	ret = reset_control_deassert(priv_data->usb_hibrst);
 	if (ret < 0) {
 		dev_err(dev, "Failed to release hibernation reset\n");
-		goto err_phy_exit;
+		goto err_reset_assert;
 	}
 
 	ret = phy_power_on(priv_data->usb3_phy);
 	if (ret < 0)
-		goto err_phy_exit;
+		goto err_reset_assert;
 
 	/* ulpi reset via gpio-modepin or gpio-framework driver */
 	reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
@@ -227,6 +229,21 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
 
 err_phy_power_off:
 	phy_power_off(priv_data->usb3_phy);
+err_reset_assert:
+	/*
+	 * Undo only the reset cycle performed above.  That cycle is skipped
+	 * when there is no usb3-phy.  The deasserts stay unconditional so a
+	 * core the bootloader left in reset still comes up, but they are
+	 * deliberately not paired with an assert here: resetting a USB3
+	 * configuration that is live but missing from the device tree could
+	 * break it.  Asserting an already asserted reset is harmless, so one
+	 * block covers however far the cycle's deasserts got.
+	 */
+	if (priv_data->usb3_phy) {
+		reset_control_assert(priv_data->usb_hibrst);
+		reset_control_assert(priv_data->usb_crst);
+		reset_control_assert(priv_data->usb_apbrst);
+	}
 err_phy_exit:
 	phy_exit(priv_data->usb3_phy);
 err:
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 124/555] w1: w1_therm: lock the list of slaves for the bulk read
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (122 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 123/555] usb: dwc3: xilinx: re-assert resets on ZynqMP init error paths Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 125/555] devres: add devm_remove_action_nowarn() Greg Kroah-Hartman
                   ` (430 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, stable, Josef Bacik,
	Krzysztof Kozlowski, Sasha Levin

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

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

From: Josef Bacik <josef@toxicpanda.com>

[ Upstream commit 1e46334d38e0217f5d255dc6fd63243593052f8e ]

The callbacks of the file therm_bulk_read walk the list of the slaves of
the master, trigger_bulk_read() three times and therm_bulk_read_show()
once, without the list_mutex which protects it.  In the meantime the
thread of the master may find out that a sensor has gone:

  write to therm_bulk_read              w1_process()
  trigger_bulk_read()                     w1_slave_detach()
    list_for_each_entry(sl, ...)            w1_unref_slave()
      bulk_read_slave(sl)                     list_del()
                                              w1_therm_remove_slave()
                                                kfree(sl->family_data)
                                              kfree(sl)
      SLAVE_CONVERT_TRIGGERED(sl) = 1

The walk reads, and writes to, memory which has been freed, and follows
the poisoned list pointers.

Take list_mutex around each of the four walks.  No pointer to a slave is
kept from one walk to the next.

This could not be done as long as w1_unref_slave() held the mutex while
it waited, in w1_therm_remove_slave(), for these very callbacks and for
the readers of the sensor, who need the bus_mutex which
trigger_bulk_read() holds around its second walk.  Now nothing is waited
for with list_mutex held, and none of the other mutexes of the subsystem
is taken under it, so it can be nested inside bus_mutex.

Fixes: 57c76221d5af ("w1_therm: adding bulk read support to trigger multiple conversion on bus")
Cc: stable <stable@kernel.org>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Link: https://patch.msgid.link/20261027-llm-char-misc-w1-v1-8-d2e6bfafb6a4@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/w1/slaves/w1_therm.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
index 361067390b714..58ba8a41dc7e8 100644
--- a/drivers/w1/slaves/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -1519,6 +1519,7 @@ static int trigger_bulk_read(struct w1_master *dev_master)
 	 * and compute duration of conversion for these devices
 	 * so we can apply a strong pullup if required
 	 */
+	mutex_lock(&dev_master->list_mutex);
 	list_for_each_entry(sl, &dev_master->slist, w1_slave_entry) {
 		if (bulk_read_slave(sl)) {
 			int t_cur = conversion_time(sl);
@@ -1530,6 +1531,7 @@ static int trigger_bulk_read(struct w1_master *dev_master)
 					w1_strong_pullup));
 		}
 	}
+	mutex_unlock(&dev_master->list_mutex);
 
 	/*
 	 * t_conv is the max conversion time required on the bus
@@ -1556,11 +1558,13 @@ static int trigger_bulk_read(struct w1_master *dev_master)
 			w1_write_8(dev_master, W1_CONVERT_TEMP);
 
 			/* set a flag to instruct that converT pending */
+			mutex_lock(&dev_master->list_mutex);
 			list_for_each_entry(sl,
 				&dev_master->slist, w1_slave_entry) {
 				if (bulk_read_slave(sl))
 					SLAVE_CONVERT_TRIGGERED(sl) = -1;
 			}
+			mutex_unlock(&dev_master->list_mutex);
 
 			if (strong_pullup) { /* some device need pullup */
 				sleep_rem = msleep_interruptible(t_conv);
@@ -1586,10 +1590,12 @@ static int trigger_bulk_read(struct w1_master *dev_master)
 	mutex_unlock(&dev_master->bus_mutex);
 set_flag:
 	/* set a flag to register convsersion is done */
+	mutex_lock(&dev_master->list_mutex);
 	list_for_each_entry(sl, &dev_master->slist, w1_slave_entry) {
 		if (bulk_read_slave(sl))
 			SLAVE_CONVERT_TRIGGERED(sl) = 1;
 	}
+	mutex_unlock(&dev_master->list_mutex);
 error:
 	return ret;
 }
@@ -1954,6 +1960,7 @@ static ssize_t therm_bulk_read_show(struct device *device,
 	struct w1_slave *sl = NULL;
 	int ret = 0;
 
+	mutex_lock(&dev_master->list_mutex);
 	list_for_each_entry(sl, &dev_master->slist, w1_slave_entry) {
 		if (bulk_read_slave(sl)) {
 			if (SLAVE_CONVERT_TRIGGERED(sl) == -1) {
@@ -1966,6 +1973,7 @@ static ssize_t therm_bulk_read_show(struct device *device,
 		}
 	}
 show_result:
+	mutex_unlock(&dev_master->list_mutex);
 	return sprintf(buf, "%d\n", ret);
 }
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 125/555] devres: add devm_remove_action_nowarn()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (123 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 124/555] w1: w1_therm: lock the list of slaves for the bulk read Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 126/555] devres: Move devm_*_action*() APIs to devres.h Greg Kroah-Hartman
                   ` (429 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Danilo Krummrich, Sasha Levin

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

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

From: Danilo Krummrich <dakr@kernel.org>

[ Upstream commit f1725160fd28a2e65e47166637aa44856a1a7f89 ]

devm_remove_action() warns if the action to remove does not exist
(anymore).

The Rust devres abstraction, however, has a use-case to call
devm_remove_action() at a point where it can't be guaranteed that the
corresponding action hasn't been released yet.

In particular, an instance of `Devres<T>` may be dropped after the
action has been released. So far, `Devres<T>` worked around this by
keeping the inner type alive.

Hence, add devm_remove_action_nowarn(), which returns an error code if
the action has been removed already.

A subsequent patch uses devm_remove_action_nowarn() to remove the action
when `Devres<T>` is dropped.

Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Link: https://lore.kernel.org/r/20250107122609.8135-1-dakr@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Stable-dep-of: 6c6508e742b4 ("usb: dwc3: xilinx: unwind ZynqMP platform init on probe failure and remove")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/base/devres.c  | 23 ++++++++++++++++++-----
 include/linux/device.h | 18 +++++++++++++++++-
 2 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index f229c5b3e7850..03da20f0431dc 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -757,25 +757,38 @@ int __devm_add_action(struct device *dev, void (*action)(void *), void *data, co
 EXPORT_SYMBOL_GPL(__devm_add_action);
 
 /**
- * devm_remove_action() - removes previously added custom action
+ * devm_remove_action_nowarn() - removes previously added custom action
  * @dev: Device that owns the action
  * @action: Function implementing the action
  * @data: Pointer to data passed to @action implementation
  *
  * Removes instance of @action previously added by devm_add_action().
  * Both action and data should match one of the existing entries.
+ *
+ * In contrast to devm_remove_action(), this function does not WARN() if no
+ * entry could have been found.
+ *
+ * This should only be used if the action is contained in an object with
+ * independent lifetime management, e.g. the Devres rust abstraction.
+ *
+ * Causing the warning from regular driver code most likely indicates an abuse
+ * of the devres API.
+ *
+ * Returns: 0 on success, -ENOENT if no entry could have been found.
  */
-void devm_remove_action(struct device *dev, void (*action)(void *), void *data)
+int devm_remove_action_nowarn(struct device *dev,
+			      void (*action)(void *),
+			      void *data)
 {
 	struct action_devres devres = {
 		.data = data,
 		.action = action,
 	};
 
-	WARN_ON(devres_destroy(dev, devm_action_release, devm_action_match,
-			       &devres));
+	return devres_destroy(dev, devm_action_release, devm_action_match,
+			      &devres);
 }
-EXPORT_SYMBOL_GPL(devm_remove_action);
+EXPORT_SYMBOL_GPL(devm_remove_action_nowarn);
 
 /**
  * devm_release_action() - release previously added custom action
diff --git a/include/linux/device.h b/include/linux/device.h
index 95bfb360915b9..601e60c68504c 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -287,7 +287,23 @@ void device_remove_bin_file(struct device *dev,
 			    const struct bin_attribute *attr);
 
 /* allows to add/remove a custom action to devres stack */
-void devm_remove_action(struct device *dev, void (*action)(void *), void *data);
+int devm_remove_action_nowarn(struct device *dev, void (*action)(void *), void *data);
+
+/**
+ * devm_remove_action() - removes previously added custom action
+ * @dev: Device that owns the action
+ * @action: Function implementing the action
+ * @data: Pointer to data passed to @action implementation
+ *
+ * Removes instance of @action previously added by devm_add_action().
+ * Both action and data should match one of the existing entries.
+ */
+static inline
+void devm_remove_action(struct device *dev, void (*action)(void *), void *data)
+{
+	WARN_ON(devm_remove_action_nowarn(dev, action, data));
+}
+
 void devm_release_action(struct device *dev, void (*action)(void *), void *data);
 
 int __devm_add_action(struct device *dev, void (*action)(void *), void *data, const char *name);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 126/555] devres: Move devm_*_action*() APIs to devres.h
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (124 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 125/555] devres: add devm_remove_action_nowarn() Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 127/555] devres: Add devm_is_action_added() helper Greg Kroah-Hartman
                   ` (428 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Raag Jadav, Andy Shevchenko,
	Zijun Hu, Bartosz Golaszewski, Sasha Levin

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

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

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

[ Upstream commit f5e5631df596ade5875ba1dc5d640611745d0c0d ]

We have a newly created header linux/device/devres.h that gathers
device managed APIs, so users won't need to include entire device.h
for only these ones. Move devm_*_action*() APIs to devres.h as well.

Reviewed-by: Raag Jadav <raag.jadav@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Zijun Hu <quic_zijuhu@quicinc.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20250220162238.2738038-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Stable-dep-of: 6c6508e742b4 ("usb: dwc3: xilinx: unwind ZynqMP platform init on probe failure and remove")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/linux/device.h        | 38 ----------------------------------
 include/linux/device/devres.h | 39 +++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 38 deletions(-)

diff --git a/include/linux/device.h b/include/linux/device.h
index 601e60c68504c..a1d412a9d6324 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -286,44 +286,6 @@ int __must_check device_create_bin_file(struct device *dev,
 void device_remove_bin_file(struct device *dev,
 			    const struct bin_attribute *attr);
 
-/* allows to add/remove a custom action to devres stack */
-int devm_remove_action_nowarn(struct device *dev, void (*action)(void *), void *data);
-
-/**
- * devm_remove_action() - removes previously added custom action
- * @dev: Device that owns the action
- * @action: Function implementing the action
- * @data: Pointer to data passed to @action implementation
- *
- * Removes instance of @action previously added by devm_add_action().
- * Both action and data should match one of the existing entries.
- */
-static inline
-void devm_remove_action(struct device *dev, void (*action)(void *), void *data)
-{
-	WARN_ON(devm_remove_action_nowarn(dev, action, data));
-}
-
-void devm_release_action(struct device *dev, void (*action)(void *), void *data);
-
-int __devm_add_action(struct device *dev, void (*action)(void *), void *data, const char *name);
-#define devm_add_action(dev, action, data) \
-	__devm_add_action(dev, action, data, #action)
-
-static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(void *),
-					     void *data, const char *name)
-{
-	int ret;
-
-	ret = __devm_add_action(dev, action, data, name);
-	if (ret)
-		action(data);
-
-	return ret;
-}
-#define devm_add_action_or_reset(dev, action, data) \
-	__devm_add_action_or_reset(dev, action, data, #action)
-
 /**
  * devm_alloc_percpu - Resource-managed alloc_percpu
  * @dev: Device to allocate per-cpu memory for
diff --git a/include/linux/device/devres.h b/include/linux/device/devres.h
index 9b49f99158508..9cd1787ef28ed 100644
--- a/include/linux/device/devres.h
+++ b/include/linux/device/devres.h
@@ -8,6 +8,7 @@
 #include <linux/overflow.h>
 #include <linux/stdarg.h>
 #include <linux/types.h>
+#include <asm/bug.h>
 
 struct device;
 struct device_node;
@@ -126,4 +127,42 @@ void __iomem *devm_of_iomap(struct device *dev, struct device_node *node, int in
 
 #endif
 
+/* allows to add/remove a custom action to devres stack */
+int devm_remove_action_nowarn(struct device *dev, void (*action)(void *), void *data);
+
+/**
+ * devm_remove_action() - removes previously added custom action
+ * @dev: Device that owns the action
+ * @action: Function implementing the action
+ * @data: Pointer to data passed to @action implementation
+ *
+ * Removes instance of @action previously added by devm_add_action().
+ * Both action and data should match one of the existing entries.
+ */
+static inline
+void devm_remove_action(struct device *dev, void (*action)(void *), void *data)
+{
+	WARN_ON(devm_remove_action_nowarn(dev, action, data));
+}
+
+void devm_release_action(struct device *dev, void (*action)(void *), void *data);
+
+int __devm_add_action(struct device *dev, void (*action)(void *), void *data, const char *name);
+#define devm_add_action(dev, action, data) \
+	__devm_add_action(dev, action, data, #action)
+
+static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(void *),
+					     void *data, const char *name)
+{
+	int ret;
+
+	ret = __devm_add_action(dev, action, data, name);
+	if (ret)
+		action(data);
+
+	return ret;
+}
+#define devm_add_action_or_reset(dev, action, data) \
+	__devm_add_action_or_reset(dev, action, data, #action)
+
 #endif /* _DEVICE_DEVRES_H_ */
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 127/555] devres: Add devm_is_action_added() helper
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (125 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 126/555] devres: Move devm_*_action*() APIs to devres.h Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 128/555] usb: dwc3: xilinx: unwind ZynqMP platform init on probe failure and remove Greg Kroah-Hartman
                   ` (427 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Raag Jadav, Andy Shevchenko,
	Zijun Hu, Bartosz Golaszewski, Sasha Levin

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

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

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

[ Upstream commit e383bb8f958444620d96386811aacf6a49757996 ]

In some code we would like to know if the action in device managed resources
was added by devm_add_action() family of calls. Introduce a helper for that.

Reviewed-by: Raag Jadav <raag.jadav@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Zijun Hu <quic_zijuhu@quicinc.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20250220162238.2738038-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Stable-dep-of: 6c6508e742b4 ("usb: dwc3: xilinx: unwind ZynqMP platform init on probe failure and remove")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/base/devres.c         | 11 +++++++++++
 include/linux/device/devres.h |  2 ++
 2 files changed, 13 insertions(+)

diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index 03da20f0431dc..89fcb95efad93 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -756,6 +756,17 @@ int __devm_add_action(struct device *dev, void (*action)(void *), void *data, co
 }
 EXPORT_SYMBOL_GPL(__devm_add_action);
 
+bool devm_is_action_added(struct device *dev, void (*action)(void *), void *data)
+{
+	struct action_devres devres = {
+		.data = data,
+		.action = action,
+	};
+
+	return devres_find(dev, devm_action_release, devm_action_match, &devres);
+}
+EXPORT_SYMBOL_GPL(devm_is_action_added);
+
 /**
  * devm_remove_action_nowarn() - removes previously added custom action
  * @dev: Device that owns the action
diff --git a/include/linux/device/devres.h b/include/linux/device/devres.h
index 9cd1787ef28ed..ae696d10faff4 100644
--- a/include/linux/device/devres.h
+++ b/include/linux/device/devres.h
@@ -165,4 +165,6 @@ static inline int __devm_add_action_or_reset(struct device *dev, void (*action)(
 #define devm_add_action_or_reset(dev, action, data) \
 	__devm_add_action_or_reset(dev, action, data, #action)
 
+bool devm_is_action_added(struct device *dev, void (*action)(void *), void *data);
+
 #endif /* _DEVICE_DEVRES_H_ */
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 128/555] usb: dwc3: xilinx: unwind ZynqMP platform init on probe failure and remove
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (126 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 127/555] devres: Add devm_is_action_added() helper Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 129/555] iio: humidity: hid-sensor-humidity: Use per-instance callbacks Greg Kroah-Hartman
                   ` (426 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, stable, Philipp Zabel,
	Radhey Shyam Pandey, Thinh Nguyen, Sasha Levin

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

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

From: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>

[ Upstream commit 6c6508e742b47539224eb18cb23f7ed5d401dcb6 ]

dwc3_xlnx_init_zynqmp() leaves the controller out of reset with the PHY
powered on, but nothing undoes that if probe fails later or when the
driver is removed. The resets stay deasserted and the PHY stays on with
no driver bound.

Register the teardown with devm_add_action_or_reset() once init has
completed, so it runs on probe failure without the driver having to
track how far init progressed. The teardown only undoes the reset cycle
init performed, so it carries the same usb3-phy guard: with no PHY the
resets were never asserted, and asserting them could break a USB3
configuration that is live but missing from the device tree.

The resets have to be asserted while the clocks are still running, so
both the probe error path and remove() run the teardown explicitly
before gating the clocks rather than leaving it to devres, which would
otherwise run it afterwards. devm_release_action() unlinks the action
before calling it, so devres cannot run it a second time.

Running it from remove() also covers .shutdown, which shares
dwc3_xlnx_remove(): device_shutdown() does not call
devres_release_all(), so a teardown left to devres would never run
there.

Fixes: 84770f028fab ("usb: dwc3: Add driver for Xilinx platforms")
Cc: stable <stable@kernel.org>
Suggested-by: Philipp Zabel <p.zabel@pengutronix.de>
Assisted-by: Claude:claude-opus-5
Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Link: https://patch.msgid.link/20260928120015.3152461-4-radhey.shyam.pandey@amd.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/usb/dwc3/dwc3-xilinx.c | 44 +++++++++++++++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/dwc3-xilinx.c b/drivers/usb/dwc3/dwc3-xilinx.c
index 103a9e6ef35c4..63b3ef205085e 100644
--- a/drivers/usb/dwc3/dwc3-xilinx.c
+++ b/drivers/usb/dwc3/dwc3-xilinx.c
@@ -99,6 +99,39 @@ static int dwc3_xlnx_init_versal(struct dwc3_xlnx *priv_data)
 	return 0;
 }
 
+static void dwc3_xlnx_zynqmp_teardown(void *data)
+{
+	struct dwc3_xlnx *priv_data = data;
+
+	phy_power_off(priv_data->usb3_phy);
+
+	/*
+	 * Undo only the reset cycle init performed.  As on the init error
+	 * path, the unconditional deasserts are not paired with an assert
+	 * here: with no usb3-phy, resetting the core could break a USB3
+	 * configuration that is live but missing from the device tree.
+	 */
+	if (priv_data->usb3_phy) {
+		reset_control_assert(priv_data->usb_hibrst);
+		reset_control_assert(priv_data->usb_crst);
+		reset_control_assert(priv_data->usb_apbrst);
+	}
+
+	phy_exit(priv_data->usb3_phy);
+}
+
+/*
+ * Run the platform teardown explicitly, so the resets are asserted while the
+ * clocks are still running.  devm_release_action() unlinks the action before
+ * calling it, so devres will not run it a second time.
+ */
+static void dwc3_xlnx_release_teardown(struct device *dev,
+				       struct dwc3_xlnx *priv_data)
+{
+	if (devm_is_action_added(dev, dwc3_xlnx_zynqmp_teardown, priv_data))
+		devm_release_action(dev, dwc3_xlnx_zynqmp_teardown, priv_data);
+}
+
 static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
 {
 	struct device		*dev = priv_data->dev;
@@ -225,7 +258,8 @@ static int dwc3_xlnx_init_zynqmp(struct dwc3_xlnx *priv_data)
 		writel(reg, priv_data->regs + XLNX_USB_TRAFFIC_ROUTE_CONFIG);
 	}
 
-	return 0;
+	return devm_add_action_or_reset(dev, dwc3_xlnx_zynqmp_teardown,
+					priv_data);
 
 err_phy_power_off:
 	phy_power_off(priv_data->usb3_phy);
@@ -352,6 +386,7 @@ static int dwc3_xlnx_probe(struct platform_device *pdev)
 	pm_runtime_set_suspended(dev);
 
 err_clk_put:
+	dwc3_xlnx_release_teardown(dev, priv_data);
 	clk_bulk_disable_unprepare(priv_data->num_clocks, priv_data->clks);
 
 	return ret;
@@ -364,6 +399,13 @@ static void dwc3_xlnx_remove(struct platform_device *pdev)
 
 	of_platform_depopulate(dev);
 
+	/*
+	 * This is also what makes .shutdown behave the same as .remove:
+	 * device_shutdown() does not call devres_release_all(), so a teardown
+	 * left to devres would never run on the shutdown path.
+	 */
+	dwc3_xlnx_release_teardown(dev, priv_data);
+
 	clk_bulk_disable_unprepare(priv_data->num_clocks, priv_data->clks);
 	priv_data->num_clocks = 0;
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 129/555] iio: humidity: hid-sensor-humidity: Use per-instance callbacks
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (127 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 128/555] usb: dwc3: xilinx: unwind ZynqMP platform init on probe failure and remove Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 130/555] iio: proximity: hx9023s: Allocate trigger before requesting IRQ Greg Kroah-Hartman
                   ` (425 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Christopher Hoover, Joshua Crofts,
	Srinivas Pandruvada, Jonathan Cameron, Sasha Levin

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

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

From: Christopher Hoover <ch@murgatroid.com>

[ Upstream commit bbe4f3f668babc9443fc1f075695e43e17ca7976 ]

hid-sensor-humidity keeps a single static struct
hid_sensor_hub_callbacks for all instances and overwrites its pdev in
every probe, so with two humidity sensors, input reports for one are
delivered with the other's platform device, and a NULL dereference
follows once that device is removed.  The same bug was found in
hid-sensor-temperature, which shares this code.

Keep the callbacks in struct hid_humidity_state, as the other HID
sensor drivers (accel, gyro, als, ...) do.

Fixes: d7ed89d5aadf ("iio: hid: Add humidity sensor support")
Cc: stable@vger.kernel.org
Signed-off-by: Christopher Hoover <ch@murgatroid.com>
Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
[ sashal: Adapted the padding of the timestamp field from aligned_s64 to u64 __aligned(8), and fixed the continuation-line indentation of the sensor_hub_register_callback() argument. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/iio/humidity/hid-sensor-humidity.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/humidity/hid-sensor-humidity.c b/drivers/iio/humidity/hid-sensor-humidity.c
index bf6d2636a85e7..7c9ae77f33f49 100644
--- a/drivers/iio/humidity/hid-sensor-humidity.c
+++ b/drivers/iio/humidity/hid-sensor-humidity.c
@@ -16,6 +16,7 @@
 struct hid_humidity_state {
 	struct hid_sensor_common common_attributes;
 	struct hid_sensor_hub_attribute_info humidity_attr;
+	struct hid_sensor_hub_callbacks callbacks;
 	struct {
 		s32 humidity_data;
 		u64 timestamp __aligned(8);
@@ -184,11 +185,6 @@ static int humidity_parse_report(struct platform_device *pdev,
 	return ret;
 }
 
-static struct hid_sensor_hub_callbacks humidity_callbacks = {
-	.send_event = &humidity_proc_event,
-	.capture_sample = &humidity_capture_sample,
-};
-
 /* Function to initialize the processing for usage id */
 static int hid_humidity_probe(struct platform_device *pdev)
 {
@@ -240,9 +236,13 @@ static int hid_humidity_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, indio_dev);
 
-	humidity_callbacks.pdev = pdev;
+	humid_st->callbacks = (struct hid_sensor_hub_callbacks) {
+		.send_event = humidity_proc_event,
+		.capture_sample = humidity_capture_sample,
+		.pdev = pdev,
+	};
 	ret = sensor_hub_register_callback(hsdev, HID_USAGE_SENSOR_HUMIDITY,
-					&humidity_callbacks);
+					&humid_st->callbacks);
 	if (ret)
 		goto error_remove_trigger;
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 130/555] iio: proximity: hx9023s: Allocate trigger before requesting IRQ
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (128 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 129/555] iio: humidity: hid-sensor-humidity: Use per-instance callbacks Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 131/555] ipvs: read flags and seqs in master atomically Greg Kroah-Hartman
                   ` (424 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Ijae Kim, Myeonghun Pak,
	Joshua Crofts, Jonathan Cameron, Sasha Levin

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

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

From: Myeonghun Pak <mhun512@gmail.com>

[ Upstream commit bfa3b177d839bb303d0187335115b572a2644920 ]

An IRQ handler that already read trigger_enabled can poll data->trig
after buffer disable. Detaching the virtual IRQ does not join this
physical IRQ, and trigger deselection can drop the consumer reference.
Devres may then free the trigger before joining the handler.

Allocate the trigger before requesting the IRQ so devres joins the
handler before dropping the allocation reference.

This issue was identified as part of our ongoing research while
reviewing kernel code.

Fixes: 60df548277b7 ("iio: proximity: Add driver support for TYHX's HX9023S capacitive proximity sensor")
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
[ sashal: Kept this tree's existing dev_err_probe() error return on IRQ request failure instead of upstream's plain return ret, while moving the IRQ request after trigger allocation. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/iio/proximity/hx9023s.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/proximity/hx9023s.c b/drivers/iio/proximity/hx9023s.c
index e780373af2d6e..b0905cfc06d2d 100644
--- a/drivers/iio/proximity/hx9023s.c
+++ b/drivers/iio/proximity/hx9023s.c
@@ -1053,14 +1053,6 @@ static int hx9023s_probe(struct i2c_client *client)
 		return dev_err_probe(dev, ret, "regcache sync failed\n");
 
 	if (client->irq) {
-		ret = devm_request_threaded_irq(dev, client->irq,
-						hx9023s_irq_handler,
-						hx9023s_irq_thread_handler,
-						IRQF_ONESHOT,
-						"hx9023s_event", indio_dev);
-		if (ret)
-			return dev_err_probe(dev, ret, "irq request failed\n");
-
 		data->trig = devm_iio_trigger_alloc(dev, "%s-dev%d",
 						    indio_dev->name,
 						    iio_device_id(indio_dev));
@@ -1071,6 +1063,14 @@ static int hx9023s_probe(struct i2c_client *client)
 		data->trig->ops = &hx9023s_trigger_ops;
 		iio_trigger_set_drvdata(data->trig, indio_dev);
 
+		ret = devm_request_threaded_irq(dev, client->irq,
+						hx9023s_irq_handler,
+						hx9023s_irq_thread_handler,
+						IRQF_ONESHOT,
+						"hx9023s_event", indio_dev);
+		if (ret)
+			return dev_err_probe(dev, ret, "irq request failed\n");
+
 		ret = devm_iio_trigger_register(dev, data->trig);
 		if (ret)
 			return dev_err_probe(dev, ret,
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 131/555] ipvs: read flags and seqs in master atomically
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (129 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 130/555] iio: proximity: hx9023s: Allocate trigger before requesting IRQ Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 132/555] ipvs: honor the overload state and do not enter it forever Greg Kroah-Hartman
                   ` (423 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Julian Anastasov, Pablo Neira Ayuso,
	Sasha Levin

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

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

From: Julian Anastasov <ja@ssi.bg>

[ Upstream commit aa9afc79f57ba5ef4385aa85cfb7dd50d5c484f6 ]

After we fixed the double read of cp->flags in the master with
commit 3e3fe49e8678 ("ipvs: fix buffer overflow when sending sync messages")
Sashiko reports that we should also read the cp->flags and the seqs
atomically. So if the SEQ_MASK is set, re-read the flags and the
seqs under cp->lock to provide a snapshot when sending the sync
message.

Fixes: 3e3fe49e8678 ("ipvs: fix buffer overflow when sending sync messages")
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260927220816.268206-1-pablo%40netfilter.org
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/netfilter/ipvs/ip_vs_sync.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
index 0036008fee65f..2f18c2b0b3e85 100644
--- a/net/netfilter/ipvs/ip_vs_sync.c
+++ b/net/netfilter/ipvs/ip_vs_sync.c
@@ -540,6 +540,7 @@ static int ip_vs_sync_conn_needed(struct netns_ipvs *ipvs,
 static void ip_vs_sync_conn_v0(struct netns_ipvs *ipvs, struct ip_vs_conn *cp,
 			       int pkts)
 {
+	struct ip_vs_sync_conn_options opts;
 	struct ip_vs_sync_mesg_v0 *m;
 	struct ip_vs_sync_conn_v0 *s;
 	struct ip_vs_sync_buff *buff;
@@ -558,6 +559,14 @@ static void ip_vs_sync_conn_v0(struct netns_ipvs *ipvs, struct ip_vs_conn *cp,
 	if (!ip_vs_sync_conn_needed(ipvs, cp, pkts))
 		return;
 
+	if (flags & IP_VS_CONN_F_SEQ_MASK) {
+		/* Take atomic snapshot of flags and seqs */
+		spin_lock_bh(&cp->lock);
+		flags = cp->flags;
+		memcpy(&opts, &cp->sync_conn_opt, sizeof(opts));
+		spin_unlock_bh(&cp->lock);
+	}
+
 	spin_lock_bh(&ipvs->sync_buff_lock);
 	if (!(ipvs->sync_state & IP_VS_STATE_MASTER)) {
 		spin_unlock_bh(&ipvs->sync_buff_lock);
@@ -605,7 +614,7 @@ static void ip_vs_sync_conn_v0(struct netns_ipvs *ipvs, struct ip_vs_conn *cp,
 	if (seq_mask) {
 		struct ip_vs_sync_conn_options *opt =
 			(struct ip_vs_sync_conn_options *)&s[1];
-		memcpy(opt, &cp->sync_conn_opt, sizeof(*opt));
+		memcpy(opt, &opts, sizeof(*opt));
 	}
 
 	m->nr_conns++;
@@ -631,6 +640,7 @@ static void ip_vs_sync_conn_v0(struct netns_ipvs *ipvs, struct ip_vs_conn *cp,
  */
 void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts)
 {
+	struct ip_vs_sync_conn_options opts;
 	struct ip_vs_sync_mesg *m;
 	union ip_vs_sync_conn *s;
 	struct ip_vs_sync_buff *buff;
@@ -652,6 +662,13 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts)
 	if (!ip_vs_sync_conn_needed(ipvs, cp, pkts))
 		goto control;
 	flags = READ_ONCE(cp->flags);
+	if (flags & IP_VS_CONN_F_SEQ_MASK) {
+		/* Take atomic snapshot of flags and seqs */
+		spin_lock_bh(&cp->lock);
+		flags = cp->flags;
+		memcpy(&opts, &cp->sync_conn_opt, sizeof(opts));
+		spin_unlock_bh(&cp->lock);
+	}
 
 	/* Sanity checks */
 	pe_name_len = 0;
@@ -753,9 +770,9 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts)
 	if (seq_mask) {
 		*(p++) = IPVS_OPT_SEQ_DATA;
 		*(p++) = sizeof(struct ip_vs_sync_conn_options);
-		hton_seq(&cp->in_seq, (struct ip_vs_seq *)p);
+		hton_seq(&opts.in_seq, (struct ip_vs_seq *)p);
 		p += sizeof(struct ip_vs_seq);
-		hton_seq(&cp->out_seq, (struct ip_vs_seq *)p);
+		hton_seq(&opts.out_seq, (struct ip_vs_seq *)p);
 		p += sizeof(struct ip_vs_seq);
 	}
 	/* Handle pe data */
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 132/555] ipvs: honor the overload state and do not enter it forever
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (130 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 131/555] ipvs: read flags and seqs in master atomically Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 133/555] iio: light: apds9306: fix PM reference leak in apds9306_read_data() Greg Kroah-Hartman
                   ` (422 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Julian Anastasov, Pablo Neira Ayuso,
	Sasha Levin

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

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

From: Julian Anastasov <ja@ssi.bg>

[ Upstream commit 567ca80d77baf4c9ab635865375956084c8bb52a ]

Sashiko warns that we may enter the dest overload state forever
if setting the u_threshold to 1 races with the ip_vs_unbind_dest()
call for the last connection for dest. The problem is that we
prefer ip_vs_unbind_dest() to avoid using locks while reading the
threshold.

To avoid the race, add a smp_mb() in __ip_vs_dest_update_overload()
that is paired with the atomic_fetch_dec() in ip_vs_unbind_dest()
which allows to re-read the totalconns and to leave the overload
state if we are below l_threshold_val.

Also, remove the overload parameter from ip_vs_dest_update_overload()
because we just need to know the current state while deciding
which threshold ranges to use. This ip_vs_dest_is_overloaded() check
can be in __ip_vs_dest_update_overload() instead.

To avoid ip_vs_bind_dest() to enter lock just to initialize
u_threshold_val to INT_MAX, do it in ip_vs_new_dest().

The LBLC and LBLCR schedulers do not honor the global overload state
for cached dests, so add a ip_vs_dest_is_overloaded() check for
the situations where we may fallback from overloaded dest (LBLC and
LBLCR) or when we hit a cached dest (LBLC).

Also, move the ip_vs_dest_set_min() call in LBLCR after the
ip_vs_dest_set_erase() call that removes the most-loaded
server because due to races we may work with dest that is
in process of removing, i.e. ip_vs_dest_set_min() and
ip_vs_dest_set_max() may return same dest.

Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261019150249.1879516-2-pablo%40netfilter.org
Fixes: 3ba20137287f ("ipvs: fix more races around the overload flag")
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/net/ip_vs.h              |  2 +-
 net/netfilter/ipvs/ip_vs_conn.c  |  4 ++--
 net/netfilter/ipvs/ip_vs_ctl.c   | 30 ++++++++++++++++++------------
 net/netfilter/ipvs/ip_vs_lblc.c  |  8 +++++---
 net/netfilter/ipvs/ip_vs_lblcr.c | 13 +++++++------
 5 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index d212b3ae0f4ea..7053d16b3632c 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -1583,7 +1583,7 @@ static inline void ip_vs_dest_put_and_free(struct ip_vs_dest *dest)
 		kfree(dest);
 }
 
-void ip_vs_dest_update_overload(struct ip_vs_dest *dest, bool overload);
+void ip_vs_dest_update_overload(struct ip_vs_dest *dest);
 
 /* Check if dest is in overloaded state */
 static inline bool ip_vs_dest_is_overloaded(const struct ip_vs_dest *dest)
diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
index 1ece384aec792..f88c99a1ca5b7 100644
--- a/net/netfilter/ipvs/ip_vs_conn.c
+++ b/net/netfilter/ipvs/ip_vs_conn.c
@@ -634,7 +634,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
 			atomic_inc(&dest->activeconns);
 		tc = atomic_inc_return(&dest->totalconns);
 		if (tc >= READ_ONCE(dest->u_threshold_val))
-			ip_vs_dest_update_overload(dest, true);
+			ip_vs_dest_update_overload(dest);
 	} else {
 		/* It is a persistent connection/template, so increase
 		   the persistent connection counter */
@@ -727,7 +727,7 @@ static inline void ip_vs_unbind_dest(struct ip_vs_conn *cp)
 			atomic_dec(&dest->activeconns);
 		tc = atomic_fetch_dec(&dest->totalconns);
 		if (tc <= READ_ONCE(dest->l_threshold_val))
-			ip_vs_dest_update_overload(dest, false);
+			ip_vs_dest_update_overload(dest);
 	} else {
 		/* It is a persistent connection/template, so decrease
 		   the persistent connection counter */
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index b46b1c850b23e..a74778706aaaa 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -960,12 +960,12 @@ void ip_vs_stats_free(struct ip_vs_stats *stats)
 	}
 }
 
-/* Update overload flag based on number of dest conns and lower/upper
+/* Update overload state based on number of dest conns and lower/upper
  * connection thresholds:
- * - conns reach u_threshold and exceed it: set the flag
- * - conns go below l_threshold (or 75% of u_threshold): clear the flag
+ * - conns reach u_threshold and exceed it: set the overload state
+ * - conns go below l_threshold (or 75% of u_threshold): clear the state
  */
-static void __ip_vs_dest_update_overload(struct ip_vs_dest *dest, bool overload)
+static void __ip_vs_dest_update_overload(struct ip_vs_dest *dest)
 {
 	int conns;
 	u32 l, u;
@@ -976,10 +976,18 @@ static void __ip_vs_dest_update_overload(struct ip_vs_dest *dest, bool overload)
 		/* Low threshold defaults to 75% of upper threshold */
 		l = READ_ONCE(dest->l_threshold) ? : (u - (u >> 2));
 		conns = atomic_read(&dest->totalconns);
-		if (conns >= (overload ? l : u)) {
+		if (conns >= (ip_vs_dest_is_overloaded(dest) ? l : u)) {
 			WRITE_ONCE(dest->u_threshold_val, INT_MAX);
 			WRITE_ONCE(dest->l_threshold_val, l);
-			return;
+			/* Commit thresholds before repeating the check,
+			 * it is paired with atomic_fetch_dec() in
+			 * ip_vs_unbind_dest() to avoid entering the
+			 * overload state forever.
+			 */
+			smp_mb();
+			conns = atomic_read(&dest->totalconns);
+			if (conns >= l)
+				return;
 		}
 	}
 
@@ -987,10 +995,10 @@ static void __ip_vs_dest_update_overload(struct ip_vs_dest *dest, bool overload)
 	WRITE_ONCE(dest->l_threshold_val, 0);
 }
 
-void ip_vs_dest_update_overload(struct ip_vs_dest *dest, bool overload)
+void ip_vs_dest_update_overload(struct ip_vs_dest *dest)
 {
 	spin_lock_bh(&dest->dst_lock);
-	__ip_vs_dest_update_overload(dest, overload);
+	__ip_vs_dest_update_overload(dest);
 	spin_unlock_bh(&dest->dst_lock);
 }
 
@@ -1062,13 +1070,10 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
 
 	if (READ_ONCE(dest->u_threshold) != udest->u_threshold ||
 	    READ_ONCE(dest->l_threshold) != udest->l_threshold) {
-		bool overload;
-
 		spin_lock_bh(&dest->dst_lock);
 		WRITE_ONCE(dest->u_threshold, udest->u_threshold);
 		WRITE_ONCE(dest->l_threshold, udest->l_threshold);
-		overload = ip_vs_dest_is_overloaded(dest);
-		__ip_vs_dest_update_overload(dest, overload);
+		__ip_vs_dest_update_overload(dest);
 		spin_unlock_bh(&dest->dst_lock);
 	}
 
@@ -1133,6 +1138,7 @@ ip_vs_new_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest)
 	if (ret < 0)
 		goto err_stats;
 
+	dest->u_threshold_val = INT_MAX;
 	dest->af = udest->af;
 	dest->protocol = svc->protocol;
 	dest->vaddr = svc->addr;
diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
index 5ee1f2f00cce8..1726ffdc1d5f0 100644
--- a/net/netfilter/ipvs/ip_vs_lblc.c
+++ b/net/netfilter/ipvs/ip_vs_lblc.c
@@ -467,10 +467,11 @@ is_overloaded(struct ip_vs_dest *dest, struct ip_vs_service *svc)
 		struct ip_vs_dest *d;
 
 		list_for_each_entry_rcu(d, &svc->destinations, n_list) {
-			if (atomic_read(&d->activeconns)*2
-			    < atomic_read(&d->weight)) {
+			if (ip_vs_dest_is_overloaded(d))
+				continue;
+			if (atomic_read(&d->activeconns) * 2 <
+			    atomic_read(&d->weight))
 				return 1;
-			}
 		}
 	}
 	return 0;
@@ -507,6 +508,7 @@ ip_vs_lblc_schedule(struct ip_vs_service *svc, const struct sk_buff *skb,
 
 		dest = en->dest;
 		if ((dest->cflags & IP_VS_DEST_CF_AVAILABLE) &&
+		    !ip_vs_dest_is_overloaded(dest) &&
 		    atomic_read(&dest->weight) > 0 && !is_overloaded(dest, svc))
 			goto out;
 	}
diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
index 81539aab73121..23fbbcabf4e95 100644
--- a/net/netfilter/ipvs/ip_vs_lblcr.c
+++ b/net/netfilter/ipvs/ip_vs_lblcr.c
@@ -630,10 +630,11 @@ is_overloaded(struct ip_vs_dest *dest, struct ip_vs_service *svc)
 		struct ip_vs_dest *d;
 
 		list_for_each_entry_rcu(d, &svc->destinations, n_list) {
-			if (atomic_read(&d->activeconns)*2
-			    < atomic_read(&d->weight)) {
+			if (ip_vs_dest_is_overloaded(d))
+				continue;
+			if (atomic_read(&d->activeconns) * 2 <
+			    atomic_read(&d->weight))
 				return 1;
-			}
 		}
 	}
 	return 0;
@@ -658,9 +659,6 @@ ip_vs_lblcr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb,
 	if (en) {
 		en->lastuse = jiffies;
 
-		/* Get the least loaded destination */
-		dest = ip_vs_dest_set_min(&en->set);
-
 		/* More than one destination + enough time passed by, cleanup */
 		if (atomic_read(&en->set.size) > 1 &&
 		    time_after(jiffies, en->set.lastmod +
@@ -676,6 +674,9 @@ ip_vs_lblcr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb,
 			spin_unlock_bh(&svc->sched_lock);
 		}
 
+		/* Get the least loaded destination */
+		dest = ip_vs_dest_set_min(&en->set);
+
 		/* If the destination is not overloaded, use it */
 		if (dest && !is_overloaded(dest, svc))
 			goto out;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 133/555] iio: light: apds9306: fix PM reference leak in apds9306_read_data()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (131 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 132/555] ipvs: honor the overload state and do not enter it forever Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 134/555] drm/ast: Handle framebuffer from dma-buf Greg Kroah-Hartman
                   ` (421 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Moksh Panicker, Jonathan Cameron,
	Dickson Wu, Sasha Levin

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

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

From: Moksh Panicker <mokshpanicker.7@gmail.com>

commit d378fceaafd79e0dc59d3546bda251a3058062c0 upstream.

apds9306_read_data() calls pm_runtime_resume_and_get() but several
error paths return directly without calling pm_runtime_put_autosuspend(),
leaking the runtime PM reference and preventing the device from
autosuspending.

Use PM_RUNTIME_ACQUIRE_AUTOSUSPEND() and PM_RUNTIME_ACQUIRE_ERR() to
automatically handle runtime PM reference release on all return paths.

Fixes: 620d1e6c7a3f ("iio: light: Add support for APDS9306 Light Sensor")
Signed-off-by: Moksh Panicker <mokshpanicker.7@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
[ adapted to 6.12.y: no PM_RUNTIME_ACQUIRE helpers, goto the put ]
Signed-off-by: Dickson Wu <dickson.wu@certik.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/iio/light/apds9306.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/light/apds9306.c b/drivers/iio/light/apds9306.c
index db648e2cb5200..5e483cf4dc153 100644
--- a/drivers/iio/light/apds9306.c
+++ b/drivers/iio/light/apds9306.c
@@ -477,19 +477,21 @@ static int apds9306_read_data(struct apds9306_data *data, int *val, int reg)
 
 	ret = regmap_field_read(rf->intg_time, &intg_time_idx);
 	if (ret)
-		return ret;
+		goto out_pm;
 
 	ret = regmap_field_read(rf->repeat_rate, &repeat_rate_idx);
 	if (ret)
-		return ret;
+		goto out_pm;
 
 	ret = regmap_field_read(rf->int_src, &int_src);
 	if (ret)
-		return ret;
+		goto out_pm;
 
 	intg_time = iio_gts_find_int_time_by_sel(&data->gts, intg_time_idx);
-	if (intg_time < 0)
-		return intg_time;
+	if (intg_time < 0) {
+		ret = intg_time;
+		goto out_pm;
+	}
 
 	/* Whichever is greater - integration time period or sampling period. */
 	delay = max(intg_time, apds9306_repeat_rate_period[repeat_rate_idx]);
@@ -512,7 +514,7 @@ static int apds9306_read_data(struct apds9306_data *data, int *val, int reg)
 						  APDS9306_ALS_INT_STAT_MASK)),
 				       APDS9306_ALS_READ_DATA_DELAY_US, delay * 2);
 	if (ret)
-		return ret;
+		goto out_pm;
 
 	/* If we reach here before the interrupt handler we push an event */
 	if ((status & APDS9306_ALS_INT_STAT_MASK)) {
@@ -532,15 +534,16 @@ static int apds9306_read_data(struct apds9306_data *data, int *val, int reg)
 	ret = regmap_bulk_read(data->regmap, reg, buff, sizeof(buff));
 	if (ret) {
 		dev_err_ratelimited(dev, "read data failed\n");
-		return ret;
+		goto out_pm;
 	}
 
 	*val = get_unaligned_le24(&buff);
 
+out_pm:
 	pm_runtime_mark_last_busy(data->dev);
 	pm_runtime_put_autosuspend(data->dev);
 
-	return 0;
+	return ret;
 }
 
 static int apds9306_intg_time_get(struct apds9306_data *data, int *val2)
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 134/555] drm/ast: Handle framebuffer from dma-buf
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (132 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 133/555] iio: light: apds9306: fix PM reference leak in apds9306_read_data() Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 135/555] iio: invensense: Prevent possible integer overflow while multiplication Greg Kroah-Hartman
                   ` (420 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Thomas Zimmermann, Jocelyn Falempe,
	Sasha Levin

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

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

From: Jocelyn Falempe <jfalempe@redhat.com>

[ Upstream commit 3dd0be7a301bb0adcca4f7021cfd2e366ca90a0e ]

In the atomic update callback, ast should call
drm_gem_fb_begin_cpu_access() to make sure it can read the
framebuffer from the CPU, otherwise the data might not be there due
to cache, and synchronization.

Tested on a Lenovo SE100, while rendering on the ArrowLake GPU with
i915 driver, and using ast for display.

Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patch.msgid.link/20251030091627.340780-1-jfalempe@redhat.com
Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpu/drm/ast/ast_mode.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index 162dc0698f4ac..f3fca438bf5c5 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -662,9 +662,14 @@ static void ast_primary_plane_helper_atomic_update(struct drm_plane *plane,
 		ast_set_vbios_color_reg(ast, fb->format, vbios_mode_info);
 	}
 
-	drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state);
-	drm_atomic_for_each_plane_damage(&iter, &damage) {
-		ast_handle_damage(ast_plane, shadow_plane_state->data, fb, &damage);
+	/* if the buffer comes from another device */
+	if (drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE) == 0) {
+		drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state);
+		drm_atomic_for_each_plane_damage(&iter, &damage) {
+			ast_handle_damage(ast_plane, shadow_plane_state->data, fb, &damage);
+		}
+
+		drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE);
 	}
 
 	/*
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 135/555] iio: invensense: Prevent possible integer overflow while multiplication
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (133 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 134/555] drm/ast: Handle framebuffer from dma-buf Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:02 ` [PATCH 6.12 136/555] iio: common: fix spelling mistakes in comments Greg Kroah-Hartman
                   ` (419 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Karan Sanghavi, Jonathan Cameron,
	Sasha Levin

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

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

From: Karan Sanghavi <karansanghvi98@gmail.com>

[ Upstream commit 6dfc256151e842fa894a2b579f9a4551c6961e2c ]

Typecast a variable to int64_t for 64-bit arithmetic multiplication.

Signed-off-by: Karan Sanghavi <karansanghvi98@gmail.com>
Link: https://scan7.scan.coverity.com/#/project-view/51946/11354?selectedIssue=1586045
Link: https://patch.msgid.link/20241103-coverity1586045integeroverflow-v1-1-43ea37a3f3cd@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Stable-dep-of: 3785dffc7c68 ("iio: inv_sensors: prevent timestamps going back in time in transitions")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/iio/common/inv_sensors/inv_sensors_timestamp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
index 37d0bdaa8d824..327f456b53c5c 100644
--- a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
+++ b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
@@ -109,8 +109,8 @@ static bool inv_update_chip_period(struct inv_sensors_timestamp *ts,
 
 static void inv_align_timestamp_it(struct inv_sensors_timestamp *ts)
 {
-	const int64_t period_min = ts->min_period * ts->mult;
-	const int64_t period_max = ts->max_period * ts->mult;
+	const int64_t period_min = (int64_t)ts->min_period * ts->mult;
+	const int64_t period_max = (int64_t)ts->max_period * ts->mult;
 	int64_t add_max, sub_max;
 	int64_t delta, jitter;
 	int64_t adjust;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 136/555] iio: common: fix spelling mistakes in comments
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (134 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 135/555] iio: invensense: Prevent possible integer overflow while multiplication Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 137/555] iio: inv_sensors: convert to kernel types Greg Kroah-Hartman
                   ` (418 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Shi Hao, Jonathan Cameron,
	Sasha Levin

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

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

From: Shi Hao <i.shihao.999@gmail.com>

[ Upstream commit 96f46405219d9bf62d9fab76e055e3b6059b0bd5 ]

Fix spelling mistakes in comments.

- exepects -> expects
- fuction -> function
- theoritical -> theoretical
- appopriate -> appropriate
- iio -> IIO

Signed-off-by: Shi Hao <i.shihao.999@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Stable-dep-of: 3785dffc7c68 ("iio: inv_sensors: prevent timestamps going back in time in transitions")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c   | 2 +-
 drivers/iio/common/hid-sensors/hid-sensor-attributes.c | 2 +-
 drivers/iio/common/inv_sensors/inv_sensors_timestamp.c | 4 ++--
 drivers/iio/common/ms_sensors/ms_sensors_i2c.c         | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
index 66153b1850f10..58c935e182639 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
@@ -106,7 +106,7 @@ static int cros_ec_sensors_read(struct iio_dev *indio_dev,
 		switch (st->core.type) {
 		case MOTIONSENSE_TYPE_ACCEL:
 			/*
-			 * EC returns data in g, iio exepects m/s^2.
+			 * EC returns data in g, IIO expects m/s^2.
 			 * Do not use IIO_G_TO_M_S_2 to avoid precision loss.
 			 */
 			*val = div_s64(val64 * 980665, 10);
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
index 650016e4a40fc..065efd1ecf476 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
@@ -352,7 +352,7 @@ int hid_sensor_write_raw_hyst_rel_value(struct hid_sensor_common *st,
 EXPORT_SYMBOL_NS(hid_sensor_write_raw_hyst_rel_value, IIO_HID);
 
 /*
- * This fuction applies the unit exponent to the scale.
+ * This function applies the unit exponent to the scale.
  * For example:
  * 9.806650000 ->exp:2-> val0[980]val1[665000000]
  * 9.000806000 ->exp:2-> val0[900]val1[80600000]
diff --git a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
index 327f456b53c5c..883cb08806be8 100644
--- a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
+++ b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
@@ -154,7 +154,7 @@ void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,
 		valid = inv_update_chip_period(ts, period);
 	}
 
-	/* no previous data, compute theoritical value from interrupt */
+	/* no previous data, compute theoretical value from interrupt */
 	if (ts->timestamp == 0) {
 		/* elapsed time: sensor period * sensor samples number */
 		interval = (int64_t)ts->period * (int64_t)sample_nb;
@@ -185,7 +185,7 @@ void inv_sensors_timestamp_apply_odr(struct inv_sensors_timestamp *ts,
 
 	/*
 	 * After ODR change the time interval with the previous sample is
-	 * undertermined (depends when the change occures). So we compute the
+	 * undertermined (depends when the change occurs). So we compute the
 	 * timestamp from the current interrupt using the new FIFO period, the
 	 * total number of samples and the current sample numero.
 	 */
diff --git a/drivers/iio/common/ms_sensors/ms_sensors_i2c.c b/drivers/iio/common/ms_sensors/ms_sensors_i2c.c
index 9c9bc77003c7f..b67453bd31f81 100644
--- a/drivers/iio/common/ms_sensors/ms_sensors_i2c.c
+++ b/drivers/iio/common/ms_sensors/ms_sensors_i2c.c
@@ -96,7 +96,7 @@ EXPORT_SYMBOL_NS(ms_sensors_read_prom_word, IIO_MEAS_SPEC_SENSORS);
  *
  * Generic ADC conversion & read function for Measurement Specialties
  * devices.
- * The function will issue conversion command, sleep appopriate delay, and
+ * The function will issue conversion command, sleep appropriate delay, and
  * issue command to read ADC.
  *
  * Return: 0 on success, negative errno otherwise.
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 137/555] iio: inv_sensors: convert to kernel types
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (135 preceding siblings ...)
  2026-12-04 10:02 ` [PATCH 6.12 136/555] iio: common: fix spelling mistakes in comments Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 138/555] iio: inv_sensors: better timestamp alignment when using watermark Greg Kroah-Hartman
                   ` (417 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Andy Shevchenko,
	Jean-Baptiste Maneyrol, Jonathan Cameron, Sasha Levin

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

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

From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>

[ Upstream commit 1330597c7480611334977ff66878fd40b411fa41 ]

Convert standard types (u)intXX_t to kernel type u/sXX.

Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Stable-dep-of: 3785dffc7c68 ("iio: inv_sensors: prevent timestamps going back in time in transitions")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 .../inv_sensors/inv_sensors_timestamp.c       | 48 +++++++++----------
 .../linux/iio/common/inv_sensors_timestamp.h  | 34 ++++++-------
 2 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
index 883cb08806be8..2fdb4cea8a54f 100644
--- a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
+++ b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
@@ -19,9 +19,9 @@
 	(((_val) * (1000 + (_jitter))) / 1000)
 
 /* Add a new value inside an accumulator and update the estimate value */
-static void inv_update_acc(struct inv_sensors_timestamp_acc *acc, uint32_t val)
+static void inv_update_acc(struct inv_sensors_timestamp_acc *acc, u32 val)
 {
-	uint64_t sum = 0;
+	u64 sum = 0;
 	size_t i;
 
 	acc->values[acc->idx++] = val;
@@ -58,9 +58,9 @@ void inv_sensors_timestamp_init(struct inv_sensors_timestamp *ts,
 EXPORT_SYMBOL_NS_GPL(inv_sensors_timestamp_init, IIO_INV_SENSORS_TIMESTAMP);
 
 int inv_sensors_timestamp_update_odr(struct inv_sensors_timestamp *ts,
-				     uint32_t period, bool fifo)
+				     u32 period, bool fifo)
 {
-	uint32_t mult;
+	u32 mult;
 
 	/* when FIFO is on, prevent odr change if one is already pending */
 	if (fifo && ts->new_mult != 0)
@@ -78,9 +78,9 @@ int inv_sensors_timestamp_update_odr(struct inv_sensors_timestamp *ts,
 }
 EXPORT_SYMBOL_NS_GPL(inv_sensors_timestamp_update_odr, IIO_INV_SENSORS_TIMESTAMP);
 
-static bool inv_validate_period(struct inv_sensors_timestamp *ts, uint32_t period)
+static bool inv_validate_period(struct inv_sensors_timestamp *ts, u32 period)
 {
-	uint32_t period_min, period_max;
+	u32 period_min, period_max;
 
 	/* check that period is acceptable */
 	period_min = ts->min_period * ts->mult;
@@ -92,9 +92,9 @@ static bool inv_validate_period(struct inv_sensors_timestamp *ts, uint32_t perio
 }
 
 static bool inv_update_chip_period(struct inv_sensors_timestamp *ts,
-				   uint32_t period)
+				   u32 period)
 {
-	uint32_t new_chip_period;
+	u32 new_chip_period;
 
 	if (!inv_validate_period(ts, period))
 		return false;
@@ -109,19 +109,19 @@ static bool inv_update_chip_period(struct inv_sensors_timestamp *ts,
 
 static void inv_align_timestamp_it(struct inv_sensors_timestamp *ts)
 {
-	const int64_t period_min = (int64_t)ts->min_period * ts->mult;
-	const int64_t period_max = (int64_t)ts->max_period * ts->mult;
-	int64_t add_max, sub_max;
-	int64_t delta, jitter;
-	int64_t adjust;
+	const s64 period_min = (s64)ts->min_period * ts->mult;
+	const s64 period_max = (s64)ts->max_period * ts->mult;
+	s64 add_max, sub_max;
+	s64 delta, jitter;
+	s64 adjust;
 
 	/* delta time between last sample and last interrupt */
 	delta = ts->it.lo - ts->timestamp;
 
 	/* adjust timestamp while respecting jitter */
-	add_max = period_max - (int64_t)ts->period;
-	sub_max = period_min - (int64_t)ts->period;
-	jitter = INV_SENSORS_TIMESTAMP_JITTER((int64_t)ts->period, ts->chip.jitter);
+	add_max = period_max - (s64)ts->period;
+	sub_max = period_min - (s64)ts->period;
+	jitter = INV_SENSORS_TIMESTAMP_JITTER((s64)ts->period, ts->chip.jitter);
 	if (delta > jitter)
 		adjust = add_max;
 	else if (delta < -jitter)
@@ -133,11 +133,11 @@ static void inv_align_timestamp_it(struct inv_sensors_timestamp *ts)
 }
 
 void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,
-				     size_t sample_nb, int64_t timestamp)
+				     size_t sample_nb, s64 timestamp)
 {
 	struct inv_sensors_timestamp_interval *it;
-	int64_t delta, interval;
-	uint32_t period;
+	s64 delta, interval;
+	u32 period;
 	bool valid = false;
 
 	if (sample_nb == 0)
@@ -157,7 +157,7 @@ void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,
 	/* no previous data, compute theoretical value from interrupt */
 	if (ts->timestamp == 0) {
 		/* elapsed time: sensor period * sensor samples number */
-		interval = (int64_t)ts->period * (int64_t)sample_nb;
+		interval = (s64)ts->period * (s64)sample_nb;
 		ts->timestamp = it->up - interval;
 		return;
 	}
@@ -169,11 +169,11 @@ void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,
 EXPORT_SYMBOL_NS_GPL(inv_sensors_timestamp_interrupt, IIO_INV_SENSORS_TIMESTAMP);
 
 void inv_sensors_timestamp_apply_odr(struct inv_sensors_timestamp *ts,
-				     uint32_t fifo_period, size_t fifo_nb,
+				     u32 fifo_period, size_t fifo_nb,
 				     unsigned int fifo_no)
 {
-	int64_t interval;
-	uint32_t fifo_mult;
+	s64 interval;
+	u32 fifo_mult;
 
 	if (ts->new_mult == 0)
 		return;
@@ -194,7 +194,7 @@ void inv_sensors_timestamp_apply_odr(struct inv_sensors_timestamp *ts,
 		fifo_mult = fifo_period / ts->chip.clock_period;
 		fifo_period = fifo_mult * ts->chip_period.val;
 		/* computes time interval between interrupt and this sample */
-		interval = (int64_t)(fifo_nb - fifo_no) * (int64_t)fifo_period;
+		interval = (s64)(fifo_nb - fifo_no) * (s64)fifo_period;
 		ts->timestamp = ts->it.up - interval;
 	}
 }
diff --git a/include/linux/iio/common/inv_sensors_timestamp.h b/include/linux/iio/common/inv_sensors_timestamp.h
index 8d506f1e9df29..e4e720e6f4b72 100644
--- a/include/linux/iio/common/inv_sensors_timestamp.h
+++ b/include/linux/iio/common/inv_sensors_timestamp.h
@@ -13,9 +13,9 @@
  * @init_period:	chip initial period at reset in ns
  */
 struct inv_sensors_timestamp_chip {
-	uint32_t clock_period;
-	uint32_t jitter;
-	uint32_t init_period;
+	u32 clock_period;
+	u32 jitter;
+	u32 init_period;
 };
 
 /**
@@ -24,8 +24,8 @@ struct inv_sensors_timestamp_chip {
  * @up:	interval upper bound
  */
 struct inv_sensors_timestamp_interval {
-	int64_t lo;
-	int64_t up;
+	s64 lo;
+	s64 up;
 };
 
 /**
@@ -35,9 +35,9 @@ struct inv_sensors_timestamp_interval {
  * @values:	table of all measured values, use for computing the mean
  */
 struct inv_sensors_timestamp_acc {
-	uint32_t val;
+	u32 val;
 	size_t idx;
-	uint32_t values[32];
+	u32 values[32];
 };
 
 /**
@@ -54,13 +54,13 @@ struct inv_sensors_timestamp_acc {
  */
 struct inv_sensors_timestamp {
 	struct inv_sensors_timestamp_chip chip;
-	uint32_t min_period;
-	uint32_t max_period;
+	u32 min_period;
+	u32 max_period;
 	struct inv_sensors_timestamp_interval it;
-	int64_t timestamp;
-	uint32_t mult;
-	uint32_t new_mult;
-	uint32_t period;
+	s64 timestamp;
+	u32 mult;
+	u32 new_mult;
+	u32 period;
 	struct inv_sensors_timestamp_acc chip_period;
 };
 
@@ -68,19 +68,19 @@ void inv_sensors_timestamp_init(struct inv_sensors_timestamp *ts,
 				const struct inv_sensors_timestamp_chip *chip);
 
 int inv_sensors_timestamp_update_odr(struct inv_sensors_timestamp *ts,
-				     uint32_t period, bool fifo);
+				     u32 period, bool fifo);
 
 void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,
-				     size_t sample_nb, int64_t timestamp);
+				     size_t sample_nb, s64 timestamp);
 
-static inline int64_t inv_sensors_timestamp_pop(struct inv_sensors_timestamp *ts)
+static inline s64 inv_sensors_timestamp_pop(struct inv_sensors_timestamp *ts)
 {
 	ts->timestamp += ts->period;
 	return ts->timestamp;
 }
 
 void inv_sensors_timestamp_apply_odr(struct inv_sensors_timestamp *ts,
-				     uint32_t fifo_period, size_t fifo_nb,
+				     u32 fifo_period, size_t fifo_nb,
 				     unsigned int fifo_no);
 
 static inline void inv_sensors_timestamp_reset(struct inv_sensors_timestamp *ts)
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 138/555] iio: inv_sensors: better timestamp alignment when using watermark
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (136 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 137/555] iio: inv_sensors: convert to kernel types Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 139/555] iio: inv_sensors: improve period measurement by using a longer delay Greg Kroah-Hartman
                   ` (416 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jean-Baptiste Maneyrol,
	Jonathan Cameron, Sasha Levin

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

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

From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>

[ Upstream commit 8f4b627656fa1767d8337a95849fe7c895b6f68a ]

Current interrupt timestamp alignment only changes the final timestamp.
When the watermark is in use, we have a batch of samples for each
interrupt. The current code doesn't manage to align the timestamp
because the jitter is too high.

Instead modify the estimated inter interrupt period and use that to
adjust the timestamp alignment over the batch in a linear fashion.

Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Stable-dep-of: 3785dffc7c68 ("iio: inv_sensors: prevent timestamps going back in time in transitions")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 .../inv_sensors/inv_sensors_timestamp.c       | 51 +++++++------------
 1 file changed, 19 insertions(+), 32 deletions(-)

diff --git a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
index 2fdb4cea8a54f..88ad439ac14c6 100644
--- a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
+++ b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
@@ -10,9 +10,7 @@
 
 #include <linux/iio/common/inv_sensors_timestamp.h>
 
-/* compute jitter, min and max following jitter in per mille */
-#define INV_SENSORS_TIMESTAMP_JITTER(_val, _jitter)		\
-	(div_s64((_val) * (_jitter), 1000))
+/* compute min and max following jitter in per mille */
 #define INV_SENSORS_TIMESTAMP_MIN(_val, _jitter)		\
 	(((_val) * (1000 - (_jitter))) / 1000)
 #define INV_SENSORS_TIMESTAMP_MAX(_val, _jitter)		\
@@ -102,34 +100,22 @@ static bool inv_update_chip_period(struct inv_sensors_timestamp *ts,
 	/* update chip internal period estimation */
 	new_chip_period = period / ts->mult;
 	inv_update_acc(&ts->chip_period, new_chip_period);
-	ts->period = ts->mult * ts->chip_period.val;
 
 	return true;
 }
 
-static void inv_align_timestamp_it(struct inv_sensors_timestamp *ts)
+static u32 inv_align_timestamp_it(struct inv_sensors_timestamp *ts,
+				  unsigned int sample_nb)
 {
 	const s64 period_min = (s64)ts->min_period * ts->mult;
 	const s64 period_max = (s64)ts->max_period * ts->mult;
-	s64 add_max, sub_max;
-	s64 delta, jitter;
-	s64 adjust;
-
-	/* delta time between last sample and last interrupt */
-	delta = ts->it.lo - ts->timestamp;
-
-	/* adjust timestamp while respecting jitter */
-	add_max = period_max - (s64)ts->period;
-	sub_max = period_min - (s64)ts->period;
-	jitter = INV_SENSORS_TIMESTAMP_JITTER((s64)ts->period, ts->chip.jitter);
-	if (delta > jitter)
-		adjust = add_max;
-	else if (delta < -jitter)
-		adjust = sub_max;
-	else
-		adjust = 0;
+	s64 new_period;
+
+	/* compute new period aligning last timestamp with interrupt timestamp */
+	new_period = div_s64(ts->it.up - ts->timestamp, sample_nb);
 
-	ts->timestamp += adjust;
+	/* ensure that period never overflows the jitter */
+	return clamp(new_period, period_min, period_max);
 }
 
 void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,
@@ -143,6 +129,13 @@ void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,
 	if (sample_nb == 0)
 		return;
 
+	/* no previous data, compute theoretical value from interrupt */
+	if (ts->timestamp == 0) {
+		/* elapsed time: sensor period * sensor samples number */
+		interval = (s64)ts->period * (s64)sample_nb;
+		ts->timestamp = timestamp - interval;
+	}
+
 	/* update interrupt timestamp and compute chip and sensor periods */
 	it = &ts->it;
 	it->lo = it->up;
@@ -154,17 +147,11 @@ void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,
 		valid = inv_update_chip_period(ts, period);
 	}
 
-	/* no previous data, compute theoretical value from interrupt */
-	if (ts->timestamp == 0) {
-		/* elapsed time: sensor period * sensor samples number */
-		interval = (s64)ts->period * (s64)sample_nb;
-		ts->timestamp = it->up - interval;
-		return;
-	}
-
 	/* if interrupt interval is valid, sync with interrupt timestamp */
 	if (valid)
-		inv_align_timestamp_it(ts);
+		ts->period = inv_align_timestamp_it(ts, sample_nb);
+	else
+		ts->period = ts->mult * ts->chip_period.val;
 }
 EXPORT_SYMBOL_NS_GPL(inv_sensors_timestamp_interrupt, IIO_INV_SENSORS_TIMESTAMP);
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 139/555] iio: inv_sensors: improve period measurement by using a longer delay
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (137 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 138/555] iio: inv_sensors: better timestamp alignment when using watermark Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 140/555] iio: inv_sensors: prevent timestamps going back in time in transitions Greg Kroah-Hartman
                   ` (415 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jean-Baptiste Maneyrol,
	Jonathan Cameron, Sasha Levin

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

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

From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>

[ Upstream commit 82bd09ce4fd3b15680735eaeafe2e688901e3b00 ]

Period measurement can be difficult when using high sampling
frequency where the jitter criteria is hard to meet because of the
system jitter.

This new version is using the delta time between 2 distant interrupts
to measure an interval of at least 20ms. 20ms is a good compromise
between the mitigation of system jitter and the delay to update
period. This way we decorrelate the period measurement from the
interrupt timestamps syncing using only the 2 last interrupts.

Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Stable-dep-of: 3785dffc7c68 ("iio: inv_sensors: prevent timestamps going back in time in transitions")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 .../inv_sensors/inv_sensors_timestamp.c       | 26 ++++++++++++++++---
 .../linux/iio/common/inv_sensors_timestamp.h  |  6 +++++
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
index 88ad439ac14c6..aacc56d1a2c77 100644
--- a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
+++ b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
@@ -16,6 +16,9 @@
 #define INV_SENSORS_TIMESTAMP_MAX(_val, _jitter)		\
 	(((_val) * (1000 + (_jitter))) / 1000)
 
+/* minimum timestamp delta between 2 interrupts for measuring period (20ms) */
+#define INV_SENSORS_MIN_IT_DELTA	(20 * NSEC_PER_MSEC)
+
 /* Add a new value inside an accumulator and update the estimate value */
 static void inv_update_acc(struct inv_sensors_timestamp_acc *acc, u32 val)
 {
@@ -122,7 +125,7 @@ void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,
 				     size_t sample_nb, s64 timestamp)
 {
 	struct inv_sensors_timestamp_interval *it;
-	s64 delta, interval;
+	s64 delta, delta_threshold, interval;
 	u32 period;
 	bool valid = false;
 
@@ -136,15 +139,32 @@ void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,
 		ts->timestamp = timestamp - interval;
 	}
 
+	/* update delta timestamps and estimated period */
+	it = &ts->delta;
+	ts->delta_counter += sample_nb;
+	delta = timestamp - it->up;
+	delta_threshold = INV_SENSORS_TIMESTAMP_MIN(INV_SENSORS_MIN_IT_DELTA, ts->chip.jitter);
+	if (delta >= delta_threshold) {
+		it->lo = it->up;
+		it->up = timestamp;
+		if (it->lo != 0) {
+			/* compute period: delta time divided by number of samples */
+			delta = it->up - it->lo;
+			period = div_s64(delta, ts->delta_counter);
+			inv_update_chip_period(ts, period);
+		}
+		ts->delta_counter = 0;
+	}
+
 	/* update interrupt timestamp and compute chip and sensor periods */
 	it = &ts->it;
 	it->lo = it->up;
 	it->up = timestamp;
 	delta = it->up - it->lo;
 	if (it->lo != 0) {
-		/* compute period: delta time divided by number of samples */
+		/* compute period and check validity */
 		period = div_s64(delta, sample_nb);
-		valid = inv_update_chip_period(ts, period);
+		valid = inv_validate_period(ts, period);
 	}
 
 	/* if interrupt interval is valid, sync with interrupt timestamp */
diff --git a/include/linux/iio/common/inv_sensors_timestamp.h b/include/linux/iio/common/inv_sensors_timestamp.h
index e4e720e6f4b72..4f08204ede3b4 100644
--- a/include/linux/iio/common/inv_sensors_timestamp.h
+++ b/include/linux/iio/common/inv_sensors_timestamp.h
@@ -46,6 +46,8 @@ struct inv_sensors_timestamp_acc {
  * @min_period:		minimal acceptable clock period
  * @max_period:		maximal acceptable clock period
  * @it:			interrupts interval timestamps
+ * @delta:		interval timestamps between several interrupts
+ * @delta_counter:	number of data samples in the delta interval
  * @timestamp:		store last timestamp for computing next data timestamp
  * @mult:		current internal period multiplier
  * @new_mult:		new set internal period multiplier (not yet effective)
@@ -57,6 +59,8 @@ struct inv_sensors_timestamp {
 	u32 min_period;
 	u32 max_period;
 	struct inv_sensors_timestamp_interval it;
+	struct inv_sensors_timestamp_interval delta;
+	u32 delta_counter;
 	s64 timestamp;
 	u32 mult;
 	u32 new_mult;
@@ -88,6 +92,8 @@ static inline void inv_sensors_timestamp_reset(struct inv_sensors_timestamp *ts)
 	const struct inv_sensors_timestamp_interval interval_init = {0LL, 0LL};
 
 	ts->it = interval_init;
+	ts->delta = interval_init;
+	ts->delta_counter = 0;
 	ts->timestamp = 0;
 }
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 140/555] iio: inv_sensors: prevent timestamps going back in time in transitions
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (138 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 139/555] iio: inv_sensors: improve period measurement by using a longer delay Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 141/555] iio: inv_sensors: fix estimated value larger than interrupt timestamp Greg Kroah-Hartman
                   ` (414 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jean-Baptiste Maneyrol,
	Jonathan Cameron, Sasha Levin

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

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

From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>

[ Upstream commit 3785dffc7c68751a8429ae6dd75804c14a5a7c7a ]

Ensure when computing first timestamp and when applying odr change,
that the next timestamp will not be lower than the previous one.

This way there is no risk to have a timestamp going back in time, meaning
being lower than the previous one. It already can never happen without
a transition because we are generating timestamps by adding the period
to the last timestamp.

Fixes: 0ecc363ccea7 ("iio: make invensense timestamp module generic")
Cc: stable@vger.kernel.org
Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 .../common/inv_sensors/inv_sensors_timestamp.c   | 16 ++++++++++++----
 include/linux/iio/common/inv_sensors_timestamp.h |  3 ++-
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
index aacc56d1a2c77..4795a24171af0 100644
--- a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
+++ b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
@@ -133,10 +133,15 @@ void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,
 		return;
 
 	/* no previous data, compute theoretical value from interrupt */
-	if (ts->timestamp == 0) {
+	if (!ts->init) {
 		/* elapsed time: sensor period * sensor samples number */
 		interval = (s64)ts->period * (s64)sample_nb;
-		ts->timestamp = timestamp - interval;
+		delta = timestamp - interval;
+		/* prevent next timestamp to be lower than the last one */
+		if ((delta + ts->period) > ts->timestamp)
+			ts->timestamp = delta;
+		ts->init = true;
+
 	}
 
 	/* update delta timestamps and estimated period */
@@ -179,7 +184,7 @@ void inv_sensors_timestamp_apply_odr(struct inv_sensors_timestamp *ts,
 				     u32 fifo_period, size_t fifo_nb,
 				     unsigned int fifo_no)
 {
-	s64 interval;
+	s64 interval, timestamp;
 	u32 fifo_mult;
 
 	if (ts->new_mult == 0)
@@ -202,7 +207,10 @@ void inv_sensors_timestamp_apply_odr(struct inv_sensors_timestamp *ts,
 		fifo_period = fifo_mult * ts->chip_period.val;
 		/* computes time interval between interrupt and this sample */
 		interval = (s64)(fifo_nb - fifo_no) * (s64)fifo_period;
-		ts->timestamp = ts->it.up - interval;
+		timestamp = ts->it.up - interval;
+		/* prevent next timestamp to be lower than current one */
+		if ((timestamp + ts->period) > ts->timestamp)
+			ts->timestamp = timestamp;
 	}
 }
 EXPORT_SYMBOL_NS_GPL(inv_sensors_timestamp_apply_odr, IIO_INV_SENSORS_TIMESTAMP);
diff --git a/include/linux/iio/common/inv_sensors_timestamp.h b/include/linux/iio/common/inv_sensors_timestamp.h
index 4f08204ede3b4..91690778ae88b 100644
--- a/include/linux/iio/common/inv_sensors_timestamp.h
+++ b/include/linux/iio/common/inv_sensors_timestamp.h
@@ -66,6 +66,7 @@ struct inv_sensors_timestamp {
 	u32 new_mult;
 	u32 period;
 	struct inv_sensors_timestamp_acc chip_period;
+	bool init;
 };
 
 void inv_sensors_timestamp_init(struct inv_sensors_timestamp *ts,
@@ -94,7 +95,7 @@ static inline void inv_sensors_timestamp_reset(struct inv_sensors_timestamp *ts)
 	ts->it = interval_init;
 	ts->delta = interval_init;
 	ts->delta_counter = 0;
-	ts->timestamp = 0;
+	ts->init = false;
 }
 
 #endif
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 141/555] iio: inv_sensors: fix estimated value larger than interrupt timestamp
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (139 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 140/555] iio: inv_sensors: prevent timestamps going back in time in transitions Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 142/555] iio: inv_sensors: do not compute period estimation when updating odr Greg Kroah-Hartman
                   ` (413 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jean-Baptiste Maneyrol,
	Jonathan Cameron, Sasha Levin

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

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

From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>

[ Upstream commit b1c3c51b0916f7d1b2dceffc0e48abe185958825 ]

When interrupt timestamp interval is not valid, we use an estimated value
that can in rare case be bigger than the interrupt timestamp. This is
obviously wrong, so better use interrupt timestamp in this case.

Fixes: 8f4b627656fa ("iio: inv_sensors: better timestamp alignment when using watermark")
Cc: stable@vger.kernel.org
Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 .../iio/common/inv_sensors/inv_sensors_timestamp.c    | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
index 4795a24171af0..d46646510bbb6 100644
--- a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
+++ b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
@@ -172,11 +172,16 @@ void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,
 		valid = inv_validate_period(ts, period);
 	}
 
-	/* if interrupt interval is valid, sync with interrupt timestamp */
+	/*
+	 * If interrupt interval is valid, sync with interrupt timestamp.
+	 * Otherwise, use estimated value while ensuring interrupt timestamp
+	 * remains the maximum possible value.
+	 */
+	period = inv_align_timestamp_it(ts, sample_nb);
 	if (valid)
-		ts->period = inv_align_timestamp_it(ts, sample_nb);
+		ts->period = period;
 	else
-		ts->period = ts->mult * ts->chip_period.val;
+		ts->period = min(ts->mult * ts->chip_period.val, period);
 }
 EXPORT_SYMBOL_NS_GPL(inv_sensors_timestamp_interrupt, IIO_INV_SENSORS_TIMESTAMP);
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 142/555] iio: inv_sensors: do not compute period estimation when updating odr
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (140 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 141/555] iio: inv_sensors: fix estimated value larger than interrupt timestamp Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 143/555] Revert "wifi: ath10k: Stop unanswered temperature reads" Greg Kroah-Hartman
                   ` (412 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jean-Baptiste Maneyrol,
	Jonathan Cameron, Sasha Levin

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

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

From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>

[ Upstream commit 0d695709ed380f1bc9303a91f57525d33766a07e ]

When odr is updated, the delta between the interrupts will change and it
will lead to a bad period estimation.

Avoid this by preventing the period estimation in this case.

Fixes: 82bd09ce4fd3 ("iio: inv_sensors: improve period measurement by using a longer delay")
Cc: stable@vger.kernel.org
Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/iio/common/inv_sensors/inv_sensors_timestamp.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
index d46646510bbb6..1f44402b5b958 100644
--- a/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
+++ b/drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
@@ -147,6 +147,12 @@ void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,
 	/* update delta timestamps and estimated period */
 	it = &ts->delta;
 	ts->delta_counter += sample_nb;
+	/* reset in case of odr change */
+	if (ts->new_mult) {
+		it->lo = 0;
+		it->up = 0;
+		ts->delta_counter = 0;
+	}
 	delta = timestamp - it->up;
 	delta_threshold = INV_SENSORS_TIMESTAMP_MIN(INV_SENSORS_MIN_IT_DELTA, ts->chip.jitter);
 	if (delta >= delta_threshold) {
@@ -166,7 +172,7 @@ void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts,
 	it->lo = it->up;
 	it->up = timestamp;
 	delta = it->up - it->lo;
-	if (it->lo != 0) {
+	if (it->lo != 0 && !ts->new_mult) {
 		/* compute period and check validity */
 		period = div_s64(delta, sample_nb);
 		valid = inv_validate_period(ts, period);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 143/555] Revert "wifi: ath10k: Stop unanswered temperature reads"
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (141 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 142/555] iio: inv_sensors: do not compute period estimation when updating odr Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 144/555] firmware: arm_scmi: Update ARM_SCMI_HAVE_TRANSPORT rationale Greg Kroah-Hartman
                   ` (411 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Jeff Johnson

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

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

From: Jeff Johnson <jeff.johnson@oss.qualcomm.com>

commit b1ed5a45b994a6473ca1cf34f35a1bf87f1d8e2a upstream.

As reported by Nicolas Escande [1] this will break some setups where
temperature reporting is supported but there are occasional requests where
there isn't a response. Revert this implementation where a single
unreported temperature read at any time will stop all future requests.

Alternate solutions are being discussed.

Link: https://lore.kernel.org/all/DMRPC2GCD51O.S4DMHZFDKRFG@gmail.com/ # [1]
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/wireless/ath/ath10k/core.c    |    1 -
 drivers/net/wireless/ath/ath10k/thermal.c |    9 +--------
 drivers/net/wireless/ath/ath10k/thermal.h |    2 --
 3 files changed, 1 insertion(+), 11 deletions(-)

--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -2979,7 +2979,6 @@ int ath10k_core_start(struct ath10k *ar,
 	clear_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags);
 
 	ar->running_fw = fw;
-	ar->thermal.broken = false;
 
 	if (!test_bit(ATH10K_FW_FEATURE_NON_BMI,
 		      ar->running_fw->fw_file.fw_features)) {
--- a/drivers/net/wireless/ath/ath10k/thermal.c
+++ b/drivers/net/wireless/ath/ath10k/thermal.c
@@ -75,12 +75,6 @@ static ssize_t ath10k_thermal_show_temp(
 		goto out;
 	}
 
-	/* Don't stall every read on firmware that never answers */
-	if (ar->thermal.broken) {
-		ret = -EOPNOTSUPP;
-		goto out;
-	}
-
 	reinit_completion(&ar->thermal.wmi_sync);
 	ret = ath10k_wmi_pdev_get_temperature(ar);
 	if (ret) {
@@ -96,8 +90,7 @@ static ssize_t ath10k_thermal_show_temp(
 	time_left = wait_for_completion_timeout(&ar->thermal.wmi_sync,
 						ATH10K_THERMAL_SYNC_TIMEOUT_HZ);
 	if (!time_left) {
-		ath10k_warn(ar, "failed to synchronize thermal read, not asking again until the firmware restarts\n");
-		ar->thermal.broken = true;
+		ath10k_warn(ar, "failed to synchronize thermal read\n");
 		ret = -ETIMEDOUT;
 		goto out;
 	}
--- a/drivers/net/wireless/ath/ath10k/thermal.h
+++ b/drivers/net/wireless/ath/ath10k/thermal.h
@@ -19,8 +19,6 @@ struct ath10k_thermal {
 	/* protected by conf_mutex */
 	u32 throttle_state;
 	u32 quiet_period;
-	/* the running firmware did not answer a temperature request */
-	bool broken;
 	/* temperature value in Celsius degree
 	 * protected by data_lock
 	 */



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 144/555] firmware: arm_scmi: Update ARM_SCMI_HAVE_TRANSPORT rationale
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (142 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 143/555] Revert "wifi: ath10k: Stop unanswered temperature reads" Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 145/555] firmware: smccc: Provide stubs for HAVE_ARM_SMCCC_DISCOVERY=n Greg Kroah-Hartman
                   ` (410 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Geert Uytterhoeven, Sudeep Holla,
	Sasha Levin

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

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

From: Geert Uytterhoeven <geert+renesas@glider.be>

[ Upstream commit e637b774416775d09540070ceecf972c59070d90 ]

Not enabling any transports no longer breaks the build.

Fixes: c0397c85b53d0bc6 ("firmware: arm_scmi: Use WARN_ON() to check configured transports")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://patch.msgid.link/48c4bed8036dcb55f554f513ce2ae61807c5677d.1790684637.git.geert+renesas@glider.be
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/firmware/arm_scmi/transports/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/arm_scmi/transports/Kconfig b/drivers/firmware/arm_scmi/transports/Kconfig
index 57eccf316e26b..66b10f511827c 100644
--- a/drivers/firmware/arm_scmi/transports/Kconfig
+++ b/drivers/firmware/arm_scmi/transports/Kconfig
@@ -5,7 +5,7 @@ config ARM_SCMI_HAVE_TRANSPORT
 	bool
 	help
 	  This declares whether at least one SCMI transport has been configured.
-	  Used to trigger a build bug when trying to build SCMI without any
+	  Used to trigger a runtime warning when enabling SCMI without any
 	  configured transport.
 
 config ARM_SCMI_HAVE_SHMEM
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 145/555] firmware: smccc: Provide stubs for HAVE_ARM_SMCCC_DISCOVERY=n
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (143 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 144/555] firmware: arm_scmi: Update ARM_SCMI_HAVE_TRANSPORT rationale Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 146/555] HID: vivaldi: Extract feature report value directly in vivaldi_feature_mapping() Greg Kroah-Hartman
                   ` (409 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Marc Zyngier, Julian Braha,
	Sudeep Holla, Sasha Levin

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

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

From: Julian Braha <julianbraha@gmail.com>

[ Upstream commit 6cc03818814aa98c3584a346b82165f1b561f2b7 ]

Add fallbacks for callers to avoid needing #ifdef guards when
HAVE_ARM_SMCCC_DISCOVERY is disabled (32-bit arm).

Fixes: 35727af2b15d ("irqchip/gicv3: Workaround for NVIDIA erratum T241-FABRIC-4")
Suggested-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Julian Braha <julianbraha@gmail.com>
Reviewed-by: Marc Zyngier <maz@kernel.org>
Link: https://patch.msgid.link/20261020222817.1231643-2-julianbraha@gmail.com
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/linux/arm-smccc.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h
index 67f6fdf2e7cd8..df868fa0edbf3 100644
--- a/include/linux/arm-smccc.h
+++ b/include/linux/arm-smccc.h
@@ -293,6 +293,7 @@ enum arm_smccc_conduit {
 	SMCCC_CONDUIT_HVC,
 };
 
+#ifdef CONFIG_HAVE_ARM_SMCCC_DISCOVERY
 /**
  * arm_smccc_1_1_get_conduit()
  *
@@ -332,6 +333,12 @@ s32 arm_smccc_get_soc_id_version(void);
  * When ARM_SMCCC_ARCH_SOC_ID is not present, returns SMCCC_RET_NOT_SUPPORTED.
  */
 s32 arm_smccc_get_soc_id_revision(void);
+#else   /* CONFIG_HAVE_ARM_SMCCC_DISCOVERY */
+#define arm_smccc_1_1_get_conduit()	SMCCC_CONDUIT_NONE
+#define arm_smccc_get_version()		0
+#define arm_smccc_get_soc_id_version()	SMCCC_RET_NOT_SUPPORTED
+#define arm_smccc_get_soc_id_revision()	SMCCC_RET_NOT_SUPPORTED
+#endif	/* CONFIG_HAVE_ARM_SMCCC_DISCOVERY */
 
 /**
  * struct arm_smccc_res - Result from SMC/HVC call
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 146/555] HID: vivaldi: Extract feature report value directly in vivaldi_feature_mapping()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (144 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 145/555] firmware: smccc: Provide stubs for HAVE_ARM_SMCCC_DISCOVERY=n Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 147/555] HID: vivaldi: avoid redundant feature report reads per usage Greg Kroah-Hartman
                   ` (408 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Dmitry Torokhov, Tzung-Bi Shih,
	Sean OBrien, Shashikirana H K, Benjamin Tissoires, Sasha Levin

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

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

From: Shashikirana H K <shashikiranah@chromium.org>

[ Upstream commit 8dbf66b011135422a28ee32da1d6aacbe08ddd7a ]

Currently vivaldi_feature_mapping() passes the raw buffer returned by
hid_hw_raw_request() to hid_report_raw_event() with the descriptor-declared
report_len just to populate field->value[usage->usage_index].

Since vivaldi_feature_mapping() already has the target report, field, and
usage in hand, and nothing else consumes field->value[] for this report,
verify that hid_hw_raw_request() returns the expected report_len, ensure
usage->usage_index is within field->report_count, and extract the value
directly using hid_field_extract(). Also use __free(kfree) to simplify
buffer cleanup.

Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Fixes: 33bbe04a15f2 ("HID: google: extract Vivaldi hid feature mapping for use in hid-hammer")
Cc: Tzung-Bi Shih <tzungbi@chromium.org>
Cc: Sean O'Brien <seobrien@chromium.org>
Signed-off-by: Shashikirana H K <shashikiranah@chromium.org>
Link: https://patch.msgid.link/20261013-upstream-vivaldi-fix-v2-1-ecc20329d24c@chromium.org
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/hid/hid-vivaldi-common.c | 72 ++++++++++++--------------------
 1 file changed, 26 insertions(+), 46 deletions(-)

diff --git a/drivers/hid/hid-vivaldi-common.c b/drivers/hid/hid-vivaldi-common.c
index b12bb5cc091aa..1359a107e63bd 100644
--- a/drivers/hid/hid-vivaldi-common.c
+++ b/drivers/hid/hid-vivaldi-common.c
@@ -5,11 +5,13 @@
  * Copyright (C) 2022 Google, Inc
  */
 
+#include <linux/cleanup.h>
 #include <linux/export.h>
 #include <linux/hid.h>
 #include <linux/input/vivaldi-fmap.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/types.h>
 
 #include "hid-vivaldi-common.h"
@@ -33,13 +35,14 @@ void vivaldi_feature_mapping(struct hid_device *hdev,
 {
 	struct vivaldi_data *data = hid_get_drvdata(hdev);
 	struct hid_report *report = field->report;
-	u8 *report_data, *buf;
-	u32 report_len;
 	unsigned int fn_key;
+	unsigned int offset;
+	u32 report_len;
 	int ret;
 
 	if (field->logical != HID_USAGE_FN_ROW_PHYSMAP ||
-	    (usage->hid & HID_USAGE_PAGE) != HID_UP_ORDINAL)
+	    (usage->hid & HID_USAGE_PAGE) != HID_UP_ORDINAL ||
+	    usage->usage_index >= field->report_count)
 		return;
 
 	fn_key = usage->hid & HID_USAGE;
@@ -49,54 +52,31 @@ void vivaldi_feature_mapping(struct hid_device *hdev,
 	if (fn_key > data->num_function_row_keys)
 		data->num_function_row_keys = fn_key;
 
-	report_data = buf = hid_alloc_report_buf(report, GFP_KERNEL);
-	if (!report_data)
+	u8 *buf __free(kfree) = hid_alloc_report_buf(report, GFP_KERNEL);
+	if (!buf)
 		return;
 
-	report_len = hid_report_len(report);
-	if (!report->id) {
-		/*
-		 * hid_hw_raw_request() will stuff report ID (which will be 0)
-		 * into the first byte of the buffer even for unnumbered
-		 * reports, so we need to account for this to avoid getting
-		 * -EOVERFLOW in return.
-		 * Note that hid_alloc_report_buf() adds 7 bytes to the size
-		 * so we can safely say that we have space for an extra byte.
-		 */
-		report_len++;
-	}
-
-	ret = hid_hw_raw_request(hdev, report->id, report_data,
-				 report_len, HID_FEATURE_REPORT,
-				 HID_REQ_GET_REPORT);
-	if (ret < 0) {
-		dev_warn(&hdev->dev, "failed to fetch feature %d\n",
-			 field->report->id);
-		goto out;
-	}
-
-	if (!report->id) {
-		/*
-		 * Undo the damage from hid_hw_raw_request() for unnumbered
-		 * reports.
-		 */
-		report_data++;
-		report_len--;
-	}
-
-	ret = hid_report_raw_event(hdev, HID_FEATURE_REPORT, report_data,
-				   report_len, report_len, 0);
-	if (ret) {
-		dev_warn(&hdev->dev, "failed to report feature %d\n",
-			 field->report->id);
-		goto out;
+	/*
+	 * hid_hw_raw_request() will stuff report ID (which will be 0)
+	 * into the first byte of the buffer even for unnumbered
+	 * reports, so we need to account for this to avoid getting
+	 * -EOVERFLOW in return.
+	 * Note that hid_alloc_report_buf() adds 7 bytes to the size
+	 * so we can safely say that we have space for an extra byte.
+	 */
+	report_len = hid_report_len(report) + !report->id;
+
+	ret = hid_hw_raw_request(hdev, report->id, buf, report_len,
+				 HID_FEATURE_REPORT, HID_REQ_GET_REPORT);
+	if (ret != report_len) {
+		dev_warn(&hdev->dev, "failed to fetch feature %d: %d\n",
+			 report->id, ret);
+		return;
 	}
 
+	offset = field->report_offset + usage->usage_index * field->report_size;
 	data->function_row_physmap[fn_key - MIN_FN_ROW_KEY] =
-		field->value[usage->usage_index];
-
-out:
-	kfree(buf);
+		hid_field_extract(hdev, buf + 1, offset, field->report_size);
 }
 EXPORT_SYMBOL_GPL(vivaldi_feature_mapping);
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 147/555] HID: vivaldi: avoid redundant feature report reads per usage
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (145 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 146/555] HID: vivaldi: Extract feature report value directly in vivaldi_feature_mapping() Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 148/555] firmware: arm_scmi: imx: Validate MISC control response size Greg Kroah-Hartman
                   ` (407 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Zhengping Jiang, Benjamin Tissoires,
	Sasha Levin

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

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

From: Zhengping Jiang <jiangzp@google.com>

[ Upstream commit 720806515cb6921ab05caaa6f470f7054b56385e ]

vivaldi_feature_mapping() is invoked by report_features() in ascending
usage_index order for each usage in the top-row physical keymap field.
Because fetching the feature report at usage_index == 0 already reads
the entire report from hardware, calling hid_hw_raw_request() again for
subsequent usages redundantly reads the same report N times (e.g., 12
sequential BLE GATT reads taking ~2s on Vivaldi BLE keyboards).

Bail out immediately when usage->usage_index != 0, fetch the feature
report once at usage_index == 0, and iterate over all usages in the
field to populate data->function_row_physmap[].

Fixes: 33bbe04a15f2 ("HID: google: extract Vivaldi hid feature mapping for use in hid-hammer")
Signed-off-by: Zhengping Jiang <jiangzp@google.com>
Link: https://patch.msgid.link/20261015064223.1939367-1-jiangzp@google.com
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/hid/hid-vivaldi-common.c | 33 +++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/drivers/hid/hid-vivaldi-common.c b/drivers/hid/hid-vivaldi-common.c
index 1359a107e63bd..973393d093561 100644
--- a/drivers/hid/hid-vivaldi-common.c
+++ b/drivers/hid/hid-vivaldi-common.c
@@ -39,19 +39,11 @@ void vivaldi_feature_mapping(struct hid_device *hdev,
 	unsigned int offset;
 	u32 report_len;
 	int ret;
+	int i;
 
-	if (field->logical != HID_USAGE_FN_ROW_PHYSMAP ||
-	    (usage->hid & HID_USAGE_PAGE) != HID_UP_ORDINAL ||
-	    usage->usage_index >= field->report_count)
+	if (field->logical != HID_USAGE_FN_ROW_PHYSMAP || usage->usage_index)
 		return;
 
-	fn_key = usage->hid & HID_USAGE;
-	if (fn_key < MIN_FN_ROW_KEY || fn_key > MAX_FN_ROW_KEY)
-		return;
-
-	if (fn_key > data->num_function_row_keys)
-		data->num_function_row_keys = fn_key;
-
 	u8 *buf __free(kfree) = hid_alloc_report_buf(report, GFP_KERNEL);
 	if (!buf)
 		return;
@@ -74,9 +66,24 @@ void vivaldi_feature_mapping(struct hid_device *hdev,
 		return;
 	}
 
-	offset = field->report_offset + usage->usage_index * field->report_size;
-	data->function_row_physmap[fn_key - MIN_FN_ROW_KEY] =
-		hid_field_extract(hdev, buf + 1, offset, field->report_size);
+	for (i = 0; i < field->maxusage && i < field->report_count; i++) {
+		usage = &field->usage[i];
+
+		if ((usage->hid & HID_USAGE_PAGE) != HID_UP_ORDINAL)
+			continue;
+
+		fn_key = usage->hid & HID_USAGE;
+		if (fn_key < MIN_FN_ROW_KEY || fn_key > MAX_FN_ROW_KEY)
+			continue;
+
+		if (fn_key > data->num_function_row_keys)
+			data->num_function_row_keys = fn_key;
+
+		offset = field->report_offset + i * field->report_size;
+		data->function_row_physmap[fn_key - MIN_FN_ROW_KEY] =
+			hid_field_extract(hdev, buf + 1, offset,
+					  field->report_size);
+	}
 }
 EXPORT_SYMBOL_GPL(vivaldi_feature_mapping);
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 148/555] firmware: arm_scmi: imx: Validate MISC control response size
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (146 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 147/555] HID: vivaldi: avoid redundant feature report reads per usage Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 149/555] firmware: arm_scmi: Unregister notifier on enable failure Greg Kroah-Hartman
                   ` (406 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sashiko, Peng Fan, Sudeep Holla,
	Sasha Levin

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

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

From: Sudeep Holla <sudeep.holla@kernel.org>

[ Upstream commit 4e3652a0ac715ba7387b072b72eaff76e761aaf9 ]

scmi_imx_misc_ctrl_get() uses @num to report the number of
values returned by firmware, but it did not retain the caller's value
as the capacity of @val.

A response with more values than the caller allocated was copied into
@val unchecked. For example, the MQS regmap callback supplies storage
for one value. Retain the input capacity and reject responses exceeding
it before copying, then update @num only after a successful copy.

Document the in/out @num contract of the exported helper.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-6897b44a-57fb-4964-95f8-447d0ce526e4
Fixes: 61c9f03e22fc ("firmware: arm_scmi: Add initial support for i.MX MISC protocol")
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Link: https://patch.msgid.link/20261028130502.2999676-2-sudeep.holla@kernel.org
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 .../firmware/arm_scmi/vendors/imx/imx-sm-misc.c  | 16 ++++++++++++----
 include/linux/firmware/imx/sm.h                  |  6 ++++++
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c b/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c
index 2641faa329cdd..1fab0e0964247 100644
--- a/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c
+++ b/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c
@@ -204,10 +204,16 @@ static int scmi_imx_misc_ctrl_get(const struct scmi_protocol_handle *ph,
 {
 	struct scmi_imx_misc_ctrl_get_out *out;
 	struct scmi_xfer *t;
+	u32 num_values, max_values;
 	int ret, i;
 	int max_msg_size = ph->hops->get_max_msg_size(ph);
 	int max_num = (max_msg_size - sizeof(*out)) / sizeof(__le32);
 
+	if (!num || !val || !*num)
+		return -EINVAL;
+
+	max_values = *num;
+
 	ret = scmi_imx_misc_ctrl_validate_id(ph, ctrl_id);
 	if (ret)
 		return ret;
@@ -221,16 +227,18 @@ static int scmi_imx_misc_ctrl_get(const struct scmi_protocol_handle *ph,
 	ret = ph->xops->do_xfer(ph, t);
 	if (!ret) {
 		out = t->rx.buf;
-		*num = le32_to_cpu(out->num);
+		num_values = le32_to_cpu(out->num);
 
-		if (*num >= max_num ||
-		    *num * sizeof(__le32) > t->rx.len - sizeof(__le32)) {
+		if (num_values > max_values || num_values >= max_num ||
+		    num_values * sizeof(__le32) > t->rx.len - sizeof(__le32)) {
 			ph->xops->xfer_put(ph, t);
 			return -EINVAL;
 		}
 
-		for (i = 0; i < *num; i++)
+		for (i = 0; i < num_values; i++)
 			val[i] = le32_to_cpu(out->val[i]);
+
+		*num = num_values;
 	}
 
 	ph->xops->xfer_put(ph, t);
diff --git a/include/linux/firmware/imx/sm.h b/include/linux/firmware/imx/sm.h
index 61f7a02b05009..b678487d5b3e4 100644
--- a/include/linux/firmware/imx/sm.h
+++ b/include/linux/firmware/imx/sm.h
@@ -18,6 +18,12 @@
 #define SCMI_IMX_CTRL_SAI5_MCLK		5	/* WAKE SAI5 MCLK */
 
 #if IS_ENABLED(CONFIG_IMX_SCMI_MISC_DRV)
+/**
+ * scmi_imx_misc_ctrl_get() - Read an i.MX MISC control
+ * @id: Control identifier
+ * @num: On entry, capacity of @val in words; on return, words read
+ * @val: Buffer for the control value
+ */
 int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val);
 int scmi_imx_misc_ctrl_set(u32 id, u32 val);
 #else
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 149/555] firmware: arm_scmi: Unregister notifier on enable failure
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (147 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 148/555] firmware: arm_scmi: imx: Validate MISC control response size Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 150/555] soundwire: qcom: disable the interrupt before gating the clock Greg Kroah-Hartman
                   ` (405 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sashiko, Peng Fan, Sudeep Holla,
	Sasha Levin

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

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

From: Sudeep Holla <sudeep.holla@kernel.org>

[ Upstream commit b9bb2eb88037a3823e7abd096b54d0a07d428f90 ]

scmi_notifier_register() adds the caller's notifier block before
enabling the corresponding event at the platform.

If enablement fails, the caller receives an error and can free its
notifier block. A concurrent registration can retain and later enable
the handler, leaving the failed caller's block in its notification
chain. Event delivery can then dereference the freed block.

Remove the notifier block before dropping the handler reference when
event enablement fails.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-c3c9437c-ba1a-4db6-837f-cb0950d89018
Fixes: e7c215f358a3 ("firmware: arm_scmi: Add notification callbacks-registration")
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Link: https://patch.msgid.link/20261028130502.2999676-3-sudeep.holla@kernel.org
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/firmware/arm_scmi/notify.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/arm_scmi/notify.c b/drivers/firmware/arm_scmi/notify.c
index c4d4337ac3a34..98edaba2a5c9d 100644
--- a/drivers/firmware/arm_scmi/notify.c
+++ b/drivers/firmware/arm_scmi/notify.c
@@ -1378,8 +1378,10 @@ static int scmi_notifier_register(const struct scmi_handle *handle,
 	/* Enable events for not pending handlers */
 	if (!IS_HNDL_PENDING(hndl)) {
 		ret = scmi_event_handler_enable_events(hndl);
-		if (ret)
+		if (ret) {
+			blocking_notifier_chain_unregister(&hndl->chain, nb);
 			scmi_put_handler(ni, hndl);
+		}
 	}
 
 	return ret;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 150/555] soundwire: qcom: disable the interrupt before gating the clock
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (148 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 149/555] firmware: arm_scmi: Unregister notifier on enable failure Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 151/555] memory: tegra: Shut down Tegra210 EMC timers before teardown Greg Kroah-Hartman
                   ` (404 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Oleg Keri, Dmitry Baryshkov,
	Vinod Koul, Sasha Levin

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

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

From: Oleg Keri <okerixx@gmail.com>

[ Upstream commit 6c067677192f054bbfa815caf04f536bb8dcdee2 ]

swrm_runtime_suspend() gates hclk straight after the ClockStopNow
broadcast, while the interrupt thread that completed it is still
clearing the status and CLK_STOP_FINISHED is about to fire. Both touch
registers with the clock going away; on x1e80100 and glymur hclk is the
SoundWire clock itself. The next clock-stop exit then fails at random
(bus clash, parity errors, AUTO_ENUM_FAILED) and one side of the
speakers stays detached until reboot.

Disable the interrupt before gating the clock and enable it again once
the clock is back.

Fixes: 74e79da9fd46 ("soundwire: qcom: add runtime pm support")
Signed-off-by: Oleg Keri <okerixx@gmail.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Link: https://patch.msgid.link/20261009082639.22662-1-okerixx@gmail.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/soundwire/qcom.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
index db7c8fb04f117..4704df8e6b70f 100644
--- a/drivers/soundwire/qcom.c
+++ b/drivers/soundwire/qcom.c
@@ -1667,6 +1667,7 @@ static int __maybe_unused swrm_runtime_resume(struct device *dev)
 	}
 
 	clk_prepare_enable(ctrl->hclk);
+	enable_irq(ctrl->irq);
 
 	if (ctrl->clock_stop_not_supported) {
 		reinit_completion(&ctrl->enumeration);
@@ -1750,6 +1751,7 @@ static int __maybe_unused swrm_runtime_suspend(struct device *dev)
 		}
 	}
 
+	disable_irq(ctrl->irq);
 	clk_disable_unprepare(ctrl->hclk);
 
 	usleep_range(300, 305);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 151/555] memory: tegra: Shut down Tegra210 EMC timers before teardown
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (149 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 150/555] soundwire: qcom: disable the interrupt before gating the clock Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 152/555] memory: tegra: fix device_node leak in tegra186_mc_probe_device() Greg Kroah-Hartman
                   ` (403 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Ijae Kim, Myeonghun Pak, Sashiko,
	Krzysztof Kozlowski, Sasha Levin

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

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

From: Myeonghun Pak <mhun512@gmail.com>

[ Upstream commit c5f343c189aa30285e7c73dbf2f185720467794b ]

The training and refresh timers can outlive the EMC state on removal
or probe failure after clock attachment, causing use-after-free.

Shut down both timers before detaching the clock provider and releasing
the timing tables to wait for callbacks and prevent rearming. Initialize
them before clock attachment, since set_rate() can start training.

Fixes: 10de21148f7d ("memory: tegra: Add EMC scaling support code for Tegra210")
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-47538f77-fb50-4a06-b49b-92dbee8b538b
Link: https://patch.msgid.link/20261015002852.2159841-1-mhun512@gmail.com
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/memory/tegra/tegra210-emc-core.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/memory/tegra/tegra210-emc-core.c b/drivers/memory/tegra/tegra210-emc-core.c
index 78ca1d6c09774..c363c4a198b5d 100644
--- a/drivers/memory/tegra/tegra210-emc-core.c
+++ b/drivers/memory/tegra/tegra210-emc-core.c
@@ -1946,12 +1946,6 @@ static int tegra210_emc_probe(struct platform_device *pdev)
 			config->same_freq = true;
 	}
 
-	err = tegra210_clk_emc_attach(emc->clk, &emc->provider);
-	if (err < 0) {
-		dev_err(&pdev->dev, "failed to attach to EMC clock: %d\n", err);
-		goto release;
-	}
-
 	emc->clkchange_delay = 100;
 	emc->training_interval = 100;
 	dev_set_drvdata(emc->dev, emc);
@@ -1963,6 +1957,12 @@ static int tegra210_emc_probe(struct platform_device *pdev)
 
 	timer_setup(&emc->training, tegra210_emc_train, 0);
 
+	err = tegra210_clk_emc_attach(emc->clk, &emc->provider);
+	if (err < 0) {
+		dev_err(&pdev->dev, "failed to attach to EMC clock: %d\n", err);
+		goto release;
+	}
+
 	tegra210_emc_debugfs_init(emc);
 
 	cd = devm_thermal_of_cooling_device_register(emc->dev, np, "emc", emc,
@@ -1978,6 +1978,8 @@ static int tegra210_emc_probe(struct platform_device *pdev)
 
 detach:
 	debugfs_remove_recursive(emc->debugfs.root);
+	timer_shutdown_sync(&emc->training);
+	timer_shutdown_sync(&emc->refresh_timer);
 	tegra210_clk_emc_detach(emc->clk);
 release:
 	of_reserved_mem_device_release(emc->dev);
@@ -1990,6 +1992,8 @@ static void tegra210_emc_remove(struct platform_device *pdev)
 	struct tegra210_emc *emc = platform_get_drvdata(pdev);
 
 	debugfs_remove_recursive(emc->debugfs.root);
+	timer_shutdown_sync(&emc->training);
+	timer_shutdown_sync(&emc->refresh_timer);
 	tegra210_clk_emc_detach(emc->clk);
 	of_reserved_mem_device_release(emc->dev);
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 152/555] memory: tegra: fix device_node leak in tegra186_mc_probe_device()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (150 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 151/555] memory: tegra: Shut down Tegra210 EMC timers before teardown Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 153/555] irqchip/gic-v4: Clear the domain and fwnode pointers after freeing them Greg Kroah-Hartman
                   ` (402 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Selby Mashiki, Krzysztof Kozlowski,
	Sasha Levin

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

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

From: Selby Mashiki <mashikiselby@gmail.com>

[ Upstream commit 21250426a8469d3bc43c2f0c69ed5497ee9ff7d4 ]

tegra186_mc_probe_device() iterates over the "interconnects" phandles
using of_parse_phandle_with_args(), which increments the reference count
of args.np on each successful call, but never drops the reference with
of_node_put(args.np).

Call of_node_put(args.np) at the end of each loop iteration.

Fixes: fe3b082a6eb8 ("memory: tegra: Add SID override programming for MC clients")
Signed-off-by: Selby Mashiki <mashikiselby@gmail.com>
Link: https://patch.msgid.link/20261025190322.449324-1-mashikiselby@gmail.com
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/memory/tegra/tegra186.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/memory/tegra/tegra186.c b/drivers/memory/tegra/tegra186.c
index 1b3183951bfe5..07fad3a9ec2f3 100644
--- a/drivers/memory/tegra/tegra186.c
+++ b/drivers/memory/tegra/tegra186.c
@@ -134,6 +134,7 @@ static int tegra186_mc_probe_device(struct tegra_mc *mc, struct device *dev)
 			}
 		}
 
+		of_node_put(args.np);
 		index++;
 	}
 #endif
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 153/555] irqchip/gic-v4: Clear the domain and fwnode pointers after freeing them
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (151 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 152/555] memory: tegra: fix device_node leak in tegra186_mc_probe_device() Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 154/555] irqchip/gic-v4: Unwind what its_alloc_vcpu_irqs() allocated on failure Greg Kroah-Hartman
                   ` (401 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Yuan Yao, Fuad Tabba, Marc Zyngier,
	Sasha Levin

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

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

From: Fuad Tabba <fuad.tabba@linux.dev>

[ Upstream commit 861bebd1fac5f5a25c11e40aec3c3291542045d1 ]

The GICv4 allocation and teardown paths free their irq domains and
fwnodes but leave the pointers set, and the allocation error paths test
those pointers before removing them. struct its_vm and struct its_vpe
are embedded in KVM's per-VM and per-vCPU state, so nothing re-zeroes
them between two attempts, and an error path taken after an earlier one
already freed the domain calls irq_domain_remove() on freed memory.

Reaching this takes two allocation failures, one to leave the stale
pointer behind and one to send the next attempt down the error path.

Fixes: 7de5c0af9c7c ("irqchip/gic-v4: Add per-VM VPE domain creation")
Fixes: 6d31b6ff985d ("irqchip/gic-v4.1: Add VSGI allocation/teardown")
Reviewed-by: Yuan Yao <yaoyuan@linux.alibaba.com>
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
Link: https://patch.msgid.link/20260921072958.2918477-2-fuad.tabba@linux.dev
Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/irqchip/irq-gic-v4.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/irqchip/irq-gic-v4.c b/drivers/irqchip/irq-gic-v4.c
index 58c28895f8c42..91df31bed7105 100644
--- a/drivers/irqchip/irq-gic-v4.c
+++ b/drivers/irqchip/irq-gic-v4.c
@@ -147,10 +147,14 @@ static int its_alloc_vcpu_sgis(struct its_vpe *vpe, int idx)
 	return 0;
 
 err:
-	if (vpe->sgi_domain)
+	if (vpe->sgi_domain) {
 		irq_domain_remove(vpe->sgi_domain);
-	if (vpe->fwnode)
+		vpe->sgi_domain = NULL;
+	}
+	if (vpe->fwnode) {
 		irq_domain_free_fwnode(vpe->fwnode);
+		vpe->fwnode = NULL;
+	}
 	kfree(name);
 	return -ENOMEM;
 }
@@ -191,10 +195,14 @@ int its_alloc_vcpu_irqs(struct its_vm *vm)
 	return 0;
 
 err:
-	if (vm->domain)
+	if (vm->domain) {
 		irq_domain_remove(vm->domain);
-	if (vm->fwnode)
+		vm->domain = NULL;
+	}
+	if (vm->fwnode) {
 		irq_domain_free_fwnode(vm->fwnode);
+		vm->fwnode = NULL;
+	}
 
 	return -ENOMEM;
 }
@@ -215,6 +223,8 @@ static void its_free_sgi_irqs(struct its_vm *vm)
 		irq_domain_free_irqs(irq, 16);
 		irq_domain_remove(vm->vpes[i]->sgi_domain);
 		irq_domain_free_fwnode(vm->vpes[i]->fwnode);
+		vm->vpes[i]->sgi_domain = NULL;
+		vm->vpes[i]->fwnode = NULL;
 	}
 }
 
@@ -224,6 +234,8 @@ void its_free_vcpu_irqs(struct its_vm *vm)
 	irq_domain_free_irqs(vm->vpes[0]->irq, vm->nr_vpes);
 	irq_domain_remove(vm->domain);
 	irq_domain_free_fwnode(vm->fwnode);
+	vm->domain = NULL;
+	vm->fwnode = NULL;
 }
 
 static int its_send_vpe_cmd(struct its_vpe *vpe, struct its_cmd_info *info)
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 154/555] irqchip/gic-v4: Unwind what its_alloc_vcpu_irqs() allocated on failure
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (152 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 153/555] irqchip/gic-v4: Clear the domain and fwnode pointers after freeing them Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 155/555] reset: scmi: Set the device for the reset controller Greg Kroah-Hartman
                   ` (400 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Yuan Yao, Fuad Tabba, Marc Zyngier,
	Sasha Levin

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

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

From: Fuad Tabba <fuad.tabba@linux.dev>

[ Upstream commit fd86d69c951765e24e89a162c53dfe33a8aba976 ]

A failure in the its_alloc_vcpu_sgis() loop leaves behind both the SGI
domains created for the vPEs below the failing index and the vPE irqs
allocated before the loop, since irq_domain_remove() frees neither. Each
leaked vPE takes its ITS state with it, a vpe_id and an LPI pending
table.

Free both from a second label before the existing unwind. With the
freed pointers now cleared, its_free_sgi_irqs() can skip a vPE with no
SGI domain and be reused there. The check has to precede the lookup:
irq_find_mapping(NULL, 0) falls back to irq_default_domain, and the
live irq it returns would then be freed.

Fixes: 6d31b6ff985d ("irqchip/gic-v4.1: Add VSGI allocation/teardown")
Reviewed-by: Yuan Yao <yaoyuan@linux.alibaba.com>
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
Link: https://patch.msgid.link/20260921072958.2918477-3-fuad.tabba@linux.dev
Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/irqchip/irq-gic-v4.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-gic-v4.c b/drivers/irqchip/irq-gic-v4.c
index 91df31bed7105..1f6edd6e94e92 100644
--- a/drivers/irqchip/irq-gic-v4.c
+++ b/drivers/irqchip/irq-gic-v4.c
@@ -159,6 +159,8 @@ static int its_alloc_vcpu_sgis(struct its_vpe *vpe, int idx)
 	return -ENOMEM;
 }
 
+static void its_free_sgi_irqs(struct its_vm *vm);
+
 int its_alloc_vcpu_irqs(struct its_vm *vm)
 {
 	int vpe_base_irq, i;
@@ -189,11 +191,14 @@ int its_alloc_vcpu_irqs(struct its_vm *vm)
 		vm->vpes[i]->irq = vpe_base_irq + i;
 		ret = its_alloc_vcpu_sgis(vm->vpes[i], i);
 		if (ret)
-			goto err;
+			goto err_free_irqs;
 	}
 
 	return 0;
 
+err_free_irqs:
+	its_free_sgi_irqs(vm);
+	irq_domain_free_irqs(vpe_base_irq, vm->nr_vpes);
 err:
 	if (vm->domain) {
 		irq_domain_remove(vm->domain);
@@ -215,8 +220,13 @@ static void its_free_sgi_irqs(struct its_vm *vm)
 		return;
 
 	for (i = 0; i < vm->nr_vpes; i++) {
-		unsigned int irq = irq_find_mapping(vm->vpes[i]->sgi_domain, 0);
+		unsigned int irq;
+
+		/* irq_find_mapping() falls back to the default domain on NULL. */
+		if (!vm->vpes[i]->sgi_domain)
+			continue;
 
+		irq = irq_find_mapping(vm->vpes[i]->sgi_domain, 0);
 		if (WARN_ON(!irq))
 			continue;
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 155/555] reset: scmi: Set the device for the reset controller
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (153 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 154/555] irqchip/gic-v4: Unwind what its_alloc_vcpu_irqs() allocated on failure Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 156/555] irqchip/gic-v4: Use a separate lockdep class for vPE doorbell IRQs Greg Kroah-Hartman
                   ` (399 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Kunihiko Hayashi, Sudeep Holla,
	Philipp Zabel, Sasha Levin

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

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

From: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>

[ Upstream commit e3e068a457cebe2e475535685c325d5ca305f44a ]

SCMI reset driver does not set rcdev.dev when registering its reset
controller.

If rcdev.of_node is not available, the reset core tries to obtain
the firmware node from rcdev.dev. However, rcdev.dev is also NULL,
causing a NULL pointer dereference.

Set rcdev.dev to the SCMI device.

Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Reviewed-by: Sudeep Holla <sudeep.holla@kernel.org>
Fixes: c8ae9c2da1cc ("reset: Add support for resets provided by SCMI")
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/reset/reset-scmi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/reset/reset-scmi.c b/drivers/reset/reset-scmi.c
index 4335811e0cfaa..0fdf593b09e24 100644
--- a/drivers/reset/reset-scmi.c
+++ b/drivers/reset/reset-scmi.c
@@ -107,6 +107,7 @@ static int scmi_reset_probe(struct scmi_device *sdev)
 
 	data->rcdev.ops = &scmi_reset_ops;
 	data->rcdev.owner = THIS_MODULE;
+	data->rcdev.dev = dev;
 	data->rcdev.of_node = np;
 	data->rcdev.nr_resets = reset_ops->num_domains_get(ph);
 	data->ph = ph;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 156/555] irqchip/gic-v4: Use a separate lockdep class for vPE doorbell IRQs
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (154 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 155/555] reset: scmi: Set the device for the reset controller Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 157/555] drm/msm: Fix a lock leak in msm_ioctl_gem_info_set_metadata() Greg Kroah-Hartman
                   ` (398 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Colton Lewis, Marc Zyngier,
	Sasha Levin

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

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

From: Colton Lewis <coltonlewis@google.com>

[ Upstream commit 7100185bdc1162eb2eca1dd20a036314e27f1561 ]

By default, init_desc() assigns the shared irq_desc_lock_class lockdep
key to desc->lock for every struct irq_desc. Device drivers that
register an IRQ affinity notifier establish a lock dependency chain of
&irq_desc_lock_class --> &pool->lock --> &p->pi_lock --> &rq->__lock
when irq_set_affinity_locked() calls schedule_work() while holding
desc->lock.

On GICv4 systems, scheduling out a KVM vCPU calls kvm_sched_out() ->
kvm_arch_vcpu_put() -> vgic_v3_put() -> vgic_v4_put() ->
its_make_vpe_non_resident() -> irq_set_vcpu_affinity() while holding the
scheduler runqueue lock (&rq->__lock). Acquiring the vPE doorbell IRQ's
desc->lock establishes &rq->__lock --> &irq_desc_lock_class, triggering
a lockdep circular locking splat:

  WARNING: possible circular locking dependency detected
  ------------------------------------------------------
  VCPU-0/109705 is trying to acquire lock:
  ffff0001e41e4cc8 (&irq_desc_lock_class){-.-.}-{2:2}, at: __irq_get_desc_lock+0x5c/0xb0

  but task is already holding lock:
  ffff00dad15fd260 (&rq->__lock){-.-.}-{2:2}, at: __schedule+0x23c/0x1850

  which lock already depends on the new lock.

  Chain exists of:
    &irq_desc_lock_class --> &p->pi_lock --> &rq->__lock

   Possible unsafe locking scenario:

         CPU0                    CPU1
         ----                    ----
    lock(&rq->__lock);
                                 lock(&p->pi_lock);
                                 lock(&rq->__lock);
    lock(&irq_desc_lock_class);

GICv4 vPE doorbell IRQs are internal to KVM and GICv4, set
IRQ_NO_BALANCING, and never register an affinity notifier or queue work
under desc->lock. However, under forced IRQ threading (threadirqs or
CONFIG_PREEMPT_RT), request_irq() creates an IRQ thread for the doorbell
handler, causing irq_set_affinity() -> irq_set_thread_affinity() in
vgic_v4_load() to call wake_up_process() under desc->lock and establish
a real desc->lock --> &p->pi_lock --> &rq->__lock dependency on the vPE
doorbell IRQ itself.

Mark vPE doorbell IRQs with irq_set_nothread() so they are never
force-threaded, and assign them a dedicated lockdep class in
its_alloc_vcpu_irqs() via irq_set_lockdep_class().

Fixes: 8e01d9a396e6 ("KVM: arm64: vgic-v4: Move the GICv4 residency flow to be driven by vcpu_load/put")
Signed-off-by: Colton Lewis <coltonlewis@google.com>
Link: https://patch.msgid.link/20261027180610.2840837-1-coltonlewis@google.com
Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/irqchip/irq-gic-v4.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/irqchip/irq-gic-v4.c b/drivers/irqchip/irq-gic-v4.c
index 1f6edd6e94e92..4f1f2d6eda00a 100644
--- a/drivers/irqchip/irq-gic-v4.c
+++ b/drivers/irqchip/irq-gic-v4.c
@@ -163,6 +163,8 @@ static void its_free_sgi_irqs(struct its_vm *vm);
 
 int its_alloc_vcpu_irqs(struct its_vm *vm)
 {
+	static struct lock_class_key vpe_irq_lock_class;
+	static struct lock_class_key vpe_irq_request_class;
 	int vpe_base_irq, i;
 
 	vm->fwnode = irq_domain_alloc_named_id_fwnode("GICv4-vpe",
@@ -189,6 +191,9 @@ int its_alloc_vcpu_irqs(struct its_vm *vm)
 	for (i = 0; i < vm->nr_vpes; i++) {
 		int ret;
 		vm->vpes[i]->irq = vpe_base_irq + i;
+		irq_set_lockdep_class(vm->vpes[i]->irq, &vpe_irq_lock_class,
+				      &vpe_irq_request_class);
+		irq_set_nothread(vm->vpes[i]->irq);
 		ret = its_alloc_vcpu_sgis(vm->vpes[i], i);
 		if (ret)
 			goto err_free_irqs;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 157/555] drm/msm: Fix a lock leak in msm_ioctl_gem_info_set_metadata()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (155 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 156/555] irqchip/gic-v4: Use a separate lockdep class for vPE doorbell IRQs Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 158/555] selftests: drivers/s390x: Select uvdevice tests using the target architecture Greg Kroah-Hartman
                   ` (397 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Bart Van Assche, Rob Clark,
	Sasha Levin

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

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

From: Bart Van Assche <bvanassche@acm.org>

[ Upstream commit 1e59855738454b14021b64115f0090eafc7526ae ]

If krealloc() fails, msm_ioctl_gem_info_set_metadata() returns without
unlocking the GEM object. Fix this by jumping to a new label that
unlocks the GEM object before the buffer is freed. This bug has been
detected by the Clang thread-safety analyzer.

Fixes: 1c8c354098ea ("drm/msm: Add error handling for krealloc in metadata setup")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Patchwork: https://patchwork.freedesktop.org/patch/763272/
Message-ID: <9671164f87138a0caf5c69b66129bbd6faf932f8.1793044688.git.bvanassche@acm.org>
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpu/drm/msm/msm_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index d924c0f286058..690530e09e1c7 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -572,13 +572,14 @@ static int msm_ioctl_gem_info_set_metadata(struct drm_gem_object *obj,
 		krealloc(msm_obj->metadata, metadata_size, GFP_KERNEL);
 	if (!new_metadata) {
 		ret = -ENOMEM;
-		goto out;
+		goto unlock;
 	}
 
 	msm_obj->metadata = new_metadata;
 	msm_obj->metadata_size = metadata_size;
 	memcpy(msm_obj->metadata, buf, metadata_size);
 
+unlock:
 	msm_gem_unlock(obj);
 
 out:
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 158/555] selftests: drivers/s390x: Select uvdevice tests using the target architecture
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (156 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 157/555] drm/msm: Fix a lock leak in msm_ioctl_gem_info_set_metadata() Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 159/555] phy: ingenic: fix unbalanced regulator disable in exit Greg Kroah-Hartman
                   ` (396 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sasha Levin, Steffen Eiden,
	Christian Borntraeger

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

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

From: Sasha Levin <sashal@kernel.org>

[ Upstream commit 62aef2c04e0e69a9b88affa74ff699ce5c4e8652 ]

The uvdevice Makefile decides whether to build its test from uname -m,
which describes the build host. A cross build for s390 on another host
therefore silently omits the test, while the non-s390 branch provides
no-op build and installation targets but no emit_tests target.

Select the test from the target ARCH when it is given and from the
host's SUBARCH otherwise, accepting both the s390 and s390x spellings,
and include lib.mk unconditionally so that other architectures build,
install and emit an empty runlist. ARCH itself is left unset so that a
native LLVM=1 build keeps using the compiler's native target.

Drop the include path derived from tools/arch/$(ARCH): the test only
needs asm/uvdevice.h from the installed kernel headers, and the path
does not exist for the s390x spelling.

Fixes: cbac924200b8 ("selftests: drivers/s390x: Add uvdevice tests")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 .../selftests/drivers/s390x/uvdevice/Makefile | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/tools/testing/selftests/drivers/s390x/uvdevice/Makefile b/tools/testing/selftests/drivers/s390x/uvdevice/Makefile
index 755d164384c46..586a9aa6fb158 100644
--- a/tools/testing/selftests/drivers/s390x/uvdevice/Makefile
+++ b/tools/testing/selftests/drivers/s390x/uvdevice/Makefile
@@ -1,20 +1,13 @@
 include ../../../../../build/Build.include
 
-UNAME_M := $(shell uname -m)
-
-ifneq ($(UNAME_M),s390x)
-nothing:
-.PHONY: all clean run_tests install
-.SILENT:
-else
+top_srcdir ?= ../../../../../..
+include $(top_srcdir)/scripts/subarch.include
+ARCH_PROCESSED := $(or $(ARCH),$(SUBARCH))
 
+ifneq (,$(filter s390 s390x,$(ARCH_PROCESSED)))
 TEST_GEN_PROGS := test_uvdevice
 
-top_srcdir ?= ../../../../../..
-LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include
-
-CFLAGS += -Wall -Werror -static $(KHDR_INCLUDES) -I$(LINUX_TOOL_ARCH_INCLUDE)
+CFLAGS += -Wall -Werror -static $(KHDR_INCLUDES)
+endif
 
 include ../../../lib.mk
-
-endif
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 159/555] phy: ingenic: fix unbalanced regulator disable in exit
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (157 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 158/555] selftests: drivers/s390x: Select uvdevice tests using the target architecture Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 160/555] phy: ti-pipe3: Fix ignored clock enable return value in init Greg Kroah-Hartman
                   ` (395 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Felix Gu, Manivannan Sadhasivam,
	Paul Cercueil, Olivier Louvignes, H. Nikolaus Schaller,
	Vinod Koul, Sasha Levin

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

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

From: Felix Gu <ustc.gu@gmail.com>

[ Upstream commit 71c1be5cc4e083852c8437bd6afcb99ee3050e8e ]

exit() and power_off() both disable vcc_supply, so the regulator
gets disabled twice for every power cycle, causing an unbalanced
disable WARN.

Drop the regulator_disable() call from the exit callback and leave
the regulator to the power_on/power_off pair.

Fixes: 31de313dfdcf ("PHY: Ingenic: Add USB PHY driver using generic PHY framework.")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Reviewed-by: Paul Cercueil <paul@crapouillou.net>
Tested-by: Olivier Louvignes <olivier@mgcrea.io>
Reviewed-By: H. Nikolaus Schaller <hns@goldelico.com>
Link: https://patch.msgid.link/20260906-ingenic-v1-1-2311f3df8ddc@gmail.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/phy/ingenic/phy-ingenic-usb.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/phy/ingenic/phy-ingenic-usb.c b/drivers/phy/ingenic/phy-ingenic-usb.c
index eb2721f72a4c1..35984dd8a1bd7 100644
--- a/drivers/phy/ingenic/phy-ingenic-usb.c
+++ b/drivers/phy/ingenic/phy-ingenic-usb.c
@@ -124,7 +124,6 @@ static int ingenic_usb_phy_exit(struct phy *phy)
 	struct ingenic_usb_phy *priv = phy_get_drvdata(phy);
 
 	clk_disable_unprepare(priv->clk);
-	regulator_disable(priv->vcc_supply);
 
 	return 0;
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 160/555] phy: ti-pipe3: Fix ignored clock enable return value in init
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (158 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 159/555] phy: ingenic: fix unbalanced regulator disable in exit Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 161/555] phy: ti: pipe3: Fix clock resource leak on probe errors Greg Kroah-Hartman
                   ` (394 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Manivannan Sadhasivam, Hongling Zeng,
	Vinod Koul, Sasha Levin

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

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

From: Hongling Zeng <zenghongling@kylinos.cn>

[ Upstream commit 64207b5bc6be7db5e75ba9b7eb271dbda30834e5 ]

ti_pipe3_init() ignores the return value of ti_pipe3_enable_clocks(),
which can lead to:

1. Unclocked hardware access if clock enable fails
2. Unbalanced clock disables in error paths

ti_pipe3_enable_clocks() returns an error code when clock enable fails
and rolls back any partially enabled clocks. If we ignore this error
and continue, we access hardware without proper clocking, which can
cause bus errors.

Additionally, if we reach error paths later in the function and call
ti_pipe3_disable_clocks(), we'll be disabling already-disabled clocks,
causing unbalanced disable warnings.

Fix this by checking the return value of ti_pipe3_enable_clocks()
and returning early if it fails.

Fixes: 234738ea3390 ("phy: ti-pipe3: move clk initialization to a separate function")
Reported-by: Sashiko AI <sashiko@kernel.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
Link: https://patch.msgid.link/20260909122630.1313205-2-zenghongling@kylinos.cn
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/phy/ti/phy-ti-pipe3.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/ti/phy-ti-pipe3.c b/drivers/phy/ti/phy-ti-pipe3.c
index 8e94d2c6e266a..91604c96f2294 100644
--- a/drivers/phy/ti/phy-ti-pipe3.c
+++ b/drivers/phy/ti/phy-ti-pipe3.c
@@ -498,9 +498,12 @@ static int ti_pipe3_init(struct phy *x)
 {
 	struct ti_pipe3 *phy = phy_get_drvdata(x);
 	u32 val;
-	int ret = 0;
+	int ret;
+
+	ret = ti_pipe3_enable_clocks(phy);
+	if (ret)
+		return ret;
 
-	ti_pipe3_enable_clocks(phy);
 	/*
 	 * Set pcie_pcs register to 0x96 for proper functioning of phy
 	 * as recommended in AM572x TRM SPRUHZ6, section 18.5.2.2, table
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 161/555] phy: ti: pipe3: Fix clock resource leak on probe errors
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (159 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 160/555] phy: ti-pipe3: Fix ignored clock enable return value in init Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 162/555] phy: ti-pipe3: Fix EPROBE_DEFER handling for clock resources Greg Kroah-Hartman
                   ` (393 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Hongling Zeng, Manivannan Sadhasivam,
	Vinod Koul, Sasha Levin

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

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

From: Hongling Zeng <zenghongling@kylinos.cn>

[ Upstream commit 6dc01e3516d79cf4d690d892499a0bd08a14285b ]

When devm_phy_create() or devm_of_phy_provider_register() fails,
the refclk that was enabled earlier is not disabled, causing a
resource leak.

Fix this by adding an error handling path to disable the clock
when these functions fail.

Fixes: 234738ea3390 ("phy: ti-pipe3: move clk initialization to a separate function")
Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Link: https://patch.msgid.link/20260909122630.1313205-3-zenghongling@kylinos.cn
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/phy/ti/phy-ti-pipe3.c | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/drivers/phy/ti/phy-ti-pipe3.c b/drivers/phy/ti/phy-ti-pipe3.c
index 91604c96f2294..de0c045f655c0 100644
--- a/drivers/phy/ti/phy-ti-pipe3.c
+++ b/drivers/phy/ti/phy-ti-pipe3.c
@@ -834,21 +834,39 @@ static int ti_pipe3_probe(struct platform_device *pdev)
 	 */
 	if (phy->mode == PIPE3_MODE_SATA) {
 		if (!IS_ERR(phy->refclk)) {
-			clk_prepare_enable(phy->refclk);
+			ret = clk_prepare_enable(phy->refclk);
+			if (ret) {
+				dev_err(dev, "Failed to enable refclk %d\n", ret);
+				goto err_pm_disable;
+			}
 			phy->sata_refclk_enabled = true;
 		}
 	}
 
 	generic_phy = devm_phy_create(dev, NULL, &ops);
-	if (IS_ERR(generic_phy))
-		return PTR_ERR(generic_phy);
+	if (IS_ERR(generic_phy)) {
+		ret = PTR_ERR(generic_phy);
+		goto err_clk_disable;
+	}
 
 	phy_set_drvdata(generic_phy, phy);
 
 	ti_pipe3_power_off(generic_phy);
 
 	phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
-	return PTR_ERR_OR_ZERO(phy_provider);
+	if (IS_ERR(phy_provider)) {
+		ret = PTR_ERR(phy_provider);
+		goto err_clk_disable;
+	}
+
+	return 0;
+
+err_clk_disable:
+	if (phy->sata_refclk_enabled)
+		clk_disable_unprepare(phy->refclk);
+err_pm_disable:
+	pm_runtime_disable(dev);
+	return ret;
 }
 
 static void ti_pipe3_remove(struct platform_device *pdev)
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 162/555] phy: ti-pipe3: Fix EPROBE_DEFER handling for clock resources
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (160 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 161/555] phy: ti: pipe3: Fix clock resource leak on probe errors Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 163/555] phy: ti-pipe3: Fix clock leaks in init/exit error paths Greg Kroah-Hartman
                   ` (392 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Manivannan Sadhasivam, Hongling Zeng,
	Vinod Koul, Sasha Levin

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

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

From: Hongling Zeng <zenghongling@kylinos.cn>

[ Upstream commit aeb637c73631851de0965514151f7ff7bc13f940 ]

ti_pipe3_get_clk() has two issues with -EPROBE_DEFER error handling:

1. When devm_clk_get() for sysclk fails, the function returns -EINVAL
   instead of propagating the actual error code. This masks -EPROBE_DEFER
   to -EINVAL, breaking the probe deferral mechanism and causing permanent
   driver initialization failure on systems with non-deterministic probe
   ordering.

2. For SATA PHY refclk, the function ignores all errors to support older
   DTBs missing the refclk property. However, this incorrectly ignores
   -EPROBE_DEFER as well, causing the driver to proceed without waiting
   for the clock provider to become available.

Fix both issues:
- Return PTR_ERR(phy->sys_clk) instead of -EINVAL to propagate all
  error codes including -EPROBE_DEFER
- Use devm_clk_get_optional() for SATA refclk to handle optional
  clocks while propagating -EPROBE_DEFER and other errors

Fixes: a70143bbef6b ("drivers: phy: usb3/pipe3: Adapt pipe3 driver to Generic PHY Framework")
Fixes: 7f33912d2978 ("phy: ti-pipe3: Fix SATA across suspend/resume")
Suggested-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Link: https://patch.msgid.link/20260909122630.1313205-4-zenghongling@kylinos.cn
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/phy/ti/phy-ti-pipe3.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/drivers/phy/ti/phy-ti-pipe3.c b/drivers/phy/ti/phy-ti-pipe3.c
index de0c045f655c0..b2eef24dcd798 100644
--- a/drivers/phy/ti/phy-ti-pipe3.c
+++ b/drivers/phy/ti/phy-ti-pipe3.c
@@ -608,14 +608,20 @@ static int ti_pipe3_get_clk(struct ti_pipe3 *phy)
 	struct clk *clk;
 	struct device *dev = phy->dev;
 
-	phy->refclk = devm_clk_get(dev, "refclk");
+	/*
+	 * refclk is optional for SATA PHY to support older DTBs, but
+	 * required for other modes. Use devm_clk_get_optional() for SATA
+	 * which returns NULL for -ENOENT, allowing us to propagate all
+	 * other errors including -EPROBE_DEFER.
+	 */
+	if (phy->mode == PIPE3_MODE_SATA)
+		phy->refclk = devm_clk_get_optional(dev, "refclk");
+	else
+		phy->refclk = devm_clk_get(dev, "refclk");
+
 	if (IS_ERR(phy->refclk)) {
-		dev_err(dev, "unable to get refclk\n");
-		/* older DTBs have missing refclk in SATA PHY
-		 * so don't bail out in case of SATA PHY.
-		 */
-		if (phy->mode != PIPE3_MODE_SATA)
-			return PTR_ERR(phy->refclk);
+		return dev_err_probe(dev, PTR_ERR(phy->refclk),
+				"unable to get refclk\n");
 	}
 
 	if (phy->mode != PIPE3_MODE_SATA) {
@@ -631,8 +637,8 @@ static int ti_pipe3_get_clk(struct ti_pipe3 *phy)
 	if (phy->mode != PIPE3_MODE_PCIE || phy->phy_power_syscon) {
 		phy->sys_clk = devm_clk_get(dev, "sysclk");
 		if (IS_ERR(phy->sys_clk)) {
-			dev_err(dev, "unable to get sysclk\n");
-			return -EINVAL;
+			return dev_err_probe(dev, PTR_ERR(phy->sys_clk),
+					"unable to get sysclk\n");
 		}
 	}
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 163/555] phy: ti-pipe3: Fix clock leaks in init/exit error paths
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (161 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 162/555] phy: ti-pipe3: Fix EPROBE_DEFER handling for clock resources Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 164/555] ksmbd: sign the last response of a compound that ends early Greg Kroah-Hartman
                   ` (391 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Hongling Zeng, Manivannan Sadhasivam,
	Vinod Koul, Sasha Levin

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

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

From: Hongling Zeng <zenghongling@kylinos.cn>

[ Upstream commit 2be6a65608a5e32b2be6f5da843b1f29f1091098 ]

Two paths return without disabling the clocks that ti_pipe3_init()
has just enabled, leaking clock enable references:

1. In ti_pipe3_init(), when regmap_update_bits() fails for PCIe mode,
   the function returns the error without calling
   ti_pipe3_disable_clocks(). The clocks stay permanently enabled
   since the PHY framework won't invoke the .exit callback on init
   failure.

2. In ti_pipe3_exit(), when the PHY is in SATA mode without
   dpll_reset_syscon, the function returns 0 early to avoid powering
   down the SATA DPLL (Errata i783), which also skips the
   ti_pipe3_disable_clocks() at the end of the function. Every
   init/exit cycle therefore leaks the clock enable reference taken
   in ti_pipe3_init().

Fix both by adding the missing ti_pipe3_disable_clocks() calls,
consistent with how the DPLL program error path handles cleanup.

Fixes: 234738ea3390 ("phy: ti-pipe3: move clk initialization to a separate function")
Fixes: 0a0830feb2ad ("phy: ti-pipe3: fix suspend")
Reported-by: Sashiko AI <sashiko@kernel.org>
Closes: https://lore.kernel.org/all/20260518023657.41852C2BCB0@smtp.kernel.org/
Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Link: https://patch.msgid.link/20260909122630.1313205-5-zenghongling@kylinos.cn
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/phy/ti/phy-ti-pipe3.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/ti/phy-ti-pipe3.c b/drivers/phy/ti/phy-ti-pipe3.c
index b2eef24dcd798..6a5e52af46a2c 100644
--- a/drivers/phy/ti/phy-ti-pipe3.c
+++ b/drivers/phy/ti/phy-ti-pipe3.c
@@ -518,6 +518,8 @@ static int ti_pipe3_init(struct phy *x)
 		val = 0x96 << OMAP_CTRL_PCIE_PCS_DELAY_COUNT_SHIFT;
 		ret = regmap_update_bits(phy->pcs_syscon, phy->pcie_pcs_reg,
 					 PCIE_PCS_MASK, val);
+		if (ret)
+			ti_pipe3_disable_clocks(phy);
 		return ret;
 	}
 
@@ -555,8 +557,10 @@ static int ti_pipe3_exit(struct phy *x)
 	/* If dpll_reset_syscon is not present we wont power down SATA DPLL
 	 * due to Errata i783
 	 */
-	if (phy->mode == PIPE3_MODE_SATA && !phy->dpll_reset_syscon)
+	if (phy->mode == PIPE3_MODE_SATA && !phy->dpll_reset_syscon) {
+		ti_pipe3_disable_clocks(phy);
 		return 0;
+	}
 
 	/* PCIe doesn't have internal DPLL */
 	if (phy->mode != PIPE3_MODE_PCIE) {
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 164/555] ksmbd: sign the last response of a compound that ends early
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (162 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 163/555] phy: ti-pipe3: Fix clock leaks in init/exit error paths Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 165/555] scsi: lpfc: Fix race conditions in ELS retry handling Greg Kroah-Hartman
                   ` (390 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Michail Andreas Michalopoulos,
	Ian Bridges, Namjae Jeon, Sasha Levin

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

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

From: Michail Andreas Michalopoulos <mike.michalo@gmail.com>

[ Upstream commit 3d322b98b56628ee69e4528a52cc1f445880fa17 ]

is_chained_smb2_message() ends a compound early when the next command
does not fit in the request, or its response would not fit in the
response buffer. Since commit e2b76ab8b5c9 ("ksmbd: add support for
read compound"), __handle_ksmbd_work() then signs ksmbd_resp_buf_curr(),
which is_chained_smb2_message() only moves to the response of the
command just processed when it chains to the next command or reaches
the last one. On an early end it returns without moving it, so for a
command after the first, the previous command's response was signed
again, over the iovecs of both responses, and the response of this
command was left unsigned. Neither signature verifies at the client.

Handle an early end as the end of the compound: pad the response to 8
bytes and make it the current one. smb2_allocate_rsp_buf() leaves room
for that padding in the response buffer of a compound.

Only a compound whose NextCommand points past the end of the message,
or whose responses fill the response buffer, takes this path. Sashiko
pointed it out in its review of an unrelated series.

An AI assistant was used to draft the patch and as an independent
reviewer.

Fixes: e2b76ab8b5c9 ("ksmbd: add support for read compound")
Signed-off-by: Michail Andreas Michalopoulos <mike.michalo@gmail.com>
Reviewed-by: Ian Bridges <icb@fastmail.org>
Tested-by: Ian Bridges <icb@fastmail.org>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/smb/server/smb2pdu.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index d919dd0333624..05eaa59f4750c 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -468,22 +468,27 @@ bool is_chained_smb2_message(struct ksmbd_work *work)
 		    get_rfc1002_len(work->request_buf)) {
 			pr_err("next command(%u) offset exceeds smb msg size\n",
 			       next_cmd);
-			return false;
+			goto last_rsp;
 		}
 
 		if ((u64)get_rfc1002_len(work->response_buf) + MAX_CIFS_SMALL_BUFFER_SIZE >
 		    work->response_sz) {
 			pr_err("next response offset exceeds response buffer size\n");
-			return false;
+			goto last_rsp;
 		}
 
 		ksmbd_debug(SMB, "got SMB2 chained command\n");
 		init_chained_smb2_rsp(work);
 		return true;
-	} else if (work->next_smb2_rcv_hdr_off) {
+	}
+
+last_rsp:
+	if (work->next_smb2_rcv_hdr_off) {
 		/*
-		 * This is last request in chained command,
-		 * align response to 8 byte
+		 * This is the last response of a compound, also when the
+		 * compound ends early because the next command does not fit.
+		 * Align it to 8 bytes and make it the current response, which
+		 * is the one the caller signs.
 		 */
 		len = ALIGN(get_rfc1002_len(work->response_buf), 8);
 		len = len - get_rfc1002_len(work->response_buf);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 165/555] scsi: lpfc: Fix race conditions in ELS retry handling
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (163 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 164/555] ksmbd: sign the last response of a compound that ends early Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 166/555] scsi: ch: Remove the minor from ch_index_idr after device_destroy() Greg Kroah-Hartman
                   ` (389 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Kyle Mahlkuch, Hannes Reinecke,
	Paul Ely, Martin K. Petersen (Oracle), Sasha Levin

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

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

From: Kyle Mahlkuch <kmahlkuc@linux.ibm.com>

[ Upstream commit 7470a1f2a84d68d177560b78388e640771b6b94a ]

This patch addresses a race condition in the lpfc driver's ELS retry event
handling that can lead to a use-after-free in the
lpfc_cancel_retry_delay_tmo(), where the NLP_DELAY_TMO flag is cleared
before acquiring the lock to check if the retry event is queued. This
creates a window where the timer can be rescheduled and fire, causing both
the cancel path and the worker thread to release the same reference,
resulting in a double-put and use-after-free.

Moved capture ndlp and clear evt_arg1 under hbalock while dequeuing
LPFC_EVT_ELS_RETRY in lpfc_work_list_done().

Signed-off-by: Kyle Mahlkuch <kmahlkuc@linux.ibm.com>
Fixes: e47c9093531d ("[SCSI] lpfc 8.2.5 : Correct ndlp referencing issues")
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Paul Ely <pely@broadcom.com>
Link: https://patch.msgid.link/dcea48dd-f76c-4bb0-9275-c12ef9bd78a2@linux.ibm.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/scsi/lpfc/lpfc_els.c     | 29 +++++++++++++++++++++++------
 drivers/scsi/lpfc/lpfc_hbadisc.c | 11 ++++++++++-
 2 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 36ee9f51a8fa2..3ab448c671bf9 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -4346,18 +4346,35 @@ lpfc_issue_els_edc(struct lpfc_vport *vport, uint8_t retry)
 void
 lpfc_cancel_retry_delay_tmo(struct lpfc_vport *vport, struct lpfc_nodelist *nlp)
 {
-	struct lpfc_work_evt *evtp;
+	struct lpfc_hba *phba = vport->phba;
+	struct lpfc_work_evt *evtp = &nlp->els_retry_evt;
+	struct lpfc_nodelist *arg_ndlp = NULL;
+	unsigned long flags;
 
 	if (!test_and_clear_bit(NLP_DELAY_TMO, &nlp->nlp_flag))
 		return;
 	del_timer_sync(&nlp->nlp_delayfunc);
 	nlp->nlp_last_elscmd = 0;
-	if (!list_empty(&nlp->els_retry_evt.evt_listp)) {
-		list_del_init(&nlp->els_retry_evt.evt_listp);
-		/* Decrement nlp reference count held for the delayed retry */
-		evtp = &nlp->els_retry_evt;
-		lpfc_nlp_put((struct lpfc_nodelist *)evtp->evt_arg1);
+
+	/*
+	 * If retry event is queued, remove it under lock and consume
+	 * its payload to prevent double-put. The event holds a reference
+	 * to the nodelist that must be released exactly once.
+	 */
+	spin_lock_irqsave(&phba->hbalock, flags);
+	if (!list_empty(&evtp->evt_listp)) {
+		list_del_init(&evtp->evt_listp);
+		/* Take local copy and clear to prevent reuse */
+		arg_ndlp = (struct lpfc_nodelist *)evtp->evt_arg1;
+		evtp->evt_arg1 = NULL;
+		smp_wmb(); /* Ensure NULL visible before unlock */
 	}
+	spin_unlock_irqrestore(&phba->hbalock, flags);
+
+	/* Drop the event-held reference outside the lock */
+	if (arg_ndlp)
+		lpfc_nlp_put(arg_ndlp);
+
 	if (test_and_clear_bit(NLP_NPR_2B_DISC, &nlp->nlp_flag)) {
 		if (vport->num_disc_nodes) {
 			if (vport->port_state < LPFC_VPORT_READY) {
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index 3ba515c1fe3a1..555295018867f 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -843,12 +843,21 @@ lpfc_work_list_done(struct lpfc_hba *phba)
 	while (!list_empty(&phba->work_list)) {
 		list_remove_head((&phba->work_list), evtp, typeof(*evtp),
 				 evt_listp);
+		/*
+		 * The ELS retry event can be requeued by lpfc_els_retry_delay()
+		 * as soon as hbalock is dropped. Consume the payload within the
+		 * hbalock to prevent reuse or double-put.
+		 */
+		if (evtp->evt == LPFC_EVT_ELS_RETRY) {
+			ndlp = (struct lpfc_nodelist *)(evtp->evt_arg1);
+			evtp->evt_arg1 = NULL;
+		}
 		spin_unlock_irq(&phba->hbalock);
 		hba_pci_err = test_bit(HBA_PCI_ERR, &phba->bit_flags);
 		free_evt = 1;
 		switch (evtp->evt) {
 		case LPFC_EVT_ELS_RETRY:
-			ndlp = (struct lpfc_nodelist *) (evtp->evt_arg1);
+			/* ndlp was already captured under hbalock */
 			if (!hba_pci_err) {
 				lpfc_els_retry_delay_handler(ndlp);
 				free_evt = 0; /* evt is part of ndlp */
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 166/555] scsi: ch: Remove the minor from ch_index_idr after device_destroy()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (164 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 165/555] scsi: lpfc: Fix race conditions in ELS retry handling Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 167/555] phy: rockchip: snps-pcie3: Raise the SRAM init timeout Greg Kroah-Hartman
                   ` (388 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Changyul Lee, Laurence Oberman,
	Martin K. Petersen (Oracle), Sasha Levin

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

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

From: Changyul Lee <lcy8047@gmail.com>

[ Upstream commit 9f9e0b1e5399045982788a954d3461de894e40c7 ]

ch_remove() removes the minor from ch_index_idr before device_destroy()
removes the "sch<N>" device. A changer probed in between can get the same
minor, and its device_create() fails:

  sysfs: cannot create duplicate filename '/class/scsi_changer/sch0'
  ...
  ch 1:0:0:0: ch0: device_create failed

The new changer is then not attached.

Replace the IDR entry with NULL instead, so that ch_open() still fails with
-ENXIO for the changer being removed, and remove the minor after
device_destroy().

Fixes: da707c54c342 ("[SCSI] ch: fix device minor number management bug")
Signed-off-by: Changyul Lee <lcy8047@gmail.com>
Reviewed-by: Laurence Oberman <loberman@redhat.com>
Link: https://patch.msgid.link/20261109160651.986356-1-lcy8047@gmail.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/scsi/ch.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index 95bbcc497de9c..711d02353ae7b 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -960,11 +960,15 @@ static int ch_remove(struct device *dev)
 	scsi_changer *ch = dev_get_drvdata(dev);
 
 	spin_lock(&ch_index_lock);
-	idr_remove(&ch_index_idr, ch->minor);
+	idr_replace(&ch_index_idr, NULL, ch->minor);
 	dev_set_drvdata(dev, NULL);
 	spin_unlock(&ch_index_lock);
 
 	device_destroy(&ch_sysfs_class, MKDEV(SCSI_CHANGER_MAJOR, ch->minor));
+
+	spin_lock(&ch_index_lock);
+	idr_remove(&ch_index_idr, ch->minor);
+	spin_unlock(&ch_index_lock);
 	scsi_device_put(ch->device);
 	kref_put(&ch->ref, ch_destroy);
 	return 0;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 167/555] phy: rockchip: snps-pcie3: Raise the SRAM init timeout
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (165 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 166/555] scsi: ch: Remove the minor from ch_index_idr after device_destroy() Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 168/555] Bluetooth: mgmt: Fix read_index_list() buffer overflow Greg Kroah-Hartman
                   ` (387 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sebastian Reichel,
	Manivannan Sadhasivam, Shawn Lin, Vinod Koul, Sasha Levin

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

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

From: Shawn Lin <shawn.lin@rock-chips.com>

[ Upstream commit 7c2a2268bd3ddf3b2c674ebb7557ae24c22309d7 ]

The SRAM initialization of the PCIe3 PHY may take longer than the 500us
currently allowed, especially on a slow power-up such as at low
temperature. In that case the driver reports

  lock failed 0x..., check input refclk and power supply

even though the input refclk and power supply are fine.

Raise the timeout to 20ms and use a named constant for it, applied to
both the RK3568 and RK3588 paths.

A non-zero sleep interval (1ms) is passed to the polling helpers so the
CPU is yielded between reads. With sleep_us == 0 the helpers tight-loop,
which would otherwise burn the CPU during the now much longer wait.

Fixes: 2e9bffc4f713 ("phy: rockchip: Support PCIe v3")
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Link: https://patch.msgid.link/20261102005129.3745527-1-shawn.lin@rock-chips.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/phy/rockchip/phy-rockchip-snps-pcie3.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/phy/rockchip/phy-rockchip-snps-pcie3.c b/drivers/phy/rockchip/phy-rockchip-snps-pcie3.c
index 4e8ffd173096a..ce7d8db2a7c5f 100644
--- a/drivers/phy/rockchip/phy-rockchip-snps-pcie3.c
+++ b/drivers/phy/rockchip/phy-rockchip-snps-pcie3.c
@@ -18,6 +18,9 @@
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 #include <linux/reset.h>
+#include <linux/units.h>
+
+#define RK_PCIE_SRAM_INIT_TIMEOUT_US		(20 * USEC_PER_MSEC)
 
 /* Register for RK3568 */
 #define GRF_PCIE30PHY_CON1			0x4
@@ -127,7 +130,7 @@ static int rockchip_p3phy_rk3568_init(struct rockchip_p3phy_priv *priv)
 	ret = regmap_read_poll_timeout(priv->phy_grf,
 				       GRF_PCIE30PHY_STATUS0,
 				       reg, SRAM_INIT_DONE(reg),
-				       0, 500);
+				       1000, RK_PCIE_SRAM_INIT_TIMEOUT_US);
 	if (ret)
 		dev_err(&priv->phy->dev, "%s: lock failed 0x%x, check input refclk and power supply\n",
 		       __func__, reg);
@@ -187,11 +190,11 @@ static int rockchip_p3phy_rk3588_init(struct rockchip_p3phy_priv *priv)
 	ret = regmap_read_poll_timeout(priv->phy_grf,
 				       RK3588_PCIE3PHY_GRF_PHY0_STATUS1,
 				       reg, RK3588_SRAM_INIT_DONE(reg),
-				       0, 500);
+				       1000, RK_PCIE_SRAM_INIT_TIMEOUT_US);
 	ret |= regmap_read_poll_timeout(priv->phy_grf,
 					RK3588_PCIE3PHY_GRF_PHY1_STATUS1,
 					reg, RK3588_SRAM_INIT_DONE(reg),
-					0, 500);
+					1000, RK_PCIE_SRAM_INIT_TIMEOUT_US);
 	if (ret)
 		dev_err(&priv->phy->dev, "lock failed 0x%x, check input refclk and power supply\n",
 			reg);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 168/555] Bluetooth: mgmt: Fix read_index_list() buffer overflow
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (166 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 167/555] phy: rockchip: snps-pcie3: Raise the SRAM init timeout Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 169/555] Bluetooth: hci_core: Take req_sync lock in hci_power_on() Greg Kroah-Hartman
                   ` (386 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
	Sasha Levin

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

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

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

[ Upstream commit cfdd650c5dabbd2f59a0e916aa8ef3f1965a3b4b ]

The first pass counts only configured controllers, but HCI_UNCONFIGURED
can change before the second pass, which may then write more entries than
were allocated. Size the buffer from the total number of controllers as
read_unconf_index_list() already does.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-7841362e-9b8f-465f-aa22-e99c315231e2
Fixes: 73d1df2a7a10 ("Bluetooth: Add support for Read Unconfigured Index List command")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/bluetooth/mgmt.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index fa91db7dab4f4..43ccc91ef7027 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -445,10 +445,8 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data,
 	read_lock(&hci_dev_list_lock);
 
 	count = 0;
-	list_for_each_entry(d, &hci_dev_list, list) {
-		if (!hci_dev_test_flag(d, HCI_UNCONFIGURED))
-			count++;
-	}
+	list_for_each_entry(d, &hci_dev_list, list)
+		count++;
 
 	rp_len = sizeof(*rp) + (2 * count);
 	rp = kmalloc(rp_len, GFP_ATOMIC);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 169/555] Bluetooth: hci_core: Take req_sync lock in hci_power_on()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (167 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 168/555] Bluetooth: mgmt: Fix read_index_list() buffer overflow Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 170/555] Bluetooth: hci_sync: Lock the lookup in hci_disable_ext_adv_instance_sync() Greg Kroah-Hartman
                   ` (385 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
	Sasha Levin

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

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

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

[ Upstream commit 6a296a4658124490d7dddd2b751e5f9ae5c5aec7 ]

hci_powered_update_sync() issues synchronous HCI commands but was called
without hci_req_sync_lock(), racing with other request users.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-1baf7393-3aeb-4fa5-806f-19cea743b9f3
Fixes: cf75ad8b41d2 ("Bluetooth: hci_sync: Convert MGMT_SET_POWERED")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/bluetooth/hci_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index d2fcccdf482e0..e42ba4743f25f 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -951,7 +951,9 @@ static void hci_power_on(struct work_struct *work)
 	    hci_dev_test_flag(hdev, HCI_MGMT) &&
 	    hci_dev_test_and_clear_flag(hdev, HCI_AUTO_OFF)) {
 		cancel_delayed_work(&hdev->power_off);
+		hci_req_sync_lock(hdev);
 		err = hci_powered_update_sync(hdev);
+		hci_req_sync_unlock(hdev);
 		mgmt_power_on(hdev, err);
 		return;
 	}
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 170/555] Bluetooth: hci_sync: Lock the lookup in hci_disable_ext_adv_instance_sync()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (168 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 169/555] Bluetooth: hci_core: Take req_sync lock in hci_power_on() Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 171/555] Bluetooth: hci_sync: Hold hdev->lock in hci_schedule_adv_instance_sync() Greg Kroah-Hartman
                   ` (384 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
	Sasha Levin

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

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

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

[ Upstream commit 8984b72f9508b2d03c58a82d73881b5e1e5f5bc4 ]

hci_disable_ext_adv_instance_sync() calls hci_find_adv_instance() and
dereferences the instance without hdev->lock, racing with the removal of
the instance. Look the instance up under the lock and only use the values
copied while it is held.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-a364929c-cd00-492a-a83c-5425d042b09f
Fixes: cba6b758711c ("Bluetooth: hci_sync: Make use of hci_cmd_sync_queue set 2")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/bluetooth/hci_sync.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 3793fc359a9ff..e0d06338f7ac4 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -1250,16 +1250,26 @@ static int hci_disable_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance)
 	struct hci_cp_ext_adv_set *set;
 	u8 data[sizeof(*cp) + sizeof(*set) * 1];
 	u8 size;
-	struct adv_info *adv = NULL;
+	u8 handle = instance;
 
 	/* If request specifies an instance that doesn't exist, fail */
 	if (instance > 0) {
+		struct adv_info *adv;
+		bool enabled = false;
+
+		hci_dev_lock(hdev);
 		adv = hci_find_adv_instance(hdev, instance);
+		if (adv) {
+			enabled = adv->enabled;
+			handle = adv->handle;
+		}
+		hci_dev_unlock(hdev);
+
 		if (!adv)
 			return -EINVAL;
 
 		/* If not enabled there is nothing to do */
-		if (!adv->enabled)
+		if (!enabled)
 			return 0;
 	}
 
@@ -1272,7 +1282,7 @@ static int hci_disable_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance)
 	cp->num_of_sets = !!instance;
 	cp->enable = 0x00;
 
-	set->handle = adv ? adv->handle : instance;
+	set->handle = handle;
 
 	size = sizeof(*cp) + sizeof(*set) * cp->num_of_sets;
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 171/555] Bluetooth: hci_sync: Hold hdev->lock in hci_schedule_adv_instance_sync()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (169 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 170/555] Bluetooth: hci_sync: Lock the lookup in hci_disable_ext_adv_instance_sync() Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 172/555] Bluetooth: hci_event: Fix not using key encryption size when its known Greg Kroah-Hartman
                   ` (383 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
	Sasha Levin

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

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

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

[ Upstream commit c592dfe9637c65eeaff4c9f6fd869f39ad7ae472 ]

The advertising instance returned by hci_find_adv_instance() was
dereferenced without hdev->lock and could be freed concurrently.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-616b1f8e-06ec-4634-a907-5eb4e82f66df
Fixes: cba6b758711c ("Bluetooth: hci_sync: Make use of hci_cmd_sync_queue set 2")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/bluetooth/hci_sync.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index e0d06338f7ac4..f89bd2c365554 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -2174,9 +2174,13 @@ int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance,
 	if (hdev->adv_instance_timeout)
 		return -EBUSY;
 
+	hci_dev_lock(hdev);
+
 	adv = hci_find_adv_instance(hdev, instance);
-	if (!adv)
+	if (!adv) {
+		hci_dev_unlock(hdev);
 		return -ENOENT;
+	}
 
 	/* A zero timeout means unlimited advertising. As long as there is
 	 * only one instance, duration should be ignored. We still set a timeout
@@ -2206,6 +2210,8 @@ int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance,
 					       msecs_to_jiffies(timeout * 1000));
 	}
 
+	hci_dev_unlock(hdev);
+
 	/* If we're just re-scheduling the same instance again then do not
 	 * execute any HCI commands. This happens when a single instance is
 	 * being advertised.
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 172/555] Bluetooth: hci_event: Fix not using key encryption size when its known
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (170 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 171/555] Bluetooth: hci_sync: Hold hdev->lock in hci_schedule_adv_instance_sync() Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 173/555] Bluetooth: SMP: Serialize link key updates from smp_notify_keys() Greg Kroah-Hartman
                   ` (382 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Luiz Augusto von Dentz, Sasha Levin

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

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

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

[ Upstream commit c82b6357a5465a3222780ac5d3edcdfb02208cc3 ]

This fixes the regression introduced by 50c1241e6a8a ("Bluetooth: l2cap:
Check encryption key size on incoming connection") introduced a check for
l2cap_check_enc_key_size which checks for hcon->enc_key_size which may
not be initialized if HCI_OP_READ_ENC_KEY_SIZE is still pending.

If the key encryption size is known, due previously reading it using
HCI_OP_READ_ENC_KEY_SIZE, then store it as part of link_key/smp_ltk
structures so the next time the encryption is changed their values are
used as conn->enc_key_size thus avoiding the racing against
HCI_OP_READ_ENC_KEY_SIZE.

Now that the enc_size is stored as part of key the information the code
then attempts to check that there is no downgrade of security if
HCI_OP_READ_ENC_KEY_SIZE returns a value smaller than what has been
previously stored.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=220061
Link: https://bugzilla.kernel.org/show_bug.cgi?id=220063
Fixes: 522e9ed157e3 ("Bluetooth: l2cap: Check encryption key size on incoming connection")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Stable-dep-of: e428ab70fb33 ("Bluetooth: SMP: Serialize link key updates from smp_notify_keys()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/net/bluetooth/hci_core.h |  1 +
 net/bluetooth/hci_conn.c         | 24 +++++++++++
 net/bluetooth/hci_event.c        | 73 ++++++++++++++++++--------------
 3 files changed, 67 insertions(+), 31 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 3dad216418e4d..83a50c0aab274 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -1831,6 +1831,7 @@ struct hci_conn_params *hci_pend_le_action_lookup(struct list_head *list,
 void hci_uuids_clear(struct hci_dev *hdev);
 
 void hci_link_keys_clear(struct hci_dev *hdev);
+u8 *hci_conn_key_enc_size(struct hci_conn *conn);
 struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr);
 struct link_key *hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn,
 				  bdaddr_t *bdaddr, u8 *val, u8 type,
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 0f1d7c623f9f1..10a7eedfe4a62 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -3068,3 +3068,27 @@ int hci_abort_conn(struct hci_conn *conn, u8 reason)
 		hci_conn_put(conn);
 	return (err == -EEXIST) ? 0 : err;
 }
+
+u8 *hci_conn_key_enc_size(struct hci_conn *conn)
+{
+	if (conn->type == ACL_LINK) {
+		struct link_key *key;
+
+		key = hci_find_link_key(conn->hdev, &conn->dst);
+		if (!key)
+			return NULL;
+
+		return &key->pin_len;
+	} else if (conn->type == LE_LINK) {
+		struct smp_ltk *ltk;
+
+		ltk = hci_find_ltk(conn->hdev, &conn->dst, conn->dst_type,
+				   conn->role);
+		if (!ltk)
+			return NULL;
+
+		return &ltk->enc_size;
+	}
+
+	return NULL;
+}
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index f723210c52e53..db9164d735156 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -745,10 +745,17 @@ static u8 hci_cc_read_enc_key_size(struct hci_dev *hdev, void *data,
 			   handle);
 		conn->enc_key_size = 0;
 	} else {
+		u8 *key_enc_size = hci_conn_key_enc_size(conn);
+
 		conn->enc_key_size = rp->key_size;
 		status = 0;
 
-		if (conn->enc_key_size < hdev->min_enc_key_size) {
+		/* Attempt to check if the key size is too small or if it has
+		 * been downgraded from the last time it was stored as part of
+		 * the link_key.
+		 */
+		if (conn->enc_key_size < hdev->min_enc_key_size ||
+		    (key_enc_size && conn->enc_key_size < *key_enc_size)) {
 			/* As slave role, the conn->state has been set to
 			 * BT_CONNECTED and l2cap conn req might not be received
 			 * yet, at this moment the l2cap layer almost does
@@ -761,6 +768,10 @@ static u8 hci_cc_read_enc_key_size(struct hci_dev *hdev, void *data,
 			clear_bit(HCI_CONN_ENCRYPT, &conn->flags);
 			clear_bit(HCI_CONN_AES_CCM, &conn->flags);
 		}
+
+		/* Update the key encryption size with the connection one */
+		if (key_enc_size && *key_enc_size != conn->enc_key_size)
+			*key_enc_size = conn->enc_key_size;
 	}
 
 	hci_encrypt_cfm(conn, status);
@@ -3110,6 +3121,34 @@ static void hci_inquiry_result_evt(struct hci_dev *hdev, void *edata,
 	hci_dev_unlock(hdev);
 }
 
+static int hci_read_enc_key_size(struct hci_dev *hdev, struct hci_conn *conn)
+{
+	struct hci_cp_read_enc_key_size cp;
+	u8 *key_enc_size = hci_conn_key_enc_size(conn);
+
+	if (!read_key_size_capable(hdev)) {
+		conn->enc_key_size = HCI_LINK_KEY_SIZE;
+		return -EOPNOTSUPP;
+	}
+
+	bt_dev_dbg(hdev, "hcon %p", conn);
+
+	memset(&cp, 0, sizeof(cp));
+	cp.handle = cpu_to_le16(conn->handle);
+
+	/* If the key enc_size is already known, use it as conn->enc_key_size,
+	 * otherwise use hdev->min_enc_key_size so the likes of
+	 * l2cap_check_enc_key_size don't fail while waiting for
+	 * HCI_OP_READ_ENC_KEY_SIZE response.
+	 */
+	if (key_enc_size && *key_enc_size)
+		conn->enc_key_size = *key_enc_size;
+	else
+		conn->enc_key_size = hdev->min_enc_key_size;
+
+	return hci_send_cmd(hdev, HCI_OP_READ_ENC_KEY_SIZE, sizeof(cp), &cp);
+}
+
 static void hci_conn_complete_evt(struct hci_dev *hdev, void *data,
 				  struct sk_buff *skb)
 {
@@ -3213,23 +3252,11 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, void *data,
 		if (ev->encr_mode == 1 && !test_bit(HCI_CONN_ENCRYPT, &conn->flags) &&
 		    ev->link_type == ACL_LINK) {
 			struct link_key *key;
-			struct hci_cp_read_enc_key_size cp;
 
 			key = hci_find_link_key(hdev, &ev->bdaddr);
 			if (key) {
 				set_bit(HCI_CONN_ENCRYPT, &conn->flags);
-
-				if (!read_key_size_capable(hdev)) {
-					conn->enc_key_size = HCI_LINK_KEY_SIZE;
-				} else {
-					cp.handle = cpu_to_le16(conn->handle);
-					if (hci_send_cmd(hdev, HCI_OP_READ_ENC_KEY_SIZE,
-							 sizeof(cp), &cp)) {
-						bt_dev_err(hdev, "sending read key size failed");
-						conn->enc_key_size = HCI_LINK_KEY_SIZE;
-					}
-				}
-
+				hci_read_enc_key_size(hdev, conn);
 				hci_encrypt_cfm(conn, ev->status);
 			}
 		}
@@ -3669,24 +3696,8 @@ static void hci_encrypt_change_evt(struct hci_dev *hdev, void *data,
 
 	/* Try reading the encryption key size for encrypted ACL links */
 	if (!ev->status && ev->encrypt && conn->type == ACL_LINK) {
-		struct hci_cp_read_enc_key_size cp;
-
-		/* Only send HCI_Read_Encryption_Key_Size if the
-		 * controller really supports it. If it doesn't, assume
-		 * the default size (16).
-		 */
-		if (!read_key_size_capable(hdev)) {
-			conn->enc_key_size = HCI_LINK_KEY_SIZE;
-			goto notify;
-		}
-
-		cp.handle = cpu_to_le16(conn->handle);
-		if (hci_send_cmd(hdev, HCI_OP_READ_ENC_KEY_SIZE,
-				 sizeof(cp), &cp)) {
-			bt_dev_err(hdev, "sending read key size failed");
-			conn->enc_key_size = HCI_LINK_KEY_SIZE;
+		if (hci_read_enc_key_size(hdev, conn))
 			goto notify;
-		}
 
 		goto unlock;
 	}
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 173/555] Bluetooth: SMP: Serialize link key updates from smp_notify_keys()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (171 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 172/555] Bluetooth: hci_event: Fix not using key encryption size when its known Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 174/555] Bluetooth: SMP: Check smp_data before using SMP_DEV() Greg Kroah-Hartman
                   ` (381 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
	Sasha Levin

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

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

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

[ Upstream commit e428ab70fb3398e835e5d70ba4839e7c06583b83 ]

smp_notify_keys() runs from the L2CAP RX path without hdev->lock, yet
hci_add_link_key() and the debug key removal modify hdev->link_keys and
dereference entries returned by hci_find_link_key(), so a concurrent
unpair or Load Link Keys can free the entry being updated.

hdev->lock can't be taken there since it is ordered before the l2cap
channel lock held by the SMP receive path (see smp_user_confirm_reply()).
Add a dedicated link_keys_lock protecting the writers of hdev->link_keys
(add, remove and clear). SMP holds it while it adds the key, notifies
mgmt and removes a debug key, so the key can't go away meanwhile, and
the debug key removed by hci_link_key_notify_evt() is deleted by
reference with hci_del_link_key() since a lookup by address skips the
keys that are blocked.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-7482a666-d2a0-44a4-9e0d-05354860a5fa
Fixes: 6a77083af57f ("Bluetooth: Add support for LE SC key generation")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/net/bluetooth/hci_core.h |  6 ++++
 net/bluetooth/hci_core.c         | 62 +++++++++++++++++++++++++++++---
 net/bluetooth/hci_event.c        |  3 +-
 net/bluetooth/smp.c              | 11 ++++--
 4 files changed, 74 insertions(+), 8 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 83a50c0aab274..0599cc3a67ddc 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -552,6 +552,8 @@ struct hci_dev {
 	struct list_head	accept_list;
 	struct list_head	uuids;
 	struct list_head	link_keys;
+	/* Serializes the writers of link_keys, see hci_add_link_key() */
+	struct mutex		link_keys_lock;
 	struct list_head	long_term_keys;
 	struct list_head	identity_resolving_keys;
 	struct mutex		remote_oob_lock;
@@ -1831,6 +1833,10 @@ struct hci_conn_params *hci_pend_le_action_lookup(struct list_head *list,
 void hci_uuids_clear(struct hci_dev *hdev);
 
 void hci_link_keys_clear(struct hci_dev *hdev);
+struct link_key *__hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn,
+				    bdaddr_t *bdaddr, u8 *val, u8 type,
+				    u8 pin_len, bool *persistent);
+void hci_del_link_key(struct hci_dev *hdev, struct link_key *key);
 u8 *hci_conn_key_enc_size(struct hci_conn *conn);
 struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr);
 struct link_key *hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn,
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index e42ba4743f25f..53b677594fc2e 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1053,10 +1053,14 @@ void hci_link_keys_clear(struct hci_dev *hdev)
 {
 	struct link_key *key, *tmp;
 
+	mutex_lock(&hdev->link_keys_lock);
+
 	list_for_each_entry_safe(key, tmp, &hdev->link_keys, list) {
 		list_del_rcu(&key->list);
 		kfree_rcu(key, rcu);
 	}
+
+	mutex_unlock(&hdev->link_keys_lock);
 }
 
 void hci_smp_ltks_clear(struct hci_dev *hdev)
@@ -1275,13 +1279,16 @@ struct smp_irk *hci_find_irk_by_addr(struct hci_dev *hdev, bdaddr_t *bdaddr,
 	return irk_to_return;
 }
 
-struct link_key *hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn,
-				  bdaddr_t *bdaddr, u8 *val, u8 type,
-				  u8 pin_len, bool *persistent)
+/* This function requires the caller holds hdev->link_keys_lock */
+struct link_key *__hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn,
+				    bdaddr_t *bdaddr, u8 *val, u8 type,
+				    u8 pin_len, bool *persistent)
 {
 	struct link_key *key, *old_key;
 	u8 old_key_type;
 
+	lockdep_assert_held(&hdev->link_keys_lock);
+
 	old_key = hci_find_link_key(hdev, bdaddr);
 	if (old_key) {
 		old_key_type = old_key->type;
@@ -1324,6 +1331,26 @@ struct link_key *hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn,
 	return key;
 }
 
+/* The writers of hdev->link_keys are serialized with hdev->link_keys_lock
+ * so the list can be modified without hdev->lock (e.g. from SMP, where it
+ * can't be taken after the l2cap channel lock). The returned key is only
+ * safe to use while hdev->lock is held, callers without it must use
+ * __hci_add_link_key() and keep hdev->link_keys_lock while using the key.
+ */
+struct link_key *hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn,
+				  bdaddr_t *bdaddr, u8 *val, u8 type,
+				  u8 pin_len, bool *persistent)
+{
+	struct link_key *key;
+
+	mutex_lock(&hdev->link_keys_lock);
+	key = __hci_add_link_key(hdev, conn, bdaddr, val, type, pin_len,
+				 persistent);
+	mutex_unlock(&hdev->link_keys_lock);
+
+	return key;
+}
+
 struct smp_ltk *hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr,
 			    u8 addr_type, u8 type, u8 authenticated,
 			    u8 tk[16], u8 enc_size, __le16 ediv, __le64 rand)
@@ -1385,18 +1412,44 @@ int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr)
 {
 	struct link_key *key;
 
+	mutex_lock(&hdev->link_keys_lock);
+
 	key = hci_find_link_key(hdev, bdaddr);
-	if (!key)
+	if (!key) {
+		mutex_unlock(&hdev->link_keys_lock);
 		return -ENOENT;
+	}
 
 	BT_DBG("%s removing %pMR", hdev->name, bdaddr);
 
 	list_del_rcu(&key->list);
 	kfree_rcu(key, rcu);
 
+	mutex_unlock(&hdev->link_keys_lock);
+
 	return 0;
 }
 
+/* Remove a key previously returned by hci_add_link_key(), unlike
+ * hci_remove_link_key() this also works for keys that are blocked.
+ */
+void hci_del_link_key(struct hci_dev *hdev, struct link_key *key)
+{
+	struct link_key *k;
+
+	mutex_lock(&hdev->link_keys_lock);
+
+	list_for_each_entry(k, &hdev->link_keys, list) {
+		if (k == key) {
+			list_del_rcu(&key->list);
+			kfree_rcu(key, rcu);
+			break;
+		}
+	}
+
+	mutex_unlock(&hdev->link_keys_lock);
+}
+
 int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 bdaddr_type)
 {
 	struct smp_ltk *k, *tmp;
@@ -2559,6 +2612,7 @@ struct hci_dev *hci_alloc_dev_priv(int sizeof_priv)
 	hdev->def_page_scan_window = 0x0012;
 
 	mutex_init(&hdev->lock);
+	mutex_init(&hdev->link_keys_lock);
 	mutex_init(&hdev->req_lock);
 	mutex_init(&hdev->mgmt_pending_lock);
 	mutex_init(&hdev->remote_oob_lock);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index db9164d735156..6c2717403d418 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -4790,8 +4790,7 @@ static void hci_link_key_notify_evt(struct hci_dev *hdev, void *data,
 	 */
 	if (key->type == HCI_LK_DEBUG_COMBINATION &&
 	    !hci_dev_test_flag(hdev, HCI_KEEP_DEBUG_KEYS)) {
-		list_del_rcu(&key->list);
-		kfree_rcu(key, rcu);
+		hci_del_link_key(hdev, key);
 		goto unlock;
 	}
 
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index be1bde5b8ed63..4bc8af6db035a 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -1112,8 +1112,13 @@ static void smp_notify_keys(struct l2cap_conn *conn)
 		else
 			type = HCI_LK_UNAUTH_COMBINATION_P256;
 
-		key = hci_add_link_key(hdev, smp->conn->hcon, &hcon->dst,
-				       smp->link_key, type, 0, &persistent);
+		/* hdev->lock can't be taken here since it is ordered before
+		 * the l2cap channel lock held by the caller.
+		 */
+		mutex_lock(&hdev->link_keys_lock);
+
+		key = __hci_add_link_key(hdev, smp->conn->hcon, &hcon->dst,
+					 smp->link_key, type, 0, &persistent);
 		if (key) {
 			mgmt_new_link_key(hdev, key, persistent);
 
@@ -1126,6 +1131,8 @@ static void smp_notify_keys(struct l2cap_conn *conn)
 				kfree_rcu(key, rcu);
 			}
 		}
+
+		mutex_unlock(&hdev->link_keys_lock);
 	}
 }
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 174/555] Bluetooth: SMP: Check smp_data before using SMP_DEV()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (172 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 173/555] Bluetooth: SMP: Serialize link key updates from smp_notify_keys() Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 175/555] Bluetooth: SMP: Dont create the BR/EDR channel while unregistered Greg Kroah-Hartman
                   ` (380 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
	Sasha Levin

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

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

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

[ Upstream commit e8764a6946341e9ee809393386e7b815179c5f5f ]

hdev->smp_data is NULL when the SMP channel could not be registered, so
receiving a Pairing Request/Response with the OOB flag set would
dereference NULL through SMP_DEV().

Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-9bc9da90-02a8-4a87-a603-87d0a4cf464c
Fixes: 94f14e472812 ("Bluetooth: SMP: Fix trying to use non-existent local OOB data")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/bluetooth/smp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 4bc8af6db035a..c3e82763b1bcb 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -1783,7 +1783,8 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb)
 	 * successfully received our local OOB data - therefore set the
 	 * flag to indicate that local OOB is in use.
 	 */
-	if (req->oob_flag == SMP_OOB_PRESENT && SMP_DEV(hdev)->local_oob)
+	if (req->oob_flag == SMP_OOB_PRESENT && hdev->smp_data &&
+	    SMP_DEV(hdev)->local_oob)
 		set_bit(SMP_FLAG_LOCAL_OOB, &smp->flags);
 
 	/* SMP over BR/EDR requires special treatment */
@@ -1969,7 +1970,8 @@ static u8 smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb)
 	 * successfully received our local OOB data - therefore set the
 	 * flag to indicate that local OOB is in use.
 	 */
-	if (rsp->oob_flag == SMP_OOB_PRESENT && SMP_DEV(hdev)->local_oob)
+	if (rsp->oob_flag == SMP_OOB_PRESENT && hdev->smp_data &&
+	    SMP_DEV(hdev)->local_oob)
 		set_bit(SMP_FLAG_LOCAL_OOB, &smp->flags);
 
 	smp->prsp[0] = SMP_CMD_PAIRING_RSP;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 175/555] Bluetooth: SMP: Dont create the BR/EDR channel while unregistered
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (173 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 174/555] Bluetooth: SMP: Check smp_data before using SMP_DEV() Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 176/555] Bluetooth: hci_event: Validate sent command length in LE Set Ext Adv Enable Greg Kroah-Hartman
                   ` (379 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
	Sasha Levin

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

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

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

[ Upstream commit 8a119ba64f33dd9ab265d3b978f7811a80b7fe8a ]

smp_force_bredr() created a BR/EDR SMP channel even when the controller
was powered off or not LE capable, leaving a stale channel that
smp_register() later warns about and leaks. Only create it when SMP is
registered and guard the removal; smp_register() creates it on power on
if the flag is set. Since smp_unregister() runs with hdev->lock take it
around smp_register() as well so they can't race with each other nor with
smp_force_bredr().

Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-a921c99c-0b41-485c-91a4-1c6e54b45b0b
Fixes: 300acfdec916 ("Bluetooth: Introduce force_bredr_smp debugfs option for testing")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/bluetooth/hci_sync.c |  2 ++
 net/bluetooth/smp.c      | 20 ++++++++++++++------
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index f89bd2c365554..84ae44fa41240 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -3842,7 +3842,9 @@ int hci_powered_update_sync(struct hci_dev *hdev)
 	 * registration is required so that LE SMP can clearly decide if
 	 * the public address or static address is used.
 	 */
+	hci_dev_lock(hdev);
 	smp_register(hdev);
+	hci_dev_unlock(hdev);
 
 	err = hci_write_ssp_mode_sync(hdev, 0x01);
 	if (err)
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index c3e82763b1bcb..1406898272eab 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -3394,20 +3394,28 @@ int smp_force_bredr(struct hci_dev *hdev, bool enable)
 	if (enable == hci_dev_test_flag(hdev, HCI_FORCE_BREDR_SMP))
 		return -EALREADY;
 
+	/* The channels are only registered while the controller is powered
+	 * and LE capable. Otherwise just record the flag, smp_register() will
+	 * create the BR/EDR channel on the next power on.
+	 */
 	if (enable) {
 		struct l2cap_chan *chan;
 
-		chan = smp_add_cid(hdev, L2CAP_CID_SMP_BREDR);
-		if (IS_ERR(chan))
-			return PTR_ERR(chan);
+		if (hdev->smp_data && !hdev->smp_bredr_data) {
+			chan = smp_add_cid(hdev, L2CAP_CID_SMP_BREDR);
+			if (IS_ERR(chan))
+				return PTR_ERR(chan);
 
-		hdev->smp_bredr_data = chan;
+			hdev->smp_bredr_data = chan;
+		}
 	} else {
 		struct l2cap_chan *chan;
 
 		chan = hdev->smp_bredr_data;
-		hdev->smp_bredr_data = NULL;
-		smp_del_chan(chan);
+		if (chan) {
+			hdev->smp_bredr_data = NULL;
+			smp_del_chan(chan);
+		}
 	}
 
 	hci_dev_change_flag(hdev, HCI_FORCE_BREDR_SMP);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 176/555] Bluetooth: hci_event: Validate sent command length in LE Set Ext Adv Enable
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (174 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 175/555] Bluetooth: SMP: Dont create the BR/EDR channel while unregistered Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 177/555] s390/cert_store: Check key_lookup() return code in invalidate_keyring_keys() Greg Kroah-Hartman
                   ` (378 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
	Sasha Levin

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

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

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

[ Upstream commit ad7c1f067df2772d73a3a34218a8f5db57ceb41c ]

hci_cc_le_set_ext_adv_enable() read num_of_sets and the set entries from
the last sent command without checking its length.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-42bcc244-62e6-4295-802c-f9a512ca49a3
Fixes: de181e887ac2 ("Bluetooth: Impmlement extended adv enable")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/bluetooth/hci_event.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 6c2717403d418..ba15618645c00 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1622,14 +1622,16 @@ static u8 hci_cc_le_set_ext_adv_enable(struct hci_dev *hdev, void *data,
 	struct hci_cp_ext_adv_set *set;
 	struct adv_info *adv = NULL, *n;
 	struct hci_ev_status *rp = data;
+	size_t len;
 
 	bt_dev_dbg(hdev, "status 0x%2.2x", rp->status);
 
 	if (rp->status)
 		return rp->status;
 
-	cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_ADV_ENABLE);
-	if (!cp)
+	cp = hci_sent_cmd_data_len(hdev, HCI_OP_LE_SET_EXT_ADV_ENABLE, &len);
+	if (!cp || len < sizeof(*cp) ||
+	    len < sizeof(*cp) + cp->num_of_sets * sizeof(*set))
 		return rp->status;
 
 	set = (void *)cp->data;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 177/555] s390/cert_store: Check key_lookup() return code in invalidate_keyring_keys()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (175 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 176/555] Bluetooth: hci_event: Validate sent command length in LE Set Ext Adv Enable Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 178/555] s390/cert_store: Fix cs_keyring reference leak in fill_cs_keyring() Greg Kroah-Hartman
                   ` (377 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Heiko Carstens, Jarkko Sakkinen,
	Alexander Gordeev, Sasha Levin

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

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

From: Heiko Carstens <hca@linux.ibm.com>

[ Upstream commit 2a102f513a68ef6771e1cf107c7f98985686ad71 ]

keyring->sem is released after writing the key serial numbers into
key_array. Keys corresponding to those serial numbers may have been
removed before key_lookup() is called.

Therefore check the return code of key_lookup() before dereferencing it.

Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/s390/kernel/cert_store.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index bf983513dd333..4b54e57ad5e42 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -332,8 +332,11 @@ static int invalidate_keyring_keys(struct key *keyring)
 		goto out;
 	}
 
+	rc = 0;
 	for (key_index = 0; key_index < num_keys; key_index++) {
 		current_key = key_lookup(key_array[key_index]);
+		if (IS_ERR(current_key))
+			continue;
 		pr_dbf_msg("Invalidating key %08x", current_key->serial);
 
 		key_invalidate(current_key);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 178/555] s390/cert_store: Fix cs_keyring reference leak in fill_cs_keyring()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (176 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 177/555] s390/cert_store: Check key_lookup() return code in invalidate_keyring_keys() Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 179/555] s390/cert_store: Fix potential use-after-free caused by find_cs_keyring() Greg Kroah-Hartman
                   ` (376 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Heiko Carstens, Jarkko Sakkinen,
	Alexander Gordeev, Sasha Levin

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

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

From: Heiko Carstens <hca@linux.ibm.com>

[ Upstream commit f992716c4c767a89b6be32e24ee6e4e41ad99da4 ]

create_cs_keyring() returns cs_keyring with a reference held. On the
success path fill_cs_keyring() never drops it, leaking the reference.
The keyring is kept alive by its link to the session keyring.

Drop the reference after add_certificates_to_keyring() returns.

Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/s390/kernel/cert_store.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index 4b54e57ad5e42..f8e41c488eedd 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -716,6 +716,7 @@ static int fill_cs_keyring(void)
 	if (rc)
 		goto cleanup_cs_keyring;
 
+	key_put(cs_keyring);
 	goto out;
 
 cleanup_cs_keyring:
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 179/555] s390/cert_store: Fix potential use-after-free caused by find_cs_keyring()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (177 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 178/555] s390/cert_store: Fix cs_keyring reference leak in fill_cs_keyring() Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 180/555] s390/cert_store: Remove unnecessary static specifier in create_cs_keyring() Greg Kroah-Hartman
                   ` (375 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Heiko Carstens, Jarkko Sakkinen,
	Alexander Gordeev, Sasha Levin

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

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

From: Heiko Carstens <hca@linux.ibm.com>

[ Upstream commit 92d377a611766f6ab7b9a63a530aa7bbd434abbb ]

find_cs_keyring() drops the refcount of cs_keyring before returning it.
Which means that callers operate on potentially already freed memory.

Let find_cs_keyring() return cs_keyring with a reference. Since
cleanup_cs_keys() now performs a balanced put via find_cs_keyring(),
remove the separate cleanup_cs_keyring error label in fill_cs_keyring()
and drop the reference unconditionally instead.

Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/s390/kernel/cert_store.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index f8e41c488eedd..11a587a40b283 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -360,17 +360,13 @@ static struct key *find_cs_keyring(void)
 	cs_keyring_ref = keyring_search(make_key_ref(get_user_session_keyring(), true),
 					&key_type_keyring, CERT_STORE_KEYRING_NAME,
 					false);
-	if (!IS_ERR(cs_keyring_ref)) {
-		cs_keyring = key_ref_to_ptr(cs_keyring_ref);
-		key_ref_put(cs_keyring_ref);
-		goto found;
-	}
+	if (!IS_ERR(cs_keyring_ref))
+		return key_ref_to_ptr(cs_keyring_ref);
+
 	/* Search default locations: thread, process, session keyrings */
 	cs_keyring = request_key(&key_type_keyring, CERT_STORE_KEYRING_NAME, NULL);
 	if (IS_ERR(cs_keyring))
 		return NULL;
-	key_put(cs_keyring);
-found:
 	return cs_keyring;
 }
 
@@ -713,14 +709,12 @@ static int fill_cs_keyring(void)
 		goto cleanup_keys;
 
 	rc = add_certificates_to_keyring(vcssb, cs_keyring);
+	key_put(cs_keyring);
 	if (rc)
-		goto cleanup_cs_keyring;
+		goto cleanup_keys;
 
-	key_put(cs_keyring);
 	goto out;
 
-cleanup_cs_keyring:
-	key_put(cs_keyring);
 cleanup_keys:
 	cleanup_cs_keys();
 out:
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 180/555] s390/cert_store: Remove unnecessary static specifier in create_cs_keyring()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (178 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 179/555] s390/cert_store: Fix potential use-after-free caused by find_cs_keyring() Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 181/555] s390/cert_store: Fix error handling of get_user_session_keyring() Greg Kroah-Hartman
                   ` (374 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Heiko Carstens, Jarkko Sakkinen,
	Alexander Gordeev, Sasha Levin

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

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

From: Heiko Carstens <hca@linux.ibm.com>

[ Upstream commit 1a58d930c82fcaf3a6a9e9daf21c7ae9ee088d7e ]

The local variable cs_keyring in create_cs_keyring() never reuses its
assigned value, therefore remove the static specifier. Callers are
serialized by cs_refresh_lock, so this does not fix a bug.

Even though this is not a bug fix, this contains a Fixes tag since other
commits require this as a prereq.

Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/s390/kernel/cert_store.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index 11a587a40b283..51dd2b2cbe6e2 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -394,7 +394,7 @@ static void cleanup_cs_keys(void)
 
 static struct key *create_cs_keyring(void)
 {
-	static struct key *cs_keyring;
+	struct key *cs_keyring;
 
 	/* Cleanup previous cs_keyring and all associated keys if any. */
 	cleanup_cs_keys();
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 181/555] s390/cert_store: Fix error handling of get_user_session_keyring()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (179 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 180/555] s390/cert_store: Remove unnecessary static specifier in create_cs_keyring() Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 182/555] s390/cert_store: Fix keyring refcount handling in get_user_session_keyring() Greg Kroah-Hartman
                   ` (373 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Heiko Carstens, Jarkko Sakkinen,
	Alexander Gordeev, Sasha Levin

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

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

From: Heiko Carstens <hca@linux.ibm.com>

[ Upstream commit 8256791b74e701361398a8d0e43c55bdabadc5ca ]

create_cs_keyring(), cleanup_cs_keys(), and find_cs_keyring() all pass
the return value of get_user_session_keyring() to other functions without
checking it. This can lead to dereferencing an error pointer.

Check the return value before using it.

Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/s390/kernel/cert_store.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index 51dd2b2cbe6e2..b81338e530e94 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -354,15 +354,18 @@ static int invalidate_keyring_keys(struct key *keyring)
 
 static struct key *find_cs_keyring(void)
 {
+	struct key *cs_keyring, *us_keyring;
 	key_ref_t cs_keyring_ref;
-	struct key *cs_keyring;
-
-	cs_keyring_ref = keyring_search(make_key_ref(get_user_session_keyring(), true),
-					&key_type_keyring, CERT_STORE_KEYRING_NAME,
-					false);
-	if (!IS_ERR(cs_keyring_ref))
-		return key_ref_to_ptr(cs_keyring_ref);
 
+	us_keyring = get_user_session_keyring();
+	if (!IS_ERR(us_keyring)) {
+		cs_keyring_ref = keyring_search(make_key_ref(us_keyring, true),
+						&key_type_keyring,
+						CERT_STORE_KEYRING_NAME,
+						false);
+		if (!IS_ERR(cs_keyring_ref))
+			return key_ref_to_ptr(cs_keyring_ref);
+	}
 	/* Search default locations: thread, process, session keyrings */
 	cs_keyring = request_key(&key_type_keyring, CERT_STORE_KEYRING_NAME, NULL);
 	if (IS_ERR(cs_keyring))
@@ -372,7 +375,7 @@ static struct key *find_cs_keyring(void)
 
 static void cleanup_cs_keys(void)
 {
-	struct key *cs_keyring;
+	struct key *cs_keyring, *us_keyring;
 
 	cs_keyring = find_cs_keyring();
 	if (!cs_keyring)
@@ -388,21 +391,26 @@ static void cleanup_cs_keys(void)
 
 	keyring_clear(cs_keyring);
 	key_invalidate(cs_keyring);
+	us_keyring = get_user_session_keyring();
+	if (!IS_ERR(us_keyring))
+		key_unlink(us_keyring, cs_keyring);
 	key_put(cs_keyring);
-	key_unlink(get_user_session_keyring(), cs_keyring);
 }
 
 static struct key *create_cs_keyring(void)
 {
-	struct key *cs_keyring;
+	struct key *cs_keyring, *us_keyring;
 
 	/* Cleanup previous cs_keyring and all associated keys if any. */
 	cleanup_cs_keys();
+	us_keyring = get_user_session_keyring();
+	if (IS_ERR(us_keyring))
+		return NULL;
 	cs_keyring = keyring_alloc(CERT_STORE_KEYRING_NAME, GLOBAL_ROOT_UID,
 				   GLOBAL_ROOT_GID, current_cred(),
 				   (KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_VIEW | KEY_USR_READ,
 				   KEY_ALLOC_NOT_IN_QUOTA | KEY_ALLOC_SET_KEEP,
-				   NULL, get_user_session_keyring());
+				   NULL, us_keyring);
 	if (IS_ERR(cs_keyring)) {
 		pr_dbf_msg("Can't allocate cert_store keyring");
 		return NULL;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 182/555] s390/cert_store: Fix keyring refcount handling in get_user_session_keyring()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (180 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 181/555] s390/cert_store: Fix error handling of get_user_session_keyring() Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 183/555] s390/cert_store: Do not search the process keyrings for the cert_store keyring Greg Kroah-Hartman
                   ` (372 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Heiko Carstens, Jarkko Sakkinen,
	Alexander Gordeev, Sasha Levin

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

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

From: Heiko Carstens <hca@linux.ibm.com>

[ Upstream commit aa7ee9e9cf17fcc7b0af55424aba6f0abd065fa7 ]

get_user_session_keyring() drops the reference of the looked up keyring
before returning it. Callers therefore use the keyring without holding a
reference.

Return the keyring with the reference and let callers drop the reference.

Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/s390/kernel/cert_store.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index b81338e530e94..638095367c8bc 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -307,7 +307,6 @@ static struct key *get_user_session_keyring(void)
 			   PTR_ERR(us_keyring_ref));
 		return ERR_PTR(-ENOKEY);
 	}
-	key_ref_put(us_keyring_ref);
 	return key_ref_to_ptr(us_keyring_ref);
 }
 
@@ -363,6 +362,7 @@ static struct key *find_cs_keyring(void)
 						&key_type_keyring,
 						CERT_STORE_KEYRING_NAME,
 						false);
+		key_put(us_keyring);
 		if (!IS_ERR(cs_keyring_ref))
 			return key_ref_to_ptr(cs_keyring_ref);
 	}
@@ -392,8 +392,10 @@ static void cleanup_cs_keys(void)
 	keyring_clear(cs_keyring);
 	key_invalidate(cs_keyring);
 	us_keyring = get_user_session_keyring();
-	if (!IS_ERR(us_keyring))
+	if (!IS_ERR(us_keyring)) {
 		key_unlink(us_keyring, cs_keyring);
+		key_put(us_keyring);
+	}
 	key_put(cs_keyring);
 }
 
@@ -411,6 +413,7 @@ static struct key *create_cs_keyring(void)
 				   (KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_VIEW | KEY_USR_READ,
 				   KEY_ALLOC_NOT_IN_QUOTA | KEY_ALLOC_SET_KEEP,
 				   NULL, us_keyring);
+	key_put(us_keyring);
 	if (IS_ERR(cs_keyring)) {
 		pr_dbf_msg("Can't allocate cert_store keyring");
 		return NULL;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 183/555] s390/cert_store: Do not search the process keyrings for the cert_store keyring
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (181 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 182/555] s390/cert_store: Fix keyring refcount handling in get_user_session_keyring() Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 184/555] s390/cert_store: Validate hash length in check_certificate_valid() Greg Kroah-Hartman
                   ` (371 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Heiko Carstens, Jarkko Sakkinen,
	Alexander Gordeev, Sasha Levin

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

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

From: Heiko Carstens <hca@linux.ibm.com>

[ Upstream commit 5ac71bb84e34337d7be280d2c06ff9cae77b7bcf ]

find_cs_keyring() first searches the user session keyring for the
cert_store keyring, and falls back to request_key(), which searches the
thread, process and session keyrings of the calling task. Any keyring
named "cert_store" found this way is accepted.

cleanup_cs_keys() then invalidates and unlinks all of its keys, and
clears and invalidates the keyring itself, without checking permissions.
If the refresh is triggered by a task which inherited a session keyring
that contains a keyring named "cert_store" not created by this code, this
keyring and its keys are destroyed.

create_cs_keyring() always links the keyring into the user session
keyring, so the first search is sufficient. Remove the request_key()
fallback.

Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/s390/kernel/cert_store.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index 638095367c8bc..dd6e0f0e5b72b 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -353,7 +353,7 @@ static int invalidate_keyring_keys(struct key *keyring)
 
 static struct key *find_cs_keyring(void)
 {
-	struct key *cs_keyring, *us_keyring;
+	struct key *us_keyring;
 	key_ref_t cs_keyring_ref;
 
 	us_keyring = get_user_session_keyring();
@@ -366,11 +366,7 @@ static struct key *find_cs_keyring(void)
 		if (!IS_ERR(cs_keyring_ref))
 			return key_ref_to_ptr(cs_keyring_ref);
 	}
-	/* Search default locations: thread, process, session keyrings */
-	cs_keyring = request_key(&key_type_keyring, CERT_STORE_KEYRING_NAME, NULL);
-	if (IS_ERR(cs_keyring))
-		return NULL;
-	return cs_keyring;
+	return NULL;
 }
 
 static void cleanup_cs_keys(void)
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 184/555] s390/cert_store: Validate hash length in check_certificate_valid()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (182 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 183/555] s390/cert_store: Do not search the process keyrings for the cert_store keyring Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 185/555] s390/cert_store: Fix max_vcxe_length output in pr_dbf_vcssb() Greg Kroah-Hartman
                   ` (370 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Alexander Gordeev, Heiko Carstens,
	Sasha Levin

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

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

From: Heiko Carstens <hca@linux.ibm.com>

[ Upstream commit 8b4e340f7742c8c3b12353e882ad5d4d25c7acc9 ]

Validate that vc_hash_length is SHA256_DIGEST_SIZE before checking the
hash and use sizeof(hash) in memcmp(). This avoids an out-of-bounds
read if vc_hash_length is incorrect.

Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/s390/kernel/cert_store.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index dd6e0f0e5b72b..870185014cf11 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -260,13 +260,11 @@ static int diag320(unsigned long subcode, void *addr)
 static int check_certificate_hash(const struct vce *vce)
 {
 	u8 hash[SHA256_DIGEST_SIZE];
-	u16 vc_hash_length;
 	u8 *vce_hash;
 
 	vce_hash = (u8 *)vce + vce->vce_hdr.vc_hash_offset;
-	vc_hash_length = vce->vce_hdr.vc_hash_length;
 	sha256((u8 *)vce + vce->vce_hdr.vc_offset, vce->vce_hdr.vc_length, hash);
-	if (memcmp(vce_hash, hash, vc_hash_length) == 0)
+	if (memcmp(vce_hash, hash, sizeof(hash)) == 0)
 		return 0;
 
 	pr_dbf_msg("SHA256 hash of received certificate does not match");
@@ -292,6 +290,10 @@ static int check_certificate_valid(const struct vce *vce)
 		pr_dbf_msg("Hash type is not supported");
 		return -EINVAL;
 	}
+	if (vce->vce_hdr.vc_hash_length != SHA256_DIGEST_SIZE) {
+		pr_dbf_msg("Hash length is not supported");
+		return -EINVAL;
+	}
 
 	return check_certificate_hash(vce);
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 185/555] s390/cert_store: Fix max_vcxe_length output in pr_dbf_vcssb()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (183 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 184/555] s390/cert_store: Validate hash length in check_certificate_valid() Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 186/555] s390/cert_store: Fix out-of-bounds read in pr_dbf_vce() Greg Kroah-Hartman
                   ` (369 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Alexander Gordeev, Heiko Carstens,
	Sasha Levin

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

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

From: Heiko Carstens <hca@linux.ibm.com>

[ Upstream commit 9d263bd8ddc31c9c3ebe3612df575d70848f5772 ]

Print the correct value for max_vcxe_length.

Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/s390/kernel/cert_store.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index 870185014cf11..f4f604e1f67c9 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -224,7 +224,7 @@ static void pr_dbf_vcssb(const struct vcssb *s)
 	pr_dbf_msg("total_vc_index_count: %u", s->total_vc_index_count);
 	pr_dbf_msg("max_vc_index_count: %u", s->max_vc_index_count);
 	pr_dbf_msg("max_vce_length: %u", s->max_vce_length);
-	pr_dbf_msg("max_vcxe_length: %u", s->max_vce_length);
+	pr_dbf_msg("max_vcxe_length: %u", s->max_vcxe_length);
 	pr_dbf_msg("max_single_vcb_length: %u", s->max_single_vcb_length);
 	pr_dbf_msg("total_vcb_length: %u", s->total_vcb_length);
 	pr_dbf_msg("max_single_vcxb_length: %u", s->max_single_vcxb_length);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 186/555] s390/cert_store: Fix out-of-bounds read in pr_dbf_vce()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (184 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 185/555] s390/cert_store: Fix max_vcxe_length output in pr_dbf_vcssb() Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 187/555] s390/cert_store: Initialize ism array in query_diag320_subcodes() Greg Kroah-Hartman
                   ` (368 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Alexander Gordeev, Heiko Carstens,
	Sasha Levin

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

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

From: Heiko Carstens <hca@linux.ibm.com>

[ Upstream commit 539cf27f0b090d84438b7da9045a271a947192ed ]

pr_dbf_vce() dumps the last 128 bytes of the certificate data of a
Verification Certificate Entry (VCE) into a debug area.
However the address calculation is wrong: vce_length is the length of
the whole entry including the header, while cert_data_buf starts
behind the header. Therefore the dump starts at the end of the entry
and starts reading behind it.

Dump the last 128 bytes of the entry like intended. Limit dumps to the
data length.

Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/s390/kernel/cert_store.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index f4f604e1f67c9..1048428c15b1e 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -180,6 +180,7 @@ static void pr_dbf_vce(const struct vce *e)
 {
 	unsigned char vc_name[VC_NAME_LEN_BYTES + 1];
 	char log_string[VC_NAME_LEN_BYTES + 40];
+	u32 data_len = 0;
 
 	pr_dbf_msg("VCE Header:");
 	pr_dbf_msg("vce_hdr.vce_length: %d", e->vce_hdr.vce_length);
@@ -205,11 +206,13 @@ static void pr_dbf_vce(const struct vce *e)
 	debug_text_event(cert_store_hexdump, 3, log_string);
 
 	/* Certificate data. */
+	if (e->vce_hdr.vce_length > sizeof(e->vce_hdr))
+		data_len = e->vce_hdr.vce_length - sizeof(e->vce_hdr);
 	debug_text_event(cert_store_hexdump, 3, "VCE: Certificate data start");
-	debug_event(cert_store_hexdump, 3, (u8 *)e->cert_data_buf, 128);
+	debug_event(cert_store_hexdump, 3, (u8 *)e->cert_data_buf, min(data_len, 128U));
 	debug_text_event(cert_store_hexdump, 3, "VCE: Certificate data end");
-	debug_event(cert_store_hexdump, 3,
-		    (u8 *)e->cert_data_buf + e->vce_hdr.vce_length - 128, 128);
+	if (data_len > 128)
+		debug_event(cert_store_hexdump, 3, (u8 *)e + e->vce_hdr.vce_length - 128, 128);
 }
 
 static void pr_dbf_vcssb(const struct vcssb *s)
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 187/555] s390/cert_store: Initialize ism array in query_diag320_subcodes()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (185 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 186/555] s390/cert_store: Fix out-of-bounds read in pr_dbf_vce() Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 188/555] Bluetooth: mgmt: Reject zero multi advertising rotation duration Greg Kroah-Hartman
                   ` (367 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Alexander Gordeev, Heiko Carstens,
	Sasha Levin

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

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

From: Heiko Carstens <hca@linux.ibm.com>

[ Upstream commit 2c1f57bce05244165f406e45982bbcd036071d3b ]

The Installed Subcode Block returned by DIAG 320 subcode 0 may be smaller
than the ism array. Initialize it to avoid copying uninitialized data to
the debug area.

Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/s390/kernel/cert_store.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index 1048428c15b1e..d91f1d21e3795 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -663,7 +663,7 @@ static int add_certificates_to_keyring(struct vcssb *vcssb, struct key *keyring)
  */
 static int query_diag320_subcodes(void)
 {
-	unsigned long ism[ISM_LEN_DWORDS];
+	unsigned long ism[ISM_LEN_DWORDS] = {};
 	int rc;
 
 	rc = diag320(0, ism);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 188/555] Bluetooth: mgmt: Reject zero multi advertising rotation duration
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (186 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 187/555] s390/cert_store: Initialize ism array in query_diag320_subcodes() Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 189/555] Bluetooth: L2CAP: Dont use uninitialized EFS in l2cap_parse_conf_rsp() Greg Kroah-Hartman
                   ` (366 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
	Sasha Levin

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

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

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

[ Upstream commit 4e0dc0523bd98adbd45ce1c66dd1a96d4f6a3ec9 ]

A zero def_multi_adv_rotation_duration makes
hci_schedule_adv_instance_sync() requeue itself with no delay, spinning
the request workqueue. Reject it in Set Default System Configuration.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-24ecb695-0c5c-408a-a016-a980c3115e95
Fixes: 17896406ff35 ("Bluetooth: implement read/set default system parameters mgmt")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/bluetooth/mgmt_config.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/net/bluetooth/mgmt_config.c b/net/bluetooth/mgmt_config.c
index 6ef701c27da48..3b1593f35f25f 100644
--- a/net/bluetooth/mgmt_config.c
+++ b/net/bluetooth/mgmt_config.c
@@ -206,6 +206,14 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data,
 				MGMT_STATUS_INVALID_PARAMS);
 		}
 
+		/* A zero rotation duration would make the advertising instance
+		 * scheduler requeue itself with no delay.
+		 */
+		if (type == 0x000c && !TLV_GET_LE16(buffer))
+			return mgmt_cmd_status(sk, hdev->id,
+				MGMT_OP_SET_DEF_SYSTEM_CONFIG,
+				MGMT_STATUS_INVALID_PARAMS);
+
 		buffer_left -= exp_len;
 		buffer += exp_len;
 	}
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 189/555] Bluetooth: L2CAP: Dont use uninitialized EFS in l2cap_parse_conf_rsp()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (187 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 188/555] Bluetooth: mgmt: Reject zero multi advertising rotation duration Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 190/555] Bluetooth: mgmt: Fix mesh transmission locking and lifetime Greg Kroah-Hartman
                   ` (365 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
	Sasha Levin

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

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

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

[ Upstream commit cb3251457da29ac1118f130bf45ac696421594a8 ]

The local EFS values were copied from an on-stack struct even when the
response carried no EFS option. Track whether it was received.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-089f015e-6251-4fea-85ef-7d6761e8c457
Fixes: 66af7aaf9edf ("Bluetooth: EFS: parse L2CAP config response")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/bluetooth/l2cap_core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 541986a5cf0f7..7325111518a79 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3727,6 +3727,7 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
 	unsigned long val;
 	struct l2cap_conf_rfc rfc = { .mode = L2CAP_MODE_BASIC };
 	struct l2cap_conf_efs efs;
+	bool remote_efs = false;
 
 	BT_DBG("chan %p, rsp %p, len %d, req %p", chan, rsp, len, data);
 
@@ -3782,6 +3783,7 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
 			if (olen != sizeof(efs))
 				break;
 			memcpy(&efs, (void *)val, olen);
+			remote_efs = true;
 			if (chan->local_stype != L2CAP_SERV_NOTRAFIC &&
 			    efs.stype != L2CAP_SERV_NOTRAFIC &&
 			    efs.stype != chan->local_stype)
@@ -3820,7 +3822,8 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
 				chan->ack_win = min_t(u16, chan->ack_win,
 						      rfc.txwin_size);
 
-			if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) {
+			if (remote_efs &&
+			    test_bit(FLAG_EFS_ENABLE, &chan->flags)) {
 				chan->local_msdu = le16_to_cpu(efs.msdu);
 				chan->local_sdu_itime =
 					le32_to_cpu(efs.sdu_itime);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 190/555] Bluetooth: mgmt: Fix mesh transmission locking and lifetime
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (188 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 189/555] Bluetooth: L2CAP: Dont use uninitialized EFS in l2cap_parse_conf_rsp() Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 191/555] Bluetooth: MGMT: Fix use-after-free in mgmt_powering_down() Greg Kroah-Hartman
                   ` (364 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
	Sasha Levin

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

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

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

[ Upstream commit 1d7a527788584e4a88ccc532ed73bfdacd0b1e74 ]

The mesh_pending list is modified under hdev->lock by Mesh Send, but the
cmd_sync callbacks and Mesh Send Cancel add/remove entries and touch
hdev->adv_instances without it, which corrupts the list and the advertising
instances. In addition the queued mesh_send_sync entry holds a raw pointer
to the mesh_tx which a cancel of the transmission can free while the entry
is running, leading to use-after-free.

Fix this by:
 - taking hdev->lock around every mesh_pending/adv_instances access in the
   cmd_sync callbacks and Mesh Send Cancel, but never across HCI commands;
 - queueing the cmd_sync entries with the transmission handle and looking
   it up under the lock instead of passing the pointer;
 - always sending the first transmission, tracked by HCI_MESH_SENDING which
   is only cleared together with the removal of the transmission so Mesh
   Send can't start another one in between, and making sure none is left
   stranded if queueing fails;
 - cancelling a transmission by dequeuing its entry, and the done entry if
   it is the one in progress, stopping the done timer, which is queued
   with hdev->lock held so a cancel can't miss it;
 - not taking hdev->lock from callbacks invoked with -ECANCELED since
   those run with the cmd_sync lock held, the transmission is removed by
   whoever cancelled the entry;
 - flushing the transmissions left, dequeuing the entries still queued for
   them and clearing HCI_MESH_SENDING, when the controller is closed (also
   when auto powered off) or the index is removed, as nothing is going to
   send them and the stale entries would act on the ones started after
   the controller is powered on again, and not accepting Mesh Send while
   the controller is not powered so none can be left behind;
 - not reporting the completion of a transmission that failed to be queued
   by Mesh Send itself since userspace wasn't told about its handle;
 - not reusing the handle of a transmission still pending when the handle
   counter wraps around, now that it is what identifies a transmission.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-4ab89465-fc27-4d91-a870-a8ed49b22e91
Link: https://sashiko.dev/#/bug/linux-ab941894-dbe1-49da-8bac-c52efda6eaee
Link: https://sashiko.dev/#/bug/linux-4016f774-7ac7-4b8a-916f-587ec9d597d4
Fixes: b338d91703fa ("Bluetooth: Implement support for Mesh")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/net/bluetooth/hci_core.h |   1 +
 net/bluetooth/hci_sync.c         |   5 +
 net/bluetooth/mgmt.c             | 301 +++++++++++++++++++++++++------
 net/bluetooth/mgmt_util.c        |  23 ++-
 4 files changed, 267 insertions(+), 63 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 0599cc3a67ddc..e76f6f96770a1 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -2382,6 +2382,7 @@ void mgmt_index_removed(struct hci_dev *hdev);
 void mgmt_set_powered_failed(struct hci_dev *hdev, int err);
 void mgmt_power_on(struct hci_dev *hdev, int err);
 void __mgmt_power_off(struct hci_dev *hdev);
+void mgmt_mesh_flush(struct hci_dev *hdev);
 void mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key,
 		       bool persistent);
 void mgmt_device_connected(struct hci_dev *hdev, struct hci_conn *conn,
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 84ae44fa41240..e99c2712a794d 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -5621,6 +5621,11 @@ int hci_dev_close_sync(struct hci_dev *hdev)
 
 	auto_off = hci_dev_test_and_clear_flag(hdev, HCI_AUTO_OFF);
 
+	/* Nothing is going to send the mesh transmissions left, whether or not
+	 * mgmt is told about the controller being powered off.
+	 */
+	mgmt_mesh_flush(hdev);
+
 	if (!auto_off && !hci_dev_test_flag(hdev, HCI_USER_CHANNEL) &&
 	    hci_dev_test_flag(hdev, HCI_MGMT))
 		__mgmt_power_off(hdev);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 43ccc91ef7027..f813ca5480ff1 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1054,6 +1054,7 @@ static void discov_off(struct work_struct *work)
 
 static int send_settings_rsp(struct sock *sk, u16 opcode, struct hci_dev *hdev);
 
+/* This function requires the caller holds hdev->lock */
 static void mesh_send_complete(struct hci_dev *hdev,
 			       struct mgmt_mesh_tx *mesh_tx, bool silent)
 {
@@ -1066,37 +1067,95 @@ static void mesh_send_complete(struct hci_dev *hdev,
 	mgmt_mesh_remove(mesh_tx);
 }
 
-static int mesh_send_done_sync(struct hci_dev *hdev, void *data)
+/* The cmd_sync entries identify the transmission by handle rather than by
+ * pointer since the mesh_tx can be removed while the entry is queued or
+ * running.
+ */
+#define MESH_TX_DATA(_handle)	((void *)(unsigned long)(_handle))
+#define MESH_TX_HANDLE(_data)	((u8)(unsigned long)(_data))
+
+static int mesh_send_sync(struct hci_dev *hdev, void *data);
+static void mesh_send_start_complete(struct hci_dev *hdev, void *data, int err);
+
+/* Start sending the first transmission unless one is already in progress,
+ * HCI_MESH_SENDING is set while the first transmission is being sent.
+ * Completion is not reported for @new, the handle of a transmission userspace
+ * wasn't told about yet.
+ *
+ * This function requires the caller holds hdev->lock.
+ */
+static void __mesh_next(struct hci_dev *hdev, u8 new)
 {
 	struct mgmt_mesh_tx *mesh_tx;
+	int err;
 
-	hci_dev_clear_flag(hdev, HCI_MESH_SENDING);
-	if (list_empty(&hdev->adv_instances))
-		hci_disable_advertising_sync(hdev);
-	mesh_tx = mgmt_mesh_next(hdev, NULL);
-
-	if (mesh_tx)
-		mesh_send_complete(hdev, mesh_tx, false);
+	while (!hci_dev_test_flag(hdev, HCI_MESH_SENDING)) {
+		mesh_tx = mgmt_mesh_next(hdev, NULL);
+		if (!mesh_tx)
+			return;
 
-	return 0;
+		err = hci_cmd_sync_queue(hdev, mesh_send_sync,
+					 MESH_TX_DATA(mesh_tx->handle),
+					 mesh_send_start_complete);
+		if (err < 0)
+			mesh_send_complete(hdev, mesh_tx,
+					   mesh_tx->handle == new);
+		else
+			hci_dev_set_flag(hdev, HCI_MESH_SENDING);
+	}
 }
 
-static int mesh_send_sync(struct hci_dev *hdev, void *data);
-static void mesh_send_start_complete(struct hci_dev *hdev, void *data, int err);
 static void mesh_next(struct hci_dev *hdev, void *data, int err)
 {
-	struct mgmt_mesh_tx *mesh_tx = mgmt_mesh_next(hdev, NULL);
-
-	if (!mesh_tx)
+	/* The entry is being cancelled with the cmd_sync lock held, which
+	 * can't be taken before hdev->lock.
+	 */
+	if (err == -ECANCELED)
 		return;
 
-	err = hci_cmd_sync_queue(hdev, mesh_send_sync, mesh_tx,
-				 mesh_send_start_complete);
+	hci_dev_lock(hdev);
+	__mesh_next(hdev, 0);
+	hci_dev_unlock(hdev);
+}
 
-	if (err < 0)
+static int mesh_send_done_sync(struct hci_dev *hdev, void *data)
+{
+	struct mgmt_mesh_tx *mesh_tx;
+	u8 handle;
+	bool disable;
+
+	hci_dev_lock(hdev);
+
+	mesh_tx = mgmt_mesh_next(hdev, NULL);
+	if (!mesh_tx || !hci_dev_test_flag(hdev, HCI_MESH_SENDING)) {
+		hci_dev_unlock(hdev);
+		return 0;
+	}
+
+	handle = mesh_tx->handle;
+	disable = list_empty(&hdev->adv_instances);
+
+	hci_dev_unlock(hdev);
+
+	if (disable)
+		hci_disable_advertising_sync(hdev);
+
+	hci_dev_lock(hdev);
+
+	/* The transmission can be cancelled meanwhile, in which case whoever
+	 * did so already moved on to the next one. HCI_MESH_SENDING is only
+	 * cleared with the transmission removed so Mesh Send doesn't start
+	 * another one in between.
+	 */
+	mesh_tx = mgmt_mesh_find(hdev, handle);
+	if (mesh_tx) {
 		mesh_send_complete(hdev, mesh_tx, false);
-	else
-		hci_dev_set_flag(hdev, HCI_MESH_SENDING);
+		hci_dev_clear_flag(hdev, HCI_MESH_SENDING);
+	}
+
+	hci_dev_unlock(hdev);
+
+	return 0;
 }
 
 static void mesh_send_done(struct work_struct *work)
@@ -1110,6 +1169,33 @@ static void mesh_send_done(struct work_struct *work)
 	hci_cmd_sync_queue(hdev, mesh_send_done_sync, NULL, mesh_next);
 }
 
+/* Nothing is going to send the transmissions left, e.g. when the controller
+ * is powered off.
+ *
+ * This function requires the caller holds hdev->lock.
+ */
+static void mesh_flush(struct hci_dev *hdev, bool silent)
+{
+	struct mgmt_mesh_tx *mesh_tx;
+
+	/* Stop the timer first, it checks HCI_MESH_SENDING without hdev->lock
+	 * so once it is clear and the work is not running anymore nothing can
+	 * queue mesh_send_done_sync behind the dequeue below.
+	 */
+	hci_dev_clear_flag(hdev, HCI_MESH_SENDING);
+	cancel_delayed_work_sync(&hdev->mesh_send_done);
+
+	/* Entries still queued would otherwise run after the controller is
+	 * powered on again and act on the transmissions started by then. The
+	 * destroy callbacks don't take hdev->lock when cancelled.
+	 */
+	hci_cmd_sync_dequeue(hdev, mesh_send_sync, NULL, NULL);
+	hci_cmd_sync_dequeue(hdev, mesh_send_done_sync, NULL, NULL);
+
+	while ((mesh_tx = mgmt_mesh_next(hdev, NULL)))
+		mesh_send_complete(hdev, mesh_tx, silent);
+}
+
 static void mgmt_init_hdev(struct sock *sk, struct hci_dev *hdev)
 {
 	if (hci_dev_test_flag(hdev, HCI_MGMT))
@@ -2277,38 +2363,71 @@ static int set_mesh(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
 
 static void mesh_send_start_complete(struct hci_dev *hdev, void *data, int err)
 {
-	struct mgmt_mesh_tx *mesh_tx = data;
-	struct mgmt_cp_mesh_send *send = (void *)mesh_tx->param;
-	unsigned long mesh_send_interval;
+	struct mgmt_mesh_tx *mesh_tx;
+	struct mgmt_cp_mesh_send *send;
 	u8 mgmt_err = mgmt_status(err);
 
+	/* The entry is being cancelled with the cmd_sync lock held, which
+	 * can't be taken before hdev->lock, so leave the removal of the
+	 * transmission, and HCI_MESH_SENDING, to whoever cancelled it or to
+	 * mgmt_power_off() if the controller is going down.
+	 */
+	if (err == -ECANCELED)
+		return;
+
+	hci_dev_lock(hdev);
+
+	/* Cancelled while the entry was running, whoever did so already moved
+	 * on to the next transmission.
+	 */
+	mesh_tx = mgmt_mesh_find(hdev, MESH_TX_HANDLE(data));
+	if (!mesh_tx) {
+		hci_dev_unlock(hdev);
+		return;
+	}
+
 	/* Report any errors here, but don't report completion */
 
 	if (mgmt_err) {
-		hci_dev_clear_flag(hdev, HCI_MESH_SENDING);
 		/* Send Complete Error Code for handle */
 		mesh_send_complete(hdev, mesh_tx, false);
-		if (err != -ECANCELED)
-			mesh_next(hdev, NULL, 0);
+		hci_dev_clear_flag(hdev, HCI_MESH_SENDING);
+		__mesh_next(hdev, 0);
+		hci_dev_unlock(hdev);
 		return;
 	}
 
-	mesh_send_interval = msecs_to_jiffies((send->cnt) * 25);
+	/* Queued with hdev->lock held so a cancel can't miss it */
+	send = (void *)mesh_tx->param;
 	queue_delayed_work(hdev->req_workqueue, &hdev->mesh_send_done,
-			   mesh_send_interval);
+			   msecs_to_jiffies((send->cnt) * 25));
+
+	hci_dev_unlock(hdev);
 }
 
 static int mesh_send_sync(struct hci_dev *hdev, void *data)
 {
-	struct mgmt_mesh_tx *mesh_tx = data;
-	struct mgmt_cp_mesh_send *send = (void *)mesh_tx->param;
+	struct mgmt_mesh_tx *mesh_tx;
+	struct mgmt_cp_mesh_send *send;
 	struct adv_info *adv, *next_instance;
 	u8 instance = hdev->le_num_of_adv_sets + 1;
 	u16 timeout, duration;
 	int err = 0;
 
-	if (hdev->le_num_of_adv_sets <= hdev->adv_instance_cnt)
+	hci_dev_lock(hdev);
+
+	mesh_tx = mgmt_mesh_find(hdev, MESH_TX_HANDLE(data));
+	if (!mesh_tx) {
+		hci_dev_unlock(hdev);
+		return -ENOENT;
+	}
+
+	send = (void *)mesh_tx->param;
+
+	if (hdev->le_num_of_adv_sets <= hdev->adv_instance_cnt) {
+		hci_dev_unlock(hdev);
 		return MGMT_STATUS_BUSY;
+	}
 
 	timeout = 1000;
 	duration = send->cnt * INTERVAL_TO_MS(hdev->le_adv_max_interval);
@@ -2346,6 +2465,8 @@ static int mesh_send_sync(struct hci_dev *hdev, void *data)
 		instance = 0;
 	}
 
+	hci_dev_unlock(hdev);
+
 	if (instance)
 		return hci_schedule_adv_instance_sync(hdev, instance, true);
 
@@ -2389,37 +2510,80 @@ static int mesh_features(struct sock *sk, struct hci_dev *hdev,
 	return 0;
 }
 
+/* Cancel a single transmission, the handle is looked up again after the
+ * entry has been dequeued since it may be gone or have completed meanwhile.
+ */
+static void mesh_cancel_tx(struct hci_dev *hdev, u8 handle)
+{
+	struct mgmt_mesh_tx *mesh_tx;
+	bool in_progress;
+
+	hci_cmd_sync_dequeue(hdev, mesh_send_sync, MESH_TX_DATA(handle), NULL);
+
+	hci_dev_lock(hdev);
+	mesh_tx = mgmt_mesh_find(hdev, handle);
+	in_progress = mesh_tx && hci_dev_test_flag(hdev, HCI_MESH_SENDING) &&
+		      mesh_tx == mgmt_mesh_next(hdev, NULL);
+	hci_dev_unlock(hdev);
+
+	/* The done timer may have fired already and be waiting to complete
+	 * the transmission in progress, which is being cancelled.
+	 */
+	if (in_progress)
+		hci_cmd_sync_dequeue(hdev, mesh_send_done_sync, NULL, NULL);
+
+	hci_dev_lock(hdev);
+
+	mesh_tx = mgmt_mesh_find(hdev, handle);
+	if (mesh_tx) {
+		/* If it is the transmission in progress make sure the timer
+		 * doesn't complete the next one in its place.
+		 */
+		if (hci_dev_test_flag(hdev, HCI_MESH_SENDING) &&
+		    mesh_tx == mgmt_mesh_next(hdev, NULL)) {
+			cancel_delayed_work(&hdev->mesh_send_done);
+			hci_dev_clear_flag(hdev, HCI_MESH_SENDING);
+		}
+
+		mesh_send_complete(hdev, mesh_tx, false);
+	}
+
+	hci_dev_unlock(hdev);
+}
+
 static int send_cancel(struct hci_dev *hdev, void *data)
 {
 	struct mgmt_pending_cmd *cmd = data;
 	struct mgmt_cp_mesh_send_cancel *cancel = (void *)cmd->param;
 	struct mgmt_mesh_tx *mesh_tx;
+	u8 handle;
 
 	if (!cancel->handle) {
-		do {
+		for (;;) {
+			hci_dev_lock(hdev);
 			mesh_tx = mgmt_mesh_next(hdev, cmd->sk);
+			handle = mesh_tx ? mesh_tx->handle : 0;
+			hci_dev_unlock(hdev);
 
-			if (mesh_tx) {
-				if (!hci_cmd_sync_dequeue(hdev, mesh_send_sync,
-							  mesh_tx, NULL))
-					mesh_send_complete(hdev, mesh_tx, false);
-			}
-		} while (mesh_tx);
+			if (!mesh_tx)
+				break;
+
+			mesh_cancel_tx(hdev, handle);
+		}
 	} else {
+		hci_dev_lock(hdev);
 		mesh_tx = mgmt_mesh_find(hdev, cancel->handle);
+		handle = mesh_tx && mesh_tx->sk == cmd->sk ? mesh_tx->handle : 0;
+		hci_dev_unlock(hdev);
 
-		if (mesh_tx && mesh_tx->sk == cmd->sk) {
-			if (!hci_cmd_sync_dequeue(hdev, mesh_send_sync,
-						  mesh_tx, NULL))
-				mesh_send_complete(hdev, mesh_tx, false);
-		}
+		if (handle)
+			mesh_cancel_tx(hdev, handle);
 	}
 
 	mgmt_cmd_complete(cmd->sk, hdev->id, MGMT_OP_MESH_SEND_CANCEL,
 			  0, NULL, 0);
 
-	if (!hci_dev_test_flag(hdev, HCI_MESH_SENDING))
-		mesh_next(hdev, NULL, 0);
+	mesh_next(hdev, NULL, 0);
 
 	return 0;
 }
@@ -2470,7 +2634,6 @@ static int mesh_send(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
 	struct mgmt_cp_mesh_send *send = data;
 	struct mgmt_rp_mesh_read_features rp;
 	u16 expected_len;
-	bool sending;
 	int err = 0;
 
 	if (!lmp_le_capable(hdev) ||
@@ -2492,6 +2655,15 @@ static int mesh_send(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
 
 	hci_dev_lock(hdev);
 
+	/* Transmissions are flushed when the controller is closed, which is
+	 * serialized with this by hdev->lock, so none can be left behind.
+	 */
+	if (!hdev_is_powered(hdev)) {
+		err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_MESH_SEND,
+				      MGMT_STATUS_NOT_POWERED);
+		goto done;
+	}
+
 	memset(&rp, 0, sizeof(rp));
 	rp.max_handles = MESH_HANDLES_MAX;
 
@@ -2503,27 +2675,27 @@ static int mesh_send(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
 		goto done;
 	}
 
-	sending = hci_dev_test_flag(hdev, HCI_MESH_SENDING);
 	mesh_tx = mgmt_mesh_add(sk, hdev, send, len);
-
-	if (!mesh_tx)
+	if (!mesh_tx) {
 		err = -ENOMEM;
-	else if (!sending)
-		err = hci_cmd_sync_queue(hdev, mesh_send_sync, mesh_tx,
-					 mesh_send_start_complete);
+	} else {
+		u8 handle = mesh_tx->handle;
+
+		/* The first transmission is the one queued, which may not be
+		 * the one just added.
+		 */
+		__mesh_next(hdev, handle);
+
+		/* Queueing failed, the transmission was removed */
+		if (!mgmt_mesh_find(hdev, handle))
+			err = -EIO;
+	}
 
 	if (err < 0) {
 		bt_dev_err(hdev, "Send Mesh Failed %d", err);
 		err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_MESH_SEND,
 				      MGMT_STATUS_FAILED);
-
-		if (mesh_tx) {
-			if (sending)
-				mgmt_mesh_remove(mesh_tx);
-		}
 	} else {
-		hci_dev_set_flag(hdev, HCI_MESH_SENDING);
-
 		mgmt_cmd_complete(sk, hdev->id, MGMT_OP_MESH_SEND, 0,
 				  &mesh_tx->handle, 1);
 	}
@@ -9866,7 +10038,8 @@ void mgmt_index_removed(struct hci_dev *hdev)
 	cancel_delayed_work_sync(&hdev->discov_off);
 	cancel_delayed_work_sync(&hdev->service_cache);
 	cancel_delayed_work_sync(&hdev->rpa_expired);
-	cancel_delayed_work_sync(&hdev->mesh_send_done);
+
+	mesh_flush(hdev, true);
 }
 
 void mgmt_power_on(struct hci_dev *hdev, int err)
@@ -9893,6 +10066,16 @@ void mgmt_power_on(struct hci_dev *hdev, int err)
 	hci_dev_unlock(hdev);
 }
 
+/* This function requires the caller holds hdev->lock */
+void mgmt_mesh_flush(struct hci_dev *hdev)
+{
+	/* The mesh work is only initialized once mgmt is used */
+	if (!hci_dev_test_flag(hdev, HCI_MGMT))
+		return;
+
+	mesh_flush(hdev, false);
+}
+
 void __mgmt_power_off(struct hci_dev *hdev)
 {
 	struct cmd_lookup match = { NULL, hdev };
diff --git a/net/bluetooth/mgmt_util.c b/net/bluetooth/mgmt_util.c
index aa7b5585cb268..c4fe63ac2e09f 100644
--- a/net/bluetooth/mgmt_util.c
+++ b/net/bluetooth/mgmt_util.c
@@ -412,16 +412,31 @@ struct mgmt_mesh_tx *mgmt_mesh_add(struct sock *sk, struct hci_dev *hdev,
 				   void *data, u16 len)
 {
 	struct mgmt_mesh_tx *mesh_tx;
+	u8 handle = hdev->mesh_send_ref;
+	int i;
+
+	/* The handle is all that identifies a transmission, so it must not be
+	 * in use by one still pending when the counter wraps around.
+	 */
+	for (i = 0; i < 255; i++) {
+		handle++;
+		if (!handle)
+			handle++;
+
+		if (!mgmt_mesh_find(hdev, handle))
+			break;
+	}
+
+	if (i == 255)
+		return NULL;
 
 	mesh_tx = kzalloc(sizeof(*mesh_tx), GFP_KERNEL);
 	if (!mesh_tx)
 		return NULL;
 
-	hdev->mesh_send_ref++;
-	if (!hdev->mesh_send_ref)
-		hdev->mesh_send_ref++;
+	hdev->mesh_send_ref = handle;
 
-	mesh_tx->handle = hdev->mesh_send_ref;
+	mesh_tx->handle = handle;
 	mesh_tx->index = hdev->id;
 	memcpy(mesh_tx->param, data, len);
 	mesh_tx->param_len = len;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 191/555] Bluetooth: MGMT: Fix use-after-free in mgmt_powering_down()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (189 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 190/555] Bluetooth: mgmt: Fix mesh transmission locking and lifetime Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 192/555] Bluetooth: MSFT: Protect the event prefix with hdev->lock Greg Kroah-Hartman
                   ` (363 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
	Sasha Levin

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

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

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

[ Upstream commit 7c8dcf322b0d978c80001632c1206d5fe1ee9ba7 ]

mgmt_powering_down() looked up the Set Powered command and read its
parameters after mgmt_pending_find() dropped mgmt_pending_lock, so the
command could be unlinked and freed in between. Do the lookup and read the
parameters while holding the lock.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-e45413fa-48a6-43f1-90be-638841567534
Fixes: 302a1f674c00 ("Bluetooth: MGMT: Fix possible UAFs")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/bluetooth/mgmt.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index f813ca5480ff1..7cb3ff9ce9906 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -10343,19 +10343,27 @@ bool mgmt_powering_down(struct hci_dev *hdev)
 {
 	struct mgmt_pending_cmd *cmd;
 	struct mgmt_mode *cp;
+	bool powering_down = false;
 
 	if (hci_dev_test_flag(hdev, HCI_POWERING_DOWN))
 		return true;
 
-	cmd = pending_find(MGMT_OP_SET_POWERED, hdev);
-	if (!cmd)
-		return false;
+	mutex_lock(&hdev->mgmt_pending_lock);
 
-	cp = cmd->param;
-	if (!cp->val)
-		return true;
+	list_for_each_entry(cmd, &hdev->mgmt_pending, list) {
+		if (hci_sock_get_channel(cmd->sk) != HCI_CHANNEL_CONTROL ||
+		    cmd->opcode != MGMT_OP_SET_POWERED)
+			continue;
 
-	return false;
+		/* cmd can only be freed after it is unlinked under the lock */
+		cp = cmd->param;
+		powering_down = !cp->val;
+		break;
+	}
+
+	mutex_unlock(&hdev->mgmt_pending_lock);
+
+	return powering_down;
 }
 
 void mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr,
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 192/555] Bluetooth: MSFT: Protect the event prefix with hdev->lock
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (190 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 191/555] Bluetooth: MGMT: Fix use-after-free in mgmt_powering_down() Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 193/555] Bluetooth: hci_core: Hold hdev->lock when removing advertisement monitors Greg Kroah-Hartman
                   ` (362 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
	Sasha Levin

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

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

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

[ Upstream commit 0434cd10518c1b58ca3f5366341f0b1c469afbca ]

msft_vendor_evt() read msft->evt_prefix_len and compared evt_prefix before
taking hdev->lock, while msft_do_open() (and the supported features
reply) free and reallocate the prefix without it, so an event received
while the controller is being opened could access freed memory. Take
hdev->lock for the whole event processing and while updating the prefix.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-246df501-f32c-46fd-8779-7fa755ed7f9d
Fixes: 5031ffcc79b8 ("Bluetooth: Keep MSFT ext info throughout a hci_dev's life cycle")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/bluetooth/msft.c | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c
index feaabfd5399f4..5be09fce557de 100644
--- a/net/bluetooth/msft.c
+++ b/net/bluetooth/msft.c
@@ -170,11 +170,16 @@ static bool read_supported_features(struct hci_dev *hdev,
 		goto failed;
 	}
 
+	/* The event prefix is used by msft_vendor_evt() with hdev->lock held */
+	hci_dev_lock(hdev);
+
 	if (rp->evt_prefix_len > 0) {
 		msft->evt_prefix = kmemdup(rp->evt_prefix, rp->evt_prefix_len,
 					   GFP_KERNEL);
-		if (!msft->evt_prefix)
+		if (!msft->evt_prefix) {
+			hci_dev_unlock(hdev);
 			goto failed;
+		}
 	}
 
 	msft->evt_prefix_len = rp->evt_prefix_len;
@@ -183,6 +188,8 @@ static bool read_supported_features(struct hci_dev *hdev,
 	if (msft->features & MSFT_FEATURE_MASK_CURVE_VALIDITY)
 		hdev->msft_curve_validity = true;
 
+	hci_dev_unlock(hdev);
+
 	kfree_skb(skb);
 	return true;
 
@@ -648,10 +655,12 @@ void msft_do_open(struct hci_dev *hdev)
 	bt_dev_dbg(hdev, "Initialize MSFT extension");
 
 	/* Reset existing MSFT data before re-reading */
+	hci_dev_lock(hdev);
 	kfree(msft->evt_prefix);
 	msft->evt_prefix = NULL;
 	msft->evt_prefix_len = 0;
 	msft->features = 0;
+	hci_dev_unlock(hdev);
 
 	if (!read_supported_features(hdev, msft)) {
 		hci_dev_lock(hdev);
@@ -1078,12 +1087,15 @@ static void msft_monitor_device_evt(struct hci_dev *hdev, struct sk_buff *skb)
 
 void msft_vendor_evt(struct hci_dev *hdev, void *data, struct sk_buff *skb)
 {
-	struct msft_data *msft = hdev->msft_data;
+	struct msft_data *msft;
 	u8 *evt_prefix;
 	u8 *evt;
 
+	hci_dev_lock(hdev);
+
+	msft = hdev->msft_data;
 	if (!msft)
-		return;
+		goto unlock;
 
 	/* When the extension has defined an event prefix, check that it
 	 * matches, and otherwise just return.
@@ -1091,23 +1103,21 @@ void msft_vendor_evt(struct hci_dev *hdev, void *data, struct sk_buff *skb)
 	if (msft->evt_prefix_len > 0) {
 		evt_prefix = msft_skb_pull(hdev, skb, 0, msft->evt_prefix_len);
 		if (!evt_prefix)
-			return;
+			goto unlock;
 
 		if (memcmp(evt_prefix, msft->evt_prefix, msft->evt_prefix_len))
-			return;
+			goto unlock;
 	}
 
 	/* Every event starts at least with an event code and the rest of
 	 * the data is variable and depends on the event code.
 	 */
 	if (skb->len < 1)
-		return;
+		goto unlock;
 
 	evt = msft_skb_pull(hdev, skb, 0, sizeof(*evt));
 	if (!evt)
-		return;
-
-	hci_dev_lock(hdev);
+		goto unlock;
 
 	switch (*evt) {
 	case MSFT_EV_LE_MONITOR_DEVICE:
@@ -1121,6 +1131,7 @@ void msft_vendor_evt(struct hci_dev *hdev, void *data, struct sk_buff *skb)
 		break;
 	}
 
+unlock:
 	hci_dev_unlock(hdev);
 }
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 193/555] Bluetooth: hci_core: Hold hdev->lock when removing advertisement monitors
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (191 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 192/555] Bluetooth: MSFT: Protect the event prefix with hdev->lock Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 194/555] Bluetooth: MSFT: Free the response of the monitor commands Greg Kroah-Hartman
                   ` (361 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
	Sasha Levin

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

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

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

[ Upstream commit 7f08b6ef44fa17f1a5ad3926663ddb5abe6ff68a ]

hci_remove_single_adv_monitor() and hci_remove_all_adv_monitor() only
require hci_req_sync_lock, yet they look up and free monitors, modifying
hdev->adv_monitors_idr and adv_monitors_cnt, which Read Advertisement
Monitor Features iterates under hdev->lock. Take hdev->lock around the
IDR accesses and the freeing, but not across the HCI commands sent to the
controller.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-8b358899-5ac9-4687-af16-58420a4d9bba
Fixes: 7cf5c2978f23 ("Bluetooth: hci_sync: Refactor remove Adv Monitor")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/bluetooth/hci_core.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 53b677594fc2e..7811d7a3f6052 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2066,7 +2066,10 @@ static int hci_remove_adv_monitor(struct hci_dev *hdev,
 	if (status == -ENOENT)
 		bt_dev_warn(hdev, "Removing monitor with no matching handle %d",
 			    monitor->handle);
+
+	hci_dev_lock(hdev);
 	hci_free_adv_monitor(hdev, monitor);
+	hci_dev_unlock(hdev);
 
 	return status;
 }
@@ -2074,7 +2077,11 @@ static int hci_remove_adv_monitor(struct hci_dev *hdev,
 /* This function requires the caller holds hci_req_sync_lock */
 int hci_remove_single_adv_monitor(struct hci_dev *hdev, u16 handle)
 {
-	struct adv_monitor *monitor = idr_find(&hdev->adv_monitors_idr, handle);
+	struct adv_monitor *monitor;
+
+	hci_dev_lock(hdev);
+	monitor = idr_find(&hdev->adv_monitors_idr, handle);
+	hci_dev_unlock(hdev);
 
 	if (!monitor)
 		return -EINVAL;
@@ -2090,7 +2097,10 @@ int hci_remove_all_adv_monitor(struct hci_dev *hdev)
 	int status = 0;
 
 	while (1) {
+		hci_dev_lock(hdev);
 		monitor = idr_get_next(&hdev->adv_monitors_idr, &idr_next_id);
+		hci_dev_unlock(hdev);
+
 		if (!monitor)
 			break;
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 194/555] Bluetooth: MSFT: Free the response of the monitor commands
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (192 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 193/555] Bluetooth: hci_core: Hold hdev->lock when removing advertisement monitors Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 195/555] Bluetooth: hci_core: Dont fail removing a monitor unknown to the controller Greg Kroah-Hartman
                   ` (360 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
	Sasha Levin

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

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

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

[ Upstream commit 775eca0c3df2f0272f21ebc8c812ad010fd47243 ]

msft_add_monitor_sync() and msft_remove_monitor_sync() send the MSFT
command with __hci_cmd_sync() and pass the returned skb to the callbacks,
which only parse it, so it is never freed. Free it once the callback
returns.

While at it initialize the RSSI fields of the handle data when it is
created instead of after the command completed, so they are never exposed
uninitialized, and do the lookup of the handle map in
msft_remove_monitor_sync() with hdev->lock held.

Found by the sashiko.dev review of the previous revision of this series.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/patchset/20261117185737.3758255-1-luiz.dentz%40gmail.com
Fixes: b747a83690c8 ("Bluetooth: hci_sync: Refactor add Adv Monitor")
Fixes: 7cf5c2978f23 ("Bluetooth: hci_sync: Refactor remove Adv Monitor")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/bluetooth/msft.c | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c
index 5be09fce557de..cd42b020c6c8d 100644
--- a/net/bluetooth/msft.c
+++ b/net/bluetooth/msft.c
@@ -297,6 +297,10 @@ static int msft_le_monitor_advertisement_cb(struct hci_dev *hdev, u16 opcode,
 	handle_data->mgmt_handle = monitor->handle;
 	handle_data->msft_handle = rp->handle;
 	handle_data->cond_type   = MSFT_MONITOR_ADVERTISEMENT_TYPE_PATTERN;
+	handle_data->rssi_high	= monitor->rssi.high_threshold;
+	handle_data->rssi_low	= monitor->rssi.low_threshold;
+	handle_data->rssi_low_interval	  = (u8)monitor->rssi.low_threshold_timeout;
+	handle_data->rssi_sampling_period = monitor->rssi.sampling_period;
 	INIT_LIST_HEAD(&handle_data->list);
 	list_add(&handle_data->list, &msft->handle_map);
 
@@ -438,23 +442,30 @@ static int msft_remove_monitor_sync(struct hci_dev *hdev,
 	struct msft_cp_le_cancel_monitor_advertisement cp;
 	struct msft_monitor_advertisement_handle_data *handle_data;
 	struct sk_buff *skb;
+	int err;
 
+	hci_dev_lock(hdev);
 	handle_data = msft_find_handle_data(hdev, monitor->handle, true);
+	if (handle_data)
+		cp.handle = handle_data->msft_handle;
+	hci_dev_unlock(hdev);
 
 	/* If no matched handle, just remove without telling controller */
 	if (!handle_data)
 		return -ENOENT;
 
 	cp.sub_opcode = MSFT_OP_LE_CANCEL_MONITOR_ADVERTISEMENT;
-	cp.handle = handle_data->msft_handle;
 
 	skb = __hci_cmd_sync(hdev, hdev->msft_opcode, sizeof(cp), &cp,
 			     HCI_CMD_TIMEOUT);
 	if (IS_ERR(skb))
 		return PTR_ERR(skb);
 
-	return msft_le_cancel_monitor_advertisement_cb(hdev, hdev->msft_opcode,
-						       monitor, skb);
+	err = msft_le_cancel_monitor_advertisement_cb(hdev, hdev->msft_opcode,
+						      monitor, skb);
+	kfree_skb(skb);
+
+	return err;
 }
 
 /* This function requires the caller holds hci_req_sync_lock */
@@ -519,7 +530,6 @@ static int msft_add_monitor_sync(struct hci_dev *hdev,
 {
 	struct msft_cp_le_monitor_advertisement *cp;
 	struct msft_le_monitor_advertisement_pattern_data *pattern_data;
-	struct msft_monitor_advertisement_handle_data *handle_data;
 	struct msft_le_monitor_advertisement_pattern *pattern;
 	struct adv_pattern *entry;
 	size_t total_size = sizeof(*cp) + sizeof(*pattern_data);
@@ -571,19 +581,7 @@ static int msft_add_monitor_sync(struct hci_dev *hdev,
 
 	err = msft_le_monitor_advertisement_cb(hdev, hdev->msft_opcode,
 					       monitor, skb);
-	if (err)
-		goto out_free;
-
-	handle_data = msft_find_handle_data(hdev, monitor->handle, true);
-	if (!handle_data) {
-		err = -ENODATA;
-		goto out_free;
-	}
-
-	handle_data->rssi_high	= cp->rssi_high;
-	handle_data->rssi_low	= cp->rssi_low;
-	handle_data->rssi_low_interval	  = cp->rssi_low_interval;
-	handle_data->rssi_sampling_period = cp->rssi_sampling_period;
+	kfree_skb(skb);
 
 out_free:
 	kfree(cp);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 195/555] Bluetooth: hci_core: Dont fail removing a monitor unknown to the controller
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (193 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 194/555] Bluetooth: MSFT: Free the response of the monitor commands Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:03 ` [PATCH 6.12 196/555] HID: magicmouse: disable the multitouch work on removal Greg Kroah-Hartman
                   ` (359 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
	Sasha Levin

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

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

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

[ Upstream commit 8d3e5e6fe6d0be5634b28788abf5685d571b13a4 ]

hci_remove_adv_monitor() frees the monitor when the controller has no
matching handle for it but still returned -ENOENT, so callers took it for
a failure of a monitor that is gone, and hci_remove_all_adv_monitor()
stopped at the first one leaving the others behind. Return success since
the monitor was removed.

Found by the sashiko.dev review of the previous revision of this series.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/patchset/20261117185737.3758255-1-luiz.dentz%40gmail.com
Fixes: 7cf5c2978f23 ("Bluetooth: hci_sync: Refactor remove Adv Monitor")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/bluetooth/hci_core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 7811d7a3f6052..2c52e4369453e 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2071,7 +2071,10 @@ static int hci_remove_adv_monitor(struct hci_dev *hdev,
 	hci_free_adv_monitor(hdev, monitor);
 	hci_dev_unlock(hdev);
 
-	return status;
+	/* The monitor is gone, not having been known by the controller is not
+	 * an error for the caller.
+	 */
+	return status == -ENOENT ? 0 : status;
 }
 
 /* This function requires the caller holds hci_req_sync_lock */
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 196/555] HID: magicmouse: disable the multitouch work on removal
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (194 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 195/555] Bluetooth: hci_core: Dont fail removing a monitor unknown to the controller Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 197/555] HID: sensor-hub: Synchronize callback removal with raw events Greg Kroah-Hartman
                   ` (358 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Ijae Kim, Myeonghun Pak, Jiri Kosina,
	Sasha Levin

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

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

From: Myeonghun Pak <mhun512@gmail.com>

[ Upstream commit 348597b22005a8f20d267cdcc503a41dcc658acf ]

During USB runtime reset-resume, usbhid can call magicmouse_reset_resume()
without serialization against HID driver unbind. The USB interface
remains bound to usbhid, so this callback can queue msc->work after
magicmouse_remove() cancels it. The delayed work can then run after
devres frees msc.

Use disable_delayed_work_sync() to drain the work and reject later
queueing. Probe initializes fresh work on rebind.

Found by a static analysis tool under development.

Fixes: 4253fe22b137 ("HID: magicmouse: re-enable multitouch after reset-resume")
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/hid/hid-magicmouse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index ca711d690b6bc..3329f4589f85c 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -1002,7 +1002,7 @@ static void magicmouse_remove(struct hid_device *hdev)
 	struct magicmouse_sc *msc = hid_get_drvdata(hdev);
 
 	if (msc) {
-		cancel_delayed_work_sync(&msc->work);
+		disable_delayed_work_sync(&msc->work);
 		if (is_usb_magicmouse2(hdev->vendor, hdev->product) ||
 		    is_usb_magictrackpad2(hdev->vendor, hdev->product))
 			del_timer_sync(&msc->battery_timer);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 197/555] HID: sensor-hub: Synchronize callback removal with raw events
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (195 preceding siblings ...)
  2026-12-04 10:03 ` [PATCH 6.12 196/555] HID: magicmouse: disable the multitouch work on removal Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 198/555] HID: sensor: custom: Set owner for misc device Greg Kroah-Hartman
                   ` (357 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Semyon Maryasin, Joshua Crofts,
	Zhang Lixu, Srinivas Pandruvada, Jonathan Cameron, Jiri Kosina,
	Sasha Levin

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

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

From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

[ Upstream commit abe10ad9c5fd868553b1262df403d5aaea3eff64 ]

Raw-event processing holds pdata->lock across callback lookup and
invocation, and takes dyn_callback_lock during lookup. Removal must
prevent both active callbacks and future lookups before client state can
be released.

Take pdata->lock before dyn_callback_lock, matching raw-event order,
and unlink the callback while holding both locks. This ensures active
raw-event callbacks have finished and prevents future lookups.

Fixes: 401ca24fb34a ("HID: sensors: introduce sensor framework")
Reported-by: Semyon Maryasin <simeon@maryasin.name>
Closes: https://lore.kernel.org/all/CAM2dg7ewfVJSP4rFyhkCB1Rmd1+X56sAg=eUdbPthG2xrLqwQQ@mail.gmail.com/
Reviewed-by: Joshua Crofts <crofts@kernel.org>
Tested-by: Semyon Maryasin <simeon@maryasin.name>
Tested-by: Zhang Lixu <lixu.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/hid/hid-sensor-hub.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index faeb9c4536f52..9f14439cc0788 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -173,7 +173,9 @@ int sensor_hub_remove_callback(struct hid_sensor_hub_device *hsdev,
 	struct sensor_hub_data *pdata = hid_get_drvdata(hsdev->hdev);
 	unsigned long flags;
 
-	spin_lock_irqsave(&pdata->dyn_callback_lock, flags);
+	/* Serialize callback removal with raw-event callback execution. */
+	spin_lock_irqsave(&pdata->lock, flags);
+	spin_lock(&pdata->dyn_callback_lock);
 	list_for_each_entry(callback, &pdata->dyn_callback_list, list)
 		if (callback->usage_id == usage_id &&
 						callback->hsdev == hsdev) {
@@ -181,7 +183,8 @@ int sensor_hub_remove_callback(struct hid_sensor_hub_device *hsdev,
 			kfree(callback);
 			break;
 		}
-	spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
+	spin_unlock(&pdata->dyn_callback_lock);
+	spin_unlock_irqrestore(&pdata->lock, flags);
 
 	return 0;
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 198/555] HID: sensor: custom: Set owner for misc device
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (196 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 197/555] HID: sensor-hub: Synchronize callback removal with raw events Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 199/555] HID: sensor: custom: Disable sensor before hub close on removal Greg Kroah-Hartman
                   ` (356 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Semyon Maryasin, Joshua Crofts,
	Zhang Lixu, Srinivas Pandruvada, Jonathan Cameron, Jiri Kosina,
	Sasha Levin

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

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

From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

[ Upstream commit 452a24b2c2ed95aa246fcb3fcaf74a97a95c02a4 ]

Set .owner in the misc-device file operations so open file descriptors
keep the module loaded until their release callbacks have completed.

Fixes: 4a7de0519df5 ("HID: sensor: Custom and Generic sensor support")
Reported-by: Semyon Maryasin <simeon@maryasin.name>
Closes: https://lore.kernel.org/all/CAM2dg7ewfVJSP4rFyhkCB1Rmd1+X56sAg=eUdbPthG2xrLqwQQ@mail.gmail.com/
Reviewed-by: Joshua Crofts <crofts@kernel.org>
Tested-by: Semyon Maryasin <simeon@maryasin.name>
Tested-by: Zhang Lixu <lixu.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/hid/hid-sensor-custom.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
index e9d2aacf5d8fd..cc0be03a49314 100644
--- a/drivers/hid/hid-sensor-custom.c
+++ b/drivers/hid/hid-sensor-custom.c
@@ -719,6 +719,7 @@ static __poll_t hid_sensor_custom_poll(struct file *file,
 }
 
 static const struct file_operations hid_sensor_custom_fops = {
+	.owner = THIS_MODULE,
 	.open =  hid_sensor_custom_open,
 	.read =  hid_sensor_custom_read,
 	.release = hid_sensor_custom_release,
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 199/555] HID: sensor: custom: Disable sensor before hub close on removal
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (197 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 198/555] HID: sensor: custom: Set owner for misc device Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 200/555] cxgb4: allocate the full ethtool filter location array Greg Kroah-Hartman
                   ` (355 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Semyon Maryasin, Joshua Crofts,
	Zhang Lixu, Srinivas Pandruvada, Jonathan Cameron, Jiri Kosina,
	Sasha Levin

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

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

From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

[ Upstream commit 6e66d69837cf07a00cbcdeb6198e08332b422b6c ]

When removing an enabled sensor, set its power and reporting states to
off before closing the hub. Keep the field descriptors alive until the
state update has completed, and release the hub's open reference.

Fixes: 4a7de0519df5 ("HID: sensor: Custom and Generic sensor support")
Reported-by: Semyon Maryasin <simeon@maryasin.name>
Closes: https://lore.kernel.org/all/CAM2dg7ewfVJSP4rFyhkCB1Rmd1+X56sAg=eUdbPthG2xrLqwQQ@mail.gmail.com/
Reviewed-by: Joshua Crofts <crofts@kernel.org>
Tested-by: Semyon Maryasin <simeon@maryasin.name>
Tested-by: Zhang Lixu <lixu.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/hid/hid-sensor-custom.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
index cc0be03a49314..b8025ad8189ad 100644
--- a/drivers/hid/hid-sensor-custom.c
+++ b/drivers/hid/hid-sensor-custom.c
@@ -1053,6 +1053,13 @@ static void hid_sensor_custom_remove(struct platform_device *pdev)
 	/* Remove enable_sensor first as it uses fields via power_state/report_state. */
 	sysfs_remove_group(&sensor_inst->pdev->dev.kobj,
 			   &enable_sensor_attr_group);
+	mutex_lock(&sensor_inst->mutex);
+	if (sensor_inst->enable) {
+		set_power_report_state(sensor_inst, false);
+		sensor_hub_device_close(hsdev);
+		sensor_inst->enable = false;
+	}
+	mutex_unlock(&sensor_inst->mutex);
 	hid_sensor_custom_remove_attributes(sensor_inst);
 	sensor_hub_remove_callback(hsdev, hsdev->usage);
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 200/555] cxgb4: allocate the full ethtool filter location array
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (198 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 199/555] HID: sensor: custom: Disable sensor before hub close on removal Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 201/555] net: bcm4908_enet: fix the TX ring wrap Greg Kroah-Hartman
                   ` (354 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Artemii Mashanov,
	Potnuri Bharat Teja, Jakub Kicinski, Sasha Levin

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

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

From: Artemii Mashanov <ralerrdirsardx@gmail.com>

[ Upstream commit ad2c7240a3981fd5f0142b61ca913b02ab476ede ]

The ethtool filter location array stores nentries u32 values, but
cxgb4_init_ethtool_filters() passes nentries to kvzalloc() as a byte
count. The insertion and lookup paths allow indices below nentries,
which can address memory beyond the requested allocation.

Allocate nentries elements with kvcalloc() and the element size.
The array remains compatible with the existing kvfree() calls.

The size mismatch was found by reviewing the allocation, the array
declaration and the indexed accesses in the filter handlers.

Fixes: d915c299f1da ("cxgb4: add skeleton for ethtool n-tuple filters")
Signed-off-by: Artemii Mashanov <ralerrdirsardx@gmail.com>
Reviewed-by: Potnuri Bharat Teja <bharat@chelsio.com>
Link: https://patch.msgid.link/20261117090608.33178-1-ralerrdirsardx@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
index 1546c3db08f09..fe6e9aea3dbd3 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
@@ -2261,7 +2261,9 @@ int cxgb4_init_ethtool_filters(struct adapter *adap)
 	eth_filter->nentries = nentries;
 
 	for (i = 0; i < adap->params.nports; i++) {
-		eth_filter->port[i].loc_array = kvzalloc(nentries, GFP_KERNEL);
+		eth_filter->port[i].loc_array =
+			kvcalloc(nentries, sizeof(*eth_filter->port[i].loc_array),
+				 GFP_KERNEL);
 		if (!eth_filter->port[i].loc_array) {
 			ret = -ENOMEM;
 			goto free_eth_finfo;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 201/555] net: bcm4908_enet: fix the TX ring wrap
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (199 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 200/555] cxgb4: allocate the full ethtool filter location array Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 202/555] net: bcm4908_enet: drop a TX frame whose DMA mapping failed Greg Kroah-Hartman
                   ` (353 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Florian Fainelli,
	Kordian Chmielewski, Jakub Kicinski, Sasha Levin

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

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

From: Kordian Chmielewski <kudzo51@gmail.com>

[ Upstream commit 4f8b1a7cf7548ebefae959486c3acc33799d1116 ]

start_xmit() wraps write_idx at length - 1 and sets WRAP on the
descriptor at length - 2, while poll_tx() wraps read_idx at length,
and the free descriptor count is taken from length. With read_idx at 0
and write_idx at length - 2 the count comes out as 2, the frame is
queued and write_idx wraps to 0 == read_idx: a full ring looks empty.
The following frames overwrite slots whose skbs were never unmapped
or freed, their bytes stay in BQL, and the queue stops for good with
nothing left to wake it.

On a TP-Link Archer AX6000 this stopped everything the CPU sent to the
switch under sustained TX load (about 1.3 Gbit/s through the switch's
CPU port): tx_packets froze, nothing was logged, and BQL showed about
185 KB in flight against a limit of about 10 KB.

The same mismatch also lets poll_tx() step onto slot length - 1, which
start_xmit() never fills: once per lap it completes that slot,
unmapping address 0 with length 0 and counting a packet that was never
sent. That one is from reading the code.

Use every descriptor, with WRAP on the last one, wrap both indexes at
length and keep one descriptor free, so that read_idx == write_idx can
only mean an empty ring. Stop and wake the queue with the
netdev_queues.h helpers: start_xmit() stops it when the ring is full,
also when it finds the ring full on entry, and poll_tx() wakes it once
there is room again.

Fixes: 4feffeadbcb2 ("net: broadcom: bcm4908enet: add BCM4908 controller driver")
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Kordian Chmielewski <kudzo51@gmail.com>
Link: https://patch.msgid.link/20261113235847.517308-2-kudzo51@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/broadcom/bcm4908_enet.c | 57 ++++++++++++--------
 1 file changed, 35 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bcm4908_enet.c b/drivers/net/ethernet/broadcom/bcm4908_enet.c
index 72df1bb101728..c661a752e2d57 100644
--- a/drivers/net/ethernet/broadcom/bcm4908_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm4908_enet.c
@@ -13,6 +13,7 @@
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/string.h>
+#include <net/netdev_queues.h>
 
 #include "bcm4908_enet.h"
 #include "unimac.h"
@@ -518,30 +519,34 @@ static int bcm4908_enet_stop(struct net_device *netdev)
 	return 0;
 }
 
+/* One descriptor always stays unused, so read_idx == write_idx can only
+ * mean an empty ring
+ */
+static int bcm4908_enet_tx_free_descs(struct bcm4908_enet_dma_ring *ring)
+{
+	int free = READ_ONCE(ring->read_idx) - READ_ONCE(ring->write_idx) - 1;
+
+	return free < 0 ? free + ring->length : free;
+}
+
 static netdev_tx_t bcm4908_enet_start_xmit(struct sk_buff *skb, struct net_device *netdev)
 {
+	struct netdev_queue *txq = netdev_get_tx_queue(netdev, 0);
 	struct bcm4908_enet *enet = netdev_priv(netdev);
 	struct bcm4908_enet_dma_ring *ring = &enet->tx_ring;
 	struct bcm4908_enet_dma_ring_slot *slot;
 	struct device *dev = enet->dev;
 	struct bcm4908_enet_dma_ring_bd *buf_desc;
-	int free_buf_descs;
 	u32 tmp;
 
 	/* Free transmitted skbs */
 	if (enet->irq_tx < 0 &&
-	    !(le32_to_cpu(ring->buf_desc[ring->read_idx].ctl) & DMA_CTL_STATUS_OWN))
+	    !(le32_to_cpu(ring->buf_desc[READ_ONCE(ring->read_idx)].ctl) &
+	      DMA_CTL_STATUS_OWN))
 		napi_schedule(&enet->tx_ring.napi);
 
-	/* Don't use the last empty buf descriptor */
-	if (ring->read_idx <= ring->write_idx)
-		free_buf_descs = ring->read_idx - ring->write_idx + ring->length;
-	else
-		free_buf_descs = ring->read_idx - ring->write_idx;
-	if (free_buf_descs < 2) {
-		netif_stop_queue(netdev);
+	if (!netif_txq_maybe_stop(txq, bcm4908_enet_tx_free_descs(ring), 1, 1))
 		return NETDEV_TX_BUSY;
-	}
 
 	/* Hardware removes OWN bit after sending data */
 	buf_desc = &ring->buf_desc[ring->write_idx];
@@ -562,7 +567,7 @@ static netdev_tx_t bcm4908_enet_start_xmit(struct sk_buff *skb, struct net_devic
 	tmp |= DMA_CTL_STATUS_SOP;
 	tmp |= DMA_CTL_STATUS_EOP;
 	tmp |= DMA_CTL_STATUS_APPEND_CRC;
-	if (ring->write_idx + 1 == ring->length - 1)
+	if (ring->write_idx == ring->length - 1)
 		tmp |= DMA_CTL_STATUS_WRAP;
 
 	netdev_sent_queue(enet->netdev, skb->len);
@@ -572,8 +577,13 @@ static netdev_tx_t bcm4908_enet_start_xmit(struct sk_buff *skb, struct net_devic
 
 	bcm4908_enet_dma_tx_ring_enable(enet, &enet->tx_ring);
 
-	if (++ring->write_idx == ring->length - 1)
-		ring->write_idx = 0;
+	if (ring->write_idx == ring->length - 1)
+		WRITE_ONCE(ring->write_idx, 0);
+	else
+		WRITE_ONCE(ring->write_idx, ring->write_idx + 1);
+
+	/* poll_tx() wakes the queue once there is room again */
+	netif_txq_maybe_stop(txq, bcm4908_enet_tx_free_descs(ring), 1, 1);
 
 	return NETDEV_TX_OK;
 }
@@ -652,17 +662,19 @@ static int bcm4908_enet_poll_tx(struct napi_struct *napi, int weight)
 {
 	struct bcm4908_enet_dma_ring *tx_ring = container_of(napi, struct bcm4908_enet_dma_ring, napi);
 	struct bcm4908_enet *enet = container_of(tx_ring, struct bcm4908_enet, tx_ring);
+	struct netdev_queue *txq = netdev_get_tx_queue(enet->netdev, 0);
 	struct bcm4908_enet_dma_ring_bd *buf_desc;
 	struct bcm4908_enet_dma_ring_slot *slot;
 	struct device *dev = enet->dev;
+	int read_idx = tx_ring->read_idx;
 	unsigned int bytes = 0;
 	int handled = 0;
 
-	while (handled < weight && tx_ring->read_idx != tx_ring->write_idx) {
-		buf_desc = &tx_ring->buf_desc[tx_ring->read_idx];
+	while (handled < weight && read_idx != READ_ONCE(tx_ring->write_idx)) {
+		buf_desc = &tx_ring->buf_desc[read_idx];
 		if (le32_to_cpu(buf_desc->ctl) & DMA_CTL_STATUS_OWN)
 			break;
-		slot = &tx_ring->slots[tx_ring->read_idx];
+		slot = &tx_ring->slots[read_idx];
 
 		dma_unmap_single(dev, slot->dma_addr, slot->len, DMA_TO_DEVICE);
 		dev_kfree_skb(slot->skb);
@@ -670,22 +682,23 @@ static int bcm4908_enet_poll_tx(struct napi_struct *napi, int weight)
 		handled++;
 		bytes += slot->len;
 
-		if (++tx_ring->read_idx == tx_ring->length)
-			tx_ring->read_idx = 0;
+		if (++read_idx == tx_ring->length)
+			read_idx = 0;
 	}
+	WRITE_ONCE(tx_ring->read_idx, read_idx);
 
-	netdev_completed_queue(enet->netdev, handled, bytes);
 	enet->netdev->stats.tx_packets += handled;
 	enet->netdev->stats.tx_bytes += bytes;
 
+	/* Reports to BQL, and wakes the queue if start_xmit() stopped it */
+	netif_txq_completed_wake(txq, handled, bytes,
+				 bcm4908_enet_tx_free_descs(tx_ring), 1);
+
 	if (handled < weight) {
 		napi_complete_done(napi, handled);
 		bcm4908_enet_dma_ring_intrs_on(enet, tx_ring);
 	}
 
-	if (netif_queue_stopped(enet->netdev))
-		netif_wake_queue(enet->netdev);
-
 	return handled;
 }
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 202/555] net: bcm4908_enet: drop a TX frame whose DMA mapping failed
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (200 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 201/555] net: bcm4908_enet: fix the TX ring wrap Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 203/555] net: bcm4908_enet: release the TX ring on stop Greg Kroah-Hartman
                   ` (352 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Florian Fainelli,
	Kordian Chmielewski, Jakub Kicinski, Sasha Levin

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

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

From: Kordian Chmielewski <kudzo51@gmail.com>

[ Upstream commit e1d4683fb4cb9d7f45a17c43a56ba2d26ab91ec6 ]

When dma_map_single() fails, start_xmit() returns NETDEV_TX_BUSY with
the queue still running, after it has already stored the skb in the
slot. Documentation/networking/driver.rst treats NETDEV_TX_BUSY under
normal circumstances as a hard error, and a driver that returns it must
not keep any reference to the skb. Here the stack requeues the frame
and retries it while the slot still points at it. Drop the frame
instead: free the skb, count it as dropped and return NETDEV_TX_OK.
Map the buffer before the slot is touched.

Found by reading the code.

Fixes: 4feffeadbcb2 ("net: broadcom: bcm4908enet: add BCM4908 controller driver")
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Kordian Chmielewski <kudzo51@gmail.com>
Link: https://patch.msgid.link/20261113235847.517308-3-kudzo51@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/broadcom/bcm4908_enet.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bcm4908_enet.c b/drivers/net/ethernet/broadcom/bcm4908_enet.c
index c661a752e2d57..e666af7fa28a6 100644
--- a/drivers/net/ethernet/broadcom/bcm4908_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm4908_enet.c
@@ -537,6 +537,7 @@ static netdev_tx_t bcm4908_enet_start_xmit(struct sk_buff *skb, struct net_devic
 	struct bcm4908_enet_dma_ring_slot *slot;
 	struct device *dev = enet->dev;
 	struct bcm4908_enet_dma_ring_bd *buf_desc;
+	dma_addr_t dma_addr;
 	u32 tmp;
 
 	/* Free transmitted skbs */
@@ -555,12 +556,17 @@ static netdev_tx_t bcm4908_enet_start_xmit(struct sk_buff *skb, struct net_devic
 		return NETDEV_TX_BUSY;
 	}
 
+	dma_addr = dma_map_single(dev, skb->data, skb->len, DMA_TO_DEVICE);
+	if (unlikely(dma_mapping_error(dev, dma_addr))) {
+		dev_kfree_skb_any(skb);
+		netdev->stats.tx_dropped++;
+		return NETDEV_TX_OK;
+	}
+
 	slot = &ring->slots[ring->write_idx];
 	slot->skb = skb;
 	slot->len = skb->len;
-	slot->dma_addr = dma_map_single(dev, skb->data, skb->len, DMA_TO_DEVICE);
-	if (unlikely(dma_mapping_error(dev, slot->dma_addr)))
-		return NETDEV_TX_BUSY;
+	slot->dma_addr = dma_addr;
 
 	tmp = skb->len << DMA_CTL_LEN_DESC_BUFLENGTH_SHIFT;
 	tmp |= DMA_CTL_STATUS_OWN;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 203/555] net: bcm4908_enet: release the TX ring on stop
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (201 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 202/555] net: bcm4908_enet: drop a TX frame whose DMA mapping failed Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 204/555] net: bcm4908_enet: unmap the buffer of a dropped RX frame Greg Kroah-Hartman
                   ` (351 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Kordian Chmielewski, Jakub Kicinski,
	Sasha Levin

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

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

From: Kordian Chmielewski <kudzo51@gmail.com>

[ Upstream commit e2785f0ff0a210158933221e86ea5bd066992870 ]

bcm4908_enet_stop() disables the TX DMA but leaves the ring as it is:
the skbs that poll_tx() has not freed yet stay mapped and are never
freed, and the descriptors the DMA has not sent yet keep
DMA_CTL_STATUS_OWN. The skbs, the socket memory they hold and their
mappings leak. The next open starts the indexes from 0 again over
those descriptors, so the DMA may send stale frames from before the
stop, and if the first descriptor still has OWN, start_xmit() stops
the queue before it enables the DMA, with nothing left to wake it.

Wait for the TX DMA channel to stop, as is already done for RX, then
unmap and free the skbs between read_idx and write_idx and leave the
ring empty, so that nothing can free them a second time. If the
channel does not stop in time, leave the skbs alone rather than free
them while the DMA may still read them. Clear the TX descriptors when
the ring is initialised. A descriptor that start_xmit() is about to
use then never carries OWN, so drop the check that stopped the queue
on one. The RX helper's timeout warning said TX; make it say RX.

Found by reading the code; I have not seen these on the hardware.

Fixes: 4feffeadbcb2 ("net: broadcom: bcm4908enet: add BCM4908 controller driver")
Signed-off-by: Kordian Chmielewski <kudzo51@gmail.com>
Link: https://patch.msgid.link/20261113235847.517308-4-kudzo51@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/broadcom/bcm4908_enet.c | 55 ++++++++++++++++----
 1 file changed, 44 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bcm4908_enet.c b/drivers/net/ethernet/broadcom/bcm4908_enet.c
index e666af7fa28a6..af68b479d805d 100644
--- a/drivers/net/ethernet/broadcom/bcm4908_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm4908_enet.c
@@ -7,6 +7,7 @@
 #include <linux/etherdevice.h>
 #include <linux/if_vlan.h>
 #include <linux/interrupt.h>
+#include <linux/iopoll.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_net.h>
@@ -313,6 +314,11 @@ static void bcm4908_enet_dma_ring_init(struct bcm4908_enet *enet,
 	enet_write(enet, ring->st_ram_block + ENET_DMA_CH_STATE_RAM_BASE_DESC_PTR,
 		   (uint32_t)ring->dma_addr);
 
+	/* A descriptor the stopped DMA never completed still carries OWN */
+	if (ring->is_tx)
+		memset(ring->buf_desc, 0,
+		       ring->length * sizeof(*ring->buf_desc));
+
 	ring->read_idx = 0;
 	ring->write_idx = 0;
 }
@@ -362,10 +368,22 @@ static void bcm4908_enet_dma_tx_ring_enable(struct bcm4908_enet *enet,
 	enet_write(enet, ring->cfg_block + ENET_DMA_CH_CFG, ENET_DMA_CH_CFG_ENABLE);
 }
 
-static void bcm4908_enet_dma_tx_ring_disable(struct bcm4908_enet *enet,
-					     struct bcm4908_enet_dma_ring *ring)
+static int bcm4908_enet_dma_tx_ring_disable(struct bcm4908_enet *enet,
+					    struct bcm4908_enet_dma_ring *ring)
 {
+	u32 tmp;
+	int err;
+
 	enet_write(enet, ring->cfg_block + ENET_DMA_CH_CFG, 0);
+
+	/* Wait for the channel to stop, as for RX, before freeing buffers */
+	err = read_poll_timeout(enet_read, tmp, !(tmp & ENET_DMA_CH_CFG_ENABLE),
+				10, 2000, false, enet,
+				ring->cfg_block + ENET_DMA_CH_CFG);
+	if (err)
+		dev_warn(enet->dev, "Timeout waiting for DMA TX stop\n");
+
+	return err;
 }
 
 static void bcm4908_enet_dma_rx_ring_enable(struct bcm4908_enet *enet,
@@ -391,7 +409,7 @@ static void bcm4908_enet_dma_rx_ring_disable(struct bcm4908_enet *enet,
 		usleep_range(10, 30);
 	} while (!time_after_eq(jiffies, deadline));
 
-	dev_warn(enet->dev, "Timeout waiting for DMA TX stop\n");
+	dev_warn(enet->dev, "Timeout waiting for DMA RX stop\n");
 }
 
 /***
@@ -496,6 +514,25 @@ static int bcm4908_enet_open(struct net_device *netdev)
 	return 0;
 }
 
+static void bcm4908_enet_tx_ring_clean(struct bcm4908_enet *enet)
+{
+	struct bcm4908_enet_dma_ring *tx_ring = &enet->tx_ring;
+	struct device *dev = enet->dev;
+	int i;
+
+	for (i = tx_ring->read_idx; i != tx_ring->write_idx;
+	     i = i == tx_ring->length - 1 ? 0 : i + 1) {
+		struct bcm4908_enet_dma_ring_slot *slot = &tx_ring->slots[i];
+
+		dma_unmap_single(dev, slot->dma_addr, slot->len, DMA_TO_DEVICE);
+		dev_kfree_skb_any(slot->skb);
+	}
+
+	/* Leave the ring empty, so that nothing frees these skbs again */
+	tx_ring->read_idx = 0;
+	tx_ring->write_idx = 0;
+}
+
 static int bcm4908_enet_stop(struct net_device *netdev)
 {
 	struct bcm4908_enet *enet = netdev_priv(netdev);
@@ -509,8 +546,10 @@ static int bcm4908_enet_stop(struct net_device *netdev)
 	netdev_reset_queue(netdev);
 
 	bcm4908_enet_dma_rx_ring_disable(enet, &enet->rx_ring);
-	bcm4908_enet_dma_tx_ring_disable(enet, &enet->tx_ring);
 
+	/* Leave the TX buffers alone if the channel may still read them */
+	if (!bcm4908_enet_dma_tx_ring_disable(enet, &enet->tx_ring))
+		bcm4908_enet_tx_ring_clean(enet);
 	bcm4908_enet_dma_uninit(enet);
 
 	free_irq(enet->irq_tx, enet);
@@ -549,13 +588,6 @@ static netdev_tx_t bcm4908_enet_start_xmit(struct sk_buff *skb, struct net_devic
 	if (!netif_txq_maybe_stop(txq, bcm4908_enet_tx_free_descs(ring), 1, 1))
 		return NETDEV_TX_BUSY;
 
-	/* Hardware removes OWN bit after sending data */
-	buf_desc = &ring->buf_desc[ring->write_idx];
-	if (unlikely(le32_to_cpu(buf_desc->ctl) & DMA_CTL_STATUS_OWN)) {
-		netif_stop_queue(netdev);
-		return NETDEV_TX_BUSY;
-	}
-
 	dma_addr = dma_map_single(dev, skb->data, skb->len, DMA_TO_DEVICE);
 	if (unlikely(dma_mapping_error(dev, dma_addr))) {
 		dev_kfree_skb_any(skb);
@@ -563,6 +595,7 @@ static netdev_tx_t bcm4908_enet_start_xmit(struct sk_buff *skb, struct net_devic
 		return NETDEV_TX_OK;
 	}
 
+	buf_desc = &ring->buf_desc[ring->write_idx];
 	slot = &ring->slots[ring->write_idx];
 	slot->skb = skb;
 	slot->len = skb->len;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 204/555] net: bcm4908_enet: unmap the buffer of a dropped RX frame
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (202 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 203/555] net: bcm4908_enet: release the TX ring on stop Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 205/555] net: bcm4908_enet: unmap RX buffers on stop with their mapped size Greg Kroah-Hartman
                   ` (350 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Florian Fainelli,
	Kordian Chmielewski, Jakub Kicinski, Sasha Levin

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

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

From: Kordian Chmielewski <kudzo51@gmail.com>

[ Upstream commit 1b48d619448c8425bd907722784f08e4e8fa4c5b ]

When poll_rx() drops a frame (too short, or not in a single buffer),
it frees the buffer without unmapping it first, so the memory goes
back to the page allocator while still mapped for the device. Unmap it
as the path for good frames does.

Found by reading the code.

Fixes: 4dc7f09b8bec ("net: broadcom: bcm4908_enet: fix RX path possible mem leak")
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Kordian Chmielewski <kudzo51@gmail.com>
Link: https://patch.msgid.link/20261113235847.517308-5-kudzo51@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/broadcom/bcm4908_enet.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bcm4908_enet.c b/drivers/net/ethernet/broadcom/bcm4908_enet.c
index af68b479d805d..d531bb56703e2 100644
--- a/drivers/net/ethernet/broadcom/bcm4908_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm4908_enet.c
@@ -661,6 +661,8 @@ static int bcm4908_enet_poll_rx(struct napi_struct *napi, int weight)
 
 		if (len < ETH_ZLEN ||
 		    (ctl & (DMA_CTL_STATUS_SOP | DMA_CTL_STATUS_EOP)) != (DMA_CTL_STATUS_SOP | DMA_CTL_STATUS_EOP)) {
+			dma_unmap_single(dev, slot.dma_addr,
+					 ENET_RX_BUF_DMA_SIZE, DMA_FROM_DEVICE);
 			skb_free_frag(slot.buf);
 			enet->netdev->stats.rx_dropped++;
 			break;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 205/555] net: bcm4908_enet: unmap RX buffers on stop with their mapped size
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (203 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 204/555] net: bcm4908_enet: unmap the buffer of a dropped RX frame Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 206/555] net: bcm4908_enet: publish the buffer address before OWN Greg Kroah-Hartman
                   ` (349 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Florian Fainelli,
	Kordian Chmielewski, Jakub Kicinski, Sasha Levin

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

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

From: Kordian Chmielewski <kudzo51@gmail.com>

[ Upstream commit 1da02595e8d2647a04c2cdd4f668dee0b8ac1ae9 ]

Since the switch to build_skb() the RX buffers are mapped with
ENET_RX_BUF_DMA_SIZE and slot->len is no longer set for them, but
bcm4908_enet_dma_uninit() still unmaps them with slot->len. Use the
size they were mapped with.

Found by reading the code.

Fixes: 3a1cc23a75ab ("net: broadcom: bcm4908_enet: use build_skb()")
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Kordian Chmielewski <kudzo51@gmail.com>
Link: https://patch.msgid.link/20261113235847.517308-6-kudzo51@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/broadcom/bcm4908_enet.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bcm4908_enet.c b/drivers/net/ethernet/broadcom/bcm4908_enet.c
index d531bb56703e2..a44ab9169d024 100644
--- a/drivers/net/ethernet/broadcom/bcm4908_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm4908_enet.c
@@ -334,7 +334,8 @@ static void bcm4908_enet_dma_uninit(struct bcm4908_enet *enet)
 		slot = &rx_ring->slots[i];
 		if (!slot->buf)
 			continue;
-		dma_unmap_single(dev, slot->dma_addr, slot->len, DMA_FROM_DEVICE);
+		dma_unmap_single(dev, slot->dma_addr, ENET_RX_BUF_DMA_SIZE,
+				 DMA_FROM_DEVICE);
 		skb_free_frag(slot->buf);
 		slot->buf = NULL;
 	}
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 206/555] net: bcm4908_enet: publish the buffer address before OWN
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (204 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 205/555] net: bcm4908_enet: unmap RX buffers on stop with their mapped size Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 207/555] net: bcm4908_enet: order the TX ring index accesses Greg Kroah-Hartman
                   ` (348 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Florian Fainelli,
	Kordian Chmielewski, Jakub Kicinski, Sasha Levin

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

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

From: Kordian Chmielewski <kudzo51@gmail.com>

[ Upstream commit 4d47e6c2f3ceb638d4ea5c21e304b20f526255bd ]

bcm4908_enet_dma_alloc_rx_buf() hands a descriptor to the DMA by
writing its control word, with DMA_CTL_STATUS_OWN, first and the new
buffer address second. If the DMA read the descriptor between the two
stores, it would write the next frame into the old buffer, which
poll_rx() is turning into an skb. start_xmit() writes the address
first, but nothing orders the two stores, and the descriptors live in
coherent memory, where arm64 may make them visible in either order.

Write the address first on both paths and order it before the control
word with dma_wmb(). In poll_rx(), read what the DMA wrote only after
seeing OWN clear (dma_rmb()), as Documentation/memory-barriers.txt
describes for descriptors shared with a device.

Found by reading the code; I have no test that shows the DMA reading a
descriptor while it is being refilled.

Fixes: 4feffeadbcb2 ("net: broadcom: bcm4908enet: add BCM4908 controller driver")
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Kordian Chmielewski <kudzo51@gmail.com>
Link: https://patch.msgid.link/20261113235847.517308-7-kudzo51@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/broadcom/bcm4908_enet.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bcm4908_enet.c b/drivers/net/ethernet/broadcom/bcm4908_enet.c
index a44ab9169d024..8456e35f6af82 100644
--- a/drivers/net/ethernet/broadcom/bcm4908_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm4908_enet.c
@@ -291,8 +291,10 @@ static int bcm4908_enet_dma_alloc_rx_buf(struct bcm4908_enet *enet, unsigned int
 	tmp |= DMA_CTL_STATUS_OWN;
 	if (idx == enet->rx_ring.length - 1)
 		tmp |= DMA_CTL_STATUS_WRAP;
-	buf_desc->ctl = cpu_to_le32(tmp);
 	buf_desc->addr = cpu_to_le32(slot->dma_addr);
+	/* Hand the descriptor to the DMA only once it holds the new buffer */
+	dma_wmb();
+	buf_desc->ctl = cpu_to_le32(tmp);
 
 	return 0;
 }
@@ -613,6 +615,8 @@ static netdev_tx_t bcm4908_enet_start_xmit(struct sk_buff *skb, struct net_devic
 	netdev_sent_queue(enet->netdev, skb->len);
 
 	buf_desc->addr = cpu_to_le32((uint32_t)slot->dma_addr);
+	/* The DMA must not see OWN before the buffer address */
+	dma_wmb();
 	buf_desc->ctl = cpu_to_le32(tmp);
 
 	bcm4908_enet_dma_tx_ring_enable(enet, &enet->tx_ring);
@@ -647,6 +651,8 @@ static int bcm4908_enet_poll_rx(struct napi_struct *napi, int weight)
 		ctl = le32_to_cpu(buf_desc->ctl);
 		if (ctl & DMA_CTL_STATUS_OWN)
 			break;
+		/* Read the rest only after the DMA gave the descriptor back */
+		dma_rmb();
 
 		slot = enet->rx_ring.slots[enet->rx_ring.read_idx];
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 207/555] net: bcm4908_enet: order the TX ring index accesses
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (205 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 206/555] net: bcm4908_enet: publish the buffer address before OWN Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 208/555] scsi: pm8001: Offset hardware queue index for MSI-X pre-vector Greg Kroah-Hartman
                   ` (347 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Kordian Chmielewski, Jakub Kicinski,
	Sasha Levin

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

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

From: Kordian Chmielewski <kudzo51@gmail.com>

[ Upstream commit ebe31472ad0a08e19a31a6647b99c6b51f90026c ]

Since the TX interrupt was added, poll_tx() runs in its own NAPI and
does not take the TX queue lock, so it and start_xmit() share the TX
ring with only the two indexes between them. Nothing orders the
accesses around those indexes:

- poll_tx() reads write_idx, then the descriptor and the slot. On arm64
  the later loads may be satisfied first, so poll_tx() may see the new
  write_idx together with the previous lap's descriptor, which has no
  OWN, and the previous lap's slot. It would then unmap and free a
  frame the DMA has not sent yet, or free the old skb a second time.
- poll_tx() publishes read_idx once it is done with the slots it
  freed, but that store is not ordered after its loads from those
  slots, so start_xmit() may refill a slot before poll_tx() has read
  it.

Publish each index with smp_store_release() and read the other side's
index with smp_load_acquire() before touching the slots. start_xmit()
now publishes write_idx right after the descriptor, before the MMIO
write that kicks the DMA rather than after it, which narrows the window
in which the DMA can complete a frame that poll_tx() cannot see yet.

Sashiko's review of the previous version of this series pointed this
out; I have not seen it on the hardware.

Fixes: 12bb508bfe5a ("net: broadcom: bcm4908_enet: support TX interrupt")
Signed-off-by: Kordian Chmielewski <kudzo51@gmail.com>
Link: https://patch.msgid.link/20261113235847.517308-8-kudzo51@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/broadcom/bcm4908_enet.c | 26 ++++++++++++++------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bcm4908_enet.c b/drivers/net/ethernet/broadcom/bcm4908_enet.c
index 8456e35f6af82..643ecc67fe1c0 100644
--- a/drivers/net/ethernet/broadcom/bcm4908_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm4908_enet.c
@@ -566,7 +566,9 @@ static int bcm4908_enet_stop(struct net_device *netdev)
  */
 static int bcm4908_enet_tx_free_descs(struct bcm4908_enet_dma_ring *ring)
 {
-	int free = READ_ONCE(ring->read_idx) - READ_ONCE(ring->write_idx) - 1;
+	/* Pairs with smp_store_release() in bcm4908_enet_poll_tx() */
+	int free = smp_load_acquire(&ring->read_idx) -
+		   READ_ONCE(ring->write_idx) - 1;
 
 	return free < 0 ? free + ring->length : free;
 }
@@ -619,12 +621,14 @@ static netdev_tx_t bcm4908_enet_start_xmit(struct sk_buff *skb, struct net_devic
 	dma_wmb();
 	buf_desc->ctl = cpu_to_le32(tmp);
 
-	bcm4908_enet_dma_tx_ring_enable(enet, &enet->tx_ring);
+	/* Publish the slot and the descriptor before the index; pairs with
+	 * smp_load_acquire() in bcm4908_enet_poll_tx()
+	 */
+	smp_store_release(&ring->write_idx,
+			  ring->write_idx < ring->length - 1 ?
+			  ring->write_idx + 1 : 0);
 
-	if (ring->write_idx == ring->length - 1)
-		WRITE_ONCE(ring->write_idx, 0);
-	else
-		WRITE_ONCE(ring->write_idx, ring->write_idx + 1);
+	bcm4908_enet_dma_tx_ring_enable(enet, &enet->tx_ring);
 
 	/* poll_tx() wakes the queue once there is room again */
 	netif_txq_maybe_stop(txq, bcm4908_enet_tx_free_descs(ring), 1, 1);
@@ -718,7 +722,10 @@ static int bcm4908_enet_poll_tx(struct napi_struct *napi, int weight)
 	unsigned int bytes = 0;
 	int handled = 0;
 
-	while (handled < weight && read_idx != READ_ONCE(tx_ring->write_idx)) {
+	while (handled < weight) {
+		/* Pairs with the release in bcm4908_enet_start_xmit() */
+		if (read_idx == smp_load_acquire(&tx_ring->write_idx))
+			break;
 		buf_desc = &tx_ring->buf_desc[read_idx];
 		if (le32_to_cpu(buf_desc->ctl) & DMA_CTL_STATUS_OWN)
 			break;
@@ -733,7 +740,10 @@ static int bcm4908_enet_poll_tx(struct napi_struct *napi, int weight)
 		if (++read_idx == tx_ring->length)
 			read_idx = 0;
 	}
-	WRITE_ONCE(tx_ring->read_idx, read_idx);
+	/* Be done with the slots before start_xmit() may reuse them; pairs
+	 * with smp_load_acquire() in bcm4908_enet_tx_free_descs()
+	 */
+	smp_store_release(&tx_ring->read_idx, read_idx);
 
 	enet->netdev->stats.tx_packets += handled;
 	enet->netdev->stats.tx_bytes += bytes;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 208/555] scsi: pm8001: Offset hardware queue index for MSI-X pre-vector
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (206 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 207/555] net: bcm4908_enet: order the TX ring index accesses Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 209/555] dmaengine: stm32-mdma: Fix runtime PM reference leak in pm_suspend Greg Kroah-Hartman
                   ` (346 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Terrence Adams, Bart Van Assche,
	Martin K. Petersen (Oracle), Sasha Levin

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

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

From: Terrence Adams <tadamsjr@google.com>

[ Upstream commit 3ad578b22f7a34a2391ca8910dfc931b01cc94f6 ]

When MSI-X interrupt vectors are configured in pm8001_setup_msix(), the
driver requests vector affinity with .pre_vectors = 1 to reserve Vector 0
for non-affinitized housekeeping interrupts.

blk_mq_map_hw_queues() maps hardware queues (hwq 0 to nr_hw_queues - 1)
with an offset of 1, mapping hwq 0 to Vector 1, hwq 1 to Vector 2, etc.

However, pm80xx_chip_get_q_index() retrieves the queue index directly from
blk_mq_unique_tag_to_hwq(tag) without adding 1 for the pre-vector
offset. Consequently, commands on hwq 0 are issued with responseQueue 0
(firing unmanaged Vector 0 on CPU 0), while hwq k fires Vector k (the CPU
affinitized to hwq k-1).

This results in 100% of I/O completion interrupts being delivered to the
wrong CPU core, causing heavy cross-CPU IPIs, cache line bouncing, and
increased kernel and IRQ CPU processing overhead.

Define PM8001_PRE_VECTORS for the reserved housekeeping vector and use it
consistently across MSI-X vector allocation, hardware queue setup and
mapping, and queue index lookup. Update pm80xx_chip_get_q_index() to accept
pm8001_ha and add PM8001_PRE_VECTORS to blk_mq_unique_tag_to_hwq() whenever
multi-queue is enabled (number_of_intr > PM8001_PRE_VECTORS), routing
completion interrupts to their affinitized CPU cores.

Note that offsetting completions by PM8001_PRE_VECTORS routes the highest
hardware queue to outbound queue max_q_num - 1, which pm80xx_chip_init()
also programs as the fatal error interrupt vector.  As a result,
process_oq() now reads MSGU_SCRATCH_PAD_1 (and MSGU_SCRATCH_PAD_RSVD_0 when
no fatal error is reported) on every interrupt for that queue, matching the
behavior before commit 42f22fe36d51 ("scsi: pm8001: Expose hardware queues
for pm80xx").

Fixes: 42f22fe36d51 ("scsi: pm8001: Expose hardware queues for pm80xx")
Signed-off-by: Terrence Adams <tadamsjr@google.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://patch.msgid.link/20261118180344.1159617-1-tadamsjr@google.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/scsi/pm8001/pm8001_defs.h |  1 +
 drivers/scsi/pm8001/pm8001_init.c | 15 +++++++++------
 drivers/scsi/pm8001/pm80xx_hwi.c  | 13 +++++++++----
 3 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/pm8001/pm8001_defs.h b/drivers/scsi/pm8001/pm8001_defs.h
index ff7b282090792..4119cc40af132 100644
--- a/drivers/scsi/pm8001/pm8001_defs.h
+++ b/drivers/scsi/pm8001/pm8001_defs.h
@@ -178,6 +178,7 @@ enum port_type {
 #define	PM8001_MAX_INB_NUM	 64
 #define	PM8001_MAX_OUTB_NUM	 64
 #define	PM8001_CAN_QUEUE	 508	/* SCSI Queue depth */
+#define	PM8001_PRE_VECTORS	 1	/* non-affinitized housekeeping vector */
 
 /* Inbound/Outbound queue size */
 #define IOMB_SIZE_SPC		64
diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c
index 01383196d806c..d8abcbfc7bd7d 100644
--- a/drivers/scsi/pm8001/pm8001_init.c
+++ b/drivers/scsi/pm8001/pm8001_init.c
@@ -100,8 +100,9 @@ static void pm8001_map_queues(struct Scsi_Host *shost)
 	struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
 	struct blk_mq_queue_map *qmap = &shost->tag_set.map[HCTX_TYPE_DEFAULT];
 
-	if (pm8001_ha->number_of_intr > 1) {
-		blk_mq_map_hw_queues(qmap, &pm8001_ha->pdev->dev, 1);
+	if (pm8001_ha->number_of_intr > PM8001_PRE_VECTORS) {
+		blk_mq_map_hw_queues(qmap, &pm8001_ha->pdev->dev,
+				     PM8001_PRE_VECTORS);
 		return;
 	}
 
@@ -975,10 +976,11 @@ static u32 pm8001_setup_msix(struct pm8001_hba_info *pm8001_ha)
 		 * include in the affinity spreading.
 		 */
 		struct irq_affinity desc = {
-			.pre_vectors = 1,
+			.pre_vectors = PM8001_PRE_VECTORS,
 		};
 		rc = pci_alloc_irq_vectors_affinity(
-				pm8001_ha->pdev, 2, PM8001_MAX_MSIX_VEC,
+				pm8001_ha->pdev, PM8001_PRE_VECTORS + 1,
+				PM8001_MAX_MSIX_VEC,
 				PCI_IRQ_MSIX | PCI_IRQ_AFFINITY, &desc);
 	}
 
@@ -1181,8 +1183,9 @@ static int pm8001_pci_probe(struct pci_dev *pdev,
 
 	PM8001_CHIP_DISP->chip_post_init(pm8001_ha);
 
-	if (pm8001_ha->number_of_intr > 1) {
-		shost->nr_hw_queues = pm8001_ha->number_of_intr - 1;
+	if (pm8001_ha->number_of_intr > PM8001_PRE_VECTORS) {
+		shost->nr_hw_queues = pm8001_ha->number_of_intr -
+				      PM8001_PRE_VECTORS;
 		/*
 		 * For now, ensure we're not sent too many commands by setting
 		 * host_tagset. This is also required if we start using request
diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c
index fd71f38d1401e..ea9c55edac8ae 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.c
+++ b/drivers/scsi/pm8001/pm80xx_hwi.c
@@ -4265,14 +4265,19 @@ static int check_enc_sat_cmd(struct sas_task *task)
 	return ret;
 }
 
-static u32 pm80xx_chip_get_q_index(struct sas_task *task)
+static u32 pm80xx_chip_get_q_index(struct pm8001_hba_info *pm8001_ha,
+				   struct sas_task *task)
 {
 	struct request *rq = sas_task_find_rq(task);
 
 	if (!rq)
 		return 0;
 
-	return blk_mq_unique_tag_to_hwq(blk_mq_unique_tag(rq));
+	if (pm8001_ha->number_of_intr > PM8001_PRE_VECTORS)
+		return blk_mq_unique_tag_to_hwq(blk_mq_unique_tag(rq)) +
+		       PM8001_PRE_VECTORS;
+
+	return 0;
 }
 
 /**
@@ -4308,7 +4313,7 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha,
 	ssp_cmd.ssp_iu.efb_prio_attr |= (task->ssp_task.task_attr & 7);
 	memcpy(ssp_cmd.ssp_iu.cdb, task->ssp_task.cmd->cmnd,
 		       task->ssp_task.cmd->cmd_len);
-	q_index = pm80xx_chip_get_q_index(task);
+	q_index = pm80xx_chip_get_q_index(pm8001_ha, task);
 
 	/* Check if encryption is set */
 	if (pm8001_ha->chip->encrypt &&
@@ -4447,7 +4452,7 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
 	u32 opc = OPC_INB_SATA_HOST_OPSTART;
 	memset(&sata_cmd, 0, sizeof(sata_cmd));
 
-	q_index = pm80xx_chip_get_q_index(task);
+	q_index = pm80xx_chip_get_q_index(pm8001_ha, task);
 
 	if (task->data_dir == DMA_NONE && !task->ata_task.use_ncq) {
 		ATAP = 0x04; /* no data*/
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 209/555] dmaengine: stm32-mdma: Fix runtime PM reference leak in pm_suspend
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (207 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 208/555] scsi: pm8001: Offset hardware queue index for MSI-X pre-vector Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 210/555] dmaengine: idxd: Free the minor number when cdev setup fails Greg Kroah-Hartman
                   ` (345 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Xiangwu Lai, Frank Li,
	Amelie Delaunay, Vinod Koul, Sasha Levin

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

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

From: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>

[ Upstream commit 34c8c2ea213aab7b452df93e5b7547f4459a49e9 ]

stm32_mdma_pm_suspend() increments the runtime PM usage counter with
pm_runtime_resume_and_get(), but when a channel is still enabled it
returns -EBUSY directly without dropping the reference.  The matching
pm_runtime_put_sync() only runs on the success path.

Each failed suspend attempt therefore leaks one runtime PM reference,
so the device can never runtime suspend afterwards.  Drop the
reference before returning -EBUSY.

Fixes: 7cb819c856d9 ("dmaengine: stm32-mdma: add suspend/resume power management support")
Signed-off-by: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Link: https://patch.msgid.link/20261102104432.873-1-laixiangwu@cmss.chinamobile.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/dma/stm32/stm32-mdma.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/dma/stm32/stm32-mdma.c b/drivers/dma/stm32/stm32-mdma.c
index 3560a6945fbfc..958a79c6e76ac 100644
--- a/drivers/dma/stm32/stm32-mdma.c
+++ b/drivers/dma/stm32/stm32-mdma.c
@@ -1785,6 +1785,7 @@ static int stm32_mdma_pm_suspend(struct device *dev)
 		ccr = stm32_mdma_read(dmadev, STM32_MDMA_CCR(id));
 		if (ccr & STM32_MDMA_CCR_EN) {
 			dev_warn(dev, "Suspend is prevented by Chan %i\n", id);
+			pm_runtime_put_sync(dev);
 			return -EBUSY;
 		}
 	}
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 210/555] dmaengine: idxd: Free the minor number when cdev setup fails
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (208 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 209/555] dmaengine: stm32-mdma: Fix runtime PM reference leak in pm_suspend Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 211/555] dmaengine: rcar-dmac: Fix PM usage counter imbalance Greg Kroah-Hartman
                   ` (344 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, SeungUk Nam, Frank Li, Vinod Koul,
	Sasha Levin

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

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

From: SeungUk Nam <tmddnr49449@gmail.com>

[ Upstream commit 56cbd7f69ce6037738410a5c50efb7cacf52b0ae ]

idxd_wq_add_cdev() allocates a minor number from cdev_ctx->minor_ida for
the new struct idxd_cdev. When dev_set_name() or cdev_device_add()
fails, the error path calls put_device(), and the release callback
idxd_cdev_dev_release() only frees idxd_cdev, so the minor number is
never returned to the ida. Leaked numbers accumulate across bind/unbind
cycles, up to MINORMASK, for as long as the module stays loaded.

Free the minor number before put_device() drops the last reference on
that path.

Fixes: c311f5e92484 ("dmaengine: idxd: Fix freeing the allocated ida too late")
Signed-off-by: SeungUk Nam <tmddnr49449@gmail.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20260910074832.15729-1-tmddnr49449@gmail.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/dma/idxd/cdev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/dma/idxd/cdev.c b/drivers/dma/idxd/cdev.c
index 14b322ac6e6c6..1cd4afbdc8c68 100644
--- a/drivers/dma/idxd/cdev.c
+++ b/drivers/dma/idxd/cdev.c
@@ -576,6 +576,7 @@ int idxd_wq_add_cdev(struct idxd_wq *wq)
 	return 0;
 
  err:
+	ida_free(&cdev_ctx->minor_ida, minor);
 	put_device(dev);
 	wq->idxd_cdev = NULL;
 	return rc;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 211/555] dmaengine: rcar-dmac: Fix PM usage counter imbalance
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (209 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 210/555] dmaengine: idxd: Free the minor number when cdev setup fails Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 212/555] dmaengine: rcar-dmac: Add missing dma_descriptor_unmap() Greg Kroah-Hartman
                   ` (343 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Zhang Shurong, Geert Uytterhoeven,
	Frank Li, Laurent Pinchart, Wolfram Sang, Vinod Koul, Sasha Levin

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

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

From: Zhang Shurong <zhang_shurong@foxmail.com>

[ Upstream commit d3c108c095712a3b7eab292ef7ea9a57ff5cd5d7 ]

pm_runtime_get_sync will increment pm usage counter even it failed.
Forgetting to putting operation will result in reference leak here. We
fix it by replacing it with pm_runtime_resume_and_get to keep usage
counter balanced.

Fixes: 87244fe5abdf ("dmaengine: rcar-dmac: Add Renesas R-Car Gen2 DMA Controller (DMAC) driver")
Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Link: https://patch.msgid.link/20261012123020.11320-6-wsa+renesas@sang-engineering.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/dma/sh/rcar-dmac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 1094a2f821649..5388115e8f52f 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -1068,7 +1068,7 @@ static int rcar_dmac_alloc_chan_resources(struct dma_chan *chan)
 	if (ret < 0)
 		return -ENOMEM;
 
-	return pm_runtime_get_sync(chan->device->dev);
+	return pm_runtime_resume_and_get(chan->device->dev);
 }
 
 static void rcar_dmac_free_chan_resources(struct dma_chan *chan)
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 212/555] dmaengine: rcar-dmac: Add missing dma_descriptor_unmap()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (210 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 211/555] dmaengine: rcar-dmac: Fix PM usage counter imbalance Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 213/555] usb: gadget: f_hid: fix report_list entries leak Greg Kroah-Hartman
                   ` (342 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Koichiro Den, Wolfram Sang, Frank Li,
	Vinod Koul, Sasha Levin

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

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

From: Koichiro Den <den@valinux.co.jp>

[ Upstream commit 0ca154b10168d8874b871edf5510640c51b326c3 ]

Call dma_descriptor_unmap() right before dma_cookie_complete() in the
threaded IRQ completion path. Without this, streaming DMA mappings
attached to the descriptor are never released and may eventually exhaust
DMA mapping resources (e.g. IOVA with an IOMMU or bounce-buffer slots
with SWIOTLB), leading to dma_map_* failures.

Also ensure dma_descriptor_unmap() is called in rcar_dmac_chan_reinit()
(error/terminate path) to avoid the same type of leaks.

Fixes: 87244fe5abdf ("dmaengine: rcar-dmac: Add Renesas R-Car Gen2 DMA Controller (DMAC) driver")
Signed-off-by: Koichiro Den <den@valinux.co.jp>
[wsa: moved unmap before cookie completion, added Fixes tag]
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20261012123020.11320-7-wsa+renesas@sang-engineering.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/dma/sh/rcar-dmac.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 5388115e8f52f..0465715891bd1 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -842,6 +842,7 @@ static void rcar_dmac_chan_reinit(struct rcar_dmac_chan *chan)
 
 	list_for_each_entry_safe(desc, _desc, &descs, node) {
 		list_del(&desc->node);
+		dma_descriptor_unmap(&desc->async_tx);
 		rcar_dmac_desc_put(chan, desc);
 	}
 }
@@ -1651,6 +1652,7 @@ static irqreturn_t rcar_dmac_isr_channel_thread(int irq, void *dev)
 	while (!list_empty(&chan->desc.done)) {
 		desc = list_first_entry(&chan->desc.done, struct rcar_dmac_desc,
 					node);
+		dma_descriptor_unmap(&desc->async_tx);
 		dma_cookie_complete(&desc->async_tx);
 		list_del(&desc->node);
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 213/555] usb: gadget: f_hid: fix report_list entries leak
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (211 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 212/555] dmaengine: rcar-dmac: Add missing dma_descriptor_unmap() Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 214/555] usb: gadget: f_hid: fix race between userspace report update and GET_REPORT response Greg Kroah-Hartman
                   ` (341 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Shunbo Shi, Sasha Levin

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

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

From: Shunbo Shi <shishunbo@cmss.chinamobile.com>

[ Upstream commit 19e8981057fb5947697f99a3c6a3f6ff4a2d85a1 ]

Each GADGET_HID_WRITE_GET_REPORT ioctl for a report ID that is not
yet in hidg->report_list allocates a report_entry and adds it to
the list.  hidg_release() frees report_desc and set_report_buf, but
never walks report_list, so every accumulated entry leaks on
function destroy (e.g. when the HID gadget is unbound and the
device is removed).

Free the entries in hidg_release().  This is safe without extra
locking: at release time the function is unbound (the workqueue is
already destroyed and userspace has no way to reach the ioctl).

Fixes: a139c98f760e ("USB: gadget: f_hid: Add GET_REPORT via userspace IOCTL")
Signed-off-by: Shunbo Shi <shishunbo@cmss.chinamobile.com>
Link: https://patch.msgid.link/20261117125051.5646-2-shishunbo@cmss.chinamobile.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/usb/gadget/function/f_hid.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
index b5702ccb7b2f2..c48496efc2a30 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -118,6 +118,12 @@ static inline struct f_hidg *func_to_hidg(struct usb_function *f)
 static void hidg_release(struct device *dev)
 {
 	struct f_hidg *hidg = container_of(dev, struct f_hidg, dev);
+	struct report_entry *entry, *tmp;
+
+	list_for_each_entry_safe(entry, tmp, &hidg->report_list, node) {
+		list_del(&entry->node);
+		kfree(entry);
+	}
 
 	kfree(hidg->report_desc);
 	kfree(hidg->set_report_buf);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 214/555] usb: gadget: f_hid: fix race between userspace report update and GET_REPORT response
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (212 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 213/555] usb: gadget: f_hid: fix report_list entries leak Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 215/555] usb: gadget: f_hid: fix get_req leak when usb_gstrings_attach() fails Greg Kroah-Hartman
                   ` (340 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Shunbo Shi, Sasha Levin

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

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

From: Shunbo Shi <shishunbo@cmss.chinamobile.com>

[ Upstream commit 07ec204e8aecbfee425008832b18d5d720daca6d ]

The GET_REPORT response is served by pointing get_req->buf at the
data[] array of a report_list entry and calling usb_ep_queue().
The request completes asynchronously, so the controller may still
be reading the entry's buffer after get_report_workqueue_handler()
drops get_report_spinlock.

At the same time, userspace can update that same entry via the
GADGET_HID_WRITE_GET_REPORT ioctl: f_hidg_get_report() copies new
report data into the entry while holding the spinlock, but the
transfer reading the entry is not serialized against that update
(the lock was already released by the work handler).

The result is that the host can receive a GET_REPORT response that
mixes bytes of the old and the new report (a torn write), with no
memory-safety violation but corrupted report data on the wire.

Serve the response from a dedicated buffer allocated once in
hidg_alloc() and freed in hidg_release().

This also removes the now unused get_report member from struct
f_hidg.

Fixes: a139c98f760e ("USB: gadget: f_hid: Add GET_REPORT via userspace IOCTL")
Signed-off-by: Shunbo Shi <shishunbo@cmss.chinamobile.com>
Link: https://patch.msgid.link/20261117125051.5646-3-shishunbo@cmss.chinamobile.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/usb/gadget/function/f_hid.c | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
index c48496efc2a30..e3b88af534856 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -91,7 +91,7 @@ struct f_hidg {
 
 	/* get report */
 	struct usb_request		*get_req;
-	struct usb_hidg_report		get_report;
+	void				*get_req_buf;
 	bool				get_report_returned;
 	int				get_report_req_report_id;
 	int				get_report_req_report_length;
@@ -125,6 +125,7 @@ static void hidg_release(struct device *dev)
 		kfree(entry);
 	}
 
+	kfree(hidg->get_req_buf);
 	kfree(hidg->report_desc);
 	kfree(hidg->set_report_buf);
 	kfree(hidg);
@@ -602,7 +603,7 @@ static void get_report_workqueue_handler(struct work_struct *work)
 	ptr = f_hidg_search_for_report(hidg, hidg->get_report_req_report_id);
 	if (ptr && !ptr->report_data.userspace_req) {
 		/* Report exists in list and it is to be used for immediate response */
-		req->buf = ptr->report_data.data;
+		memcpy(req->buf, ptr->report_data.data, req->length);
 		status = usb_ep_queue(cdev->gadget->ep0, req, GFP_ATOMIC);
 		hidg->get_report_returned = true;
 		spin_unlock_irqrestore(&hidg->get_report_spinlock, flags);
@@ -637,10 +638,9 @@ static void get_report_workqueue_handler(struct work_struct *work)
 			 * Either get an updated response just serviced by userspace
 			 * or send the latest response in the list
 			 */
-			req->buf = ptr->report_data.data;
+			memcpy(req->buf, ptr->report_data.data, req->length);
 		} else {
 			/* If there are no prevoiusly sent reports send empty report */
-			req->buf = hidg->get_report.data;
 			memset(req->buf, 0x0, req->length);
 		}
 
@@ -1176,6 +1176,15 @@ static int hidg_bind(struct usb_configuration *c, struct usb_function *f)
 	if (!hidg->get_req)
 		return -ENOMEM;
 
+	/*
+	 * The GET_REPORT response is served from a dedicated buffer
+	 * (allocated in hidg_alloc()), not from the report_list
+	 * entries: userspace may update an entry while the controller
+	 * is still reading the previous response, which would corrupt
+	 * the data on the wire.
+	 */
+	hidg->get_req->buf = hidg->get_req_buf;
+
 	hidg->get_req->zero = 0;
 	hidg->get_req->complete = hidg_get_report_complete;
 	hidg->get_req->context = hidg;
@@ -1587,6 +1596,18 @@ static struct usb_function *hidg_alloc(struct usb_function_instance *fi)
 	}
 	hidg->use_out_ep = !opts->no_out_endpoint;
 
+	/*
+	 * Dedicated buffer for GET_REPORT responses, allocated once for
+	 * the whole lifetime of this function instance: hidg_release()
+	 * is the only safe free point, as it runs after all USB
+	 * activity has ceased and all file references are gone.
+	 */
+	hidg->get_req_buf = kmalloc(MAX_REPORT_LENGTH, GFP_KERNEL);
+	if (!hidg->get_req_buf) {
+		ret = -ENOMEM;
+		goto err_put_device;
+	}
+
 	++opts->refcnt;
 	mutex_unlock(&opts->lock);
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 215/555] usb: gadget: f_hid: fix get_req leak when usb_gstrings_attach() fails
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (213 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 214/555] usb: gadget: f_hid: fix race between userspace report update and GET_REPORT response Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 216/555] HID: sensor: custom: Fix state lifetime during removal Greg Kroah-Hartman
                   ` (339 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Shunbo Shi, Sasha Levin

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

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

From: Shunbo Shi <shishunbo@cmss.chinamobile.com>

[ Upstream commit f11175ece1250557ec595ea7a2854f0391cab53d ]

In hidg_bind(), hidg->get_req is allocated early; if
usb_gstrings_attach() subsequently fails, the function returns
directly without freeing the request, leaking it.  Unwind through
the fail path instead.

Fixes: a139c98f760e ("USB: gadget: f_hid: Add GET_REPORT via userspace IOCTL")
Signed-off-by: Shunbo Shi <shishunbo@cmss.chinamobile.com>
Link: https://patch.msgid.link/20261117125051.5646-4-shishunbo@cmss.chinamobile.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/usb/gadget/function/f_hid.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
index e3b88af534856..56171e3794cbb 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -1193,8 +1193,10 @@ static int hidg_bind(struct usb_configuration *c, struct usb_function *f)
 	/* maybe allocate device-global string IDs, and patch descriptors */
 	us = usb_gstrings_attach(c->cdev, ct_func_strings,
 				 ARRAY_SIZE(ct_func_string_defs));
-	if (IS_ERR(us))
-		return PTR_ERR(us);
+	if (IS_ERR(us)) {
+		status = PTR_ERR(us);
+		goto fail;
+	}
 	hidg_interface_desc.iInterface = us[CT_FUNC_HID_IDX].id;
 
 	/* allocate instance-specific interface IDs, and patch descriptors */
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 216/555] HID: sensor: custom: Fix state lifetime during removal
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (214 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 215/555] usb: gadget: f_hid: fix get_req leak when usb_gstrings_attach() fails Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 217/555] HID: sensor: custom: Serialize misc device reads Greg Kroah-Hartman
                   ` (338 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Semyon Maryasin, Zhang Lixu,
	Srinivas Pandruvada, Jonathan Cameron, Jiri Kosina, Sasha Levin

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

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

From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

[ Upstream commit ac6c19392c7996ac8135dba6907c391a4be5beaf ]

Open misc device files can outlive platform-device removal. Since the
devm-allocated state can be freed while a reader is queued on its wait
queue, subsequent file operations may access freed memory.

Allocate the state independently of devres and give every open
file a reference to keep the FIFO and state alive after removal.

On removal, mark the device as disconnected and wake readers; make reads
return -ENODEV and polls report hangup and error. Free the FIFO and state
when the final reference is released. Unregister the sensor hub callback
before tearing down the interface so in-flight raw-event processing
finishes before the sensor state can be freed.

Fixes: 4a7de0519df5 ("HID: sensor: Custom and Generic sensor support")
Reported-by: Semyon Maryasin <simeon@maryasin.name>
Closes: https://lore.kernel.org/all/CAM2dg7ewfVJSP4rFyhkCB1Rmd1+X56sAg=eUdbPthG2xrLqwQQ@mail.gmail.com/
Tested-by: Semyon Maryasin <simeon@maryasin.name>
Tested-by: Zhang Lixu <lixu.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/hid/hid-sensor-custom.c | 82 ++++++++++++++++++++++-----------
 1 file changed, 56 insertions(+), 26 deletions(-)

diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
index b8025ad8189ad..4777d8f74156d 100644
--- a/drivers/hid/hid-sensor-custom.c
+++ b/drivers/hid/hid-sensor-custom.c
@@ -11,6 +11,7 @@
 #include <linux/init.h>
 #include <linux/miscdevice.h>
 #include <linux/kfifo.h>
+#include <linux/kref.h>
 #include <linux/sched.h>
 #include <linux/wait.h>
 #include <linux/poll.h>
@@ -37,6 +38,8 @@ struct hid_sensor_custom_field {
 
 struct hid_sensor_custom {
 	struct mutex mutex;
+	struct kref ref;
+	bool removed;
 	struct platform_device *pdev;
 	struct hid_sensor_hub_device *hsdev;
 	struct hid_sensor_hub_callbacks callbacks;
@@ -643,6 +646,15 @@ static void hid_sensor_custom_remove_attributes(struct hid_sensor_custom *
 	kfree(sensor_inst->fields);
 }
 
+static void hid_sensor_custom_free(struct kref *ref)
+{
+	struct hid_sensor_custom *sensor_inst =
+		container_of(ref, struct hid_sensor_custom, ref);
+
+	kfifo_free(&sensor_inst->data_fifo);
+	kfree(sensor_inst);
+}
+
 static ssize_t hid_sensor_custom_read(struct file *file, char __user *buf,
 				      size_t count, loff_t *f_ps)
 {
@@ -656,22 +668,27 @@ static ssize_t hid_sensor_custom_read(struct file *file, char __user *buf,
 	if (count < sizeof(struct hid_sensor_sample))
 		return -EINVAL;
 
-	do {
-		if (kfifo_is_empty(&sensor_inst->data_fifo)) {
-			if (file->f_flags & O_NONBLOCK)
-				return -EAGAIN;
+	for (;;) {
+		if (READ_ONCE(sensor_inst->removed))
+			return -ENODEV;
 
-			ret = wait_event_interruptible(sensor_inst->wait,
-				!kfifo_is_empty(&sensor_inst->data_fifo));
-			if (ret)
-				return ret;
-		}
 		ret = kfifo_to_user(&sensor_inst->data_fifo, buf, count,
 				    &copied);
+		if (ret || copied)
+			break;
+
+		if (file->f_flags & O_NONBLOCK)
+			return -EAGAIN;
+
+		ret = wait_event_interruptible(sensor_inst->wait,
+			READ_ONCE(sensor_inst->removed) ||
+			!kfifo_is_empty(&sensor_inst->data_fifo));
 		if (ret)
 			return ret;
+	}
 
-	} while (copied == 0);
+	if (ret)
+		return ret;
 
 	return copied;
 }
@@ -684,6 +701,7 @@ static int hid_sensor_custom_release(struct inode *inode, struct file *file)
 				   struct hid_sensor_custom, custom_dev);
 
 	clear_bit(0, &sensor_inst->misc_opened);
+	kref_put(&sensor_inst->ref, hid_sensor_custom_free);
 
 	return 0;
 }
@@ -691,14 +709,25 @@ static int hid_sensor_custom_release(struct inode *inode, struct file *file)
 static int hid_sensor_custom_open(struct inode *inode, struct file *file)
 {
 	struct hid_sensor_custom *sensor_inst;
+	int ret;
 
 	sensor_inst = container_of(file->private_data,
 				   struct hid_sensor_custom, custom_dev);
+	if (READ_ONCE(sensor_inst->removed))
+		return -ENODEV;
+
 	/* We essentially have single reader and writer */
 	if (test_and_set_bit(0, &sensor_inst->misc_opened))
 		return -EBUSY;
 
-	return stream_open(inode, file);
+	kref_get(&sensor_inst->ref);
+	ret = stream_open(inode, file);
+	if (ret) {
+		clear_bit(0, &sensor_inst->misc_opened);
+		kref_put(&sensor_inst->ref, hid_sensor_custom_free);
+	}
+
+	return ret;
 }
 
 static __poll_t hid_sensor_custom_poll(struct file *file,
@@ -712,6 +741,9 @@ static __poll_t hid_sensor_custom_poll(struct file *file,
 
 	poll_wait(file, &sensor_inst->wait, wait);
 
+	if (READ_ONCE(sensor_inst->removed))
+		return EPOLLHUP | EPOLLERR;
+
 	if (!kfifo_is_empty(&sensor_inst->data_fifo))
 		mask = EPOLLIN | EPOLLRDNORM;
 
@@ -741,21 +773,15 @@ static int hid_sensor_custom_dev_if_add(struct hid_sensor_custom *sensor_inst)
 	sensor_inst->custom_dev.minor = MISC_DYNAMIC_MINOR;
 	sensor_inst->custom_dev.name = dev_name(&sensor_inst->pdev->dev);
 	sensor_inst->custom_dev.fops = &hid_sensor_custom_fops;
-	ret = misc_register(&sensor_inst->custom_dev);
-	if (ret) {
-		kfifo_free(&sensor_inst->data_fifo);
-		return ret;
-	}
-	return 0;
+	return misc_register(&sensor_inst->custom_dev);
 }
 
 static void hid_sensor_custom_dev_if_remove(struct hid_sensor_custom
 								*sensor_inst)
 {
-	wake_up(&sensor_inst->wait);
+	WRITE_ONCE(sensor_inst->removed, true);
+	wake_up_interruptible_all(&sensor_inst->wait);
 	misc_deregister(&sensor_inst->custom_dev);
-	kfifo_free(&sensor_inst->data_fifo);
-
 }
 
 /*
@@ -978,8 +1004,7 @@ static int hid_sensor_custom_probe(struct platform_device *pdev)
 	int ret;
 	const struct hid_sensor_custom_match *match;
 
-	sensor_inst = devm_kzalloc(&pdev->dev, sizeof(*sensor_inst),
-				   GFP_KERNEL);
+	sensor_inst = kzalloc(sizeof(*sensor_inst), GFP_KERNEL);
 	if (!sensor_inst)
 		return -ENOMEM;
 
@@ -989,6 +1014,7 @@ static int hid_sensor_custom_probe(struct platform_device *pdev)
 	sensor_inst->hsdev = hsdev;
 	sensor_inst->pdev = pdev;
 	mutex_init(&sensor_inst->mutex);
+	kref_init(&sensor_inst->ref);
 	platform_set_drvdata(pdev, sensor_inst);
 
 	ret = hid_sensor_custom_get_known(hsdev, &match);
@@ -1000,7 +1026,7 @@ static int hid_sensor_custom_probe(struct platform_device *pdev)
 		if (ret) {
 			dev_err(&pdev->dev,
 				"register_platform_device failed\n");
-			return ret;
+			goto err_put;
 		}
 
 		return 0;
@@ -1010,7 +1036,7 @@ static int hid_sensor_custom_probe(struct platform_device *pdev)
 					   &sensor_inst->callbacks);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "callback reg failed\n");
-		return ret;
+		goto err_put;
 	}
 
 	ret = hid_sensor_custom_add_attributes(sensor_inst);
@@ -1035,6 +1061,8 @@ static int hid_sensor_custom_probe(struct platform_device *pdev)
 	hid_sensor_custom_remove_attributes(sensor_inst);
 err_remove_callback:
 	sensor_hub_remove_callback(hsdev, hsdev->usage);
+err_put:
+	kref_put(&sensor_inst->ref, hid_sensor_custom_free);
 
 	return ret;
 }
@@ -1046,9 +1074,10 @@ static void hid_sensor_custom_remove(struct platform_device *pdev)
 
 	if (sensor_inst->custom_pdev) {
 		platform_device_unregister(sensor_inst->custom_pdev);
-		return;
+		goto out;
 	}
 
+	sensor_hub_remove_callback(hsdev, hsdev->usage);
 	hid_sensor_custom_dev_if_remove(sensor_inst);
 	/* Remove enable_sensor first as it uses fields via power_state/report_state. */
 	sysfs_remove_group(&sensor_inst->pdev->dev.kobj,
@@ -1061,7 +1090,8 @@ static void hid_sensor_custom_remove(struct platform_device *pdev)
 	}
 	mutex_unlock(&sensor_inst->mutex);
 	hid_sensor_custom_remove_attributes(sensor_inst);
-	sensor_hub_remove_callback(hsdev, hsdev->usage);
+out:
+	kref_put(&sensor_inst->ref, hid_sensor_custom_free);
 }
 
 static const struct platform_device_id hid_sensor_custom_ids[] = {
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 217/555] HID: sensor: custom: Serialize misc device reads
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (215 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 216/555] HID: sensor: custom: Fix state lifetime during removal Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 218/555] HID: sensor: custom: Register enable attribute after misc device Greg Kroah-Hartman
                   ` (337 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Semyon Maryasin, Zhang Lixu,
	Srinivas Pandruvada, Jonathan Cameron, Jiri Kosina, Sasha Levin

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

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

From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

[ Upstream commit fecb7895fbb1b7891e81a033f0dd1f5f7876dc07 ]

The misc device permits only one open file, but threads sharing that
file can still read concurrently. Serialize readers to preserve the
single-reader assumption of the FIFO while keeping removal independent
of a stalled user copy.

Fixes: 4a7de0519df5 ("HID: sensor: Custom and Generic sensor support")
Reported-by: Semyon Maryasin <simeon@maryasin.name>
Closes: https://lore.kernel.org/all/CAM2dg7ewfVJSP4rFyhkCB1Rmd1+X56sAg=eUdbPthG2xrLqwQQ@mail.gmail.com/
Tested-by: Semyon Maryasin <simeon@maryasin.name>
Tested-by: Zhang Lixu <lixu.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/hid/hid-sensor-custom.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
index 4777d8f74156d..88a8918edf4b1 100644
--- a/drivers/hid/hid-sensor-custom.c
+++ b/drivers/hid/hid-sensor-custom.c
@@ -38,6 +38,7 @@ struct hid_sensor_custom_field {
 
 struct hid_sensor_custom {
 	struct mutex mutex;
+	struct mutex read_mutex;
 	struct kref ref;
 	bool removed;
 	struct platform_device *pdev;
@@ -668,25 +669,39 @@ static ssize_t hid_sensor_custom_read(struct file *file, char __user *buf,
 	if (count < sizeof(struct hid_sensor_sample))
 		return -EINVAL;
 
+	if (file->f_flags & O_NONBLOCK) {
+		if (!mutex_trylock(&sensor_inst->read_mutex))
+			return -EAGAIN;
+	} else {
+		ret = mutex_lock_interruptible(&sensor_inst->read_mutex);
+		if (ret)
+			return ret;
+	}
+
 	for (;;) {
-		if (READ_ONCE(sensor_inst->removed))
-			return -ENODEV;
+		if (READ_ONCE(sensor_inst->removed)) {
+			ret = -ENODEV;
+			break;
+		}
 
 		ret = kfifo_to_user(&sensor_inst->data_fifo, buf, count,
 				    &copied);
 		if (ret || copied)
 			break;
 
-		if (file->f_flags & O_NONBLOCK)
-			return -EAGAIN;
+		if (file->f_flags & O_NONBLOCK) {
+			ret = -EAGAIN;
+			break;
+		}
 
 		ret = wait_event_interruptible(sensor_inst->wait,
 			READ_ONCE(sensor_inst->removed) ||
 			!kfifo_is_empty(&sensor_inst->data_fifo));
 		if (ret)
-			return ret;
+			break;
 	}
 
+	mutex_unlock(&sensor_inst->read_mutex);
 	if (ret)
 		return ret;
 
@@ -1014,6 +1029,7 @@ static int hid_sensor_custom_probe(struct platform_device *pdev)
 	sensor_inst->hsdev = hsdev;
 	sensor_inst->pdev = pdev;
 	mutex_init(&sensor_inst->mutex);
+	mutex_init(&sensor_inst->read_mutex);
 	kref_init(&sensor_inst->ref);
 	platform_set_drvdata(pdev, sensor_inst);
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 218/555] HID: sensor: custom: Register enable attribute after misc device
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (216 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 217/555] HID: sensor: custom: Serialize misc device reads Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 219/555] HID: sensor-hub: Remove clients before stopping hardware Greg Kroah-Hartman
                   ` (336 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Semyon Maryasin, Zhang Lixu,
	Srinivas Pandruvada, Jonathan Cameron, Jiri Kosina, Sasha Levin

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

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

From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

[ Upstream commit c6ebe27e3ba09edf956139c741b38e8432be3f67 ]

Register the enable_sensor sysfs group only after misc-device setup
succeeds. This prevents userspace from opening the sensor hub while
probe can still fail, which would otherwise leave the hub open reference
unbalanced on unwind.

Fixes: 4a7de0519df5 ("HID: sensor: Custom and Generic sensor support")
Reported-by: Semyon Maryasin <simeon@maryasin.name>
Closes: https://lore.kernel.org/all/CAM2dg7ewfVJSP4rFyhkCB1Rmd1+X56sAg=eUdbPthG2xrLqwQQ@mail.gmail.com/
Tested-by: Semyon Maryasin <simeon@maryasin.name>
Tested-by: Zhang Lixu <lixu.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/hid/hid-sensor-custom.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
index 88a8918edf4b1..e5f2318183149 100644
--- a/drivers/hid/hid-sensor-custom.c
+++ b/drivers/hid/hid-sensor-custom.c
@@ -1059,20 +1059,19 @@ static int hid_sensor_custom_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_remove_callback;
 
-	ret = sysfs_create_group(&sensor_inst->pdev->dev.kobj,
-				 &enable_sensor_attr_group);
+	ret = hid_sensor_custom_dev_if_add(sensor_inst);
 	if (ret)
 		goto err_remove_attributes;
 
-	ret = hid_sensor_custom_dev_if_add(sensor_inst);
+	ret = sysfs_create_group(&sensor_inst->pdev->dev.kobj,
+				 &enable_sensor_attr_group);
 	if (ret)
-		goto err_remove_group;
+		goto err_remove_dev_if;
 
 	return 0;
 
-err_remove_group:
-	sysfs_remove_group(&sensor_inst->pdev->dev.kobj,
-			   &enable_sensor_attr_group);
+err_remove_dev_if:
+	hid_sensor_custom_dev_if_remove(sensor_inst);
 err_remove_attributes:
 	hid_sensor_custom_remove_attributes(sensor_inst);
 err_remove_callback:
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 219/555] HID: sensor-hub: Remove clients before stopping hardware
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (217 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 218/555] HID: sensor: custom: Register enable attribute after misc device Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 220/555] HID: letsketch: skip string descriptors the firmware does not implement Greg Kroah-Hartman
                   ` (335 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Semyon Maryasin, Zhang Lixu,
	Srinivas Pandruvada, Jonathan Cameron, Jiri Kosina, Sasha Levin

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

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

From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

[ Upstream commit 41cb3076a221afba052ae1624ccf62e500706b20 ]

Remove MFD clients before stopping the HID hardware so their close calls
remain valid. Runtime-PM teardown may cancel a pending autosuspend without
running the client suspend callback, leaving hub references after child
removal.

Clients share one HID open while ref_cnt is nonzero. After removing the
children, drain any remaining references and call hid_hw_close() once if
the count is nonzero. Then stop the HID hardware. This avoids both a
leaked open and the underflow caused by an unconditional close.

The pending-request walk runs before hid_hw_stop() disconnects HID-core
children such as hidraw. Skip non-platform children and platform children
without sensor-hub data before checking pending request state.

Fixes: 1df3a401154a ("HID: Delay opening HID device")
Reported-by: Semyon Maryasin <simeon@maryasin.name>
Closes: https://lore.kernel.org/all/CAM2dg7ewfVJSP4rFyhkCB1Rmd1+X56sAg=eUdbPthG2xrLqwQQ@mail.gmail.com/
Tested-by: Semyon Maryasin <simeon@maryasin.name>
Tested-by: Zhang Lixu <lixu.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/hid/hid-sensor-hub.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 9f14439cc0788..e9eb32f15f091 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -10,6 +10,7 @@
 #include <linux/slab.h>
 #include <linux/mfd/core.h>
 #include <linux/list.h>
+#include <linux/platform_device.h>
 #include <linux/hid-sensor-ids.h>
 #include <linux/hid-sensor-hub.h>
 #include "hid-ids.h"
@@ -808,7 +809,14 @@ static int sensor_hub_probe(struct hid_device *hdev,
 
 static int sensor_hub_finalize_pending_fn(struct device *dev, void *data)
 {
-	struct hid_sensor_hub_device *hsdev = dev->platform_data;
+	struct hid_sensor_hub_device *hsdev;
+
+	if (!dev_is_platform(dev))
+		return 0;
+
+	hsdev = to_platform_device(dev)->dev.platform_data;
+	if (!hsdev)
+		return 0;
 
 	if (hsdev->pending.status)
 		complete(&hsdev->pending.ready);
@@ -822,8 +830,6 @@ static void sensor_hub_remove(struct hid_device *hdev)
 	unsigned long flags;
 
 	hid_dbg(hdev, " hardware removed\n");
-	hid_hw_close(hdev);
-	hid_hw_stop(hdev);
 
 	spin_lock_irqsave(&data->lock, flags);
 	device_for_each_child(&hdev->dev, NULL,
@@ -831,6 +837,14 @@ static void sensor_hub_remove(struct hid_device *hdev)
 	spin_unlock_irqrestore(&data->lock, flags);
 
 	mfd_remove_devices(&hdev->dev);
+	/* Clients share one HID open; release it if references remain. */
+	mutex_lock(&data->mutex);
+	if (data->ref_cnt) {
+		data->ref_cnt = 0;
+		hid_hw_close(hdev);
+	}
+	mutex_unlock(&data->mutex);
+	hid_hw_stop(hdev);
 	mutex_destroy(&data->mutex);
 }
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 220/555] HID: letsketch: skip string descriptors the firmware does not implement
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (218 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 219/555] HID: sensor-hub: Remove clients before stopping hardware Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 221/555] HID: nintendo: release the player ID when LED setup fails Greg Kroah-Hartman
                   ` (334 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Eren Çakar, Hans de Goede,
	Jiri Kosina, Sasha Levin

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

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

From: Eren Çakar <hey@erencakar.com>

[ Upstream commit f2f69bbddd34801cbf6af2e89235ca427f3811c5 ]

The Starcom GC-422 is a rebranded LetSketch WP9620C with the same USB
ID (6161:4d15), so it binds to this driver. Its firmware
("Vision_V201_180530") does not implement every string descriptor index
that the raw mode handshake reads. For those indices usb_string() keeps
returning an empty string or -EPIPE, letsketch_get_string() gives up
after its retries, and the probe fails:

  letsketch ...: probe with driver letsketch failed with error -5

The tablet then does not work at all.

The handshake only needs the reads to happen, not their contents. Once
the retries are used up, report an index that still reads as empty or
STALLs as missing with -ENOENT, and let the probe skip it. Other errors
still fail the probe as before, and the retries stay in place, so
firmware that only fails a read now and then behaves as it did.

With this change the GC-422 completes the handshake, switches to raw
mode and reports pen position, pressure and the five pad buttons.

The change and this message were written with the help of an AI coding
assistant (Claude Code); I reviewed them and tested the result on the
hardware.

Fixes: 33a5c2793451 ("HID: Add new Letsketch tablet driver")
Signed-off-by: Eren Çakar <hey@erencakar.com>
Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/hid/hid-letsketch.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/hid/hid-letsketch.c b/drivers/hid/hid-letsketch.c
index 447496d2b3e74..dedbe8e504e82 100644
--- a/drivers/hid/hid-letsketch.c
+++ b/drivers/hid/hid-letsketch.c
@@ -212,6 +212,12 @@ static int letsketch_raw_event(struct hid_device *hdev,
  * string descriptors. But the firmware is buggy and does not like it if
  * we do this too fast. Even if we go slow sometimes the usb_string() call
  * fails. Ignore errors and retry it a couple of times if necessary.
+ *
+ * Some firmware revisions (e.g. "Vision_V201_180530", sold as the Starcom
+ * GC-422) do not implement every string descriptor index the handshake
+ * reads. For those indices usb_string() keeps returning an empty string or
+ * -EPIPE (STALL). Report such an index as missing with -ENOENT once the
+ * retries are used up, so that the caller can skip it.
  */
 static int letsketch_get_string(struct usb_device *udev, int index, char *buf, int size)
 {
@@ -224,9 +230,14 @@ static int letsketch_get_string(struct usb_device *udev, int index, char *buf, i
 			return 0;
 	}
 
+	if (ret == 0 || ret == -EPIPE) {
+		dev_dbg(&udev->dev, "String descriptor %d not implemented\n", index);
+		return -ENOENT;
+	}
+
 	dev_err(&udev->dev, "Max retries (%d) exceeded reading string descriptor %d\n",
 		LETSKETCH_GET_STRING_RETRIES, index);
-	return ret ? ret : -EIO;
+	return ret;
 }
 
 static int letsketch_probe(struct hid_device *hdev, const struct hid_device_id *id)
@@ -255,6 +266,8 @@ static int letsketch_probe(struct hid_device *hdev, const struct hid_device_id *
 	 */
 	for (i = LETSKETCH_INFO_STR_IDX_BEGIN; i <= LETSKETCH_INFO_STR_IDX_END; i++) {
 		ret = letsketch_get_string(udev, i, buf, sizeof(buf));
+		if (ret == -ENOENT)
+			continue;
 		if (ret)
 			return ret;
 
@@ -263,16 +276,16 @@ static int letsketch_probe(struct hid_device *hdev, const struct hid_device_id *
 
 	for (i = 1; i <= 250; i++) {
 		ret = letsketch_get_string(udev, i, buf, sizeof(buf));
-		if (ret)
+		if (ret && ret != -ENOENT)
 			return ret;
 	}
 
 	ret = letsketch_get_string(udev, 0x64, buf, sizeof(buf));
-	if (ret)
+	if (ret && ret != -ENOENT)
 		return ret;
 
 	ret = letsketch_get_string(udev, LETSKETCH_INFO_STR_IDX_BEGIN, buf, sizeof(buf));
-	if (ret)
+	if (ret && ret != -ENOENT)
 		return ret;
 
 	/*
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 221/555] HID: nintendo: release the player ID when LED setup fails
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (219 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 220/555] HID: letsketch: skip string descriptors the firmware does not implement Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 222/555] usb: cdns3: report endpoint reset timeout Greg Kroah-Hartman
                   ` (333 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Changyul Lee, Sang-Hoon Choi,
	Jiri Kosina, Sasha Levin

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

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

From: Sang-Hoon Choi <csh0052@gmail.com>

[ Upstream commit 10bc1d627c297097cfdc099377f8a13efdfffd86 ]

joycon_leds_create() allocates a player ID before allocating the LED
names and registering the LEDs. If one of those later steps fails,
nintendo_hid_probe() jumps to err_io_stop and skips the ID cleanup.
The failed probe leaves the allocated ID in nintendo_player_id_allocator.

Use err_ida for this failure, as the power supply and input setup error
paths already do. If the ID allocation itself failed, player_id is
U32_MAX and ida_free() leaves the allocator untouched.

Fixes: 5307de63d71d ("HID: nintendo: use ida for LED player id")
Reported-by: Changyul Lee <lcy8047@gmail.com>
Assisted-by: LLM
Signed-off-by: Sang-Hoon Choi <csh0052@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/hid/hid-nintendo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c
index ea7751b3555c0..317db8648a766 100644
--- a/drivers/hid/hid-nintendo.c
+++ b/drivers/hid/hid-nintendo.c
@@ -2702,7 +2702,7 @@ static int nintendo_hid_probe(struct hid_device *hdev,
 	ret = joycon_leds_create(ctlr);
 	if (ret) {
 		hid_err(hdev, "Failed to create leds; ret=%d\n", ret);
-		goto err_io_stop;
+		goto err_ida;
 	}
 
 	/* Initialize the battery power supply */
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 222/555] usb: cdns3: report endpoint reset timeout
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (220 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 221/555] HID: nintendo: release the player ID when LED setup fails Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 223/555] Bluetooth: MSFT: Record the filter state on Command Disallowed Greg Kroah-Hartman
                   ` (332 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Jiale Yao, Peter Chen, Sasha Levin

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

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

From: Jiale Yao <yaojiale02@163.com>

[ Upstream commit 8f51823de3c9184fd8b7a4430a030eb071f39dae ]

cdns3_gadget_ep_disable() discards the endpoint reset poll result and
then tests ret, which is still zero. A reset timeout is therefore
neither reported nor returned to the caller.

Store the poll result in ret so the existing diagnostic and return path
expose the timeout.

Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
Add: stable@kernel.org
Acked-by: Peter Chen <peter.chen@kernel.org>
Link: https://patch.msgid.link/20261003081152.433499-1-yaojiale02@163.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/usb/cdns3/cdns3-gadget.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
index 331f10cc3fca8..29a69d6d09668 100644
--- a/drivers/usb/cdns3/cdns3-gadget.c
+++ b/drivers/usb/cdns3/cdns3-gadget.c
@@ -2530,9 +2530,9 @@ static int cdns3_gadget_ep_disable(struct usb_ep *ep)
 				  !(val & EP_STS_DBUSY), 1, 10);
 	writel(EP_CMD_EPRST, &priv_dev->regs->ep_cmd);
 
-	readl_poll_timeout_atomic(&priv_dev->regs->ep_cmd, val,
-				  !(val & (EP_CMD_CSTALL | EP_CMD_EPRST)),
-				  1, 1000);
+	ret = readl_poll_timeout_atomic(&priv_dev->regs->ep_cmd, val,
+					!(val & (EP_CMD_CSTALL | EP_CMD_EPRST)),
+					1, 1000);
 	if (unlikely(ret))
 		dev_err(priv_dev->dev, "Timeout: %s resetting failed.\n",
 			priv_ep->name);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 223/555] Bluetooth: MSFT: Record the filter state on Command Disallowed
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (221 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 222/555] usb: cdns3: report endpoint reset timeout Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 224/555] Bluetooth: MSFT: Only enable the advertisement filter with monitors Greg Kroah-Hartman
                   ` (331 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Thomas de Gruijter,
	Luiz Augusto von Dentz, Sasha Levin

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

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

From: Thomas de Gruijter <thomasdegruijter@pm.me>

[ Upstream commit 75d6b9d82c35d35dad9fdd783975be1edd32fe2f ]

msft_le_set_advertisement_filter_enable_cb() treats status 0x0C (Command
Disallowed) as success: a controller returns it when the advertisement
filter is already in the requested state, and some controllers start
with the filter enabled.

Since commit 493ea69970e2 ("Bluetooth: Convert MSFT filter HCI cmd to
hci_sync") the callback is passed the return value of
__hci_cmd_sync_status() instead of the HCI status. That function reports
Command Disallowed as -EBUSY, so the 0x0C branch is never taken and
msft->filter_enabled keeps its old value whenever the filter was already
in the requested state. msft_set_filter_enable() also always returns 0,
hiding real errors from its callers.

Pass the error code to the callback, treat -EBUSY as the filter already
being in the requested state, and return real errors from
msft_set_filter_enable(). Nothing reads msft->filter_enabled yet, but
the next patch relies on it to decide when to change the filter state.

The problem was found, with the help of an AI coding assistant
(Claude Code with Claude Opus 5.5).

Fixes: 493ea69970e2 ("Bluetooth: Convert MSFT filter HCI cmd to hci_sync")
Signed-off-by: Thomas de Gruijter <thomasdegruijter@pm.me>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/bluetooth/msft.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c
index cd42b020c6c8d..e4597763e06c6 100644
--- a/net/bluetooth/msft.c
+++ b/net/bluetooth/msft.c
@@ -1142,26 +1142,27 @@ __u64 msft_get_features(struct hci_dev *hdev)
 
 static void msft_le_set_advertisement_filter_enable_cb(struct hci_dev *hdev,
 						       void *user_data,
-						       u8 status)
+						       int err)
 {
 	struct msft_cp_le_set_advertisement_filter_enable *cp = user_data;
 	struct msft_data *msft = hdev->msft_data;
 
-	/* Error 0x0C would be returned if the filter enabled status is
+	/* Error 0x0C (Command Disallowed), which __hci_cmd_sync_status()
+	 * reports as -EBUSY, would be returned if the filter enabled status is
 	 * already set to whatever we were trying to set.
 	 * Although the default state should be disabled, some controller set
 	 * the initial value to enabled. Because there is no way to know the
 	 * actual initial value before sending this command, here we also treat
 	 * error 0x0C as success.
 	 */
-	if (status != 0x00 && status != 0x0C)
+	if (err && err != -EBUSY)
 		return;
 
 	hci_dev_lock(hdev);
 
 	msft->filter_enabled = cp->enable;
 
-	if (status == 0x0C)
+	if (err == -EBUSY)
 		bt_dev_warn(hdev, "MSFT filter_enable is already %s",
 			    cp->enable ? "on" : "off");
 
@@ -1212,7 +1213,7 @@ int msft_set_filter_enable(struct hci_dev *hdev, bool enable)
 
 	msft_le_set_advertisement_filter_enable_cb(hdev, &cp, err);
 
-	return 0;
+	return err == -EBUSY ? 0 : err;
 }
 
 bool msft_curve_validity(struct hci_dev *hdev)
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 224/555] Bluetooth: MSFT: Only enable the advertisement filter with monitors
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (222 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 223/555] Bluetooth: MSFT: Record the filter state on Command Disallowed Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 225/555] ALSA: pcm: Fix potential ABBA deadlock at snd_pcm_action_nonatomic() Greg Kroah-Hartman
                   ` (330 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Thomas de Gruijter,
	Luiz Augusto von Dentz, Sasha Levin

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

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

From: Thomas de Gruijter <thomasdegruijter@pm.me>

[ Upstream commit 4a8f9b7fb4f503f48e2ccfc67caa8b07d303f8a8 ]

msft_do_open() unconditionally enables the MSFT LE advertisement filter
on every power on, whether or not any advertisement monitor is
registered.

On MediaTek MT7922 (USB 0e8d:0616, firmware build 20260724) the
controller then drops every LE advertisement: LE Set Extended Scan
Enable succeeds, but no LE Extended Advertising Report is ever
delivered, so LE discovery and passive scanning find nothing. BR/EDR
inquiry is not affected. Sending LE Set Advertisement Filter Enable with
Enable set to 0x00 restores reporting immediately. The Microsoft HCI
extension specification defines the filter as disabled by default and
does not specify what a controller reports while the filter is enabled
without any monitor condition.

Only enable the filter while at least one monitor is offloaded to the
controller, and update it after a monitor is added or removed and after
the monitors are re-registered on power on and resume. Like the
monitors, the filter state does not survive a power off, so reset the
tracked state in msft_do_close() instead of sending a redundant disable
on power on. A command is only sent when the wanted state differs from
msft->filter_enabled, so this depends on the previous patch keeping
that state accurate when the controller reports the filter as already
being in the requested state.

Fixes: 394566bf1e37 ("Bluetooth: advmon offload MSFT handle filter enablement")
Signed-off-by: Thomas de Gruijter <thomasdegruijter@pm.me>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/bluetooth/msft.c | 46 +++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 43 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c
index e4597763e06c6..caec2869249f4 100644
--- a/net/bluetooth/msft.c
+++ b/net/bluetooth/msft.c
@@ -468,6 +468,30 @@ static int msft_remove_monitor_sync(struct hci_dev *hdev,
 	return err;
 }
 
+/* Keep the advertisement filter enabled only while at least one monitor is
+ * offloaded to the controller. With the filter enabled and no monitors, some
+ * controllers (e.g. MediaTek MT7922) drop every advertisement, which breaks
+ * LE discovery and passive scanning entirely.
+ *
+ * This function requires the caller holds hci_req_sync_lock
+ */
+static void msft_update_filter_enable(struct hci_dev *hdev)
+{
+	struct msft_data *msft = hdev->msft_data;
+	bool enable, update;
+
+	if (!msft)
+		return;
+
+	hci_dev_lock(hdev);
+	enable = !list_empty(&msft->handle_map);
+	update = enable != msft->filter_enabled;
+	hci_dev_unlock(hdev);
+
+	if (update)
+		msft_set_filter_enable(hdev, enable);
+}
+
 /* This function requires the caller holds hci_req_sync_lock */
 int msft_suspend_sync(struct hci_dev *hdev)
 {
@@ -493,6 +517,8 @@ int msft_suspend_sync(struct hci_dev *hdev)
 	/* All monitors have been removed */
 	msft->suspending = false;
 
+	msft_update_filter_enable(hdev);
+
 	return 0;
 }
 
@@ -633,6 +659,7 @@ int msft_resume_sync(struct hci_dev *hdev)
 	hci_dev_unlock(hdev);
 
 	reregister_monitor(hdev);
+	msft_update_filter_enable(hdev);
 
 	return 0;
 }
@@ -670,11 +697,11 @@ void msft_do_open(struct hci_dev *hdev)
 
 	if (msft_monitor_supported(hdev)) {
 		msft->resuming = true;
-		msft_set_filter_enable(hdev, true);
 		/* Monitors get removed on power off, so we need to explicitly
 		 * tell the controller to re-monitor.
 		 */
 		reregister_monitor(hdev);
+		msft_update_filter_enable(hdev);
 	}
 }
 
@@ -706,6 +733,11 @@ void msft_do_close(struct hci_dev *hdev)
 		kfree(handle_data);
 	}
 
+	/* The advertisement filter is back to its default, disabled state
+	 * after power off as well.
+	 */
+	msft->filter_enabled = false;
+
 	hci_dev_unlock(hdev);
 
 	mutex_lock(&msft->filter_lock);
@@ -1173,6 +1205,7 @@ static void msft_le_set_advertisement_filter_enable_cb(struct hci_dev *hdev,
 int msft_add_monitor_pattern(struct hci_dev *hdev, struct adv_monitor *monitor)
 {
 	struct msft_data *msft = hdev->msft_data;
+	int err;
 
 	if (!msft)
 		return -EOPNOTSUPP;
@@ -1180,13 +1213,17 @@ int msft_add_monitor_pattern(struct hci_dev *hdev, struct adv_monitor *monitor)
 	if (msft->resuming || msft->suspending)
 		return -EBUSY;
 
-	return msft_add_monitor_sync(hdev, monitor);
+	err = msft_add_monitor_sync(hdev, monitor);
+	msft_update_filter_enable(hdev);
+
+	return err;
 }
 
 /* This function requires the caller holds hci_req_sync_lock */
 int msft_remove_monitor(struct hci_dev *hdev, struct adv_monitor *monitor)
 {
 	struct msft_data *msft = hdev->msft_data;
+	int err;
 
 	if (!msft)
 		return -EOPNOTSUPP;
@@ -1194,7 +1231,10 @@ int msft_remove_monitor(struct hci_dev *hdev, struct adv_monitor *monitor)
 	if (msft->resuming || msft->suspending)
 		return -EBUSY;
 
-	return msft_remove_monitor_sync(hdev, monitor);
+	err = msft_remove_monitor_sync(hdev, monitor);
+	msft_update_filter_enable(hdev);
+
+	return err;
 }
 
 int msft_set_filter_enable(struct hci_dev *hdev, bool enable)
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 225/555] ALSA: pcm: Fix potential ABBA deadlock at snd_pcm_action_nonatomic()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (223 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 224/555] Bluetooth: MSFT: Only enable the advertisement filter with monitors Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 226/555] ipv6, calipso: fix data-race in calipso_cache_add() bucketsize check Greg Kroah-Hartman
                   ` (329 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, sashiko-bot, Takashi Iwai,
	Sasha Levin

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

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

From: Takashi Iwai <tiwai@suse.de>

[ Upstream commit bedefcbb8a0827e2758d6fc4a0601756eba7c248 ]

snd_pcm_action_nonatomic() is called for PCM PREPARE and other
operations, and the function takes snd_pcm_buffer_access_lock() of the
given substream (that takes runtime->buffer_mutex internally) at
first, followed by the call of snd_pcm_action_group() that takes
buffer_mutex of other substreams in the same link group again.
Recently Sashiko suggested it may lead to an ABBA deadlock when two
different substreams in the same PCM link call it concurrently:

  CPU0                                   CPU1
  ----                                   ----
  lock(&A->runtime->buffer_mutex)
                                         lock(&B->runtime->buffer_mutex)
  lock(&B->runtime->buffer_mutex)
                                         lock(&A->runtime->buffer_mutex)

This patch tries to address the potential deadlock.  Instead of taking
the buffer_mutex of the target substream at first and processing the
rest in the loop, take the whole buffer_mutex for each in the loop.
This assures the order of the nested mutexes -- the linked list itself
is kept intact by the read_rwsem() around snd_pcm_action_nonatomic().

Also, this changes the action in the snd_pcm_action_group() loop from
the direct call of mutex_lock(buffer_mutex) to
snd_pcm_buffer_access_lock().  This prevents the unexpected state
transition or the buffer access during the action, too.

Since the target substream is no longer locked before the loop, the
lockdep subclass for buffer_mutex in the loop now starts from 0, so
that a link group of N substreams uses the subclasses 0..N-1 as
before.  The subclass for the stream lock case still starts from 1,
as the caller holds the target stream lock at subclass 0.

Note that this change might have a slight side-effect, though: when
some concurrent operations happen during the PREPARE or RESET, now it
may return -EBUSY.  But this can be seen rather as an expected
behavior that was overlooked before the fix.

Fixes: 3c3201f8c7bb ("ALSA: pcm: Fix races among concurrent prepare and hw_params/hw_free calls")
Reported-by: sashiko-bot@kernel.org
Closes: https://lore.kernel.org/sashiko-outbox-221145@kernel.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20261119122356.2134523-2-tiwai@suse.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 sound/core/pcm_native.c | 63 +++++++++++++++++++++++++++--------------
 1 file changed, 41 insertions(+), 22 deletions(-)

diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 8f023ef792213..acdf6a2a3a676 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -714,14 +714,20 @@ static int snd_pcm_hw_params_choose(struct snd_pcm_substream *pcm,
 /* acquire buffer_mutex; if it's in r/w operation, return -EBUSY, otherwise
  * block the further r/w operations
  */
-static int snd_pcm_buffer_access_lock(struct snd_pcm_runtime *runtime)
+static int __snd_pcm_buffer_access_lock(struct snd_pcm_runtime *runtime,
+					int depth)
 {
 	if (!atomic_dec_unless_positive(&runtime->buffer_accessing))
 		return -EBUSY;
-	mutex_lock(&runtime->buffer_mutex);
+	mutex_lock_nested(&runtime->buffer_mutex, depth);
 	return 0; /* keep buffer_mutex, unlocked by below */
 }
 
+static int snd_pcm_buffer_access_lock(struct snd_pcm_runtime *runtime)
+{
+	return __snd_pcm_buffer_access_lock(runtime, 0);
+}
+
 /* release buffer_mutex and clear r/w access flag */
 static void snd_pcm_buffer_access_unlock(struct snd_pcm_runtime *runtime)
 {
@@ -1251,26 +1257,38 @@ struct action_ops {
  *  this functions is core for handling of linked stream
  *  Note: the stream state might be changed also on failure
  *  Note2: call with calling stream lock + link lock
+ *
+ * Locking:
+ *  When @stream_lock is false, it takes buffer-access lock for all substreams.
+ *  OTOH, when @stream_lock is true, takes substream lock except for the
+ *  target substream (that should have taken its lock before calling this).
  */
 static int snd_pcm_action_group(const struct action_ops *ops,
 				struct snd_pcm_substream *substream,
 				snd_pcm_state_t state,
 				bool stream_lock)
 {
-	struct snd_pcm_substream *s = NULL;
-	struct snd_pcm_substream *s1;
-	int res = 0, depth = 1;
+	struct snd_pcm_substream *s, *s1, *last;
+	int res = 0, depth;
 
+	/* the caller already holds the target stream lock at depth 0 */
+	depth = stream_lock ? 1 : 0;
+
+	last = NULL;
 	snd_pcm_group_for_each_entry(s, substream) {
-		if (s != substream) {
-			if (!stream_lock)
-				mutex_lock_nested(&s->runtime->buffer_mutex, depth);
-			else if (s->pcm->nonatomic)
+		if (!stream_lock) {
+			res = __snd_pcm_buffer_access_lock(s->runtime, depth);
+			if (res < 0)
+				goto _unlock;
+			depth++;
+		} else if (s != substream) {
+			if (s->pcm->nonatomic)
 				mutex_lock_nested(&s->self_group.mutex, depth);
 			else
 				spin_lock_nested(&s->self_group.lock, depth);
 			depth++;
 		}
+		last = s;
 		res = ops->pre_action(s, state);
 		if (res < 0)
 			goto _unlock;
@@ -1285,7 +1303,6 @@ static int snd_pcm_action_group(const struct action_ops *ops,
 					ops->undo_action(s1, state);
 				}
 			}
-			s = NULL; /* unlock all */
 			goto _unlock;
 		}
 	}
@@ -1293,17 +1310,19 @@ static int snd_pcm_action_group(const struct action_ops *ops,
 		ops->post_action(s, state);
 	}
  _unlock:
+	if (!last)
+		return res;
 	/* unlock streams */
-	snd_pcm_group_for_each_entry(s1, substream) {
-		if (s1 != substream) {
-			if (!stream_lock)
-				mutex_unlock(&s1->runtime->buffer_mutex);
-			else if (s1->pcm->nonatomic)
-				mutex_unlock(&s1->self_group.mutex);
+	snd_pcm_group_for_each_entry(s, substream) {
+		if (!stream_lock) {
+			snd_pcm_buffer_access_unlock(s->runtime);
+		} else if (s != substream) {
+			if (s->pcm->nonatomic)
+				mutex_unlock(&s->self_group.mutex);
 			else
-				spin_unlock(&s1->self_group.lock);
+				spin_unlock(&s->self_group.lock);
 		}
-		if (s1 == s)	/* end */
+		if (s == last)	/* end */
 			break;
 	}
 	return res;
@@ -1430,13 +1449,13 @@ static int snd_pcm_action_nonatomic(const struct action_ops *ops,
 
 	/* Guarantee the group members won't change during non-atomic action */
 	guard(rwsem_read)(&snd_pcm_link_rwsem);
+	if (snd_pcm_stream_linked(substream))
+		return snd_pcm_action_group(ops, substream, state, false);
+
 	res = snd_pcm_buffer_access_lock(substream->runtime);
 	if (res < 0)
 		return res;
-	if (snd_pcm_stream_linked(substream))
-		res = snd_pcm_action_group(ops, substream, state, false);
-	else
-		res = snd_pcm_action_single(ops, substream, state);
+	res = snd_pcm_action_single(ops, substream, state);
 	snd_pcm_buffer_access_unlock(substream->runtime);
 	return res;
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 226/555] ipv6, calipso: fix data-race in calipso_cache_add() bucketsize check
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (224 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 225/555] ALSA: pcm: Fix potential ABBA deadlock at snd_pcm_action_nonatomic() Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 227/555] net: marvell: prestera: disable port before changing its MAC mode Greg Kroah-Hartman
                   ` (328 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jiayuan Chen, Paul Moore,
	Jakub Kicinski, Sasha Levin

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

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

From: Jiayuan Chen <jiayuan.chen@linux.dev>

[ Upstream commit 18a7abf1a0b168ea6a50f08562de2f286d6f5a86 ]

Issue found by sashiko when reviewing my data-races patch [1]. This is
not a plain READ_ONCE() annotation like the rest of that series but a
real fix, so it is sent separately.

calipso_cache_add() reads calipso_cache_bucketsize twice: the "<= 0"
guard on entry, then the "size < bucketsize" test after taking the
bucket lock. A writer can flip it to 0 in between:

  CPU0                                    CPU1
  calipso_cache_add()
    calipso_cache_bucketsize == 10 (> 0)
                                          proc_dointvec()
                                            calipso_cache_bucketsize = 0
    spin_lock_bh(&bucket.lock)
    size(0) < calipso_cache_bucketsize(0) -> false
    -> else branch, but the bucket is empty

On an empty bucket the else branch takes list.prev (the list head
itself), list_del()s it and then list_add()s through the now poisoned
head:

 Oops: general protection fault, probably for non-canonical address
 0xdead000000000108
 RIP: 0010:calipso_cache_add+0x2f0/0x380
 Call Trace:
  <IRQ>
  calipso_cache_add+0x4c/0x70
  netlbl_cache_add+0x4a/0xa0
  selinux_netlbl_skbuff_getsid+0x1ac/0x280
  selinux_skb_peerlbl_sid+0x7d/0x100
  selinux_socket_sock_rcv_skb+0x2d3/0x460
  security_sock_rcv_skb+0x86/0x150
  sk_filter_trim_cap+0x56/0x730
  sock_queue_rcv_skb_reason+0x1e/0x80
  rawv6_rcv+0x679/0xb20
  raw6_local_deliver+0x1f0/0x5b0
  ip6_protocol_deliver_rcu+0x215/0x9a0
  ip6_input_finish+0xb0/0x1b0
  ip6_input+0xa8/0x250
  ipv6_rcv+0x14b/0x1c0
  __netif_receive_skb_one_core+0x8f/0xe0
  __netif_receive_skb+0x23/0xb0
  process_backlog+0x27a/0x950
  __napi_poll.constprop.0+0x61/0x2c0
  net_rx_action+0x372/0x800
  handle_softirqs+0x109/0x570
  __do_softirq+0x10/0x18
  do_softirq.part.0+0x47/0xd0
  </IRQ>
  <TASK>
  __local_bh_enable_ip+0xf0/0x120
  __dev_queue_xmit+0x578/0x23f0
  neigh_resolve_output+0x278/0x3c0
  ip6_finish_output2+0x4b1/0xcb0
  ip6_finish_output+0x2b6/0x6b0
  ip6_output+0x122/0x400
  ip6_local_out+0x61/0xb0
  ip6_send_skb+0xa0/0x260
  ip6_push_pending_frames+0x2b/0x40
  rawv6_sendmsg+0x1b7a/0x2750
  inet_sendmsg+0xa1/0xb0
  __sys_sendto+0x2fe/0x350
  __x64_sys_sendto+0x7f/0xb0
  do_syscall_64+0xe1/0x450
  entry_SYSCALL_64_after_hwframe+0x76/0x7e

Snapshot the sysctl into a local once and use it for both tests, like
cipso_v4_cache_add() has since commit dd44f04b9214 ("cipso: Fix
data-races around sysctl.").

[1] https://lore.kernel.org/netdev/179428999963.994134.16904544500890053668@kernel.org/

Fixes: 4fee5242bf41 ("calipso: Add a label cache.")
Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Acked-by: Paul Moore <paul@paul-moore.com>
Link: https://patch.msgid.link/20261115144508.71543-1-jiayuan.chen@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/ipv6/calipso.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/calipso.c b/net/ipv6/calipso.c
index 9e32a732ecbff..5ee2c5c3a6634 100644
--- a/net/ipv6/calipso.c
+++ b/net/ipv6/calipso.c
@@ -264,13 +264,14 @@ static int calipso_cache_check(const unsigned char *key,
 static int calipso_cache_add(const unsigned char *calipso_ptr,
 			     const struct netlbl_lsm_secattr *secattr)
 {
+	int bkt_size = READ_ONCE(calipso_cache_bucketsize);
 	int ret_val = -EPERM;
 	u32 bkt;
 	struct calipso_map_cache_entry *entry = NULL;
 	struct calipso_map_cache_entry *old_entry = NULL;
 	u32 calipso_ptr_len;
 
-	if (!calipso_cache_enabled || calipso_cache_bucketsize <= 0)
+	if (!calipso_cache_enabled || bkt_size <= 0)
 		return 0;
 
 	calipso_ptr_len = calipso_ptr[1];
@@ -290,7 +291,7 @@ static int calipso_cache_add(const unsigned char *calipso_ptr,
 
 	bkt = entry->hash & (CALIPSO_CACHE_BUCKETS - 1);
 	spin_lock_bh(&calipso_cache[bkt].lock);
-	if (calipso_cache[bkt].size < calipso_cache_bucketsize) {
+	if (calipso_cache[bkt].size < bkt_size) {
 		list_add(&entry->list, &calipso_cache[bkt].list);
 		calipso_cache[bkt].size += 1;
 	} else {
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 227/555] net: marvell: prestera: disable port before changing its MAC mode
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (225 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 226/555] ipv6, calipso: fix data-race in calipso_cache_add() bucketsize check Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 228/555] net/mlx5e: Release FIB event work flows before dropping RTNL Greg Kroah-Hartman
                   ` (327 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Imre Kaloz, Elad Nachman,
	Jakub Kicinski, Sasha Levin

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

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

From: Imre Kaloz <kaloz@kernel.org>

[ Upstream commit fdb6fcabdbb8247f1647d54fb1b9dc3575d7fcc8 ]

prestera_pcs_config() writes a new mode, speed or inband setting to an
enabled port. The firmware can then report link down until the port is
disabled and enabled again.

Disable the port before such a write. 2500BASE-X and SGMII share one MAC
mode, so SGMII sets its own speed and the speed is compared as well.
Exercising this needs a link partner, so no in-tree test covers it.

Before this patch, the SFP+ ports (S-RJ01 module in sfp-52) on
a Delta TN48M (98DX3265) with firmware 4.1.0 come up in 21 of 30
attempts. 30 out of 30 with the patch.

Fixes: 52323ef75414 ("net: marvell: prestera: add phylink support")
Signed-off-by: Imre Kaloz <kaloz@kernel.org>
Reviewed-by: Elad Nachman <enachman@marvell.com>
Link: https://patch.msgid.link/20261115230812.29644-1-kaloz@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 .../ethernet/marvell/prestera/prestera_main.c   | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/prestera/prestera_main.c b/drivers/net/ethernet/marvell/prestera/prestera_main.c
index ebd42fc263fce..f81e5343eb559 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_main.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_main.c
@@ -306,13 +306,14 @@ static int prestera_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
 			       bool permit_pause_to_mac)
 {
 	struct prestera_port *port = prestera_pcs_to_port(pcs);
-	struct prestera_port_mac_config cfg_mac;
+	struct prestera_port_mac_config cfg_mac, old;
 	int err;
 
 	err = prestera_port_cfg_mac_read(port, &cfg_mac);
 	if (err)
 		return err;
 
+	old = cfg_mac;
 	cfg_mac.admin = true;
 	cfg_mac.fec = PRESTERA_PORT_FEC_OFF;
 	cfg_mac.inband = neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED;
@@ -328,6 +329,7 @@ static int prestera_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
 		cfg_mac.mode = PRESTERA_MAC_MODE_SGMII;
 		break;
 	case PHY_INTERFACE_MODE_SGMII:
+		cfg_mac.speed = SPEED_1000;
 		cfg_mac.mode = PRESTERA_MAC_MODE_SGMII;
 		break;
 	case PHY_INTERFACE_MODE_1000BASEX:
@@ -338,6 +340,19 @@ static int prestera_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
 		break;
 	}
 
+	/* Firmware may not report link up after the mode, speed or inband
+	 * setting of an enabled port changes until the port is disabled and
+	 * re-enabled.
+	 */
+	if (old.admin && (old.mode != cfg_mac.mode ||
+			  old.speed != cfg_mac.speed ||
+			  old.inband != cfg_mac.inband)) {
+		old.admin = false;
+		err = prestera_port_cfg_mac_write(port, &old);
+		if (err)
+			return err;
+	}
+
 	err = prestera_port_cfg_mac_write(port, &cfg_mac);
 	if (err)
 		return err;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 228/555] net/mlx5e: Release FIB event work flows before dropping RTNL
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (226 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 227/555] net: marvell: prestera: disable port before changing its MAC mode Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 229/555] net: clear skb->mac_len in skb_unset_mac_header() Greg Kroah-Hartman
                   ` (326 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Gal Pressman, Jianbo Liu,
	Tariq Toukan, Jakub Kicinski, Sasha Levin

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

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

From: Gal Pressman <gal@nvidia.com>

[ Upstream commit bfccb4e44e4725270ccef366078d7b6063920ff3 ]

The FIB event work, neigh update work and the neigh stats work all use
flow->tmp_list to hold the encap flows they work on, while RTNL is what
keeps them from using it at the same time.

mlx5e_tc_fib_event_work() drops RTNL before it is done with its list.
A neigh work can then take the same flows while the FIB work is still
walking them, and the two overwrite each other's list.

Release the flow list before dropping RTNL.

The issue was hit once in our regression testing (OVS connection
tracking with the VXLAN endpoint on a VF, KASAN build):
  BUG: KASAN: stack-out-of-bounds in mlx5e_flow_put+0x23/0x80 [mlx5_core]
  Write of size 4 at addr ffff8881226d7b20 by task kworker/u40:1/20171
  Workqueue: mlx5e mlx5e_tc_fib_event_work [mlx5_core]
  Call Trace:
   mlx5e_flow_put+0x23/0x80 [mlx5_core]
   mlx5e_put_flow_list+0x82/0xe0 [mlx5_core]
   mlx5e_tc_fib_event_work+0x704/0x1fb0 [mlx5_core]
   process_one_work+0x8df/0x1660

The race was also reproduced with an msleep() inserted between
rtnl_unlock() and mlx5e_put_flow_list() to widen the window, a VXLAN
encap rule whose endpoint IP is on a VF, and route churn on the endpoint
address.

Fixes: 8914add2c9e5 ("net/mlx5e: Handle FIB events to update tunnel endpoint device")
Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Jianbo Liu <jianbol@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20261118143653.1915247-1-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
index e7e01f3298efb..1f87fc5bb56c0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
@@ -1724,9 +1724,9 @@ static void mlx5e_tc_fib_event_work(struct work_struct *work)
 		r->flags |= MLX5E_ROUTE_ENTRY_VALID;
 out:
 	mutex_unlock(&esw->offloads.encap_tbl_lock);
+	mlx5e_put_flow_list(priv, &flow_list);
 	rtnl_unlock();
 
-	mlx5e_put_flow_list(priv, &flow_list);
 	mlx5e_route_put(priv, event_data->r);
 	dev_put(event_data->ul_dev);
 	kfree(event_data);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 229/555] net: clear skb->mac_len in skb_unset_mac_header()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (227 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 228/555] net/mlx5e: Release FIB event work flows before dropping RTNL Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 230/555] net/mlx5: DR, Fix out-of-bounds write when sync to HW fails Greg Kroah-Hartman
                   ` (325 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Piyus Kedia, Kapil Vaswani,
	Eric Dumazet, Jakub Kicinski, Sasha Levin

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

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

From: Eric Dumazet <edumazet@kernel.org>

[ Upstream commit 7a505bb0168a132c2a3ab4efff4c6d6474ca3aa1 ]

skb_unset_mac_header() marks the mac header as unset but leaves
skb->mac_len alone, so an skb can end up with no mac header and a
non-zero mac_len. Code that uses mac_len to decide whether a mac
header is present is then misled.

end_dt_vrf_rcv() (SRv6 End.DT4/End.DT6) unsets the mac header of the
decapsulated packet so that the VRF device can rebuild it. The VRF
device only does so when a packet sniffer is attached, so without one
the skb continues up the stack with mac_len == 14. In
xfrm4_remove_tunnel_encap() and xfrm6_remove_tunnel_encap(),
skb_mac_header_rebuild() is a no-op for such an skb, and the following

        if (skb->mac_len)
                eth_hdr(skb)->h_proto = skb->protocol;

writes two bytes at skb->head + 0xffff + offsetof(struct ethhdr, h_proto):

  BUG: KASAN: slab-out-of-bounds in xfrm4_remove_tunnel_encap+0x17d/0x220
  Write of size 2 at addr ffff88805f85800b by task syz-executor/10831
   xfrm4_remove_tunnel_encap
   xfrm_input
   xfrm4_esp_rcv
   ip_protocol_deliver_rcu
   ip_local_deliver_finish
   seg6_local_input_core
   lwtunnel_input
   __netif_receive_skb
   netif_receive_skb
   tun_rx_batched
   tun_get_user

__input_process_payload() in net/xfrm/xfrm_iptfs.c has the same three
lines and reported as a use-after-free rather than an out-of-bounds. The
address written is fixed relative to skb->head, so what it lands in is
whatever the allocator placed sixteen pages past the skb: a live object
gives slab-out-of-bounds, a freed one or a page back on the buddy free
list gives use-after-free, and a different live object gives no report at
all. Clearing mac_len at the source makes the guard false at all three
sites.

Clear mac_len in skb_unset_mac_header() so that all callers leave the
skb in a consistent state, and remove the now redundant assignment in
skb_carve_reset_headers(). The other callers are on egress paths
(__bpf_redirect_neigh(), bpf_lwt_push_ip_encap()) or only reach the
helper when the mac header was already unset (bpf_update_srh_state()),
and do not read mac_len afterwards. vrf_prepare_mac_header(), the rebuild
end_dt_vrf_rcv() unsets the header for, pushes ETH_HLEN and then calls
skb_reset_mac_header() and skb_reset_mac_len(), so it recomputes mac_len
itself and never reads the stale value.

The issue was reported on the list by Piyus Kedia and Kapil Vaswani,
who found it by fuzzing with AI assistance and reproduced the KASAN
splat on v7.4-rc3. Their reproducer was not published.

Fixes: 664d6f86868b ("seg6: add support for the SRv6 End.DT4 behavior")
Reported-by: Piyus Kedia <piyus@iiitd.ac.in>
Reported-by: Kapil Vaswani <kapil@presceralabs.ai>
Closes: https://lore.kernel.org/netdev/20261116174531.2540348-2-piyus@iiitd.ac.in/
Suggested-by: Kapil Vaswani <kapil@presceralabs.ai>
Suggested-by: Piyus Kedia <piyus@iiitd.ac.in>
Tested-by: Piyus Kedia <piyus@iiitd.ac.in>
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Signed-off-by: Piyus Kedia <piyus@iiitd.ac.in>
Link: https://patch.msgid.link/20261117143612.95112-1-piyus@iiitd.ac.in
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/linux/skbuff.h | 1 +
 net/core/skbuff.c      | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 0e352786115cc..7df799b751ceb 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -3105,6 +3105,7 @@ static inline u32 skb_mac_header_len(const struct sk_buff *skb)
 static inline void skb_unset_mac_header(struct sk_buff *skb)
 {
 	skb->mac_header = (typeof(skb->mac_header))~0U;
+	skb->mac_len = 0;
 }
 
 static inline void skb_reset_mac_header(struct sk_buff *skb)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 341cc822933f1..b772dd4c041f4 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -6743,7 +6743,6 @@ static void skb_carve_reset_headers(struct sk_buff *skb)
 	skb_unset_mac_header(skb);
 	skb_unset_transport_header(skb);
 	skb_reset_network_header(skb);
-	skb->mac_len = 0;
 
 	/* Inner offsets have no "unset" marker, zero them so that
 	 * skb_inner_network_header_was_set() becomes false and no
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 230/555] net/mlx5: DR, Fix out-of-bounds write when sync to HW fails
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (228 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 229/555] net: clear skb->mac_len in skb_unset_mac_header() Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 231/555] scsi: ufs-mediatek: Restore the M-PHY power state when va09 disable fails Greg Kroah-Hartman
                   ` (324 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Yevgeny Kliteynik, Alex Vesker,
	Tariq Toukan, Jakub Kicinski, Sasha Levin

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

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

From: Yevgeny Kliteynik <kliteyn@nvidia.com>

[ Upstream commit 0e56ff4441eea333bfbfeff86ef39038f6e8c378 ]

mlx5dr_icm_free_chunk() moves a freed chunk to the "hot" chunks array by
writing it to hot_chunks_arr and, once the accumulated hot memory
crosses a threshold, triggers a sync to HW that flushes the array.  The
array is large enough to hold the chunks of a single accumulation cycle,
and relies on the sync path to flush it.

However, if sync to HW fails, hot chunks array is not cleared, and every
subsequent mlx5dr_icm_free_chunk will write past the end of
hot_chunks_arr, resulting in an out-of-bounds write and kernel heap
corruption.

A failed sync to HW also means it is no longer safe to recycle ICM: a
chunk's memory may only be returned to the buddy allocator (and thus be
reused) after a sync has confirmed that HW no longer references it.

The issue was discovered by a fuzzer that repeatedly triggered sync
failure, at which point the out-of-bounds write was reported by KASAN:

   KASAN log excerpt: BUG:
     slab-out-of-bounds in mlx5dr_icm_free_chunk+0x4cd at call 2
     (hot_chunks_num=3 > cap=2).

Fix this by putting the pool into an error state on the first failed
sync to HW, reporting the failure once. The sync is not retried, and
while the pool is in this state:

- mlx5dr_icm_free_chunk() doesn't queue freed chunks; the segment is
  left reserved and is reclaimed when the pool is destroyed.

- mlx5dr_icm_alloc_chunk() doesn't serve new chunks.

Fixes: 4519fc45beeb ("net/mlx5: DR, Keep track of hot ICM chunks in an array instead of list")
Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Reviewed-by: Alex Vesker <valex@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20261118173227.1957670-3-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 .../mellanox/mlx5/core/steering/dr_icm_pool.c | 32 +++++++++++++++++--
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_icm_pool.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_icm_pool.c
index 0b5af9f3f605b..c0beedffba60f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_icm_pool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_icm_pool.c
@@ -33,6 +33,11 @@ struct mlx5dr_icm_pool {
 	u64 hot_memory_size;
 	/* hot memory size threshold for triggering sync */
 	u64 th;
+	/* Set when a sync to HW fails - no new chunks are served, freed
+	 * chunks are no longer queued, and their ICM is not returned to
+	 * the buddy allocator.
+	 */
+	bool error_state;
 };
 
 struct mlx5dr_icm_dm {
@@ -369,7 +374,15 @@ static int dr_icm_pool_sync_all_buddy_pools(struct mlx5dr_icm_pool *pool)
 
 	err = mlx5dr_cmd_sync_steering(pool->dmn->mdev);
 	if (err) {
-		mlx5dr_err(pool->dmn, "Failed to sync to HW (err: %d)\n", err);
+		/* The hot chunks could not be flushed. Put the pool in an
+		 * error state so that no further chunks are queued (which
+		 * would overflow hot_chunks_arr), and no new chunks are
+		 * served. The sync is not retried.
+		 */
+		mlx5dr_err(pool->dmn,
+			   "Failed to sync to HW (err: %d), disabling ICM pool\n",
+			   err);
+		pool->error_state = true;
 		return err;
 	}
 
@@ -444,6 +457,10 @@ mlx5dr_icm_alloc_chunk(struct mlx5dr_icm_pool *pool,
 		return NULL;
 
 	mutex_lock(&pool->mutex);
+
+	if (pool->error_state)
+		goto out;
+
 	/* find mem, get back the relevant buddy pool and seg in that mem */
 	ret = dr_icm_handle_buddies_get_mem(pool, chunk_size, &buddy, &seg);
 	if (ret)
@@ -476,6 +493,14 @@ void mlx5dr_icm_free_chunk(struct mlx5dr_icm_chunk *chunk)
 	/* move the chunk to the waiting chunks array, AKA "hot" memory */
 	mutex_lock(&pool->mutex);
 
+	/* If the pool is in an error state, the chunk must not be queued.
+	 * ICM memory is not returned to the buddy allocator - it is
+	 * reclaimed only when the pool is destroyed.
+	 * Just free the chunk's bookkeeping struct.
+	 */
+	if (pool->error_state)
+		goto out;
+
 	pool->hot_memory_size += mlx5dr_icm_pool_get_chunk_byte_size(chunk);
 
 	hot_chunk = &pool->hot_chunks_arr[pool->hot_chunks_num++];
@@ -483,12 +508,13 @@ void mlx5dr_icm_free_chunk(struct mlx5dr_icm_chunk *chunk)
 	hot_chunk->seg = chunk->seg;
 	hot_chunk->size = chunk->size;
 
-	kmem_cache_free(chunks_cache, chunk);
-
 	/* Check if we have chunks that are waiting for sync-ste */
 	if (dr_icm_pool_is_sync_required(pool))
 		dr_icm_pool_sync_all_buddy_pools(pool);
 
+out:
+	kmem_cache_free(chunks_cache, chunk);
+
 	mutex_unlock(&pool->mutex);
 }
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 231/555] scsi: ufs-mediatek: Restore the M-PHY power state when va09 disable fails
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (229 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 230/555] net/mlx5: DR, Fix out-of-bounds write when sync to HW fails Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 232/555] net: qrtr: ns: keep notifying local servers after a failed send Greg Kroah-Hartman
                   ` (323 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Peter Wang, Xiangwu Lai,
	Martin K. Petersen (Oracle), Sasha Levin

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

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

From: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>

[ Upstream commit 71b5da0b45fb83b590f1ec3df5361c7754b0e113 ]

In ufs_mtk_mphy_power_on(), the power-off path tears the M-PHY down in two
steps before regulator_disable() is called: phy_power_off() puts the PHY
PLL and its clocks down, and ufs_mtk_va09_pwr_ctrl() asks the firmware to
drop the VA09 supply.  If regulator_disable() then fails, the M-PHY stays
physically off while host->mphy_powered_on is left set, so the next
power-on attempt bails out through the !(on ^ host->mphy_powered_on) check
and never powers the M-PHY back up, leaving the UFS host with an unpowered
PHY (I/O timeouts, controller lockups).

Simply forcing mphy_powered_on to false would trade this for two more
problems.  First, the regulator core drops the consumer enable count only
after a successful disable, so the count stays at 1, the next power-on
raises it to 2 and it never returns to zero: va09 is then never physically
disabled and the devm-acquired regulator would hit WARN_ON(enable_count)
again on release.  Second, when the power-off fails during
ufs_mtk_suspend(), the error recovery in __ufshcd_wl_suspend() runs
ufshcd_host_reset_and_restore() without powering the M-PHY back on, which
would run against an unpowered PHY.  (Both points were raised by the
Sashiko AI review of v2.)

Since the va09 regulator stays enabled when its disable fails, restore the
M-PHY power state instead: power the PHY back on through
ufs_mtk_va09_pwr_ctrl() and phy_power_on() and leave mphy_powered_on set.
The next power-off attempt then retries the full sequence and the enable
count stays balanced.

Found by code inspection while reviewing the va09 error paths of the
driver; the failure has not been observed on real hardware.

Suggested-by: Peter Wang <peter.wang@mediatek.com>
Link: https://lore.kernel.org/r/sashiko-outbox-220026@kernel.org
Fixes: cf137b3ea49a ("scsi: ufs-mediatek: Support VA09 regulator operations")
Signed-off-by: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Link: https://patch.msgid.link/20261119071611.117-3-laixiangwu@cmss.chinamobile.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/ufs/host/ufs-mediatek.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
index e4156238f51d9..1053166105139 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -476,6 +476,16 @@ static int ufs_mtk_mphy_power_on(struct ufs_hba *hba, bool on)
 		if (ufs_mtk_is_va09_supported(hba)) {
 			ufs_mtk_va09_pwr_ctrl(res, 0);
 			ret = regulator_disable(host->reg_va09);
+			if (ret) {
+				/*
+				 * The va09 regulator stays enabled, so
+				 * bring the M-PHY back up to keep the
+				 * software state in sync with the
+				 * hardware.
+				 */
+				ufs_mtk_va09_pwr_ctrl(res, 1);
+				phy_power_on(mphy);
+			}
 		}
 	}
 out:
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 232/555] net: qrtr: ns: keep notifying local servers after a failed send
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (230 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 231/555] scsi: ufs-mediatek: Restore the M-PHY power state when va09 disable fails Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 233/555] riscv: efi: Map runtime MMIO with device attributes Greg Kroah-Hartman
                   ` (322 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Igor Opaniuk, Jakub Kicinski,
	Sasha Levin

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

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

From: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>

[ Upstream commit d5b89d55a322b632e2b465b392a4c1d9d338db9c ]

ctrl_cmd_bye() and ctrl_cmd_del_client() forward the event to every
local server, but stop at the first failed send. Each send goes to a
different socket, so a single server with a full receive queue
(-ENOSPC) hides the event from all servers after it.

Log the failure and carry on. Likewise, keep notifying local lookups
when the NEW_SERVER broadcast fails, which can only happen on -ENOMEM.

Tested on the Arduino UNO Q (QRB2210).

Fixes: 0c2204a4ad71 ("net: qrtr: Migrate nameservice to kernel from userspace")
Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Link: https://patch.msgid.link/20261114-upstream-qrtr-hello-gate-fix_b4-v2-1-2fb62c2853bb@oss.qualcomm.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/qrtr/ns.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/net/qrtr/ns.c b/net/qrtr/ns.c
index e8e3ba1b3b823..ea278dd62eea9 100644
--- a/net/qrtr/ns.c
+++ b/net/qrtr/ns.c
@@ -410,11 +410,11 @@ static int ctrl_cmd_bye(struct sockaddr_qrtr *from)
 		msg.msg_name = (struct sockaddr *)&sq;
 		msg.msg_namelen = sizeof(sq);
 
+		/* A server that cannot take it must not hide it from the rest */
 		ret = kernel_sendmsg(qrtr_ns.sock, &msg, &iv, 1, sizeof(pkt));
-		if (ret < 0 && ret != -ENODEV) {
-			pr_err("failed to send bye cmd\n");
-			goto delete_node;
-		}
+		if (ret < 0 && ret != -ENODEV)
+			pr_err_ratelimited("failed to send bye cmd to %u:%u: %d\n",
+					   srv->node, srv->port, ret);
 	}
 
 	/* Ignore -ENODEV */
@@ -494,11 +494,11 @@ static int ctrl_cmd_del_client(struct sockaddr_qrtr *from,
 		msg.msg_name = (struct sockaddr *)&sq;
 		msg.msg_namelen = sizeof(sq);
 
+		/* A server that cannot take it must not hide it from the rest */
 		ret = kernel_sendmsg(qrtr_ns.sock, &msg, &iv, 1, sizeof(pkt));
-		if (ret < 0 && ret != -ENODEV) {
-			pr_err("failed to send del client cmd\n");
-			return ret;
-		}
+		if (ret < 0 && ret != -ENODEV)
+			pr_err_ratelimited("failed to send del client cmd to %u:%u: %d\n",
+					   srv->node, srv->port, ret);
 	}
 	return 0;
 }
@@ -523,11 +523,10 @@ static int ctrl_cmd_new_server(struct sockaddr_qrtr *from,
 		return -EINVAL;
 
 	if (srv->node == qrtr_ns.local_node) {
+		/* The lookups below still need to hear about the server */
 		ret = service_announce_new(&qrtr_ns.bcast_sq, srv);
-		if (ret < 0) {
+		if (ret < 0)
 			pr_err("failed to announce new service\n");
-			return ret;
-		}
 	}
 
 	/* Notify any potential lookups about the new server */
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 233/555] riscv: efi: Map runtime MMIO with device attributes
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (231 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 232/555] net: qrtr: ns: keep notifying local servers after a failed send Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 234/555] net: do not run out of frags in alloc_skb_with_frags() Greg Kroah-Hartman
                   ` (321 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Han Gao, Ard Biesheuvel, Sasha Levin

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

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

From: Han Gao <gaohan@iscas.ac.cn>

[ Upstream commit 7d49d6e0898680925ea410cbb9d1a6a0e6441462 ]

EFI_MEMORY_MAPPED_IO regions are mapped with PAGE_KERNEL, so device
registers end up mapped as normal memory.

On Milk-V Pioneer, GetTime() reads the clock controller registers and
faults:

  Oops - load access fault [#1]
  Workqueue: efi_runtime efi_call_rts
  status: 0000000200000120 badaddr: 0000007030012000 cause: 0000000000000005

Use PAGE_KERNEL_IO for these regions.

Fixes: b91540d52a08 ("RISC-V: Add EFI runtime services")
Signed-off-by: Han Gao <gaohan@iscas.ac.cn>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/riscv/kernel/efi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/efi.c b/arch/riscv/kernel/efi.c
index b64bf1624a052..0cf27d4e10f0d 100644
--- a/arch/riscv/kernel/efi.c
+++ b/arch/riscv/kernel/efi.c
@@ -22,7 +22,7 @@ static __init pgprot_t efimem_to_pgprot_map(efi_memory_desc_t *md)
 	u32 type = md->type;
 
 	if (type == EFI_MEMORY_MAPPED_IO)
-		return PAGE_KERNEL;
+		return PAGE_KERNEL_IO;
 
 	/* R-- */
 	if ((attr & (EFI_MEMORY_XP | EFI_MEMORY_RO)) ==
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 234/555] net: do not run out of frags in alloc_skb_with_frags()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (232 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 233/555] riscv: efi: Map runtime MMIO with device attributes Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 235/555] net/mlx5: E-Switch, skip vport change work for disabled vports Greg Kroah-Hartman
                   ` (320 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Haishuang Yan, Jakub Kicinski,
	Sasha Levin

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

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

From: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>

[ Upstream commit 5924465bb4e986eae6809c899ddaf38d3897f55d ]

alloc_skb_with_frags() can need more than MAX_SKB_FRAGS frags for a
data_len that passed its size check, and then fails with -ENOBUFS:

- the tail is split into one frag per bit set in its page count;
- after a failed high-order allocation, the order is lowered without
  checking that the frags left can hold the rest.

tun hits this with large GSO packets from a vhost-net guest.

Use one larger page for the tail when splitting it would not fit. Only
lower the order if the rest still fits, else retry the same order with
direct reclaim. If that retry fails too, the allocation still fails.

Found while prototyping >64K TSO in a virtio-net guest. Tested with that
guest, page allocation fault injection and the KUnit test in patch 2.

Fixes: 09c2c90705bb ("net: allow alloc_skb_with_frags() to allocate bigger packets")
Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
Link: https://patch.msgid.link/20261116115620.18151-2-yanhaishuang@cmss.chinamobile.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/core/skbuff.c | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index b772dd4c041f4..a218157a06a03 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -6699,17 +6699,40 @@ struct sk_buff *alloc_skb_with_frags(unsigned long header_len,
 	while (data_len) {
 		if (nr_frags == MAX_SKB_FRAGS)
 			goto failure;
-		while (order && PAGE_ALIGN(data_len) < (PAGE_SIZE << order))
-			order--;
+		if (order && PAGE_ALIGN(data_len) < (PAGE_SIZE << order)) {
+			unsigned long pages = DIV_ROUND_UP(data_len, PAGE_SIZE);
+
+			/* If splitting the rest into smaller pages would need
+			 * more frags than we have left, use one larger page.
+			 */
+			if (hweight_long(pages) > MAX_SKB_FRAGS - nr_frags)
+				order = order_base_2(pages);
+			else
+				order = ilog2(pages);
+		}
 
 		if (order) {
 			page = alloc_pages((gfp_mask & ~__GFP_DIRECT_RECLAIM) |
 					   __GFP_COMP |
 					   __GFP_NOWARN,
 					   order);
-			if (!page) {
-				order--;
-				continue;
+			if (unlikely(!page)) {
+				unsigned int shift = PAGE_SHIFT + order - 1;
+
+				/* Can smaller pages hold the rest? */
+				if (((data_len - 1) >> shift) + 1 <=
+				    MAX_SKB_FRAGS - nr_frags) {
+					order--;
+					continue;
+				}
+				/* No, retry this order with direct reclaim. */
+				if (!gfpflags_allow_blocking(gfp_mask))
+					goto failure;
+				page = alloc_pages(gfp_mask | __GFP_COMP |
+						   __GFP_NOWARN | __GFP_NORETRY,
+						   order);
+				if (!page)
+					goto failure;
 			}
 		} else {
 			page = alloc_page(gfp_mask);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 235/555] net/mlx5: E-Switch, skip vport change work for disabled vports
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (233 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 234/555] net: do not run out of frags in alloc_skb_with_frags() Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 236/555] ice: use global queue index in TC to-queue offload Greg Kroah-Hartman
                   ` (319 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Uri Dar, Shay Drory, Mark Bloch,
	Tariq Toukan, Jakub Kicinski, Sasha Levin

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

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

From: Uri Dar <udar@nvidia.com>

[ Upstream commit 890f23ba87a7ca1aba97c8320770a686e3b689fb ]

A vport change work can still be pending when its vport is disabled.
For an SF, the vport is then freed in FW and the work's query fails
with syndrome 0x29d722. A disabled vport has nothing to sync, so skip
the work.

Fixes: d970812b91d0 ("net/mlx5: E-switch, Add eswitch helpers for SF vport")
Signed-off-by: Uri Dar <udar@nvidia.com>
Reviewed-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20261118165155.1946097-1-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index 985263fda8f59..84cdf3e468b2f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -758,7 +758,8 @@ static void esw_vport_change_handler(struct work_struct *work)
 	struct mlx5_eswitch *esw = vport->dev->priv.eswitch;
 
 	mutex_lock(&esw->state_lock);
-	esw_vport_change_handle_locked(vport);
+	if (vport->enabled)
+		esw_vport_change_handle_locked(vport);
 	mutex_unlock(&esw->state_lock);
 }
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 236/555] ice: use global queue index in TC to-queue offload
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (234 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 235/555] net/mlx5: E-Switch, skip vport change work for disabled vports Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 237/555] ice: allow reading the last byte of the NVM and Shadow RAM regions Greg Kroah-Hartman
                   ` (318 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Aleksandr Loktionov,
	Michal Swiatkowski, Simon Horman, Alexander Nowlin, Tony Nguyen,
	Jakub Kicinski, Sasha Levin

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

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

From: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>

[ Upstream commit 9175e1d6d2f0d4f353682833f78188cb35b80e4d ]

Previously index within PF was used, which caused rules to fail on any PF
other than PF0. Switch to global queue index by adding first RX queue id
from caps.

Triggered during code development. Validated on HW by adding different
set of to queue rules on various PFs

Fixes: 143b86f346c7 ("ice: Enable RX queue selection using skbedit action")
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Tested-by: Alexander Nowlin <alexander.nowlin@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Link: https://patch.msgid.link/20261113231225.1864810-2-anthony.l.nguyen@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/intel/ice/ice_tc_lib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_tc_lib.c b/drivers/net/ethernet/intel/ice/ice_tc_lib.c
index ea39b999a0d00..ff8edcd1afda9 100644
--- a/drivers/net/ethernet/intel/ice/ice_tc_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_tc_lib.c
@@ -1047,7 +1047,8 @@ ice_add_tc_flower_adv_fltr(struct ice_vsi *vsi,
 		break;
 	case ICE_FWD_TO_Q:
 		/* HW queue number in global space */
-		rule_info.sw_act.fwd_id.q_id = tc_fltr->action.fwd.q.hw_queue;
+		rule_info.sw_act.fwd_id.q_id = tc_fltr->action.fwd.q.hw_queue +
+			hw->func_caps.common_cap.rxq_first_id;
 		rule_info.sw_act.vsi_handle = dest_vsi->idx;
 		rule_info.priority = ICE_SWITCH_FLTR_PRIO_QUEUE;
 		rule_info.sw_act.src = hw->pf_id;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 237/555] ice: allow reading the last byte of the NVM and Shadow RAM regions
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (235 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 236/555] ice: use global queue index in TC to-queue offload Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 238/555] ALSA: hda: intel: Release i915 power also when delayed probe fails Greg Kroah-Hartman
                   ` (317 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Petr Oros, Przemek Kitszel,
	Jacob Keller, Alexander Nowlin, Tony Nguyen, Jakub Kicinski,
	Sasha Levin

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

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

From: Petr Oros <poros@redhat.com>

[ Upstream commit dc84cae413bdcebfe130803022b8e02abc2ffa83 ]

ice_devlink_nvm_read() rejects a read whose end lands exactly on the
region size, so feeding back the size devlink itself reports fails:

  devlink region show pci/0000:04:00.0/nvm-flash
  pci/0000:04:00.0/nvm-flash: size 10485760 snapshot [] max 1

  devlink region read pci/0000:04:00.0/nvm-flash address 0 length 10485760
  Error: ice: Cannot read beyond the region size.

shadow-ram behaves the same. The regions are created with those sizes, so
a read ending on the size is the whole region and has to be allowed.
ice_read_flat_nvm() uses > for its own Shadow RAM check, and so does
ixgbe, which grew its region support from this code.

Fixes: 3af4b40b0f2f ("ice: implement direct read for NVM and Shadow RAM regions")
Signed-off-by: Petr Oros <poros@redhat.com>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Acked-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Alexander Nowlin <alexander.nowlin@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Link: https://patch.msgid.link/20261113231225.1864810-7-anthony.l.nguyen@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/intel/ice/devlink/devlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink.c b/drivers/net/ethernet/intel/ice/devlink/devlink.c
index b1efd287b3309..eed4b46c30977 100644
--- a/drivers/net/ethernet/intel/ice/devlink/devlink.c
+++ b/drivers/net/ethernet/intel/ice/devlink/devlink.c
@@ -1800,7 +1800,7 @@ static int ice_devlink_nvm_read(struct devlink *devlink,
 		return -EOPNOTSUPP;
 	}
 
-	if (offset + size >= nvm_size) {
+	if (offset + size > nvm_size) {
 		NL_SET_ERR_MSG_MOD(extack, "Cannot read beyond the region size");
 		return -ERANGE;
 	}
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 238/555] ALSA: hda: intel: Release i915 power also when delayed probe fails
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (236 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 237/555] ice: allow reading the last byte of the NVM and Shadow RAM regions Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 239/555] tools/bootconfig: Use the registered global tracing parameter names Greg Kroah-Hartman
                   ` (316 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Michal Grzelak, Kai Vehmanen,
	Takashi Iwai, Sasha Levin

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

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

From: Kai Vehmanen <kai.vehmanen@linux.intel.com>

[ Upstream commit 0a5550dd94e61852941fb37142f4664ecddef312 ]

Commit fbaccb1b19c7 ("ALSA: hda: intel: Don't free card in the probe
work") stopped freeing the card from azx_probe_work() when the delayed
probe fails, and only disconnects it, leaving the free to azx_remove().
This avoids the double free, but the resources that were released by
the card free via azx_free() are now kept until the PCI device is
unbound. In particular the display power reference stay held, blocking
runtime suspend for i915/xe.

Release the display power in the azx_probe_continue() work in all cases.
This power reference is only taken for the purpose of the display codec
probe. If the display codec probe was successful, it will have taken its
own reference. In case of systems with the HDA controller on GPU side
(hda->need_i915_power), functionality is same as before - we have to
keep power.

Fixes: fbaccb1b19c7 ("ALSA: hda: intel: Don't free card in the probe work")
Reported-by: Michal Grzelak <michal.grzelak@intel.com>
Link: https://gitlab.freedesktop.org/drm/i915/kernel/-/work_items/17751
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://patch.msgid.link/20261120150937.2187228-1-kai.vehmanen@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 sound/pci/hda/hda_intel.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 979290248eaba..754965cc0a48e 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -2386,6 +2386,9 @@ static int azx_probe_continue(struct azx *chip, bool free_on_error)
 	}
 
 out_free:
+	if (!hda->need_i915_power)
+		display_power(chip, false);
+
 	if (err < 0) {
 		if (hda->vga_switcheroo_registered)
 			dev_warn(&pci->dev, "GPU sound probed, but not operational: please add a quirk to driver_denylist\n");
@@ -2396,8 +2399,6 @@ static int azx_probe_continue(struct azx *chip, bool free_on_error)
 		return err;
 	}
 
-	if (!hda->need_i915_power)
-		display_power(chip, false);
 	complete_all(&hda->probe_wait);
 	to_hda_bus(bus)->bus_probing = 0;
 	hda->probe_retry = 0;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 239/555] tools/bootconfig: Use the registered global tracing parameter names
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (237 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 238/555] ALSA: hda: intel: Release i915 power also when delayed probe fails Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 240/555] tun: complete the zerocopy buffer of packets consumed by XDP Greg Kroah-Hartman
                   ` (315 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Eduardo Mucelli Rezende Oliveira,
	Masami Hiramatsu (Google), Sasha Levin

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

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

From: Eduardo Mucelli Rezende Oliveira <edumucelli@gmail.com>

[ Upstream commit 51934668ca98f1b23c51ce4edea3c61018da342c ]

The boot-time tracing guide lists four kernel.* keys that do not match
the parameters registered by the tracing code. For example,
ftrace2bconf.sh emits kernel.fgraph_max_depth, which bootconfig passes
as fgraph_max_depth on the kernel command line. The function-graph
tracer registers ftrace_graph_max_depth.

Use the registered names in the guide and the exporter. Teach
bconf2ftrace.sh to read those names, with the previous script keys as
fallbacks so existing replay configurations still work.

Link: https://lore.kernel.org/all/fecf6e33d4f7e2ddf031526e7a1abef27e28f754.1795307698.git.edumucelli@gmail.com/

Fixes: 47781947947a ("Documentation: tracing: Add boot-time tracing document")
Fixes: 7e66ef0046cc ("tools/bootconfig: Add a script to generate ftrace shell-command from bootconfig")
Fixes: 2b86062a34a8 ("tools/bootconfig: Add a script to generates bootconfig from ftrace")
Signed-off-by: Eduardo Mucelli Rezende Oliveira <edumucelli@gmail.com>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 Documentation/trace/boottime-trace.rst   |  8 ++++----
 tools/bootconfig/scripts/bconf2ftrace.sh | 21 ++++++++++++++++-----
 tools/bootconfig/scripts/ftrace2bconf.sh |  5 +++--
 3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/Documentation/trace/boottime-trace.rst b/Documentation/trace/boottime-trace.rst
index d594597201fdd..ac3aad42d73c5 100644
--- a/Documentation/trace/boottime-trace.rst
+++ b/Documentation/trace/boottime-trace.rst
@@ -36,20 +36,20 @@ these options are passed as a part of kernel legacy command line.
 kernel.tp_printk
    Output trace-event data on printk buffer too.
 
-kernel.dump_on_oops [= MODE]
+kernel.ftrace_dump_on_oops [= MODE]
    Dump ftrace on Oops. If MODE = 1 or omitted, dump trace buffer
    on all CPUs. If MODE = 2, dump a buffer on a CPU which kicks Oops.
 
 kernel.traceoff_on_warning
    Stop tracing if WARN_ON() occurs.
 
-kernel.fgraph_max_depth = MAX_DEPTH
+kernel.ftrace_graph_max_depth = MAX_DEPTH
    Set MAX_DEPTH to maximum depth of fgraph tracer.
 
-kernel.fgraph_filters = FILTER[, FILTER2...]
+kernel.ftrace_graph_filter = FILTER[, FILTER2...]
    Add fgraph tracing function filters.
 
-kernel.fgraph_notraces = FILTER[, FILTER2...]
+kernel.ftrace_graph_notrace = FILTER[, FILTER2...]
    Add fgraph non-tracing function filters.
 
 
diff --git a/tools/bootconfig/scripts/bconf2ftrace.sh b/tools/bootconfig/scripts/bconf2ftrace.sh
index 850c2073433e1..ba29f7411f62a 100755
--- a/tools/bootconfig/scripts/bconf2ftrace.sh
+++ b/tools/bootconfig/scripts/bconf2ftrace.sh
@@ -275,15 +275,26 @@ setup_instance() { # [instance]
 }
 
 # ftrace global configs (kernel.*)
-if xbc_has_key "kernel.dump_on_oops"; then
-	dump_mode=`xbc_get_val "kernel.dump_on_oops" 1`
+# Prefer the kernel parameter names and accept the old script keys as fallbacks.
+dump_key=kernel.ftrace_dump_on_oops
+xbc_has_key "$dump_key" || dump_key=kernel.dump_on_oops
+if xbc_has_key "$dump_key"; then
+	dump_mode=`xbc_get_val "$dump_key" 1`
 	[ "$dump_mode" ] && dump_mode=`eval echo $dump_mode` || dump_mode=1
 	run_cmd "echo \"$dump_mode\" > /proc/sys/kernel/ftrace_dump_on_oops"
 fi
 
-set_value_of kernel.fgraph_max_depth $TRACEFS/max_graph_depth
-set_array_of kernel.fgraph_filters $TRACEFS/set_graph_function
-set_array_of kernel.fgraph_notraces $TRACEFS/set_graph_notrace
+graph_depth_key=kernel.ftrace_graph_max_depth
+xbc_has_key "$graph_depth_key" || graph_depth_key=kernel.fgraph_max_depth
+set_value_of "$graph_depth_key" $TRACEFS/max_graph_depth
+
+graph_filter_key=kernel.ftrace_graph_filter
+xbc_has_key "$graph_filter_key" || graph_filter_key=kernel.fgraph_filters
+set_array_of "$graph_filter_key" $TRACEFS/set_graph_function
+
+graph_notrace_key=kernel.ftrace_graph_notrace
+xbc_has_key "$graph_notrace_key" || graph_notrace_key=kernel.fgraph_notraces
+set_array_of "$graph_notrace_key" $TRACEFS/set_graph_notrace
 
 # Per-instance/per-event configs
 if ! xbc_has_branch "ftrace" ; then
diff --git a/tools/bootconfig/scripts/ftrace2bconf.sh b/tools/bootconfig/scripts/ftrace2bconf.sh
index 1603801cf1264..564a3085525f3 100755
--- a/tools/bootconfig/scripts/ftrace2bconf.sh
+++ b/tools/bootconfig/scripts/ftrace2bconf.sh
@@ -46,10 +46,11 @@ emit_kv() { # key =|+= value
 
 global_options() {
 	val=`cat $TRACEFS/max_graph_depth`
-	[ $val != 0 ] && emit_kv kernel.fgraph_max_depth = $val
+	[ $val != 0 ] && emit_kv kernel.ftrace_graph_max_depth = $val
 	if grep -qv "^#" $TRACEFS/set_graph_function $TRACEFS/set_graph_notrace ; then
 		cat 1>&2 << EOF
-# WARN: kernel.fgraph_filters and kernel.fgraph_notrace are not supported, since the wild card expression was expanded and lost from memory.
+# WARN: Cannot export kernel.ftrace_graph_filter and kernel.ftrace_graph_notrace.
+# Only the expanded function list is available.
 EOF
 	fi
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 240/555] tun: complete the zerocopy buffer of packets consumed by XDP
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (238 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 239/555] tools/bootconfig: Use the registered global tracing parameter names Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 241/555] tools: gpio-hammer: Accept the maximum number of line offsets Greg Kroah-Hartman
                   ` (314 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Antonio Quartulli, Paolo Abeni,
	Sasha Levin

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

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

From: Antonio Quartulli <antonio@mandelbit.com>

[ Upstream commit 3896ae4adf5ffc11ffd0f7f42c3923e8dc195e75 ]

When vhost-net passes a zerocopy buffer that tun_get_user() does not use,
because the packet spans too many pages, the packet is copied and the
buffer completed. If the copy goes through build_skb() and native XDP
consumes the packet (DROP, TX or REDIRECT), tun_get_user() returns
without completing it: vhost-net never gets the descriptor back, and
closing the vhost-net device then blocks forever.

Complete it in that case too, as copied.

Reproducer: vhost-net with experimental_zcopytx=1 on a tap device with a
native XDP_DROP program; send one 806-byte packet as 40 descriptors, each
in its own page. The descriptor is never returned and close() of the
vhost-net fd does not return. With the patch it is returned.

Tested in an x86-64 VM with the reproducer and the tun kselftest.

Found by the Sashiko AI review bot, as a pre-existing issue while
reviewing an unrelated tun patch, and confirmed with the reproducer.

Link: https://sashiko.dev/#/bug/linux-f9997fb6-303f-41d6-93e2-60c392b1856f
Fixes: 761876c857cb ("tap: XDP support")
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
Link: https://patch.msgid.link/20261113232843.2338734-1-antonio@mandelbit.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/tun.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index e8b4d988cd330..016fc158e13af 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1844,8 +1844,15 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
 		err = PTR_ERR_OR_ZERO(skb);
 		if (err)
 			goto drop;
-		if (!skb)
+		if (!skb) {
+			/* consumed by XDP, after copying */
+			if (msg_control) {
+				struct ubuf_info *uarg = msg_control;
+
+				uarg->ops->complete(NULL, uarg, false);
+			}
 			return total_len;
+		}
 	} else {
 		if (!zerocopy) {
 			copylen = len;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 241/555] tools: gpio-hammer: Accept the maximum number of line offsets
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (239 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 240/555] tun: complete the zerocopy buffer of packets consumed by XDP Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 242/555] tools: gpio: Preserve device listing errors in lsgpio Greg Kroah-Hartman
                   ` (313 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Zhu Jun, Bartosz Golaszewski,
	Sasha Levin

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

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

From: Zhu Jun <zhujun2@cmss.chinamobile.com>

[ Upstream commit 0b3f1876d6db7fad0391ce714b315269b0dd5758 ]

The offset count is incremented for every -o option, but the final
check rejects the maximum itself and reports one extra offset. Only
reject counts above the maximum and report the actual count.

Fixes: d1ee7e1f5c91 ("tools: gpio-hammer: Avoid potential overflow in main")
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
Link: https://patch.msgid.link/20261120061827.98066-1-zhujun2@cmss.chinamobile.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/gpio/gpio-hammer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/gpio/gpio-hammer.c b/tools/gpio/gpio-hammer.c
index ba0866eb35814..1b33691a68a36 100644
--- a/tools/gpio/gpio-hammer.c
+++ b/tools/gpio/gpio-hammer.c
@@ -159,10 +159,10 @@ int main(int argc, char **argv)
 		}
 	}
 
-	if (i >= GPIOHANDLES_MAX) {
+	if (i > GPIOHANDLES_MAX) {
 		fprintf(stderr,
 			"Only %d occurrences of '-o' are allowed, %d were found\n",
-			GPIOHANDLES_MAX, i + 1);
+			GPIOHANDLES_MAX, i);
 		return -1;
 	}
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 242/555] tools: gpio: Preserve device listing errors in lsgpio
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (240 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 241/555] tools: gpio-hammer: Accept the maximum number of line offsets Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 243/555] tools: gpio: Return success after monitoring requested events Greg Kroah-Hartman
                   ` (312 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Zhu Jun, Bartosz Golaszewski,
	Sasha Levin

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

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

From: Zhu Jun <zhujun2@cmss.chinamobile.com>

[ Upstream commit 809117fc28453aafa7164ad45ea853f900974d08 ]

When no chip is selected, lsgpio breaks out of the directory scan on a
list_device() failure, then unconditionally resets ret to zero. A chip
that cannot be opened or queried is therefore reported as success.

Initialize ret to zero before scanning instead, so an empty scan still
succeeds and errors from list_device() reach the caller.

Fixes: 6d591c46bce0 ("tools/gpio: create GPIO tools")
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
Link: https://patch.msgid.link/20261120062053.98356-1-zhujun2@cmss.chinamobile.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/gpio/lsgpio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/gpio/lsgpio.c b/tools/gpio/lsgpio.c
index 52a0be45410c9..de2eccc134796 100644
--- a/tools/gpio/lsgpio.c
+++ b/tools/gpio/lsgpio.c
@@ -205,7 +205,7 @@ int main(int argc, char **argv)
 			goto error_out;
 		}
 
-		ret = -ENOENT;
+		ret = 0;
 		while (ent = readdir(dp), ent) {
 			if (check_prefix(ent->d_name, "gpiochip")) {
 				ret = list_device(ent->d_name);
@@ -214,7 +214,6 @@ int main(int argc, char **argv)
 			}
 		}
 
-		ret = 0;
 		if (closedir(dp) == -1) {
 			perror("scanning devices: Failed to close directory");
 			ret = -errno;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 243/555] tools: gpio: Return success after monitoring requested events
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (241 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 242/555] tools: gpio: Preserve device listing errors in lsgpio Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 244/555] s390/cert_store: Allocate keyring with link restriction Greg Kroah-Hartman
                   ` (311 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Zhu Jun, Bartosz Golaszewski,
	Sasha Levin

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

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

From: Zhu Jun <zhujun2@cmss.chinamobile.com>

[ Upstream commit 1eaf27d99938dd30ea7855174b65e37a2503a349 ]

After reading the requested number of events, monitor_device() returns
the positive byte count left in ret by read(). main() passes this value
through as the exit status, so a successful invocation with -c reports
failure.

Clear ret when the event limit is reached, keeping read failures on their
existing error paths.

Fixes: 97f69747d8b1 ("tools/gpio: add the gpio-event-mon tool")
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
Link: https://patch.msgid.link/20261120062107.98391-1-zhujun2@cmss.chinamobile.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/gpio/gpio-event-mon.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/gpio/gpio-event-mon.c b/tools/gpio/gpio-event-mon.c
index 5dee2b98ab604..77807be4fc39b 100644
--- a/tools/gpio/gpio-event-mon.c
+++ b/tools/gpio/gpio-event-mon.c
@@ -124,8 +124,10 @@ int monitor_device(const char *device_name,
 		fprintf(stdout, "\n");
 
 		i++;
-		if (i == loops)
+		if (i == loops) {
+			ret = 0;
 			break;
+		}
 	}
 
 exit_line_close:
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 244/555] s390/cert_store: Allocate keyring with link restriction
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (242 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 243/555] tools: gpio: Return success after monitoring requested events Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 245/555] s390/cert_store: Only allow the kernel to create cert_store_key keys Greg Kroah-Hartman
                   ` (310 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Anastasia Eskova, Jarkko Sakkinen,
	Heiko Carstens, Sasha Levin

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

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

From: Anastasia Eskova <anastasia.eskova@ibm.com>

[ Upstream commit 602af7b1c19309330a36ffe787336cb95e040ab1 ]

The keyring is linked into the user session keyring on allocation, but
keyring_restrict() is only called after all certificates were added.
Until then a possessor of the keyring can link arbitrary keys into it.
If keyring_restrict() fails, the error is only logged and the keyring
stays writable.

Allocate the keyring with a restriction which rejects all links, create
the certificate keys with KEY_ALLOC_BYPASS_RESTRICTION and drop the late
keyring_restrict() call.

Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Signed-off-by: Anastasia Eskova <anastasia.eskova@ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/s390/kernel/cert_store.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index d91f1d21e3795..35b64bad24c19 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -402,6 +402,7 @@ static void cleanup_cs_keys(void)
 
 static struct key *create_cs_keyring(void)
 {
+	struct key_restriction *restriction;
 	struct key *cs_keyring, *us_keyring;
 
 	/* Cleanup previous cs_keyring and all associated keys if any. */
@@ -409,13 +410,21 @@ static struct key *create_cs_keyring(void)
 	us_keyring = get_user_session_keyring();
 	if (IS_ERR(us_keyring))
 		return NULL;
+	restriction = kzalloc_obj(*restriction);
+	if (!restriction) {
+		key_put(us_keyring);
+		return NULL;
+	}
+	/* Reject all links, the kernel bypasses the restriction. */
+	restriction->check = restrict_link_reject;
 	cs_keyring = keyring_alloc(CERT_STORE_KEYRING_NAME, GLOBAL_ROOT_UID,
 				   GLOBAL_ROOT_GID, current_cred(),
 				   (KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_VIEW | KEY_USR_READ,
 				   KEY_ALLOC_NOT_IN_QUOTA | KEY_ALLOC_SET_KEEP,
-				   NULL, us_keyring);
+				   restriction, us_keyring);
 	key_put(us_keyring);
 	if (IS_ERR(cs_keyring)) {
+		kfree(restriction);
 		pr_dbf_msg("Can't allocate cert_store keyring");
 		return NULL;
 	}
@@ -478,7 +487,7 @@ static int create_key_from_vce(struct vcssb *vcssb, struct vce *vce,
 		desc, (u8 *)vce + vce->vce_hdr.vc_offset,
 		vce->vce_hdr.vc_length,
 		(KEY_POS_ALL & ~KEY_POS_SETATTR)  | KEY_USR_VIEW | KEY_USR_READ,
-		KEY_ALLOC_NOT_IN_QUOTA);
+		KEY_ALLOC_NOT_IN_QUOTA | KEY_ALLOC_BYPASS_RESTRICTION);
 
 	rc = PTR_ERR_OR_ZERO(newkey);
 	if (rc) {
@@ -646,14 +655,6 @@ static int add_certificates_to_keyring(struct vcssb *vcssb, struct key *keyring)
 
 	pr_info("Added %d of %d keys to cert_store keyring", added, count);
 
-	/*
-	 * Do not allow to link more keys to certificate store keyring after all
-	 * the VCEs were processed.
-	 */
-	rc = keyring_restrict(make_key_ref(keyring, true), NULL, NULL);
-	if (rc)
-		pr_dbf_msg("Failed to set restriction to cert_store keyring (%d)", rc);
-
 	return 0;
 }
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 245/555] s390/cert_store: Only allow the kernel to create cert_store_key keys
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (243 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 244/555] s390/cert_store: Allocate keyring with link restriction Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 246/555] chardev: GPIO common access methods: repair non-kernel-doc comment Greg Kroah-Hartman
                   ` (309 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Anastasia Eskova, Jarkko Sakkinen,
	Heiko Carstens, Sasha Levin

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

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

From: Anastasia Eskova <anastasia.eskova@ibm.com>

[ Upstream commit 23a04cb4f2bdbfc87fc4e1c15450e7f8cfc9842a ]

Keys of type cert_store_key can be created by any user with add_key() in
any keyring, as the key type has no vet_description() callback. The type
is registered whenever CONFIG_CERT_STORE is enabled, even if the machine
has no DIAG 320 support.

cert_store_key_describe() expects a description in the format created by
get_key_description(), i.e. a 64 byte key name followed by the VCE index
and the certificate store token. If a key with a shorter description is
created, seq_puts() may read beyond the end of the description
allocation. Reading /proc/keys may then disclose adjacent kernel heap
memory to the user space. Also, a consumer which trusts keys by type can
be fooled by keys that were not created from the certificate store.

Add a vet_description() callback which only accepts the task currently
executing refresh_store(), which creates all valid keys of this type.

Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Signed-off-by: Anastasia Eskova <anastasia.eskova@ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/s390/kernel/cert_store.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index 35b64bad24c19..8e9c0025f2dba 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -45,6 +45,9 @@
 static debug_info_t *cert_store_dbf;
 static debug_info_t *cert_store_hexdump;
 
+/* Task currently running refresh_store(). Written under cs_refresh_lock. */
+static struct task_struct *cs_refresh_task;
+
 #define pr_dbf_msg(fmt, ...) \
 	debug_sprintf_event(cert_store_dbf, 3, fmt "\n", ## __VA_ARGS__)
 
@@ -147,12 +150,24 @@ static void cert_store_key_describe(const struct key *key, struct seq_file *m)
 		seq_printf(m, ": %u", key->datalen);
 }
 
+/*
+ * Only the kernel may create keys of this type. Accept the task which runs
+ * refresh_store(), as it cannot execute userspace during the refresh.
+ */
+static int cert_store_key_vet_description(const char *description)
+{
+	if (READ_ONCE(cs_refresh_task) != current)
+		return -EPERM;
+	return 0;
+}
+
 /*
  * Certificate store key type takes over properties of
  * user key but cannot be updated.
  */
 static struct key_type key_type_cert_store_key = {
 	.name		= CERT_STORE_KEY_TYPE_NAME,
+	.vet_description = cert_store_key_vet_description,
 	.preparse	= user_preparse,
 	.free_preparse	= user_free_preparse,
 	.instantiate	= generic_key_instantiate,
@@ -761,6 +776,7 @@ static ssize_t refresh_store(struct kobject *kobj, struct kobj_attribute *attr,
 	if (rc)
 		return rc;
 
+	WRITE_ONCE(cs_refresh_task, current);
 	for (retries = 0; retries < DIAG_MAX_RETRIES; retries++) {
 		/* Request certificates from certificate store. */
 		rc = fill_cs_keyring();
@@ -769,6 +785,7 @@ static ssize_t refresh_store(struct kobject *kobj, struct kobj_attribute *attr,
 		if (rc != -EAGAIN)
 			break;
 	}
+	WRITE_ONCE(cs_refresh_task, NULL);
 	cs_status_val = rc;
 	mutex_unlock(&cs_refresh_lock);
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 246/555] chardev: GPIO common access methods: repair non-kernel-doc comment
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (244 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 245/555] s390/cert_store: Only allow the kernel to create cert_store_key keys Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 247/555] tun: flush uc and mc addresses in TUNSETLINK Greg Kroah-Hartman
                   ` (308 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Randy Dunlap, Jim Cromie,
	Linus Walleij, Bartosz Golaszewski, Sasha Levin

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

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

From: Randy Dunlap <rdunlap@infradead.org>

[ Upstream commit d4dc896fa2bdfd7d1a78911598a0fa3e3c831d92 ]

Change a "/**" non-kernel-doc comment to a plain C comment "/*"
to avoid 21 warnings like these:

Warning: ./include/linux/nsc_gpio.h:2 Cannot find identifier on line:
   nsc_gpio.c
Warning: ./include/linux/nsc_gpio.h:4 Cannot find identifier on line:
   National Semiconductor GPIO common access methods.
Warning: ./include/linux/nsc_gpio.h:6 Cannot find identifier on line:
   struct nsc_gpio_ops abstracts the low-level access

Fixes: fe3a168a2ce1 ("[PATCH] chardev: GPIO for SCx200 & PC-8736x: add gpio-ops vtable")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Acked-by: Jim Cromie <jim.cromie@gmail.com>
Acked-by: Linus Walleij <linusw@kernel.org>
Link: https://patch.msgid.link/20261123004501.1771603-1-rdunlap@infradead.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/linux/nsc_gpio.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/nsc_gpio.h b/include/linux/nsc_gpio.h
index d7a04a6e3783a..342ce97975e8a 100644
--- a/include/linux/nsc_gpio.h
+++ b/include/linux/nsc_gpio.h
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-/**
+/*
    nsc_gpio.c
 
    National Semiconductor GPIO common access methods.
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 247/555] tun: flush uc and mc addresses in TUNSETLINK
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (245 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 246/555] chardev: GPIO common access methods: repair non-kernel-doc comment Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 248/555] btrfs: send: fix missing hole punching during incremental send Greg Kroah-Hartman
                   ` (307 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Eric Dumazet, Willem de Bruijn,
	Paolo Abeni, Sasha Levin

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

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

From: Eric Dumazet <edumazet@kernel.org>

[ Upstream commit 5677cf0e039b3cabf79d5aa10facbdb54aea93c6 ]

TUNSETLINK changes dev->type and dev->addr_len, but leaves
dev->uc and dev->mc untouched.

Entries added with the old addr_len stay in lists and rb-trees
that are now searched and dumped with the new addr_len.

When addr_len grows (eg ARPHRD_NONE -> ARPHRD_IP6GRE), dumps like
/proc/net/dev_mcast and RTM_GETMULTICAST expose bytes of
netdev_hw_addr that were never initialized.

bonding and team already call dev_uc_flush() and dev_mc_flush()
between NETDEV_PRE_TYPE_CHANGE and the type change. Do the same
in tun, but only when addr_len changes: if it does not, existing
entries are still valid and there is no reason to drop them.

Fixes: cca8ea3b05c9 ("net: tun: set tun->dev->addr_len during TUNSETLINK processing")
Link: https://lore.kernel.org/netdev/20261116024056.1274402-1-bsdhenrymartin@gmail.com/
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20261118125443.1137177-1-edumazet@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/tun.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 016fc158e13af..815a0b8319983 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -3282,6 +3282,8 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
 			   (unsigned short)arg == ARPHRD_6LOWPAN) {
 			ret = -EINVAL;
 		} else {
+			unsigned char addr_len = tun_get_addr_len(arg);
+
 			ret = call_netdevice_notifiers(NETDEV_PRE_TYPE_CHANGE,
 						       tun->dev);
 			ret = notifier_to_errno(ret);
@@ -3290,8 +3292,13 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
 					   "Refused to change device type\n");
 				break;
 			}
+			/* Addresses were added with the old dev->addr_len. */
+			if (addr_len != tun->dev->addr_len) {
+				dev_uc_flush(tun->dev);
+				dev_mc_flush(tun->dev);
+			}
 			tun->dev->type = (int) arg;
-			tun->dev->addr_len = tun_get_addr_len(tun->dev->type);
+			tun->dev->addr_len = addr_len;
 			netif_info(tun, drv, tun->dev, "linktype set to %d\n",
 				   tun->dev->type);
 			call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE,
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 248/555] btrfs: send: fix missing hole punching during incremental send
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (246 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 247/555] tun: flush uc and mc addresses in TUNSETLINK Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 249/555] btrfs: send: fix invalid access to inline extents in clone_range() Greg Kroah-Hartman
                   ` (306 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Tristan Elvers, Qu Wenruo,
	Filipe Manana, David Sterba, Sasha Levin

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

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

From: Filipe Manana <fdmanana@suse.com>

[ Upstream commit 398ee8a011d9187e83fc24738b3391e508da91da ]

When using the no-holes feature (enabled by default since btrfs-progs
v5.15) and doing an incremental send, we can miss issuing a hole punching
command when the following conditions happen:

1) A hole is punched in a tail section of a file extent item that happens
   to be the last item in a leaf (for example the extent covers the file
   range [1M, 3M) and a hole is punched in the range [2M, 3M)). Between
   the end of this file extent item's range and the i_size, there are
   other file extent items;

2) The next leaf was not modified in the send snapshot, remaining shared
   with the parent snapshot.

In this scenario we are unable to detect a hole was punched and never
issue a hole punch command because with no-holes there we don't have an
explicit file extent item to mark a hole.

Fix this by teaching maybe_send_hole() to detect such case.
A test case for fstests will follow soon.

Reported-by: Tristan Elvers <tristanelvers@gmail.com>
Link: https://lore.kernel.org/linux-btrfs/CAFoLKK+aErV4p6ZJPnVeH5SHQ5++0f=8ZgxPWe-E-CkeKBs8PA@mail.gmail.com/
Fixes: 16e7549f045d ("Btrfs: incompatible format change to remove hole extents")
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/btrfs/send.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 65 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 6300418ce3574..8bb1031afbc8f 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -6569,6 +6569,9 @@ static int range_is_hole_in_parent(struct send_ctx *sctx,
 static int maybe_send_hole(struct send_ctx *sctx, struct btrfs_path *path,
 			   struct btrfs_key *key)
 {
+	BTRFS_PATH_AUTO_FREE(next_path);
+	const u64 cur_extent_end = btrfs_file_extent_end(path);
+	u64 next_offset;
 	int ret = 0;
 
 	if (sctx->cur_ino != key->objectid || !need_send_hole(sctx))
@@ -6595,14 +6598,72 @@ static int maybe_send_hole(struct send_ctx *sctx, struct btrfs_path *path,
 		ret = range_is_hole_in_parent(sctx,
 					      sctx->cur_inode_last_extent,
 					      key->offset);
+		if (ret == 0)
+			ret = send_hole(sctx, key->offset);
+		else if (ret == 1)
+			ret = 0;
+
 		if (ret < 0)
 			return ret;
-		else if (ret == 0)
-			ret = send_hole(sctx, key->offset);
+	}
+	sctx->cur_inode_last_extent = cur_extent_end;
+
+	/*
+	 * If we are the last file extent item in a leaf, we may have had a tail
+	 * section that got a hole punched or the extent replaced with a smaller
+	 * one, and if there is no change in the next leaf, we must find out if
+	 * we have such a hole and punch it.
+	 */
+	if (!btrfs_fs_incompat(sctx->send_root->fs_info, NO_HOLES) ||
+	    (sctx->cur_inode_size <= cur_extent_end) ||
+	    (path->slots[0] != btrfs_header_nritems(path->nodes[0]) - 1))
+		return 0;
+
+	next_path = alloc_path_for_send();
+	if (!next_path)
+		return -ENOMEM;
+
+	ret = btrfs_search_slot(NULL, sctx->send_root, key, next_path, 0, 0);
+	if (ret < 0)
+		return ret;
+	if (WARN_ON(ret != 0))
+		return -EUCLEAN;
+
+	ret = btrfs_next_leaf(sctx->send_root, next_path);
+	if (ret < 0) {
+		return ret;
+	} else if (ret > 0) {
+		/*
+		 * No next leaf, must punch hole to i_size and set the path back
+		 * to where it was before.
+		 */
+		next_offset = sctx->cur_inode_size;
+	} else {
+		struct btrfs_key next_key;
+
+		btrfs_item_key_to_cpu(next_path->nodes[0], &next_key,
+				      next_path->slots[0]);
+		if (next_key.objectid != key->objectid ||
+		    next_key.type != BTRFS_EXTENT_DATA_KEY)
+			next_offset = sctx->cur_inode_size;
 		else
-			ret = 0;
+			next_offset = next_key.offset;
 	}
-	sctx->cur_inode_last_extent = btrfs_file_extent_end(path);
+
+	if (next_offset == cur_extent_end)
+		return 0;
+
+	btrfs_free_path(next_path);
+	next_path = NULL;
+
+	ret = range_is_hole_in_parent(sctx, sctx->cur_inode_last_extent, next_offset);
+	if (ret == 0)
+		ret = send_hole(sctx, next_offset);
+	else if (ret == 1)
+		ret = 0;
+
+	sctx->cur_inode_last_extent = next_offset;
+
 	return ret;
 }
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 249/555] btrfs: send: fix invalid access to inline extents in clone_range()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (247 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 248/555] btrfs: send: fix missing hole punching during incremental send Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 250/555] btrfs: wait for a grace period before freeing a new device Greg Kroah-Hartman
                   ` (305 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Qu Wenruo, Filipe Manana,
	David Sterba, Sasha Levin

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

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

From: Filipe Manana <fdmanana@suse.com>

[ Upstream commit beed53bd3cb5f0b0a0aad453aa6f0b49060ff2dc ]

We can't access the disk_bytenr and offset fields of a file extent item
that represents an inline extent, since the extent's data starts at the
offset of the disk_bytenr field and the offset field is after that, so
both fields point either to inline data or beyond the file extent item
in case the data is too small.

Fix this by not reading the disk_bytenr and offset fields if we are
dealing with an inline extent.

Link: https://sashiko.dev/#/bug/linux-b662b951-0491-465b-a262-f01a108d8146
Fixes: 040ee6120cb6 ("Btrfs: send, improve clone range")
Fixes: d906d49fc5f4 ("Btrfs: send, fix file corruption due to incorrect cloning operations")
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/btrfs/send.c | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 8bb1031afbc8f..f80f9ea317829 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -6015,7 +6015,7 @@ static int clone_range(struct send_ctx *sctx, struct btrfs_path *dst_path,
 		u8 type;
 		u64 ext_len;
 		u64 clone_len;
-		u64 clone_data_offset;
+		u64 clone_data_offset = 0;
 		bool crossed_src_i_size = false;
 
 		if (slot >= btrfs_header_nritems(leaf)) {
@@ -6079,23 +6079,26 @@ static int clone_range(struct send_ctx *sctx, struct btrfs_path *dst_path,
 			crossed_src_i_size = true;
 		}
 
-		clone_data_offset = btrfs_file_extent_offset(leaf, ei);
-		if (btrfs_file_extent_disk_bytenr(leaf, ei) == disk_byte) {
-			clone_root->offset = key.offset;
-			if (clone_data_offset < data_offset &&
-				clone_data_offset + ext_len > data_offset) {
-				u64 extent_offset;
-
-				extent_offset = data_offset - clone_data_offset;
-				ext_len -= extent_offset;
-				clone_data_offset += extent_offset;
-				clone_root->offset += extent_offset;
+		if (type != BTRFS_FILE_EXTENT_INLINE) {
+			clone_data_offset = btrfs_file_extent_offset(leaf, ei);
+			if (btrfs_file_extent_disk_bytenr(leaf, ei) == disk_byte) {
+				clone_root->offset = key.offset;
+				if (clone_data_offset < data_offset &&
+				    clone_data_offset + ext_len > data_offset) {
+					u64 extent_offset;
+
+					extent_offset = data_offset - clone_data_offset;
+					ext_len -= extent_offset;
+					clone_data_offset += extent_offset;
+					clone_root->offset += extent_offset;
+				}
 			}
 		}
 
 		clone_len = min_t(u64, ext_len, len);
 
-		if (btrfs_file_extent_disk_bytenr(leaf, ei) == disk_byte &&
+		if (type != BTRFS_FILE_EXTENT_INLINE &&
+		    btrfs_file_extent_disk_bytenr(leaf, ei) == disk_byte &&
 		    clone_data_offset == data_offset) {
 			const u64 src_end = clone_root->offset + clone_len;
 			const u64 sectorsize = SZ_64K;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 250/555] btrfs: wait for a grace period before freeing a new device
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (248 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 249/555] btrfs: send: fix invalid access to inline extents in clone_range() Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 251/555] ASoC: fsl_asrc: fix pair ownership on repeated or failed hw_params Greg Kroah-Hartman
                   ` (304 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Daniel Vacek, Binbin Deng,
	David Sterba, Sasha Levin

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

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

From: Binbin Deng <18983559317@163.com>

[ Upstream commit 38c94b99f8743a5b9aab864a12ecf9a06d36aeb4 ]

KASAN reports a slab-use-after-free in btrfs_statfs() walking
fs_devices->devices. btrfs_init_new_device() publishes the new device
with list_add_rcu() and can fail afterwards, for example with -ENOSPC
in init_first_rw_device() when a user with CAP_SYS_ADMIN adds a device
that is too small to a seeding filesystem mounted read-only. The error
path removes the entry with list_del_rcu() and frees the object in
btrfs_free_device() without waiting for a grace period, while
btrfs_calc_avail_data_space() and btrfs_ioctl_fs_info() keep reading
the device list under rcu_read_lock().

BUG: KASAN: slab-use-after-free in btrfs_statfs+0x11af/0x14a0
Read of size 8 at addr ffff8880096be858 by task poc/252
Call Trace:
 <TASK>
 dump_stack_lvl+0x53/0x70
 print_report+0xd0/0x630
 ? __pfx__raw_spin_lock_irqsave+0x10/0x10
 ? filename_lookup+0x1a9/0x540
 ? btrfs_statfs+0x11af/0x14a0
 kasan_report+0xce/0x100
 ? btrfs_statfs+0x11af/0x14a0
 btrfs_statfs+0x11af/0x14a0
 statfs_by_dentry+0x117/0x1e0
 user_statfs+0xac/0x130
 ? __pfx_user_statfs+0x10/0x10
 __do_sys_statfs+0x80/0xe0
 ? __pfx___do_sys_statfs+0x10/0x10
 do_syscall_64+0xf9/0x540
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Allocated by task 256:
 kasan_save_stack+0x33/0x60
 kasan_save_track+0x14/0x30
 __kasan_kmalloc+0x8f/0xa0
 __kmalloc_cache_noprof+0x158/0x370
 btrfs_alloc_device+0xad/0x3e0
 btrfs_init_new_device+0x3e8/0x36e0
 btrfs_ioctl+0x150d/0x6c20
 __x64_sys_ioctl+0x134/0x1c0
 do_syscall_64+0xf9/0x540
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 256:
 kasan_save_stack+0x33/0x60
 kasan_save_track+0x14/0x30
 kasan_save_free_info+0x3b/0x60
 __kasan_slab_free+0x43/0x70
 kfree+0x121/0x380
 btrfs_init_new_device+0x4a0/0x36e0
 btrfs_ioctl+0x150d/0x6c20
 __x64_sys_ioctl+0x134/0x1c0
 do_syscall_64+0xf9/0x540
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Fix by waiting for an RCU grace period after the device is removed
from the list and before it is freed.Place the synchronize_rcu() after
dropping the mutexes and before the `error_trans` label.

Fixes: 1f78160ce1b1 ("Btrfs: using rcu lock in the reader side of devices list")
Reviewed-by: Daniel Vacek <neelx@suse.com>
Signed-off-by: Binbin Deng <18983559317@163.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/btrfs/volumes.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 0652c630743e8..0587de27a277f 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -3066,6 +3066,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
 		btrfs_rollback_sprout(fs_info, seed_devices);
 	mutex_unlock(&fs_info->chunk_mutex);
 	mutex_unlock(&fs_info->fs_devices->device_list_mutex);
+	synchronize_rcu();
 error_trans:
 	if (trans)
 		btrfs_end_transaction(trans);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 251/555] ASoC: fsl_asrc: fix pair ownership on repeated or failed hw_params
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (249 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 250/555] btrfs: wait for a grace period before freeing a new device Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 252/555] ASoC: fsl_easrc: fix context ownership on repeated hw_params Greg Kroah-Hartman
                   ` (303 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Stefan Ghetu, Shengjiu Wang,
	Mark Brown, Sasha Levin

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

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

From: Stefan Ghetu <stefan.ghetu@nxp.com>

[ Upstream commit fbeac9352de6584bd5eb7c23d2f224339772c992 ]

hw_params() can be called again without hw_free() in between, and
hw_free() is also called after a failed hw_params().

fsl_asrc_request_pair() always takes a new pair, so a second hw_params()
leaves the stream in two asrc->pair[] entries. Only one is released, and
after close the other points to freed memory, which is dereferenced by
fsl_asrc_isr() and fsl_asrc_m2m_suspend(). After a failed hw_params(),
fsl_asrc_release_pair() releases a stale index that may belong to
another running stream.

Keep the owned pair and only update its channels when it is requested
again, and ignore a pair the stream does not own on release.

Fixes: 3117bb3109dc ("ASoC: fsl_asrc: Add ASRC ASoC CPU DAI and platform drivers")
Signed-off-by: Stefan Ghetu <stefan.ghetu@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@gmail.com>
Link: https://patch.msgid.link/20261116093751.138455-3-stefan.ghetu@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 sound/soc/fsl/fsl_asrc.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c
index f68b53ba17dd7..73eee0f43ba99 100644
--- a/sound/soc/fsl/fsl_asrc.c
+++ b/sound/soc/fsl/fsl_asrc.c
@@ -210,6 +210,8 @@ static void fsl_asrc_sel_proc(int inrate, int outrate,
  * It assigns pair by the order of A->C->B because allocation of pair B,
  * within range [ANCA, ANCA+ANCB-1], depends on the channels of pair A
  * while pair A and pair C are comparatively independent.
+ *
+ * If @pair already owns a pair, it is kept and only its channels are updated.
  */
 static int fsl_asrc_request_pair(int channels, struct fsl_asrc_pair *pair)
 {
@@ -221,6 +223,19 @@ static int fsl_asrc_request_pair(int channels, struct fsl_asrc_pair *pair)
 
 	spin_lock_irqsave(&asrc->lock, lock_flags);
 
+	if (asrc->pair[pair->index] == pair) {
+		if (asrc->channel_avail + pair->channels < channels) {
+			dev_err(dev, "can't afford required channels: %d\n", channels);
+			return -EINVAL;
+		}
+
+		asrc->channel_avail += pair->channels;
+		asrc->channel_avail -= channels;
+		pair->channels = channels;
+
+		return 0;
+	}
+
 	for (i = ASRC_PAIR_A; i < ASRC_PAIR_MAX_NUM; i++) {
 		if (asrc->pair[i] != NULL)
 			continue;
@@ -254,6 +269,7 @@ static int fsl_asrc_request_pair(int channels, struct fsl_asrc_pair *pair)
  * @pair: pair to release
  *
  * It clears the resource from asrc and releases the occupied channels.
+ * Nothing is done if @pair does not own a pair.
  */
 static void fsl_asrc_release_pair(struct fsl_asrc_pair *pair)
 {
@@ -261,6 +277,12 @@ static void fsl_asrc_release_pair(struct fsl_asrc_pair *pair)
 	enum asrc_pair_index index = pair->index;
 	unsigned long lock_flags;
 
+	/* Only the owner clears its entry, so it cannot change after this check */
+	scoped_guard(spinlock_irqsave, &asrc->lock) {
+		if (asrc->pair[index] != pair)
+			return;
+	}
+
 	/* Make sure the pair is disabled */
 	regmap_update_bits(asrc->regmap, REG_ASRCTR,
 			   ASRCTR_ASRCEi_MASK(index), 0);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 252/555] ASoC: fsl_easrc: fix context ownership on repeated hw_params
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (250 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 251/555] ASoC: fsl_asrc: fix pair ownership on repeated or failed hw_params Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 253/555] btrfs: remove devid kobject when deleting a missing device Greg Kroah-Hartman
                   ` (302 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Stefan Ghetu, Shengjiu Wang,
	Mark Brown, Sasha Levin

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

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

From: Stefan Ghetu <stefan.ghetu@nxp.com>

[ Upstream commit f50dfefe6d4dd8cf5e826353de21228b9f073e68 ]

hw_params() can be called again without hw_free() in between.
fsl_easrc_hw_params() then requests a second context while the stream
still owns the first one, which is never released. After close, that
easrc->pair[] entry points to freed memory and is dereferenced by
fsl_easrc_runtime_resume() on the next open.

The EASRC slots depend on the number of channels, so release the owned
context before requesting a new one, and make
fsl_easrc_release_context() ignore a context it does not own.

Fixes: 955ac624058f ("ASoC: fsl_easrc: Add EASRC ASoC CPU DAI drivers")
Signed-off-by: Stefan Ghetu <stefan.ghetu@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@gmail.com>
Link: https://patch.msgid.link/20261116093751.138455-5-stefan.ghetu@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 sound/soc/fsl/fsl_easrc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/sound/soc/fsl/fsl_easrc.c b/sound/soc/fsl/fsl_easrc.c
index e4079e154202c..351a165e240d6 100644
--- a/sound/soc/fsl/fsl_easrc.c
+++ b/sound/soc/fsl/fsl_easrc.c
@@ -1353,6 +1353,10 @@ static void fsl_easrc_release_context(struct fsl_asrc_pair *ctx)
 
 	spin_lock_irqsave(&easrc->lock, lock_flags);
 
+	/* Nothing to release if the context is not owned by @ctx */
+	if (easrc->pair[ctx->index] != ctx)
+		return;
+
 	fsl_easrc_release_slot(easrc, ctx->index);
 
 	easrc->channel_avail += ctx->channels;
@@ -1508,6 +1512,12 @@ static int fsl_easrc_hw_params(struct snd_pcm_substream *substream,
 	snd_pcm_format_t format = params_format(params);
 	int ret;
 
+	/* hw_params() may be called again without hw_free() in between */
+	if (ctx_priv->ctx_streams & BIT(substream->stream)) {
+		ctx_priv->ctx_streams &= ~BIT(substream->stream);
+		fsl_easrc_release_context(ctx);
+	}
+
 	ret = fsl_easrc_request_context(channels, ctx);
 	if (ret) {
 		dev_err(dev, "failed to request context\n");
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 253/555] btrfs: remove devid kobject when deleting a missing device
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (251 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 252/555] ASoC: fsl_easrc: fix context ownership on repeated hw_params Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 254/555] btrfs: pass struct btrfs_inode to btrfs_double_mmap_lock() Greg Kroah-Hartman
                   ` (301 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Qu Wenruo, Cheng Yongkang,
	David Sterba, Sasha Levin

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

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

From: Cheng Yongkang <teel4res@gmail.com>

[ Upstream commit 9383a7fdcb27142d97e65fc76f28475018980b35 ]

btrfs_rm_device() removes the sysfs device entry only when
device->bdev_file is non-NULL.  A missing device (created by
add_missing_dev() for an absent disk) has bdev_file == NULL, but
btrfs_sysfs_add_device() still registers its devid kobject under
/sys/fs/btrfs/<uuid>/devinfo/<devid>.

When such a device is deleted, btrfs_free_device() frees the
btrfs_device while the devid kobject remains registered.  The kobject is
embedded in the freed btrfs_device and its show functions use
container_of() to reach it, so reading any devinfo attribute is a
use-after-free:

  BUG: KASAN: slab-use-after-free in sysfs_kf_seq_show+0x157/0x490
  Read of size 8 at addr ffff88801d8172a8 by task poc/9385
  ...
  Freed by task 9385:
   kfree
   btrfs_rm_device+0x11ee/0x17b0
   btrfs_ioctl_rm_dev+0x265/0x400
  Allocated by task 9390:
   btrfs_alloc_device+0x7e/0x400
   device_list_add
   btrfs_scan_one_device
   btrfs_control_ioctl

The freed object is kmalloc-1k and the faulting access is 680 bytes
inside it (offsetof(struct btrfs_device, devid_kobj) = 640 plus
offsetof(struct kobject, ktype) = 40), confirming the embedded
devid_kobj.

btrfs_sysfs_remove_device() already skips the block-device link when
device->bdev is NULL and only touches the devid kobject when it is
initialized.  Call it for missing devices too.

Fixes: 668e48af7a94 ("btrfs: sysfs, add devid/dev_state kobject and device attributes")
Reviewed-by: Qu Wenruo <wqu@suse.com>
Assisted-by: LLM
Signed-off-by: Cheng Yongkang <teel4res@gmail.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/btrfs/volumes.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 0587de27a277f..8b210ba3eb642 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2383,11 +2383,11 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info,
 
 	btrfs_assign_next_active_device(device, NULL);
 
-	if (device->bdev_file) {
+	if (device->bdev_file)
 		cur_devices->open_devices--;
-		/* remove sysfs entry */
-		btrfs_sysfs_remove_device(device);
-	}
+
+	/* Remove sysfs entry, including for a missing device. */
+	btrfs_sysfs_remove_device(device);
 
 	num_devices = btrfs_super_num_devices(fs_info->super_copy) - 1;
 	btrfs_set_super_num_devices(fs_info->super_copy, num_devices);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 254/555] btrfs: pass struct btrfs_inode to btrfs_double_mmap_lock()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (252 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 253/555] btrfs: remove devid kobject when deleting a missing device Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 255/555] btrfs: pass struct btrfs_inode to btrfs_double_mmap_unlock() Greg Kroah-Hartman
                   ` (300 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Johannes Thumshirn, David Sterba,
	Sasha Levin

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

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

From: David Sterba <dsterba@suse.com>

[ Upstream commit 0061ba125b25d29cd62d55c3499087b7a019a849 ]

Pass a struct btrfs_inode to btrfs_double_mmap_lock() as it's an
internal interface, allowing to remove some use of BTRFS_I.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Stable-dep-of: ad4bb983915d ("btrfs: fix race between concurrent sync direct IO writes")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/btrfs/reflink.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index 74aa18155edd8..233a5df967a40 100644
--- a/fs/btrfs/reflink.c
+++ b/fs/btrfs/reflink.c
@@ -672,12 +672,12 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
 	return ret;
 }
 
-static void btrfs_double_mmap_lock(struct inode *inode1, struct inode *inode2)
+static void btrfs_double_mmap_lock(struct btrfs_inode *inode1, struct btrfs_inode *inode2)
 {
 	if (inode1 < inode2)
 		swap(inode1, inode2);
-	down_write(&BTRFS_I(inode1)->i_mmap_lock);
-	down_write_nested(&BTRFS_I(inode2)->i_mmap_lock, SINGLE_DEPTH_NESTING);
+	down_write(&inode1->i_mmap_lock);
+	down_write_nested(&inode2->i_mmap_lock, SINGLE_DEPTH_NESTING);
 }
 
 static void btrfs_double_mmap_unlock(struct inode *inode1, struct inode *inode2)
@@ -930,7 +930,7 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
 		btrfs_inode_lock(BTRFS_I(src_inode), BTRFS_ILOCK_MMAP);
 	} else {
 		lock_two_nondirectories(src_inode, dst_inode);
-		btrfs_double_mmap_lock(src_inode, dst_inode);
+		btrfs_double_mmap_lock(BTRFS_I(src_inode), BTRFS_I(dst_inode));
 	}
 
 	ret = btrfs_remap_file_range_prep(src_file, off, dst_file, destoff,
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 255/555] btrfs: pass struct btrfs_inode to btrfs_double_mmap_unlock()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (253 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 254/555] btrfs: pass struct btrfs_inode to btrfs_double_mmap_lock() Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:04 ` [PATCH 6.12 256/555] btrfs: use struct btrfs_inode inside btrfs_remap_file_range() Greg Kroah-Hartman
                   ` (299 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Johannes Thumshirn, David Sterba,
	Sasha Levin

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

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

From: David Sterba <dsterba@suse.com>

[ Upstream commit 651cef46116f33c0897dc814b4c0ff5df43470c7 ]

Pass a struct btrfs_inode to btrfs_double_mmap_unlock() as it's an
internal interface, allowing to remove some use of BTRFS_I.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Stable-dep-of: ad4bb983915d ("btrfs: fix race between concurrent sync direct IO writes")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/btrfs/reflink.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index 233a5df967a40..9033fa5e1dd00 100644
--- a/fs/btrfs/reflink.c
+++ b/fs/btrfs/reflink.c
@@ -680,10 +680,10 @@ static void btrfs_double_mmap_lock(struct btrfs_inode *inode1, struct btrfs_inod
 	down_write_nested(&inode2->i_mmap_lock, SINGLE_DEPTH_NESTING);
 }
 
-static void btrfs_double_mmap_unlock(struct inode *inode1, struct inode *inode2)
+static void btrfs_double_mmap_unlock(struct btrfs_inode *inode1, struct btrfs_inode *inode2)
 {
-	up_write(&BTRFS_I(inode1)->i_mmap_lock);
-	up_write(&BTRFS_I(inode2)->i_mmap_lock);
+	up_write(&inode1->i_mmap_lock);
+	up_write(&inode2->i_mmap_lock);
 }
 
 static int btrfs_extent_same_range(struct inode *src, u64 loff, u64 len,
@@ -947,7 +947,7 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
 	if (same_inode) {
 		btrfs_inode_unlock(BTRFS_I(src_inode), BTRFS_ILOCK_MMAP);
 	} else {
-		btrfs_double_mmap_unlock(src_inode, dst_inode);
+		btrfs_double_mmap_unlock(BTRFS_I(src_inode), BTRFS_I(dst_inode));
 		unlock_two_nondirectories(src_inode, dst_inode);
 	}
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 256/555] btrfs: use struct btrfs_inode inside btrfs_remap_file_range()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (254 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 255/555] btrfs: pass struct btrfs_inode to btrfs_double_mmap_unlock() Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 257/555] btrfs: use struct btrfs_inode inside btrfs_remap_file_range_prep() Greg Kroah-Hartman
                   ` (298 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Johannes Thumshirn, David Sterba,
	Sasha Levin

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

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

From: David Sterba <dsterba@suse.com>

[ Upstream commit 8b044e17e55aef2d64739a99f6f5d912a68f7f73 ]

Use a struct btrfs_inode to btrfs_remap_file_range() as it's an internal
helper, allowing to remove some use of BTRFS_I.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Stable-dep-of: ad4bb983915d ("btrfs: fix race between concurrent sync direct IO writes")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/btrfs/reflink.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index 9033fa5e1dd00..d0ab45ba9e51d 100644
--- a/fs/btrfs/reflink.c
+++ b/fs/btrfs/reflink.c
@@ -918,8 +918,8 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
 		struct file *dst_file, loff_t destoff, loff_t len,
 		unsigned int remap_flags)
 {
-	struct inode *src_inode = file_inode(src_file);
-	struct inode *dst_inode = file_inode(dst_file);
+	struct btrfs_inode *src_inode = BTRFS_I(file_inode(src_file));
+	struct btrfs_inode *dst_inode = BTRFS_I(file_inode(dst_file));
 	bool same_inode = dst_inode == src_inode;
 	int ret;
 
@@ -927,10 +927,10 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
 		return -EINVAL;
 
 	if (same_inode) {
-		btrfs_inode_lock(BTRFS_I(src_inode), BTRFS_ILOCK_MMAP);
+		btrfs_inode_lock(src_inode, BTRFS_ILOCK_MMAP);
 	} else {
-		lock_two_nondirectories(src_inode, dst_inode);
-		btrfs_double_mmap_lock(BTRFS_I(src_inode), BTRFS_I(dst_inode));
+		lock_two_nondirectories(&src_inode->vfs_inode, &dst_inode->vfs_inode);
+		btrfs_double_mmap_lock(src_inode, dst_inode);
 	}
 
 	ret = btrfs_remap_file_range_prep(src_file, off, dst_file, destoff,
@@ -939,16 +939,18 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
 		goto out_unlock;
 
 	if (remap_flags & REMAP_FILE_DEDUP)
-		ret = btrfs_extent_same(src_inode, off, len, dst_inode, destoff);
+		ret = btrfs_extent_same(&src_inode->vfs_inode, off, len,
+					&dst_inode->vfs_inode, destoff);
 	else
 		ret = btrfs_clone_files(dst_file, src_file, off, len, destoff);
 
 out_unlock:
 	if (same_inode) {
-		btrfs_inode_unlock(BTRFS_I(src_inode), BTRFS_ILOCK_MMAP);
+		btrfs_inode_unlock(src_inode, BTRFS_ILOCK_MMAP);
 	} else {
-		btrfs_double_mmap_unlock(BTRFS_I(src_inode), BTRFS_I(dst_inode));
-		unlock_two_nondirectories(src_inode, dst_inode);
+		btrfs_double_mmap_unlock(src_inode, dst_inode);
+		unlock_two_nondirectories(&src_inode->vfs_inode,
+					  &dst_inode->vfs_inode);
 	}
 
 	/*
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 257/555] btrfs: use struct btrfs_inode inside btrfs_remap_file_range_prep()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (255 preceding siblings ...)
  2026-12-04 10:04 ` [PATCH 6.12 256/555] btrfs: use struct btrfs_inode inside btrfs_remap_file_range() Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 258/555] btrfs: pre-flush reflink source before taking inode locks Greg Kroah-Hartman
                   ` (297 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Johannes Thumshirn, David Sterba,
	Sasha Levin

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

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

From: David Sterba <dsterba@suse.com>

[ Upstream commit 2d4323ced58f949626a93c179f26dcee418ceb53 ]

Use a struct btrfs_inode in btrfs_remap_file_range_prep() as it's an
internal helper, allowing to remove some use of BTRFS_I.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Stable-dep-of: ad4bb983915d ("btrfs: fix race between concurrent sync direct IO writes")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/btrfs/reflink.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index d0ab45ba9e51d..acd6280ac29bb 100644
--- a/fs/btrfs/reflink.c
+++ b/fs/btrfs/reflink.c
@@ -830,24 +830,24 @@ static int btrfs_remap_file_range_prep(struct file *file_in, loff_t pos_in,
 				       struct file *file_out, loff_t pos_out,
 				       loff_t *len, unsigned int remap_flags)
 {
-	struct inode *inode_in = file_inode(file_in);
-	struct inode *inode_out = file_inode(file_out);
-	u64 bs = BTRFS_I(inode_out)->root->fs_info->sectorsize;
+	struct btrfs_inode *inode_in = BTRFS_I(file_inode(file_in));
+	struct btrfs_inode *inode_out = BTRFS_I(file_inode(file_out));
+	u64 bs = inode_out->root->fs_info->sectorsize;
 	u64 wb_len;
 	int ret;
 
 	if (!(remap_flags & REMAP_FILE_DEDUP)) {
-		struct btrfs_root *root_out = BTRFS_I(inode_out)->root;
+		struct btrfs_root *root_out = inode_out->root;
 
 		if (btrfs_root_readonly(root_out))
 			return -EROFS;
 
-		ASSERT(inode_in->i_sb == inode_out->i_sb);
+		ASSERT(inode_in->vfs_inode.i_sb == inode_out->vfs_inode.i_sb);
 	}
 
 	/* Don't make the dst file partly checksummed */
-	if ((BTRFS_I(inode_in)->flags & BTRFS_INODE_NODATASUM) !=
-	    (BTRFS_I(inode_out)->flags & BTRFS_INODE_NODATASUM)) {
+	if ((inode_in->flags & BTRFS_INODE_NODATASUM) !=
+	    (inode_out->flags & BTRFS_INODE_NODATASUM)) {
 		return -EINVAL;
 	}
 
@@ -866,7 +866,7 @@ static int btrfs_remap_file_range_prep(struct file *file_in, loff_t pos_in,
 	 *    to complete so that new file extent items are in the fs tree.
 	 */
 	if (*len == 0 && !(remap_flags & REMAP_FILE_DEDUP))
-		wb_len = ALIGN(inode_in->i_size, bs) - ALIGN_DOWN(pos_in, bs);
+		wb_len = ALIGN(inode_in->vfs_inode.i_size, bs) - ALIGN_DOWN(pos_in, bs);
 	else
 		wb_len = ALIGN(*len, bs);
 
@@ -887,16 +887,14 @@ static int btrfs_remap_file_range_prep(struct file *file_in, loff_t pos_in,
 	 * Also we don't need to check ASYNC_EXTENT, as async extent will be
 	 * CoWed anyway, not affecting nocow part.
 	 */
-	ret = filemap_flush(inode_in->i_mapping);
+	ret = filemap_flush(inode_in->vfs_inode.i_mapping);
 	if (ret < 0)
 		return ret;
 
-	ret = btrfs_wait_ordered_range(BTRFS_I(inode_in), ALIGN_DOWN(pos_in, bs),
-				       wb_len);
+	ret = btrfs_wait_ordered_range(inode_in, ALIGN_DOWN(pos_in, bs), wb_len);
 	if (ret < 0)
 		return ret;
-	ret = btrfs_wait_ordered_range(BTRFS_I(inode_out), ALIGN_DOWN(pos_out, bs),
-				       wb_len);
+	ret = btrfs_wait_ordered_range(inode_out, ALIGN_DOWN(pos_out, bs), wb_len);
 	if (ret < 0)
 		return ret;
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 258/555] btrfs: pre-flush reflink source before taking inode locks
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (256 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 257/555] btrfs: use struct btrfs_inode inside btrfs_remap_file_range_prep() Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 259/555] btrfs: downgrade the reflink source inode lock for tree walking Greg Kroah-Hartman
                   ` (296 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Filipe Manana, Boris Burkov,
	David Sterba, Sasha Levin

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

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

From: Boris Burkov <boris@bur.io>

[ Upstream commit 220c44b1b90fbff746472cbb3dde778b02afbef9 ]

Consider the following sketch of a shell script:

  dd if=/dev/urandom of=/mnt/src bs=1M count=4096
  cp --reflink=always /mnt/src /mnt/dst &
  sleep 0.1   # let the clone reach its flush
  time dd if=/mnt/src of=/dev/null bs=4K count=1 iflag=direct

The current logic in reflink ensures the existence and stability of both
the src and destination inode by locking them both and then flushing all
dirty pages / ordered_extents under the inode lock. This blocks
concurrent usage by even readers of the inode locks, like direct reads
or seeks for the duration of writeback on the entirety of the two files.

We observe this particular contention frequently in the Meta fleet.

It is also a relatively common pattern to write the src file, then reflink
it while it is still dirty, so that typical path naturally hits this
contention. This workload motivates a relatively simple optimization:
trigger the unavoidable src flushing outside the locked region.

Therefore, do an optimistic btrfs_wait_ordered_range() without the locks
while relying on the calls to btrfs_wait_ordered_range() under the
locks in btrfs_remap_file_range_prep() to ensure correctness. In the
worst case with concurrent writes while unlocked, we can end up doing
the writeback twice, which I think is a reasonable price to pay to avoid
victimizing innocent readers in a common case.

With and without this patch, the above reproducer runs the reflink in
the same ~0.5s on my system. Without the patch, the direct read blocks
for basically the full duration of the reflink while with the patch it
returns in a few milliseconds.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Boris Burkov <boris@bur.io>
Signed-off-by: David Sterba <dsterba@suse.com>
Stable-dep-of: ad4bb983915d ("btrfs: fix race between concurrent sync direct IO writes")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/btrfs/reflink.c | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index acd6280ac29bb..0eb68b7742e29 100644
--- a/fs/btrfs/reflink.c
+++ b/fs/btrfs/reflink.c
@@ -826,6 +826,17 @@ static noinline int btrfs_clone_files(struct file *file, struct file *file_src,
 	return ret;
 }
 
+static u64 calc_remap_wb_len(struct btrfs_inode *src_inode, loff_t off, loff_t len,
+			     unsigned int remap_flags)
+{
+	const u32 bs = src_inode->root->fs_info->sectorsize;
+	const loff_t isize = i_size_read(&src_inode->vfs_inode);
+
+	if (len == 0 && !(remap_flags & REMAP_FILE_DEDUP))
+		return ALIGN(isize, bs) - ALIGN_DOWN(off, bs);
+	return ALIGN(len, bs);
+}
+
 static int btrfs_remap_file_range_prep(struct file *file_in, loff_t pos_in,
 				       struct file *file_out, loff_t pos_out,
 				       loff_t *len, unsigned int remap_flags)
@@ -865,10 +876,7 @@ static int btrfs_remap_file_range_prep(struct file *file_in, loff_t pos_in,
 	 *    not for the ordered extents to complete. We need to wait for them
 	 *    to complete so that new file extent items are in the fs tree.
 	 */
-	if (*len == 0 && !(remap_flags & REMAP_FILE_DEDUP))
-		wb_len = ALIGN(inode_in->vfs_inode.i_size, bs) - ALIGN_DOWN(pos_in, bs);
-	else
-		wb_len = ALIGN(*len, bs);
+	wb_len = calc_remap_wb_len(inode_in, pos_in, *len, remap_flags);
 
 	/*
 	 * Workaround to make sure NOCOW buffered write reach disk as NOCOW.
@@ -919,11 +927,23 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
 	struct btrfs_inode *src_inode = BTRFS_I(file_inode(src_file));
 	struct btrfs_inode *dst_inode = BTRFS_I(file_inode(dst_file));
 	bool same_inode = dst_inode == src_inode;
+	u64 wb_start, wb_len;
 	int ret;
 
 	if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY))
 		return -EINVAL;
 
+	/*
+	 * Optimistically write out the src inode before taking locks.
+	 * Consistency is properly ensured by the btrfs_wait_ordered_range()
+	 * inside btrfs_remap_file_range_prep().
+	 */
+	wb_start = ALIGN_DOWN(off, src_inode->root->fs_info->sectorsize);
+	wb_len = calc_remap_wb_len(src_inode, off, len, remap_flags);
+	ret = btrfs_wait_ordered_range(src_inode, wb_start, wb_len);
+	if (ret < 0)
+		return ret;
+
 	if (same_inode) {
 		btrfs_inode_lock(src_inode, BTRFS_ILOCK_MMAP);
 	} else {
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 259/555] btrfs: downgrade the reflink source inode lock for tree walking
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (257 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 258/555] btrfs: pre-flush reflink source before taking inode locks Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 260/555] btrfs: fix race between concurrent sync direct IO writes Greg Kroah-Hartman
                   ` (295 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Filipe Manana, Boris Burkov,
	David Sterba, Sasha Levin

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

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

From: Boris Burkov <boris@bur.io>

[ Upstream commit cf02c310d018c7e5363b80dfd68ffdf159f3c914 ]

When doing a reflink, we are not writing to the src inode or modifying
it in any way, so it is counter-intuitive to have to lock it
exclusively. This has the cost of blocking other shared lock users of
the src file for the duration of any new writeback since the optimistic
pre-flush and all the actual reflinking. So we would like to downgrade
the lock to shared as much as possible.

There are two important gotchas to do with direct io that must be
addressed to make this idea work.

The first gotcha is that dio writes that come in under EOF try to take
inode->i_rwsem shared, which would result in messed up views of the
extents in the reflinked file. Therefore, add "being used as a reflink
src" as another inode flag exception for the dio write shared tests that
already exist to check for other dangerous conditions. In order to
ensure that this flag is visible to the dio writer, reflink must first
take i_rwsem exclusive, then set the flag, then downgrade to shared.

The second is that dio reads increment inode->i_dio_count which blocks
inode_dio_wait() in __generic_remap_file_range_prep(). Therefore, we
must remain exclusive to dio reads through finishing the prep or risk
starving the clone on a stream of dio readers. There is still O(extents)
work in btrfs_clone() which can be done without holding the lock
exclusive, so we should downgrade to shared and admit dio readers (and
other shared lock users like lseek) after we are finished with
inode_dio_wait().

By running concurrent clones and lseeks or dio reads on a src file with
32k extents on a vm, I can demonstrate 100ms+ stalls on the readers
without this patch and they go away entirely with the patch.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Boris Burkov <boris@bur.io>
Signed-off-by: David Sterba <dsterba@suse.com>
Stable-dep-of: ad4bb983915d ("btrfs: fix race between concurrent sync direct IO writes")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/btrfs/btrfs_inode.h |  6 ++++++
 fs/btrfs/direct-io.c   |  7 +++++++
 fs/btrfs/reflink.c     | 17 +++++++++++++++--
 3 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 877f9fc54d97a..33a0fe1456d69 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -98,6 +98,12 @@ enum {
 	 * range).
 	 */
 	BTRFS_INODE_COW_WRITE_ERROR,
+	/*
+	 * Set by reflink while it holds the source's VFS inode lock shared.
+	 * Direct IO writes also take that lock shared; one that finds this bit
+	 * set after acquiring it must retry with the exclusive lock.
+	 */
+	BTRFS_INODE_REFLINK_SRC,
 	/*
 	 * Indicate this is a directory that points to a subvolume for which
 	 * there is no root reference item. That's a case like the following:
diff --git a/fs/btrfs/direct-io.c b/fs/btrfs/direct-io.c
index 3d6fabd67960c..68d553d477d5b 100644
--- a/fs/btrfs/direct-io.c
+++ b/fs/btrfs/direct-io.c
@@ -898,6 +898,13 @@ ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
 		goto relock;
 	}
 
+	if ((ilock_flags & BTRFS_ILOCK_SHARED) &&
+	    test_bit(BTRFS_INODE_REFLINK_SRC, &BTRFS_I(inode)->runtime_flags)) {
+		btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
+		ilock_flags &= ~BTRFS_ILOCK_SHARED;
+		goto relock;
+	}
+
 	ret = generic_write_checks(iocb, from);
 	if (ret <= 0) {
 		btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index 0eb68b7742e29..d189dcb61bc3f 100644
--- a/fs/btrfs/reflink.c
+++ b/fs/btrfs/reflink.c
@@ -928,6 +928,7 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
 	struct btrfs_inode *dst_inode = BTRFS_I(file_inode(dst_file));
 	bool same_inode = dst_inode == src_inode;
 	u64 wb_start, wb_len;
+	bool src_downgraded = false;
 	int ret;
 
 	if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY))
@@ -956,6 +957,12 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
 	if (ret < 0 || len == 0)
 		goto out_unlock;
 
+	if (!same_inode) {
+		set_bit(BTRFS_INODE_REFLINK_SRC, &src_inode->runtime_flags);
+		downgrade_write(&src_inode->vfs_inode.i_rwsem);
+		src_downgraded = true;
+	}
+
 	if (remap_flags & REMAP_FILE_DEDUP)
 		ret = btrfs_extent_same(&src_inode->vfs_inode, off, len,
 					&dst_inode->vfs_inode, destoff);
@@ -967,8 +974,14 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
 		btrfs_inode_unlock(src_inode, BTRFS_ILOCK_MMAP);
 	} else {
 		btrfs_double_mmap_unlock(src_inode, dst_inode);
-		unlock_two_nondirectories(&src_inode->vfs_inode,
-					  &dst_inode->vfs_inode);
+		if (src_downgraded) {
+			clear_bit(BTRFS_INODE_REFLINK_SRC, &src_inode->runtime_flags);
+			inode_unlock_shared(&src_inode->vfs_inode);
+			inode_unlock(&dst_inode->vfs_inode);
+		} else {
+			unlock_two_nondirectories(&src_inode->vfs_inode,
+						  &dst_inode->vfs_inode);
+		}
 	}
 
 	/*
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 260/555] btrfs: fix race between concurrent sync direct IO writes
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (258 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 259/555] btrfs: downgrade the reflink source inode lock for tree walking Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 261/555] ASoC: SOF: control: reject out-of-range enum values Greg Kroah-Hartman
                   ` (294 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Qu Wenruo, Filipe Manana,
	David Sterba, Sasha Levin

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

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

From: Filipe Manana <fdmanana@suse.com>

[ Upstream commit ad4bb983915d8588dc9dd3aeb60cf58aff574e3b ]

If we have a direct IO write within i_size, we lock the inode's VFS lock
in shared mode, which allows for concurrent direct IO writes within
different ranges of the file, which is an important optimization for many
applications such as databases.

However if we have a sync direct IO write within i_size, it locks the
inode in shared mode and then enters fsync through the call to the
iomap_dio_complete() function from iomap using the shared lock. This
means that if we have another concurrent direct IO write that locks the
inode in shared mode and the fsync is in fast mode (the inode flag
BTRFS_INODE_NEEDS_FULL_SYNC is not set), the fsync does not wait for
the ordered extent created by the concurrent direct IO write to complete
before logging its extent map. The fsync code relies on direct IO writes
to create ordered extents and wait for their IO to finish while holding
the inode's lock, while the fsync should hold the inode lock in exclusive
mode. This means that this race can end up persisting a log tree with
file extent items that point to extents that were not yet written when
the log is synced.

Fix this by always taking the inode lock in exclusive mode if we have a
sync write.

This issue was identified by Sashiko in the link below, which identifies
two different races between direct IO writes and fsync. The race fixed
here is the second case identified by Sashiko in the link below. The first
race is already being fixed in a separate patch from Josef.

Link: https://sashiko.dev/#/bug/linux-ee047626-2fa7-46d5-b543-861136993fc7
Fixes: 939b656bc8ab ("btrfs: fix corruption after buffer fault in during direct IO append write")
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/btrfs/direct-io.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/direct-io.c b/fs/btrfs/direct-io.c
index 68d553d477d5b..29b9a95423e2d 100644
--- a/fs/btrfs/direct-io.c
+++ b/fs/btrfs/direct-io.c
@@ -871,9 +871,13 @@ ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
 	 * If the write DIO is within EOF, use a shared lock and also only if
 	 * security bits will likely not be dropped by file_remove_privs() called
 	 * from btrfs_write_check(). Either will need to be rechecked after the
-	 * lock was acquired.
+	 * lock was acquired. Also if this is a sync write we will need to fsync
+	 * and therefore we must lock in exclusive mode, otherwise we would race
+	 * with other concurrent DIO writes and the fsync would not wait for
+	 * their ordered extent to finish IO before logging the new extent maps.
 	 */
-	if (iocb->ki_pos + iov_iter_count(from) <= i_size_read(inode) && IS_NOSEC(inode))
+	if (iocb->ki_pos + iov_iter_count(from) <= i_size_read(inode) &&
+	    IS_NOSEC(inode) && !iocb_is_dsync(iocb))
 		ilock_flags |= BTRFS_ILOCK_SHARED;
 
 	/*
@@ -905,6 +909,13 @@ ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
 		goto relock;
 	}
 
+	/* Sync writes must use exclusive locking, see the comment above. */
+	if ((ilock_flags & BTRFS_ILOCK_SHARED) && iocb_is_dsync(iocb)) {
+		btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
+		ilock_flags &= ~BTRFS_ILOCK_SHARED;
+		goto relock;
+	}
+
 	ret = generic_write_checks(iocb, from);
 	if (ret <= 0) {
 		btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 261/555] ASoC: SOF: control: reject out-of-range enum values
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (259 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 260/555] btrfs: fix race between concurrent sync direct IO writes Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 262/555] btrfs: fiemap: deal with inline extent in fiemap_find_last_extent_offset() Greg Kroah-Hartman
                   ` (293 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Arnav Kapoor, Mark Brown,
	Sasha Levin

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

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

From: Arnav Kapoor <kapoorarnav43@gmail.com>

[ Upstream commit 3092b9e481fedc413bf7acda9edc04b0bd8cb28a ]

snd_sof_enum_put() passes the item indexes from user space to the IPC
enum_put() op unchecked, and the IPC3 and IPC4 ops store them as they
are and send them to the DSP. With the IPC4 sof-hda-generic-2ch.tplg on
a Tiger Lake laptop, "Dmic0 Capture TDFB angle set enum" has 13 items
but accepts 13 and 0xffffffff, and reads them back. The ALSA mixer-test
selftest reports this as a write_invalid failure.

Reject indexes past the last item, as snd_soc_put_enum_double() does.

Fixes: c3078f539704 ("ASoC: SOF: Add Sound Open Firmware KControl support")
Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
Link: https://patch.msgid.link/20261118103129.113970-1-kapoorarnav43@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 sound/soc/sof/control.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sound/soc/sof/control.c b/sound/soc/sof/control.c
index 463d418e72001..0800e9ffd7256 100644
--- a/sound/soc/sof/control.c
+++ b/sound/soc/sof/control.c
@@ -120,6 +120,11 @@ int snd_sof_enum_put(struct snd_kcontrol *kcontrol,
 	struct snd_soc_component *scomp = scontrol->scomp;
 	struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
 	const struct sof_ipc_tplg_ops *tplg_ops = sof_ipc_get_ops(sdev, tplg);
+	unsigned int i;
+
+	for (i = 0; i < scontrol->num_channels; i++)
+		if (ucontrol->value.enumerated.item[i] >= se->items)
+			return -EINVAL;
 
 	if (tplg_ops && tplg_ops->control && tplg_ops->control->enum_put)
 		return tplg_ops->control->enum_put(scontrol, ucontrol);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 262/555] btrfs: fiemap: deal with inline extent in fiemap_find_last_extent_offset()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (260 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 261/555] ASoC: SOF: control: reject out-of-range enum values Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 263/555] btrfs: abort transaction on failure to update inode after hole punching Greg Kroah-Hartman
                   ` (292 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Qu Wenruo, Filipe Manana,
	David Sterba, Sasha Levin

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

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

From: Filipe Manana <fdmanana@suse.com>

[ Upstream commit fd573263740371f76cad610cbcc70629b27f6c0c ]

In the while loop that finds the first file extent item, counting from the
end of the file, that is not a hole, we are accessing the disk_bytenr
field of each file extent item, which is wrong in case we have an item
that represents an inline extent. In that case the inline data starts at
the disk_bytenr offset and therefore we are reading user data or in case
the inline data is less than 8 bytes, we are accessing another region of
the leaf or even beyond the leaf boundaries in case it's the last item.

This should be a very rare case, as it implies having an inline extent
followed by a hole file extent item (the no-holes feature is not used).

Fixes: ac3c0d36a2a2 ("btrfs: make fiemap more efficient and accurate reporting extent sharedness")
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/btrfs/fiemap.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/btrfs/fiemap.c b/fs/btrfs/fiemap.c
index cf93318d14080..e430d524365fc 100644
--- a/fs/btrfs/fiemap.c
+++ b/fs/btrfs/fiemap.c
@@ -621,6 +621,8 @@ static int fiemap_find_last_extent_offset(struct btrfs_inode *inode,
 		leaf = path->nodes[0];
 		ei = btrfs_item_ptr(leaf, path->slots[0],
 				    struct btrfs_file_extent_item);
+		if (btrfs_file_extent_type(leaf, ei) == BTRFS_FILE_EXTENT_INLINE)
+			break;
 		disk_bytenr = btrfs_file_extent_disk_bytenr(leaf, ei);
 	}
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 263/555] btrfs: abort transaction on failure to update inode after hole punching
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (261 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 262/555] btrfs: fiemap: deal with inline extent in fiemap_find_last_extent_offset() Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 264/555] btrfs: unfold transaction abort at __btrfs_update_delayed_inode() Greg Kroah-Hartman
                   ` (291 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Qu Wenruo, Filipe Manana,
	David Sterba, Sasha Levin

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

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

From: Filipe Manana <fdmanana@suse.com>

[ Upstream commit 6cd72166183bfc290fd853470232020c4b807aa2 ]

If we fail to update the inode we simply release the transaction and don't
abort the transaction. This means the transaction can get committed and we
will not persist important updates to the inode item such as nbytes (which
gets reduced after punching holes) and the timestamps. Fix this by adding
the missing abort.

Link: https://sashiko.dev/#/bug/linux-d8b4cb7a-8dfe-454f-9b19-a67af28b81bd
Fixes: 2aaa66558172 ("Btrfs: add hole punching")
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/btrfs/file.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index c885c9a221094..87b8e4a2f9ac9 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2768,7 +2768,10 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len)
 	inode_inc_iversion(inode);
 	inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
 	ret = btrfs_update_inode(trans, BTRFS_I(inode));
-	updated_inode = true;
+	if (ret)
+		btrfs_abort_transaction(trans, ret);
+	else
+		updated_inode = true;
 	btrfs_end_transaction(trans);
 	btrfs_btree_balance_dirty(fs_info);
 out:
@@ -2794,6 +2797,8 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len)
 			int ret2;
 
 			ret = btrfs_update_inode(trans, BTRFS_I(inode));
+			if (ret)
+				btrfs_abort_transaction(trans, ret);
 			ret2 = btrfs_end_transaction(trans);
 			if (!ret)
 				ret = ret2;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 264/555] btrfs: unfold transaction abort at __btrfs_update_delayed_inode()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (262 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 263/555] btrfs: abort transaction on failure to update inode after hole punching Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 265/555] btrfs: fix delayed inode count leak after failure to delete inode ref Greg Kroah-Hartman
                   ` (290 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Daniel Vacek, Filipe Manana,
	David Sterba, Sasha Levin

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

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

From: Filipe Manana <fdmanana@suse.com>

[ Upstream commit 35bb03e57aa7d1ed8203b802d306089d64664d52 ]

We have a common error path where we abort the transaction, but like this
in case we get a transaction abort stack trace we don't know exactly which
previous function call failed. Instead abort the transaction after any
function call that returns an error, so that we can easily identify which
function failed.

Reviewed-by: Daniel Vacek <neelx@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Stable-dep-of: 3100f46985fd ("btrfs: fix delayed inode count leak after failure to delete inode ref")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/btrfs/delayed-inode.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index 508bdbae29a0a..7fc46c69583de 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -1030,8 +1030,16 @@ static int __btrfs_update_delayed_inode(struct btrfs_trans_handle *trans,
 	ret = btrfs_lookup_inode(trans, root, path, &key, mod);
 	if (ret > 0)
 		ret = -ENOENT;
-	if (ret < 0)
+	if (ret < 0) {
+		/*
+		 * If we fail to update the delayed inode we need to abort the
+		 * transaction, because we could leave the inode with the
+		 * improper counts behind.
+		 */
+		if (ret != -ENOENT)
+			btrfs_abort_transaction(trans, ret);
 		goto out;
+	}
 
 	leaf = path->nodes[0];
 	inode_item = btrfs_item_ptr(leaf, path->slots[0],
@@ -1057,8 +1065,10 @@ static int __btrfs_update_delayed_inode(struct btrfs_trans_handle *trans,
 
 		btrfs_release_path(path);
 		ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
-		if (ret < 0)
+		if (ret < 0) {
+			btrfs_abort_transaction(trans, ret);
 			goto err_out;
+		}
 		ASSERT(ret > 0);
 		ASSERT(path->slots[0] > 0);
 		ret = 0;
@@ -1080,21 +1090,14 @@ static int __btrfs_update_delayed_inode(struct btrfs_trans_handle *trans,
 	 * in the same item doesn't exist.
 	 */
 	ret = btrfs_del_item(trans, root, path);
+	if (ret < 0)
+		btrfs_abort_transaction(trans, ret);
 out:
 	btrfs_release_delayed_iref(node);
 	btrfs_release_path(path);
 err_out:
 	btrfs_delayed_inode_release_metadata(fs_info, node, (ret < 0));
 	btrfs_release_delayed_inode(node);
-
-	/*
-	 * If we fail to update the delayed inode we need to abort the
-	 * transaction, because we could leave the inode with the improper
-	 * counts behind.
-	 */
-	if (ret && ret != -ENOENT)
-		btrfs_abort_transaction(trans, ret);
-
 	return ret;
 }
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 265/555] btrfs: fix delayed inode count leak after failure to delete inode ref
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (263 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 264/555] btrfs: unfold transaction abort at __btrfs_update_delayed_inode() Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 266/555] jbd2: set JBD2_LOADED under j_state_lock Greg Kroah-Hartman
                   ` (289 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Qu Wenruo, Filipe Manana,
	David Sterba, Sasha Levin

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

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

From: Filipe Manana <fdmanana@suse.com>

[ Upstream commit 3100f46985fd14148e79a0e79912180934ef7231 ]

When updating a delayed inode, if we have an inode ref to delete (the flag
BTRFS_DELAYED_NODE_DEL_IREF is set) and we fail the deletion of the inode
ref item (if it's in another leaf), we abort the transaction and then
never release the delayed count for the inode ref deletion (by calling
btrfs_release_delayed_iref()), resulting in a permanent leak of the
delayed inode.

Fix this by jumping to the 'out' label instead and removing the now no
longer necessary 'err_out' label.

Fixes: 67de11769bd5 ("Btrfs: introduce the delayed inode ref deletion for the single link inode")
Link: https://sashiko.dev/#/bug/linux-3520c6eb-7928-477d-b369-9caff2b98d10
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/btrfs/delayed-inode.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index 7fc46c69583de..f62e64c9d5776 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -1067,7 +1067,7 @@ static int __btrfs_update_delayed_inode(struct btrfs_trans_handle *trans,
 		ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
 		if (ret < 0) {
 			btrfs_abort_transaction(trans, ret);
-			goto err_out;
+			goto out;
 		}
 		ASSERT(ret > 0);
 		ASSERT(path->slots[0] > 0);
@@ -1095,7 +1095,6 @@ static int __btrfs_update_delayed_inode(struct btrfs_trans_handle *trans,
 out:
 	btrfs_release_delayed_iref(node);
 	btrfs_release_path(path);
-err_out:
 	btrfs_delayed_inode_release_metadata(fs_info, node, (ret < 0));
 	btrfs_release_delayed_inode(node);
 	return ret;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 266/555] jbd2: set JBD2_LOADED under j_state_lock
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (264 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 265/555] btrfs: fix delayed inode count leak after failure to delete inode ref Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 267/555] bpf: Let the bpf_fastcall boundary cover the longest pattern Greg Kroah-Hartman
                   ` (288 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Christian Göttsche, Jan Kara,
	Theodore Tso, Sasha Levin

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

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

From: Christian Göttsche <cgzones@googlemail.com>

[ Upstream commit 40e53dad45a92e932156de23a69c991f3e2512c9 ]

j_flags is protected by j_state_lock, with only quick racy checks done
without it.  jbd2_journal_load() however sets JBD2_LOADED with a plain
read-modify-write after journal_reset() has already started kjournald2,
which tests and may update j_flags under the lock.  KCSAN reports this
while mounting the root file system:

  BUG: KCSAN: data-race in jbd2_journal_load / kjournald2

  write to 0xffff9c6b012c6000 of 8 bytes by task 1 on cpu 3:
   jbd2_journal_load+0x279/0x3c0
   ext4_fill_super+0x34dc/0x5740
   get_tree_bdev_flags+0x21d/0x340
   ...
  read to 0xffff9c6b012c6000 of 8 bytes by task 77 on cpu 0:
   kjournald2+0xc8/0x3e0
   kthread+0x1bd/0x200
   ...

  value changed: 0x00000000000000a8 -> 0x00000000000000b8

A concurrent update of another flag, e.g. JBD2_ABORT, could be lost.
Take j_state_lock when setting JBD2_LOADED, like the other writers of
j_flags do.

Fixes: 470decc613ab ("[PATCH] jbd2: initial copy of files from jbd")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20260928202159.2463182-1-cgoettsche@seltendoof.de
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/jbd2/journal.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 67dc1903d53dc..47b39ad7013ea 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -2112,7 +2112,10 @@ int jbd2_journal_load(journal_t *journal)
 		return err;
 	}
 
+	/* kjournald2 is already running, see journal_reset(). */
+	write_lock(&journal->j_state_lock);
 	journal->j_flags |= JBD2_LOADED;
+	write_unlock(&journal->j_state_lock);
 	return 0;
 }
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 267/555] bpf: Let the bpf_fastcall boundary cover the longest pattern
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (265 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 266/555] jbd2: set JBD2_LOADED under j_state_lock Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 268/555] net: sock_reuseport: Check program type on the migration path Greg Kroah-Hartman
                   ` (287 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov,
	Kumar Kartikeya Dwivedi, Sasha Levin

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

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

From: Alexei Starovoitov <ast@kernel.org>

[ Upstream commit 95d366cb57752fb8821488676f607ebd0050fa9e ]

A subprog can have bpf_fastcall patterns of different length:

  *(u64 *)(r10 - 8) = r2
  *(u64 *)(r10 - 16) = r1
  call bpf_get_smp_processor_id
  r1 = *(u64 *)(r10 - 16)
  r2 = *(u64 *)(r10 - 8)
  *(u64 *)(r10 - 16) = r1
  call bpf_get_smp_processor_id
  r1 = *(u64 *)(r10 - 16)
  r0 = *(u64 *)(r10 - 8)

For each pattern, take the offset just above its highest spill slot: 0 for
the first pattern here, -8 for the second. Currently
mark_fastcall_pattern_for_call() keeps the lowest of these offsets in
fastcall_stack_off, the bpf_fastcall boundary of the subprog, which is -8
here. check_fastcall_stack_contract() looks only at accesses below the
boundary, so the last load, at -8, does not switch the rewrite off.
bpf_remove_fastcall_spills_fills() then removes all three pairs of a spill
and a fill, and the load reads a slot that nothing wrote, while the
verifier took it for a slot with the type of R2.

Keep the highest of these offsets instead: every slot of every pattern is
below it. Start from S16_MIN, the value that says that nothing is
rewritten. Stop at 0, as min() did, because a pattern in code that never
runs may end above the frame pointer.

Fixes: 5b5f51bff1b6 ("bpf: no_caller_saved_registers attribute for helper calls")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://patch.msgid.link/adbe7671c30f744adf6682d6431b9d818039cefb.1795462417.git.memxor@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/bpf/verifier.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 7ffd073c08423..91f3caf4fecfd 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -17008,7 +17008,11 @@ static void mark_fastcall_pattern_for_call(struct bpf_verifier_env *env,
 		env->insn_aux_data[insn_idx].fastcall_spills_num = i - 1;
 	else
 		subprog->keep_fastcall_stack = 1;
-	subprog->fastcall_stack_off = min(subprog->fastcall_stack_off, off);
+	/*
+	 * The upper end of the longest pattern: no slot of a pattern is above it. Code that never
+	 * runs may have a pattern that ends above the frame pointer.
+	 */
+	subprog->fastcall_stack_off = max(subprog->fastcall_stack_off, min_t(s16, off, 0));
 }
 
 static int mark_fastcall_patterns(struct bpf_verifier_env *env)
@@ -17019,6 +17023,7 @@ static int mark_fastcall_patterns(struct bpf_verifier_env *env)
 	int s, i;
 
 	for (s = 0; s < env->subprog_cnt; ++s, ++subprog) {
+		subprog->fastcall_stack_off = S16_MIN;
 		/* find lowest stack spill offset used in this subprog */
 		lowest_off = 0;
 		for (i = subprog->start; i < (subprog + 1)->start; ++i) {
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 268/555] net: sock_reuseport: Check program type on the migration path
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (266 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 267/555] bpf: Let the bpf_fastcall boundary cover the longest pattern Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 269/555] arm64: dts: st: add PSCI idle state to STM32MP25 CPU domains Greg Kroah-Hartman
                   ` (286 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Shihuang Liu, Alexei Starovoitov,
	Kuniyuki Iwashima, Jakub Kicinski, Sasha Levin

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

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

From: Shihuang Liu <shlomojune6@gmail.com>

[ Upstream commit cbaaeff649b7aa09170cb31db001e5468c2726c0 ]

A BPF_PROG_TYPE_SOCKET_FILTER program can be loaded with
expected_attach_type set to BPF_SK_REUSEPORT_SELECT_OR_MIGRATE and
attached to a SO_REUSEPORT TCP group.  Closing a listener that still
has queued children then runs it with a struct sk_reuseport_kern
context even though it was verified against struct sk_buff, which
KASAN reports as a stack-out-of-bounds in ___bpf_prog_run().
Reaching this without CAP_BPF requires
kernel.unprivileged_bpf_disabled=0; with
CONFIG_BPF_UNPRIV_DEFAULT_OFF=y, the Kconfig default, the sysctl
starts at 2.

reuseport_migrate_sock() decides from prog->expected_attach_type
alone, a field user space sets that does not identify the program
type.  Require BPF_PROG_TYPE_SK_REUSEPORT there and in
reuseport_stop_listen_sock(); socket filters still work as
selectors, so the selection path is unchanged.

Fixes: d5e4ddaeb6ab ("bpf: Support socket migration by eBPF.")
Signed-off-by: Shihuang Liu <shlomojune6@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Link: https://patch.msgid.link/20261118153541.172499-1-shlomojune6@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/core/sock_reuseport.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/net/core/sock_reuseport.c b/net/core/sock_reuseport.c
index eb8d24964e2f6..7174c61e2e59c 100644
--- a/net/core/sock_reuseport.c
+++ b/net/core/sock_reuseport.c
@@ -461,6 +461,18 @@ void reuseport_detach_sock(struct sock *sk)
 }
 EXPORT_SYMBOL(reuseport_detach_sock);
 
+/*
+ * Only a BPF_PROG_TYPE_SK_REUSEPORT program is verified against
+ * struct sk_reuseport_kern, which is the context bpf_run_sk_reuseport()
+ * passes to it.  expected_attach_type is set by user space and does not
+ * identify the program type.
+ */
+static bool reuseport_is_migration_prog(const struct bpf_prog *prog)
+{
+	return prog && prog->type == BPF_PROG_TYPE_SK_REUSEPORT &&
+	       prog->expected_attach_type == BPF_SK_REUSEPORT_SELECT_OR_MIGRATE;
+}
+
 void reuseport_stop_listen_sock(struct sock *sk)
 {
 	if (sk->sk_protocol == IPPROTO_TCP) {
@@ -475,7 +487,7 @@ void reuseport_stop_listen_sock(struct sock *sk)
 						 lockdep_is_held(&reuseport_lock));
 
 		if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_migrate_req) ||
-		    (prog && prog->expected_attach_type == BPF_SK_REUSEPORT_SELECT_OR_MIGRATE)) {
+		    reuseport_is_migration_prog(prog)) {
 			/* Migration capable, move sk from the listening section
 			 * to the closed section.
 			 */
@@ -645,7 +657,7 @@ struct sock *reuseport_migrate_sock(struct sock *sk,
 
 	hash = migrating_sk->sk_hash;
 	prog = rcu_dereference(reuse->prog);
-	if (!prog || prog->expected_attach_type != BPF_SK_REUSEPORT_SELECT_OR_MIGRATE) {
+	if (!reuseport_is_migration_prog(prog)) {
 		if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_migrate_req))
 			goto select_by_hash;
 		goto failure;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 269/555] arm64: dts: st: add PSCI idle state to STM32MP25 CPU domains
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (267 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 268/555] net: sock_reuseport: Check program type on the migration path Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 270/555] arm64: dts: st: add PSCI idle state to STM32MP23 " Greg Kroah-Hartman
                   ` (285 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Patrick Delaunay, Amelie Delaunay,
	Alexandre Torgue, Sasha Levin

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

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

From: Patrick Delaunay <patrick.delaunay@foss.st.com>

[ Upstream commit ab4ce1d0630f677032d7e20d27c80ecfbd9960cb ]

Define a PSCI CPU suspend state and reference it from both STM32MP25
CPU power domains.

In OSI mode, PSCI power domains are initialized as off. The idle-state
allows the CPU power-domain governor to manage them, avoiding probe
stalls for devices that depend on the cluster power domain, including
SDMMC1.

Fixes: 9c8d852dabbd ("arm64: dts: st: add power domain on stm32mp25")
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Tested-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Reviewed-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Link: https://lore.kernel.org/r/20261119185544.v2.1.Ia5e0774883d237f5825b7090962b454294922558@changeid
Signed-off-by: Alexandre Torgue <alexandre.torgue@foss.st.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/arm64/boot/dts/st/stm32mp251.dtsi | 14 ++++++++++++++
 arch/arm64/boot/dts/st/stm32mp253.dtsi |  1 +
 2 files changed, 15 insertions(+)

diff --git a/arch/arm64/boot/dts/st/stm32mp251.dtsi b/arch/arm64/boot/dts/st/stm32mp251.dtsi
index 777652026bb64..eff16095cba3c 100644
--- a/arch/arm64/boot/dts/st/stm32mp251.dtsi
+++ b/arch/arm64/boot/dts/st/stm32mp251.dtsi
@@ -24,6 +24,19 @@ cpu0: cpu@0 {
 			power-domains = <&CPU_PD0>;
 			power-domain-names = "psci";
 		};
+
+		idle-states {
+			entry-method = "psci";
+
+			cpu_sleep: cpu-sleep {
+				compatible = "arm,idle-state";
+				arm,psci-suspend-param = <0x00000002>;
+				local-timer-stop;
+				entry-latency-us = <150>;
+				exit-latency-us = <200>;
+				min-residency-us = <1000>;
+			};
+		};
 	};
 
 	arm-pmu {
@@ -129,6 +142,7 @@ psci {
 
 		CPU_PD0: power-domain-cpu0 {
 			#power-domain-cells = <0>;
+			domain-idle-states = <&cpu_sleep>;
 			power-domains = <&CLUSTER_PD>;
 		};
 
diff --git a/arch/arm64/boot/dts/st/stm32mp253.dtsi b/arch/arm64/boot/dts/st/stm32mp253.dtsi
index eeceb086252bf..96483733d7a86 100644
--- a/arch/arm64/boot/dts/st/stm32mp253.dtsi
+++ b/arch/arm64/boot/dts/st/stm32mp253.dtsi
@@ -26,6 +26,7 @@ arm-pmu {
 	psci {
 		CPU_PD1: power-domain-cpu1 {
 			#power-domain-cells = <0>;
+			domain-idle-states = <&cpu_sleep>;
 			power-domains = <&CLUSTER_PD>;
 		};
 	};
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 270/555] arm64: dts: st: add PSCI idle state to STM32MP23 CPU domains
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (268 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 269/555] arm64: dts: st: add PSCI idle state to STM32MP25 CPU domains Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 271/555] arm64: dts: st: mark STM32MP23 timer as stopping in suspend Greg Kroah-Hartman
                   ` (284 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Patrick Delaunay, Amelie Delaunay,
	Alexandre Torgue, Sasha Levin

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

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

From: Patrick Delaunay <patrick.delaunay@foss.st.com>

[ Upstream commit 0818ec0de18627ff7d2306e5c2843a0358960874 ]

Define a PSCI CPU suspend state and reference it from both STM32MP23
CPU power domains.

In OSI mode, PSCI power domains are initialized as off. The idle-state
allows the CPU power-domain governor to manage them, avoiding probe
stalls for devices that depend on the cluster power domain, including
SDMMC1.

Fixes: e9b03ef21386 ("arm64: dts: st: introduce stm32mp23 SoCs family")
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Link: https://lore.kernel.org/all/20261030102907.1.I0ef2a7ac525ef18fa683368382d93e98cc36ee25@changeid/
Link: https://lore.kernel.org/r/20261119184209.v2.1.If2b6b99285c1e60ca11b6e7fccf7d9b130ca20dd@changeid
Signed-off-by: Alexandre Torgue <alexandre.torgue@foss.st.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/arm64/boot/dts/st/stm32mp231.dtsi | 14 ++++++++++++++
 arch/arm64/boot/dts/st/stm32mp233.dtsi |  1 +
 2 files changed, 15 insertions(+)

diff --git a/arch/arm64/boot/dts/st/stm32mp231.dtsi b/arch/arm64/boot/dts/st/stm32mp231.dtsi
index ae5de0965f566..d56a3514d25e4 100644
--- a/arch/arm64/boot/dts/st/stm32mp231.dtsi
+++ b/arch/arm64/boot/dts/st/stm32mp231.dtsi
@@ -24,6 +24,19 @@ cpu0: cpu@0 {
 			power-domains = <&cpu0_pd>;
 			power-domain-names = "psci";
 		};
+
+		idle-states {
+			entry-method = "psci";
+
+			cpu_sleep: cpu-sleep {
+				compatible = "arm,idle-state";
+				arm,psci-suspend-param = <0x00000002>;
+				local-timer-stop;
+				entry-latency-us = <150>;
+				exit-latency-us = <200>;
+				min-residency-us = <1000>;
+			};
+		};
 	};
 
 	arm-pmu {
@@ -117,6 +130,7 @@ psci {
 
 		cpu0_pd: power-domain-cpu0 {
 			#power-domain-cells = <0>;
+			domain-idle-states = <&cpu_sleep>;
 			power-domains = <&cluster_pd>;
 		};
 
diff --git a/arch/arm64/boot/dts/st/stm32mp233.dtsi b/arch/arm64/boot/dts/st/stm32mp233.dtsi
index 78f4059fca5db..cebefd99906f6 100644
--- a/arch/arm64/boot/dts/st/stm32mp233.dtsi
+++ b/arch/arm64/boot/dts/st/stm32mp233.dtsi
@@ -26,6 +26,7 @@ arm-pmu {
 	psci {
 		cpu1_pd: power-domain-cpu1 {
 			#power-domain-cells = <0>;
+			domain-idle-states = <&cpu_sleep>;
 			power-domains = <&cluster_pd>;
 		};
 	};
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 271/555] arm64: dts: st: mark STM32MP23 timer as stopping in suspend
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (269 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 270/555] arm64: dts: st: add PSCI idle state to STM32MP23 " Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 272/555] ftrace: Fix lost recursion records in ftrace_record_recursion() Greg Kroah-Hartman
                   ` (283 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Patrick Delaunay, Amelie Delaunay,
	Alexandre Torgue, Sasha Levin

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

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

From: Patrick Delaunay <patrick.delaunay@foss.st.com>

[ Upstream commit 9eb9bea92c7ea2a8886eeab01cdfe4365bee0328 ]

The generic ARM timer, based on STGEN, stops ticking in low-power
states such as Stop1. Replace the always-on property with
arm,no-tick-in-suspend in the STM32MP23 timer node, matching the
STM32MP25 configuration.

Fixes: e9b03ef21386 ("arm64: dts: st: introduce stm32mp23 SoCs family")
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Link: https://lore.kernel.org/r/20261030102907.1.I0ef2a7ac525ef18fa683368382d93e98cc36ee25@changeid
Signed-off-by: Alexandre Torgue <alexandre.torgue@foss.st.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/arm64/boot/dts/st/stm32mp231.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/st/stm32mp231.dtsi b/arch/arm64/boot/dts/st/stm32mp231.dtsi
index d56a3514d25e4..0626fb9b9b49c 100644
--- a/arch/arm64/boot/dts/st/stm32mp231.dtsi
+++ b/arch/arm64/boot/dts/st/stm32mp231.dtsi
@@ -151,7 +151,7 @@ timer {
 			     <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_LOW)>,
 			     <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_LOW)>,
 			     <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_LOW)>;
-		always-on;
+		arm,no-tick-in-suspend;
 	};
 
 	soc@0 {
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 272/555] ftrace: Fix lost recursion records in ftrace_record_recursion()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (270 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 271/555] arm64: dts: st: mark STM32MP23 timer as stopping in suspend Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 273/555] workqueue: Skip redundant unbound updates during CPU bringup Greg Kroah-Hartman
                   ` (282 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Andrea Parri, Steven Rostedt,
	Sasha Levin

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

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

From: Andrea Parri <parri.andrea@gmail.com>

[ Upstream commit 7792e21d0a6e2fa819209949e8ba957504bedcd4 ]

cached_function is set to the current ip before the cmpxchg() that
claims a slot in recursed_functions[]. When that cmpxchg() loses a
race for the same slot, the code bumps index and retries via "goto
again", but the retry immediately matches its own cached_function
write and returns without ever reaching the bumped-index cmpxchg().

Concretely, for two writers racing on the same index:

  CPU 0 (ip = A)                    CPU 1 (ip = B)
  --------------                    --------------
                                     cmpxchg(&recursed_functions[index].ip,
                                             0, B);      // succeeds
  cached_function = A;
  cmpxchg(&recursed_functions[index].ip,
          0, A);
    // fails, old == B
  index++;
  goto again;
  if (A == cached_function)         // true: matches A's own store
          return;                   // A is dropped, not retried

Once dropped this way, cached_function stays set to A, so every later
recursion of A also hits the fast path and returns before reaching the
retry, until some unrelated ip overwrites the cache.

Set cached_function only after the cmpxchg() has claimed the slot. The
retry path then leaves the cache untouched and no longer matches its
own store. When the cmpxchg() finds ip already present, the writer
that installed it sets the cache.

The bug was found with the help of an LLM.

Link: https://patch.msgid.link/20261026182553.221141-1-parri.andrea@gmail.com
Fixes: 773c16705058e ("ftrace: Add recording of functions that caused recursion")
Signed-off-by: Andrea Parri <parri.andrea@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/trace/trace_recursion_record.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/kernel/trace/trace_recursion_record.c b/kernel/trace/trace_recursion_record.c
index a520b11afb0dd..800569b647178 100644
--- a/kernel/trace/trace_recursion_record.c
+++ b/kernel/trace/trace_recursion_record.c
@@ -17,8 +17,8 @@ static struct recursed_functions recursed_functions[CONFIG_FTRACE_RECORD_RECURSI
 static atomic_t nr_records;
 
 /*
- * Cache the last found function. Yes, updates to this is racey, but
- * so is memory cache ;-)
+ * Cache the last function found in or added to recursed_functions[].
+ * Updates to this are racy, but this is only a best-effort cache.
  */
 static unsigned long cached_function;
 
@@ -67,24 +67,25 @@ void ftrace_record_recursion(unsigned long ip, unsigned long parent_ip)
 		}
 	}
 
-	cached_function = ip;
-
 	/*
 	 * We only want to add a function if it hasn't been added before.
-	 * Add to the current location before incrementing the count.
-	 * If it fails to add, then increment the index (save in i)
-	 * and try again.
+	 * Claim the current slot before incrementing the count. If the slot
+	 * is occupied by another function, advance to the next slot and retry.
+	 *
+	 * Do not update cached_function until ip is known to be present;
+	 * otherwise the retry would match its own cache update.
 	 */
 	old = cmpxchg(&recursed_functions[index].ip, 0, ip);
 	if (old != 0) {
 		/* Did something else already added this for us? */
 		if (old == ip)
 			return;
-		/* Try the next location (use i for the next index) */
+		/* Try the next location */
 		index++;
 		goto again;
 	}
 
+	cached_function = ip;
 	recursed_functions[index].parent_ip = parent_ip;
 
 	/*
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 273/555] workqueue: Skip redundant unbound updates during CPU bringup
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (271 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 272/555] ftrace: Fix lost recursion records in ftrace_record_recursion() Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 274/555] net: dsa: b53: initialize the jumbo frame size register offset Greg Kroah-Hartman
                   ` (281 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Saurabh Sengar, Tejun Heo,
	Sasha Levin

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

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

From: Saurabh Sengar <ssengar@linux.microsoft.com>

[ Upstream commit edf1066ba69c89c42c3007e4230c7b9cb13405a8 ]

Before workqueue_init_topology(), all CPUs share the SYSTEM pod,
which contains every possible CPU. The effective cpumask and the
per-pod cpumask of an unbound workqueue are therefore identical,
regardless of which CPUs are online.

During this stage, workqueue_online_cpu() walks every possible CPU for
every unbound workqueue each time a secondary CPU comes online. The
pwq mappings cannot change yet, so this repeats redundant work that
scales quadratically with CPU count.

On a 640-vCPU Hyper-V VM, each of the 639 secondary CPU-online
callbacks walks all 640 possible CPUs for each of the 8 unbound
workqueues, giving 3,271,680 unbound_wq_update_pwq() calls that took
about 975 ms in total.

Skip these updates until workqueue_init_topology(). The pwq mappings
already match the effective cpumask, and wq_update_node_max_active()
does nothing before topology initialization. workqueue_init_topology()
will apply the topology-specific mappings and node limits once ready.

Keep worker rebinding and restoration of unbound worker affinity before
the guard. CPU hotplug after topology initialization is unchanged.

On the same VM running a v7.3 kernel, smp_init() took 1054 ms with this
change, compared to 2008 ms without it, a 47.5% reduction.

                                 Before    After    Reduction
  smp_init()                     2008 ms   1054 ms      47.5%

Fixes: 84193c07105c ("workqueue: Generalize unbound CPU pods")
Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/workqueue.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index f6dde83c9466f..9ac39907627e7 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -6714,6 +6714,14 @@ int workqueue_online_cpu(unsigned int cpu)
 		mutex_unlock(&wq_pool_attach_mutex);
 	}
 
+	/*
+	 * Before topology initialization, the SYSTEM pod covers all possible
+	 * CPUs, so CPU onlining does not require updating pwq mappings.
+	 * wq_update_node_max_active() also returns early at this stage.
+	 */
+	if (!wq_topo_initialized)
+		goto out_unlock;
+
 	/* update pod affinity of unbound workqueues */
 	list_for_each_entry(wq, &workqueues, list) {
 		struct workqueue_attrs *attrs = wq->unbound_attrs;
@@ -6731,6 +6739,7 @@ int workqueue_online_cpu(unsigned int cpu)
 		}
 	}
 
+out_unlock:
 	mutex_unlock(&wq_pool_mutex);
 	return 0;
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 274/555] net: dsa: b53: initialize the jumbo frame size register offset
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (272 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 273/555] workqueue: Skip redundant unbound updates during CPU bringup Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 275/555] net: dsa: b53: fix the SRAB grant timeout check Greg Kroah-Hartman
                   ` (280 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jonas Gorski, Florian Fainelli,
	Willem de Bruijn, Sasha Levin

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

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

From: Florian Fainelli <florian.fainelli@broadcom.com>

[ Upstream commit 5d30a02245c375a9c5e557b1b7476710c4a94a2d ]

The chip data specifies both the jumbo port mask and frame size register
offsets, but b53_switch_init() only copies the former into the device.
Since the device is zero-initialized, b53_set_jumbo() writes the frame
size to offset zero instead of the chip-specific size register at 0x05
or 0x08.

Copy jumbo_size_reg from the chip data along with jumbo_pm_reg so frame
size updates reach the intended register.

Fixes: 967dd82ffc52 ("net: dsa: b53: Add support for Broadcom RoboSwitch")
Reviewed-by: Jonas Gorski <jonas.gorski@gmail.com>
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/dsa/b53/b53_common.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 0ad48ef3ecfc9..bc74f617dc835 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -2898,6 +2898,7 @@ static int b53_switch_init(struct b53_device *dev)
 			dev->vta_regs[1] = chip->vta_regs[1];
 			dev->vta_regs[2] = chip->vta_regs[2];
 			dev->jumbo_pm_reg = chip->jumbo_pm_reg;
+			dev->jumbo_size_reg = chip->jumbo_size_reg;
 			dev->imp_port = chip->imp_port;
 			dev->num_vlans = chip->vlans;
 			dev->num_arl_bins = chip->arl_bins;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 275/555] net: dsa: b53: fix the SRAB grant timeout check
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (273 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 274/555] net: dsa: b53: initialize the jumbo frame size register offset Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 276/555] net: dsa: b53: use the correct override register 2 Gbps bit Greg Kroah-Hartman
                   ` (279 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jonas Gorski, Daniel Machon,
	Florian Fainelli, Willem de Bruijn, Sasha Levin

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

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

From: Florian Fainelli <florian.fainelli@broadcom.com>

[ Upstream commit bd7fc60896b3de8ce677142142c96277377e5167 ]

b53_srab_request_grant() polls for a grant up to 20 times, but checks for
an iteration count of five to detect a timeout. This rejects a grant
received on the sixth poll and reports success when all 20 polls finish
without a grant. The latter allows a register access to proceed without
ownership of the switch resources.

Check for exhaustion of all 20 iterations instead.

Fixes: 967dd82ffc52 ("net: dsa: b53: Add support for Broadcom RoboSwitch")
Reviewed-by: Jonas Gorski <jonas.gorski@gmail.com>
Reviewed-by: Daniel Machon <daniel.machon@microchip.com>
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/dsa/b53/b53_srab.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/b53/b53_srab.c b/drivers/net/dsa/b53/b53_srab.c
index f3f95332ff17e..2687f08cc966c 100644
--- a/drivers/net/dsa/b53/b53_srab.c
+++ b/drivers/net/dsa/b53/b53_srab.c
@@ -105,7 +105,7 @@ static int b53_srab_request_grant(struct b53_device *dev)
 			break;
 		usleep_range(10, 100);
 	}
-	if (WARN_ON(i == 5))
+	if (WARN_ON(i == 20))
 		return -EIO;
 
 	return 0;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 276/555] net: dsa: b53: use the correct override register 2 Gbps bit
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (274 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 275/555] net: dsa: b53: fix the SRAB grant timeout check Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 277/555] net: dsa: b53: fix mirror port encoding on BCM5325 and BCM5365 Greg Kroah-Hartman
                   ` (278 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jonas Gorski, Florian Fainelli,
	Willem de Bruijn, Sasha Levin

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

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

From: Florian Fainelli <florian.fainelli@broadcom.com>

[ Upstream commit fd2752aac6c2193507af2e96cfc1406b28cade6f ]

The IMP and per-port GMII override registers swap the override-enable and 2
Gbps speed bits. Using the IMP speed bit on a GMII port clears its override
enable and leaves any previous 2 Gbps selection intact. Select the speed
bit alongside the register and enable bit so lower speeds clear the correct
bit and 2 Gbps sets it.

Fixes: b6a8a5477fe9 ("net: dsa: b53: fix resetting speed and pause on forced link")
Fixes: 41af38324341 ("net: dsa: b53: restore the NSP IMP port 2 Gbps mode")
Reviewed-by: Jonas Gorski <jonas.gorski@gmail.com>
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/dsa/b53/b53_common.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index bc74f617dc835..be16e773903a4 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1354,17 +1354,19 @@ static void b53_force_port_config(struct b53_device *dev, int port,
 				  int speed, int duplex,
 				  bool tx_pause, bool rx_pause)
 {
-	u8 reg, val, off;
+	u8 reg, val, off, speed2000;
 
 	/* Override the port settings */
 	if (port == dev->imp_port) {
 		off = B53_PORT_OVERRIDE_CTRL;
 		val = PORT_OVERRIDE_EN;
+		speed2000 = PORT_OVERRIDE_SPEED_2000M;
 	} else if (is5325(dev)) {
 		return;
 	} else {
 		off = B53_GMII_PORT_OVERRIDE_CTRL(port);
 		val = GMII_PO_EN;
+		speed2000 = GMII_PO_SPEED_2000M;
 	}
 
 	b53_read8(dev, B53_CTRL_PAGE, off, &reg);
@@ -1376,11 +1378,12 @@ static void b53_force_port_config(struct b53_device *dev, int port,
 
 	reg &= ~(0x3 << GMII_PO_SPEED_S);
 	if (is5301x(dev) || is58xx(dev))
-		reg &= ~PORT_OVERRIDE_SPEED_2000M;
+		reg &= ~speed2000;
 
 	switch (speed) {
 	case 2000:
-		reg |= PORT_OVERRIDE_SPEED_2000M;
+		if (is5301x(dev) || is58xx(dev))
+			reg |= speed2000;
 		fallthrough;
 	case SPEED_1000:
 		reg |= PORT_OVERRIDE_SPEED_1000M;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 277/555] net: dsa: b53: fix mirror port encoding on BCM5325 and BCM5365
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (275 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 276/555] net: dsa: b53: use the correct override register 2 Gbps bit Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 278/555] net: dsa: b53: fix mirror destination and source state tracking Greg Kroah-Hartman
                   ` (277 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Florian Fainelli, Willem de Bruijn,
	Sasha Levin

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

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

From: Florian Fainelli <florian.fainelli@broadcom.com>

[ Upstream commit 000d468855945953c491810f97fb0bd4166b0b07 ]

BCM5325 and BCM5365 use an 11-bit bitmap for the mirror capture port,
whereas newer switches use a four-bit port ID. Programming the port
number directly can select no destination or the wrong destination, and
can select multiple destinations. For example, port 2 requires BIT(2),
but writing 2 selects port 1 instead.

Use the bitmap encoding on BCM5325 and BCM5365, including translating
logical CPU port 5 to hardware bit 8. Apply the corresponding field mask
when checking for a conflicting destination, replacing the destination,
and clearing it after the last mirror source is removed. Keep the port ID
encoding for newer switches.

The ingress and egress mirror source masks use the same layout on these
switches, with the CPU port at bit 8 and bits 5-7 reserved, so apply the
same translation when setting and clearing a source port bit.

Fixes: ed3af5fd08eb ("net: dsa: b53: Add support for port mirroring")
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/dsa/b53/b53_common.c | 35 +++++++++++++++++++++++++++-----
 drivers/net/dsa/b53/b53_regs.h   |  1 +
 2 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index be16e773903a4..c2cb5ca65ccc3 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -2395,6 +2395,31 @@ enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds, int port,
 }
 EXPORT_SYMBOL(b53_get_tag_protocol);
 
+static u16 b53_mirror_capture_port_mask(struct b53_device *dev)
+{
+	if (is5325(dev) || is5365(dev))
+		return CAP_PORT_MASK_25;
+
+	return CAP_PORT_MASK;
+}
+
+static u16 b53_mirror_port_mask(struct b53_device *dev, int port)
+{
+	/* These switches use a bitmap with the CPU port at bit 8. */
+	if ((is5325(dev) || is5365(dev)) && port == B53_CPU_PORT_25)
+		port = B53_CPU_PORT;
+
+	return BIT(port);
+}
+
+static u16 b53_mirror_capture_port(struct b53_device *dev, int port)
+{
+	if (is5325(dev) || is5365(dev))
+		return b53_mirror_port_mask(dev, port);
+
+	return port;
+}
+
 int b53_mirror_add(struct dsa_switch *ds, int port,
 		   struct dsa_mall_mirror_tc_entry *mirror, bool ingress,
 		   struct netlink_ext_ack *extack)
@@ -2408,12 +2433,12 @@ int b53_mirror_add(struct dsa_switch *ds, int port,
 		loc = B53_EG_MIR_CTL;
 
 	b53_read16(dev, B53_MGMT_PAGE, loc, &reg);
-	reg |= BIT(port);
+	reg |= b53_mirror_port_mask(dev, port);
 	b53_write16(dev, B53_MGMT_PAGE, loc, reg);
 
 	b53_read16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, &reg);
-	reg &= ~CAP_PORT_MASK;
-	reg |= mirror->to_local_port;
+	reg &= ~b53_mirror_capture_port_mask(dev);
+	reg |= b53_mirror_capture_port(dev, mirror->to_local_port);
 	reg |= MIRROR_EN;
 	b53_write16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, reg);
 
@@ -2435,7 +2460,7 @@ void b53_mirror_del(struct dsa_switch *ds, int port,
 
 	/* Update the desired ingress/egress register */
 	b53_read16(dev, B53_MGMT_PAGE, loc, &reg);
-	reg &= ~BIT(port);
+	reg &= ~b53_mirror_port_mask(dev, port);
 	if (!(reg & MIRROR_MASK))
 		loc_disable = true;
 	b53_write16(dev, B53_MGMT_PAGE, loc, reg);
@@ -2454,7 +2479,7 @@ void b53_mirror_del(struct dsa_switch *ds, int port,
 	/* Both no longer have ports, let's disable mirroring */
 	if (loc_disable && other_loc_disable) {
 		reg &= ~MIRROR_EN;
-		reg &= ~mirror->to_local_port;
+		reg &= ~b53_mirror_capture_port_mask(dev);
 	}
 	b53_write16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, reg);
 }
diff --git a/drivers/net/dsa/b53/b53_regs.h b/drivers/net/dsa/b53/b53_regs.h
index 628fdfae47c84..f71206a0a74ff 100644
--- a/drivers/net/dsa/b53/b53_regs.h
+++ b/drivers/net/dsa/b53/b53_regs.h
@@ -227,6 +227,7 @@
 /* Mirror capture control register (16 bit) */
 #define B53_MIR_CAP_CTL			0x10
 #define  CAP_PORT_MASK			0xf
+#define  CAP_PORT_MASK_25		0x7ff
 #define  BLK_NOT_MIR			BIT(14)
 #define  MIRROR_EN			BIT(15)
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 278/555] net: dsa: b53: fix mirror destination and source state tracking
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (276 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 277/555] net: dsa: b53: fix mirror port encoding on BCM5325 and BCM5365 Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 279/555] net: bcmasp: avoid refcount drain on probe Greg Kroah-Hartman
                   ` (276 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Florian Fainelli, Joseph Telaak,
	Willem de Bruijn, Sasha Levin

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

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

From: Florian Fainelli <florian.fainelli@broadcom.com>

[ Upstream commit 320bc9b8e2bc8a5fc75537082529b534ace633e3 ]

The mirror capture control register selects one destination for all
ingress and egress sources. Adding a rule for another destination
currently redirects existing rules. Multiple matchall filters can also
share one source bit, but deleting any one of them clears that bit and
can disable mirroring while other filters still need it.

Reject a different destination while either source mask is occupied, and
reference count each port's ingress and egress source bit under RTNL.
Program a source on its first reference and clear it on its last one.
Check every mirror register access and record a first reference only
after programming succeeds. Select the destination before enabling the
source, and log deletion failures because the callback returns no error.
Use the source masks to retain the destination after a failed source
deletion and allow a new destination after a failed capture-control clear.

Not all supported switches receive a hardware reset during setup, so
clear stale capture and source registers before accepting mirror rules.
Introduce b53_mirror_init() together with its b53 and bcm_sf2 setup
callers. Rebuild active sources and their destination from the reference
counts when setup runs again, preserving rules across bcm_sf2 resume.
Propagate initialization failures instead of accepting stale state.

This depends on "net: dsa: b53: fix mirror port encoding on BCM5325 and
BCM5365" for the chip-specific source and capture-port helpers.

Fixes: ed3af5fd08eb ("net: dsa: b53: Add support for port mirroring")
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Tested-by: Joseph Telaak <joseph@telaak.dev>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/dsa/b53/b53_common.c | 168 ++++++++++++++++++++++++-------
 drivers/net/dsa/b53/b53_priv.h   |   4 +
 drivers/net/dsa/bcm_sf2.c        |   4 +
 3 files changed, 140 insertions(+), 36 deletions(-)

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index c2cb5ca65ccc3..12b8d4e98819f 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1287,6 +1287,10 @@ static int b53_setup(struct dsa_switch *ds)
 		return ret;
 	}
 
+	ret = b53_mirror_init(ds);
+	if (ret)
+		return ret;
+
 	/* setup default vlan for filtering mode */
 	pvid = b53_default_pvid(dev);
 	vl = &dev->vlans[pvid];
@@ -2420,27 +2424,103 @@ static u16 b53_mirror_capture_port(struct b53_device *dev, int port)
 	return port;
 }
 
+int b53_mirror_init(struct dsa_switch *ds)
+{
+	struct b53_device *dev = ds->priv;
+	u16 ingress = 0, egress = 0, cap_ctl = 0;
+	unsigned int port;
+	int ret;
+
+	/* A switch reset may leave the previous mirror configuration intact. */
+	ret = b53_write16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, 0);
+	if (ret)
+		return ret;
+
+	ret = b53_write16(dev, B53_MGMT_PAGE, B53_IG_MIR_CTL, 0);
+	if (ret)
+		return ret;
+
+	ret = b53_write16(dev, B53_MGMT_PAGE, B53_EG_MIR_CTL, 0);
+	if (ret)
+		return ret;
+
+	/* DSA retains matchall filters across suspend and resume. */
+	for (port = 0; port < dev->num_ports; port++) {
+		if (dev->ports[port].mirror_count[true])
+			ingress |= b53_mirror_port_mask(dev, port);
+		if (dev->ports[port].mirror_count[false])
+			egress |= b53_mirror_port_mask(dev, port);
+	}
+
+	if (!(ingress | egress))
+		return 0;
+
+	cap_ctl = MIRROR_EN | b53_mirror_capture_port(dev, dev->mirror_port);
+	ret = b53_write16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, cap_ctl);
+	if (ret)
+		return ret;
+
+	ret = b53_write16(dev, B53_MGMT_PAGE, B53_IG_MIR_CTL, ingress);
+	if (ret)
+		return ret;
+
+	return b53_write16(dev, B53_MGMT_PAGE, B53_EG_MIR_CTL, egress);
+}
+EXPORT_SYMBOL(b53_mirror_init);
+
 int b53_mirror_add(struct dsa_switch *ds, int port,
 		   struct dsa_mall_mirror_tc_entry *mirror, bool ingress,
 		   struct netlink_ext_ack *extack)
 {
 	struct b53_device *dev = ds->priv;
-	u16 reg, loc;
+	unsigned int *mirror_count = &dev->ports[port].mirror_count[ingress];
+	u16 reg, other_reg, loc, other_loc, cap_ctl;
+	u16 cap_mask = b53_mirror_capture_port_mask(dev);
+	u16 cap_port = b53_mirror_capture_port(dev, mirror->to_local_port);
+	int ret;
 
-	if (ingress)
-		loc = B53_IG_MIR_CTL;
-	else
-		loc = B53_EG_MIR_CTL;
+	loc = ingress ? B53_IG_MIR_CTL : B53_EG_MIR_CTL;
+	other_loc = ingress ? B53_EG_MIR_CTL : B53_IG_MIR_CTL;
 
-	b53_read16(dev, B53_MGMT_PAGE, loc, &reg);
-	reg |= b53_mirror_port_mask(dev, port);
-	b53_write16(dev, B53_MGMT_PAGE, loc, reg);
+	ret = b53_read16(dev, B53_MGMT_PAGE, loc, &reg);
+	if (ret)
+		return ret;
 
-	b53_read16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, &reg);
-	reg &= ~b53_mirror_capture_port_mask(dev);
-	reg |= b53_mirror_capture_port(dev, mirror->to_local_port);
-	reg |= MIRROR_EN;
-	b53_write16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, reg);
+	ret = b53_read16(dev, B53_MGMT_PAGE, other_loc, &other_reg);
+	if (ret)
+		return ret;
+
+	ret = b53_read16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, &cap_ctl);
+	if (ret)
+		return ret;
+
+	if (((reg | other_reg) & MIRROR_MASK) &&
+	    (cap_ctl & cap_mask) != cap_port) {
+		NL_SET_ERR_MSG_MOD(extack,
+				   "Only one mirroring destination is supported");
+		return -EOPNOTSUPP;
+	}
+
+	if (*mirror_count) {
+		(*mirror_count)++;
+		return 0;
+	}
+
+	/* Select the destination before enabling the new source. */
+	cap_ctl &= ~cap_mask;
+	cap_ctl |= cap_port;
+	cap_ctl |= MIRROR_EN;
+	ret = b53_write16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, cap_ctl);
+	if (ret)
+		return ret;
+
+	ret = b53_write16(dev, B53_MGMT_PAGE, loc,
+			  reg | b53_mirror_port_mask(dev, port));
+	if (ret)
+		return ret;
+
+	(*mirror_count)++;
+	dev->mirror_port = mirror->to_local_port;
 
 	return 0;
 }
@@ -2450,38 +2530,54 @@ void b53_mirror_del(struct dsa_switch *ds, int port,
 		    struct dsa_mall_mirror_tc_entry *mirror)
 {
 	struct b53_device *dev = ds->priv;
-	bool loc_disable = false, other_loc_disable = false;
-	u16 reg, loc;
+	unsigned int *mirror_count =
+		&dev->ports[port].mirror_count[mirror->ingress];
+	u16 reg, other_reg, loc, other_loc;
+	int ret;
 
-	if (mirror->ingress)
-		loc = B53_IG_MIR_CTL;
-	else
-		loc = B53_EG_MIR_CTL;
+	if (!*mirror_count)
+		return;
+
+	if (--(*mirror_count))
+		return;
+
+	loc = mirror->ingress ? B53_IG_MIR_CTL : B53_EG_MIR_CTL;
+	other_loc = mirror->ingress ? B53_EG_MIR_CTL : B53_IG_MIR_CTL;
 
 	/* Update the desired ingress/egress register */
-	b53_read16(dev, B53_MGMT_PAGE, loc, &reg);
+	ret = b53_read16(dev, B53_MGMT_PAGE, loc, &reg);
+	if (ret)
+		goto err;
+
 	reg &= ~b53_mirror_port_mask(dev, port);
-	if (!(reg & MIRROR_MASK))
-		loc_disable = true;
-	b53_write16(dev, B53_MGMT_PAGE, loc, reg);
+	ret = b53_write16(dev, B53_MGMT_PAGE, loc, reg);
+	if (ret)
+		goto err;
 
 	/* Now look at the other one to know if we can disable mirroring
 	 * entirely
 	 */
-	if (mirror->ingress)
-		b53_read16(dev, B53_MGMT_PAGE, B53_EG_MIR_CTL, &reg);
-	else
-		b53_read16(dev, B53_MGMT_PAGE, B53_IG_MIR_CTL, &reg);
-	if (!(reg & MIRROR_MASK))
-		other_loc_disable = true;
+	ret = b53_read16(dev, B53_MGMT_PAGE, other_loc, &other_reg);
+	if (ret)
+		goto err;
 
-	b53_read16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, &reg);
-	/* Both no longer have ports, let's disable mirroring */
-	if (loc_disable && other_loc_disable) {
-		reg &= ~MIRROR_EN;
-		reg &= ~b53_mirror_capture_port_mask(dev);
-	}
-	b53_write16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, reg);
+	if ((reg | other_reg) & MIRROR_MASK)
+		return;
+
+	ret = b53_read16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, &reg);
+	if (ret)
+		goto err;
+
+	reg &= ~(MIRROR_EN | b53_mirror_capture_port_mask(dev));
+	ret = b53_write16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, reg);
+	if (ret)
+		goto err;
+
+	return;
+
+err:
+	dev_err(dev->dev, "Failed to delete mirror rule for port %d: %d\n",
+		port, ret);
 }
 EXPORT_SYMBOL(b53_mirror_del);
 
diff --git a/drivers/net/dsa/b53/b53_priv.h b/drivers/net/dsa/b53/b53_priv.h
index f981537bc0a1b..ccd1928490846 100644
--- a/drivers/net/dsa/b53/b53_priv.h
+++ b/drivers/net/dsa/b53/b53_priv.h
@@ -94,6 +94,8 @@ struct b53_pcs {
 #define B53_N_PCS	2
 
 struct b53_port {
+	/* References to each egress/ingress mirror source mask bit. */
+	unsigned int mirror_count[2];
 	u16		vlan_ctl_mask;
 	u16		pvid;
 	struct ethtool_keee eee;
@@ -143,6 +145,7 @@ struct b53_device {
 
 	/* run time configuration */
 	bool enable_jumbo;
+	unsigned int mirror_port;
 
 	unsigned int num_vlans;
 	struct b53_vlan *vlans;
@@ -376,6 +379,7 @@ int b53_mdb_add(struct dsa_switch *ds, int port,
 int b53_mdb_del(struct dsa_switch *ds, int port,
 		const struct switchdev_obj_port_mdb *mdb,
 		struct dsa_db db);
+int b53_mirror_init(struct dsa_switch *ds);
 int b53_mirror_add(struct dsa_switch *ds, int port,
 		   struct dsa_mall_mirror_tc_entry *mirror, bool ingress,
 		   struct netlink_ext_ack *extack);
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 99b44e20c6fee..729feaf036e1b 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -1061,6 +1061,10 @@ static int bcm_sf2_sw_setup(struct dsa_switch *ds)
 	unsigned int port;
 	int ret;
 
+	ret = b53_mirror_init(ds);
+	if (ret)
+		return ret;
+
 	/* Enable all valid ports and disable those unused */
 	for (port = 0; port < priv->hw_params.num_ports; port++) {
 		/* IMP port receives special treatment */
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 279/555] net: bcmasp: avoid refcount drain on probe
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (277 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 278/555] net: dsa: b53: fix mirror destination and source state tracking Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 280/555] net: bcmgenet: use napi_complete_done return value Greg Kroah-Hartman
                   ` (275 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Wang Haoran, Willem de Bruijn,
	Sasha Levin

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

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

From: Wang Haoran <wanghr2026@mail.zgclab.edu.cn>

[ Upstream commit 846a6d0982be30aaba5268aac14a0c557d70cc23 ]

bcmasp_probe() calls of_find_node_by_name(dev->of_node, "ethernet-ports"),
which unconditionally drops the from-node reference the caller never held.
Every probe or bind cycle that reaches the port scan, including ones that
later fail with "No ports found", drains the asp node refcount by one. Once
it hits zero, of_node_release() deadlocks in its error printk (%pOF on the
parent while holding devtree_lock with IRQs off), so the machine freezes
silently with nothing on the console.

Use of_get_child_by_name() which leaves the parent reference alone.

Fixes: 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controller")
Signed-off-by: Wang Haoran <wanghr2026@mail.zgclab.edu.cn>
Link: https://patch.msgid.link/1795076102979-9-385853cc@mail.zgclab.edu.cn
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/broadcom/asp2/bcmasp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp.c b/drivers/net/ethernet/broadcom/asp2/bcmasp.c
index 35a35aa0ad69b..3c9c7d1d2ca77 100644
--- a/drivers/net/ethernet/broadcom/asp2/bcmasp.c
+++ b/drivers/net/ethernet/broadcom/asp2/bcmasp.c
@@ -1347,7 +1347,7 @@ static int bcmasp_probe(struct platform_device *pdev)
 
 	bcmasp_init_wol(priv);
 
-	ports_node = of_find_node_by_name(dev->of_node, "ethernet-ports");
+	ports_node = of_get_child_by_name(dev->of_node, "ethernet-ports");
 	if (!ports_node) {
 		dev_warn(dev, "No ports found\n");
 		ret = -EINVAL;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 280/555] net: bcmgenet: use napi_complete_done return value
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (278 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 279/555] net: bcmasp: avoid refcount drain on probe Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 281/555] net: bcmgenet: keep DIM from getting stuck after close or suspend Greg Kroah-Hartman
                   ` (274 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Zak Kemble, Florian Fainelli,
	Jakub Kicinski, Sasha Levin

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

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

From: Zak Kemble <zakkemble@gmail.com>

[ Upstream commit 28ed9bed5fb24e4235b8d6cffb5a5c68de710a25 ]

Make use of the return value from napi_complete_done(). This allows users to
use the gro_flush_timeout and napi_defer_hard_irqs sysfs attributes for
configuring software interrupt coalescing.

Signed-off-by: Zak Kemble <zakkemble@gmail.com>
Tested-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://patch.msgid.link/20250610220403.935-2-zakkemble@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Stable-dep-of: aa5a537ec43c ("net: bcmgenet: keep DIM from getting stuck after close or suspend")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 7ed77db673976..342ee9d25dab2 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -2427,10 +2427,8 @@ static int bcmgenet_rx_poll(struct napi_struct *napi, int budget)
 
 	work_done = bcmgenet_desc_rx(ring, budget);
 
-	if (work_done < budget) {
-		napi_complete_done(napi, work_done);
+	if (work_done < budget && napi_complete_done(napi, work_done))
 		bcmgenet_rx_ring_int_enable(ring);
-	}
 
 	if (ring->dim.use_dim) {
 		dim_update_sample(ring->dim.event_ctr, ring->dim.packets,
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 281/555] net: bcmgenet: keep DIM from getting stuck after close or suspend
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (279 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 280/555] net: bcmgenet: use napi_complete_done return value Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 282/555] net: bcmgenet: accumulate the DIM packet and byte counters Greg Kroah-Hartman
                   ` (273 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Nicolai Buchwitz, Florian Fainelli,
	Willem de Bruijn, Sasha Levin

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

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

From: Nicolai Buchwitz <nb@tipi-net.de>

[ Upstream commit aa5a537ec43c13e4d2850468b0d88f97cce45dd3 ]

A close or WoL suspend cancels the pending profile work and can leave
DIM in DIM_APPLY_NEW_PROFILE, where net_dim() does nothing. Adaptive
coalescing then stays stuck after the next open or resume, and the
profile index no longer matches the hardware. The poll also calls
net_dim() after napi_complete_done(), so it can queue new work after
napi_disable() has returned.

Run net_dim() before completing NAPI and flush the work instead of
cancelling it, so the pending profile gets applied. Also reset the DIM
state on ring init and start from the default profile, which is what
bcmgenet_init_rx_coalesce() programs.

Fixes: 9f4ca05827a2 ("net: bcmgenet: Add support for adaptive RX coalescing")
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 342ee9d25dab2..9e9d079564b77 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -2427,15 +2427,16 @@ static int bcmgenet_rx_poll(struct napi_struct *napi, int budget)
 
 	work_done = bcmgenet_desc_rx(ring, budget);
 
-	if (work_done < budget && napi_complete_done(napi, work_done))
-		bcmgenet_rx_ring_int_enable(ring);
-
+	/* net_dim() can queue work, so run it while NAPI is still owned */
 	if (ring->dim.use_dim) {
 		dim_update_sample(ring->dim.event_ctr, ring->dim.packets,
 				  ring->dim.bytes, &dim_sample);
 		net_dim(&ring->dim.dim, dim_sample);
 	}
 
+	if (work_done < budget && napi_complete_done(napi, work_done))
+		bcmgenet_rx_ring_int_enable(ring);
+
 	return work_done;
 }
 
@@ -2629,8 +2630,11 @@ static void bcmgenet_init_dim(struct bcmgenet_rx_ring *ring,
 {
 	struct bcmgenet_net_dim *dim = &ring->dim;
 
+	memset(&dim->dim, 0, sizeof(dim->dim));
 	INIT_WORK(&dim->dim.work, cb);
 	dim->dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE;
+	/* Match the profile bcmgenet_init_rx_coalesce() programs */
+	dim->dim.profile_ix = NET_DIM_DEF_PROFILE_EQE;
 	dim->event_ctr = 0;
 	dim->packets = 0;
 	dim->bytes = 0;
@@ -2906,7 +2910,8 @@ static void bcmgenet_disable_rx_napi(struct bcmgenet_priv *priv)
 	for (i = 0; i <= priv->hw_params->rx_queues; ++i) {
 		ring = &priv->rx_rings[i];
 		napi_disable(&ring->napi);
-		cancel_work_sync(&ring->dim.dim.work);
+		/* Cancelling would leave DIM stuck in DIM_APPLY_NEW_PROFILE */
+		flush_work(&ring->dim.dim.work);
 	}
 }
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 282/555] net: bcmgenet: accumulate the DIM packet and byte counters
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (280 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 281/555] net: bcmgenet: keep DIM from getting stuck after close or suspend Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 283/555] net: bcmgenet: reset the Rx discard count with the ring Greg Kroah-Hartman
                   ` (272 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Florian Fainelli, Nicolai Buchwitz,
	Willem de Bruijn, Sasha Levin

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

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

From: Nicolai Buchwitz <nb@tipi-net.de>

[ Upstream commit a15079369636f4324d2985cede7ce7fbefddf4b3 ]

net_dim() computes rates from the difference between two samples and
needs running totals, but bcmgenet_desc_rx() passes the counts of the
last poll. Adaptive coalescing then picks profiles from wrong rates.

On a CM4 at a steady 300 Mbit/s UDP, DIM changed profile about 1000
times in 20 s. With the fix it settles, and Rx interrupts drop from about
4500/s to 2240/s.

Accumulate the counters instead.

Fixes: 9f4ca05827a2 ("net: bcmgenet: Add support for adaptive RX coalescing")
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 9e9d079564b77..5413497aba081 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -2411,8 +2411,8 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring,
 		bcmgenet_rdma_ring_writel(priv, ring->index, ring->c_index, RDMA_CONS_INDEX);
 	}
 
-	ring->dim.bytes = bytes_processed;
-	ring->dim.packets = rxpktprocessed;
+	ring->dim.bytes += bytes_processed;
+	ring->dim.packets += rxpktprocessed;
 
 	return rxpktprocessed;
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 283/555] net: bcmgenet: reset the Rx discard count with the ring
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (281 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 282/555] net: bcmgenet: accumulate the DIM packet and byte counters Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 284/555] net: systemport: restart DIM from the default profile on start Greg Kroah-Hartman
                   ` (271 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Florian Fainelli, Nicolai Buchwitz,
	Willem de Bruijn, Sasha Levin

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

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

From: Nicolai Buchwitz <nb@tipi-net.de>

[ Upstream commit e99faa3a16209ea5d0b83cc58b64785efd2d9045 ]

Ring init clears the hardware discard counter but not
ring->old_discards. Discards after an ifdown and ifup or a resume are
then missing from rx_missed. On a CM4, after an ifdown and ifup, 3666
discards showed up as 0 in rx_missed.

Reset old_discards together with the ring.

Fixes: d26ea6cc48da ("net: bcmgenet: collect Rx discarded packet count")
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 5413497aba081..c6f53ebd4a570 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -2727,6 +2727,8 @@ static int bcmgenet_init_rx_ring(struct bcmgenet_priv *priv,
 	ring->read_ptr = start_ptr;
 	ring->cb_ptr = start_ptr;
 	ring->end_ptr = end_ptr - 1;
+	/* Zeroing RDMA_PROD_INDEX below also clears the discard counter */
+	ring->old_discards = 0;
 
 	ret = bcmgenet_alloc_rx_buffers(priv, ring);
 	if (ret)
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 284/555] net: systemport: restart DIM from the default profile on start
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (282 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 283/555] net: bcmgenet: reset the Rx discard count with the ring Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 285/555] net: systemport: accumulate the DIM packet and byte counters Greg Kroah-Hartman
                   ` (270 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Nicolai Buchwitz, Willem de Bruijn,
	Sasha Levin

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

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

From: Nicolai Buchwitz <nb@tipi-net.de>

[ Upstream commit 8e428e263fa4fd3a752db8d9e1e584307f446aae ]

A close or suspend can cancel the pending profile work and leave DIM in
DIM_APPLY_NEW_PROFILE, where net_dim() does nothing. Adaptive coalescing
then stays stuck after the next open or resume. The poll also calls
net_dim() after napi_complete_done(), so it can queue new work after
napi_disable() has returned.

Run net_dim() before completing NAPI. Reset the DIM state on start and
begin from the default profile, which is what
bcm_sysport_init_rx_coalesce() programs.

Fixes: b6e0e875421e ("net: systemport: Implement adaptive interrupt coalescing")
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/broadcom/bcmsysport.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 2cb3693080744..8dfe9bbe8207a 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -1046,18 +1046,19 @@ static int bcm_sysport_poll(struct napi_struct *napi, int budget)
 	else
 		rdma_writel(priv, priv->rx_c_index << 16, RDMA_CONS_INDEX);
 
-	if (work_done < budget) {
-		napi_complete_done(napi, work_done);
-		/* re-enable RX interrupts */
-		intrl2_0_mask_clear(priv, INTRL2_0_RDMA_MBDONE);
-	}
-
+	/* net_dim() can queue work, so run it while NAPI is still owned */
 	if (priv->dim.use_dim) {
 		dim_update_sample(priv->dim.event_ctr, priv->dim.packets,
 				  priv->dim.bytes, &dim_sample);
 		net_dim(&priv->dim.dim, dim_sample);
 	}
 
+	if (work_done < budget) {
+		napi_complete_done(napi, work_done);
+		/* re-enable RX interrupts */
+		intrl2_0_mask_clear(priv, INTRL2_0_RDMA_MBDONE);
+	}
+
 	return work_done;
 }
 
@@ -1486,8 +1487,11 @@ static void bcm_sysport_init_dim(struct bcm_sysport_priv *priv,
 {
 	struct bcm_sysport_net_dim *dim = &priv->dim;
 
+	memset(&dim->dim, 0, sizeof(dim->dim));
 	INIT_WORK(&dim->dim.work, cb);
 	dim->dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE;
+	/* Match the profile bcm_sysport_init_rx_coalesce() programs */
+	dim->dim.profile_ix = NET_DIM_DEF_PROFILE_EQE;
 	dim->event_ctr = 0;
 	dim->packets = 0;
 	dim->bytes = 0;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 285/555] net: systemport: accumulate the DIM packet and byte counters
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (283 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 284/555] net: systemport: restart DIM from the default profile on start Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 286/555] ipv4: fix conntrack defrag forwarding after ip_frag_reinit() Greg Kroah-Hartman
                   ` (269 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Florian Fainelli, Nicolai Buchwitz,
	Willem de Bruijn, Sasha Levin

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

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

From: Nicolai Buchwitz <nb@tipi-net.de>

[ Upstream commit 3e7e20beef4ec04f7601e92e78608333f2ab3904 ]

net_dim() computes rates from the difference between two samples and
needs running totals, but bcm_sysport_desc_rx() passes the counts of the
last poll. Adaptive coalescing then picks profiles from wrong rates.

Accumulate the counters instead.

Fixes: b6e0e875421e ("net: systemport: Implement adaptive interrupt coalescing")
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/broadcom/bcmsysport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 8dfe9bbe8207a..40880d9b5f32c 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -878,8 +878,8 @@ static unsigned int bcm_sysport_desc_rx(struct bcm_sysport_priv *priv,
 			priv->rx_read_ptr = 0;
 	}
 
-	priv->dim.packets = processed;
-	priv->dim.bytes = processed_bytes;
+	priv->dim.packets += processed;
+	priv->dim.bytes += processed_bytes;
 
 	return processed;
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 286/555] ipv4: fix conntrack defrag forwarding after ip_frag_reinit()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (284 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 285/555] net: systemport: accumulate the DIM packet and byte counters Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 287/555] tun: bound the NAPI receive queue Greg Kroah-Hartman
                   ` (268 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Eric Dumazet, Jiayuan Chen,
	Willem de Bruijn, Sasha Levin

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

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

From: Jiayuan Chen <jiayuan.chen@linux.dev>

[ Upstream commit 3ab5aae0eb60079d17378af5aab0db84ba946e0e ]

q.max_size and max_df_size are used by ip_frag_reasm() to set
IPCB(skb)->frag_max_size and the DF bit of the reassembled packet.

ip_frag_reinit() reuses the queue for a new datagram but does not
reset them, so the new datagram inherits them from the old one.

On a router with conntrack defrag, if the largest fragment of the old
datagram had DF set and was larger than the egress MTU, a new datagram
without DF gets DF set after reassembly and is rejected with
ICMP_FRAG_NEEDED, even though all its fragments fit.

Reset both fields.

Fixes: 5f2d04f1f9b5 ("ipv4: fix path MTU discovery with connection tracking")
Fixes: d6b915e29f4a ("ip_fragment: don't forward defragmented DF packet")
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Link: https://patch.msgid.link/20261120094700.46500-1-jiayuan.chen@linux.dev
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/ipv4/ip_fragment.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 648e80c1f8df3..62c8bcbce628c 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -251,6 +251,8 @@ static int ip_frag_reinit(struct ipq *qp)
 	qp->q.flags = 0;
 	qp->q.len = 0;
 	qp->q.meat = 0;
+	qp->q.max_size = 0;
+	qp->max_df_size = 0;
 	qp->iif = 0;
 	qp->ecn = 0;
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 287/555] tun: bound the NAPI receive queue
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (285 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 286/555] ipv4: fix conntrack defrag forwarding after ip_frag_reinit() Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 288/555] bpf: clear list node owner and unlink before drop Greg Kroah-Hartman
                   ` (267 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Antonio Quartulli, Willem de Bruijn,
	Sasha Levin

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

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

From: Antonio Quartulli <antonio@mandelbit.com>

[ Upstream commit cc7fe6e741730fef549e484379281736d32746f0 ]

With IFF_NAPI, tun_get_user() queues every written packet for NAPI on
an unbounded list. When the poll runs asynchronously (threaded NAPI or
ksoftirqd) and is slower than the writer, the queue grows until the
system runs out of memory. An unprivileged user can do this from its own
user and network namespaces, and the queued skbs are not charged to its
memcg: in a test VM, a uid 1000 process limited to 128 MB caused a
global OOM in ~6 seconds. The socket send buffer does not help: tun sets
it to INT_MAX by default, the build_skb() path is only used while it is
INT_MAX, and the XDP batch path never checks it.

Drop packets once more than netdev_max_backlog of them are queued, like
enqueue_to_backlog() does, and count them as rx_dropped; the write still
reports success, as for a full backlog. The check sits where packets are
queued for NAPI, in tun_get_user() and in tun_xdp_one() for the batches
vhost-net passes, so packets consumed by XDP or delivered through
IFF_NAPI_FRAGS are not affected. A dropped zerocopy skb completes its
buffer when freed. The check is lockless, so concurrent writers can each
still add one packet.

The NAPI poll moved the whole queue out, processed up to its budget and
put the rest back: while it ran, the queue looked empty to writers, so
with the poll on another CPU the backlog could still grow without limit.
Take at most budget packets instead: the rest stays on the queue writers
check.

Dropping also schedules NAPI. vhost-net sends with MSG_MORE while it has
more packets, and tun_get_user() schedules NAPI only for a packet
without it or once more than NAPI_POLL_WEIGHT are queued. With a
netdev_max_backlog below that, the queue fills first and the packet
without MSG_MORE is dropped too: nothing would schedule NAPI, and the
queued packets, with zerocopy also their buffers, would wait forever.

Reproducer, as an unprivileged user in a new user and network
namespace, without kernel modifications or fault injection:
  ip tuntap add t0 mode tun; ip addr add 10.11.0.1/24 dev t0
  ip link add d0 type dummy; ip addr add 10.20.0.1/24 dev d0
  ip link set t0 up; ip link set d0 up; sysctl net.ipv4.ip_forward=1
  install ~500 iptables FORWARD rules, to slow down the poll, and a
  MASQUERADE rule on d0
  open t0 with IFF_TUN | IFF_NO_PI | IFF_NAPI
  echo 1 > /sys/class/net/t0/threaded
  write() 1400-byte IPv4 packets for 10.20.0.2 in a loop

Found by code inspection while analysing the performance of the tun
write path. Tested in an x86-64 VM on net, with 1 and 2 vCPUs: the
reproducer causes a global OOM without the patch, while with it memory
use stays flat and the forwarding rate is unchanged; the tun kselftest
passes; a local vhost-net test of the batch, copy and zerocopy paths
with netdev_max_backlog set to 8 passes, and fails without the patch;
an XDP program on the device sees every packet while the excess is
dropped.

Still open: neither the packet size nor the queued memory is bounded,
and the skbs are not charged to the writer's memcg. A single write can
create an skb of several hundred KB, so even one queue can hold a lot,
and IFF_MULTI_QUEUE (allowed in a user namespace) and more devices
multiply it. This bounds the queue as enqueue_to_backlog() bounds the
per-CPU backlog; charging the skbs to the writer is left to a follow-up.

Fixes: 943170998b20 ("tun: enable NAPI for TUN/TAP driver")
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20261119153056.353156-1-antonio@mandelbit.com
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/tun.c | 52 +++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 44 insertions(+), 8 deletions(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 815a0b8319983..9662d2a8cd9de 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -58,6 +58,7 @@
 #include <linux/nsproxy.h>
 #include <linux/virtio_net.h>
 #include <linux/rcupdate.h>
+#include <net/hotdata.h>
 #include <net/net_namespace.h>
 #include <net/netns/generic.h>
 #include <net/rtnetlink.h>
@@ -224,6 +225,16 @@ struct veth {
 static void tun_flow_init(struct tun_struct *tun);
 static void tun_flow_uninit(struct tun_struct *tun);
 
+/* In IFF_NAPI mode written packets wait in the tfile's sk_write_queue for the
+ * NAPI poll, which may run later in a kthread or ksoftirqd. Bound that queue
+ * like the per-CPU backlog.
+ */
+static bool tun_napi_queue_full(const struct sk_buff_head *queue)
+{
+	return skb_queue_len_lockless(queue) >
+	       READ_ONCE(net_hotdata.max_backlog);
+}
+
 static int tun_napi_receive(struct napi_struct *napi, int budget)
 {
 	struct tun_file *tfile = container_of(napi, struct tun_file, napi);
@@ -234,21 +245,22 @@ static int tun_napi_receive(struct napi_struct *napi, int budget)
 
 	__skb_queue_head_init(&process_queue);
 
+	/* At most budget skbs: the rest stays on the queue writers check */
 	spin_lock(&queue->lock);
-	skb_queue_splice_tail_init(queue, &process_queue);
+	if (skb_queue_len(queue) <= budget) {
+		skb_queue_splice_tail_init(queue, &process_queue);
+	} else {
+		while (skb_queue_len(&process_queue) < budget &&
+		       (skb = __skb_dequeue(queue)))
+			__skb_queue_tail(&process_queue, skb);
+	}
 	spin_unlock(&queue->lock);
 
-	while (received < budget && (skb = __skb_dequeue(&process_queue))) {
+	while ((skb = __skb_dequeue(&process_queue))) {
 		napi_gro_receive(napi, skb);
 		++received;
 	}
 
-	if (!skb_queue_empty(&process_queue)) {
-		spin_lock(&queue->lock);
-		skb_queue_splice(&process_queue, queue);
-		spin_unlock(&queue->lock);
-	}
-
 	return received;
 }
 
@@ -2021,6 +2033,19 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
 		struct sk_buff_head *queue = &tfile->sk.sk_write_queue;
 		int queue_len;
 
+		/* Queue full: drop, and schedule NAPI, which a MSG_MORE sender
+		 * may not have done yet. Lockless: concurrent writers can each
+		 * still add one.
+		 */
+		if (unlikely(tun_napi_queue_full(queue))) {
+			local_bh_disable();
+			napi_schedule(&tfile->napi);
+			local_bh_enable();
+			rcu_read_unlock();
+			drop_reason = SKB_DROP_REASON_FULL_RING;
+			goto drop;
+		}
+
 		spin_lock_bh(&queue->lock);
 
 		if (unlikely(tfile->detached)) {
@@ -2577,6 +2602,17 @@ static int tun_xdp_one(struct tun_struct *tun,
 
 	if (tfile->napi_enabled) {
 		queue = &tfile->sk.sk_write_queue;
+
+		/* Queue full: drop, and schedule NAPI so that it drains even if
+		 * nothing in this batch gets queued.
+		 */
+		if (unlikely(tun_napi_queue_full(queue))) {
+			napi_schedule(&tfile->napi);
+			kfree_skb_reason(skb, SKB_DROP_REASON_FULL_RING);
+			dev_core_stats_rx_dropped_inc(tun->dev);
+			return 0;
+		}
+
 		spin_lock(&queue->lock);
 
 		if (unlikely(tfile->detached)) {
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 288/555] bpf: clear list node owner and unlink before drop
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (286 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 287/555] tun: bound the NAPI receive queue Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 289/555] bpf: Save irq flags on the stack when freeing a list head or rb root Greg Kroah-Hartman
                   ` (266 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Kaitao Cheng, Alexei Starovoitov,
	Sasha Levin

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

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

From: Kaitao Cheng <chengkaitao@kylinos.cn>

[ Upstream commit cfa6afa4b931aed08288454943e5077f114fd7f3 ]

The issue only becomes exposed once bpf_list_del() is available: callers
can pass an arbitrary bpf_list_head and bpf_list_node pair, including
nodes that are not actually linked to the supplied head, or nodes that
outlive their original head after refcount-based retention.  This was
not practically reachable for callers restricted to pop-style helpers
alone; bpf_list_del() widens the API surface.

A failure mode appears when bpf_list_head_free() runs while a program
still holds an independent refcount on a node (for example via
bpf_refcount_acquire()).  The list head value embedded in map memory can
go away while the node object survives.  If node->owner is left pointing
at the old head address until drop completes, that pointer becomes stale.
If a new bpf_list_head is later allocated at the same address and the
stale node is passed to bpf_list_del(), the owner comparison can succeed
even though the node is not really linked to the new head, and
list_del_init() will follow bogus next/prev pointers with the risk of
memory corruption.

When draining a bpf_list_head, mark each node owner with BPF_PTR_POISON
under the map spinlock while moving it to a private drain list, then
list_del_init() the node and clear owner to NULL before calling
__bpf_obj_drop_impl().  Concurrent readers therefore never observe a
node that appears linked to a head while its list_head is inconsistent,
and surviving refcounted nodes never retain a stale non-NULL owner.

Signed-off-by: Kaitao Cheng <chengkaitao@kylinos.cn>
Link: https://lore.kernel.org/r/20260521032306.97118-3-kaitao.cheng@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Stable-dep-of: 81c6c8c608b6 ("bpf: Save irq flags on the stack when freeing a list head or rb root")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/bpf/helpers.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index 7ae6acfc14d36..4614442745afd 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -2076,10 +2076,11 @@ EXPORT_SYMBOL_GPL(bpf_base_func_proto);
 void bpf_list_head_free(const struct btf_field *field, void *list_head,
 			struct bpf_spin_lock *spin_lock)
 {
-	struct list_head *head = list_head, *orig_head = list_head;
+	struct list_head *head = list_head, drain, *pos, *n;
 
 	BUILD_BUG_ON(sizeof(struct list_head) > sizeof(struct bpf_list_head));
 	BUILD_BUG_ON(__alignof__(struct list_head) > __alignof__(struct bpf_list_head));
+	INIT_LIST_HEAD(&drain);
 
 	/* Do the actual list draining outside the lock to not hold the lock for
 	 * too long, and also prevent deadlocks if tracing programs end up
@@ -2090,20 +2091,30 @@ void bpf_list_head_free(const struct btf_field *field, void *list_head,
 	__bpf_spin_lock_irqsave(spin_lock);
 	if (!head->next || list_empty(head))
 		goto unlock;
-	head = head->next;
+	list_for_each_safe(pos, n, head) {
+		struct bpf_list_node_kern *node;
+
+		node = container_of(pos, struct bpf_list_node_kern, list_head);
+		WRITE_ONCE(node->owner, BPF_PTR_POISON);
+		list_move_tail(pos, &drain);
+	}
 unlock:
-	INIT_LIST_HEAD(orig_head);
+	INIT_LIST_HEAD(head);
 	__bpf_spin_unlock_irqrestore(spin_lock);
 
-	while (head != orig_head) {
-		void *obj = head;
+	while (!list_empty(&drain)) {
+		struct bpf_list_node_kern *node;
 
-		obj -= field->graph_root.node_offset;
-		head = head->next;
+		pos = drain.next;
+		node = container_of(pos, struct bpf_list_node_kern, list_head);
+		list_del_init(pos);
+		/* Ensure __bpf_list_add() sees the node as unlinked. */
+		smp_store_release(&node->owner, NULL);
 		/* The contained type can also have resources, including a
 		 * bpf_list_head which needs to be freed.
 		 */
-		__bpf_obj_drop_impl(obj, field->graph_root.value_rec, false);
+		__bpf_obj_drop_impl((char *)pos - field->graph_root.node_offset,
+				    field->graph_root.value_rec, false);
 	}
 }
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 289/555] bpf: Save irq flags on the stack when freeing a list head or rb root
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (287 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 288/555] bpf: clear list node owner and unlink before drop Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 290/555] net: dsa: felix: fix NULL pointer dereference in felix_port_enable() Greg Kroah-Hartman
                   ` (265 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov,
	Kumar Kartikeya Dwivedi, Sasha Levin

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

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

From: Alexei Starovoitov <ast@kernel.org>

[ Upstream commit 81c6c8c608b6075846d3bd5b6f57958300a56eda ]

bpf_spin_lock() saves the irq flags in the per-cpu variable irqsave_flags,
and bpf_spin_unlock() restores them from there. One word per cpu is enough
as long as a cpu takes no second bpf_spin_lock before it releases the
first.

bpf_list_head_free() and bpf_rb_root_free() take a second one. They lock
the list or the tree that they free with __bpf_spin_lock_irqsave(), and
they can run while a program holds a bpf_spin_lock of its own.
bpf_list_add(), bpf_list_push_front(), bpf_list_push_back() and
bpf_rbtree_add() drop the node when they fail. The drop frees a node that
has no other reference, with its fields, and the node can have a list or a
tree itself, like struct foo of the selftests' linked_list.h:

  bpf_spin_lock(&glock)               irqsave_flags = on
  bpf_list_add(&ghead, foo, prev)     prev is not in the list
    bpf_list_head_free(&foo->head)
      __bpf_spin_lock_irqsave()       irqsave_flags = off
  bpf_spin_unlock(&glock)             restores off

The program returns with irqs off.

Keep the flags of the two functions in a local variable, and take the lock
with __bpf_spin_lock(). Both functions unlock before they drop the nodes,
so nothing else runs between the save and the restore.

A failed add drops the node since the commit below. Until bpf_list_add()
existed, an add failed only for a node that a list or a tree still owned,
with a reference of its own, so the drop freed the node only in a race
with the release of that reference. bpf_list_add() fails for any node when
@prev is not in the list.

Fixes: d2dcc67df910 ("bpf: Migrate bpf_rbtree_add and bpf_list_push_{front,back} to possibly fail")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://patch.msgid.link/178849392dfb8ddf82d7ba4259be6113349bdc2e.1795550092.git.memxor@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/bpf/helpers.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index 4614442745afd..af00019b53880 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -2077,6 +2077,7 @@ void bpf_list_head_free(const struct btf_field *field, void *list_head,
 			struct bpf_spin_lock *spin_lock)
 {
 	struct list_head *head = list_head, drain, *pos, *n;
+	unsigned long flags;
 
 	BUILD_BUG_ON(sizeof(struct list_head) > sizeof(struct bpf_list_head));
 	BUILD_BUG_ON(__alignof__(struct list_head) > __alignof__(struct bpf_list_head));
@@ -2088,7 +2089,8 @@ void bpf_list_head_free(const struct btf_field *field, void *list_head,
 	 * section, and end up doing map ops that call bpf_list_head_free for
 	 * the same map value again.
 	 */
-	__bpf_spin_lock_irqsave(spin_lock);
+	local_irq_save(flags);
+	__bpf_spin_lock(spin_lock);
 	if (!head->next || list_empty(head))
 		goto unlock;
 	list_for_each_safe(pos, n, head) {
@@ -2100,7 +2102,8 @@ void bpf_list_head_free(const struct btf_field *field, void *list_head,
 	}
 unlock:
 	INIT_LIST_HEAD(head);
-	__bpf_spin_unlock_irqrestore(spin_lock);
+	__bpf_spin_unlock(spin_lock);
+	local_irq_restore(flags);
 
 	while (!list_empty(&drain)) {
 		struct bpf_list_node_kern *node;
@@ -2137,19 +2140,22 @@ void bpf_rb_root_free(const struct btf_field *field, void *rb_root,
 	struct rb_root_cached orig_root, *root = rb_root;
 	struct bpf_rb_node_kern *node;
 	struct rb_node *pos, *n;
+	unsigned long flags;
 	void *obj;
 
 	BUILD_BUG_ON(sizeof(struct rb_root_cached) > sizeof(struct bpf_rb_root));
 	BUILD_BUG_ON(__alignof__(struct rb_root_cached) > __alignof__(struct bpf_rb_root));
 
-	__bpf_spin_lock_irqsave(spin_lock);
+	local_irq_save(flags);
+	__bpf_spin_lock(spin_lock);
 	orig_root = *root;
 	bpf_rbtree_postorder_for_each_entry_safe(pos, n, &orig_root.rb_root) {
 		node = rb_entry(pos, struct bpf_rb_node_kern, rb_node);
 		WRITE_ONCE(node->owner, BPF_PTR_POISON);
 	}
 	*root = RB_ROOT_CACHED;
-	__bpf_spin_unlock_irqrestore(spin_lock);
+	__bpf_spin_unlock(spin_lock);
+	local_irq_restore(flags);
 
 	bpf_rbtree_postorder_for_each_entry_safe(pos, n, &orig_root.rb_root) {
 		obj = pos;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 290/555] net: dsa: felix: fix NULL pointer dereference in felix_port_enable()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (288 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 289/555] bpf: Save irq flags on the stack when freeing a list head or rb root Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 291/555] ipv6: mcast: do not pass uninitialized bytes to dev_mc_add() Greg Kroah-Hartman
                   ` (264 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Aristo Chen, Vladimir Oltean,
	Paolo Abeni, Sasha Levin

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

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

From: Aristo Chen <aristo.chen@canonical.com>

[ Upstream commit 469b61e4be88bc671dabe802e11f706b1ea7aa15 ]

DSA registers the user ports in dsa_tree_setup_ports() before it sets
conduit->dsa_ptr in dsa_tree_setup_conduit(). On teardown, it clears
conduit->dsa_ptr in dsa_tree_teardown_conduit() before
dsa_tree_teardown_ports() removes the user ports. RTNL is not held
across either pair of steps, so user space can open a user port while
conduit->dsa_ptr is NULL.

In NPI mode, felix_port_enable() calls felix_cpu_port_for_conduit().
For a physical conduit, that function reads the CPU port index through
conduit->dsa_ptr without checking for NULL. This caused an oops on an
LS1028A RDB when systemd-networkd tried to open a user port while the
switch was being probed again at runtime:

  [  166.722423] Unable to handle kernel access to user memory outside uaccess routines at virtual address 0000000000000028
  [  166.816908] Internal error: Oops: 0000000096000004 [#1]  SMP
  [  166.961766] pc : felix_cpu_port_for_conduit.isra.0+0x90/0xb8 [mscc_felix_dsa_lib]
  [  166.969289] lr : felix_port_enable+0x120/0x1a0 [mscc_felix_dsa_lib]

The oops left RTNL locked. Later operations that waited for RTNL hung,
and the board had to be power cycled.

NPI mode uses one CPU port for the whole switch. Changing the conduit
of a user port can move the NPI port to another CPU port, and the check
in felix_port_enable() keeps user ports that still use the old CPU port
down.

For a physical conduit, compare dp->cpu_dp->index with the NPI port
instead. DSA sets dp->cpu_dp before it registers the user port and
clears it only after it removes the user port, so the check keeps
working while conduit->dsa_ptr is NULL. As long as the physical
conduit is set up, conduit->dsa_ptr and dp->cpu_dp point to the same
CPU port, so the check gives the same result as before. LAG conduits
keep using felix_cpu_port_for_conduit(), which does not read dsa_ptr
for them.

Fixes: eca70102cfb1 ("net: dsa: felix: add support for changing DSA master")
Signed-off-by: Aristo Chen <aristo.chen@canonical.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://patch.msgid.link/20261119100710.129379-1-aristo.chen@canonical.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/dsa/ocelot/felix.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
index 72fb6594331e9..e43b0862d701b 100644
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -1239,8 +1239,19 @@ static int felix_port_enable(struct dsa_switch *ds, int port,
 
 	if (ocelot->npi >= 0) {
 		struct net_device *conduit = dsa_port_to_conduit(dp);
+		int cpu;
 
-		if (felix_cpu_port_for_conduit(ds, conduit) != ocelot->npi) {
+		/* Do not use conduit->dsa_ptr for a physical conduit. It is
+		 * NULL before DSA sets up the conduit and after it tears it
+		 * down, and opening a user port can reach this check in both
+		 * cases.
+		 */
+		if (netif_is_lag_master(conduit))
+			cpu = felix_cpu_port_for_conduit(ds, conduit);
+		else
+			cpu = dp->cpu_dp->index;
+
+		if (cpu != ocelot->npi) {
 			dev_err(ds->dev, "Multiple conduits are not allowed\n");
 			return -EINVAL;
 		}
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 291/555] ipv6: mcast: do not pass uninitialized bytes to dev_mc_add()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (289 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 290/555] net: dsa: felix: fix NULL pointer dereference in felix_port_enable() Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 292/555] tcp: Dont clear saddr before ->put_port() Greg Kroah-Hartman
                   ` (263 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Kuniyuki Iwashima, Eric Dumazet,
	Hangbin Liu, Ido Schimmel, Willem de Bruijn, Sasha Levin

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

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

From: Eric Dumazet <edumazet@kernel.org>

[ Upstream commit 58f419bfa4c3a6797246a7c4e53a535ee34372ae ]

igmp6_group_added() and igmp6_group_dropped() build a link-layer
multicast address in an on-stack buffer with ndisc_mc_map(), which
fills a number of bytes depending on dev->type.

dev_mc_add() and dev_mc_del() then use dev->addr_len bytes of it.

Since IPv6 multicast joins and leaves no longer hold RTNL, dev->type
and dev->addr_len can change between the two steps, for instance with
TUNSETLINK, or when bonding or team change their type.

If addr_len grows (eg ARPHRD_ETHER -> ARPHRD_IP6GRE), dev_mc_add()
copies uninitialized stack bytes into a netdev_hw_addr, which can
later be dumped to user space by /proc/net/dev_mcast and
RTM_GETMULTICAST.

Zero the buffers.

Found by Sashiko AI review of a tun patch, by code inspection only.
Kernels built with CONFIG_INIT_STACK_ALL_ZERO=y are not affected.

Fixes: 1767bb2d47b7 ("ipv6: mcast: Don't hold RTNL for IPV6_ADD_MEMBERSHIP and MCAST_JOIN_GROUP.")
Link: https://lore.kernel.org/netdev/179512665919.3136.5931555157250030152@kernel.org/
Cc: Kuniyuki Iwashima <kuniyu@google.com>
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20261123124458.205233-1-edumazet@kernel.org
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/ipv6/mcast.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 9326dd3976bf8..4ad504fa71c3d 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -713,7 +713,10 @@ bool inet6_mc_check(const struct sock *sk, const struct in6_addr *mc_addr,
 static void igmp6_group_added(struct ifmcaddr6 *mc)
 {
 	struct net_device *dev = mc->idev->dev;
-	char buf[MAX_ADDR_LEN];
+	/* RTNL might not be held: dev->type and dev->addr_len can change.
+	 * Make sure dev_mc_{add|del}() do not use uninitialized bytes.
+	 */
+	char buf[MAX_ADDR_LEN] = {};
 
 	mc_assert_locked(mc->idev);
 
@@ -749,7 +752,10 @@ static void igmp6_group_added(struct ifmcaddr6 *mc)
 static void igmp6_group_dropped(struct ifmcaddr6 *mc)
 {
 	struct net_device *dev = mc->idev->dev;
-	char buf[MAX_ADDR_LEN];
+	/* RTNL might not be held: dev->type and dev->addr_len can change.
+	 * Make sure dev_mc_{add|del}() do not use uninitialized bytes.
+	 */
+	char buf[MAX_ADDR_LEN] = {};
 
 	mc_assert_locked(mc->idev);
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 292/555] tcp: Dont clear saddr before ->put_port().
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (290 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 291/555] ipv6: mcast: do not pass uninitialized bytes to dev_mc_add() Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 293/555] bpf: Do not allow bpf_d_path() by an id of another BTF Greg Kroah-Hartman
                   ` (262 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Kuniyuki Iwashima, Eric Dumazet,
	Willem de Bruijn, Sasha Levin

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

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

From: Kuniyuki Iwashima <kuniyu@google.com>

[ Upstream commit 1ab3fb564f20b78615a6d88b8c90da292f29e227 ]

When CGROUP_INET4_POST_BIND or CGROUP_INET6_POST_BIND prog fails,
__inet_bind() / __inet6_bind() calls sk->sk_prot->put_port().

For TCP, __inet_put_port() calls inet_bhashfn_portaddr() to get
the corresponding bhash2 bucket.

inet_bhashfn_portaddr() requires saddr, but it is cleared before
__inet_put_port(), leading to bhash2 lock mismatch.

This triggers list corruption or use-after-free by a conccurent
thread touching the same bhash2 bucket, e.g. tcp_diag_dump()
with TCPF_BOUND_INACTIVE. [0]

Let's clear saddr after calling sk->sk_prot->put_port().

[0]:
BUG: KASAN: slab-use-after-free in tcp_diag_dump (net/ipv4/tcp_diag.c:415)
Read of size 8 at addr ffff88810ae0e7a0 by task a/1007

CPU: 10 UID: 0 PID: 1007 Comm: a Not tainted 7.4.0-rc3-00456-gd5b89d55a322 #295 PREEMPT(lazy)
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-debian-1.17.0-1 04/01/2014
Call Trace:
 <TASK>
 dump_stack_lvl (lib/dump_stack.c:120)
 print_address_description (mm/kasan/report.c:378)
 print_report (mm/kasan/report.c:482)
 kasan_report (mm/kasan/report.c:595)
 sock_recvmsg (net/socket.c:1154)
 __sys_recvfrom (net/socket.c:2333)
 __x64_sys_recvfrom (net/socket.c:2348 net/socket.c:2344 net/socket.c:2344)
 do_syscall_64 (arch/x86/entry/syscall_64.c:61 arch/x86/entry/syscall_64.c:89)
 entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
RIP: 0033:0x7f2f268f8e92
Code: 08 0f 85 91 41 ff ff 49 89 fb 48 89 f0 48 89 d7 48 89 ce 4c 89 c2 4d 89 ca 4c 8b 44 24 08 4c 8b 4c 24 10 4c 89 5c 24 08 0f 05 <c3> 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 f3 0f 1e fa 55 bf 01 00
RSP: 002b:00007f2f26874d28 EFLAGS: 00000246 ORIG_RAX: 000000000000002d
RAX: ffffffffffffffda RBX: 00007f2f26879ce4 RCX: 00007f2f268f8e92
RDX: 0000000000004000 RSI: 00007f2f26874db0 RDI: 00000000000007d7
RBP: 00007f2f26874d50 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000021
R13: 00007ffcbb216e70 R14: 0000000000000000 R15: 00007ffcbb216f77
 </TASK>

Allocated by task 1009:
 kasan_save_track (mm/kasan/common.c:57 mm/kasan/common.c:79)
 __kasan_slab_alloc (mm/kasan/common.c:354 mm/kasan/common.c:380)
 kmem_cache_alloc_noprof (./include/linux/kasan.h:257 mm/slub.c:4720 mm/slub.c:5033 mm/slub.c:5047)
 inet_bind2_bucket_create (net/ipv4/inet_hashtables.c:162)
 inet_csk_get_port (net/ipv4/inet_connection_sock.c:573)
 __inet_bind (net/ipv4/af_inet.c:544)
 inet_bind_sk (net/ipv4/af_inet.c:470)
 __sys_bind (net/socket.c:1947 net/socket.c:1978)
 __x64_sys_bind (net/socket.c:1983 net/socket.c:1981 net/socket.c:1981)
 do_syscall_64 (arch/x86/entry/syscall_64.c:61 arch/x86/entry/syscall_64.c:89)
 entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)

Freed by task 1009:
 kasan_save_track (mm/kasan/common.c:57 mm/kasan/common.c:79)
 kasan_save_free_info (mm/kasan/generic.c:599)
 __kasan_slab_free (mm/kasan/common.c:267 mm/kasan/common.c:299)
 kmem_cache_free (./include/linux/kasan.h:239 mm/slub.c:2780 mm/slub.c:6637 mm/slub.c:6764)
 inet_put_port (net/ipv4/inet_hashtables.c:178)
 __inet_bind (net/ipv4/af_inet.c:554)
 inet_bind_sk (net/ipv4/af_inet.c:470)
 __sys_bind (net/socket.c:1947 net/socket.c:1978)
 __x64_sys_bind (net/socket.c:1983 net/socket.c:1981 net/socket.c:1981)
 do_syscall_64 (arch/x86/entry/syscall_64.c:61 arch/x86/entry/syscall_64.c:89)
 entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)

The buggy address belongs to the object at ffff88810ae0e780
 which belongs to the cache tcp_bind2_bucket of size 80

Fixes: 28044fc1d495 ("net: Add a bhash2 table hashed by port and address")
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Link: https://patch.msgid.link/20261121203537.341320-1-kuniyu@google.com
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/ipv4/af_inet.c  | 2 +-
 net/ipv6/af_inet6.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index b61d07620c1fd..7d092f2d01079 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -541,9 +541,9 @@ int __inet_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len,
 		if (!(flags & BIND_FROM_BPF)) {
 			err = BPF_CGROUP_RUN_PROG_INET4_POST_BIND(sk);
 			if (err) {
-				inet->inet_saddr = inet->inet_rcv_saddr = 0;
 				if (sk->sk_prot->put_port)
 					sk->sk_prot->put_port(sk);
+				inet->inet_saddr = inet->inet_rcv_saddr = 0;
 				goto out_release_sock;
 			}
 		}
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 3b701dbb4691d..c578d50a5befb 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -413,10 +413,10 @@ static int __inet6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len,
 		if (!(flags & BIND_FROM_BPF)) {
 			err = BPF_CGROUP_RUN_PROG_INET6_POST_BIND(sk);
 			if (err) {
-				sk->sk_ipv6only = saved_ipv6only;
-				inet_reset_saddr(sk);
 				if (sk->sk_prot->put_port)
 					sk->sk_prot->put_port(sk);
+				sk->sk_ipv6only = saved_ipv6only;
+				inet_reset_saddr(sk);
 				goto out;
 			}
 		}
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 293/555] bpf: Do not allow bpf_d_path() by an id of another BTF
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (291 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 292/555] tcp: Dont clear saddr before ->put_port() Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 294/555] bpf: Keep the names in front of a number in delegate options Greg Kroah-Hartman
                   ` (261 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin

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

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

From: Alexei Starovoitov <ast@kernel.org>

[ Upstream commit 1139c7d8ffcd941d4860a75ef37eb1ffd15b4f87 ]

For a program that is attached to a program attach_btf_id is an id in
the BTF of the target. bpf_d_path_allowed() looks for it in a list of
kernel functions, it can match by chance. Do not look at the list when
there is a target program.

Fixes: 6e22ab9da793 ("bpf: Add d_path helper")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-5-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/trace/bpf_trace.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index a174d4b27d662..068c2446bed3a 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -954,6 +954,10 @@ BTF_SET_END(btf_allowlist_d_path)
 
 static bool bpf_d_path_allowed(const struct bpf_prog *prog)
 {
+	/* attach_btf_id is a function of the target program */
+	if (prog->aux->dst_prog)
+		return false;
+
 	if (prog->type == BPF_PROG_TYPE_TRACING &&
 	    prog->expected_attach_type == BPF_TRACE_ITER)
 		return true;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 294/555] bpf: Keep the names in front of a number in delegate options
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (292 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 293/555] bpf: Do not allow bpf_d_path() by an id of another BTF Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 295/555] bpf: Add the symbol of a prog before its id Greg Kroah-Hartman
                   ` (260 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin

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

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

From: Alexei Starovoitov <ast@kernel.org>

[ Upstream commit 4151f3558d6e65d4ae6cf1a431537ed52ad48239 ]

The delegate_* mount options of bpffs take names and numbers. A number
overwrites the mask, the names in front of it are lost. That is the
order in which /proc/mounts shows them.

Fixes: 6c1752e0b6ca ("bpf: Support symbolic BPF FS delegation mount options")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-11-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/bpf/inode.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index 57c2c31969997..2d625071f1ee3 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -888,7 +888,7 @@ static int bpf_parse_param(struct fs_context *fc, struct fs_parameter *param)
 		struct bpffs_btf_enums info;
 		const struct btf_type *enum_t;
 		const char *enum_pfx;
-		u64 *delegate_msk, msk = 0;
+		u64 *delegate_msk, msk = 0, num;
 		char *p, *str;
 		int val;
 
@@ -927,9 +927,10 @@ static int bpf_parse_param(struct fs_context *fc, struct fs_parameter *param)
 			} else if (find_btf_enum_const(info.btf, enum_t, enum_pfx, p, &val)) {
 				msk |= 1ULL << val;
 			} else {
-				err = kstrtou64(p, 0, &msk);
+				err = kstrtou64(p, 0, &num);
 				if (err)
 					return err;
+				msk |= num;
 			}
 		}
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 295/555] bpf: Add the symbol of a prog before its id
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (293 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 294/555] bpf: Keep the names in front of a number in delegate options Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 296/555] bpf: Do not fill jited line info for a hidden subprog Greg Kroah-Hartman
                   ` (259 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin

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

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

From: Alexei Starovoitov <ast@kernel.org>

[ Upstream commit f7a40c2de8d4abdea6d1e21122b447b593e28bd9 ]

A prog can be taken by its id and run before bpf_prog_kallsyms_add().
bpf_throw() does not find the main prog and oopses:

  KASAN: null-ptr-deref in range [0x0000000000000568-0x000000000000056f]
  RIP: 0010:bpf_throw+0x129/0x220

The exception table is found by the same symbol.

Add the symbol first. bpf_prog_free() removes it when there is no id.

Fixes: 3dec541b2e63 ("bpf: Add support for BTF pointers to x86 JIT")
Fixes: f18b03fabaa9 ("bpf: Implement BPF exceptions")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-15-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/bpf/syscall.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 2626189f746ba..6657e4fbd8bb3 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -2854,6 +2854,9 @@ static int bpf_prog_load(union bpf_attr *attr, bpfptr_t uattr, u32 uattr_size)
 	if (err < 0)
 		goto free_used_maps;
 
+	/* bpf_throw() and faults look for the symbol. The prog can run once it has the id. */
+	bpf_prog_kallsyms_add(prog);
+
 	err = bpf_prog_alloc_id(prog);
 	if (err)
 		goto free_used_maps;
@@ -2872,7 +2875,6 @@ static int bpf_prog_load(union bpf_attr *attr, bpfptr_t uattr, u32 uattr_size)
 	 * Also, any failure handling from this point onwards must
 	 * be using bpf_prog_put() given the program is exposed.
 	 */
-	bpf_prog_kallsyms_add(prog);
 	perf_event_bpf_event(prog, PERF_BPF_EVENT_PROG_LOAD, 0);
 	bpf_audit_prog(prog, BPF_AUDIT_LOAD);
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 296/555] bpf: Do not fill jited line info for a hidden subprog
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (294 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 295/555] bpf: Add the symbol of a prog before its id Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 297/555] bpf: Fix NULL dereference in XDP redirect from async callbacks Greg Kroah-Hartman
                   ` (258 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin

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

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

From: Alexei Starovoitov <ast@kernel.org>

[ Upstream commit 2f2b119ea30dfba27563c1c939eb42b5298a391a ]

func_idx of the default exception callback is func_cnt, and the test
for hidden subprogs is off by one. The address of the callback goes to
jited_linfo[0]. libbpf and bpftool refuse the jited line info of the
prog.

Fixes: 335d1c5b5452 ("bpf: Implement support for adding hidden subprogs")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-16-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/bpf/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index f94524481f27b..c6b2b43b843cb 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -226,7 +226,8 @@ void bpf_prog_fill_jited_linfo(struct bpf_prog *prog,
 	const struct bpf_line_info *linfo;
 	void **jited_linfo;
 
-	if (!prog->aux->jited_linfo || prog->aux->func_idx > prog->aux->func_cnt)
+	if (!prog->aux->jited_linfo ||
+	    (prog->aux->func_idx && prog->aux->func_idx >= prog->aux->func_cnt))
 		/* Userspace did not provide linfo */
 		return;
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 297/555] bpf: Fix NULL dereference in XDP redirect from async callbacks
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (295 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 296/555] bpf: Do not fill jited line info for a hidden subprog Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 298/555] bpf: Fix reads past an enum in prints of BTF data Greg Kroah-Hartman
                   ` (257 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin

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

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

From: Alexei Starovoitov <ast@kernel.org>

[ Upstream commit f28ed533106bc01aedba6ba47c0e1a1098c92092 ]

bpf_redirect() and bpf_redirect_map() do not take the context, so the
timer callback of an XDP program can call them. There is no
current->bpf_net_context then:

  KASAN: null-ptr-deref in range [0x0000000000000038-0x000000000000003f]
  RIP: 0010:bpf_xdp_redirect+0x5b/0x170

Return XDP_ABORTED, like the tc helpers return TC_ACT_SHOT. It is one
more test and branch on a value that is loaded anyway.

Fixes: 401cb7dae813 ("net: Reference bpf_redirect_info via task_struct on PREEMPT_RT.")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-17-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/linux/filter.h | 5 +++--
 net/core/filter.c      | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/linux/filter.h b/include/linux/filter.h
index b88a213bcbbe1..8aeb073792c39 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -1740,13 +1740,14 @@ static __always_inline long __bpf_xdp_redirect_map(struct bpf_map *map, u64 inde
 						   u64 flags, const u64 flag_mask,
 						   void *lookup_elem(struct bpf_map *map, u32 key))
 {
-	struct bpf_redirect_info *ri = bpf_net_ctx_get_ri();
 	const u64 action_mask = XDP_ABORTED | XDP_DROP | XDP_PASS | XDP_TX;
+	struct bpf_redirect_info *ri;
 
 	/* Lower bits of the flags are used as return code on lookup failure */
-	if (unlikely(flags & ~(action_mask | flag_mask)))
+	if (unlikely(!bpf_net_ctx_get() || flags & ~(action_mask | flag_mask)))
 		return XDP_ABORTED;
 
+	ri = bpf_net_ctx_get_ri();
 	ri->tgt_value = lookup_elem(map, index);
 	if (unlikely(!ri->tgt_value) && !(flags & BPF_F_BROADCAST)) {
 		/* If the lookup fails we want to clear out the state in the
diff --git a/net/core/filter.c b/net/core/filter.c
index 22ea8540f3114..3d75bd7137477 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -4742,11 +4742,12 @@ int xdp_do_generic_redirect(struct net_device *dev, struct sk_buff *skb,
 
 BPF_CALL_2(bpf_xdp_redirect, u32, ifindex, u64, flags)
 {
-	struct bpf_redirect_info *ri = bpf_net_ctx_get_ri();
+	struct bpf_redirect_info *ri;
 
-	if (unlikely(flags))
+	if (unlikely(!bpf_net_ctx_get() || flags))
 		return XDP_ABORTED;
 
+	ri = bpf_net_ctx_get_ri();
 	/* NB! Map type UNSPEC and map_id == INT_MAX (never generated
 	 * by map_idr) is used for ifindex based XDP redirect.
 	 */
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 298/555] bpf: Fix reads past an enum in prints of BTF data
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (296 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 297/555] bpf: Fix NULL dereference in XDP redirect from async callbacks Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 299/555] bpf: Give syscall programs without CAP_PERFMON the base helpers only Greg Kroah-Hartman
                   ` (256 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin

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

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

From: Alexei Starovoitov <ast@kernel.org>

[ Upstream commit 6c8d5a113c2341a9fc12a6550c0645d5cda0d56d ]

An enum has 1, 2, 4 or 8 bytes. It's read as int, enum64 as u64,
whatever the size is. The file of a map in bpffs shows what is behind
a key or a value that ends with a short enum.

Read as many bytes as the type has. The check of a member of a struct
with bitfields takes any enum for 4 bytes, so an enum of 8 bytes can
stick out of it. Use the size there too.

Short enums are printed by their names. BTF with an enum that sticks
out of its struct is refused, compilers don't make it.

Fixes: 9eea98497951 ("bpf: fix BTF verification of enums")
Fixes: 6089fb325cf7 ("bpf: Add btf enum64 support")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-24-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/bpf/btf.c | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index e152b4d9113f8..12354e9a66456 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -4317,7 +4317,7 @@ static int btf_enum_check_kflag_member(struct btf_verifier_env *env,
 			return -EINVAL;
 		}
 
-		nr_bits = int_bitsize;
+		nr_bits = member_type->size * BITS_PER_BYTE;
 	} else if (nr_bits > int_bitsize) {
 		btf_verifier_log_member(env, struct_type, member,
 					"Invalid member bitfield_size");
@@ -4400,12 +4400,30 @@ static void btf_enum_log(struct btf_verifier_env *env,
 	btf_verifier_log(env, "size=%u vlen=%u", t->size, btf_type_vlen(t));
 }
 
+static s64 btf_enum_read(const struct btf_type *t, const void *data)
+{
+	bool sign = btf_type_kflag(t);
+
+	switch (t->size) {
+	case 1:
+		return sign ? *(s8 *)data : *(u8 *)data;
+	case 2:
+		return sign ? *(s16 *)data : *(u16 *)data;
+	case 4:
+		return sign ? (s64)*(s32 *)data : *(u32 *)data;
+	default:
+		return *(s64 *)data;
+	}
+}
+
 static void btf_enum_show(const struct btf *btf, const struct btf_type *t,
 			  u32 type_id, void *data, u8 bits_offset,
 			  struct btf_show *show)
 {
 	const struct btf_enum *enums = btf_type_enum(t);
 	u32 i, nr_enums = btf_type_vlen(t);
+	/* Old compilers don't set the flag for negative values */
+	u32 mask = t->size < 4 ? BIT(t->size * BITS_PER_BYTE) - 1 : U32_MAX;
 	void *safe_data;
 	int v;
 
@@ -4413,10 +4431,10 @@ static void btf_enum_show(const struct btf *btf, const struct btf_type *t,
 	if (!safe_data)
 		return;
 
-	v = *(int *)safe_data;
+	v = btf_enum_read(t, safe_data);
 
 	for (i = 0; i < nr_enums; i++) {
-		if (v != enums[i].val)
+		if ((v ^ enums[i].val) & mask)
 			continue;
 
 		btf_show_type_value(show, "%s",
@@ -4516,7 +4534,7 @@ static void btf_enum64_show(const struct btf *btf, const struct btf_type *t,
 	if (!safe_data)
 		return;
 
-	v = *(u64 *)safe_data;
+	v = btf_enum_read(t, safe_data);
 
 	for (i = 0; i < nr_enums; i++) {
 		if (v != btf_enum64_value(enums + i))
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 299/555] bpf: Give syscall programs without CAP_PERFMON the base helpers only
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (297 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 298/555] bpf: Fix reads past an enum in prints of BTF data Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 300/555] bpf: dont skip other information if xlated_prog_insns is skipped Greg Kroah-Hartman
                   ` (255 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin

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

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

From: Alexei Starovoitov <ast@kernel.org>

[ Upstream commit 2ff55b023f637d61a56a893b0a3eb534acfb2ffd ]

A syscall program needs CAP_BPF only, and it gets all helpers of tracing
programs. These don't ask for CAP_PERFMON, the load of a tracing program
does.

The helpers for loader programs take current for the loader. It's
another task in a callback. bpf_kallsyms_lookup_name() answers in a
callback of bpf_wq, as a kworker has all capabilities. bpf_sys_close()
in a task work closes a file of any process.

Give the program the base helpers. It loses bpf_perf_event_output() too.
Loader programs are not affected, bpf_sys_bpf() needs CAP_PERFMON
already.

Fixes: 79a7f8bdb159 ("bpf: Introduce bpf_sys_bpf() helper and program type.")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-26-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/bpf/syscall.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 6657e4fbd8bb3..f7a06b3179c57 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -6098,10 +6098,12 @@ static const struct bpf_func_proto bpf_kallsyms_lookup_name_proto = {
 static const struct bpf_func_proto *
 syscall_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
 {
+	if (!bpf_token_capable(prog->aux->token, CAP_PERFMON))
+		return bpf_base_func_proto(func_id, prog);
+
 	switch (func_id) {
 	case BPF_FUNC_sys_bpf:
-		return !bpf_token_capable(prog->aux->token, CAP_PERFMON)
-		       ? NULL : &bpf_sys_bpf_proto;
+		return &bpf_sys_bpf_proto;
 	case BPF_FUNC_btf_find_by_name_kind:
 		return &bpf_btf_find_by_name_kind_proto;
 	case BPF_FUNC_sys_close:
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 300/555] bpf: dont skip other information if xlated_prog_insns is skipped
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (298 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 299/555] bpf: Give syscall programs without CAP_PERFMON the base helpers only Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 301/555] bpf: Require CAP_PERFMON for dumps of xlated insns Greg Kroah-Hartman
                   ` (254 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Max Altgelt, Alexei Starovoitov,
	Sasha Levin

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

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

From: Altgelt, Max (Nextron) <max.altgelt@nextron-systems.com>

[ Upstream commit 4722981cca373a338bbcf3a93ecf7144a892b03b ]

If xlated_prog_insns should not be exposed, other information
(such as func_info) still can and should be filled in.
Therefore, instead of directly terminating in this case,
continue with the normal flow.

Signed-off-by: Max Altgelt <max.altgelt@nextron-systems.com>
Link: https://lore.kernel.org/r/efd00fcec5e3e247af551632726e2a90c105fbd8.camel@nextron-systems.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Stable-dep-of: b8aa487429d4 ("bpf: Require CAP_PERFMON for dumps of xlated insns")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/bpf/syscall.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index f7a06b3179c57..dbc2646e96a14 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -4795,19 +4795,19 @@ static int bpf_prog_get_info_by_fd(struct file *file,
 		struct bpf_insn *insns_sanitized;
 		bool fault;
 
-		if (prog->blinded && !bpf_dump_raw_ok(file->f_cred)) {
+		if (!prog->blinded || bpf_dump_raw_ok(file->f_cred)) {
+			insns_sanitized = bpf_insn_prepare_dump(prog, file->f_cred);
+			if (!insns_sanitized)
+				return -ENOMEM;
+			uinsns = u64_to_user_ptr(info.xlated_prog_insns);
+			ulen = min_t(u32, info.xlated_prog_len, ulen);
+			fault = copy_to_user(uinsns, insns_sanitized, ulen);
+			kfree(insns_sanitized);
+			if (fault)
+				return -EFAULT;
+		} else {
 			info.xlated_prog_insns = 0;
-			goto done;
 		}
-		insns_sanitized = bpf_insn_prepare_dump(prog, file->f_cred);
-		if (!insns_sanitized)
-			return -ENOMEM;
-		uinsns = u64_to_user_ptr(info.xlated_prog_insns);
-		ulen = min_t(u32, info.xlated_prog_len, ulen);
-		fault = copy_to_user(uinsns, insns_sanitized, ulen);
-		kfree(insns_sanitized);
-		if (fault)
-			return -EFAULT;
 	}
 
 	if (bpf_prog_is_offloaded(prog->aux)) {
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 301/555] bpf: Require CAP_PERFMON for dumps of xlated insns
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (299 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 300/555] bpf: dont skip other information if xlated_prog_insns is skipped Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 302/555] bpf: Zero bpf_list_head in copies of map values Greg Kroah-Hartman
                   ` (253 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin

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

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

From: Alexei Starovoitov <ast@kernel.org>

[ Upstream commit b8aa487429d46a72881933c026a6ca2a8e72d6d2 ]

The verifier puts addresses of the kernel to insns: for ksyms, inlined
helpers and hidden arguments. The dump of xlated insns hides the ones of
maps and calls only, the others look like constants by then. Give no
dump, as for a blinded program, to who has no CAP_PERFMON and can't read
kallsyms.

Fixes: 2c78ee898d8f ("bpf: Implement CAP_BPF")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-30-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/bpf/syscall.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index dbc2646e96a14..a844f01f27760 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -4795,7 +4795,8 @@ static int bpf_prog_get_info_by_fd(struct file *file,
 		struct bpf_insn *insns_sanitized;
 		bool fault;
 
-		if (!prog->blinded || bpf_dump_raw_ok(file->f_cred)) {
+		/* The verifier puts addresses to ld_imm64 and mov insns */
+		if (bpf_dump_raw_ok(file->f_cred) || (!prog->blinded && perfmon_capable())) {
 			insns_sanitized = bpf_insn_prepare_dump(prog, file->f_cred);
 			if (!insns_sanitized)
 				return -ENOMEM;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 302/555] bpf: Zero bpf_list_head in copies of map values
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (300 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 301/555] bpf: Require CAP_PERFMON for dumps of xlated insns Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 303/555] bpf: Clear the data that bpf_msg_push_data() adds Greg Kroah-Hartman
                   ` (252 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin

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

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

From: Alexei Starovoitov <ast@kernel.org>

[ Upstream commit 8252c3517f95f02a8569480563a773e0462dce52 ]

Lookups from user space copy the value to a buffer and init special
fields there. An empty list_head points to itself. The caller gets the
address of the buffer.

Fill the fields with zeros. It's what a new element of a map has.
bpf_refcount in a value reads as 0.

Fixes: 3e81740a9062 ("bpf: Centralize btf_field-specific initialization logic")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-31-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/linux/bpf.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index c8d8663b63915..9e8d82248cf56 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -471,7 +471,14 @@ static inline void bpf_obj_init(const struct btf_record *rec, void *obj)
  */
 static inline void check_and_init_map_value(struct bpf_map *map, void *dst)
 {
-	bpf_obj_init(map->record, dst);
+	const struct btf_record *rec = map->record;
+	int i;
+
+	if (IS_ERR_OR_NULL(rec))
+		return;
+	/* Not bpf_obj_init(): an empty list_head has the address of 'dst' */
+	for (i = 0; i < rec->cnt; i++)
+		memset(dst + rec->fields[i].offset, 0, rec->fields[i].size);
 }
 
 /* memcpy that is used with 8-byte aligned pointers, power-of-8 size and
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 303/555] bpf: Clear the data that bpf_msg_push_data() adds
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (301 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 302/555] bpf: Zero bpf_list_head in copies of map values Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 304/555] bpf: Fail loads from a network header that was not set Greg Kroah-Hartman
                   ` (251 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin

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

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

From: Alexei Starovoitov <ast@kernel.org>

[ Upstream commit 401fce9f48b1d684b92dbc08389d7c20bd036280 ]

The helper puts a new page into the message as the allocator gave it.
Bytes that the program does not write can be read by it, and are sent
to the peer. Allocate zeroed memory.

Fixes: 6fff607e2f14 ("bpf: sk_msg program helper bpf_msg_push_data")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-39-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/core/filter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/filter.c b/net/core/filter.c
index 3d75bd7137477..659b8e64591c1 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2875,7 +2875,7 @@ BPF_CALL_4(bpf_msg_push_data, struct sk_msg *, msg, u32, start,
 	if (unlikely(copy + len < copy))
 		return -EINVAL;
 
-	page = alloc_pages(__GFP_NOWARN | GFP_ATOMIC | __GFP_COMP,
+	page = alloc_pages(__GFP_NOWARN | GFP_ATOMIC | __GFP_COMP | __GFP_ZERO,
 			   get_order(copy + len));
 	if (unlikely(!page))
 		return -ENOMEM;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 304/555] bpf: Fail loads from a network header that was not set
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (302 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 303/555] bpf: Clear the data that bpf_msg_push_data() adds Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 305/555] bpf: Clear family and port of a short address for cgroup sockaddr hooks Greg Kroah-Hartman
                   ` (250 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin

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

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

From: Alexei Starovoitov <ast@kernel.org>

[ Upstream commit 766907cdaeefb57faddc5d09a49bdd4ce20a6272 ]

skb->network_header is 0 until something sets it. Loads at SKF_NET_OFF
and bpf_skb_load_bytes_relative() start at skb->head then, and read
headroom that nobody has written. qrtr and AF_XDP in copy mode make such
skbs.

Fail the load, like for the MAC header. A network header at skb->head
counts as set when skb->data or the MAC header is there too. CAN and
6LoWPAN make such skbs.

Fixes: 2e07fa9cd3ba ("[SK_BUFF]: Use offsets for skb->{mac,network,transport}_header on 64bit architectures")
Fixes: 0f5d82f187e1 ("net/filter: Permit reading NET in load_bytes_relative when MAC not set")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-40-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/linux/filter.h | 9 +++++++++
 kernel/bpf/core.c      | 2 ++
 net/core/filter.c      | 5 ++++-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/include/linux/filter.h b/include/linux/filter.h
index 8aeb073792c39..87fcbb14c8fa0 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -925,6 +925,15 @@ static inline void bpf_restore_data_end(
 	cb->data_end = saved_data_end;
 }
 
+/*
+ * If nothing has set the header, it points to headroom that was not written.
+ * The packet starts at skb->head when skb->data or the MAC header is there.
+ */
+static inline bool bpf_skb_has_network_header(const struct sk_buff *skb)
+{
+	return skb->network_header || !skb->mac_header || !skb_headroom(skb);
+}
+
 static inline u8 *bpf_skb_cb(const struct sk_buff *skb)
 {
 	/* eBPF programs may read/write skb->cb[] area to transfer meta
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index c6b2b43b843cb..d478e8e298a29 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -78,6 +78,8 @@ void *bpf_internal_load_pointer_neg_helper(const struct sk_buff *skb, int k, uns
 	u8 *ptr = NULL;
 
 	if (k >= SKF_NET_OFF) {
+		if (unlikely(!bpf_skb_has_network_header(skb)))
+			return NULL;
 		ptr = skb_network_header(skb) + k - SKF_NET_OFF;
 	} else if (k >= SKF_LL_OFF) {
 		if (unlikely(!skb_mac_header_was_set(skb)))
diff --git a/net/core/filter.c b/net/core/filter.c
index 659b8e64591c1..1575424d4ca65 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -224,7 +224,8 @@ static int bpf_skb_load_helper_convert_offset(const struct sk_buff *skb, int off
 		return offset;
 
 	if (offset >= SKF_NET_OFF)
-		return offset - SKF_NET_OFF + skb_network_offset(skb);
+		return bpf_skb_has_network_header(skb) ?
+		       offset - SKF_NET_OFF + skb_network_offset(skb) : INT_MIN;
 
 	if (offset >= SKF_LL_OFF && skb_mac_header_was_set(skb))
 		return offset - SKF_LL_OFF + skb_mac_offset(skb);
@@ -1867,6 +1868,8 @@ BPF_CALL_5(bpf_skb_load_bytes_relative, const struct sk_buff *, skb,
 		start = skb_mac_header(skb);
 		break;
 	case BPF_HDR_START_NET:
+		if (unlikely(!bpf_skb_has_network_header(skb)))
+			goto err_clear;
 		start = skb_network_header(skb);
 		break;
 	default:
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 305/555] bpf: Clear family and port of a short address for cgroup sockaddr hooks
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (303 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 304/555] bpf: Fail loads from a network header that was not set Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 306/555] bpf: Take a neighbour of the L3 master in bpf_redirect_neigh() Greg Kroah-Hartman
                   ` (249 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin

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

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

From: Alexei Starovoitov <ast@kernel.org>

[ Upstream commit 2abc088aae543fa97350df8b2dd5eedf622e380d ]

recvmsg() from a unix socket that has no name leaves the buffer of the
address as it is, and that is on the stack of the kernel. The program
reads user_family and user_port whatever the length is.
bpf_sock_addr_set_sun_path() sends the family to user space.

Clear the bytes from the length up to 4. Write AF_UNIX next to the path
in the kfunc.

Fixes: 859051dd165e ("bpf: Implement cgroup sockaddr hooks for unix sockets")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-42-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/bpf/cgroup.c | 4 ++++
 net/core/filter.c   | 1 +
 2 files changed, 5 insertions(+)

diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c
index 03e31f1371715..4439957fe8827 100644
--- a/kernel/bpf/cgroup.c
+++ b/kernel/bpf/cgroup.c
@@ -1719,6 +1719,10 @@ int __cgroup_bpf_run_filter_sock_addr(struct sock *sk,
 		ctx.uaddrlen = 0;
 	} else {
 		ctx.uaddrlen = *uaddrlen;
+		/* Programs read the family and the port also of a short address. */
+		if (ctx.uaddrlen < offsetofend(struct sockaddr_in, sin_port))
+			memset((void *)uaddr + ctx.uaddrlen, 0,
+			       offsetofend(struct sockaddr_in, sin_port) - ctx.uaddrlen);
 	}
 
 	cgrp = sock_cgroup_ptr(&sk->sk_cgrp_data);
diff --git a/net/core/filter.c b/net/core/filter.c
index 1575424d4ca65..4efe10a2fea6b 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -12170,6 +12170,7 @@ __bpf_kfunc int bpf_sock_addr_set_sun_path(struct bpf_sock_addr_kern *sa_kern,
 		return -EINVAL;
 
 	un = (struct sockaddr_un *)sa_kern->uaddr;
+	un->sun_family = AF_UNIX;
 	memcpy(un->sun_path, sun_path, sun_path__sz);
 	sa_kern->uaddrlen = offsetof(struct sockaddr_un, sun_path) + sun_path__sz;
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 306/555] bpf: Take a neighbour of the L3 master in bpf_redirect_neigh()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (304 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 305/555] bpf: Clear family and port of a short address for cgroup sockaddr hooks Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 307/555] bpf: Keep the MAC header in bpf_skb_change_tail() Greg Kroah-Hartman
                   ` (248 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin

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

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

From: Alexei Starovoitov <ast@kernel.org>

[ Upstream commit c1b5decc73149f69db0b8d28ebcea204249e3b0b ]

bpf_redirect_neigh() takes the neighbour from the route, the skb gets
the device that the program has named. They are not always the same for
IPv4, and the queue of a neighbour is purged with its own device only.

When a L3 master was named take a neighbour of that device, as IPv6
does. Its driver drops the header and routes the packet, one entry does
for all.

Fixes: ba452c9e996d ("bpf: Fix bpf_redirect_neigh helper api to support supplying nexthop")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-43-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/core/filter.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/core/filter.c b/net/core/filter.c
index 4efe10a2fea6b..c2e26724a7548 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2374,7 +2374,11 @@ static int bpf_out_neigh_v4(struct net *net, struct sk_buff *skb,
 	}
 
 	rcu_read_lock();
-	if (!nh) {
+	if (!nh && netif_is_l3_master(dev)) {
+		/* The route leads to another device, this one looks it up again */
+		skb_dst_drop(skb);
+		neigh = ip_neigh_gw4(dev, htonl(INADDR_ANY));
+	} else if (!nh) {
 		struct rtable *rt = skb_rtable(skb);
 
 		neigh = ip_neigh_for_gw(rt, skb, &is_v6gw);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 307/555] bpf: Keep the MAC header in bpf_skb_change_tail()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (305 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 306/555] bpf: Take a neighbour of the L3 master in bpf_redirect_neigh() Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 308/555] bpf, sockmap: Hold the psock of the work in sk_psock_backlog() Greg Kroah-Hartman
                   ` (247 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin

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

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

From: Alexei Starovoitov <ast@kernel.org>

[ Upstream commit 28ffeb9cb9722f39854f11e5f0511a4a8c12d9fb ]

The least length of the skb is the offset of the transport header when
it's set, also when that is below the offset of the network header.
Callers of tc programs count on a skb that is not shorter than mac_len.

Take the bigger one of the two offsets.

Fixes: 5293efe62df8 ("bpf: add bpf_skb_change_tail helper")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-44-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/core/filter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/filter.c b/net/core/filter.c
index c2e26724a7548..377cbf801d7e3 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -3911,7 +3911,7 @@ static u32 __bpf_skb_min_len(const struct sk_buff *skb)
 	if (skb_transport_header_was_set(skb)) {
 		offset = skb_transport_offset(skb);
 		if (offset > 0)
-			min_len = offset;
+			min_len = max_t(u32, min_len, offset);
 	}
 	return min_len;
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 308/555] bpf, sockmap: Hold the psock of the work in sk_psock_backlog()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (306 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 307/555] bpf: Keep the MAC header in bpf_skb_change_tail() Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 309/555] net: dpaa2-eth: fix objtool warning and logic bug Greg Kroah-Hartman
                   ` (246 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin

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

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

From: Alexei Starovoitov <ast@kernel.org>

[ Upstream commit 9abfa0ad4f7606619586187152a0479efd306b13 ]

The socket can leave its map and come back after the test of
SK_PSOCK_TX_ENABLED. sk_psock_get() takes a reference to the new psock
then, and the work puts the old one that has none left. The new one and
its socket are never freed.

Take the reference that is put.

Fixes: 8259eb0e06d8 ("bpf, sockmap: Avoid using sk_socket after free when sending")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-46-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/core/skmsg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/skmsg.c b/net/core/skmsg.c
index 6eca57da3cff6..d8589771a504a 100644
--- a/net/core/skmsg.c
+++ b/net/core/skmsg.c
@@ -690,7 +690,7 @@ static void sk_psock_backlog(struct work_struct *work)
 	 * before sk_socket freed. If refcnt increment fails, it indicates
 	 * sock_map_close() completed with sk_socket potentially already freed.
 	 */
-	if (!sk_psock_get(psock->sk))
+	if (!refcount_inc_not_zero(&psock->refcnt))
 		return;
 	mutex_lock(&psock->work_mutex);
 	while ((skb = skb_peek(&psock->ingress_skb))) {
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 309/555] net: dpaa2-eth: fix objtool warning and logic bug
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (307 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 308/555] bpf, sockmap: Hold the psock of the work in sk_psock_backlog() Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 310/555] tg3: Dont fail probe if 31-bit coherent DMA mask is unsupported Greg Kroah-Hartman
                   ` (245 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Robert-Ionut Alexa, Ioana Ciornei,
	David S. Miller, Andrew Lunn, Jakub Kicinski, Paolo Abeni,
	Linus Torvalds, Sasha Levin

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

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

From: Linus Torvalds <torvalds@linux-foundation.org>

[ Upstream commit 25faec9ce61c01fb45abf812a222c5b43c3cd5c5 ]

This commit came about because I locally had a build with COMPILE_TEST
and various runtime hardening features (that don't make sense for a pure
build test anyway) disabled - and objtool complained about some of the
code as a result:

   drivers/net/ethernet/freescale/dpaa2/fsl-dpaa2-eth.o: warning: objtool: dpaa2_eth_add_bufs+0x3f8: stack state mismatch: reg1[15]=-1+0 reg2[15]=-2-208

The reason seems to be that without the hardening features, objtool
notices that gcc is doing really odd things with the 'page' variable,
which is uninitialized in the path where 'ch->xsk_zc' is true.

Now, this seems to be just objtool becoming confused about some ugly
code, but that code is _also_ actively buggy in a different way, so
let's just fix this all.

What confuses objtool seems to be the stack slot for the uninitialized
'page' variable - for the case where that variable isn't actually used.
There is some shared error handling code that frees the previously
allocated page or xsk buffers depending on previous state.

That code is ugly and worth fixing: just free the page or buffers in the
context where they are actually allocated, not at some common point
where you have to wonder "which one is it I'm supposed to free again?".

That gets rid of the objtool warning, because now gcc doesn't take messy
and incomprehensible source code and turn it into messy and even more
incomprehensible object code any more.  No more questionable stack
frames with CFI information that blows objtool's little mind.

But fixing that then makes a real bug more obvious: the freeing of the
xsk buffers is buggy.  It frees the buffers that never got mapped:

		for (; i < batch; i++)
			xsk_buff_free(xdp_buffs[i]);

and that looks sane enough: iterate over the unused part of the batch.

But it's horrendously wrong, because it updates 'i'.

And 'i' isn't some harmless little local loop counter.  It's the
variable that is supposed to contain how many buffers have been
successfully mapped.  So now that 'free the buffers we didn't map' loop
ends up updating that counter, and after the loop 'i' will be the whole
batch we allocated.

So that loop first freed the buffers that failed to map, and then as a
side effect said "all these buffers I just freed were successfully
mapped" and they would be released to hardware.

So objtool didn't actually find a real bug.  It just found code that was
so ugly that it triggered a false positive.  And as is often the case
with ugly code: people hadn't understood it either, and it was buggy.

It's worth noting that the code is still ugly.  A variable name like 'i'
is perfectly fine for some random anonymous loop iterator that is just
that.  But when it has serious meaning outside the loop, you should give
it a serious name that makes sense non-locally.

This does not fix that kind of ugliness.  This is just the minimal fix
for the objtool warning and the entirely incidental bug it then
uncovered.  They had nothing in common except for the obfuscated C code
contest entry.

Fixes: 48276c08cf5d ("net: dpaa2-eth: AF_XDP RX zero copy support")
Cc: Robert-Ionut Alexa <robert-ionut.alexa@nxp.com>
Cc: Ioana Ciornei <ioana.ciornei@nxp.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 .../net/ethernet/freescale/dpaa2/dpaa2-eth.c  | 28 ++++++++-----------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
index 047a09e9e6da2..462af416ee49f 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
@@ -1679,11 +1679,9 @@ static int dpaa2_eth_add_bufs(struct dpaa2_eth_priv *priv,
 	struct device *dev = priv->net_dev->dev.parent;
 	u64 buf_array[DPAA2_ETH_BUFS_PER_CMD];
 	struct dpaa2_eth_swa *swa;
-	struct page *page;
 	dma_addr_t addr;
 	int retries = 0;
 	int i = 0, err;
-	u32 batch;
 
 	/* Allocate buffers visible to WRIOP */
 	if (!ch->xsk_zc) {
@@ -1693,14 +1691,16 @@ static int dpaa2_eth_add_bufs(struct dpaa2_eth_priv *priv,
 			 * the entire page except for a tailroom reserved for
 			 * skb shared info
 			 */
-			page = dev_alloc_pages(0);
+			struct page *page = dev_alloc_pages(0);
 			if (!page)
 				goto err_alloc;
 
 			addr = dma_map_page(dev, page, 0, priv->rx_buf_size,
 					    DMA_BIDIRECTIONAL);
-			if (unlikely(dma_mapping_error(dev, addr)))
-				goto err_map;
+			if (unlikely(dma_mapping_error(dev, addr))) {
+				__free_pages(page, 0);
+				goto err_alloc;
+			}
 
 			buf_array[i] = addr;
 
@@ -1716,8 +1716,8 @@ static int dpaa2_eth_add_bufs(struct dpaa2_eth_priv *priv,
 		 * of DPAA2_ETH_BUFS_PER_CMD. Bail out if the UMEM cannot
 		 * provide enough buffers at the moment
 		 */
-		batch = xsk_buff_alloc_batch(ch->xsk_pool, xdp_buffs,
-					     DPAA2_ETH_BUFS_PER_CMD);
+		u32 batch = xsk_buff_alloc_batch(ch->xsk_pool, xdp_buffs,
+						 DPAA2_ETH_BUFS_PER_CMD);
 		if (!batch)
 			goto err_alloc;
 
@@ -1727,8 +1727,11 @@ static int dpaa2_eth_add_bufs(struct dpaa2_eth_priv *priv,
 			swa->xsk.xdp_buff = xdp_buffs[i];
 
 			addr = xsk_buff_xdp_get_frame_dma(xdp_buffs[i]);
-			if (unlikely(dma_mapping_error(dev, addr)))
-				goto err_map;
+			if (unlikely(dma_mapping_error(dev, addr))) {
+				for (int j = i; j < batch; j++)
+					xsk_buff_free(xdp_buffs[j]);
+				goto err_alloc;
+			}
 
 			buf_array[i] = addr;
 
@@ -1759,13 +1762,6 @@ static int dpaa2_eth_add_bufs(struct dpaa2_eth_priv *priv,
 
 	return i;
 
-err_map:
-	if (!ch->xsk_zc) {
-		__free_pages(page, 0);
-	} else {
-		for (; i < batch; i++)
-			xsk_buff_free(xdp_buffs[i]);
-	}
 err_alloc:
 	/* If we managed to allocate at least some buffers,
 	 * release them to hardware
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 310/555] tg3: Dont fail probe if 31-bit coherent DMA mask is unsupported
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (308 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 309/555] net: dpaa2-eth: fix objtool warning and logic bug Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 311/555] tg3: Skip management FW version when APE firmware is not ready Greg Kroah-Hartman
                   ` (244 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Rui Salvaterra, Pavan Chebbi,
	Simon Horman, Paolo Abeni, Sasha Levin

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

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

From: Pavan Chebbi <pavan.chebbi@broadcom.com>

[ Upstream commit 686b8dbcedf8773dc505f9f315a0551c0bca70a3 ]

Commit 614f4d166eee ("tg3: Set coherent DMA mask bits to 31 for
BCM57766 chipsets") lowered the coherent DMA mask to 31 bits as a
workaround for a spurious address overflow error in the hardware.
The result of dma_set_coherent_mask() is fatal to probe, so on
platforms that cannot satisfy such a mask the device fails to probe:

  tg3 0000:01:00.0: Unable to obtain 64 bit DMA for consistent allocations
  tg3 0000:01:00.0: probe with driver tg3 failed with error -5

This was reported on a Mac mini (Macmini6,2, BCM57766) running a
kernel built without CONFIG_ZONE_DMA and with IOMMU passthrough as
the default. Without CONFIG_ZONE_DMA, dma_direct_supported() only
accepts a mask narrower than 32 bits if it covers the highest
physical memory address, so with direct mapping a 31-bit coherent
mask is rejected whenever memory extends above 2GB.

Treat the 31-bit mask as best effort.  If it is refused, warn and fall
back to the mask used before 614f4d166eee, so that the device still
probes.  Platforms that accept the mask are unaffected.  Where it is
refused, 614f4d166eee never protected the device, it only stopped it
from probing, so this restores the behaviour of kernels before that
commit.  Warn when a status block lands at an address matching the
pattern described in 614f4d166eee, so that a resulting TX timeout can
be identified.

Fixes: 614f4d166eee ("tg3: Set coherent DMA mask bits to 31 for BCM57766 chipsets")
Reported-by: Rui Salvaterra <rsalvaterra@gmail.com>
Link: https://lore.kernel.org/netdev/CALjTZvYKHWrD5m+RXimjxODvpFPw7Cq_EOEuzRi1PZT9_JxF+g@mail.gmail.com/
Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20261118105408.1076095-2-pavan.chebbi@broadcom.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/broadcom/tg3.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 190e7f622e7f8..12fea72cbf105 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -8834,6 +8834,13 @@ static int tg3_alloc_consistent(struct tg3 *tp)
 		if (!tnapi->hw_status)
 			goto err_out;
 
+		if (tg3_asic_rev(tp) == ASIC_REV_57766 &&
+		    (lower_32_bits(tnapi->status_mapping) & 0xffff0000) ==
+		    0xffff0000)
+			dev_warn(&tp->pdev->dev,
+				 "Status block at DMA address %pad may cause TX timeouts on this device\n",
+				 &tnapi->status_mapping);
+
 		sblk = tnapi->hw_status;
 
 		if (tg3_flag(tp, ENABLE_RSS)) {
@@ -17672,6 +17679,7 @@ static int tg3_init_one(struct pci_dev *pdev,
 	u64 dma_mask, persist_dma_mask;
 	netdev_features_t features = 0;
 	u8 addr[ETH_ALEN] __aligned(2);
+	u64 test_dma_mask = 0;
 
 	err = pci_enable_device(pdev);
 	if (err) {
@@ -17811,15 +17819,22 @@ static int tg3_init_one(struct pci_dev *pdev,
 		persist_dma_mask = dma_mask = DMA_BIT_MASK(64);
 
 	if (tg3_asic_rev(tp) == ASIC_REV_57766)
-		persist_dma_mask = DMA_BIT_MASK(31);
+		test_dma_mask = DMA_BIT_MASK(31);
 
 	/* Configure DMA attributes. */
 	if (dma_mask > DMA_BIT_MASK(32)) {
 		err = dma_set_mask(&pdev->dev, dma_mask);
 		if (!err) {
 			features |= NETIF_F_HIGHDMA;
-			err = dma_set_coherent_mask(&pdev->dev,
-						    persist_dma_mask);
+			if (!test_dma_mask ||
+			    dma_set_coherent_mask(&pdev->dev,
+						  test_dma_mask)) {
+				if (test_dma_mask)
+					dev_warn(&pdev->dev,
+						 "Unable to set 31 bit coherent DMA mask, workaround not applied\n");
+				err = dma_set_coherent_mask(&pdev->dev,
+							    persist_dma_mask);
+			}
 			if (err < 0) {
 				dev_err(&pdev->dev, "Unable to obtain 64 bit "
 					"DMA for consistent allocations\n");
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 311/555] tg3: Skip management FW version when APE firmware is not ready
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (309 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 310/555] tg3: Dont fail probe if 31-bit coherent DMA mask is unsupported Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 312/555] tg3: Fix heap overflow in unbuffered NVRAM write path Greg Kroah-Hartman
                   ` (243 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Pavan Chebbi, Simon Horman,
	Paolo Abeni, Sasha Levin

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

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

From: Pavan Chebbi <pavan.chebbi@broadcom.com>

[ Upstream commit 70e57e1255e06fd7a22d45dd2bf854200fcbd575 ]

When the APE firmware is not present or not ready, for example when
the NCSI component is missing in the NVRAM, tg3_read_fw_ver() still
calls tg3_read_dash_ver() after tg3_probe_ncsi().  The signature and
ready checks that tg3_read_dash_ver() used to make were moved into
tg3_probe_ncsi(), which only sets the NCSI flag and does not stop the
caller.  The driver then reads the APE firmware version register, which
holds no valid data in this state, and ethtool -i shows an invalid
"DASH" string with a garbage version.

Make tg3_probe_ncsi() return whether valid, ready APE firmware was
found, and read the version only in that case.  Otherwise just report
the bootcode version.

This was seen by a user on BCM5719/BCM5720 with no NCSI component in
the NVRAM.  With this change, ethtool -i displays only the bootcode
version.

Fixes: 165f4d1cb3d7 ("tg3: Fix the setting of the APE_HAS_NCSI flag")
Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20261118105408.1076095-3-pavan.chebbi@broadcom.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/broadcom/tg3.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 12fea72cbf105..a243c38a16f2e 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -15983,20 +15983,26 @@ static void tg3_read_mgmtfw_ver(struct tg3 *tp)
 	}
 }
 
-static void tg3_probe_ncsi(struct tg3 *tp)
+/* Returns true if valid, ready APE firmware is present, regardless of
+ * whether it advertises NCSI (it may be DASH or SMASH).  Sets APE_HAS_NCSI
+ * if the NCSI feature is advertised.
+ */
+static bool tg3_probe_ncsi(struct tg3 *tp)
 {
 	u32 apedata;
 
 	apedata = tg3_ape_read32(tp, TG3_APE_SEG_SIG);
 	if (apedata != APE_SEG_SIG_MAGIC)
-		return;
+		return false;
 
 	apedata = tg3_ape_read32(tp, TG3_APE_FW_STATUS);
 	if (!(apedata & APE_FW_STATUS_READY))
-		return;
+		return false;
 
 	if (tg3_ape_read32(tp, TG3_APE_FW_FEATURES) & TG3_APE_FW_FEATURE_NCSI)
 		tg3_flag_set(tp, APE_HAS_NCSI);
+
+	return true;
 }
 
 static void tg3_read_dash_ver(struct tg3 *tp)
@@ -16075,8 +16081,7 @@ static void tg3_read_fw_ver(struct tg3 *tp)
 
 	if (tg3_flag(tp, ENABLE_ASF)) {
 		if (tg3_flag(tp, ENABLE_APE)) {
-			tg3_probe_ncsi(tp);
-			if (!vpd_vers)
+			if (tg3_probe_ncsi(tp) && !vpd_vers)
 				tg3_read_dash_ver(tp);
 		} else if (!vpd_vers) {
 			tg3_read_mgmtfw_ver(tp);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 312/555] tg3: Fix heap overflow in unbuffered NVRAM write path
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (310 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 311/555] tg3: Skip management FW version when APE firmware is not ready Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 313/555] perf: Prevent duplicate sigtrap task work enqueue Greg Kroah-Hartman
                   ` (242 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Shravya KN, Pavan Chebbi,
	Simon Horman, Paolo Abeni, Sasha Levin

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

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

From: Shravya KN <shravya.k-n@broadcom.com>

[ Upstream commit 0323a427052447e2c41c650fc98a6c04bf417e5d ]

tg3_nvram_write_block_unbuffered() reads a whole NVRAM page into a
buffer of pagesize bytes, copies the caller's data into it at page_off,
and writes the page back.  The copy size was clamped to pagesize rather
than to the room left in the page, pagesize - page_off, so a write at an
offset that is not page aligned, as ETHTOOL_SEEPROM allows, copies past
the end of the buffer and corrupts the kernel heap.

Clamp size to pagesize - page_off.  Also advance buf by size on each
iteration.  Without this, a write that spans more than one page
programmed every page after the first with the data of the first page,
and a write that did not start on a page boundary lost the tail of the
data without reporting an error.

Reject an nvram_pagesize that is smaller than 4 or not a power of two.
The page mask is pagesize - 1, which is only a valid mask for a power
of two.  A page size of 0, which tg3_get_nvram_info() leaves unset for
an unhandled flash vendor, also made the loop issue erase commands at
address 0 forever with the rtnl and NVRAM locks held.  ethtool -E now
fails with -EINVAL in these cases.

This was found by an AI code review scan.  It has not been observed on
hardware, but it can be reached with ethtool -E on devices with
unbuffered flash.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Shravya KN <shravya.k-n@broadcom.com>
Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20261118105408.1076095-4-pavan.chebbi@broadcom.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/broadcom/tg3.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index a243c38a16f2e..9c29abeb48dfb 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -56,6 +56,7 @@
 #include <linux/hwmon-sysfs.h>
 #include <linux/crc32poly.h>
 #include <linux/dmi.h>
+#include <linux/log2.h>
 
 #include <net/checksum.h>
 #include <net/gso.h>
@@ -3379,6 +3380,9 @@ static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len,
 	u32 nvram_cmd;
 	u8 *tmp;
 
+	if (pagesize < 4 || !is_power_of_2(pagesize))
+		return -EINVAL;
+
 	tmp = kmalloc(pagesize, GFP_KERNEL);
 	if (tmp == NULL)
 		return -ENOMEM;
@@ -3399,13 +3403,14 @@ static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len,
 			break;
 
 		page_off = offset & pagemask;
-		size = pagesize;
+		size = pagesize - page_off;
 		if (len < size)
 			size = len;
 
 		len -= size;
 
 		memcpy(tmp + page_off, buf, size);
+		buf += size;
 
 		offset = offset + (pagesize - page_off);
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 313/555] perf: Prevent duplicate sigtrap task work enqueue
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (311 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 312/555] tg3: Fix heap overflow in unbuffered NVRAM write path Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 314/555] perf: Fix sigtrap for software events Greg Kroah-Hartman
                   ` (241 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Tengda Wu, Peter Zijlstra (Intel),
	Sasha Levin

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

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

From: Tengda Wu <wutengda@huaweicloud.com>

[ Upstream commit e4c5112f01816b0ac6d74724545eca1195788c38 ]

The sigtrap handling in __perf_event_overflow() checks
event->pending_work before calling task_work_add(), but only sets
pending_work after the task work has been queued.

This leaves a window where an NMI can interrupt task_work_add() and
re-enter __perf_event_overflow() for the same (software/tracepoint)
event. Since pending_work is still zero, the nested invocation can
enqueue the same pending_task again.

The re-entrant call path looks like this:

  __perf_event_overflow()
    task_work_add()
      <NMI>
        __perf_event_overflow()
          task_work_add()

The nested invocation may enqueue pending_task before the outer
invocation does. When the outer invocation resumes, it inserts the
same task work entry again, potentially creating a cycle in the task
work list.

As a result, perf_pending_task() may be executed repeatedly, leading
to unbalanced event reference counting.

Fix this by atomically claiming pending_work with cmpxchg_local()
before calling task_work_add(). This ensures that only one invocation
can enqueue the task work, even when another overflow occurs
re-entrantly from an NMI.

Notably: sigtrap events must be per-task, meaning that the there is no
concurrency, only re-entrancy.

[peterz: clarify and rewrite]
Fixes: c5d93d23a260 ("perf: Enqueue SIGTRAP always via task_work.")
Signed-off-by: Tengda Wu <wutengda@huaweicloud.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/45bd71c976aea1a0e8bf5762dd6b6552e6009439.1795053619.git.wutengda@huaweicloud.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/events/core.c | 34 +++++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index e830683daef43..b91838ce2a226 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7063,9 +7063,15 @@ static void perf_pending_task(struct callback_head *head)
 	rctx = perf_swevent_get_recursion_context();
 
 	if (event->pending_work) {
-		event->pending_work = 0;
 		perf_sigtrap(event);
 		local_dec(&event->ctx->nr_no_switch_fast);
+		/*
+		 * event->pending_work also acts as a 'lock' for
+		 * event->{pending_addr, orig_type, attr.sig_data}. As such we
+		 * must clear after perf_sigtrap is complete.
+		 */
+		barrier();
+		event->pending_work = 0;
 	}
 	put_event(event);
 
@@ -9949,16 +9955,22 @@ static int __perf_event_overflow(struct perf_event *event,
 
 		notify_mode = in_nmi() ? TWA_NMI_CURRENT : TWA_RESUME;
 
-		if (!event->pending_work &&
-		    !task_work_add(current, &event->pending_task, notify_mode)) {
-			event->pending_work = pending_id;
-			local_inc(&event->ctx->nr_no_switch_fast);
-			WARN_ON_ONCE(!atomic_long_inc_not_zero(&event->refcount));
-
-			event->pending_addr = 0;
-			if (valid_sample && (data->sample_flags & PERF_SAMPLE_ADDR))
-				event->pending_addr = data->addr;
-
+		/*
+		 * Software events can nest and attempt this recursively;
+		 * claim the pending_work before task_work_add() recurses.
+		 */
+		if (cmpxchg_local(&event->pending_work, 0, 1) == 0) {
+			if (!task_work_add(current, &event->pending_task, notify_mode)) {
+				event->pending_work = pending_id;
+				local_inc(&event->ctx->nr_no_switch_fast);
+				WARN_ON_ONCE(!atomic_long_inc_not_zero(&event->refcount));
+
+				event->pending_addr = 0;
+				if (valid_sample && (data->sample_flags & PERF_SAMPLE_ADDR))
+					event->pending_addr = data->addr;
+			} else {
+				event->pending_work = 0;
+			}
 		} else if (event->attr.exclude_kernel && valid_sample) {
 			/*
 			 * Should not be able to return to user space without
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 314/555] perf: Fix sigtrap for software events
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (312 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 313/555] perf: Prevent duplicate sigtrap task work enqueue Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 315/555] perf: Fix sigtrap vs fast-switch Greg Kroah-Hartman
                   ` (240 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Tengda Wu, Peter Zijlstra (Intel),
	Sasha Levin

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

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

From: Peter Zijlstra <peterz@infradead.org>

[ Upstream commit 38606d2911f7f2fe80388315da0c4a7fc98af0f8 ]

perf_sigtrap() contains:

	WARN_ON_ONCE(event->ctx->task != current)

The warning assumes that an event's ctx->task always matches the task
that ends up running the pending task_work. That assumption can be
broken by the context fast-swap path.

The failure sequence is:

  1. A -> B switch, perf_event_context_sched_out() takes the fast path
     and does WRITE_ONCE(ctx->task, next) / WRITE_ONCE(next_ctx->task, task).
     An NMI then hits while the context is swapped, and
     __perf_event_overflow() queues pending task_work on the *current*
     task (A), even though the event now belongs to B's swapped-in
     context view.

  2. B -> A switch. Because A now has pending task_work,
     nr_no_switch_fast is non-zero, so the slow path is taken and
     ctx->task is *not* swapped back.

  3. A returns to user mode, task_work runs perf_pending_task() ->
     perf_sigtrap(), and event->ctx->task no longer equals current,
     tripping the WARN_ON_ONCE().

The nr_no_switch_fast bits hard rely on perf_pmu_disable() actually working. It
turns out the software events do not implement the pmu::pmu_{dis,en}able()
methods and generally ignore the state, making the above scenario worse in that
an overflow can happen in the middle of swapping task contexts, making it
impossible to reconstruct state.

Ensure software and tracepoint events respect the disable state.

Fixes: ca6c21327c6a ("perf: Fix missing SIGTRAPs")
Fixes: c5d93d23a260 ("perf: Enqueue SIGTRAP always via task_work.")
Reported-by: Tengda Wu <wutengda@huaweicloud.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Tengda Wu <wutengda@huaweicloud.com>
Link: https://patch.msgid.link/20261125161342.GP2669272%40noisy.programming.kicks-ass.net
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/linux/perf_event.h |  1 +
 kernel/events/core.c       | 12 ++++++++++++
 2 files changed, 13 insertions(+)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index d88c0091e57dd..35f9377f70a2a 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -1148,6 +1148,7 @@ extern const struct perf_event_attr *perf_event_attrs(struct perf_event *event);
 extern void perf_event_print_debug(void);
 extern void perf_pmu_disable(struct pmu *pmu);
 extern void perf_pmu_enable(struct pmu *pmu);
+extern bool perf_pmu_enabled(struct pmu *pmu);
 extern void perf_sched_cb_dec(struct pmu *pmu);
 extern void perf_sched_cb_inc(struct pmu *pmu);
 extern int perf_event_task_disable(void);
diff --git a/kernel/events/core.c b/kernel/events/core.c
index b91838ce2a226..b48b7222feae0 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -1219,6 +1219,12 @@ void perf_pmu_enable(struct pmu *pmu)
 		pmu->pmu_enable(pmu);
 }
 
+bool perf_pmu_enabled(struct pmu *pmu)
+{
+	int *count = &this_cpc(pmu)->pmu_disable_count;
+	return *count == 0;
+}
+
 static void perf_assert_pmu_disabled(struct pmu *pmu)
 {
 	int *count = &this_cpc(pmu)->pmu_disable_count;
@@ -10157,6 +10163,9 @@ static int perf_swevent_match(struct perf_event *event,
 				struct perf_sample_data *data,
 				struct pt_regs *regs)
 {
+	if (!perf_pmu_enabled(event->pmu))
+		return 0;
+
 	if (event->attr.type != type)
 		return 0;
 
@@ -10537,6 +10546,9 @@ static int perf_tp_event_match(struct perf_event *event,
 				struct perf_raw_record *raw,
 				struct pt_regs *regs)
 {
+	if (!perf_pmu_enabled(event->pmu))
+		return 0;
+
 	if (event->hw.state & PERF_HES_STOPPED)
 		return 0;
 	/*
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 315/555] perf: Fix sigtrap vs fast-switch
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (313 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 314/555] perf: Fix sigtrap for software events Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:05 ` [PATCH 6.12 316/555] gpio: davinci: use generic device properties Greg Kroah-Hartman
                   ` (239 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Tengda Wu, Peter Zijlstra (Intel),
	Sasha Levin

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

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

From: Peter Zijlstra <peterz@infradead.org>

[ Upstream commit 34dc983cc1628dea5054baa8687477cbb8683e28 ]

perf_sigtrap() contains:

	WARN_ON_ONCE(event->ctx->task != current)

The warning assumes that an event's ctx->task always matches the task
that ends up running the pending task_work. That assumption can be
broken by the context fast-swap path.

The failure sequence is:

  1. A -> B switch, perf_event_context_sched_out() takes the fast path
     and does WRITE_ONCE(ctx->task, next) / WRITE_ONCE(next_ctx->task, task).
     An NMI then hits while the context is swapped, and
     __perf_event_overflow() queues pending task_work on the *current*
     task (A), even though the event now belongs to B's swapped-in
     context view.

  2. B -> A switch. Because A now has pending task_work,
     nr_no_switch_fast is non-zero, so the slow path is taken and
     ctx->task is *not* swapped back.

  3. A returns to user mode, task_work runs perf_pending_task() ->
     perf_sigtrap(), and event->ctx->task no longer equals current,
     tripping the WARN_ON_ONCE().

Therefore; the task_work_add() should in fact use event->ctx->task, rather than
current. They are always the same, except in this narrow window between
perf_event_task_sched_out() and switch_to().

Fixes: c5d93d23a260 ("perf: Enqueue SIGTRAP always via task_work.")
Reported-by: Tengda Wu <wutengda@huaweicloud.com>
Tested-by: Tengda Wu <wutengda@huaweicloud.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20261125161342.GP2669272%40noisy.programming.kicks-ass.net
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/events/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index b48b7222feae0..b414a8e078afe 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -9966,7 +9966,7 @@ static int __perf_event_overflow(struct perf_event *event,
 		 * claim the pending_work before task_work_add() recurses.
 		 */
 		if (cmpxchg_local(&event->pending_work, 0, 1) == 0) {
-			if (!task_work_add(current, &event->pending_task, notify_mode)) {
+			if (!task_work_add(event->ctx->task, &event->pending_task, notify_mode)) {
 				event->pending_work = pending_id;
 				local_inc(&event->ctx->nr_no_switch_fast);
 				WARN_ON_ONCE(!atomic_long_inc_not_zero(&event->refcount));
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 316/555] gpio: davinci: use generic device properties
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (314 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 315/555] perf: Fix sigtrap vs fast-switch Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 317/555] gpio: davinci: use controller-specific MMIO for BINTEN Greg Kroah-Hartman
                   ` (238 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Linus Walleij, Bartosz Golaszewski,
	Sasha Levin

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

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

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

[ Upstream commit 5dfdcd9e73119dcb60b0299e96d2d84d23c354fd ]

OF-specific routines should not be used unless necessary. Generic device
properties are preferred so switch to using them in the driver code.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20241007103440.38416-2-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Stable-dep-of: a142f1c5de4b ("gpio: davinci: use controller-specific MMIO for BINTEN")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpio/gpio-davinci.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index 2011db9ccb4e5..1a09e394f41ba 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -15,7 +15,6 @@
 #include <linux/irq.h>
 #include <linux/irqdomain.h>
 #include <linux/module.h>
-#include <linux/of.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/property.h>
@@ -159,14 +158,13 @@ static int davinci_gpio_probe(struct platform_device *pdev)
 	unsigned int ngpio, nbank, nirq, gpio_unbanked;
 	struct davinci_gpio_controller *chips;
 	struct device *dev = &pdev->dev;
-	struct device_node *dn = dev_of_node(dev);
 
 	/*
 	 * The gpio banks conceptually expose a segmented bitmap,
 	 * and "ngpio" is one more than the largest zero-based
 	 * bit index that's valid.
 	 */
-	ret = of_property_read_u32(dn, "ti,ngpio", &ngpio);
+	ret = device_property_read_u32(dev, "ti,ngpio", &ngpio);
 	if (ret)
 		return dev_err_probe(dev, ret, "Failed to get the number of GPIOs\n");
 	if (ngpio == 0)
@@ -177,8 +175,8 @@ static int davinci_gpio_probe(struct platform_device *pdev)
 	 * interrupts is equal to number of gpios else all are banked so
 	 * number of interrupts is equal to number of banks(each with 16 gpios)
 	 */
-	ret = of_property_read_u32(dn, "ti,davinci-gpio-unbanked",
-				   &gpio_unbanked);
+	ret = device_property_read_u32(dev, "ti,davinci-gpio-unbanked",
+				       &gpio_unbanked);
 	if (ret)
 		return dev_err_probe(dev, ret, "Failed to get the unbanked GPIOs property\n");
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 317/555] gpio: davinci: use controller-specific MMIO for BINTEN
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (315 preceding siblings ...)
  2026-12-04 10:05 ` [PATCH 6.12 316/555] gpio: davinci: use generic device properties Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 318/555] gpio: mvebu: validate ngpios before use Greg Kroah-Hartman
                   ` (237 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Linus Walleij, Sahaj Chaudhari,
	Bartosz Golaszewski, Sasha Levin

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

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

From: Sahaj Chaudhari <sahaj123.sc@gmail.com>

[ Upstream commit a142f1c5de4b9c03910cc304a26fbbdef69ca422 ]

The file-global gpio_base can be overwritten when probes for multiple
DaVinci GPIO controllers overlap. The later IRQ setup can then write the
BINTEN register of a different controller.

Derive the BINTEN address from the current controller's mapped bank
instead of shared global state.

Fixes: 118150f22d6b ("gpio: davinci: move to platform device")
Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Sahaj Chaudhari <sahaj123.sc@gmail.com>
Link: https://patch.msgid.link/20261124121500.2cd5cbf30f89-2-sahaj123.sc@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpio/gpio-davinci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index 1a09e394f41ba..5137b6fcc6403 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -42,7 +42,6 @@ typedef struct irq_chip *(*gpio_get_irq_chip_cb_t)(unsigned int irq);
 
 #define BINTEN	0x8 /* GPIO Interrupt Per-Bank Enable Register */
 
-static void __iomem *gpio_base;
 static unsigned int offset_array[5] = {0x10, 0x38, 0x60, 0x88, 0xb0};
 
 struct davinci_gpio_irq_data {
@@ -158,6 +157,7 @@ static int davinci_gpio_probe(struct platform_device *pdev)
 	unsigned int ngpio, nbank, nirq, gpio_unbanked;
 	struct davinci_gpio_controller *chips;
 	struct device *dev = &pdev->dev;
+	void __iomem *gpio_base;
 
 	/*
 	 * The gpio banks conceptually expose a segmented bitmap,
@@ -570,7 +570,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
 	 * BINTEN -- per-bank interrupt enable. genirq would also let these
 	 * bits be set/cleared dynamically.
 	 */
-	writel_relaxed(binten, gpio_base + BINTEN);
+	writel_relaxed(binten, chips->regs[0] - offset_array[0] + BINTEN);
 
 	return 0;
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 318/555] gpio: mvebu: validate ngpios before use
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (316 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 317/555] gpio: davinci: use controller-specific MMIO for BINTEN Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 319/555] bpf, sockmap: Clear the redirect target after the stream parser runs Greg Kroah-Hartman
                   ` (236 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Rosen Penev, Bartosz Golaszewski,
	Sasha Levin

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

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

From: Rosen Penev <rosenp@gmail.com>

[ Upstream commit 62a41997c1553b723a7a333c0246d0646ebd2c95 ]

If ngpios is read as 0 from device tree, it is passed via
irq_alloc_domain_generic_chips() as irqs_per_chip, which leads to a
division by zero in DIV_ROUND_UP(d->revmap_size, irqs_per_chip).
Reject ngpios == 0 early.

Also reject higher than 32, which is the limit.

Fixes: fefe7b0923459 ("gpio: introduce gpio-mvebu driver for Marvell SoCs")
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://patch.msgid.link/20261126002650.603321-1-rosenp@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpio/gpio-mvebu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index 4b482d116d04c..7a76f62a51ea6 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -1191,6 +1191,9 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
+	if (ngpios == 0 || ngpios > MVEBU_MAX_GPIO_PER_BANK)
+		return dev_err_probe(&pdev->dev, -EINVAL, "ngpios must be between 1 and 32\n");
+
 	id = of_alias_get_id(pdev->dev.of_node, "gpio");
 	if (id < 0) {
 		dev_err(&pdev->dev, "Couldn't get OF id\n");
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 319/555] bpf, sockmap: Clear the redirect target after the stream parser runs
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (317 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 318/555] gpio: mvebu: validate ngpios before use Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 320/555] block: fix BLKSECDISCARD zero-length range causing page cache invalidation Greg Kroah-Hartman
                   ` (235 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sechang Lim, Alexei Starovoitov,
	Jiayuan Chen, Sasha Levin

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

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

From: Sechang Lim <rhkrqnwk98@gmail.com>

[ Upstream commit 14f6b10422d640695803c621687f790f6f3d2401 ]

A stream parser can call bpf_sk_redirect_{map,hash}(), which store the
target socket in skb->_sk_redir. sk_psock_strp_parse() never clears it,
and it shares storage with skb->_skb_refdst, so skb_dst_drop() later
passes the socket to dst_release():

  KASAN: null-ptr-deref in range [0x0000000000000128-0x000000000000012f]
  RIP: 0010:percpu_counter_add_batch+0x24/0x220
  Call Trace:
   dst_release.part.0+0xc9/0x180
   skb_release_head_state+0x1cc/0x2f0
   sk_skb_reason_drop+0xbc/0x420
   strp_done+0xcf/0x150
   sk_psock_destroy+0x85e/0xb10

Drop the dst before the parser runs, as the verdict paths do, and clear
the redirect after it. The parser's redirect was never used.

Fixes: e3526bb92a20 ("skmsg: Move sk_redir from TCP_SKB_CB to skb")
Signed-off-by: Sechang Lim <rhkrqnwk98@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Link: https://patch.msgid.link/20261126101950.1682160-1-rhkrqnwk98@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/core/skmsg.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/core/skmsg.c b/net/core/skmsg.c
index d8589771a504a..a2fca0051cdb2 100644
--- a/net/core/skmsg.c
+++ b/net/core/skmsg.c
@@ -1155,7 +1155,9 @@ static int sk_psock_strp_parse(struct strparser *strp, struct sk_buff *skb)
 	prog = READ_ONCE(psock->progs.stream_parser);
 	if (likely(prog)) {
 		skb->sk = psock->sk;
+		skb_dst_drop(skb);
 		ret = bpf_prog_run_pin_on_cpu(prog, skb);
+		skb_bpf_redirect_clear(skb);
 		skb->sk = NULL;
 	}
 	rcu_read_unlock();
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 320/555] block: fix BLKSECDISCARD zero-length range causing page cache invalidation
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (318 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 319/555] bpf, sockmap: Clear the redirect target after the stream parser runs Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 321/555] drm/gud: avoid divide error in gud_stats_debugfs Greg Kroah-Hartman
                   ` (234 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Zizhi Wo, Yu Kuai, Christoph Hellwig,
	Bart Van Assche, Jens Axboe, Sasha Levin

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

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

From: Zizhi Wo <wozizhi@huawei.com>

[ Upstream commit aea1c2ec03b399434ff1bafbb2f0d5076f74ce03 ]

Commit 697ba0b6ec4a ("block: fix integer overflow in BLKSECDISCARD") fixed
the start+len overflow via check_add_overflow() but did not handle the
start=0, len=0 case. There, start + len = 0, so end = 0 passes all checks,
and truncate_bdev_range()->truncate_inode_pages_range() is then called with
lend=UINT64_MAX, whitch is the "truncate to the end of file" sentinel, so
the entire page cache is invalidated.

Fix this by replacing the validation with blk_validate_byte_range(), which
already rejects a zero-length range and is what BLKDISCARD uses. This also
switches the alignment check from a hardcoded 512 to
bdev_logical_block_size().

Fixes: 0bd1ed4860d0 ("block: pass inclusive 'lend' parameter to truncate_inode_pages_range")
Signed-off-by: Zizhi Wo <wozizhi@huawei.com>
Reviewed-by: Yu Kuai <yukuai@fygo.io>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://patch.msgid.link/20261102080420.3774409-1-wozizhi@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 block/ioctl.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/block/ioctl.c b/block/ioctl.c
index f801bddf6fd1b..4fb7fb0704485 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -181,8 +181,7 @@ static int blk_ioctl_discard(struct block_device *bdev, blk_mode_t mode,
 static int blk_ioctl_secure_erase(struct block_device *bdev, blk_mode_t mode,
 		void __user *argp)
 {
-	uint64_t start, len, end;
-	uint64_t range[2];
+	uint64_t range[2], start, len;
 	int err;
 
 	if (!(mode & BLK_OPEN_WRITE))
@@ -194,15 +193,13 @@ static int blk_ioctl_secure_erase(struct block_device *bdev, blk_mode_t mode,
 
 	start = range[0];
 	len = range[1];
-	if ((start & 511) || (len & 511))
-		return -EINVAL;
-	if (check_add_overflow(start, len, &end) ||
-	    end > bdev_nr_bytes(bdev))
-		return -EINVAL;
+	err = blk_validate_byte_range(bdev, start, len);
+	if (err)
+		return err;
 
 	inode_lock(bdev->bd_mapping->host);
 	filemap_invalidate_lock(bdev->bd_mapping);
-	err = truncate_bdev_range(bdev, mode, start, end - 1);
+	err = truncate_bdev_range(bdev, mode, start, start + len - 1);
 	if (!err)
 		err = blkdev_issue_secure_erase(bdev, start >> 9, len >> 9,
 						GFP_KERNEL);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 321/555] drm/gud: avoid divide error in gud_stats_debugfs
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (319 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 320/555] block: fix BLKSECDISCARD zero-length range causing page cache invalidation Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 322/555] drm/i915/pps: Reset PPS state after TypeC port init on resume Greg Kroah-Hartman
                   ` (233 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Bin Yu, Cheng Wen, YuanZhe Liu,
	Ruben Wauters

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

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

From: YuanZhe Liu <25031212351@stu.xidian.edu.cn>

commit 431c2dffd2b7c1240a6e579f0c74104cd2e17329 upstream.

gud_stats_debugfs() computes the compression ratio by dividing the
accumulated uncompressed length by stats_actual_length. That counter is
zero until the first framebuffer flush has completed, so reading the
stats debugfs file on a display which negotiates LZ4 compression raises
a divide error before any frame has been sent. The wrap-around reset in
gud_flush_rect() also clears the counter for a moment, which a
concurrent read can observe.

Copy the counter into a local variable and skip the ratio computation
when it is zero.

Fixes: 40e1a70b4aed ("drm: Add GUD USB Display driver")
Cc: stable@vger.kernel.org
Co-developed-by: Bin Yu <byu@xidian.edu.cn>
Signed-off-by: Bin Yu <byu@xidian.edu.cn>
Co-developed-by: Cheng Wen <wencheng@xidian.edu.cn>
Signed-off-by: Cheng Wen <wencheng@xidian.edu.cn>
Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
Acked-by: Ruben Wauters <rubenru09@aol.com>
Link: https://patch.msgid.link/20261029073311.14556-1-25031212351@stu.xidian.edu.cn
Signed-off-by: Ruben Wauters <rubenru09@aol.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/gud/gud_drv.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

--- a/drivers/gpu/drm/gud/gud_drv.c
+++ b/drivers/gpu/drm/gud/gud_drv.c
@@ -343,10 +343,17 @@ static int gud_stats_debugfs(struct seq_
 	seq_puts(m, "\n");
 
 	if (gdrm->compression) {
+		u64 actual_length = gdrm->stats_actual_length;
 		u64 remainder;
-		u64 ratio = div64_u64_rem(gdrm->stats_length, gdrm->stats_actual_length,
-					  &remainder);
-		u64 ratio_frac = div64_u64(remainder * 10, gdrm->stats_actual_length);
+		u64 ratio, ratio_frac;
+
+		if (!actual_length) {
+			seq_puts(m, "Compression ratio: n/a\n");
+			return 0;
+		}
+
+		ratio = div64_u64_rem(gdrm->stats_length, actual_length, &remainder);
+		ratio_frac = div64_u64(remainder * 10, actual_length);
 
 		seq_printf(m, "Compression ratio: %llu.%llu\n", ratio, ratio_frac);
 	}



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 322/555] drm/i915/pps: Reset PPS state after TypeC port init on resume
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (320 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 321/555] drm/gud: avoid divide error in gud_stats_debugfs Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 323/555] drm/meson: encoder_dsi: load ENCL gamma table while ENCL is disabled Greg Kroah-Hartman
                   ` (232 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Mika Kahola, Imre Deak,
	Joonas Lahtinen

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

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

From: Imre Deak <imre.deak@intel.com>

commit af8b4d4817678a255ee310dbca983193cc09a075 upstream.

Resetting the PPS state involves acquiring an AUX power domain
reference. On TypeC ports, the AUX power domain depends on the TypeC
mode of the port using the PPS.

An upcoming change will set the port/PHY type to TypeC for eDP ports on
PTL+ platforms with an eDP DDI mapped to a TypeC PHY. Prepare for this by
resetting the PPS state on resume only after initializing the port's
TypeC mode.

CC: stable@vger.kernel.org # 6.14+
Reviewed-by: Mika Kahola <mika.kahola@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patch.msgid.link/20261029113017.618286-4-imre.deak@intel.com
(cherry picked from commit 43eb42b332fe48ab8649bd5e4e0ef351473d8a4a)
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/i915/display/intel_ddi.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/gpu/drm/i915/display/intel_ddi.c
+++ b/drivers/gpu/drm/i915/display/intel_ddi.c
@@ -4392,10 +4392,10 @@ static void intel_ddi_encoder_reset(stru
 
 	intel_dp->reset_link_params = true;
 
-	intel_pps_encoder_reset(intel_dp);
-
 	if (intel_encoder_is_tc(&dig_port->base))
 		intel_tc_port_init_mode(dig_port);
+
+	intel_pps_encoder_reset(intel_dp);
 }
 
 static int intel_ddi_encoder_late_register(struct drm_encoder *_encoder)



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 323/555] drm/meson: encoder_dsi: load ENCL gamma table while ENCL is disabled
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (321 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 322/555] drm/i915/pps: Reset PPS state after TypeC port init on resume Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 324/555] drm/nouveau/disp: Set drm_mode_config_funcs.atomic_(check|commit) (attempt 2) Greg Kroah-Hartman
                   ` (231 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, John Williams, Shigeaki Asai,
	Neil Armstrong

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

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

From: Shigeaki Asai <y-asai.0816@docomonet.jp>

commit 0cb7f6d9e4b1d0a411b628ccf78695ad41c66570 upstream.

meson_encoder_dsi_atomic_enable() programmed the ENCL gamma LUT right
after meson_venc_mipi_dsi_mode_set(), i.e. while the ENCL timing
generator was already running (ENCL_VIDEO_EN=1). Writing the LUT
during active video stalls the hardware: L_GAMMA_CNTL_PORT
WR_RDY/ADR_RDY deassert and the ENCL line counter (ENCL_INFO_READ)
freezes, so every remaining write times out (~8s total at boot) and
the panel ends up with a corrupted gamma table (wrong colors).

Instrumented boots on the ODROID-GO Ultra (S922X) show:

  failing:  start: VIDEO_EN=1 INFO 0000001a->002d0000 GAMMA_CNTL=00000030
            stall: INFO 002d0000->002d0000 GAMMA_CNTL=00000000
            (VID_CLK_CNTL2 / VIID_CLK_CNTL / VIID_CLK_DIV unchanged,
             i.e. the ENCL clock is still running)
  fixed:    start: VIDEO_EN=0 INFO 00000000->00000000 GAMMA_CNTL=00000030
            no stall, no timeout

Whether it failed depended only on timing, which is why enabling
lock debugging (LOCKDEP etc.) appeared to "fix" it most of the time.
It happens regardless of the bootloader (mainline or Hardkernel vendor
U-Boot).

The function already writes ENCL_VIDEO_EN=0 right afterwards before
re-enabling the encoder, so simply move meson_encl_load_gamma() after
that write. This matches the order used by the vendor U-Boot's own LCD
driver, which never times out.

Tested on the ODROID-GO Ultra with mainline U-Boot: 5 cold boots +
3 warm reboots, no timeouts, correct colors, LOCKDEP disabled.

Fixes: 42dcf15f901c ("drm/meson: add DSI encoder")
Cc: stable@vger.kernel.org
Tested-by: John Williams <porschemad911@gmail.com>
Signed-off-by: Shigeaki Asai <y-asai.0816@docomonet.jp>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://patch.msgid.link/20261004-meson-gamma-v1-1-6347558e2bb3@docomonet.jp
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/meson/meson_encoder_dsi.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/gpu/drm/meson/meson_encoder_dsi.c
+++ b/drivers/gpu/drm/meson/meson_encoder_dsi.c
@@ -66,9 +66,9 @@ static void meson_encoder_dsi_atomic_ena
 	/* ENCL clock setup is handled by CCF */
 
 	meson_venc_mipi_dsi_mode_set(priv, &crtc_state->adjusted_mode);
-	meson_encl_load_gamma(priv);
 
 	writel_relaxed(0, priv->io_base + _REG(ENCL_VIDEO_EN));
+	meson_encl_load_gamma(priv);
 
 	writel_bits_relaxed(ENCL_VIDEO_MODE_ADV_VFIFO_EN, ENCL_VIDEO_MODE_ADV_VFIFO_EN,
 			    priv->io_base + _REG(ENCL_VIDEO_MODE_ADV));



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 324/555] drm/nouveau/disp: Set drm_mode_config_funcs.atomic_(check|commit) (attempt 2)
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (322 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 323/555] drm/meson: encoder_dsi: load ENCL gamma table while ENCL is disabled Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 325/555] drm/nouveau: do not return early from a synchronous VM_BIND Greg Kroah-Hartman
                   ` (230 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Ruben Wauters, Lyude Paul,
	Dave Airlie

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

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

From: Dave Airlie <airlied@redhat.com>

commit ed7fb901fce31588bd12ab95adc36ebcb51bc8ea upstream.

commit 604826acb3f5 attempted to add these flags but
commit 6c65db809796 reverted it due to it
failing on hw from pre-atomic times.

So use a second set of functions.

original commit msg from Lyude:
"Apparently we never actually filled these in, despite the fact that we do
in fact technically support atomic modesetting.

Since not having these filled in causes us to potentially forget to disable
fbdev and friends during suspend/resume, let's fix it."

Reported-by: Ruben Wauters <rubenru09@aol.com>
Closes: https://gitlab.freedesktop.org/drm/nouveau/-/work_items/517
Fixes: 6c65db809796 ("Revert "drm/nouveau/disp: Set drm_mode_config_funcs.atomic_(check|commit)"")
Cc: stable@vger.kernel.org
Reviewed-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patch.msgid.link/20261111-nouveau-atomic-fix-v1-1-118e65d3a2f5@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/nouveau/nouveau_display.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -393,6 +393,11 @@ static const struct drm_mode_config_func
 	.fb_create = nouveau_user_framebuffer_create,
 };
 
+static const struct drm_mode_config_funcs nouveau_mode_config_funcs_atomic = {
+	.fb_create = nouveau_user_framebuffer_create,
+	.atomic_commit = drm_atomic_helper_commit,
+	.atomic_check = drm_atomic_helper_check,
+};
 
 struct nouveau_drm_prop_enum_list {
 	u8 gen_mask;
@@ -693,7 +698,11 @@ nouveau_display_create(struct drm_device
 	drm_mode_create_scaling_mode_property(dev);
 	drm_mode_create_dvi_i_properties(dev);
 
-	dev->mode_config.funcs = &nouveau_mode_config_funcs;
+	/* this only gets set if the driver has the ATOMIC flag */
+	if (drm_drv_uses_atomic_modeset(dev))
+		dev->mode_config.funcs = &nouveau_mode_config_funcs_atomic;
+	else
+		dev->mode_config.funcs = &nouveau_mode_config_funcs;
 
 	dev->mode_config.min_width = 0;
 	dev->mode_config.min_height = 0;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 325/555] drm/nouveau: do not return early from a synchronous VM_BIND
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (323 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 324/555] drm/nouveau/disp: Set drm_mode_config_funcs.atomic_(check|commit) (attempt 2) Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 326/555] drm/radeon: Bound GPIO I2C table entry count from VBIOS Greg Kroah-Hartman
                   ` (229 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Mohamed Ahmed, Thomas Andersen,
	Dave Airlie

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

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

From: Mohamed Ahmed <mohamedahmedegypt2001@gmail.com>

commit b1939b201353d803f09a8eb07aa69e44f8441701 upstream.

A synchronous VM_BIND waits for its job with an interruptible wait and
ignores the result. On a signal the ioctl returns 0 while the job is
still queued. Userspace can then use the new mappings before the page
tables are written, and the channel can take an MMU fault.

Wait uninterruptibly. A synchronous job takes no syncobjs, so only the
jobs queued before it on the same scheduler can delay it.

Fixes: b88baab82871 ("drm/nouveau: implement new VM_BIND uAPI")
Cc: stable@vger.kernel.org
Signed-off-by: Mohamed Ahmed <mohamedahmedegypt2001@gmail.com>
Tested-by: Thomas Andersen <phomes@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patch.msgid.link/20261117214352.337961-2-mohamedahmedegypt2001@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/nouveau/nouveau_sched.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

--- a/drivers/gpu/drm/nouveau/nouveau_sched.c
+++ b/drivers/gpu/drm/nouveau/nouveau_sched.c
@@ -330,7 +330,11 @@ nouveau_job_submit(struct nouveau_job *j
 	mutex_unlock(&sched->mutex);
 
 	if (done_fence) {
-		dma_fence_wait(done_fence, true);
+		/* The job is queued and its VA space changes are applied. It
+		 * can neither be restarted nor reported as failed, so wait
+		 * until it has run.
+		 */
+		dma_fence_wait(done_fence, false);
 		dma_fence_put(done_fence);
 	}
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 326/555] drm/radeon: Bound GPIO I2C table entry count from VBIOS
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (324 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 325/555] drm/nouveau: do not return early from a synchronous VM_BIND Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 327/555] drm/radeon: only unregister the ATPX handler if we registered it Greg Kroah-Hartman
                   ` (228 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Alex Deucher, Andrey Misiurov

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

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

From: Andrey Misiurov <amisiurov@cloudlinux.com>

commit 7345797c8652c976d18dc4be4bae632557c3bc38 upstream.

radeon_atombios_i2c_init() derives the number of GPIO I2C entries from
the size field of the VBIOS GPIO_I2C_Info table and stores a bus for
every valid entry in rdev->i2c_bus[i], which has RADEON_MAX_I2C_BUS
(16) slots.  A table that claims more than 16 entries makes it write
past the end of the array into the rest of struct radeon_device.  A
size smaller than the common header wraps the subtraction and the loop
walks far past the table.  radeon_lookup_i2c_gpio() uses the same
calculation.

Reject undersized tables and cap the entry count at
RADEON_MAX_I2C_BUS.

Fixes: f376b94fbc0a ("drm/radeon/kms: unify i2c handling")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Andrey Misiurov <amisiurov@cloudlinux.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit ad5ddb2f77ff5e80b3c793f062dc1cad9907a2b9)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/radeon/radeon_atombios.c |   22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -125,6 +125,22 @@ static struct radeon_i2c_bus_rec radeon_
 	return i2c;
 }
 
+/*
+ * The VBIOS table size is not checked against the image; cap the
+ * entry count to RADEON_MAX_I2C_BUS, the size of rdev->i2c_bus[].
+ */
+static int radeon_atombios_gpio_i2c_num_entries(uint16_t size)
+{
+	u32 bytes;
+
+	if (size < sizeof(ATOM_COMMON_TABLE_HEADER))
+		return 0;
+
+	bytes = size - sizeof(ATOM_COMMON_TABLE_HEADER);
+	return min_t(u32, bytes / sizeof(ATOM_GPIO_I2C_ASSIGMENT),
+		     RADEON_MAX_I2C_BUS);
+}
+
 static struct radeon_i2c_bus_rec radeon_lookup_i2c_gpio(struct radeon_device *rdev,
 							       uint8_t id)
 {
@@ -142,8 +158,7 @@ static struct radeon_i2c_bus_rec radeon_
 	if (atom_parse_data_header(ctx, index, &size, NULL, NULL, &data_offset)) {
 		i2c_info = (struct _ATOM_GPIO_I2C_INFO *)(ctx->bios + data_offset);
 
-		num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) /
-			sizeof(ATOM_GPIO_I2C_ASSIGMENT);
+		num_indices = radeon_atombios_gpio_i2c_num_entries(size);
 
 		gpio = &i2c_info->asGPIO_Info[0];
 		for (i = 0; i < num_indices; i++) {
@@ -176,8 +191,7 @@ void radeon_atombios_i2c_init(struct rad
 	if (atom_parse_data_header(ctx, index, &size, NULL, NULL, &data_offset)) {
 		i2c_info = (struct _ATOM_GPIO_I2C_INFO *)(ctx->bios + data_offset);
 
-		num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) /
-			sizeof(ATOM_GPIO_I2C_ASSIGMENT);
+		num_indices = radeon_atombios_gpio_i2c_num_entries(size);
 
 		gpio = &i2c_info->asGPIO_Info[0];
 		for (i = 0; i < num_indices; i++) {



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 327/555] drm/radeon: only unregister the ATPX handler if we registered it
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (325 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 326/555] drm/radeon: Bound GPIO I2C table entry count from VBIOS Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 328/555] drm/amd/pm: send smu8 sclk level indices, not the level mask Greg Kroah-Hartman
                   ` (227 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Alex Deucher, Jiaming Fan

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

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

From: Jiaming Fan <fan.jiaming@hotmail.com>

commit 83876755d089321e426a58f365a31b27b2c77f3b upstream.

radeon_register_atpx_handler() registers the ATPX handler with
vga_switcheroo only when ATPX is detected, and ignores the result:
vga_switcheroo has a single handler slot and refuses a second handler
with -EINVAL. radeon_unregister_atpx_handler() calls
vga_switcheroo_unregister_handler() in either case, and that clears the
slot no matter who set it.

So unloading radeon removes a handler registered by another driver, such
as apple-gmux. No Radeon GPU is needed for this; loading and unloading
radeon is enough. amdgpu is another such driver: when radeon and amdgpu
are both loaded and both detect ATPX, only the first one gets the slot,
and unloading the other one clears it. Afterwards vga_switcheroo can no
longer switch outputs, and a client that uses the vga_switcheroo runtime
PM domain, such as nouveau on a non-Optimus machine with a v1 DSM, can
dereference the now NULL handler during runtime suspend.

Record whether the registration succeeded and unregister only in that
case. amdgpu has the same problem and gets the same fix.

Fixes: 6a9ee8af344e ("vga_switcheroo: initial implementation (v15)")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Jiaming Fan <fan.jiaming@hotmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit f90ef5de500fa47d8e2371d429700f0275e0b88d)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/radeon/radeon_atpx_handler.c |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

--- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c
+++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
@@ -34,6 +34,7 @@ struct radeon_atpx {
 static struct radeon_atpx_priv {
 	bool atpx_detected;
 	bool bridge_pm_usable;
+	bool handler_registered;
 	/* handle for device - and atpx */
 	acpi_handle dhandle;
 	struct radeon_atpx atpx;
@@ -605,7 +606,8 @@ void radeon_register_atpx_handler(void)
 	if (!r)
 		return;
 
-	vga_switcheroo_register_handler(&radeon_atpx_handler, handler_flags);
+	if (!vga_switcheroo_register_handler(&radeon_atpx_handler, handler_flags))
+		radeon_atpx_priv.handler_registered = true;
 }
 
 /**
@@ -615,5 +617,14 @@ void radeon_register_atpx_handler(void)
  */
 void radeon_unregister_atpx_handler(void)
 {
+	/*
+	 * vga_switcheroo has a single handler slot and unregistering clears it
+	 * no matter who set it, so leave a handler registered by another
+	 * driver, such as amdgpu or apple-gmux, in place.
+	 */
+	if (!radeon_atpx_priv.handler_registered)
+		return;
+
 	vga_switcheroo_unregister_handler();
+	radeon_atpx_priv.handler_registered = false;
 }



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 328/555] drm/amd/pm: send smu8 sclk level indices, not the level mask
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (326 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 327/555] drm/radeon: only unregister the ATPX handler if we registered it Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 329/555] drm/amdgpu/gfx_v9_0: Add gfxoff quirk for Lenovo Picasso 318F Greg Kroah-Hartman
                   ` (226 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Alex Deucher, Joshua Horne

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

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

From: Joshua Horne <hornejd@etsu.edu>

commit 535f6852652e3239c8688491ccd0ed4b6e09d14f upstream.

smu8_force_clock_level() passes the pp_dpm_sclk level mask straight to
PPSMC_MSG_SetSclkSoftMin and PPSMC_MSG_SetSclkSoftMax, which take a
level index, as the other smu8 callers do through smu8_get_sclk_level().
In manual mode, "echo 0 > pp_dpm_sclk" thus selects level 1, "echo 2"
selects level 4, and masks above the highest level index are out of
range for the SMU, so e.g. "echo 3", "echo 7" or "echo 0 1 2 3 4 5 6 7"
do not select the requested levels. The original single level version
sent 1 << level and had the same problem.

Send the lowest and highest level in the mask, as smu10 does, and reject
levels above those the SMU has enabled, as smu10 and vega20 do.

Fixes: d7341ef66870 ("drm/amd/powerplay: add some hwmgr functions for sysfs interface on Carrizo")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Joshua Horne <hornejd@etsu.edu>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 8ff6b368360adb24ccf145047b0261dfae77f28a)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
@@ -1546,15 +1546,25 @@ static int smu8_get_dal_power_level(stru
 static int smu8_force_clock_level(struct pp_hwmgr *hwmgr,
 		enum pp_clock_type type, uint32_t mask)
 {
+	struct phm_clock_voltage_dependency_table *table =
+				hwmgr->dyn_state.vddc_dependency_on_sclk;
+	uint32_t low, high;
+
 	switch (type) {
 	case PP_SCLK:
+		/* the SMU takes level indices, not a mask of levels */
+		low = mask ? (ffs(mask) - 1) : 0;
+		high = mask ? (fls(mask) - 1) : 0;
+		if (high >= min(table->count, smu8_get_max_sclk_level(hwmgr)))
+			return -EINVAL;
+
 		smum_send_msg_to_smc_with_parameter(hwmgr,
 				PPSMC_MSG_SetSclkSoftMin,
-				mask,
+				low,
 				NULL);
 		smum_send_msg_to_smc_with_parameter(hwmgr,
 				PPSMC_MSG_SetSclkSoftMax,
-				mask,
+				high,
 				NULL);
 		break;
 	default:



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 329/555] drm/amdgpu/gfx_v9_0: Add gfxoff quirk for Lenovo Picasso 318F
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (327 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 328/555] drm/amd/pm: send smu8 sclk level indices, not the level mask Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 330/555] drm/amd/display: Fix logger leak on perf trace allocation failure Greg Kroah-Hartman
                   ` (225 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Alex Deucher, Wang Jiang

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

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

From: Wang Jiang <jiangwang@kylinos.cn>

commit 24916f2c98f86c90db617d0e828d930d7a35577e upstream.

GFXOFF causes gfx ring timeout and desktop freeze on Lenovo 90NYA05DCD
(Ryzen 5 3400G, Picasso). Add a quirk entry with ANY_REV marker to
disable gfxoff for subsystem 17aa:318f regardless of chip revision.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Wang Jiang <jiangwang@kylinos.cn>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 32a647c3218d8bb5bf03f68784fbc405c1e5fbd3)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -1337,6 +1337,9 @@ struct amdgpu_gfxoff_quirk {
 	u8 revision;
 };
 
+/* Match any chip revision in amdgpu_gfxoff_quirk.revision */
+#define AMDGPU_GFXOFF_QUIRK_ANY_REV	0xff
+
 static const struct amdgpu_gfxoff_quirk amdgpu_gfxoff_quirk_list[] = {
 	/* https://bugzilla.kernel.org/show_bug.cgi?id=204689 */
 	{ 0x1002, 0x15dd, 0x1002, 0x15dd, 0xc8 },
@@ -1346,6 +1349,7 @@ static const struct amdgpu_gfxoff_quirk
 	{ 0x1002, 0x15dd, 0x1002, 0x15dd, 0xc6 },
 	/* Apple MacBook Pro (15-inch, 2019) Radeon Pro Vega 20 4 GB */
 	{ 0x1002, 0x69af, 0x106b, 0x019a, 0xc0 },
+	{ 0x1002, 0x15d8, 0x17aa, 0x318f, AMDGPU_GFXOFF_QUIRK_ANY_REV },
 	/* https://bbs.openkylin.top/t/topic/171497 */
 	{ 0x1002, 0x15d8, 0x19e5, 0x3e14, 0xc2 },
 	/* HP 705G4 DM with R5 2400G */
@@ -1362,7 +1366,8 @@ static bool gfx_v9_0_should_disable_gfxo
 		    pdev->device == p->chip_device &&
 		    pdev->subsystem_vendor == p->subsys_vendor &&
 		    pdev->subsystem_device == p->subsys_device &&
-		    pdev->revision == p->revision) {
+		    (p->revision == AMDGPU_GFXOFF_QUIRK_ANY_REV ||
+		     pdev->revision == p->revision)) {
 			return true;
 		}
 		++p;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 330/555] drm/amd/display: Fix logger leak on perf trace allocation failure
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (328 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 329/555] drm/amdgpu/gfx_v9_0: Add gfxoff quirk for Lenovo Picasso 318F Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 331/555] drm/amdgpu: enable MGCG/FGCG/PERF_CLK for GC 11.0.2 Greg Kroah-Hartman
                   ` (224 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Wayne Lin, Jackie Liu, Alex Deucher

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

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

From: Jackie Liu <liuyun01@kylinos.cn>

commit 5b148562d193fd63e5d1ae3c442d3d54403c7e51 upstream.

dc_construct_ctx() allocates a logger and stores an alias in dc->dml.logger
before allocating the performance trace object. If dc_perf_trace_create()
fails, the function frees dc_ctx without releasing the logger. Since
dc->ctx is assigned only after the trace allocation succeeds,
dc_destruct() cannot reclaim the logger on this error path.

Free the logger before discarding dc_ctx and clear dc->dml.logger to avoid
leaving a dangling alias after the failed construction.

Fixes: 5d72e247e58c ("drm/amd/display: switch DC over to the new DRM logging macros")
Reviewed-by: Wayne Lin <Wayne.Lin@amd.com>
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
Signed-off-by: Wayne Lin <Wayne.Lin@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit ac088505e74932f276ea6e3bbe19713e5770e7a1)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/amd/display/dc/core/dc.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -970,6 +970,8 @@ static bool dc_construct_ctx(struct dc *
 
 	dc_ctx->perf_trace = dc_perf_trace_create();
 	if (!dc_ctx->perf_trace) {
+		kfree(dc_ctx->logger);
+		dc->dml.logger = NULL;
 		kfree(dc_ctx);
 		ASSERT_CRITICAL(false);
 		return false;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 331/555] drm/amdgpu: enable MGCG/FGCG/PERF_CLK for GC 11.0.2
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (329 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 330/555] drm/amd/display: Fix logger leak on perf trace allocation failure Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 332/555] drm/amdgpu: Fix VCE buffer size check for DPB and input surface Greg Kroah-Hartman
                   ` (223 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Andrei Krautsou, Kenneth Feng,
	Alex Deucher

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

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

From: Andrei Krautsou <an9949an@gmail.com>

commit 491aa2b083e18ef11d34f776bcb0e396a84f47e4 upstream.

GC 11.0.2 (Navi33) never got the GFX MGCG, FGCG and PERF_CLK clock
gating flags. GC 11.0.0, 11.0.1 and 11.0.4 have all three, GC 11.0.3
has MGCG. The gfx_v11_0 code behind these flags is shared by all
GC 11 parts. Enable them for GC 11.0.2, same as for GC 11.0.0.

Without the flags the driver does not clear the override bits in
RLC_CGTT_MGCG_OVERRIDE (0x000605e7 under load), so this gating stays
off. On RX 7600S the GFX clock is limited by the GFX TDC limit
(68 A), in Linux and in Windows. With the gating off each MHz costs
more GFX current, so PMFW stops at a lower clock than in Windows.

vkpeak fp32-scalar for 300 s, median after the first 60 s, GFX
current is about 68 A (TDC limit) in all cases:

                          gfxclk    VDDGFX   GFLOPS
  current flags           2030 MHz  800 mV    8915
  + MGCG                  2261 MHz  873 mV    9921
  + MGCG, FGCG, PERF_CLK  2314 MHz  894 mV   10104
  Windows 11, AMD driver            910 mV   10157-10186

GFLOPS per MHz is the same, only the current per clock goes down.
Windows shows other clock sensors, so there I compare GFLOPS only.
With all three flags vkpeak is within 1% of Windows. MGCG gives most
of the gain, FGCG and PERF_CLK add about 2% more.

Tested on one laptop, ASUS TUF A16 FA617NS (RX 7600S, PMFW 82.97.0),
Fedora kernel 7.2.11, Mesa 26.2.5, with the same flags set by a local
debug patch. One 300 s vkpeak run for each setting and some gaming,
no amdgpu errors in dmesg. Suspend/resume and long runs are not
tested yet.

Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/6082
Signed-off-by: Andrei Krautsou <an9949an@gmail.com>
Reviewed-by: Kenneth Feng <kenneth.feng@amd.com>
Signed-off-by: Andrei Krautsou <an9949an@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 85e5015b7879c04f7b9aabc865cdf7bcdf3d7470)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/amd/amdgpu/soc21.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/gpu/drm/amd/amdgpu/soc21.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc21.c
@@ -612,7 +612,10 @@ static int soc21_common_early_init(struc
 		adev->cg_flags =
 			AMD_CG_SUPPORT_GFX_CGCG |
 			AMD_CG_SUPPORT_GFX_CGLS |
+			AMD_CG_SUPPORT_GFX_MGCG |
 			AMD_CG_SUPPORT_REPEATER_FGCG |
+			AMD_CG_SUPPORT_GFX_FGCG |
+			AMD_CG_SUPPORT_GFX_PERF_CLK |
 			AMD_CG_SUPPORT_VCN_MGCG |
 			AMD_CG_SUPPORT_JPEG_MGCG |
 			AMD_CG_SUPPORT_ATHUB_MGCG |



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 332/555] drm/amdgpu: Fix VCE buffer size check for DPB and input surface
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (330 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 331/555] drm/amdgpu: enable MGCG/FGCG/PERF_CLK for GC 11.0.2 Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 333/555] drm/amdgpu: only unregister the ATPX handler if we registered it Greg Kroah-Hartman
                   ` (222 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Leo Liu, Ruijing Dong, David Rosca,
	Alex Deucher

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

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

From: David Rosca <david.rosca@amd.com>

commit 87a841d8c0b711519fb76e2412bb293743f602bd upstream.

In create command we get pitch and height for DPB, input surface
pitch and height is in encode command.
Fix the calculation to also consider different luma and chroma pitch.

Acked-by: Leo Liu <leo.liu@amd.com>
Reviewed-by: Ruijing Dong <ruijing.dong@amd.com>
Signed-off-by: David Rosca <david.rosca@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 24c0be8ac3ef2eaa20f614b540e41382b5e97afc)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c |   35 +++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)

--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
@@ -748,6 +748,7 @@ int amdgpu_vce_ring_parse_cs(struct amdg
 	uint32_t allocated = 0;
 	uint32_t tmp, handle = 0;
 	uint32_t dummy = 0xffffffff;
+	uint32_t luma_pitch, chroma_pitch, height;
 	uint32_t *size = &dummy;
 	unsigned int idx;
 	int i, r = 0;
@@ -853,19 +854,19 @@ int amdgpu_vce_ring_parse_cs(struct amdg
 				goto out;
 			}
 
-			uint32_t width, height;
-			width = amdgpu_ib_get_value(ib, idx + 8);
-			height = amdgpu_ib_get_value(ib, idx + 10);
-
-			if (width == 0 || height == 0 ||
-			    width > 4096 || height > 2304) {
-				DRM_ERROR("invalid VCE image size: %ux%u\n",
-					  width, height);
+			luma_pitch = amdgpu_ib_get_value(ib, idx + 8);
+			chroma_pitch = amdgpu_ib_get_value(ib, idx + 9);
+			height = amdgpu_ib_get_value(ib, idx + 10); /* encRefYHeightInQw */
+
+			if (luma_pitch == 0 || chroma_pitch == 0 || height == 0 ||
+			    luma_pitch > 4096 || chroma_pitch > 4096 || height > 2304 / 8) {
+				DRM_ERROR("invalid VCE ref image size: (%u %u)x%u\n",
+					  luma_pitch, chroma_pitch, height * 8);
 				r = -EINVAL;
 				goto out;
 			}
 
-			*size = width * height * 8 * 3 / 2;
+			*size = luma_pitch * height * 8 + chroma_pitch * height * 8 / 2;
 
 			break;
 
@@ -894,13 +895,25 @@ int amdgpu_vce_ring_parse_cs(struct amdg
 			break;
 
 		case 0x03000001: /* encode */
+			height = amdgpu_ib_get_value(ib, idx + 13);
+			luma_pitch = amdgpu_ib_get_value(ib, idx + 14);
+			chroma_pitch = amdgpu_ib_get_value(ib, idx + 15);
+
+			if (luma_pitch == 0 || chroma_pitch == 0 || height == 0 ||
+			    luma_pitch > 4096 || chroma_pitch > 4096 || height > 2304) {
+				DRM_ERROR("invalid VCE image size: (%u %u)x%u\n",
+					  luma_pitch, chroma_pitch, height);
+				r = -EINVAL;
+				goto out;
+			}
+
 			r = amdgpu_vce_cs_reloc(p, ib, idx + 10, idx + 9,
-						*size, 0);
+						luma_pitch * height, 0);
 			if (r)
 				goto out;
 
 			r = amdgpu_vce_cs_reloc(p, ib, idx + 12, idx + 11,
-						*size / 3, 0);
+						chroma_pitch * height / 2, 0);
 			if (r)
 				goto out;
 			break;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 333/555] drm/amdgpu: only unregister the ATPX handler if we registered it
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (331 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 332/555] drm/amdgpu: Fix VCE buffer size check for DPB and input surface Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 334/555] drm/amdkfd: Acquire cwsr buffer during CRIU resume Greg Kroah-Hartman
                   ` (221 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Alex Deucher, Jiaming Fan

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

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

From: Jiaming Fan <fan.jiaming@hotmail.com>

commit 53fc1be11892a8e695937fdbc24db2699d23dabf upstream.

amdgpu_register_atpx_handler() registers the ATPX handler with
vga_switcheroo only when ATPX is detected, and ignores the result:
vga_switcheroo has a single handler slot and refuses a second handler
with -EINVAL. amdgpu_unregister_atpx_handler() calls
vga_switcheroo_unregister_handler() in either case, and that clears the
slot no matter who set it.

So unloading amdgpu removes a handler registered by another driver, such
as apple-gmux. No AMD GPU is needed for this; loading and unloading
amdgpu is enough. Afterwards vga_switcheroo can no longer switch outputs,
and a client that uses the vga_switcheroo runtime PM domain, such as
nouveau on a non-Optimus machine with a v1 DSM, can dereference the now
NULL handler during runtime suspend.

Record whether the registration succeeded and unregister only in that
case.

Fixes: d38ceaf99ed0 ("drm/amdgpu: add core driver (v4)")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Jiaming Fan <fan.jiaming@hotmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit fbb6ebeff9d5327e8d06a83a3f7daa88422c9127)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
@@ -45,6 +45,7 @@ struct amdgpu_atpx {
 static struct amdgpu_atpx_priv {
 	bool atpx_detected;
 	bool bridge_pm_usable;
+	bool handler_registered;
 	unsigned int quirks;
 	/* handle for device - and atpx */
 	acpi_handle dhandle;
@@ -666,7 +667,8 @@ void amdgpu_register_atpx_handler(void)
 	if (!r)
 		return;
 
-	vga_switcheroo_register_handler(&amdgpu_atpx_handler, handler_flags);
+	if (!vga_switcheroo_register_handler(&amdgpu_atpx_handler, handler_flags))
+		amdgpu_atpx_priv.handler_registered = true;
 }
 
 /**
@@ -676,5 +678,14 @@ void amdgpu_register_atpx_handler(void)
  */
 void amdgpu_unregister_atpx_handler(void)
 {
+	/*
+	 * vga_switcheroo has a single handler slot and unregistering clears it
+	 * no matter who set it, so leave a handler registered by another
+	 * driver, such as apple-gmux, in place.
+	 */
+	if (!amdgpu_atpx_priv.handler_registered)
+		return;
+
 	vga_switcheroo_unregister_handler();
+	amdgpu_atpx_priv.handler_registered = false;
 }



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 334/555] drm/amdkfd: Acquire cwsr buffer during CRIU resume
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (332 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 333/555] drm/amdgpu: only unregister the ATPX handler if we registered it Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 335/555] drm/amdkfd: check CRIU SVM priv data bounds before allocating Greg Kroah-Hartman
                   ` (220 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, David Francis, Felix Kuehling,
	Alex Deucher

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

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

From: David Francis <David.Francis@amd.com>

commit 86aa8332ab2b2296cda98cde189e2ec539c4e1b3 upstream.

In normal kfd queue create, a reference to the cwsr svm range
is acquired so that this buffer is not freed from underneath the
queue. We weren't doing that.

After svm ranges are restored in RESUME phase of CRIU, go through
all the queues and acquire a reference to the cwsr.

Signed-off-by: David Francis <David.Francis@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 5a00bdd267a5d87307f9aaddabf550f2410c9d40)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c               |    2 +
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h                  |    3 +
 drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c |   32 +++++++++++++++++
 drivers/gpu/drm/amd/amdkfd/kfd_queue.c                 |    4 +-
 4 files changed, 39 insertions(+), 2 deletions(-)

--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -2689,6 +2689,8 @@ static int criu_resume(struct file *file
 		goto exit;
 	}
 
+	kfd_criu_resume_queues(target);
+
 	ret =  amdgpu_amdkfd_criu_resume(target->kgd_process_info);
 	if (ret)
 		pr_err("amdgpu_amdkfd_criu_resume failed for %i\n", args->pid);
--- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
@@ -1323,6 +1323,8 @@ int kfd_criu_restore_event(struct file *
 			   uint8_t __user *user_priv_data,
 			   uint64_t *priv_data_offset,
 			   uint64_t max_priv_data_size);
+
+int kfd_criu_resume_queues(struct kfd_process *p);
 /* CRIU - End */
 
 /* Queue Context Management */
@@ -1339,6 +1341,7 @@ void kfd_queue_unref_bo_va(struct amdgpu
 int kfd_queue_unref_bo_vas(struct kfd_process_device *pdd,
 			   struct queue_properties *properties);
 void kfd_queue_ctx_save_restore_size(struct kfd_topology_device *dev);
+int kfd_queue_buffer_svm_get(struct kfd_process_device *pdd, u64 addr, u64 size);
 
 struct mqd_manager *mqd_manager_init_cik(enum KFD_MQD_TYPE type,
 		struct kfd_node *dev);
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
@@ -1107,6 +1107,38 @@ exit:
 	return ret;
 }
 
+int kfd_criu_resume_queues(struct kfd_process *p)
+{
+	int ret, i;
+	u64 total_cwsr_size;
+
+	for (i = 0; i < p->n_pdds; i++) {
+		struct kfd_process_device *pdd = p->pdds[i];
+		struct kfd_topology_device *topo_dev;
+		struct queue *q;
+
+		topo_dev = kfd_topology_device_by_id(pdd->dev->id);
+
+		list_for_each_entry(q, &pdd->qpd.queues_list, list) {
+			total_cwsr_size = q->properties.ctx_save_restore_area_size +
+					  topo_dev->node_props.debug_memory_size;
+			if (check_mul_overflow(total_cwsr_size,
+					       NUM_XCC(pdd->dev->xcc_mask),
+					       &total_cwsr_size))
+				return -EINVAL;
+			total_cwsr_size = ALIGN(total_cwsr_size, PAGE_SIZE);
+
+			ret = kfd_queue_buffer_svm_get(pdd, q->properties.ctx_save_restore_area_address,
+						       total_cwsr_size);
+			if (ret)
+				return ret;
+		}
+
+	}
+
+	return 0;
+}
+
 int pqm_get_queue_checkpoint_info(struct process_queue_manager *pqm,
 				  unsigned int qid,
 				  uint32_t *mqd_size,
--- a/drivers/gpu/drm/amd/amdkfd/kfd_queue.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_queue.c
@@ -88,7 +88,7 @@ void uninit_queue(struct queue *q)
 
 #if IS_ENABLED(CONFIG_HSA_AMD_SVM)
 
-static int kfd_queue_buffer_svm_get(struct kfd_process_device *pdd, u64 addr, u64 size)
+int kfd_queue_buffer_svm_get(struct kfd_process_device *pdd, u64 addr, u64 size)
 {
 	struct kfd_process *p = pdd->process;
 	struct list_head update_list;
@@ -183,7 +183,7 @@ static void kfd_queue_buffer_svm_put(str
 }
 #else
 
-static int kfd_queue_buffer_svm_get(struct kfd_process_device *pdd, u64 addr, u64 size)
+int kfd_queue_buffer_svm_get(struct kfd_process_device *pdd, u64 addr, u64 size)
 {
 	return -EINVAL;
 }



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 335/555] drm/amdkfd: check CRIU SVM priv data bounds before allocating
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (333 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 334/555] drm/amdkfd: Acquire cwsr buffer during CRIU resume Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 336/555] drm/amdkfd: Dont reuse a VRAM page that is still referenced Greg Kroah-Hartman
                   ` (219 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Perry Yuan, Yifan Zhang,
	Alex Deucher

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

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

From: Perry Yuan <perry.yuan@amd.com>

commit 732239b002678d8c534503f52a16afc310095523 upstream.

kfd_criu_restore_svm() allocated the per-range metadata before checking
that the range fits in the user supplied private data buffer, so an out
of range offset cost a pointless kzalloc()/kfree() round trip. Do the
bounds check first and return -EINVAL directly.

v2:
- split the original patch into two, one change per patch (Yifan)

Signed-off-by: Perry Yuan <perry.yuan@amd.com>
Reviewed-by: Yifan Zhang <yifan1.zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 0c3caec1161e458092364cb448e5bd165a26dcdb)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -4112,15 +4112,14 @@ int kfd_criu_restore_svm(struct kfd_proc
 	svm_priv_data_size = sizeof(struct kfd_criu_svm_range_priv_data) +
 								svm_attrs_size;
 
+	if (*priv_data_offset + svm_priv_data_size > max_priv_data_size)
+		return -EINVAL;
+
 	criu_svm_md = kzalloc(svm_object_md_size, GFP_KERNEL);
 	if (!criu_svm_md) {
 		pr_err("failed to allocate memory to store svm metadata\n");
 		return -ENOMEM;
 	}
-	if (*priv_data_offset + svm_priv_data_size > max_priv_data_size) {
-		ret = -EINVAL;
-		goto exit;
-	}
 
 	ret = copy_from_user(&criu_svm_md->data, user_priv_ptr + *priv_data_offset,
 			     svm_priv_data_size);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 336/555] drm/amdkfd: Dont reuse a VRAM page that is still referenced
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (334 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 335/555] drm/amdkfd: check CRIU SVM priv data bounds before allocating Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 337/555] drm/amdkfd: keep the DMA addresses of a range intact if splitting fails Greg Kroah-Hartman
                   ` (218 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Apurv Mishra, Philip Yang,
	Alex Deucher

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

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

From: Apurv Mishra <Apurv.Mishra@amd.com>

commit 8cd5429d429eced2441173b3306f7e137a4dc31f upstream.

In svm_migrate_copy_to_vram(), skip VRAM pages with a non-zero refcount
and leave those pages in system memory for this migration.

When an svm_bo is reused, a VRAM page can still be held by an in-flight
CPU fault (do_swap_page -> svm_migrate_to_ram). Migrating to VRAM then
re-initializes the page via zone_device_page_init(), resetting its
refcount. The fault's late put_page() frees the page mid-migration, so
migrate_vma_finalize() never restores that PTE. It is left pointing at a
freed system page and hmm_range_fault() hits BUG_ON in
pfn_swap_entry_to_page() (swapops.h).

Signed-off-by: Apurv Mishra <Apurv.Mishra@amd.com>
Reviewed-by: Philip Yang <Philip.Yang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 1f19aa7acacbce35584dd8f75a30880096fda6a4)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/amd/amdkfd/kfd_migrate.c |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

--- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
@@ -277,16 +277,26 @@ svm_migrate_copy_to_vram(struct kfd_node
 			 npages << PAGE_SHIFT, &cursor);
 	mpages = 0;
 	for (i = j = 0; (i < npages) && (mpages < migrate->cpages); i++) {
-		struct page *spage;
+		struct page *spage = migrate_pfn_to_page(migrate->src[i]);
 
 		if (migrate->src[i] & MIGRATE_PFN_MIGRATE) {
 			dst[i] = cursor.start + (j << PAGE_SHIFT);
 			migrate->dst[i] = svm_migrate_addr_to_pfn(adev, dst[i]);
-			svm_migrate_get_vram_page(prange, migrate->dst[i]);
-			migrate->dst[i] = migrate_pfn(migrate->dst[i]);
-			mpages++;
+			/*
+			 * A reused svm_bo page may still be held by a CPU fault.
+			 * Reinitializing it would free it under this migration,
+			 * so leave this page in system memory.
+			 */
+			if (page_ref_count(pfn_to_page(migrate->dst[i]))) {
+				dst[i] = 0;
+				migrate->dst[i] = 0;
+				spage = NULL;
+			} else {
+				svm_migrate_get_vram_page(prange, migrate->dst[i]);
+				migrate->dst[i] = migrate_pfn(migrate->dst[i]);
+				mpages++;
+			}
 		}
-		spage = migrate_pfn_to_page(migrate->src[i]);
 		if (spage && !is_zone_device_page(spage)) {
 			src[i] = dma_map_page(dev, spage, 0, PAGE_SIZE,
 					      DMA_BIDIRECTIONAL);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 337/555] drm/amdkfd: keep the DMA addresses of a range intact if splitting fails
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (335 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 336/555] drm/amdkfd: Dont reuse a VRAM page that is still referenced Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 338/555] drm/amdkfd: wait for the queue quiesce in concurrent SVM evictions Greg Kroah-Hartman
                   ` (217 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Felix Kuehling, Jesse Zhang,
	Alex Deucher

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

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

From: Jesse Zhang <Jesse.Zhang@amd.com>

commit 63b42ad2fdd371ae4a86658295943d60a86a519b upstream.

svm_range_split_pages() splits the DMA address array of one GPU after
the other, and each split replaces the old range's array by a shorter
one. If a later GPU's array can't be allocated, the old range is left
with the arrays of the earlier GPUs already shortened, but with its old
size. Unmapping it then walks past their end.

On navi31 with its iGPU, an SVM range accessible by both GPUs, and
unmapping a page in its middle with allocations failing in turn through
failslab:

  BUG: KASAN: slab-out-of-bounds in svm_range_dma_unmap_dev+0x13f/0x170 [amdgpu]
  Read of size 8 at addr ffff88819ac32800 by task kworker/8:1/171
   svm_range_dma_unmap_dev+0x13f/0x170 [amdgpu]
   svm_range_dma_unmap+0x119/0x2c0 [amdgpu]
   svm_range_free+0x312/0x520 [amdgpu]
   svm_range_handle_list_op+0x326/0x500 [amdgpu]
   svm_range_deferred_list_work+0x338/0x790 [amdgpu]
  Allocated by task 2749:
   svm_range_copy_array.constprop.0+0x55/0x190 [amdgpu]
   svm_range_split+0x388/0x17b0 [amdgpu]
   svm_range_unmap_split+0x254/0x370 [amdgpu]
   svm_range_cpu_invalidate_pagetables+0xb29/0x11d0 [amdgpu]
  The buggy address is located 0 bytes to the right of
   allocated 2048-byte region [ffff88819ac32000, ffff88819ac32800)

Split the arrays of all GPUs first and only replace the old ones once
all succeeded. With that the 2759 unmaps of the same sweep give no
report.

Fixes: f80fe9d3c114 ("drm/amdkfd: map svm range to GPUs")
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 3cbd0b498ac18821ec01c08e39050a4d22ea9eeb)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c |   23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -974,7 +974,7 @@ svm_range_split_array(void *ppnew, void
 		kvfree(new);
 		return -ENOMEM;
 	}
-	kvfree(pold);
+	/* The caller frees pold once all arrays of the range are split */
 	*(void **)ppold = old;
 	*(void **)ppnew = new;
 
@@ -985,19 +985,36 @@ static int
 svm_range_split_pages(struct svm_range *new, struct svm_range *old,
 		      uint64_t start, uint64_t last)
 {
+	dma_addr_t *old_dma[MAX_GPU_INSTANCE];
 	uint64_t npages = last - start + 1;
 	bool has_dma_addr = false;
 	int i, r;
 
+	/*
+	 * Split the arrays of all GPUs before replacing any of them, the old
+	 * range must stay intact if one fails.
+	 */
 	for (i = 0; i < MAX_GPU_INSTANCE; i++) {
+		old_dma[i] = old->dma_addr[i];
 		if (old->dma_addr[i])
 			has_dma_addr = true;
-		r = svm_range_split_array(&new->dma_addr[i], &old->dma_addr[i],
+		r = svm_range_split_array(&new->dma_addr[i], &old_dma[i],
 					  sizeof(*old->dma_addr[i]), old->start,
 					  npages, new->start, new->npages,
 					  old->actual_loc ? &new->vram_pages : NULL);
-		if (r)
+		if (r) {
+			/* new->dma_addr[] goes with the new range */
+			while (i--)
+				if (old_dma[i] != old->dma_addr[i])
+					kvfree(old_dma[i]);
 			return r;
+		}
+	}
+	for (i = 0; i < MAX_GPU_INSTANCE; i++) {
+		if (old_dma[i] == old->dma_addr[i])
+			continue;
+		kvfree(old->dma_addr[i]);
+		old->dma_addr[i] = old_dma[i];
 	}
 	if (old->actual_loc) {
 		/*



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 338/555] drm/amdkfd: wait for the queue quiesce in concurrent SVM evictions
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (336 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 337/555] drm/amdkfd: keep the DMA addresses of a range intact if splitting fails Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 339/555] drm/vc4: Hold a runtime PM reference while allocating the binner BO Greg Kroah-Hartman
                   ` (216 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Qiang Han, Philip Yang,
	Felix Kuehling, Alex Deucher

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

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

From: Qiang Han <qiangh@amd.com>

commit 8c417209754a9d2cd8dc1e78c0dfadefd0ad0e82 upstream.

With XNACK off, svm_range_evict() leaves the GPU page tables in place
and relies on the process's queues being stopped before the MMU
notifier returns.

Only the first eviction (evicted_ranges == 1) calls
kgd2kfd_quiesce_mm(). The quiesce preempts every GPU the process has
opened and takes milliseconds. Any other range invalidated in the
meantime sees evicted_ranges > 1 and returns at once. The core mm then
frees, migrates or reuses the page while the queues still run, and an
in-flight SDMA or blit copy accesses it through the old GPU PTE. The
result is silent corruption of the copy, or of whatever process now
owns the page.

Hold a new svms->evict_lock across the first evictor's quiesce, so that
concurrent evictions return only after the queues have stopped. This is
the scheme amdgpu_amdkfd_evict_userptr() uses with
process_info->notifier_lock. evict_lock nests inside prange->lock and
is taken nowhere else. Under it, the quiesce path takes the dqm lock,
which is already used in MMU notifiers (memalloc_noreclaim).

One way to reach this: a pageable hipMemcpy() larger than 1 MiB. ROCclr
pins the buffer with hsa_amd_memory_lock(), libhsakmt registers it as
a KFD SVM range, and host memory pressure (reclaim, compaction,
allocator purge) invalidates the range.

Fixes: 8a7c184a16d7 ("drm/amdkfd: svm range eviction and restore")
Signed-off-by: Qiang Han <qiangh@amd.com>
Signed-off-by: Philip Yang <Philip.Yang@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit d443bd2512c04a5d34c4473ce9ce2f2a6f7bf8f5)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h |    2 +
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c  |   35 ++++++++++++++++++++++------------
 2 files changed, 25 insertions(+), 12 deletions(-)

--- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
@@ -882,6 +882,8 @@ struct svm_range_list {
 	struct list_head		deferred_range_list;
 	struct list_head                criu_svm_metadata_list;
 	spinlock_t			deferred_list_lock;
+	/* serializes XNACK-off evictions with the queue quiesce */
+	struct mutex			evict_lock;
 	atomic_t			evicted_ranges;
 	atomic_t			drain_pagefaults;
 	struct delayed_work		restore_work;
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -2022,21 +2022,30 @@ svm_range_evict(struct svm_range *prange
 		if (prange->start <= last && prange->last >= start)
 			atomic_inc(&prange->invalid);
 
+		/* The MMU notifier must not return before the GPU has stopped
+		 * accessing the invalidated pages. Only the first eviction stops
+		 * the queues, which takes milliseconds (HWS preemption on every
+		 * GPU of the process). Serialize all evictions of this process so
+		 * that a concurrent invalidation of another range waits until
+		 * that quiesce has completed instead of returning while queues
+		 * still run on stale PTEs.
+		 */
+		mutex_lock(&svms->evict_lock);
 		evicted_ranges = atomic_inc_return(&svms->evicted_ranges);
-		if (evicted_ranges != 1)
-			return r;
+		if (evicted_ranges == 1) {
+			pr_debug("evicting svms 0x%p range [0x%lx 0x%lx]\n",
+				 prange->svms, prange->start, prange->last);
 
-		pr_debug("evicting svms 0x%p range [0x%lx 0x%lx]\n",
-			 prange->svms, prange->start, prange->last);
-
-		/* First eviction, stop the queues */
-		r = kgd2kfd_quiesce_mm(mm, KFD_QUEUE_EVICTION_TRIGGER_SVM);
-		if (r)
-			pr_debug("failed to quiesce KFD\n");
+			/* First eviction, stop the queues */
+			r = kgd2kfd_quiesce_mm(mm, KFD_QUEUE_EVICTION_TRIGGER_SVM);
+			if (r)
+				pr_debug("failed to quiesce KFD\n");
 
-		pr_debug("schedule to restore svm %p ranges\n", svms);
-		queue_delayed_work(system_freezable_wq, &svms->restore_work,
-			msecs_to_jiffies(AMDGPU_SVM_RANGE_RESTORE_DELAY_MS));
+			pr_debug("schedule to restore svm %p ranges\n", svms);
+			queue_delayed_work(system_freezable_wq, &svms->restore_work,
+					   msecs_to_jiffies(AMDGPU_SVM_RANGE_RESTORE_DELAY_MS));
+		}
+		mutex_unlock(&svms->evict_lock);
 	} else {
 		unsigned long s, l;
 		uint32_t trigger;
@@ -3332,6 +3341,7 @@ void svm_range_list_fini(struct kfd_proc
 		svm_range_free(prange, true);
 	}
 
+	mutex_destroy(&p->svms.evict_lock);
 	mutex_destroy(&p->svms.lock);
 
 	pr_debug("pasid 0x%x svms 0x%p done\n", p->pasid, &p->svms);
@@ -3344,6 +3354,7 @@ int svm_range_list_init(struct kfd_proce
 
 	svms->objects = RB_ROOT_CACHED;
 	mutex_init(&svms->lock);
+	mutex_init(&svms->evict_lock);
 	INIT_LIST_HEAD(&svms->list);
 	atomic_set(&svms->evicted_ranges, 0);
 	atomic_set(&svms->drain_pagefaults, 0);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 339/555] drm/vc4: Hold a runtime PM reference while allocating the binner BO
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (337 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 338/555] drm/amdkfd: wait for the queue quiesce in concurrent SVM evictions Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 340/555] drm/vc4: Check for a validated shader before reading its thread mode Greg Kroah-Hartman
                   ` (215 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Iago Toral Quiroga, Maíra Canal

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

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

From: Maíra Canal <mcanal@igalia.com>

commit a7d7a25b566635ac1ee6af1c3ef06484cf752c3f upstream.

bin_bo_alloc() arms the out-of-memory interrupt once it has allocated the
binner BO, and accessing a V3D register requires the block to be powered.
vc4_submit_cl_ioctl() already holds a runtime PM reference by the time it
reaches vc4_get_bcl(), but vc4_create_bo_ioctl() reaches vc4_grab_bin_bo()
without one, so the write can land on a suspended device.

Take the reference in vc4_v3d_bin_bo_get(), which covers both callers, and
take it before bin_bo_lock so that runtime PM is never waited for with the
mutex held.

Cc: stable@vger.kernel.org
Fixes: 35c8b4b2c0fe ("drm/vc4: Allocate binner bo when starting to use the V3D")
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Link: https://patch.msgid.link/20261111-vc4-irq-cleanup-v2-1-aa757bb742f2@igalia.com
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/vc4/vc4_v3d.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

--- a/drivers/gpu/drm/vc4/vc4_v3d.c
+++ b/drivers/gpu/drm/vc4/vc4_v3d.c
@@ -320,11 +320,15 @@ static int bin_bo_alloc(struct vc4_dev *
 
 int vc4_v3d_bin_bo_get(struct vc4_dev *vc4, bool *used)
 {
-	int ret = 0;
+	int ret;
 
 	if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4))
 		return -ENODEV;
 
+	ret = vc4_v3d_pm_get(vc4);
+	if (ret)
+		return ret;
+
 	mutex_lock(&vc4->bin_bo_lock);
 
 	if (used && *used)
@@ -340,6 +344,7 @@ int vc4_v3d_bin_bo_get(struct vc4_dev *v
 
 complete:
 	mutex_unlock(&vc4->bin_bo_lock);
+	vc4_v3d_pm_put(vc4);
 
 	return ret;
 }



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 340/555] drm/vc4: Check for a validated shader before reading its thread mode
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (338 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 339/555] drm/vc4: Hold a runtime PM reference while allocating the binner BO Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 341/555] drm/vc4: Clear the slice caches before resetting a stalled GPU Greg Kroah-Hartman
                   ` (214 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Iago Toral Quiroga, Maíra Canal

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

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

From: Maíra Canal <mcanal@igalia.com>

commit 15da41dff1f66a389d238db60a1c19fa83582d07 upstream.

validate_gl_shader_rec() reads the thread mode from the validated_shader
of the FS, VS and CS BOs before checking it for NULL. A shader record
pointing at a BO not created by DRM_IOCTL_VC4_CREATE_SHADER_BO has no
validated_shader, so userspace can trigger a NULL pointer dereference.

Check that every shader BO has a validated shader before using it.

Cc: stable@vger.kernel.org
Fixes: c778cc5df944 ("drm/vc4: Add fragment shader threading support")
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Link: https://patch.msgid.link/20261118-vc4-icache-workaround-v1-2-5b8adc2c84fe@igalia.com
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/vc4/vc4_validate.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

--- a/drivers/gpu/drm/vc4/vc4_validate.c
+++ b/drivers/gpu/drm/vc4/vc4_validate.c
@@ -830,6 +830,9 @@ validate_gl_shader_rec(struct drm_device
 		bo[i] = to_drm_gem_dma_obj(exec->bo[src_handles[i]]);
 		if (!bo[i])
 			return -EINVAL;
+
+		if (!to_vc4_bo(&bo[i]->base)->validated_shader)
+			return -EINVAL;
 	}
 	for (i = shader_reloc_count; i < nr_relocs; i++) {
 		bo[i] = vc4_use_bo(exec, src_handles[i]);
@@ -850,7 +853,8 @@ validate_gl_shader_rec(struct drm_device
 	}
 
 	for (i = 0; i < shader_reloc_count; i++) {
-		struct vc4_validated_shader_info *validated_shader;
+		struct vc4_validated_shader_info *validated_shader =
+			to_vc4_bo(&bo[i]->base)->validated_shader;
 		uint32_t o = shader_reloc_offsets[i];
 		uint32_t src_offset = *(uint32_t *)(pkt_u + o);
 		uint32_t *texture_handles_u;
@@ -865,10 +869,6 @@ validate_gl_shader_rec(struct drm_device
 			return -EINVAL;
 		}
 
-		validated_shader = to_vc4_bo(&bo[i]->base)->validated_shader;
-		if (!validated_shader)
-			return -EINVAL;
-
 		if (validated_shader->uniforms_src_size >
 		    exec->uniforms_size) {
 			DRM_DEBUG("Uniforms src buffer overflow\n");



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 341/555] drm/vc4: Clear the slice caches before resetting a stalled GPU
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (339 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 340/555] drm/vc4: Check for a validated shader before reading its thread mode Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 342/555] drm/vc4: Fix off-by-one in the shader record BO handle check Greg Kroah-Hartman
                   ` (213 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Iago Toral Quiroga, Maíra Canal

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

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

From: Maíra Canal <mcanal@igalia.com>

commit af1cf92e8617a7f7aa24b415596cbf64b76a12e7 upstream.

Starting shader code at varying offsets makes the GFXH-16 icache livelock
unlikely, but not impossible. When the livelock happens, the QPUs make no
progress and the hangcheck resets the GPU, losing the job.

When the hangcheck finds no progress, clear the slice instruction and
uniforms caches and check again before resetting. If the stall is a
livelock, clearing the caches can break it and let the job continue.

Drop round_jiffies_up() from the hangcheck timer, so checks run every
100 ms instead of at the next whole second. This shortens the screen
freeze before the caches are cleared. Long jobs are unaffected: while the
control lists advance, the hangcheck won't clear the caches or reset the
GPU.

Cc: stable@vger.kernel.org
Fixes: d5b1a78a772f ("drm/vc4: Add support for drawing 3D frames.")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/16652
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Link: https://patch.msgid.link/20261118-vc4-icache-workaround-v1-4-5b8adc2c84fe@igalia.com
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/vc4/vc4_drv.h |    5 +++++
 drivers/gpu/drm/vc4/vc4_gem.c |   20 ++++++++++++++++++--
 2 files changed, 23 insertions(+), 2 deletions(-)

--- a/drivers/gpu/drm/vc4/vc4_drv.h
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
@@ -225,6 +225,11 @@ struct vc4_dev {
 	struct {
 		struct timer_list timer;
 		struct work_struct reset_work;
+
+		/* The instruction and uniforms caches were cleared at the
+		 * last check that found no progress.
+		 */
+		bool caches_cleared;
 	} hangcheck;
 
 	struct drm_modeset_lock ctm_state_lock;
--- a/drivers/gpu/drm/vc4/vc4_gem.c
+++ b/drivers/gpu/drm/vc4/vc4_gem.c
@@ -41,8 +41,7 @@ vc4_queue_hangcheck(struct drm_device *d
 {
 	struct vc4_dev *vc4 = to_vc4_dev(dev);
 
-	mod_timer(&vc4->hangcheck.timer,
-		  round_jiffies_up(jiffies + msecs_to_jiffies(100)));
+	mod_timer(&vc4->hangcheck.timer, jiffies + msecs_to_jiffies(100));
 }
 
 struct vc4_hang_state {
@@ -341,6 +340,7 @@ vc4_hangcheck_elapsed(struct timer_list
 
 	/* If idle, we can stop watching for hangs. */
 	if (!bin_exec && !render_exec) {
+		vc4->hangcheck.caches_cleared = false;
 		spin_unlock_irqrestore(&vc4->job_lock, irqflags);
 		return;
 	}
@@ -357,11 +357,27 @@ vc4_hangcheck_elapsed(struct timer_list
 			bin_exec->last_ct0ca = ct0ca;
 		if (render_exec)
 			render_exec->last_ct1ca = ct1ca;
+
+		vc4->hangcheck.caches_cleared = false;
+
 		spin_unlock_irqrestore(&vc4->job_lock, irqflags);
 		vc4_queue_hangcheck(dev);
 		return;
 	}
 
+	/* Clear the slice caches to workaround GFXH-16 */
+	if (!vc4->hangcheck.caches_cleared) {
+		V3D_WRITE(V3D_SLCACTL, VC4_SET_FIELD(0xf, V3D_SLCACTL_ICC) |
+			  VC4_SET_FIELD(0xf, V3D_SLCACTL_UCC));
+
+		vc4->hangcheck.caches_cleared = true;
+		spin_unlock_irqrestore(&vc4->job_lock, irqflags);
+		vc4_queue_hangcheck(dev);
+		return;
+	}
+
+	vc4->hangcheck.caches_cleared = false;
+
 	spin_unlock_irqrestore(&vc4->job_lock, irqflags);
 
 	/* We've gone too long with no progress, reset.  This has to



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 342/555] drm/vc4: Fix off-by-one in the shader record BO handle check
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (340 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 341/555] drm/vc4: Clear the slice caches before resetting a stalled GPU Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 343/555] drm/vc4: Start shader code at varying offsets in its BO Greg Kroah-Hartman
                   ` (212 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Iago Toral Quiroga, Maíra Canal

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

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

From: Maíra Canal <mcanal@igalia.com>

commit 1fbbd14add401c70c178f0fa13016a3a53ef0de5 upstream.

validate_gl_shader_rec() accepts a shader BO handle equal to
exec->bo_count, reading one entry past the end of exec->bo[] and
using it as a GEM object.

Reject handles that aren't below exec->bo_count.

Cc: stable@vger.kernel.org
Fixes: d5b1a78a772f ("drm/vc4: Add support for drawing 3D frames.")
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Link: https://patch.msgid.link/20261118-vc4-icache-workaround-v1-1-5b8adc2c84fe@igalia.com
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/vc4/vc4_validate.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/gpu/drm/vc4/vc4_validate.c
+++ b/drivers/gpu/drm/vc4/vc4_validate.c
@@ -822,7 +822,7 @@ validate_gl_shader_rec(struct drm_device
 	exec->shader_rec_size -= packet_size;
 
 	for (i = 0; i < shader_reloc_count; i++) {
-		if (src_handles[i] > exec->bo_count) {
+		if (src_handles[i] >= exec->bo_count) {
 			DRM_DEBUG("Shader handle %d too big\n", src_handles[i]);
 			return -EINVAL;
 		}



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 343/555] drm/vc4: Start shader code at varying offsets in its BO
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (341 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 342/555] drm/vc4: Fix off-by-one in the shader record BO handle check Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 344/555] drm/vmwgfx: avoid underflow when stripping short GuestInfo replies Greg Kroah-Hartman
                   ` (211 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Iago Toral Quiroga, Maíra Canal

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

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

From: Maíra Canal <mcanal@igalia.com>

commit c0e1ed41ad86cf5230d64dc5f2c6d2e3aeb59937 upstream.

VC4 is affected by the HW erratum GFXH-16: the QPUs can get stuck in a
loop where instruction cache loads are evicted before they are used.

The QPUs of a slice share one instruction cache. Shader BOs are page
aligned and the code always starts at offset 0, so instructions at the
same position in different shaders end up mapping to the same cache sets.
When the four QPUs of a slice run four different shaders, their fills
evict each other, no instruction executes and the hangcheck resets the
GPU.

Place each shader's code at one of four offsets, 256 bytes apart, inside
its BO, and add the offset when relocating the shader record. Shader code
is position independent, as the validator only accepts relative branches.
The offsets are tracked per client, so shaders a given client creates in
sequence (which tend to run together) start in different sets.

Notice that this approach makes the livelock unlikely, but not impossible.
The next commit will address the remaining cases.

On a Raspberry Pi 3 running the issue's reproducer, GPU resets went from
dozens in an hour to none.

Cc: stable@vger.kernel.org
Fixes: 463873d57014 ("drm/vc4: Add an API for creating GPU shaders in GEM BOs.")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/16652
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Link: https://patch.msgid.link/20261118-vc4-icache-workaround-v1-3-5b8adc2c84fe@igalia.com
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/vc4/vc4_bo.c               |   43 ++++++++++++++++++++++-------
 drivers/gpu/drm/vc4/vc4_drv.h              |   10 ++++++
 drivers/gpu/drm/vc4/vc4_validate.c         |    3 +-
 drivers/gpu/drm/vc4/vc4_validate_shaders.c |    7 ++--
 4 files changed, 48 insertions(+), 15 deletions(-)

--- a/drivers/gpu/drm/vc4/vc4_bo.c
+++ b/drivers/gpu/drm/vc4/vc4_bo.c
@@ -17,6 +17,7 @@
  */
 
 #include <linux/dma-buf.h>
+#include <linux/overflow.h>
 
 #include <drm/drm_fourcc.h>
 
@@ -836,6 +837,19 @@ int vc4_mmap_bo_ioctl(struct drm_device
 	return 0;
 }
 
+/*
+ * QPUs sharing a slice's instruction cache can livelock evicting each
+ * other's fills. Considering that shader BOs are page aligned, any code
+ * at offset 0 maps every shader to the same cache sets. This makes a
+ * livelock more likely to happen due to GFXH-16.
+ *
+ * Start each shader at one of four offsets, cycled per client, to spread
+ * them across sets. The use of four different offsets is motivated by the
+ * number of QPUs per slice (4 QPUs).
+ */
+#define VC4_SHADER_OFFSET_STEP	256
+#define VC4_SHADER_OFFSET_NUM	4
+
 int
 vc4_create_shader_bo_ioctl(struct drm_device *dev, void *data,
 			   struct drm_file *file_priv)
@@ -844,6 +858,7 @@ vc4_create_shader_bo_ioctl(struct drm_de
 	struct vc4_file *vc4file = file_priv->driver_priv;
 	struct vc4_dev *vc4 = to_vc4_dev(dev);
 	struct vc4_bo *bo = NULL;
+	u32 offset, size;
 	int ret;
 
 	if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4))
@@ -865,29 +880,37 @@ vc4_create_shader_bo_ioctl(struct drm_de
 		return -EINVAL;
 	}
 
+	offset = ((u32)atomic_inc_return(&vc4file->shader_offset_idx) %
+		  VC4_SHADER_OFFSET_NUM) * VC4_SHADER_OFFSET_STEP;
+
+	if (check_add_overflow(offset, args->size, &size))
+		return -EINVAL;
+
 	ret = vc4_grab_bin_bo(vc4, vc4file);
 	if (ret)
 		return ret;
 
-	bo = vc4_bo_create(dev, args->size, true, VC4_BO_TYPE_V3D_SHADER);
+	bo = vc4_bo_create(dev, size, true, VC4_BO_TYPE_V3D_SHADER);
 	if (IS_ERR(bo))
 		return PTR_ERR(bo);
 
 	bo->madv = VC4_MADV_WILLNEED;
+	bo->shader_offset = offset;
 
-	if (copy_from_user(bo->base.vaddr,
-			     (void __user *)(uintptr_t)args->data,
-			     args->size)) {
+	/* Clear the memory around the code, which may come from the BO
+	 * cache.
+	 */
+	memset(bo->base.vaddr, 0, offset);
+	if (copy_from_user(bo->base.vaddr + offset,
+			   (void __user *)(uintptr_t)args->data,
+			   args->size)) {
 		ret = -EFAULT;
 		goto fail;
 	}
-	/* Clear the rest of the memory from allocating from the BO
-	 * cache.
-	 */
-	memset(bo->base.vaddr + args->size, 0,
-	       bo->base.base.size - args->size);
+	memset(bo->base.vaddr + offset + args->size, 0,
+	       bo->base.base.size - offset - args->size);
 
-	bo->validated_shader = vc4_validate_shader(&bo->base);
+	bo->validated_shader = vc4_validate_shader(&bo->base, offset);
 	if (!bo->validated_shader) {
 		ret = -EINVAL;
 		goto fail;
--- a/drivers/gpu/drm/vc4/vc4_drv.h
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
@@ -277,6 +277,9 @@ struct vc4_bo {
 	 */
 	struct vc4_validated_shader_info *validated_shader;
 
+	/* Byte offset of the shader code in the BO. */
+	u32 shader_offset;
+
 	/* One of enum vc4_kernel_bo_type, or VC4_BO_TYPE_COUNT + i
 	 * for user-allocated labels.
 	 */
@@ -785,6 +788,11 @@ struct vc4_file {
 	} perfmon;
 
 	bool bin_bo_used;
+
+	/* Counter picking the start offset of the next shader BO's code,
+	 * see vc4_create_shader_bo_ioctl().
+	 */
+	atomic_t shader_offset_idx;
 };
 
 static inline struct vc4_exec_info *
@@ -1072,7 +1080,7 @@ bool vc4_check_tex_size(struct vc4_exec_
 
 /* vc4_validate_shader.c */
 struct vc4_validated_shader_info *
-vc4_validate_shader(struct drm_gem_dma_object *shader_obj);
+vc4_validate_shader(struct drm_gem_dma_object *shader_obj, u32 offset);
 
 /* vc4_perfmon.c */
 void vc4_perfmon_get(struct vc4_perfmon *perfmon);
--- a/drivers/gpu/drm/vc4/vc4_validate.c
+++ b/drivers/gpu/drm/vc4/vc4_validate.c
@@ -861,7 +861,8 @@ validate_gl_shader_rec(struct drm_device
 		void *uniform_data_u;
 		uint32_t tex, uni;
 
-		*(uint32_t *)(pkt_v + o) = bo[i]->dma_addr + src_offset;
+		*(uint32_t *)(pkt_v + o) = bo[i]->dma_addr + src_offset +
+					   to_vc4_bo(&bo[i]->base)->shader_offset;
 
 		if (src_offset != 0) {
 			DRM_DEBUG("Shaders must be at offset 0 of "
--- a/drivers/gpu/drm/vc4/vc4_validate_shaders.c
+++ b/drivers/gpu/drm/vc4/vc4_validate_shaders.c
@@ -777,7 +777,7 @@ vc4_handle_branch_target(struct vc4_shad
 }
 
 struct vc4_validated_shader_info *
-vc4_validate_shader(struct drm_gem_dma_object *shader_obj)
+vc4_validate_shader(struct drm_gem_dma_object *shader_obj, u32 offset)
 {
 	struct vc4_dev *vc4 = to_vc4_dev(shader_obj->base.dev);
 	bool found_shader_end = false;
@@ -791,8 +791,9 @@ vc4_validate_shader(struct drm_gem_dma_o
 		return NULL;
 
 	memset(&validation_state, 0, sizeof(validation_state));
-	validation_state.shader = shader_obj->vaddr;
-	validation_state.max_ip = shader_obj->base.size / sizeof(uint64_t);
+	validation_state.shader = shader_obj->vaddr + offset;
+	validation_state.max_ip = (shader_obj->base.size - offset) /
+				  sizeof(uint64_t);
 
 	reset_validation_state(&validation_state);
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 344/555] drm/vmwgfx: avoid underflow when stripping short GuestInfo replies
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (342 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 343/555] drm/vc4: Start shader code at varying offsets in its BO Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 345/555] drm/vmwgfx: bound MKSSTAT lengths before rounding to pages Greg Kroah-Hartman
                   ` (210 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Zack Rusin, Maaz Mombasawala

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

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

From: Zack Rusin <zack.rusin@broadcom.com>

commit 05ee42f3dd5484415fac587d0efb8fe846b74c2c upstream.

vmw_host_get_guestinfo subtracts the two-byte reply prefix using
max(reply_len - 2, (size_t)0). Since reply_len is unsigned, a one-byte
reply wraps to SIZE_MAX instead of being clamped to zero. The subsequent
copy can read past the host reply allocation.

Theoretically malformed host reply can reach this path when the driver
queries the GuestInfo parameter used to enable VKMS.

Check the reply length before subtracting the prefix so short replies
produce an empty payload and cannot cause an out-of-bounds read.

Sashiko reported this while reviewing the i386 hypercall changes.

Fixes: 89da76fde68d ("drm/vmwgfx: Add VMWare host messaging capability")
Cc: stable@vger.kernel.org
Closes: https://sashiko.dev/#/patchset/4ab10678a8f50053934b62b56af81f881c1d3798.1788414669.git.zack.rusin%40broadcom.com
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Reviewed-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Link: https://patch.msgid.link/20261029215738.3010276-1-zack.rusin@broadcom.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_msg.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
@@ -431,7 +431,7 @@ int vmw_host_get_guestinfo(const char *g
 		/* Remove reply code, which are the first 2 characters of
 		 * the reply
 		 */
-		reply_len = max(reply_len - 2, (size_t) 0);
+		reply_len = reply_len > 2 ? reply_len - 2 : 0;
 		reply_len = min(reply_len, *length);
 
 		if (reply_len > 0)



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 345/555] drm/vmwgfx: bound MKSSTAT lengths before rounding to pages
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (343 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 344/555] drm/vmwgfx: avoid underflow when stripping short GuestInfo replies Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 346/555] drm/vmwgfx: do not hand the embedded sg_table to the PRIME core Greg Kroah-Hartman
                   ` (209 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Zack Rusin, Maaz Mombasawala

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

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

From: Zack Rusin <zack.rusin@broadcom.com>

commit 9725b0454e65f15ae76788f2004a7ba8b493362a upstream.

vmw_mksstat_add_ioctl rounds the user-supplied 64bit lengths to page
counts before comparing them with the descriptors page arrays. PFN_UP
can wrap for lengths near U64_MAX. On 32bit kernels, storing a large page
count in size_t can also truncate it to a value that passes the checks.

A render-node client can therefore register a descriptor with lengths
that exceed its pinned page arrays, including nonzero lengths with no
backing pages.

Compare each byte length with its page array's capacity before rounding
or narrowing it. Compute those capacities in 64 bits and calculate the
page counts only after all three lengths have passed validation.

Sashiko reported this while reviewing the i386 hypercall changes.

Fixes: 7a7a933edd6c ("drm/vmwgfx: Introduce VMware mks-guest-stats")
Cc: stable@vger.kernel.org
Closes: https://sashiko.dev/#/patchset/4ab10678a8f50053934b62b56af81f881c1d3798.1788414669.git.zack.rusin%40broadcom.com
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Reviewed-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Link: https://patch.msgid.link/20261029215738.3010276-2-zack.rusin@broadcom.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_msg.c |   19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

--- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
@@ -939,9 +939,12 @@ int vmw_mksstat_add_ioctl(struct drm_dev
 
 	struct vmw_private *const dev_priv = vmw_priv(dev);
 
-	const size_t num_pages_stat = PFN_UP(arg->stat_len);
-	const size_t num_pages_info = PFN_UP(arg->info_len);
-	const size_t num_pages_strs = PFN_UP(arg->strs_len);
+	const u64 max_stat_len = (u64)MKS_GUEST_STAT_INSTANCE_MAX_STAT_PPNS * PAGE_SIZE;
+	const u64 max_info_len = (u64)MKS_GUEST_STAT_INSTANCE_MAX_INFO_PPNS * PAGE_SIZE;
+	const u64 max_strs_len = (u64)MKS_GUEST_STAT_INSTANCE_MAX_STRS_PPNS * PAGE_SIZE;
+	size_t num_pages_stat;
+	size_t num_pages_info;
+	size_t num_pages_strs;
 	long desc_len;
 	long nr_pinned_stat;
 	long nr_pinned_info;
@@ -965,11 +968,15 @@ int vmw_mksstat_add_ioctl(struct drm_dev
 	if (!arg->description)
 		return -EINVAL;
 
-	if (num_pages_stat > ARRAY_SIZE(pdesc->statPPNs) ||
-		num_pages_info > ARRAY_SIZE(pdesc->infoPPNs) ||
-		num_pages_strs > ARRAY_SIZE(pdesc->strsPPNs))
+	if (arg->stat_len > max_stat_len ||
+	    arg->info_len > max_info_len ||
+	    arg->strs_len > max_strs_len)
 		return -EINVAL;
 
+	num_pages_stat = PFN_UP(arg->stat_len);
+	num_pages_info = PFN_UP(arg->info_len);
+	num_pages_strs = PFN_UP(arg->strs_len);
+
 	/* Find an available slot in the mksGuestStats user array and reserve it */
 	for (slot = 0; slot < ARRAY_SIZE(dev_priv->mksstat_user_pids); ++slot)
 		if (!atomic_cmpxchg(&dev_priv->mksstat_user_pids[slot], 0, MKSSTAT_PID_RESERVED))



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 346/555] drm/vmwgfx: do not hand the embedded sg_table to the PRIME core
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (344 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 345/555] drm/vmwgfx: bound MKSSTAT lengths before rounding to pages Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 347/555] drm/vmwgfx: Erase the detached resource entry on resource release Greg Kroah-Hartman
                   ` (208 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Aldo Ariel Panzardo, Zack Rusin

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

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

From: Aldo Ariel Panzardo <qwe.aldo@gmail.com>

commit 030e6d11d3e5eb7328f7a3e8177737a4b1c30654 upstream.

vmw_gem_object_get_sg_table() returns vmw_tt->vsgt.sgt when the buffer
object has already been DMA mapped.  vmw_ttm_map_dma() sets that field
to &vmw_tt->sgt, which is a member embedded inside the struct
vmw_ttm_tt allocation and not a table of its own.

The core owns whatever .get_sg_table returns.  drm_gem_map_dma_buf()
takes the table and drm_gem_unmap_dma_buf() destroys it in full:

	dma_unmap_sgtable(attach->dev, sgt, dir, DMA_ATTR_SKIP_CPU_SYNC);
	sg_free_table(sgt);
	kfree(sgt);

Both are ops of drm_gem_prime_dmabuf_ops, so the core ends up calling
kfree() on &vmw_tt->sgt, which is not the start of an allocation.  The
preceding sg_free_table() also destroys a scatterlist that vmwgfx still
considers its own and frees again from vmw_ttm_unmap_dma().

drm_gem_unmap_dma_buf() runs from dma_buf_detach(), including the
importer's error path, so a failed import is enough to reach it:
exporting a bound buffer with DRM_IOCTL_PRIME_HANDLE_TO_FD and
importing it on a second DRM device with DRM_IOCTL_PRIME_FD_TO_HANDLE
is sufficient.  Both ioctls are DRM_RENDER_ALLOW.

Observed on 6.12.101 with KASAN, as uid 65534:

  BUG: KASAN: invalid-free in drm_gem_unmap_dma_buf+0xb3/0xf0
  Free of addr ffff888008290450 by task poc_mm04_sgtabl/321
  CPU: 1 UID: 65534 PID: 321 Comm: poc_mm04_sgtabl Not tainted 6.12.101 #4
   kasan_report_invalid_free+0x94/0xc0
   check_slab_allocation+0x116/0x120
   kfree+0x103/0x360
   drm_gem_unmap_dma_buf+0xb3/0xf0
   dma_buf_detach+0x165/0x510
   drm_gem_prime_import_dev+0x33e/0x430
  which belongs to the cache kmalloc-192 of size 192
  The buggy address is located 80 bytes inside of
   144-byte region [ffff888008290400, ffff888008290490)

80 is offsetof(struct vmw_ttm_tt, sgt) and 144 is sizeof(struct
vmw_ttm_tt), which identifies the freed pointer as the embedded member.

Always return a table the core can own, as the other drivers do.
Reusing the cached representation would require copying it into a
freshly allocated sg_table, never returning the alias.

Fixes: 8afa13a0583f ("drm/vmwgfx: Implement DRIVER_GEM")
Cc: stable@vger.kernel.org
Signed-off-by: Aldo Ariel Panzardo <qwe.aldo@gmail.com>
Reviewed-by: Zack Rusin <zack.rusin@broadcom.com>
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Link: https://patch.msgid.link/20260923122601.438892-1-qwe.aldo@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_gem.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

--- a/drivers/gpu/drm/vmwgfx/vmwgfx_gem.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gem.c
@@ -73,10 +73,13 @@ static struct sg_table *vmw_gem_object_g
 	struct vmw_ttm_tt *vmw_tt =
 		container_of(bo->ttm, struct vmw_ttm_tt, dma_ttm);
 
-	if (vmw_tt->vsgt.sgt)
-		return vmw_tt->vsgt.sgt;
-
-	return drm_prime_pages_to_sg(obj->dev, vmw_tt->dma_ttm.pages, vmw_tt->dma_ttm.num_pages);
+	/*
+	 * Do not return &vmw_tt->sgt: the core owns what this returns and
+	 * drm_gem_unmap_dma_buf() sg_free_table()s and kfree()s it, but that
+	 * sg_table is embedded in the vmw_ttm_tt allocation.
+	 */
+	return drm_prime_pages_to_sg(obj->dev, vmw_tt->dma_ttm.pages,
+				     vmw_tt->dma_ttm.num_pages);
 }
 
 static int vmw_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map)



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 347/555] drm/vmwgfx: Erase the detached resource entry on resource release
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (345 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 346/555] drm/vmwgfx: do not hand the embedded sg_table to the PRIME core Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 348/555] drm/vmwgfx: fix NULL pointer dereference in vmw_validation_bo_fence() Greg Kroah-Hartman
                   ` (207 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Jaeyeong Lee, Zack Rusin

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

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

From: Jaeyeong Lee <finpiler@protonmail.com>

commit c4b134969ce350cdd4e726b5102b85b8a2d6fad5 upstream.

vmw_bo_add_detached_resource() stores a raw struct vmw_resource pointer in
bo->detached_resources without taking a reference on the resource, and the
only place that erases the entry again is vmw_resource_mob_attach(). A
resource that is never validated, and therefore never attached to its
backing mob, keeps its entry until the buffer object itself is destroyed.

vmw_resource_release() detaches the resource from the mob RB tree and drops
its reference on the backing buffer object, but leaves the
detached_resources entry in place. Userspace can hold an independent GEM
handle on that buffer object, either because DRM_VMW_GB_SURFACE_CREATE
returned one in rep.buffer_handle, or because DRM_VMW_GB_SURFACE_REF minted
one with drm_gem_handle_create(). The buffer object then outlives the
surface while still holding a pointer to freed memory.

Any later surface lookup for that buffer object dereferences it:

  vmw_prime_handle_to_fd()
    vmw_lookup_surface_handle_for_buffer()
      vmw_lookup_user_surface_for_buffer()
        vmw_bo_surface()
          res->func->res_type		<-- use-after-free read

vmw_bo_surface() walks detached_resources before the mob RB tree, so the
stale entry is matched first. The kref_get_unless_zero() in
vmw_lookup_user_surface_for_buffer() does not help here: it runs after
the dereference, and struct vmw_user_surface is freed with kfree_rcu()
on a slab that is not SLAB_TYPESAFE_BY_RCU, so the memory is handed out
to unrelated allocations once the grace period elapses.

A sequence that reaches this from userspace is to create a guest-backed
surface with drm_vmw_surface_flag_create_buffer, never validate it,
release it with DRM_VMW_UNREF_SURFACE, and then call
DRM_IOCTL_PRIME_HANDLE_TO_FD on the buffer handle returned by the create
ioctl. All of the ioctls involved are DRM_RENDER_ALLOW.

Erase the entry next to the existing vmw_resource_mob_detach() call, so
that a released resource is removed from both containers, mirroring what
vmw_resource_mob_attach() does. The dumb buffer teardown path in
vmw_bo_free() clears res->guest_memory_bo before dropping its surface
reference, so it does not reach this code and is unaffected.

Fixes: d6667f0ddf46 ("drm/vmwgfx: Fix handling of dumb buffers")
Cc: stable@vger.kernel.org
Signed-off-by: Jaeyeong Lee <finpiler@protonmail.com>
Reviewed-by: Zack Rusin <zack.rusin@broadcom.com>
[zack: rebased; dropped the v7.2-rc4 analysis note from the commit message]
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Link: https://patch.msgid.link/20260725143859.797134-1-finpiler@protonmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c |    1 +
 1 file changed, 1 insertion(+)

--- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
@@ -138,6 +138,7 @@ static void vmw_resource_release(struct
 		}
 		res->guest_memory_dirty = false;
 		vmw_resource_mob_detach(res);
+		vmw_bo_del_detached_resource(res->guest_memory_bo, res);
 		if (res->dirty)
 			res->func->dirty_free(res);
 		if (res->coherent)



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 348/555] drm/vmwgfx: fix NULL pointer dereference in vmw_validation_bo_fence()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (346 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 347/555] drm/vmwgfx: Erase the detached resource entry on resource release Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 349/555] drm/vmwgfx: log missing primary planes only once Greg Kroah-Hartman
                   ` (206 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Vladimir Popov, Zack Rusin

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

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

From: Vladimir Popov <popov.nkv@gmail.com>

commit 06f8a6708a98dff199ef7ea553b092efc38b4eab upstream.

If vmw_execbuf_fence_commands() call fails in
vmw_kms_helper_validation_finish(), it sets *p_fence = NULL. If
ctx->bo_list is not empty, the caller, vmw_kms_helper_validation_finish(),
passes the fence through a chain of functions to dma_fence_is_array(),
which causes a NULL pointer dereference in dma_fence_is_array():

vmw_kms_helper_validation_finish() // pass NULL fence
  vmw_validation_done()
    vmw_validation_bo_fence()
      ttm_eu_fence_buffer_objects() // pass NULL fence
        dma_resv_add_fence()
          dma_fence_is_container()
            dma_fence_is_array() // NULL deref

Fix this by adding a NULL check in vmw_validation_bo_fence(): if the fence
is NULL, fall back to ttm_eu_backoff_reservation()to safely release
the buffer object reservations without attempting to add a NULL fence to
dma_resv. This is safe because when fence is NULL, vmw_fallback_wait()
has already been called inside vmw_execbuf_fence_commands() to synchronize
the GPU.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 038ecc503236 ("drm/vmwgfx: Add a validation module v2")
Cc: stable@vger.kernel.org
Signed-off-by: Vladimir Popov <popov.nkv@gmail.com>
Reviewed-by: Zack Rusin <zack.rusin@broadcom.com>
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Link: https://patch.msgid.link/20260414105529.9883-1-popov.nkv@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_validation.h |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

--- a/drivers/gpu/drm/vmwgfx/vmwgfx_validation.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_validation.h
@@ -127,16 +127,23 @@ vmw_validation_bo_reserve(struct vmw_val
  * vmw_validation_bo_fence - Unreserve and fence buffer objects registered
  * with a validation context
  * @ctx: The validation context
+ * @fence: Fence with which to fence all buffer objects taking part in the
+ * command submission.
  *
  * This function unreserves the buffer objects previously reserved using
- * vmw_validation_bo_reserve, and fences them with a fence object.
+ * vmw_validation_bo_reserve, and fences them with a fence object if the
+ * given fence object is not NULL.
  */
 static inline void
 vmw_validation_bo_fence(struct vmw_validation_context *ctx,
 			struct vmw_fence_obj *fence)
 {
-	ttm_eu_fence_buffer_objects(&ctx->ticket, &ctx->bo_list,
-				    (void *) fence);
+	/* fence is able to be NULL if vmw_execbuf_fence_commands() fails */
+	if (fence)
+		ttm_eu_fence_buffer_objects(&ctx->ticket, &ctx->bo_list,
+					    (void *)fence);
+	else
+		ttm_eu_backoff_reservation(&ctx->ticket, &ctx->bo_list);
 }
 
 /**



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 349/555] drm/vmwgfx: log missing primary planes only once
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (347 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 348/555] drm/vmwgfx: fix NULL pointer dereference in vmw_validation_bo_fence() Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 350/555] drm/vmwgfx: log MOB limits outside the manager spinlock Greg Kroah-Hartman
                   ` (205 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Zack Rusin, Maaz Mombasawala

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

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

From: Zack Rusin <zack.rusin@broadcom.com>

commit f01848d84577e5860a187eea64f5321acaf1f893 upstream.

Stop filling kernel logs due to something that's not even a bug. Some
igt tests, e.g. kms_flip trigger this message ~17000 times which makes
all the other diagnostics almost impossible to find.

Just inform the user about this condition once and let it through
afterward.

Fixes: a60ccade88f9 ("drm/vmwgfx: Fix crtc's atomic check conditional")
Cc: stable@vger.kernel.org
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Reviewed-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Link: https://patch.msgid.link/20261029215540.3008997-1-zack.rusin@broadcom.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -965,9 +965,8 @@ int vmw_du_crtc_atomic_check(struct drm_
 	 * some actual rendering so give a clue as why it's blank.
 	 */
 	if (new_state->enable && !has_primary)
-		drm_dbg_driver(&vmw->drm,
-			       "CRTC without a primary plane will be blank.\n");
-
+		drm_info_once(&vmw->drm,
+			      "CRTC without a primary plane will be blank.\n");
 
 	if (new_state->connector_mask != connector_mask &&
 	    new_state->connector_mask != 0) {



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 350/555] drm/vmwgfx: log MOB limits outside the manager spinlock
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (348 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 349/555] drm/vmwgfx: log missing primary planes only once Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 351/555] drm/vmwgfx: reserve dumb buffers while detaching their surfaces Greg Kroah-Hartman
                   ` (204 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Zack Rusin, Maaz Mombasawala

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

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

From: Zack Rusin <zack.rusin@broadcom.com>

commit eee4285a8c3c918bbd21791e17f2bb261a709792 upstream.

vmw_gmrid_man_get_node reports MOB limit expansion and allocation
failures through vmw_host_printf while holding gman->lock. The helper
formats its messages with GFP_KERNEL allocations, which may sleep.

KDE startup and desktop mode changes can reach this path, producing
"BUG: sleeping function called from invalid context" from kvasprintf()
while the manager spinlock is held. That's likely a separate bug
because KDE shouldn't be using that much memory but to debug
that properly stop filling kernel logs with warnings.

Defer both host messages until after dropping the spinlock. Capture the
failed allocation's page limit and roll back its accounting while locked,
then report the error and free the resource after unlocking. Use
drm_warn for the guest messages so they identify the device.

Fixes: cfdc3458db8a ("drm/vmwgfx: Be a lot more flexible with MOB limits")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Reviewed-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Link: https://patch.msgid.link/20261029215700.3009996-1-zack.rusin@broadcom.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c |   55 ++++++++++++++++----------
 1 file changed, 34 insertions(+), 21 deletions(-)

--- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
@@ -54,8 +54,11 @@ static int vmw_gmrid_man_get_node(struct
 				  const struct ttm_place *place,
 				  struct ttm_resource **res)
 {
+	struct vmw_private *vmw = vmw_priv_from_ttm(bo->bdev);
 	struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man);
-	int id;
+	u32 max_gmr_pages = 0;
+	bool mob_overflow = false;
+	int id, ret = 0;
 
 	*res = kmalloc(sizeof(**res), GFP_KERNEL);
 	if (!*res)
@@ -85,43 +88,53 @@ static int vmw_gmrid_man_get_node(struct
 			const unsigned long max_graphics_pages = totalram_pages() / 2;
 			uint32_t new_max_pages = 0;
 
-			DRM_WARN("vmwgfx: mob memory overflow. Consider increasing guest RAM and graphicsMemory.\n");
-			vmw_host_printf("vmwgfx, warning: mob memory overflow. Consider increasing guest RAM and graphicsMemory.\n");
+			mob_overflow = true;
+			drm_warn(&vmw->drm,
+				 "vmwgfx: mob memory overflow. Consider increasing guest RAM and graphicsMemory.\n");
 
 			if (gman->max_gmr_pages > (max_graphics_pages / 2)) {
-				DRM_WARN("vmwgfx: guest requires more than half of RAM for graphics.\n");
+				drm_warn(&vmw->drm,
+					 "vmwgfx: guest requires more than half of RAM for graphics.\n");
 				new_max_pages = max_graphics_pages;
 			} else
 				new_max_pages = gman->max_gmr_pages * 2;
 			if (new_max_pages > gman->max_gmr_pages && new_max_pages >= gman->used_gmr_pages) {
-				DRM_WARN("vmwgfx: increasing guest mob limits to %u KiB.\n",
-					 ((new_max_pages) << (PAGE_SHIFT - 10)));
+				drm_warn(&vmw->drm,
+					 "vmwgfx: increasing guest mob limits to %u KiB.\n",
+					 new_max_pages << (PAGE_SHIFT - 10));
 
 				gman->max_gmr_pages = new_max_pages;
 			} else {
-				char buf[256];
-				snprintf(buf, sizeof(buf),
-					 "vmwgfx, error: guest graphics is out of memory (mob limit at: %u KiB).\n",
-					 ((gman->max_gmr_pages) << (PAGE_SHIFT - 10)));
-				vmw_host_printf(buf);
-				DRM_WARN("%s", buf);
-				goto nospace;
+				max_gmr_pages = gman->max_gmr_pages;
+				gman->used_gmr_pages -= PFN_UP((*res)->size);
+				ret = -ENOSPC;
+				goto out_unlock;
 			}
 		}
 	}
 
 	(*res)->start = id;
 
+out_unlock:
 	spin_unlock(&gman->lock);
-	return 0;
 
-nospace:
-	gman->used_gmr_pages -= PFN_UP((*res)->size);
-	spin_unlock(&gman->lock);
-	ida_free(&gman->gmr_ida, id);
-	ttm_resource_fini(man, *res);
-	kfree(*res);
-	return -ENOSPC;
+	/* Host logging allocates with GFP_KERNEL and must run unlocked. */
+	if (mob_overflow)
+		vmw_host_printf("%s",
+				"vmwgfx, warning: mob memory overflow. Consider increasing guest RAM and graphicsMemory.\n");
+	if (ret) {
+		char buf[256];
+
+		snprintf(buf, sizeof(buf),
+			 "vmwgfx, error: guest graphics is out of memory (mob limit at: %u KiB).\n",
+			 max_gmr_pages << (PAGE_SHIFT - 10));
+		vmw_host_printf("%s", buf);
+		drm_warn(&vmw->drm, "%s", buf);
+		ida_free(&gman->gmr_ida, id);
+		ttm_resource_fini(man, *res);
+		kfree(*res);
+	}
+	return ret;
 }
 
 static void vmw_gmrid_man_put_node(struct ttm_resource_manager *man,



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 351/555] drm/vmwgfx: reserve dumb buffers while detaching their surfaces
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (349 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 350/555] drm/vmwgfx: log MOB limits outside the manager spinlock Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 352/555] drm/vmwgfx: return an error when a shared GB surface has no backup buffer Greg Kroah-Hartman
                   ` (203 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Zack Rusin, Maaz Mombasawala,
	fausten

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

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

From: Zack Rusin <zack.rusin@broadcom.com>

commit 13e766130673ec3b9df8b72ff1dbe6826cac1dfe upstream.

vmw_bo_free() detaches the surface associated with a dumb buffer and
clears its guest memory binding. It reserves the resource, but does not
hold the buffer reservation required by vmw_resource_mob_detach(). TTM
releases that reservation before invoking the buffer destructor.

KMS clients destroying dumb buffers can therefore trigger the reservation
assertion from vmw_resource_mob_detach(). GNOME reaches this path through
DRM_IOCTL_MODE_DESTROY_DUMB during cursor and display updates.

Reacquire the buffer reservation while detaching the surface and clearing
its dirty tracking and guest memory binding. Acquire it after
cmdbuf_mutex, following the command validation lock order, and release it
before releasing the resource and GEM object.

Fixes: d6667f0ddf46 ("drm/vmwgfx: Fix handling of dumb buffers")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Reviewed-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Tested-by: fausten <yunfeng.li.nb@gmail.com>
Link: https://patch.msgid.link/20261027211729.646988-5-zack.rusin@broadcom.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_bo.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
@@ -56,6 +56,8 @@ static void vmw_bo_free(struct ttm_buffe
 			/* Reserve and switch the backing mob. */
 			mutex_lock(&res->dev_priv->cmdbuf_mutex);
 			(void)vmw_resource_reserve(res, false, true);
+			/* TTM drops the reservation before calling the destructor. */
+			dma_resv_lock(bo->base.resv, NULL);
 			vmw_resource_mob_detach(res);
 			if (res->dirty)
 				res->func->dirty_free(res);
@@ -63,6 +65,7 @@ static void vmw_bo_free(struct ttm_buffe
 				vmw_bo_dirty_release(res->guest_memory_bo);
 			res->guest_memory_bo = NULL;
 			res->guest_memory_offset = 0;
+			dma_resv_unlock(bo->base.resv);
 			vmw_resource_unreserve(res, true, false, false, NULL,
 					       0);
 			mutex_unlock(&res->dev_priv->cmdbuf_mutex);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 352/555] drm/vmwgfx: return an error when a shared GB surface has no backup buffer
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (350 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 351/555] drm/vmwgfx: reserve dumb buffers while detaching their surfaces Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 353/555] drm/vmwgfx: validate command body sizes before parsing Greg Kroah-Hartman
                   ` (202 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Zack Rusin, Aldo Ariel Panzardo

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

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

From: Aldo Ariel Panzardo <qwe.aldo@gmail.com>

commit 3a2f97af36754b64083d463a4cee0af26826bec8 upstream.

vmw_gb_surface_reference_internal() rejects a surface that has no backup
buffer by logging an error and jumping to out_bad_resource, but it never
sets ret on that path. ret is still 0 from the earlier successful
vmw_surface_handle_reference(), so the ioctl returns success while
leaving the reply structure unfilled — user space is handed a
"successful" reply that was never produced. DRM_VMW_GB_SURFACE_REF is
DRM_RENDER_ALLOW, so an unprivileged local user can reach it.

Set ret to -EINVAL and, on the error paths, drop the reference that
vmw_surface_handle_reference() took; once the ioctl fails user space no
longer releases it via DRM_VMW_UNREF_SURFACE. The unref is guarded by
ret so the shared success fall-through keeps the reference the caller
still owns, and it also plugs the same leak on the drm_gem_handle_create()
failure path.

Fixes: 14b1c33e8429 ("drm/vmwgfx: Add new ioctl for GB surface create and reference")
Cc: stable@vger.kernel.org
Suggested-by: Zack Rusin <zack.rusin@broadcom.com>
Signed-off-by: Aldo Ariel Panzardo <qwe.aldo@gmail.com>
Reviewed-by: Zack Rusin <zack.rusin@broadcom.com>
[zack: aligned a continuation line with the open parenthesis]
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Link: https://patch.msgid.link/20261007212051.2574235-2-qwe.aldo@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c |    4 ++++
 1 file changed, 4 insertions(+)

--- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
@@ -1755,6 +1755,7 @@ vmw_gb_surface_reference_internal(struct
 	srf = &user_srf->srf;
 	if (!srf->res.guest_memory_bo) {
 		DRM_ERROR("Shared GB surface is missing a backup buffer.\n");
+		ret = -EINVAL;
 		goto out_bad_resource;
 	}
 	metadata = &srf->metadata;
@@ -1793,6 +1794,9 @@ vmw_gb_surface_reference_internal(struct
 	rep->creq.must_be_zero = 0;
 
 out_bad_resource:
+	if (ret)
+		ttm_ref_object_base_unref(vmw_fpriv(file_priv)->tfile,
+					  base->handle);
 	ttm_base_object_unref(&base);
 
 	return ret;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 353/555] drm/vmwgfx: validate command body sizes before parsing
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (351 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 352/555] drm/vmwgfx: return an error when a shared GB surface has no backup buffer Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 354/555] drm/vmwgfx: close TOCTOU on guest_memory_bo in surface reference ioctl Greg Kroah-Hartman
                   ` (201 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Zack Rusin, Maaz Mombasawala

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

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

From: Zack Rusin <zack.rusin@broadcom.com>

commit 06069d6d650dbef746eb933e2f4fbfc686b6d330 upstream.

vmw_cmd_check verifies that a command's declared size fits in the
submitted buffer, but handlers can access fields beyond the declared
body. A truncated body can therefore cause relocations to target the
next command. Applying those relocations after validation can change
an already validated command ID and bypass command restrictions.

Legacy query conversion can also overwrite the next command, while
texture-state parsing can access fields beyond a truncated final record.

Check each handler's minimum body size before accessing command fields.
Use the common prefix for shared handlers to preserve shorter command
variants, and reject texture-state arrays containing incomplete records.

Fixes: fb1d9738ca05 ("drm/vmwgfx: Add DRM driver for VMware Virtual GPU")
Cc: stable@vger.kernel.org
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Reviewed-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Link: https://patch.msgid.link/20261111193836.3161904-1-zack.rusin@broadcom.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c |  200 ++++++++++++++++++++++++++++++++
 1 file changed, 200 insertions(+)

--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -583,6 +583,29 @@ static int vmw_cmd_ok(struct vmw_private
 }
 
 /**
+ * vmw_cmd_body_fits - Check that a command body covers what a handler reads
+ *
+ * @header: Pointer to the command header in the command stream.
+ * @size: Number of body bytes that the command handler interprets.
+ *
+ * vmw_cmd_check() only verifies that @header->size fits into the submitted
+ * command buffer. A handler that reads past the declared body reads the next
+ * command, which is verified separately. A relocation recorded there would
+ * rewrite the already verified command after verification has finished.
+ *
+ * Return: true if the body is at least @size bytes, false otherwise.
+ */
+static bool vmw_cmd_body_fits(const SVGA3dCmdHeader *header, size_t size)
+{
+	if (likely(header->size >= size))
+		return true;
+
+	VMW_DEBUG_USER("SVGA3D command %u: body size %u is smaller than %zu.\n",
+		       header->id, header->size, size);
+	return false;
+}
+
+/**
  * vmw_resources_reserve - Reserve all resources on the sw_context's resource
  * list.
  *
@@ -828,6 +851,9 @@ static int vmw_cmd_cid_check(struct vmw_
 	VMW_DECLARE_CMD_VAR(*cmd, uint32_t) =
 		container_of(header, typeof(*cmd), header);
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context,
 				 VMW_RES_DIRTY_SET, user_context_converter,
 				 &cmd->body, NULL);
@@ -871,6 +897,8 @@ static int vmw_cmd_set_render_target_che
 	int ret;
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
 
 	if (cmd->body.type >= SVGA3D_RT_MAX) {
 		VMW_DEBUG_USER("Illegal render target type %u.\n",
@@ -916,6 +944,8 @@ static int vmw_cmd_surface_copy_check(st
 	int ret;
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
 
 	ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
 				VMW_RES_DIRTY_NONE, user_surface_converter,
@@ -936,6 +966,9 @@ static int vmw_cmd_buffer_copy_check(str
 	int ret;
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
 				VMW_RES_DIRTY_NONE, user_surface_converter,
 				&cmd->body.src, NULL);
@@ -955,6 +988,9 @@ static int vmw_cmd_pred_copy_check(struc
 	int ret;
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
 				VMW_RES_DIRTY_NONE, user_surface_converter,
 				&cmd->body.srcSid, NULL);
@@ -974,6 +1010,9 @@ static int vmw_cmd_stretch_blt_check(str
 	int ret;
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
 				VMW_RES_DIRTY_NONE, user_surface_converter,
 				&cmd->body.src.sid, NULL);
@@ -992,6 +1031,9 @@ static int vmw_cmd_blt_surf_screen_check
 	VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdBlitSurfaceToScreen) =
 		container_of(header, typeof(*cmd), header);
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
 				 VMW_RES_DIRTY_NONE, user_surface_converter,
 				 &cmd->body.srcImage.sid, NULL);
@@ -1004,6 +1046,9 @@ static int vmw_cmd_present_check(struct
 	VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdPresent) =
 		container_of(header, typeof(*cmd), header);
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
 				 VMW_RES_DIRTY_NONE, user_surface_converter,
 				 &cmd->body.sid, NULL);
@@ -1261,6 +1306,8 @@ static int vmw_cmd_dx_define_query(struc
 		return -EINVAL;
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
 
 	if (cmd->body.type <  SVGA3D_QUERYTYPE_MIN ||
 	    cmd->body.type >= SVGA3D_QUERYTYPE_MAX)
@@ -1298,6 +1345,8 @@ static int vmw_cmd_dx_bind_query(struct
 		return -EINVAL;
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
 
 	/*
 	 * Look up the buffer pointed to by q.mobid, put it on the relocation
@@ -1328,6 +1377,9 @@ static int vmw_cmd_begin_gb_query(struct
 	VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdBeginGBQuery) =
 		container_of(header, typeof(*cmd), header);
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context,
 				 VMW_RES_DIRTY_SET, user_context_converter,
 				 &cmd->body.cid, NULL);
@@ -1347,6 +1399,9 @@ static int vmw_cmd_begin_query(struct vm
 	VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdBeginQuery) =
 		container_of(header, typeof(*cmd), header);
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	if (unlikely(dev_priv->has_mob)) {
 		VMW_DECLARE_CMD_VAR(gb_cmd, SVGA3dCmdBeginGBQuery);
 
@@ -1382,6 +1437,9 @@ static int vmw_cmd_end_gb_query(struct v
 	int ret;
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	ret = vmw_cmd_cid_check(dev_priv, sw_context, header);
 	if (unlikely(ret != 0))
 		return ret;
@@ -1412,6 +1470,9 @@ static int vmw_cmd_end_query(struct vmw_
 	int ret;
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	if (dev_priv->has_mob) {
 		VMW_DECLARE_CMD_VAR(gb_cmd, SVGA3dCmdEndGBQuery);
 
@@ -1458,6 +1519,9 @@ static int vmw_cmd_wait_gb_query(struct
 	int ret;
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	ret = vmw_cmd_cid_check(dev_priv, sw_context, header);
 	if (unlikely(ret != 0))
 		return ret;
@@ -1486,6 +1550,9 @@ static int vmw_cmd_wait_query(struct vmw
 	int ret;
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	if (dev_priv->has_mob) {
 		VMW_DECLARE_CMD_VAR(gb_cmd, SVGA3dCmdWaitForGBQuery);
 
@@ -1655,6 +1722,15 @@ static int vmw_cmd_tex_state(struct vmw_
 	int ret;
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
+	/* The loop below must not read a truncated trailing state. */
+	if ((header->size - sizeof(cmd->body)) % sizeof(*cur_state)) {
+		VMW_DEBUG_USER("Invalid texture state size %u.\n",
+			       header->size);
+		return -EINVAL;
+	}
 
 	ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context,
 				VMW_RES_DIRTY_SET, user_context_converter,
@@ -1800,6 +1876,9 @@ static int vmw_cmd_bind_gb_surface(struc
 	VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdBindGBSurface) =
 		container_of(header, typeof(*cmd), header);
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	return vmw_cmd_switch_backup(dev_priv, sw_context, vmw_res_surface,
 				     user_surface_converter, &cmd->body.sid,
 				     &cmd->body.mobid, 0);
@@ -1819,6 +1898,9 @@ static int vmw_cmd_update_gb_image(struc
 	VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdUpdateGBImage) =
 		container_of(header, typeof(*cmd), header);
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
 				 VMW_RES_DIRTY_NONE, user_surface_converter,
 				 &cmd->body.image.sid, NULL);
@@ -1838,6 +1920,9 @@ static int vmw_cmd_update_gb_surface(str
 	VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdUpdateGBSurface) =
 		container_of(header, typeof(*cmd), header);
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
 				 VMW_RES_DIRTY_CLEAR, user_surface_converter,
 				 &cmd->body.sid, NULL);
@@ -1857,6 +1942,9 @@ static int vmw_cmd_readback_gb_image(str
 	VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdReadbackGBImage) =
 		container_of(header, typeof(*cmd), header);
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
 				 VMW_RES_DIRTY_NONE, user_surface_converter,
 				 &cmd->body.image.sid, NULL);
@@ -1877,6 +1965,9 @@ static int vmw_cmd_readback_gb_surface(s
 	VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdReadbackGBSurface) =
 		container_of(header, typeof(*cmd), header);
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
 				 VMW_RES_DIRTY_CLEAR, user_surface_converter,
 				 &cmd->body.sid, NULL);
@@ -1897,6 +1988,9 @@ static int vmw_cmd_invalidate_gb_image(s
 	VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdInvalidateGBImage) =
 		container_of(header, typeof(*cmd), header);
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
 				 VMW_RES_DIRTY_NONE, user_surface_converter,
 				 &cmd->body.image.sid, NULL);
@@ -1917,6 +2011,9 @@ static int vmw_cmd_invalidate_gb_surface
 	VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdInvalidateGBSurface) =
 		container_of(header, typeof(*cmd), header);
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
 				 VMW_RES_DIRTY_CLEAR, user_surface_converter,
 				 &cmd->body.sid, NULL);
@@ -1939,6 +2036,8 @@ static int vmw_cmd_shader_define(struct
 	struct vmw_resource *ctx;
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
 
 	ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context,
 				VMW_RES_DIRTY_SET, user_context_converter,
@@ -1978,6 +2077,8 @@ static int vmw_cmd_shader_destroy(struct
 	struct vmw_resource *ctx;
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
 
 	ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context,
 				VMW_RES_DIRTY_SET, user_context_converter,
@@ -2017,6 +2118,8 @@ static int vmw_cmd_set_shader(struct vmw
 	int ret;
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
 
 	if (!vmw_shadertype_is_valid(VMW_SM_LEGACY, cmd->body.type)) {
 		VMW_DEBUG_USER("Illegal shader type %u.\n",
@@ -2095,6 +2198,8 @@ static int vmw_cmd_set_shader_const(stru
 	int ret;
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
 
 	ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context,
 				VMW_RES_DIRTY_SET, user_context_converter,
@@ -2122,6 +2227,9 @@ static int vmw_cmd_bind_gb_shader(struct
 	VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdBindGBShader) =
 		container_of(header, typeof(*cmd), header);
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	return vmw_cmd_switch_backup(dev_priv, sw_context, vmw_res_shader,
 				     user_shader_converter, &cmd->body.shid,
 				     &cmd->body.mobid, cmd->body.offsetInBytes);
@@ -2151,6 +2259,9 @@ vmw_cmd_dx_set_single_constant_buffer(st
 		return -EINVAL;
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
 				VMW_RES_DIRTY_NONE, user_surface_converter,
 				&cmd->body.sid, &res);
@@ -2204,6 +2315,9 @@ vmw_cmd_dx_set_constant_buffer_offset(st
 		return -EINVAL;
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	if (cmd->body.slot >= SVGA3D_DX_MAX_CONSTBUFFERS) {
 		VMW_DEBUG_USER("Illegal const buffer slot %u.\n",
 			       (unsigned int) cmd->body.slot);
@@ -2235,6 +2349,9 @@ static int vmw_cmd_dx_set_shader_res(str
 	u32 num_sr_view = (cmd->header.size - sizeof(cmd->body)) /
 		sizeof(SVGA3dShaderResourceViewId);
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	if ((u64) cmd->body.startView + (u64) num_sr_view >
 	    (u64) SVGA3D_DX_MAX_SRVIEWS ||
 	    !vmw_shadertype_is_valid(dev_priv->sm_type, cmd->body.type)) {
@@ -2270,6 +2387,8 @@ static int vmw_cmd_dx_set_shader(struct
 		return -EINVAL;
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
 
 	if (!vmw_shadertype_is_valid(dev_priv->sm_type, cmd->body.type)) {
 		VMW_DEBUG_USER("Illegal shader type %u.\n",
@@ -2327,6 +2446,9 @@ static int vmw_cmd_dx_set_vertex_buffers
 		return -EINVAL;
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	num = (cmd->header.size - sizeof(cmd->body)) /
 		sizeof(SVGA3dVertexBuffer);
 	if ((u64)num + (u64)cmd->body.startBuffer >
@@ -2378,6 +2500,9 @@ static int vmw_cmd_dx_set_index_buffer(s
 		return -EINVAL;
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
 				VMW_RES_DIRTY_NONE, user_surface_converter,
 				&cmd->body.sid, &res);
@@ -2413,6 +2538,9 @@ static int vmw_cmd_dx_set_rendertargets(
 		sizeof(SVGA3dRenderTargetViewId);
 	int ret;
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	if (num_rt_view > SVGA3D_DX_MAX_RENDER_TARGETS) {
 		VMW_DEBUG_USER("Invalid DX Rendertarget binding.\n");
 		return -EINVAL;
@@ -2444,6 +2572,9 @@ static int vmw_cmd_dx_clear_rendertarget
 		container_of(header, typeof(*cmd), header);
 	struct vmw_resource *ret;
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	ret = vmw_view_id_val_add(sw_context, vmw_view_rt,
 				  cmd->body.renderTargetViewId);
 
@@ -2466,6 +2597,9 @@ static int vmw_cmd_dx_clear_depthstencil
 		container_of(header, typeof(*cmd), header);
 	struct vmw_resource *ret;
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	ret = vmw_view_id_val_add(sw_context, vmw_view_ds,
 				  cmd->body.depthStencilViewId);
 
@@ -2499,6 +2633,9 @@ static int vmw_cmd_dx_view_define(struct
 		return -EINVAL;
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(*cmd) - sizeof(*header)))
+		return -EINVAL;
+
 	if (unlikely(cmd->sid == SVGA3D_INVALID_ID)) {
 		VMW_DEBUG_USER("Invalid surface id.\n");
 		return -EINVAL;
@@ -2547,6 +2684,9 @@ static int vmw_cmd_dx_set_so_targets(str
 		return -EINVAL;
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	num = (cmd->header.size - sizeof(cmd->body)) / sizeof(SVGA3dSoTarget);
 
 	if (num > SVGA3D_DX_MAX_SOTARGETS) {
@@ -2600,6 +2740,9 @@ static int vmw_cmd_dx_so_define(struct v
 	if (IS_ERR_OR_NULL(res))
 		return res ? PTR_ERR(res) : -EINVAL;
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(*cmd) - sizeof(*header)))
+		return -EINVAL;
+
 	ret = vmw_cotable_notify(res, cmd->defined_id);
 
 	return ret;
@@ -2635,6 +2778,9 @@ static int vmw_cmd_dx_check_subresource(
 		     offsetof(typeof(*cmd), sid));
 
 	cmd = container_of(header, typeof(*cmd), header);
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->sid)))
+		return -EINVAL;
+
 	return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
 				 VMW_RES_DIRTY_NONE, user_surface_converter,
 				 &cmd->sid, NULL);
@@ -2676,6 +2822,9 @@ static int vmw_cmd_dx_view_remove(struct
 	struct vmw_resource *view;
 	int ret;
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	if (!ctx_node)
 		return -EINVAL;
 
@@ -2713,6 +2862,9 @@ static int vmw_cmd_dx_define_shader(stru
 		container_of(header, typeof(*cmd), header);
 	int ret;
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	if (!ctx_node)
 		return -EINVAL;
 
@@ -2744,6 +2896,9 @@ static int vmw_cmd_dx_destroy_shader(str
 		container_of(header, typeof(*cmd), header);
 	int ret;
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	if (!ctx_node)
 		return -EINVAL;
 
@@ -2770,6 +2925,9 @@ static int vmw_cmd_dx_bind_shader(struct
 		container_of(header, typeof(*cmd), header);
 	int ret;
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	if (cmd->body.cid != SVGA3D_INVALID_ID) {
 		ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context,
 					VMW_RES_DIRTY_SET,
@@ -2821,6 +2979,9 @@ static int vmw_cmd_dx_genmips(struct vmw
 	struct vmw_resource *view;
 	struct vmw_res_cache_entry *rcache;
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	view = vmw_view_id_val_add(sw_context, vmw_view_sr,
 				   cmd->body.shaderResourceViewId);
 	if (IS_ERR(view))
@@ -2854,6 +3015,9 @@ static int vmw_cmd_dx_transfer_from_buff
 		container_of(header, typeof(*cmd), header);
 	int ret;
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
 				VMW_RES_DIRTY_NONE, user_surface_converter,
 				&cmd->body.srcSid, NULL);
@@ -2879,6 +3043,9 @@ static int vmw_cmd_intra_surface_copy(st
 	VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdIntraSurfaceCopy) =
 		container_of(header, typeof(*cmd), header);
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	if (!(dev_priv->capabilities2 & SVGA_CAP2_INTRA_SURFACE_COPY))
 		return -EINVAL;
 
@@ -2927,6 +3094,9 @@ static int vmw_cmd_clear_uav_uint(struct
 	} *cmd = container_of(header, typeof(*cmd), header);
 	struct vmw_resource *ret;
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	if (!has_sm5_context(dev_priv))
 		return -EINVAL;
 
@@ -2946,6 +3116,9 @@ static int vmw_cmd_clear_uav_float(struc
 	} *cmd = container_of(header, typeof(*cmd), header);
 	struct vmw_resource *ret;
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	if (!has_sm5_context(dev_priv))
 		return -EINVAL;
 
@@ -2967,6 +3140,9 @@ static int vmw_cmd_set_uav(struct vmw_pr
 		sizeof(SVGA3dUAViewId);
 	int ret;
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	if (!has_sm5_context(dev_priv))
 		return -EINVAL;
 
@@ -2999,6 +3175,9 @@ static int vmw_cmd_set_cs_uav(struct vmw
 		sizeof(SVGA3dUAViewId);
 	int ret;
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	if (!has_sm5_context(dev_priv))
 		return -EINVAL;
 
@@ -3031,6 +3210,9 @@ static int vmw_cmd_dx_define_streamoutpu
 	} *cmd = container_of(header, typeof(*cmd), header);
 	int ret;
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	if (!has_sm5_context(dev_priv))
 		return -EINVAL;
 
@@ -3062,6 +3244,9 @@ static int vmw_cmd_dx_destroy_streamoutp
 		SVGA3dCmdDXDestroyStreamOutput body;
 	} *cmd = container_of(header, typeof(*cmd), header);
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	if (!ctx_node) {
 		DRM_ERROR("DX Context not set.\n");
 		return -EINVAL;
@@ -3099,6 +3284,9 @@ static int vmw_cmd_dx_bind_streamoutput(
 	} *cmd = container_of(header, typeof(*cmd), header);
 	int ret;
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	if (!has_sm5_context(dev_priv))
 		return -EINVAL;
 
@@ -3141,6 +3329,9 @@ static int vmw_cmd_dx_set_streamoutput(s
 	} *cmd = container_of(header, typeof(*cmd), header);
 	int ret;
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	if (!ctx_node) {
 		DRM_ERROR("DX Context not set.\n");
 		return -EINVAL;
@@ -3193,6 +3384,9 @@ static int vmw_cmd_indexed_instanced_ind
 		SVGA3dCmdDXDrawIndexedInstancedIndirect body;
 	} *cmd = container_of(header, typeof(*cmd), header);
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	if (!has_sm5_context(dev_priv))
 		return -EINVAL;
 
@@ -3210,6 +3404,9 @@ static int vmw_cmd_instanced_indirect(st
 		SVGA3dCmdDXDrawInstancedIndirect body;
 	} *cmd = container_of(header, typeof(*cmd), header);
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	if (!has_sm5_context(dev_priv))
 		return -EINVAL;
 
@@ -3227,6 +3424,9 @@ static int vmw_cmd_dispatch_indirect(str
 		SVGA3dCmdDXDispatchIndirect body;
 	} *cmd = container_of(header, typeof(*cmd), header);
 
+	if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+		return -EINVAL;
+
 	if (!has_sm5_context(dev_priv))
 		return -EINVAL;
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 354/555] drm/vmwgfx: close TOCTOU on guest_memory_bo in surface reference ioctl
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (352 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 353/555] drm/vmwgfx: validate command body sizes before parsing Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 355/555] ALSA: pcm: oss: Restore params flag after failed reconfiguration Greg Kroah-Hartman
                   ` (200 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sashiko, Aldo Ariel Panzardo,
	Zack Rusin

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

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

From: Aldo Ariel Panzardo <qwe.aldo@gmail.com>

commit 30131b82b062180183a09a97183a944fadab72ee upstream.

vmw_gb_surface_reference_internal() checks srf->res.guest_memory_bo
for NULL and reads its vma_node offset and base.size outside the
cmdbuf_mutex scope that protects the backup pointer.

A concurrent backup switch, e.g. from SVGA_3D_CMD_BIND_GB_SURFACE
via vmw_resource_unreserve(), drops its reference to the old buffer
and installs a new one under cmdbuf_mutex. The unlocked check in
the surface reference ioctl can see a transient NULL. The reads
after the unlock can return another buffer's offset and size; a
further switch can drop that buffer's last reference and free it
while the ioctl reads from it.

Move the NULL check inside the mutex, and read buffer_map_handle
and buffer_size while still holding it.

Fixes: a97e21923b42 ("drm/vmwgfx: Hook up guest-backed surfaces")
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/r/20260808233347.209DD1F000E9@smtp.kernel.org
Signed-off-by: Aldo Ariel Panzardo <qwe.aldo@gmail.com>
Reviewed-by: Zack Rusin <zack.rusin@broadcom.com>
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Link: https://patch.msgid.link/20261007212051.2574235-3-qwe.aldo@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

--- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
@@ -1753,23 +1753,32 @@ vmw_gb_surface_reference_internal(struct
 
 	user_srf = container_of(base, struct vmw_user_surface, prime.base);
 	srf = &user_srf->srf;
+	metadata = &srf->metadata;
+
+	mutex_lock(&dev_priv->cmdbuf_mutex);
+
 	if (!srf->res.guest_memory_bo) {
+		mutex_unlock(&dev_priv->cmdbuf_mutex);
 		DRM_ERROR("Shared GB surface is missing a backup buffer.\n");
 		ret = -EINVAL;
 		goto out_bad_resource;
 	}
-	metadata = &srf->metadata;
 
-	mutex_lock(&dev_priv->cmdbuf_mutex); /* Protect res->backup */
 	ret = drm_gem_handle_create(file_priv, &srf->res.guest_memory_bo->tbo.base,
 				    &backup_handle);
-	mutex_unlock(&dev_priv->cmdbuf_mutex);
 	if (ret != 0) {
+		mutex_unlock(&dev_priv->cmdbuf_mutex);
 		drm_err(dev, "Wasn't able to create a backing handle for surface sid = %u.\n",
 			req->sid);
 		goto out_bad_resource;
 	}
 
+	rep->crep.buffer_map_handle =
+		drm_vma_node_offset_addr(&srf->res.guest_memory_bo->tbo.base.vma_node);
+	rep->crep.buffer_size = srf->res.guest_memory_bo->tbo.base.size;
+
+	mutex_unlock(&dev_priv->cmdbuf_mutex);
+
 	rep->creq.base.svga3d_flags = SVGA3D_FLAGS_LOWER_32(metadata->flags);
 	rep->creq.base.format = metadata->format;
 	rep->creq.base.mip_levels = metadata->mip_levels[0];
@@ -1782,9 +1791,6 @@ vmw_gb_surface_reference_internal(struct
 	rep->crep.handle = user_srf->prime.base.handle;
 	rep->crep.backup_size = srf->res.guest_memory_size;
 	rep->crep.buffer_handle = backup_handle;
-	rep->crep.buffer_map_handle =
-		drm_vma_node_offset_addr(&srf->res.guest_memory_bo->tbo.base.vma_node);
-	rep->crep.buffer_size = srf->res.guest_memory_bo->tbo.base.size;
 
 	rep->creq.version = drm_vmw_gb_surface_v1;
 	rep->creq.svga3d_flags_upper_32_bits =



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 355/555] ALSA: pcm: oss: Restore params flag after failed reconfiguration
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (353 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 354/555] drm/vmwgfx: close TOCTOU on guest_memory_bo in surface reference ioctl Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 356/555] ARC: io: work around GCC PR127718 in __raw_write{w,l}() Greg Kroah-Hartman
                   ` (199 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Ye Weihua, Takashi Iwai

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

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

From: Ye Weihua <yeweihua4@huawei.com>

commit bc3d6817c5325e76578cdd75e9c08bdadc5f73c4 upstream.

snd_pcm_runtime_buffer_set_silence() may fail with -EBUSY when a
concurrent PCM transfer is accessing the buffer.  The error path
releases runtime->oss.buffer and clears the plugins, but leaves
runtime->oss.params cleared as well.  A subsequent small read/write
then skips the reconfiguration and dereferences the released buffer:

  Unable to handle kernel NULL pointer dereference at virtual address
  0000000000000000
  pc : __arch_copy_from_user+0x78/0x23c
  lr : snd_pcm_oss_write+0x10c/0x340 [snd_pcm_oss]

Restore runtime->oss.params on the error path so that the next OSS
operation reconfigures and reallocates the buffer.

Fixes: 47c27c9c9c72 ("ALSA: pcm: Improve the fix for race of buffer access at PCM OSS layer")
Cc: stable@vger.kernel.org
Signed-off-by: Ye Weihua <yeweihua4@huawei.com>
Link: https://patch.msgid.link/20261116064850.3540576-1-yeweihua4@huawei.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 sound/core/oss/pcm_oss.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -1082,8 +1082,10 @@ static int snd_pcm_oss_change_params_loc
 
 	err = 0;
 failure:
-	if (err)
+	if (err) {
+		runtime->oss.params = 1;
 		snd_pcm_oss_release_buffers(substream);
+	}
 	kfree(sw_params);
 	kfree(params);
 	kfree(sparams);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 356/555] ARC: io: work around GCC PR127718 in __raw_write{w,l}()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (354 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 355/555] ALSA: pcm: oss: Restore params flag after failed reconfiguration Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 357/555] arm64: kexec: use a typed entry to fix kCFI oops Greg Kroah-Hartman
                   ` (198 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Vineet Gupta

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

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

From: Vineet Gupta <vgupta@kernel.org>

commit 603b4fd69b4e77770761ea03451e2164186f8590 upstream.

The __raw_write{w,l}() accessors use inline asm with an "m" operand for
the store destination. GCC's ARC backend lets "m" match any legitimate
address, including the register-indexed [b,c] forms that only loads
support: stores only have [reg], [reg,s9] and [limm] addressing. With
newer GCC (late-combine in GCC 15, combine in GCC 16), a writew() with a
scaled, non-constant offset gets

	stw.as r2,[r0,r1]

which the assembler rejects:

  Error: inappropriate arguments for opcode 'stw'

With GCC 16 this breaks even hsdk_defconfig (drivers/net/pcs/
pcs-xpcs-plat.c) and axs101_defconfig. allyesconfig additionally trips
in drivers/pinctrl/renesas/pinctrl-rza2.c and drivers/video/fbdev/
s3c-fb.c.

Work around it by passing the address in a register and using a fixed
[%1] address in the asm template, so the compiler can't pick an
addressing mode that stores don't support. This is the minimal fix.
The next patch drops the inline asm altogether.

Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127718
Cc: stable@vger.kernel.org
Signed-off-by: Vineet Gupta <vgupta@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/arc/include/asm/io.h |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

--- a/arch/arc/include/asm/io.h
+++ b/arch/arc/include/asm/io.h
@@ -136,10 +136,14 @@ static inline void __raw_writeb(u8 b, vo
 #define __raw_writew __raw_writew
 static inline void __raw_writew(u16 s, volatile void __iomem *addr)
 {
+	/*
+	 * Not an "m" operand: GCC can pick a register-indexed address for it,
+	 * which ST doesn't support (GCC PR target/127718).
+	 */
 	__asm__ __volatile__(
-	"	stw%U1 %0, %1	\n"
+	"	stw %0, [%1]	\n"
 	:
-	: "r" (s), "m" (*(volatile u16 __force *)addr)
+	: "r" (s), "r" (addr)
 	: "memory");
 
 }
@@ -147,10 +151,11 @@ static inline void __raw_writew(u16 s, v
 #define __raw_writel __raw_writel
 static inline void __raw_writel(u32 w, volatile void __iomem *addr)
 {
+	/* See __raw_writew() above for why this doesn't use an "m" operand. */
 	__asm__ __volatile__(
-	"	st%U1 %0, %1	\n"
+	"	st %0, [%1]	\n"
 	:
-	: "r" (w), "m" (*(volatile u32 __force *)addr)
+	: "r" (w), "r" (addr)
 	: "memory");
 
 }



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 357/555] arm64: kexec: use a typed entry to fix kCFI oops
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (355 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 356/555] ARC: io: work around GCC PR127718 in __raw_write{w,l}() Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 358/555] ASoC: qcom: audioreach: only disconnect the route a mixer control owns Greg Kroah-Hartman
                   ` (197 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Kees Cook, Ben Cressey,
	Catalin Marinas

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

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

From: Ben Cressey <ben@cressey.dev>

commit b059e957d07b3cab92eef4656988244043f5769a upstream.

An arm64 Linux kernel built with CONFIG_CFI=y oopses after "Bye!" on
every kexec that relocates the image. Crash images load in place and are
not affected. The oops reproduces under QEMU:

 Unable to handle kernel paging request at virtual address 00000000544bfffc
 pc : machine_kexec+0x104/0x274
 Code: d5182008 d5033fdf aa1303e0 f9418a68 (b85fc110)

b85fc110 is "ldur w16, [x8, #-4]", the kCFI check's load of the type
hash in front of the callee. Commit efc2d0f20a9d ("arm64: kexec: keep
MMU enabled during kexec relocation") made machine_kexec() call the
control page's copy of arm64_relocate_new_kernel() indirectly, while
TTBR0 maps only that page. The copy starts at the page's first byte, so
the load faults. SYM_CODE_START() also gives the routine no hash.

SYM_TYPED_FUNC_START() emits the hash inside .kexec_relocate.text, and
machine_kexec_post_load() already copies that whole section, at most
4 KiB, to the page's start, so the mapped page holds both hash and
entry.

The ASSERT from commit dc4824faa265 ("arm64: avoid executing padding
bytes during kexec / hibernation") kept the entry first, since C
branched to the page's start. Relax it, so the entry need only be in the
section.

Fix by typing the routine with SYM_TYPED_FUNC_START() and a C prototype,
and entering the copy at the symbol's offset in the section.

The code is Kees Cook's, as posted in review, with two comments and the
ASSERT message reworded.

An LLM diagnosed the oops.

Fixes: efc2d0f20a9d ("arm64: kexec: keep MMU enabled during kexec relocation")
Cc: stable@vger.kernel.org
Suggested-by: Kees Cook <kees@kernel.org>
Link: https://lore.kernel.org/linux-arm-kernel/202609241804.BB23BF10@keescook/
Signed-off-by: Ben Cressey <ben@cressey.dev>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/arm64/include/asm/kexec.h      |    2 ++
 arch/arm64/kernel/machine_kexec.c   |    7 +++++--
 arch/arm64/kernel/relocate_kernel.S |   11 +++++++----
 arch/arm64/kernel/vmlinux.lds.S     |    5 +++--
 4 files changed, 17 insertions(+), 8 deletions(-)

--- a/arch/arm64/include/asm/kexec.h
+++ b/arch/arm64/include/asm/kexec.h
@@ -100,6 +100,8 @@ void cpu_soft_restart(unsigned long el2_
 		      unsigned long arg0, unsigned long arg1,
 		      unsigned long arg2);
 
+void arm64_relocate_new_kernel(struct kimage *kimage);
+
 int machine_kexec_post_load(struct kimage *image);
 #define machine_kexec_post_load machine_kexec_post_load
 #endif
--- a/arch/arm64/kernel/machine_kexec.c
+++ b/arch/arm64/kernel/machine_kexec.c
@@ -136,9 +136,12 @@ int machine_kexec_post_load(struct kimag
 	kimage->arch.ttbr1 = __pa(trans_pgd);
 	kimage->arch.zero_page = __pa_symbol(empty_zero_page);
 
+	/* Copy the whole section: a kCFI hash may precede the entry point */
 	reloc_size = __relocate_new_kernel_end - __relocate_new_kernel_start;
 	memcpy(reloc_code, __relocate_new_kernel_start, reloc_size);
-	kimage->arch.kern_reloc = __pa(reloc_code);
+	kimage->arch.kern_reloc = __pa(reloc_code) +
+		((unsigned long)arm64_relocate_new_kernel -
+		 (unsigned long)__relocate_new_kernel_start);
 	rc = trans_pgd_idmap_page(&info, &kimage->arch.ttbr0,
 				  &kimage->arch.t0sz, reloc_code);
 	if (rc)
@@ -193,7 +196,7 @@ void machine_kexec(struct kimage *kimage
 		restart(is_hyp_nvhe(), kimage->start, kimage->arch.dtb_mem,
 			0, 0);
 	} else {
-		void (*kernel_reloc)(struct kimage *kimage);
+		typeof(arm64_relocate_new_kernel) *kernel_reloc;
 
 		if (is_hyp_nvhe())
 			__hyp_set_vectors(kimage->arch.el2_vectors);
--- a/arch/arm64/kernel/relocate_kernel.S
+++ b/arch/arm64/kernel/relocate_kernel.S
@@ -8,6 +8,7 @@
  * Pasha Tatashin <pasha.tatashin@soleen.com>
  */
 
+#include <linux/cfi_types.h>
 #include <linux/kexec.h>
 #include <linux/linkage.h>
 
@@ -32,11 +33,13 @@
  * new image to its final location.  To assure that the
  * arm64_relocate_new_kernel routine which does that copy is not overwritten,
  * all code and data needed by arm64_relocate_new_kernel must be between the
- * symbols arm64_relocate_new_kernel and arm64_relocate_new_kernel_end.  The
- * machine_kexec() routine will copy arm64_relocate_new_kernel to the kexec
+ * symbols __relocate_new_kernel_start and __relocate_new_kernel_end.  The
+ * machine_kexec_post_load() routine will copy that whole region to the kexec
  * safe memory that has been set up to be preserved during the copy operation.
+ *
+ * Called indirectly by machine_kexec(), this routine needs a kCFI type hash.
  */
-SYM_CODE_START(arm64_relocate_new_kernel)
+SYM_TYPED_FUNC_START(arm64_relocate_new_kernel)
 	/*
 	 * The kimage structure isn't allocated specially and may be clobbered
 	 * during relocation. We must load any values we need from it prior to
@@ -97,4 +100,4 @@ SYM_CODE_START(arm64_relocate_new_kernel
 	mov	x2, xzr
 	mov	x3, xzr
 	br	x28				/* Jumps from el1 */
-SYM_CODE_END(arm64_relocate_new_kernel)
+SYM_FUNC_END(arm64_relocate_new_kernel)
--- a/arch/arm64/kernel/vmlinux.lds.S
+++ b/arch/arm64/kernel/vmlinux.lds.S
@@ -391,6 +391,7 @@ ASSERT(swapper_pg_dir - tramp_pg_dir ==
 ASSERT(__relocate_new_kernel_end - __relocate_new_kernel_start <= SZ_4K,
        "kexec relocation code is bigger than 4 KiB")
 ASSERT(KEXEC_CONTROL_PAGE_SIZE >= SZ_4K, "KEXEC_CONTROL_PAGE_SIZE is broken")
-ASSERT(__relocate_new_kernel_start == arm64_relocate_new_kernel,
-       "kexec control page does not start with arm64_relocate_new_kernel")
+ASSERT(arm64_relocate_new_kernel >= __relocate_new_kernel_start &&
+       arm64_relocate_new_kernel < __relocate_new_kernel_end,
+       "kexec relocation code does not contain arm64_relocate_new_kernel")
 #endif



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 358/555] ASoC: qcom: audioreach: only disconnect the route a mixer control owns
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (356 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 357/555] arm64: kexec: use a typed entry to fix kCFI oops Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 359/555] ASoC: qcom: q6apm-dai: reject compress rings larger than the DMA buffer Greg Kroah-Hartman
                   ` (196 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Marc Herrero, Srinivas Kandagatla,
	Mark Brown

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

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

From: Marc Herrero <marcht@proton.me>

commit 562b2cc2aa88e039790248b5f1014c4850a7e528 upstream.

Each AudioReach virtual mixer route control ("<BE> Audio Mixer <FE>")
connects a front-end stream graph to a back-end device graph by storing
the source module in the device graph's audioreach_graph_info. Writing 0
to any of these controls clears that link unconditionally, even when the
device graph is connected to a different front end.

When two front ends can feed the same back end the result therefore
depends on write order. On QCS6490 (Radxa Dragon Q6A):

 - alsactl restore writes 'DISPLAY_PORT_RX_0 Audio Mixer MultiMedia2' = 1
   and then 'DISPLAY_PORT_RX_0 Audio Mixer MultiMedia1' = 0, which leaves
   DisplayPort disconnected although the saved state has it connected;
 - the UCM HDMI enable sequence writes
   'RX_CODEC_DMA_RX_0 Audio Mixer MultiMedia2' = 0, which disconnects
   MultiMedia1 from the headphones. A PCM started on MultiMedia1 after
   that never advances (hw_ptr stays at 0).

Make audioreach_connect_sub_graphs() only clear the link when it belongs
to the control being cleared, using the same test as
audioreach_is_vmixer_connected() does for get(). The DAPM mixer state is
still updated for every write, so DAPM keeps tracking each route control
as before.

Fixes: e4977b91cff8 ("ASoC: qdsp6: audioreach: Simplify handing FE and BE graph connections")
Cc: stable@vger.kernel.org
Signed-off-by: Marc Herrero <marcht@proton.me>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Link: https://patch.msgid.link/20261116-q6apm-fixes-v2-2-ea89fb43316a@proton.me
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 sound/soc/qcom/qdsp6/topology.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/sound/soc/qcom/qdsp6/topology.c
+++ b/sound/soc/qcom/qdsp6/topology.c
@@ -1093,7 +1093,9 @@ static void audioreach_connect_sub_graph
 		info->dst_mod_inst_id = m2->module_instance_id;
 		info->dst_mod_ip_port_id = 2;
 
-	} else {
+	} else if (info->src_mod_inst_id == m1->module_instance_id &&
+		   info->dst_mod_inst_id == m2->module_instance_id) {
+		/* only drop the link this control made, not another FE's */
 		info->src_mod_inst_id = 0;
 		info->src_mod_op_port_id = 0;
 		info->dst_mod_inst_id = 0;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 359/555] ASoC: qcom: q6apm-dai: reject compress rings larger than the DMA buffer
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (357 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 358/555] ASoC: qcom: audioreach: only disconnect the route a mixer control owns Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 360/555] ASoC: qcom: q6asm-dai: " Greg Kroah-Hartman
                   ` (195 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Julius Bairaktaris,
	Srinivas Kandagatla, Mark Brown

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

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

From: Julius Bairaktaris <julius@bairaktaris.de>

commit 3857bc06e5a40c5ebb62917147375a811f010aa0 upstream.

q6apm_dai_compr_open() allocates a fixed 8 MiB DMA buffer, but
q6apm_dai_compr_set_params() takes the ring size from the fragment size
and count that userspace passes to SNDRV_COMPRESS_SET_PARAMS without
checking it against that buffer. The compress core checks the geometry
against the runtime buffer only for drivers without a copy callback.
q6apm_compr_copy() places each write() at the stream position modulo the
ring size, so a ring larger than the DMA buffer lets write() copy user
data past its end, and after SNDRV_COMPRESS_NEXT_TRACK the copy starts at
the next multiple of the fragment size.

Reject a ring larger than the DMA buffer.

Fixes: c317d148a2b0 ("ASoC: q6dsp: q6apm-dai: Add mmap and copy compress DAI callbacks")
Cc: stable@vger.kernel.org
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Link: https://patch.msgid.link/20261111080624.244291-2-julius@bairaktaris.de
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 sound/soc/qcom/qdsp6/q6apm-dai.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/sound/soc/qcom/qdsp6/q6apm-dai.c
+++ b/sound/soc/qcom/qdsp6/q6apm-dai.c
@@ -659,6 +659,9 @@ static int q6apm_dai_compr_set_params(st
 	if (!pdata)
 		return -EINVAL;
 
+	if (runtime->buffer_size > prtd->dma_buffer.bytes)
+		return -EINVAL;
+
 	prtd->periods = runtime->fragments;
 	prtd->pcm_count = runtime->fragment_size;
 	prtd->pcm_size = runtime->fragments * runtime->fragment_size;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 360/555] ASoC: qcom: q6asm-dai: reject compress rings larger than the DMA buffer
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (358 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 359/555] ASoC: qcom: q6apm-dai: reject compress rings larger than the DMA buffer Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 361/555] ASoC: qcom: q6dsp-lpass-clocks: Set driver data before registering clocks Greg Kroah-Hartman
                   ` (194 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Julius Bairaktaris, Mark Brown

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

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

From: Julius Bairaktaris <julius@bairaktaris.de>

commit 4c15e549b7ad03183d10826da91e9ddc207a02cd upstream.

q6asm_dai_compr_open() allocates a fixed 8 MiB DMA buffer, but
q6asm_dai_compr_set_params() takes the ring size from the fragment size
and count that userspace passes to SNDRV_COMPRESS_SET_PARAMS without
checking it against that buffer. The compress core checks the geometry
against the runtime buffer only for drivers without a copy callback.
q6asm_compr_copy() places each write() at the stream position modulo the
ring size, so a ring larger than the DMA buffer lets write() copy user
data past its end, and after SNDRV_COMPRESS_NEXT_TRACK the copy starts at
the next multiple of the fragment size.

Reject a ring larger than the DMA buffer.

Fixes: a08cd56a4524 ("ASoC: q6asm-dai: add support to copy callback")
Cc: stable@vger.kernel.org
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
Link: https://patch.msgid.link/20261111080624.244291-3-julius@bairaktaris.de
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 sound/soc/qcom/qdsp6/q6asm-dai.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/sound/soc/qcom/qdsp6/q6asm-dai.c
+++ b/sound/soc/qcom/qdsp6/q6asm-dai.c
@@ -885,6 +885,9 @@ static int q6asm_dai_compr_set_params(st
 		return -EINVAL;
 	}
 
+	if (runtime->buffer_size > prtd->dma_buffer.bytes)
+		return -EINVAL;
+
 	prtd->periods = runtime->fragments;
 	prtd->pcm_count = runtime->fragment_size;
 	prtd->pcm_size = runtime->fragments * runtime->fragment_size;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 361/555] ASoC: qcom: q6dsp-lpass-clocks: Set driver data before registering clocks
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (359 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 360/555] ASoC: qcom: q6asm-dai: " Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 362/555] ASoC: wm8962: Fix broken headset button caused by wrong guard constant Greg Kroah-Hartman
                   ` (193 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, yzddMr6, Srinivas Kandagatla,
	Mark Brown

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

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

From: yzddMr6 <yzddmr6@gmail.com>

commit bd6e011c8121c909daf51c78b56bb3bf7f467889 upstream.

The clk ops of the q6dsp clock controller look up struct q6dsp_cc with
dev_get_drvdata(), but q6dsp_clock_dev_probe() sets the driver data only
after it has registered the clocks and added the OF clock provider. A
consumer that gets and prepares one of the clocks in between
dereferences a NULL pointer.

fw_devlink does not keep consumers out of that window. The q6prm and
q6afe clock controllers are described below the ADSP remoteproc node,
and their devices are only created once the ADSP has booted and its
GPR/APR services have come up, long after the remoteproc device has
bound. fw_devlink therefore makes the remoteproc device the supplier of
their consumers. A consumer such as the LPASS LPI pinctrl then just
defers until of_clk_get() succeeds, and its retry from the deferred
probe worker can run while the clock controller is still in its probe.

That happened once on a Xiaomi Pad 8 Pro (SM8750). While the LPI pinctrl
probe registered its GPIO chip, gpiolib read a GPIO direction, which
runtime resumed the device and prepared its q6prm vote clocks through
pm_clk. The prepare op then faulted with a NULL pointer dereference at
virtual address 0x350 (trimmed):

  pc : clk_vote_q6dsp_block+0x24/0x58 [snd_q6dsp_common]
  lr : clk_core_prepare+0x7c/0x298
  Call trace:
   clk_vote_q6dsp_block+0x24/0x58 [snd_q6dsp_common] (P)
   clk_core_prepare+0x7c/0x298
   clk_prepare+0x28/0x44
   pm_clk_resume+0x10c/0x188
   pm_generic_runtime_resume+0x2c/0x44
   ...
   __pm_runtime_resume+0x50/0x94
   ...
   lpi_gpio_get_direction+0x4c/0x8c [pinctrl_lpass_lpi]
   gpiochip_add_data_with_key+0x7b0/0x10dc
   devm_gpiochip_add_data_with_key+0x38/0x8c
   lpi_pinctrl_probe+0x2b8/0x320 [pinctrl_lpass_lpi]
   ...
   deferred_probe_work_func+0x88/0xc0

0x350 is the offset of desc in struct q6dsp_cc; the driver data pointer
it was loaded from was NULL. The oops left the clk prepare_lock held,
which blocks every later clk_prepare(), and the system did not finish
booting.

On mainline the window is short, but it includes a wait for prepare_lock
in clk_core_reparent_orphans(), which of_clk_add_hw_provider() calls
right after listing the provider. The kernel that hit this had
out-of-tree changes to drivers/clk/clk.c that do more work at that
point, which makes the window wider.

Both q6afe-clocks and q6prm-clocks use q6dsp_clock_dev_probe(). Set the
driver data before the first clock is registered.

The oops was analysed and the fix written with the help of an AI coding
assistant.

Fixes: 9ab71ac37240 ("ASoC: qdsp6: q6afe-clocks: move audio-clocks to common file")
Cc: stable@vger.kernel.org
Signed-off-by: yzddMr6 <yzddmr6@gmail.com>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Link: https://patch.msgid.link/20261115-upstream-q6dsp-clk-drvdata-v1-1-4d7dbea52e52@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

--- a/sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c
+++ b/sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c
@@ -146,6 +146,12 @@ int q6dsp_clock_dev_probe(struct platfor
 	cc->dev = dev;
 	q6dsp_clks = desc->clks;
 
+	/*
+	 * The clk ops look up cc through the driver data, so set it before
+	 * any of the clocks can be prepared.
+	 */
+	dev_set_drvdata(dev, cc);
+
 	for (i = 0; i < desc->num_clks; i++) {
 		unsigned int id = q6dsp_clks[i].clk_id;
 		struct clk_init_data init = {
@@ -174,12 +180,6 @@ int q6dsp_clock_dev_probe(struct platfor
 			return ret;
 	}
 
-	ret = devm_of_clk_add_hw_provider(dev, q6dsp_of_clk_hw_get, cc);
-	if (ret)
-		return ret;
-
-	dev_set_drvdata(dev, cc);
-
-	return 0;
+	return devm_of_clk_add_hw_provider(dev, q6dsp_of_clk_hw_get, cc);
 }
 EXPORT_SYMBOL_GPL(q6dsp_clock_dev_probe);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 362/555] ASoC: wm8962: Fix broken headset button caused by wrong guard constant
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (360 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 361/555] ASoC: qcom: q6dsp-lpass-clocks: Set driver data before registering clocks Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 363/555] ata: libata-scsi: fix the INC_512 bit test for SECURITY PROTOCOL IN/OUT Greg Kroah-Hartman
                   ` (192 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Chen Yuxi, Charles Keepax,
	Sebastian Krzyszkowiak, Mark Brown

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

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

From: Chen Yuxi <chenyuxi19@huawei.com>

commit fd3b0fc97ea72d027359e7603a1224703cec1864 upstream.

Commit e59075211902 ("ASoC: wm8962: Don't report a microphone if
it's shorted to ground on plug") guards the mic short report by
testing wm8962->mic_status against WM8962_MICDET_STS.  But mic_status
stores the reported jack status, composed of SND_JACK_MICROPHONE and
SND_JACK_BTN_0, which never has WM8962_MICDET_STS set.  The guard is
therefore always true, so every mic short event reports nothing.

Pressing the button on a TRRS headset shorts the mic pin to ground,
which used to be reported as SND_JACK_BTN_0.  After that commit the
button press is silently dropped, breaking the headset button on all
wm8962 boards using the mic detect path.

Test mic_status against SND_JACK_MICROPHONE instead, restoring the
intended behaviour: suppress the report only when no microphone was
previously detected, i.e. a TRS plug in a TRRS socket.

Fixes: e59075211902 ("ASoC: wm8962: Don't report a microphone if it's shorted to ground on plug")
Cc: stable@vger.kernel.org
Signed-off-by: Chen Yuxi <chenyuxi19@huawei.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm>
Link: https://patch.msgid.link/20261117070516.3861828-1-chenyuxi19@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 sound/soc/codecs/wm8962.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -3079,7 +3079,7 @@ static void wm8962_mic_work(struct work_
 		/* Don't report a microphone if it's shorted right after
 		 * plugging in, as this may be a TRS plug in a TRRS socket.
 		 */
-		if (!(wm8962->mic_status & WM8962_MICDET_STS))
+		if (!(wm8962->mic_status & SND_JACK_MICROPHONE))
 			status = 0;
 	}
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 363/555] ata: libata-scsi: fix the INC_512 bit test for SECURITY PROTOCOL IN/OUT
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (361 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 362/555] ASoC: wm8962: Fix broken headset button caused by wrong guard constant Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 364/555] blk-iocost: Fix overflow in donation weight calculation Greg Kroah-Hartman
                   ` (191 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Damien Le Moal, Niklas Cassel

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

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

From: Niklas Cassel <cassel@kernel.org>

commit e2954988bb987c1432806379f602573d2388df93 upstream.

ata_scsi_security_inout_xlat() tests the INC_512 bit with cdb[4] & 7.
INC_512 is bit 7 of byte 4 of the SECURITY PROTOCOL IN and SECURITY
PROTOCOL OUT CDBs (SPC-6, tables 280 and 282), and bits 6:0 of that
byte are reserved.

Test bit 7 instead.

Fixes: 818831c8b22f ("libata: implement SECURITY PROTOCOL IN/OUT")
Cc: stable@vger.kernel.org
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Link: https://lore.kernel.org/r/20261116191008.2954277-2-cassel@kernel.org
Signed-off-by: Niklas Cassel <cassel@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/ata/libata-scsi.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -4485,7 +4485,7 @@ static unsigned int ata_scsi_security_in
 		return 1;
 	}
 
-	if (cdb[4] & 7) { /* INC_512 */
+	if (cdb[4] & 0x80) { /* INC_512 */
 		if (len > 0xffff) {
 			ata_scsi_set_invalid_field(qc->dev, scmd, 6, 0);
 			return 1;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 364/555] blk-iocost: Fix overflow in donation weight calculation
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (362 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 363/555] ata: libata-scsi: fix the INC_512 bit test for SECURITY PROTOCOL IN/OUT Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 365/555] Bluetooth: hci_qca: clear qca_memdump when discarding dump packets Greg Kroah-Hartman
                   ` (190 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Alex Kazinsky, Tejun Heo, Jens Axboe

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

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

From: Alex Kazinsky <a.kazinsky@ideco.ru>

commit a56d5a485be4a9d52f0d7b3ed0dc3521367cb986 upstream.

hweight_after_donation() receives usage as u32, clamped to the range
[1, WEIGHT_ONE]. Since WEIGHT_ONE is 1 << 16, multiplying it by usage
equal to WEIGHT_ONE wraps the 32-bit unsigned result to zero before
it is passed to div64_s64().

This makes new_hwi zero, which is then clamped to 1, incorrectly
reducing the cgroup's in-use weight to the minimum.

Cast WEIGHT_ONE to s64 before multiplication to preserve the full
product.

Found by Linux Verification Center (linuxtesting.org) with SVACE static
analysis tool.

Fixes: f1de2439ec43 ("blk-iocost: revamp donation amount determination")
Cc: stable@vger.kernel.org
Signed-off-by: Alex Kazinsky <a.kazinsky@ideco.ru>
Acked-by: Tejun Heo <tj@kernel.org>
Link: https://patch.msgid.link/20261113110842.4189035-1-a.kazinsky@ideco.ru
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 block/blk-iocost.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -1845,7 +1845,8 @@ static u32 hweight_after_donation(struct
 	delta = div64_s64(WEIGHT_ONE * (now->vnow - vtime),
 			  now->vnow - ioc->period_at_vtime);
 	target = WEIGHT_ONE * MARGIN_TARGET_PCT / 100;
-	new_hwi = div64_s64(WEIGHT_ONE * usage, WEIGHT_ONE - target + delta);
+	new_hwi = div64_s64((s64)WEIGHT_ONE * usage,
+			    WEIGHT_ONE - target + delta);
 
 	return clamp_t(s64, new_hwi, 1, hwm);
 }



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 365/555] Bluetooth: hci_qca: clear qca_memdump when discarding dump packets
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (363 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 364/555] blk-iocost: Fix overflow in donation weight calculation Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 366/555] Bluetooth: MGMT: Fix runtime config status opcode Greg Kroah-Hartman
                   ` (189 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Joas Antonio dos Santos,
	Luiz Augusto von Dentz

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

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

From: Joas Antonio dos Santos <joasantonio108@gmail.com>

commit 45a25a1bfd267d9e420119a48e5291d7882395df upstream.

qca_controller_memdump() frees qca_memdump when a memdump packet with a
non-zero sequence number arrives while QCA_MEMDUMP_COLLECTION is not
set, but leaves qca->qca_memdump pointing at the freed object.

The next run of the work reads the stale pointer into its local
variable, skips the allocation and uses the freed memory.  Another
packet with a non-zero sequence number frees it a second time, and a
packet with sequence number 0 writes ram_dump_size, current_seq_no and
received_dump into it.

The original code cleared the pointer here; the assignment was dropped
when the condition was changed to test QCA_MEMDUMP_COLLECTION.  All
other places that free the structure clear the pointer.

A controller that sends two memdump events without a leading sequence
number 0 can trigger a use-after-free or double free of a kmalloc
object.

Found by LLM-assisted source review.

Fixes: 06d3fdfcdf5c ("Bluetooth: hci_qca: Add qcom devcoredump support")
Cc: stable@vger.kernel.org
Signed-off-by: Joas Antonio dos Santos <joasantonio108@gmail.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/bluetooth/hci_qca.c |    1 +
 1 file changed, 1 insertion(+)

--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -1115,6 +1115,7 @@ static void qca_controller_memdump(struc
 		if (!test_bit(QCA_MEMDUMP_COLLECTION, &qca->flags)) {
 			bt_dev_err(hu->hdev, "QCA: Discarding other packets");
 			kfree(qca_memdump);
+			qca->qca_memdump = NULL;
 			kfree_skb(skb);
 			mutex_unlock(&qca->hci_memdump_lock);
 			return;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 366/555] Bluetooth: MGMT: Fix runtime config status opcode
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (364 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 365/555] Bluetooth: hci_qca: clear qca_memdump when discarding dump packets Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 367/555] cpufreq: CPPC: Set CPPC Enable register in cpu_init() Greg Kroah-Hartman
                   ` (188 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Xu Rao, Luiz Augusto von Dentz

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

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

From: Xu Rao <raoxu@uniontech.com>

commit 4728474344793dd67956e03a2cb244b71383ef7c upstream.

The Set Default Runtime Configuration command uses opcode 0x004e,
but set_def_runtime_config() reports its invalid-parameter status with
the Set Default System Configuration opcode, 0x004c.

A management client that matches Command Status events to its pending
request by opcode therefore cannot associate the response with the
request it sent. Runtime configuration parameters are not implemented,
so the command still returns MGMT_STATUS_INVALID_PARAMS.

Use MGMT_OP_SET_DEF_RUNTIME_CONFIG for the status event so the response
identifies the command that was actually handled.

Fixes: aececa645dc7 ("Bluetooth: mgmt: Add commands for runtime configuration")
Signed-off-by: Xu Rao <raoxu@uniontech.com>
Cc: stable@vger.kernel.org
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/bluetooth/mgmt_config.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/net/bluetooth/mgmt_config.c
+++ b/net/bluetooth/mgmt_config.c
@@ -349,6 +349,6 @@ int set_def_runtime_config(struct sock *
 {
 	bt_dev_dbg(hdev, "sock %p", sk);
 
-	return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DEF_SYSTEM_CONFIG,
+	return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DEF_RUNTIME_CONFIG,
 			       MGMT_STATUS_INVALID_PARAMS);
 }



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 367/555] cpufreq: CPPC: Set CPPC Enable register in cpu_init()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (365 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 366/555] Bluetooth: MGMT: Fix runtime config status opcode Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 368/555] dma-coherent: serialize reserved memory pool initialization Greg Kroah-Hartman
                   ` (187 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sumit Gupta, Christian Loehle,
	Rafael J. Wysocki

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

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

From: Sumit Gupta <sumitg@nvidia.com>

commit 7cca01c39cc89f6ef39079484d26b6d99287a610 upstream.

As per ACPI 6.x s8.4.6.1.4 (CPPC Enable Register):

  "If supported by the platform, OSPM writes a one to this register
   to enable CPPC on this processor. If not implemented, OSPM assumes
   the platform always has CPPC enabled."

The driver never writes this register. CPPC therefore stays disabled
on platforms such as NVIDIA GB10 that wait for OSPM to enable it.

Call cppc_set_enable() in cppc_cpufreq_cpu_init(). Fail init if
enabling CPPC fails. If init fails after CPPC is enabled, disable it
again. The register is optional, so -EOPNOTSUPP is not an error.

Fixes: 5477fb3bd1e8 ("ACPI / CPPC: Add a CPUFreq driver for use with CPPC")
Cc: All applicable <stable@vger.kernel.org> # ab482f1bac6b "ACPI: CPPC: Refactor register value get and set ABIs"
Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
Reviewed-by: Christian Loehle <christian.loehle@arm.com>
[ rjw: Subject tweak ]
Link: https://patch.msgid.link/20261110101246.3665797-1-sumitg@nvidia.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/cpufreq/cppc_cpufreq.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

--- a/drivers/cpufreq/cppc_cpufreq.c
+++ b/drivers/cpufreq/cppc_cpufreq.c
@@ -670,7 +670,17 @@ static int cppc_cpufreq_cpu_init(struct
 		pr_debug("Unsupported CPU co-ord type: %d\n",
 			 policy->shared_type);
 		ret = -EFAULT;
-		goto out;
+		goto out_put;
+	}
+
+	/*
+	 * Enable CPPC. The Enable register is optional - some platforms
+	 * may not support it.
+	 */
+	ret = cppc_set_enable(cpu, true);
+	if (ret && ret != -EOPNOTSUPP) {
+		pr_err("Failed to enable CPPC for CPU%u (%d)\n", cpu, ret);
+		goto out_put;
 	}
 
 	policy->fast_switch_possible = cppc_allow_fast_switch();
@@ -698,6 +708,8 @@ static int cppc_cpufreq_cpu_init(struct
 	return 0;
 
 out:
+	cppc_set_enable(cpu, false);
+out_put:
 	cppc_cpufreq_put_cpu_data(policy);
 	return ret;
 }



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 368/555] dma-coherent: serialize reserved memory pool initialization
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (366 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 367/555] cpufreq: CPPC: Set CPPC Enable register in cpu_init() Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 369/555] dma: swiotlb: Properly tear down the default pool on exit Greg Kroah-Hartman
                   ` (186 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Marek Szyprowski

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

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

From: Marek Szyprowski <m.szyprowski@samsung.com>

commit 494f40ffabcdc8d9fa4012b2c972690f25a0a40f upstream.

Multiple devices can share the same "shared-dma-pool" reserved memory
region, in which case the dma_coherent_mem structure is created by the
first device attached to it and stored in rmem->priv. To avoid the
potential race, serialize the check and initialization of rmem->priv
with a mutex.

Fixes: 7bfa5ab6fa1b ("drivers: dma-coherent: add initialization from device tree")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20261026095423.966856-2-m.szyprowski@samsung.com
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 kernel/dma/coherent.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

--- a/kernel/dma/coherent.c
+++ b/kernel/dma/coherent.c
@@ -7,6 +7,7 @@
 #include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mutex.h>
 #include <linux/dma-direct.h>
 #include <linux/dma-map-ops.h>
 
@@ -334,10 +335,18 @@ static phys_addr_t dma_reserved_default_
 static phys_addr_t dma_reserved_default_memory_size __initdata;
 #endif
 
+static DEFINE_MUTEX(rmem_dma_mutex);
+
 static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev)
 {
-	struct dma_coherent_mem *mem = rmem->priv;
+	struct dma_coherent_mem *mem;
 
+	/*
+	 * Multiple devices can share the same pool and may be probed
+	 * concurrently, so serialize the initialization of rmem->priv.
+	 */
+	guard(mutex)(&rmem_dma_mutex);
+	mem = rmem->priv;
 	if (!mem) {
 		mem = dma_init_coherent_memory(rmem->base, rmem->base,
 					       rmem->size, true);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 369/555] dma: swiotlb: Properly tear down the default pool on exit
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (367 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 368/555] dma-coherent: serialize reserved memory pool initialization Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 370/555] dma: swiotlb: Serialize restricted DMA pool initialization Greg Kroah-Hartman
                   ` (185 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Marek Szyprowski

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

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

From: Marek Szyprowski <m.szyprowski@samsung.com>

commit 7d4a177d0d9bc0ca04caec9293ccb902a853cc47 upstream.

With CONFIG_SWIOTLB_DYNAMIC enabled, the default memory pool is added to
the io_tlb_default_mem.pools RCU list during initialization. When an IOMMU
takes over DMA translation, swiotlb_exit() tears the default pool down and
clears it with memset(), but leaves its node on the pools list. The list
then contains a zeroed entry with a NULL next pointer, and any later walk
of the list, for example mem_used() when reading the io_tlb_used debugfs
file, dereferences an invalid pointer and crashes.

swiotlb_exit() also leaves the io_tlb_default_mem fields that describe
the pool. io_tlb_default_mem.nslabs and can_grow stay set, so
is_swiotlb_allocated() and is_swiotlb_active() keep returning true, and
swiotlb_find_slots() can schedule dynamic pool allocation after teardown.
Without CONFIG_SWIOTLB_DYNAMIC, a later mapping can reach the zeroed
defpool and hit BUG_ON(area_index >= pool->nareas). Before the pool data
was split out of struct io_tlb_mem, swiotlb_exit() cleared the whole
structure, including nslabs.

Clear can_grow and cancel any pending dyn_alloc work, then remove the
default pool from the list and subtract its slots from nslabs, and wait
for an RCU grace period before clearing it, so that no reader can still
see it. Without CONFIG_SWIOTLB_DYNAMIC, reset nslabs directly.

As a result, with CONFIG_SWIOTLB_DYNAMIC swiotlb no longer silently keeps
working through dynamic or transient pools after an IOMMU has turned it
off, so for example dma-iommu bouncing for untrusted devices reports that
bounce buffers are inactive, as it did before the dynamic pools support.

Fixes: 158dbe9c9a3d ("swiotlb: separate memory pool data from other allocator data")
Fixes: 62708b2ba405 ("swiotlb: add a flag whether SWIOTLB is allowed to grow")
Fixes: 1aaa736815eb ("swiotlb: allocate a new memory pool when existing pools are full")
Closes: https://sashiko.dev/#/bug/linux-f75998aa-65ea-4596-9bb4-fa83773012a3
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20261109170603.385791-1-m.szyprowski@samsung.com
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 kernel/dma/swiotlb.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

--- a/kernel/dma/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -537,6 +537,17 @@ void __init swiotlb_exit(void)
 		return;
 
 	pr_info("tearing down default memory pool\n");
+#ifdef CONFIG_SWIOTLB_DYNAMIC
+	io_tlb_default_mem.can_grow = false;
+	cancel_work_sync(&io_tlb_default_mem.dyn_alloc);
+	spin_lock(&io_tlb_default_mem.lock);
+	list_del_rcu(&mem->node);
+	io_tlb_default_mem.nslabs -= mem->nslabs;
+	spin_unlock(&io_tlb_default_mem.lock);
+	synchronize_rcu();
+#else
+	io_tlb_default_mem.nslabs = 0;
+#endif
 	tbl_vaddr = (unsigned long)phys_to_virt(mem->start);
 	tbl_size = PAGE_ALIGN(mem->end - mem->start);
 	slots_size = PAGE_ALIGN(array_size(sizeof(*mem->slots), mem->nslabs));



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 370/555] dma: swiotlb: Serialize restricted DMA pool initialization
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (368 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 369/555] dma: swiotlb: Properly tear down the default pool on exit Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 371/555] EDAC/i5000: Fix slot number passed to determine_mtr() Greg Kroah-Hartman
                   ` (184 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Marek Szyprowski

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

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

From: Marek Szyprowski <m.szyprowski@samsung.com>

commit 7ad92b81b415de806957b19828fc4777a9cf2216 upstream.

Multiple devices can share the same restricted DMA pool, in which case
the io_tlb_mem structure is allocated and initialized by the first
device attached to it and stored in rmem->priv. To avoid the potential
race, serialize the check and initialization of rmem->priv with a mutex.

Fixes: 0b84e4f8b793 ("swiotlb: Add restricted DMA pool initialization")
Closes: https://sashiko.dev/#/bug/linux-6fda7589-591d-4a68-b6e1-b1561f867319
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20261026095423.966856-3-m.szyprowski@samsung.com
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 kernel/dma/swiotlb.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

--- a/kernel/dma/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -35,6 +35,7 @@
 #include <linux/init.h>
 #include <linux/memblock.h>
 #include <linux/mm.h>
+#include <linux/mutex.h>
 #include <linux/pfn.h>
 #include <linux/rculist.h>
 #include <linux/scatterlist.h>
@@ -1823,10 +1824,12 @@ bool swiotlb_free(struct device *dev, st
 	return true;
 }
 
+static DEFINE_MUTEX(rmem_swiotlb_mutex);
+
 static int rmem_swiotlb_device_init(struct reserved_mem *rmem,
 				    struct device *dev)
 {
-	struct io_tlb_mem *mem = rmem->priv;
+	struct io_tlb_mem *mem;
 	unsigned long nslabs = rmem->size >> IO_TLB_SHIFT;
 
 	/* Set Per-device io tlb area to one */
@@ -1840,8 +1843,10 @@ static int rmem_swiotlb_device_init(stru
 	/*
 	 * Since multiple devices can share the same pool, the private data,
 	 * io_tlb_mem struct, will be initialized by the first device attached
-	 * to it.
+	 * to it. Serialize this, as devices may be probed concurrently.
 	 */
+	guard(mutex)(&rmem_swiotlb_mutex);
+	mem = rmem->priv;
 	if (!mem) {
 		struct io_tlb_pool *pool;
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 371/555] EDAC/i5000: Fix slot number passed to determine_mtr()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (369 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 370/555] dma: swiotlb: Serialize restricted DMA pool initialization Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 372/555] fscrypt: Initialize ->ci_master_key before publication Greg Kroah-Hartman
                   ` (183 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Aristeu Rozanski, Andrew Luebke,
	Borislav Petkov (AMD)

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

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

From: Aristeu Rozanski <aris@redhat.com>

commit a088b092a8962db62327690ae2d0d68827e81229 upstream.

When the logic mapping branch/slot/channel was reworked back in

  64e1fdaf55d6 ("i5000_edac: Fix the logic that retrieves memory information")

i5000_init_csrows() was not updated and kept passing twice the number
of slots to determine_mtr(), which leads to accessing past the end of
i5000_pvt.b1_mtr[]. This was found by KASAN.

Fixes: 64e1fdaf55d6 ("i5000_edac: Fix the logic that retrieves memory information")
Signed-off-by: Aristeu Rozanski <aris@redhat.com>
Signed-off-by: Andrew Luebke <andrew.luebke@gmail.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Tested-by: Andrew Luebke <andrew.luebke@gmail.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/all/20220921181009.oxytvicy6sry6it7@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/edac/i5000_edac.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

--- a/drivers/edac/i5000_edac.c
+++ b/drivers/edac/i5000_edac.c
@@ -1250,14 +1250,12 @@ static int i5000_init_csrows(struct mem_
 	struct i5000_pvt *pvt;
 	struct dimm_info *dimm;
 	int empty;
-	int max_csrows;
 	int mtr;
 	int csrow_megs;
 	int channel;
 	int slot;
 
 	pvt = mci->pvt_info;
-	max_csrows = pvt->maxdimmperch * 2;
 
 	empty = 1;		/* Assume NO memory */
 
@@ -1268,7 +1266,7 @@ static int i5000_init_csrows(struct mem_
 	 * to map the dimms. A good cleanup would be to remove this array,
 	 * and do a loop here with branch, channel, slot
 	 */
-	for (slot = 0; slot < max_csrows; slot++) {
+	for (slot = 0; slot < pvt->maxdimmperch; slot++) {
 		for (channel = 0; channel < pvt->maxch; channel++) {
 
 			mtr = determine_mtr(pvt, slot, channel);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 372/555] fscrypt: Initialize ->ci_master_key before publication
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (370 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 371/555] EDAC/i5000: Fix slot number passed to determine_mtr() Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 373/555] fbdev: fm2fb: Fix iomem access Greg Kroah-Hartman
                   ` (182 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Ada Smith, Eric Biggers

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

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

From: Eric Biggers <ebiggers@kernel.org>

commit 2de253924266eeedb798fb662173726c90b0cf04 upstream.

fscrypt_prepare_setflags() assumes that if the key for an inode with a
v2 encryption policy has been set up, then ->ci_master_key is non-NULL.
This is a reasonable assumption, but it does not take into account the
very short gap in fscrypt_setup_encryption_info() between the inode's
fscrypt_inode_info being set and ->ci_master_key being initialized.
Thus, a NULL pointer dereference was possible.

Fix this by closing the gap: make fscrypt_setup_encryption_info()
initialize ->ci_master_key before publication.  If it loses the cmpxchg
race afterwards, set it back to NULL so that put_crypt_info() continues
to have the same behavior.

Fixes: b1c0ec3599f4 ("fscrypt: add FS_IOC_REMOVE_ENCRYPTION_KEY ioctl")
Cc: stable@vger.kernel.org
Reported-by: Ada Smith <adasmithgt@gmail.com>
Link: https://patch.msgid.link/20261110212011.35487-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/crypto/keysetup.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

--- a/fs/crypto/keysetup.c
+++ b/fs/crypto/keysetup.c
@@ -632,6 +632,13 @@ fscrypt_setup_encryption_info(struct ino
 		goto out;
 
 	/*
+	 * Preemptively initialize ->ci_master_key, even though we don't know
+	 * whether we'll win the race below yet, because if we do win the race
+	 * then other tasks can see it right away and need ->ci_master_key.
+	 */
+	crypt_info->ci_master_key = mk;
+
+	/*
 	 * For existing inodes, multiple tasks may race to set ->i_crypt_info.
 	 * So use cmpxchg_release().  This pairs with the smp_load_acquire() in
 	 * fscrypt_get_inode_info().  I.e., here we publish ->i_crypt_info with
@@ -643,7 +650,6 @@ fscrypt_setup_encryption_info(struct ino
 		 * Now link it into the master key's inode list.
 		 */
 		if (mk) {
-			crypt_info->ci_master_key = mk;
 			refcount_inc(&mk->mk_active_refs);
 			spin_lock(&mk->mk_decrypted_inodes_lock);
 			list_add(&crypt_info->ci_master_key_link,
@@ -651,6 +657,12 @@ fscrypt_setup_encryption_info(struct ino
 			spin_unlock(&mk->mk_decrypted_inodes_lock);
 		}
 		crypt_info = NULL;
+	} else {
+		/*
+		 * Lost the race, so we won't be taking an active reference to
+		 * the master key.  Clear ->ci_master_key accordingly.
+		 */
+		crypt_info->ci_master_key = NULL;
 	}
 	res = 0;
 out:



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 373/555] fbdev: fm2fb: Fix iomem access
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (371 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 372/555] fscrypt: Initialize ->ci_master_key before publication Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 374/555] fbdev: macmodes: compare the pixel clock of each candidate mode Greg Kroah-Hartman
                   ` (181 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Steffen A. Mork, Helge Deller

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

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

From: Steffen A. Mork <linux-dev@morknet.de>

commit 7d4a8a804cd1a3bcaa1a9a38e87517ead3130ca1 upstream.

This driver has not been tested for at least twenty years. In the meantime,
the frame buffer API has been updated. This patch addresses this issue and
makes the driver functional again.

Signed-off-by: Steffen A. Mork <linux-dev@morknet.de>
Cc: stable@vger.kernel.org
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/video/fbdev/fm2fb.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/video/fbdev/fm2fb.c
+++ b/drivers/video/fbdev/fm2fb.c
@@ -257,7 +257,7 @@ static int fm2fb_probe(struct zorro_dev
 	strcpy(fb_fix.id, is_fm ? "FrameMaster II" : "Rainbow II");
 
 	/* make EBU color bars on display */
-	ptr = (unsigned long *)fb_fix.smem_start;
+	ptr = (unsigned long *)info->screen_base;
 	for (y = 0; y < 576; y++) {
 		for (x = 0; x < 96; x++) *ptr++ = 0xffffff;/* white */
 		for (x = 0; x < 96; x++) *ptr++ = 0xffff00;/* yellow */



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 374/555] fbdev: macmodes: compare the pixel clock of each candidate mode
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (372 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 373/555] fbdev: fm2fb: Fix iomem access Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 375/555] fbdev: radeonfb: reject a zero pixclock in radeonfb_check_var() Greg Kroah-Hartman
                   ` (180 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Tim Douglas, Helge Deller

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

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

From: Tim Douglas <me@timdoug.com>

commit 3e973ab62c86d620b2db9e90eb8fc3b065929e6e upstream.

In the second pass through the mode table in mac_var_to_vmode(),
the requested pixel clock period was compared with the first mode's
period at every step. The last mode at that resolution was therefore
returned even when its period was too short. Compare against the
current candidate's period.

Tested on a Performa 6200CD using a kernel with local platform
support. With video=valkyriefb:vmode:10 (800x600 at 60 Hz), the
measured refresh rate was about 72 Hz before the fix and 60 Hz
afterward. At 640x480, 67 Hz was also selected for a 60 Hz request
before the fix.

AI assistance was used to investigate the mode-table walk and draft
the fix.

Signed-off-by: Tim Douglas <me@timdoug.com>
Fixes: d876c11a0fd4 ("fbdev: mac_var_to_mode() fix")
Cc: stable@vger.kernel.org
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/video/fbdev/macmodes.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/video/fbdev/macmodes.c
+++ b/drivers/video/fbdev/macmodes.c
@@ -341,7 +341,7 @@ int mac_var_to_vmode(const struct fb_var
 
 	    if (mode->xres != clk_mode->xres || mode->yres != clk_mode->yres)
 		break;
-	    if (var->pixclock > mode->pixclock)
+	    if (var->pixclock > clk_mode->pixclock)
 	        break;
 	    if (mode->vmode != clk_mode->vmode)
 		continue;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 375/555] fbdev: radeonfb: reject a zero pixclock in radeonfb_check_var()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (373 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 374/555] fbdev: macmodes: compare the pixel clock of each candidate mode Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:06 ` [PATCH 6.12 376/555] fbdev: smscufx: allocate the size advertised in smem_len Greg Kroah-Hartman
                   ` (179 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Jianqiang Zou, Helge Deller

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

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

From: Jianqiang Zou <jq.zou@outlook.com>

commit b3f1631d362539cfe14571ccfd7db919ffbc08c7 upstream.

radeonfb_set_par() derives the dot clock from the user supplied
struct fb_var_screeninfo:

	dotClock = 1000000000 / pixClock;

where pixClock is copied from mode->pixclock.  A zero pixclock
bypasses the existing validation and makes the kernel divide by zero
in radeonfb_set_par().

The driver does have a check for this: fb_validate_mode() returns
-EINVAL when pixclock is 0, but radeon_match_mode() only calls it when
the output has no scaler and an EDID-derived mode database is
available:

	if (has_rmx == 0 && rinfo->mon1_modedb)
		if (fb_validate_mode(...))
			return -EINVAL;

mon1_modedb is only filled in when an EDID is read, so when no
EDID-derived mode database is available the validation is skipped and
the invalid mode reaches radeonfb_set_par().

Reject a zero pixclock in radeonfb_check_var() before matching the
mode.  fb_set_var() calls it on the FBIOPUT_VSCREENINFO path before
->fb_set_par(), so the invalid value is rejected before the mode is
applied.  This is the same check other fbdev drivers use (i740fb,
arkfb, s3fb).

Reproduced on Linux 7.3.0 using a custom QEMU PCI stub device with
vendor/device ID 1002:5955; no physical Radeon hardware was used.  A
single FBIOPUT_VSCREENINFO with pixclock = 0 is enough to trigger the
divide error.

Signed-off-by: Jianqiang Zou <jq.zou@outlook.com>
Cc: stable@vger.kernel.org
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/video/fbdev/aty/radeon_base.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/video/fbdev/aty/radeon_base.c
+++ b/drivers/video/fbdev/aty/radeon_base.c
@@ -836,6 +836,9 @@ static int radeonfb_check_var (struct fb
         int nom, den;
 	unsigned int pitch;
 
+	if (!var->pixclock)
+		return -EINVAL;
+
 	if (radeon_match_mode(rinfo, &v, var))
 		return -EINVAL;
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 376/555] fbdev: smscufx: allocate the size advertised in smem_len
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (374 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 375/555] fbdev: radeonfb: reject a zero pixclock in radeonfb_check_var() Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 377/555] fbdev: smscufx: dont free registered framebuffer on probe error Greg Kroah-Hartman
                   ` (178 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, YuanZhe Liu, Helge Deller

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

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

From: YuanZhe Liu <25031212351@stu.xidian.edu.cn>

commit ae14fe6f367a9779e108449b4af41791bd6aaa47 upstream.

ufx_realloc_framebuffer() allocates line_length * yres bytes but records
PAGE_ALIGN(line_length * yres) in info->fix.smem_len.  ufx_ops_set_par()
clears the framebuffer by writing smem_len bytes, so the write runs past
the end of the vmalloc() allocation whenever the mode size is not page
aligned:

  BUG: KASAN: vmalloc-out-of-bounds in ufx_ops_set_par
  Write of size 2 at addr ffffc90005518600
  Call Trace:
   ufx_ops_set_par
   ufx_usb_probe
   usb_probe_interface

This runs from the probe path, before any client can open the device: with
the fallback mode of 800x600 at 16 bpp the framebuffer is 960000 bytes and
PAGE_ALIGN() adds 2560 bytes that were never allocated.

Allocate the page aligned size that is published in smem_len instead, so
the buffer covers every byte the driver and the framebuffer core can reach
through smem_start and smem_len.

Fixes: 3c8a63e22a08 ("Add support for SMSC UFX6000/7000 USB display adapters")
Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
Cc: stable@vger.kernel.org
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/video/fbdev/smscufx.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1280,9 +1280,10 @@ static int ufx_realloc_framebuffer(struc
 
 	if (PAGE_ALIGN(new_len) > old_len) {
 		/*
-		 * Alloc system memory for virtual framebuffer
+		 * Alloc system memory for virtual framebuffer.  smem_len is
+		 * rounded up to a page, so allocate that much as well.
 		 */
-		new_fb = vmalloc(new_len);
+		new_fb = vmalloc(PAGE_ALIGN(new_len));
 		if (!new_fb)
 			return -ENOMEM;
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 377/555] fbdev: smscufx: dont free registered framebuffer on probe error
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (375 preceding siblings ...)
  2026-12-04 10:06 ` [PATCH 6.12 376/555] fbdev: smscufx: allocate the size advertised in smem_len Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 378/555] fbdev: smscufx: keep the usb_device alive while ufx_data is in use Greg Kroah-Hartman
                   ` (177 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, YuanZhe Liu, Helge Deller

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

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

From: YuanZhe Liu <25031212351@stu.xidian.edu.cn>

commit ed52e47133f72195f246a9f70c98e47431bb566d upstream.

register_framebuffer() can return an error after the framebuffer has
already been installed: do_register_framebuffer() bumps info->count,
creates /dev/fbN and stores the fb_info in registered_fb[] before it
returns the result of the console takeover, and that takeover may fail.
ufx_usb_probe() treats any error as "nothing was registered" and unwinds
through reset_active, which releases the fb_info and drops both
references to struct ufx_data, freeing @dev.

The framebuffer stays registered and can still be opened, so the next
open() of /dev/fbN reaches ufx_ops_open() with info->par pointing at
freed memory:

  refcount_t: addition on 0; use-after-free.
  WARNING: lib/refcount.c:25 at refcount_warn_saturate
  Call Trace:
   kref_get
   ufx_ops_open    drivers/video/fbdev/smscufx.c:1033
   fb_open         drivers/video/fbdev/core/fb_chrdev.c:351
   chrdev_open
   ...
  refcount_t: underflow; use-after-free.
  WARNING: lib/refcount.c:28 at refcount_warn_saturate
  Call Trace:
   ufx_ops_release drivers/video/fbdev/smscufx.c:1135
   fb_release       drivers/video/fbdev/core/fb_chrdev.c:378
   __fput

Reuse the "has this fb_info been registered" test that ufx_setup_modes()
already uses: take the error path only when refcount_read(&info->count)
says the core did not register the framebuffer.  A failed console
takeover is not fatal for the driver, so report it and keep the
framebuffer registered; the disconnect callback will unregister it
normally.

Fixes: 3c8a63e22a08 ("Add support for SMSC UFX6000/7000 USB display adapters")
Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
Cc: stable@vger.kernel.org
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/video/fbdev/smscufx.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1701,8 +1701,16 @@ static int ufx_usb_probe(struct usb_inte
 	dev_dbg(dev->gdev, "registering framebuffer");
 	retval = register_framebuffer(info);
 	if (retval < 0) {
-		dev_err(dev->gdev, "error %d register_framebuffer", retval);
-		goto reset_active;
+		/*
+		 * info is installed before the takeover can fail; freeing @dev
+		 * here would leave registered_fb[] and /dev/fbN pointing at
+		 * freed memory.
+		 */
+		if (!refcount_read(&info->count)) { /* not registered */
+			dev_err(dev->gdev, "error %d register_framebuffer", retval);
+			goto reset_active;
+		}
+		dev_warn(dev->gdev, "console takeover failed: %d\n", retval);
 	}
 
 	dev_info(dev->gdev, "SMSC UDX USB device /dev/fb%d attached. %dx%d resolution."



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 378/555] fbdev: smscufx: keep the usb_device alive while ufx_data is in use
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (376 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 377/555] fbdev: smscufx: dont free registered framebuffer on probe error Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 379/555] fbdev: sstfb: Error out if pixclock equals zero Greg Kroah-Hartman
                   ` (176 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, YuanZhe Liu, Helge Deller

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

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

From: YuanZhe Liu <25031212351@stu.xidian.edu.cn>

commit e8645fe7419828fd95a90171149c565c1bb72911 upstream.

ufx_usb_probe() stores the usb_device pointer in dev->udev without
taking a reference, and ufx_usb_disconnect() does not wait for in-flight
control transfers.  A mode set or blank request that runs while the
device is being unplugged - through ufx_ops_set_par() or ufx_ops_blank()
on an open /dev/fbN file - keeps issuing synchronous control messages for
the whole ufx_set_vid_mode() sequence, including two msleep(1) delays in
ufx_config_pix_clk().  Once the disconnect callback returns, the USB core
may release the usb_device, and the next ufx_reg_write()/ufx_reg_read()
dereferences dev->udev through __create_pipe():

  general protection fault, probably for non-canonical address
  0xdffffc0000000006: 0000 [#1] SMP
  KASAN: null-ptr-deref in range [0x0000000000000030-0x0000000000000037]
  RIP: __create_pipe include/linux/usb.h:2031
  Call Trace:
   ufx_set_vid_mode
   ufx_ops_set_par
   fb_set_var
   fb_set_var_from_user
   store_rotate

Take a reference to the usb_device in ufx_usb_probe() and drop it in
ufx_free(), so dev->udev and dev->gdev stay valid until the last
ufx_data user is gone.  The control transfers then fail with -ENODEV
instead of dereferencing freed memory.

Also return early from ufx_set_vid_mode() while the device is inactive,
matching the other transmit paths.  That check alone is not enough,
because it is not serialized against ufx_usb_disconnect() and the
transfer sequence continues after it; it only avoids a long series of
failing transfers.

Fixes: 3c8a63e22a08 ("Add support for SMSC UFX6000/7000 USB display adapters")
Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
Cc: stable@vger.kernel.org
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/video/fbdev/smscufx.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -661,8 +661,12 @@ static int ufx_set_vid_mode(struct ufx_d
 	u32 temp;
 	u16 h_total, h_active, h_blank_start, h_blank_end, h_sync_start, h_sync_end;
 	u16 v_total, v_active, v_blank_start, v_blank_end, v_sync_start, v_sync_end;
+	int status;
 
-	int status = ufx_reg_write(dev, 0x8028, 0);
+	if (!atomic_read(&dev->usb_active))
+		return -ENODEV;
+
+	status = ufx_reg_write(dev, 0x8028, 0);
 	check_warn_return(status, "ufx_set_vid_mode error disabling RGB pad");
 
 	status = ufx_reg_write(dev, 0x8024, 0);
@@ -1067,6 +1071,7 @@ static void ufx_free(struct kref *kref)
 {
 	struct ufx_data *dev = container_of(kref, struct ufx_data, kref);
 
+	usb_put_dev(dev->udev);
 	kfree(dev);
 }
 
@@ -1610,6 +1615,8 @@ static int ufx_usb_probe(struct usb_inte
 
 	dev->udev = usbdev;
 	dev->gdev = &usbdev->dev; /* our generic struct device * */
+	/* keep the device alive until the last ufx_data user is gone */
+	usb_get_dev(usbdev);
 	usb_set_intfdata(interface, dev);
 
 	dev_dbg(dev->gdev, "%s %s - serial #%s\n",



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 379/555] fbdev: sstfb: Error out if pixclock equals zero
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (377 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 378/555] fbdev: smscufx: keep the usb_device alive while ufx_data is in use Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 380/555] fbdev: valkyriefb: keep the framebuffer mapping size fixed Greg Kroah-Hartman
                   ` (175 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Xue Haolin, Helge Deller

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

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

From: Xue Haolin <xuehaolin@uniontech.com>

commit f37d206e145d25607c6a8e920d7bb643d203a1f7 upstream.

The userspace program could pass any values to the driver through
ioctl() interface. If the driver doesn't check the value of pixclock,
it may cause divide-by-zero error.

sstfb_check_var() calls PICOS2KHZ(var->pixclock) which expands to
1000000000UL / var->pixclock. If var->pixclock is zero, this causes
a divide-by-zero exception.

Fix this by checking whether pixclock is zero at the beginning of
sstfb_check_var(), before it is used as a divisor.

This is similar to CVE-2022-3061 in i740fb which was fixed by
commit 15cf0b82271b ("video: fbdev: i740fb: Error out if
'pixclock' equals zero"), and the fix in savagefb by
commit 04e5eac8f3ab ("fbdev: savage: Error out if pixclock equals zero").

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Xue Haolin <xuehaolin@uniontech.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/video/fbdev/sstfb.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/video/fbdev/sstfb.c
+++ b/drivers/video/fbdev/sstfb.c
@@ -359,6 +359,9 @@ static int sstfb_check_var(struct fb_var
 	int tiles_in_X, real_length;
 	unsigned int freq;
 
+	if (!var->pixclock)
+		return -EINVAL;
+
 	if (sst_calc_pll(PICOS2KHZ(var->pixclock), &freq, &par->pll)) {
 		printk(KERN_ERR "sstfb: Pixclock at %ld KHZ out of range\n",
 				PICOS2KHZ(var->pixclock));



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 380/555] fbdev: valkyriefb: keep the framebuffer mapping size fixed
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (378 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 379/555] fbdev: sstfb: Error out if pixclock equals zero Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 381/555] fbdev: vfb: Validate framebuffer geometry and memory size Greg Kroah-Hartman
                   ` (174 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Tim Douglas, Helge Deller

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

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

From: Tim Douglas <me@timdoug.com>

commit fa9bebccf45571bd710b0591359b28d5354e7e7a upstream.

When /dev/fb0 is mapped before a depth change, as with Xorg's fbdev
driver, the mapping may be too short for the new mode. At 640x480,
a full frame at 16 bpp is 600 KiB, so drawing it through the
original 300 KiB mapping from 8 bpp can fault.

Set smem_len to the usable video RAM by subtracting the 4 KiB offset
already applied to smem_start, then keep that size across mode
changes.

On a Performa 6200CD using a kernel with local platform support,
a write past the mapping caused a fault during an Xorg test at
16 bpp. With the corrected mapping size in the test kernel, twm
and xterm were displayed successfully in Xorg at 640x480 and 16 bpp.

In a test on a Quadra 630 in MAME with Linux v7.4-rc3, /dev/fb0 was
mapped at 8 bpp and the depth was changed to 16 bpp with the original
mapping still in place. A SIGSEGV was reported during the 16 bpp draw
before the fix, and all 480 lines were drawn afterward.

AI assistance was used to investigate the mapping size and draft
the fix.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Tim Douglas <me@timdoug.com>
Cc: stable@vger.kernel.org
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/video/fbdev/valkyriefb.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/drivers/video/fbdev/valkyriefb.c
+++ b/drivers/video/fbdev/valkyriefb.c
@@ -510,7 +510,7 @@ static void valkyrie_init_fix(struct fb_
 	fix->mmio_len = sizeof(struct valkyrie_regs);
 	fix->type = FB_TYPE_PACKED_PIXELS;
 	fix->smem_start = p->frame_buffer_phys + 0x1000;
-	fix->smem_len = p->total_vram;
+	fix->smem_len = p->total_vram - 0x1000;
 
 	fix->type_aux = 0;
 	fix->ywrapstep = 0;
@@ -523,7 +523,6 @@ static void valkyrie_init_fix(struct fb_
 static void valkyrie_par_to_fix(struct fb_par_valkyrie *par,
 	struct fb_fix_screeninfo *fix)
 {
-	fix->smem_len = valkyrie_vram_reqd(par->vmode, par->cmode);
 	fix->visual = (par->cmode == CMODE_8) ?
 		FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR;
 	fix->line_length = par->vxres << par->cmode;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 381/555] fbdev: vfb: Validate framebuffer geometry and memory size
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (379 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 380/555] fbdev: valkyriefb: keep the framebuffer mapping size fixed Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 382/555] fuse: fix possible UAF in fuse_direntplus_link() Greg Kroah-Hartman
                   ` (173 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, co+b0df61d49532b2ee, Helge Deller,
	Weiming Shi

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

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

From: Weiming Shi <bestswngs@gmail.com>

commit b438bb88f65a8b464ad08057873db9605cdae945 upstream.

FBIOPUT_VSCREENINFO can supply a virtual width large enough to
overflow get_line_length()'s int multiplication and bypass the
video-memory limit, allowing fbcon to write past the framebuffer. The
offset additions can also wrap, while an excessive videomemorysize
module parameter can be truncated when PAGE_ALIGN() is assigned to
unsigned int.

Limit virtual geometry and offsets to 8192 x 8192 and cap video
memory at 512 MiB, keeping the stride, framebuffer-size, and generic
fbdev drawing calculations within their destination types.

KASAN reports:

  BUG: KASAN: vmalloc-out-of-bounds in sys_fillrect
    drivers/video/fbdev/core/sysfillrect.c:24
  Write of size 8 at addr ffa0000001671000 by task poc/198
  sys_fillrect
    drivers/video/fbdev/core/sysfillrect.c:24
  bit_clear_margins
    drivers/video/fbdev/core/bitblit.c:247
  fbcon_clear_margins.constprop.0
    drivers/video/fbdev/core/fbcon.c:1410
  fbcon_switch
    drivers/video/fbdev/core/fbcon.c:2261
  redraw_screen
    drivers/tty/vt/vt.c:994
  fbcon_modechanged
    drivers/video/fbdev/core/fbcon.c:2693
  fbcon_update_vcs
    drivers/video/fbdev/core/fbcon.c:2732

Cc: stable@vger.kernel.org
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: co+b0df61d49532b2ee@bugs.sh
Suggested-by: Helge Deller <deller@gmx.de>
Assisted-by: LLM
Signed-off-by: Weiming Shi <bestswngs@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/video/fbdev/vfb.c |   18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

--- a/drivers/video/fbdev/vfb.c
+++ b/drivers/video/fbdev/vfb.c
@@ -30,7 +30,10 @@
      *  The default can be overridden if the driver is compiled as a module
      */
 
-#define VIDEOMEMSIZE	(1*1024*1024)	/* 1 MB */
+#define MAX_XRES		8192
+#define MAX_YRES		8192
+#define VIDEOMEMSIZE		(1 * 1024 * 1024)	/* 1 MB */
+#define MAX_VIDEOMEMSIZE	(8192 * 8192 * sizeof(u32))
 
 static void *videomemory;
 static u_long videomemorysize = VIDEOMEMSIZE;
@@ -159,6 +162,14 @@ static int vfb_check_var(struct fb_var_s
 	else
 		return -EINVAL;
 
+	if (var->xres_virtual > MAX_XRES ||
+	    var->yres_virtual > MAX_YRES)
+		return -EINVAL;
+
+	if (var->xoffset > MAX_XRES - var->xres ||
+	    var->yoffset > MAX_YRES - var->yres)
+		return -EINVAL;
+
 	if (var->xres_virtual < var->xoffset + var->xres)
 		var->xres_virtual = var->xoffset + var->xres;
 	if (var->yres_virtual < var->yoffset + var->yres)
@@ -434,9 +445,12 @@ static int __init vfb_setup(char *option
 static int vfb_probe(struct platform_device *dev)
 {
 	struct fb_info *info;
-	unsigned int size = PAGE_ALIGN(videomemorysize);
+	unsigned int size;
 	int retval = -ENOMEM;
 
+	videomemorysize = min(videomemorysize, MAX_VIDEOMEMSIZE);
+	size = PAGE_ALIGN(videomemorysize);
+
 	/*
 	 * For real video cards we use ioremap.
 	 */



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 382/555] fuse: fix possible UAF in fuse_direntplus_link()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (380 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 381/555] fbdev: vfb: Validate framebuffer geometry and memory size Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 383/555] fuse: limit name size in listxattr Greg Kroah-Hartman
                   ` (172 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Sashiko, Miklos Szeredi

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

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

From: Miklos Szeredi <mszeredi@redhat.com>

commit 9191c2c1a76a759ac97be72481fdd4f9e920c902 upstream.

In fuse_direntplus_link() a use-after-free occurs on struct fuse_inode when
linking a newly allocated in-lookup dentry during FUSE_READDIRPLUS
processing fails inside d_splice_alias().

When d_in_lookup(dentry) is true, fuse_iget() returns an inode with an
incremented reference count and fi->nlookup, which is then passed to
d_splice_alias(). Inside d_splice_alias_ops(), if the directory inode has
an existing alias and splicing fails with -ELOOP in d_ancestor() or -ESTALE
in __d_unalias(), the function drops the alias reference via dput(new) and
unconditionally consumes the caller's inode reference via iput(inode)
before returning the error pointer.

If the existing alias is concurrently unhashed and dropped, iput(inode)
drops the final inode reference and evicts the inode immediately via
fuse_evict_inode(), sending a FUSE_FORGET request for fi->nlookup and
freeing struct fuse_inode via RCU. Because fuse_direntplus_link()
subsequently checks !IS_ERR(inode) outside an RCU read-side critical
section, it dereferences the freed inode to acquire fi->lock and decrement
fi->nlookup, and its caller parse_dirplusfile() then invokes
fuse_force_forget() on the error return, issuing a duplicate FUSE_FORGET
request to the server.

Fixes: b8bd342d50cb ("fuse: nlookup missing decrement in fuse_direntplus_link")
Cc: stable@vger.kernel.org #v6.6+
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-0a00a32c-3732-46fe-9cdb-3c67a11903cc
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/fuse/readdir.c |   20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

--- a/fs/fuse/readdir.c
+++ b/fs/fuse/readdir.c
@@ -238,9 +238,13 @@ retry:
 		inode = fuse_iget(dir->i_sb, o->nodeid, o->generation,
 				  &o->attr, ATTR_TIMEOUT(o),
 				  attr_version, evict_ctr);
-		if (!inode)
-			inode = ERR_PTR(-ENOMEM);
+		if (!inode) {
+			d_lookup_done(dentry);
+			dput(dentry);
+			return -ENOMEM;
+		}
 
+		ihold(inode); /* d_splice_alias() eats a reference */
 		alias = d_splice_alias(inode, dentry);
 		d_lookup_done(dentry);
 		if (alias) {
@@ -248,15 +252,15 @@ retry:
 			dentry = alias;
 		}
 		if (IS_ERR(dentry)) {
-			if (!IS_ERR(inode)) {
-				struct fuse_inode *fi = get_fuse_inode(inode);
+			struct fuse_inode *fi = get_fuse_inode(inode);
 
-				spin_lock(&fi->lock);
-				fi->nlookup--;
-				spin_unlock(&fi->lock);
-			}
+			spin_lock(&fi->lock);
+			fi->nlookup--;
+			spin_unlock(&fi->lock);
+			iput(inode);
 			return PTR_ERR(dentry);
 		}
+		iput(inode);
 	}
 	if (fc->readdirplus_auto)
 		set_bit(FUSE_I_INIT_RDPLUS, &get_fuse_inode(inode)->state);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 383/555] fuse: limit name size in listxattr
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (381 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 382/555] fuse: fix possible UAF in fuse_direntplus_link() Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 384/555] fuse: skip dcache instantiation for readdirplus names with embedded NUL Greg Kroah-Hartman
                   ` (171 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Miklos Szeredi

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

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

From: Miklos Szeredi <mszeredi@redhat.com>

commit 7f7b822d09c5590defcc61a37ffbd5a3533ed518 upstream.

Limit the size of names to XATTR_NAME_MAX.  Return -EIO to the listxattr()
caller if the server exceeds this limit.

Fixes: 92a8780e1136 ("[PATCH] FUSE - extended attribute operations")
Cc: stable@vger.kernel.org
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/fuse/xattr.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/fs/fuse/xattr.c
+++ b/fs/fuse/xattr.c
@@ -96,7 +96,7 @@ static int fuse_verify_xattr_list(char *
 	while (size) {
 		size_t thislen = strnlen(list, size);
 
-		if (!thislen || thislen == size)
+		if (!thislen || thislen == size || thislen > XATTR_NAME_MAX)
 			return -EIO;
 
 		size -= thislen + 1;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 384/555] fuse: skip dcache instantiation for readdirplus names with embedded NUL
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (382 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 383/555] fuse: limit name size in listxattr Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 385/555] gpio: ljca: Validate the pin index of interrupt events Greg Kroah-Hartman
                   ` (170 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Gwanhyun Lee, Junyoung Jang,
	Amir Goldstein, Miklos Szeredi

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

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

From: Junyoung Jang <graypanda.inzag@gmail.com>

commit ae932b1f5727004f585d603e0cbab7e0725c04cf upstream.

FUSE READDIRPLUS can pass a length-bearing qstr with an embedded NUL to
d_splice_alias().  Unlike verify_dirent_name() in fs/readdir.c, this
path can create a dentry whose d_name.len extends past the NUL.

For such a name, strscpy() in inotify_handle_inode_event() and the
fanotify name-copy helpers stop early.  The kmalloc() and kvmalloc()
event-name buffers retain uninitialized bytes within the recorded name
length, which copy_event_to_user() and copy_fid_info_to_user() can expose.

Some FUSE servers include a terminating NUL in namelen.  Follow
nfs_prime_dcache() in commit 78d04af4995a1 ("NFS: nfs_prime_dcache must
validate the filename") by skipping dcache instantiation without
failing getdents().  Return -EIO from fuse_direntplus_link() so
parse_dirplusfile() sends FUSE_FORGET for the unused lookup reference
and continues readdir.

Fixes: 0b05b18381ee ("fuse: implement NFS-like readdirplus support")
Cc: stable@vger.kernel.org
Co-developed-by: Gwanhyun Lee <gwanhyunlee@gmail.com>
Signed-off-by: Gwanhyun Lee <gwanhyunlee@gmail.com>
Signed-off-by: Junyoung Jang <graypanda.inzag@gmail.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/fuse/readdir.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/fs/fuse/readdir.c
+++ b/fs/fuse/readdir.c
@@ -192,6 +192,8 @@ static int fuse_direntplus_link(struct f
 		return -EIO;
 	if (fuse_invalid_attr(&o->attr))
 		return -EIO;
+	if (memchr(name.name, '\0', name.len))
+		return -EIO;
 
 	fc = get_fuse_conn(dir);
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 385/555] gpio: ljca: Validate the pin index of interrupt events
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (383 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 384/555] fuse: skip dcache instantiation for readdirplus names with embedded NUL Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 386/555] gpio: virtio: bound the line names block by its configured size Greg Kroah-Hartman
                   ` (169 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Alexandre Becholey,
	Bartosz Golaszewski

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

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

From: Alexandre Becholey <alex@becholey.ch>

commit e6e2181c6920ff59ded349a100f80cf85d074601 upstream.

ljca_gpio_event_cb() takes the pin index of every item in a GPIO
interrupt event from the device and passes it to set_bit() on the
reenable_irqs bitmap, which is only LJCA_MAX_GPIO_NUM (64) bits long.
The index is a u8, so a malfunctioning or malicious device can set
bits past the end of the bitmap, in the members that follow it in
struct ljca_gpio_dev: the output_enabled bitmap, the connect_mode
pointer and the irq_lock mutex. connect_mode is later dereferenced and
written to by ljca_gpio_set_config() and ljca_irq_set_type(), so the
device can flip bits of a kernel pointer that is then used for a write.

Until commit 4c4e6ea4a120 ("gpio: ljca: Fix duplicated IRQ mapping")
an index without an IRQ mapping made irq_find_mapping() fail and the
handler returned before set_bit(). Since that change nothing checks
the index.

A device bound to usb-ljca can trigger this by sending one GPIO
interrupt event, once the gpiochip is registered, with an index that
sets a bit of connect_mode which is still clear in a kernel pointer:
175 (bit 47) on arm64, 174 (bit 46) on x86_64. The next GPIO line
request then faults in ljca_gpio_set_config(). With dummy_hcd and
KASAN, on arm64 (torvalds/master 067c5c24cef2):

 Unable to handle kernel paging request at virtual address ffff7000023dfd30
 pc : ljca_gpio_set_config (drivers/gpio/gpio-ljca.c:212)

and on x86_64 (torvalds/master 7e1392a42ea2, nokaslr):

 BUG: unable to handle page fault for address: ffffc8800f5452b8
 RIP: 0010:ljca_gpio_set_config (drivers/gpio/gpio-ljca.c:212)

Ignore event items whose pin index is not below the number of GPIOs of
the chip. That number never exceeds LJCA_MAX_GPIO_NUM, because
usb-ljca rejects larger values at enumeration, so set_bit() stays
inside the bitmap. Valid items in the same event are still handled.

The bug was found by AI agents (Claude Mythos and Claude Opus models). The
analysis and the patch were reviewed by a human, who also reproduced the
bug on x86_64 and aarch64 with current master.

Fixes: 4c4e6ea4a120 ("gpio: ljca: Fix duplicated IRQ mapping")
Cc: stable@vger.kernel.org
Signed-off-by: Alexandre Becholey <alex@becholey.ch>
Link: https://patch.msgid.link/20261113144432.1354180-1-alex@becholey.ch
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpio/gpio-ljca.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

--- a/drivers/gpio/gpio-ljca.c
+++ b/drivers/gpio/gpio-ljca.c
@@ -287,9 +287,14 @@ static void ljca_gpio_event_cb(void *con
 		return;
 
 	for (i = 0; i < packet->num; i++) {
-		generic_handle_domain_irq(ljca_gpio->gc.irq.domain,
-					packet->item[i].index);
-		set_bit(packet->item[i].index, ljca_gpio->reenable_irqs);
+		u8 index = packet->item[i].index;
+
+		/* The pin index comes from the device, do not trust it */
+		if (index >= ljca_gpio->gc.ngpio)
+			continue;
+
+		generic_handle_domain_irq(ljca_gpio->gc.irq.domain, index);
+		set_bit(index, ljca_gpio->reenable_irqs);
 	}
 
 	schedule_work(&ljca_gpio->work);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 386/555] gpio: virtio: bound the line names block by its configured size
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (384 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 385/555] gpio: ljca: Validate the pin index of interrupt events Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 387/555] gpio: virtio: compute the line names size in a size_t Greg Kroah-Hartman
                   ` (168 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Lianjie Wang, Viresh Kumar,
	Bartosz Golaszewski

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

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

From: Lianjie Wang <lian@is.s.u-tokyo.ac.jp>

commit 74aee8e06277df39ec10ed043bae0ed5b7a83864 upstream.

virtio_gpio_get_names() walks the line names that the device returns in
a block of gpio_names_size bytes, which the driver ends with a NUL, and
checks each name only after stepping past it. If the block holds fewer
than ngpio names, the walk reaches the end of the block after the last
name, and the next iteration starts strlen() at the byte after the
allocation. With a block that holds one name for four lines, KASAN
reports:

  BUG: KASAN: slab-out-of-bounds in strlen+0x57/0x70
  Read of size 1 at addr ffff8880026687c0 by task swapper/0/1
  Call Trace:
   strlen+0x57/0x70
   virtio_gpio_probe+0xcb4/0xfc0
   virtio_dev_probe+0xa7a/0xc50
  Allocated by task 1:
   devm_kmalloc+0x6e/0x280
   virtio_gpio_probe+0xc06/0xfc0
  The buggy address is located 0 bytes to the right of
   allocated 64-byte region [ffff888002668780, ffff8880026687c0)

Check that a name starts inside the block before reading it.

Fixes: 3a29355a22c0 ("gpio: Add virtio-gpio driver")
Cc: stable@vger.kernel.org
Signed-off-by: Lianjie Wang <lian@is.s.u-tokyo.ac.jp>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Link: https://patch.msgid.link/20261104195632.1702765-1-lian@is.s.u-tokyo.ac.jp
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpio/gpio-virtio.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--- a/drivers/gpio/gpio-virtio.c
+++ b/drivers/gpio/gpio-virtio.c
@@ -525,13 +525,13 @@ static const char **virtio_gpio_get_name
 	gpio_names[gpio_names_size - 1] = '\0';
 
 	for (i = 0, str = gpio_names; i < ngpio; i++) {
-		names[i] = str;
-		str += strlen(str) + 1; /* zero-length strings are allowed */
-
-		if (str > gpio_names + gpio_names_size) {
+		if (str >= gpio_names + gpio_names_size) {
 			dev_err(dev, "gpio_names block is too short (%d)\n", i);
 			return NULL;
 		}
+
+		names[i] = str;
+		str += strlen(str) + 1; /* zero-length strings are allowed */
 	}
 
 	return names;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 387/555] gpio: virtio: compute the line names size in a size_t
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (385 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 386/555] gpio: virtio: bound the line names block by its configured size Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 388/555] ieee802154: require CAP_NET_ADMIN for SIOCSIFADDR Greg Kroah-Hartman
                   ` (167 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Lianjie Wang, Viresh Kumar,
	Bartosz Golaszewski

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

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

From: Lianjie Wang <lian@is.s.u-tokyo.ac.jp>

commit 9e3032dc4d92e6214ae687b4c474de9270ce74a2 upstream.

virtio_gpio_get_names() computes the size of the GET_LINE_NAMES response
as sizeof(*res) + gpio_names_size in an int, where gpio_names_size is a
u32 from the config space. A gpio_names_size of 0xffffffff makes the
size 0, devm_kzalloc() returns ZERO_SIZE_PTR, and reading the status
byte of the response through it oopses:

  Oops: general protection fault, probably for non-canonical address 0xdffffc0000000002: 0000 [#1] SMP KASAN PTI
  KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
  RIP: 0010:_virtio_gpio_req+0x2b8/0x550
  Call Trace:
   virtio_gpio_probe+0xc2a/0xfc0
   virtio_dev_probe+0xa7a/0xc50

Compute the size with struct_size() into a size_t.

Fixes: 3a29355a22c0 ("gpio: Add virtio-gpio driver")
Cc: stable@vger.kernel.org
Signed-off-by: Lianjie Wang <lian@is.s.u-tokyo.ac.jp>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Link: https://patch.msgid.link/20261104195632.1702765-2-lian@is.s.u-tokyo.ac.jp
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpio/gpio-virtio.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- a/drivers/gpio/gpio-virtio.c
+++ b/drivers/gpio/gpio-virtio.c
@@ -499,12 +499,13 @@ static const char **virtio_gpio_get_name
 	struct device *dev = &vgpio->vdev->dev;
 	u8 *gpio_names, *str;
 	const char **names;
-	int i, ret, len;
+	size_t len;
+	int i, ret;
 
 	if (!gpio_names_size)
 		return NULL;
 
-	len = sizeof(*res) + gpio_names_size;
+	len = struct_size(res, value, gpio_names_size);
 	res = devm_kzalloc(dev, len, GFP_KERNEL);
 	if (!res)
 		return NULL;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 388/555] ieee802154: require CAP_NET_ADMIN for SIOCSIFADDR
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (386 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 387/555] gpio: virtio: compute the line names size in a size_t Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 389/555] iavf: fix ASQ command buffer leak on init failure Greg Kroah-Hartman
                   ` (166 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sung Byeongchan, Miquel Raynal,
	Jakub Kicinski

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

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

From: Sung Byeongchan <tjdqudcks0424@naver.com>

commit a0abc1e4c9d5b8b846abe4293b7bca578736da8a upstream.

PF_IEEE802154 DGRAM sockets are available to ordinary init-net processes.
Their family-specific SIOCSIFADDR path calls the netdev ioctl directly and
does not pass through the generic network-device setter capability check.
An unprivileged process can therefore change the PAN ID and short address
of a separately administrator-owned down WPAN interface.

In a local fakelb fixture, uid 1000 changed both identifiers and the values
remained active through a later administrator interface open in three of
three fresh KASAN boots.

Require CAP_NET_ADMIN in the socket network namespace before processing
SIOCSIFADDR. Keep SIOCGIFADDR and all existing state and value checks
unchanged.

The fixed kernel rejected the same unprivileged request with -EPERM and
preserved the administrator identity in three of three matched boots.
Administrator SET, running-device, invalid-value, wrong-device, cleanup,
later-open and recovery controls passed in all baseline and fixed runs.

The demonstrated impact is local cross-principal WPAN identity and policy
modification after privileged device setup. Memory corruption, disclosure,
RCE and LPE were not demonstrated.

Fixes: 9ec767160357 ("net: add IEEE 802.15.4 socket family implementation")
Cc: stable@vger.kernel.org
Signed-off-by: Sung Byeongchan <tjdqudcks0424@naver.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://patch.msgid.link/20261107093601.619363-1-tjdqudcks0424@naver.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/ieee802154/socket.c |    4 ++++
 1 file changed, 4 insertions(+)

--- a/net/ieee802154/socket.c
+++ b/net/ieee802154/socket.c
@@ -128,6 +128,10 @@ static int ieee802154_dev_ioctl(struct s
 	int ret = -ENOIOCTLCMD;
 	struct net_device *dev;
 
+	if (cmd == SIOCSIFADDR &&
+	    !ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN))
+		return -EPERM;
+
 	if (get_user_ifreq(&ifr, NULL, arg))
 		return -EFAULT;
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 389/555] iavf: fix ASQ command buffer leak on init failure
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (387 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 388/555] ieee802154: require CAP_NET_ADMIN for SIOCSIFADDR Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 390/555] hwmon: (ads7871) Add error handle from spi_setup() Greg Kroah-Hartman
                   ` (165 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Xuanqiang Luo, Jedrzej Jagielski,
	Aleksandr Loktionov, Tony Nguyen, Jakub Kicinski

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

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

From: Xuanqiang Luo <luoxuanqiang@kylinos.cn>

commit 2a1f106379a90ce7ac63f96a57c241a4cf20a983 upstream.

iavf_alloc_adminq_asq_ring() allocates cmd_buf before the remaining ASQ
resources. If iavf_alloc_asq_bufs() or iavf_config_asq_regs() fails, the
unwind path elides cmd_buf while freeing the other allocations.

The ASQ count is not set until initialization succeeds, so the shutdown
path cannot reclaim the buffer. Free cmd_buf in the common unwind path.

Fixes: d358aa9a7a2d ("i40evf: init code and hardware support")
Cc: stable@vger.kernel.org
Signed-off-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
Reviewed-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Link: https://patch.msgid.link/20261113004602.129864-6-anthony.l.nguyen@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/ethernet/intel/iavf/iavf_adminq.c |    1 +
 1 file changed, 1 insertion(+)

--- a/drivers/net/ethernet/intel/iavf/iavf_adminq.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_adminq.c
@@ -60,6 +60,7 @@ static enum iavf_status iavf_alloc_admin
  **/
 static void iavf_free_adminq_asq(struct iavf_hw *hw)
 {
+	iavf_free_virt_mem(hw, &hw->aq.asq.cmd_buf);
 	iavf_free_dma_mem(hw, &hw->aq.asq.desc_buf);
 }
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 390/555] hwmon: (ads7871) Add error handle from spi_setup()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (388 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 389/555] iavf: fix ASQ command buffer leak on init failure Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 391/555] hwmon: (dell-smm) Reject a fan_max that the BIOS cannot take Greg Kroah-Hartman
                   ` (164 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Vítor Hugo Silva, Guenter Roeck

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

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

From: Vítor Hugo Silva <vitorhg20080@gmail.com>

commit 449cdc5e29c63aa66b41ce8c2783f6b0d84c62b0 upstream.

The ads7871 probe() ignores the spi_setup() error return value
and it attempts to write to registers even if spi_setup() fails.

Return the setup error before accessing any registers.

AI was used for peer-review the patch.

Fixes: e0c70b8078629 ("hwmon: add TI ads7871 a/d converter driver")
Cc: stable@vger.kernel.org
Signed-off-by: Vítor Hugo Silva <vitorhg20080@gmail.com>
Link: https://patch.msgid.link/20261118092928.163553-1-vitorhg20080@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/hwmon/ads7871.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/drivers/hwmon/ads7871.c
+++ b/drivers/hwmon/ads7871.c
@@ -164,7 +164,9 @@ static int ads7871_probe(struct spi_devi
 	/* Configure the SPI bus */
 	spi->mode = (SPI_MODE_0);
 	spi->bits_per_word = 8;
-	spi_setup(spi);
+	ret = spi_setup(spi);
+	if (ret)
+		return ret;
 
 	ads7871_write_reg8(spi, REG_SER_CONTROL, 0);
 	ads7871_write_reg8(spi, REG_AD_CONTROL, 0);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 391/555] hwmon: (dell-smm) Reject a fan_max that the BIOS cannot take
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (389 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 390/555] hwmon: (ads7871) Add error handle from spi_setup() Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 392/555] hwmon: (dell-smm) Reject out-of-range pwm values Greg Kroah-Hartman
                   ` (163 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Rosen Penev, Guenter Roeck

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

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

From: Rosen Penev <rosenp@gmail.com>

commit 69624d7d821ec7d3f9801e86acf555a8edc82f99 upstream.

The fan_max module parameter is used without any range check, unlike
fan_mult. dell_smm_init_hwmon() allocates the nominal speed table with

	devm_kmalloc_array(dev, data->i8k_fan_max + 1, ...)

and fan_max=4294967295 wraps the count to 0. devm_kmalloc() then
returns ZERO_SIZE_PTR, which the first successful nominal speed call
writes through.

Values above 255 are also meaningless: the fan state is passed to the
BIOS as fan | (speed << 8), so the higher bits end up in other parts of
the request. Large values that do not wrap still cost one SMM call per
state and fan while probing.

Fail probing if the maximum fan state does not fit in a byte, like the
existing check for fan_mult.

Fixes: 81474fc2fae9 ("i8k: Add support for configurable maximum fan speed value")
cc: stable@vger.kernel.org
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://patch.msgid.link/6d3b86acf6713e9286e60ecf788582e840946238.1794633179.git.rosenp@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/hwmon/dell-smm-hwmon.c |    6 ++++++
 1 file changed, 6 insertions(+)

--- a/drivers/hwmon/dell-smm-hwmon.c
+++ b/drivers/hwmon/dell-smm-hwmon.c
@@ -1213,6 +1213,12 @@ static int dell_smm_init_data(struct dev
 		return -EINVAL;
 	}
 	data->i8k_fan_max = fan_max ? : I8K_FAN_HIGH;
+	/* The BIOS takes the fan state in a single byte */
+	if (data->i8k_fan_max > U8_MAX) {
+		dev_err(dev, "maximum fan state %u is too large (max %u)\n",
+			data->i8k_fan_max, U8_MAX);
+		return -EINVAL;
+	}
 	data->i8k_pwm_mult = DIV_ROUND_UP(255, data->i8k_fan_max);
 
 	return 0;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 392/555] hwmon: (dell-smm) Reject out-of-range pwm values
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (390 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 391/555] hwmon: (dell-smm) Reject a fan_max that the BIOS cannot take Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 393/555] hwmon: (nct6775) Fix incorrect struct cast in beep callbacks Greg Kroah-Hartman
                   ` (162 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Rosen Penev, Guenter Roeck

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

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

From: Rosen Penev <rosenp@gmail.com>

commit 7494b0c50c9fcd9f9f5235777bb506dd45676557 upstream.

dell_smm_write() scales the value written to pwmN with

	DIV_ROUND_CLOSEST(val, data->i8k_pwm_mult)

before clamping the result to the valid fan states. The rounding adds
i8k_pwm_mult / 2 to val first, which overflows for values near
LONG_MAX and wraps to a large negative number. That is then clamped to
0, so writing a huge value turns the fan off instead of running it at
the highest speed. With the default fan_max of 2, writing any value
from LONG_MAX - 63 up to LONG_MAX selects fan state 0.

The pwm range is well defined, so return -EINVAL for values outside
0 to 255, as is the convention for pwm attributes.

Fixes: e7f5f275c62a ("i8k: Implement hwmon based fan speed control")
Cc: stable@vger.kernel.org
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://patch.msgid.link/20261118040417.19049-1-rosenp@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/hwmon/dell-smm-hwmon.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/hwmon/dell-smm-hwmon.c
+++ b/drivers/hwmon/dell-smm-hwmon.c
@@ -1011,6 +1011,9 @@ static int dell_smm_write(struct device
 	case hwmon_pwm:
 		switch (attr) {
 		case hwmon_pwm_input:
+			if (val < 0 || val > 255)
+				return -EINVAL;
+
 			pwm = clamp_val(DIV_ROUND_CLOSEST(val, data->i8k_pwm_mult), 0,
 					data->i8k_fan_max);
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 393/555] hwmon: (nct6775) Fix incorrect struct cast in beep callbacks
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (391 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 392/555] hwmon: (dell-smm) Reject out-of-range pwm values Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 394/555] hwmon: (nct6775) Fix swapped temperature tolerance register writes Greg Kroah-Hartman
                   ` (161 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Ziheng Wei, Guenter Roeck

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

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

From: Ziheng Wei <zihengw03@163.com>

commit 07571b42cf41d0e42fb890713340a8f0a3c03d56 upstream.

On big-endian architectures, writing the in[1-*]_beep, fan[1-*]_beep
and temp[1-*]_beep sysfs attributes in the nct6775 hardware monitoring
driver always changes channel 0 due to an incorrect struct downcast in
the beep store callbacks.

The driver defines these sysfs attributes using SENSOR_TEMPLATE(),
which initializes them as struct sensor_device_attribute (where the
index is a 32-bit int). However, the sysfs store callbacks
nct6775_store_beep() and store_temp_beep() incorrectly downcast the
attribute to a struct sensor_device_attribute_2 (where the index is
an 8-bit u8).

Because both structs start with struct device_attribute,
container_of() resolves to the same base address. On big-endian
architectures, reading the 8-bit index field from the memory layout
of a 32-bit int fetches the most significant byte (which is 0),
rather than the intended channel number.

This type mismatch causes all beep writes to change the beep setting
of channel 0, regardless of which channel the user targeted.

Fix the type casts in the two store callbacks.

Not runtime-tested: the only big-endian machine available to me (s390x
under QEMU) cannot build the platform driver (no HAS_IOPORT).

Fixes: 30846993047b ("hwmon: (nct6775) Add support for beep attributes")
Cc: stable@vger.kernel.org
Signed-off-by: Ziheng Wei <zihengw03@163.com>
Link: https://patch.msgid.link/20261115080203.910033-2-zihengw03@163.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/hwmon/nct6775-core.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/hwmon/nct6775-core.c
+++ b/drivers/hwmon/nct6775-core.c
@@ -1819,7 +1819,7 @@ EXPORT_SYMBOL_GPL(nct6775_show_beep);
 ssize_t
 nct6775_store_beep(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
-	struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
+	struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr);
 	struct nct6775_data *data = dev_get_drvdata(dev);
 	int nr = data->BEEP_BITS[sattr->index];
 	int regindex = nr >> 3;
@@ -1873,7 +1873,7 @@ static ssize_t
 store_temp_beep(struct device *dev, struct device_attribute *attr,
 		const char *buf, size_t count)
 {
-	struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
+	struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr);
 	struct nct6775_data *data = dev_get_drvdata(dev);
 	int nr, bit, regindex;
 	unsigned long val;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 394/555] hwmon: (nct6775) Fix swapped temperature tolerance register writes
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (392 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 393/555] hwmon: (nct6775) Fix incorrect struct cast in beep callbacks Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 395/555] hwmon: (nct6775) Fix tolerance bitmask when reading REG_FAN_MODE Greg Kroah-Hartman
                   ` (160 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Sashiko, Anton Lundin, Guenter Roeck

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

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

From: Guenter Roeck <linux@roeck-us.net>

commit 3cc60eb1b9aa07da81593f8f027efefb67185144 upstream.

sensor_dev_template_pwm_temp_tolerance uses index 0 (backed by
REG_FAN_MODE via pwm_update_registers()) while
sensor_dev_template_pwm_crit_temp_tolerance uses index 1 (backed by
REG_CRITICAL_TEMP_TOLERANCE). However, store_temp_tolerance() checks
if (index) with inverted branches.

As a result, writing to pwm*_temp_tolerance writes the new tolerance to
REG_CRITICAL_TEMP_TOLERANCE instead of REG_FAN_MODE, while writing to
pwm*_crit_temp_tolerance updates REG_FAN_MODE with temp_tolerance[0] and
leaves REG_CRITICAL_TEMP_TOLERANCE unchanged.

Invert the index check in store_temp_tolerance() so index 0 updates fan
mode registers via pwm_update_registers() and index 1 writes to
REG_CRITICAL_TEMP_TOLERANCE.

Fixes: cdcaeceb74ff ("hwmon: (nct6775) Add support for automatic fan control")
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Cc: Anton Lundin <glance@ac2.se>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/hwmon/nct6775-core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/hwmon/nct6775-core.c
+++ b/drivers/hwmon/nct6775-core.c
@@ -2958,7 +2958,7 @@ store_temp_tolerance(struct device *dev,
 
 	mutex_lock(&data->update_lock);
 	data->temp_tolerance[index][nr] = val;
-	if (index)
+	if (!index)
 		err = pwm_update_registers(data, nr);
 	else
 		err = nct6775_write_value(data, data->REG_CRITICAL_TEMP_TOLERANCE[nr], val);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 395/555] hwmon: (nct6775) Fix tolerance bitmask when reading REG_FAN_MODE
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (393 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 394/555] hwmon: (nct6775) Fix swapped temperature tolerance register writes Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 396/555] hwmon: (sht3x) Fix overflow when writing alert limits Greg Kroah-Hartman
                   ` (159 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Sashiko, Anton Lundin, Guenter Roeck

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

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

From: Guenter Roeck <linux@roeck-us.net>

commit 39cd14ca605d1aa55a0ad26767014a88b5c39f20 upstream.

On NCT6775, bits 0..3 of REG_FAN_MODE hold the temperature or fan speed
tolerance (tolerance_mask is 0x0f), whereas on NCT5525, NCT6106,
NCT6116, NCT6126, and NCT6776+, only bits 0..2 hold the temperature
tolerance or low 3 bits of speed tolerance (tolerance_mask is 0x07).
However, nct6775_update_pwm() masks fanmodecfg with a hardcoded 0x0f.

When bit 3 of REG_FAN_MODE is set on chips where tolerance_mask is 0x07,
nct6775_update_pwm() includes bit 3 in temp_tolerance[0] and
target_speed_tolerance, corrupting reported tolerance values and causing
pwm_update_registers() to OR bit 3 back into REG_FAN_MODE.

Mask fanmodecfg with data->tolerance_mask instead of 0x0f in
nct6775_update_pwm().

Fixes: cdcaeceb74ff ("hwmon: (nct6775) Add support for automatic fan control")
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Cc: Anton Lundin <glance@ac2.se>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/hwmon/nct6775-core.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/hwmon/nct6775-core.c
+++ b/drivers/hwmon/nct6775-core.c
@@ -1418,10 +1418,10 @@ static int nct6775_update_pwm(struct dev
 
 		if (!data->temp_tolerance[0][i] ||
 		    data->pwm_enable[i] != speed_cruise)
-			data->temp_tolerance[0][i] = fanmodecfg & 0x0f;
+			data->temp_tolerance[0][i] = fanmodecfg & data->tolerance_mask;
 		if (!data->target_speed_tolerance[i] ||
 		    data->pwm_enable[i] == speed_cruise) {
-			u8 t = fanmodecfg & 0x0f;
+			u8 t = fanmodecfg & data->tolerance_mask;
 
 			if (data->REG_TOLERANCE_H) {
 				err = nct6775_read_value(data, data->REG_TOLERANCE_H[i], &reg);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 396/555] hwmon: (sht3x) Fix overflow when writing alert limits
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (394 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 395/555] hwmon: (nct6775) Fix tolerance bitmask when reading REG_FAN_MODE Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 397/555] hwmon: (w83791d) Fix incorrect struct cast in show_temp1() and store_temp1() Greg Kroah-Hartman
                   ` (158 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Sashiko, Wayne Ho, Guenter Roeck

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

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

From: Wayne Ho <wayneho219@gmail.com>

commit e6872defbb2eb1dc61b3ea168ca13e1362efbd86 upstream.

limit_write() encodes the limits with 32-bit arithmetic, which overflows
for the largest accepted values:

  (130000 + 45000) * 24543 = 4295025000 > U32_MAX
  100000 * 42950           = 4295000000 > U32_MAX

Writing 130000 to temp1_max therefore programs -45 degrees C, and
writing 100000 to humidity1_max programs 0 %RH, so a limit set to its
maximum makes the alert fire instead of never firing. Reading the
attributes back returns the cached values, so this is not visible from
sysfs.

Use 64-bit arithmetic and clamp each result to its field width. Even
with 64-bit arithmetic, 130000 encodes to 0x200, which overflows the
9-bit temperature field, and 100000 encodes to 0x10000, which is still 0
after masking.

Prepared with the help of an AI coding assistant (Claude); I reproduced
the bug and tested the fix on hardware.

Fixes: 7c84f7f80d6f ("hwmon: add support for Sensirion SHT3x sensors")
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/linux-hwmon/20260725222229.EA69B1F000E9@smtp.kernel.org/
Signed-off-by: Wayne Ho <wayneho219@gmail.com>
Link: https://patch.msgid.link/20261113054857.97048-1-wayneho219@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/hwmon/sht3x.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/hwmon/sht3x.c
+++ b/drivers/hwmon/sht3x.c
@@ -390,8 +390,8 @@ static size_t limit_write(struct device
 	 * adapted for fixed point arithmetic and packed the same as
 	 * in limit_read()
 	 */
-	raw = ((u32)(temperature + 45000) * 24543) >> (16 + 7);
-	raw |= ((humidity * 42950) >> 16) & 0xfe00;
+	raw = min(((u64)(temperature + 45000) * 24543) >> (16 + 7), 0x1ff);
+	raw |= min(((u64)humidity * 42950) >> 16, 0xffff) & 0xfe00;
 
 	put_unaligned_be16(raw, position);
 	position += SHT3X_WORD_LEN;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 397/555] hwmon: (w83791d) Fix incorrect struct cast in show_temp1() and store_temp1()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (395 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 396/555] hwmon: (sht3x) Fix overflow when writing alert limits Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 398/555] hwmon: (w83792d) " Greg Kroah-Hartman
                   ` (157 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Ziheng Wei, Guenter Roeck

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

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

From: Ziheng Wei <zihengw03@163.com>

commit fb47eb0528d275362b01423ceb956e3ce1f9d715 upstream.

On big-endian architectures, accessing the temp1_max and temp1_max_hyst
sysfs attributes in the w83791d hardware monitoring driver uses a huge
out-of-bounds index, because show_temp1() and store_temp1() downcast the
attribute to the wrong struct.

The driver defines the temp1_* attributes with SENSOR_ATTR_2(), which
initializes them as struct sensor_device_attribute_2 (where the index is
an 8-bit u8). The temp1_input attribute has index 0, temp1_max has
index 1 and temp1_max_hyst has index 2. However, show_temp1() and
store_temp1() downcast the attribute to struct sensor_device_attribute
(where the index is a 32-bit int) and use it to index data->temp1[].

Because both structs start with struct device_attribute, container_of()
resolves to the same base address, but the field widths differ. On
big-endian architectures, reading the 32-bit int from the memory layout
of the two u8 fields yields index << 24: 0x01000000 for temp1_max and
0x02000000 for temp1_max_hyst, instead of 1 and 2. data->temp1[] has
only 3 elements, so the access runs off the end of the array by up to
32 MiB.

Fix the type casts in show_temp1() and store_temp1().

Confirmed on a big-endian s390x QEMU guest with the driver bound to an
emulated chip: temp1_max and temp1_max_hyst read 0 instead of the
register values. Not tested on real hardware.

Fixes: 9873964d6eb2 ("[PATCH] HWMON: w83791d: New hardware monitoring driver for the Winbond W83791D")
Cc: stable@vger.kernel.org
Signed-off-by: Ziheng Wei <zihengw03@163.com>
Link: https://patch.msgid.link/20261115080203.910033-3-zihengw03@163.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/hwmon/w83791d.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/hwmon/w83791d.c
+++ b/drivers/hwmon/w83791d.c
@@ -924,7 +924,7 @@ static struct sensor_device_attribute sd
 static ssize_t show_temp1(struct device *dev, struct device_attribute *devattr,
 				char *buf)
 {
-	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+	struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr);
 	struct w83791d_data *data = w83791d_update_device(dev);
 	return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->temp1[attr->index]));
 }
@@ -932,7 +932,7 @@ static ssize_t show_temp1(struct device
 static ssize_t store_temp1(struct device *dev, struct device_attribute *devattr,
 				const char *buf, size_t count)
 {
-	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+	struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr);
 	struct i2c_client *client = to_i2c_client(dev);
 	struct w83791d_data *data = i2c_get_clientdata(client);
 	int nr = attr->index;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 398/555] hwmon: (w83792d) Fix incorrect struct cast in show_temp1() and store_temp1()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (396 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 397/555] hwmon: (w83791d) Fix incorrect struct cast in show_temp1() and store_temp1() Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 399/555] Input: cyapa - fix runtime PM leak in cyapa_update_rt_suspend_scanrate() Greg Kroah-Hartman
                   ` (156 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Ziheng Wei, Guenter Roeck

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

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

From: Ziheng Wei <zihengw03@163.com>

commit d4f7d626cc1a966dca930a5ba07e8c4739adceb0 upstream.

On big-endian architectures, accessing the temp1_max and temp1_max_hyst
sysfs attributes in the w83792d hardware monitoring driver uses a huge
out-of-bounds index, because show_temp1() and store_temp1() downcast the
attribute to the wrong struct.

The driver defines the temp1_* attributes with SENSOR_DEVICE_ATTR_2(),
which initializes them as struct sensor_device_attribute_2 (where the
index is an 8-bit u8). The temp1_input attribute has index 0, temp1_max
has index 1 and temp1_max_hyst has index 2. However, show_temp1() and
store_temp1() downcast the attribute to struct sensor_device_attribute
(where the index is a 32-bit int) and use it to index data->temp1[].

Because both structs start with struct device_attribute, container_of()
resolves to the same base address, but the field widths differ. On
big-endian architectures, reading the 32-bit int from the memory layout
of the two u8 fields yields index << 24: 0x01000000 for temp1_max and
0x02000000 for temp1_max_hyst, instead of 1 and 2. data->temp1[] has
only 3 elements, so the access runs off the end of the array by up to
32 MiB.

Fix the type casts in show_temp1() and store_temp1().

Confirmed on a big-endian s390x QEMU guest with the driver bound to an
emulated chip: temp1_max and temp1_max_hyst read 0 instead of the
register values. Not tested on real hardware.

Fixes: 1f8dae31fe8d ("[PATCH] hwmon: w83792d use arrays of attributes")
Cc: stable@vger.kernel.org
Signed-off-by: Ziheng Wei <zihengw03@163.com>
Link: https://patch.msgid.link/20261115080203.910033-4-zihengw03@163.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/hwmon/w83792d.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/hwmon/w83792d.c
+++ b/drivers/hwmon/w83792d.c
@@ -487,7 +487,7 @@ store_fan_div(struct device *dev, struct
 static ssize_t show_temp1(struct device *dev, struct device_attribute *attr,
 				char *buf)
 {
-	struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+	struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr);
 	int nr = sensor_attr->index;
 	struct w83792d_data *data = w83792d_update_device(dev);
 	return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->temp1[nr]));
@@ -496,7 +496,7 @@ static ssize_t show_temp1(struct device
 static ssize_t store_temp1(struct device *dev, struct device_attribute *attr,
 				const char *buf, size_t count)
 {
-	struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+	struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr);
 	int nr = sensor_attr->index;
 	struct i2c_client *client = to_i2c_client(dev);
 	struct w83792d_data *data = i2c_get_clientdata(client);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 399/555] Input: cyapa - fix runtime PM leak in cyapa_update_rt_suspend_scanrate()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (397 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 398/555] hwmon: (w83792d) " Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 400/555] Input: da7280 - do not advertise FF_GAIN Greg Kroah-Hartman
                   ` (155 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Wentao Liang, Dmitry Torokhov

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

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

From: Wentao Liang <vulab@iscas.ac.cn>

commit f5f8cc539f8b2bd5324c03dfce8cca57284653e6 upstream.

pm_runtime_get_sync() unconditionally increments the runtime PM usage
counter. If mutex_lock_interruptible() is interrupted, the function
returns without dropping that reference, so the usage count stays
elevated for as long as the driver is bound and the device can no longer
be autosuspended. Drop the reference on the error path.

Use pm_runtime_put_autosuspend() rather than the synchronous variant
there: nothing has been done to the device on this path, so there is
nothing to wait for, and with the 2 s autosuspend delay the driver
configures the put only arms the autosuspend timer instead of suspending
the device.

Fixes: 672865080a8f ("Input: cyapa - add runtime power management support")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Link: https://patch.msgid.link/1794120347.2701234.vulab@iscas.ac.cn
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/input/mouse/cyapa.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/drivers/input/mouse/cyapa.c
+++ b/drivers/input/mouse/cyapa.c
@@ -904,8 +904,10 @@ static ssize_t cyapa_update_rt_suspend_s
 	pm_runtime_get_sync(dev);
 
 	error = mutex_lock_interruptible(&cyapa->state_sync_lock);
-	if (error)
+	if (error) {
+		pm_runtime_put_autosuspend(dev);
 		return error;
+	}
 
 	cyapa->runtime_suspend_sleep_time = min_t(u16, time, 1000);
 	cyapa->runtime_suspend_power_mode =



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 400/555] Input: da7280 - do not advertise FF_GAIN
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (398 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 399/555] Input: cyapa - fix runtime PM leak in cyapa_update_rt_suspend_scanrate() Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 401/555] Input: goodix - reject a bak_ref length that cannot hold the checksum Greg Kroah-Hartman
                   ` (154 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Ivan Verbovoy, Dmitry Torokhov

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ivan Verbovoy <ivanverbovoy@gmail.com>

commit c1f4db7e869ce7dafd1811a75b392740985e1199 upstream.

The driver sets FF_GAIN in the device's force feedback capabilities but
provides no set_gain() callback. input_ff_event() checks the capability
bit, not the callback, before calling ff->set_gain(), so an EV_FF/FF_GAIN
event written to the event node by any process with write access to it
calls through a NULL pointer.

The driver has no global gain to set: a constant effect carries its own
level, and a periodic effect plays a pattern from the device's waveform
memory. Drop FF_GAIN from the capabilities, so that input_ff_event()
ignores such an event.

Fixes: cd3f609823a5 ("Input: new da7280 haptic driver")
Cc: stable@vger.kernel.org
Signed-off-by: Ivan Verbovoy <ivanverbovoy@gmail.com>
Link: https://patch.msgid.link/20261109-da7280-fixes-v1-1-09cc3650261c@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/input/misc/da7280.c |    1 -
 1 file changed, 1 deletion(-)

--- a/drivers/input/misc/da7280.c
+++ b/drivers/input/misc/da7280.c
@@ -1227,7 +1227,6 @@ static int da7280_probe(struct i2c_clien
 	input_set_capability(haptics->input_dev, EV_FF, FF_PERIODIC);
 	input_set_capability(haptics->input_dev, EV_FF, FF_CUSTOM);
 	input_set_capability(haptics->input_dev, EV_FF, FF_CONSTANT);
-	input_set_capability(haptics->input_dev, EV_FF, FF_GAIN);
 
 	error = input_ff_create(haptics->input_dev,
 				DA7280_FF_EFFECT_COUNT_MAX);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 401/555] Input: goodix - reject a bak_ref length that cannot hold the checksum
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (399 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 400/555] Input: da7280 - do not advertise FF_GAIN Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 402/555] Input: trackpoint - add new TP JYT_NDT device variant id 7 Greg Kroah-Hartman
                   ` (153 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Liu Chao, Dmitry Torokhov

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Liu Chao <liuc63@xiaopeng.com>

commit b3249e446d47c65dc09611705ad4d0a7587405ac upstream.

driver_num and sensor_num are taken from the touchscreen config.  A
config with driver_num 1 and sensor_num 0 yields a bak_ref length of
0, for which devm_kzalloc() returns ZERO_SIZE_PTR.  That pointer
passes the !ts->bak_ref check and the subsequent
ts->bak_ref[ts->bak_ref_len - 1] = 1 writes before the allocation.

Reject a length that leaves no room for the trailing checksum before
allocating, and skip saving a bak_ref that was never allocated.
Without the second check a rejected length leaves bak_ref NULL while
bak_ref_len still holds the bogus value, and goodix_save_bak_ref()
then writes through the same index on suspend.

Fixes: 09182ed20c04 ("Input: goodix - add support for controllers without flash")
Cc: stable@vger.kernel.org
Signed-off-by: Liu Chao <liuc63@xiaopeng.com>
Link: https://patch.msgid.link/20261106075129.3106093-1-liuc63@xiaopeng.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/input/touchscreen/goodix_fwupload.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/drivers/input/touchscreen/goodix_fwupload.c
+++ b/drivers/input/touchscreen/goodix_fwupload.c
@@ -280,6 +280,8 @@ static int goodix_prepare_bak_ref(struct
 		driver_num, sensor_num, have_key);
 
 	ts->bak_ref_len = (driver_num * (sensor_num - 2) + 2) * 2;
+	if (ts->bak_ref_len < 2)
+		return -EINVAL;
 
 	ts->bak_ref = devm_kzalloc(&ts->client->dev,
 				   ts->bak_ref_len, GFP_KERNEL);
@@ -408,7 +410,7 @@ void goodix_save_bak_ref(struct goodix_t
 	int error;
 	u8 val;
 
-	if (!ts->firmware_name)
+	if (!ts->firmware_name || !ts->bak_ref)
 		return;
 
 	error = goodix_i2c_read(ts->client, GOODIX_REG_STATUS, &val, 1);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 402/555] Input: trackpoint - add new TP JYT_NDT device variant id 7
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (400 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 401/555] Input: goodix - reject a bak_ref length that cannot hold the checksum Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 403/555] Input: xpad - add support to Hori Real Arcade Pro 4 Greg Kroah-Hartman
                   ` (152 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Yuan Yao, Dmitry Torokhov

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Yuan Yao <yaoyuan0329os@gmail.com>

commit ce8010f11f3ea62f8675e9bc921ee485aef82019 upstream.

The new trackpoint variant id 7 is found on Lenovo Thinkpad X14
Gen1 laptop(Product Name: 21XMA006CD), it belongs to JYT_NDT with
confirmation from Vishnu Sankar in Lenovo. now it's incorrectly
probed as Generic or Logitech PS/2 mouse.

Add the variant id 7 to match the TP_READ_ID command return
value, probe the device as trackpoint correctly.

BEFORE:
input: PS/2 Generic Mouse as /devices/platform/i8042/serio1/input/input63

AFTER:
psmouse serio1: trackpoint: JYT_NDT TrackPoint firmware: 0xa1, buttons: 3/3
input: TPPS/2 JYT_NDT TrackPoint as /devices/platform/i8042/serio1/input/input8

Signed-off-by: Yuan Yao <yaoyuan@linux.alibaba.com>
Link: https://patch.msgid.link/20261113112202.10304-2-yaoyuan@linux.alibaba.com
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/input/mouse/trackpoint.c |    2 ++
 drivers/input/mouse/trackpoint.h |    1 +
 2 files changed, 3 insertions(+)

--- a/drivers/input/mouse/trackpoint.c
+++ b/drivers/input/mouse/trackpoint.c
@@ -23,6 +23,7 @@ static const char * const trackpoint_var
 	[TP_VARIANT_NXP]		= "NXP",
 	[TP_VARIANT_JYT_SYNAPTICS]	= "JYT_Synaptics",
 	[TP_VARIANT_SYNAPTICS]		= "Synaptics",
+	[TP_VARIANT_JYT_NDT]		= "JYT_NDT"
 };
 
 /*
@@ -283,6 +284,7 @@ static int trackpoint_start_protocol(str
 	case TP_VARIANT_ELAN:
 	case TP_VARIANT_NXP:
 	case TP_VARIANT_JYT_SYNAPTICS:
+	case TP_VARIANT_JYT_NDT:
 	case TP_VARIANT_SYNAPTICS:
 		if (variant_id)
 			*variant_id = param[0];
--- a/drivers/input/mouse/trackpoint.h
+++ b/drivers/input/mouse/trackpoint.h
@@ -30,6 +30,7 @@
 #define TP_VARIANT_NXP			0x04
 #define TP_VARIANT_JYT_SYNAPTICS	0x05
 #define TP_VARIANT_SYNAPTICS		0x06
+#define TP_VARIANT_JYT_NDT		0x07
 
 /*
  * Commands



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 403/555] Input: xpad - add support to Hori Real Arcade Pro 4
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (401 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 402/555] Input: trackpoint - add new TP JYT_NDT device variant id 7 Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 404/555] ip6mr: prevent info-leak in ip6mr_cache_report() Greg Kroah-Hartman
                   ` (151 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Juan Parrado, Dmitry Torokhov

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Juan Parrado <jparrado.1817@gmail.com>

commit 9cfed185db8f1c12bf2629fb37c77d85bf93b193 upstream.

The HORI Real Arcade Pro 4 in PC mode is currently recognized by xpad.c as
a 'Generic X-Box pad' and works out of the box. However, this generic name
does not match the actual device name, making it difficult for users to
distinguish this controller when multiple devices are connected.

Tested on physical hardware. The proposed change works perfectly as is.
The MAP_TRIGGERS_TO_BUTTONS parameter does not work here. Other arcade
sticks use an identical configuration, such as the 'Street Fighter IV
FightPad' and the 'Hori Real Arcade Pro.EX Premium VLX'.

Signed-off-by: Juan Parrado <jparrado.1817@gmail.com>
Link: https://patch.msgid.link/20261109194118.18127-1-jparrado1817@gmail.com
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/input/joystick/xpad.c |    1 +
 1 file changed, 1 insertion(+)

--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -284,6 +284,7 @@ static const struct xpad_device {
 	{ 0x0f0d, 0x0063, "Hori Real Arcade Pro Hayabusa (USA) Xbox One", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
 	{ 0x0f0d, 0x0067, "HORIPAD ONE", 0, XTYPE_XBOXONE },
 	{ 0x0f0d, 0x0078, "Hori Real Arcade Pro V Kai Xbox One", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
+	{ 0x0f0d, 0x008c, "Real Arcade Pro 4", 0, XTYPE_XBOX360 },
 	{ 0x0f0d, 0x00c5, "Hori Fighting Commander ONE", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
 	{ 0x0f0d, 0x00dc, "HORIPAD FPS for Nintendo Switch", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
 	{ 0x0f0d, 0x0151, "Hori Racing Wheel Overdrive for Xbox Series X", 0, XTYPE_XBOXONE },



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 404/555] ip6mr: prevent info-leak in ip6mr_cache_report()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (402 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 403/555] Input: xpad - add support to Hori Real Arcade Pro 4 Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 405/555] mac802154: llsec: reject secured frames with security level 0 Greg Kroah-Hartman
                   ` (150 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Henry Martin, Ido Schimmel,
	Jakub Kicinski

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Henry Martin <bsdhenrymartin@gmail.com>

commit ea538b5790eed4f042ea787ea761cb1a695f8138 upstream.

The non-WHOLEPKT branch copies the IPv6 header at offset 0 and then
appends 40 bytes with skb_put(), but the mrt6msg is written at offset 0
after skb_reset_transport_header(), so the appended 40 bytes are never
initialized.  They hold stale heap contents.

The report is queued to the mroute6 socket and copied into the
IP6MRA_CREPORT_PKT netlink attribute, disclosing the stale bytes to
user space.  The stale bytes can contain kernel heap and image
pointers, and the report is reachable from an unprivileged user
namespace (MRT6_INIT in a new netns, plus the non-root
RTNLGRP_IPV6_MROUTE_R group).

Use skb_put_zero() instead, as the IPv4 code does since
commit 4f34002e2e376 ("ipmr: prevent info-leak in pmr_cache_report()").

This issue was discovered by Tencent CodeBuddy Security.

Fixes: 7bc570c8b4f75 ("[IPV6] MROUTE: Support multicast forwarding.")
Cc: stable@vger.kernel.org
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20261112042415.617221-1-bsdhenrymartin@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/ipv6/ip6mr.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -1124,7 +1124,7 @@ static int ip6mr_cache_report(const stru
 	/*
 	 *	Add our header
 	 */
-	skb_put(skb, sizeof(*msg));
+	skb_put_zero(skb, sizeof(*msg));
 	skb_reset_transport_header(skb);
 	msg = (struct mrt6msg *)skb_transport_header(skb);
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 405/555] mac802154: llsec: reject secured frames with security level 0
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (403 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 404/555] ip6mr: prevent info-leak in ip6mr_cache_report() Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 406/555] maple_tree: fix rcu reader NULL dereference after the tree is emptied Greg Kroah-Hartman
                   ` (149 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Joas Antonio dos Santos,
	Miquel Raynal, Jakub Kicinski

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Joas Antonio dos Santos <joasantonio108@gmail.com>

commit 3e8c853c959e9637ed66ae1e55e0d3bb97372cc5 upstream.

mac802154_llsec_decrypt() handles every received frame that has the
Security Enabled bit set.  The security level is taken from the
auxiliary security header of the frame and is not required to be
non-zero.  The only check that looks at level 0 rejects the frame only
if level 0 is not allowed by the matching seclevel entry, the entry has
device_override set and the device is not seclevel_exempt:

	if (!(seclevel.sec_levels & BIT(hdr.sec.level)) &&
	    (hdr.sec.level == 0 && seclevel.device_override &&
	     !dev->dev.seclevel_exempt)) {

Otherwise the frame reaches llsec_do_decrypt(), which sends every level
other than IEEE802154_SCF_SECLEVEL_ENC to llsec_do_decrypt_auth().
There ieee802154_sechdr_authtag_len() returns 0 for level 0 and

	req = aead_request_alloc(llsec_tfm_by_len(key, authlen), GFP_ATOMIC);

looks for a transform with an authentication tag size of 0.  The key
only has transforms for tag sizes 4, 8 and 16, so llsec_tfm_by_len()
runs into its BUG().

The frame is not authenticated at that point.  A station in radio range
can crash a node that has llsec enabled if it sends a frame that matches
a configured key entry and a device table entry (source address, key id
mode and key id are sent in the clear and can be observed), uses a frame
type that has a seclevel entry and carries a frame counter that is not
lower than the stored one.  No key material is needed.  The frame
counter of that device is also updated before the BUG() is reached.

A frame with the Security Enabled bit set and security level 0 carries
no protection and cannot be processed by the incoming security
procedure.  Reject it before any key or device state is looked up.  The
transmit side already leaves such frames alone in
mac802154_llsec_encrypt().

Found by LLM-assisted source review.

Fixes: 4c14a2fb5d14 ("mac802154: add llsec decryption method")
Cc: stable@vger.kernel.org
Signed-off-by: Joas Antonio dos Santos <joasantonio108@gmail.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://patch.msgid.link/20261110-llsec-seclevel-none-v1-1-06ef143e467f@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/mac802154/llsec.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/net/mac802154/llsec.c
+++ b/net/mac802154/llsec.c
@@ -1019,6 +1019,8 @@ int mac802154_llsec_decrypt(struct mac80
 		return 0;
 	if (hdr.fc.version == 0)
 		return -EINVAL;
+	if (hdr.sec.level == IEEE802154_SCF_SECLEVEL_NONE)
+		return -EINVAL;
 
 	read_lock_bh(&sec->lock);
 	if (!sec->params.enabled) {



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 406/555] maple_tree: fix rcu reader NULL dereference after the tree is emptied
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (404 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 405/555] mac802154: llsec: reject secured frames with security level 0 Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 407/555] mptcp: Avoid unsequenced accesses to jiffies in mptcp_reset_tout_timer() Greg Kroah-Hartman
                   ` (148 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Liam R. Howlett (Google),
	Andrew Morton, Chris Mason, Lorenzo Stoakes, Alice Ryhl,
	Andrew Ballance

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Liam R. Howlett (Google) <liam@infradead.org>

commit e8a71f284ba7eeddd9475bb0b65200e95428b497 upstream.

Patch series "maple_tree fixes for 7.3", v2.

Two bugs found by an LLM review, and one problem Lorenzo Stoakes
reported off list.

An RCU reader that restarts after its node dies can dereference NULL if
the tree was emptied, or holds a single entry in the root pointer.
Patch 1 fixes it and patch 2 adds a test.

With CONFIG_DEBUG_MAPLE_TREE, MT_WARN_ON() and the other WARN macros
print the tree and call dump_stack() rather than WARN(), so syzbot never
sees them.  Patch 3 makes them WARN once per call site, after the dump,
and makes the BUG macros BUG() after theirs.  The userspace tests make
WARN() fatal to keep failing as they did on dump_stack().


This patch (of 3):

RCU readers may hit a NULL dereference if the tree is emptied while the
walker is restarted from a dead node.  Avoid the NULL dereference by
checking for an emptied/pointer tree (0->ptr, 1-ULONG_MAX -> NULL) and
set the maple state limits correctly.

A reader of /proc/<pid>/maps racing with an munmap() of the whole
address space can hit this.  The first implementation has the same
problem in both directions.

Initial fix was generated by LLM and sent by Chris Mason in private.

[akpm@linux-foundation.org: fix reverse iterator state when the root disappears]
  Link: https://lore.kernel.org/20261104104137.2058705ac29734a7ab5666c1@linux-foundation.org
Link: https://lore.kernel.org/20261103020724.2614498-1-liam@infradead.org
Link: https://lore.kernel.org/20261103020724.2614498-2-liam@infradead.org
Fixes: 54a611b60590 ("Maple Tree: add new data structure")
Signed-off-by: Liam R. Howlett (Google) <liam@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Chris Mason <mason@kernel.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Alice Ryhl <aliceryhl@google.com>
Cc: Andrew Ballance <andrewjballance@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 lib/maple_tree.c |  120 ++++++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 93 insertions(+), 27 deletions(-)

--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -4347,14 +4347,64 @@ retry:
 		goto retry;
 }
 
-static __always_inline bool mas_rewalk_if_dead(struct ma_state *mas,
-		struct maple_node *node, const unsigned long index)
+/*
+ * mas_next_no_node() - Finish a next walk that restarted into a tree without
+ * nodes.
+ * @mas: The inactive maple state (ma_none or ma_root)
+ *
+ * The arrival here is either because there is a root value or nothing.  Either
+ * way, the next entry is nothing.  So set the limits and overwrite the status.
+ *
+ * Return: NULL
+ */
+static inline void *mas_next_no_node(struct ma_state *mas)
 {
-	if (unlikely(ma_dead_node(node))) {
-		mas_rewalk(mas, index);
-		return true;
+	if (mas_is_ptr(mas))
+		mas->index = 1;
+	else
+		mas->index = 0;
+
+	mas->last = ULONG_MAX;
+	mas->status = ma_none;
+	return NULL;
+}
+
+/*
+ * mas_prev_no_node() - Finish a prev walk that restarted into a tree without
+ * nodes.
+ * @mas: The inactive maple state (ma_none or ma_root)
+ * @index: The start of the range the walk left
+ * @min: The lowest index to return
+ *
+ * The arrival here is either because there is a root value or nothing.  With
+ * nothing, leave the limits mas_walk() sets for an empty tree.  A root value
+ * sits at 0: stop on it as mas_prev_setup() does, unless the walk was at 0.
+ *
+ * Return: The root entry if @index and @min allow it, NULL otherwise.  A node
+ * if the root changed again since the walk; the caller restarts.
+ */
+static inline void *mas_prev_no_node(struct ma_state *mas, unsigned long index,
+		unsigned long min)
+{
+	void *entry;
+
+	mas->index = 0;
+	if (mas_is_none(mas)) {
+		mas->last = ULONG_MAX;
+		return NULL;
 	}
-	return false;
+
+	mas->last = 0;
+	if (!index || min)
+		return NULL;
+
+	entry = mas_root(mas);
+	if (!entry) {
+		mas->status = ma_none;
+		mas->last = ULONG_MAX;
+	}
+
+	return entry;
 }
 
 /*
@@ -4462,14 +4512,14 @@ retry:
 	node = mas_mn(mas);
 	type = mte_node_type(mas->node);
 	pivots = ma_pivots(node, type);
-	if (unlikely(mas_rewalk_if_dead(mas, node, save_point)))
-		goto retry;
+	if (unlikely(ma_dead_node(node)))
+		goto dead;
 
 	if (mas->min <= min) {
 		pivot = mas_safe_min(mas, pivots, mas->offset);
 
-		if (unlikely(mas_rewalk_if_dead(mas, node, save_point)))
-			goto retry;
+		if (unlikely(ma_dead_node(node)))
+			goto dead;
 
 		if (pivot <= min)
 			goto underflow;
@@ -4484,10 +4534,8 @@ again:
 		if (mas->index <= min)
 			goto underflow;
 
-		if (mas_prev_node(mas, min)) {
-			mas_rewalk(mas, save_point);
-			goto retry;
-		}
+		if (mas_prev_node(mas, min))
+			goto dead;
 
 		if (WARN_ON_ONCE(mas_is_underflow(mas)))
 			return NULL;
@@ -4501,8 +4549,8 @@ again:
 
 	slots = ma_slots(node, type);
 	entry = mas_slot(mas, slots, mas->offset);
-	if (unlikely(mas_rewalk_if_dead(mas, node, save_point)))
-		goto retry;
+	if (unlikely(ma_dead_node(node)))
+		goto dead;
 
 
 	if (likely(entry))
@@ -4522,6 +4570,17 @@ again:
 underflow:
 	mas->status = ma_underflow;
 	return NULL;
+
+dead:
+	mas_rewalk(mas, save_point);
+	if (likely(mas_is_active(mas)))
+		goto retry;
+
+	entry = mas_prev_no_node(mas, save_point, min);
+	if (unlikely(xa_is_node(entry))) /* The root changed again */
+		goto dead;
+
+	return entry;
 }
 
 /*
@@ -4635,8 +4694,8 @@ retry:
 	node = mas_mn(mas);
 	type = mte_node_type(mas->node);
 	pivots = ma_pivots(node, type);
-	if (unlikely(mas_rewalk_if_dead(mas, node, save_point)))
-		goto retry;
+	if (unlikely(ma_dead_node(node)))
+		goto dead;
 
 	if (mas->max >= max) {
 		if (likely(mas->offset < mas->end))
@@ -4644,8 +4703,8 @@ retry:
 		else
 			pivot = mas->max;
 
-		if (unlikely(mas_rewalk_if_dead(mas, node, save_point)))
-			goto retry;
+		if (unlikely(ma_dead_node(node)))
+			goto dead;
 
 		if (pivot >= max) { /* Was at the limit, next will extend beyond */
 			mas->status = ma_overflow;
@@ -4667,10 +4726,8 @@ again:
 			return NULL;
 		}
 
-		if (mas_next_node(mas, node, max)) {
-			mas_rewalk(mas, save_point);
-			goto retry;
-		}
+		if (mas_next_node(mas, node, max))
+			goto dead;
 
 		if (WARN_ON_ONCE(mas_is_overflow(mas)))
 			return NULL;
@@ -4685,8 +4742,8 @@ again:
 
 	slots = ma_slots(node, type);
 	entry = mt_slot(mas->tree, slots, mas->offset);
-	if (unlikely(mas_rewalk_if_dead(mas, node, save_point)))
-		goto retry;
+	if (unlikely(ma_dead_node(node)))
+		goto dead;
 
 	if (entry)
 		return entry;
@@ -4703,6 +4760,13 @@ again:
 	}
 
 	return entry;
+
+dead:
+	mas_rewalk(mas, save_point);
+	if (likely(mas_is_active(mas)))
+		goto retry;
+
+	return mas_next_no_node(mas);
 }
 
 /*
@@ -6016,7 +6080,9 @@ void *mas_find(struct ma_state *mas, uns
 	/* Retries on dead nodes handled by mas_next_slot */
 	entry = mas_next_slot(mas, max, false);
 	/* Ignore overflow */
-	mas->status = ma_active;
+	if (mas_is_overflow(mas))
+		mas->status = ma_active;
+
 	return entry;
 }
 EXPORT_SYMBOL_GPL(mas_find);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 407/555] mptcp: Avoid unsequenced accesses to jiffies in mptcp_reset_tout_timer()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (405 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 406/555] maple_tree: fix rcu reader NULL dereference after the tree is emptied Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 408/555] net/tls: serialize context removal in tls_device_down() Greg Kroah-Hartman
                   ` (147 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Nathan Chancellor,
	Matthieu Baerts (NGI0), Jakub Kicinski

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Nathan Chancellor <nathan@kernel.org>

commit 728a2abd15a767f662a44030931ea7b2959b4e88 upstream.

After a recent improvement in clang to warn on unsequenced accesses to
volatile variables [1], an instance appears in mptcp_reset_tout_timer(),
which can break the build with CONFIG_WERROR=y / W=e:

  net/mptcp/protocol.c:3044:20: error: unsequenced accesses to volatile qualified 'jiffies' [-Werror,-Wunsequenced]
   3044 |                         tcp_jiffies32 + jiffies + mptcp_close_timeout(sk);
        |                         ~~~~~~~~~~~~~   ^

Per C11 5.1.2.3.2, accessing a volatile object is a side effect. Per C11
6.5.2, unsequenced side effects on the same scalar object are undefined
behavior. Per C11 6.5.3, unless otherwise specified, side effects and
value computations of subexpressions are unsequenced within expressions.

Add an explicit sequence point by splitting the addition expression in
half, eliminating the undefined behavior and clearing up the warning.

Cc: stable@vger.kernel.org
Fixes: 76a13b315709 ("mptcp: invoke MP_FAIL response when needed")
Closes: https://github.com/ClangBuiltLinux/linux/issues/2193
Link: https://github.com/llvm/llvm-project/commit/955715460eaf9188c241c74750637fc82dfcc423 [1]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20261114-mptcp-wunsequenced-v1-1-707a73a6c172@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/mptcp/protocol.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2865,7 +2865,8 @@ void mptcp_reset_tout_timer(struct mptcp
 		return;
 
 	close_timeout = (unsigned long)inet_csk(sk)->icsk_mtup.probe_timestamp -
-			tcp_jiffies32 + jiffies + mptcp_close_timeout(sk);
+			tcp_jiffies32;
+	close_timeout += jiffies + mptcp_close_timeout(sk);
 
 	/* the close timeout takes precedence on the fail one, and here at least one of
 	 * them is active



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 408/555] net/tls: serialize context removal in tls_device_down()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (406 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 407/555] mptcp: Avoid unsequenced accesses to jiffies in mptcp_reset_tout_timer() Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 409/555] ipv6: mcast: use skb_set_transport_header_careful() in ipv6_mc_check_exthdrs() Greg Kroah-Hartman
                   ` (146 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Jaeyeong Lee, Paolo Abeni

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jaeyeong Lee <lee@jaeyeong.cc>

commit 81c8333141b9aa465d98bb4c035284556e699701 upstream.

tls_device_down() moves each context to tls_device_down_list while
holding tls_device_lock. It then drops its reference and removes the
context after releasing the lock.

tls_device_queue_ctx_destruction() removes contexts from the same list
under tls_device_lock. If it removes an adjacent context while
tls_device_down() is deleting its node, the two list updates can
interleave. One update can then target a context freed by the other path,
causing a use-after-free write.

Drop the reference and remove the context in the existing
tls_device_lock critical section. Keep tls_device_free_ctx() after
releasing the lock.

This issue was found with a static analysis tool.

Fixes: f6336724a4d4 ("net/tls: Remove the context from the list in tls_device_down")
Cc: stable@vger.kernel.org
Signed-off-by: Jaeyeong Lee <lee@jaeyeong.cc>
Link: https://patch.msgid.link/20261112043209.102404-1-lee@jaeyeong.cc
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/tls/tls_device.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

--- a/net/tls/tls_device.c
+++ b/net/tls/tls_device.c
@@ -1349,6 +1349,8 @@ static int tls_device_down(struct net_de
 	spin_unlock_irqrestore(&tls_device_lock, flags);
 
 	list_for_each_entry_safe(ctx, tmp, &list, list)	{
+		bool free_ctx;
+
 		/* Stop offloaded TX and switch to the fallback.
 		 * tls_is_skb_tx_device_offloaded will return false.
 		 */
@@ -1386,17 +1388,19 @@ static int tls_device_down(struct net_de
 		 */
 		spin_lock_irqsave(&tls_device_lock, flags);
 		list_move_tail(&ctx->list, &tls_device_down_list);
+		/* Serialize the final removal with sk_destruct. */
+		free_ctx = refcount_dec_and_test(&ctx->refcount);
+		if (free_ctx)
+			list_del(&ctx->list);
 		spin_unlock_irqrestore(&tls_device_lock, flags);
 
 		/* Device contexts for RX and TX will be freed in on sk_destruct
 		 * by tls_device_free_ctx. rx_conf and tx_conf stay in TLS_HW.
-		 * Now release the ref taken above.
 		 */
-		if (refcount_dec_and_test(&ctx->refcount)) {
+		if (free_ctx) {
 			/* sk_destruct ran after tls_device_down took a ref, and
 			 * it returned early. Complete the destruction here.
 			 */
-			list_del(&ctx->list);
 			tls_device_free_ctx(ctx);
 		}
 	}



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 409/555] ipv6: mcast: use skb_set_transport_header_careful() in ipv6_mc_check_exthdrs()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (407 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 408/555] net/tls: serialize context removal in tls_device_down() Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 410/555] ipvs: ftp: skip conntrack templates in ip_vs_ftp_out Greg Kroah-Hartman
                   ` (145 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Eric Dumazet, Ido Schimmel,
	Justin Iurman, Paolo Abeni

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Eric Dumazet <edumazet@kernel.org>

commit 425b1fe50b71628299d33faff28057e7fa4c60c7 upstream.

skb->transport_header is a 16-bit offset from skb->head, and U16_MAX is
reserved as the "not set" value. skb_set_transport_header() silently
truncates an offset that does not fit.

ipv6_mc_check_exthdrs() stores the offset returned by ipv6_skip_exthdr(),
which depends on the extension headers found in the packet. Should the
value be truncated, ipv6_mc_check_icmpv6() and ipv6_mc_check_mld_msg()
would then validate and parse the MLD message at the wrong place.

Since commit 3744b0964d52 ("ipv6: Implement limits on extension header
parsing") a single chain is bounded to IP6_MAX_EXT_HDRS_CNT headers
(24576 bytes), so this needs a large skb->data - skb->head on top of it,
for instance after several nested decapsulations, each of them possibly
pulling its own extension header chain. No reproducer was written,
this is hardening.

Use skb_set_transport_header_careful() and treat such a packet as
broken (-EINVAL).

Fixes: 9afd85c9e455 ("net: Export IGMP/MLD message validation code")
Cc: stable@vger.kernel.org
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20261113124625.4010206-3-edumazet@kernel.org
Reviewed-by: Justin Iurman <justin.iurman@gmail.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/ipv6/mcast_snoop.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/net/ipv6/mcast_snoop.c
+++ b/net/ipv6/mcast_snoop.c
@@ -56,7 +56,8 @@ static int ipv6_mc_check_exthdrs(struct
 	if (nexthdr != IPPROTO_ICMPV6)
 		return -ENOMSG;
 
-	skb_set_transport_header(skb, offset);
+	if (!skb_set_transport_header_careful(skb, offset))
+		return -EINVAL;
 
 	return 0;
 }



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 410/555] ipvs: ftp: skip conntrack templates in ip_vs_ftp_out
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (408 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 409/555] ipv6: mcast: use skb_set_transport_header_careful() in ipv6_mc_check_exthdrs() Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 411/555] ipvs: reject FTP control ports as data ports Greg Kroah-Hartman
                   ` (144 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Theodor Arsenij Larionov Trichkine,
	Julian Anastasov, Pablo Neira Ayuso

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Theodor Arsenij Larionov Trichkine <theodorlarionov@gmail.com>

commit 4656934d460da68382cf91766a1ff2d0610554ae upstream.

A CT target hooked after conntrack attaches its template to a packet
that conntrack left without an entry. On an IPVS FTP PASV/EPSV reply,
ip_vs_ftp_out() then mangles with the template and creates an
expectation with the template as master. Deleting the CT rule frees
the template and leaves the expectation, so a later expectation flush
reads freed memory:

  BUG: KASAN: slab-use-after-free in nf_ct_unlink_expect_report

Reachable with CAP_NET_ADMIN in a user namespace.

Skip templates, as nft_ct and nfnetlink_queue do.

Fixes: f4bc17cdd205 ("ipvs: netfilter connection tracking changes")
Cc: stable@vger.kernel.org
Signed-off-by: Theodor Arsenij Larionov Trichkine <theodorlarionov@gmail.com>
Acked-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/netfilter/ipvs/ip_vs_ftp.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/net/netfilter/ipvs/ip_vs_ftp.c
+++ b/net/netfilter/ipvs/ip_vs_ftp.c
@@ -369,7 +369,7 @@ static int ip_vs_ftp_out(struct ip_vs_ap
 	buf_len = strlen(buf);
 
 	ct = nf_ct_get(skb, &ctinfo);
-	if (ct) {
+	if (ct && !nf_ct_is_template(ct)) {
 		bool mangled;
 
 		/* If mangling fails this function will return 0



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 411/555] ipvs: reject FTP control ports as data ports
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (409 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 410/555] ipvs: ftp: skip conntrack templates in ip_vs_ftp_out Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 412/555] ipvs: validate cport in received sync records Greg Kroah-Hartman
                   ` (143 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Vega, Luxing Yin, Zihan Xi,
	Julian Anastasov, Pablo Neira Ayuso

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Zihan Xi <zihanx@nebusec.ai>

commit a107e150e105836bb5349cdee14541d4995009ea upstream.

The FTP helper must not treat a configured control port as a data port.
Accepting such a port can leave IPVS connections in a state that leads
to recursive expiration and kernel stack exhaustion.

Reject zero and configured control ports before creating passive data
connections. For active mode, reject a zero client port and a derived
data port that is itself a configured control port.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Reported-by: Vega <vega@nebusec.ai>
Co-developed-by: Luxing Yin <root@tr0jan.top>
Signed-off-by: Luxing Yin <root@tr0jan.top>
Signed-off-by: Zihan Xi <zihanx@nebusec.ai>
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/netfilter/ipvs/ip_vs_ftp.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

--- a/net/netfilter/ipvs/ip_vs_ftp.c
+++ b/net/netfilter/ipvs/ip_vs_ftp.c
@@ -63,6 +63,17 @@ static unsigned short ports[IP_VS_APP_MA
 module_param_array(ports, ushort, &ports_count, 0444);
 MODULE_PARM_DESC(ports, "Ports to monitor for FTP control commands");
 
+static bool is_control_port(u16 port)
+{
+	unsigned int i;
+
+	for (i = 0; i < ports_count; i++) {
+		if (ports[i] == port)
+			return true;
+	}
+	return false;
+}
+
 
 static char *ip_vs_ftp_data_ptr(struct sk_buff *skb, struct ip_vs_iphdr *ipvsh)
 {
@@ -320,6 +331,10 @@ static int ip_vs_ftp_out(struct ip_vs_ap
 		return 1;
 	}
 
+	/* Do not redirect data to control ports */
+	if (!port || is_control_port(ntohs(port)))
+		return 0;
+
 	/* Now update or create a connection entry for it */
 	{
 		struct ip_vs_conn_param p;
@@ -530,6 +545,9 @@ static int ip_vs_ftp_in(struct ip_vs_app
 		return 1;
 	}
 
+	if (!port || is_control_port(ntohs(cp->vport) - 1))
+		return 0;
+
 	/* Passive mode off */
 	cp->app_data = (void *) IP_VS_FTP_ACTIVE;
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 412/555] ipvs: validate cport in received sync records
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (410 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 411/555] ipvs: reject FTP control ports as data ports Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 413/555] KVM: PPC: Book3S HV: Avoid spurious interrupts caused by LPCR_MER bit Greg Kroah-Hartman
                   ` (142 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Julian Anastasov, Axel Mierczuk,
	Pablo Neira Ayuso

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Axel Mierczuk <axel.mierczuk@1password.com>

commit 1d1e8bc81f790a48cd643b1b1762de43334d4f14 upstream.

Local templates have cport 0 and IP_VS_CONN_F_NO_CPORT clear, so
ip_vs_conn_in_get() cannot match them. A template received over the
unauthenticated sync protocol with a nonzero cport can reach the
protocol state machine. Before template state validation, this
could cause out-of-bounds reads, crashes and kernel data leaks.

Ordinary records with cport 0 and IP_VS_CONN_F_NO_CPORT clear, or
with a nonzero cport and IP_VS_CONN_F_NO_CPORT set, create connections
that incoming lookups cannot match. The latter also keeps the
cport-zero fallback in ip_vs_conn_in_get() enabled.

Reject all three cases. Continue accepting ordinary connections with
cport 0 and IP_VS_CONN_F_NO_CPORT. The companion commit f96e91748f63
("ipvs: filter some flags received in the backup server") rejects
template records carrying IP_VS_CONN_F_NO_CPORT.

Fixes: 87375ab47cd0 ("[IPVS]: ip_vs_ftp breaks connections using persistence")
Cc: stable@vger.kernel.org
Suggested-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Axel Mierczuk <axel.mierczuk@1password.com>
Acked-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/netfilter/ipvs/ip_vs_sync.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

--- a/net/netfilter/ipvs/ip_vs_sync.c
+++ b/net/netfilter/ipvs/ip_vs_sync.c
@@ -871,6 +871,25 @@ static void ip_vs_proc_conn(struct netns
 	struct ip_vs_dest *dest;
 	struct ip_vs_conn *cp;
 
+	/* Templates require cport 0. Ordinary connections require
+	 * NO_CPORT exactly when cport is 0.
+	 */
+	if (flags & IP_VS_CONN_F_TEMPLATE) {
+		if (param->cport) {
+			IP_VS_DBG(2, "BACKUP, template with cport dropped\n");
+			kfree(param->pe_data);
+			return;
+		}
+	} else if (!param->cport && !(flags & IP_VS_CONN_F_NO_CPORT)) {
+		IP_VS_DBG(2, "BACKUP, conn without cport dropped\n");
+		kfree(param->pe_data);
+		return;
+	} else if (param->cport && (flags & IP_VS_CONN_F_NO_CPORT)) {
+		IP_VS_DBG(2, "BACKUP, conn with cport and NO_CPORT dropped\n");
+		kfree(param->pe_data);
+		return;
+	}
+
 	if (!(flags & IP_VS_CONN_F_TEMPLATE)) {
 		cp = ip_vs_conn_in_get(param);
 		if (cp && ((cp->dport != dport) ||



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 413/555] KVM: PPC: Book3S HV: Avoid spurious interrupts caused by LPCR_MER bit
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (411 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 412/555] ipvs: validate cport in received sync records Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 414/555] KVM: PPC: Book3S HV: Disable preemption around host-side HPT lock users Greg Kroah-Hartman
                   ` (141 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Timothy Pearson, Gautam Menghani,
	Ritesh Harjani (IBM), Madhavan Srinivasan

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Gautam Menghani <gautam@linux.ibm.com>

commit 9751c361cb234f000261879b1b5015bf08f6a428 upstream.

A huge number of spurious interrupts can be seen immediately after a KVM
on PowerNV guest boots up in XIVE mode.

$ cat /proc/interrupts  | grep SPU
SPU:     223705     192439     273526     147623   Spurious interrupts

This bug was introduced by commit ecd10702baae5 ("KVM: PPC: Book3S HV:
Handle pending exceptions on guest entry with MSR_EE"). The root cause
is that once LPCR_MER bit is set, it is supposed to be reset by
software. But when a vCPU starts running with LPCR_MER set, the vCPU does
not exit back to the host until the decrementer expires or there is an
hcall, etc. This is because KVM on PowerNV guests have support for
native XIVE, so they are not dependent on host for interrupt emulation.
Due to this behaviour, a huge number of spurious interrupts are seen
since LPCR_MER continues to be set and LPCR_MER cannot be reset until the
vCPU exits to the host.

Fix this behaviour by not using the LPCR_MER bit whenever native XIVE is
available (currently in case of KVM on PowerNV only), as the XIVE hardware
can present interrupts to the KVM guest vCPU directly. So the LPCR_MER
functionality is not required. This reduces the number of spurious
interrupts drastically.

Fixes: ecd10702baae5 ("KVM: PPC: Book3S HV: Handle pending exceptions on guest entry with MSR_EE")
Cc: stable@vger.kernel.org # 6.8+
Reported-by: Timothy Pearson <tpearson@raptorengineering.com>
Closes: https://lore.kernel.org/linuxppc-dev/582904882.11159.1786719390349.JavaMail.zimbra@raptorengineeringinc.com
Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20261102091700.253381-1-gautam@linux.ibm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/powerpc/kvm/book3s_hv.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -4911,7 +4911,7 @@ int kvmhv_run_single_vcpu(struct kvm_vcp
 			if (!kvmhv_on_pseries() && (__kvmppc_get_msr_hv(vcpu) & MSR_EE))
 				kvmppc_inject_interrupt_hv(vcpu,
 							   BOOK3S_INTERRUPT_EXTERNAL, 0);
-			else
+			else if (!kvmppc_xive_enabled(vcpu))
 				lpcr |= LPCR_MER;
 		} else {
 			/*



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 414/555] KVM: PPC: Book3S HV: Disable preemption around host-side HPT lock users
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (412 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 413/555] KVM: PPC: Book3S HV: Avoid spurious interrupts caused by LPCR_MER bit Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 415/555] KVM: PPC: Book3S HV: Ensure that calls to idr_alloc are synchronized Greg Kroah-Hartman
                   ` (140 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Amit Machhiwal, Ritesh Harjani (IBM),
	Madhavan Srinivasan

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Amit Machhiwal <amachhiw@linux.ibm.com>

commit 4e6e66ecf62185828f731914000a6b0baff355db upstream.

A previous change ("KVM: PPC: Book3S HV: Add preempt_disable() around
virtual-mode HPTE bit-lock users") at [1] added preempt_disable() around
guest vCPU HPT hcalls and page fault handlers executed in virtual mode.
This ensures vCPU threads cannot be preempted while holding
HPTE_V_HVLOCK or the reverse-map lock.

However, several host-side virtual-mode paths in book3s_64_mmu_hv.c also
acquire HPTE_V_HVLOCK and lock_rmap() in process context with preemption
enabled.  Specifically, kvm_unmap_rmapp() and kvm_age_rmapp() take both
locks during MMU notifier callbacks and memslot flushes, while
resize_hpt_rehash_hpte() acquires HPTE_V_HVLOCK during HPT resizing.  If
a host thread is preempted while holding either bit-lock, any guest vCPU
thread scheduled on the same CPU spinning for the same lock with
preemption disabled will never yield, resulting in a permanent CPU hang.

Fix this by disabling preemption across these host-side critical
sections.

For kvm_unmap_rmapp() and kvm_age_rmapp(), place preempt_disable()
before lock_rmap() so that both the rmap chain lock and the subsequent
HPTE_V_HVLOCK bit-lock are held under a single non-preemptible window.
To preserve the ABBA lock ordering between the two locks, re-enable
preemption after dropping the rmap lock on any retry or early-exit path
before spinning on cpu_relax(), allowing the lock holder to be
scheduled.

For kvm_htab_write(), the HPT migration restore path, replace the direct
calls to kvmppc_do_h_remove() with kvmppc_virtmode_do_h_remove(), a thin
wrapper that brackets kvmppc_do_h_remove() with preempt_disable() and
preempt_enable(), mirroring the existing kvmppc_virtmode_do_h_enter()
helper.

For resize_hpt_rehash_hpte(), place preempt_disable() before the
try_lock_hpte() spin loop and preempt_enable() after unlock_hpte() at
the function exit.

[1] https://git.kernel.org/powerpc/c/abbbe5ff83e7c9ed3a4d61b73011f1df7bf87907

Fixes: 6165d5dd99db ("KVM: PPC: Book3S HV: add virtual mode handlers for HPT hcalls and page faults")
Cc: stable@vger.kernel.org # v5.14+
Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20261014185215.71832-1-amachhiw@linux.ibm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/powerpc/kvm/book3s_64_mmu_hv.c |   33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

--- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
@@ -47,6 +47,9 @@
 static long kvmppc_virtmode_do_h_enter(struct kvm *kvm, unsigned long flags,
 				long pte_index, unsigned long pteh,
 				unsigned long ptel, unsigned long *pte_idx_ret);
+static void kvmppc_virtmode_do_h_remove(struct kvm *kvm, unsigned long flags,
+				unsigned long pte_index, unsigned long avpn,
+				unsigned long *hpret);
 
 struct kvm_resize_hpt {
 	/* These fields read-only after init */
@@ -308,6 +311,22 @@ static long kvmppc_virtmode_do_h_enter(s
 
 }
 
+/*
+ * Virtual-mode H_REMOVE. kvmppc_do_h_remove() is also called from real mode,
+ * where preempt_disable() is not usable, so the guard stays here. The function
+ * spins on HPTE_V_HVLOCK and then lock_rmap() (via remove_revmap_chain());
+ * preemption must be disabled across both bit-locks so that spinning callers
+ * holding preempt_disable() can make forward progress.
+ */
+static void kvmppc_virtmode_do_h_remove(struct kvm *kvm, unsigned long flags,
+				unsigned long pte_index, unsigned long avpn,
+				unsigned long *hpret)
+{
+	preempt_disable();
+	kvmppc_do_h_remove(kvm, flags, pte_index, avpn, hpret);
+	preempt_enable();
+}
+
 static struct kvmppc_slb *kvmppc_mmu_book3s_hv_find_slbe(struct kvm_vcpu *vcpu,
 							 gva_t eaddr)
 {
@@ -827,9 +846,11 @@ static void kvm_unmap_rmapp(struct kvm *
 
 	rmapp = &memslot->arch.rmap[gfn - memslot->base_gfn];
 	for (;;) {
+		preempt_disable();
 		lock_rmap(rmapp);
 		if (!(*rmapp & KVMPPC_RMAP_PRESENT)) {
 			unlock_rmap(rmapp);
+			preempt_enable();
 			break;
 		}
 
@@ -843,6 +864,7 @@ static void kvm_unmap_rmapp(struct kvm *
 		if (!try_lock_hpte(hptep, HPTE_V_HVLOCK)) {
 			/* unlock rmap before spinning on the HPTE lock */
 			unlock_rmap(rmapp);
+			preempt_enable();
 			while (be64_to_cpu(hptep[0]) & HPTE_V_HVLOCK)
 				cpu_relax();
 			continue;
@@ -851,6 +873,7 @@ static void kvm_unmap_rmapp(struct kvm *
 		kvmppc_unmap_hpte(kvm, i, memslot, rmapp, gfn);
 		unlock_rmap(rmapp);
 		__unlock_hpte(hptep, be64_to_cpu(hptep[0]));
+		preempt_enable();
 	}
 }
 
@@ -907,6 +930,7 @@ static bool kvm_age_rmapp(struct kvm *kv
 
 	rmapp = &memslot->arch.rmap[gfn - memslot->base_gfn];
  retry:
+	preempt_disable();
 	lock_rmap(rmapp);
 	if (*rmapp & KVMPPC_RMAP_REFERENCED) {
 		*rmapp &= ~KVMPPC_RMAP_REFERENCED;
@@ -914,6 +938,7 @@ static bool kvm_age_rmapp(struct kvm *kv
 	}
 	if (!(*rmapp & KVMPPC_RMAP_PRESENT)) {
 		unlock_rmap(rmapp);
+		preempt_enable();
 		return ret;
 	}
 
@@ -929,6 +954,7 @@ static bool kvm_age_rmapp(struct kvm *kv
 		if (!try_lock_hpte(hptep, HPTE_V_HVLOCK)) {
 			/* unlock rmap before spinning on the HPTE lock */
 			unlock_rmap(rmapp);
+			preempt_enable();
 			while (be64_to_cpu(hptep[0]) & HPTE_V_HVLOCK)
 				cpu_relax();
 			goto retry;
@@ -948,6 +974,7 @@ static bool kvm_age_rmapp(struct kvm *kv
 	} while ((i = j) != head);
 
 	unlock_rmap(rmapp);
+	preempt_enable();
 	return ret;
 }
 
@@ -1236,6 +1263,7 @@ static unsigned long resize_hpt_rehash_h
 	if (!(vpte & HPTE_V_VALID) && !(vpte & HPTE_V_ABSENT))
 		return 0; /* nothing to do */
 
+	preempt_disable();
 	while (!try_lock_hpte(hptep, HPTE_V_HVLOCK))
 		cpu_relax();
 
@@ -1363,6 +1391,7 @@ static unsigned long resize_hpt_rehash_h
 
 out:
 	unlock_hpte(hptep, vpte);
+	preempt_enable();
 	return ret;
 }
 
@@ -1885,7 +1914,7 @@ static ssize_t kvm_htab_write(struct fil
 			nb += HPTE_SIZE;
 
 			if (be64_to_cpu(hptp[0]) & (HPTE_V_VALID | HPTE_V_ABSENT))
-				kvmppc_do_h_remove(kvm, 0, i, 0, tmp);
+				kvmppc_virtmode_do_h_remove(kvm, 0, i, 0, tmp);
 			err = -EIO;
 			ret = kvmppc_virtmode_do_h_enter(kvm, H_EXACT, i, v, r,
 							 tmp);
@@ -1914,7 +1943,7 @@ static ssize_t kvm_htab_write(struct fil
 
 		for (j = 0; j < hdr.n_invalid; ++j) {
 			if (be64_to_cpu(hptp[0]) & (HPTE_V_VALID | HPTE_V_ABSENT))
-				kvmppc_do_h_remove(kvm, 0, i, 0, tmp);
+				kvmppc_virtmode_do_h_remove(kvm, 0, i, 0, tmp);
 			++i;
 			hptp += 2;
 		}



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 415/555] KVM: PPC: Book3S HV: Ensure that calls to idr_alloc are synchronized
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (413 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 414/555] KVM: PPC: Book3S HV: Disable preemption around host-side HPT lock users Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 416/555] KVM: PPC: Book3S HV: Take SRCU read lock around kvmppc_h_page_init() call Greg Kroah-Hartman
                   ` (139 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Ritesh Harjani (IBM),
	Gautam Menghani, Madhavan Srinivasan

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Gautam Menghani <gautam@linux.ibm.com>

commit d8c6ab0aeeca7cc2adfcf0ce1f796c6a86314ec0 upstream.

Calls to idr_alloc() in __prealloc_nested() are not currently synchronized.
According to the documentation [1], the caller should provide their own
locking to prevent concurrent modifications to the idr to prevent bugs.

__prealloc_nested() calls idr_alloc() with GFP_KERNEL which can
sleep and mmu_lock is a spinlock. So idr_alloc() cannot be moved under
mmu_lock. In such cases the idr Documentation says:
    If you need to take a lock while allocating a new ID from the IDR,
    you may need to pass a restrictive set of GFP flags, which can lead
    to the IDR being unable to allocate memory.  To work around this,
    you can call idr_preload() before taking the lock, and then
    idr_preload_end() after the allocation.

Hence preload the idr memory with idr_preload() before taking mmu_lock,
which allows us to use idr_alloc(..., GFP_NOWAIT) under the spinlock.

This also allows to kill __prealloc_nested() and __add_nested(), as they
are not needed anymore with idr_preload().

[1]: lib/idr.c

Fixes: c0f00a18e2a8 ("KVM: PPC: Book3S HV Nested: Change nested guest lookup to use idr")
Cc: stable@vger.kernel.org # 5.19+
Co-developed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20261012082922.218799-2-gautam@linux.ibm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/powerpc/kvm/book3s_hv_nested.c |   34 ++++++++++------------------------
 1 file changed, 10 insertions(+), 24 deletions(-)

--- a/arch/powerpc/kvm/book3s_hv_nested.c
+++ b/arch/powerpc/kvm/book3s_hv_nested.c
@@ -700,20 +700,6 @@ static struct kvm_nested_guest *__find_n
 	return idr_find(&kvm->arch.kvm_nested_guest_idr, lpid);
 }
 
-static bool __prealloc_nested(struct kvm *kvm, int lpid)
-{
-	if (idr_alloc(&kvm->arch.kvm_nested_guest_idr,
-				NULL, lpid, lpid + 1, GFP_KERNEL) != lpid)
-		return false;
-	return true;
-}
-
-static void __add_nested(struct kvm *kvm, int lpid, struct kvm_nested_guest *gp)
-{
-	if (idr_replace(&kvm->arch.kvm_nested_guest_idr, gp, lpid))
-		WARN_ON(1);
-}
-
 static void __remove_nested(struct kvm *kvm, int lpid)
 {
 	idr_remove(&kvm->arch.kvm_nested_guest_idr, lpid);
@@ -860,21 +846,21 @@ struct kvm_nested_guest *kvmhv_get_neste
 	if (!newgp)
 		return NULL;
 
-	if (!__prealloc_nested(kvm, l1_lpid)) {
-		kvmhv_release_nested(newgp);
-		return NULL;
-	}
-
+	idr_preload(GFP_KERNEL);
 	spin_lock(&kvm->mmu_lock);
 	gp = __find_nested(kvm, l1_lpid);
 	if (!gp) {
-		__add_nested(kvm, l1_lpid, newgp);
-		++newgp->refcnt;
-		gp = newgp;
-		newgp = NULL;
+		if (idr_alloc(&kvm->arch.kvm_nested_guest_idr, newgp,
+			      l1_lpid, l1_lpid + 1, GFP_NOWAIT) >= 0) {
+			++newgp->refcnt;
+			gp = newgp;
+			newgp = NULL;
+		}
 	}
-	++gp->refcnt;
+	if (gp)
+		++gp->refcnt;
 	spin_unlock(&kvm->mmu_lock);
+	idr_preload_end();
 
 	if (newgp)
 		kvmhv_release_nested(newgp);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 416/555] KVM: PPC: Book3S HV: Take SRCU read lock around kvmppc_h_page_init() call
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (414 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 415/555] KVM: PPC: Book3S HV: Ensure that calls to idr_alloc are synchronized Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 417/555] KVM: PPC: Book3S HV: XICS: Avoid NULL ptr deref in kvmppc_xive_cleanup_vcpu() Greg Kroah-Hartman
                   ` (138 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Gautam Menghani,
	Ritesh Harjani (IBM), Madhavan Srinivasan

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Gautam Menghani <gautam@linux.ibm.com>

commit b04be22bf6ea06b92bff7850328a8057b8d964ae upstream.

Since there is no srcu read lock around kvmppc_h_page_init(), a
"suspicious rcu_dereference_check() usage" can be triggered by running
host linux with CONFIG_PROVE_RCU=y and the following code in the guest:

plpar_hcall_norets(H_PAGE_INIT, H_ZERO_PAGE, phys_addr, 0);

 =============================
 WARNING: suspicious RCU usage
 7.0.0-dirty #227 Not tainted
 -----------------------------
./include/linux/kvm_host.h:1074 suspicious rcu_dereference_check() usage!

other info that might help us debug this:

rcu_scheduler_active = 2, debug_locks = 1
1 lock held by qemu-system-ppc/2093:
 #0: c000000354197ab0 (&vcpu->mutex){+.+.}-{3:3}, at: kvm_vcpu_ioctl+0x10c/0xaf0

stack backtrace:
CPU: 30 UID: 0 PID: 2093 Comm: qemu-system-ppc Not tainted 7.0.0-dirty #227 PREEMPT(full)
Hardware name: IBM,9080-HEX POWER10 (architected) 0x800200 0xf000006 of:IBM,FW1060.60 (NH1060_158) hv:phyp pSeries
Call Trace:
[c00000033e1bf430] [c000000001b3dbd4] dump_stack_lvl+0xc8/0x130 (unreliable)
[c00000033e1bf470] [c0000000003da964] lockdep_rcu_suspicious+0x1f4/0x290
[c00000033e1bf520] [c000000000231424] gfn_to_memslot+0x1b4/0x1c0
[c00000033e1bf560] [c00000000023637c] kvm_clear_guest+0x9c/0x110
[c00000033e1bf5c0] [c0000000002714a4] kvmppc_h_page_init+0x160/0x1a0
[c00000033e1bf610] [c00000000026c040] kvmppc_pseries_do_hcall+0x1930/0x1940
[c00000033e1bf6d0] [c00000000026fb18] kvmppc_vcpu_run_hv+0x268/0x800
[c00000033e1bf7a0] [c000000000246b30] kvmppc_vcpu_run+0x30/0x50
[c00000033e1bf7c0] [c000000000241ed4] kvm_arch_vcpu_ioctl_run+0x364/0x530
[c00000033e1bf860] [c00000000022b870] kvm_vcpu_ioctl+0x1b0/0xaf0
[c00000033e1bfa50] [c0000000009b4514] sys_ioctl+0x144/0x190
[c00000033e1bfab0] [c000000000034330] system_call_exception+0x170/0x370
[c00000033e1bfe50] [c00000000000d05c] system_call_vectored_common+0x15c/0x2ec

Fix this by taking a srcu read lock around kvmppc_h_page_init().

Fixes: 2d34d1c3bbfd ("KVM: PPC: Book3S HV: Implement virtual mode H_PAGE_INIT handler")
Cc: stable@vger.kernel.org # 5.2+
Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20261012082922.218799-5-gautam@linux.ibm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/powerpc/kvm/book3s_hv.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -1368,9 +1368,11 @@ int kvmppc_pseries_do_hcall(struct kvm_v
 			ret = kvmhv_copy_tofrom_guest_nested(vcpu);
 		break;
 	case H_PAGE_INIT:
+		idx = srcu_read_lock(&kvm->srcu);
 		ret = kvmppc_h_page_init(vcpu, kvmppc_get_gpr(vcpu, 4),
 					 kvmppc_get_gpr(vcpu, 5),
 					 kvmppc_get_gpr(vcpu, 6));
+		srcu_read_unlock(&kvm->srcu, idx);
 		break;
 	case H_SVM_PAGE_IN:
 		ret = H_UNSUPPORTED;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 417/555] KVM: PPC: Book3S HV: XICS: Avoid NULL ptr deref in kvmppc_xive_cleanup_vcpu()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (415 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 416/555] KVM: PPC: Book3S HV: Take SRCU read lock around kvmppc_h_page_init() call Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 418/555] KVM: PPC: Book3S HV: XICS: Update irq_type for cleanup to work Greg Kroah-Hartman
                   ` (137 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Gautam Menghani,
	Ritesh Harjani (IBM), Madhavan Srinivasan

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Gautam Menghani <gautam@linux.ibm.com>

commit 7279692d70f3e399b3dd2d07ffa365e9f533761f upstream.

In kvmppc_xive_connect_vcpu() if there is a failure before
xc->vp_ipi_data is setup, it can result in a NULL pointer dereference in
kvmppc_xive_cleanup_vcpu() when accessing the MMIO page in
xive_vm_esb_load(). Fix this by adding a check before masking
the VP IPI before accessing the MMIO pages.

Fixes: 5af50993850a ("KVM: PPC: Book3S HV: Native usage of the XIVE interrupt controller")
Cc: stable@vger.kernel.org # 4.12+
Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20261012082922.218799-4-gautam@linux.ibm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/powerpc/kvm/book3s_xive.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/arch/powerpc/kvm/book3s_xive.c
+++ b/arch/powerpc/kvm/book3s_xive.c
@@ -1820,7 +1820,8 @@ void kvmppc_xive_cleanup_vcpu(struct kvm
 	kvmppc_xive_disable_vcpu_interrupts(vcpu);
 
 	/* Mask the VP IPI */
-	xive_vm_esb_load(&xc->vp_ipi_data, XIVE_ESB_SET_PQ_01);
+	if (xc->vp_ipi_data.eoi_mmio)
+		xive_vm_esb_load(&xc->vp_ipi_data, XIVE_ESB_SET_PQ_01);
 
 	/* Free escalations */
 	for (i = 0; i < KVMPPC_XIVE_Q_COUNT; i++) {



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 418/555] KVM: PPC: Book3S HV: XICS: Update irq_type for cleanup to work
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (416 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 417/555] KVM: PPC: Book3S HV: XICS: Avoid NULL ptr deref in kvmppc_xive_cleanup_vcpu() Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 419/555] mm/damon/core: reset watermark wait state on each iteration Greg Kroah-Hartman
                   ` (136 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Gautam Menghani,
	Ritesh Harjani (IBM), Madhavan Srinivasan

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Gautam Menghani <gautam@linux.ibm.com>

commit b9d9a8741752c5b42c65b1c8dffba867889b74e5 upstream.

In kvmppc_xive_connect_vcpu(), if any failures are encountered, the
control flow jumps to the 'bail' label where kvmppc_xive_cleanup_vcpu()
is called. This cleanup function exits prematurely since
vcpu->arch.irq_type is set to KVMPPC_IRQ_DEFAULT at this point. This ends
up resulting in wasted memory.

Fix this by setting irq_type to KVMPPC_IRQ_XICS before vcpu configuration
starts. This makes XICS initialization symmetrical to XIVE
initialization done in kvmppc_xive_native_connect_vcpu().

Fixes: 5af50993850a ("KVM: PPC: Book3S HV: Native usage of the XIVE interrupt controller")
Cc: stable@vger.kernel.org # 4.12+
Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20261012082922.218799-3-gautam@linux.ibm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/powerpc/kvm/book3s_xive.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/powerpc/kvm/book3s_xive.c
+++ b/arch/powerpc/kvm/book3s_xive.c
@@ -1940,6 +1940,7 @@ int kvmppc_xive_connect_vcpu(struct kvm_
 	xc->vp_id = vp_id;
 	xc->mfrr = 0xff;
 	xc->valid = true;
+	vcpu->arch.irq_type = KVMPPC_IRQ_XICS;
 
 	r = xive_native_get_vp_info(xc->vp_id, &xc->vp_cam, &xc->vp_chip_id);
 	if (r)
@@ -2028,7 +2029,6 @@ bail:
 		return r;
 	}
 
-	vcpu->arch.irq_type = KVMPPC_IRQ_XICS;
 	return 0;
 }
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 419/555] mm/damon/core: reset watermark wait state on each iteration
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (417 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 418/555] KVM: PPC: Book3S HV: XICS: Update irq_type for cleanup to work Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 420/555] mm/damon/tests/sysfs-kunit: fix leaked pid reference in add_targets test Greg Kroah-Hartman
                   ` (135 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Aveline Noir, SJ Park, Andrew Morton,
	Wang Xiaolei

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Aveline Noir <jm5905938@gmail.com>

commit 5fe092741502770107a0be7b3885ce55f7761f01 upstream.

Patch series "mm/damon: fix watermark state, kunit pid leak and selftest
fake pass".

Three hotfixes for core, kunit and selftest.  Fix kdamond deactivation
from missed watermark reset with patch 1.  Fix pid leak in kunit test
with patch 2.  Fix a selftest wrongly passing when it should skip, with
patch 3.

Note for reviewers.  This series is a collection of fixes that were
initially developed by different people.  Changelog is in each patch.


This patch (of 3):

Found while reviewing the DAMON source code that if an online commit
removes all schemes while kdamond is waiting for watermark activation,
the scheme loop becomes empty but min_wait_time keeps the previous
positive value.  kdamond then keeps sleeping instead of resuming
monitoring without schemes.

The way to wake up the kdamond again without DAMON is bit complicated.
Install a scheme having watermarks that can activate the kdamond again,
and remove the scheme again.  Doable but cumbersome and complicated.

Initialize min_wait_time and init_wait_time on each loop iteration so
the wait is calculated from the current schemes and an empty scheme
list resumes monitoring.

Link: https://lore.kernel.org/20261102144627.88843-1-sj@kernel.org
Link: https://lore.kernel.org/20261102144627.88843-2-sj@kernel.org
Fixes: da87878010e5 ("mm/damon/sysfs: support online inputs update")
Signed-off-by: Aveline Noir <jm5905938@gmail.com>
Signed-off-by: SJ Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: SJ Park <sj@kernel.org>
Cc: Wang Xiaolei <xiaoleiwangxiaolei@gmail.com>
Cc: <stable@vger.kernel.org> # 5.19.x
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 mm/damon/core.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -2077,10 +2077,11 @@ static int kdamond_wait_activation(struc
 {
 	struct damos *s;
 	unsigned long wait_time;
-	unsigned long min_wait_time = 0;
-	bool init_wait_time = false;
 
 	while (!kdamond_need_stop(ctx)) {
+		unsigned long min_wait_time = 0;
+		bool init_wait_time = false;
+
 		damon_for_each_scheme(s, ctx) {
 			wait_time = damos_wmark_wait_us(s);
 			if (!init_wait_time || wait_time < min_wait_time) {



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 420/555] mm/damon/tests/sysfs-kunit: fix leaked pid reference in add_targets test
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (418 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 419/555] mm/damon/core: reset watermark wait state on each iteration Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 421/555] mm/filemap: stop fault-around when the walk steps back Greg Kroah-Hartman
                   ` (134 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Wang Xiaolei, SJ Park, Andrew Morton,
	Michal Hocko, Mike Rapoport, Suren Baghdasaryan, Vlastimil Babka,
	Liam R. Howlett, Brendan Higgins, David Gow, Aveline Noir

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Wang Xiaolei <xiaoleiwangxiaolei@gmail.com>

commit 9d2cc214935ad78b8f54bf886f0b4e3f387fa44f upstream.

damon_sysfs_test_add_targets() creates its monitoring context with
damon_new_ctx(), which leaves ctx->ops zero-initialized.  Since
DAMON_OPS_VADDR is zero, damon_target_has_pid() returns true for the
context, and damon_sysfs_add_targets() therefore calls
damon_set_target_pid() for each target it adds.  That function grabs a
reference to the target's struct pid via find_get_pid().

The test then tears the context down with damon_destroy_ctx(), which
releases such a reference from ctx->ops.cleanup_target().  For the vaddr
operations set that callback is damon_va_cleanup_target(), and it is the
only place where the reference is put.  The test never selects an
operations set, though, so cleanup_target is NULL and both references --
one for each of the two damon_sysfs_add_targets() calls -- are leaked on
every run of the test.  Running the test with CONFIG_DEBUG_KMEMLEAK
enabled reports the leaked struct pid objects as unreferenced.

Fix this by selecting the vaddr operations set for the context before
adding the targets, mirroring what the sysfs interface does.
damon_select_ops() fails if the vaddr operations set is not registered,
in which case the test cannot exercise the pid handling and skips
itself.

Link: https://lore.kernel.org/20261102144627.88843-3-sj@kernel.org
Fixes: b8ee5575f763 ("mm/damon/sysfs-test: add a unit test for damon_sysfs_set_targets()")
Signed-off-by: Wang Xiaolei <xiaoleiwangxiaolei@gmail.com>
Signed-off-by: SJ Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: SJ Park <sj@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: "Liam R. Howlett" <liam@infradead.org>
Cc: Brendan Higgins <brendan.higgins@linux.dev>
Cc: David Gow <davidgow@davidgow.net>
Cc: Aveline Noir <jm5905938@gmail.com>
Cc: <stable@vger.kernel.org> # 6.7.x
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 mm/damon/tests/sysfs-kunit.h |    9 +++++++++
 1 file changed, 9 insertions(+)

--- a/mm/damon/tests/sysfs-kunit.h
+++ b/mm/damon/tests/sysfs-kunit.h
@@ -81,6 +81,15 @@ static void damon_sysfs_test_add_targets
 		kunit_skip(test, "ctx alloc fail");
 	}
 
+	if (damon_select_ops(ctx, DAMON_OPS_VADDR)) {
+		damon_destroy_ctx(ctx);
+		kfree(sysfs_targets->targets_arr);
+		kfree(sysfs_targets);
+		kfree(sysfs_target->regions);
+		kfree(sysfs_target);
+		kunit_skip(test, "vaddr ops not registered");
+	}
+
 	damon_sysfs_add_targets(ctx, sysfs_targets);
 	KUNIT_EXPECT_EQ(test, 1u, nr_damon_targets(ctx));
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 421/555] mm/filemap: stop fault-around when the walk steps back
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (419 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 420/555] mm/damon/tests/sysfs-kunit: fix leaked pid reference in add_targets test Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 422/555] mm/khugepaged: dont map folios that are not uptodate in MADV_COLLAPSE Greg Kroah-Hartman
                   ` (133 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jose Fernandez (Anthropic),
	Andrew Morton, Jan Kara, Matthew Wilcox (Oracle),
	David Hildenbrand, Krystian Kaniewski, Pedro Falcato

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jose Fernandez (Anthropic) <jose.fernandez@linux.dev>

commit cf5518aa1832d82b391ac2492863ae6a7315827c upstream.

filemap_map_pages() can dereference a PTE pointer outside the page table
it locked.  KASAN has reported this as a use-after-free read [1].  The
same path can also write out of bounds.  When the stray entry reads as
none, the fault-around loop maps a page there with set_pte_range().

Its fault-around loop walks the page cache and moves vmf->pte by the
change in index.  A lower index moves it back.  xas_find() can step back
to a lower index when a multi-index entry is split during the walk.

[1] fixes xas_find(), but the loop still relies on the walk never stepping
back.  Stop the fault-around when the walk steps back.  ->fault() maps the
faulting page if the loop did not.

Link: https://lore.kernel.org/20261031-jf-mm-filemap-map-pages-lower-bound-v2-1-21029744e589@linux.dev
Link: https://lore.kernel.org/20260904121301.200049-1-krystianmkaniewski@gmail.com [1]
Fixes: 6b24ca4a1a8d ("mm: Use multi-index entries in the page cache")
Signed-off-by: Jose Fernandez (Anthropic) <jose.fernandez@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Krystian Kaniewski <krystianmkaniewski@gmail.com>
Cc: Pedro Falcato <pfalcato@suse.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 mm/filemap.c |    7 +++++++
 1 file changed, 7 insertions(+)

--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -3684,6 +3684,13 @@ vm_fault_t filemap_map_pages(struct vm_f
 	do {
 		unsigned long end;
 
+		/* A lower index could move vmf->pte out of its page table. */
+		if (unlikely(xas.xa_index < last_pgoff)) {
+			folio_unlock(folio);
+			folio_put(folio);
+			break;
+		}
+
 		addr += (xas.xa_index - last_pgoff) << PAGE_SHIFT;
 		vmf->pte += xas.xa_index - last_pgoff;
 		last_pgoff = xas.xa_index;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 422/555] mm/khugepaged: dont map folios that are not uptodate in MADV_COLLAPSE
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (420 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 421/555] mm/filemap: stop fault-around when the walk steps back Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 423/555] mm/migrate: move NR_FILE_THPS on cross-node migration Greg Kroah-Hartman
                   ` (132 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Chris Mason, Lorenzo Stoakes (ARM),
	Hugh Dickins, Zi Yan, Zach OKeefe, SJ Park, Baolin Wang,
	Lance Yang, Kiryl Shutsemau (Meta), Pedro Falcato,
	David Hildenbrand (Arm)

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: David Hildenbrand (Arm) <david@kernel.org>

commit 043a2260b96ffc13121a1dd65282e67eb2e1d8a8 upstream.

madvise(MADV_COLLAPSE) can map PMD-sized pagecache folios that are not
uptodate. For example, shmem fallocate() can put such folios into the
page cache.

collapse_file() already refuses to proceed with folios that are not
uptodate. Let's just do the same in try_collapse_pte_mapped_thp() and skip
such folios, leaving handling to the page faults.

Note that collapse_file() effectively clears shmem folios through
shmem_get_folio(); let's keep this fix simple and simply let the page
fault path deal with that.

Fixes: 34488399fa08 ("mm/madvise: add file and shmem support to MADV_COLLAPSE")
Reported-by: Chris Mason <mason@kernel.org>
Cc: stable@vger.kernel.org
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Acked-by: Hugh Dickins <hughd@google.com>
Acked-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Zach O'Keefe <zokeefe@google.com>
Reviewed-by: SJ Park <sj@kernel.org>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Reviewed-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Link: https://patch.msgid.link/20261105-set_huge_pmd_uptodate-v1-1-a78d8a1b7117@kernel.org
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 mm/khugepaged.c |    6 ++++++
 1 file changed, 6 insertions(+)

--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1547,6 +1547,12 @@ int collapse_pte_mapped_thp(struct mm_st
 		goto drop_folio;
 	}
 
+	/* Leave any uninitialized folios to the page fault path. */
+	if (!folio_test_uptodate(folio)) {
+		result = SCAN_FAIL;
+		goto drop_folio;
+	}
+
 	result = find_pmd_or_thp_or_none(mm, haddr, &pmd);
 	switch (result) {
 	case SCAN_SUCCEED:



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 423/555] mm/migrate: move NR_FILE_THPS on cross-node migration
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (421 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 422/555] mm/khugepaged: dont map folios that are not uptodate in MADV_COLLAPSE Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 424/555] PPC32: Fix hard_irq_disable to follow tracing and lockdep state Greg Kroah-Hartman
                   ` (131 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Ridong Chen, Andrew Morton,
	David Hildenbrand (Arm), Zi Yan, Matthew Brost, Joshua Hahn,
	Byungchul Park, Gregory Price, Ying Huang, Alistair Popple,
	Matthew Wilcox (Oracle), Garg, Shivank

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ridong Chen <chenridong@xiaomi.com>

commit a2108a958143de74b4e5ddca12b01f05ecd030f9 upstream.

When a page cache folio is migrated to another node,
__folio_migrate_mapping() moves the per-node and per-memcg counters
that are keyed off the folio's node: NR_FILE_PAGES, NR_SHMEM,
NR_SHMEM_THPS, NR_SWAPCACHE and NR_FILE_DIRTY.  NR_FILE_THPS is not
moved, although __filemap_add_folio() charges it to the source node and
filemap_unaccount_folio() takes it off whatever node the folio lives on
when it is removed.

Commit 0b52c420350e ("mm: fix shmem THP counters on migration") added
the NR_SHMEM_THPS case but not its file-backed counterpart.  Now that
ext4, xfs, btrfs and erofs can all have PMD-sized page cache folios,
migrating them via NUMA balancing, mbind(), migratepages, demotion or
memory offlining leaks FileHugePages on the source node and underflows
it on the destination, in both /sys/devices/system/node/nodeN/meminfo
and memory.numa_stat.  The global value is unaffected, which is why this
went unnoticed.

Reproducer, on a 2-node QEMU guest with THP set to "always":

  1. read a 256M ext4 file through a MADV_HUGEPAGE mapping while bound
     to node 0, so its page cache is 128 PMD-sized folios on node 0;
  2. move the mapping to node 1 with mbind(MPOL_MF_MOVE);
  3. unmap the file and drop its page cache.

nr_file_hugepages in /sys/devices/system/node/nodeN/vmstat after each
step (in units of PMD-sized folios):

                    without this patch     with this patch
                     node0     node1       node0     node1
  1. cached           128         0         128         0
  2. migrated         128         0           0       128
  3. dropped          128         0 (*)       0         0

  (*) the counter has underflowed to -128; negative values read as 0.

Without the patch the 128 folios stay accounted to node 0 forever, and
every further round adds another 128.  The same happens to the per-memcg
per-node counter: after step 3, memory.stat of the cgroup shows
"file_thp 0", while memory.numa_stat still shows
"file_thp N0=268435456 N1=0".  With the patch both are 0.

Move NR_FILE_THPS together with NR_FILE_PAGES, using the same condition
filemap_unaccount_folio() uses to take it off, so that THPs in the swap
cache are left alone.

Link: https://lore.kernel.org/20261025110209.4105994-1-ridong.chen@linux.dev
Fixes: d68eccad3706 ("mm/filemap: Allow large folios to be added to the page cache")
Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: Byungchul Park <byungchul@sk.com>
Cc: Gregory Price <gourry@gourry.net>
Cc: Ying Huang <ying.huang@linux.alibaba.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: "Garg, Shivank" <shivankg@amd.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 mm/migrate.c |    4 ++++
 1 file changed, 4 insertions(+)

--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -618,6 +618,10 @@ static int __folio_migrate_mapping(struc
 				__mod_lruvec_state(old_lruvec, NR_SHMEM_THPS, -nr);
 				__mod_lruvec_state(new_lruvec, NR_SHMEM_THPS, nr);
 			}
+		} else if (!folio_test_swapbacked(folio) &&
+			   folio_test_pmd_mappable(folio)) {
+			mod_lruvec_state(old_lruvec, NR_FILE_THPS, -nr);
+			mod_lruvec_state(new_lruvec, NR_FILE_THPS, nr);
 		}
 #ifdef CONFIG_SWAP
 		if (folio_test_swapcache(folio)) {



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 424/555] PPC32: Fix hard_irq_disable to follow tracing and lockdep state
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (422 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 423/555] mm/migrate: move NR_FILE_THPS on cross-node migration Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 425/555] qca_spi: Avoid unsequenced accesses to jiffies in qcaspi_netdev_tx_timeout() Greg Kroah-Hartman
                   ` (130 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Ritesh Harjani (IBM),
	Shrikanth Hegde, Mukesh Kumar Chaurasiya (IBM),
	Madhavan Srinivasan

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Shrikanth Hegde <sshegde@linux.ibm.com>

commit 2672bdcc7857073722c4772831a24b14832ee88a upstream.

On PPC32, the code for hard_irq_disable has diverged and it doesn't
do lockdep/tracing anymore, leading to use of both local_irq_disable
and hard_irq_disable on PPC32 to overcome those.

That is un-necessary, instead simply calling local_irq_disable is
enough. It disables EE bit and does lockdep tracking.

Subsequent patch uses this API in KVM code to avoid the warnings.
Wider use of it is possible, but it will be taken subsequently.

Cc: stable@vger.kernel.org # v7.2+
Suggested-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Reviewed-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20261118051419.783878-2-sshegde@linux.ibm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/powerpc/include/asm/hw_irq.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/powerpc/include/asm/hw_irq.h
+++ b/arch/powerpc/include/asm/hw_irq.h
@@ -464,7 +464,7 @@ static inline bool arch_irqs_disabled(vo
 	return arch_irqs_disabled_flags(arch_local_save_flags());
 }
 
-#define hard_irq_disable()		arch_local_irq_disable()
+#define hard_irq_disable()		local_irq_disable()
 
 static inline bool arch_irq_disabled_regs(struct pt_regs *regs)
 {



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 425/555] qca_spi: Avoid unsequenced accesses to jiffies in qcaspi_netdev_tx_timeout()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (423 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 424/555] PPC32: Fix hard_irq_disable to follow tracing and lockdep state Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 426/555] RDMA/mlx5: Fix DevX umem page size truncation for pages >= 4G Greg Kroah-Hartman
                   ` (129 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Nathan Chancellor, Stefan Wahren,
	Nick Desaulniers, Jakub Kicinski

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Nathan Chancellor <nathan@kernel.org>

commit 695d0824cb6b27ff1a1cdeabb2d5138f00b15251 upstream.

After a recent improvement in clang to warn on unsequenced accesses to
volatile variables [1], an instance appears in
qcaspi_netdev_tx_timeout(), which can break the build with
CONFIG_WERROR=y / W=e:

  drivers/net/ethernet/qualcomm/qca_spi.c:805:16: error: unsequenced accesses to volatile qualified 'jiffies' [-Werror,-Wunsequenced]
    805 |                     jiffies, jiffies - dev_trans_start(dev));
        |                     ~~~~~~~  ^

Per C11 5.1.2.3.2, accessing a volatile object is a side effect. Per C11
6.5.2, unsequenced side effects on the same scalar object are undefined
behavior. Per C11 6.5.2.2.10/12, the evaluation of arguments in a
function call is indeterminately sequenced, meaning any side effects in
the arguments are unsequenced.

Printing jiffies on its own is not that useful for debugging transmit
timeouts, so get rid of it to clear up the warning.

Cc: stable@vger.kernel.org
Fixes: 291ab06ecf67 ("net: qualcomm: new Ethernet over SPI driver for QCA7000")
Closes: https://github.com/ClangBuiltLinux/linux/issues/2197
Link: https://github.com/llvm/llvm-project/commit/955715460eaf9188c241c74750637fc82dfcc423 [1]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Acked-by: Stefan Wahren <wahrenst@gmx.net>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Link: https://patch.msgid.link/20261115-qca_spi-wunsequenced-v2-1-8cf32f12d546@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/ethernet/qualcomm/qca_spi.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -795,8 +795,8 @@ qcaspi_netdev_tx_timeout(struct net_devi
 {
 	struct qcaspi *qca = netdev_priv(dev);
 
-	netdev_info(qca->net_dev, "Transmit timeout at %ld, latency %ld\n",
-		    jiffies, jiffies - dev_trans_start(dev));
+	netdev_info(qca->net_dev, "Transmit timeout, latency %ld\n",
+		    jiffies - dev_trans_start(dev));
 	qca->net_dev->stats.tx_errors++;
 	/* Trigger tx queue flush and QCA7000 reset */
 	qca->sync = QCASPI_SYNC_UNKNOWN;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 426/555] RDMA/mlx5: Fix DevX umem page size truncation for pages >= 4G
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (424 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 425/555] qca_spi: Avoid unsequenced accesses to jiffies in qcaspi_netdev_tx_timeout() Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 427/555] RDMA/mlx5: Skip vport context query on FW without ib_virt support Greg Kroah-Hartman
                   ` (128 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Dezhen Lu, Jason Gunthorpe,
	Leon Romanovsky

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Dezhen Lu <dezhen.lu@student.uni-tuebingen.de>

commit b5c11bf9759834731440806708143c40638dc2ff upstream.

devx_umem_find_best_pgsize() computes the page size in an unsigned long
but returns it as unsigned int, and devx_umem_reg_cmd_alloc() stores it
in an unsigned int. When the DMA mapping of the umem is contiguous and
aligned to 4 GiB or more, and the umem length is a multiple of that
size, ib_umem_find_best_pgoff() selects a page size >= 2^32. Since the
value is a power of two, the truncation turns it into 0 and the
registration fails with -EINVAL.

The umem log_page_size field is 5 bits wide on top of
MLX5_ADAPTER_PAGE_SHIFT, so the command can encode these page sizes.

Seen on two GH200 nodes (ConnectX-7, firmware 32.38.3056 and
32.43.1014) with a dma-buf exported from cudaMalloc memory: registering
4 GiB or 8 GiB umems at 4 GiB-aligned offsets of the dma-buf fails with
EINVAL every time, while 2 GiB umems at the same offsets and
ibv_reg_dmabuf_mr() of the same ranges succeed. Restricting the user
pgsz_bitmap to <= 2 GiB makes all of them succeed.

Other large physically contiguous buffers, such as a 16 GiB hugetlb
page on an arm64 kernel with 64K base pages, should hit the same path.

Use unsigned long for the page size, as commit f0c2427412b4
("RDMA/mlx5: Fix page_size variable overflow") already did for the MR
paths.

The bug was found by an AI coding assistant (Claude Opus 5.5, Anthropic)
during an audit of 32-bit truncations of page sizes and offsets in
drivers/infiniband/core and drivers/infiniband/hw/mlx5. The assistant
also wrote the reproducer and this patch. The reproducer was run on the
GH200 nodes described above.

Fixes: 7610ab57de56 ("RDMA/mlx5: Allow larger pages in DevX umem")
Cc: stable@vger.kernel.org
Signed-off-by: Dezhen Lu <dezhen.lu@student.uni-tuebingen.de>
Link: https://patch.msgid.link/20261103142804.67210-1-dezhen.lu@student.uni-tuebingen.de
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/infiniband/hw/mlx5/devx.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/drivers/infiniband/hw/mlx5/devx.c
+++ b/drivers/infiniband/hw/mlx5/devx.c
@@ -2232,8 +2232,8 @@ static int devx_umem_get(struct mlx5_ib_
 	return 0;
 }
 
-static unsigned int devx_umem_find_best_pgsize(struct ib_umem *umem,
-					       unsigned long pgsz_bitmap)
+static unsigned long devx_umem_find_best_pgsize(struct ib_umem *umem,
+						unsigned long pgsz_bitmap)
 {
 	unsigned long page_size;
 
@@ -2271,7 +2271,7 @@ static int devx_umem_reg_cmd_alloc(struc
 				   int access)
 {
 	unsigned long pgsz_bitmap;
-	unsigned int page_size;
+	unsigned long page_size;
 	__be64 *mtt;
 	void *umem;
 	int ret;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 427/555] RDMA/mlx5: Skip vport context query on FW without ib_virt support
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (425 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 426/555] RDMA/mlx5: Fix DevX umem page size truncation for pages >= 4G Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 428/555] RDMA/rtrs: Register client event handler after capability check Greg Kroah-Hartman
                   ` (127 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Tony Battersby, Moshe Shemesh,
	Edward Srouji, Leon Romanovsky

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Moshe Shemesh <moshe@nvidia.com>

commit e7732ec135b501e87ab060d992b3b5f2ec4396c9 upstream.

Since commit b02289b3d60f ("RDMA: Validate grh_required when handling
AVs"), mlx5_port_immutable() unconditionally issues
QUERY_HCA_VPORT_CONTEXT on InfiniBand ports to read grh_required.
Devices that do not support the InfiniBand virtualization interface
(ib_virt cleared) are not guaranteed to implement this command. For
example, Connect-IB with FW 10.10.5020 rejects it and mlx5_ib fails to
probe:

  mlx5_core 0000:01:00.0: mlx5_cmd_out_err:810:(pid 731): QUERY_HCA_VPORT_CONTEXT(0x762) op_mod(0x0) failed, status bad operation(0x2), syndrome (0x3590f5), err(-22)
  infiniband mlx5_0: Couldn't create per-port data
  mlx5_ib.rdma: probe of mlx5_core.rdma.0 failed with error -12

All other HCA vport context users in mlx5_ib are already gated on
ib_virt, either directly, as in set_has_smi_cap(),
mlx5_ib_get_plane_num() and mlx5_ib_modify_port(), or via
mlx5_use_mad_ifc(), which selects MAD_IFC for port queries when
ib_virt is not supported.

Skipping the query loses nothing. grh_required indicates a GID-based
vport, which only exists with InfiniBand virtualization. Without
ib_virt the port is always LID-based and the field is zero, even on
firmware that accepts the command. This also matches the behavior
before b02289b3d60f, when grh_required was filled in only by
mlx5_query_hca_port() and was never set on the MAD_IFC path.

Fixes: b02289b3d60f ("RDMA: Validate grh_required when handling AVs")
Cc: stable@vger.kernel.org
Reported-by: Tony Battersby <tonyb@cybernetics.com>
Closes: https://lore.kernel.org/all/064dfa67-8fd4-40f0-b925-6d1e0cd42e6a@cybernetics.com/
Tested-by: Tony Battersby <tonyb@cybernetics.com>
Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
Signed-off-by: Edward Srouji <edwards@nvidia.com>
Link: https://patch.msgid.link/20261112-moshe-ib-virt-guard-v1-1-6d2caf8bdb1b@nvidia.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/infiniband/hw/mlx5/main.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -3316,7 +3316,8 @@ static int mlx5_port_immutable(struct ib
 	if (err)
 		return err;
 
-	if (ll == IB_LINK_LAYER_INFINIBAND) {
+	if (ll == IB_LINK_LAYER_INFINIBAND &&
+	    MLX5_CAP_GEN(dev->mdev, ib_virt)) {
 		if (ibdev->type == RDMA_DEVICE_TYPE_SMI)
 			port_num = smi_to_native_portnum(dev, port_num);
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 428/555] RDMA/rtrs: Register client event handler after capability check
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (426 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 427/555] RDMA/mlx5: Skip vport context query on FW without ib_virt support Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 429/555] RDMA/siw: Fix use-after-free in siw_mem_id2obj() Greg Kroah-Hartman
                   ` (126 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jaeyeong Lee, Jack Wang,
	Leon Romanovsky

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jaeyeong Lee <lee@jaeyeong.cc>

commit 90d95fbc1bcc8464f6d8c6891c62bad4c0dc2d58 upstream.

rtrs_clt_ib_dev_init() registers dev->event_handler before checking
IB_DEVICE_MEM_MGT_EXTENSIONS. If the device does not provide that
capability, init returns -ENOTSUPP and rtrs_ib_dev_find_or_add() frees
dev through out_free_pd without calling the deinit callback. The embedded
event handler therefore remains on the IB device's list after its storage
has been freed.

A later IB event walks the dangling list entry and accesses freed memory.
The issue was found by static analysis. A focused out-of-tree test module
on an x86_64 QEMU/KASAN kernel temporarily cleared only
IB_DEVICE_MEM_MGT_EXTENSIONS on a SIW device, exercised the real
rtrs_clt_ib_dev_init() callback through rtrs_ib_dev_find_or_add(), restored
the capabilities, and dispatched IB_EVENT_DEVICE_FATAL. KASAN reported
an 8-byte slab-use-after-free read in ib_dispatch_event_clients(), with
both the allocation and free originating in rtrs_ib_dev_find_or_add().

Move the capability check before event handler registration. The check is
a prerequisite for successful client initialization. Registration cannot
fail and init returns success immediately afterwards, so every installed
handler is now owned by a successfully initialized device and is removed
by the existing deinit callback.

Fixes: 667db86bcbe8 ("RDMA/rtrs: Register ib event handler")
Cc: stable@vger.kernel.org
Signed-off-by: Jaeyeong Lee <lee@jaeyeong.cc>
Link: https://patch.msgid.link/179378222423.73361.3247716499619173751@jaeyeong.cc
Acked-by: Jack Wang <jinpu.wang@cloud.ionos.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/infiniband/ulp/rtrs/rtrs-clt.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
@@ -3167,16 +3167,16 @@ void rtrs_clt_ib_event_handler(struct ib
 
 static int rtrs_clt_ib_dev_init(struct rtrs_ib_dev *dev)
 {
-	INIT_IB_EVENT_HANDLER(&dev->event_handler, dev->ib_dev,
-			      rtrs_clt_ib_event_handler);
-	ib_register_event_handler(&dev->event_handler);
-
 	if (!(dev->ib_dev->attrs.device_cap_flags &
 	      IB_DEVICE_MEM_MGT_EXTENSIONS)) {
 		pr_err("Memory registrations not supported.\n");
 		return -ENOTSUPP;
 	}
 
+	INIT_IB_EVENT_HANDLER(&dev->event_handler, dev->ib_dev,
+			      rtrs_clt_ib_event_handler);
+	ib_register_event_handler(&dev->event_handler);
+
 	return 0;
 }
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 429/555] RDMA/siw: Fix use-after-free in siw_mem_id2obj()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (427 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 428/555] RDMA/rtrs: Register client event handler after capability check Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 430/555] RDMA/srpt: bound the indirect descriptor table to the IU Greg Kroah-Hartman
                   ` (125 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Deep Shah, Leon Romanovsky

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Deep Shah <deepshah146@gmail.com>

commit a70672b9b3ac7d8945f67cd199c1bb680d5d5f64 upstream.

siw_mem_id2obj() finds a siw_mem with xa_load() under rcu_read_lock()
and then takes a reference with kref_get_unless_zero(). This is only
safe if the object stays allocated until RCU readers are done with it.
siw_free_mem() frees it with kfree() as soon as the last reference is
dropped, so a lookup that races with the final put reads freed memory.

This happens when an MR is deregistered while an incoming RDMA WRITE
looks up its STag:

  BUG: KASAN: slab-use-after-free in siw_mem_id2obj+0xe5/0x310
  Read of size 4 at addr ff110001042aed88 by task repro-rcu2/90
  Call Trace:
   <IRQ>
   siw_mem_id2obj+0xe5/0x310
   siw_proc_write+0x282/0x430
   siw_tcp_rx_data+0x12e/0xbf0
   __tcp_read_sock+0x12c/0x440
   siw_qp_llp_data_ready+0x147/0x260
  Allocated by task 89:
   siw_mr_add_mem+0xb2/0x2a0
   siw_reg_user_mr+0x19f/0x380
   ib_uverbs_reg_mr+0x2a7/0x4c0
  Freed by task 89:
   kfree+0x301/0x530
   siw_dereg_mr+0x31/0x50
   ib_dereg_mr_user+0xb9/0x200

Free siw_mem with kfree_rcu(). A lookup that loses the race then sees
a zero refcount and fails. The umem or PBL is still released at the
last put, since a failed lookup never touches it.

Fixes: 2251334dcac9 ("rdma/siw: application buffer management")
Cc: stable@vger.kernel.org
Signed-off-by: Deep Shah <deepshah146@gmail.com>
Link: https://patch.msgid.link/20261102064437.23976-1-deepshah146@gmail.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/infiniband/sw/siw/siw.h     |    1 +
 drivers/infiniband/sw/siw/siw_mem.c |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

--- a/drivers/infiniband/sw/siw/siw.h
+++ b/drivers/infiniband/sw/siw/siw.h
@@ -156,6 +156,7 @@ struct siw_mem {
 		void *mem_obj;
 	};
 	struct ib_pd *pd;
+	struct rcu_head rcu;
 };
 
 struct siw_mr {
--- a/drivers/infiniband/sw/siw/siw_mem.c
+++ b/drivers/infiniband/sw/siw/siw_mem.c
@@ -141,7 +141,7 @@ void siw_free_mem(struct kref *ref)
 		else
 			kfree(mem->pbl);
 	}
-	kfree(mem);
+	kfree_rcu(mem, rcu);
 }
 
 /*



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 430/555] RDMA/srpt: bound the indirect descriptor table to the IU
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (428 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 429/555] RDMA/siw: Fix use-after-free in siw_mem_id2obj() Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 431/555] RDMA/srpt: reject zero-length buffer descriptors Greg Kroah-Hartman
                   ` (124 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Yehyeong Lee, Bart Van Assche,
	Leon Romanovsky

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Yehyeong Lee <yhlee@isslab.korea.ac.kr>

commit 82d46dedf750addfad5480f79165cacb81c89650 upstream.

srpt_get_desc_tbl() takes the number of INDIRECT descriptors from
idb->table_desc.len, which the initiator controls, and checks it only
against data_out_desc_cnt + data_in_desc_cnt, two more initiator fields.
Both are u8, so the pair admits up to 510 descriptors, and nothing
compares the table against the receive IU it has to live in.
srpt_alloc_rw_ctxs() then walks idb->desc_list for that many entries.

With the default srp_max_req_size of 8276 the table fits as long as the
additional CDB is short, but ADDITIONAL CDB LENGTH is an initiator field
too, and at its maximum of 252 bytes 510 descriptors end at
48 + 252 + 20 + 510 * 16 = 8480, which is past the end of the object.

  BUG: KASAN: slab-out-of-bounds in srpt_alloc_rw_ctxs+0x631/0x870
  Read of size 4 at addr ffff888002d6a05c by task kunit_try_catch/43

  CPU: 0 UID: 0 PID: 43 Comm: kunit_try_catch Tainted: G                 N   7.3.0-12378-g6fba331225f5-dirty #1 PREEMPT(lazy)
  Tainted: [N]=TEST
  Call Trace:
   <TASK>
   dump_stack_lvl+0x3f/0x50
   print_report+0xcd/0x620
   ? alloc_pages_node_noprof+0xa2/0x140
   ? srpt_alloc_rw_ctxs+0x631/0x870
   kasan_report+0xde/0x110
   ? srpt_alloc_rw_ctxs+0x631/0x870
   srpt_alloc_rw_ctxs+0x631/0x870
   srpt_test_parse+0x114/0x580
   ? __pfx_srpt_test_ctx_common.constprop.0+0x10/0x10
   ? __pfx_srpt_test_parse+0x10/0x10
   ? srpt_test_ctx_init.constprop.0+0x4cb/0x6c0
   srpt_test_run.constprop.0+0xc1/0xa60
   ? pick_task_fair+0x126/0x1950
   ? __pfx_srpt_test_run.constprop.0+0x10/0x10
   ? update_curr.constprop.0+0x4a/0x390
   ? __set_cpus_allowed_ptr+0x181/0x240
   ? __pfx_read_tsc+0x10/0x10
   ? ktime_get_ts64+0x192/0x250
   kunit_try_run_case+0x1ca/0x4b0
   ? __pfx_kunit_try_run_case+0x10/0x10
   ? kthread_affine_node+0x24b/0x370
   ? __pfx_kthread_affine_node+0x10/0x10
   ? __pfx_kunit_try_run_case+0x10/0x10
   ? __pfx_kunit_generic_run_threadfn_adapter+0x10/0x10
   kunit_generic_run_threadfn_adapter+0x7b/0xe0
   kthread+0x36e/0x500
   ? __pfx_kthread+0x10/0x10
   ret_from_fork+0x34d/0x620
   ? __pfx_ret_from_fork+0x10/0x10
   ? __switch_to+0x22/0xdd0
   ? __pfx_kthread+0x10/0x10
   ret_from_fork_asm+0x19/0x30
   </TASK>

  Allocated by task 43:
   kasan_save_stack+0x33/0x60
   kasan_save_track+0x14/0x30
   __kasan_slab_alloc+0x6e/0x70
   kmem_cache_alloc_noprof+0xfc/0x2b0
   srpt_test_ctx_common.constprop.0+0x46f/0x9b0
   srpt_test_ctx_init.constprop.0+0x30/0x6c0
   srpt_test_run.constprop.0+0xb6/0xa60
   kunit_try_run_case+0x1ca/0x4b0
   kunit_generic_run_threadfn_adapter+0x7b/0xe0
   kthread+0x36e/0x500
   ret_from_fork+0x34d/0x620
   ret_from_fork_asm+0x19/0x30

  The buggy address belongs to the object at ffff888002d68000
   which belongs to the cache srpt-kunit-iu of size 8276
  The buggy address is located 8 bytes to the right of
   allocated 8276-byte region [ffff888002d68000, ffff888002d6a054)

The KUnit harness that forces this is not part of this patch.

A table_desc.len below one descriptor is the other way in. It gives nbufs
zero, which the count check admits and a span check cannot catch either,
since an empty table fits in any IU. srpt_alloc_rw_ctxs() then returns
success with n_rw_ctx zero, no scatterlist is chained, and
srpt_write_pending() reaches ib_post_send() with an empty work request
list. rvt_post_send() evaluates !wr->next before the loop that tests wr
against NULL, so an rdmavt device faults there whenever its send queue is
idle.

Reject a table that does not fit by comparing the span it occupies
against byte_len, and reject an empty one. The span is the table offset
plus struct_size(idb, desc_list, nbufs), and nbufs is at most 510 once
the existing count check has passed, so it cannot saturate.

The header always lies inside the allocated buffer, since the largest
offset srpt_get_desc_buf() can return is 48 + 252 and the header is 20
bytes, so it ends at 320 while srp_max_req_size is at least
MIN_MAX_REQ_SIZE, which is 996. It does not always lie inside the bytes
the initiator actually sent, which is why the span starts at the table
offset and covers the header as well.

Fixes: a42d985bd5b2 ("ib_srpt: Initial SRP Target merge for v3.3-rc1")
Cc: stable@vger.kernel.org
Signed-off-by: Yehyeong Lee <yhlee@isslab.korea.ac.kr>
Link: https://patch.msgid.link/20261025013748.3755639-2-yhlee@isslab.korea.ac.kr
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/infiniband/ulp/srpt/ib_srpt.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -1118,6 +1118,7 @@ static int srpt_get_desc_tbl(struct srpt
 		struct srp_indirect_buf *idb = srpt_get_desc_buf(srp_cmd);
 		int nbufs = be32_to_cpu(idb->table_desc.len) /
 				sizeof(struct srp_direct_buf);
+		size_t desc_off = (uintptr_t)idb - (uintptr_t)srp_cmd;
 
 		if (nbufs >
 		    (srp_cmd->data_out_desc_cnt + srp_cmd->data_in_desc_cnt)) {
@@ -1129,6 +1130,18 @@ static int srpt_get_desc_tbl(struct srpt
 			return -EINVAL;
 		}
 
+		if (nbufs == 0) {
+			pr_err("received SRP_CMD with an empty indirect descriptor table\n");
+			return -EINVAL;
+		}
+
+		if (desc_off + struct_size(idb, desc_list, nbufs) >
+		    recv_ioctx->byte_len) {
+			pr_err("received SRP_CMD indirect table (%d descriptors) that does not fit the %d-byte IU\n",
+			       nbufs, recv_ioctx->byte_len);
+			return -EINVAL;
+		}
+
 		*data_len = be32_to_cpu(idb->len);
 		return srpt_alloc_rw_ctxs(ioctx, idb->desc_list, nbufs,
 				sg, sg_cnt);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 431/555] RDMA/srpt: reject zero-length buffer descriptors
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (429 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 430/555] RDMA/srpt: bound the indirect descriptor table to the IU Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 432/555] RDMA/srpt: widen the indirect RDMA context counters Greg Kroah-Hartman
                   ` (123 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Yehyeong Lee, Bart Van Assche,
	Leon Romanovsky

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Yehyeong Lee <yhlee@isslab.korea.ac.kr>

commit 252fc17ff4fbc2c6ead5e2f9404c9d0c490f0965 upstream.

srpt_alloc_rw_ctxs() takes each buffer descriptor length straight from the
wire and hands it to target_alloc_sgl(), which has no length check of its
own.

For the single descriptor of a DIRECT request, and for the last descriptor
of an INDIRECT table, chainable is false, so a zero length makes
sgl_alloc_order() compute nalloc zero. kmalloc_objs() answers that with
ZERO_SIZE_PTR, which is not NULL, so the allocation looks like it
succeeded and sg_init_table(sgl, 0) runs. That reaches sg_init_marker(),
which does sg_mark_end(&sgl[nents - 1]) with nents unsigned, so the index
is 4294967295 rather than minus one and the read modify write of page_link
lands far outside any allocation.

  Oops: general protection fault, probably for non-canonical address 0xdffffc03fffffffe: 0000 [#1] KASAN PTI
  KASAN: probably user-memory-access in range [0x0000001ffffffff0-0x0000001ffffffff7]
  CPU: 0 UID: 0 PID: 43 Comm: kunit_try_catch Tainted: G                 N   7.3.0-12378-g6fba331225f5-dirty #1 PREEMPT(lazy)
  Tainted: [N]=TEST
  RIP: 0010:sgl_alloc_order+0xb6/0x370
  Code: ef 01 4c 89 e2 49 89 c4 31 f6 49 c1 e7 05 48 89 c7 e8 ae e0 cb ff 4d 01 e7 48 b8 00 00 00 00 00 fc ff df 4c 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 6b 02 00 00 49 bc 00 00 00 00 00 fc ff df 49 8b
  RSP: 0000:ffff888002d4fa38 EFLAGS: 00010202
  RAX: dffffc0000000000 RBX: 0000000000001000 RCX: 0000000000000000
  RDX: 00000003fffffffe RSI: 0000000000000000 RDI: 0000000000000010
  RBP: 0000000000000000 R08: ffff888002b158a0 R09: 0000000000000000
  R10: 0000000000000010 R11: 0000000000000037 R12: 0000000000000010
  R13: ffff888002d6803c R14: 0000000000000000 R15: 0000001ffffffff0
  FS:  0000000000000000(0000) GS:0000000000000000(0000) knlGS:0000000000000000
  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
  CR2: ffff88802f1c8000 CR3: 000000002e458000 CR4: 00000000000006f0
  Call Trace:
   <TASK>
   target_alloc_sgl+0x2b/0x70
   srpt_alloc_rw_ctxs+0x2ef/0x870
   srpt_test_parse+0x114/0x580
   ? __pfx_srpt_test_parse+0x10/0x10
   ? srpt_test_ctx_init_direct+0x17d/0x280
   srpt_direct_len0_test+0xa4/0x280
   ? __pfx_srpt_direct_len0_test+0x10/0x10
   ? __set_cpus_allowed_ptr+0x181/0x240
   ? __pfx_read_tsc+0x10/0x10
   ? ktime_get_ts64+0x192/0x250
   kunit_try_run_case+0x1ca/0x4b0
   ? __pfx_kunit_try_run_case+0x10/0x10
   ? kthread_affine_node+0x24b/0x370
   ? __pfx_kthread_affine_node+0x10/0x10
   ? __pfx_kunit_try_run_case+0x10/0x10
   ? __pfx_kunit_generic_run_threadfn_adapter+0x10/0x10
   kunit_generic_run_threadfn_adapter+0x7b/0xe0
   kthread+0x36e/0x500
   ? __pfx_kthread+0x10/0x10
   ret_from_fork+0x34d/0x620
   ? __pfx_ret_from_fork+0x10/0x10
   ? __switch_to+0x22/0xdd0
   ? __pfx_kthread+0x10/0x10
   ret_from_fork_asm+0x19/0x30
   </TASK>

The KUnit harness that forces this is not part of this patch.

A zero length descriptor elsewhere in a table is chainable, so one entry
is allocated and that write does not happen, but the entry count comes
back zero and the mapping in rdma_rw_ctx_init() then refuses it.

The target core never hands the same allocator a zero length. Its own call
in transport_generic_new_cmd() sits behind a cmd->data_length test.

Reject a descriptor whose length is zero. The existing unwind label covers
the first iteration, where its loop body does not run because nothing has
been allocated yet.

Fixes: b99f8e4d7bcd ("IB/srpt: convert to the generic RDMA READ/WRITE API")
Cc: stable@vger.kernel.org
Signed-off-by: Yehyeong Lee <yhlee@isslab.korea.ac.kr>
Link: https://patch.msgid.link/20261025013748.3755639-3-yhlee@isslab.korea.ac.kr
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/infiniband/ulp/srpt/ib_srpt.c |    6 ++++++
 1 file changed, 6 insertions(+)

--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -980,6 +980,12 @@ static int srpt_alloc_rw_ctxs(struct srp
 		u32 size = be32_to_cpu(db->len);
 		u32 rkey = be32_to_cpu(db->key);
 
+		if (size == 0) {
+			pr_err("received SRP_CMD buffer descriptor with zero length\n");
+			ret = -EINVAL;
+			goto unwind;
+		}
+
 		ret = target_alloc_sgl(&ctx->sg, &ctx->nents, size, false,
 				i < nbufs - 1);
 		if (ret)



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 432/555] RDMA/srpt: widen the indirect RDMA context counters
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (430 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 431/555] RDMA/srpt: reject zero-length buffer descriptors Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 433/555] perf record: Reject CPU indices equal to the mask size Greg Kroah-Hartman
                   ` (122 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Bart Van Assche, Yehyeong Lee,
	Leon Romanovsky

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Yehyeong Lee <yhlee@isslab.korea.ac.kr>

commit 013eb66a8ef25ef531bf41d79815948ab4938571 upstream.

srpt_send_ioctx::n_rdma and ::n_rw_ctx are u8, and neither of the values
stored in them is bounded by 255.

n_rw_ctx counts the INDIRECT descriptors a command carries, and the count
guard in srpt_get_desc_tbl() admits data_out_desc_cnt plus
data_in_desc_cnt, so up to 510. At 256 descriptors n_rw_ctx wraps to
zero, and srpt_release_cmd() frees the contexts only when it is non-zero,
so every scatterlist and RDMA context the command allocated leaks.

n_rdma is not a descriptor count at all. It is the sum of the
rdma_rw_ctx_init() return values, which is the number of work requests
each context needs, accumulated by ioctx->n_rdma += ret. A handful of
descriptors for large transfers can pass 255 on their own, with no
unusual descriptor count involved. A wrapped n_rdma is then handed to
atomic_sub_return(ioctx->n_rdma, &ch->sq_wr_avail) and tested by
WARN_ON(ioctx->n_rdma <= 0), so the send queue work request accounting
drifts too.

Make both counters int, the type the values they accumulate already have.

Fixes: b99f8e4d7bcd ("IB/srpt: convert to the generic RDMA READ/WRITE API")
Cc: stable@vger.kernel.org
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Yehyeong Lee <yhlee@isslab.korea.ac.kr>
Link: https://patch.msgid.link/20261025013748.3755639-4-yhlee@isslab.korea.ac.kr
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/infiniband/ulp/srpt/ib_srpt.c |    2 +-
 drivers/infiniband/ulp/srpt/ib_srpt.h |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -959,7 +959,7 @@ static int srpt_alloc_rw_ctxs(struct srp
 	struct srpt_rdma_ch *ch = ioctx->ch;
 	struct scatterlist *prev = NULL;
 	unsigned prev_nents;
-	u8 n_rdma, n_rw_ctx;
+	int n_rdma, n_rw_ctx;
 	int ret, i;
 
 	if (nbufs == 1) {
--- a/drivers/infiniband/ulp/srpt/ib_srpt.h
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.h
@@ -223,8 +223,8 @@ struct srpt_send_ioctx {
 	struct ib_cqe		rdma_cqe;
 	enum srpt_command_state	state;
 	struct se_cmd		cmd;
-	u8			n_rdma;
-	u8			n_rw_ctx;
+	int			n_rdma;
+	int			n_rw_ctx;
 	bool			queue_status_only;
 	u8			sense_data[TRANSPORT_SENSE_BUFFER];
 };



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 433/555] perf record: Reject CPU indices equal to the mask size
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (431 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 432/555] RDMA/srpt: widen the indirect RDMA context counters Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 434/555] powerpc/eeh: NUL-terminate force recovery input Greg Kroah-Hartman
                   ` (121 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Paul Moses, Namhyung Kim,
	Adrian Hunter, Alexander Shishkin, Athira Rajeev, Ian Rogers,
	Ingo Molnar, James Clark, Jiri Olsa, Mark Rutland, Peter Zijlstra,
	Arnaldo Carvalho de Melo

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Paul Moses <p@1g4.org>

commit 82b4a28e758816365405e01d9ed09027d13ef77a upstream.

record__mmap_cpu_mask_init() rejects CPU indices greater than nbits but
accepts nbits itself. Valid indices end at nbits - 1. When nbits is a
multiple of BITS_PER_LONG, __set_bit() accesses the word immediately past
the bitmap allocation.

User specified recording thread masks reach this write before they are
intersected with the selected CPU mask. For example, an affinity mask
containing CPU 64 overruns a bitmap allocated for 64 possible CPUs.

==40343==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7bbab4000018 at pc 0x6195de57af45 bp 0x7ffe25545d20 sp 0x7ffe25545d18
READ of size 8 at 0x7bbab4000018 thread T0

Reject indices greater than or equal to nbits before setting a bit.

Fixes: cbd7bfc7fd99acdd ("tools/perf: Fix out of bound access to cpu mask array")
Signed-off-by: Paul Moses <p@1g4.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: stable@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 tools/perf/builtin-record.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -3580,8 +3580,8 @@ static int record__mmap_cpu_mask_init(st
 		return 0;
 
 	perf_cpu_map__for_each_cpu_skip_any(cpu, idx, cpus) {
-		/* Return ENODEV is input cpu is greater than max cpu */
-		if ((unsigned long)cpu.cpu > mask->nbits)
+		/* Return ENODEV if the CPU index is outside the mask. */
+		if ((unsigned long)cpu.cpu >= mask->nbits)
 			return -ENODEV;
 		__set_bit(cpu.cpu, mask->bits);
 	}



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 434/555] powerpc/eeh: NUL-terminate force recovery input
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (432 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 433/555] perf record: Reject CPU indices equal to the mask size Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 435/555] powerpc/xmon: Avoid unsequenced accesses to tsk in show_task() Greg Kroah-Hartman
                   ` (120 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jiale Yao, Ritesh Harjani (IBM),
	Madhavan Srinivasan

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jiale Yao <yaojiale02@163.com>

commit f294ebd827e7a2b831b1eef4aaf437f07b2c235e upstream.

eeh_force_recover_write() can fill its entire stack buffer from userspace
and then pass the unterminated data to strncmp() and sscanf(). This can
make the string helpers read beyond the buffer.

Reserve the last byte and initialize the buffer so every accepted input is
NUL-terminated. Propagate copy errors before parsing as well.

Fixes: 954bd99435b8 ("powerpc/eeh: Add eeh_force_recover to debugfs")
Cc: stable@vger.kernel.org
Signed-off-by: Jiale Yao <yaojiale02@163.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20261029052948.2525048-1-yaojiale02@163.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/powerpc/kernel/eeh.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -1734,10 +1734,12 @@ static ssize_t eeh_force_recover_write(s
 	struct pci_controller *hose;
 	uint32_t phbid, pe_no;
 	struct eeh_pe *pe;
-	char buf[20];
+	char buf[20] = {};
 	int ret;
 
-	ret = simple_write_to_buffer(buf, sizeof(buf), ppos, user_buf, count);
+	ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
+	if (ret < 0)
+		return ret;
 	if (!ret)
 		return -EFAULT;
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 435/555] powerpc/xmon: Avoid unsequenced accesses to tsk in show_task()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (433 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 434/555] powerpc/eeh: NUL-terminate force recovery input Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:07 ` [PATCH 6.12 436/555] powerpc32/modules: Reserve a PLT entry for ftrace_regs_caller Greg Kroah-Hartman
                   ` (119 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Nathan Chancellor,
	Ritesh Harjani (IBM), Madhavan Srinivasan

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Nathan Chancellor <nathan@kernel.org>

commit 9ea01307e6c824eb0b8934d95d52bbacae17887d upstream.

After a recent improvement in clang to warn on unsequenced accesses to
volatile variables [1], an instance appears in show_task(), which can
break the build with CONFIG_PPC_WERROR=y / CONFIG_WERROR=y / W=e:

  arch/powerpc/xmon/xmon.c:3262:3: error: unsequenced accesses to volatile qualified 'tsk' [-Werror,-Wunsequenced]
   3261 |         printf("%16px %16lx %16px %6d %6d %c %2d %s\n", tsk,
        |                                                         ~~~
   3262 |                 tsk->thread.ksp, tsk->thread.regs,
        |                 ^

Per C11 5.1.2.3.2, accessing a volatile object is a side effect. Per C11
6.5.2, unsequenced side effects on the same scalar object are undefined
behavior. Per C11 6.5.2.2.10/12, the evaluation of arguments in a
function call is indeterminately sequenced, meaning any side effects in
the arguments are unsequenced.

tsk was made volatile in commit a2305e3de819 ("powerpc: mark local
variables around longjmp as volatile") to ensure its value in
show_tasks() was properly restored after returning from a potential
longjmp(). Aside from that, the value is not being modified through
other means, so rename the volatile parameter and add a local variable
named tsk to hold its value throughout show_task(), clearing up the
warning.

Cc: stable@vger.kernel.org
Fixes: a2305e3de819 ("powerpc: mark local variables around longjmp as volatile")
Closes: https://github.com/ClangBuiltLinux/linux/issues/2199
Link: https://github.com/llvm/llvm-project/commit/955715460eaf9188c241c74750637fc82dfcc423 [1]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20261115-xmon-wunsequenced-v1-1-42ae3fe45bf4@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/powerpc/xmon/xmon.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -3257,8 +3257,9 @@ memzcan(void)
 		printf("%.8lx\n", a - mskip);
 }
 
-static void show_task(struct task_struct *volatile tsk)
+static void show_task(struct task_struct *volatile vol_tsk)
 {
+	struct task_struct *tsk = vol_tsk;
 	unsigned int p_state = READ_ONCE(tsk->__state);
 	char state;
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 436/555] powerpc32/modules: Reserve a PLT entry for ftrace_regs_caller
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (434 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 435/555] powerpc/xmon: Avoid unsequenced accesses to tsk in show_task() Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 437/555] riscv: Fix SR_SUM leakage across context switches Greg Kroah-Hartman
                   ` (118 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Bradley Morgan,
	Christophe Leroy (CS GROUP), Madhavan Srinivasan

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Bradley Morgan <brads@mainlining.org>

commit dc6eb6f08be536223e8289c7a8b1f515b1355721 upstream.

Commit 7dfbfb87c243 ("powerpc/ftrace: Activate
HAVE_DYNAMIC_FTRACE_WITH_REGS on PPC32") made count_relocs()
undercount the PLT entries the loader
consumes: module_finalize_ftrace() now creates two trampolines
(mod->arch.tramp for ftrace_caller() and mod->arch.tramp_regs for
ftrace_regs_caller()), while count_relocs() reserves only one entry
for ftrace.

So the core .plt ends up one ppc_plt_entry (16 bytes) short. The
walk in do_plt_call() scans for a free slot with
"while (entry->jump[0])" and has no bound check, so once the last
reserved slot is used up, the walk steps past the end of the section
and patch_instruction() writes the 4-instruction trampoline into
whatever module memory follows the .plt.

Count the second entry, mirroring what module_64.c does for the same
pair of stubs.

Signed-off-by: Bradley Morgan <brads@mainlining.org>
Fixes: 7dfbfb87c243 ("powerpc/ftrace: Activate HAVE_DYNAMIC_FTRACE_WITH_REGS on PPC32")
Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20260923175631.235276-1-brads@mainlining.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/powerpc/kernel/module_32.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/arch/powerpc/kernel/module_32.c
+++ b/arch/powerpc/kernel/module_32.c
@@ -41,6 +41,9 @@ static unsigned int count_relocs(const E
 
 #ifdef CONFIG_DYNAMIC_FTRACE
 	_count_relocs++;	/* add one for ftrace_caller */
+#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
+	_count_relocs++;	/* add one for ftrace_regs_caller */
+#endif
 #endif
 	return _count_relocs;
 }



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 437/555] riscv: Fix SR_SUM leakage across context switches
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (435 preceding siblings ...)
  2026-12-04 10:07 ` [PATCH 6.12 436/555] powerpc32/modules: Reserve a PLT entry for ftrace_regs_caller Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 438/555] s390/appldata: Fix error handling in appldata_generic_handler() Greg Kroah-Hartman
                   ` (117 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Yunhui Cui, Jisheng Zhang, Andy Chiu,
	Yicong Yang, Paul Walmsley

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Yunhui Cui <cuiyunhui@bytedance.com>

commit 807b09be9c8f234ce758bcf43101f34e0a036b83 upstream.

__switch_to() saves the sstatus value of prev and restores the SR_SUM bit
of next with csrs. However, csrs only sets bits. If prev has SR_SUM set
and next has SR_SUM clear in its saved state, the old SR_SUM bit remains
set in sstatus.

This lets next run with user memory access enabled even though its saved
SR_SUM state is clear.

Use csrrc to save the sstatus value of prev and clear SR_SUM from the
live CSR before restoring the saved SR_SUM state of next. This keeps
prev's SR_SUM state intact, while preventing it from leaking to next.

Fixes: 788aa64c01f1 ("riscv: save the SR_SUM status over switches")
Cc: stable@vger.kernel.org
Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
Reviewed-by: Jisheng Zhang <jszhang@kernel.org>
Reviewed-by: Andy Chiu <tchiu@tenstorrent.com>
Reviewed-by: Yicong Yang <yang.yicong@picoheart.com>
Link: https://patch.msgid.link/20261022083212.84721-1-cuiyunhui@bytedance.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/riscv/kernel/entry.S |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/arch/riscv/kernel/entry.S
+++ b/arch/riscv/kernel/entry.S
@@ -403,15 +403,15 @@ SYM_FUNC_START(__switch_to)
 	REG_S s10, TASK_THREAD_S10_RA(a3)
 	REG_S s11, TASK_THREAD_S11_RA(a3)
 
-	/* save the user space access flag */
-	csrr  s0, CSR_STATUS
+	/* Save and clear the user space access flag. */
+	li    s1, SR_SUM
+	csrrc s0, CSR_STATUS, s1
 	REG_S s0, TASK_THREAD_SUM_RA(a3)
 
 	/* Save the kernel shadow call stack pointer */
 	scs_save_current
 	/* Restore context from next->thread */
 	REG_L s0,  TASK_THREAD_SUM_RA(a4)
-	li    s1,  SR_SUM
 	and   s0,  s0, s1
 	csrs  CSR_STATUS, s0
 	REG_L ra,  TASK_THREAD_RA_RA(a4)



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 438/555] s390/appldata: Fix error handling in appldata_generic_handler()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (436 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 437/555] riscv: Fix SR_SUM leakage across context switches Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 439/555] s390/dcssblk: Initialize device semaphore before sysfs registration Greg Kroah-Hartman
                   ` (116 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Gerald Schaefer, Heiko Carstens,
	Alexander Gordeev

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Gerald Schaefer <gerald.schaefer@linux.ibm.com>

commit 0f01f3156f260a5fbce3b4017e1f1ff93cb29465 upstream.

appldata_generic_handler() always returns 0 after starting or stopping
monitor recording.

So "echo {0,1} > /proc/sys/appldata/{os,mem,net_sum}" returns success even
when DIAG 0xDC failed. A failed start would keep ops->active as 0, so
reading the sysctl later would correctly reflect this.

A failed stop would falsely set ops->active to 0 and decrement module
refcount. This would allow the data gathering module to be removed, and
the data buffer to be freed, while z/VM monitor service is still collecting
data from that buffer.

Fix this by returning -EIO when appldata_diag() failed, and only set
ops->active to 0 and decrement module refcount when it succeeded on stop
path.

Cc: stable@vger.kernel.org
Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/s390/appldata/appldata_base.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

--- a/arch/s390/appldata/appldata_base.c
+++ b/arch/s390/appldata/appldata_base.c
@@ -319,21 +319,25 @@ appldata_generic_handler(const struct ct
 			pr_err("Starting the data collection for %s "
 			       "failed with rc=%d\n", ops->name, rc);
 			module_put(ops->owner);
+			rc = -EIO;
 		} else
 			ops->active = 1;
 	} else if (!active && (ops->active == 1)) {
-		ops->active = 0;
 		rc = appldata_diag(ops->record_nr, APPLDATA_STOP_REC,
 				(unsigned long) ops->data, ops->size,
 				ops->mod_lvl);
-		if (rc != 0)
+		if (rc != 0) {
 			pr_err("Stopping the data collection for %s "
 			       "failed with rc=%d\n", ops->name, rc);
-		module_put(ops->owner);
+			rc = -EIO;
+		} else {
+			ops->active = 0;
+			module_put(ops->owner);
+		}
 	}
 	mutex_unlock(&appldata_ops_mutex);
 	module_put(ops->owner);
-	return 0;
+	return rc;
 }
 
 /*************************** /proc stuff <END> *******************************/



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 439/555] s390/dcssblk: Initialize device semaphore before sysfs registration
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (437 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 438/555] s390/appldata: Fix error handling in appldata_generic_handler() Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 440/555] scsi: mpi3mr: Validate reply frame size bounds Greg Kroah-Hartman
                   ` (115 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Alexander Gordeev, Jiale Yao,
	Heiko Carstens

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jiale Yao <yaojiale02@163.com>

commit 64ee7f863655e67f26947420516daba4e232675d upstream.

device_create_file() makes the add and remove attributes writable before
the device list semaphore is initialized. A sysfs write racing module
initialization can therefore acquire an uninitialized rwsem.

Initialize the semaphore before registering the root device and its
attributes.

[hca@linux.ibm.com: Use DECLARE_RWSEM() instead of moving init_rwsem()]

Cc: stable@vger.kernel.org
Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Jiale Yao <yaojiale02@163.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/s390/block/dcssblk.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/drivers/s390/block/dcssblk.c
+++ b/drivers/s390/block/dcssblk.c
@@ -101,7 +101,7 @@ static DEVICE_ATTR(remove, S_IWUSR, NULL
 static struct device *dcssblk_root_dev;
 
 static LIST_HEAD(dcssblk_devices);
-static struct rw_semaphore dcssblk_devices_sem;
+static DECLARE_RWSEM(dcssblk_devices_sem);
 
 /*
  * release function for segment device.
@@ -1008,7 +1008,6 @@ dcssblk_init(void)
 	if (rc < 0)
 		goto out_root;
 	dcssblk_major = rc;
-	init_rwsem(&dcssblk_devices_sem);
 
 	dcssblk_check_params();
 	return 0;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 440/555] scsi: mpi3mr: Validate reply frame size bounds
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (438 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 439/555] s390/dcssblk: Initialize device semaphore before sysfs registration Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 441/555] scsi: rdac: Keep the error status when controller lookup fails Greg Kroah-Hartman
                   ` (114 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Milan P. Gandhi,
	Martin K. Petersen (Oracle)

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Milan P. Gandhi <mgandhi@redhat.com>

commit e550f2b2b4aab4c5f12db89d04d8978ce4ed7b4e upstream.

Firmware provides reply_frame_size in dwords, which the driver multiplies
by 4 to compute facts.reply_sz (u16). If the reported size exceeds U16_MAX
/ 4, the multiplication overflows u16 before assignment, causing
under-allocated DMA reply buffers.

Furthermore, several paths assume a minimal reply frame size:

 - logdata_entry_sz calculations underflow or hit zero when reply_sz <= 20
   bytes, leading to zero-size allocations and divide-by-zero crashes.

 - Unsolicited status descriptors and fixed replies (such as struct
   mpi3_iounit_control_reply, 64 bytes) require at least 16 dwords.

Validate reply_frame_size in mpi3mr_issue_iocfacts() to ensure it is within
[16, U16_MAX / 4] dwords before processing facts data.

Fixes: 824a156633df ("scsi: mpi3mr: Base driver code")
Cc: stable@vger.kernel.org
Signed-off-by: Milan P. Gandhi <mgandhi@redhat.com>
Link: https://patch.msgid.link/20261105122401.266559-1-mgandhi@redhat.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/scsi/mpi3mr/mpi3mr.h    |    1 +
 drivers/scsi/mpi3mr/mpi3mr_fw.c |   18 ++++++++++++++++++
 2 files changed, 19 insertions(+)

--- a/drivers/scsi/mpi3mr/mpi3mr.h
+++ b/drivers/scsi/mpi3mr/mpi3mr.h
@@ -83,6 +83,7 @@ extern atomic64_t event_counter;
 #define MPI3MR_ADMIN_REPLY_Q_SIZE	(8 * MPI3MR_PAGE_SIZE_4K)
 #define MPI3MR_ADMIN_REQ_FRAME_SZ	128
 #define MPI3MR_ADMIN_REPLY_FRAME_SZ	16
+#define MPI3MR_MIN_REPLY_FRAME_SZ_DWORDS	16	/* 64 bytes */
 
 /* Operational queue management definitions */
 #define MPI3MR_OP_REQ_Q_QD		512
--- a/drivers/scsi/mpi3mr/mpi3mr_fw.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c
@@ -3009,6 +3009,7 @@ static int mpi3mr_issue_iocfacts(struct
 	struct mpi3_ioc_facts_data *facts_data)
 {
 	struct mpi3_ioc_facts_request iocfacts_req;
+	u16 reply_frame_size;
 	void *data = NULL;
 	dma_addr_t data_dma;
 	u32 data_len = sizeof(*facts_data);
@@ -3066,6 +3067,23 @@ static int mpi3mr_issue_iocfacts(struct
 		goto out_unlock;
 	}
 	memcpy(facts_data, (u8 *)data, data_len);
+
+	reply_frame_size = le16_to_cpu(facts_data->reply_frame_size);
+	/*
+	 * Validate reply_frame_size:
+	 * - Must be at least 16 dwords (64 bytes) to accommodate fixed reply
+	 *   structures and avoid underflow/divide-by-zero in logdata sizing.
+	 * - Must not exceed U16_MAX / 4 to prevent integer overflow.
+	 */
+	if (reply_frame_size < MPI3MR_MIN_REPLY_FRAME_SZ_DWORDS ||
+	    reply_frame_size > (U16_MAX / 4)) {
+		ioc_err(mrioc, "Invalid reply_frame_size %u (must be %u..%u dwords)\n",
+			reply_frame_size, MPI3MR_MIN_REPLY_FRAME_SZ_DWORDS,
+			(unsigned int)(U16_MAX / 4));
+		retval = -EINVAL;
+		goto out_unlock;
+	}
+
 	mpi3mr_process_factsdata(mrioc, facts_data);
 out_unlock:
 	mrioc->init_cmds.state = MPI3MR_CMD_NOTUSED;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 441/555] scsi: rdac: Keep the error status when controller lookup fails
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (439 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 440/555] scsi: mpi3mr: Validate reply frame size bounds Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 442/555] scsi: sd_zbc: Cap zone report count by buffer size Greg Kroah-Hartman
                   ` (113 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Shao Mingyin,
	Martin K. Petersen (Oracle)

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Shao Mingyin <shao.mingyin@zte.com.cn>

commit 46846939d5f33c9333612662c52475f92e753407 upstream.

initialize_controller() records SCSI_DH_RES_TEMP_UNAVAIL when
get_controller() fails, but then overwrites it with SCSI_DH_OK
unconditionally. It therefore reports success with h->ctlr == NULL and
rdac_bus_attach() continues with check_ownership(), which dereferences
h->ctlr:

  BUG: kernel NULL pointer dereference, address: 0000000000000000
  ...
  check_ownership
  rdac_bus_attach

get_controller() only fails when its GFP_ATOMIC allocation fails, so the
crash happens exactly when memory is already scarce.

Only report success after the controller was found and the device was added
to its list.

Fixes: 327825574132 ("scsi_dh_rdac: switch to scsi_execute_req_flags()")
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261026195409354OWEI2b6HO7swSphvv1FOc@zte.com.cn
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/scsi/device_handler/scsi_dh_rdac.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/drivers/scsi/device_handler/scsi_dh_rdac.c
+++ b/drivers/scsi/device_handler/scsi_dh_rdac.c
@@ -450,14 +450,14 @@ static int initialize_controller(struct
 
 		spin_lock(&list_lock);
 		h->ctlr = get_controller(index, array_name, array_id, sdev);
-		if (!h->ctlr)
+		if (!h->ctlr) {
 			err = SCSI_DH_RES_TEMP_UNAVAIL;
-		else {
+		} else {
 			h->sdev = sdev;
 			list_add_rcu(&h->node, &h->ctlr->dh_list);
+			err = SCSI_DH_OK;
 		}
 		spin_unlock(&list_lock);
-		err = SCSI_DH_OK;
 	}
 	return err;
 }



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 442/555] scsi: sd_zbc: Cap zone report count by buffer size
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (440 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 441/555] scsi: rdac: Keep the error status when controller lookup fails Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 443/555] parisc: Fix register corruption in 32-bit dynamic ftrace Greg Kroah-Hartman
                   ` (112 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, co+4a4f9998e2b4b490, Boyan Liu,
	Martin K. Petersen (Oracle)

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Boyan Liu <yymhvert@gmail.com>

commit 612293fb469c81408829e6325bae25725968986f upstream.

sd_zbc_report_zones() limits descriptor parsing to the requested zone
count and the device-reported ZONE LIST LENGTH, but not to the number of
descriptors that fit in the allocated report buffer. A malicious or
malfunctioning device can report an oversized length and cause
out-of-bounds reads while the descriptors are parsed:

    BUG: KASAN: slab-out-of-bounds in sd_zbc_report_zones (drivers/scsi/sd_zbc.c:256)
    Read of size 8 at addr ffff88802c8d2610 by task kworker/u8:2/37
    Call Trace:
     sd_zbc_report_zones (drivers/scsi/sd_zbc.c:256)
     blk_revalidate_disk_zones (block/blk-zoned.c:2354)
     sd_zbc_revalidate_zones (drivers/scsi/sd_zbc.c:566)
     sd_revalidate_disk (drivers/scsi/sd.c:3898)
     sd_probe (drivers/scsi/sd.c:4101)

Cap the descriptor count with min3() over the remaining requested zones,
the device-reported count, and max_in_buf derived from buflen. This
matches nvme_ns_report_zones() and preserves iteration over reports that
require multiple commands. Use shared constants for the REPORT ZONES
header and zone descriptor sizes.

[mkp: define constants]

Fixes: d41003513e61 ("block: rework zone reporting")
Cc: stable@vger.kernel.org
Reported-by: co+4a4f9998e2b4b490@bugs.sh
Signed-off-by: Boyan Liu <yymhvert@gmail.com>
Link: https://patch.msgid.link/20261028061651.110435-1-yymhvert@gmail.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/scsi/sd_zbc.c     |    9 +++++++--
 include/scsi/scsi_proto.h |    3 +++
 2 files changed, 10 insertions(+), 2 deletions(-)

--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -228,7 +228,7 @@ int sd_zbc_report_zones(struct gendisk *
 {
 	struct scsi_disk *sdkp = scsi_disk(disk);
 	sector_t lba = sectors_to_logical(sdkp->device, sector);
-	unsigned int nr, i;
+	unsigned int nr, i, max_in_buf;
 	unsigned char *buf;
 	u64 zone_length, start_lba;
 	size_t offset, buflen = 0;
@@ -247,13 +247,18 @@ int sd_zbc_report_zones(struct gendisk *
 	if (!buf)
 		return -ENOMEM;
 
+	max_in_buf = (buflen - ZBC_REPORT_ZONES_HEADER_SIZE) /
+		ZBC_ZONE_DESCRIPTOR_SIZE;
+
 	while (zone_idx < nr_zones && lba < sdkp->capacity) {
 		ret = sd_zbc_do_report_zones(sdkp, buf, buflen, lba, true);
 		if (ret)
 			goto out;
 
 		offset = 0;
-		nr = min(nr_zones, get_unaligned_be32(&buf[0]) / 64);
+		nr = min3(nr_zones - zone_idx,
+			  get_unaligned_be32(&buf[0]) / ZBC_ZONE_DESCRIPTOR_SIZE,
+			  max_in_buf);
 		if (!nr)
 			break;
 
--- a/include/scsi/scsi_proto.h
+++ b/include/scsi/scsi_proto.h
@@ -419,6 +419,9 @@ enum zbc_zone_reporting_options {
 
 #define ZBC_REPORT_ZONE_PARTIAL 0x80
 
+#define ZBC_REPORT_ZONES_HEADER_SIZE	64
+#define ZBC_ZONE_DESCRIPTOR_SIZE	64
+
 /* Zone types of REPORT ZONES zone descriptors */
 enum zbc_zone_type {
 	ZBC_ZONE_TYPE_CONV		= 0x1,



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 443/555] parisc: Fix register corruption in 32-bit dynamic ftrace
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (441 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 442/555] scsi: sd_zbc: Cap zone report count by buffer size Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 444/555] parisc: irq: Trace hardirq state in do_cpu_irq_mask() Greg Kroah-Hartman
                   ` (111 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Karl Mehltretter, Helge Deller

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Karl Mehltretter <kmehltretter@gmail.com>

commit e9c14351f84f2ddf4aae2914979c0378bc14460a upstream.

The 32-bit dynamic ftrace trampoline allocates a 64-byte frame.
ftrace_caller() saves %r26 at offset 20, which overlaps the third
argument's spill slot for ftrace_function_trampoline().

In the failing build, GCC spills org_sp_gr3 into that slot, overwriting
saved %r26 with the original stack pointer. Tracing preempt_count_add()
then passes that pointer as val and corrupts the preempt count.

Allocate two frames on 32-bit, as 64-bit already does, and update the
generated trampoline instruction to match.

Fixes: 6ca6366220ed ("parisc: add dynamic ftrace")
Cc: stable@vger.kernel.org
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/parisc/kernel/entry.S  |    4 ----
 arch/parisc/kernel/ftrace.c |    2 +-
 2 files changed, 1 insertion(+), 5 deletions(-)

--- a/arch/parisc/kernel/entry.S
+++ b/arch/parisc/kernel/entry.S
@@ -1949,11 +1949,7 @@ ENDPROC_CFI(mcount)
 
 #ifdef CONFIG_DYNAMIC_FTRACE
 
-#ifdef CONFIG_64BIT
 #define FTRACE_FRAME_SIZE (2*FRAME_SIZE)
-#else
-#define FTRACE_FRAME_SIZE FRAME_SIZE
-#endif
 ENTRY_CFI(ftrace_caller, caller,frame=FTRACE_FRAME_SIZE,CALLS,SAVE_RP,SAVE_SP)
 ftrace_caller:
 	.global ftrace_caller
--- a/arch/parisc/kernel/ftrace.c
+++ b/arch/parisc/kernel/ftrace.c
@@ -146,7 +146,7 @@ int ftrace_make_call(struct dyn_ftrace *
 #else
 	u32 ftrace_trampoline[] = {
 		(u32)addr,
-		0x6fc10080, /* stw,ma r1,40(sp) */
+		0x6fc10100, /* stw,ma r1,80(sp) */
 		0x48213fd1, /* ldw -18(r1),r1 */
 		0xe820c002, /* bv,n r0(r1) */
 		0xe83f1fdf, /* b,l,n .-c,r1 */



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 444/555] parisc: irq: Trace hardirq state in do_cpu_irq_mask()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (442 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 443/555] parisc: Fix register corruption in 32-bit dynamic ftrace Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 445/555] objtool/rust: add more `noreturn` Rust functions for Rust 1.101.0 Greg Kroah-Hartman
                   ` (110 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Karl Mehltretter, Helge Deller

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Karl Mehltretter <kmehltretter@gmail.com>

commit a739c9192173c0437ed3c76f87f5a39532ef9fe1 upstream.

intr_extint calls do_cpu_irq_mask() with PSW[I] already clear. Since
commit 044d0d6de9f5 ("lockdep: Only trace IRQ edges"), its
local_irq_disable() then skips trace_hardirqs_off(), and lockdep
assertions fail in the timer tick:

  WARNING: kernel/rcu/tree.c:2739 at rcu_sched_clock_irq+0x618/0x1f84

The return to a context with PSW[I] set has not been annotated since
TRACE_IRQFLAGS_SUPPORT was enabled. Annotate both transitions.

Fixes: 366dd4ea9d5f ("parisc: Fix ftrace function tracer")
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
Cc: stable@vger.kernel.org # v5.9+
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/parisc/kernel/irq.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/arch/parisc/kernel/irq.c
+++ b/arch/parisc/kernel/irq.c
@@ -497,7 +497,7 @@ asmlinkage void do_cpu_irq_mask(struct p
 #endif
 
 	old_regs = set_irq_regs(regs);
-	local_irq_disable();
+	trace_hardirqs_off();
 	irq_enter_rcu();
 
 	eirr_val = mfctl(23) & cpu_eiem & per_cpu(local_ack_eiem, cpu);
@@ -535,6 +535,8 @@ asmlinkage void do_cpu_irq_mask(struct p
  out:
 	irq_exit_rcu();
 	set_irq_regs(old_regs);
+	if (!irqs_disabled_flags(regs->gr[0]))
+		trace_hardirqs_on();
 	return;
 
  set_out:



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 445/555] objtool/rust: add more `noreturn` Rust functions for Rust 1.101.0
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (443 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 444/555] parisc: irq: Trace hardirq state in do_cpu_irq_mask() Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 446/555] ocfs2/dlmfs: keep the superblock alive during lock work Greg Kroah-Hartman
                   ` (109 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Josh Poimboeuf, Peter Zijlstra,
	Gary Guo, Miguel Ojeda

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Miguel Ojeda <ojeda@kernel.org>

commit 1846c049cfe325abe0be8d1ea50eda16aa02d1a8 upstream.

Starting with Rust 1.101.0 (expected 2026-12-24), `objtool` may report:

    rust/kernel.o: warning: objtool: _R..._6kernel3pci2ioINtB7_6DeviceNtNtB9_6device5BoundE8cfg_size()
    falls through to next function _R..._6kernel3oppNtB5_3OPP18from_raw_opp_owned()

(and others) due to calls to the `noreturn` symbol:

    core::panicking::unreachable_default_msg

Rust now outlines the constant messages of the panicking macros [1],
thus `unreachable!()` (i.e. without arguments) calls that new function
instead of `core::panicking::panic`, which is already in the list.

The same change introduced the equivalent `noreturn` functions for
`panic!()`, `todo!()` and `unimplemented!()`, which lead to the same
warning when those are used:

    core::panicking::panic_default_msg
    core::panicking::todo_default_msg
    core::panicking::unimplemented_default_msg

Thus add the mangled ones to the list so that `objtool` knows they are
actually `noreturn`.

See commit 56d680dd23c3 ("objtool/rust: list `noreturn` Rust functions")
for more details.

Cc: stable@vger.kernel.org # 6.12.x (Rust is pinned in older LTSs)
Cc: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://github.com/rust-lang/rust/pull/163766 [1]
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://patch.msgid.link/20261114001708.80599-1-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 tools/objtool/check.c |    4 ++++
 1 file changed, 4 insertions(+)

--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -218,9 +218,13 @@ static bool is_rust_noreturn(const struc
 	       str_ends_with(func->name, "_4core9panicking9panic_fmt")					||
 	       str_ends_with(func->name, "_4core9panicking14panic_explicit")				||
 	       str_ends_with(func->name, "_4core9panicking14panic_nounwind")				||
+	       str_ends_with(func->name, "_4core9panicking16todo_default_msg")				||
+	       str_ends_with(func->name, "_4core9panicking17panic_default_msg")				||
 	       str_ends_with(func->name, "_4core9panicking18panic_bounds_check")			||
 	       str_ends_with(func->name, "_4core9panicking18panic_nounwind_fmt")			||
 	       str_ends_with(func->name, "_4core9panicking19assert_failed_inner")			||
+	       str_ends_with(func->name, "_4core9panicking23unreachable_default_msg")			||
+	       str_ends_with(func->name, "_4core9panicking25unimplemented_default_msg")			||
 	       str_ends_with(func->name, "_4core9panicking30panic_null_pointer_dereference")		||
 	       str_ends_with(func->name, "_4core9panicking32panic_null_reference_constructed")		||
 	       str_ends_with(func->name, "_4core9panicking36panic_misaligned_pointer_dereference")	||



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 446/555] ocfs2/dlmfs: keep the superblock alive during lock work
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (444 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 445/555] objtool/rust: add more `noreturn` Rust functions for Rust 1.101.0 Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 447/555] ocfs2: advance locking_state through the live cursor Greg Kroah-Hartman
                   ` (108 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Cen Zhang, Andrew Morton, Joseph Qi,
	Mark Fasheh, Joel Becker, Heming Zhao, Jia-Ju Bai, jjzuming

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Cen Zhang <zzzccc427@gmail.com>

commit e9e66aa5ef1a76ec92fe41c5eb16fda7a39db279 upstream.

Queued dlmfs lock work holds an inode reference, but no active reference
to its superblock.  The workqueue is drained on module exit rather than on
each dlmfs unmount, and an inode reference does not stop superblock
shutdown: generic_shutdown_super() reports the busy inode and goes on.

  DLM callback / worker               Unmount
  ---------------------               -------
  queue lock work; igrab(inode)
  worker delayed
                                      drop last active superblock ref
                                      kill_anon_super()
                                        report the busy inode
                                        free the superblock
  finish lock work
  iput(inode)
    access the inode's freed superblock

Flushing the workqueue from a dlmfs kill_sb would not be enough: a
blocking AST can queue new work for an inode that is still alive after the
flush and before eviction, and that work again holds only an inode
reference.

Take an active superblock reference before acquiring the queued inode
reference, with the atomic_inc_not_zero() on s_active that grab_super()
and the NFS and procfs superblock walkers use.  Decline to queue if the
superblock is already shutting down; the inode is then being evicted and
user_dlm_destroy_lock() tears the lock down.  The existing l_lock and
USER_LOCK_QUEUED flag serialize this with other queue attempts.  Each
execution drops its inode reference before releasing the active superblock
reference, outside l_lock.  If that releases the last active reference,
the unmount completes on the worker; it only waits for DLM replies and
never for this workqueue.

Only the relevant frames of the report are kept:

Oops: general protection fault, probably for non-canonical address 0xfbd59c0000000026: 0000 [#1] SMP KASAN NOPTI
KASAN: maybe wild-memory-access in range [0xdead000000000130-0xdead000000000137]
Workqueue: user_dlm user_dlm_unblock_lock
RIP: 0010:iput+0x246/0xc10
Call Trace:
 <TASK>
 user_dlm_unblock_lock+0x503/0xa50
 process_one_work+0x9a8/0x1b40
 worker_thread+0x65c/0xe40
 </TASK>

Link: https://lore.kernel.org/pm-ocfs2-objects-candidate-0054-v6-c3887cceae3b039e591e@gmail.com
Fixes: 8df08c89c668 ("[PATCH] OCFS2: The Second Oracle Cluster Filesystem")
Signed-off-by: Cen Zhang <zzzccc427@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Heming Zhao <heming.zhao@suse.com>
Cc: Jia-Ju Bai <baijiaju1990@gmail.com>
Cc: <jjzuming@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 fs/ocfs2/dlmfs/userdlm.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
---
 fs/ocfs2/dlmfs/userdlm.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

--- a/fs/ocfs2/dlmfs/userdlm.c
+++ b/fs/ocfs2/dlmfs/userdlm.c
@@ -162,7 +162,13 @@ static void user_dlm_unblock_lock(struct
 
 static void __user_dlm_queue_lockres(struct user_lock_res *lockres)
 {
+	struct inode *inode = user_dlm_inode_from_user_lockres(lockres);
+
 	if (!(lockres->l_flags & USER_LOCK_QUEUED)) {
+		/* Pin the superblock through the worker's iput(). */
+		if (!atomic_inc_not_zero(&inode->i_sb->s_active))
+			return;
+
 		user_dlm_grab_inode_ref(lockres);
 
 		INIT_WORK(&lockres->l_work, user_dlm_unblock_lock);
@@ -275,9 +281,11 @@ static struct ocfs2_locking_protocol use
 
 static inline void user_dlm_drop_inode_ref(struct user_lock_res *lockres)
 {
-	struct inode *inode;
-	inode = user_dlm_inode_from_user_lockres(lockres);
+	struct inode *inode = user_dlm_inode_from_user_lockres(lockres);
+	struct super_block *sb = inode->i_sb;
+
 	iput(inode);
+	deactivate_super(sb);
 }
 
 static void user_dlm_unblock_lock(struct work_struct *work)



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 447/555] ocfs2: advance locking_state through the live cursor
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (445 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 446/555] ocfs2/dlmfs: keep the superblock alive during lock work Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 448/555] ocfs2: fix kernel BUG in ocfs2_page_mkwrite() when write_end fails Greg Kroah-Hartman
                   ` (107 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Cen Zhang, Andrew Morton, Joseph Qi,
	Mark Fasheh, Joel Becker, Heming Zhao, Jia-Ju Bai, jjzuming

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Cen Zhang <zzzccc427@gmail.com>

commit fffc86cbe3ebfd7fea3937f8698e4322b3137984 upstream.

locking_state copies each lock resource under ocfs2_dlm_tracking_lock so
its containing inode or quota object can be freed during the dump.  The
copied l_debug_list pointers do not have that lifetime protection.  Yet
ocfs2_dlm_seq_next() follows them to find the next record.

Remounting read-only can free a quota-info object while a debugfs read is
between the snapshot and the next iterator callback:

  locking_state reader                Quota suspension
  --------------------                ----------------
  snapshot current lock resource
    copy l_debug_list.next
                                      remove next resource from live list
                                      free quota-info object
  seq_next(): follow copied link
    read freed lock resource

Advance through the live dummy cursor instead.  List removal updates its
links under the tracking lock.  Position it after the resource being
copied before releasing the lock, and never walk the snapshot's links.
Reuse the per-open snapshot for a nonzero seq_start() position, including
read continuation and buffer retries.  Rewind the live cursor only when
seq_file starts at index zero; seq_lseek() traverses from there through
seq_next().  Clear the snapshot's l_ops marker at end of list so later
reads remain at EOF.  This avoids replaying the list prefix under the
tracking lock on each read, without adding a new cursor or position field.

KASAN report as below:

    BUG: KASAN: slab-use-after-free in ocfs2_dlm_next_res.isra.0+0x1b1/0x1d0
    Read of size 8 at addr ffff888117ea9838 by task python3/489

    CPU: 3 UID: 0 PID: 489 Comm: python3 Not tainted 7.3.0-rc4-next-20260921-pmb-bt-functional-v1+ #1 PREEMPT(lazy)
    Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
    Call Trace:
     <TASK>
     dump_stack_lvl+0x93/0xd0
     print_report+0xce/0x630
     ? ocfs2_dlm_next_res.isra.0+0x1b1/0x1d0
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? __virt_addr_valid+0x20e/0x420
     ? ocfs2_dlm_next_res.isra.0+0x1b1/0x1d0
     kasan_report+0xe0/0x110
     ? ocfs2_dlm_next_res.isra.0+0x1b1/0x1d0
     ocfs2_dlm_next_res.isra.0+0x1b1/0x1d0
     ? __pfx_ocfs2_dlm_next_res.isra.0+0x10/0x10
     ? __pfx_do_raw_spin_lock+0x10/0x10
     ocfs2_dlm_seq_next+0xb8/0x4c0
     ? srso_alias_return_thunk+0x5/0xfbef5
     seq_read_iter+0x92f/0x1110
     ? srso_alias_return_thunk+0x5/0xfbef5
     seq_read+0x362/0x5a0
     ? __pfx_seq_read+0x10/0x10
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? selinux_file_permission+0x11d/0x540
     full_proxy_read+0x11f/0x180
     ? __pfx_full_proxy_read+0x10/0x10
     vfs_read+0x1a0/0xc20
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? kmem_cache_free+0x242/0x580
     ? __pfx_vfs_read+0x10/0x10
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? putname+0x93/0xe0
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? do_sys_openat2+0x12a/0x1b0
     ? __pfx_do_sys_openat2+0x10/0x10
     ksys_read+0x111/0x200
     ? __pfx_ksys_read+0x10/0x10
     ? irqentry_exit+0xbe/0x820
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? trace_hardirqs_on_prepare+0x11d/0x150
     do_syscall_64+0x114/0x620
     entry_SYSCALL_64_after_hwframe+0x77/0x7f
    RIP: 0033:0x7f0266dbb687
    Code: 48 89 fa 4c 89 df e8 58 b3 00 00 8b 93 08 03 00 00 59 5e 48 83 f8 fc 74 1a 5b c3 0f 1f 84 00 00 00 00 00 48 8b 44 24 10 0f 05 <5b> c3 0f 1f 80 00 00 00 00 83 e2 39 83 fa 08 75 de e8 23 ff ff ff
    RSP: 002b:00007ffccf76fc40 EFLAGS: 00000202 ORIG_RAX: 0000000000000000
    RAX: ffffffffffffffda RBX: 00007f0266d27780 RCX: 00007f0266dbb687
    RDX: 0000000000000001 RSI: 00007f0266a53200 RDI: 0000000000000004
    RBP: 00007f0266d27700 R08: 0000000000000000 R09: 0000000000000000
    R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000001
    R13: 00007f0266a53200 R14: 0000000000000004 R15: 00007f0266b651e0
     </TASK>

    Allocated by task 547:
     kasan_save_stack+0x33/0x60
     kasan_save_track+0x14/0x30
     __kasan_kmalloc+0xaa/0xb0
     __kmalloc_cache_noprof+0x28d/0x610
     ocfs2_local_read_info+0x181/0x1580
     dquot_load_quota_sb+0x68b/0x1000
     dquot_load_quota_inode+0x227/0x3e0
     ocfs2_enable_quotas+0x27c/0x520
     ocfs2_fill_super+0x21f9/0x38f0
     get_tree_bdev_flags+0x35d/0x5f0
     vfs_get_tree+0x93/0x320
     fc_mount+0x1d/0x200
     path_mount+0x592/0x1e00
     __x64_sys_mount+0x24b/0x2d0
     do_syscall_64+0x114/0x620
     entry_SYSCALL_64_after_hwframe+0x77/0x7f

    Freed by task 577:
     kasan_save_stack+0x33/0x60
     kasan_save_track+0x14/0x30
     kasan_save_free_info+0x3b/0x60
     __kasan_slab_free+0x5f/0x80
     kfree+0x308/0x580
     ocfs2_local_free_info+0x47b/0x800
     dquot_disable+0x5d9/0x17a0
     ocfs2_susp_quotas.isra.0+0x22c/0x2b0
     ocfs2_reconfigure+0x284/0xd00
     reconfigure_super+0x3ca/0xa70
     path_mount+0x16ae/0x1e00
     __x64_sys_mount+0x24b/0x2d0
     do_syscall_64+0x114/0x620
     entry_SYSCALL_64_after_hwframe+0x77/0x7f

    The buggy address belongs to the object at ffff888117ea9800
     which belongs to the cache kmalloc-1k of size 1024
    The buggy address is located 56 bytes inside of
     freed 1024-byte region [ffff888117ea9800, ffff888117ea9c00)

    The buggy address belongs to the physical page:
    page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x117ea8
    head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
    flags: 0x200000000000040(head|node=0|zone=2)
    page_type: f5(slab)
    raw: 0200000000000040 ffff888100042dc0 dead000000000100 dead000000000122
    raw: 0000000000000000 0000000000100010 00000000f5000000 0000000000000000
    head: 0200000000000040 ffff888100042dc0 dead000000000100 dead000000000122
    head: 0000000000000000 0000000000100010 00000000f5000000 0000000000000000
    head: 0200000000000003 fffffffffffffe01 00000000ffffffff 00000000ffffffff
    head: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
    page dumped because: kasan: bad access detected

    Memory state around the buggy address:
     ffff888117ea9700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
     ffff888117ea9780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
    >ffff888117ea9800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                            ^
     ffff888117ea9880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
     ffff888117ea9900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
    ==================================================================

Link: https://lore.kernel.org/pm-ocfs2-objects-candidate-0053-v7-ec41d4bbd38bb4d795a8@gmail.com
Fixes: ccd979bdbce9 ("[PATCH] OCFS2: The Second Oracle Cluster Filesystem")
Signed-off-by: Cen Zhang <zzzccc427@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Suggested-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Heming Zhao <heming.zhao@suse.com>
Cc: Jia-Ju Bai <baijiaju1990@gmail.com>
Cc: <jjzuming@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 fs/ocfs2/dlmglue.c |   19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
---
 fs/ocfs2/dlmglue.c |   19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -3095,9 +3095,17 @@ static void *ocfs2_dlm_seq_start(struct
 {
 	struct ocfs2_dlm_seq_priv *priv = m->private;
 	struct ocfs2_lock_res *iter;
+	struct ocfs2_lock_res *dummy = &priv->p_iter_res;
+
+	/* Continue or retry the snapshot left by ->next(). */
+	if (*pos)
+		return priv->p_tmp_res.l_ops ? &priv->p_tmp_res : NULL;
 
+	/* Reads from zero and seek traversal start at the list head. */
 	spin_lock(&ocfs2_dlm_tracking_lock);
-	iter = ocfs2_dlm_next_res(&priv->p_iter_res, priv);
+	list_move(&dummy->l_debug_list,
+		  &priv->p_dlm_debug->d_lockres_tracking);
+	iter = ocfs2_dlm_next_res(dummy, priv);
 	if (iter) {
 		/* Since lockres' have the lifetime of their container
 		 * (which can be inodes, ocfs2_supers, etc) we want to
@@ -3106,8 +3114,11 @@ static void *ocfs2_dlm_seq_start(struct
 		 * trust any pointers on the copy returned, but that's
 		 * ok as the information we want isn't typically held
 		 * in them. */
+		list_move(&dummy->l_debug_list, &iter->l_debug_list);
 		priv->p_tmp_res = *iter;
 		iter = &priv->p_tmp_res;
+	} else {
+		priv->p_tmp_res.l_ops = NULL;
 	}
 	spin_unlock(&ocfs2_dlm_tracking_lock);
 
@@ -3121,17 +3132,19 @@ static void ocfs2_dlm_seq_stop(struct se
 static void *ocfs2_dlm_seq_next(struct seq_file *m, void *v, loff_t *pos)
 {
 	struct ocfs2_dlm_seq_priv *priv = m->private;
-	struct ocfs2_lock_res *iter = v;
+	struct ocfs2_lock_res *iter;
 	struct ocfs2_lock_res *dummy = &priv->p_iter_res;
 
 	(*pos)++;
 	spin_lock(&ocfs2_dlm_tracking_lock);
-	iter = ocfs2_dlm_next_res(iter, priv);
+	iter = ocfs2_dlm_next_res(dummy, priv);
 	list_del_init(&dummy->l_debug_list);
 	if (iter) {
 		list_add(&dummy->l_debug_list, &iter->l_debug_list);
 		priv->p_tmp_res = *iter;
 		iter = &priv->p_tmp_res;
+	} else {
+		priv->p_tmp_res.l_ops = NULL;
 	}
 	spin_unlock(&ocfs2_dlm_tracking_lock);
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 448/555] ocfs2: fix kernel BUG in ocfs2_page_mkwrite() when write_end fails
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (446 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 447/555] ocfs2: advance locking_state through the live cursor Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 449/555] ocfs2: serialize inode journal access with shutdown Greg Kroah-Hartman
                   ` (106 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Zhiyuan Zhang, Andrew Morton,
	syzbot+42984127d45ad96219de, Joseph Qi, Heming Zhao, Mark Fasheh,
	Joel Becker, yangwenfang

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Zhiyuan Zhang <zhiyuanzhang912@gmail.com>

commit 5158f371faceb185235ba42882e67a840cfd7f48 upstream.

syzbot reported a kernel BUG in the ocfs2 write fault path:

  (syz.0.17,5578,0):ocfs2_write_end_nolock:1945 ERROR: status = -30
  kernel BUG at fs/ocfs2/mmap.c:106!
  Call Trace:
   do_page_mkwrite+0x147/0x310 mm/memory.c:3879
   do_shared_fault mm/memory.c:6145 [inline]
   handle_mm_fault+0x1a53/0x3750 mm/memory.c:6943

__ocfs2_page_mkwrite() calls ocfs2_write_begin_nolock() and then
ocfs2_write_end_nolock(), and uses BUG_ON() to assert that the latter
returns the full length.  But ocfs2_write_end_nolock() can fail: since
commit 7f27ec978b0e ("ocfs2: call ocfs2_journal_access_di() before
ocfs2_journal_dirty() in ocfs2_write_end_nolock()") it gets journal
access to the inode buffer again, because the handle may have been
restarted since ocfs2_write_begin_nolock().  That fails with -EROFS or
-EIO once the journal has been aborted or jbd2 has seen write errors
on the device.  The syzbot reproducer gets there by shrinking the
backing loop device to zero with LOOP_SET_STATUS while writing to a
shared file mapping.

Handle the failure instead of crashing.  ocfs2_write_end_nolock()
leaves the mmap folio locked, because ocfs2_unlock_folios() skips it
when w_target_locked is set so that it can be returned with
VM_FAULT_LOCKED, and do_page_mkwrite() does not unlock it either when
->page_mkwrite() returns an error.  So unlock it and fail the fault;
the faulting task gets SIGBUS, like for the other errors in this
function.

For an mmap write ocfs2_write_end_nolock() returns either len or a
negative errno: inline data has already been converted to extents by
ocfs2_write_begin_nolock(), and copied is equal to len.

The BUG matters for local mounts, where the filesystem is expected to
go read-only and keep running after a journal abort.  On clustered
mounts ocfs2_abort() panics the node anyway as soon as it notices the
aborted journal.

Link: https://lore.kernel.org/20261111023444.22688-1-zhiyuanzhang912@gmail.com
Fixes: 7f27ec978b0e ("ocfs2: call ocfs2_journal_access_di() before ocfs2_journal_dirty() in ocfs2_write_end_nolock()")
Signed-off-by: Zhiyuan Zhang <zhiyuanzhang912@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: <syzbot+42984127d45ad96219de@syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=42984127d45ad96219de
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: Heming Zhao <heming.zhao@suse.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: yangwenfang <vicky.yangwenfang@huawei.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 fs/ocfs2/mmap.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
---
 fs/ocfs2/mmap.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

--- a/fs/ocfs2/mmap.c
+++ b/fs/ocfs2/mmap.c
@@ -103,7 +103,17 @@ static vm_fault_t __ocfs2_page_mkwrite(s
 		goto out;
 	}
 	err = ocfs2_write_end_nolock(mapping, pos, len, len, fsdata);
-	BUG_ON(err != len);
+	if (err != len) {
+		/*
+		 * ocfs2_write_end_nolock() keeps the mmap folio locked so
+		 * that it can be returned to the VM with VM_FAULT_LOCKED.
+		 * On failure nobody else will unlock it, so do it here.
+		 */
+		folio_unlock(locked_folio);
+		mlog_errno(err);
+		ret = vmf_error(err);
+		goto out;
+	}
 	ret = VM_FAULT_LOCKED;
 out:
 	return ret;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 449/555] ocfs2: serialize inode journal access with shutdown
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (447 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 448/555] ocfs2: fix kernel BUG in ocfs2_page_mkwrite() when write_end fails Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 450/555] sctp: do not free a new asoc peeled off while sendmsg slept Greg Kroah-Hartman
                   ` (105 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Cen Zhang, Andrew Morton, Joseph Qi,
	Mark Fasheh, Joel Becker, Heming Zhao, Jia-Ju Bai, jjzuming

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Cen Zhang <zzzccc427@gmail.com>

commit f277230d002d03ed98b814b735f9d3d01b42020a upstream.

The downconvert thread can run inode cleanup until ocfs2_dlm_shutdown()
stops it, but unmount shuts down the journal earlier. A final dentry
post-unlock put can therefore enter ocfs2_clear_inode() while the journal
is being destroyed.

ocfs2_ci_fully_checkpointed() loads osb->journal before taking
trans_inc_lock. Journal shutdown neither takes that lock for removal
nor waits for the downconvert thread before freeing the journal:

  Downconvert thread                    Unmount
  ------------------                    -------
  dentry post-unlock; final iput()
    ocfs2_checkpoint_inode()
      load osb->journal
                                        ocfs2_journal_shutdown()
                                          free journal; clear pointer
      read the transaction ID

The checkpoint wait queue is embedded in that journal, and the final
jbd2_journal_release_jbd_inode() also needs its JBD2 journal to remain
alive for the whole call. Protecting only the pointer load would leave
those longer uses unprotected.

Read and clear osb->journal under trans_inc_lock when checking checkpoint
progress. Treat a removed journal as checkpointed. Move checkpoint
waiters to the existing mount-owned checkpoint_event and wake it after
checkpoint progress and journal removal, so the queue outlives the
journal. The commit thread also waits there and rechecks its condition
when woken.

Serialize the final JBD2 inode release against JBD2 destruction and the
journal free with a mount-owned rw_semaphore. Take the write side only
after stopping the commit thread, and drop it before the journal inode's
final iput(), whose cleanup can take the read side. Inode cleanup holds
the read side only around the JBD2 release, outside checkpoint waits and
DLM lock teardown.

KASAN report as below:

    Oops: general protection fault, probably for non-canonical address 0xdffffc000000000e: 0000 [#1] SMP KASAN NOPTI
    KASAN: null-ptr-deref in range [0x0000000000000070-0x0000000000000077]
    CPU: 0 UID: 0 PID: 587 Comm: ocfs2dc-33CAF04 Not tainted 7.3.0-rc4-next-20260921-pmb-ocfs2-functional-v1+ #1 PREEMPT(lazy)
    Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
    RIP: 0010:ocfs2_clear_inode+0x8ae/0x1630
    Code: fc ff df 48 c1 ea 03 80 3c 02 00 0f 85 27 0c 00 00 49 8d 7d 70 48 8b 43 c8 48 ba 00 00 00 00 00 fc ff df 48 89 f9 48 c1 e9 03 <80> 3c 11 00 0f 85 f0 0b 00 00 49 3b 45 70 0f 88 62 03 00 00 e8 49
    RSP: 0018:ffff888118d3f878 EFLAGS: 00010212
    RAX: 0000000000000001 RBX: ffff88811a5edc60 RCX: 000000000000000e
    RDX: dffffc0000000000 RSI: 0000000000000001 RDI: 0000000000000070
    RBP: ffff888116134000 R08: 0000000000000001 R09: 0000000000000001
    R10: ffffffff8965765f R11: 0000000000000001 R12: ffff88811a5ed400
    R13: 0000000000000000 R14: ffff88811a5edbf8 R15: ffff88811a5ed408
    FS:  0000000000000000(0000) GS:ffff8881fd4dc000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00007ff35b66f2c0 CR3: 00000001092ae005 CR4: 0000000000770ef0
    PKRU: 55555554
    Call Trace:
     <TASK>
     ? __pfx_ocfs2_clear_inode+0x10/0x10
     ? __pfx_ocfs2_inode_is_valid_to_delete+0x10/0x10
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? __lock_acquire+0x5a3/0x2140
     ocfs2_evict_inode+0x1ed/0x11e0
     ? inode_wait_for_writeback+0x14c/0x330
     ? __pfx_ocfs2_evict_inode+0x10/0x10
     ? lock_acquire+0x190/0x300
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? find_held_lock+0x2b/0x80
     ? evict+0x347/0x9f0
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? lock_release+0xc8/0x290
     ? _raw_spin_unlock+0x23/0x40
     ? __pfx_ocfs2_evict_inode+0x10/0x10
     evict+0x38b/0x9f0
     ? __pfx_evict+0x10/0x10
     ? lock_acquire+0x190/0x300
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? lock_release+0xc8/0x290
     ? __pfx_inode_just_drop+0x10/0x10
     iput+0x680/0xb80
     ocfs2_dentry_lock_put+0xc2/0x110
     ? __pfx_ocfs2_dentry_post_unlock+0x10/0x10
     ocfs2_process_blocked_lock+0x1fb/0x420
     ? __pfx_ocfs2_process_blocked_lock+0x10/0x10
     ? __pfx_pmbd_probe_hit_cookie+0x10/0x10
     ? lock_release+0xc8/0x290
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? lockdep_hardirqs_on_prepare+0xeb/0x1a0
     ? srso_alias_return_thunk+0x5/0xfbef5
     ocfs2_downconvert_thread+0x32b/0x780
     ? do_raw_spin_lock+0x130/0x270
     ? __pfx_ocfs2_downconvert_thread+0x10/0x10
     ? __kthread_parkme+0xc1/0x220
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? lock_release+0xc8/0x290
     ? __pfx_autoremove_wake_function+0x10/0x10
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? __kthread_parkme+0x177/0x220
     ? __pfx_ocfs2_downconvert_thread+0x10/0x10
     kthread+0x351/0x460
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? __pfx_kthread+0x10/0x10
     ret_from_fork+0x659/0x940
     ? __pfx_ret_from_fork+0x10/0x10
     ? srso_alias_return_thunk+0x5/0xfbef5
     ? __switch_to+0x74f/0xf70
     ? __pfx_kthread+0x10/0x10
     ret_from_fork_asm+0x1a/0x30
     </TASK>
    Modules linked in:
    ---[ end trace 0000000000000000 ]---

Link: https://lore.kernel.org/pm-ocfs2-objects-candidate-0004-v8-dbcb8f80b8df476084d6@gmail.com
Fixes: da5e7c87827e ("ocfs2: cleanup journal init and shutdown")
Signed-off-by: Cen Zhang <zzzccc427@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Heming Zhao <heming.zhao@suse.com>
Cc: Jia-Ju Bai <baijiaju1990@gmail.com>
Cc: <jjzuming@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

 fs/ocfs2/inode.c   |   17 +++++++++--------
 fs/ocfs2/journal.c |   30 ++++++++++++++++++++++--------
 fs/ocfs2/journal.h |   17 +++++++++--------
 fs/ocfs2/ocfs2.h   |    1 +
 fs/ocfs2/super.c   |    1 +
 5 files changed, 42 insertions(+), 24 deletions(-)
---
 fs/ocfs2/inode.c   |   17 +++++++++--------
 fs/ocfs2/journal.c |   30 ++++++++++++++++++++++--------
 fs/ocfs2/journal.h |   17 +++++++++--------
 fs/ocfs2/ocfs2.h   |    1 +
 fs/ocfs2/super.c   |    1 +
 5 files changed, 42 insertions(+), 24 deletions(-)

--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -1255,15 +1255,16 @@ static void ocfs2_clear_inode(struct ino
 	oi->ip_blkno = 0ULL;
 
 	/*
-	 * ip_jinode is used to track txns against this inode. We ensure that
-	 * the journal is flushed before journal shutdown. Thus it is safe to
-	 * have inodes get cleaned up after journal shutdown.
+	 * ip_jinode is used to track txns against this inode. The journal is
+	 * flushed before it is shut down, so an inode cleaned up after that
+	 * has nothing left to release. Hold the shutdown lock so a journal
+	 * found here stays allocated until the release has finished.
 	 */
-	if (!osb->journal)
-		return;
-
-	jbd2_journal_release_jbd_inode(osb->journal->j_journal,
-				       &oi->ip_jinode);
+	down_read(&osb->journal_shutdown_sem);
+	if (osb->journal)
+		jbd2_journal_release_jbd_inode(osb->journal->j_journal,
+					       &oi->ip_jinode);
+	up_read(&osb->journal_shutdown_sem);
 }
 
 void ocfs2_evict_inode(struct inode *inode)
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -355,7 +355,7 @@ static int ocfs2_commit_cache(struct ocf
 	trace_ocfs2_commit_cache_end(journal->j_trans_id, flushed);
 
 	ocfs2_wake_downconvert_thread(osb);
-	wake_up(&journal->j_checkpointed);
+	wake_up(&osb->checkpoint_event);
 finally:
 	return status;
 }
@@ -903,7 +903,6 @@ int ocfs2_journal_alloc(struct ocfs2_sup
 
 	atomic_set(&journal->j_num_trans, 0);
 	init_rwsem(&journal->j_trans_barrier);
-	init_waitqueue_head(&journal->j_checkpointed);
 	spin_lock_init(&journal->j_lock);
 	journal->j_trans_id = 1UL;
 	INIT_LIST_HEAD(&journal->j_la_cleanups);
@@ -1077,12 +1076,14 @@ void ocfs2_journal_shutdown(struct ocfs2
 
 	journal = osb->journal;
 	if (!journal)
-		goto done;
+		return;
 
 	inode = journal->j_inode;
 
-	if (journal->j_state != OCFS2_JOURNAL_LOADED)
-		goto done;
+	if (journal->j_state != OCFS2_JOURNAL_LOADED) {
+		down_write(&osb->journal_shutdown_sem);
+		goto free;
+	}
 
 	/* need to inc inode use count - jbd2_journal_destroy will iput. */
 	if (!igrab(inode))
@@ -1118,6 +1119,12 @@ void ocfs2_journal_shutdown(struct ocfs2
 			mlog_errno(status);
 	}
 
+	/*
+	 * Exclude the final JBD2 inode cleanup in ocfs2_clear_inode() while
+	 * the journal is destroyed and freed.
+	 */
+	down_write(&osb->journal_shutdown_sem);
+
 	/* Shutdown the kernel journal system */
 	if (!jbd2_journal_destroy(journal->j_journal) && !status) {
 		/*
@@ -1140,10 +1147,17 @@ void ocfs2_journal_shutdown(struct ocfs2
 
 	journal->j_state = OCFS2_JOURNAL_FREE;
 
-done:
-	iput(inode);
-	kfree(journal);
+free:
+	/* Serialize the removal with ocfs2_ci_fully_checkpointed(). */
+	spin_lock(&trans_inc_lock);
 	osb->journal = NULL;
+	spin_unlock(&trans_inc_lock);
+	wake_up(&osb->checkpoint_event);
+	kfree(journal);
+	up_write(&osb->journal_shutdown_sem);
+
+	/* The journal inode's own cleanup takes the read side. */
+	iput(inode);
 }
 
 static void ocfs2_clear_journal_error(struct super_block *sb,
--- a/fs/ocfs2/journal.h
+++ b/fs/ocfs2/journal.h
@@ -54,7 +54,6 @@ struct ocfs2_journal {
 	spinlock_t                j_lock;
 	unsigned long             j_trans_id;
 	struct rw_semaphore       j_trans_barrier;
-	wait_queue_head_t         j_checkpointed;
 
 	/* both fields protected by j_lock*/
 	struct list_head          j_la_cleanups;
@@ -91,11 +90,15 @@ static inline void ocfs2_set_ci_lock_tra
 static inline int ocfs2_ci_fully_checkpointed(struct ocfs2_caching_info *ci)
 {
 	int ret;
-	struct ocfs2_journal *journal =
-		OCFS2_SB(ocfs2_metadata_cache_get_super(ci))->journal;
+	struct ocfs2_super *osb =
+		OCFS2_SB(ocfs2_metadata_cache_get_super(ci));
+	struct ocfs2_journal *journal;
 
 	spin_lock(&trans_inc_lock);
-	ret = time_after(journal->j_trans_id, ci->ci_last_trans);
+	journal = osb->journal;
+	/* A NULL journal has already completed checkpointing. */
+	ret = !journal ||
+		time_after(journal->j_trans_id, ci->ci_last_trans);
 	spin_unlock(&trans_inc_lock);
 	return ret;
 }
@@ -196,9 +199,6 @@ static inline void ocfs2_checkpoint_inod
 	if (ocfs2_mount_local(osb))
 		return;
 
-	if (!osb->journal)
-		return;
-
 	if (!ocfs2_ci_fully_checkpointed(INODE_CACHE(inode))) {
 		/* WARNING: This only kicks off a single
 		 * checkpoint. If someone races you and adds more
@@ -208,7 +208,8 @@ static inline void ocfs2_checkpoint_inod
 		 * OK. */
 		ocfs2_start_checkpoint(osb);
 
-		wait_event(osb->journal->j_checkpointed,
+		/* The wait queue must outlive journal shutdown. */
+		wait_event(osb->checkpoint_event,
 			   ocfs2_ci_fully_checkpointed(INODE_CACHE(inode)));
 	}
 }
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -388,6 +388,7 @@ struct ocfs2_super
 	enum ocfs2_recovery_state recovery_state;
 	wait_queue_head_t checkpoint_event;
 	struct ocfs2_journal *journal;
+	struct rw_semaphore journal_shutdown_sem;
 	unsigned long osb_commit_interval;
 
 	/* Journal triggers for checksum */
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -2094,6 +2094,7 @@ static int ocfs2_initialize_super(struct
 	}
 
 	init_waitqueue_head(&osb->checkpoint_event);
+	init_rwsem(&osb->journal_shutdown_sem);
 
 	osb->s_atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM;
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 450/555] sctp: do not free a new asoc peeled off while sendmsg slept
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (448 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 449/555] ocfs2: serialize inode journal access with shutdown Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 451/555] sctp: use skb_set_transport_header_careful() in sctp_v6_err() Greg Kroah-Hartman
                   ` (104 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Yves Bieri, Xin Long, Jakub Kicinski

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Yves Bieri <yves.bieri@theori.io>

commit f2540da93a113d3f0a70fd0961e00eb849ce8342 upstream.

When sctp_sendmsg() creates a new association and sending on it fails
with anything but -ESRCH, it frees the association. The send can
sleep in sctp_wait_for_sndbuf(), which releases the socket lock, and
meanwhile another thread can peel the new association off to a new
socket. The wait then returns -EPIPE, and sctp_sendmsg() frees an
association that now belongs to the peeled-off socket, without holding
that socket's lock.

If the peeled-off socket frees the association first, e.g. on close(),
sctp_sendmsg() frees it a second time. Otherwise a syscall running
concurrently on the peeled-off socket can use it after sctp_sendmsg()
freed it. Both are reachable by an unprivileged user. The double free
on net with KASAN:

  BUG: KASAN: double-free in sctp_tsnmap_free+0x5c/0x80
   sctp_association_free+0x1eb/0x750
   sctp_sendmsg+0x15ff/0x2020
  Freed by task 836:
   sctp_association_free+0x1eb/0x750
   sctp_primitive_ABORT+0x85/0xe0
   sctp_close+0x22a/0x8d0

Commit dfcb9f4f99f1 ("sctp: deny peeloff operation on asocs with threads
sleeping on it") fixed this double free by denying the peeloff.
Commit cea0cc80a677 ("sctp: use the right sk after waking up from
wait_buf sleep") replaced that check, and commit a0ff660058b8 ("sctp:
return error if the asoc has been peeled off in sctp_wait_for_sndbuf")
reverted it to return -EPIPE, without restoring the check.

Fix this by holding a reference on the new association while sending
on it, and by freeing it on error only if this socket still owns it.
asoc->base.sk only changes in sctp_sock_migrate(), which runs with this
socket locked, so the ownership check is stable. The reference keeps
the check safe if the new owner frees the association meanwhile.
Userspace still gets -EPIPE, and the association stays with the socket
it was peeled off to.

This was found by Xint Code, an AI code review agent, and reproduced as
an unprivileged user on net with KASAN (trace above), without modifying
the kernel or using error injection. With this patch the sender gets
-EPIPE and the association keeps working on the peeled-off socket.
Without a peeloff, a failed send that created the association (EAGAIN,
EINTR) still frees it, and a peer ABORT while the sender sleeps still
frees it exactly once. The SCTP selftest sctp_vrf.sh passes. The
reproducer is available on request.

Fixes: a0ff660058b8 ("sctp: return error if the asoc has been peeled off in sctp_wait_for_sndbuf")
Cc: stable@vger.kernel.org
Signed-off-by: Yves Bieri <yves.bieri@theori.io>
Acked-by: Xin Long <lucien.xin@gmail.com>
Link: https://patch.msgid.link/20261112172149.27355-1-yves.bieri@theori.io
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/sctp/socket.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -2063,6 +2063,11 @@ static int sctp_sendmsg(struct sock *sk,
 
 			asoc = transport->asoc;
 			new = true;
+			/* sctp_sendmsg_to_asoc() may release the socket lock,
+			 * and the new asoc can be peeled off meanwhile.  Hold
+			 * it, and free it on error only if sk still owns it.
+			 */
+			sctp_association_hold(asoc);
 		}
 
 		if (!sctp_style(sk, TCP) && !(sflags & SCTP_ADDR_OVER))
@@ -2084,8 +2089,11 @@ static int sctp_sendmsg(struct sock *sk,
 
 	/* Send msg to the asoc */
 	err = sctp_sendmsg_to_asoc(asoc, msg, msg_len, transport, sinfo);
-	if (err < 0 && err != -ESRCH && new)
-		sctp_association_free(asoc);
+	if (new) {
+		if (err < 0 && err != -ESRCH && asoc->base.sk == sk)
+			sctp_association_free(asoc);
+		sctp_association_put(asoc);
+	}
 
 out_unlock:
 	release_sock(sk);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 451/555] sctp: use skb_set_transport_header_careful() in sctp_v6_err()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (449 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 450/555] sctp: do not free a new asoc peeled off while sendmsg slept Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 452/555] selftests/landlock: Test that layering does not break refer Greg Kroah-Hartman
                   ` (103 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Eric Dumazet, Justin Iurman,
	Paolo Abeni

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Eric Dumazet <edumazet@kernel.org>

commit 13391f1a8c584e7c1addaea3fd47105d92cc724c upstream.

skb->transport_header is a 16-bit offset from skb->head, and U16_MAX is
reserved as the "not set" value. skb_set_transport_header() silently
truncates an offset that does not fit.

sctp_v6_err() stores @offset, computed by icmpv6_notify() from the
extension headers of the packet embedded in an ICMPv6 error. Should
the value be truncated, sctp_err_lookup() would read the SCTP header
at the wrong place.

Since commit 3744b0964d52 ("ipv6: Implement limits on extension header
parsing") a single chain is bounded to IP6_MAX_EXT_HDRS_CNT headers
(24576 bytes), so this needs a large skb->data - skb->head on top of it,
for instance after several nested decapsulations, each of them possibly
pulling its own extension header chain, since @offset is relative to
the IPv6 header embedded in the ICMPv6 error. No reproducer was written,
this is hardening.

Use skb_set_transport_header_careful() and ignore the ICMPv6 error if
the offset can not be stored. Do this before changing the network
header, so that nothing has to be restored on failure.

Fixes: 1a37e412a022 ("net: Use 16bits for *_headers fields of struct skbuff")
Cc: stable@vger.kernel.org
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Link: https://patch.msgid.link/20261113124625.4010206-5-edumazet@kernel.org
Reviewed-by: Justin Iurman <justin.iurman@gmail.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/sctp/ipv6.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -170,8 +170,11 @@ static int sctp_v6_err(struct sk_buff *s
 	/* Fix up skb to look at the embedded net header. */
 	saveip	 = skb->network_header;
 	savesctp = skb->transport_header;
+	if (unlikely(!skb_set_transport_header_careful(skb, offset))) {
+		__ICMP6_INC_STATS(net, __in6_dev_get(skb->dev), ICMP6_MIB_INERRORS);
+		return -EINVAL;
+	}
 	skb_reset_network_header(skb);
-	skb_set_transport_header(skb, offset);
 	sk = sctp_err_lookup(net, AF_INET6, skb, sctp_hdr(skb), &asoc, &transport);
 	/* Put back, the original pointers. */
 	skb->network_header   = saveip;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 452/555] selftests/landlock: Test that layering does not break refer
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (450 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 451/555] sctp: use skb_set_transport_header_careful() in sctp_v6_err() Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 453/555] selinux: check MAP_SHARED_VALIDATE mappings as shared Greg Kroah-Hartman
                   ` (102 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Günther Noack,
	Mickaël Salaün

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Günther Noack <gnoack3000@gmail.com>

commit 047e27306d268d6972f8242b69f50e5814b09282 upstream.

Regression test to exercise that layered Landlock domains do not
accidentally deny the LANDLOCK_ACCESS_FS_REFER access right.  This
used to be the case when layering a non-filesystem ruleset with a
filesystem-enforcing ruleset.  In that case, REFER operations that
would have been allowed for the individual rulesets would get denied
when layering the same rulesets.

Link: https://github.com/landlock-lsm/linux/issues/67
Link: https://github.com/landlock-lsm/go-landlock/issues/66
Fixes: fff69fb03dde ("landlock: Support network rules with TCP bind and connect")
Cc: stable@vger.kernel.org
Signed-off-by: Günther Noack <gnoack3000@gmail.com>
Link: https://patch.msgid.link/20261113-b4-landlock-refer-nonfs-layer-v3-3-02d7e42bcdfd@gmail.com
Signed-off-by: Mickaël Salaün <mic@digikod.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 tools/testing/selftests/landlock/fs_test.c |   54 +++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

--- a/tools/testing/selftests/landlock/fs_test.c
+++ b/tools/testing/selftests/landlock/fs_test.c
@@ -2612,6 +2612,60 @@ TEST_F_FORK(layout1, refer_denied_by_def
 }
 
 /*
+ * Regression test for layered domains: The two enforced Landlock layers both do
+ * not restrict the tested "refer" operations on their own, so they should also
+ * not restrict them when they are layered, regardless of the layer order.
+ */
+static void test_layering_does_not_break_refer(
+	struct __test_metadata *const _metadata,
+	const struct landlock_ruleset_attr *const non_fs_attr,
+	const bool non_fs_first)
+{
+	ASSERT_EQ(0, unlink(file1_s1d2));
+
+	if (non_fs_first)
+		drop_access_rights(_metadata, non_fs_attr);
+
+	enforce_fs(_metadata, LANDLOCK_ACCESS_FS_REFER, layer_dir_s1d1_refer);
+
+	if (!non_fs_first)
+		drop_access_rights(_metadata, non_fs_attr);
+
+	EXPECT_EQ(0, test_rename(file1_s1d1, file1_s1d2));
+	EXPECT_EQ(0, test_rename(file1_s1d2, file1_s1d1));
+	EXPECT_EQ(0, test_exchange(file2_s1d1, file2_s1d2));
+	EXPECT_EQ(0, test_exchange(file2_s1d2, file2_s1d1));
+}
+
+static const struct landlock_ruleset_attr net_attr = {
+	.handled_access_net = LANDLOCK_ACCESS_NET_BIND_TCP,
+};
+
+static const struct landlock_ruleset_attr scoped_attr = {
+	.scoped = LANDLOCK_SCOPE_SIGNAL,
+};
+
+TEST_F_FORK(layout1, layering_fs_then_net_does_not_break_refer)
+{
+	test_layering_does_not_break_refer(_metadata, &net_attr, false);
+}
+
+TEST_F_FORK(layout1, layering_net_then_fs_does_not_break_refer)
+{
+	test_layering_does_not_break_refer(_metadata, &net_attr, true);
+}
+
+TEST_F_FORK(layout1, layering_fs_then_scoped_does_not_break_refer)
+{
+	test_layering_does_not_break_refer(_metadata, &scoped_attr, false);
+}
+
+TEST_F_FORK(layout1, layering_scoped_then_fs_does_not_break_refer)
+{
+	test_layering_does_not_break_refer(_metadata, &scoped_attr, true);
+}
+
+/*
  * Tests walking through a denied root mount.
  */
 TEST_F_FORK(layout1, refer_mount_root_deny)



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 453/555] selinux: check MAP_SHARED_VALIDATE mappings as shared
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (451 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 452/555] selftests/landlock: Test that layering does not break refer Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 454/555] spi: Fix runtime PM imbalance on pump transfer message error Greg Kroah-Hartman
                   ` (101 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Stephen Smalley, Paul Moore

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Stephen Smalley <stephen.smalley.work@gmail.com>

commit beb0ae6bcd7505e2e61babe5d98a8dd3b3f03c7f upstream.

selinux_mmap_file() only recognizes MAP_SHARED as a shared mapping,
but MAP_SHARED_VALIDATE is also a shared mapping type. The mmap flags
reach this hook before the mm code processes the mapping type.

Consequently, a writable MAP_SHARED_VALIDATE mapping was failing to
check the file write permission at mmap time, and a writable
executable file mapping was wrongly checking process execmem
permission as if it were private.

Cc: stable@vger.kernel.org
Link: https://github.com/SELinuxProject/selinux-kernel/issues/78
Fixes: 1c9725974074 ("mm: introduce MAP_SHARED_VALIDATE, a mechanism to safely define new mmap flags")
Signed-off-by: Stephen Smalley <stephen.smalley.work@gmail.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 security/selinux/hooks.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -4006,8 +4006,11 @@ static int selinux_mmap_file(struct file
 			     unsigned long reqprot __always_unused,
 			     unsigned long prot, unsigned long flags)
 {
+	const unsigned long map_type = (flags & MAP_TYPE);
+
 	return selinux_mmap_file_common(file, prot,
-					(flags & MAP_TYPE) == MAP_SHARED,
+					(map_type == MAP_SHARED ||
+					 map_type == MAP_SHARED_VALIDATE),
 					false);
 }
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 454/555] spi: Fix runtime PM imbalance on pump transfer message error
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (452 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 453/555] selinux: check MAP_SHARED_VALIDATE mappings as shared Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 455/555] tcp: Fix the SO_REUSEPORT bind cache admitting a conflicting socket Greg Kroah-Hartman
                   ` (100 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sebastian Reichel, Alexander Shiyan,
	Mark Brown

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Sebastian Reichel <sebastian.reichel@collabora.com>

commit bb5caf7a2e0b2dae8e8905d32fc376703eabcfc4 upstream.

The current SPI message pumping code may drop the runtime PM twice when
an SPI message cannot be sent:

spi_master spi2: noqueue transfer failed
rockchip-spi feb20000.spi: Runtime PM usage count underflow!

Fix the problem by always keeping the runtime PM count increased when
exiting __spi_pump_transfer_message(), as the caller handles decreasing
it.

Note, that the function already keeps the RPM usage counter increased
for the error paths following after the prepare_transfer_hardware step.

Cc: stable@vger.kernel.org
Fixes: bef4a48f4ef7 ("spi: Fix null dereference on suspend")
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Tested-by: Alexander Shiyan <eagle.alexander923@gmail.com>
Link: https://patch.msgid.link/20261110-spi-runtime-pm-fix-v1-1-8601ebb2f6a8@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/spi/spi.c |    4 ----
 1 file changed, 4 deletions(-)

--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1752,7 +1752,6 @@ static int __spi_pump_transfer_message(s
 	if (!was_busy && ctlr->auto_runtime_pm) {
 		ret = pm_runtime_get_sync(ctlr->dev.parent);
 		if (ret < 0) {
-			pm_runtime_put_noidle(ctlr->dev.parent);
 			dev_err(&ctlr->dev, "Failed to power device: %d\n",
 				ret);
 
@@ -1773,9 +1772,6 @@ static int __spi_pump_transfer_message(s
 				"failed to prepare transfer hardware: %d\n",
 				ret);
 
-			if (ctlr->auto_runtime_pm)
-				pm_runtime_put(ctlr->dev.parent);
-
 			msg->status = ret;
 			spi_finalize_current_message(ctlr);
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 455/555] tcp: Fix the SO_REUSEPORT bind cache admitting a conflicting socket
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (453 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 454/555] spi: Fix runtime PM imbalance on pump transfer message error Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 456/555] udp: use skb_set_transport_header_careful() in __udp6_lib_err_encap() Greg Kroah-Hartman
                   ` (99 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Juan Agustin Niccolini,
	Kuniyuki Iwashima, Eric Dumazet, Jakub Kicinski

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Juan Agustin Niccolini <juanagusnicco@gmail.com>

commit f675070191f202010b010160b509a543dd232ae6 upstream.

When the port is in the FASTREUSEPORT_STRICT state, inet_csk_get_port()
skips the bind conflict check if sk_reuseport_match() finds the new
socket's address covered by the socket cached in tb->fast_*.

This is only safe if both sockets match on everything
inet_bind_conflict() reads. The cache misses some of it:

- It does not record sk_bound_dev_if or sk_reuse.
- It records the family and IPV6_V6ONLY but never compares them with
  the new socket, so a cached v6only [::] (or 0.0.0.0) socket covers
  a dual-stack [::] socket.

As a result, an unprivileged user can bind and listen on a port that
another user is listening on, for example a dual-stack [::] socket on
top of a 0.0.0.0 listener:

  victim:   bind(0.0.0.0:P), listen()
  attacker: SO_REUSEPORT + IPV6_V6ONLY, bind([::]:P)   /* fills cache */
  attacker: SO_REUSEPORT, bind([::]:P), listen()       /* should fail */

Only take the fast path when the new socket matches the cached one in
family, IPV6_V6ONLY, bound device and SO_REUSEADDR. Identical
SO_REUSEPORT listeners, the workload this cache was added for, still
skip the scan (binding 16384 of them: 9.80 ms before, 9.86 ms after,
5874 ms with the full check every time).

Fixes: 637bc8bbe6c0 ("inet: reset tb->fastreuseport when adding a reuseport sk")
Cc: stable@vger.kernel.org
Signed-off-by: Juan Agustin Niccolini <juanagusnicco@gmail.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Link: https://patch.msgid.link/20261111174704.24312-2-juanagusnicco@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 include/net/inet_hashtables.h   |    2 ++
 net/ipv4/inet_connection_sock.c |   15 ++++++++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)

--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -87,6 +87,8 @@ struct inet_bind_bucket {
 	__be32			fast_rcv_saddr;
 	unsigned short		fast_sk_family;
 	bool			fast_ipv6_only;
+	unsigned char		fast_sk_reuse;
+	int			fast_bound_dev_if;
 	struct hlist_node	node;
 	struct hlist_head	bhash2;
 };
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -422,13 +422,18 @@ static inline int sk_reuseport_match(str
 		return 0;
 	if (!uid_eq(tb->fastuid, uid))
 		return 0;
-	/* We only need to check the rcv_saddr if this tb was once marked
+	/* We only need to check the fast_* fields if this tb was once marked
 	 * without fastreuseport and then was reset, as we can only know that
-	 * the fast_*rcv_saddr doesn't have any conflicts with the socks on the
-	 * owners list.
+	 * the socket they describe doesn't have any conflicts with the socks
+	 * on the owners list.
 	 */
 	if (tb->fastreuseport == FASTREUSEPORT_ANY)
 		return 1;
+	if (tb->fast_sk_family != sk->sk_family ||
+	    tb->fast_ipv6_only != ipv6_only_sock(sk) ||
+	    tb->fast_bound_dev_if != sk->sk_bound_dev_if ||
+	    tb->fast_sk_reuse != sk->sk_reuse)
+		return 0;
 #if IS_ENABLED(CONFIG_IPV6)
 	if (tb->fast_sk_family == AF_INET6)
 		return ipv6_rcv_saddr_equal(&tb->fast_v6_rcv_saddr,
@@ -458,6 +463,8 @@ void inet_csk_update_fastreuse(struct in
 			tb->fast_rcv_saddr = sk->sk_rcv_saddr;
 			tb->fast_ipv6_only = ipv6_only_sock(sk);
 			tb->fast_sk_family = sk->sk_family;
+			tb->fast_sk_reuse = sk->sk_reuse;
+			tb->fast_bound_dev_if = sk->sk_bound_dev_if;
 #if IS_ENABLED(CONFIG_IPV6)
 			tb->fast_v6_rcv_saddr = sk->sk_v6_rcv_saddr;
 #endif
@@ -485,6 +492,8 @@ void inet_csk_update_fastreuse(struct in
 				tb->fast_rcv_saddr = sk->sk_rcv_saddr;
 				tb->fast_ipv6_only = ipv6_only_sock(sk);
 				tb->fast_sk_family = sk->sk_family;
+				tb->fast_sk_reuse = sk->sk_reuse;
+				tb->fast_bound_dev_if = sk->sk_bound_dev_if;
 #if IS_ENABLED(CONFIG_IPV6)
 				tb->fast_v6_rcv_saddr = sk->sk_v6_rcv_saddr;
 #endif



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 456/555] udp: use skb_set_transport_header_careful() in __udp6_lib_err_encap()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (454 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 455/555] tcp: Fix the SO_REUSEPORT bind cache admitting a conflicting socket Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 457/555] vgacon: Fall back to the dummy console if mapping VGA memory fails Greg Kroah-Hartman
                   ` (98 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Eric Dumazet, Stefano Brivio,
	Justin Iurman, Paolo Abeni

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Eric Dumazet <edumazet@kernel.org>

commit 02f578b736f1524ed73ef879fb1cf1ba4a875aa4 upstream.

skb->transport_header is a 16-bit offset from skb->head, and U16_MAX is
reserved as the "not set" value. skb_set_transport_header() silently
truncates an offset that does not fit.

__udp6_lib_err_encap() stores @offset, computed by icmpv6_notify() from
the extension headers of the packet embedded in an ICMPv6 error. Should
the value be truncated, the tunnel encap_err_lookup() and err_handler()
callbacks would read the UDP header at the wrong place.

Since commit 3744b0964d52 ("ipv6: Implement limits on extension header
parsing") a single chain is bounded to IP6_MAX_EXT_HDRS_CNT headers
(24576 bytes), so this needs a large skb->data - skb->head on top of it,
for instance after several nested decapsulations, each of them possibly
pulling its own extension header chain, since @offset is relative to
the IPv6 header embedded in the ICMPv6 error. No reproducer was written,
this is hardening.

Use skb_set_transport_header_careful() and return an error if the
offset can not be stored, in which case udpv6_err() ignores the
ICMPv6 error. Do this before changing the network header, so that
nothing has to be restored on failure.

Fixes: a36e185e8c85 ("udp: Handle ICMP errors for tunnels with same destination port on both endpoints")
Cc: stable@vger.kernel.org
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
Link: https://patch.msgid.link/20261113124625.4010206-6-edumazet@kernel.org
Reviewed-by: Justin Iurman <justin.iurman@gmail.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/ipv6/udp.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -576,12 +576,13 @@ static struct sock *__udp6_lib_err_encap
 	network_offset = skb_network_offset(skb);
 	transport_offset = skb_transport_offset(skb);
 
+	/* Transport header needs to point to the UDP header */
+	if (unlikely(!skb_set_transport_header_careful(skb, offset)))
+		return ERR_PTR(-EINVAL);
+
 	/* Network header needs to point to the outer IPv6 header inside ICMP */
 	skb_reset_network_header(skb);
 
-	/* Transport header needs to point to the UDP header */
-	skb_set_transport_header(skb, offset);
-
 	if (sk) {
 		up = udp_sk(sk);
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 457/555] vgacon: Fall back to the dummy console if mapping VGA memory fails
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (455 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 456/555] udp: use skb_set_transport_header_careful() in __udp6_lib_err_encap() Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 458/555] virtiofs: fix use-after-free of fs->tag on device removal Greg Kroah-Hartman
                   ` (97 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Matt Turner, Magnus Lindholm,
	Helge Deller

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Matt Turner <mattst88@gmail.com>

commit e3512c7628621f7048a9615d21fd7cf63173c518 upstream.

On Alpha, setup_arch() registers vgacon whenever CONFIG_VGA_CONSOLE is
enabled. On Marvel (EV7) systems whose SRM console is serial, no VGA
hose is set, so marvel_ioremap() finds no hose for 0xb8000 and returns
NULL. vgacon_startup() then probes video memory through that NULL
pointer and oopses in console_init():

  Unable to handle kernel paging request at virtual address 0000000000000000
  pc is at vgacon_startup+0x174/0x910

VGA_MAP_MEM() is ioremap() on Alpha and powerpc and can fail. Treat
failure like a failed probe and fall back to the dummy console. If a
VGA card is present, locate_and_init_vga() still switches to vgacon
once PCI is up.

Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Magnus Lindholm <linmag7@gmail.com>
Tested-by: Magnus Lindholm <linmag7@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/video/console/vgacon.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -324,6 +324,8 @@ static const char *vgacon_startup(void)
 	}
 
 	vga_vram_base = VGA_MAP_MEM(vga_vram_base, vga_vram_size);
+	if (!vga_vram_base)
+		goto no_vga;
 	vga_vram_end = vga_vram_base + vga_vram_size;
 
 	/*



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 458/555] virtiofs: fix use-after-free of fs->tag on device removal
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (456 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 457/555] vgacon: Fall back to the dummy console if mapping VGA memory fails Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 459/555] watchdog: npcm: fix sleeping clock call in restart handler Greg Kroah-Hartman
                   ` (96 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Sashiko, Miklos Szeredi

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Miklos Szeredi <mszeredi@redhat.com>

commit 6df984631391616dafd9b989a3505d93ca4fd235 upstream.

The virtio_fs object is refcounted via its kobject, so a mount can keep it
alive well beyond the lifetime of the virtio device binding.  The tag
string, however, was allocated with devm_kmalloc() and is therefore freed
by devres_release_all() as soon as the device is unbound, i.e. right after
virtio_fs_remove() returns (see device_unbind_cleanup() in
drivers/base/dd.c).

virtio_fs_get_tree() looks up the instance, takes a kobject reference and
then drops virtio_fs_mutex before doing the sleepable part of the mount
(allocations, fuse_conn_init(), sget_fc()).  A concurrent device removal
can complete in that window:

  CPU 0 (mount)                         CPU 1 (remove)
  -------------                         --------------
  virtio_fs_get_tree()
    virtio_fs_find_instance()
    // reference taken, mutex dropped
                                        virtio_fs_remove()
                                          list_del_init(&fs->list);
                                        // driver core unbinds device
                                        // devres frees fs->tag
  virtio_fs_fill_super()
    mutex_lock(&virtio_fs_mutex);
    if (list_empty(&fs->list))
            pr_info(... fs->tag);   <-- use-after-free

The virtio_fs object itself is still valid here, only its tag has been
freed behind its back.

Fix the lifetime mismatch at the source: allocate the tag with kmalloc()
and free it from virtio_fs_ktype_release(), so that it lives exactly as
long as the object embedding it.  All probe error paths already drop the
final kobject reference, so they are covered.  Merely dropping the tag
from the error message would paper over this instance while leaving a
devres pointer embedded in an object that routinely outlives its device.

The other readers of fs->tag are unaffected: tag_show() is fenced off by
the kobject_del() in virtio_fs_remove(), the automatic KOBJ_REMOVE uevent
is emitted from __kobject_del() while the device is still bound, and both
virtio_fs_add_instance() and virtio_fs_find_instance() only walk instances
still on virtio_fs_instances.

Fixes: a62a8ef9d97d ("virtio-fs: add virtiofs filesystem")
Cc: <stable@vger.kernel.org>
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-0328b3a1-043b-468e-8425-6a613d91b5ef
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/fuse/virtio_fs.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

--- a/fs/fuse/virtio_fs.c
+++ b/fs/fuse/virtio_fs.c
@@ -191,6 +191,7 @@ static void virtio_fs_ktype_release(stru
 {
 	struct virtio_fs *vfs = container_of(kobj, struct virtio_fs, kobj);
 
+	kfree(vfs->tag);
 	kfree(vfs->mq_map);
 	kfree(vfs->vqs);
 	kfree(vfs);
@@ -487,7 +488,11 @@ static void virtio_fs_free_devs(struct v
 	}
 }
 
-/* Read filesystem name from virtio config into fs->tag (must kfree()). */
+/*
+ * Read filesystem name from virtio config into fs->tag.  Freed by
+ * virtio_fs_ktype_release() so that it stays valid for as long as the
+ * virtio_fs object itself, which may outlive the virtio device.
+ */
 static int virtio_fs_read_tag(struct virtio_device *vdev, struct virtio_fs *fs)
 {
 	char tag_buf[sizeof_field(struct virtio_fs_config, tag)];
@@ -503,7 +508,7 @@ static int virtio_fs_read_tag(struct vir
 		end = &tag_buf[sizeof(tag_buf)];
 
 	len = end - tag_buf;
-	fs->tag = devm_kmalloc(&vdev->dev, len + 1, GFP_KERNEL);
+	fs->tag = kmalloc(len + 1, GFP_KERNEL);
 	if (!fs->tag)
 		return -ENOMEM;
 	memcpy(fs->tag, tag_buf, len);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 459/555] watchdog: npcm: fix sleeping clock call in restart handler
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (457 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 458/555] virtiofs: fix use-after-free of fs->tag on device removal Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 460/555] x86/apic/msi: Fix MSI interrupt affinity configuration Greg Kroah-Hartman
                   ` (95 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Zhao Feng, Guenter Roeck

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Zhao Feng <zhaofeng2@cmss.chinamobile.com>

commit 4e83ea5b22193fd0db8bcee5682935f1d528705e upstream.

The watchdog .restart callback runs in atomic context: it is invoked
from the restart handler chain via atomic_notifier_call_chain(), under
an RCU read-side critical section, on every reboot or restart.  Since
commit af084fdccfaf ("watchdog: npcm: Enable clock if provided"),
npcm_wdt_restart() calls clk_prepare_enable(), and clk_prepare()
takes a mutex unconditionally, so kernels built with
CONFIG_DEBUG_ATOMIC_SLEEP=y report

  BUG: sleeping function called from invalid context

on every reboot.  Worse, a panic-time restart can block on
prepare_lock and never issue the reset at all.

Get the clock with devm_clk_get_optional_prepared() at probe time and
keep it prepared for the lifetime of the driver, so the restart
handler only needs clk_enable(), which is safe in atomic context.
With the clock permanently prepared, npcm_wdt_start() and
npcm_wdt_stop() are simplified to clk_enable()/clk_disable() as well.

Fixes: af084fdccfaf ("watchdog: npcm: Enable clock if provided")
Cc: stable@vger.kernel.org
Signed-off-by: Zhao Feng <zhaofeng2@cmss.chinamobile.com>
Link: https://patch.msgid.link/20261111083236.248-1-zhaofeng2@cmss.chinamobile.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/watchdog/npcm_wdt.c |   19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

--- a/drivers/watchdog/npcm_wdt.c
+++ b/drivers/watchdog/npcm_wdt.c
@@ -98,7 +98,7 @@ static int npcm_wdt_start(struct watchdo
 {
 	struct npcm_wdt *wdt = to_npcm_wdt(wdd);
 
-	clk_prepare_enable(wdt->clk);
+	clk_enable(wdt->clk);
 
 	__npcm_wdt_start(wdd);
 
@@ -111,7 +111,7 @@ static int npcm_wdt_stop(struct watchdog
 
 	writel(0, wdt->reg);
 
-	clk_disable_unprepare(wdt->clk);
+	clk_disable(wdt->clk);
 
 	return 0;
 }
@@ -160,8 +160,12 @@ static int npcm_wdt_restart(struct watch
 {
 	struct npcm_wdt *wdt = to_npcm_wdt(wdd);
 
-	/* For reset, we start the WDT clock and leave it running. */
-	clk_prepare_enable(wdt->clk);
+	/*
+	 * For reset, we start the WDT clock and leave it running.
+	 * The clock was prepared at probe time; only clk_enable() is
+	 * safe in this atomic (restart notifier) context.
+	 */
+	clk_enable(wdt->clk);
 
 	writel(NPCM_WTR | NPCM_WTRE | NPCM_WTE, wdt->reg);
 	udelay(1000);
@@ -207,7 +211,12 @@ static int npcm_wdt_probe(struct platfor
 	if (IS_ERR(wdt->reg))
 		return PTR_ERR(wdt->reg);
 
-	wdt->clk = devm_clk_get_optional(&pdev->dev, NULL);
+	/*
+	 * Keep the clock prepared for the lifetime of the driver:
+	 * npcm_wdt_restart() runs in atomic context and may only call
+	 * clk_enable().
+	 */
+	wdt->clk = devm_clk_get_optional_prepared(&pdev->dev, NULL);
 	if (IS_ERR(wdt->clk))
 		return PTR_ERR(wdt->clk);
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 460/555] x86/apic/msi: Fix MSI interrupt affinity configuration
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (458 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 459/555] watchdog: npcm: fix sleeping clock call in restart handler Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 461/555] x86/mce: Do not treat cache hierarchy errors as memory errors Greg Kroah-Hartman
                   ` (94 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Weitao Wang, Borislav Petkov (AMD),
	Koichiro Den, Thomas Gleixner

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: WeitaoWang-oc <WeitaoWang-oc@zhaoxin.com>

commit 068d82afd070beb8ea32c8ee64d685af7d3f36e2 upstream.

The two step update sequence in msi_set_affinity() is required for MSI
interrupts which cannot be migrated atomically, i.e. devices which do not
provide MSI masking.

The MSI message update writes address and data registers separately, so such
a device can raise an interrupt in between, which results in a message built
from half updated state: a stray interrupt on a stale vector and a possibly
lost device interrupt.

The update sequence is selected by a per interrupt quirk flag, which is set
for interrupts which cannot use reservation mode. Reservation mode is only
enabled for maskable interrupts, i.e. devices which provide MSI-X or
mask support, so the quirk flag is the inverse of the reservation mode
bit.

The removal of the quirk flag replaced the flag check with a reservation mode
check, but dropped the negation of the removed condition:

   - if (!irqd_msi_nomask_quirk(irqd) || ...)
   + if (!irqd_can_reserve(irqd) || ...)

As the quirk flag is the inverse of the reservation mode bit, the replacement
inverted the condition and selects the wrong update path for every interrupt:
non-maskable interrupts take the direct update path again, which reopens the
race, while maskable interrupts needlessly go through the two step update.

Restore the original condition so that the direct update path is selected when
reservation mode is enabled, which also matches the comment above the check:
direct update is possible when the MSI is maskable, which is the case when the
reservation mode bit is set.

  [ bp: Massage commit message. ]

Fixes: b56ebe7c896d ("x86/apic/msi: Fix misconfigured non-maskable MSI quirk")
Signed-off-by: Weitao Wang <WeitaoWang-oc@zhaoxin.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Koichiro Den <den@valinux.co.jp>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org # v6.1+
Link: https://patch.msgid.link/20261016181016.3850-1-WeitaoWang-oc@zhaoxin.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/x86/kernel/apic/msi.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/x86/kernel/apic/msi.c
+++ b/arch/x86/kernel/apic/msi.c
@@ -62,7 +62,7 @@ msi_set_affinity(struct irq_data *irqd,
 	 * - The interrupt is not yet started up
 	 * - The new destination CPU is the same as the old destination CPU
 	 */
-	if (!irqd_can_reserve(irqd) ||
+	if (irqd_can_reserve(irqd) ||
 	    cfg->vector == old_cfg.vector ||
 	    old_cfg.vector == MANAGED_IRQ_SHUTDOWN_VECTOR ||
 	    !irqd_is_started(irqd) ||



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 461/555] x86/mce: Do not treat cache hierarchy errors as memory errors
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (459 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 460/555] x86/apic/msi: Fix MSI interrupt affinity configuration Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 462/555] xarray: fix index jumping backwards in xas_find() Greg Kroah-Hartman
                   ` (93 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Adrian Schlegel,
	Borislav Petkov (AMD), Qiuxu Zhuo, Tony Luck, Yazen Ghannam,
	Sohil Mehta, stable

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Adrian Schlegel <me@adrianschlegel.com>

commit 29b74cf57f432d60da2b79c827f1379125409611 upstream.

On Intel and Zhaoxin, mce_is_memory_error() also returns true for cache
hierarchy errors. All callers expect it to report memory errors only.

The CEC uses it to count corrected DRAM errors. A corrected cache error only
names the cache line that was affected, not a faulty DRAM page.  With a faulty
CPU core, the CEC therefore soft-offlines healthy pages.  On an i9-9900K this
caused about 500 soft-offline attempts per hour.

Report only memory controller errors on Intel and Zhaoxin, as is already done
for AMD.

Fixes: fa92c5869426 ("x86, mce: Support memory error recovery for both UCNA and Deferred error in machine_check_poll")
Signed-off-by: Adrian Schlegel <me@adrianschlegel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Qiuxu Zhuo <qzhuo@nvidia.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Yazen Ghannam <yazen.ghannam@amd.com>
Reviewed-by: Sohil Mehta <sohil.mehta@intel.com>
Cc: <stable@kernel.org>
Link: https://patch.msgid.link/20261012193305.38931-1-me@adrianschlegel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/x86/kernel/cpu/mce/core.c |   18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

--- a/arch/x86/kernel/cpu/mce/core.c
+++ b/arch/x86/kernel/cpu/mce/core.c
@@ -526,21 +526,13 @@ bool mce_is_memory_error(struct mce *m)
 	case X86_VENDOR_INTEL:
 	case X86_VENDOR_ZHAOXIN:
 		/*
-		 * Intel SDM Volume 3B - 15.9.2 Compound Error Codes
+		 * Intel SDM Volume 3B "Compound Error Codes".
 		 *
-		 * Bit 7 of the MCACOD field of IA32_MCi_STATUS is used for
-		 * indicating a memory error. Bit 8 is used for indicating a
-		 * cache hierarchy error. The combination of bit 2 and bit 3
-		 * is used for indicating a `generic' cache hierarchy error
-		 * But we can't just blindly check the above bits, because if
-		 * bit 11 is set, then it is a bus/interconnect error - and
-		 * either way the above bits just gives more detail on what
-		 * bus/interconnect error happened. Note that bit 12 can be
-		 * ignored, as it's the "filter" bit.
+		 * Memory controller errors have an MCACOD of 000F 0000 1MMM CCCC:
+		 * bit 7 set, bits 8-11 and 13-15 clear. Bit 12 is the "filter"
+		 * bit and is ignored.
 		 */
-		return (m->status & 0xef80) == BIT(7) ||
-		       (m->status & 0xef00) == BIT(8) ||
-		       (m->status & 0xeffc) == 0xc;
+		return (m->status & 0xef80) == BIT(7);
 
 	default:
 		return false;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 462/555] xarray: fix index jumping backwards in xas_find()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (460 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 461/555] x86/mce: Do not treat cache hierarchy errors as memory errors Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 463/555] zonefs: ignore RLIMIT_FSIZE above LLONG_MAX in zonefs_write_check_limits() Greg Kroah-Hartman
                   ` (92 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, syzbot+b72767277f29b6407083,
	Krystian Kaniewski, Andrew Morton, Jose Fernandez (Anthropic),
	Matthew Wilcox (Oracle), Mike Rapoport

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Krystian Kaniewski <krystianmkaniewski@gmail.com>

commit a4e667346a8d91e629a2ca9affc70dc28978f4a1 upstream.

A bug in the XArray iterator xas_find() causes the iterator's index
(xas->xa_index) to jump backwards when iterating over a multi-index entry
(like a THP) that resides in a non-leaf node and is concurrently split.

When iterating over a multi-index entry in a non-leaf node, xas_load()
sets xas->xa_offset to the base offset of the entry, but leaves
xas->xa_index at the requested index.  When the caller subsequently wants
to advance to the next entry, xas_find() is called.  xas_find() attempts
to synchronize xas->xa_offset with xas->xa_index before advancing.
However, the fixup logic was incorrectly restricted to leaf nodes
(!xas->xa_node->shift).  Because the THP resides in a non-leaf node, the
fixup is skipped.

As a result, xas_find() simply increments xas->xa_offset and recalculates
xas->xa_index based on this new offset.  This causes xas->xa_index to jump
backwards.  If the THP was concurrently split, the entry at the new offset
is a node pointer, so xas_find() descends into it and returns the folio at
the backwards index.  The caller (filemap_map_pages()) then calculates the
PTE pointer based on this backwards index, resulting in an invalid memory
access such as an out-of-bounds read or use-after-free on a page-table
page freed via tlb_remove_table_rcu().

A userspace access that faults in a file-backed mapping can trigger this
path.  When the index moves backwards, filemap_map_pages() can calculate a
PTE outside the page locked for fault-around and dereference a freed
page-table page, resulting in a KASAN-detected use-after-free read.

To fix this, check if xas->xa_offset matches get_offset(xas->xa_index,
xas->xa_node).  If it does not and the node is a non-leaf node, set
xas->xa_offset to get_offset(xas->xa_index, xas->xa_node) before
advancing.  Also add test cases in test_xarray to verify xas_find()
behavior when iterating over and splitting multi-index entries.

Link: https://lore.kernel.org/20260904121301.200049-1-krystianmkaniewski@gmail.com
Fixes: b803b42823d0 ("xarray: Add XArray iterators")
Reported-by: syzbot+b72767277f29b6407083@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=b72767277f29b6407083
Closes: https://syzkaller.appspot.com/ai_job?id=a01c56bd-74d0-411c-afb4-ee6f0cb6cb61
Signed-off-by: Krystian Kaniewski <krystianmkaniewski@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Tested-by: Jose Fernandez (Anthropic) <jose.fernandez@linux.dev>
  Link: https://lore.kernel.org/20261104-jf-filemap-v2-pedro-reply-r2-74c87c6fbcf@linux.dev
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 lib/test_xarray.c |   70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/xarray.c      |    8 +++---
 2 files changed, 75 insertions(+), 3 deletions(-)

--- a/lib/test_xarray.c
+++ b/lib/test_xarray.c
@@ -1234,6 +1234,75 @@ static noinline void check_multi_find_3(
 	}
 }
 
+static noinline void check_multi_find_4(struct xarray *xa)
+{
+#ifdef CONFIG_XARRAY_MULTI
+	unsigned int order = XA_CHUNK_SHIFT + 1;
+	unsigned long next = 1UL << order;
+	unsigned long start = next - 1;
+	XA_STATE(xas, xa, start);
+	XA_STATE_ORDER(split, xa, 0, 0);
+	void *entry;
+	unsigned long i;
+
+	/* Multi-index entry in two slots of a non-leaf node. */
+	xa_store_order(xa, 0, order, xa_mk_index(0), GFP_KERNEL);
+	XA_BUG_ON(xa, xa_store_index(xa, next, GFP_KERNEL) != NULL);
+
+	rcu_read_lock();
+	entry = xas_find(&xas, ULONG_MAX);
+	XA_BUG_ON(xa, entry != xa_mk_index(0));
+	XA_BUG_ON(xa, xas.xa_index != start);
+
+	entry = xas_find(&xas, ULONG_MAX);
+	XA_BUG_ON(xa, entry != xa_mk_index(next));
+	XA_BUG_ON(xa, xas.xa_index != next);
+
+	entry = xas_find(&xas, ULONG_MAX);
+	XA_BUG_ON(xa, entry != NULL);
+	rcu_read_unlock();
+
+	xa_erase_index(xa, next);
+	xa_erase_index(xa, 0);
+	XA_BUG_ON(xa, !xa_empty(xa));
+
+	/* Split the multi-index entry after a lookup begins inside it. */
+	xa_store_order(xa, 0, order, xa_mk_index(0), GFP_KERNEL);
+	XA_BUG_ON(xa, xa_store_index(xa, next, GFP_KERNEL) != NULL);
+
+	xas_set(&xas, start);
+	rcu_read_lock();
+	entry = xas_find(&xas, ULONG_MAX);
+	XA_BUG_ON(xa, entry != xa_mk_index(0));
+	XA_BUG_ON(xa, xas.xa_index != start);
+	rcu_read_unlock();
+
+	xas_split_alloc(&split, xa_mk_index(0), order, GFP_KERNEL);
+	if (xas_error(&split)) {
+		XA_BUG_ON(xa, true);
+		goto out;
+	}
+	xas_lock(&split);
+	xas_split(&split, xa_mk_index(0), order);
+	for (i = 0; i < next; i++)
+		__xa_store(xa, i, xa_mk_index(i), 0);
+	xas_unlock(&split);
+
+	rcu_read_lock();
+	entry = xas_find(&xas, ULONG_MAX);
+	XA_BUG_ON(xa, entry != xa_mk_index(next));
+	XA_BUG_ON(xa, xas.xa_index != next);
+
+	entry = xas_find(&xas, ULONG_MAX);
+	XA_BUG_ON(xa, entry != NULL);
+	rcu_read_unlock();
+
+out:
+	xa_destroy(xa);
+	XA_BUG_ON(xa, !xa_empty(xa));
+#endif
+}
+
 static noinline void check_find_1(struct xarray *xa)
 {
 	unsigned long i, j, k;
@@ -1357,6 +1426,7 @@ static noinline void check_find(struct x
 		check_multi_find_1(xa, i);
 	check_multi_find_2(xa);
 	check_multi_find_3(xa);
+	check_multi_find_4(xa);
 }
 
 /* See find_swap_entry() in mm/shmem.c */
--- a/lib/xarray.c
+++ b/lib/xarray.c
@@ -1269,9 +1269,11 @@ void *xas_find(struct xa_state *xas, uns
 		entry = xas_load(xas);
 		if (entry || xas_not_node(xas->xa_node))
 			return entry;
-	} else if (!xas->xa_node->shift &&
-		    xas->xa_offset != (xas->xa_index & XA_CHUNK_MASK)) {
-		xas->xa_offset = ((xas->xa_index - 1) & XA_CHUNK_MASK) + 1;
+	} else if (xas->xa_offset != get_offset(xas->xa_index, xas->xa_node)) {
+		if (!xas->xa_node->shift)
+			xas->xa_offset = ((xas->xa_index - 1) & XA_CHUNK_MASK) + 1;
+		else
+			xas->xa_offset = get_offset(xas->xa_index, xas->xa_node);
 	}
 
 	xas_next_offset(xas);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 463/555] zonefs: ignore RLIMIT_FSIZE above LLONG_MAX in zonefs_write_check_limits()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (461 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 462/555] xarray: fix index jumping backwards in xas_find() Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 464/555] xfs: break layouts before swapping extents Greg Kroah-Hartman
                   ` (91 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Ding Feng, Damien Le Moal

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ding Feng <dingf3ng@gmail.com>

commit fb5289b697c965581104bafdd875b969a1db3e79 upstream.

zonefs_write_check_limits() follows generic_write_check_limits() and
has the same problem: it stores rlimit(RLIMIT_FSIZE), an unsigned long,
in a loff_t, so a soft limit between 2^63 and RLIM_INFINITY is negative
and every write fails with -EFBIG and raises SIGXFSZ.

Keep the limit unsigned and apply it only when it is at most LLONG_MAX,
as the generic helper now does.

Fixes: ebfd68cd0c1e ("zonefs: Fix O_APPEND async write handling")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-5-5 Frama-C
Signed-off-by: Ding Feng <dingf3ng@gmail.com>
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/zonefs/file.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

--- a/fs/zonefs/file.c
+++ b/fs/zonefs/file.c
@@ -390,15 +390,16 @@ static loff_t zonefs_write_check_limits(
 {
 	struct inode *inode = file_inode(file);
 	struct zonefs_zone *z = zonefs_inode_zone(inode);
-	loff_t limit = rlimit(RLIMIT_FSIZE);
+	u64 limit = rlimit(RLIMIT_FSIZE);
 	loff_t max_size = z->z_capacity;
 
-	if (limit != RLIM_INFINITY) {
-		if (pos >= limit) {
+	/* No file position reaches a limit above LLONG_MAX. */
+	if (limit != RLIM_INFINITY && limit <= LLONG_MAX) {
+		if (pos >= (loff_t)limit) {
 			send_sig(SIGXFSZ, current, 0);
 			return -EFBIG;
 		}
-		count = min(count, limit - pos);
+		count = min(count, (loff_t)limit - pos);
 	}
 
 	if (!(file->f_flags & O_LARGEFILE))



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 464/555] xfs: break layouts before swapping extents
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (462 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 463/555] zonefs: ignore RLIMIT_FSIZE above LLONG_MAX in zonefs_write_check_limits() Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 465/555] xfs: keep successful near rt allocations Greg Kroah-Hartman
                   ` (90 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Daejun Park, Christoph Hellwig,
	Carlos Maiolino

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Daejun Park <daejun7.park@samsung.com>

commit 0d8026c7ac0c79a8ebe2942a3c3114c06aced734 upstream.

XFS_IOC_SWAPEXT does not break pNFS layouts. A client can keep writing
to blocks that the swap moved to the temporary file. xfs_fsr frees
those blocks when it closes that file. The writes then land in whatever
reuses them.

Lock with xfs_ilock2_io_mmap(), as the exchange-range ioctls do.

Fixes: 781355c6e5ae ("xfs: recall pNFS layouts on conflicting access")
Cc: stable@vger.kernel.org
Signed-off-by: Daejun Park <daejun7.park@samsung.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/xfs_bmap_util.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1514,9 +1514,9 @@ xfs_swap_extents(
 	 * page cache safely. Once we have done this we can take the ilocks and
 	 * do the rest of the checks.
 	 */
-	lock_two_nondirectories(VFS_I(ip), VFS_I(tip));
-	filemap_invalidate_lock_two(VFS_I(ip)->i_mapping,
-				    VFS_I(tip)->i_mapping);
+	error = xfs_ilock2_io_mmap(ip, tip);
+	if (error)
+		return error;
 
 	/* Verify that both files have the same format */
 	if ((VFS_I(ip)->i_mode & S_IFMT) != (VFS_I(tip)->i_mode & S_IFMT)) {
@@ -1710,9 +1710,7 @@ out_unlock_ilock:
 	xfs_iunlock(ip, XFS_ILOCK_EXCL);
 	xfs_iunlock(tip, XFS_ILOCK_EXCL);
 out_unlock:
-	filemap_invalidate_unlock_two(VFS_I(ip)->i_mapping,
-				      VFS_I(tip)->i_mapping);
-	unlock_two_nondirectories(VFS_I(ip), VFS_I(tip));
+	xfs_iunlock2_io_mmap(ip, tip);
 	return error;
 
 out_trans_cancel:



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 465/555] xfs: keep successful near rt allocations
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (463 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 464/555] xfs: break layouts before swapping extents Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 466/555] xfs: wait for direct I/O before swapping extents Greg Kroah-Hartman
                   ` (89 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Christian Andres Saide, Rik van Riel,
	Christoph Hellwig, Carlos Maiolino, Carlos Maiolino

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Rik van Riel <riel@surriel.com>

commit f9bfe5af596a5ef6fc745c30bda41f9a109ed16d upstream.

XFS realtime allocations first attempt to allocate space near where
other parts of a file already are. If that allocation succeeds, it
does not have to do a global search for free space.

Unfortunately, a code cleanup a while ago causes xfs_rtallocate_rtg
to unconditionally do the global search, even when the search for a
nearby extent has succeeded.

Fix it by running the global search only when the near search did
not find available space.

Found by noticing higher kernel CPU use and examining the profile.

Fixes: fd048a1bb391d ("xfs: rework the rtalloc fallback handling")
Cc: stable@vger.kernel.org # v6.12
Reported-by: Christian Andres Saide <csaide@meta.com>
Signed-off-by: Rik van Riel <riel@surriel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/xfs_rtalloc.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -1310,10 +1310,14 @@ xfs_rtallocate(
 		if (error == -ENOSPC) {
 			xfs_rtbuf_cache_relse(&args);
 			error = 0;
+			start = 0;
 		}
 	}
 
-	if (!error) {
+	/*
+	 * Global search, runs when the near search did not find space.
+	 */
+	if (!error && !start) {
 		error = xfs_rtallocate_extent_size(&args, minlen, maxlen, &len,
 				prod, &rtx);
 	}



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 466/555] xfs: wait for direct I/O before swapping extents
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (464 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 465/555] xfs: keep successful near rt allocations Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 467/555] net: bridge: fix skb leak of reinjected link-local frames Greg Kroah-Hartman
                   ` (88 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Daejun Park, Christoph Hellwig,
	Carlos Maiolino

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Daejun Park <daejun7.park@samsung.com>

commit 844bc1167f1b2d19d9495a556599af24dc4468bd upstream.

An AIO direct write drops the iolock before its bios complete.
XFS_IOC_SWAPEXT does not wait for it. The write can land in blocks that
the swap moved to the temporary file. Once xfs_fsr frees them, the
write corrupts whatever reuses them.

Wait for direct I/O first, as exchange-range does.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Daejun Park <daejun7.park@samsung.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/xfs/xfs_bmap_util.c |    1 +
 1 file changed, 1 insertion(+)

--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1217,6 +1217,7 @@ xfs_swap_extent_flush(
 {
 	int	error;
 
+	inode_dio_wait(VFS_I(ip));
 	error = filemap_write_and_wait(VFS_I(ip)->i_mapping);
 	if (error)
 		return error;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 467/555] net: bridge: fix skb leak of reinjected link-local frames
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (465 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 466/555] xfs: wait for direct I/O before swapping extents Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 468/555] net: e1000: fix warning in iounmap on probe failure Greg Kroah-Hartman
                   ` (87 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Daniel Wade, Xia Yan,
	Nikolay Aleksandrov, Jakub Kicinski

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Daniel Wade <danjwade95@gmail.com>

commit 98382d41f92f048cf3cbb7af415f48a722b19ebc upstream.

br_handle_frame() passes the link-local frames it neither forwards nor
delivers (01:80:c2:00:00:02 to 0d and 0f, unless set in the group
forward mask) through NF_HOOK() at NF_BR_LOCAL_IN. Since commit
3b2e2904deb3 ("net: bridge: fix per-port af_packet sockets") the okfn
only learns the source and returns 1, which becomes RX_HANDLER_PASS.

That commit sent the nf_queue case to RX_HANDLER_CONSUMED, which is
right for the synchronous return, but the frame comes back: on
reinjection nf_reinject() calls the okfn and ignores its return value,
because every other okfn consumes the skb. This one no longer does, so
nothing frees the frame. NFQA_CFG_F_FAIL_OPEN leaks it the same way
with no verdict at all, when the queue or the listener's socket is full.

Each frame leaks an skb, and one sent from a local socket keeps that
socket charged, so neither it nor the network namespace holding it is
freed. Bridge, rule and queue need only CAP_NET_ADMIN in a netns, so
with user namespaces an unprivileged user can exhaust kernel memory.

nf_reinject() cannot free the skb on a 1 from the okfn, because other
okfns return NET_RX_DROP, which is 1, after freeing it.

Call nf_hook() instead of NF_HOOK() and do the learning and the
RX_HANDLER_PASS return in br_handle_frame() on 1, as the 0x00 and 0x0e
cases already do and as vrf_rcv_nfhook() does. The okfn then runs only
for a reinjected frame, which br_handle_frame() has already reported
consumed and cannot pass on the port, so it learns from the frame and
frees it. These frames were not delivered before this change either.

Also set *pskb before the new RX_HANDLER_PASS, as the other such
returns do; skb_share_check() may have replaced the skb, and the commit
above added that return without the assignment.

Discovered by an AI code review agent and reproduced on unmodified
mainline under KASAN: an unprivileged user in a new user and network
namespace bridged a veth, queued link-local frames to an NFQUEUE
listener that accepted every one, and leaked an skb per frame. With
this patch the reinjected frames are freed and nothing leaks.

Fixes: 3b2e2904deb3 ("net: bridge: fix per-port af_packet sockets")
Cc: stable@vger.kernel.org
Signed-off-by: Daniel Wade <danjwade95@gmail.com>
Reviewed-by: Xia Yan <yanxia@cmss.chinamobile.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Link: https://patch.msgid.link/20261115130211.7724-1-danjwade95@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/bridge/br_input.c |   18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -241,13 +241,18 @@ static void __br_handle_local_finish(str
 		br_fdb_update(p->br, p, eth_hdr(skb)->h_source, vid, 0);
 }
 
-/* note: already called with rcu_read_lock */
+/* okfn of the link-local NF_BR_LOCAL_IN hook in br_handle_frame(). It is
+ * only called when a queued frame is reinjected, after br_handle_frame()
+ * returned RX_HANDLER_CONSUMED for it, so the frame can no longer be
+ * passed up on the port and has to be freed here.
+ * note: already called with rcu_read_lock
+ */
 static int br_handle_local_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
 	__br_handle_local_finish(skb);
+	kfree_skb(skb);
 
-	/* return 1 to signal the okfn() was called so it's ok to use the skb */
-	return 1;
+	return 0;
 }
 
 static int nf_hook_bridge_pre(struct sk_buff *skb, struct sk_buff **pskb)
@@ -404,11 +409,14 @@ static rx_handler_result_t br_handle_fra
 		/* The else clause should be hit when nf_hook():
 		 *   - returns < 0 (drop/error)
 		 *   - returns = 0 (stolen/nf_queue)
-		 * Thus return 1 from the okfn() to signal the skb is ok to pass
+		 * On 1 the frame is passed on here. The okfn() only runs if a
+		 * queued frame is reinjected later, and must consume it then.
 		 */
-		if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN,
+		if (nf_hook(NFPROTO_BRIDGE, NF_BR_LOCAL_IN,
 			    dev_net(skb->dev), NULL, skb, skb->dev, NULL,
 			    br_handle_local_finish) == 1) {
+			*pskb = skb;
+			__br_handle_local_finish(skb);
 			return RX_HANDLER_PASS;
 		} else {
 			return RX_HANDLER_CONSUMED;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 468/555] net: e1000: fix warning in iounmap on probe failure
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (466 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 467/555] net: bridge: fix skb leak of reinjected link-local frames Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 469/555] net: gianfar: clear the pending Rx skb when freeing the Rx ring Greg Kroah-Hartman
                   ` (86 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, syzbot+ca1ef9e2e234b8d3599b,
	Svyatoslav Nikolenko, Aleksandr Loktionov, Tony Nguyen,
	Jakub Kicinski

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Svyatoslav Nikolenko <nsvatoslav515@gmail.com>

commit cf704cc62ffaf9206f1cbc12c2a3baec316b0ac1 upstream.

In e1000_probe(), the error unwinding path at err_sw_init unconditionally
calls iounmap(hw->ce4100_gbe_mdio_base_virt). On non-CE4100 hardware,
hw->ce4100_gbe_mdio_base_virt remains NULL.
Passing NULL to iounmap() triggers a WARN_ON_ONCE on x86 architectures.
Furthermore, on CE4100 hardware, if probe fails before or during
MDIO mapping, ce4100_gbe_mdio_base_virt is also NULL.

Fix this by adding a NULL pointer check before calling iounmap() on
hw->ce4100_gbe_mdio_base_virt. iounmap(hw->hw_addr) remains unconditional
because every code path reaching err_sw_init occurs after hw->hw_addr has
been successfully mapped.

Reported-by: syzbot+ca1ef9e2e234b8d3599b@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=ca1ef9e2e234b8d3599b
Fixes: 13acde8fffc0 ("e1000: cleanup CE4100 MDIO registers access")
Cc: stable@vger.kernel.org
Signed-off-by: Svyatoslav Nikolenko <nsvatoslav515@gmail.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Link: https://patch.msgid.link/20261113005823.130021-4-anthony.l.nguyen@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/ethernet/intel/e1000/e1000_main.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/drivers/net/ethernet/intel/e1000/e1000_main.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
@@ -1230,7 +1230,8 @@ err_mdio_ioremap:
 	kfree(adapter->rx_ring);
 err_dma:
 err_sw_init:
-	iounmap(hw->ce4100_gbe_mdio_base_virt);
+	if (hw->ce4100_gbe_mdio_base_virt)
+		iounmap(hw->ce4100_gbe_mdio_base_virt);
 	iounmap(hw->hw_addr);
 err_ioremap:
 	disable_dev = !test_and_set_bit(__E1000_DISABLED, &adapter->flags);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 469/555] net: gianfar: clear the pending Rx skb when freeing the Rx ring
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (467 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 468/555] net: e1000: fix warning in iounmap on probe failure Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 470/555] net: microchip: encx24j600: Avoid unsequenced accesses to jiffies in encx24j600_tx() Greg Kroah-Hartman
                   ` (85 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Anthony Pighin, Daniel Machon,
	Jakub Kicinski

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Anthony Pighin <anthony.pighin@nokia.com>

commit c35761f43c582460b45429f51be5c2a0f07ed9af upstream.

gfar_clean_rx_ring() keeps a frame that spans several Rx buffers in
rx_queue->skb between NAPI polls. When the interface is stopped (close,
MTU change, reset), free_skb_rx_queue() frees that skb but leaves the
pointer set, and nothing clears it when the rings are set up again.

After the restart, gfar_clean_rx_ring() picks up the stale pointer. The
first buffer it sees has RXBD_FIRST set, so the overrun handling frees
the skb a second time. By then the skb has usually been reallocated, so
the second free releases another owner's skb and data while they are
still in use.

Clear rx_queue->skb after freeing it.

Hit during development, as intermittent kernel panics in our automated
regression on an NXP LS1021A board (eTSEC), in an L2 Ethernet traffic
test that shuts and re-enables ports. It was seen on 6.6, 6.12 and
6.18 based kernels, crashing in unrelated places such as
kmem_cache_alloc() called from build_skb() in gfar_poll_rx_sq().
With the fix, the same test ran 90 bounces with no warnings or crashes.

Fixes: 75354148ce69 ("gianfar: Add paged allocation and Rx S/G")
Cc: stable@vger.kernel.org
Signed-off-by: Anthony Pighin <anthony.pighin@nokia.com>
Reviewed-by: Daniel Machon <daniel.machon@microchip.com>
Link: https://patch.msgid.link/20261112143140.1395197-1-anthony.pighin@nokia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/ethernet/freescale/gianfar.c |    1 +
 1 file changed, 1 insertion(+)

--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -1104,6 +1104,7 @@ static void free_skb_rx_queue(struct gfa
 	struct rxbd8 *rxbdp = rx_queue->rx_bd_base;
 
 	dev_kfree_skb(rx_queue->skb);
+	rx_queue->skb = NULL;
 
 	for (i = 0; i < rx_queue->rx_ring_size; i++) {
 		struct	gfar_rx_buff *rxb = &rx_queue->rx_buff[i];



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 470/555] net: microchip: encx24j600: Avoid unsequenced accesses to jiffies in encx24j600_tx()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (468 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 469/555] net: gianfar: clear the pending Rx skb when freeing the Rx ring Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 471/555] net: openvswitch: use skb_set_transport_header_careful() in parse_ipv6hdr() Greg Kroah-Hartman
                   ` (84 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Nathan Chancellor, Andrew Lunn,
	Jakub Kicinski

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Nathan Chancellor <nathan@kernel.org>

commit 5ec918f8d66a0311c52cc767ade67e7019beb176 upstream.

After a recent improvement in clang to warn on unsequenced accesses to
volatile variables [1], an instance appears in encx24j600_tx(), which
can break the build with CONFIG_WERROR=y / W=e:

  drivers/net/ethernet/microchip/encx24j600.c:898:14: error: unsequenced accesses to volatile qualified 'jiffies' [-Werror,-Wunsequenced]
    898 |                   jiffies, jiffies - dev_trans_start(dev));
        |                   ~~~~~~~  ^

Per C11 5.1.2.3.2, accessing a volatile object is a side effect. Per C11
6.5.2, unsequenced side effects on the same scalar object are undefined
behavior. Per C11 6.5.2.2.10/12, the evaluation of arguments in a
function call is indeterminately sequenced, meaning any side effects in
the arguments are unsequenced.

Add a local variable to hold the value of jiffies before the function
call so that there are no unsequenced side effects, clearing up the
warning.

Cc: stable@vger.kernel.org
Fixes: 04fbfce7a222 ("net: Microchip encx24j600 driver")
Closes: https://github.com/ClangBuiltLinux/linux/issues/2196
Link: https://github.com/llvm/llvm-project/commit/955715460eaf9188c241c74750637fc82dfcc423 [1]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20261114-encx24j600-wunsequenced-v1-1-c978fc36cacd@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/ethernet/microchip/encx24j600.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/drivers/net/ethernet/microchip/encx24j600.c
+++ b/drivers/net/ethernet/microchip/encx24j600.c
@@ -893,9 +893,10 @@ static netdev_tx_t encx24j600_tx(struct
 static void encx24j600_tx_timeout(struct net_device *dev, unsigned int txqueue)
 {
 	struct encx24j600_priv *priv = netdev_priv(dev);
+	unsigned long j = jiffies;
 
 	netif_err(priv, tx_err, dev, "TX timeout at %ld, latency %ld\n",
-		  jiffies, jiffies - dev_trans_start(dev));
+		  j, j - dev_trans_start(dev));
 
 	dev->stats.tx_errors++;
 	netif_wake_queue(dev);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 471/555] net: openvswitch: use skb_set_transport_header_careful() in parse_ipv6hdr()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (469 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 470/555] net: microchip: encx24j600: Avoid unsequenced accesses to jiffies in encx24j600_tx() Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 472/555] net: stmmac: dwmac1000: dont discard frames with only a checksum error Greg Kroah-Hartman
                   ` (83 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Eric Dumazet, Ilya Maximets,
	Aaron Conole, Justin Iurman, Paolo Abeni

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Eric Dumazet <edumazet@kernel.org>

commit b9b77e2430032c21cc82b7da3a0bc0d8e74e6c26 upstream.

skb->transport_header is a 16-bit offset from skb->head, and U16_MAX is
reserved as the "not set" value. skb_set_transport_header() silently
truncates an offset that does not fit.

parse_ipv6hdr() stores the payload offset found by ipv6_find_hdr(),
which depends on the extension headers found in the packet. Should the
value be truncated, key_extract_l3l4() would parse the L4 header at the
wrong place.

Since commit 3744b0964d52 ("ipv6: Implement limits on extension header
parsing") a single chain is bounded to IP6_MAX_EXT_HDRS_CNT headers
(24576 bytes), so this needs a large skb->data - skb->head on top of it,
for instance after several nested decapsulations, each of them possibly
pulling its own extension header chain. No reproducer was written,
this is hardening.

Use skb_set_transport_header_careful() and return -EPROTO if the offset
can not be stored. As for other ipv6_find_hdr() failures, the caller
then sets the transport header to the network header and does not
parse L4. While at it, use payload_ofs directly, since
nh_ofs + nh_len == payload_ofs.

Fixes: 1a37e412a022 ("net: Use 16bits for *_headers fields of struct skbuff")
Cc: stable@vger.kernel.org
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Reviewed-by: Ilya Maximets <i.maximets@ovn.org>
Reviewed-by: Aaron Conole <aconole@redhat.com>
Link: https://patch.msgid.link/20261113124625.4010206-4-edumazet@kernel.org
Reviewed-by: Justin Iurman <justin.iurman@gmail.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/openvswitch/flow.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -443,7 +443,8 @@ static int parse_ipv6hdr(struct sk_buff
 		return -EPROTO;
 
 	nh_len = payload_ofs - nh_ofs;
-	skb_set_transport_header(skb, nh_ofs + nh_len);
+	if (unlikely(!skb_set_transport_header_careful(skb, payload_ofs)))
+		return -EPROTO;
 	key->ip.proto = nexthdr;
 	return nh_len;
 }



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 472/555] net: stmmac: dwmac1000: dont discard frames with only a checksum error
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (470 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 471/555] net: openvswitch: use skb_set_transport_header_careful() in parse_ipv6hdr() Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 473/555] net: stmmac: honour Rx checksum errors in the AF_XDP zero-copy path Greg Kroah-Hartman
                   ` (82 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Christian Schmidbauer,
	Maxime Chevallier, Paolo Abeni

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Christian Schmidbauer <opensource@grische.xyz>

commit 596c9408682feba536d7f39de97959807eb3ba1c upstream.

On dwmac1000 with enhanced descriptors, the hardware sets the Error
Summary (ES) bit of the Rx descriptor not only for L2 errors but also
for an L3/L4 checksum error. enh_desc_get_rx_status() returns
discard_frame whenever ES is set, and since commit 1b746ce8b397 ("net:
stmmac: don't overwrite discard_frame status") the checksum status is
only evaluated for good frames.

Return discard_frame only when ES comes with one of the L2 error bits.
A frame with only a checksum error is then reported as csum_none and
reaches the stack as CHECKSUM_NONE, so the stack verifies the checksum
itself. This matches dwmac4, whose Error Summary bit does not cover
checksum errors.

RDES0 bit 7 is not in the mask, because depending on the core and on
Rx checksum offload it reports a timestamp, an IP header checksum error
or a giant frame, and enh_desc_get_rx_status() cannot tell which. In
threshold Rx mode, a giant frame that fits one buffer therefore reaches
the stack with a verified FCS.

Also remove the pr_err that enh_desc_get_rx_status() prints when bit 7
is set. Once the MAC stops dropping checksum-error frames, any host on
the link can flood the kernel log by sending frames with a bad IPv4
header checksum.

This prepares for setting DMA_CONTROL_DT, which makes the MAC deliver
checksum-error frames instead of dropping them in its Rx FIFO.

Fixes: 1b746ce8b397 ("net: stmmac: don't overwrite discard_frame status")
Cc: <stable@vger.kernel.org> # 6.6.x: ee0aace5f844: net: stmmac: Correctly handle Rx checksum offload errors
Cc: <stable@vger.kernel.org> # 6.6.x
Signed-off-by: Christian Schmidbauer <opensource@grische.xyz>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Tested-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/20261114133640.3285413-3-opensource@grische.xyz
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/ethernet/stmicro/stmmac/enh_desc.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--- a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c
+++ b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c
@@ -221,9 +221,6 @@ static int enh_desc_get_rx_status(struct
 		if (unlikely(rdes0 & RDES0_OVERFLOW_ERROR))
 			x->rx_gmac_overflow++;
 
-		if (unlikely(rdes0 & RDES0_IPC_CSUM_ERROR))
-			pr_err("\tIPC Csum Error/Giant frame\n");
-
 		if (unlikely(rdes0 & RDES0_COLLISION))
 			x->rx_collision++;
 		if (unlikely(rdes0 & RDES0_RECEIVE_WATCHDOG))
@@ -235,7 +232,10 @@ static int enh_desc_get_rx_status(struct
 		if (unlikely(rdes0 & RDES0_CRC_ERROR)) {
 			x->rx_crc_errors++;
 		}
-		ret = discard_frame;
+		if (rdes0 & (RDES0_DESCRIPTOR_ERROR | RDES0_OVERFLOW_ERROR |
+			     RDES0_COLLISION | RDES0_RECEIVE_WATCHDOG |
+			     RDES0_MII_ERROR | RDES0_CRC_ERROR))
+			ret = discard_frame;
 	}
 
 	/* After a payload csum error, the ES bit is set.



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 473/555] net: stmmac: honour Rx checksum errors in the AF_XDP zero-copy path
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (471 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 472/555] net: stmmac: dwmac1000: dont discard frames with only a checksum error Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 474/555] net: stmmac: re-enable on-chip parity checkers for XGMAC ASP 0x2 Greg Kroah-Hartman
                   ` (81 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Christian Schmidbauer,
	Maxime Chevallier, Paolo Abeni

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Christian Schmidbauer <opensource@grische.xyz>

commit fcfc52fcf89a3076c3a9afbbc70c0fecd2b5fc8d upstream.

Commit ee0aace5f844 ("net: stmmac: Correctly handle Rx checksum offload
errors") taught stmmac_rx() to honour the csum_none status, but
stmmac_dispatch_skb_zc() still ignores it and sets CHECKSUM_UNNECESSARY
for every IP frame whenever the checksum offload engine (CoE) is
enabled.

Since commit fe4042797651 ("net: stmmac: dwmac4: stop hardware from
dropping checksum-error packets") dwmac4 delivers such frames instead of
dropping them, so this path receives them.

Mark the skb CHECKSUM_NONE when csum_none is set, as stmmac_rx() does.

Fixes: bba2556efad6 ("net: stmmac: Enable RX via AF_XDP zero-copy")
Cc: <stable@vger.kernel.org>
Signed-off-by: Christian Schmidbauer <opensource@grische.xyz>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/20261114133640.3285413-2-opensource@grische.xyz
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -5176,7 +5176,7 @@ static struct sk_buff *stmmac_construct_
 
 static void stmmac_dispatch_skb_zc(struct stmmac_priv *priv, u32 queue,
 				   struct dma_desc *p, struct dma_desc *np,
-				   struct xdp_buff *xdp)
+				   struct xdp_buff *xdp, int status)
 {
 	struct stmmac_rxq_stats *rxq_stats = &priv->xstats.rxq_stats[queue];
 	struct stmmac_channel *ch = &priv->channel[queue];
@@ -5201,7 +5201,8 @@ static void stmmac_dispatch_skb_zc(struc
 		stmmac_rx_vlan(priv->dev, skb);
 	skb->protocol = eth_type_trans(skb, priv->dev);
 
-	if (unlikely(!coe) || !stmmac_has_ip_ethertype(skb))
+	if (unlikely(!coe) || !stmmac_has_ip_ethertype(skb) ||
+	    (status & csum_none))
 		skb_checksum_none_assert(skb);
 	else
 		skb->ip_summed = CHECKSUM_UNNECESSARY;
@@ -5436,7 +5437,8 @@ read_again:
 
 		switch (res) {
 		case STMMAC_XDP_PASS:
-			stmmac_dispatch_skb_zc(priv, queue, p, np, buf->xdp);
+			stmmac_dispatch_skb_zc(priv, queue, p, np, buf->xdp,
+					       status);
 			xsk_buff_free(buf->xdp);
 			break;
 		case STMMAC_XDP_CONSUMED:



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 474/555] net: stmmac: re-enable on-chip parity checkers for XGMAC ASP 0x2
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (472 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 473/555] net: stmmac: honour Rx checksum errors in the AF_XDP zero-copy path Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 475/555] net: usb: smsc75xx: reject frames without a full header and FCS Greg Kroah-Hartman
                   ` (80 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Zxyan Zhu, Maxime Chevallier,
	Nicolai Buchwitz, Jakub Kicinski

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Zxyan Zhu <zxyan0222@gmail.com>

commit 9c9863f9b9f120b771a908849157791a32eadb02 upstream.

Commit 669a55560e4b ("net: stmmac: Check more MAC HW features for XGMAC
Core 3.20") made dwxgmac3_safety_feat_config() bail out early for
asp == 0x2, assuming that configuration has no parity protection.

Per the DWC_xgmac databook, the ASP field of MAC_HW_Feature3 selects:

  0x1 (AS_EPPE):  all automotive safety features, with ECC and parity
                  ports on the external application interface
  0x2 (AS_NEPPE): all automotive safety features, without ECC or
                  parity ports on the external application interface
  0x3 (AS_PPE):   all automotive safety features, with parity ports
                  on the external application interface

The reset value of the field is defined as:

  (DWCXG_ASP_ALL && DWCXG_ASP_PPE == 1) ? "3"
  : (DWCXG_ASP_ALL && DWCXG_ASP_PPE == 0) ? "2"
  : (DWCXG_ASP_ALL && DWCXG_ASP_PPE == 2) ? "1" : "0"

so ASP 0x2 implies DWCXG_ASP_ALL = 1, where the internal FSM state
parity and timeout (MAC_FSM_Control) and the on-chip data-path parity
(MTL_DPP_CONTROL) features exist; only the ports on the external
application interface are absent.  The early return therefore skips
enabling safety checkers that are present in the hardware.

Drop 0x2 from the condition so the FSM and data-path parity checkers
are enabled again.

Also update the safety feature descriptions printed by
stmmac_dma_cap_show() to spell out that ASP 0x1/0x2/0x3 differ only
in the ECC or parity ports on the external application interface; the
previous wording, "All Safety Features without ECC or Parity",
suggests the on-chip checkers are absent from an ASP 0x2 device.

Keep the early return for ASP 0x4 (EASP), which selects only ECC
protection for external memory and has no on-chip parity features.

Tested on XGMAC 3.10 and 3.40 cores.

Fixes: 669a55560e4b ("net: stmmac: Check more MAC HW features for XGMAC Core 3.20")
Cc: stable@vger.kernel.org
Signed-off-by: Zxyan Zhu <zxyan0222@gmail.com>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de>
Link: https://patch.msgid.link/20261114015554.2187341-1-zxyan0222@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c |    6 +++---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c   |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

--- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
@@ -937,10 +937,10 @@ dwxgmac3_safety_feat_config(void __iomem
 	value |= XGMAC_TCEIE; /* TSO Memory Correctable Error */
 	writel(value, ioaddr + XGMAC_DMA_ECC_INT_ENABLE);
 
-	/* 0x2: Without ECC or Parity Ports on External Application Interface
-	 * 0x4: Only ECC Protection for External Memory feature is selected
+	/* 0x4: Only ECC Protection for External Memory feature is
+	 * selected, without any on-chip parity protection
 	 */
-	if (asp == 0x2 || asp == 0x4)
+	if (asp == 0x4)
 		return 0;
 
 	/* 4. Enable Parity and Timeout for FSM */
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -6462,9 +6462,9 @@ static int stmmac_dma_cap_show(struct se
 	};
 	static const char * const dwxgmac_safety_feature_desc[] = {
 		"No",
-		"All Safety Features with ECC and Parity",
-		"All Safety Features without ECC or Parity",
-		"All Safety Features with Parity Only",
+		"All Safety Features with ECC and Parity Ports on External Application Interface",
+		"All Safety Features without ECC or Parity Ports on External Application Interface",
+		"All Safety Features with Parity Ports on External Application Interface",
 		"ECC Only",
 		"UNDEFINED",
 		"UNDEFINED",



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 475/555] net: usb: smsc75xx: reject frames without a full header and FCS
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (473 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 474/555] net: stmmac: re-enable on-chip parity checkers for XGMAC ASP 0x2 Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 476/555] nvme-auth: use the parsed offset for the DH-CHAP key Greg Kroah-Hartman
                   ` (79 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Joas Antonio dos Santos, Andrew Lunn,
	Jakub Kicinski

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Joas Antonio dos Santos <joasantonio108@gmail.com>

commit 1b02f90976d4bdf8c67d19dadf31b4bba05eb66f upstream.

smsc75xx_rx_fixup() takes the frame length from the RX command word
supplied by the device and strips the FCS by using "size - 4" for the
allocation, skb_put() and memcpy() of each frame that is not the last
one in the URB.  The length is only checked against an upper bound and
against skb->len, so a device can report a length field of 2..5, which
gives a size of 0..3 after RXW_PADDING is subtracted.

size is a u32, so "size - 4" then wraps to 0xfffffffc..0xffffffff.
__netdev_alloc_skb() adds NET_SKB_PAD to the unsigned length, which
wraps back to a small value and the allocation succeeds.  skb_put()
adds the length to the 32-bit skb->tail and skb->len, which also wrap,
so the skb_over_panic() check does not fire.  The following memcpy()
then tries to copy almost 4 GiB from the URB buffer into that small
allocation and writes far beyond it.

A malicious or malfunctioning USB device can use this to corrupt
kernel memory or crash the machine.

A frame that holds an FCS but less than an Ethernet header is not
valid either.  usbnet drops it when it is the last frame in the URB,
but the other frames go straight to usbnet_skb_return(), where
eth_type_trans() reads an Ethernet header that was never copied into
the new skb.

Reject frames that are too short to hold an Ethernet header and an
FCS, which covers both cases with one check.

The driver does not set FLAG_RX_ASSEMBLE, so usbnet already counts
rx_errors when smsc75xx_rx_fixup() returns 0.  Also count
rx_length_errors for these frames, as usbnet does for the short frames
it drops itself.

Found by LLM-assisted source review.

Fixes: 1b3b2d9e772b ("net: usb: smsc75xx: stop lying about skb->truesize")
Cc: stable@vger.kernel.org
Signed-off-by: Joas Antonio dos Santos <joasantonio108@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20261112-smsc75xx-rx-fcs-v3-1-6ad0378d0384@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/usb/smsc75xx.c |    8 ++++++++
 1 file changed, 8 insertions(+)

--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -2223,6 +2223,14 @@ static int smsc75xx_rx_fixup(struct usbn
 				return 0;
 			}
 
+			if (unlikely(size < ETH_HLEN + ETH_FCS_LEN)) {
+				netif_dbg(dev, rx_err, dev->net,
+					  "size err rx_cmd_a=0x%08x\n",
+					  rx_cmd_a);
+				dev->net->stats.rx_length_errors++;
+				return 0;
+			}
+
 			/* last frame in this batch */
 			if (skb->len == size) {
 				smsc75xx_rx_csum_offload(dev, skb, rx_cmd_a,



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 476/555] nvme-auth: use the parsed offset for the DH-CHAP key
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (474 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 475/555] net: usb: smsc75xx: reject frames without a full header and FCS Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 477/555] nvme-loop: release the target request when SG setup fails Greg Kroah-Hartman
                   ` (78 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Shao Mingyin, Hannes Reinecke,
	Christoph Hellwig, Keith Busch

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Shao Mingyin <shao.mingyin@zte.com.cn>

commit f7141618d5d0b51bc2a64961bab738a0fe57e83f upstream.

nvme_auth_parse_key() accepts the DH-HMAC-CHAP key with

	if (sscanf(secret, "DHHC-1:%hhd:%*s:", &key_hash) != 1)
		return -EINVAL;

and then skips a hardcoded ten characters:

	key = nvme_auth_extract_key(secret + 10, key_hash);

The ten characters assume that the hash identifier is exactly two
characters long.  A string such as "DHHC-1:1:" still makes sscanf()
return 1, and secret + 10 then points one byte past the NUL terminator
of the buffer.  nvme_auth_extract_key() starts with
strlen(secret), so it reads past the end of the allocation.  The sysfs
dhchap_secret and dhchap_ctrl_secret stores only require seven
characters and a "DHHC-1:" prefix, so a short value reaches this code
(even though the nvme-fabrics option parser rejects secrets shorter than
eleven characters).

Use the %n conversion to obtain the real offset after the
"DHHC-1:<hash>:" prefix and reject a string where the prefix is not
complete.  This accepts both one and two character hash identifiers and
never starts the key past the terminator.

Fixes: f50fff73d620 ("nvme: implement In-Band authentication")
Cc: stable@vger.kernel.org
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/nvme/common/auth.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/drivers/nvme/common/auth.c
+++ b/drivers/nvme/common/auth.c
@@ -450,17 +450,19 @@ int nvme_auth_generate_key(u8 *secret, s
 {
 	struct nvme_dhchap_key *key;
 	u8 key_hash;
+	int offset = 0;
 
 	if (!secret) {
 		*ret_key = NULL;
 		return 0;
 	}
 
-	if (sscanf(secret, "DHHC-1:%hhd:%*s:", &key_hash) != 1)
+	if (sscanf(secret, "DHHC-1:%hhd:%n", &key_hash, &offset) != 1 ||
+	    !offset)
 		return -EINVAL;
 
 	/* Pass in the secret without the 'DHHC-1:XX:' prefix */
-	key = nvme_auth_extract_key(secret + 10, key_hash);
+	key = nvme_auth_extract_key(secret + offset, key_hash);
 	if (IS_ERR(key)) {
 		*ret_key = NULL;
 		return PTR_ERR(key);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 477/555] nvme-loop: release the target request when SG setup fails
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (475 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 476/555] nvme-auth: use the parsed offset for the DH-CHAP key Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 478/555] nvme-tcp: require the R2T offset to match the data sent Greg Kroah-Hartman
                   ` (77 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Christoph Hellwig, Shao Mingyin,
	Keith Busch

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Shao Mingyin <shao.mingyin@zte.com.cn>

commit f2937481c28033e10e8a29b8742a767e73c696df upstream.

nvme_loop_queue_rq() calls nvmet_req_init(), which takes a reference on
the submission queue percpu ref, pins the namespace and, for a
reservation-enabled namespace, takes a per-controller PR reference.  If
sg_alloc_table_chained() then fails under memory pressure, the function
returns BLK_STS_RESOURCE without calling nvmet_req_uninit().  blk-mq
retries the same request and nvmet_req_init() overwrites req->ns and
req->pc_ref, leaking the queue, namespace and PR references taken by the
failed attempt each time this happens.

Release the request before returning BLK_STS_RESOURCE.

Fixes: 3a85a5de29ea ("nvme-loop: add a NVMe loopback host driver")
Cc: stable@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/nvme/target/loop.c |    1 +
 1 file changed, 1 insertion(+)

--- a/drivers/nvme/target/loop.c
+++ b/drivers/nvme/target/loop.c
@@ -158,6 +158,7 @@ static blk_status_t nvme_loop_queue_rq(s
 				blk_rq_nr_phys_segments(req),
 				iod->sg_table.sgl, NVME_INLINE_SG_CNT)) {
 			nvme_cleanup_cmd(req);
+			nvmet_req_uninit(&iod->req);
 			return BLK_STS_RESOURCE;
 		}
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 478/555] nvme-tcp: require the R2T offset to match the data sent
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (476 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 477/555] nvme-loop: release the target request when SG setup fails Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 479/555] nvme: reject invalid reconnect_delay sysfs values Greg Kroah-Hartman
                   ` (76 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Christoph Hellwig, Shao Mingyin,
	Keith Busch

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Shao Mingyin <shao.mingyin@zte.com.cn>

commit 347d50d92e25d4b9c50c5f5c1d8b727b9c88d12c upstream.

nvme_tcp_handle_r2t() rejects offsets below data_sent but accepts
larger offsets.  The send iterator still points at data_sent, so the
next H2CData PDU carries bytes from that position while advertising the
larger offset.  A target that accepts the PDU can place the data at the
wrong position; the Linux target rejects it and fails the connection.

Require the R2T offset to equal data_sent, rejecting the invalid request
before transmitting data with a mismatched offset.

Fixes: 3f2304f8c6d6 ("nvme-tcp: add NVMe over TCP host driver")
Cc: stable@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/nvme/host/tcp.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -839,7 +839,7 @@ static int nvme_tcp_handle_r2t(struct nv
 		return -EPROTO;
 	}
 
-	if (unlikely(r2t_offset < req->data_sent)) {
+	if (unlikely(r2t_offset != req->data_sent)) {
 		dev_err(queue->ctrl->ctrl.device,
 			"req %d unexpected r2t offset %u (expected %zu)\n",
 			rq->tag, r2t_offset, req->data_sent);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 479/555] nvme: reject invalid reconnect_delay sysfs values
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (477 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 478/555] nvme-tcp: require the R2T offset to match the data sent Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 480/555] nvme: stop asynchronous event work before ANA teardown Greg Kroah-Hartman
                   ` (75 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Shao Mingyin, Keith Busch

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Shao Mingyin <shao.mingyin@zte.com.cn>

commit f92fe8dea19c743eb9e4d998ae0384344dd40091 upstream.

nvme_ctrl_reconnect_delay_store() stores whatever kstrtou32() accepted
into opts->reconnect_delay without validating it.  The nvme-fabrics
option parser refuses reconnect_delay values that are zero or negative,
and the rest of the driver relies on that: nvme_ctrl_loss_tmo_store()
computes

	opts->max_reconnects = DIV_ROUND_UP(ctrl_loss_tmo,
					    opts->reconnect_delay);

Writing 0 to reconnect_delay and then a positive value to ctrl_loss_tmo
therefore divides by zero in the kernel.  In addition, a value larger
than INT_MAX is truncated to a negative int in the assignment and
silently bypasses the checks done by the fabrics parser.

Reject zero and values that do not fit into the signed int field.

Fixes: 764075fdcb2f ("nvme: expose reconnect_delay and ctrl_loss_tmo via sysfs")
Cc: stable@vger.kernel.org
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/nvme/host/sysfs.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/nvme/host/sysfs.c
+++ b/drivers/nvme/host/sysfs.c
@@ -478,6 +478,9 @@ static ssize_t nvme_ctrl_reconnect_delay
 	if (err)
 		return err;
 
+	if (!v || v > INT_MAX)
+		return -EINVAL;
+
 	ctrl->opts->reconnect_delay = v;
 	return count;
 }



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 480/555] nvme: stop asynchronous event work before ANA teardown
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (478 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 479/555] nvme: reject invalid reconnect_delay sysfs values Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 481/555] nvmet-fc: reject duplicate queue IDs on Create Connection Greg Kroah-Hartman
                   ` (74 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Yaohan Li, Christoph Hellwig,
	Keith Busch

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Yaohan Li <shunsheng1218@gmail.com>

commit 9b657c565984f28976b1e471e3ce2f81cc269238 upstream.

NVMe ANA work has several producers, including ANA AER completion,
namespace scanning and failover processing.

An AER completion can queue ana_work for an ANA notice and can
separately queue async_event_work, which sends the AEN uevent and
submits the next asynchronous event request.  These work items access
controller-owned state during asynchronous processing.

This issue was investigated and the fix was developed with AI
assistance (ZCode/GLM-4).

Fixes: 0d0b660f214dc ("nvme: add ANA support")
Cc: stable@vger.kernel.org
Signed-off-by: Yaohan Li <shunsheng1218@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/nvme/host/core.c      |    9 +++++++++
 drivers/nvme/host/multipath.c |    7 +++++++
 2 files changed, 16 insertions(+)

--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -4815,6 +4815,15 @@ EXPORT_SYMBOL_GPL(nvme_start_ctrl);
 void nvme_uninit_ctrl(struct nvme_ctrl *ctrl)
 {
 	nvme_stop_keep_alive(ctrl);
+
+	/*
+	 * An AER completion can queue async_event_work; drain it before the
+	 * controller's final release.  Note that ana_work has additional
+	 * producers (namespace scanning via nvme_scan_work, and the failover
+	 * path in nvme_failover_req), which is why nvme_mpath_uninit()
+	 * separately cancels ana_work after this point.
+	 */
+	cancel_work_sync(&ctrl->async_event_work);
 	nvme_hwmon_exit(ctrl);
 	nvme_fault_inject_fini(&ctrl->fault_inject);
 	dev_pm_qos_hide_latency_tolerance(ctrl->device);
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -1096,6 +1096,13 @@ out_uninit:
 
 void nvme_mpath_uninit(struct nvme_ctrl *ctrl)
 {
+	/*
+	 * ANA work can be queued by nvme_handle_aen_notice, nvme_scan_work,
+	 * and nvme_failover_req. Drain remaining work before releasing the ANA
+	 * resources.
+	 */
+	cancel_work_sync(&ctrl->ana_work);
+
 	kvfree(ctrl->ana_log_buf);
 	ctrl->ana_log_buf = NULL;
 	ctrl->ana_log_size = 0;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 481/555] nvmet-fc: reject duplicate queue IDs on Create Connection
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (479 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 480/555] nvme: stop asynchronous event work before ANA teardown Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 482/555] nvmet-tcp: only wait for in-capsule data for inline SGLs Greg Kroah-Hartman
                   ` (73 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Christoph Hellwig, Shao Mingyin,
	Keith Busch

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Shao Mingyin <shao.mingyin@zte.com.cn>

commit 153eac284ebf68be74993643e9b2fe2f9b2b1d88 upstream.

nvmet_fc_alloc_target_queue() stores the new queue with

	WARN_ON(assoc->queues[qid]);
	assoc->queues[qid] = queue;

The queue ID comes straight from the Create Connection LS and is only
checked against NVMET_NR_QUEUES.  A remote initiator can send a second
Create Connection for a queue ID that already exists, or send queue ID 0
which was already created as the admin queue by Create Association.  The
WARN fires and the old pointer is overwritten: the old queue's base
reference is never put, so its workqueue, nvmet_sq and nvmet_cq are
never released.  For the admin queue this also leaves the controller
reference unreachable from nvmet_fc_delete_target_assoc(), so the
controller and its subsystem reference leak permanently.

Publish the queue with cmpxchg() and destroy the newly created queue if
the slot is already taken, returning the normal queue allocation error
to the initiator.  This keeps the existing error path and makes both
duplicate and admin queue IDs fail cleanly.

Fixes: c53432030d86 ("nvme-fabrics: Add target support for FC transport")
Cc: stable@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/nvme/target/fc.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

--- a/drivers/nvme/target/fc.c
+++ b/drivers/nvme/target/fc.c
@@ -820,8 +820,17 @@ nvmet_fc_alloc_target_queue(struct nvmet
 	if (ret)
 		goto out_fail_iodlist;
 
-	WARN_ON(assoc->queues[qid]);
-	assoc->queues[qid] = queue;
+	/*
+	 * Publish the queue only if the slot is still free.  A Create
+	 * Connection may arrive twice for the same queue ID, or with the
+	 * admin queue ID that was created by Create Association; replacing
+	 * the old pointer would leak that queue and its controller
+	 * reference forever.
+	 */
+	if (cmpxchg(&assoc->queues[qid], NULL, queue)) {
+		nvmet_sq_destroy(&queue->nvme_sq);
+		goto out_fail_iodlist;
+	}
 
 	return queue;
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 482/555] nvmet-tcp: only wait for in-capsule data for inline SGLs
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (480 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 481/555] nvmet-fc: reject duplicate queue IDs on Create Connection Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 483/555] nvmet: handle short reads and writes in the file backend Greg Kroah-Hartman
                   ` (72 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Shao Mingyin, Keith Busch

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Shao Mingyin <shao.mingyin@zte.com.cn>

commit 9dac3b1aa2a99e126a5504b7f5bc781c8b2771e0 upstream.

nvmet-tcp decides whether to wait for in-capsule data using only the
write direction and SGL length.  A write using a transport SGL can fit
within inline_data_size without carrying any in-capsule data.  The
response path then withholds its R2T, leaving the command stuck.

If request initialization fails, the same length-only test both
withholds the error response and attempts to drain inline data that
will never arrive.  This can also consume the following PDU as data
or a digest.

Require an offset data-block SGL in both checks.  Share a helper that
only uses command and port fields, as the completion callback can run
before nvmet_req_init() has finished.

Fixes: bdaf13279192 ("nvmet-tcp: fix a segmentation fault during io parsing error")
Fixes: 872d26a391da ("nvmet-tcp: add NVMe over TCP target driver")
Cc: stable@vger.kernel.org
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/nvme/target/tcp.c |   42 +++++++++++++++++++++++++++++-------------
 1 file changed, 29 insertions(+), 13 deletions(-)

--- a/drivers/nvme/target/tcp.c
+++ b/drivers/nvme/target/tcp.c
@@ -273,6 +273,30 @@ static inline bool nvmet_tcp_has_inline_
 		!cmd->rbytes_done;
 }
 
+/*
+ * Check whether the SGL of @cmd carries in-capsule data that the host
+ * will send right after the command PDU.  Only the offset form of the
+ * data block descriptor is in-capsule; a regular transport SGL is
+ * fetched through an R2T instead.
+ */
+static inline bool nvmet_tcp_sgl_is_inline(struct nvmet_tcp_cmd *cmd)
+{
+	struct nvme_sgl_desc *sgl = &cmd->req.cmd->common.dptr.sgl;
+	u32 len = le32_to_cpu(sgl->length);
+
+	if (sgl->type != ((NVME_SGL_FMT_DATA_DESC << 4) |
+			  NVME_SGL_FMT_OFFSET))
+		return false;
+
+	if (!nvme_is_write(cmd->req.cmd))
+		return false;
+
+	if (!len)
+		return false;
+
+	return len <= cmd->req.port->inline_data_size;
+}
+
 static inline struct nvmet_tcp_cmd *
 nvmet_tcp_get_cmd(struct nvmet_tcp_queue *queue)
 {
@@ -635,25 +659,19 @@ static void nvmet_tcp_queue_response(str
 	struct nvmet_tcp_queue	*queue = cmd->queue;
 	enum nvmet_tcp_recv_state queue_state;
 	struct nvmet_tcp_cmd *queue_cmd;
-	struct nvme_sgl_desc *sgl;
-	u32 len;
 
 	/* Pairs with store_release in nvmet_prepare_receive_pdu() */
 	queue_state = smp_load_acquire(&queue->rcv_state);
 	queue_cmd = READ_ONCE(queue->cmd);
 
 	if (unlikely(cmd == queue_cmd)) {
-		sgl = &cmd->req.cmd->common.dptr.sgl;
-		len = le32_to_cpu(sgl->length);
-
 		/*
-		 * Wait for inline data before processing the response.
-		 * Avoid using helpers, this might happen before
-		 * nvmet_req_init is completed.
+		 * Wait for in-capsule data before processing the response.
+		 * This can happen before nvmet_req_init() has completed, so
+		 * only look at the SGL descriptor itself.
 		 */
 		if (queue_state == NVMET_TCP_RECV_PDU &&
-		    len && len <= cmd->req.port->inline_data_size &&
-		    nvme_is_write(cmd->req.cmd))
+		    nvmet_tcp_sgl_is_inline(cmd))
 			return;
 	}
 
@@ -1033,7 +1051,6 @@ static int nvmet_tcp_handle_icreq(struct
 static int nvmet_tcp_handle_req_failure(struct nvmet_tcp_queue *queue,
 		struct nvmet_tcp_cmd *cmd, struct nvmet_req *req)
 {
-	size_t data_len = le32_to_cpu(req->cmd->common.dptr.sgl.length);
 	int ret;
 
 	/*
@@ -1043,8 +1060,7 @@ static int nvmet_tcp_handle_req_failure(
 	 * otherwise we will need to prepare a buffer and receive the
 	 * stale data before continuing forward.
 	 */
-	if (!nvme_is_write(cmd->req.cmd) || !data_len ||
-	    data_len > cmd->req.port->inline_data_size) {
+	if (!nvmet_tcp_sgl_is_inline(cmd)) {
 		nvmet_prepare_receive_pdu(queue);
 		return 0;
 	}



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 483/555] nvmet: handle short reads and writes in the file backend
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (481 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 482/555] nvmet-tcp: only wait for in-capsule data for inline SGLs Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 484/555] nvmet: use overflow-safe range checks " Greg Kroah-Hartman
                   ` (71 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Christoph Hellwig, Shao Mingyin,
	Keith Busch

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Shao Mingyin <shao.mingyin@zte.com.cn>

commit 1738de07a79b9abdcffe03571c442033b80e7fed upstream.

When the file backend falls back to its bvec mempool, large requests
are submitted in synchronous chunks.  A short completion advances the
file position by the full chunk length and is eventually overwritten
with the total request length.  The target reports success for an
incomplete write or returns unread buffer contents as valid data.

The common completion path has another short-I/O case: a zero-byte
return, such as a read at EOF after the backing file is truncated, is
passed to errno_to_nvme_status() and becomes success.

Stop at any incomplete chunk and convert nonnegative short completions
to -EIO in both paths.  Preserve negative errors and full completions.

Fixes: d5eff33ee6f8 ("nvmet: add simple file backed ns support")
Fixes: c6aa3542e010 ("nvmet: add error log support for file backend")
Cc: stable@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/nvme/target/io-cmd-file.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

--- a/drivers/nvme/target/io-cmd-file.c
+++ b/drivers/nvme/target/io-cmd-file.c
@@ -113,7 +113,7 @@ static void nvmet_file_io_done(struct ki
 	}
 
 	if (unlikely(ret != req->transfer_len))
-		status = errno_to_nvme_status(req, ret);
+		status = errno_to_nvme_status(req, ret < 0 ? ret : -EIO);
 	nvmet_req_complete(req, status);
 }
 
@@ -150,8 +150,11 @@ static bool nvmet_file_execute_io(struct
 		if (unlikely(is_sync) &&
 		    (nr_bvec - 1 == 0 || bv_cnt == NVMET_MAX_MPOOL_BVEC)) {
 			ret = nvmet_file_submit_bvec(req, pos, bv_cnt, len, 0);
-			if (ret < 0)
+			if (ret != len) {
+				if (ret >= 0)
+					ret = -EIO;
 				goto complete;
+			}
 
 			pos += len;
 			bv_cnt = 0;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 484/555] nvmet: use overflow-safe range checks in the file backend
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (482 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 483/555] nvmet: handle short reads and writes in the file backend Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 485/555] nvmet: zns: return the namespace lookup error for Identify Greg Kroah-Hartman
                   ` (70 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Shao Mingyin, Christoph Hellwig,
	Keith Busch

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Shao Mingyin <shao.mingyin@zte.com.cn>

commit bcd5316e708d418f03707c183571549ad878cfff upstream.

The file backend shifts a host-supplied SLBA to form a byte offset
before checking it against the namespace size. The shift can discard
high bits: with a 4 KiB block size, SLBA 2^52 + 1 becomes offset 4096.
The range check then accepts a command aimed outside the namespace and
the backend accesses data at the wrapped offset.

Reject overflowing LBA-to-byte conversions and check the transfer
length against the remaining namespace size without adding it to the
offset. Apply the checks to reads, writes, discard and write zeroes.

Fixes: 9c891c139894 ("nvmet: check fileio lba range access boundaries")
Cc: stable@vger.kernel.org
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/nvme/target/io-cmd-file.c |   40 +++++++++++++++++++++++++++-----------
 1 file changed, 29 insertions(+), 11 deletions(-)

--- a/drivers/nvme/target/io-cmd-file.c
+++ b/drivers/nvme/target/io-cmd-file.c
@@ -117,6 +117,19 @@ static void nvmet_file_io_done(struct ki
 	nvmet_req_complete(req, status);
 }
 
+static bool nvmet_file_check_lba_range(struct nvmet_req *req, u64 slba,
+				       u64 len, loff_t *pos)
+{
+	u64 pos64;
+
+	if (check_shl_overflow(slba, req->ns->blksize_shift, &pos64) ||
+	    pos64 > req->ns->size || len > req->ns->size - pos64)
+		return false;
+
+	*pos = pos64;
+	return true;
+}
+
 static bool nvmet_file_execute_io(struct nvmet_req *req, int ki_flags)
 {
 	ssize_t nr_bvec = req->sg_cnt;
@@ -131,8 +144,9 @@ static bool nvmet_file_execute_io(struct
 	if (req->f.mpool_alloc && nr_bvec > NVMET_MAX_MPOOL_BVEC)
 		is_sync = true;
 
-	pos = le64_to_cpu(req->cmd->rw.slba) << req->ns->blksize_shift;
-	if (unlikely(pos + req->transfer_len > req->ns->size)) {
+	if (unlikely(!nvmet_file_check_lba_range(req,
+						 le64_to_cpu(req->cmd->rw.slba),
+						 req->transfer_len, &pos))) {
 		ret = -ENOSPC;
 		goto complete;
 	}
@@ -283,19 +297,22 @@ static void nvmet_file_execute_discard(s
 	int i;
 
 	for (i = 0; i <= le32_to_cpu(req->cmd->dsm.nr); i++) {
+		u64 len64;
+
 		status = nvmet_copy_from_sgl(req, i * sizeof(range), &range,
 					sizeof(range));
 		if (status)
 			break;
 
-		offset = le64_to_cpu(range.slba) << req->ns->blksize_shift;
-		len = le32_to_cpu(range.nlb);
-		len <<= req->ns->blksize_shift;
-		if (offset + len > req->ns->size) {
+		if (check_shl_overflow((u64)le32_to_cpu(range.nlb),
+				       req->ns->blksize_shift, &len64) ||
+		    !nvmet_file_check_lba_range(req, le64_to_cpu(range.slba),
+					len64, &offset)) {
 			req->error_slba = le64_to_cpu(range.slba);
 			status = errno_to_nvme_status(req, -ENOSPC);
 			break;
 		}
+		len = len64;
 
 		ret = vfs_fallocate(req->ns->file, mode, offset, len);
 		if (ret && ret != -EOPNOTSUPP) {
@@ -340,16 +357,17 @@ static void nvmet_file_write_zeroes_work
 	int mode = FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE;
 	loff_t offset;
 	loff_t len;
+	u64 len64;
 	int ret;
 
-	offset = le64_to_cpu(write_zeroes->slba) << req->ns->blksize_shift;
-	len = (((sector_t)le16_to_cpu(write_zeroes->length) + 1) <<
-			req->ns->blksize_shift);
-
-	if (unlikely(offset + len > req->ns->size)) {
+	if (check_shl_overflow((u64)le16_to_cpu(write_zeroes->length) + 1,
+			       req->ns->blksize_shift, &len64) ||
+	    !nvmet_file_check_lba_range(req, le64_to_cpu(write_zeroes->slba),
+				len64, &offset)) {
 		nvmet_req_complete(req, errno_to_nvme_status(req, -ENOSPC));
 		return;
 	}
+	len = len64;
 
 	ret = vfs_fallocate(req->ns->file, mode, offset, len);
 	nvmet_req_complete(req, ret < 0 ? errno_to_nvme_status(req, ret) : 0);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 485/555] nvmet: zns: return the namespace lookup error for Identify
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (483 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 484/555] nvmet: use overflow-safe range checks " Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 486/555] scsi: target: core: Parse APTPL res_type and res_scope as hex Greg Kroah-Hartman
                   ` (69 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Shao Mingyin, Keith Busch

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Shao Mingyin <shao.mingyin@zte.com.cn>

commit 687f3014afcd5826fa3d8f40b445f647b5a379b6 upstream.

nvmet_execute_identify_ns_zns() jumps to done when nvmet_req_find_ns()
fails, and that label overwrites status with a successful copy of the
zeroed identify data.  An Identify with CNS 05h and CSI 02h for a
missing NSID therefore completes with SUCCESS and zeroed data instead
of Invalid Namespace.

Return the lookup error instead.

Fixes: aaf2e048af27 ("nvmet: add ZBD over ZNS backend support")
Cc: stable@vger.kernel.org
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/nvme/target/zns.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/drivers/nvme/target/zns.c
+++ b/drivers/nvme/target/zns.c
@@ -112,7 +112,7 @@ void nvmet_execute_identify_ns_zns(struc
 
 	status = nvmet_req_find_ns(req);
 	if (status)
-		goto done;
+		goto out;
 
 	if (nvmet_ns_revalidate(req->ns)) {
 		mutex_lock(&req->ns->subsys->lock);
@@ -144,7 +144,6 @@ void nvmet_execute_identify_ns_zns(struc
 		mar--;
 	id_zns->mar = cpu_to_le32(mar);
 
-done:
 	status = nvmet_copy_to_sgl(req, 0, id_zns, sizeof(*id_zns));
 out:
 	kfree(id_zns);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 486/555] scsi: target: core: Parse APTPL res_type and res_scope as hex
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (484 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 485/555] nvmet: zns: return the namespace lookup error for Identify Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 487/555] scsi: target: Fix NULL pointer dereference in core_alua_do_port_transition() Greg Kroah-Hartman
                   ` (68 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Ciro Iriarte,
	Martin K. Petersen (Oracle)

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ciro Iriarte <ciro.iriarte+software@gmail.com>

commit 08f08a6d49efc422258edba802faa4fc7677309e upstream.

core_scsi3_update_aptpl_buf() saves the reservation holder's type and scope
to the APTPL metadata file as zero-padded hex ("res_type=%02x",
"res_scope=%02x"), but target_pr_res_aptpl_metadata_store() reads them back
with "%d" tokens and match_int(), which parse with base 0. A leading zero
selects octal, so match_token() parses only the "0" of "res_type=08", the
trailing "8" makes the token not match, and the field is ignored as
unknown. An Exclusive Access - All Registrants holder (type 0x8) is left
with type 0 and the write fails with -EINVAL and

  Illegal PR type: 0x00 for reservation holder

Userspace that restores APTPL state by writing the saved records back to
pr/res_aptpl_metadata (rtslib-fb does this when it recreates a storage
object) therefore loses every type 8 reservation across a target restart,
and with rtslib the storage object creation fails. The other valid types
(1, 3, 5, 6, 7) and scope 0 only work because their octal and decimal
values coincide.

Keep the on-disk format and parse both fields as hex. The valid type and
scope values have the same hex and decimal representation, so records
written in decimal by hand keep working.

Fixes: c66ac9db8d4a ("[SCSI] target: Add LIO target core v4.0.0-rc6")
Cc: stable@vger.kernel.org
Signed-off-by: Ciro Iriarte <ciro.iriarte+software@gmail.com>
Link: https://patch.msgid.link/ea903e6c-09b5-4a11-80e8-6e1387f39ef5@gmail.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/target/target_core_configfs.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -2041,8 +2041,8 @@ static match_table_t tokens = {
 	{Opt_initiator_sid, "initiator_sid=%s"},
 	{Opt_sa_res_key, "sa_res_key=%s"},
 	{Opt_res_holder, "res_holder=%d"},
-	{Opt_res_type, "res_type=%d"},
-	{Opt_res_scope, "res_scope=%d"},
+	{Opt_res_type, "res_type=%x"},
+	{Opt_res_scope, "res_scope=%x"},
 	{Opt_res_all_tg_pt, "res_all_tg_pt=%d"},
 	{Opt_mapped_lun, "mapped_lun=%u"},
 	{Opt_target_fabric, "target_fabric=%s"},
@@ -2144,13 +2144,13 @@ static ssize_t target_pr_res_aptpl_metad
 			res_holder = arg;
 			break;
 		case Opt_res_type:
-			ret = match_int(args, &arg);
+			ret = match_hex(args, &arg);
 			if (ret)
 				goto out;
 			type = (u8)arg;
 			break;
 		case Opt_res_scope:
-			ret = match_int(args, &arg);
+			ret = match_hex(args, &arg);
 			if (ret)
 				goto out;
 			break;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 487/555] scsi: target: Fix NULL pointer dereference in core_alua_do_port_transition()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (485 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 486/555] scsi: target: core: Parse APTPL res_type and res_scope as hex Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 488/555] scsi: target: Fix NULL pointer dereference in target_dev_alua_lu_gp_store() Greg Kroah-Hartman
                   ` (67 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Shao Mingyin,
	Martin K. Petersen (Oracle)

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Shao Mingyin <shao.mingyin@zte.com.cn>

commit c0bb6614132c64205a3c40c32dc1494c1bfeffe1 upstream.

core_alua_do_port_transition() assumes that the device has an ALUA LU group
member and that the member is associated with an LU group. Neither is
guaranteed: internal-use HBAs never allocate dev_alua_lu_gp_mem, and the
association with an LU group is dropped when "NULL" is written to the
device's alua_lu_gp attribute.

The configfs path can reach the second case. After clearing the LU group
association, writing the implicit ALUA access state of a target port group
calls core_alua_do_port_transition(), which dereferences the NULL lu_gp in
atomic_inc(&lu_gp->lu_gp_ref_cnt).

Return -ENODEV when the device has no LU group association instead.

Fixes: c66ac9db8d4a ("[SCSI] target: Add LIO target core v4.0.0-rc6")
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261026195133237y2UxJLoV1FK6aD1zrFbIU@zte.com.cn
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/target/target_core_alua.c |    7 +++++++
 1 file changed, 7 insertions(+)

--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -1072,8 +1072,15 @@ int core_alua_do_port_transition(
 		return -EINVAL;
 
 	local_lu_gp_mem = l_dev->dev_alua_lu_gp_mem;
+	if (!local_lu_gp_mem)
+		return -ENODEV;
+
 	spin_lock(&local_lu_gp_mem->lu_gp_mem_lock);
 	lu_gp = local_lu_gp_mem->lu_gp;
+	if (!lu_gp) {
+		spin_unlock(&local_lu_gp_mem->lu_gp_mem_lock);
+		return -ENODEV;
+	}
 	atomic_inc(&lu_gp->lu_gp_ref_cnt);
 	spin_unlock(&local_lu_gp_mem->lu_gp_mem_lock);
 	/*



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 488/555] scsi: target: Fix NULL pointer dereference in target_dev_alua_lu_gp_store()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (486 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 487/555] scsi: target: Fix NULL pointer dereference in core_alua_do_port_transition() Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 489/555] scsi: target: iscsi: Check for existing sessions only after authentication Greg Kroah-Hartman
                   ` (66 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Shao Mingyin,
	Martin K. Petersen (Oracle)

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Shao Mingyin <shao.mingyin@zte.com.cn>

commit fe5988e8708e1d42cb844bd9ac8f0a51388061fc upstream.

Writing "NULL" to the alua_lu_gp attribute clears the ALUA LU group
association of a device. The attribute can be written again after the
association has already been cleared. In that case lu_gp_mem->lu_gp and
lu_gp_new are both NULL, but the code still calls
__core_alua_attach_lu_gp_mem(), which dereferences the NULL lu_gp pointer:

  BUG: kernel NULL pointer dereference, address: 0000000000000000
  ...
  __core_alua_attach_lu_gp_mem
  target_dev_alua_lu_gp_store

Clearing an already cleared association is a no-op, so return early when
there is no association left to clear.

Fixes: c66ac9db8d4a ("[SCSI] target: Add LIO target core v4.0.0-rc6")
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261026194955694FnXGoQ352dstLk5HPBqCG@zte.com.cn
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/target/target_core_configfs.c |    8 ++++++++
 1 file changed, 8 insertions(+)

--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -2462,6 +2462,14 @@ static ssize_t target_dev_alua_lu_gp_sto
 
 	spin_lock(&lu_gp_mem->lu_gp_mem_lock);
 	lu_gp = lu_gp_mem->lu_gp;
+	if (!lu_gp && !lu_gp_new) {
+		/*
+		 * The LU group association has already been cleared, so
+		 * there is nothing left to do.
+		 */
+		spin_unlock(&lu_gp_mem->lu_gp_mem_lock);
+		return count;
+	}
 	if (lu_gp) {
 		/*
 		 * Clearing an existing lu_gp association, and replacing



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 489/555] scsi: target: iscsi: Check for existing sessions only after authentication
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (487 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 488/555] scsi: target: Fix NULL pointer dereference in target_dev_alua_lu_gp_store() Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 490/555] scsi: ufs: bsg: Abort ufs_bsg_request() when runtime resume fails Greg Kroah-Hartman
                   ` (65 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Praneeth Balasubramanian,
	Martin K. Petersen (Oracle)

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Praneeth Balasubramanian <praneeth@ucsb.edu>

commit 48d3b732e5ad3fffe74e033d9a3cf47ebaa314b0 upstream.

In the operational-negotiation path (CSG=1), iscsi_target_handle_csg_one()
calls iscsi_target_check_for_existing_instances() before
iscsi_conn_authenticated(). An initiator can therefore send a first Login
PDU with CSG=1, TSIH=0 and no CHAP exchange, carrying the InitiatorName and
ISID of an existing session. The target reinstates that session, which
tears down the legitimate initiator's connection. Only afterwards does it
reject the login with AUTH_FAILED.

iscsi_check_for_session_reinstatement() matches on ISID, InitiatorName and
SessionType only. The InitiatorName is not secret, and open-iscsi ISIDs are
a fixed OUI followed by a small session counter. A remote peer with no
credentials can thus repeatedly disconnect a CHAP-authenticated session and
keep its I/O failing.

The comment above iscsi_target_check_for_existing_instances() already
states the intended invariant:

  NOTE: We check for existing sessions or connections AFTER the initiator
  has been successfully authenticated in order to protect against faked
  ISID/TSIH combinations.

The security-negotiation path (CSG=0) honours this, calling the check only
once authentication completes. Move the CSG=1 call below the authentication
check so both paths behave the same. When authentication is not required,
iscsi_conn_authenticated() returns true and behaviour is unchanged.

Fixes: e48354ce078c ("iscsi-target: Add iSCSI fabric support for target v4.1")
Cc: stable@vger.kernel.org
Signed-off-by: Praneeth Balasubramanian <praneeth@ucsb.edu>
Link: https://patch.msgid.link/20261029205456.1211532-1-praneethb2002@gmail.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/target/iscsi/iscsi_target_nego.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/drivers/target/iscsi/iscsi_target_nego.c
+++ b/drivers/target/iscsi/iscsi_target_nego.c
@@ -982,9 +982,6 @@ static int iscsi_target_handle_csg_one(s
 		if (iscsi_target_check_first_request(conn, login) < 0)
 			return -1;
 
-	if (iscsi_target_check_for_existing_instances(conn, login) < 0)
-		return -1;
-
 	ret = iscsi_encode_text_output(
 			PHASE_OPERATIONAL|PHASE_DECLARATIVE,
 			SENDER_TARGET,
@@ -1008,6 +1005,9 @@ static int iscsi_target_handle_csg_one(s
 		return -1;
 	}
 
+	if (iscsi_target_check_for_existing_instances(conn, login) < 0)
+		return -1;
+
 	if (!iscsi_check_negotiated_keys(conn->param_list))
 		if ((login_req->flags & ISCSI_FLAG_LOGIN_NEXT_STAGE3) &&
 		    (login_req->flags & ISCSI_FLAG_LOGIN_TRANSIT))



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 490/555] scsi: ufs: bsg: Abort ufs_bsg_request() when runtime resume fails
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (488 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 489/555] scsi: target: iscsi: Check for existing sessions only after authentication Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 491/555] scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper Greg Kroah-Hartman
                   ` (64 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Stanley Jhu, Bart Van Assche,
	Peter Wang, Martin K. Petersen (Oracle)

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Stanley Jhu <stanleyjhu@google.com>

commit 2b8541edf7c43f0294c45d2e687bbc1288292f4e upstream.

ufs_bsg_request() resumes the UFS device W-LUN with ufshcd_rpm_get_sync()
and ignores its return value:

 1. The W-LUN is runtime suspended.
 2. User space submits a BSG request.
 3. ufs_bsg_request() calls ufshcd_rpm_get_sync().
 4. The W-LUN runtime resume fails and the W-LUN stays suspended.
 5. ufshcd_rpm_get_sync() returns a negative errno, which is ignored.
 6. ufs_bsg_request() dispatches the BSG command while the W-LUN is
    still suspended.

Use ufshcd_rpm_resume_and_get() and jump to out_complete on error so the
BSG job is completed via bsg_job_done() with the failure code without
dropping an unacquired runtime PM reference.

Fixes: b294ff3e3449 ("scsi: ufs: core: Enable power management for wlun")
Cc: stable@vger.kernel.org # needs "scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper"
Signed-off-by: Stanley Jhu <stanleyjhu@google.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Link: https://patch.msgid.link/20261029040003.2100003-5-stanleyjhu@google.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/ufs/core/ufs_bsg.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/drivers/ufs/core/ufs_bsg.c
+++ b/drivers/ufs/core/ufs_bsg.c
@@ -152,7 +152,9 @@ static int ufs_bsg_request(struct bsg_jo
 		goto out_complete;
 	}
 
-	ufshcd_rpm_get_sync(hba);
+	ret = ufshcd_rpm_resume_and_get(hba);
+	if (ret)
+		goto out_complete;
 
 	msgcode = bsg_request->msgcode;
 	switch (msgcode) {



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 491/555] scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (489 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 490/555] scsi: ufs: bsg: Abort ufs_bsg_request() when runtime resume fails Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 492/555] smb: client: fix negative timestamps being read from smb Greg Kroah-Hartman
                   ` (63 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Stanley Jhu, Bart Van Assche,
	Peter Wang, Martin K. Petersen (Oracle)

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Stanley Jhu <stanleyjhu@google.com>

commit cbab12e5b4a7f49d5add4301de275351269cd431 upstream.

ufshcd_clkscale_enable_store() and ufshcd_auto_hibern8_update() resume the
UFS device W-LUN with ufshcd_rpm_get_sync() and ignore its return value.

For clkscale_enable:

 1. The W-LUN is runtime suspended and clock scaling is disabled.
 2. User space writes 1 to clkscale_enable.
 3. ufshcd_clkscale_enable_store() calls ufshcd_rpm_get_sync().
 4. The W-LUN runtime resume fails and the W-LUN stays suspended.
 5. ufshcd_rpm_get_sync() returns a negative errno, which is ignored.
 6. ufshcd_clkscale_enable_store() enables clock scaling and resumes
    devfreq while the W-LUN is still suspended.

For auto_hibern8:

 1. The W-LUN starts a runtime suspend.
 2. User space writes a new value to auto_hibern8.
 3. ufshcd_auto_hibern8_update() sees that the W-LUN is not yet
    suspended and calls ufshcd_rpm_get_sync().
 4. ufshcd_rpm_get_sync() waits for the runtime suspend to finish and
    then runs the W-LUN runtime resume.
 5. The W-LUN runtime resume fails and the W-LUN stays suspended.
 6. ufshcd_rpm_get_sync() returns a negative errno, which is ignored.
 7. ufshcd_auto_hibern8_update() writes REG_AUTO_HIBERNATE_IDLE_TIMER
    while the W-LUN is still suspended.

Add ufshcd_rpm_resume_and_get() wrapping pm_runtime_resume_and_get() so
failed resumes drop the usage reference automatically, and return early in
ufshcd_clkscale_enable_store() and ufshcd_auto_hibern8_update() when it
fails.

Fixes: b294ff3e3449 ("scsi: ufs: core: Enable power management for wlun")
Cc: stable@vger.kernel.org
Signed-off-by: Stanley Jhu <stanleyjhu@google.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Link: https://patch.msgid.link/20261029040003.2100003-3-stanleyjhu@google.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/ufs/core/ufshcd-priv.h |    5 +++++
 drivers/ufs/core/ufshcd.c      |    7 +++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

--- a/drivers/ufs/core/ufshcd-priv.h
+++ b/drivers/ufs/core/ufshcd-priv.h
@@ -317,6 +317,11 @@ static inline int ufshcd_rpm_get_sync(st
 	return pm_runtime_get_sync(&hba->ufs_device_wlun->sdev_gendev);
 }
 
+static inline int ufshcd_rpm_resume_and_get(struct ufs_hba *hba)
+{
+	return pm_runtime_resume_and_get(&hba->ufs_device_wlun->sdev_gendev);
+}
+
 static inline int ufshcd_rpm_get_if_active(struct ufs_hba *hba)
 {
 	return pm_runtime_get_if_active(&hba->ufs_device_wlun->sdev_gendev);
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -1778,7 +1778,9 @@ static ssize_t ufshcd_clkscale_enable_st
 	if (value == hba->clk_scaling.is_enabled)
 		goto out;
 
-	ufshcd_rpm_get_sync(hba);
+	err = ufshcd_rpm_resume_and_get(hba);
+	if (err)
+		goto out;
 	ufshcd_hold(hba);
 
 	hba->clk_scaling.is_enabled = value;
@@ -4542,7 +4544,8 @@ void ufshcd_auto_hibern8_update(struct u
 
 	WRITE_ONCE(hba->ahit, ahit);
 	if (!pm_runtime_suspended(&hba->ufs_device_wlun->sdev_gendev)) {
-		ufshcd_rpm_get_sync(hba);
+		if (ufshcd_rpm_resume_and_get(hba))
+			return;
 		ufshcd_hold(hba);
 		ufshcd_configure_auto_hibern8(hba);
 		ufshcd_release(hba);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 492/555] smb: client: fix negative timestamps being read from smb
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (490 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 491/555] scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 493/555] smb: client: fix times assignments in cifs_posix_to_fattr() Greg Kroah-Hartman
                   ` (62 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, koraynilay, Namjae Jeon,
	Paulo Alcantara

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: koraynilay <koray.fra@gmail.com>

commit 6a75ce0866bb1efe67947fc5536a476381d7a9d9 upstream.

When reading a timestamp before epoch 0, cifs converts it from NT format
to Unix format without normalizing it, leading to the nanoseconds field
to be used as a negative number, which leads to a garbled stat command
output.

This bug also violates a struct timespec64 invariant, as documented in
the set_normalized_timespec64() kernel-doc:
[...]
 * Note: The tv_nsec part is always in the range of 0 <= tv_nsec <
 * NSEC_PER_SEC.
 * For negative values only the tv_sec field is negative !
 */

Reproducer, with /tmp as the local filesystem folder exported as [test]
in ksmbd.conf and /mnt as the smb folder mounted with mount -t cifs:

  mount -t cifs //127.0.0.1/test /mnt -o username=user,password=pass
  touch -d "1969-07-20 20:17:40.123456789" /tmp/test.txt
  stat -c "Server local (/tmp):   %y" /tmp/test.txt
  stat -c "CIFS client  (/mnt):   %y" /mnt/test.txt --cached=never
  smbclient //127.0.0.1/test -U user%pass -c "allinfo test.txt"

which prints (stat output is garbled because of negative value):

  Server local (/tmp):   1969-07-20 20:17:40.123456789 +0000
  CIFS client  (/mnt):   1969-07-20 20:17:41.()*+,--00 +0000
  altname: TESTT~K6.TXT
  [...]
  access_time:    Sun Jul 20 20:17:40 1969 UTC
  write_time:     Sun Jul 20 20:17:40 1969 UTC
  [...]

Fix this by using set_normalized_timespec64() in cifs_NTtimeToUnix().

Fixes: 2ae83bf93882 ("[CIFS] Fix setting time before epoch (negative time values)")
Cc: stable@vger.kernel.org
Assisted-by: Gemini:3.8-flash-high antigravity-cli-1.5.3
Signed-off-by: koraynilay <koray.fra@gmail.com>
Reviewed-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/smb/client/netmisc.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/fs/smb/client/netmisc.c
+++ b/fs/smb/client/netmisc.c
@@ -942,8 +942,7 @@ cifs_NTtimeToUnix(__le64 ntutc)
 	if (t < 0) {
 		abs_t = -t;
 		ts.tv_nsec = (time64_t)(do_div(abs_t, 10000000) * 100);
-		ts.tv_nsec = -ts.tv_nsec;
-		ts.tv_sec = -abs_t;
+		set_normalized_timespec64(&ts, -abs_t, -ts.tv_nsec);
 	} else {
 		abs_t = t;
 		ts.tv_nsec = (time64_t)do_div(abs_t, 10000000) * 100;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 493/555] smb: client: fix times assignments in cifs_posix_to_fattr()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (491 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 492/555] smb: client: fix negative timestamps being read from smb Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 494/555] tracing/osnoise: Dont start a kthread in timerlat user-space mode Greg Kroah-Hartman
                   ` (61 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Sashiko, koraynilay, Namjae Jeon,
	Paulo Alcantara

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: koraynilay <koray.fra@gmail.com>

commit 8b456f136a76a29fee8d36934740cb7f7fb5c837 upstream.

Currently cifs_posix_to_fattr() wrongly sets SMB's CreationTime to
fattr->cf_ctime.

Fix this by setting fattr->cf_createtime to SMB's CreationTime and
fattr->cf_ctime to SMB's ChangeTime, matching the behaviour of
__dir_info_to_fattr().

This patch also fixes a few related issues reported by sashiko on
another patch (see Sashiko Link tag).

Reproducers for these bugs, with /tmp as the local filesystem folder
exported as [test] in ksmbd.conf and /mnt as the smb folder mounted with
mount -t cifs:

  mount -t cifs //127.0.0.1/test /mnt -o username=ciao,password=c,posix

Issue 1: ctime clobbered by CreationTime during readdir

  mkdir -p /mnt/dir
  touch /mnt/dir/file
  sleep 4
  chmod 644 /mnt/dir/file
  stat -c "ctime and btime before readdir: %Z %W" /mnt/dir/file
  ls -lc /mnt/dir > /dev/null
  stat -c "ctime and btime after readdir:  %Z %W" /mnt/dir/file
  stat -c "ctime and btime on disk:        %Z %W" /tmp/dir/file

output before the fix, notice how ctime is the same as btime after the
readdir, while it's 4 seconds ahead (because of the sleep 4) before the
readdir (on disk timestamps are not touched):

  ctime and btime before readdir: 1794842068 1794842064
  ctime and btime after readdir:  1794842064 1794842064

  ctime and btime on disk:        1794842068 1794842064

output after the fix:

  ctime and btime before readdir: 1794842908 1794842904
  ctime and btime after readdir:  1794842908 1794842904

  ctime and btime on disk:        1794842908 1794842904

Issue 2: btime and ptime wiped out by readdir

[ no reproducer as it only happens after the linked patch series is
  applied, since it needs cifs_i->createtime = fattr->cf_createtime in
  cifs_fattr_to_inode() ]

Issue 3: in-memory inode aliasing (flock bypass on hardlink via readdir)

  mkdir -p /mnt/dir1 /mnt/dir2
  echo "test" > /mnt/dir1/h1
  ln /mnt/dir1/h1 /mnt/dir2/h2
  exec 3< /mnt/dir1/h1
  flock -x -n 3 # get exclusive lock
  ls /mnt/dir2 > /dev/null
  exec 4< /mnt/dir2/h2
  flock -x -n 4
  if [ $? -eq 0 ];then
  	echo "acquired: duplicate in-memory inode"
  else
  	echo "blocked: same inode"
  fi

output before the fix:

  acquired: duplicate in-memory inode

output after the fix:

  blocked: same inode

Fixes: 3d519bd1269f ("cifs: plumb smb2 POSIX dir enumeration")
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/patchset/20261115180343.576773-1-koray.fra%40gmail.com?part=10
Link: https://lore.kernel.org/all/20261115180343.576773-11-koray.fra@gmail.com/
Assisted-by: Gemini:3.8-flash-high antigravity-cli-1.5.7
Signed-off-by: koraynilay <koray.fra@gmail.com>
Reviewed-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/smb/client/readdir.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/fs/smb/client/readdir.c
+++ b/fs/smb/client/readdir.c
@@ -252,9 +252,10 @@ cifs_posix_to_fattr(struct cifs_fattr *f
 	fattr->cf_bytes = le64_to_cpu(info->AllocationSize);
 	fattr->cf_eof = le64_to_cpu(info->EndOfFile);
 
+	fattr->cf_createtime = le64_to_cpu(info->CreationTime);
 	fattr->cf_atime = cifs_NTtimeToUnix(info->LastAccessTime);
 	fattr->cf_mtime = cifs_NTtimeToUnix(info->LastWriteTime);
-	fattr->cf_ctime = cifs_NTtimeToUnix(info->CreationTime);
+	fattr->cf_ctime = cifs_NTtimeToUnix(info->ChangeTime);
 
 	fattr->cf_nlink = le32_to_cpu(info->HardLinks);
 	fattr->cf_cifsattrs = le32_to_cpu(info->DosAttributes);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 494/555] tracing/osnoise: Dont start a kthread in timerlat user-space mode
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (492 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 493/555] smb: client: fix times assignments in cifs_posix_to_fattr() Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 495/555] tracing/user_events: Dont free an event that a dynamic event still references Greg Kroah-Hartman
                   ` (60 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Chaosheng Qu, Steven Rostedt

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Chaosheng Qu <chaosheng.qu.linux@gmail.com>

commit 5f855410554564ca05903979e6dab96e754d8773 upstream.

In timerlat user-space mode (NO_OSNOISE_WORKLOAD) the workload is a user
task reading timerlat_fd, so there is no per-CPU kernel thread to run.
start_kthread() only checks for that in the osnoise branch:

	if (timerlat_enabled()) {
		snprintf(comm, 24, "timerlat/%d", cpu);
		main = timerlat_main;
	} else {
		/* if no workload, just return */
		if (!test_bit(OSN_WORKLOAD, &osnoise_options)) {
			...
			return 0;
		}
		...
	}

start_per_cpu_kthreads() guards against this mode itself, but
osnoise_hotplug_workfn() calls start_kthread() directly. Bringing a CPU
online in user-space mode therefore starts a timerlat/N thread and sets
its bit in kthread_cpumask while OSN_WORKLOAD is clear.

stop_kthread() uses that bit to decide what the recorded task is:

	if (cpumask_test_and_clear_cpu(cpu, &kthread_cpumask) &&
	    !WARN_ON(!test_bit(OSN_WORKLOAD, &osnoise_options))) {
		kthread_stop(kthread);
	} else if (!WARN_ON(test_bit(OSN_WORKLOAD, &osnoise_options))) {
		kill_pid(kthread->thread_pid, SIGKILL, 1);
		put_task_struct(kthread);
	}

The bit is set but OSN_WORKLOAD is not, so the first WARN_ON() fires and
the && short-circuits into the user-task branch. A running kernel thread
is SIGKILLed and its task_struct is put without ever being stopped, so it
keeps executing until it is freed underneath itself.

Any write to osnoise/options reaches this: osnoise_options_write() stops
the per-CPU threads before applying the new value, so stop_kthread()
still sees OSN_WORKLOAD clear. Re-writing the value that is already set
triggers it just as well as changing it.

  echo NO_OSNOISE_WORKLOAD > osnoise/options
  echo timerlat > current_tracer
  echo 0 > /sys/devices/system/cpu/cpu1/online
  echo 1 > /sys/devices/system/cpu/cpu1/online
  echo NO_OSNOISE_WORKLOAD > osnoise/options

The offline/online pair is required, otherwise no kthread is recorded and
no bit is set. Running this on 7.3-rc7 with KASAN gives a WARNING in
stop_kthread() followed by a slab-use-after-free in update_se(); leaving
out the hotplug step produces neither.

Keep the check in start_kthread(), where the related hotplug bug was
fixed in 0bb0a5c12ecf, instead of adding another copy to the callback.

Cc: stable@vger.kernel.org
Fixes: e88ed227f639 ("tracing/timerlat: Add user-space interface")
Link: https://patch.msgid.link/20261014081034.12702-1-chaosheng.qu.linux@gmail.com
Signed-off-by: Chaosheng Qu <chaosheng.qu.linux@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 kernel/trace/trace_osnoise.c |    8 ++++++++
 1 file changed, 8 insertions(+)

--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -2018,6 +2018,14 @@ static int start_kthread(unsigned int cp
 		return 0;
 
 	if (timerlat_enabled()) {
+		/*
+		 * In timerlat user-space mode the workload is the user task
+		 * reading timerlat_fd, so there is no kernel thread to start.
+		 * One started here would set its kthread_cpumask bit, which
+		 * stop_kthread() reads as "osnoise workload kthread".
+		 */
+		if (!test_bit(OSN_WORKLOAD, &osnoise_options))
+			return 0;
 		snprintf(comm, 24, "timerlat/%d", cpu);
 		main = timerlat_main;
 	} else {



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 495/555] tracing/user_events: Dont free an event that a dynamic event still references
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (493 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 494/555] tracing/osnoise: Dont start a kthread in timerlat user-space mode Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:08 ` [PATCH 6.12 496/555] tracing/filters: Check for missing operand after operator in parse_pred() Greg Kroah-Hartman
                   ` (59 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, David Carlier, Steven Rostedt

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: David Carlier <devnexen@gmail.com>

commit 0fbdc293697a5d72dc985e533eef5155a1b264cc upstream.

An eprobe takes a reference on the call of the event it attaches to,
and kprobe, uprobe, fprobe and synth events all refuse to go away while
trace_event_dyn_busy() says such a reference exists. user_events never
checks it, so a user event can be freed under an eprobe:

  echo 'u:test u32 a' >> dynamic_events
  echo 'e:ep user_events/test a=$a' >> dynamic_events
  echo '-:user_events/test u32 a' >> dynamic_events
  echo '-:eprobes/ep' >> dynamic_events

The last write drops the reference on the freed call.

If the last fd of a non-persistent event closes while such a reference
is held, the delayed destroy now fails. Mark the event persistent then,
so it can still be deleted once the reference is gone instead of being
leaked.

Return -EBUSY from destroy_user_event() in that case.

Fixes: 7f5a08c79df3 ("user_events: Add minimal support for trace_event into ftrace")
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261031212453.16116-1-devnexen@gmail.com
Signed-off-by: David Carlier <devnexen@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 kernel/trace/trace_events_user.c |    9 +++++++++
 1 file changed, 9 insertions(+)

--- a/kernel/trace/trace_events_user.c
+++ b/kernel/trace/trace_events_user.c
@@ -256,6 +256,11 @@ static void delayed_destroy_user_event(s
 		 * attempt to delete it later.
 		 */
 		pr_warn("user_events: Unable to delete event\n");
+		/*
+		 * Keep it as persistent so it can be still deleted
+		 * since nobody own this event
+		 */
+		user->reg_flags |= USER_EVENT_REG_PERSIST;
 		refcount_set(&user->refcnt, 1);
 	}
 out:
@@ -1516,6 +1521,10 @@ static int destroy_user_event(struct use
 
 	lockdep_assert_held(&event_mutex);
 
+	/* If there is a reference to a dynamic event */
+	if (trace_event_dyn_busy(&user->call))
+		return -EBUSY;
+
 	/*
 	 * Detach the fields before removing the call. Removing the event
 	 * frees the field list memory (trace_destroy_fields() is run on



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 496/555] tracing/filters: Check for missing operand after operator in parse_pred()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (494 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 495/555] tracing/user_events: Dont free an event that a dynamic event still references Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 497/555] tracing/filters: Fix MATCH_END_ONLY regex matching for fixed-size strings Greg Kroah-Hartman
                   ` (58 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Masami Hiramatsu (Google),
	Steven Rostedt

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

commit 42647658bdd8434a90c1b63391081396f36820ba upstream.

In parse_pred(), after matching the operator and skipping whitespace,
the filter string may terminate (str[i] == '\0') if the operand is
missing (e.g. "ip ==" or "common_pid ==").

For function events, the loop 'for (i++; str[i]; i++)' unconditionally
increments 'i' past the NUL terminator, causing an out-of-bounds read.
For other event types, allocating a predicate only to fail later during
value parsing is wasteful.

Check if 'str[i]' is NUL immediately after skipping whitespace after
the operator, and report FILT_ERR_INVALID_FILTER.

Cc: stable@vger.kernel.org
Fixes: 80765597bc58 ("tracing: Rewrite filter logic to be simpler and faster")
Link: https://patch.msgid.link/179323789181.740114.16161070743864669086.stgit@devnote2
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 kernel/trace/trace_events_filter.c |    5 +++++
 1 file changed, 5 insertions(+)

--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -1583,6 +1583,11 @@ static int parse_pred(const char *str, v
 	while (isspace(str[i]))
 		i++;
 
+	if (!str[i]) {
+		parse_error(pe, FILT_ERR_INVALID_FILTER, pos + i);
+		goto err_free;
+	}
+
 	s = i;
 
 	pred = kzalloc(sizeof(*pred), GFP_KERNEL);



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 497/555] tracing/filters: Fix MATCH_END_ONLY regex matching for fixed-size strings
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (495 preceding siblings ...)
  2026-12-04 10:08 ` [PATCH 6.12 496/555] tracing/filters: Check for missing operand after operator in parse_pred() Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 498/555] tracing/filters: Handle out-of-range CPU for OP_NE in cpumask comparison Greg Kroah-Hartman
                   ` (57 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Masami Hiramatsu (Google),
	Steven Rostedt

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

commit b82178ad9e282e20c3f3636bde5c52143ed5b933 upstream.

regex_match_end() calculates string length as "len - 1", assuming @len
is the string length including trailing '\0'. For dynamic strings
(filter_pred_strloc) and pointer strings (filter_pchar), this assumption
holds and allows O(1) constant-time suffix matching.

However, for fixed-size string fields (FILTER_STATIC_STRING) and "comm"
(FILTER_COMM), the callers pass the buffer capacity rather than the
actual string length (field->size for filter_pred_string, and
TASK_COMM_LEN for filter_pred_comm). Because these buffers hold
null-terminated strings (e.g. prev_comm in sched_switch holding "bash"
in a 16-byte buffer), regex_match_end() tests against the tail of the
buffer capacity (typically trailing '\0' padding at offset 13) rather
than the actual string end. Consequently, suffix matching like
comm ~ "*sh" or prev_comm ~ "*sh" fails for all strings shorter than
the buffer capacity.

Furthermore, for trace events like ftrace/print (trace_marker), the
"buf" field is defined with size 0, denoting an unbounded NUL-terminated
string. regex_match_end() and regex_match_end_str() return 0 when len
is 0, causing suffix matching to fail on ftrace/print events as well.

To fix this without penalizing dynamic and pointer strings with an
unnecessary scan on every event:
- Introduce regex_match_end_str() using strnlen(str, len) for fixed-size
  buffers (FILTER_COMM and FILTER_STATIC_STRING with field->size > 0).
- Introduce regex_match_end_dynstr() using strlen(str) for unbounded
  strings (FILTER_STATIC_STRING with field->size == 0).

Assign these match callbacks in parse_pred() when MATCH_END_ONLY is
requested.

Cc: stable@vger.kernel.org
Fixes: a3291c14ecf0 ("tracing/filters: Fix MATCH_END_ONLY filter matching")
Fixes: 10f20e9f9da9 ("tracing: Have zero size length in filter logic be full string")
Link: https://patch.msgid.link/179323785497.740114.7643531772387726730.stgit@devnote2
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 kernel/trace/trace_events_filter.c |   32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -1064,6 +1064,30 @@ static int regex_match_end(char *str, st
 	return 0;
 }
 
+static int regex_match_end_str(char *str, struct regex *r, int len)
+{
+	int slen;
+
+	if (len < r->len)
+		return 0;
+
+	slen = strnlen(str, len);
+	if (slen >= r->len &&
+	    memcmp(str + slen - r->len, r->pattern, r->len) == 0)
+		return 1;
+	return 0;
+}
+
+static int regex_match_end_dynstr(char *str, struct regex *r, int len)
+{
+	int slen = strlen(str);
+
+	if (slen >= r->len &&
+	    memcmp(str + slen - r->len, r->pattern, r->len) == 0)
+		return 1;
+	return 0;
+}
+
 static int regex_match_glob(char *str, struct regex *r, int len)
 {
 	return glob_match_len(r->pattern, str, len) ? 1 : 0;
@@ -1877,10 +1901,18 @@ static int parse_pred(const char *str, v
 
 		if (field->filter_type == FILTER_COMM) {
 			pred->fn_num = FILTER_PRED_FN_COMM;
+			if (pred->regex->match == regex_match_end)
+				pred->regex->match = regex_match_end_str;
 
 		} else if (field->filter_type == FILTER_STATIC_STRING) {
 			pred->fn_num = FILTER_PRED_FN_STRING;
 			pred->regex->field_len = field->size;
+			if (pred->regex->match == regex_match_end) {
+				if (!field->size)
+					pred->regex->match = regex_match_end_dynstr;
+				else
+					pred->regex->match = regex_match_end_str;
+			}
 
 		} else if (field->filter_type == FILTER_DYN_STRING) {
 			pred->fn_num = FILTER_PRED_FN_STRLOC;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 498/555] tracing/filters: Handle out-of-range CPU for OP_NE in cpumask comparison
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (496 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 497/555] tracing/filters: Fix MATCH_END_ONLY regex matching for fixed-size strings Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 499/555] tracing/filters: Treat zero-length dynamic strings as empty Greg Kroah-Hartman
                   ` (56 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Masami Hiramatsu (Google),
	Steven Rostedt

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

commit 87e0a196153e983a4d95903e7422b7d766cd37cf upstream.

In filter_pred_##size##_cpumask(), if the event's scalar CPU value is
out of range (cpu >= nr_cpu_ids), it unconditionally returns 0.

However, if the predicate operation is OP_NE (e.g., field != CPUS{0,1}),
an out-of-range CPU cannot match any valid CPU in the user-provided
cpumask and the condition is satisfied. Returning 0 produces a false
negative.

Return "pred->op == OP_NE" instead of 0 when cpu >= nr_cpu_ids.

Cc: stable@vger.kernel.org
Fixes: 3cbec9d7b93d ("tracing/filters: Enable filtering a scalar field by a cpumask")
Link: https://patch.msgid.link/179323787340.740114.14434420599496956193.stgit@devnote2
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 kernel/trace/trace_events_filter.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -756,7 +756,7 @@ static int filter_pred_##size##_cpumask(
 	unsigned int cpu = *addr;						\
 										\
 	if (cpu >= nr_cpu_ids)							\
-		return 0;							\
+		return pred->op == OP_NE;					\
 										\
 	return do_filter_scalar_cpumask(pred->op, cpu, pred->mask);		\
 }



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 499/555] tracing/filters: Treat zero-length dynamic strings as empty
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (497 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 498/555] tracing/filters: Handle out-of-range CPU for OP_NE in cpumask comparison Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 500/555] tracing: Avoid undefined shifts for zero histogram map size Greg Kroah-Hartman
                   ` (55 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Kyle Zeng, Masami Hiramatsu (Google),
	Steven Rostedt

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Kyle Zeng <kylebot@openai.com>

commit 97adb02064c6e3f378523b35563848cedbc23ec7 upstream.

The regex callbacks use a length of zero for NUL-terminated strings of
unknown size, such as the trailing buffer in a trace_marker record.
However, filter_pred_strloc() and filter_pred_strrelloc() pass the length
from a data locator directly to those callbacks. A zero-length locator
has no data and need not point at a NUL byte.

In particular, syscall entry events can contain an empty captured array
or a failed user-string copy. Matching such a field with an equality,
prefix, or substring filter can read beyond the record. The per-CPU perf
trace buffer is reused, so an unprivileged counting syscall event can
disclose bytes left by a previous kernel tracepoint even when raw
sampling is denied and exclude_kernel prevents counting that tracepoint.

Handle both locator formats through a common helper. For a zero-length
field, pass an empty string and its actual size to the regex callback.
This gives all matching modes the empty-string semantics without reading
the locator's target. Keep nonzero fields and the legacy trace_marker
unknown-length convention unchanged.

Fixes: 10f20e9f9da9 ("tracing: Have zero size length in filter logic be full string")
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261006225642.58778-1-kylebot@openai.com
Assisted-by: Codex:gpt-6-astra
Signed-off-by: Kyle Zeng <kylebot@openai.com>
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 kernel/trace/trace_events_filter.c |   38 +++++++++++++++++++++++--------------
 1 file changed, 24 insertions(+), 14 deletions(-)

--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -889,6 +889,25 @@ static int filter_pred_pchar_user(struct
 	return filter_pchar(pred, str);
 }
 
+static __always_inline int filter_dyn_string(struct filter_pred *pred,
+					     char *str, int len)
+{
+	int cmp;
+
+	/*
+	 * The regex callbacks use zero for an unknown-length, NUL-terminated
+	 * string. A zero-length data_loc or rel_loc field has no bytes at all.
+	 * Match an empty string instead of reading past the end of the field.
+	 */
+	if (!len) {
+		str = "";
+		len = 1;
+	}
+
+	cmp = pred->regex->match(str, pred->regex, len);
+	return cmp ^ pred->not;
+}
+
 /*
  * Filter predicate for dynamic sized arrays of characters.
  * These are implemented through a list of strings at the end
@@ -905,13 +924,8 @@ static int filter_pred_strloc(struct fil
 	int str_loc = str_item & 0xffff;
 	int str_len = str_item >> 16;
 	char *addr = (char *)(event + str_loc);
-	int cmp, match;
-
-	cmp = pred->regex->match(addr, pred->regex, str_len);
 
-	match = cmp ^ pred->not;
-
-	return match;
+	return filter_dyn_string(pred, addr, str_len);
 }
 
 /*
@@ -928,13 +942,8 @@ static int filter_pred_strrelloc(struct
 	int str_loc = str_item & 0xffff;
 	int str_len = str_item >> 16;
 	char *addr = (char *)(&item[1]) + str_loc;
-	int cmp, match;
-
-	cmp = pred->regex->match(addr, pred->regex, str_len);
-
-	match = cmp ^ pred->not;
 
-	return match;
+	return filter_dyn_string(pred, addr, str_len);
 }
 
 /* Filter predicate for CPUs. */
@@ -1019,7 +1028,8 @@ static int filter_pred_function(struct f
  *
  * @str: the string to be searched
  * @r:   the regex structure containing the pattern string
- * @len: the length of the string to be searched (including '\0')
+ * @len: the length of the string to be searched (including '\0'), or zero
+ *       for a NUL-terminated string of unknown length
  *
  * Note:
  * - @str might not be NULL-terminated if it's of type DYN_STRING
@@ -1028,7 +1038,7 @@ static int filter_pred_function(struct f
 
 static int regex_match_full(char *str, struct regex *r, int len)
 {
-	/* len of zero means str is dynamic and ends with '\0' */
+	/* Zero is reserved for a NUL-terminated string of unknown length. */
 	if (!len)
 		return strcmp(str, r->pattern) == 0;
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 500/555] tracing: Avoid undefined shifts for zero histogram map size
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (498 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 499/555] tracing/filters: Treat zero-length dynamic strings as empty Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 501/555] tracing: Do not allow user events to add a system name Greg Kroah-Hartman
                   ` (54 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Jaewon Jung, Steven Rostedt

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jaewon Jung <jaewon8868@gmail.com>

commit cae7fb0d853eff05c70b08ef9e7ecb18867f8945 upstream.

Reject size=0 before calling roundup_pow_of_two().

include/linux/log2.h documents roundup_pow_of_two() as:

  - the result is undefined when n == 0

With CONFIG_UBSAN_SHIFT=y, a size=0 histogram trigger reports:

  UBSAN: shift-out-of-bounds in include/linux/log2.h
  shift exponent 64 is too large for 64-bit type 'long unsigned int'

Tested on x86_64 QEMU: size=0 is rejected without UBSAN warnings,
and the histogram modifier and parser tests pass.

Fixes: 7ef224d1d0e3 ("tracing: Add 'hist' event trigger command")
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261028074610.2212374-1-jaewon8868@gmail.com
Signed-off-by: Jaewon Jung <jaewon8868@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 kernel/trace/trace_events_hist.c |    5 +++++
 1 file changed, 5 insertions(+)

--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -1414,6 +1414,11 @@ static int parse_map_size(char *str)
 	if (ret)
 		goto out;
 
+	if (!size) {
+		ret = -EINVAL;
+		goto out;
+	}
+
 	map_bits = ilog2(roundup_pow_of_two(size));
 	if (map_bits < TRACING_MAP_BITS_MIN ||
 	    map_bits > TRACING_MAP_BITS_MAX)



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 501/555] tracing: Do not allow user events to add a system name
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (499 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 500/555] tracing: Avoid undefined shifts for zero histogram map size Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 502/555] tracing: Drop the synthetic event ref when clearing hist triggers Greg Kroah-Hartman
                   ` (53 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Beau Belgrave, Steven Rostedt

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Steven Rostedt <rostedt@goodmis.org>

commit 761a77e09577bc7e5fdaff1d11bbff3486a87bf9 upstream.

User events currently do not support the addition of a system name, but
the parsing does not check to see if one is specified.

A kprobe can add its own system name with the following command:

 ~# echo 'p:mysystem/kprobe_event schedule a=%ax' >> dynamic_events
 ~# ls events/mysystem
 enable  filter  kprobe_event

But if one tries to do the same with user events:

 ~# echo 'u:user_events/test u32 a' >> dynamic_events
 ~# ls events/user_events
 ls: reading directory 'events/user_events/': Invalid argument
 enable  filter

It corrupts the file system as the event added had a '/' in the name.

Until user events support specifying system names, just return -EINVAL to
prevent the corrupted file system from happening:

 ~# echo 'u:user_events/test u32 a' >> dynamic_events
 -bash: echo: write error: Invalid argument

Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261118122520.4a689710@gandalf.local.home
Acked-by: Beau Belgrave <beaub@linux.microsoft.com>
Fixes: 7f5a08c79df35 ("user_events: Add minimal support for trace_event into ftrace")
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 kernel/trace/trace_events_user.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/kernel/trace/trace_events_user.c
+++ b/kernel/trace/trace_events_user.c
@@ -1040,6 +1040,9 @@ static int user_event_parse_cmd(struct u
 	if (flags)
 		*flags++ = '\0';
 
+	if (strstr(name, "/") != NULL)
+		return -EINVAL;
+
 	return user_event_parse(group, name, args, flags, newuser, reg_flags);
 }
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 502/555] tracing: Drop the synthetic event ref when clearing hist triggers
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (500 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 501/555] tracing: Do not allow user events to add a system name Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 503/555] tracing: Ignore .function on the function trace event Greg Kroah-Hartman
                   ` (52 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, David Carlier, Steven Rostedt

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: David Carlier <devnexen@gmail.com>

commit 2b3bed9617bb71c9b1893d9f54ef8df59a239224 upstream.

clear_event_triggers() frees a hist trigger on a synthetic event without
dropping the se->ref taken by event_hist_trigger_parse(). Removing an
instance with such a trigger leaves the synthetic event busy forever.

Cc: stable@vger.kernel.org
Fixes: 4b147936fa50 ("tracing: Add support for 'synthetic' events")
Link: https://patch.msgid.link/20261022205405.1228742-1-devnexen@gmail.com
Signed-off-by: David Carlier <devnexen@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 kernel/trace/trace.h                |    2 ++
 kernel/trace/trace_events_hist.c    |   20 +++++++++++++-------
 kernel/trace/trace_events_trigger.c |    2 ++
 3 files changed, 17 insertions(+), 7 deletions(-)

--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -1683,9 +1683,11 @@ extern const struct file_operations even
 #ifdef CONFIG_HIST_TRIGGERS
 extern int register_trigger_hist_cmd(void);
 extern int register_trigger_hist_enable_disable_cmds(void);
+extern void hist_put_synth_event(struct trace_event_file *file);
 #else
 static inline int register_trigger_hist_cmd(void) { return 0; }
 static inline int register_trigger_hist_enable_disable_cmds(void) { return 0; }
+static inline void hist_put_synth_event(struct trace_event_file *file) { }
 #endif
 
 extern int register_trigger_cmds(void);
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -6721,6 +6721,17 @@ static bool hist_trigger_check_refs(stru
 	return false;
 }
 
+void hist_put_synth_event(struct trace_event_file *file)
+{
+	struct synth_event *se;
+
+	lockdep_assert_held(&event_mutex);
+
+	se = find_synth_event_call(file->event_call);
+	if (se)
+		se->ref--;
+}
+
 static void hist_unregister_trigger(char *glob,
 				    struct event_trigger_data *data,
 				    struct trace_event_file *file)
@@ -6776,7 +6787,6 @@ static void hist_unreg_all(struct trace_
 {
 	struct event_trigger_data *test, *n;
 	struct hist_trigger_data *hist_data;
-	struct synth_event *se;
 
 	lockdep_assert_held(&event_mutex);
 
@@ -6789,9 +6799,7 @@ static void hist_unreg_all(struct trace_
 			list_del_rcu(&test->list);
 			trace_event_trigger_enable_disable(file, 0);
 
-			se = find_synth_event_call(file->event_call);
-			if (se)
-				se->ref--;
+			hist_put_synth_event(file);
 
 			update_cond_flag(file);
 			if (hist_data->enable_timestamps)
@@ -6906,9 +6914,7 @@ static int event_hist_trigger_parse(stru
 		}
 
 		event_trigger_unregister(cmd_ops, file, glob+1, trigger_data);
-		se = find_synth_event_call(file->event_call);
-		if (se)
-			se->ref--;
+		hist_put_synth_event(file);
 		ret = 0;
 		goto out_free;
 	}
--- a/kernel/trace/trace_events_trigger.c
+++ b/kernel/trace/trace_events_trigger.c
@@ -560,6 +560,8 @@ clear_event_triggers(struct trace_array
 		list_for_each_entry_safe(data, n, &file->triggers, list) {
 			trace_event_trigger_enable_disable(file, 0);
 			list_del_rcu(&data->list);
+			if (data->cmd_ops->trigger_type == ETT_EVENT_HIST)
+				hist_put_synth_event(file);
 			if (data->cmd_ops->free)
 				data->cmd_ops->free(data);
 		}



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 503/555] tracing: Ignore .function on the function trace event
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (501 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 502/555] tracing: Drop the synthetic event ref when clearing hist triggers Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 504/555] tracing: Take trace_access_lock() in tracing_buffers_ioctl() Greg Kroah-Hartman
                   ` (51 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Steven Rostedt, David Carlier

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: David Carlier <devnexen@gmail.com>

commit 56ce4ed6316cae9536ea891d6686b92f1d930c00 upstream.

For the function event, parse_pred() handles the .function suffix
before the ftrace_event_is_function() case, so "ip.function == schedule"
builds a predicate with no regex. Setting it through perf then
dereferences the NULL pred->regex in ftrace_function_set_filter_pred().

The "ip" field of that event already takes a function name, so ignore
the suffix there and let the function event case handle it.

Cc: stable@vger.kernel.org
Fixes: cfb58e278c6a ("tracing/filters: Dynamically allocate filter_pred.regex")
Link: https://patch.msgid.link/20261119080139.131834-1-devnexen@gmail.com
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: David Carlier <devnexen@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 kernel/trace/trace_events_filter.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -1593,7 +1593,9 @@ static int parse_pred(const char *str, v
 
 	/* See if the field is a kernel function name */
 	if ((len = str_has_prefix(str + i, ".function"))) {
-		function = true;
+		/* Ignore if event is already a function */
+		if (!ftrace_event_is_function(call))
+			function = true;
 		i += len;
 	}
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 504/555] tracing: Take trace_access_lock() in tracing_buffers_ioctl()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (502 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 503/555] tracing: Ignore .function on the function trace event Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 505/555] netrom: clear the choke flag on frames sent again Greg Kroah-Hartman
                   ` (50 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Kyuwon Cho, Vincent Donnefort,
	Masami Hiramatsu (Google), Steven Rostedt

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Vincent Donnefort <vdonnefort@google.com>

commit 2891516d90b4dc9d41aa55fde08882e40c7c0336 upstream.

tracing_buffers_ioctl() calls ring_buffer_map_get_reader() without
trace_access_lock, breaking concurrent readers. Take trace_access_lock()
around ring_buffer_map_get_reader(), matching the other consuming
readers.

Cc: stable@vger.kernel.org
Fixes: cf9f0f7c4c5b ("tracing: Allow user-space mapping of the ring-buffer")
Reported-by: Kyuwon Cho <kyuwoncho18@gmail.com>
Closes: https://lore.kernel.org/all/179485165154.2547186.6129837870360499372@gmail.com/
Link: https://patch.msgid.link/20261117082932.3441173-1-vdonnefort@google.com
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 kernel/trace/trace.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -8192,8 +8192,12 @@ static long tracing_buffers_ioctl(struct
 				return err;
 		}
 
-		return ring_buffer_map_get_reader(iter->array_buffer->buffer,
-						  iter->cpu_file);
+		trace_access_lock(iter->cpu_file);
+		err = ring_buffer_map_get_reader(iter->array_buffer->buffer,
+						 iter->cpu_file);
+		trace_access_unlock(iter->cpu_file);
+
+		return err;
 	} else if (cmd) {
 		return -ENOTTY;
 	}



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 505/555] netrom: clear the choke flag on frames sent again
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (503 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 504/555] tracing: Take trace_access_lock() in tracing_buffers_ioctl() Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 506/555] netrom: bound the resequencing queue while we are busy Greg Kroah-Hartman
                   ` (49 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Bernard Pidoux, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Bernard Pidoux <bernard.f6bvp@gmail.com>

nr_send_iframe() and nr_send_nak_frame() set NR_CHOKE_FLAG in the
transport header when we are busy, but never clear it. Both work on a
clone of the frame kept on the ack queue, so the flag lands in the data
shared with that frame and stays there.

When such a frame is sent again, on T1 or after a NAK, it still carries
the choke flag although we are no longer busy. The peer then stops
sending to us again, until its own T4 runs out (180 s by default) or
until we send something else.

Set or clear the flag on every send, as is already done for N(S) and
N(R). The copy that goes on the air is made by nr_route_frame() or
nr_loopback_queue(), so no frame in flight shares the data.

Tested on two QEMU guests (6.12.94, KASAN, lockdep) linked by KISS: A
speaks NET/ROM itself and fills the receive buffer of a socket on B, B
sends m1 while busy, then reads its data; m1 is sent again on T1 and
after a NAK.

  before: m1 sent again twice, both times with the choke flag
  after:  m1 sent again twice, without the choke flag

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit af2fe5949ad00457409fc61041feed48b3194896)
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/netrom/nr_out.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/net/netrom/nr_out.c b/net/netrom/nr_out.c
index 1c6b4386c86b4..d692cf8278243 100644
--- a/net/netrom/nr_out.c
+++ b/net/netrom/nr_out.c
@@ -105,8 +105,16 @@ static void nr_send_iframe(struct sock *sk, struct sk_buff *skb)
 	skb->data[2] = nr->vs;
 	skb->data[3] = nr->vr;
 
+	/*
+	 * skb is a clone: its data is shared with the frame kept on the
+	 * ack queue, which is sent again on T1 or a NAK. Set or clear the
+	 * choke flag on every send, so that a frame first sent while we
+	 * were busy does not carry the flag on every later copy.
+	 */
 	if (nr->condition & NR_COND_OWN_RX_BUSY)
 		skb->data[4] |= NR_CHOKE_FLAG;
+	else
+		skb->data[4] &= ~NR_CHOKE_FLAG;
 
 	nr_start_idletimer(sk);
 
@@ -129,6 +137,8 @@ void nr_send_nak_frame(struct sock *sk)
 
 	if (nr->condition & NR_COND_OWN_RX_BUSY)
 		skbn->data[4] |= NR_CHOKE_FLAG;
+	else
+		skbn->data[4] &= ~NR_CHOKE_FLAG;
 
 	nr_transmit_buffer(sk, skbn);
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 506/555] netrom: bound the resequencing queue while we are busy
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (504 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 505/555] netrom: clear the choke flag on frames sent again Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 507/555] netrom: leave the busy state when the application reads Greg Kroah-Hartman
                   ` (48 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Bernard Pidoux, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Bernard Pidoux <bernard.f6bvp@gmail.com>

In state 3, an INFO frame that arrives while we are busy
(NR_COND_OWN_RX_BUSY) is put on the resequencing queue and nothing
else is done: no check of N(S) against the receive window and no check
for a copy already there. The queue is only sorted out once we are no
longer busy.

A peer that keeps sending while we have set the choke flag, or that
sends the same frames again on its own timer, therefore makes the
queue grow without limit. These buffers are not charged to the socket,
so the receive buffer limit does not stop it either, and they stay
until the circuit is closed or the frames can be delivered.

Keep a frame that arrives while we are busy only if it is inside the
receive window and not already on the queue. Frames outside the window
were dropped later anyway, and a copy of a frame we already hold
brings nothing, so nothing that can be delivered is lost. The queue is
now bounded by the window size.

Tested on two QEMU guests (6.12.94, KASAN, lockdep) linked by KISS: A
speaks NET/ROM itself, makes a socket on B busy, then ignores the
choke flag and sends twice 3000 INFO frames of 20 bytes (N(S) outside
the window, and one in ten a copy of a frame inside it). Active
skbuff_head_cache objects on B:

  before: 732, 3780 after the first 3000 frames, 6785 after the second
  after:  720,  791 after the first 3000 frames, 1100 after the second

In both cases the application on B reads the same data afterwards, and
there is no KASAN, lockdep or WARN report.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit 953622a061da21812307406fc171fbd8ac8c5809)
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/netrom/nr_in.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/net/netrom/nr_in.c b/net/netrom/nr_in.c
index 805881e5d6c01..f4f5b5fba15b3 100644
--- a/net/netrom/nr_in.c
+++ b/net/netrom/nr_in.c
@@ -182,6 +182,16 @@ static int nr_state2_machine(struct sock *sk, struct sk_buff *skb,
 	return 0;
 }
 
+static bool nr_reseq_has_ns(struct nr_sock *nrom, unsigned short ns)
+{
+	struct sk_buff *skb;
+
+	skb_queue_walk(&nrom->reseq_queue, skb)
+		if (skb->data[17] == ns)
+			return true;
+	return false;
+}
+
 /*
  * State machine for state 3, Connected State.
  * The handling of the timer(s) is in file nr_timer.c
@@ -266,6 +276,16 @@ static int nr_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype
 				}
 			}
 		}
+		/*
+		 * While we are busy the frames are only kept for later.
+		 * Keep the ones inside the window that we do not hold
+		 * already, so that a peer that does not stop sending
+		 * cannot make the queue grow without limit.
+		 */
+		ns = skb->data[17];
+		if ((nrom->condition & NR_COND_OWN_RX_BUSY) &&
+		    (!nr_in_rx_window(sk, ns) || nr_reseq_has_ns(nrom, ns)))
+			break;
 		queued = 1;
 		skb_queue_head(&nrom->reseq_queue, skb);
 		if (nrom->condition & NR_COND_OWN_RX_BUSY)
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 507/555] netrom: leave the busy state when the application reads
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (505 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 506/555] netrom: bound the resequencing queue while we are busy Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 508/555] mkiss: leave the escaped state on any byte after FESC Greg Kroah-Hartman
                   ` (47 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Bernard Pidoux, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Bernard Pidoux <bernard.f6bvp@gmail.com>

When the receive buffer of a socket is full we set NR_COND_OWN_RX_BUSY,
send the choke flag, and keep the in-window frames that arrive on the
resequencing queue. Two things then wait longer than needed:

- The busy state is only left by the heartbeat, up to five seconds
  after the application has read its data, so the flow stops and
  starts in steps with a slow reader.

- The heartbeat sends an INFO ACK but does not hand over the frames
  held meanwhile: they stay on the queue, are not acknowledged, and
  only reach the socket when another frame comes in. If the peer has
  nothing more to send, that is when its T1 expires and it sends them
  again (120 s by default).

Move the resequencing loop into nr_reseq_deliver(), and add
nr_check_rx_busy(), which leaves the busy state once the buffer is
half empty, hands over the held frames, and answers at once with
nr_enquiry_response(), so that the INFO ACK carries the new N(R) (and
the choke or NAK flag when needed). Call it from the heartbeat as
before, and from nr_recvmsg() after a message is consumed.

Tested on two QEMU guests (6.12.94, KASAN, lockdep) linked by KISS: A
speaks NET/ROM itself and sends four INFO frames of 200 bytes to a
socket on B with a minimal receive buffer; B reads only after 20 s and
A sends nothing more.

  before: B reads a, b, c at 20.0 s; INFO ACK N(R)=3 without choke
          at 20.5 s (heartbeat); d never reaches the application
  after:  B reads a, b, c, d at 20.0 s; INFO ACK N(R)=4 without choke
          at 20.15 s

No KASAN, lockdep or WARN report.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit 719b06480659208bceae8e66ca34f4a4d5260689)
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/net/netrom.h   |  1 +
 net/netrom/af_netrom.c |  7 ++++
 net/netrom/nr_in.c     | 87 ++++++++++++++++++++++++++++--------------
 net/netrom/nr_timer.c  |  9 +----
 4 files changed, 68 insertions(+), 36 deletions(-)

diff --git a/include/net/netrom.h b/include/net/netrom.h
index 3f6fd2f894344..72850f5f561e4 100644
--- a/include/net/netrom.h
+++ b/include/net/netrom.h
@@ -195,6 +195,7 @@ void nr_setup(struct net_device *);
 
 /* nr_in.c */
 int nr_process_rx_frame(struct sock *, struct sk_buff *);
+void nr_check_rx_busy(struct sock *sk);
 
 /* nr_loopback.c */
 void nr_loopback_init(void);
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index 99d9fe19d27f1..154367e6aad15 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -1248,6 +1248,13 @@ static int nr_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
 
 	skb_free_datagram(sk, skb);
 
+	/* Room was made: leave the busy state now if we can */
+	local_bh_disable();
+	bh_lock_sock(sk);
+	nr_check_rx_busy(sk);
+	bh_unlock_sock(sk);
+	local_bh_enable();
+
 	release_sock(sk);
 	return copied;
 }
diff --git a/net/netrom/nr_in.c b/net/netrom/nr_in.c
index f4f5b5fba15b3..9d2d1d853a586 100644
--- a/net/netrom/nr_in.c
+++ b/net/netrom/nr_in.c
@@ -192,6 +192,63 @@ static bool nr_reseq_has_ns(struct nr_sock *nrom, unsigned short ns)
 	return false;
 }
 
+/*
+ * Hand the frames held on the resequencing queue to the socket, in
+ * order, for as long as the socket takes them.
+ */
+static void nr_reseq_deliver(struct sock *sk)
+{
+	struct nr_sock *nrom = nr_sk(sk);
+	struct sk_buff_head temp_queue;
+	struct sk_buff *skbn;
+	unsigned short save_vr, ns;
+	int more;
+
+	skb_queue_head_init(&temp_queue);
+	do {
+		save_vr = nrom->vr;
+		while ((skbn = skb_dequeue(&nrom->reseq_queue)) != NULL) {
+			ns = skbn->data[17];
+			if (ns == nrom->vr) {
+				/* The flags of this frame, not of the one just received */
+				more = skbn->data[19] & NR_MORE_FLAG;
+				if (nr_queue_rx_frame(sk, skbn, more) == 0) {
+					nrom->vr = (nrom->vr + 1) % NR_MODULUS;
+				} else {
+					nrom->condition |= NR_COND_OWN_RX_BUSY;
+					skb_queue_tail(&temp_queue, skbn);
+				}
+			} else if (nr_in_rx_window(sk, ns)) {
+				skb_queue_tail(&temp_queue, skbn);
+			} else {
+				kfree_skb(skbn);
+			}
+		}
+		while ((skbn = skb_dequeue(&temp_queue)) != NULL)
+			skb_queue_tail(&nrom->reseq_queue, skbn);
+	} while (save_vr != nrom->vr);
+}
+
+/*
+ * Leave the busy state as soon as the application has made room in the
+ * receive buffer: hand over the frames held meanwhile and tell the peer
+ * at once, instead of waiting for the next heartbeat or the next frame.
+ * Called with the socket spinlock held.
+ */
+void nr_check_rx_busy(struct sock *sk)
+{
+	struct nr_sock *nrom = nr_sk(sk);
+
+	if (nrom->state != NR_STATE_3 ||
+	    !(nrom->condition & NR_COND_OWN_RX_BUSY) ||
+	    atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf / 2)
+		return;
+
+	nrom->condition &= ~NR_COND_OWN_RX_BUSY;
+	nr_reseq_deliver(sk);
+	nr_enquiry_response(sk);
+}
+
 /*
  * State machine for state 3, Connected State.
  * The handling of the timer(s) is in file nr_timer.c
@@ -200,11 +257,8 @@ static bool nr_reseq_has_ns(struct nr_sock *nrom, unsigned short ns)
 static int nr_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype)
 {
 	struct nr_sock *nrom = nr_sk(sk);
-	struct sk_buff_head temp_queue;
-	struct sk_buff *skbn;
-	unsigned short save_vr;
 	unsigned short nr, ns;
-	int queued = 0, more;
+	int queued = 0;
 
 	nr = skb->data[18];
 
@@ -290,30 +344,7 @@ static int nr_state3_machine(struct sock *sk, struct sk_buff *skb, int frametype
 		skb_queue_head(&nrom->reseq_queue, skb);
 		if (nrom->condition & NR_COND_OWN_RX_BUSY)
 			break;
-		skb_queue_head_init(&temp_queue);
-		do {
-			save_vr = nrom->vr;
-			while ((skbn = skb_dequeue(&nrom->reseq_queue)) != NULL) {
-				ns = skbn->data[17];
-				if (ns == nrom->vr) {
-					/* The flags of this frame, not of the one just received */
-					more = skbn->data[19] & NR_MORE_FLAG;
-					if (nr_queue_rx_frame(sk, skbn, more) == 0) {
-						nrom->vr = (nrom->vr + 1) % NR_MODULUS;
-					} else {
-						nrom->condition |= NR_COND_OWN_RX_BUSY;
-						skb_queue_tail(&temp_queue, skbn);
-					}
-				} else if (nr_in_rx_window(sk, ns)) {
-					skb_queue_tail(&temp_queue, skbn);
-				} else {
-					kfree_skb(skbn);
-				}
-			}
-			while ((skbn = skb_dequeue(&temp_queue)) != NULL) {
-				skb_queue_tail(&nrom->reseq_queue, skbn);
-			}
-		} while (save_vr != nrom->vr);
+		nr_reseq_deliver(sk);
 		/*
 		 * Window is full, ack it immediately.
 		 */
diff --git a/net/netrom/nr_timer.c b/net/netrom/nr_timer.c
index efa5cf6d7bf55..f49a421e8e5db 100644
--- a/net/netrom/nr_timer.c
+++ b/net/netrom/nr_timer.c
@@ -133,14 +133,7 @@ static void nr_heartbeat_expiry(struct timer_list *t)
 		/*
 		 * Check for the state of the receive buffer.
 		 */
-		if (atomic_read(&sk->sk_rmem_alloc) < (sk->sk_rcvbuf / 2) &&
-		    (nr->condition & NR_COND_OWN_RX_BUSY)) {
-			nr->condition &= ~NR_COND_OWN_RX_BUSY;
-			nr->condition &= ~NR_COND_ACK_PENDING;
-			nr->vl         = nr->vr;
-			nr_write_internal(sk, NR_INFOACK);
-			break;
-		}
+		nr_check_rx_busy(sk);
 		break;
 	}
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 508/555] mkiss: leave the escaped state on any byte after FESC
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (506 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 507/555] netrom: leave the busy state when the application reads Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 509/555] ax25: leave the busy state when the application reads Greg Kroah-Hartman
                   ` (46 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Bernard Pidoux, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Bernard Pidoux <bernard.f6bvp@gmail.com>

kiss_unesc() sets AXF_ESCAPE on FESC and clears it only on TFEND,
TFESC or FEND. When FESC is followed by any other byte, that byte is
stored and the escaped state stays set. The next TFEND (0xDC) or TFESC
(0xDD) byte of plain data in the same frame is then taken as escaped
and stored as FEND (0xC0) or FESC (0xDB): the frame is delivered with
a wrong byte.

KISS gives no meaning to FESC followed by another byte, and asks that
frame assembly goes on. Keep the byte as before, but clear the escaped
state, so that the error stays on that one byte.

Tested on a QEMU guest (6.12.94, KASAN, lockdep): KISS frames are
written on the master side of a pseudo-terminal whose other side has
the mkiss line discipline, and an AF_PACKET socket on ax0 shows what
mkiss delivers.

  "A" FESC TFEND "B"          before: 41 C0 42        after: 41 C0 42
  "x" FESC "Q" "y" 0xDC "z"   before: 78 51 79 C0 7A  after: 78 51 79 DC 7A
  "x" FESC "Q" "y" 0xDD "z"   before: 78 51 79 DB 7A  after: 78 51 79 DD 7A

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit 74f8e79c2feb4d6df0f7b036d1620416c289bf1a)
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/hamradio/mkiss.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index 8b0e2ca5d0ea3..d25ce56102bd5 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -325,6 +325,14 @@ static void kiss_unesc(struct mkiss *ax, unsigned char s)
 		if (test_and_clear_bit(AXF_ESCAPE, &ax->flags))
 			s = END;
 		break;
+	default:
+		/*
+		 * FESC must be followed by TFEND or TFESC.  Keep the byte,
+		 * but leave the escaped state so that a later TFEND or
+		 * TFESC data byte is not taken as escaped.
+		 */
+		clear_bit(AXF_ESCAPE, &ax->flags);
+		break;
 	}
 
 	spin_lock_bh(&ax->buflock);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 509/555] ax25: leave the busy state when the application reads
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (507 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 508/555] mkiss: leave the escaped state on any byte after FESC Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 510/555] rose: acknowledge delivered data before resetting a call Greg Kroah-Hartman
                   ` (45 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Bernard Pidoux, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Bernard Pidoux <bernard.f6bvp@gmail.com>

When the receive buffer of a connected socket is full, the frame is
not taken, AX25_COND_OWN_RX_BUSY is set and the peer gets RNR. Only the
heartbeat clears it again, up to five seconds after the application
has read its data. Until then every I frame is answered with RNR and
the peer waits, so with a slow reader the flow stops and starts in
steps of up to five seconds.

Add ax25_check_rx_busy(), which leaves the busy state once the buffer
is half empty and sends RR at once, as the heartbeat does. A DAMA slave
only clears the condition and answers the master's next poll, as
ax25_ds_heartbeat_expiry() does. Call it from the standard heartbeat
instead of its own copy of the code, and from ax25_recvmsg() after a
frame of a SOCK_SEQPACKET socket is consumed.

Tested on two QEMU guests (6.12.94, KASAN, lockdep) linked by KISS: A
writes twelve messages of 200 bytes on a connected socket, B has a
minimal receive buffer and starts reading after 20 s.

  before: B reads messages 1-3 at 20.0 s, messages 4-12 at 23.5 s
  after:  B reads messages 1-12 between 20.0 s and 20.1 s

No KASAN, lockdep or WARN report.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit 321859eeb03bd6d5e2a7c298b974ec6e93370435)
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/net/ax25.h        |  1 +
 net/ax25/af_ax25.c        |  9 +++++++++
 net/ax25/ax25_std_timer.c | 11 +----------
 net/ax25/ax25_subr.c      | 27 +++++++++++++++++++++++++++
 4 files changed, 38 insertions(+), 10 deletions(-)

diff --git a/include/net/ax25.h b/include/net/ax25.h
index e3c10a9395944..59d2dd2b77431 100644
--- a/include/net/ax25.h
+++ b/include/net/ax25.h
@@ -452,6 +452,7 @@ void ax25_requeue_frames(ax25_cb *);
 int ax25_validate_nr(ax25_cb *, unsigned short);
 int ax25_decode(ax25_cb *, struct sk_buff *, int *, int *, int *);
 void ax25_send_control(ax25_cb *, int, int, int);
+void ax25_check_rx_busy(ax25_cb *ax25);
 void ax25_return_dm(struct net_device *, ax25_address *, ax25_address *,
 		    ax25_digi *);
 void ax25_calculate_t1(ax25_cb *);
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index d464f8ea4e558..6088baf162b15 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -1874,6 +1874,15 @@ static int ax25_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
 	skb_free_datagram(sk, skb);
 	err = copied;
 
+	/* Room was made: leave the busy state now if we can */
+	if (sk->sk_type == SOCK_SEQPACKET) {
+		local_bh_disable();
+		bh_lock_sock(sk);
+		ax25_check_rx_busy(sk_to_ax25(sk));
+		bh_unlock_sock(sk);
+		local_bh_enable();
+	}
+
 out:
 	release_sock(sk);
 
diff --git a/net/ax25/ax25_std_timer.c b/net/ax25/ax25_std_timer.c
index 05ff1032748f6..be5720b469d8d 100644
--- a/net/ax25/ax25_std_timer.c
+++ b/net/ax25/ax25_std_timer.c
@@ -58,16 +58,7 @@ void ax25_std_heartbeat_expiry(ax25_cb *ax25)
 		/*
 		 * Check the state of the receive buffer.
 		 */
-		if (sk != NULL) {
-			if (atomic_read(&sk->sk_rmem_alloc) <
-			    (sk->sk_rcvbuf >> 1) &&
-			    (ax25->condition & AX25_COND_OWN_RX_BUSY)) {
-				ax25->condition &= ~AX25_COND_OWN_RX_BUSY;
-				ax25->condition &= ~AX25_COND_ACK_PENDING;
-				ax25_send_control(ax25, AX25_RR, AX25_POLLOFF, AX25_RESPONSE);
-				break;
-			}
-		}
+		ax25_check_rx_busy(ax25);
 	}
 
 	if (sk)
diff --git a/net/ax25/ax25_subr.c b/net/ax25/ax25_subr.c
index fbfeb09784119..d9ad696f524a3 100644
--- a/net/ax25/ax25_subr.c
+++ b/net/ax25/ax25_subr.c
@@ -212,6 +212,33 @@ void ax25_send_control(ax25_cb *ax25, int frametype, int poll_bit, int type)
  *
  *	Note: src here is the sender, thus it's the target of the DM
  */
+/*
+ *	Leave the busy state as soon as the application has made room in
+ *	the receive buffer, instead of waiting for the next heartbeat.
+ *	A DAMA slave does not send on its own: the master's next poll is
+ *	answered with RR. Called with the socket spinlock held.
+ */
+void ax25_check_rx_busy(ax25_cb *ax25)
+{
+	struct sock *sk = ax25->sk;
+
+	if (!sk || !ax25->ax25_dev ||
+	    !(ax25->condition & AX25_COND_OWN_RX_BUSY) ||
+	    (ax25->state != AX25_STATE_3 && ax25->state != AX25_STATE_4) ||
+	    atomic_read(&sk->sk_rmem_alloc) >= (sk->sk_rcvbuf >> 1))
+		return;
+
+	ax25->condition &= ~AX25_COND_OWN_RX_BUSY;
+	ax25->condition &= ~AX25_COND_ACK_PENDING;
+
+#ifdef CONFIG_AX25_DAMA_SLAVE
+	if (ax25->ax25_dev->values[AX25_VALUES_PROTOCOL] == AX25_PROTO_DAMA_SLAVE &&
+	    ax25->ax25_dev->dama.slave)
+		return;
+#endif
+	ax25_send_control(ax25, AX25_RR, AX25_POLLOFF, AX25_RESPONSE);
+}
+
 void ax25_return_dm(struct net_device *dev, ax25_address *src, ax25_address *dest, ax25_digi *digi)
 {
 	struct sk_buff *skb;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 510/555] rose: acknowledge delivered data before resetting a call
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (508 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 509/555] ax25: leave the busy state when the application reads Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 511/555] rose: say when we are busy, and leave the busy state on read Greg Kroah-Hartman
                   ` (44 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Bernard Pidoux, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Bernard Pidoux <bernard.f6bvp@gmail.com>

When a DATA packet arrives in sequence but cannot be queued, because
the receive buffer is full or a socket filter drops it, the call is
reset ("Should never happen"). Acknowledgements are held back for up to
the hold-back time (5 s by default), so the peer has usually not been
told yet about the packets the application already received. On the
reset, rose_requeue_frames() makes the peer send all its
unacknowledged packets again, and these packets are delivered a second
time: the application gets the same data twice.

The receive buffer fills easily: OWN_RX_BUSY is only set after a
packet has been queued, and the RNR that tells the peer to stop waits
for the next acknowledgment.

Send RR (or RNR) with the current V(R) before the reset, as is already
done when a packet arrives out of sequence, so that the peer only
sends again what was not delivered.

Tested on two QEMU guests (6.12.94, KASAN, lockdep) linked by KISS: A
calls B and writes twelve messages of 200 bytes; B has a minimal
receive buffer and starts reading after 20 s.

  before: B reads 15 messages, three of them twice (a, b, c)
  after:  B reads the 12 messages once each, in order

No KASAN, lockdep or WARN report.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit f0917462b6fe270717add07f8c173ac3f330481a)
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/rose/rose_in.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/net/rose/rose_in.c b/net/rose/rose_in.c
index 980f82655c12e..0bb801c3142c8 100644
--- a/net/rose/rose_in.c
+++ b/net/rose/rose_in.c
@@ -178,7 +178,14 @@ static int rose_state3_machine(struct sock *sk, struct sk_buff *skb, int framety
 				rose->vr = (rose->vr + 1) % ROSE_MODULUS;
 				queued = 1;
 			} else {
-				/* Should never happen ! */
+				/*
+				 * The receive buffer is full (or a filter
+				 * dropped the packet). Acknowledge first what
+				 * the application already has: the reset makes
+				 * the peer send its unacknowledged packets
+				 * again, and those would be delivered twice.
+				 */
+				rose_enquiry_response(sk);
 				rose_write_internal(sk, ROSE_RESET_REQUEST);
 				rose->condition = 0x00;
 				rose->vs        = 0;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 511/555] rose: say when we are busy, and leave the busy state on read
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (509 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 510/555] rose: acknowledge delivered data before resetting a call Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 512/555] crypto: nx - fix nx_crypto_ctx_exit argument Greg Kroah-Hartman
                   ` (43 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Bernard Pidoux, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Bernard Pidoux <bernard.f6bvp@gmail.com>

ROSE_COND_OWN_RX_BUSY is set when the receive buffer is more than half
full, but the peer only learns it with the next acknowledgment, which
is held back for up to the hold-back time (5 s by default). Meanwhile
it keeps sending, the buffer overflows and the call is reset. The busy
state is then only left by the heartbeat, up to five seconds after the
application has read its data.

Acknowledge at once when we have just become busy, so that the peer
gets RNR before the buffer overflows. Add rose_check_rx_busy(), which
leaves the busy state once the buffer is half empty and sends RR, as
the heartbeat does, and call it from the heartbeat and from
rose_recvmsg() after a message is consumed, with the socket locked so
that it does not race with the receive path.

Tested on two QEMU guests (6.12.94, KASAN, lockdep) linked by KISS: A
calls B and writes twelve messages of 200 bytes; B has a minimal
receive buffer and starts reading after 20 s.

  before: messages 1-3 read at 20.0 s, the others at 23.5 s
  after:  the twelve messages read between 20.0 s and 20.1 s

No KASAN, lockdep or WARN report.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com>
Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit 09b0e6261615f80f35e4df588cf18134990d21d8)
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/net/rose.h    |  1 +
 net/rose/af_rose.c    |  5 +++++
 net/rose/rose_in.c    |  7 +++++--
 net/rose/rose_out.c   | 21 +++++++++++++++++++++
 net/rose/rose_timer.c | 10 +---------
 5 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/include/net/rose.h b/include/net/rose.h
index 30b0809dd0a65..b60d2dd5d2995 100644
--- a/include/net/rose.h
+++ b/include/net/rose.h
@@ -253,6 +253,7 @@ int rose_loopback_queue(struct sk_buff *, struct rose_neigh *);
 /* rose_out.c */
 void rose_kick(struct sock *);
 void rose_enquiry_response(struct sock *);
+void rose_check_rx_busy(struct sock *sk);
 
 /* rose_route.c */
 extern struct rose_neigh *rose_loopback_neigh;
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index 2a610cf8425af..48ac6fd660316 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -1490,6 +1490,11 @@ static int rose_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
 
 	skb_free_datagram(sk, skb);
 
+	/* Room was made: leave the busy state now if we can */
+	lock_sock(sk);
+	rose_check_rx_busy(sk);
+	release_sock(sk);
+
 	return copied;
 }
 
diff --git a/net/rose/rose_in.c b/net/rose/rose_in.c
index 0bb801c3142c8..c6c4e92016ae7 100644
--- a/net/rose/rose_in.c
+++ b/net/rose/rose_in.c
@@ -224,9 +224,12 @@ static int rose_state3_machine(struct sock *sk, struct sk_buff *skb, int framety
 		}
 		/*
 		 * If the window is full, ack the frame, else start the
-		 * acknowledge hold back timer.
+		 * acknowledge hold back timer. When we have just become busy,
+		 * send RNR at once, so that the peer stops before our
+		 * receive buffer overflows.
 		 */
-		if (((rose->vl + sysctl_rose_window_size) % ROSE_MODULUS) == rose->vr) {
+		if (((rose->vl + sysctl_rose_window_size) % ROSE_MODULUS) == rose->vr ||
+		    (rose->condition & ROSE_COND_OWN_RX_BUSY)) {
 			rose->condition &= ~ROSE_COND_ACK_PENDING;
 			rose_stop_timer(sk);
 			rose_enquiry_response(sk);
diff --git a/net/rose/rose_out.c b/net/rose/rose_out.c
index 6672fc65a7651..6a8881116bf31 100644
--- a/net/rose/rose_out.c
+++ b/net/rose/rose_out.c
@@ -121,3 +121,24 @@ void rose_enquiry_response(struct sock *sk)
 
 	rose_stop_timer(sk);
 }
+
+/*
+ * Leave the busy state as soon as the application has made room in the
+ * receive buffer, instead of waiting for the next heartbeat. Called with
+ * the socket locked.
+ */
+void rose_check_rx_busy(struct sock *sk)
+{
+	struct rose_sock *rose = rose_sk(sk);
+
+	if (rose->state != ROSE_STATE_3 ||
+	    !(rose->condition & ROSE_COND_OWN_RX_BUSY) ||
+	    atomic_read(&sk->sk_rmem_alloc) >= (sk->sk_rcvbuf / 2))
+		return;
+
+	rose->condition &= ~ROSE_COND_OWN_RX_BUSY;
+	rose->condition &= ~ROSE_COND_ACK_PENDING;
+	rose->vl         = rose->vr;
+	rose_write_internal(sk, ROSE_RR);
+	rose_stop_timer(sk);	/* HB */
+}
diff --git a/net/rose/rose_timer.c b/net/rose/rose_timer.c
index 5ba0c89e4ee1b..9f28cbf8c9a8a 100644
--- a/net/rose/rose_timer.c
+++ b/net/rose/rose_timer.c
@@ -218,15 +218,7 @@ static void rose_heartbeat_expiry(struct timer_list *t)
 		/*
 		 * Check for the state of the receive buffer.
 		 */
-		if (atomic_read(&sk->sk_rmem_alloc) < (sk->sk_rcvbuf / 2) &&
-		    (rose->condition & ROSE_COND_OWN_RX_BUSY)) {
-			rose->condition &= ~ROSE_COND_OWN_RX_BUSY;
-			rose->condition &= ~ROSE_COND_ACK_PENDING;
-			rose->vl         = rose->vr;
-			rose_write_internal(sk, ROSE_RR);
-			rose_stop_timer(sk);	/* HB */
-			break;
-		}
+		rose_check_rx_busy(sk);
 		break;
 	}
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 512/555] crypto: nx - fix nx_crypto_ctx_exit argument
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (510 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 511/555] rose: say when we are busy, and leave the busy state on read Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 513/555] net/sched: codel: bound the dropping loop per dequeue call Greg Kroah-Hartman
                   ` (42 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Eric Biggers, Breno Leitao,
	Calvin Buckley, Brad Spengler, Sam James, Herbert Xu, Dickson Wu,
	Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Sam James <sam@gentoo.org>

commit 4e67f504ee9ded15e256b64f4fde150e917381d7 upstream.

nx_crypto_ctx_shash_exit calls nx_crypto_ctx_exit with crypto_shash_ctx(...)
but crypto_shash_ctx gives a nx_crypto_ctx *, not a crypto_tfm *.

Fix the type in nx_crypto_ctx_exit and drop the bogus crypto_tfm_ctx
call.

This fixes the following oops:

  BUG: Unable to handle kernel data access at 0xc0403effffffffc8
  Faulting instruction address: 0xc000000000396cb4
  Oops: Kernel access of bad area, sig: 11 [#15]
  Call Trace:
   nx_crypto_ctx_shash_exit+0x24/0x60
   crypto_shash_exit_tfm+0x28/0x40
   crypto_destroy_tfm+0x98/0x140
   crypto_exit_ahash_using_shash+0x20/0x40
   crypto_destroy_tfm+0x98/0x140
   hash_release+0x1c/0x30
   alg_sock_destruct+0x38/0x60
   __sk_destruct+0x48/0x2b0
   af_alg_release+0x58/0xb0
   __sock_release+0x68/0x150
   sock_close+0x20/0x40
   __fput+0x110/0x3a0
   sys_close+0x48/0xa0
   system_call_exception+0x140/0x2d0
   system_call_common+0xf4/0x258

.. which came from hardlink(1) opportunistically using AF_ALG.

The same problem exists with nx_crypto_ctx_skcipher_exit getting a context
it wasn't expecting, but apparently nobody hit that for years.

Cc: Eric Biggers <ebiggers@kernel.org>
Cc: stable@vger.kernel.org
Fixes: bfd9efddf990 ("crypto: nx - convert AES-ECB to skcipher API")
Fixes: 9420e628e7d8 ("crypto: nx - Use API partial block handling")
Acked-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Eric Biggers <ebiggers@kernel.org>
Reported-by: Calvin Buckley <calvin@cmpct.info>
Tested-by: Calvin Buckley <calvin@cmpct.info>
Suggested-by: Brad Spengler <brad.spengler@opensrcsec.com>
Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
[ adapted to 6.12.y: pass the skcipher tfm to the legacy exit helper ]
Signed-off-by: Dickson Wu <dickson.wu@certik.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/crypto/nx/nx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/crypto/nx/nx.c b/drivers/crypto/nx/nx.c
index 010e87d9da36b..e9186ff339451 100644
--- a/drivers/crypto/nx/nx.c
+++ b/drivers/crypto/nx/nx.c
@@ -756,7 +756,7 @@ void nx_crypto_ctx_exit(struct crypto_tfm *tfm)
 
 void nx_crypto_ctx_skcipher_exit(struct crypto_skcipher *tfm)
 {
-	nx_crypto_ctx_exit(crypto_skcipher_ctx(tfm));
+	nx_crypto_ctx_exit(crypto_skcipher_tfm(tfm));
 }
 
 void nx_crypto_ctx_aead_exit(struct crypto_aead *tfm)
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 513/555] net/sched: codel: bound the dropping loop per dequeue call
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (511 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 512/555] crypto: nx - fix nx_crypto_ctx_exit argument Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 514/555] ipv6: Prevent rt6_insert_exception() for dying fib6_info Greg Kroah-Hartman
                   ` (41 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Vega, Eric Dumazet, Victor Nogueira,
	Jamal Hadi Salim, Toke Høiland-Jørgensen,
	Jakub Kicinski, Artem Dinaburg, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jamal Hadi Salim <jhs@mojatatu.com>

[ Upstream commit 7f4a5ec6258fd7c92633ec4b0493fc51166d9398 ]

The CoDel control law schedules the next drop one interval/sqrt(count)
after the previous drop, using the configured interval
(codel_params.interval). For very small intervals the scheduled step
rounds down to zero, so the dropping loop in codel_dequeue() never
advances and drains the entire backlog under the qdisc lock in one
call - an unprivileged user can trigger a soft lockup this way.

Fix in the shared codel code used by both codel and fq_codel:

1. Make the control-law step at least 1 tick so the dropping loop
   always moves forward.

2. Cap the dropping loop at CODEL_MAX_DROPS_PER_DEQUEUE (256) drops
   per codel_dequeue() call, resyncing drop_next to now when the cap
   is hit: the catch-up owed to the loop grows with the idle gap and
   the backlog, which no interval threshold can bound. This is a
   deliberate behaviour change after long idle gaps.

The cap applies to fq_codel (4b549a2ef4be) and the mac80211 TXQ path
(fixed interval, cap only).

The target sojourn delay (codel_params.target) is not validated: it
does not feed the control law, so a sub-tick value is aggressive
rather than deadlock-prone.

Conditions to recreate the bug:
  - tc qdisc add dev lo root handle 1: tbf rate 1kbit burst 2kb limit 1000000
  - tc qdisc add dev lo parent 1:1 handle 10: codel interval 2us target 1ms noecn limit 1000000 (same for fq_codel)
  - unpatched kernel: tc accepts it; a UDP flood under the 1kbit tbf
    soft-lockups (watchdog: BUG: soft lockup) while one
    codel_dequeue() call drops the backlog under the qdisc lock
  - patched kernel: same setup, at most 256 drops per dequeue call,
    no soft lockup

Testing: claim reproducer and interval 2us/3us variants run clean;
tdc qdisc category passes (see the selftests patch).

Fixes: 76e3cc126bb2 ("codel: Controlled Delay AQM")
Reported-by: Vega <vega@nebusec.ai>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Tested-by: Victor Nogueira <victor@mojatatu.com>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Reviewed-by: Toke Høiland-Jørgensen <toke@toke.dk>
Link: https://patch.msgid.link/QDISC-1L5H.v1.20260912080102@mojatatu.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[ Backport to 6.12.y: context adjusted in codel_dequeue(); 6.12.y lacks
  the upstream WRITE_ONCE() annotations of the codel state. The added
  code is unchanged. ]
Signed-off-by: Artem Dinaburg <artem@trailofbits.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/net/codel.h      |  5 +++++
 include/net/codel_impl.h | 16 +++++++++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/include/net/codel.h b/include/net/codel.h
index aa80f744826cd..183d43c2bd434 100644
--- a/include/net/codel.h
+++ b/include/net/codel.h
@@ -140,6 +140,11 @@ struct codel_vars {
 /* needed shift to get a Q0.32 number from rec_inv_sqrt */
 #define REC_INV_SQRT_SHIFT (32 - REC_INV_SQRT_BITS)
 
+/* Cap on drops per codel_dequeue() call: the loop's work depends on the
+ * idle gap and backlog, both outside our control; resync when exceeded.
+ */
+#define CODEL_MAX_DROPS_PER_DEQUEUE 256
+
 /**
  * struct codel_stats - contains codel shared variables and stats
  * @maxpacket:	largest packet we've seen so far
diff --git a/include/net/codel_impl.h b/include/net/codel_impl.h
index b2c359c6dd1b8..4d5e471472f6a 100644
--- a/include/net/codel_impl.h
+++ b/include/net/codel_impl.h
@@ -93,12 +93,17 @@ static void codel_Newton_step(struct codel_vars *vars)
  * CoDel control_law is t + interval/sqrt(count)
  * We maintain in rec_inv_sqrt the reciprocal value of sqrt(count) to avoid
  * both sqrt() and divide operation.
+ *
+ * Clamp the increment to at least 1 tick: a very small interval (or a
+ * large count) can truncate it to zero, stalling the dropping loop.
  */
 static codel_time_t codel_control_law(codel_time_t t,
 				      codel_time_t interval,
 				      u32 rec_inv_sqrt)
 {
-	return t + reciprocal_scale(interval, rec_inv_sqrt << REC_INV_SQRT_SHIFT);
+	return t + max_t(u32, 1,
+			 reciprocal_scale(interval,
+					  rec_inv_sqrt << REC_INV_SQRT_SHIFT));
 }
 
 static bool codel_should_drop(const struct sk_buff *skb,
@@ -154,6 +159,7 @@ static struct sk_buff *codel_dequeue(void *ctx,
 				     codel_skb_dequeue_t dequeue_func)
 {
 	struct sk_buff *skb = dequeue_func(vars, ctx);
+	unsigned int drops = 0;
 	codel_time_t now;
 	bool drop;
 
@@ -180,6 +186,14 @@ static struct sk_buff *codel_dequeue(void *ctx,
 			 */
 			while (vars->dropping &&
 			       codel_time_after_eq(now, vars->drop_next)) {
+				if (++drops > CODEL_MAX_DROPS_PER_DEQUEUE) {
+					/* fell far behind the schedule */
+					WRITE_ONCE(vars->drop_next,
+						   codel_control_law(now,
+								     params->interval,
+								     vars->rec_inv_sqrt));
+					break;
+				}
 				vars->count++; /* dont care of possible wrap
 						* since there is no more divide
 						*/
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 514/555] ipv6: Prevent rt6_insert_exception() for dying fib6_info.
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (512 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 513/555] net/sched: codel: bound the dropping loop per dequeue call Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 515/555] mm: constify pagemap related test/getter functions Greg Kroah-Hartman
                   ` (40 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Kuniyuki Iwashima, Ido Schimmel,
	Jakub Kicinski, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Kuniyuki Iwashima <kuniyu@google.com>

[ Upstream commit 0346ec2f080b40d95ed05b853bb9226289e75212 ]

Before the cited commit, fib6_nh_flush_exceptions() always set
from->exception_bucket_flushed = 1 under rt6_exception_lock to
prevent rt6_insert_exception() from inserting a new exception
for a dying fib6_info.

The flag was replaced with the FIB6_EXCEPTION_BUCKET_FLUSHED
bit stored in nh->rt6i_exception_bucket.

The problem is that now the bit is only set when the bucket
is not NULL and fib6_nh_flush_exceptions() is called from
fib6_nh_release() after fib6_ref has already reached zero.

If rt6_insert_exception() is called while the target fib6_info
is being removed via fib6_purge_rt(), a new exception could be
created successfully because rt6_flush_exceptions() no longer
sets the bit.

This creates a reference cycle between the fib6_info and the
exception route, leaking the fib6_info, its nexthop device,
and all per-CPU routes in fib6_nh->rt6i_pcpu, which stalls netdev
unregistration.

[   34.680602] unregister_netdevice: waiting for gre6 to become free. Usage count = 68
[   44.920675] unregister_netdevice: waiting for gre6 to become free. Usage count = 68
[   55.176582] unregister_netdevice: waiting for gre6 to become free. Usage count = 68

Let's call fib6_drop_pcpu_from() before rt6_flush_exceptions(),
to set fib6_destroying before rt6_exception_lock, and check
f6i->fib6_destroying in rt6_insert_exception().

Note that FIB6_EXCEPTION_BUCKET_FLUSHED logic is dead and
we can clean it up in net-next.

Fixes: cc5c073a693f ("ipv6: Move exception bucket to fib6_nh")
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20260918082209.2853582-1-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[ sashal: Kept this tree's fib6_drop_pcpu_from(rt, table) signature while applying the swap with rt6_flush_exceptions(), since the surrounding rt->nh context differs. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/ipv6/ip6_fib.c | 2 +-
 net/ipv6/route.c   | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index aab1dddf1f59f..0406488b4327d 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -1073,8 +1073,8 @@ static void fib6_purge_rt(struct fib6_info *rt, struct fib6_node *fn,
 	struct fib6_table *table = rt->fib6_table;
 
 	/* Flush all cached dst in exception table */
-	rt6_flush_exceptions(rt);
 	fib6_drop_pcpu_from(rt, table);
+	rt6_flush_exceptions(rt);
 
 	if (rt->nh && !list_empty(&rt->nh_list))
 		list_del_init(&rt->nh_list);
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 3c0c0e1cb82a7..bc7cd0e8940b3 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1741,6 +1741,11 @@ static int rt6_insert_exception(struct rt6_info *nrt,
 
 	spin_lock_bh(&rt6_exception_lock);
 
+	if (f6i->fib6_destroying) {
+		err = -ENOENT;
+		goto out;
+	}
+
 	bucket = rcu_dereference_protected(nh->rt6i_exception_bucket,
 					  lockdep_is_held(&rt6_exception_lock));
 	if (!bucket) {
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 515/555] mm: constify pagemap related test/getter functions
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (513 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 514/555] ipv6: Prevent rt6_insert_exception() for dying fib6_info Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 516/555] filemap: Add folio_next_pos() Greg Kroah-Hartman
                   ` (39 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Max Kellermann,
	Vishal Moola (Oracle), Lorenzo Stoakes, David Hildenbrand,
	Vlastimil Babka, Mike Rapoport (Microsoft), Shakeel Butt,
	Alexander Gordeev, Al Viro, Andreas Larsson, Andy Lutomirski,
	Axel Rasmussen, Baolin Wang, Borislav Betkov,
	Christian Borntraeger, Christian Brauner, Christian Zankel,
	David Rientjes, David S. Miller, Gerald Schaefer, Heiko Carstens,
	Helge Deller, H. Peter Anvin, Hugh Dickins, Ingo Molnar,
	James Bottomley, Jan Kara, Jocelyn Falempe, Liam Howlett,
	Mark Brown, Matthew Wilcox (Oracle), Max Filippov,
	Michael Ellerman, Michal Hocko, Nysal Jan K.A, Oscar Salvador,
	Peter Zijlstra, Russel King, Suren Baghdasaryan, Sven Schnelle,
	Thomas Gleinxer, Thomas Huth, Vasily Gorbik, Wei Xu, Yuanchu Xie,
	Andrew Morton, Pedro Falcato, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Max Kellermann <max.kellermann@ionos.com>

commit 7c3e97ac0d75306d9d03de575c9878f8fd9efe3b upstream.

For improved const-correctness.

We select certain test functions which either invoke each other, functions
that are already const-ified, or no further functions.

It is therefore relatively trivial to const-ify them, which provides a
basis for further const-ification further up the call stack.

Link: https://lkml.kernel.org/r/20250901205021.3573313-3-max.kellermann@ionos.com
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Borislav Betkov <bp@alien8.de>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Christian Zankel <chris@zankel.net>
Cc: David Rientjes <rientjes@google.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Helge Deller <deller@gmx.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Bottomley <james.bottomley@HansenPartnership.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Jocelyn Falempe <jfalempe@redhat.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michal Hocko <mhocko@suse.com>
Cc: "Nysal Jan K.A" <nysal@linux.ibm.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Russel King <linux@armlinux.org.uk>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Thomas Gleinxer <tglx@linutronix.de>
Cc: Thomas Huth <thuth@redhat.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Wei Xu <weixugc@google.com>
Cc: Yuanchu Xie <yuanchu@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Stable-dep-of: 4511fd86db6f ("filemap: Add folio_next_pos()")
[pfalcato: massage this for 6.12]
Signed-off-by: Pedro Falcato <pfalcato@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/linux/pagemap.h | 55 +++++++++++++++++++++--------------------
 1 file changed, 28 insertions(+), 27 deletions(-)

diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 01717aa4a054b..97e9690394dbb 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -140,7 +140,7 @@ static inline int inode_drain_writes(struct inode *inode)
 	return filemap_write_and_wait(inode->i_mapping);
 }
 
-static inline bool mapping_empty(struct address_space *mapping)
+static inline bool mapping_empty(const struct address_space *mapping)
 {
 	return xa_empty(&mapping->i_pages);
 }
@@ -166,7 +166,7 @@ static inline bool mapping_empty(struct address_space *mapping)
  * refcount and the referenced bit, which will be elevated or set in
  * the process of adding new cache pages to an inode.
  */
-static inline bool mapping_shrinkable(struct address_space *mapping)
+static inline bool mapping_shrinkable(const struct address_space *mapping)
 {
 	void *head;
 
@@ -264,7 +264,7 @@ static inline void mapping_clear_unevictable(struct address_space *mapping)
 	clear_bit(AS_UNEVICTABLE, &mapping->flags);
 }
 
-static inline bool mapping_unevictable(struct address_space *mapping)
+static inline bool mapping_unevictable(const struct address_space *mapping)
 {
 	return mapping && test_bit(AS_UNEVICTABLE, &mapping->flags);
 }
@@ -274,7 +274,7 @@ static inline void mapping_set_exiting(struct address_space *mapping)
 	set_bit(AS_EXITING, &mapping->flags);
 }
 
-static inline int mapping_exiting(struct address_space *mapping)
+static inline int mapping_exiting(const struct address_space *mapping)
 {
 	return test_bit(AS_EXITING, &mapping->flags);
 }
@@ -284,7 +284,7 @@ static inline void mapping_set_no_writeback_tags(struct address_space *mapping)
 	set_bit(AS_NO_WRITEBACK_TAGS, &mapping->flags);
 }
 
-static inline int mapping_use_writeback_tags(struct address_space *mapping)
+static inline int mapping_use_writeback_tags(const struct address_space *mapping)
 {
 	return !test_bit(AS_NO_WRITEBACK_TAGS, &mapping->flags);
 }
@@ -330,18 +330,18 @@ static inline void mapping_set_inaccessible(struct address_space *mapping)
 	set_bit(AS_INACCESSIBLE, &mapping->flags);
 }
 
-static inline bool mapping_inaccessible(struct address_space *mapping)
+static inline bool mapping_inaccessible(const struct address_space *mapping)
 {
 	return test_bit(AS_INACCESSIBLE, &mapping->flags);
 }
 
-static inline gfp_t mapping_gfp_mask(struct address_space * mapping)
+static inline gfp_t mapping_gfp_mask(const struct address_space * mapping)
 {
 	return mapping->gfp_mask;
 }
 
 /* Restricts the given gfp_mask to what the mapping allows. */
-static inline gfp_t mapping_gfp_constraint(struct address_space *mapping,
+static inline gfp_t mapping_gfp_constraint(const struct address_space *mapping,
 		gfp_t gfp_mask)
 {
 	return mapping_gfp_mask(mapping) & gfp_mask;
@@ -464,7 +464,7 @@ mapping_min_folio_order(const struct address_space *mapping)
 }
 
 static inline unsigned long
-mapping_min_folio_nrpages(struct address_space *mapping)
+mapping_min_folio_nrpages(const struct address_space *mapping)
 {
 	return 1UL << mapping_min_folio_order(mapping);
 }
@@ -478,7 +478,7 @@ mapping_min_folio_nrpages(struct address_space *mapping)
  * new folio to the page cache and need to know what index to give it,
  * call this function.
  */
-static inline pgoff_t mapping_align_index(struct address_space *mapping,
+static inline pgoff_t mapping_align_index(const struct address_space *mapping,
 					  pgoff_t index)
 {
 	return round_down(index, mapping_min_folio_nrpages(mapping));
@@ -488,7 +488,7 @@ static inline pgoff_t mapping_align_index(struct address_space *mapping,
  * Large folio support currently depends on THP.  These dependencies are
  * being worked on but are not yet fixed.
  */
-static inline bool mapping_large_folio_support(struct address_space *mapping)
+static inline bool mapping_large_folio_support(const struct address_space *mapping)
 {
 	/* AS_FOLIO_ORDER is only reasonable for pagecache folios */
 	VM_WARN_ONCE((unsigned long)mapping & PAGE_MAPPING_ANON,
@@ -503,7 +503,7 @@ static inline size_t mapping_max_folio_size(const struct address_space *mapping)
 	return PAGE_SIZE << mapping_max_folio_order(mapping);
 }
 
-static inline int filemap_nr_thps(struct address_space *mapping)
+static inline int filemap_nr_thps(const struct address_space *mapping)
 {
 #ifdef CONFIG_READ_ONLY_THP_FOR_FS
 	return atomic_read(&mapping->nr_thps);
@@ -933,7 +933,7 @@ static inline pgoff_t folio_index(struct folio *folio)
  *
  * Return: The index of the folio which follows this folio in the file.
  */
-static inline pgoff_t folio_next_index(struct folio *folio)
+static inline pgoff_t folio_next_index(const struct folio *folio)
 {
 	return folio->index + folio_nr_pages(folio);
 }
@@ -963,9 +963,9 @@ static inline struct page *folio_file_page(struct folio *folio, pgoff_t index)
  * and changing its index in the middle of the operation.
  * Return: true or false.
  */
-static inline bool folio_contains(struct folio *folio, pgoff_t index)
+static inline bool folio_contains(const struct folio *folio, pgoff_t index)
 {
-	return index - folio_index(folio) < folio_nr_pages(folio);
+	return index - folio_index((struct folio *) folio) < folio_nr_pages(folio);
 }
 
 /*
@@ -1059,13 +1059,13 @@ static inline loff_t folio_pos(struct folio *folio)
 /*
  * Get the offset in PAGE_SIZE (even for hugetlb folios).
  */
-static inline pgoff_t folio_pgoff(struct folio *folio)
+static inline pgoff_t folio_pgoff(const struct folio *folio)
 {
 	return folio->index;
 }
 
-static inline pgoff_t linear_page_index(struct vm_area_struct *vma,
-					unsigned long address)
+static inline pgoff_t linear_page_index(const struct vm_area_struct *vma,
+					const unsigned long address)
 {
 	pgoff_t pgoff;
 	pgoff = (address - vma->vm_start) >> PAGE_SHIFT;
@@ -1526,7 +1526,7 @@ static inline unsigned int __readahead_batch(struct readahead_control *rac,
  * readahead_pos - The byte offset into the file of this readahead request.
  * @rac: The readahead request.
  */
-static inline loff_t readahead_pos(struct readahead_control *rac)
+static inline loff_t readahead_pos(const struct readahead_control *rac)
 {
 	return (loff_t)rac->_index * PAGE_SIZE;
 }
@@ -1535,7 +1535,7 @@ static inline loff_t readahead_pos(struct readahead_control *rac)
  * readahead_length - The number of bytes in this readahead request.
  * @rac: The readahead request.
  */
-static inline size_t readahead_length(struct readahead_control *rac)
+static inline size_t readahead_length(const struct readahead_control *rac)
 {
 	return rac->_nr_pages * PAGE_SIZE;
 }
@@ -1544,7 +1544,7 @@ static inline size_t readahead_length(struct readahead_control *rac)
  * readahead_index - The index of the first page in this readahead request.
  * @rac: The readahead request.
  */
-static inline pgoff_t readahead_index(struct readahead_control *rac)
+static inline pgoff_t readahead_index(const struct readahead_control *rac)
 {
 	return rac->_index;
 }
@@ -1553,7 +1553,7 @@ static inline pgoff_t readahead_index(struct readahead_control *rac)
  * readahead_count - The number of pages in this readahead request.
  * @rac: The readahead request.
  */
-static inline unsigned int readahead_count(struct readahead_control *rac)
+static inline unsigned int readahead_count(const struct readahead_control *rac)
 {
 	return rac->_nr_pages;
 }
@@ -1562,12 +1562,12 @@ static inline unsigned int readahead_count(struct readahead_control *rac)
  * readahead_batch_length - The number of bytes in the current batch.
  * @rac: The readahead request.
  */
-static inline size_t readahead_batch_length(struct readahead_control *rac)
+static inline size_t readahead_batch_length(const struct readahead_control *rac)
 {
 	return rac->_batch_count * PAGE_SIZE;
 }
 
-static inline unsigned long dir_pages(struct inode *inode)
+static inline unsigned long dir_pages(const struct inode *inode)
 {
 	return (unsigned long)(inode->i_size + PAGE_SIZE - 1) >>
 			       PAGE_SHIFT;
@@ -1581,8 +1581,8 @@ static inline unsigned long dir_pages(struct inode *inode)
  * Return: the number of bytes in the folio up to EOF,
  * or -EFAULT if the folio was truncated.
  */
-static inline ssize_t folio_mkwrite_check_truncate(struct folio *folio,
-					      struct inode *inode)
+static inline ssize_t folio_mkwrite_check_truncate(const struct folio *folio,
+						   const struct inode *inode)
 {
 	loff_t size = i_size_read(inode);
 	pgoff_t index = size >> PAGE_SHIFT;
@@ -1641,7 +1641,8 @@ static inline int page_mkwrite_check_truncate(struct page *page,
  * Return: The number of filesystem blocks covered by this folio.
  */
 static inline
-unsigned int i_blocks_per_folio(struct inode *inode, struct folio *folio)
+unsigned int i_blocks_per_folio(const struct inode *inode,
+				const struct folio *folio)
 {
 	return folio_size(folio) >> inode->i_blkbits;
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 516/555] filemap: Add folio_next_pos()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (514 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 515/555] mm: constify pagemap related test/getter functions Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 517/555] mm: limit pagecache folio refcount when mapping pages Greg Kroah-Hartman
                   ` (38 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Matthew Wilcox (Oracle), Joseph Qi,
	Christoph Hellwig, Mark Fasheh, Joel Becker, ocfs2-devel,
	Christian Brauner, Pedro Falcato, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Matthew Wilcox (Oracle) <willy@infradead.org>

commit 4511fd86db6f8f94f8aff01044f5c69aa38f81f4 upstream.

Replace the open-coded implementation in ocfs2 (which loses the top
32 bits on 32-bit architectures) with a helper in pagemap.h.

Fixes: 35edec1d52c0 (ocfs2: update truncate handling of partial clusters)
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Link: https://patch.msgid.link/20251024170822.1427218-2-willy@infradead.org
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: ocfs2-devel@lists.linux.dev
Signed-off-by: Christian Brauner <brauner@kernel.org>
[pfalcato: ocfs2 is page-based in 6.12, use page_offset() there]
Stable-dep-of: c6c9a4c1c9a1 ("mm: limit pagecache folio refcount when splicing into pipes")
Signed-off-by: Pedro Falcato <pfalcato@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/ocfs2/alloc.c        |  2 +-
 include/linux/pagemap.h | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index f33aa48a3bc57..cb86ba1ecc804 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -6885,7 +6885,7 @@ static void ocfs2_zero_cluster_pages(struct inode *inode, loff_t start,
 		ocfs2_map_and_dirty_page(inode, handle, from, to, page, 1,
 					 &phys);
 
-		start = (page->index + 1) << PAGE_SHIFT;
+		start = page_offset(page) + PAGE_SIZE;
 	}
 out:
 	if (pages)
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 97e9690394dbb..aabf0de227290 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -938,6 +938,17 @@ static inline pgoff_t folio_next_index(const struct folio *folio)
 	return folio->index + folio_nr_pages(folio);
 }
 
+/**
+ * folio_next_pos - Get the file position of the next folio.
+ * @folio: The current folio.
+ *
+ * Return: The position of the folio which follows this folio in the file.
+ */
+static inline loff_t folio_next_pos(const struct folio *folio)
+{
+	return (loff_t)folio_next_index(folio) << PAGE_SHIFT;
+}
+
 /**
  * folio_file_page - The page for a particular index.
  * @folio: The folio which contains this index.
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 517/555] mm: limit pagecache folio refcount when mapping pages
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (515 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 516/555] filemap: Add folio_next_pos() Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 518/555] mm: limit pagecache folio refcount when splicing into pipes Greg Kroah-Hartman
                   ` (37 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Chris Mason,
	Jose A. Perez de Azpillaga, Zi Yan, Pedro Falcato,
	David Hildenbrand (Arm), Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: David Hildenbrand (Arm) <david@kernel.org>

commit 26b8f029ce5224dd5c5f45a4bc964a209c259914 upstream.

With large file folios, overflowing the folio mapcount and refcount
became possible more easily. For anon folios it is currently not really
an issue: each large anon folio can only be mapped once into a process; on
4k kernels it would be more processes than usually allowed on a system,
and on 16k or 64k kernels the processes alone would consume hundreds of
GiB. Something to be sorted out at some point, but it's not as urgent.

Being able to overflow the refcount is not really big news, but it's about
time that we do something about it because some modern technology might
find ways to abuse it :)

One of the enablers for that was commit ddc58f27f9ee ("mm: drop tail page
refcounting"), however, file thp support was added later.

File folios can be mapped multiple times into the same process, allowing
for processes to hold many references to the same folio.

As a short-term solution, let's introduce two folio refcount limits:
one for ordinary consumers and one for admins. Leave some headroom
before the refcount goes negative, which we really don't want (having
the mapcount go negative is also not expected).

Start reporting SIGBUS and a ratelimited warning if we run into limits.
When restoring mappings from migration entries, instead zap the pte/pmd
entry. We allow for slightly exceeding the limit to keep things simpler.

During fork(), prefer not copying page table entries over failing fork.
For fault-around, check in next_uptodate_folio() before trying to lock
the folio.

Export folio_ref_count_over_limit_slowpath() using EXPORT_SYMBOL_GPL
right away so modules can use it through try_get_page(), where we will
use it next.

Use has_capability_noaudit(current, CAP_SYS_RESOURCE),
so filesystem credential overrides do not affect access to the admin
reserve, and to not generate auditing messages simply because we access
optional reserves.

Don't grant access to the admin reserve from kernel threads, from
interrupt context, where "current" is just the interrupted task, or with
IRQs disabled, as even unaudited capability checks can take locks.

This is far from ideal, but better than all easy alternatives we can
backport comfortably. For now it fixes the big problem: letting
the refcount (+mapcount) go negative and cause trouble.

This is only a temporary fix. Keep the mapping checks explicit and
separate from reference acquisition: most are expected to disappear when
we rework the underlying refcounting.

Check order 0 folios as well for consistency: each
folio_add_file_rmap*() and folio_dup_file_rmap*() needs a prior check.

Adjust the check in folio_get() to just check for invalid refcounts and
drop folio_ref_zero_or_close_to_overflow(): we really don't want
negative refcounts or negative mapcounts. Convert to VM_WARN_ON_FOLIO as
we touch it.

Also, just document -EHWPOISON for copy_present_ptes() while at it.

Note: When zapping file migration entries, uffd-wp is preserved using PTE
markers, but uffd-rwp protection is lost because there is no corresponding
marker. try_to_unmap() already has the same problem when unmapping file
folios, so we'll happily ignore it.

Reported-by: Chris Mason <mason@kernel.org>
Fixes: 800d8c63b2e9 ("shmem: add huge pages support")
Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
Fixes: 793917d997df ("mm/readahead: Add large folio readahead")
Cc: stable@vger.kernel.org
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Acked-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Link: https://patch.msgid.link/20261112-refcount_overflow_stable-v4-1-ad3deef0bd23@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
[pfalcato: drop most of huge_memory.c changes (DAX pages are not refcounted in 6.12), massage]
Signed-off-by: Pedro Falcato <pfalcato@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/linux/mm.h | 36 ++++++++++++++++++++++++++++++++----
 mm/filemap.c       |  2 ++
 mm/huge_memory.c   | 10 ++++++++++
 mm/memory.c        | 35 +++++++++++++++++++++++++++++++----
 mm/migrate.c       | 11 +++++++++++
 mm/userfaultfd.c   |  4 ++++
 mm/util.c          | 26 ++++++++++++++++++++++++++
 7 files changed, 116 insertions(+), 8 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index a6348b25aee22..a600d6c4c3118 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1457,9 +1457,37 @@ static inline bool put_devmap_managed_folio_refs(struct folio *folio, int refs)
 }
 #endif /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */
 
-/* 127: arbitrary random number, small enough to assemble well */
-#define folio_ref_zero_or_close_to_overflow(folio) \
-	((unsigned int) folio_ref_count(folio) + 127u <= 127u)
+/* Leave separate reserves for administrators and concurrent reference gains. */
+#define FOLIO_REF_COUNT_LIMIT		(INT_MAX - (1U << 26))
+#define FOLIO_REF_COUNT_ADMIN_LIMIT	(INT_MAX - (1U << 25))
+
+bool folio_ref_count_over_limit_slowpath(const struct folio *folio,
+		unsigned int ref_count);
+
+/**
+ * folio_ref_count_over_limit - Check whether to refuse more folio references.
+ * @folio: The folio.
+ *
+ * Check before adding page table mappings or other significant refcount users
+ * to pagecache folios (!hugetlb), either before acquiring references or
+ * afterwards with rollback if the operation is refused.
+ *
+ * Checking other folios does no harm.
+ *
+ * This check is an approximation; we leave some headroom such that concurrent
+ * increments, batches, temporary references, or other bounded refcount
+ * consumers are not a problem.
+ *
+ * Return: True if the caller should refuse the operation, false otherwise.
+ */
+static inline bool folio_ref_count_over_limit(const struct folio *folio)
+{
+	const unsigned int ref_count = folio_ref_count(folio);
+
+	if (likely(ref_count < FOLIO_REF_COUNT_LIMIT))
+		return false;
+	return folio_ref_count_over_limit_slowpath(folio, ref_count);
+}
 
 /**
  * folio_get - Increment the reference count on a folio.
@@ -1471,7 +1499,7 @@ static inline bool put_devmap_managed_folio_refs(struct folio *folio, int refs)
  */
 static inline void folio_get(struct folio *folio)
 {
-	VM_BUG_ON_FOLIO(folio_ref_zero_or_close_to_overflow(folio), folio);
+	VM_WARN_ON_FOLIO(folio_ref_count(folio) <= 0, folio);
 	folio_ref_inc(folio);
 }
 
diff --git a/mm/filemap.c b/mm/filemap.c
index 76efdb1e1b784..dc32676906540 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -3506,6 +3506,8 @@ static struct folio *next_uptodate_folio(struct xa_state *xas,
 			continue;
 		if (!folio_try_get(folio))
 			continue;
+		if (unlikely(folio_ref_count_over_limit(folio)))
+			goto skip;
 		/* Has the page moved or been split? */
 		if (unlikely(folio != xas_reload(xas)))
 			goto skip;
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 6cd88cd4b33be..6d5a615107a80 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -4381,6 +4381,16 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new)
 	if (!(pvmw->pmd && !pvmw->pte))
 		return;
 
+	if (!folio_test_anon(folio) && unlikely(folio_ref_count_over_limit(folio))) {
+		/* Leave the file mapping absent so it can be faulted in. */
+		pmd_clear(pvmw->pmd);
+		if (arch_needs_pgtable_deposit())
+			zap_deposited_table(mm, pvmw->pmd);
+		update_hiwater_rss(mm);
+		add_mm_counter(mm, mm_counter_file(folio), -HPAGE_PMD_NR);
+		return;
+	}
+
 	entry = pmd_to_swp_entry(*pvmw->pmd);
 	folio_get(folio);
 	pmde = mk_huge_pmd(new, READ_ONCE(vma->vm_page_prot));
diff --git a/mm/memory.c b/mm/memory.c
index 37b039cc7ba39..4840889461064 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -975,7 +975,10 @@ static __always_inline void __copy_present_ptes(struct vm_area_struct *dst_vma,
  * consecutive pages of the same folio by copying them as well.
  *
  * Returns -EAGAIN if one preallocated page is required to copy the next PTE.
- * Otherwise, returns the number of copied PTEs (at least 1).
+ * Returns -ENOMEM if the file folio refcount is too high and the PTE must
+ * be copied.
+ * Returns -EHWPOISON if copying a page fails.
+ * Otherwise, returns the number of processed PTEs (at least 1).
  */
 static inline int
 copy_present_ptes(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma,
@@ -994,6 +997,18 @@ copy_present_ptes(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma
 
 	folio = page_folio(page);
 
+	if (!folio_test_anon(folio) && unlikely(folio_ref_count_over_limit(folio))) {
+		/*
+		 * VM_MIXEDMAP may contain pages inserted by a driver at mmap
+		 * time, with no fault handler to restore a missing PTE.
+		 */
+		if (dst_vma->vm_flags & VM_MIXEDMAP)
+			return -ENOMEM;
+		/* Preserve uffd-wp protection when faulting the page back in. */
+		pte_install_uffd_wp_if_needed(dst_vma, addr, dst_pte, pte);
+		return 1;
+	}
+
 	/*
 	 * If we likely have to copy, just don't bother with batching. Make
 	 * sure that the common "small folio" case is as fast as possible
@@ -1170,9 +1185,9 @@ copy_pte_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma,
 		/*
 		 * If we need a pre-allocated page for this pte, drop the
 		 * locks, allocate, and try again.
-		 * If copy failed due to hwpoison in source page, break out.
+		 * Other errors abort the copy after releasing the page table locks.
 		 */
-		if (unlikely(ret == -EAGAIN || ret == -EHWPOISON))
+		if (unlikely(ret < 0))
 			break;
 		if (unlikely(prealloc)) {
 			/*
@@ -1202,7 +1217,7 @@ copy_pte_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma,
 			goto out;
 		}
 		entry.val = 0;
-	} else if (ret == -EBUSY || unlikely(ret == -EHWPOISON)) {
+	} else if (ret == -EBUSY || ret == -ENOMEM || unlikely(ret == -EHWPOISON)) {
 		goto out;
 	} else if (ret ==  -EAGAIN) {
 		prealloc = folio_prealloc(src_mm, src_vma, addr, false);
@@ -2052,6 +2067,8 @@ static int insert_page_into_pte_locked(struct vm_area_struct *vma, pte_t *pte,
 	if (unlikely(is_zero_folio(folio))) {
 		pteval = pte_mkspecial(pteval);
 	} else {
+		if (unlikely(folio_ref_count_over_limit(folio)))
+			return -EOVERFLOW;
 		folio_get(folio);
 		inc_mm_counter(vma->vm_mm, mm_counter_file(folio));
 		folio_add_file_rmap_pte(folio, page, vma);
@@ -4994,6 +5011,9 @@ vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page)
 	if (unlikely(folio_test_has_hwpoisoned(folio)))
 		return ret;
 
+	if (unlikely(folio_ref_count_over_limit(folio)))
+		return VM_FAULT_SIGBUS;
+
 	/*
 	 * Archs like ppc64 need additional space to store information
 	 * related to pte entry. Use the preallocated table for that.
@@ -5048,6 +5068,9 @@ vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page)
  * @page: The first page to create a PTE for.
  * @nr: The number of PTEs to create.
  * @addr: The first address to create a PTE for.
+ *
+ * For file mappings, the caller must check folio_ref_count_over_limit()
+ * before installing PTEs.
  */
 void set_pte_range(struct vm_fault *vmf, struct folio *folio,
 		struct page *page, unsigned int nr, unsigned long addr)
@@ -5218,6 +5241,10 @@ vm_fault_t finish_fault(struct vm_fault *vmf)
 		goto fallback;
 	}
 
+	if (!is_cow && unlikely(folio_ref_count_over_limit(folio))) {
+		ret = VM_FAULT_SIGBUS;
+		goto unlock;
+	}
 	folio_ref_add(folio, nr_pages - 1);
 	set_pte_range(vmf, folio, page, nr_pages, addr);
 	type = is_cow ? MM_ANONPAGES : mm_counter_file(folio);
diff --git a/mm/migrate.c b/mm/migrate.c
index 66af1dd6a9411..8f57b302f2ad0 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -322,6 +322,17 @@ static bool remove_migration_pte(struct folio *folio,
 		    try_to_map_unused_to_zeropage(&pvmw, folio, old_pte, idx))
 			continue;
 
+		if (!folio_test_anon(folio) && !folio_test_hugetlb(folio) &&
+		    unlikely(folio_ref_count_over_limit(folio))) {
+			/* File contents remain available for a later fault. */
+			pte_clear(vma->vm_mm, pvmw.address, pvmw.pte);
+			pte_install_uffd_wp_if_needed(vma, pvmw.address,
+						  pvmw.pte, old_pte);
+			update_hiwater_rss(vma->vm_mm);
+			dec_mm_counter(vma->vm_mm, mm_counter_file(folio));
+			continue;
+		}
+
 		folio_get(folio);
 		pte = mk_pte(new, READ_ONCE(vma->vm_page_prot));
 
diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
index 6a575335bc6f0..f592f92c74079 100644
--- a/mm/userfaultfd.c
+++ b/mm/userfaultfd.c
@@ -211,6 +211,10 @@ int mfill_atomic_install_pte(pmd_t *dst_pmd,
 		goto out_unlock;
 
 	if (page_in_cache) {
+		if (unlikely(folio_ref_count_over_limit(folio))) {
+			ret = -ENOMEM;
+			goto out_unlock;
+		}
 		/* Usually, cache pages are already added to LRU */
 		if (newly_allocated)
 			folio_add_lru(folio);
diff --git a/mm/util.c b/mm/util.c
index 8c6d8d4d62c4f..af1531a092cee 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -1248,3 +1248,29 @@ void flush_dcache_folio(struct folio *folio)
 }
 EXPORT_SYMBOL(flush_dcache_folio);
 #endif
+
+bool folio_ref_count_over_limit_slowpath(const struct folio *folio,
+			   unsigned int ref_count)
+{
+	if (ref_count >= FOLIO_REF_COUNT_ADMIN_LIMIT)
+		goto over_limit;
+	/* Background threads must not consume admin reserves. */
+	if (current->flags & PF_KTHREAD)
+		goto over_limit;
+	/* Neither must interrupt contexts on behalf of the interrupted task. */
+	if (!in_task())
+		goto over_limit;
+	/* Capability checks are not safe with IRQs disabled. */
+	if (irqs_disabled())
+		goto over_limit;
+	/* Use the task's credentials, which filesystem overrides cannot change. */
+	if (has_capability_noaudit(current, CAP_SYS_RESOURCE))
+		return false;
+
+over_limit:
+	pr_warn_ratelimited("folio:%p refcount:%d mapcount:%d mapping:%p index:%#lx reached refcount limit\n",
+				folio, (int)ref_count, folio_mapcount(folio),
+				folio_mapping((struct folio *) folio), folio->index);
+	return true;
+}
+EXPORT_SYMBOL_GPL(folio_ref_count_over_limit_slowpath);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 518/555] mm: limit pagecache folio refcount when splicing into pipes
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (516 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 517/555] mm: limit pagecache folio refcount when mapping pages Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 519/555] mm/mmu_gather: flush pending references early before the folio limit Greg Kroah-Hartman
                   ` (36 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jose A. Perez de Azpillaga,
	Pedro Falcato, David Hildenbrand (Arm), Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: David Hildenbrand (Arm) <david@kernel.org>

commit c6c9a4c1c9a1669693330205cb9d86fafd3cf235 upstream.

Similar to mapping pagecache folios into page tables, let's reject
additional references when splicing folios into a pipe if the refcount
is at its limit.

This will prevent more cases of possible folio refcount overflows with
large pagecache folios.

Introduce folio_get_checked() for checked reference acquisition when
the caller already holds a reference. It warns and fails on a non-positive
refcount and rejects additional references at the limit.

Add __folio_ref_count_over_limit() so folio_get_checked() can reuse the
refcount instead of having to read it a second time.

Use folio_get_checked() in splice_folio_into_pipe() and
fuse_ref_folio(), returning -EFAULT on failure, like we already do for
pipe-buffer duplication. Similarly, make try_get_page() use it instead.

Likely try_get_page() should be renamed (or removed) later, as it doesn't
match the folio_try_get() semantics and is confusing.

If we hit the limit after splicing some data, return the number of bytes
already spliced. Teach the callers to handle errors, and stop
filemap_splice_read() if we only spliced part of a folio, so we don't
skip ahead to the next folio: note that we wouldn't run into this
scenario before as we always spliced the requested range.

The check in try_get_page() also covers pipe-buffer duplication by tee()
and partial pipe-to-pipe splicing.

Note that we deliberately will not fall back to the slow path of copying
the folio, particularly as the folio might have an invalid refcount. If
it is ever really required, we can revisit.

Fixes: 800d8c63b2e9 ("shmem: add huge pages support")
Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
Fixes: 793917d997df ("mm/readahead: Add large folio readahead")
Cc: stable@vger.kernel.org
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Link: https://patch.msgid.link/20261112-refcount_overflow_stable-v4-2-ad3deef0bd23@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
[pfalcato: fixup fuse_ref_page changes for folios, filemap_splice_read pipe_full check]
Signed-off-by: Pedro Falcato <pfalcato@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/fuse/dev.c      |  5 ++++-
 include/linux/mm.h | 49 ++++++++++++++++++++++++++++++++++++++--------
 mm/filemap.c       | 27 +++++++++++++++----------
 mm/internal.h      |  4 ++--
 mm/shmem.c         |  7 +++++--
 5 files changed, 69 insertions(+), 23 deletions(-)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 27ce1f1bcfe19..d0374e2bcb235 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -938,13 +938,16 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep)
 static int fuse_ref_page(struct fuse_copy_state *cs, struct page *page,
 			 unsigned offset, unsigned count)
 {
+	struct folio *folio = page_folio(page);
 	struct pipe_buffer *buf;
 	int err;
 
 	if (cs->nr_segs >= cs->pipe->max_usage)
 		return -EIO;
 
-	get_page(page);
+	if (!folio_get_checked(folio))
+		return -EFAULT;
+
 	err = unlock_request(cs->req);
 	if (err) {
 		put_page(page);
diff --git a/include/linux/mm.h b/include/linux/mm.h
index a600d6c4c3118..6341c9433dfb1 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1465,8 +1465,9 @@ bool folio_ref_count_over_limit_slowpath(const struct folio *folio,
 		unsigned int ref_count);
 
 /**
- * folio_ref_count_over_limit - Check whether to refuse more folio references.
+ * __folio_ref_count_over_limit - Check whether to refuse more folio references.
  * @folio: The folio.
+ * @ref_count: The sampled folio reference count.
  *
  * Check before adding page table mappings or other significant refcount users
  * to pagecache folios (!hugetlb), either before acquiring references or
@@ -1480,15 +1481,27 @@ bool folio_ref_count_over_limit_slowpath(const struct folio *folio,
  *
  * Return: True if the caller should refuse the operation, false otherwise.
  */
-static inline bool folio_ref_count_over_limit(const struct folio *folio)
+static inline bool __folio_ref_count_over_limit(const struct folio *folio,
+		unsigned int ref_count)
 {
-	const unsigned int ref_count = folio_ref_count(folio);
-
 	if (likely(ref_count < FOLIO_REF_COUNT_LIMIT))
 		return false;
 	return folio_ref_count_over_limit_slowpath(folio, ref_count);
 }
 
+/**
+ * folio_ref_count_over_limit - Check whether to refuse more folio references.
+ * @folio: The folio.
+ *
+ * See __folio_ref_count_over_limit().
+ *
+ * Return: True if the caller should refuse the operation, false otherwise.
+ */
+static inline bool folio_ref_count_over_limit(const struct folio *folio)
+{
+	return __folio_ref_count_over_limit(folio, folio_ref_count(folio));
+}
+
 /**
  * folio_get - Increment the reference count on a folio.
  * @folio: The folio.
@@ -1508,15 +1521,35 @@ static inline void get_page(struct page *page)
 	folio_get(page_folio(page));
 }
 
-static inline __must_check bool try_get_page(struct page *page)
+/**
+ * folio_get_checked - Try to acquire a reference to a live folio.
+ * @folio: The folio.
+ *
+ * The caller must already hold a reference to @folio. Warn and fail on a
+ * non-positive refcount, and refuse additional references at the limit.
+ *
+ * Use folio_try_get() for speculative reference acquisition where the
+ * refcount can legitimately be zero.
+ *
+ * Return: True if the refcount was incremented, false otherwise.
+ */
+static inline __must_check bool folio_get_checked(struct folio *folio)
 {
-	page = compound_head(page);
-	if (WARN_ON_ONCE(page_ref_count(page) <= 0))
+	const int ref_count = folio_ref_count(folio);
+
+	if (WARN_ON_ONCE(ref_count <= 0))
+		return false;
+	if (unlikely(__folio_ref_count_over_limit(folio, ref_count)))
 		return false;
-	page_ref_inc(page);
+	folio_ref_inc(folio);
 	return true;
 }
 
+static inline __must_check bool try_get_page(struct page *page)
+{
+	return folio_get_checked(page_folio(page));
+}
+
 /**
  * folio_put - Decrement the reference count on a folio.
  * @folio: The folio.
diff --git a/mm/filemap.c b/mm/filemap.c
index dc32676906540..17148fffc124b 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2848,10 +2848,11 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
 EXPORT_SYMBOL(generic_file_read_iter);
 
 /*
- * Splice subpages from a folio into a pipe.
+ * Splice subpages from a folio into a pipe. Return the number of bytes spliced,
+ * or -EFAULT if we cannot splice from the folio.
  */
-size_t splice_folio_into_pipe(struct pipe_inode_info *pipe,
-			      struct folio *folio, loff_t fpos, size_t size)
+ssize_t splice_folio_into_pipe(struct pipe_inode_info *pipe,
+			       struct folio *folio, loff_t fpos, size_t size)
 {
 	struct page *page;
 	size_t spliced = 0, offset = offset_in_folio(folio, fpos);
@@ -2865,13 +2866,15 @@ size_t splice_folio_into_pipe(struct pipe_inode_info *pipe,
 		struct pipe_buffer *buf = pipe_head_buf(pipe);
 		size_t part = min_t(size_t, PAGE_SIZE - offset, size - spliced);
 
+		if (!folio_get_checked(folio))
+			return spliced ? spliced : -EFAULT;
+
 		*buf = (struct pipe_buffer) {
 			.ops	= &page_cache_pipe_buf_ops,
 			.page	= page,
 			.offset	= offset,
 			.len	= part,
 		};
-		folio_get(folio);
 		pipe->head++;
 		page++;
 		spliced += part;
@@ -2896,9 +2899,10 @@ size_t splice_folio_into_pipe(struct pipe_inode_info *pipe,
  * Return: On success, the number of bytes read will be returned and *@ppos
  * will be updated if appropriate; 0 will be returned if there is no more data
  * to be read; -EAGAIN will be returned if the pipe had no space, and some
- * other negative error code will be returned on error.  A short read may occur
- * if the pipe has insufficient space, we reach the end of the data or we hit a
- * hole.
+ * other negative error code will be returned on error; -EFAULT will be returned
+ * if acquiring a folio reference fails and no data has been spliced.
+ * A short read may occur if the pipe has insufficient space, we reach the
+ * end of the data, hit a hole or hit a folio refcount limit.
  */
 ssize_t filemap_splice_read(struct file *in, loff_t *ppos,
 			    struct pipe_inode_info *pipe,
@@ -2956,7 +2960,7 @@ ssize_t filemap_splice_read(struct file *in, loff_t *ppos,
 
 		for (i = 0; i < folio_batch_count(&fbatch); i++) {
 			struct folio *folio = fbatch.folios[i];
-			size_t n;
+			ssize_t n;
 
 			if (folio_pos(folio) >= end_offset)
 				goto out;
@@ -2972,13 +2976,16 @@ ssize_t filemap_splice_read(struct file *in, loff_t *ppos,
 
 			n = min_t(loff_t, len, isize - *ppos);
 			n = splice_folio_into_pipe(pipe, folio, *ppos, n);
-			if (!n)
+			if (n <= 0) {
+				error = n;
 				goto out;
+			}
 			len -= n;
 			total_spliced += n;
 			*ppos += n;
 			in->f_ra.prev_pos = *ppos;
-			if (pipe_full(pipe->head, pipe->tail, pipe->max_usage))
+			if (pipe_full(pipe->head, pipe->tail, pipe->max_usage) ||
+			    *ppos < folio_next_pos(folio))
 				goto out;
 		}
 
diff --git a/mm/internal.h b/mm/internal.h
index 85f60a77f550b..0cb49d2a51025 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -1297,8 +1297,8 @@ struct migration_target_control {
 /*
  * mm/filemap.c
  */
-size_t splice_folio_into_pipe(struct pipe_inode_info *pipe,
-			      struct folio *folio, loff_t fpos, size_t size);
+ssize_t splice_folio_into_pipe(struct pipe_inode_info *pipe,
+			       struct folio *folio, loff_t fpos, size_t size);
 
 /*
  * mm/vmalloc.c
diff --git a/mm/shmem.c b/mm/shmem.c
index 1693aa906227a..b40595fda88ba 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -3373,7 +3373,8 @@ static ssize_t shmem_file_splice_read(struct file *in, loff_t *ppos,
 	struct inode *inode = file_inode(in);
 	struct address_space *mapping = inode->i_mapping;
 	struct folio *folio = NULL;
-	size_t total_spliced = 0, used, npages, n, part;
+	size_t total_spliced = 0, used, npages, part;
+	ssize_t n;
 	loff_t isize;
 	int error = 0;
 
@@ -3437,8 +3438,10 @@ static ssize_t shmem_file_splice_read(struct file *in, loff_t *ppos,
 			n = splice_zeropage_into_pipe(pipe, *ppos, part);
 		}
 
-		if (!n)
+		if (n <= 0) {
+			error = n;
 			break;
+		}
 		len -= n;
 		total_spliced += n;
 		*ppos += n;
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 519/555] mm/mmu_gather: flush pending references early before the folio limit
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (517 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 518/555] mm: limit pagecache folio refcount when splicing into pipes Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 520/555] mm/gup: limit pagecache folio refcount when grabbing references Greg Kroah-Hartman
                   ` (35 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Chris Mason,
	Jose A. Perez de Azpillaga, Lance Yang, Pedro Falcato,
	David Hildenbrand (Arm), Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: David Hildenbrand (Arm) <david@kernel.org>

commit 317bd7d28b248fd4d4e14614d7c30b17a36ef4d7 upstream.

When a task zaps mappings (e.g., MADV_DONTNEED), it can drop the PT lock
and defer dropping the folio references. In the meantime, page faults
can refault pagecache folios, creating more references for the same
folios. These deferred references can build up over multiple VMAs.

Let's just request a flush after enqueueing folios whose refcount reached
a certain threshold. Start flushing well before new references are refused,
regardless of the caller's privileges.

When returning "true" from __tlb_remove_folio_pages_size(), PTE zapping
will flush the TLB before dropping the PT lock, but drop the references
afterwards. Refaults can still race with that, but flushing early reduces
the risk of letting others hit the limit.

This is a temporary measure until we have something better.

Reported-by: Chris Mason <mason@kernel.org>
Fixes: 800d8c63b2e9 ("shmem: add huge pages support")
Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
Fixes: 793917d997df ("mm/readahead: Add large folio readahead")
Cc: stable@vger.kernel.org
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Link: https://patch.msgid.link/20261112-refcount_overflow_stable-v4-3-ad3deef0bd23@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
[pfalcato: massage comment]
Signed-off-by: Pedro Falcato <pfalcato@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/asm-generic/tlb.h |  6 +++---
 include/linux/mm.h        |  1 +
 mm/memory.c               |  4 ++--
 mm/mmu_gather.c           | 10 ++++++----
 4 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
index c046a09b0b487..b4f690a623056 100644
--- a/include/asm-generic/tlb.h
+++ b/include/asm-generic/tlb.h
@@ -73,9 +73,9 @@
  *  - __tlb_remove_folio_pages()
  *
  *    __tlb_remove_page_size() is the basic primitive that queues a page for
- *    freeing. __tlb_remove_page() assumes PAGE_SIZE. Both will return a
- *    boolean indicating if the queue is (now) full and a call to
- *    tlb_flush_mmu() is required.
+ *    freeing. __tlb_remove_page() assumes PAGE_SIZE. They return true when
+ *    a call to tlb_flush_mmu() is required, either because the queue is full
+ *    or a folio is near its refcount limit.
  *
  *    tlb_remove_page() and tlb_remove_page_size() imply the call to
  *    tlb_flush_mmu() when required and has no return value.
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 6341c9433dfb1..e8c676fe84511 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1460,6 +1460,7 @@ static inline bool put_devmap_managed_folio_refs(struct folio *folio, int refs)
 /* Leave separate reserves for administrators and concurrent reference gains. */
 #define FOLIO_REF_COUNT_LIMIT		(INT_MAX - (1U << 26))
 #define FOLIO_REF_COUNT_ADMIN_LIMIT	(INT_MAX - (1U << 25))
+#define FOLIO_REF_COUNT_FLUSH_LIMIT	(INT_MAX - (1U << 27))
 
 bool folio_ref_count_over_limit_slowpath(const struct folio *folio,
 		unsigned int ref_count);
diff --git a/mm/memory.c b/mm/memory.c
index 4840889461064..a6a127c5a8255 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1704,8 +1704,8 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb,
 	pte_unmap_unlock(start_pte, ptl);
 
 	/*
-	 * If we forced a TLB flush (either due to running out of
-	 * batch buffers or because we needed to flush dirty TLB
+	 * If we forced a TLB flush (either to release batched
+	 * references or because we needed to flush dirty TLB
 	 * entries before releasing the ptl), free the batched
 	 * memory too. Come back again if we didn't do everything.
 	 */
diff --git a/mm/mmu_gather.c b/mm/mmu_gather.c
index 04469b481b93f..fc705de6a3bb7 100644
--- a/mm/mmu_gather.c
+++ b/mm/mmu_gather.c
@@ -178,10 +178,7 @@ static bool __tlb_remove_folio_pages_size(struct mmu_gather *tlb,
 #endif
 
 	batch = tlb->active;
-	/*
-	 * Add the page and check if we are full. If so
-	 * force a flush.
-	 */
+	/* Add the pages before deciding whether we need to flush. */
 	if (likely(nr_pages == 1)) {
 		batch->encoded_pages[batch->nr++] = encode_page(page, flags);
 	} else {
@@ -189,6 +186,11 @@ static bool __tlb_remove_folio_pages_size(struct mmu_gather *tlb,
 		batch->encoded_pages[batch->nr++] = encode_page(page, flags);
 		batch->encoded_pages[batch->nr++] = encode_nr_pages(nr_pages);
 	}
+	/* Flush pending references well before new references are refused. */
+	if (unlikely((unsigned int)folio_ref_count(page_folio(page)) >=
+		     FOLIO_REF_COUNT_FLUSH_LIMIT))
+		return true;
+
 	/*
 	 * Make sure that we can always add another "page" + "nr_pages",
 	 * requiring two entries instead of only a single one.
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 520/555] mm/gup: limit pagecache folio refcount when grabbing references
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (518 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 519/555] mm/mmu_gather: flush pending references early before the folio limit Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 521/555] ipv6: Remove FIB6_EXCEPTION_BUCKET_FLUSHED Greg Kroah-Hartman
                   ` (34 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jose A. Perez de Azpillaga,
	Pedro Falcato, David Hildenbrand (Arm), Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: David Hildenbrand (Arm) <david@kernel.org>

commit 2d9bcd380585abc436f055fbb618b34f98882004 upstream.

Let's add __folio_ref_count_over_limit() checks in fast and slow GUP
before acquiring additional references or pins.

Keep it simple and use the check for all folio types.

Also propagate try_grab_folio() errors when grabbing additional
references in __get_user_pages() and in memfd_pin_folios(), so hitting
the limit returns -ENOMEM instead of -EFAULT and -EINVAL, respectively.

Keep the existing invalid-refcount warnings.

Fixes: 800d8c63b2e9 ("shmem: add huge pages support")
Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
Fixes: 793917d997df ("mm/readahead: Add large folio readahead")
Cc: stable@vger.kernel.org
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Link: https://patch.msgid.link/20261112-refcount_overflow_stable-v4-5-ad3deef0bd23@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Pedro Falcato <pfalcato@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/linux/mm.h | 11 +++++------
 mm/gup.c           | 32 +++++++++++++++++++++-----------
 2 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index e8c676fe84511..b46deb18495e0 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1474,6 +1474,9 @@ bool folio_ref_count_over_limit_slowpath(const struct folio *folio,
  * to pagecache folios (!hugetlb), either before acquiring references or
  * afterwards with rollback if the operation is refused.
  *
+ * Also required when pinning folios without a dedicated pincount that use
+ * GUP_PIN_COUNTING_BIAS.
+ *
  * Checking other folios does no harm.
  *
  * This check is an approximation; we leave some headroom such that concurrent
@@ -2030,12 +2033,8 @@ static inline bool folio_maybe_dma_pinned(struct folio *folio)
 		return atomic_read(&folio->_pincount) > 0;
 
 	/*
-	 * folio_ref_count() is signed. If that refcount overflows, then
-	 * folio_ref_count() returns a negative value, and callers will avoid
-	 * further incrementing the refcount.
-	 *
-	 * Here, for that overflow case, use the sign bit to count a little
-	 * bit higher via unsigned math, and thus still get an accurate result.
+	 * Use unsigned math so even an unexpected negative refcount is
+	 * treated as possibly pinned.
 	 */
 	return ((unsigned int)folio_ref_count(folio)) >=
 		GUP_PIN_COUNTING_BIAS;
diff --git a/mm/gup.c b/mm/gup.c
index 01a6408055102..7c607ba3bbb86 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -78,10 +78,14 @@ static inline void sanity_check_pinned_pages(struct page **pages,
 static inline struct folio *try_get_folio(struct page *page, int refs)
 {
 	struct folio *folio;
+	int ref_count;
 
 retry:
 	folio = page_folio(page);
-	if (WARN_ON_ONCE(folio_ref_count(folio) < 0))
+	ref_count = folio_ref_count(folio);
+	if (WARN_ON_ONCE(ref_count < 0))
+		return NULL;
+	if (unlikely(__folio_ref_count_over_limit(folio, ref_count)))
 		return NULL;
 	if (unlikely(!folio_ref_try_add(folio, refs)))
 		return NULL;
@@ -146,7 +150,13 @@ static void gup_put_folio(struct folio *folio, int refs, unsigned int flags)
 int __must_check try_grab_folio(struct folio *folio, int refs,
 				unsigned int flags)
 {
-	if (WARN_ON_ONCE(folio_ref_count(folio) <= 0))
+	const int ref_count = folio_ref_count(folio);
+
+	if (WARN_ON_ONCE(ref_count <= 0))
+		return -ENOMEM;
+
+	if ((flags & (FOLL_GET | FOLL_PIN)) &&
+	    unlikely(__folio_ref_count_over_limit(folio, ref_count)))
 		return -ENOMEM;
 
 	if (unlikely(!(flags & FOLL_PCI_P2PDMA) && is_pci_p2pdma_page(&folio->page)))
@@ -1547,17 +1557,17 @@ static long __get_user_pages(struct mm_struct *mm,
 				struct folio *folio = page_folio(page);
 
 				/*
-				 * Since we already hold refcount on the
-				 * large folio, this should never fail.
+				 * Grabbing more references can fail once we
+				 * hit folio refcount limits.
 				 */
-				if (try_grab_folio(folio, page_increm - 1,
-						   gup_flags)) {
+				ret = try_grab_folio(folio, page_increm - 1,
+						     gup_flags);
+				if (ret) {
 					/*
-					 * Release the 1st page ref if the
-					 * folio is problematic, fail hard.
+					 * Release the folio reference we
+					 * already took.
 					 */
 					gup_put_folio(folio, 1, gup_flags);
-					ret = -EFAULT;
 					goto out;
 				}
 			}
@@ -3796,10 +3806,10 @@ long memfd_pin_folios(struct file *memfd, loff_t start, loff_t end,
 					break;
 				}
 
-				if (try_grab_folio(folio, 1, FOLL_PIN)) {
+				ret = try_grab_folio(folio, 1, FOLL_PIN);
+				if (ret) {
 					folio_unlock(folio);
 					folio_batch_release(&fbatch);
-					ret = -EINVAL;
 					goto err;
 				}
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 521/555] ipv6: Remove FIB6_EXCEPTION_BUCKET_FLUSHED.
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (519 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 520/555] mm/gup: limit pagecache folio refcount when grabbing references Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 522/555] ipv6: Flush exception route while replacing nexthop Greg Kroah-Hartman
                   ` (33 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Kuniyuki Iwashima, Ido Schimmel,
	Jakub Kicinski, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Kuniyuki Iwashima <kuniyu@google.com>

[ Upstream commit c66d93e68728cfb5f40b40d0f24129d7768faf43 ]

The FIB6_EXCEPTION_BUCKET_FLUSHED logic has been dead since added.

Commit 0346ec2f080b ("ipv6: Prevent rt6_insert_exception() for
dying fib6_info.") restored the original race protection in
rt6_insert_exception() by reusing fib6_info.fib6_destroying.

The flag now prevents two races for per-cpu and exception routes.

Let's remove FIB6_EXCEPTION_BUCKET_FLUSHED and set fib6_destroying
in fib6_purge_rt().

Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20260926033355.3295550-1-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[ sashal: adapted the fib6_purge_rt() call to fib6_drop_pcpu_from(rt, table) to match the existing two-argument signature in this tree. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/ipv6/ip6_fib.c | 14 +++++++-------
 net/ipv6/route.c   | 45 ---------------------------------------------
 2 files changed, 7 insertions(+), 52 deletions(-)

diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 0406488b4327d..257318e8c4a40 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -1045,12 +1045,6 @@ static int fib6_nh_drop_pcpu_from(struct fib6_nh *nh, void *_arg)
 static void fib6_drop_pcpu_from(struct fib6_info *f6i,
 				const struct fib6_table *table)
 {
-	/* Make sure rt6_make_pcpu_route() wont add other percpu routes
-	 * while we are cleaning them here.
-	 */
-	f6i->fib6_destroying = 1;
-	mb(); /* paired with the cmpxchg() in rt6_make_pcpu_route() */
-
 	if (f6i->nh) {
 		struct fib6_nh_pcpu_arg arg = {
 			.from = f6i,
@@ -1072,7 +1066,13 @@ static void fib6_purge_rt(struct fib6_info *rt, struct fib6_node *fn,
 {
 	struct fib6_table *table = rt->fib6_table;
 
-	/* Flush all cached dst in exception table */
+	/* Make sure rt6_make_pcpu_route() / rt6_insert_exception()
+	 * will not add other percpu / exception routes after cleaning
+	 * them up in __fib6_drop_pcpu_from() / rt6_flush_exceptions().
+	 */
+	rt->fib6_destroying = 1;
+	mb(); /* paired with the cmpxchg() in rt6_make_pcpu_route() */
+
 	fib6_drop_pcpu_from(rt, table);
 	rt6_flush_exceptions(rt);
 
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index bc7cd0e8940b3..25a055763bd1b 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1674,13 +1674,6 @@ static unsigned int fib6_mtu(const struct fib6_result *res)
 	return mtu - lwtunnel_headroom(nh->fib_nh_lws, mtu);
 }
 
-#define FIB6_EXCEPTION_BUCKET_FLUSHED  0x1UL
-
-/* used when the flushed bit is not relevant, only access to the bucket
- * (ie., all bucket users except rt6_insert_exception);
- *
- * called under rcu lock; sometimes called with rt6_exception_lock held
- */
 static
 struct rt6_exception_bucket *fib6_nh_get_excptn_bucket(const struct fib6_nh *nh,
 						       spinlock_t *lock)
@@ -1693,40 +1686,9 @@ struct rt6_exception_bucket *fib6_nh_get_excptn_bucket(const struct fib6_nh *nh,
 	else
 		bucket = rcu_dereference(nh->rt6i_exception_bucket);
 
-	/* remove bucket flushed bit if set */
-	if (bucket) {
-		unsigned long p = (unsigned long)bucket;
-
-		p &= ~FIB6_EXCEPTION_BUCKET_FLUSHED;
-		bucket = (struct rt6_exception_bucket *)p;
-	}
-
 	return bucket;
 }
 
-static bool fib6_nh_excptn_bucket_flushed(struct rt6_exception_bucket *bucket)
-{
-	unsigned long p = (unsigned long)bucket;
-
-	return !!(p & FIB6_EXCEPTION_BUCKET_FLUSHED);
-}
-
-/* called with rt6_exception_lock held */
-static void fib6_nh_excptn_bucket_set_flushed(struct fib6_nh *nh,
-					      spinlock_t *lock)
-{
-	struct rt6_exception_bucket *bucket;
-	unsigned long p;
-
-	bucket = rcu_dereference_protected(nh->rt6i_exception_bucket,
-					   lockdep_is_held(lock));
-
-	p = (unsigned long)bucket;
-	p |= FIB6_EXCEPTION_BUCKET_FLUSHED;
-	bucket = (struct rt6_exception_bucket *)p;
-	rcu_assign_pointer(nh->rt6i_exception_bucket, bucket);
-}
-
 static int rt6_insert_exception(struct rt6_info *nrt,
 				const struct fib6_result *res)
 {
@@ -1756,9 +1718,6 @@ static int rt6_insert_exception(struct rt6_info *nrt,
 			goto out;
 		}
 		rcu_assign_pointer(nh->rt6i_exception_bucket, bucket);
-	} else if (fib6_nh_excptn_bucket_flushed(bucket)) {
-		err = -EINVAL;
-		goto out;
 	}
 
 #ifdef CONFIG_IPV6_SUBTREES
@@ -1829,10 +1788,6 @@ static void fib6_nh_flush_exceptions(struct fib6_nh *nh, struct fib6_info *from)
 	if (!bucket)
 		goto out;
 
-	/* Prevent rt6_insert_exception() to recreate the bucket list */
-	if (!from)
-		fib6_nh_excptn_bucket_set_flushed(nh, &rt6_exception_lock);
-
 	for (i = 0; i < FIB6_EXCEPTION_BUCKET_SIZE; i++) {
 		hlist_for_each_entry_safe(rt6_ex, tmp, &bucket->chain, hlist) {
 			if (!from ||
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 522/555] ipv6: Flush exception route while replacing nexthop.
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (520 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 521/555] ipv6: Remove FIB6_EXCEPTION_BUCKET_FLUSHED Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 523/555] ASoC: SOF: Intel: lnl: Enable offload for UAOL link Greg Kroah-Hartman
                   ` (32 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Jason Zhang, Kuniyuki Iwashima,
	Ido Schimmel, Paolo Abeni, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Kuniyuki Iwashima <kuniyu@google.com>

[ Upstream commit 9401b428b5d4dfe1fd5752973fd02b4e9cd05536 ]

The following creates a cyclic reference between IPv6 route
and nexthop:

  1. create a nexthop A
  2. create a nexthop group w/ A
  3. create an IPv6 route with the nexthop group
  4. create an exception route w/ A
  5. replace A with a new nexthop B in the nexthop group
  6. remove the IPv6 route
  7. replace B with A in the nexthop group
  8. remove the nexthop group

Then, removing a device tied to the route gets stuck and
triggers the splat below. [0]

At 5., fib6_nh_release_dsts() is called, but it does not
flush exception routes, so the nexthop A continues to grab
the IPv6 route reference.

  nh_A->rt6i_exception_bucket[] -> rt6_ex->rt6i->from

At 6., fib6_purge_rt() calls rt6_flush_exceptions(), but it
only purges exceptions tied to nexthop B.  Also, the route is
unlinked from the nexthop group by list_del_init(&rt->nh_list).

  -> f6i->nh -> nhg->nh_entries[]

At 8., __remove_nexthop_fib() cannot find the IPv6 route, and
remove_nexthop_group() calls list_del_init(&nhge->nh_list) to
unlink the group from the nexthop A's nhe->grp_list.

  nhg->nh_entries[] -> nh_A -> ... -> f6i

Here, the nexthop A is reachable from net->nexthop.devhash[],
but remove_nexthop_from_groups() cannot find the nexthop group,
leaking the whole chain.

Let's call fib6_nh_flush_exceptions() in fib6_nh_release_dsts().

[0]:
unregister_netdevice: waiting for gre6 to become free. Usage count = 4
ref_tracker: netdev@000000009652f190 has 1/3 users at
     dst_alloc+0x14b/0x490
     ip6_rt_cache_alloc+0x27b/0x670
     __ip6_rt_update_pmtu+0x572/0x850
     ip6_tnl_xmit+0x8c5/0x1b70
     __gre6_xmit+0x7af/0xaa0
     ip6gre_tunnel_xmit+0x685/0xdc0
     dev_hard_start_xmit+0x204/0x5a0
     __dev_queue_xmit+0xe8a/0x2550
     ip6_finish_output+0x232/0x570
     ip6_output+0x226/0x3b0
     ip6_send_skb+0x133/0x250
     rawv6_push_pending_frames+0x503/0x6f0
     rawv6_sendmsg+0xdf0/0x1310
     sock_sendmsg_nosec+0xde/0x130
     __sys_sendto+0x27f/0x320
     __x64_sys_sendto+0xd9/0xf0

Fixes: 7bf4796dd099 ("nexthops: add support for replace")
Reported-by: Jason Zhang <jdz@google.com>
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20261101064418.2055158-2-kuniyu@google.com
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/ipv6/route.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 25a055763bd1b..4255f6b920254 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -3687,9 +3687,10 @@ void fib6_nh_release(struct fib6_nh *fib6_nh)
 {
 	struct rt6_exception_bucket *bucket;
 
+	fib6_nh_release_dsts(fib6_nh);
+
 	rcu_read_lock();
 
-	fib6_nh_flush_exceptions(fib6_nh, NULL);
 	bucket = fib6_nh_get_excptn_bucket(fib6_nh, NULL);
 	if (bucket) {
 		rcu_assign_pointer(fib6_nh->rt6i_exception_bucket, NULL);
@@ -3698,7 +3699,6 @@ void fib6_nh_release(struct fib6_nh *fib6_nh)
 
 	rcu_read_unlock();
 
-	fib6_nh_release_dsts(fib6_nh);
 	free_percpu(fib6_nh->rt6i_pcpu);
 
 	fib_nh_common_release(&fib6_nh->nh_common);
@@ -3708,6 +3708,8 @@ void fib6_nh_release_dsts(struct fib6_nh *fib6_nh)
 {
 	int cpu;
 
+	fib6_nh_flush_exceptions(fib6_nh, NULL);
+
 	if (!fib6_nh->rt6i_pcpu)
 		return;
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 523/555] ASoC: SOF: Intel: lnl: Enable offload for UAOL link
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (521 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 522/555] ipv6: Flush exception route while replacing nexthop Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 524/555] wifi: rtw89: modify active scan rule for 6GHz band Greg Kroah-Hartman
                   ` (31 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Peter Ujfalusi, Bard Liao,
	Kai Vehmanen, Mark Brown, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>

commit fdfbd9ff86a145f09978ab49305ed7acfad66a1d upstream.

The handling of UAOL (USB Audio Offload Link) is similar to SSP and DMIC,
it is handled by the DSP firmware.
Set the offload enable for it similar to SSP and DMIC.

Cc: <stable@vger.kernel.org> # 6.12.x
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://patch.msgid.link/20260520150639.25301-3-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
[ Peter: Adjusted to the int returning hdac_bus_eml_enable_offload() as
  commit 978152b2cab5 ("ASoC: SOF: Intel: hda-mlink/lnl: Convert offload
  enable functions to void") is not backported. The helper is renamed from
  hdac_bus_offload_dmic_ssp() to hdac_bus_set_dsp_offload() to match
  upstream, since it now also handles UAOL.
  Firmware built with UAOL support reads the UAOL registers and crashes if
  the host has not granted the DSP access to them. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 sound/soc/sof/intel/lnl.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/sound/soc/sof/intel/lnl.c b/sound/soc/sof/intel/lnl.c
index 3d5a1f8b17e5c..0d5ab01d7555e 100644
--- a/sound/soc/sof/intel/lnl.c
+++ b/sound/soc/sof/intel/lnl.c
@@ -31,8 +31,8 @@ static const struct snd_sof_debugfs_map lnl_dsp_debugfs[] = {
 	{"fw_regs", HDA_DSP_BAR,  MTL_SRAM_WINDOW_OFFSET(0), 0x1000, SOF_DEBUGFS_ACCESS_D0_ONLY},
 };
 
-/* this helps allows the DSP to setup DMIC/SSP */
-static int hdac_bus_offload_dmic_ssp(struct hdac_bus *bus, bool enable)
+/* Configure DSP offload for DMIC/SSP/UAOL */
+static int hdac_bus_set_dsp_offload(struct hdac_bus *bus, bool enable)
 {
 	int ret;
 
@@ -46,6 +46,9 @@ static int hdac_bus_offload_dmic_ssp(struct hdac_bus *bus, bool enable)
 	if (ret < 0)
 		return ret;
 
+	hdac_bus_eml_enable_offload(bus, true,
+				    AZX_REG_ML_LEPTR_ID_INTEL_UAOL, enable);
+
 	return 0;
 }
 
@@ -57,17 +60,17 @@ static int lnl_hda_dsp_probe(struct snd_sof_dev *sdev)
 	if (ret < 0)
 		return ret;
 
-	return hdac_bus_offload_dmic_ssp(sof_to_bus(sdev), true);
+	return hdac_bus_set_dsp_offload(sof_to_bus(sdev), true);
 }
 
 static void lnl_hda_dsp_remove(struct snd_sof_dev *sdev)
 {
 	int ret;
 
-	ret = hdac_bus_offload_dmic_ssp(sof_to_bus(sdev), false);
+	ret = hdac_bus_set_dsp_offload(sof_to_bus(sdev), false);
 	if (ret < 0)
 		dev_warn(sdev->dev,
-			 "Failed to disable offload for DMIC/SSP: %d\n", ret);
+			 "Failed to disable offload for DMIC/SSP/UAOL: %d\n", ret);
 
 	hda_dsp_remove(sdev);
 }
@@ -80,7 +83,7 @@ static int lnl_hda_dsp_resume(struct snd_sof_dev *sdev)
 	if (ret < 0)
 		return ret;
 
-	return hdac_bus_offload_dmic_ssp(sof_to_bus(sdev), true);
+	return hdac_bus_set_dsp_offload(sof_to_bus(sdev), true);
 }
 
 static int lnl_hda_dsp_runtime_resume(struct snd_sof_dev *sdev)
@@ -91,7 +94,7 @@ static int lnl_hda_dsp_runtime_resume(struct snd_sof_dev *sdev)
 	if (ret < 0)
 		return ret;
 
-	return hdac_bus_offload_dmic_ssp(sof_to_bus(sdev), true);
+	return hdac_bus_set_dsp_offload(sof_to_bus(sdev), true);
 }
 
 static int lnl_dsp_post_fw_run(struct snd_sof_dev *sdev)
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 524/555] wifi: rtw89: modify active scan rule for 6GHz band
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (522 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 523/555] ASoC: SOF: Intel: lnl: Enable offload for UAOL link Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 525/555] sched_ext: Enable tick for finite slices on nohz_full Greg Kroah-Hartman
                   ` (30 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Po-Hao Huang, Ping-Ke Shih,
	Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Po-Hao Huang <phhuang@realtek.com>

[ Upstream commit 0788bad5d012b164e5eabf5da206dea4fa67db1c ]

Remove the cancellation of active scan with specific SSID when receiving
beacons/probe responses of that SSID. Per IEEE Std 802.11ax 26.17.2.3.3,
only active scan of direct BSSID should be cancelled. Previously the
cancellation causes hidden AP under same ESS couldn't be found.

Signed-off-by: Po-Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260909070004.35353-5-pkshih@realtek.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/wireless/realtek/rtw89/core.c | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
index 12bb293fafd31..de28ee7b4adb0 100644
--- a/drivers/net/wireless/realtek/rtw89/core.c
+++ b/drivers/net/wireless/realtek/rtw89/core.c
@@ -2022,7 +2022,6 @@ static void rtw89_core_cancel_6ghz_probe_tx(struct rtw89_dev *rtwdev,
 	struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data;
 	struct list_head *pkt_list = rtwdev->scan_info.pkt_list;
 	struct rtw89_pktofld_info *info;
-	const u8 *ies = mgmt->u.beacon.variable, *ssid_ie;
 	bool queue_work = false;
 
 	if (rx_status->band != NL80211_BAND_6GHZ)
@@ -2033,21 +2032,10 @@ static void rtw89_core_cancel_6ghz_probe_tx(struct rtw89_dev *rtwdev,
 		return;
 	}
 
-	ssid_ie = cfg80211_find_ie(WLAN_EID_SSID, ies, skb->len);
-
 	list_for_each_entry(info, &pkt_list[NL80211_BAND_6GHZ], list) {
 		if (ether_addr_equal(info->bssid, mgmt->bssid)) {
 			info->cancel = true;
 			queue_work = true;
-			continue;
-		}
-
-		if (!ssid_ie || ssid_ie[1] != info->ssid_len || info->ssid_len == 0)
-			continue;
-
-		if (memcmp(&ssid_ie[2], info->ssid, info->ssid_len) == 0) {
-			info->cancel = true;
-			queue_work = true;
 		}
 	}
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 525/555] sched_ext: Enable tick for finite slices on nohz_full
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (523 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 524/555] wifi: rtw89: modify active scan rule for 6GHz band Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 526/555] drm/imagination: Set scheduler timeout period higher than Firmware timeout Greg Kroah-Hartman
                   ` (29 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Andrea Righi, Tejun Heo,
	Kuba Piecuch, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Andrea Righi <arighi@nvidia.com>

[ Upstream commit 4ec10f38ff901dc10503d57cbdcf941248419ac1 ]

set_next_task_scx() updates the tick dependency before __schedule()
updates rq->curr. When switching from a non-EXT task, such as idle, to
an EXT task with a finite slice, sched_update_tick_dependency() checks
the outgoing task and can allow the tick to remain stopped.

The dependency can also be lost without a slice-type transition. After a
finite-slice task leaves the CPU idle, the enqueue path can clear the
dependency against the idle rq->curr. SCX_RQ_CAN_STOP_TICK still records
a finite slice, so another finite task skips the transition block and
can run without the ticks needed to expire its slice.

The reverse mismatch can also happen when the last finite-slice EXT task
is dequeued: sub_nr_running() updates the dependency before rq->curr
changes, so the outgoing task state can keep the dependency set after
the CPU goes idle.

Fix this by unconditionally enabling the scheduler tick whenever a
finite-slice EXT task is selected on a nohz_full CPU. Moreover, when the
last runnable EXT task leaves, ignore the outgoing EXT slice state so
the generic scheduler can correctly re-evaluate and clear the tick
dependency.

Fixes: 22a920209ab6 ("sched_ext: Implement tickless support")
Signed-off-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
[ jpiecuch: Adapted path to kernel/sched/ext.c and moved scx_rq_bypassing()
  below the !rq->scx.nr_running check in scx_can_stop_tick(). ]

Signed-off-by: Kuba Piecuch <jpiecuch@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/sched/ext.c | 53 +++++++++++++++++++++++++++++++++-------------
 1 file changed, 38 insertions(+), 15 deletions(-)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 63e83e55d170f..5f5a41f6fed28 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -2980,24 +2980,38 @@ static void set_next_task_scx(struct rq *rq, struct task_struct *p, bool first)
 
 	/*
 	 * @p is getting newly scheduled or got kicked after someone updated its
-	 * slice. Refresh whether tick can be stopped. See scx_can_stop_tick().
+	 * slice. Update SCX_RQ_CAN_STOP_TICK to reflect whether the tick can be
+	 * stopped. See scx_can_stop_tick().
+	 *
+	 * Moreover, refresh the load_avgs just when transitioning in and out of
+	 * nohz. In the future, we might want to add a mechanism to update
+	 * load_avgs periodically on tick-stopped CPUs.
 	 */
-	if ((p->scx.slice == SCX_SLICE_INF) !=
-	    (bool)(rq->scx.flags & SCX_RQ_CAN_STOP_TICK)) {
-		if (p->scx.slice == SCX_SLICE_INF)
+	if (p->scx.slice == SCX_SLICE_INF) {
+		if (!(rq->scx.flags & SCX_RQ_CAN_STOP_TICK)) {
+			/*
+			 * Bypass mode always assigns finite slices, so @p
+			 * can't have an infinite slice while bypassing.
+			 * Therefore, sched_update_tick_dependency() can safely
+			 * evaluate the outgoing task.
+			 */
 			rq->scx.flags |= SCX_RQ_CAN_STOP_TICK;
-		else
-			rq->scx.flags &= ~SCX_RQ_CAN_STOP_TICK;
+			sched_update_tick_dependency(rq);
 
-		sched_update_tick_dependency(rq);
+			update_other_load_avgs(rq);
+		}
+	} else {
+		if (rq->scx.flags & SCX_RQ_CAN_STOP_TICK) {
+			rq->scx.flags &= ~SCX_RQ_CAN_STOP_TICK;
+			update_other_load_avgs(rq);
+		}
 
 		/*
-		 * For now, let's refresh the load_avgs just when transitioning
-		 * in and out of nohz. In the future, we might want to add a
-		 * mechanism which calls the following periodically on
-		 * tick-stopped CPUs.
+		 * @rq still references the outgoing scheduling context. A finite
+		 * slice is sufficient by itself to require the tick.
 		 */
-		update_other_load_avgs(rq);
+		if (tick_nohz_full_cpu(cpu_of(rq)))
+			tick_nohz_dep_set_cpu(cpu_of(rq), TICK_DEP_BIT_SCHED);
 	}
 }
 
@@ -3992,12 +4006,21 @@ bool scx_can_stop_tick(struct rq *rq)
 {
 	struct task_struct *p = rq->curr;
 
-	if (scx_rq_bypassing(rq))
-		return false;
-
 	if (p->sched_class != &ext_sched_class)
 		return true;
 
+	/*
+	 * @rq->curr may still reference an outgoing EXT task after it has been
+	 * dequeued. If no EXT tasks are accounted on @rq, ignore its stale
+	 * slice state. If another task is dispatched from a DSQ,
+	 * set_next_task_scx() will update the dependency for the incoming task.
+	 */
+	if (!rq->scx.nr_running)
+		return true;
+
+	if (scx_rq_bypassing(rq))
+		return false;
+
 	/*
 	 * @rq can dispatch from different DSQs, so we can't tell whether it
 	 * needs the tick or not by looking at nr_running. Allow stopping ticks
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 526/555] drm/imagination: Set scheduler timeout period higher than Firmware timeout
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (524 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 525/555] sched_ext: Enable tick for finite slices on nohz_full Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 527/555] vhost/net: Fix receive queue test in busy poll Greg Kroah-Hartman
                   ` (28 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Brajesh Gupta, Alessio Belle,
	Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Brajesh Gupta <brajesh.gupta@imgtec.com>

[ Upstream commit 2224d6642136767ec01d146d48ffc881b55b32f7 ]

Firmware schedules workloads on the GPU and tracks progress.
It is also responsible for detecting any lockup and triggering recovery.

Update the GPU scheduler timeout to a reasonably high value to avoid
premature timeout at the GPU scheduler end.

Signed-off-by: Brajesh Gupta <brajesh.gupta@imgtec.com>
Reviewed-by: Alessio Belle <alessio.belle@imgtec.com>
Link: https://patch.msgid.link/20260729-sched_timeout-v1-1-4adc801b1997@imgtec.com
Signed-off-by: Alessio Belle <alessio.belle@imgtec.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpu/drm/imagination/pvr_queue.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/imagination/pvr_queue.c b/drivers/gpu/drm/imagination/pvr_queue.c
index b660b85b58fdd..346e9dd7ec5bc 100644
--- a/drivers/gpu/drm/imagination/pvr_queue.c
+++ b/drivers/gpu/drm/imagination/pvr_queue.c
@@ -15,6 +15,7 @@
 #include "pvr_rogue_fwif_client.h"
 
 #define MAX_DEADLINE_MS 30000
+#define SCHED_TIMEOUT_PERIOD (2 * MAX_DEADLINE_MS)
 
 #define CTX_COMPUTE_CCCB_SIZE_LOG2 15
 #define CTX_FRAG_CCCB_SIZE_LOG2 15
@@ -1246,7 +1247,7 @@ struct pvr_queue *pvr_queue_create(struct pvr_context *ctx,
 		.num_rqs = 1,
 		.credit_limit = 64 * 1024,
 		.hang_limit = 1,
-		.timeout = msecs_to_jiffies(500),
+		.timeout = msecs_to_jiffies(SCHED_TIMEOUT_PERIOD),
 		.timeout_wq = pvr_dev->sched_wq,
 		.name = "pvr-queue",
 		.dev = pvr_dev->base.dev,
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 527/555] vhost/net: Fix receive queue test in busy poll
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (525 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 526/555] drm/imagination: Set scheduler timeout period higher than Firmware timeout Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 528/555] i915/vma: use kfree_rcu to make sure vma are freed after a rcu grace period Greg Kroah-Hartman
                   ` (27 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Xu Rao, Eugenio Pérez,
	Willem de Bruijn

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Xu Rao <raoxu@uniontech.com>

commit cdf84b850584574fc81bd80990d3bf1cf81b6a00 upstream.

sock_has_rx_data() returns a positive value when receive data is
available. For sockets without a peek_len() callback, however, its
fallback returns skb_queue_empty(), which has the opposite meaning.

An AF_PACKET SOCK_RAW socket is accepted by get_raw_socket() as a
vhost-net backend, and its socket operations do not provide peek_len().
With busy polling enabled for this backend, an empty receive queue is
treated as ready and a nonempty queue as not ready. This can make
vhost_net_busy_poll() stop polling prematurely or fail to stop for
queued receive data, and invert its receive-side scheduling decision.
TUN and TAP backends provide peek_len() and are unaffected.

Negate skb_queue_empty() so the fallback matches the callback and the
readiness checks in vhost_net_busy_poll().

The issue was found during AI-assisted code review. The helper's
incorrect result was confirmed on x86_64 running 6.6.0-amd64-desktop
using a temporary diagnostic module containing the original and fixed
helpers. An AF_PACKET SOCK_RAW socket, without PACKET_RX_RING, was
bound to loopback in a private network namespace. Across three cycles
of sending and receiving a 60-byte frame, the original helper returned
1 for an empty queue and 0 for a queued frame. The fixed helper returned
0 and 1 respectively, matching socket readability in all nine checks.
This tests helper copies on real sockets, not the running vhost-net
busy-poll path; the vhost-net module was not replaced.

The patched drivers/vhost/net.o was also build-tested on the net tree
with x86_64 GCC 12.3 and W=1 under allmodconfig and allyesconfig.
No end-to-end vhost tests or kernel selftests were run.

Fixes: 1576d9860599 ("tun: switch to use skb array for tx")
Cc: stable@vger.kernel.org
Signed-off-by: Xu Rao <raoxu@uniontech.com>
Acked-by: Eugenio Pérez <eperezma@redhat.com>
Link: https://patch.msgid.link/1B3A1B72438119BC+20261120033824.681219-1-raoxu@uniontech.com
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/vhost/net.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -518,7 +518,7 @@ static int sock_has_rx_data(struct socke
 	if (sock->ops->peek_len)
 		return sock->ops->peek_len(sock);
 
-	return skb_queue_empty(&sock->sk->sk_receive_queue);
+	return !skb_queue_empty(&sock->sk->sk_receive_queue);
 }
 
 static void vhost_net_busy_poll_try_queue(struct vhost_net *net,



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 528/555] i915/vma: use kfree_rcu to make sure vma are freed after a rcu grace period
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (526 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 527/555] vhost/net: Fix receive queue test in busy poll Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 529/555] usb: gadget: f_uac1_legacy: fix double close of the ALSA devices Greg Kroah-Hartman
                   ` (26 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Dave Airlie

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Dave Airlie <airlied@redhat.com>

commit 4cd3c5bdf16789fc8c8736ed1a1a645b8cecb3b6 upstream.

There is a race in the vma lookup and the vma freeing that can race
object close against object execbuffer vma lookups.

execbuffer2 and close on two threads can be raced, so the radix tree
lookup and tryget in eb_lookup_vma can be raced against a freed vma.

The rcu protection in the eb lookup doesn't help because we don't
use rcu around the free path.

This patch adds rcu protection around the vma destruction path.

We could also probably use SLAB_TYPESAFE_BY_RCU but there may be
other submarined vma races in other code that this might not fix,
so let's just force the rcu on free.

Cc: stable@vger.kernel.org
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/i915/i915_vma.c       |    2 +-
 drivers/gpu/drm/i915/i915_vma_types.h |    3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

--- a/drivers/gpu/drm/i915/i915_vma.c
+++ b/drivers/gpu/drm/i915/i915_vma.c
@@ -65,7 +65,7 @@ static struct i915_vma *i915_vma_alloc(v
 
 static void i915_vma_free(struct i915_vma *vma)
 {
-	return kmem_cache_free(slab_vmas, vma);
+	kfree_rcu(vma, rcu);
 }
 
 #if IS_ENABLED(CONFIG_DRM_I915_ERRLOG_GEM) && IS_ENABLED(CONFIG_DRM_DEBUG_MM)
--- a/drivers/gpu/drm/i915/i915_vma_types.h
+++ b/drivers/gpu/drm/i915/i915_vma_types.h
@@ -296,6 +296,9 @@ struct i915_vma {
 
 	struct list_head closed_link;
 
+	/** rcu head for kfree_rcu */
+	struct rcu_head rcu;
+
 	/** The async vma resource. Protected by the vm_mutex */
 	struct i915_vma_resource *resource;
 };



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 529/555] usb: gadget: f_uac1_legacy: fix double close of the ALSA devices
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (527 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 528/555] i915/vma: use kfree_rcu to make sure vma are freed after a rcu grace period Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 530/555] ALSA: firewire-lib: Abort the FCP transaction on a bus reset Greg Kroah-Hartman
                   ` (25 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, stable, syzbot+df868600fe111c5ff79f,
	Vasileios Almpanis

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Vasileios Almpanis <vasilisalmpanis@gmail.com>

commit ba4bbac98e65c6998cac4ea2b63baf2159d00a8c upstream.

f_audio_bind() records that the ALSA files are open in the function
instance flag opts->bound, but keeps the file pointers in the
per-function gaudio card. Its error path calls gaudio_cleanup(), which
closes the files without clearing the filp pointers or opts->bound.
A failed bind does not destroy the usb_function, configfs_composite_bind()
puts it back on cfg->func_list, so the next write to UDC binds the same
f_audio, skips gaudio_setup() because opts->bound is still set, and on
failure closes the files a second time. Dropping the config symlink after
a failed bind closes them again via f_audio_free().

BUG: KASAN: slab-use-after-free in filp_flush+0x31/0x190 fs/open.c:1464
Read of size 8 at addr ffff888045f01990 by task syz-executor659/5617
Call Trace:
 filp_close+0x1d/0x40 fs/open.c:1484
 gaudio_close_snd_dev drivers/usb/gadget/function/u_uac1_legacy.c:263 [inline]
 gaudio_cleanup+0x54/0xf0 drivers/usb/gadget/function/u_uac1_legacy.c:305
 f_audio_bind+0x4a0/0x630 drivers/usb/gadget/function/f_uac1_legacy.c:792
 usb_add_function+0x290/0x930 drivers/usb/gadget/composite.c:333
 configfs_composite_bind+0xde0/0x1410 drivers/usb/gadget/configfs.c:1802
 gadget_bind_driver+0x2ca/0x9e0 drivers/usb/gadget/udc/core.c:1662
 gadget_dev_desc_UDC_store+0x1c9/0x2f0 drivers/usb/gadget/configfs.c:300

Clear filp, substream and card in gaudio_close_snd_dev() so cleanup is
idempotent, and close the devices on the bind error path only if that
bind opened them, resetting opts->bound as well.

Fixes: f3a3406b3f56 ("usb: gadget: f_uac1: convert to new function interface with backward compatibility")
Cc: stable <stable@kernel.org>
Reported-by: syzbot+df868600fe111c5ff79f@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=df868600fe111c5ff79f
Signed-off-by: Vasileios Almpanis <vasilisalmpanis@gmail.com>
Link: https://patch.msgid.link/20260731-alsa-v1-1-95eb93ba32ec@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/usb/gadget/function/f_uac1_legacy.c |    8 +++++++-
 drivers/usb/gadget/function/u_uac1_legacy.c |   17 ++++++++++++++---
 2 files changed, 21 insertions(+), 4 deletions(-)

--- a/drivers/usb/gadget/function/f_uac1_legacy.c
+++ b/drivers/usb/gadget/function/f_uac1_legacy.c
@@ -732,6 +732,7 @@ f_audio_bind(struct usb_configuration *c
 	int			status;
 	struct usb_ep		*ep = NULL;
 	struct f_uac1_legacy_opts	*audio_opts;
+	bool			bound_here = false;
 
 	audio_opts = container_of(f->fi, struct f_uac1_legacy_opts, func_inst);
 	audio->card.gadget = c->cdev->gadget;
@@ -741,6 +742,7 @@ f_audio_bind(struct usb_configuration *c
 		if (status < 0)
 			return status;
 		audio_opts->bound = true;
+		bound_here = true;
 	}
 	us = usb_gstrings_attach(cdev, uac1_strings, ARRAY_SIZE(strings_uac1));
 	if (IS_ERR(us))
@@ -789,7 +791,11 @@ f_audio_bind(struct usb_configuration *c
 	return 0;
 
 fail:
-	gaudio_cleanup(&audio->card);
+	/* Only tear down the ALSA devices if this bind opened them; the */
+	if (bound_here) {
+		gaudio_cleanup(&audio->card);
+		audio_opts->bound = false;
+	}
 	return status;
 }
 
--- a/drivers/usb/gadget/function/u_uac1_legacy.c
+++ b/drivers/usb/gadget/function/u_uac1_legacy.c
@@ -259,18 +259,29 @@ static int gaudio_close_snd_dev(struct g
 
 	/* Close control device */
 	snd = &gau->control;
-	if (snd->filp)
+	if (snd->filp) {
 		filp_close(snd->filp, NULL);
+		snd->filp = NULL;
+		snd->card = NULL;
+	}
 
 	/* Close PCM playback device and setup substream */
 	snd = &gau->playback;
-	if (snd->filp)
+	if (snd->filp) {
 		filp_close(snd->filp, NULL);
+		snd->filp = NULL;
+		snd->substream = NULL;
+		snd->card = NULL;
+	}
 
 	/* Close PCM capture device and setup substream */
 	snd = &gau->capture;
-	if (snd->filp)
+	if (snd->filp) {
 		filp_close(snd->filp, NULL);
+		snd->filp = NULL;
+		snd->substream = NULL;
+		snd->card = NULL;
+	}
 
 	return 0;
 }



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 530/555] ALSA: firewire-lib: Abort the FCP transaction on a bus reset
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (528 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 529/555] usb: gadget: f_uac1_legacy: fix double close of the ALSA devices Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 531/555] ALSA: fireworks: Abort the " Greg Kroah-Hartman
                   ` (24 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Takashi Sakamoto, Kaixuan Li,
	Suyuan Wang, Takashi Iwai

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Suyuan Wang <stevewong@hust.edu.cn>

commit 5e8802bf480da76634a8ac929c29af7b7acde615 upstream.

When fcp_bus_reset() marks a transaction as STATE_BUS_RESET,
fcp_avc_transaction() sleeps and resends the command, but leaves the
state as it is. The response to the resent command is then ignored, and
the next wait returns at once, so the loop keeps resending the command
without a retry limit until sending fails.

The AV/C Digital Interface Command Set General Specification 4.2 says
that a target which detects a bus reset discards any AV/C transaction
in progress without returning a response. So instead of resending, end
the transaction on a bus reset and return -EAGAIN, so that the caller
can start the sequence again. ERROR_DELAY_MS and <linux/delay.h> have no
users left after this, so drop them.

Found with a static analysis tool and checked by hand.

Suggested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Fixes: 31ef9134eb52 ("ALSA: add LaCie FireWire Speakers/Griffin FireWave Surround driver")
Cc: stable@vger.kernel.org
Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20261122-firewire-busreset-v2-1-e104d785c8a1@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 sound/firewire/fcp.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

--- a/sound/firewire/fcp.c
+++ b/sound/firewire/fcp.c
@@ -14,7 +14,6 @@
 #include <linux/sched.h>
 #include <linux/spinlock.h>
 #include <linux/wait.h>
-#include <linux/delay.h>
 #include "fcp.h"
 #include "lib.h"
 #include "amdtp-stream.h"
@@ -22,7 +21,6 @@
 #define CTS_AVC 0x00
 
 #define ERROR_RETRIES	3
-#define ERROR_DELAY_MS	5
 #define FCP_TIMEOUT_MS	125
 
 int avc_general_set_sig_fmt(struct fw_unit *unit, unsigned int rate,
@@ -272,7 +270,8 @@ deferred:
 			ret = t.response_size;
 			break;
 		} else if (t.state == STATE_BUS_RESET) {
-			msleep(ERROR_DELAY_MS);
+			ret = -EAGAIN;
+			break;
 		} else if (++tries >= ERROR_RETRIES) {
 			dev_err(&t.unit->device, "FCP command timed out\n");
 			ret = -EIO;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 531/555] ALSA: fireworks: Abort the transaction on a bus reset
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (529 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 530/555] ALSA: firewire-lib: Abort the FCP transaction on a bus reset Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 532/555] ALSA: oss: Fix deadlock at unregistering (again) Greg Kroah-Hartman
                   ` (23 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Takashi Sakamoto, Kaixuan Li,
	Suyuan Wang, Takashi Iwai

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Suyuan Wang <stevewong@hust.edu.cn>

commit 890eff85e8a01012e1d3b6c54cba787416331381 upstream.

When snd_efw_transaction_bus_reset() marks a transaction as
STATE_BUS_RESET, snd_efw_transaction_run() sleeps and resends the
command, but leaves the state as it is. The response to the resent
command is then ignored, and the next wait returns at once, so the loop
keeps resending the command without a retry limit until sending fails.

Fireworks devices also accept AV/C commands, and the AV/C general
specification says that a bus reset discards any transaction in
progress. Do the same as for FCP: end the transaction on a bus reset and
return -EAGAIN. ERROR_DELAY_MS has no users left, so drop it.

Found with a static analysis tool and checked by hand.

Suggested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Fixes: bde8a8f23bbe ("ALSA: fireworks: Add transaction and some commands")
Cc: stable@vger.kernel.org
Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20261122-firewire-busreset-v2-2-e104d785c8a1@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 sound/firewire/fireworks/fireworks_transaction.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/sound/firewire/fireworks/fireworks_transaction.c
+++ b/sound/firewire/fireworks/fireworks_transaction.c
@@ -34,7 +34,6 @@
 #define MEMORY_SPACE_EFW_RESPONSE	0xecc080000000ULL
 
 #define ERROR_RETRIES 3
-#define ERROR_DELAY_MS 5
 #define EFC_TIMEOUT_MS 125
 
 static DEFINE_SPINLOCK(instances_lock);
@@ -99,7 +98,8 @@ int snd_efw_transaction_run(struct fw_un
 			ret = t.size;
 			break;
 		} else if (t.state == STATE_BUS_RESET) {
-			msleep(ERROR_DELAY_MS);
+			ret = -EAGAIN;
+			break;
 		} else if (++tries >= ERROR_RETRIES) {
 			dev_err(&t.unit->device, "EFW transaction timed out\n");
 			ret = -EIO;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 532/555] ALSA: oss: Fix deadlock at unregistering (again)
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (530 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 531/555] ALSA: fireworks: Abort the " Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 533/555] KEYS: Fix asym key overflow in keyctl_pkey_verify() Greg Kroah-Hartman
                   ` (22 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Takashi Iwai

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Takashi Iwai <tiwai@suse.de>

commit dda2d9cd1fcd9ea1e4a93657e7386fde37d7e2ba upstream.

The recent code refactoring using guard() re-introduced a potential
deadlock at unregistering OSS device that had been fixed onceby the
commit 97d917879d7f ("ALSA: oss: Fix potential deadlock at
unregistration").  The unregister_sound_special() call must be done
outside the sound_oss_mutex.

Fix the regression by changing guard() with scoped_guard() to limit
the range.

Fixes: 742ecf3ce1ac ("ALSA: core: Use guard() for locking")
Cc: <stable@vger.kernel.org>
Link: https://patch.msgid.link/20261125135453.2088984-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 sound/core/sound_oss.c |   35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

--- a/sound/core/sound_oss.c
+++ b/sound/core/sound_oss.c
@@ -153,24 +153,25 @@ int snd_unregister_oss_device(int type,
 		return 0;
 	if (minor < 0)
 		return minor;
-	guard(mutex)(&sound_oss_mutex);
-	mptr = snd_oss_minors[minor];
-	if (mptr == NULL)
-		return -ENOENT;
-	switch (SNDRV_MINOR_OSS_DEVICE(minor)) {
-	case SNDRV_MINOR_OSS_PCM:
-		track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_AUDIO);
-		break;
-	case SNDRV_MINOR_OSS_MIDI:
-		track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_DMMIDI);
-		break;
-	case SNDRV_MINOR_OSS_MIDI1:
-		track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_DMMIDI1);
-		break;
+	scoped_guard(mutex, &sound_oss_mutex) {
+		mptr = snd_oss_minors[minor];
+		if (mptr == NULL)
+			return -ENOENT;
+		switch (SNDRV_MINOR_OSS_DEVICE(minor)) {
+		case SNDRV_MINOR_OSS_PCM:
+			track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_AUDIO);
+			break;
+		case SNDRV_MINOR_OSS_MIDI:
+			track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_DMMIDI);
+			break;
+		case SNDRV_MINOR_OSS_MIDI1:
+			track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_DMMIDI1);
+			break;
+		}
+		if (track2 >= 0)
+			snd_oss_minors[track2] = NULL;
+		snd_oss_minors[minor] = NULL;
 	}
-	if (track2 >= 0)
-		snd_oss_minors[track2] = NULL;
-	snd_oss_minors[minor] = NULL;
 
 	/* call unregister_sound_special() outside sound_oss_mutex;
 	 * otherwise may deadlock, as it can trigger the release of a card



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 533/555] KEYS: Fix asym key overflow in keyctl_pkey_verify()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (531 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 532/555] ALSA: oss: Fix deadlock at unregistering (again) Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 534/555] KEYS: Fix crash on big_key read Greg Kroah-Hartman
                   ` (21 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Jarkko Sakkinen

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jarkko Sakkinen <jarkko@kernel.org>

commit 94cd215923495a0e1031b86dc7d246ef3c33cc73 upstream.

While verifying a variable-length signature shorter than info.max_sig_size,
memdup_user() reads past the end of the caller's _in2 and passes trailing
bytes to ->asym_verify_signature().

Set params->in2_len to uparams.in2_len in the KEYCTL_PKEY_VERIFY case.

Cc: stable@vger.kernel.org # v7.2+
Closes: https://sashiko.dev/#/bug/linux-dd9ad2ca-a846-4d0d-89d6-aa262ffd40f1
Fixes: cb481e59ea6c ("KEYS: fix overflow in keyctl_pkey_params_get_2()")
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 security/keys/keyctl_pkey.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/security/keys/keyctl_pkey.c
+++ b/security/keys/keyctl_pkey.c
@@ -175,7 +175,7 @@ static int keyctl_pkey_params_get_2(cons
 			goto out_up_key_sem;
 		}
 
-		params->out_len = info.max_sig_size;
+		params->in2_len = uparams.in2_len;
 		break;
 	default:
 		ret = -EOPNOTSUPP;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 534/555] KEYS: Fix crash on big_key read
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (532 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 533/555] KEYS: Fix asym key overflow in keyctl_pkey_verify() Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 535/555] KEYS: Fix userspace buffer overflow in keyctl_pkey_e_d_s() Greg Kroah-Hartman
                   ` (20 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Henry Martin, Jarkko Sakkinen,
	Guicai Ma

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Henry Martin <bsdhenrymartin@gmail.com>

commit 1bcff832c48d83c5132662bec83bda37f566d8a2 upstream.

big_key_update() reserves quota with the raw payload length and then
destroys the old payload before instantiating the new one.  For a payload
of N < 16 bytes that reserve releases 16-N bytes, so the reserve of 16
done by generic_key_instantiate() charges them again and can fail with
-EDQUOT once the payload is already destroyed.  big_key_destroy() keeps
payload->length but clears path and data, so the key stays positive with
a stale length that KEYCTL_READ and KEYCTL_REVOKE then follow:

kernel BUG at fs/open.c:1145!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI
RIP: 0010:dentry_open+0x7b/0x90
 big_key_read+0x141/0x280

Instantiate the new payload first and destroy the old one only on success;
a positive key's reservation is already 16 bytes, so it cannot fail.

This issue was discovered by Tencent CodeBuddy Security.

Cc: stable@vger.kernel.org
Fixes: b6f61c314649 ("keys: Implement update for the big_key type")
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Reviewed-by: Guicai Ma <maguicai@kylinos.cn>
Tested-by: Guicai Ma <maguicai@kylinos.cn>
Link: https://lore.kernel.org/r/20261124025759.39344-1-bsdhenrymartin@gmail.com
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 security/keys/big_key.c |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

--- a/security/keys/big_key.c
+++ b/security/keys/big_key.c
@@ -193,16 +193,24 @@ void big_key_destroy(struct key *key)
  */
 int big_key_update(struct key *key, struct key_preparsed_payload *prep)
 {
+	struct big_key_payload old = { };
+	bool positive = key_is_positive(key);
 	int ret;
 
-	ret = key_payload_reserve(key, prep->datalen);
+	if (positive)
+		old = *to_big_key_payload(key->payload);
+
+	ret = generic_key_instantiate(key, prep);
 	if (ret < 0)
 		return ret;
 
-	if (key_is_positive(key))
-		big_key_destroy(key);
+	if (positive) {
+		if (old.length > BIG_KEY_FILE_THRESHOLD)
+			path_put(&old.path);
+		kfree_sensitive(old.data);
+	}
 
-	return generic_key_instantiate(key, prep);
+	return 0;
 }
 
 /*



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 535/555] KEYS: Fix userspace buffer overflow in keyctl_pkey_e_d_s()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (533 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 534/555] KEYS: Fix crash on big_key read Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 536/555] KEYS: serialise key instantiation against keyctl_chown_key() Greg Kroah-Hartman
                   ` (19 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Guicai Ma, Jarkko Sakkinen

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Guicai Ma <maguicai@kylinos.cn>

commit 484dc27f031229b374446cf038fa9c7a84d0f725 upstream.

Commit cb481e59ea6c ("KEYS: fix overflow in keyctl_pkey_params_get_2()")
changed keyctl_pkey_params_get_2() to set params->out_len to the maximum
output size of the operation instead of uparams.out_len, so that the
kernel buffer allocated in keyctl_pkey_e_d_s() is large enough.

Because uparams.out_len is no longer kept, keyctl_pkey_e_d_s() copies
ret bytes to _out without checking whether the result fits in the
caller's buffer. If a smaller out_len was passed, copy_to_user() writes
past the end of _out instead of failing with -EOVERFLOW.

uparams.out_len cannot simply be required to be at least the maximum
output size in keyctl_pkey_params_get_2(), since KEYCTL_PKEY_DECRYPT
with enc=pkcs1 can return a plaintext shorter than max_dec_size into a
matching smaller buffer.

Pass uparams.out_len back to keyctl_pkey_e_d_s() and return -EOVERFLOW
before copy_to_user() if ret exceeds it.

Cc: stable@vger.kernel.org # v7.2+
Fixes: cb481e59ea6c ("KEYS: fix overflow in keyctl_pkey_params_get_2()")
Signed-off-by: Guicai Ma <maguicai@kylinos.cn>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 security/keys/keyctl_pkey.c |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

--- a/security/keys/keyctl_pkey.c
+++ b/security/keys/keyctl_pkey.c
@@ -113,7 +113,8 @@ static int keyctl_pkey_params_get(key_se
 static int keyctl_pkey_params_get_2(const struct keyctl_pkey_params __user *_params,
 				    const char __user *_info,
 				    int op,
-				    struct kernel_pkey_params *params)
+				    struct kernel_pkey_params *params,
+				    u32 *user_out_len)
 {
 	struct keyctl_pkey_params uparams;
 	struct kernel_pkey_query info;
@@ -183,6 +184,8 @@ static int keyctl_pkey_params_get_2(cons
 	}
 
 	params->in_len  = uparams.in_len;
+	if (user_out_len)
+		*user_out_len = uparams.out_len;
 
 	switch (op) {
 	case KEYCTL_PKEY_VERIFY:
@@ -264,10 +267,12 @@ long keyctl_pkey_e_d_s(int op,
 		       void __user *_out)
 {
 	struct kernel_pkey_params params;
+	u32 user_out_len;
 	void *in, *out;
 	long ret;
 
-	ret = keyctl_pkey_params_get_2(_params, _info, op, &params);
+	ret = keyctl_pkey_params_get_2(_params, _info, op, &params,
+				       &user_out_len);
 	if (ret < 0)
 		goto error_params;
 
@@ -310,6 +315,10 @@ out_up_key_sem:
 	if (ret < 0)
 		goto error_out;
 
+	if (ret > user_out_len) {
+		ret = -EOVERFLOW;
+		goto error_out;
+	}
 	if (copy_to_user(_out, out, ret) != 0)
 		ret = -EFAULT;
 
@@ -349,7 +358,7 @@ long keyctl_pkey_verify(const struct key
 	long ret;
 
 	ret = keyctl_pkey_params_get_2(_params, _info, KEYCTL_PKEY_VERIFY,
-				       &params);
+				       &params, NULL);
 	if (ret < 0)
 		goto out_free_params;
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 536/555] KEYS: serialise key instantiation against keyctl_chown_key()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (534 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 535/555] KEYS: Fix userspace buffer overflow in keyctl_pkey_e_d_s() Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 537/555] KEYS: trusted: Update static calls before init Greg Kroah-Hartman
                   ` (18 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Sinan Turunc, Jarkko Sakkinen

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Sinan Turunc <enscrpt@pm.me>

commit 899af9ffd2671351e5402d572934dd59b5e91ae5 upstream.

keyctl_chown_key() looks up the target key by calling lookup_user_key()
with the KEY_LOOKUP_PARTIAL flag. That flag lets a caller with
CAP_SYS_ADMIN change the UID of an uninstantiated key during construction.
When the UID changes, keyctl_chown_key() replaces key->user under key->sem
and drops the old reference with key_user_put().

__key_instantiate_and_link() and key_reject_and_link() hold
key_construction_mutex during instantiation, but neither function takes
key->sem. Both functions increment key->user->nikeys, and
__key_instantiate_and_link() also calls key->type->instantiate() without
holding key->sem. When a key is in quota and its size changes,
key_payload_reserve() reads key->user seven times without key->sem. Those
reads include spin_lock_irqsave(&key->user->lock, flags) at the start and
spin_unlock_irqrestore(&key->user->lock, flags) at the end.

If keyctl_chown_key() swaps key->user between those two calls,
key_payload_reserve() unlocks the new owner's spinlock and leaves the old
spinlock held. By source inspection, key_user_put() can also kfree() the
old struct key_user while instantiation still dereferences it. That struct
key_user use-after-free was found by reading the code and did not trigger
during our KASAN runs.

  =====================================
  WARNING: bad unlock balance detected!
  7.4.0-rc2-g23c62304dde2 #3 Not tainted
  -------------------------------------
  request-key/163 is trying to release lock (&candidate->lock) at:
  [<ffffffff82698fff>] key_payload_reserve+0x29f/0x370
  but there are no more locks to release!

  other info that might help us debug this:
  locks held by request-key/163: 2, on CPU#3:
   #0: ffffffff871c10a0 (key_construction_mutex){+.+.}-{4:4}, at: __key_instantiate_and_link+0x38/0x370
   #1: ffff88800de4a8b8 (&candidate->lock){..-.}-{3:3}, at: key_payload_reserve+0x160/0x370

  Call Trace:
   lock_release+0x286/0x2e0
   _raw_spin_unlock_irqrestore+0x1a/0x50
   key_payload_reserve+0x29f/0x370
   generic_key_instantiate+0x42/0x230
   __key_instantiate_and_link+0xd7/0x370
   key_instantiate_and_link+0x40d/0x4b0
   keyctl_instantiate_key_common+0x2d2/0x450
   keyctl_instantiate_key+0x167/0x180
   __do_sys_keyctl+0x391/0x550

Take key->sem for write with down_write_nested(&key->sem, 2) inside
key_construction_mutex in __key_instantiate_and_link() and
key_reject_and_link().

Fixes: 5801649d8b83 ("[PATCH] keys: let keyctl_chown() change a key's owner")
Cc: stable@vger.kernel.org
Signed-off-by: Sinan Turunc <enscrpt@pm.me>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Link: https://lore.kernel.org/r/20261121111246.3478-1-enscrpt@pm.me
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 security/keys/key.c |    4 ++++
 1 file changed, 4 insertions(+)

--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -440,6 +440,7 @@ static int __key_instantiate_and_link(st
 	ret = -EBUSY;
 
 	mutex_lock(&key_construction_mutex);
+	down_write_nested(&key->sem, 2);
 
 	/* can't instantiate twice */
 	if (key->state == KEY_IS_UNINSTANTIATED) {
@@ -472,6 +473,7 @@ static int __key_instantiate_and_link(st
 		}
 	}
 
+	up_write(&key->sem);
 	mutex_unlock(&key_construction_mutex);
 
 	/* wake up anyone waiting for a key to be constructed */
@@ -608,6 +610,7 @@ int key_reject_and_link(struct key *key,
 	}
 
 	mutex_lock(&key_construction_mutex);
+	down_write_nested(&key->sem, 2);
 
 	/* can't instantiate twice */
 	if (key->state == KEY_IS_UNINSTANTIATED) {
@@ -631,6 +634,7 @@ int key_reject_and_link(struct key *key,
 			key_invalidate(authkey);
 	}
 
+	up_write(&key->sem);
 	mutex_unlock(&key_construction_mutex);
 
 	if (keyring && link_ret == 0)



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 537/555] KEYS: trusted: Update static calls before init
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (535 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 536/555] KEYS: serialise key instantiation against keyctl_chown_key() Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 538/555] KEYS: Use kfree_sensitive() in keyctl_pkey_e_d_s() Greg Kroah-Hartman
                   ` (17 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Jarkko Sakkinen

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jarkko Sakkinen <jarkko@kernel.org>

commit f8b462c497549e9991299156ed0e019eae8524f1 upstream.

Given that the static calls are updated only after ->init() returns, an
added trusted key can race with the callback initializations. This can
ultimately lead into null dereference as static_call() is used unchecked.

Address the bug by updating the static calls before invoking ->init(), and
roll back on failure.

Cc: stable@vger.kernel.org # v5.15+
Fixes: 31de287345f4 ("KEYS: trusted: Rollback init_trusted() consistently")
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 security/keys/trusted-keys/trusted_core.c |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

--- a/security/keys/trusted-keys/trusted_core.c
+++ b/security/keys/trusted-keys/trusted_core.c
@@ -362,14 +362,19 @@ static int __init init_trusted(void)
 		if (!get_random)
 			get_random = kernel_get_random;
 
+		static_call_update(trusted_key_seal, trusted_key_sources[i].ops->seal);
+		static_call_update(trusted_key_unseal, trusted_key_sources[i].ops->unseal);
+		static_call_update(trusted_key_get_random, get_random);
+		migratable = trusted_key_sources[i].ops->migratable;
+
 		ret = trusted_key_sources[i].ops->init();
 		if (!ret) {
-			static_call_update(trusted_key_seal, trusted_key_sources[i].ops->seal);
-			static_call_update(trusted_key_unseal, trusted_key_sources[i].ops->unseal);
-			static_call_update(trusted_key_get_random, get_random);
-
 			trusted_key_exit = trusted_key_sources[i].ops->exit;
-			migratable = trusted_key_sources[i].ops->migratable;
+		} else {
+			static_call_update(trusted_key_seal, NULL);
+			static_call_update(trusted_key_unseal, NULL);
+			static_call_update(trusted_key_get_random, NULL);
+			migratable = 0;
 		}
 
 		if (!ret || ret != -ENODEV)



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 538/555] KEYS: Use kfree_sensitive() in keyctl_pkey_e_d_s()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (536 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 537/555] KEYS: trusted: Update static calls before init Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 539/555] ext4: fix OOB memmove in ext4_xattr_set_entry Greg Kroah-Hartman
                   ` (16 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Guicai Ma, Jarkko Sakkinen

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Guicai Ma <maguicai@kylinos.cn>

commit f779bd424bf27e17cee57c94f068328be29f3662 upstream.

keyctl_pkey_e_d_s() frees the temporary 'in' and 'out' buffers with
kfree(). For encrypt, decrypt and sign operations these buffers hold
plaintext or other sensitive data.

Free them with kfree_sensitive() instead.

Closes: https://sashiko.dev/#/bug/linux-4199b169-0b8d-4055-9a71-6b5b79e38eb3
Fixes: 00d60fd3b932 ("KEYS: Provide keyctls to drive the new key type ops for asymmetric keys [ver #2]")
Cc: stable@vger.kernel.org
Signed-off-by: Guicai Ma <maguicai@kylinos.cn>
Link: https://lore.kernel.org/r/20261124052849.940005-1-maguicai@kylinos.cn
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 security/keys/keyctl_pkey.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/security/keys/keyctl_pkey.c
+++ b/security/keys/keyctl_pkey.c
@@ -323,9 +323,9 @@ out_up_key_sem:
 		ret = -EFAULT;
 
 error_out:
-	kfree(out);
+	kfree_sensitive(out);
 error_in:
-	kfree(in);
+	kfree_sensitive(in);
 error_params:
 	keyctl_pkey_params_free(&params);
 	return ret;



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 539/555] ext4: fix OOB memmove in ext4_xattr_set_entry
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (537 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 538/555] KEYS: Use kfree_sensitive() in keyctl_pkey_e_d_s() Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 540/555] xfrm: interface: drop non-IP packets before pskb_inet_may_pull() Greg Kroah-Hartman
                   ` (15 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Zhao Gongyi, Theodore Tso

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Zhao Gongyi <zhaogongyi@bytedance.com>

commit e290c77088e6f829f7d1d88c915f2a2fb22241e6 upstream.

A corrupted filesystem can leave an inode marked as having inline data
while the system.data xattr is missing. ext4_destroy_inline_data_nolock()
then asks ext4_xattr_set_entry() to remove an entry even though
ext4_xattr_ibody_find() left the search state at the insertion position.

In the syzkaller reproducer, the old xattr value offset is smaller than
min_offs. ext4_xattr_set_entry() then computes val - first_val for
memmove(), the length wraps to a huge size_t, and memmove() can run out of
the xattr buffer. This results in an out-of-bounds memmove and a kernel
page fault.

A crafted corrupted ext4 image can trigger this while inline data is being
converted out of the inode. Treat the inconsistent inline/xattr state as
filesystem corruption before updating the xattr entry.

The issue was found by syzkaller and reproduced with the generated C
reproducer. The crash signature is:

  BUG: unable to handle page fault for address: ffff8880074cf000
  RIP: 0010:memmove+0x28/0x1b0
  Call Trace:
   ext4_xattr_set_entry+0xe2f/0x1e90 fs/ext4/xattr.c:1761
   ext4_xattr_ibody_set+0x3d6/0x5d0 fs/ext4/xattr.c:2268
   ext4_destroy_inline_data_nolock+0x288/0x5b0 fs/ext4/inline.c:467
   ext4_convert_inline_data_nolock+0x178/0xe80 fs/ext4/inline.c:1222
   ext4_convert_inline_data+0x52a/0x610 fs/ext4/inline.c:2083
   ext4_fallocate+0x1a0/0x3ba0 fs/ext4/extents.c:4752

Reject the missing system.data xattr before destroying inline data, and
validate the old value offset before ext4_xattr_set_entry() reaches the
memmove().

The crash was reproduced on unpatched 7.3.0-rc3 and 6.6.122 kernels. With
this fix applied to both versions, the same syzkaller C reproducer ran for
120 seconds without triggering KASAN, Oops, a memmove fault, or panic.

Fixes: 67cf5b09a46f ("ext4: add the basic function for inline data support")
Cc: stable@vger.kernel.org # v3.8+
Signed-off-by: Zhao Gongyi <zhaogongyi@bytedance.com>
Link: https://patch.msgid.link/20260918101249.43643-1-zhaogongyi@bytedance.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/ext4/inline.c |    6 ++++++
 fs/ext4/xattr.c  |   12 ++++++++++++
 2 files changed, 18 insertions(+)

--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -457,6 +457,12 @@ static int ext4_destroy_inline_data_nolo
 	error = ext4_xattr_ibody_find(inode, &i, &is);
 	if (error)
 		goto out;
+	if (is.s.not_found) {
+		EXT4_ERROR_INODE(inode,
+				 "corrupted inline data without system.data xattr");
+		error = -EFSCORRUPTED;
+		goto out;
+	}
 
 	BUFFER_TRACE(is.iloc.bh, "get_write_access");
 	error = ext4_journal_get_write_access(handle, inode->i_sb, is.iloc.bh,
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1708,6 +1708,18 @@ static int ext4_xattr_set_entry(struct e
 		}
 	}
 
+	if (!s->not_found && here->e_value_size && !here->e_value_inum) {
+		size_t offs = le16_to_cpu(here->e_value_offs);
+
+		if (offs < min_offs) {
+			EXT4_ERROR_INODE(inode,
+					 "corrupted xattr: value offset %zu < min_offs %zu",
+					 offs, min_offs);
+			ret = -EFSCORRUPTED;
+			goto out;
+		}
+	}
+
 	/*
 	 * Getting access to old and new ea inodes is subject to failures.
 	 * Finish that work before doing any modifications to the xattr data.



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 540/555] xfrm: interface: drop non-IP packets before pskb_inet_may_pull()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (538 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 539/555] ext4: fix OOB memmove in ext4_xattr_set_entry Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 541/555] net: prevent receive header offset overflow during decapsulation Greg Kroah-Hartman
                   ` (14 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, syzbot+d29af9ef5c96a3f5e96c,
	Shuai Liu, Steffen Klassert, Paolo Abeni

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Shuai Liu <847807867@qq.com>

commit e509726660dd06ce107437aecf7c106c9d3fc1e7 upstream.

AF_XDP sockets bound to an xfrm interface submit skbs with
skb->protocol unset (0) and skb->network_header still 0 from the
__alloc_skb() zero-initialization; skb_reserve() only moves data
NET_SKB_PAD bytes into the headroom.

Since commit 86de3a1118a16 ("xfrm: interface: validate the IP header
on xmit"), xfrmi_xmit() calls pskb_inet_may_pull() unconditionally.
For such a skb, pskb_inet_may_pull_reason() selects nhlen = 0 for the
unknown protocol and pskb_may_pull_reason() receives
len = skb_network_offset(skb) = network_header - data = -64, which as
unsigned int exceeds INT_MAX and trips the
DEBUG_NET_WARN_ON_ONCE(len > INT_MAX) in pskb_may_pull_reason():

  WARNING: ./include/linux/skbuff.h:2856 at pskb_may_pull_reason [inline]
  WARNING: ./include/linux/skbuff.h:3286 at pskb_network_may_pull_reason [inline]
  WARNING: ./include/net/ip_tunnels.h:483 at pskb_inet_may_pull_reason [inline]
  WARNING: ./include/net/ip_tunnels.h:488 at pskb_inet_may_pull [inline]
  WARNING: ./include/net/ip_tunnels.h:488 at xfrmi_xmit+0x1844/0x1eb0
    net/xfrm/xfrm_interface_core.c:534
  RIP: 0010:pskb_may_pull_reason include/linux/skbuff.h:2856 [inline]
  Call Trace:
   __dev_direct_xmit+0x4b6/0x730 net/core/dev.c:5164
   __xsk_generic_xmit net/xdp/xsk.c:1288 [inline]
   xsk_generic_xmit+0x27d8/0x47a0 net/xdp/xsk.c:1344
   xsk_poll+0x326/0x670 net/xdp/xsk.c:1472

The packet is dropped by the pull returning PKT_TOO_SMALL and hitting
the default case afterwards anyway, so the only visible effect is the
warning; reject unknown protocols before the pull to restore the
pre-86de3a1118a16 behavior of dropping them silently via the switch
default.

Reported-by: syzbot+d29af9ef5c96a3f5e96c@syzkaller.appspotmail.com
Closes: https://syzbot.org/bug?extid=d29af9ef5c96a3f5e96c
Fixes: 86de3a1118a16 ("xfrm: interface: validate the IP header on xmit")
Cc: stable@vger.kernel.org
Signed-off-by: Shuai Liu <847807867@qq.com>
Acked-by: Steffen Klassert <steffen.klassert@secunet.com>
Link: https://patch.msgid.link/tencent_46F20906773869221623F9FA26275C133107@qq.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/xfrm/xfrm_interface_core.c |    8 ++++++++
 1 file changed, 8 insertions(+)

--- a/net/xfrm/xfrm_interface_core.c
+++ b/net/xfrm/xfrm_interface_core.c
@@ -532,6 +532,14 @@ static netdev_tx_t xfrmi_xmit(struct sk_
 
 	memset(&fl, 0, sizeof(fl));
 
+	switch (skb->protocol) {
+	case htons(ETH_P_IPV6):
+	case htons(ETH_P_IP):
+		break;
+	default:
+		goto tx_err;
+	}
+
 	if (!pskb_inet_may_pull(skb))
 		goto tx_err;
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 541/555] net: prevent receive header offset overflow during decapsulation
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (539 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 540/555] xfrm: interface: drop non-IP packets before pskb_inet_may_pull() Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 542/555] scsi: target: iscsi: reject invalid size Extended CDB AHS Greg Kroah-Hartman
                   ` (13 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, stable, Eric Dumazet, Chris J Arges,
	Ido Schimmel, Paolo Abeni, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Chris J Arges <carges@cloudflare.com>

[ Upstream commit b10c986f1769287270de248548476f6dc2275d59 ]

Repeated decapsulation can leave skb->data far from skb->head while
the remaining packet data is still valid. Since the skb header positions
are 16-bit offsets, a later header update can truncate and make header
access use unrelated bytes and eventually crash.

Limit receive headroom to 32 KiB. This is well beyond the headroom of
normal packets while allowing the networking stack to pull enough
headers in a single pass without overflowing 16-bit header offsets.

Tunnel decapsulation re-enters __netif_receive_skb_core(), so its check
protects nested IPIP and GRE. FOU and GUE bypass receive core, so check
their IPv4 and IPv6 resubmission paths too. Together, these checks
prevent 16-bit header-offset truncation in cases of repeated
decapsulation.

Report these rejections with the SKB_RX_HEADROOM drop reason.

Fixes: 1a37e412a022 ("net: Use 16bits for *_headers fields of struct skbuff")
Cc: stable@kernel.org
Suggested-by: Eric Dumazet <edumazet@kernel.org>
Signed-off-by: Chris J Arges <carges@cloudflare.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20261118-prevent_rx_header_offset_overflow-v1-1-92a5be55f994@cloudflare.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
[ carges: add drop_reason variable to dev.c and adjust dropreason-core.h ]
Signed-off-by: Chris J Arges <carges@cloudflare.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/linux/skbuff.h        | 1 +
 include/net/dropreason-core.h | 6 ++++++
 net/core/dev.c                | 7 ++++++-
 net/ipv4/ip_input.c           | 6 ++++++
 net/ipv6/ip6_input.c          | 4 ++++
 5 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 7df799b751ceb..d1831da744815 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -267,6 +267,7 @@
 	SKB_WITH_OVERHEAD((PAGE_SIZE << (ORDER)) - (X))
 #define SKB_MAX_HEAD(X)		(SKB_MAX_ORDER((X), 0))
 #define SKB_MAX_ALLOC		(SKB_MAX_ORDER(0, 2))
+#define SKB_MAX_RX_HEADROOM	(U16_MAX / 2)
 
 /* return minimum truesize of one skb containing X bytes of data */
 #define SKB_TRUESIZE(X) ((X) +						\
diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h
index 31e0cc1b64ff1..ac4bf047d7b92 100644
--- a/include/net/dropreason-core.h
+++ b/include/net/dropreason-core.h
@@ -106,6 +106,7 @@
 	FN(IP_TUNNEL_ECN)		\
 	FN(TUNNEL_TXINFO)		\
 	FN(LOCAL_MAC)			\
+	FN(SKB_RX_HEADROOM)		\
 	FNe(MAX)
 
 /**
@@ -488,6 +489,11 @@ enum skb_drop_reason {
 	 * the MAC address of the local netdev.
 	 */
 	SKB_DROP_REASON_LOCAL_MAC,
+	/**
+	 * @SKB_DROP_REASON_SKB_RX_HEADROOM: accumulated receive headroom
+	 * exceeds the header-offset budget.
+	 */
+	SKB_DROP_REASON_SKB_RX_HEADROOM,
 	/**
 	 * @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which
 	 * shouldn't be used as a real 'reason' - only for tracing code gen
diff --git a/net/core/dev.c b/net/core/dev.c
index 426f6d2e19524..1a9bd6a9eb454 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5661,6 +5661,7 @@ static inline int nf_ingress(struct sk_buff *skb, struct packet_type **pt_prev,
 static int __netif_receive_skb_core(struct sk_buff **pskb, bool pfmemalloc,
 				    struct packet_type **ppt_prev)
 {
+	enum skb_drop_reason drop_reason = SKB_DROP_REASON_UNHANDLED_PROTO;
 	struct packet_type *ptype, *pt_prev;
 	rx_handler_func_t *rx_handler;
 	struct sk_buff *skb = *pskb;
@@ -5674,6 +5675,10 @@ static int __netif_receive_skb_core(struct sk_buff **pskb, bool pfmemalloc,
 	trace_netif_receive_skb(skb);
 
 	orig_dev = skb->dev;
+	if (unlikely(skb_headroom(skb) > SKB_MAX_RX_HEADROOM)) {
+		drop_reason = SKB_DROP_REASON_SKB_RX_HEADROOM;
+		goto drop;
+	}
 
 	skb_reset_network_header(skb);
 	if (!skb_transport_header_was_set(skb))
@@ -5851,7 +5856,7 @@ static int __netif_receive_skb_core(struct sk_buff **pskb, bool pfmemalloc,
 			dev_core_stats_rx_dropped_inc(skb->dev);
 		else
 			dev_core_stats_rx_nohandler_inc(skb->dev);
-		kfree_skb_reason(skb, SKB_DROP_REASON_UNHANDLED_PROTO);
+		kfree_skb_reason(skb, drop_reason);
 		/* Jamal, now you will not able to escape explaining
 		 * me how you were going to use this. :-)
 		 */
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index 9db51472c1e0f..29d7afaa1f583 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -205,6 +205,12 @@ void ip_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int protocol)
 		ret = INDIRECT_CALL_2(ipprot->handler, tcp_v4_rcv, udp_rcv,
 				      skb);
 		if (ret < 0) {
+			if (unlikely(skb_headroom(skb) > SKB_MAX_RX_HEADROOM)) {
+				__IP_INC_STATS(net, IPSTATS_MIB_INDISCARDS);
+				kfree_skb_reason(skb,
+						 SKB_DROP_REASON_SKB_RX_HEADROOM);
+				return;
+			}
 			protocol = -ret;
 			goto resubmit;
 		}
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index 54fc4b0eb57ba..e6e71f6f60b28 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -438,6 +438,10 @@ void ip6_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int nexthdr,
 		ret = INDIRECT_CALL_2(ipprot->handler, tcp_v6_rcv, udpv6_rcv,
 				      skb);
 		if (ret > 0) {
+			if (unlikely(skb_headroom(skb) > SKB_MAX_RX_HEADROOM)) {
+				SKB_DR_SET(reason, SKB_RX_HEADROOM);
+				goto discard;
+			}
 			if (ipprot->flags & INET6_PROTO_FINAL) {
 				/* Not an extension header, most likely UDP
 				 * encapsulation. Use return value as nexthdr
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 542/555] scsi: target: iscsi: reject invalid size Extended CDB AHS
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (540 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 541/555] net: prevent receive header offset overflow during decapsulation Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 543/555] gpiolib: dont overwrite the entire flags field in gpiod_get_direction() Greg Kroah-Hartman
                   ` (12 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Carlos Bilbao, Dmitry Bogdanov,
	Martin K. Petersen, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Carlos Bilbao <carlos.bilbao@kernel.org>

[ Upstream commit 2f3835771dff512750205aa5f5f61aec0f2b8cb7 ]

If ecdb_ahdr->ahslength is zero, two bugs follow:

  kmalloc(be16_to_cpu(ecdb_ahdr->ahslength) + 15, ...)

allocates 15 bytes, but the immediately following memcpy writes
ISCSI_CDB_SIZE (16) bytes into it, a one-byte heap overflow. Also:

  memcpy(cdb + ISCSI_CDB_SIZE, ecdb_ahdr->ecdb,
           be16_to_cpu(ecdb_ahdr->ahslength) - 1);

(u16)0 - 1 promotes to (int)-1 which converts to SIZE_MAX as size_t,
causing a massive out-of-bounds write.

Reject ahslength == 0 with ISCSI_REASON_PROTOCOL_ERROR before the kmalloc.
Also reject ahslength values that exceed the actual AHS buffer advertised.

Fixes: 8f1f7d297bce ("scsi: target: iscsi: Add support for extended CDB AHS")
Signed-off-by: Carlos Bilbao <carlos.bilbao@kernel.org>
Reviewed-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
Link: https://patch.msgid.link/20260415040728.187680-1-carlos.bilbao@kernel.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/target/iscsi/iscsi_target.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index a23553a3d279b..c12373146d4cf 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -1005,6 +1005,7 @@ int iscsit_setup_scsi_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
 	int data_direction, payload_length;
 	struct iscsi_ecdb_ahdr *ecdb_ahdr;
 	struct iscsi_scsi_req *hdr;
+	u16 ahslength, cdb_length;
 	int iscsi_task_attr;
 	unsigned char *cdb;
 	int sam_task_attr;
@@ -1118,14 +1119,27 @@ int iscsit_setup_scsi_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
 				ISCSI_REASON_CMD_NOT_SUPPORTED, buf);
 		}
 
-		cdb = kmalloc(be16_to_cpu(ecdb_ahdr->ahslength) + 15,
-			      GFP_KERNEL);
+		ahslength = be16_to_cpu(ecdb_ahdr->ahslength);
+		if (!ahslength) {
+			pr_err("Extended CDB AHS with zero length, protocol error.\n");
+			return iscsit_add_reject_cmd(cmd,
+				ISCSI_REASON_PROTOCOL_ERROR, buf);
+		}
+		if (ahslength > (hdr->hlength * 4) - 3) {
+			pr_err("Extended CDB AHS length %u exceeds available PDU buffer.\n",
+			       ahslength);
+			return iscsit_add_reject_cmd(cmd,
+				ISCSI_REASON_PROTOCOL_ERROR, buf);
+		}
+
+		cdb_length = ahslength - 1 + ISCSI_CDB_SIZE;
+
+		cdb = kmalloc(cdb_length, GFP_KERNEL);
 		if (cdb == NULL)
 			return iscsit_add_reject_cmd(cmd,
 				ISCSI_REASON_BOOKMARK_NO_RESOURCES, buf);
 		memcpy(cdb, hdr->cdb, ISCSI_CDB_SIZE);
-		memcpy(cdb + ISCSI_CDB_SIZE, ecdb_ahdr->ecdb,
-		       be16_to_cpu(ecdb_ahdr->ahslength) - 1);
+		memcpy(cdb + ISCSI_CDB_SIZE, ecdb_ahdr->ecdb, cdb_length - ISCSI_CDB_SIZE);
 	}
 
 	data_direction = (hdr->flags & ISCSI_FLAG_CMD_WRITE) ? DMA_TO_DEVICE :
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 543/555] gpiolib: dont overwrite the entire flags field in gpiod_get_direction()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (541 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 542/555] scsi: target: iscsi: reject invalid size Extended CDB AHS Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 544/555] rcu/nocb: Avoid unsequenced accesses to jiffies in show_rcu_nocb_state() Greg Kroah-Hartman
                   ` (11 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Kent Gibson, Bartosz Golaszewski,
	Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

commit 8ed87a9adf48703b5729f9d020eb15fa79ffb099 upstream.

gpiod_get_direction() snapshots desc->flags with READ_ONCE(), updates
FLAG_IS_OUT in the local copy and writes the whole word back with
WRITE_ONCE(). Any bit that a concurrent user sets or clears atomically in
between - for instance: FLAG_USED_AS_IRQ from gpiochip_lock_as_irq() - is
silently lost.

Update FLAG_IS_OUT with a single atomic assign_bit() directly on
desc->flags. The earlier READ_ONCE() snapshot is only used for the
open-drain check and stays.

Cc: stable@vger.kernel.org
Fixes: 2559f2e09211 ("gpio: reinforce desc->flags handling")
Reviewed-by: Kent Gibson <warthog618@gmail.com>
Link: https://patch.msgid.link/20261110-gpio-desc-flags-atomic-v3-1-2f463bce8086@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpio/gpiolib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index b3a557c41fa91..2fcf98ffc1932 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -393,8 +393,7 @@ int gpiod_get_direction(struct gpio_desc *desc)
 	if (ret > 0)
 		ret = 1;
 
-	assign_bit(FLAG_IS_OUT, &flags, !ret);
-	WRITE_ONCE(desc->flags, flags);
+	assign_bit(FLAG_IS_OUT, &desc->flags, !ret);
 
 	return ret;
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 544/555] rcu/nocb: Avoid unsequenced accesses to jiffies in show_rcu_nocb_state()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (542 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 543/555] gpiolib: dont overwrite the entire flags field in gpiod_get_direction() Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 545/555] block: Remove queue freezing from several sysfs store callbacks Greg Kroah-Hartman
                   ` (10 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Nathan Chancellor, Joel Fernandes,
	Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Nathan Chancellor <nathan@kernel.org>

commit c3f98ff6309a29979e1867bc3c9d4172755ca122 upstream.

After a recent improvement in clang to warn on unsequenced accesses to
volatile variables [1], an instance appears in show_rcu_nocb_state(),
which can break the build with CONFIG_WERROR=y / W=e:

  In file included from kernel/rcu/tree.c:5123:
  kernel/rcu/tree_nocb.h:1651:3: error: unsequenced accesses to volatile qualified 'jiffies' [-Werror,-Wunsequenced]
   1650 |                 jiffies - rdp->nocb_bypass_first,
        |                 ~~~~~~~
   1651 |                 jiffies - rdp->nocb_nobypass_last,
        |                 ^

Per C11 5.1.2.3.2, accessing a volatile object is a side effect. Per C11
6.5.2, unsequenced side effects on the same scalar object are undefined
behavior. Per C11 6.5.2.2.10/12, the evaluation of arguments in a
function call is indeterminately sequenced, meaning any side effects in
the arguments are unsequenced.

Add a local variable to hold the value of jiffies before the function
call so that there are no unsequenced side effects, clearing up the
warning.

Cc: stable@vger.kernel.org
Fixes: f7a81b12d6af ("rcu/nocb: Print no-CBs diagnostics when rcutorture writer unduly delayed")
Closes: https://github.com/ClangBuiltLinux/linux/issues/2192
Link: https://github.com/llvm/llvm-project/commit/955715460eaf9188c241c74750637fc82dfcc423 [1]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Joel Fernandes <jfern@kernel.org>
Signed-off-by: Joel Fernandes <jfern@kernel.org>
[nathan: Fix conflicts]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/rcu/tree_nocb.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h
index e11ca88677bbb..3d184bbd13ef0 100644
--- a/kernel/rcu/tree_nocb.h
+++ b/kernel/rcu/tree_nocb.h
@@ -1538,6 +1538,7 @@ static void show_rcu_nocb_state(struct rcu_data *rdp)
 	struct rcu_segcblist *rsclp = &rdp->cblist;
 	bool waslocked;
 	bool wassleep;
+	unsigned long j;
 
 	if (rdp->nocb_gp_rdp == rdp)
 		show_rcu_nocb_gp_state(rdp);
@@ -1549,6 +1550,7 @@ static void show_rcu_nocb_state(struct rcu_data *rdp)
 
 	sprintf(bufw, "%ld", rsclp->gp_seq[RCU_WAIT_TAIL]);
 	sprintf(bufr, "%ld", rsclp->gp_seq[RCU_NEXT_READY_TAIL]);
+	j = jiffies;
 	pr_info("   CB %d^%d->%d %c%c%c%c%c F%ld L%ld C%d %c%c%s%c%s%c%c q%ld %c CPU %d%s\n",
 		rdp->cpu, rdp->nocb_gp_rdp->cpu,
 		nocb_next_rdp ? nocb_next_rdp->cpu : -1,
@@ -1557,8 +1559,8 @@ static void show_rcu_nocb_state(struct rcu_data *rdp)
 		"lL"[raw_spin_is_locked(&rdp->nocb_lock)],
 		"sS"[!!rdp->nocb_cb_sleep],
 		".W"[swait_active(&rdp->nocb_cb_wq)],
-		jiffies - rdp->nocb_bypass_first,
-		jiffies - rdp->nocb_nobypass_last,
+		j - rdp->nocb_bypass_first,
+		j - rdp->nocb_nobypass_last,
 		rdp->nocb_nobypass_count,
 		".D"[rcu_segcblist_ready_cbs(rsclp)],
 		".W"[!rcu_segcblist_segempty(rsclp, RCU_WAIT_TAIL)],
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 545/555] block: Remove queue freezing from several sysfs store callbacks
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (543 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 544/555] rcu/nocb: Avoid unsequenced accesses to jiffies in show_rcu_nocb_state() Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 546/555] nvme-tcp: use an aligned buffer for the TLS record type Greg Kroah-Hartman
                   ` (9 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Christoph Hellwig, Ming Lei,
	Nilay Shroff, Martin Wilck, Benjamin Marzinski, Bart Van Assche,
	Jens Axboe, Dickson Wu, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Bart Van Assche <bvanassche@acm.org>

commit 935a20d1bebf6236076785fac3ff81e3931834e9 upstream.

Freezing the request queue from inside sysfs store callbacks may cause a
deadlock in combination with the dm-multipath driver and the
queue_if_no_path option. Additionally, freezing the request queue slows
down system boot on systems where sysfs attributes are set synchronously.

Fix this by removing the blk_mq_freeze_queue() / blk_mq_unfreeze_queue()
calls from the store callbacks that do not strictly need these callbacks.
Add the __data_racy annotation to request_queue.rq_timeout to suppress
KCSAN data race reports about the rq_timeout reads.

This patch may cause a small delay in applying the new settings.

For all the attributes affected by this patch, I/O will complete
correctly whether the old or the new value of the attribute is used.

This patch affects the following sysfs attributes:
* io_poll_delay
* io_timeout
* nomerges
* read_ahead_kb
* rq_affinity

Here is an example of a deadlock triggered by running test srp/002
if this patch is not applied:

task:multipathd
Call Trace:
 <TASK>
 __schedule+0x8c1/0x1bf0
 schedule+0xdd/0x270
 schedule_preempt_disabled+0x1c/0x30
 __mutex_lock+0xb89/0x1650
 mutex_lock_nested+0x1f/0x30
 dm_table_set_restrictions+0x823/0xdf0
 __bind+0x166/0x590
 dm_swap_table+0x2a7/0x490
 do_resume+0x1b1/0x610
 dev_suspend+0x55/0x1a0
 ctl_ioctl+0x3a5/0x7e0
 dm_ctl_ioctl+0x12/0x20
 __x64_sys_ioctl+0x127/0x1a0
 x64_sys_call+0xe2b/0x17d0
 do_syscall_64+0x96/0x3a0
 entry_SYSCALL_64_after_hwframe+0x4b/0x53
 </TASK>
task:(udev-worker)
Call Trace:
 <TASK>
 __schedule+0x8c1/0x1bf0
 schedule+0xdd/0x270
 blk_mq_freeze_queue_wait+0xf2/0x140
 blk_mq_freeze_queue_nomemsave+0x23/0x30
 queue_ra_store+0x14e/0x290
 queue_attr_store+0x23e/0x2c0
 sysfs_kf_write+0xde/0x140
 kernfs_fop_write_iter+0x3b2/0x630
 vfs_write+0x4fd/0x1390
 ksys_write+0xfd/0x230
 __x64_sys_write+0x76/0xc0
 x64_sys_call+0x276/0x17d0
 do_syscall_64+0x96/0x3a0
 entry_SYSCALL_64_after_hwframe+0x4b/0x53
 </TASK>

Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Nilay Shroff <nilay@linux.ibm.com>
Cc: Martin Wilck <mwilck@suse.com>
Cc: Benjamin Marzinski <bmarzins@redhat.com>
Cc: stable@vger.kernel.org
Fixes: af2814149883 ("block: freeze the queue in queue_attr_store")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Nilay Shroff <nilay@linux.ibm.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
[ adapted: skip store freeze, omit 5e40f4452dc9 lock, fold d23977fee1ee ]
Signed-off-by: Dickson Wu <dickson.wu@certik.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 block/blk-settings.c   |  2 +-
 block/blk-sysfs.c      | 19 +++++++++++++++++--
 include/linux/blkdev.h |  2 +-
 3 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index d72a283401c3a..1a173d4437507 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -21,7 +21,7 @@
 
 void blk_queue_rq_timeout(struct request_queue *q, unsigned int timeout)
 {
-	q->rq_timeout = timeout;
+	WRITE_ONCE(q->rq_timeout, timeout);
 }
 EXPORT_SYMBOL_GPL(blk_queue_rq_timeout);
 
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index f21de1898ff15..55eff38c19c0b 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -92,7 +92,11 @@ queue_ra_store(struct gendisk *disk, const char *page, size_t count)
 	ret = queue_var_store(&ra_kb, page, count);
 	if (ret < 0)
 		return ret;
-	disk->bdi->ra_pages = ra_kb >> (PAGE_SHIFT - 10);
+	/*
+	 * bdi->ra_pages reads are not serialized against bdi->ra_pages writes.
+	 * Use WRITE_ONCE() to write bdi->ra_pages once.
+	 */
+	WRITE_ONCE(disk->bdi->ra_pages, ra_kb >> (PAGE_SHIFT - 10));
 	return ret;
 }
 
@@ -342,7 +346,8 @@ static ssize_t queue_poll_store(struct gendisk *disk, const char *page,
 
 static ssize_t queue_io_timeout_show(struct gendisk *disk, char *page)
 {
-	return sysfs_emit(page, "%u\n", jiffies_to_msecs(disk->queue->rq_timeout));
+	return sysfs_emit(page, "%u\n",
+			jiffies_to_msecs(READ_ONCE(disk->queue->rq_timeout)));
 }
 
 static ssize_t queue_io_timeout_store(struct gendisk *disk, const char *page,
@@ -701,11 +706,21 @@ queue_attr_store(struct kobject *kobj, struct attribute *attr,
 	}
 
 	mutex_lock(&q->sysfs_lock);
+	if (entry == &queue_ra_entry || entry == &queue_nomerges_entry ||
+	    entry == &queue_rq_affinity_entry || entry == &queue_poll_entry ||
+	    entry == &queue_poll_delay_entry || entry == &queue_io_timeout_entry) {
+		noio_flag = memalloc_noio_save();
+		res = entry->store(disk, page, length);
+		memalloc_noio_restore(noio_flag);
+		goto unlock;
+	}
+
 	blk_mq_freeze_queue(q);
 	noio_flag = memalloc_noio_save();
 	res = entry->store(disk, page, length);
 	memalloc_noio_restore(noio_flag);
 	blk_mq_unfreeze_queue(q);
+unlock:
 	mutex_unlock(&q->sysfs_lock);
 	return res;
 }
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 33f5b16c0fd9a..eb60179e3b363 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -460,7 +460,7 @@ struct request_queue {
 	 */
 	unsigned long		queue_flags;
 
-	unsigned int		rq_timeout;
+	unsigned int __data_racy rq_timeout;
 
 	unsigned int		queue_depth;
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 546/555] nvme-tcp: use an aligned buffer for the TLS record type
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (544 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 545/555] block: Remove queue freezing from several sysfs store callbacks Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 547/555] nvme-tcp: move the TLS record read loop into a helper Greg Kroah-Hartman
                   ` (8 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Martin Belanger, Hannes Reinecke,
	Keith Busch, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Martin Belanger <martin.belanger@dell.com>

commit 1193566c35ead643e954ff8356bb54b1cd78378a upstream.

The buffers that receive the TLS record type are char arrays.
put_cmsg() and tls_get_record_type() access them as struct cmsghdr,
which needs a stricter alignment than a char array has.

Use a union with struct cmsghdr, sized with CMSG_SPACE(), as
svc_tcp_recv_cmsg() and xs_tls_read_record() in sunrpc do.

Fixes: 2837966ab2a8 ("nvme-tcp: control message handling for recvmsg()")
Cc: stable@vger.kernel.org
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Signed-off-by: Keith Busch <kbusch@kernel.org>
[ Martin: resolved a context conflict next to nvme_tcp_cpu_queues ]
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/nvme/host/tcp.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 3d89e20dfe3e0..42f65263cbe59 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -76,6 +76,12 @@ MODULE_PARM_DESC(tls_handshake_timeout,
 /* TLS records read while waiting for the ICResp, the ICResp included */
 #define NVME_TCP_ICRESP_MAX_RECORDS 8
 
+/* control message buffer for the TLS record type */
+union nvme_tcp_tls_cmsg {
+	struct cmsghdr	cmsg;
+	u8		buf[CMSG_SPACE(sizeof(u8))];
+};
+
 static atomic_t nvme_tcp_cpu_queues[NR_CPUS];
 
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
@@ -1672,11 +1678,11 @@ static int nvme_tcp_skip_tls_record(struct nvme_tcp_queue *queue,
 			.iov_base = buf,
 			.iov_len = sizeof(buf),
 		};
-		char cbuf[CMSG_LEN(sizeof(char))] = {};
+		union nvme_tcp_tls_cmsg u = {};
 		/* kTLS fails a control record read without a cmsg buffer */
 		struct msghdr drain = {
-			.msg_control = cbuf,
-			.msg_controllen = sizeof(cbuf),
+			.msg_control = &u,
+			.msg_controllen = sizeof(u),
 		};
 
 		ret = kernel_recvmsg(queue->sock, &drain, &iov, 1, sizeof(buf),
@@ -1701,7 +1707,7 @@ static int nvme_tcp_skip_tls_record(struct nvme_tcp_queue *queue,
 static int nvme_tcp_recv_icresp(struct nvme_tcp_queue *queue,
 				struct nvme_tcp_icresp_pdu *icresp)
 {
-	char cbuf[CMSG_LEN(sizeof(char))];
+	union nvme_tcp_tls_cmsg u;
 	struct msghdr msg;
 	struct kvec iov;
 	u8 ctype;
@@ -1709,12 +1715,12 @@ static int nvme_tcp_recv_icresp(struct nvme_tcp_queue *queue,
 
 	for (i = 0; i < NVME_TCP_ICRESP_MAX_RECORDS; i++) {
 		memset(&msg, 0, sizeof(msg));
-		memset(cbuf, 0, sizeof(cbuf));
+		memset(&u, 0, sizeof(u));
 		iov.iov_base = icresp;
 		iov.iov_len = sizeof(*icresp);
 		if (nvme_tcp_queue_tls(queue)) {
-			msg.msg_control = cbuf;
-			msg.msg_controllen = sizeof(cbuf);
+			msg.msg_control = &u;
+			msg.msg_controllen = sizeof(u);
 		}
 		msg.msg_flags = MSG_WAITALL;
 		ret = kernel_recvmsg(queue->sock, &msg, &iov, 1,
@@ -1722,8 +1728,7 @@ static int nvme_tcp_recv_icresp(struct nvme_tcp_queue *queue,
 		if (ret <= 0 || !nvme_tcp_queue_tls(queue))
 			return ret;
 
-		ctype = tls_get_record_type(queue->sock->sk,
-					    (struct cmsghdr *)cbuf);
+		ctype = tls_get_record_type(queue->sock->sk, &u.cmsg);
 		if (ctype == TLS_RECORD_TYPE_DATA)
 			return ret;
 
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 547/555] nvme-tcp: move the TLS record read loop into a helper
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (545 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 546/555] nvme-tcp: use an aligned buffer for the TLS record type Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 548/555] nvme-tcp: consume TLS records without application data Greg Kroah-Hartman
                   ` (7 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Martin Belanger, Hannes Reinecke,
	Keith Busch, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Martin Belanger <martin.belanger@dell.com>

commit 76afef5e29221e68f9a19df767f94b092c31e974 upstream.

Move the read loop out of nvme_tcp_skip_tls_record() into a new
helper, nvme_tcp_drain_tls_record(). The next patch uses the helper
to read TLS records that arrive on a live queue.

No functional change.

Cc: stable@vger.kernel.org
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/nvme/host/tcp.c | 60 ++++++++++++++++++++++++++---------------
 1 file changed, 38 insertions(+), 22 deletions(-)

diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 42f65263cbe59..28df8937b4379 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -1648,31 +1648,16 @@ static int nvme_tcp_recv_tls_alert(struct nvme_tcp_queue *queue,
 }
 
 /*
- * Discard a TLS record that arrived in place of the ICResp. A peer may send
- * a NewSessionTicket as soon as the handshake completes.
+ * Read the rest of a TLS record whose first part was read into @msg.
  *
- * Returns 0 when the record was discarded and the ICResp can be read, or a
- * negative errno if the connection cannot continue.
+ * Returns the bytes read, or a negative errno.
  */
-static int nvme_tcp_skip_tls_record(struct nvme_tcp_queue *queue,
-				    struct msghdr *msg, u8 ctype, int len)
+static int nvme_tcp_drain_tls_record(struct nvme_tcp_queue *queue,
+				     struct msghdr *msg, int flags)
 {
 	u8 buf[NVME_TCP_TLS_REC_CHUNK];
-	int ret;
+	int ret, drained = 0;
 
-	switch (ctype) {
-	case TLS_RECORD_TYPE_HANDSHAKE:
-		break;
-	case TLS_RECORD_TYPE_ALERT:
-		ret = nvme_tcp_recv_tls_alert(queue, msg, len);
-		return ret ? : -ENOTCONN;
-	default:
-		pr_err("queue %d: unhandled TLS record %u\n",
-		       nvme_tcp_queue_id(queue), ctype);
-		return -ENOTCONN;
-	}
-
-	/* the ICResp is in a later record, drain this one first */
 	while (!(msg->msg_flags & MSG_EOR)) {
 		struct kvec iov = {
 			.iov_base = buf,
@@ -1686,16 +1671,47 @@ static int nvme_tcp_skip_tls_record(struct nvme_tcp_queue *queue,
 		};
 
 		ret = kernel_recvmsg(queue->sock, &drain, &iov, 1, sizeof(buf),
-				     0);
+				     flags);
 		if (ret <= 0) {
 			pr_warn("queue %d: failed to drain TLS record: %d\n",
 				nvme_tcp_queue_id(queue), ret);
 			return ret ? : -ECONNRESET;
 		}
+		drained += ret;
 		msg->msg_flags = drain.msg_flags;
 	}
 
-	return 0;
+	return drained;
+}
+
+/*
+ * Discard a TLS record that arrived in place of the ICResp. A peer may send
+ * a NewSessionTicket as soon as the handshake completes.
+ *
+ * Returns 0 when the record was discarded and the ICResp can be read, or a
+ * negative errno if the connection cannot continue.
+ */
+static int nvme_tcp_skip_tls_record(struct nvme_tcp_queue *queue,
+				    struct msghdr *msg, u8 ctype, int len)
+{
+	int ret;
+
+	switch (ctype) {
+	case TLS_RECORD_TYPE_HANDSHAKE:
+		break;
+	case TLS_RECORD_TYPE_ALERT:
+		ret = nvme_tcp_recv_tls_alert(queue, msg, len);
+		return ret ? : -ENOTCONN;
+	default:
+		pr_err("queue %d: unhandled TLS record %u\n",
+		       nvme_tcp_queue_id(queue), ctype);
+		return -ENOTCONN;
+	}
+
+	/* the ICResp is in a later record, drain this one first */
+	ret = nvme_tcp_drain_tls_record(queue, msg, 0);
+
+	return ret < 0 ? ret : 0;
 }
 
 /*
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 548/555] nvme-tcp: consume TLS records without application data
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (546 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 547/555] nvme-tcp: move the TLS record read loop into a helper Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 549/555] direct-io: remove IOCB_NOWAIT support Greg Kroah-Hartman
                   ` (6 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Martin Belanger, Hannes Reinecke,
	Keith Busch, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Martin Belanger <martin.belanger@dell.com>

commit 687e743e4089b2a854982b321cb2d681ae5d6136 upstream.

A peer may send a TLS record without application data at any time
after the handshake: a NewSessionTicket, a KeyUpdate or an alert.
tls_sw_read_sock() cannot pass such a record to nvme_tcp_recv_skb().
It returns -EINVAL and leaves the record at the head of the receive
queue. nvme_tcp_try_recv() then starts error recovery, and the
controller reconnects.

TLS 1.3 allows a server to send a NewSessionTicket at any time after
the handshake (RFC 8446, section 4.6.1). Alerts can also arrive at any
time.

On -EINVAL, read the record with recvmsg(), which reports the record
type. Discard handshake messages other than KeyUpdate. Log alerts, and
fail the queue on a fatal alert. Fail the queue on a KeyUpdate, which
nvme-tcp cannot answer, and on any other record type. recvmsg() takes
the socket lock, so release it around the read.

Handle these records in one helper, also for the records that arrive
ahead of the ICResp. A warning alert ahead of the ICResp no longer fails
the connection.

On a poll queue, nvme_tcp_poll() and nvme_tcp_io_work() can both see
the record while the socket lock is released. A queue flag makes sure
that only one of them reads it.

svc_tcp_recvfrom() in sunrpc handles -EINVAL from read_sock() the same
way.

Fixes: be8e82caa685 ("nvme-tcp: enable TLS handshake upcall")
Cc: stable@vger.kernel.org
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Signed-off-by: Keith Busch <kbusch@kernel.org>
[ Martin: added the TLS_HANDSHAKE_KEYUPDATE define from 0471b1093e3a
  ("tls: block decryption when a rekey is pending"), which is not in 6.12 ]
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/nvme/host/tcp.c | 113 ++++++++++++++++++++++++++++++++++------
 include/net/tls.h       |   2 +
 2 files changed, 99 insertions(+), 16 deletions(-)

diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 28df8937b4379..9ff0291e4beba 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -159,6 +159,7 @@ enum nvme_tcp_queue_flags {
 	NVME_TCP_Q_LIVE		= 1,
 	NVME_TCP_Q_POLLING	= 2,
 	NVME_TCP_Q_IO_CPU_SET	= 3,
+	NVME_TCP_Q_TLS_RECORD	= 4,
 };
 
 #define NVME_TCP_OPT_NR_QUEUES(opts) ((opts)->nr_io_queues + \
@@ -1442,6 +1443,8 @@ static int nvme_tcp_try_send(struct nvme_tcp_queue *queue)
 	return ret;
 }
 
+static int nvme_tcp_recv_tls_record(struct nvme_tcp_queue *queue);
+
 static int nvme_tcp_try_recv(struct nvme_tcp_queue *queue)
 {
 	struct socket *sock = queue->sock;
@@ -1454,10 +1457,31 @@ static int nvme_tcp_try_recv(struct nvme_tcp_queue *queue)
 	lock_sock(sk);
 	queue->nr_cqe = 0;
 	consumed = sock->ops->read_sock(sk, &rd_desc, nvme_tcp_recv_skb);
+	/*
+	 * kTLS cannot pass a TLS record without application data to
+	 * nvme_tcp_recv_skb(). It returns -EINVAL and leaves the record at
+	 * the head of the receive queue. recvmsg() takes the socket lock,
+	 * so read the record without it.
+	 */
+	if (unlikely(consumed == -EINVAL && nvme_tcp_queue_tls(queue) &&
+		     queue->rd_enabled)) {
+		/*
+		 * On a poll queue, nvme_tcp_poll() and nvme_tcp_io_work() can
+		 * both get here for the same record. Only one of them reads it.
+		 */
+		if (test_and_set_bit(NVME_TCP_Q_TLS_RECORD, &queue->flags)) {
+			consumed = 0;
+		} else {
+			release_sock(sk);
+			consumed = nvme_tcp_recv_tls_record(queue);
+			lock_sock(sk);
+			clear_bit(NVME_TCP_Q_TLS_RECORD, &queue->flags);
+		}
+	}
 	/*
 	 * nvme_tcp_recv_skb() handles its own errors, so a queue that is
-	 * still enabled failed inside read_sock(). Handle it before
-	 * release_sock() processes the backlog.
+	 * still enabled failed inside read_sock() or while reading a TLS
+	 * record. Handle it before release_sock() processes the backlog.
 	 */
 	if (unlikely(consumed < 0 && consumed != -EAGAIN &&
 		     queue->rd_enabled)) {
@@ -1685,33 +1709,88 @@ static int nvme_tcp_drain_tls_record(struct nvme_tcp_queue *queue,
 }
 
 /*
- * Discard a TLS record that arrived in place of the ICResp. A peer may send
- * a NewSessionTicket as soon as the handshake completes.
+ * Consume a TLS record without application data. The first @len bytes of
+ * the record were read into @msg and @data.
  *
- * Returns 0 when the record was discarded and the ICResp can be read, or a
- * negative errno if the connection cannot continue.
+ * A KeyUpdate needs new keys that nothing here can supply. Other handshake
+ * messages, such as a NewSessionTicket, are discarded.
+ *
+ * Returns the bytes read after the first @len, or a negative errno if the
+ * connection cannot continue.
  */
-static int nvme_tcp_skip_tls_record(struct nvme_tcp_queue *queue,
-				    struct msghdr *msg, u8 ctype, int len)
+static int nvme_tcp_consume_tls_record(struct nvme_tcp_queue *queue,
+				       struct msghdr *msg, u8 ctype,
+				       const u8 *data, int len, int flags)
 {
 	int ret;
 
 	switch (ctype) {
 	case TLS_RECORD_TYPE_HANDSHAKE:
+		if (data[0] == TLS_HANDSHAKE_KEYUPDATE) {
+			dev_err(queue->ctrl->ctrl.device,
+				"queue %d: TLS KeyUpdate is not supported\n",
+				nvme_tcp_queue_id(queue));
+			return -EKEYEXPIRED;
+		}
 		break;
 	case TLS_RECORD_TYPE_ALERT:
 		ret = nvme_tcp_recv_tls_alert(queue, msg, len);
-		return ret ? : -ENOTCONN;
+		if (ret)
+			return ret;
+		break;
 	default:
-		pr_err("queue %d: unhandled TLS record %u\n",
-		       nvme_tcp_queue_id(queue), ctype);
-		return -ENOTCONN;
+		dev_err(queue->ctrl->ctrl.device,
+			"queue %d: unexpected TLS record %u\n",
+			nvme_tcp_queue_id(queue), ctype);
+		return -EPROTO;
 	}
 
-	/* the ICResp is in a later record, drain this one first */
-	ret = nvme_tcp_drain_tls_record(queue, msg, 0);
+	return nvme_tcp_drain_tls_record(queue, msg, flags);
+}
+
+/*
+ * Read the TLS record that read_sock() could not pass to
+ * nvme_tcp_recv_skb(). The caller must not hold the socket lock.
+ *
+ * Returns the bytes consumed, or a negative errno if the connection cannot
+ * continue.
+ */
+static int nvme_tcp_recv_tls_record(struct nvme_tcp_queue *queue)
+{
+	u8 buf[NVME_TCP_TLS_REC_CHUNK];
+	union nvme_tcp_tls_cmsg u = {};
+	struct kvec iov = {
+		.iov_base = buf,
+		.iov_len = sizeof(buf),
+	};
+	struct msghdr msg = {
+		.msg_control = &u,
+		.msg_controllen = sizeof(u),
+	};
+	int len, ret;
+	u8 ctype;
+
+	len = kernel_recvmsg(queue->sock, &msg, &iov, 1, sizeof(buf),
+			     MSG_DONTWAIT);
+	if (len <= 0)
+		goto fail;
+
+	ctype = tls_get_record_type(queue->sock->sk, &u.cmsg);
+	ret = nvme_tcp_consume_tls_record(queue, &msg, ctype, buf, len,
+					  MSG_DONTWAIT);
+	if (ret < 0) {
+		len = ret;
+		goto fail;
+	}
+
+	return len + ret;
+
+fail:
+	/* read_sock() left a whole record, so none of it can be missing */
+	if (len == -EAGAIN)
+		return -EPROTO;
 
-	return ret < 0 ? ret : 0;
+	return len ? : -ECONNRESET;
 }
 
 /*
@@ -1748,7 +1827,9 @@ static int nvme_tcp_recv_icresp(struct nvme_tcp_queue *queue,
 		if (ctype == TLS_RECORD_TYPE_DATA)
 			return ret;
 
-		ret = nvme_tcp_skip_tls_record(queue, &msg, ctype, ret);
+		/* the ICResp is in a later record */
+		ret = nvme_tcp_consume_tls_record(queue, &msg, ctype,
+						  (const u8 *)icresp, ret, 0);
 		if (ret < 0)
 			return ret;
 	}
diff --git a/include/net/tls.h b/include/net/tls.h
index 3f4235cc0207c..8c3a2699e8aa0 100644
--- a/include/net/tls.h
+++ b/include/net/tls.h
@@ -59,6 +59,8 @@ struct tls_rec;
 
 #define TLS_CRYPTO_INFO_READY(info)	((info)->cipher_type)
 
+#define TLS_HANDSHAKE_KEYUPDATE		24	/* rfc8446 B.3: Key update */
+
 #define TLS_AAD_SPACE_SIZE		13
 
 #define TLS_MAX_IV_SIZE			16
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 549/555] direct-io: remove IOCB_NOWAIT support
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (547 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 548/555] nvme-tcp: consume TLS records without application data Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 550/555] drm/amd/display: Saturate refresh rates in v1/v2 FreeSync infopackets Greg Kroah-Hartman
                   ` (5 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Christoph Hellwig, Christian Brauner,
	Jan Kara, Damien Le Moal, Jens Axboe, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Christoph Hellwig <hch@lst.de>

[ Upstream commit 38273e7b153d88562bddba9a24dafa733da4fd22 ]

None of the file systems using the legacy direct I/O code actually sets
FMODE_NOWAIT, and if they did this would not work, as the write locking
could not handle the retry.  Remove this dead code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Link: https://patch.msgid.link/20260518063336.507369-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/direct-io.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/fs/direct-io.c b/fs/direct-io.c
index bbd05f1a21453..102df712aa523 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -502,12 +502,8 @@ static blk_status_t dio_bio_complete(struct dio *dio, struct bio *bio)
 	const enum req_op dio_op = dio->opf & REQ_OP_MASK;
 	bool should_dirty = dio_op == REQ_OP_READ && dio->should_dirty;
 
-	if (err) {
-		if (err == BLK_STS_AGAIN && (bio->bi_opf & REQ_NOWAIT))
-			dio->io_error = -EAGAIN;
-		else
-			dio->io_error = -EIO;
-	}
+	if (err)
+		dio->io_error = -EIO;
 
 	if (dio->is_async && should_dirty) {
 		bio_check_pages_dirty(bio);	/* transfers ownership */
@@ -1178,13 +1174,10 @@ ssize_t __blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
 		dio->is_async = true;
 
 	dio->inode = inode;
-	if (iov_iter_rw(iter) == WRITE) {
+	if (iov_iter_rw(iter) == WRITE)
 		dio->opf = REQ_OP_WRITE | REQ_SYNC | REQ_IDLE;
-		if (iocb->ki_flags & IOCB_NOWAIT)
-			dio->opf |= REQ_NOWAIT;
-	} else {
+	else
 		dio->opf = REQ_OP_READ;
-	}
 
 	/*
 	 * For AIO O_(D)SYNC writes we need to defer completions to a workqueue
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 550/555] drm/amd/display: Saturate refresh rates in v1/v2 FreeSync infopackets
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (548 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 549/555] direct-io: remove IOCB_NOWAIT support Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 551/555] gpiolib: dont overwrite the entire flags field in gpiod_free_commit() Greg Kroah-Hartman
                   ` (4 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Harry Wentland, Cooper Morgan,
	Wayne Lin, Alex Deucher, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Cooper Morgan <ext-github@cwooper.dev>

commit 76850a457474a629dc0ceffaafb3aed78ff5f469 upstream.

The v1 and v2 FreeSync infopackets carry the minimum and maximum
refresh rate in one byte each, and build_vrr_infopacket_data_v1() casts
the rate in Hz to unsigned char. On a sink whose range goes above
255 Hz the value wraps: a 320 Hz mode is advertised as a 64 Hz maximum.

Sinks that treat the field as authoritative misbehave once the wrapped
value lands inside their range. An MSI MAG 271QPX32 (48-320 Hz) over
native DP looks like a ~720p image upscaled to the full screen at 320 Hz
and runs its self-test pattern at 305-315 Hz, while 300 Hz (wrapping to
44 Hz, below its minimum) is fine. Capping the EDID range at 255 Hz, so
the packet says 255, gives a correct picture at 320 Hz.

Saturate the fields at 255 Hz instead of wrapping.

Capping v1 at 255 as a fallback was suggested by oystersuki in the linked
issue.

Fixes: 98e6436d3af5 ("drm/amd/display: Refactor FreeSync module")
Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/5988
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Cooper Morgan <ext-github@cwooper.dev>
Signed-off-by: Wayne Lin <Wayne.Lin@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 8f91c13d9a14085216725f60b55546fce5c2dd19)
Cc: stable@vger.kernel.org
(cherry picked from commit 76850a457474a629dc0ceffaafb3aed78ff5f469)
[ Cooper: Dropped the KUnit test hunks, since 6.12.y has no
  amdgpu_dm_freesync_test.c. In freesync.c, resolved a context conflict:
  6.12.y still has mod_freesync_get_vmin_vmax() and
  mod_freesync_get_v_position() above build_vrr_infopacket_data_v1(), so
  the new helper goes after them. The code change is unchanged. ]
Signed-off-by: Cooper Morgan <ext-github@cwooper.dev>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 .../gpu/drm/amd/display/modules/freesync/freesync.c  | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
index ab62a76d48cf7..aad1959f3f1d7 100644
--- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
+++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
@@ -575,6 +575,12 @@ bool mod_freesync_get_v_position(struct mod_freesync *mod_freesync,
 	return false;
 }
 
+/* v1/v2 packets hold each rate in one byte; saturate instead of wrapping. */
+static unsigned char vrr_refresh_hz_u8(unsigned int refresh_in_uhz)
+{
+	return min((refresh_in_uhz + 500000) / 1000000, 255U);
+}
+
 static void build_vrr_infopacket_data_v1(const struct mod_vrr_params *vrr,
 		struct dc_info_packet *infopacket,
 		bool freesync_on_desktop)
@@ -618,15 +624,15 @@ static void build_vrr_infopacket_data_v1(const struct mod_vrr_params *vrr,
 	/* PB7 = FreeSync Minimum refresh rate (Hz) */
 	if (vrr->state == VRR_STATE_ACTIVE_VARIABLE ||
 			vrr->state == VRR_STATE_ACTIVE_FIXED) {
-		infopacket->sb[7] = (unsigned char)((vrr->min_refresh_in_uhz + 500000) / 1000000);
+		infopacket->sb[7] = vrr_refresh_hz_u8(vrr->min_refresh_in_uhz);
 	} else {
-		infopacket->sb[7] = (unsigned char)((vrr->max_refresh_in_uhz + 500000) / 1000000);
+		infopacket->sb[7] = vrr_refresh_hz_u8(vrr->max_refresh_in_uhz);
 	}
 
 	/* PB8 = FreeSync Maximum refresh rate (Hz)
 	 * Note: We should never go above the field rate of the mode timing set.
 	 */
-	infopacket->sb[8] = (unsigned char)((vrr->max_refresh_in_uhz + 500000) / 1000000);
+	infopacket->sb[8] = vrr_refresh_hz_u8(vrr->max_refresh_in_uhz);
 }
 
 static void build_vrr_infopacket_data_v3(const struct mod_vrr_params *vrr,
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 551/555] gpiolib: dont overwrite the entire flags field in gpiod_free_commit()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (549 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 550/555] drm/amd/display: Saturate refresh rates in v1/v2 FreeSync infopackets Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 552/555] gpiolib: wait for pending label frees before cleaning up desc_srcu Greg Kroah-Hartman
                   ` (3 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Kent Gibson, Bartosz Golaszewski,
	Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

commit 63d7aedf6add8a24415af4c010588f63fa7296ab upstream.

Use set_mask_bits() to clear all request-related flags in one go
instead of risking racing with concurrent users and overwriting any
changes they could have done between READ_ONCE() and WRITE_ONCE().

Cc: stable@vger.kernel.org
Fixes: 35b545332b80 ("gpio: remove gpio_lock")
Reviewed-by: Kent Gibson <warthog618@gmail.com>
Link: https://patch.msgid.link/20261110-gpio-desc-flags-atomic-v3-4-2f463bce8086@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpio/gpiolib.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 2fcf98ffc1932..81436cb78a476 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2431,24 +2431,23 @@ static void gpiod_free_commit(struct gpio_desc *desc)
 		if (guard.gc->free)
 			guard.gc->free(guard.gc, gpio_chip_hwgpio(desc));
 
-		clear_bit(FLAG_ACTIVE_LOW, &flags);
-		clear_bit(FLAG_REQUESTED, &flags);
-		clear_bit(FLAG_OPEN_DRAIN, &flags);
-		clear_bit(FLAG_OPEN_SOURCE, &flags);
-		clear_bit(FLAG_PULL_UP, &flags);
-		clear_bit(FLAG_PULL_DOWN, &flags);
-		clear_bit(FLAG_BIAS_DISABLE, &flags);
-		clear_bit(FLAG_EDGE_RISING, &flags);
-		clear_bit(FLAG_EDGE_FALLING, &flags);
-		clear_bit(FLAG_EVENT_CLOCK_REALTIME, &flags);
-		clear_bit(FLAG_EVENT_CLOCK_HTE, &flags);
-		clear_bit(FLAG_IS_HOGGED, &flags);
 #ifdef CONFIG_OF_DYNAMIC
 		WRITE_ONCE(desc->hog, NULL);
 #endif
 		desc_set_label(desc, NULL);
-		WRITE_ONCE(desc->flags, flags);
-
+		set_mask_bits(&desc->flags,
+			      BIT(FLAG_ACTIVE_LOW) |
+			      BIT(FLAG_REQUESTED) |
+			      BIT(FLAG_OPEN_DRAIN) |
+			      BIT(FLAG_OPEN_SOURCE) |
+			      BIT(FLAG_PULL_UP) |
+			      BIT(FLAG_PULL_DOWN) |
+			      BIT(FLAG_BIAS_DISABLE) |
+			      BIT(FLAG_EDGE_RISING) |
+			      BIT(FLAG_EDGE_FALLING) |
+			      BIT(FLAG_EVENT_CLOCK_REALTIME) |
+			      BIT(FLAG_EVENT_CLOCK_HTE) |
+			      BIT(FLAG_IS_HOGGED), 0);
 		gpiod_line_state_notify(desc, GPIOLINE_CHANGED_RELEASED);
 	}
 }
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 552/555] gpiolib: wait for pending label frees before cleaning up desc_srcu
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (550 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 551/555] gpiolib: dont overwrite the entire flags field in gpiod_free_commit() Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 553/555] gpiolib: free the label of lines released after their chip was removed Greg Kroah-Hartman
                   ` (2 subsequent siblings)
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Paul E. McKenney, Andy Shevchenko,
	Yi Lai, Adrian Ambrozewicz, Bartosz Golaszewski, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Adrian Ambrozewicz <aambrozewicz@nvidia.com>

[ Upstream commit c901e8fddd3a23353bb12c9d93b9a5fc482ac8f5 ]

desc_set_label() frees the old label with call_srcu() on
gdev->desc_srcu, and gpiodev_release() calls synchronize_srcu() before
cleanup_srcu_struct(). synchronize_srcu() waits for a grace period, not
for queued callbacks. Once the srcu_struct uses per-CPU callback lists,
a label freed by gpiochip_free_hogs() can still be pending, and
cleanup_srcu_struct() warns:

  WARNING: kernel/rcu/srcutree.c:706 at cleanup_srcu_struct+0x239/0x330, CPU#0: init/1
  Call Trace:
   gpiodev_release
   device_release
   kobject_put
   devres_release_all
   device_release_driver_internal
   platform_device_unregister
   gpio_sim_device_deactivate

Use srcu_barrier(), which waits for them.

Reproduced with a hogged gpio-sim line, setting the chip live and back
on a 4-CPU guest with srcutree.convert_to_big=1: it warns within 60
cycles; with this change, 1000 cycles pass.

Fixes: a86d27693066 ("gpiolib: fix the speed of descriptor label setting with SRCU")
Cc: stable@vger.kernel.org
Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Yi Lai <yi1.lai@intel.com>
Signed-off-by: Adrian Ambrozewicz <aambrozewicz@nvidia.com>
Link: https://patch.msgid.link/20261124-gpiolib-chip-removal-v8-1-aambrozewicz@nvidia.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpio/gpiolib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 81436cb78a476..86ab8bc142ca1 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -757,7 +757,7 @@ static void gpiodev_release(struct device *dev)
 	struct gpio_device *gdev = to_gpio_device(dev);
 
 	/* Call pending kfree()s for descriptor labels. */
-	synchronize_srcu(&gdev->desc_srcu);
+	srcu_barrier(&gdev->desc_srcu);
 	cleanup_srcu_struct(&gdev->desc_srcu);
 
 	ida_free(&gpio_ida, gdev->id);
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 553/555] gpiolib: free the label of lines released after their chip was removed
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (551 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 552/555] gpiolib: wait for pending label frees before cleaning up desc_srcu Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 554/555] drm/gud: fix potential divide error due to optimisation Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 555/555] cpufreq: intel_pstate: Use dedicated lock in set_power_ctl_ee_state() Greg Kroah-Hartman
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Andy Shevchenko, Adrian Ambrozewicz,
	Bartosz Golaszewski, Sasha Levin

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Adrian Ambrozewicz <aambrozewicz@nvidia.com>

[ Upstream commit 4bc5e234e10866ebaad01ce11ed08f64333dcac0 ]

gpiod_free_commit() drops the consumer label only while the chip is
still there. A line that user space keeps requested across
gpiochip_remove() is released when gdev->chip is already NULL, and its
label leaks:

  unreferenced object (size 32):
    comm "gpio-hold"
    backtrace (crc 7ff222d9):
      desc_set_label
      gpiod_request_commit
      gpiod_request
      linereq_create
      gpio_ioctl

Clear the label before the chip check. The ->free() callback, the flags
update and the line state notification need the chip and stay under it.

Reproduced with gpio-sim: request a line, set the chip's "live"
attribute to 0, then close the request. kmemleak reports up to 30 such
objects after 30 cycles; with this change, none after 100.

Fixes: 35b545332b80 ("gpio: remove gpio_lock")
Cc: stable@vger.kernel.org
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Adrian Ambrozewicz <aambrozewicz@nvidia.com>
Link: https://patch.msgid.link/20261124-gpiolib-chip-removal-v8-2-aambrozewicz@nvidia.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
[ sashal: Replaced the GPIOD_FLAG_REQUESTED name in the test_bit() condition with this tree's older FLAG_REQUESTED, leaving the rest of the upstream logic unchanged. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/gpio/gpiolib.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 86ab8bc142ca1..129b8345b5d4c 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2427,14 +2427,18 @@ static void gpiod_free_commit(struct gpio_desc *desc)
 
 	flags = READ_ONCE(desc->flags);
 
-	if (guard.gc && test_bit(FLAG_REQUESTED, &flags)) {
+	if (guard.gc && !test_bit(FLAG_REQUESTED, &flags))
+		return;
+
+	desc_set_label(desc, NULL);
+
+	if (guard.gc) {
 		if (guard.gc->free)
 			guard.gc->free(guard.gc, gpio_chip_hwgpio(desc));
 
 #ifdef CONFIG_OF_DYNAMIC
 		WRITE_ONCE(desc->hog, NULL);
 #endif
-		desc_set_label(desc, NULL);
 		set_mask_bits(&desc->flags,
 			      BIT(FLAG_ACTIVE_LOW) |
 			      BIT(FLAG_REQUESTED) |
-- 
2.53.0




^ permalink raw reply related	[flat|nested] 556+ messages in thread

* [PATCH 6.12 554/555] drm/gud: fix potential divide error due to optimisation
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (552 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 553/555] gpiolib: free the label of lines released after their chip was removed Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  2026-12-04 10:09 ` [PATCH 6.12 555/555] cpufreq: intel_pstate: Use dedicated lock in set_power_ctl_ee_state() Greg Kroah-Hartman
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable; +Cc: Greg Kroah-Hartman, patches, Thomas Zimmermann, Ruben Wauters

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ruben Wauters <ruben.wauters@linux.dev>

commit cbea6bdc930b2de974e77e6c3031f67796793625 upstream.

Compilers can potentially optmise the read of gdrm->stats_actual_length
to two separate reads. As flagged by sashiko, when the rect is flushed
the stats_actual_length can reset to zero. If this was to occur between
the two reads, the divide error can still be triggered (albeit rarely).

Fix this by adding a READ_ONCE around the gdrm->stats_actual_length

Fixes: 431c2dffd2b7 ("drm/gud: avoid divide error in gud_stats_debugfs")
Cc: <stable@vger.kernel.org>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patch.msgid.link/20261117141943.10540-1-ruben.wauters@linux.dev
Signed-off-by: Ruben Wauters <ruben.wauters@linux.dev>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/gud/gud_drv.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/gpu/drm/gud/gud_drv.c
+++ b/drivers/gpu/drm/gud/gud_drv.c
@@ -343,7 +343,7 @@ static int gud_stats_debugfs(struct seq_
 	seq_puts(m, "\n");
 
 	if (gdrm->compression) {
-		u64 actual_length = gdrm->stats_actual_length;
+		u64 actual_length = READ_ONCE(gdrm->stats_actual_length);
 		u64 remainder;
 		u64 ratio, ratio_frac;
 



^ permalink raw reply	[flat|nested] 556+ messages in thread

* [PATCH 6.12 555/555] cpufreq: intel_pstate: Use dedicated lock in set_power_ctl_ee_state()
  2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
                   ` (553 preceding siblings ...)
  2026-12-04 10:09 ` [PATCH 6.12 554/555] drm/gud: fix potential divide error due to optimisation Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
  554 siblings, 0 replies; 556+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
  To: stable
  Cc: Greg Kroah-Hartman, patches, Borah, Chaitanya Kumar,
	Rafael J. Wysocki

6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

commit 569e1eb36b033f42a9c363ffe4bfbf50bdadae51 upstream.

Commit eee2a44e4e2b ("cpufreq: Improve suspend-resume synchronization")
caused lockdep to complain about a possible circular locking dependency
because intel_pstate_resume() is now called under cpus_read_lock, and it
calls set_power_ctl_ee_state() that acquires intel_pstate_driver_lock
which can be held around CPU hotplug locking.

Fortunately, this cannot lead to a real deadlock because
intel_pstate_resume() does not run in parallel with the other holders
of intel_pstate_driver_lock, but in fact set_power_ctl_ee_state() need
not use that particular lock either.  Moreover, the original purpose of
that lock is different, so using it in set_power_ctl_ee_state() is
questionable.

Accordingly, introduce a dedicated mutex for protecting MSR_IA32_POWER_CTL
updates and power_ctl_ee_state accesses and make set_power_ctl_ee_state()
use it instead of intel_pstate_driver_lock.  Also take it directly in
intel_pstate_resume() around the EE state restore.

Fixes: eee2a44e4e2b ("cpufreq: Improve suspend-resume synchronization")
Reported-by: "Borah, Chaitanya Kumar" <chaitanya.kumar.borah@intel.com>
Closes: https://lore.kernel.org/linux-pm/efcb1647-46fd-442a-bbda-283560d9df53@intel.com/
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/2862244.mvXUDI8C0e@rafael.j.wysocki
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/cpufreq/intel_pstate.c |   26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -1276,13 +1276,15 @@ static void intel_pstate_hwp_offline(str
 #define POWER_CTL_EE_ENABLE	1
 #define POWER_CTL_EE_DISABLE	2
 
+static DEFINE_MUTEX(power_ctl_update_lock);
 static int power_ctl_ee_state;
 
-static void set_power_ctl_ee_state(bool input)
+static void __set_power_ctl_ee_state(bool input)
 {
 	u64 power_ctl;
 
-	mutex_lock(&intel_pstate_driver_lock);
+	lockdep_assert_held(&power_ctl_update_lock);
+
 	rdmsrl(MSR_IA32_POWER_CTL, power_ctl);
 	if (input) {
 		power_ctl &= ~BIT(MSR_IA32_POWER_CTL_BIT_EE);
@@ -1292,7 +1294,13 @@ static void set_power_ctl_ee_state(bool
 		power_ctl_ee_state = POWER_CTL_EE_DISABLE;
 	}
 	wrmsrl(MSR_IA32_POWER_CTL, power_ctl);
-	mutex_unlock(&intel_pstate_driver_lock);
+}
+
+static void set_power_ctl_ee_state(bool input)
+{
+	guard(mutex)(&power_ctl_update_lock);
+
+	__set_power_ctl_ee_state(input);
 }
 
 static void intel_pstate_hwp_enable(struct cpudata *cpudata);
@@ -1323,11 +1331,13 @@ static int intel_pstate_resume(struct cp
 
 	pr_debug("CPU %d resuming\n", cpu->cpu);
 
-	/* Only restore if the system default is changed */
-	if (power_ctl_ee_state == POWER_CTL_EE_ENABLE)
-		set_power_ctl_ee_state(true);
-	else if (power_ctl_ee_state == POWER_CTL_EE_DISABLE)
-		set_power_ctl_ee_state(false);
+	scoped_guard(mutex, &power_ctl_update_lock) {
+		/* Only restore if the system default has changed */
+		if (power_ctl_ee_state == POWER_CTL_EE_ENABLE)
+			__set_power_ctl_ee_state(true);
+		else if (power_ctl_ee_state == POWER_CTL_EE_DISABLE)
+			__set_power_ctl_ee_state(false);
+	}
 
 	if (cpu->suspended && hwp_active) {
 		mutex_lock(&intel_pstate_limits_lock);



^ permalink raw reply	[flat|nested] 556+ messages in thread

end of thread, other threads:[~2026-12-04 13:09 UTC | newest]

Thread overview: 556+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 10:00 [PATCH 6.12 000/555] 6.12.121-rc1 review Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 001/555] net: ipv6: keep room for the mac header in dst_dev_overhead() Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 002/555] virtgpu: dont reset on shutdown Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 003/555] virtio: add virtio_device_shutdown() helper Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 004/555] virtio_balloon: factor out virtballoon_quiesce() Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 005/555] virtio_balloon: quiesce balloon work before device shutdown Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 006/555] mm/page_alloc: snapshot the preferred zone against shrink rebuilds Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 007/555] pidfd: restrict task access ioctls to the callers pid namespace Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 008/555] net/smc: fix link group ownership in handshake abort Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 009/555] net/mlx5e: Fix queue stats access to queues without stats Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 010/555] tcp: do not coalesce segments after FIN Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 011/555] tcp: fastopen: note that a child socket was created Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 012/555] tcp: fix request_sock use-after-free during Fast Open accept() Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 013/555] net: gro: invalidate frag0 after a pull Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 014/555] wifi: mac80211: fix use-after-free on TTLM disconnect Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 015/555] dm: fix infinite loop in dm_blk_do_report_zones() Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 6.12 016/555] iio: common: scmi_sensors: fix truncating 64-bit divisions Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 017/555] iio: proximity: sx9500: ignore event config writes that dont change state Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 018/555] iio: imu: inv_mpu6050: fix swapped accel and gyro startup times Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 019/555] mmc: jz4740: Remove the host before resetting the controller Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 020/555] ALSA: hda: Fix [codec] ID matching in patch files for IDs with bit 31 set Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 021/555] kprobes: Adopt guard() and scoped_guard() Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 022/555] mmc: omap: synchronize clock timer before disabling fclk Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 023/555] mmc: sunxi: Use devm_mmc_alloc_host() helper Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 024/555] mmc: sunxi: fix clock and runtime PM leaks on probe failure Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 025/555] errseq: eliminate special limitation for macro MAX_ERRNO Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 026/555] errseq: dont let errseq_check_and_advance() hide later errors Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 027/555] xsk: defer software checksum until the skb is complete Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 028/555] cpufreq: Improve suspend-resume synchronization Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 029/555] tpm: flush timeout work outside buffer_mutex to avoid deadlock Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 030/555] spi: tegra210-quad: Track DMA mapping state Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 031/555] watchdog: npcm: Remove unnecessary NULL check before clk_prepare_enable/clk_disable_unprepare Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 032/555] watchdog: npcm: fix clock prepare leak when setting timeout on a running watchdog Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 033/555] tracing/probes: Enable newly appended probe when target event is enabled Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 034/555] tracing/probes: Fix missing BTF kind checks in char pointer/array helpers Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 035/555] xfrm: Dont clobber inner headers when already set Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 036/555] Bluetooth: hci_core: Fix not checking skb length on hci_scodata_packet Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 037/555] mtd: core: avoid double-free of OTP NVMEM device Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 038/555] bpf: Introduce jit_required flag and remove bpf_prog_has_kfunc_call() Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 039/555] bpf: Reject programs with inlined helpers if JIT is not available Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 040/555] bpf: Disallow interpreter fallback for arena-related insns Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 041/555] bpf: Disallow interpreter fallback for BPF_ADDR_PERCPU insn Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 042/555] mm/page_alloc: dont increase highatomic reserve after pcp alloc Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 043/555] mm/page_alloc: use existing highatomic reserves on the buddy fastpath Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 044/555] xprtrdma: serialize unmap_sync with xprt_disconnect Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 045/555] gve: Fix race between stats query and queue reconfig Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 046/555] gve: Block invalid ring sizes when device options are 0 Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 047/555] net: wait for in-flight device unregistrations before netns dismantle Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 048/555] ksmbd: pin parent dentries in SMB2 CREATE ACL path Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 049/555] ksmbd: refuse to read a handle that is not open for reading Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 050/555] tracing/probes: Fix BTF bitfield parsing and out-of-bounds buffer write Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 051/555] comedi: comedi_bond: Fix leak of opened device references Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 052/555] Bluetooth: btusb: fix use-after-free in force_poll_sync Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 053/555] tools/bootconfig: Close only opened braces in compact output Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 054/555] ipv6: Remove IPV6_ADDRFORM Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 055/555] iio: proximity: sx9360: fix sampling frequency write and available range Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 056/555] KEYS: Expand key->{datalen,quotalen} to unsigned int Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 057/555] keys: keyctl_pkey: replace BUG with return -EOPNOTSUPP Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 058/555] KEYS: Protect pkey method checks against type removal Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 059/555] tcp: move __reqsk_free() out of line Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 060/555] tcp: free saved_syn after an RCU grace period Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 061/555] cgroup/cpuset: Correctly set isolated_cpus when switching partition state Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 062/555] arm64: suspend: rely on daif helpers to handle PMR Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 063/555] arm64: suspend: Only track cpuidle context for idle tasks Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 064/555] pNFS: avoid repeatedly cancelling I/O for the same lseg Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 065/555] watchdog: rz: Discard pm_runtime_put() return values Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 066/555] watchdog: rzv2h: Use pm_runtime_put_sync() Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 067/555] hwmon: (nct6775) Handle dual use registers Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 068/555] s390/dasd: Fix typo immediatly -> immediately Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 069/555] s390/dasd: Re-initialize RCD buffer with "V1.0" before every start Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 070/555] sched/core: Do not touch SMT siblings that have not joined the core yet Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 071/555] ksmbd: skip metadata-only opens in sharing checks Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 072/555] wifi: mac80211_hwsim: ignore non-generic netlink releases Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 073/555] gpio: mvebu: name regmaps to fix debugfs collisions Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 074/555] gpio: mvebu: fix sleeping-while-atomic in mvebu_gpio_level_irq_mask() Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 075/555] gpio: keep the chip reference when deferred setup fails Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 6.12 076/555] mm/mmzone: read each zoneref slot once when filtering by nodemask Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 077/555] mm/page_alloc: retry allocations that raced with a zonelist rebuild Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 078/555] mm/hugetlb: retry the pool walk when the zonelist is rebuilt Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 079/555] kprobes: Fix error return and slot leak in __register_kprobe() Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 080/555] page_alloc: allow migration of smaller hugepages during contig_alloc Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 081/555] mm/page_alloc: retry alloc_contig_pages() when the zonelist is rebuilt Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 082/555] mm/page_alloc: dont undo another isolation in alloc_contig_range Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 083/555] mm/page_alloc: remove the zone_spans_pfn() check from get_pfnblock_bitmap_bitidx() Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 084/555] Bluetooth: L2CAP: Only accept LE responses to outstanding requests Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 085/555] kprobes: Validate re-registration earlier in register_kretprobe() Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 086/555] kprobes: Reduce preempt disable scope in check_kprobe_access_safe() Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 087/555] jump_label: Define guard() for jump_label_lock Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 088/555] kprobes: Use guard() for external locks Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 089/555] kprobes: Switch ftrace ops when adding probe with post_handler Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 090/555] net: warn, if pf->create does not clear sock->sk on error Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 091/555] socket: Print pf->create() when it does not clear sock->sk on failure Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 092/555] netfilter: nf_dup{4, 6}: Move duplication check to task_struct Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 093/555] netfilter: nf_dup: preserve guard across NFQUEUE reinjection Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 094/555] vsock: do not leave dangling sk pointer in vsock_create() Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 095/555] cpufreq: Introduce policy->boost_supported flag Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 096/555] cpufreq: Avoid redundant target() calls for unchanged limits Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 097/555] cpufreq: Fix updates of cached resolved frequency and index Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 098/555] sched_ext: Fix ops.enqueue/dispatch() calls before ops.cpu_online() Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 099/555] Bluetooth: l2cap: defer conn param update to avoid conn->lock/hdev->lock inversion Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 100/555] Revert "mm/hugetlb_vmemmap: fix incorrect vmemmap restore in rollback" Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 101/555] selftests: net: reuseport_bpf_numa: include stdbool.h Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 102/555] smb/client: Prevent error pointer dereference Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 103/555] smb: client: validate descriptor headers before query result allocation Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 104/555] dm cache: validate the discard block size before narrowing Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 105/555] dm: fix use-after-free when dm_get_device() widens the open mode Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 106/555] dm: fail a REQ_PREFLUSH bio with data when its preflush fails Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 107/555] iio: adc: ad7923: add the AD7927 to the SPI ID table Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 108/555] iio: temperature: hid-sensor-temperature: Use per-instance callbacks Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 109/555] ACPI: PM: Avoid initializing power management for absent devices Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 110/555] Revert "ALSA: hda/realtek: Fix silent speaker on Higole F9B" Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 111/555] ovl: use wrapper ovl_revert_creds() Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 112/555] ovl: make redirect/metacopy rejection consistent Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 113/555] ovl: refactor ovl_lookup() Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 114/555] ovl: do not read the flags of a put upper dentry in lookup Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 115/555] ovl: fix leak of lowerdata redirect on ovl_get_inode() failure Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 116/555] ovl: bump the impure dir version when linking a file with origin Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 117/555] smb: client: hold server ref while queueing reconnect work Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 118/555] smb: client: dont write back through O_DIRECT handles Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 119/555] smb: client: dont fail writeback preparation if the task is dying Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 120/555] serial: core: respect runtime PM when sending x_char Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 121/555] usb: typec: ucsi: acpi: Assume UCSI 1.0 on HP ZBook 8 G2i 14 Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 122/555] usb: dwc3: Always deassert xilinx resets Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 123/555] usb: dwc3: xilinx: re-assert resets on ZynqMP init error paths Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 124/555] w1: w1_therm: lock the list of slaves for the bulk read Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 125/555] devres: add devm_remove_action_nowarn() Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 126/555] devres: Move devm_*_action*() APIs to devres.h Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 127/555] devres: Add devm_is_action_added() helper Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 128/555] usb: dwc3: xilinx: unwind ZynqMP platform init on probe failure and remove Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 129/555] iio: humidity: hid-sensor-humidity: Use per-instance callbacks Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 130/555] iio: proximity: hx9023s: Allocate trigger before requesting IRQ Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 131/555] ipvs: read flags and seqs in master atomically Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 132/555] ipvs: honor the overload state and do not enter it forever Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 133/555] iio: light: apds9306: fix PM reference leak in apds9306_read_data() Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 134/555] drm/ast: Handle framebuffer from dma-buf Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 135/555] iio: invensense: Prevent possible integer overflow while multiplication Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 6.12 136/555] iio: common: fix spelling mistakes in comments Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 137/555] iio: inv_sensors: convert to kernel types Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 138/555] iio: inv_sensors: better timestamp alignment when using watermark Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 139/555] iio: inv_sensors: improve period measurement by using a longer delay Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 140/555] iio: inv_sensors: prevent timestamps going back in time in transitions Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 141/555] iio: inv_sensors: fix estimated value larger than interrupt timestamp Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 142/555] iio: inv_sensors: do not compute period estimation when updating odr Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 143/555] Revert "wifi: ath10k: Stop unanswered temperature reads" Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 144/555] firmware: arm_scmi: Update ARM_SCMI_HAVE_TRANSPORT rationale Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 145/555] firmware: smccc: Provide stubs for HAVE_ARM_SMCCC_DISCOVERY=n Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 146/555] HID: vivaldi: Extract feature report value directly in vivaldi_feature_mapping() Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 147/555] HID: vivaldi: avoid redundant feature report reads per usage Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 148/555] firmware: arm_scmi: imx: Validate MISC control response size Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 149/555] firmware: arm_scmi: Unregister notifier on enable failure Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 150/555] soundwire: qcom: disable the interrupt before gating the clock Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 151/555] memory: tegra: Shut down Tegra210 EMC timers before teardown Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 152/555] memory: tegra: fix device_node leak in tegra186_mc_probe_device() Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 153/555] irqchip/gic-v4: Clear the domain and fwnode pointers after freeing them Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 154/555] irqchip/gic-v4: Unwind what its_alloc_vcpu_irqs() allocated on failure Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 155/555] reset: scmi: Set the device for the reset controller Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 156/555] irqchip/gic-v4: Use a separate lockdep class for vPE doorbell IRQs Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 157/555] drm/msm: Fix a lock leak in msm_ioctl_gem_info_set_metadata() Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 158/555] selftests: drivers/s390x: Select uvdevice tests using the target architecture Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 159/555] phy: ingenic: fix unbalanced regulator disable in exit Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 160/555] phy: ti-pipe3: Fix ignored clock enable return value in init Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 161/555] phy: ti: pipe3: Fix clock resource leak on probe errors Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 162/555] phy: ti-pipe3: Fix EPROBE_DEFER handling for clock resources Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 163/555] phy: ti-pipe3: Fix clock leaks in init/exit error paths Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 164/555] ksmbd: sign the last response of a compound that ends early Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 165/555] scsi: lpfc: Fix race conditions in ELS retry handling Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 166/555] scsi: ch: Remove the minor from ch_index_idr after device_destroy() Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 167/555] phy: rockchip: snps-pcie3: Raise the SRAM init timeout Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 168/555] Bluetooth: mgmt: Fix read_index_list() buffer overflow Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 169/555] Bluetooth: hci_core: Take req_sync lock in hci_power_on() Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 170/555] Bluetooth: hci_sync: Lock the lookup in hci_disable_ext_adv_instance_sync() Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 171/555] Bluetooth: hci_sync: Hold hdev->lock in hci_schedule_adv_instance_sync() Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 172/555] Bluetooth: hci_event: Fix not using key encryption size when its known Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 173/555] Bluetooth: SMP: Serialize link key updates from smp_notify_keys() Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 174/555] Bluetooth: SMP: Check smp_data before using SMP_DEV() Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 175/555] Bluetooth: SMP: Dont create the BR/EDR channel while unregistered Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 176/555] Bluetooth: hci_event: Validate sent command length in LE Set Ext Adv Enable Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 177/555] s390/cert_store: Check key_lookup() return code in invalidate_keyring_keys() Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 178/555] s390/cert_store: Fix cs_keyring reference leak in fill_cs_keyring() Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 179/555] s390/cert_store: Fix potential use-after-free caused by find_cs_keyring() Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 180/555] s390/cert_store: Remove unnecessary static specifier in create_cs_keyring() Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 181/555] s390/cert_store: Fix error handling of get_user_session_keyring() Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 182/555] s390/cert_store: Fix keyring refcount handling in get_user_session_keyring() Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 183/555] s390/cert_store: Do not search the process keyrings for the cert_store keyring Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 184/555] s390/cert_store: Validate hash length in check_certificate_valid() Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 185/555] s390/cert_store: Fix max_vcxe_length output in pr_dbf_vcssb() Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 186/555] s390/cert_store: Fix out-of-bounds read in pr_dbf_vce() Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 187/555] s390/cert_store: Initialize ism array in query_diag320_subcodes() Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 188/555] Bluetooth: mgmt: Reject zero multi advertising rotation duration Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 189/555] Bluetooth: L2CAP: Dont use uninitialized EFS in l2cap_parse_conf_rsp() Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 190/555] Bluetooth: mgmt: Fix mesh transmission locking and lifetime Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 191/555] Bluetooth: MGMT: Fix use-after-free in mgmt_powering_down() Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 192/555] Bluetooth: MSFT: Protect the event prefix with hdev->lock Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 193/555] Bluetooth: hci_core: Hold hdev->lock when removing advertisement monitors Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 194/555] Bluetooth: MSFT: Free the response of the monitor commands Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 195/555] Bluetooth: hci_core: Dont fail removing a monitor unknown to the controller Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 6.12 196/555] HID: magicmouse: disable the multitouch work on removal Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 197/555] HID: sensor-hub: Synchronize callback removal with raw events Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 198/555] HID: sensor: custom: Set owner for misc device Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 199/555] HID: sensor: custom: Disable sensor before hub close on removal Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 200/555] cxgb4: allocate the full ethtool filter location array Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 201/555] net: bcm4908_enet: fix the TX ring wrap Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 202/555] net: bcm4908_enet: drop a TX frame whose DMA mapping failed Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 203/555] net: bcm4908_enet: release the TX ring on stop Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 204/555] net: bcm4908_enet: unmap the buffer of a dropped RX frame Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 205/555] net: bcm4908_enet: unmap RX buffers on stop with their mapped size Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 206/555] net: bcm4908_enet: publish the buffer address before OWN Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 207/555] net: bcm4908_enet: order the TX ring index accesses Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 208/555] scsi: pm8001: Offset hardware queue index for MSI-X pre-vector Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 209/555] dmaengine: stm32-mdma: Fix runtime PM reference leak in pm_suspend Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 210/555] dmaengine: idxd: Free the minor number when cdev setup fails Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 211/555] dmaengine: rcar-dmac: Fix PM usage counter imbalance Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 212/555] dmaengine: rcar-dmac: Add missing dma_descriptor_unmap() Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 213/555] usb: gadget: f_hid: fix report_list entries leak Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 214/555] usb: gadget: f_hid: fix race between userspace report update and GET_REPORT response Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 215/555] usb: gadget: f_hid: fix get_req leak when usb_gstrings_attach() fails Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 216/555] HID: sensor: custom: Fix state lifetime during removal Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 217/555] HID: sensor: custom: Serialize misc device reads Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 218/555] HID: sensor: custom: Register enable attribute after misc device Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 219/555] HID: sensor-hub: Remove clients before stopping hardware Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 220/555] HID: letsketch: skip string descriptors the firmware does not implement Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 221/555] HID: nintendo: release the player ID when LED setup fails Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 222/555] usb: cdns3: report endpoint reset timeout Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 223/555] Bluetooth: MSFT: Record the filter state on Command Disallowed Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 224/555] Bluetooth: MSFT: Only enable the advertisement filter with monitors Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 225/555] ALSA: pcm: Fix potential ABBA deadlock at snd_pcm_action_nonatomic() Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 226/555] ipv6, calipso: fix data-race in calipso_cache_add() bucketsize check Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 227/555] net: marvell: prestera: disable port before changing its MAC mode Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 228/555] net/mlx5e: Release FIB event work flows before dropping RTNL Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 229/555] net: clear skb->mac_len in skb_unset_mac_header() Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 230/555] net/mlx5: DR, Fix out-of-bounds write when sync to HW fails Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 231/555] scsi: ufs-mediatek: Restore the M-PHY power state when va09 disable fails Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 232/555] net: qrtr: ns: keep notifying local servers after a failed send Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 233/555] riscv: efi: Map runtime MMIO with device attributes Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 234/555] net: do not run out of frags in alloc_skb_with_frags() Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 235/555] net/mlx5: E-Switch, skip vport change work for disabled vports Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 236/555] ice: use global queue index in TC to-queue offload Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 237/555] ice: allow reading the last byte of the NVM and Shadow RAM regions Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 238/555] ALSA: hda: intel: Release i915 power also when delayed probe fails Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 239/555] tools/bootconfig: Use the registered global tracing parameter names Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 240/555] tun: complete the zerocopy buffer of packets consumed by XDP Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 241/555] tools: gpio-hammer: Accept the maximum number of line offsets Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 242/555] tools: gpio: Preserve device listing errors in lsgpio Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 243/555] tools: gpio: Return success after monitoring requested events Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 244/555] s390/cert_store: Allocate keyring with link restriction Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 245/555] s390/cert_store: Only allow the kernel to create cert_store_key keys Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 246/555] chardev: GPIO common access methods: repair non-kernel-doc comment Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 247/555] tun: flush uc and mc addresses in TUNSETLINK Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 248/555] btrfs: send: fix missing hole punching during incremental send Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 249/555] btrfs: send: fix invalid access to inline extents in clone_range() Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 250/555] btrfs: wait for a grace period before freeing a new device Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 251/555] ASoC: fsl_asrc: fix pair ownership on repeated or failed hw_params Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 252/555] ASoC: fsl_easrc: fix context ownership on repeated hw_params Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 253/555] btrfs: remove devid kobject when deleting a missing device Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 254/555] btrfs: pass struct btrfs_inode to btrfs_double_mmap_lock() Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 255/555] btrfs: pass struct btrfs_inode to btrfs_double_mmap_unlock() Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 6.12 256/555] btrfs: use struct btrfs_inode inside btrfs_remap_file_range() Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 257/555] btrfs: use struct btrfs_inode inside btrfs_remap_file_range_prep() Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 258/555] btrfs: pre-flush reflink source before taking inode locks Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 259/555] btrfs: downgrade the reflink source inode lock for tree walking Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 260/555] btrfs: fix race between concurrent sync direct IO writes Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 261/555] ASoC: SOF: control: reject out-of-range enum values Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 262/555] btrfs: fiemap: deal with inline extent in fiemap_find_last_extent_offset() Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 263/555] btrfs: abort transaction on failure to update inode after hole punching Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 264/555] btrfs: unfold transaction abort at __btrfs_update_delayed_inode() Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 265/555] btrfs: fix delayed inode count leak after failure to delete inode ref Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 266/555] jbd2: set JBD2_LOADED under j_state_lock Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 267/555] bpf: Let the bpf_fastcall boundary cover the longest pattern Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 268/555] net: sock_reuseport: Check program type on the migration path Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 269/555] arm64: dts: st: add PSCI idle state to STM32MP25 CPU domains Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 270/555] arm64: dts: st: add PSCI idle state to STM32MP23 " Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 271/555] arm64: dts: st: mark STM32MP23 timer as stopping in suspend Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 272/555] ftrace: Fix lost recursion records in ftrace_record_recursion() Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 273/555] workqueue: Skip redundant unbound updates during CPU bringup Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 274/555] net: dsa: b53: initialize the jumbo frame size register offset Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 275/555] net: dsa: b53: fix the SRAB grant timeout check Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 276/555] net: dsa: b53: use the correct override register 2 Gbps bit Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 277/555] net: dsa: b53: fix mirror port encoding on BCM5325 and BCM5365 Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 278/555] net: dsa: b53: fix mirror destination and source state tracking Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 279/555] net: bcmasp: avoid refcount drain on probe Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 280/555] net: bcmgenet: use napi_complete_done return value Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 281/555] net: bcmgenet: keep DIM from getting stuck after close or suspend Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 282/555] net: bcmgenet: accumulate the DIM packet and byte counters Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 283/555] net: bcmgenet: reset the Rx discard count with the ring Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 284/555] net: systemport: restart DIM from the default profile on start Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 285/555] net: systemport: accumulate the DIM packet and byte counters Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 286/555] ipv4: fix conntrack defrag forwarding after ip_frag_reinit() Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 287/555] tun: bound the NAPI receive queue Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 288/555] bpf: clear list node owner and unlink before drop Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 289/555] bpf: Save irq flags on the stack when freeing a list head or rb root Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 290/555] net: dsa: felix: fix NULL pointer dereference in felix_port_enable() Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 291/555] ipv6: mcast: do not pass uninitialized bytes to dev_mc_add() Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 292/555] tcp: Dont clear saddr before ->put_port() Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 293/555] bpf: Do not allow bpf_d_path() by an id of another BTF Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 294/555] bpf: Keep the names in front of a number in delegate options Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 295/555] bpf: Add the symbol of a prog before its id Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 296/555] bpf: Do not fill jited line info for a hidden subprog Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 297/555] bpf: Fix NULL dereference in XDP redirect from async callbacks Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 298/555] bpf: Fix reads past an enum in prints of BTF data Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 299/555] bpf: Give syscall programs without CAP_PERFMON the base helpers only Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 300/555] bpf: dont skip other information if xlated_prog_insns is skipped Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 301/555] bpf: Require CAP_PERFMON for dumps of xlated insns Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 302/555] bpf: Zero bpf_list_head in copies of map values Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 303/555] bpf: Clear the data that bpf_msg_push_data() adds Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 304/555] bpf: Fail loads from a network header that was not set Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 305/555] bpf: Clear family and port of a short address for cgroup sockaddr hooks Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 306/555] bpf: Take a neighbour of the L3 master in bpf_redirect_neigh() Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 307/555] bpf: Keep the MAC header in bpf_skb_change_tail() Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 308/555] bpf, sockmap: Hold the psock of the work in sk_psock_backlog() Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 309/555] net: dpaa2-eth: fix objtool warning and logic bug Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 310/555] tg3: Dont fail probe if 31-bit coherent DMA mask is unsupported Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 311/555] tg3: Skip management FW version when APE firmware is not ready Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 312/555] tg3: Fix heap overflow in unbuffered NVRAM write path Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 313/555] perf: Prevent duplicate sigtrap task work enqueue Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 314/555] perf: Fix sigtrap for software events Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 315/555] perf: Fix sigtrap vs fast-switch Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 6.12 316/555] gpio: davinci: use generic device properties Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 317/555] gpio: davinci: use controller-specific MMIO for BINTEN Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 318/555] gpio: mvebu: validate ngpios before use Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 319/555] bpf, sockmap: Clear the redirect target after the stream parser runs Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 320/555] block: fix BLKSECDISCARD zero-length range causing page cache invalidation Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 321/555] drm/gud: avoid divide error in gud_stats_debugfs Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 322/555] drm/i915/pps: Reset PPS state after TypeC port init on resume Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 323/555] drm/meson: encoder_dsi: load ENCL gamma table while ENCL is disabled Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 324/555] drm/nouveau/disp: Set drm_mode_config_funcs.atomic_(check|commit) (attempt 2) Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 325/555] drm/nouveau: do not return early from a synchronous VM_BIND Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 326/555] drm/radeon: Bound GPIO I2C table entry count from VBIOS Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 327/555] drm/radeon: only unregister the ATPX handler if we registered it Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 328/555] drm/amd/pm: send smu8 sclk level indices, not the level mask Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 329/555] drm/amdgpu/gfx_v9_0: Add gfxoff quirk for Lenovo Picasso 318F Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 330/555] drm/amd/display: Fix logger leak on perf trace allocation failure Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 331/555] drm/amdgpu: enable MGCG/FGCG/PERF_CLK for GC 11.0.2 Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 332/555] drm/amdgpu: Fix VCE buffer size check for DPB and input surface Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 333/555] drm/amdgpu: only unregister the ATPX handler if we registered it Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 334/555] drm/amdkfd: Acquire cwsr buffer during CRIU resume Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 335/555] drm/amdkfd: check CRIU SVM priv data bounds before allocating Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 336/555] drm/amdkfd: Dont reuse a VRAM page that is still referenced Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 337/555] drm/amdkfd: keep the DMA addresses of a range intact if splitting fails Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 338/555] drm/amdkfd: wait for the queue quiesce in concurrent SVM evictions Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 339/555] drm/vc4: Hold a runtime PM reference while allocating the binner BO Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 340/555] drm/vc4: Check for a validated shader before reading its thread mode Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 341/555] drm/vc4: Clear the slice caches before resetting a stalled GPU Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 342/555] drm/vc4: Fix off-by-one in the shader record BO handle check Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 343/555] drm/vc4: Start shader code at varying offsets in its BO Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 344/555] drm/vmwgfx: avoid underflow when stripping short GuestInfo replies Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 345/555] drm/vmwgfx: bound MKSSTAT lengths before rounding to pages Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 346/555] drm/vmwgfx: do not hand the embedded sg_table to the PRIME core Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 347/555] drm/vmwgfx: Erase the detached resource entry on resource release Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 348/555] drm/vmwgfx: fix NULL pointer dereference in vmw_validation_bo_fence() Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 349/555] drm/vmwgfx: log missing primary planes only once Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 350/555] drm/vmwgfx: log MOB limits outside the manager spinlock Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 351/555] drm/vmwgfx: reserve dumb buffers while detaching their surfaces Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 352/555] drm/vmwgfx: return an error when a shared GB surface has no backup buffer Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 353/555] drm/vmwgfx: validate command body sizes before parsing Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 354/555] drm/vmwgfx: close TOCTOU on guest_memory_bo in surface reference ioctl Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 355/555] ALSA: pcm: oss: Restore params flag after failed reconfiguration Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 356/555] ARC: io: work around GCC PR127718 in __raw_write{w,l}() Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 357/555] arm64: kexec: use a typed entry to fix kCFI oops Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 358/555] ASoC: qcom: audioreach: only disconnect the route a mixer control owns Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 359/555] ASoC: qcom: q6apm-dai: reject compress rings larger than the DMA buffer Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 360/555] ASoC: qcom: q6asm-dai: " Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 361/555] ASoC: qcom: q6dsp-lpass-clocks: Set driver data before registering clocks Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 362/555] ASoC: wm8962: Fix broken headset button caused by wrong guard constant Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 363/555] ata: libata-scsi: fix the INC_512 bit test for SECURITY PROTOCOL IN/OUT Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 364/555] blk-iocost: Fix overflow in donation weight calculation Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 365/555] Bluetooth: hci_qca: clear qca_memdump when discarding dump packets Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 366/555] Bluetooth: MGMT: Fix runtime config status opcode Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 367/555] cpufreq: CPPC: Set CPPC Enable register in cpu_init() Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 368/555] dma-coherent: serialize reserved memory pool initialization Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 369/555] dma: swiotlb: Properly tear down the default pool on exit Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 370/555] dma: swiotlb: Serialize restricted DMA pool initialization Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 371/555] EDAC/i5000: Fix slot number passed to determine_mtr() Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 372/555] fscrypt: Initialize ->ci_master_key before publication Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 373/555] fbdev: fm2fb: Fix iomem access Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 374/555] fbdev: macmodes: compare the pixel clock of each candidate mode Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 375/555] fbdev: radeonfb: reject a zero pixclock in radeonfb_check_var() Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 6.12 376/555] fbdev: smscufx: allocate the size advertised in smem_len Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 377/555] fbdev: smscufx: dont free registered framebuffer on probe error Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 378/555] fbdev: smscufx: keep the usb_device alive while ufx_data is in use Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 379/555] fbdev: sstfb: Error out if pixclock equals zero Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 380/555] fbdev: valkyriefb: keep the framebuffer mapping size fixed Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 381/555] fbdev: vfb: Validate framebuffer geometry and memory size Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 382/555] fuse: fix possible UAF in fuse_direntplus_link() Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 383/555] fuse: limit name size in listxattr Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 384/555] fuse: skip dcache instantiation for readdirplus names with embedded NUL Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 385/555] gpio: ljca: Validate the pin index of interrupt events Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 386/555] gpio: virtio: bound the line names block by its configured size Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 387/555] gpio: virtio: compute the line names size in a size_t Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 388/555] ieee802154: require CAP_NET_ADMIN for SIOCSIFADDR Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 389/555] iavf: fix ASQ command buffer leak on init failure Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 390/555] hwmon: (ads7871) Add error handle from spi_setup() Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 391/555] hwmon: (dell-smm) Reject a fan_max that the BIOS cannot take Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 392/555] hwmon: (dell-smm) Reject out-of-range pwm values Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 393/555] hwmon: (nct6775) Fix incorrect struct cast in beep callbacks Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 394/555] hwmon: (nct6775) Fix swapped temperature tolerance register writes Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 395/555] hwmon: (nct6775) Fix tolerance bitmask when reading REG_FAN_MODE Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 396/555] hwmon: (sht3x) Fix overflow when writing alert limits Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 397/555] hwmon: (w83791d) Fix incorrect struct cast in show_temp1() and store_temp1() Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 398/555] hwmon: (w83792d) " Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 399/555] Input: cyapa - fix runtime PM leak in cyapa_update_rt_suspend_scanrate() Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 400/555] Input: da7280 - do not advertise FF_GAIN Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 401/555] Input: goodix - reject a bak_ref length that cannot hold the checksum Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 402/555] Input: trackpoint - add new TP JYT_NDT device variant id 7 Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 403/555] Input: xpad - add support to Hori Real Arcade Pro 4 Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 404/555] ip6mr: prevent info-leak in ip6mr_cache_report() Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 405/555] mac802154: llsec: reject secured frames with security level 0 Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 406/555] maple_tree: fix rcu reader NULL dereference after the tree is emptied Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 407/555] mptcp: Avoid unsequenced accesses to jiffies in mptcp_reset_tout_timer() Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 408/555] net/tls: serialize context removal in tls_device_down() Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 409/555] ipv6: mcast: use skb_set_transport_header_careful() in ipv6_mc_check_exthdrs() Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 410/555] ipvs: ftp: skip conntrack templates in ip_vs_ftp_out Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 411/555] ipvs: reject FTP control ports as data ports Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 412/555] ipvs: validate cport in received sync records Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 413/555] KVM: PPC: Book3S HV: Avoid spurious interrupts caused by LPCR_MER bit Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 414/555] KVM: PPC: Book3S HV: Disable preemption around host-side HPT lock users Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 415/555] KVM: PPC: Book3S HV: Ensure that calls to idr_alloc are synchronized Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 416/555] KVM: PPC: Book3S HV: Take SRCU read lock around kvmppc_h_page_init() call Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 417/555] KVM: PPC: Book3S HV: XICS: Avoid NULL ptr deref in kvmppc_xive_cleanup_vcpu() Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 418/555] KVM: PPC: Book3S HV: XICS: Update irq_type for cleanup to work Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 419/555] mm/damon/core: reset watermark wait state on each iteration Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 420/555] mm/damon/tests/sysfs-kunit: fix leaked pid reference in add_targets test Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 421/555] mm/filemap: stop fault-around when the walk steps back Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 422/555] mm/khugepaged: dont map folios that are not uptodate in MADV_COLLAPSE Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 423/555] mm/migrate: move NR_FILE_THPS on cross-node migration Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 424/555] PPC32: Fix hard_irq_disable to follow tracing and lockdep state Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 425/555] qca_spi: Avoid unsequenced accesses to jiffies in qcaspi_netdev_tx_timeout() Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 426/555] RDMA/mlx5: Fix DevX umem page size truncation for pages >= 4G Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 427/555] RDMA/mlx5: Skip vport context query on FW without ib_virt support Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 428/555] RDMA/rtrs: Register client event handler after capability check Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 429/555] RDMA/siw: Fix use-after-free in siw_mem_id2obj() Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 430/555] RDMA/srpt: bound the indirect descriptor table to the IU Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 431/555] RDMA/srpt: reject zero-length buffer descriptors Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 432/555] RDMA/srpt: widen the indirect RDMA context counters Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 433/555] perf record: Reject CPU indices equal to the mask size Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 434/555] powerpc/eeh: NUL-terminate force recovery input Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 435/555] powerpc/xmon: Avoid unsequenced accesses to tsk in show_task() Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 6.12 436/555] powerpc32/modules: Reserve a PLT entry for ftrace_regs_caller Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 437/555] riscv: Fix SR_SUM leakage across context switches Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 438/555] s390/appldata: Fix error handling in appldata_generic_handler() Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 439/555] s390/dcssblk: Initialize device semaphore before sysfs registration Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 440/555] scsi: mpi3mr: Validate reply frame size bounds Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 441/555] scsi: rdac: Keep the error status when controller lookup fails Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 442/555] scsi: sd_zbc: Cap zone report count by buffer size Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 443/555] parisc: Fix register corruption in 32-bit dynamic ftrace Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 444/555] parisc: irq: Trace hardirq state in do_cpu_irq_mask() Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 445/555] objtool/rust: add more `noreturn` Rust functions for Rust 1.101.0 Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 446/555] ocfs2/dlmfs: keep the superblock alive during lock work Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 447/555] ocfs2: advance locking_state through the live cursor Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 448/555] ocfs2: fix kernel BUG in ocfs2_page_mkwrite() when write_end fails Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 449/555] ocfs2: serialize inode journal access with shutdown Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 450/555] sctp: do not free a new asoc peeled off while sendmsg slept Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 451/555] sctp: use skb_set_transport_header_careful() in sctp_v6_err() Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 452/555] selftests/landlock: Test that layering does not break refer Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 453/555] selinux: check MAP_SHARED_VALIDATE mappings as shared Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 454/555] spi: Fix runtime PM imbalance on pump transfer message error Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 455/555] tcp: Fix the SO_REUSEPORT bind cache admitting a conflicting socket Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 456/555] udp: use skb_set_transport_header_careful() in __udp6_lib_err_encap() Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 457/555] vgacon: Fall back to the dummy console if mapping VGA memory fails Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 458/555] virtiofs: fix use-after-free of fs->tag on device removal Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 459/555] watchdog: npcm: fix sleeping clock call in restart handler Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 460/555] x86/apic/msi: Fix MSI interrupt affinity configuration Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 461/555] x86/mce: Do not treat cache hierarchy errors as memory errors Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 462/555] xarray: fix index jumping backwards in xas_find() Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 463/555] zonefs: ignore RLIMIT_FSIZE above LLONG_MAX in zonefs_write_check_limits() Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 464/555] xfs: break layouts before swapping extents Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 465/555] xfs: keep successful near rt allocations Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 466/555] xfs: wait for direct I/O before swapping extents Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 467/555] net: bridge: fix skb leak of reinjected link-local frames Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 468/555] net: e1000: fix warning in iounmap on probe failure Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 469/555] net: gianfar: clear the pending Rx skb when freeing the Rx ring Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 470/555] net: microchip: encx24j600: Avoid unsequenced accesses to jiffies in encx24j600_tx() Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 471/555] net: openvswitch: use skb_set_transport_header_careful() in parse_ipv6hdr() Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 472/555] net: stmmac: dwmac1000: dont discard frames with only a checksum error Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 473/555] net: stmmac: honour Rx checksum errors in the AF_XDP zero-copy path Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 474/555] net: stmmac: re-enable on-chip parity checkers for XGMAC ASP 0x2 Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 475/555] net: usb: smsc75xx: reject frames without a full header and FCS Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 476/555] nvme-auth: use the parsed offset for the DH-CHAP key Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 477/555] nvme-loop: release the target request when SG setup fails Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 478/555] nvme-tcp: require the R2T offset to match the data sent Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 479/555] nvme: reject invalid reconnect_delay sysfs values Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 480/555] nvme: stop asynchronous event work before ANA teardown Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 481/555] nvmet-fc: reject duplicate queue IDs on Create Connection Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 482/555] nvmet-tcp: only wait for in-capsule data for inline SGLs Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 483/555] nvmet: handle short reads and writes in the file backend Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 484/555] nvmet: use overflow-safe range checks " Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 485/555] nvmet: zns: return the namespace lookup error for Identify Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 486/555] scsi: target: core: Parse APTPL res_type and res_scope as hex Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 487/555] scsi: target: Fix NULL pointer dereference in core_alua_do_port_transition() Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 488/555] scsi: target: Fix NULL pointer dereference in target_dev_alua_lu_gp_store() Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 489/555] scsi: target: iscsi: Check for existing sessions only after authentication Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 490/555] scsi: ufs: bsg: Abort ufs_bsg_request() when runtime resume fails Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 491/555] scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 492/555] smb: client: fix negative timestamps being read from smb Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 493/555] smb: client: fix times assignments in cifs_posix_to_fattr() Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 494/555] tracing/osnoise: Dont start a kthread in timerlat user-space mode Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 495/555] tracing/user_events: Dont free an event that a dynamic event still references Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 6.12 496/555] tracing/filters: Check for missing operand after operator in parse_pred() Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 497/555] tracing/filters: Fix MATCH_END_ONLY regex matching for fixed-size strings Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 498/555] tracing/filters: Handle out-of-range CPU for OP_NE in cpumask comparison Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 499/555] tracing/filters: Treat zero-length dynamic strings as empty Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 500/555] tracing: Avoid undefined shifts for zero histogram map size Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 501/555] tracing: Do not allow user events to add a system name Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 502/555] tracing: Drop the synthetic event ref when clearing hist triggers Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 503/555] tracing: Ignore .function on the function trace event Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 504/555] tracing: Take trace_access_lock() in tracing_buffers_ioctl() Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 505/555] netrom: clear the choke flag on frames sent again Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 506/555] netrom: bound the resequencing queue while we are busy Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 507/555] netrom: leave the busy state when the application reads Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 508/555] mkiss: leave the escaped state on any byte after FESC Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 509/555] ax25: leave the busy state when the application reads Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 510/555] rose: acknowledge delivered data before resetting a call Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 511/555] rose: say when we are busy, and leave the busy state on read Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 512/555] crypto: nx - fix nx_crypto_ctx_exit argument Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 513/555] net/sched: codel: bound the dropping loop per dequeue call Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 514/555] ipv6: Prevent rt6_insert_exception() for dying fib6_info Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 515/555] mm: constify pagemap related test/getter functions Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 516/555] filemap: Add folio_next_pos() Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 517/555] mm: limit pagecache folio refcount when mapping pages Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 518/555] mm: limit pagecache folio refcount when splicing into pipes Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 519/555] mm/mmu_gather: flush pending references early before the folio limit Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 520/555] mm/gup: limit pagecache folio refcount when grabbing references Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 521/555] ipv6: Remove FIB6_EXCEPTION_BUCKET_FLUSHED Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 522/555] ipv6: Flush exception route while replacing nexthop Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 523/555] ASoC: SOF: Intel: lnl: Enable offload for UAOL link Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 524/555] wifi: rtw89: modify active scan rule for 6GHz band Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 525/555] sched_ext: Enable tick for finite slices on nohz_full Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 526/555] drm/imagination: Set scheduler timeout period higher than Firmware timeout Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 527/555] vhost/net: Fix receive queue test in busy poll Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 528/555] i915/vma: use kfree_rcu to make sure vma are freed after a rcu grace period Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 529/555] usb: gadget: f_uac1_legacy: fix double close of the ALSA devices Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 530/555] ALSA: firewire-lib: Abort the FCP transaction on a bus reset Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 531/555] ALSA: fireworks: Abort the " Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 532/555] ALSA: oss: Fix deadlock at unregistering (again) Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 533/555] KEYS: Fix asym key overflow in keyctl_pkey_verify() Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 534/555] KEYS: Fix crash on big_key read Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 535/555] KEYS: Fix userspace buffer overflow in keyctl_pkey_e_d_s() Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 536/555] KEYS: serialise key instantiation against keyctl_chown_key() Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 537/555] KEYS: trusted: Update static calls before init Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 538/555] KEYS: Use kfree_sensitive() in keyctl_pkey_e_d_s() Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 539/555] ext4: fix OOB memmove in ext4_xattr_set_entry Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 540/555] xfrm: interface: drop non-IP packets before pskb_inet_may_pull() Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 541/555] net: prevent receive header offset overflow during decapsulation Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 542/555] scsi: target: iscsi: reject invalid size Extended CDB AHS Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 543/555] gpiolib: dont overwrite the entire flags field in gpiod_get_direction() Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 544/555] rcu/nocb: Avoid unsequenced accesses to jiffies in show_rcu_nocb_state() Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 545/555] block: Remove queue freezing from several sysfs store callbacks Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 546/555] nvme-tcp: use an aligned buffer for the TLS record type Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 547/555] nvme-tcp: move the TLS record read loop into a helper Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 548/555] nvme-tcp: consume TLS records without application data Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 549/555] direct-io: remove IOCB_NOWAIT support Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 550/555] drm/amd/display: Saturate refresh rates in v1/v2 FreeSync infopackets Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 551/555] gpiolib: dont overwrite the entire flags field in gpiod_free_commit() Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 552/555] gpiolib: wait for pending label frees before cleaning up desc_srcu Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 553/555] gpiolib: free the label of lines released after their chip was removed Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 554/555] drm/gud: fix potential divide error due to optimisation Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 6.12 555/555] cpufreq: intel_pstate: Use dedicated lock in set_power_ctl_ee_state() Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox