Skip to content

[rocky9_8] History Rebuild through kernel-5.14.0-687.5.3.el9_8#1250

Merged
PlaidCat merged 99 commits into
rocky9_8from
rocky9_8_rebuild
May 21, 2026
Merged

[rocky9_8] History Rebuild through kernel-5.14.0-687.5.3.el9_8#1250
PlaidCat merged 99 commits into
rocky9_8from
rocky9_8_rebuild

Conversation

@PlaidCat

@PlaidCat PlaidCat commented May 19, 2026

Copy link
Copy Markdown
Collaborator

This is an automated kernel history rebuild using cron and internal tooling. It follows the same process used for previous history rebuilds:

  • Download all unprocessed src.rpm packages
  • For each src.rpm:
    • Identify all commits in the changelog up to the last known tag (5.14.0-687)
    • Replay commits in chronological order (oldest to newest in the changelog) using git cherry-pick
    • Replace the code in the branch with the output of rpmbuild -bp for the corresponding src.rpm
    • Tag the rebuild branch

JIRA Tickets

Rebuild Splat Inspection

kernel-5.14.0-687.5.1.el9_8

$ cat ciq/ciq_backports/kernel-5.14.0-687.5.1.el9_8/rebuild.details.txt
Rebuild_History BUILDABLE
Rebuilding Kernel from rpm changelog with Fuzz Limit: 87.50%
Number of commits in upstream range v5.14~1..kernel-mainline: 380232
Number of commits in rpm: 99
Number of commits matched with upstream: 85 (85.86%)
Number of commits in upstream but not in rpm: 380147
Number of commits NOT found in upstream: 14 (14.14%)

Rebuilding Kernel on Branch rocky9_8_rebuild_kernel-5.14.0-687.5.1.el9_8 for kernel-5.14.0-687.5.1.el9_8
Clean Cherry Picks: 43 (50.59%)
Empty Cherry Picks: 42 (49.41%)
_______________________________

__EMPTY COMMITS__________________________
7cc183f2e67d19b03ee5c13a6664b8c6cc37ff9d mm: move page table sync declarations to linux/pgtable.h
f2d2f9598ebb0158a3fe17cda0106d7752e654a2 mm: introduce and use {pgd,p4d}_populate_kernel()
6659d027998083fbb6d42a165b0c90dc2e8ba989 x86/mm/64: define ARCH_PAGE_TABLE_SYNC_MASK and arch_sync_kernel_mappings()
e135826b2da0cf25305086dc9ac1e91718a148e1 mm/rmap: introduce and use hugetlb_remove_rmap()
59d9094df3d79443937add8700b2ef1a866b1081 mm: hugetlb: independent PMD page table shared count
14967a9c7d247841b0312c48dcf8cd29e55a4cc8 mm/hugetlb: fix copy_hugetlb_page_range() to use ->pt_share_count
3937027caecb4f8251e82dd857ba1d749bb5a428 mm/hugetlb: fix two comments related to huge_pmd_unshare()
b0752f1a709740fd6ae518e969a25f90ec6a100f mm/hugetlb: pass folio instead of page to unmap_ref_private()
81edb1ba3232afd45ae7f3f492a91019571b18c9 mm/hugetlb: refactor unmap_hugepage_range() to take folio instead of page
7f4b6065d9a842721a04632fc219aa453d1b2f5c mm/hugetlb: refactor __unmap_hugepage_range() to take folio instead of page
05275594a311cd7427a64b8bcc6097645c0344af mm/hugetlb: convert use of struct page to folio in __unmap_hugepage_range()
21cc2b5c5062a256ae9064442d37ebbc23f5aef7 mm/hugetlb: add missing hugetlb_lock in __unmap_hugepage_range()
8ce720d5bd91e9dc16db3604aa4b1bf76770a9a1 mm/hugetlb: fix excessive IPI broadcasts when unsharing PMD tables using mmu_gather
eafb64f40ca49c79f0769aab25d0fae5c9d3becb vsock: add netns to vsock core
a69686327e42912e87d1f4be23f54ce1eae4dbd2 vsock: add netns support to virtio transports
9dd391493a727464e9a03cfff9356c8e10b8da0b vsock: fix child netns mode initialization
6a997f38bdf822d4c5cc10b445ff1cb26872580a vsock: prevent child netns mode switch from local to global
5cc619583c7e735c4fb801bede671fb6f9c79425 vsock: Use container_of() to get net namespace in sysctl handlers
102eab95f025b4d3f3a6c0a858400aca2af2fe52 vsock: lock down child_ns_mode as write-once
b7880cb166ab62c2409046b2347261abf701530e migrate: correct lock ordering for hugetlb file folios
7288185ce87ec70133b7bc3b694b0f74bf46a0ee gfs2: less aggressive low-memory log flushing
9ec84f79c5a7a65cd69b5b705a203759665160cd perf: Remove unnecessary parameter of security check
b0a09142622a994c4f4088c3f61db5da87cfc711 perf/amd/ibs: Avoid calling perf_allow_kernel() from the IBS NMI handler
1b80b6f446ed262077f5212ad213e8ead2cdecc3 crypto/krb5: Test manager data
3936f02bf2d3308a7359dd37dd96cd60603d8170 crypto/krb5: Implement Kerberos crypto core
025ac491f4eeb48c03353719f0de20a6db36b826 crypto/krb5: Add an API to query the layout of the crypto section
a9c27d2d87a388433db100889262841afe771f7a crypto/krb5: Add an API to alloc and prepare a crypto object
0392b110ccaf543b31842b04c8142f4f8ce7bdec crypto/krb5: Add an API to perform requests
41cf1d1e8a86c5c675982136f07c519c4b15b157 crypto/krb5: Provide infrastructure and key derivation
c8d8f6af66c3cd7896460da4a0ddd006f391f6d2 crypto/krb5: Implement the Kerberos5 rfc3961 key derivation
8bcdbfa89f4fc1ab7b06e784cb9c3346a943955e crypto/krb5: Provide RFC3961 setkey packaging functions
00244da40f7821b242c4612428d4192230dba27f crypto/krb5: Implement the Kerberos5 rfc3961 encrypt and decrypt functions
348f5669d1f6c1c210b9017ebb8b82282eca6f25 crypto/krb5: Implement the Kerberos5 rfc3961 get_mic and verify_mic
7c164b66b276c49b3888d3280e1b70a85732a38c crypto/krb5: Implement the AES enctypes from rfc3962
6c3c0e86c2acf53bf67c095c67335a0bec2a16af crypto/krb5: Implement the AES enctypes from rfc8009
742e38d4d4033e7ff53178acf7edd2b1fe0142ef crypto/krb5: Implement the Camellia enctypes from rfc6803
fc0cf10c04f49ddba1925b630467f49ea993569e crypto/krb5: Implement crypto self-testing
da6f9bf40ac267b5c720694a817beea84fa40f77 crypto: krb5 - Use SG miter instead of doing it by hand
eed848871c96d4b5a7b06307755b75abd0cc7a06 crypto/krb5: Fix change to use SG miter to use offset
b19f1ab8d5bf417e00d5855c62e061fb449b13c5 crypto: krb5 - Fix memory leak in krb5_test_one_prf()
b7cc142dbafeaf6c053284ca9121b9f70b6d6d06 libceph: add support for CEPH_CRYPTO_AES256KRB5
8356b4b1103b8c970648c94bab724aa30e42d869 libceph: adapt ceph_x_challenge_blob hashing and msgr1 message signing

__CHANGES NOT IN UPSTREAM________________
Replace sbat with Rocky Linux sbat
Change bug tracker URL
Ensure appended release in sbat is removed'
kabi: enable check-kabi
kabi: add symbols to stablelist
redhat/configs: disable CONFIG_CRYPTO_KRB5_SELFTESTS
redhat/configs: enable CONFIG_CRYPTO_KRB5[ENC]
redhat: genlog: add new JIRA cloud server hostname
io_uring: graduate to full support
Add signing key for Nvidia Jetson and Bluefield GPU signing keys
Add NVIDIA Jetson signing key for OOT modules
redhat: update self-test data
redhat: set defaults for 9.8
gitlab-ci: disttag override for 9.8

kernel-5.14.0-687.5.3.el9_8

$ cat ciq/ciq_backports/kernel-5.14.0-687.5.3.el9_8/rebuild.details.txt
Rebuild_History BUILDABLE
Rebuilding Kernel from rpm changelog with Fuzz Limit: 87.50%
Number of commits in upstream range v5.14~1..kernel-mainline: 380232
Number of commits in rpm: 14
Number of commits matched with upstream: 10 (71.43%)
Number of commits in upstream but not in rpm: 380222
Number of commits NOT found in upstream: 4 (28.57%)

Rebuilding Kernel on Branch rocky9_8_rebuild_kernel-5.14.0-687.5.3.el9_8 for kernel-5.14.0-687.5.3.el9_8
Clean Cherry Picks: 4 (40.00%)
Empty Cherry Picks: 6 (60.00%)
_______________________________

__EMPTY COMMITS__________________________
a664bf3d603dc3bdcf9ae47cc21e0daec706d7a5 crypto: algif_aead - Revert to operating out-of-place
8eceab19eba9dcbfd2a0daec72e1bf48aa100170 crypto: af_alg - limit RX SG extraction by receive buffer budget
31d00156e50ecad37f2cb6cbf04aaa9a260505ef crypto: af_alg - Fix page reassignment overflow in af_alg_pull_tsgl
e02494114ebf7c8b42777c6cd6982f113bfdbec7 crypto: authencesn - Do not place hiseq at end of dst for out-of-place decryption
1f48ad3b19a9dfc947868edda0bb8e48e5b5a8fa crypto: authencesn - Fix src offset when decrypting in-place
5aa58c3a572b3e3b6c786953339f7978b845cc52 crypto: algif_aead - snapshot IV for async AEAD requests

__CHANGES NOT IN UPSTREAM________________
Replace sbat with Rocky Linux sbat
Change bug tracker URL
Ensure appended release in sbat is removed'
xfrm: esp: avoid in-place decrypt on shared skb frags

BUILD

$ grep -E -B 5 -A 5 "\[TIMER\]|^Starting Build" $(ls -t kbuild* | head -n1)
/mnt/code/kernel-src-tree-build
Running make mrproper...
  CLEAN   scripts/basic
  CLEAN   scripts/kconfig
  CLEAN   include/config include/generated
[TIMER]{MRPROPER}: 5s
x86_64 architecture detected, copying config
'configs/kernel-x86_64-rhel.config' -> '.config'
Setting Local Version for build
CONFIG_LOCALVERSION="-rocky9_8_rebuild-6206e514e8a1"
Making olddefconfig
--
  HOSTCC  scripts/kconfig/util.o
  HOSTLD  scripts/kconfig/conf
#
# configuration written to .config
#
Starting Build
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_32.h
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_64.h
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_x32.h
  SYSTBL  arch/x86/include/generated/asm/syscalls_32.h
  SYSHDR  arch/x86/include/generated/asm/unistd_32_ia32.h
--
  BTF [M] sound/usb/usx2y/snd-usb-usx2y.ko
  LD [M]  sound/xen/snd_xen_front.ko
  BTF [M] sound/x86/snd-hdmi-lpe-audio.ko
  BTF [M] sound/virtio/virtio_snd.ko
  BTF [M] sound/xen/snd_xen_front.ko
[TIMER]{BUILD}: 1438s
Making Modules
  INSTALL /lib/modules/5.14.0-rocky9_8_rebuild-6206e514e8a1/kernel/arch/x86/crypto/blake2s-x86_64.ko
  INSTALL /lib/modules/5.14.0-rocky9_8_rebuild-6206e514e8a1/kernel/arch/x86/crypto/blowfish-x86_64.ko
  INSTALL /lib/modules/5.14.0-rocky9_8_rebuild-6206e514e8a1/kernel/arch/x86/crypto/camellia-aesni-avx-x86_64.ko
  INSTALL /lib/modules/5.14.0-rocky9_8_rebuild-6206e514e8a1/kernel/arch/x86/crypto/camellia-aesni-avx2.ko
--
  SIGN    /lib/modules/5.14.0-rocky9_8_rebuild-6206e514e8a1/kernel/sound/usb/usx2y/snd-usb-usx2y.ko
  SIGN    /lib/modules/5.14.0-rocky9_8_rebuild-6206e514e8a1/kernel/sound/virtio/virtio_snd.ko
  SIGN    /lib/modules/5.14.0-rocky9_8_rebuild-6206e514e8a1/kernel/sound/x86/snd-hdmi-lpe-audio.ko
  SIGN    /lib/modules/5.14.0-rocky9_8_rebuild-6206e514e8a1/kernel/sound/xen/snd_xen_front.ko
  DEPMOD  /lib/modules/5.14.0-rocky9_8_rebuild-6206e514e8a1
[TIMER]{MODULES}: 16s
Making Install
sh ./arch/x86/boot/install.sh 5.14.0-rocky9_8_rebuild-6206e514e8a1 \
	arch/x86/boot/bzImage System.map "/boot"
[TIMER]{INSTALL}: 22s
Checking kABI
kABI check passed
Setting Default Kernel to /boot/vmlinuz-5.14.0-rocky9_8_rebuild-6206e514e8a1 and Index to 0
Hopefully Grub2.0 took everything ... rebooting after time metrices
[TIMER]{MRPROPER}: 5s
[TIMER]{BUILD}: 1438s
[TIMER]{MODULES}: 16s
[TIMER]{INSTALL}: 22s
[TIMER]{TOTAL} 1487s
Rebooting in 10 seconds

KSelfTests

$ get_kselftest_diff.sh
kselftest.5.14.0-rocky9_7_rebuild-198ac3bfa55c.log
313
kselftest.5.14.0-rocky9_7_rebuild-a329e5e04e2d.log
313
kselftest.5.14.0-rocky9_7_rebuild-c294943263c6.log
313
kselftest.5.14.0-rocky9_8_rebuild-6206e514e8a1.log
311
Before: kselftest.5.14.0-rocky9_7_rebuild-c294943263c6.log
After: kselftest.5.14.0-rocky9_8_rebuild-6206e514e8a1.log
Diff:
-ok 1 selftests: futex: run.sh
-ok 1 selftests: net/hsr: hsr_ping.sh # SKIP

PlaidCat added 30 commits May 19, 2026 18:43
jira KERNEL-1035
cve CVE-2025-71085
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Will Rosenberg <whrosenb@asu.edu>
commit 58fc734

There exists a kernel oops caused by a BUG_ON(nhead < 0) at
net/core/skbuff.c:2232 in pskb_expand_head().
This bug is triggered as part of the calipso_skbuff_setattr()
routine when skb_cow() is passed headroom > INT_MAX
(i.e. (int)(skb_headroom(skb) + len_delta) < 0).

The root cause of the bug is due to an implicit integer cast in
__skb_cow(). The check (headroom > skb_headroom(skb)) is meant to ensure
that delta = headroom - skb_headroom(skb) is never negative, otherwise
we will trigger a BUG_ON in pskb_expand_head(). However, if
headroom > INT_MAX and delta <= -NET_SKB_PAD, the check passes, delta
becomes negative, and pskb_expand_head() is passed a negative value for
nhead.

Fix the trigger condition in calipso_skbuff_setattr(). Avoid passing
"negative" headroom sizes to skb_cow() within calipso_skbuff_setattr()
by only using skb_cow() to grow headroom.

PoC:
	Using `netlabelctl` tool:

        netlabelctl map del default
        netlabelctl calipso add pass doi:7
        netlabelctl map add default address:0::1/128 protocol:calipso,7

        Then run the following PoC:

        int fd = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);

        // setup msghdr
        int cmsg_size = 2;
        int cmsg_len = 0x60;
        struct msghdr msg;
        struct sockaddr_in6 dest_addr;
        struct cmsghdr * cmsg = (struct cmsghdr *) calloc(1,
                        sizeof(struct cmsghdr) + cmsg_len);
        msg.msg_name = &dest_addr;
        msg.msg_namelen = sizeof(dest_addr);
        msg.msg_iov = NULL;
        msg.msg_iovlen = 0;
        msg.msg_control = cmsg;
        msg.msg_controllen = cmsg_len;
        msg.msg_flags = 0;

        // setup sockaddr
        dest_addr.sin6_family = AF_INET6;
        dest_addr.sin6_port = htons(31337);
        dest_addr.sin6_flowinfo = htonl(31337);
        dest_addr.sin6_addr = in6addr_loopback;
        dest_addr.sin6_scope_id = 31337;

        // setup cmsghdr
        cmsg->cmsg_len = cmsg_len;
        cmsg->cmsg_level = IPPROTO_IPV6;
        cmsg->cmsg_type = IPV6_HOPOPTS;
        char * hop_hdr = (char *)cmsg + sizeof(struct cmsghdr);
        hop_hdr[1] = 0x9; //set hop size - (0x9 + 1) * 8 = 80

        sendmsg(fd, &msg, 0);

Fixes: 2917f57 ("calipso: Allow the lsm to label the skbuff directly.")
	Suggested-by: Paul Moore <paul@paul-moore.com>
	Signed-off-by: Will Rosenberg <whrosenb@asu.edu>
	Acked-by: Paul Moore <paul@paul-moore.com>
Link: https://patch.msgid.link/20251219173637.797418-1-whrosenb@asu.edu
	Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit 58fc734)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>
jira KERNEL-1035
cve CVE-2025-39844
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Harry Yoo <harry.yoo@oracle.com>
commit 7cc183f
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.1.el9_8/7cc183f2.failed

During our internal testing, we started observing intermittent boot
failures when the machine uses 4-level paging and has a large amount of
persistent memory:

  BUG: unable to handle page fault for address: ffffe70000000034
  #PF: supervisor write access in kernel mode
  #PF: error_code(0x0002) - not-present page
  PGD 0 P4D 0
  Oops: 0002 [#1] SMP NOPTI
  RIP: 0010:__init_single_page+0x9/0x6d
  Call Trace:
   <TASK>
   __init_zone_device_page+0x17/0x5d
   memmap_init_zone_device+0x154/0x1bb
   pagemap_range+0x2e0/0x40f
   memremap_pages+0x10b/0x2f0
   devm_memremap_pages+0x1e/0x60
   dev_dax_probe+0xce/0x2ec [device_dax]
   dax_bus_probe+0x6d/0xc9
   [... snip ...]
   </TASK>

It turns out that the kernel panics while initializing vmemmap (struct
page array) when the vmemmap region spans two PGD entries, because the new
PGD entry is only installed in init_mm.pgd, but not in the page tables of
other tasks.

And looking at __populate_section_memmap():
  if (vmemmap_can_optimize(altmap, pgmap))
          // does not sync top level page tables
          r = vmemmap_populate_compound_pages(pfn, start, end, nid, pgmap);
  else
          // sync top level page tables in x86
          r = vmemmap_populate(start, end, nid, altmap);

In the normal path, vmemmap_populate() in arch/x86/mm/init_64.c
synchronizes the top level page table (See commit 9b86152 ("x86-64,
mem: Update all PGDs for direct mapping and vmemmap mapping changes")) so
that all tasks in the system can see the new vmemmap area.

However, when vmemmap_can_optimize() returns true, the optimized path
skips synchronization of top-level page tables.  This is because
vmemmap_populate_compound_pages() is implemented in core MM code, which
does not handle synchronization of the top-level page tables.  Instead,
the core MM has historically relied on each architecture to perform this
synchronization manually.

We're not the first party to encounter a crash caused by not-sync'd top
level page tables: earlier this year, Gwan-gyeong Mun attempted to address
the issue [1] [2] after hitting a kernel panic when x86 code accessed the
vmemmap area before the corresponding top-level entries were synced.  At
that time, the issue was believed to be triggered only when struct page
was enlarged for debugging purposes, and the patch did not get further
updates.

It turns out that current approach of relying on each arch to handle the
page table sync manually is fragile because 1) it's easy to forget to sync
the top level page table, and 2) it's also easy to overlook that the
kernel should not access the vmemmap and direct mapping areas before the
sync.

# The solution: Make page table sync more code robust and harder to miss

To address this, Dave Hansen suggested [3] [4] introducing
{pgd,p4d}_populate_kernel() for updating kernel portion of the page tables
and allow each architecture to explicitly perform synchronization when
installing top-level entries.  With this approach, we no longer need to
worry about missing the sync step, reducing the risk of future
regressions.

The new interface reuses existing ARCH_PAGE_TABLE_SYNC_MASK,
PGTBL_P*D_MODIFIED and arch_sync_kernel_mappings() facility used by
vmalloc and ioremap to synchronize page tables.

pgd_populate_kernel() looks like this:
static inline void pgd_populate_kernel(unsigned long addr, pgd_t *pgd,
                                       p4d_t *p4d)
{
        pgd_populate(&init_mm, pgd, p4d);
        if (ARCH_PAGE_TABLE_SYNC_MASK & PGTBL_PGD_MODIFIED)
                arch_sync_kernel_mappings(addr, addr);
}

It is worth noting that vmalloc() and apply_to_range() carefully
synchronizes page tables by calling p*d_alloc_track() and
arch_sync_kernel_mappings(), and thus they are not affected by this patch
series.

This series was hugely inspired by Dave Hansen's suggestion and hence
added Suggested-by: Dave Hansen.

Cc stable because lack of this series opens the door to intermittent
boot failures.

This patch (of 3):

Move ARCH_PAGE_TABLE_SYNC_MASK and arch_sync_kernel_mappings() to
linux/pgtable.h so that they can be used outside of vmalloc and ioremap.

Link: https://lkml.kernel.org/r/20250818020206.4517-1-harry.yoo@oracle.com
Link: https://lkml.kernel.org/r/20250818020206.4517-2-harry.yoo@oracle.com
Link: https://lore.kernel.org/linux-mm/20250220064105.808339-1-gwan-gyeong.mun@intel.com [1]
Link: https://lore.kernel.org/linux-mm/20250311114420.240341-1-gwan-gyeong.mun@intel.com [2]
Link: https://lore.kernel.org/linux-mm/d1da214c-53d3-45ac-a8b6-51821c5416e4@intel.com [3]
Link: https://lore.kernel.org/linux-mm/4d800744-7b88-41aa-9979-b245e8bf794b@intel.com  [4]
Fixes: 8d40091 ("x86/vmemmap: handle unpopulated sub-pmd ranges")
	Signed-off-by: Harry Yoo <harry.yoo@oracle.com>
	Acked-by: Kiryl Shutsemau <kas@kernel.org>
	Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
	Reviewed-by: "Uladzislau Rezki (Sony)" <urezki@gmail.com>
	Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
	Acked-by: David Hildenbrand <david@redhat.com>
	Cc: Alexander Potapenko <glider@google.com>
	Cc: Alistair Popple <apopple@nvidia.com>
	Cc: Andrey Konovalov <andreyknvl@gmail.com>
	Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
	Cc: Andy Lutomirski <luto@kernel.org>
	Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
	Cc: Anshuman Khandual <anshuman.khandual@arm.com>
	Cc: Ard Biesheuvel <ardb@kernel.org>
	Cc: Arnd Bergmann <arnd@arndb.de>
	Cc: bibo mao <maobibo@loongson.cn>
	Cc: Borislav Betkov <bp@alien8.de>
	Cc: Christoph Lameter (Ampere) <cl@gentwo.org>
	Cc: Dennis Zhou <dennis@kernel.org>
	Cc: Dev Jain <dev.jain@arm.com>
	Cc: Dmitriy Vyukov <dvyukov@google.com>
	Cc: Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>
	Cc: Ingo Molnar <mingo@redhat.com>
	Cc: Jane Chu <jane.chu@oracle.com>
	Cc: Joao Martins <joao.m.martins@oracle.com>
	Cc: Joerg Roedel <joro@8bytes.org>
	Cc: John Hubbard <jhubbard@nvidia.com>
	Cc: Kevin Brodsky <kevin.brodsky@arm.com>
	Cc: Liam Howlett <liam.howlett@oracle.com>
	Cc: Michal Hocko <mhocko@suse.com>
	Cc: Oscar Salvador <osalvador@suse.de>
	Cc: Peter Xu <peterx@redhat.com>
	Cc: Peter Zijlstra <peterz@infradead.org>
	Cc: Qi Zheng <zhengqi.arch@bytedance.com>
	Cc: Ryan Roberts <ryan.roberts@arm.com>
	Cc: Suren Baghdasaryan <surenb@google.com>
	Cc: Tejun Heo <tj@kernel.org>
	Cc: Thomas Gleinxer <tglx@linutronix.de>
	Cc: Thomas Huth <thuth@redhat.com>
	Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
	Cc: Vlastimil Babka <vbabka@suse.cz>
	Cc: Dave Hansen <dave.hansen@linux.intel.com>
	Cc: <stable@vger.kernel.org>
	Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 7cc183f)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	include/linux/pgtable.h
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Harry Yoo <harry.yoo@oracle.com>
commit f2d2f95
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.1.el9_8/f2d2f959.failed

Introduce and use {pgd,p4d}_populate_kernel() in core MM code when
populating PGD and P4D entries for the kernel address space.  These
helpers ensure proper synchronization of page tables when updating the
kernel portion of top-level page tables.

Until now, the kernel has relied on each architecture to handle
synchronization of top-level page tables in an ad-hoc manner.  For
example, see commit 9b86152 ("x86-64, mem: Update all PGDs for direct
mapping and vmemmap mapping changes").

However, this approach has proven fragile for following reasons:

  1) It is easy to forget to perform the necessary page table
     synchronization when introducing new changes.
     For instance, commit 4917f55 ("mm/sparse-vmemmap: improve memory
     savings for compound devmaps") overlooked the need to synchronize
     page tables for the vmemmap area.

  2) It is also easy to overlook that the vmemmap and direct mapping areas
     must not be accessed before explicit page table synchronization.
     For example, commit 8d40091 ("x86/vmemmap: handle unpopulated
     sub-pmd ranges")) caused crashes by accessing the vmemmap area
     before calling sync_global_pgds().

To address this, as suggested by Dave Hansen, introduce _kernel() variants
of the page table population helpers, which invoke architecture-specific
hooks to properly synchronize page tables.  These are introduced in a new
header file, include/linux/pgalloc.h, so they can be called from common
code.

They reuse existing infrastructure for vmalloc and ioremap.
Synchronization requirements are determined by ARCH_PAGE_TABLE_SYNC_MASK,
and the actual synchronization is performed by
arch_sync_kernel_mappings().

This change currently targets only x86_64, so only PGD and P4D level
helpers are introduced.  Currently, these helpers are no-ops since no
architecture sets PGTBL_{PGD,P4D}_MODIFIED in ARCH_PAGE_TABLE_SYNC_MASK.

In theory, PUD and PMD level helpers can be added later if needed by other
architectures.  For now, 32-bit architectures (x86-32 and arm) only handle
PGTBL_PMD_MODIFIED, so p*d_populate_kernel() will never affect them unless
we introduce a PMD level helper.

[harry.yoo@oracle.com: fix KASAN build error due to p*d_populate_kernel()]
  Link: https://lkml.kernel.org/r/20250822020727.202749-1-harry.yoo@oracle.com
Link: https://lkml.kernel.org/r/20250818020206.4517-3-harry.yoo@oracle.com
Fixes: 8d40091 ("x86/vmemmap: handle unpopulated sub-pmd ranges")
	Signed-off-by: Harry Yoo <harry.yoo@oracle.com>
	Suggested-by: Dave Hansen <dave.hansen@linux.intel.com>
	Acked-by: Kiryl Shutsemau <kas@kernel.org>
	Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
	Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
	Acked-by: David Hildenbrand <david@redhat.com>
	Cc: Alexander Potapenko <glider@google.com>
	Cc: Alistair Popple <apopple@nvidia.com>
	Cc: Andrey Konovalov <andreyknvl@gmail.com>
	Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
	Cc: Andy Lutomirski <luto@kernel.org>
	Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
	Cc: Anshuman Khandual <anshuman.khandual@arm.com>
	Cc: Ard Biesheuvel <ardb@kernel.org>
	Cc: Arnd Bergmann <arnd@arndb.de>
	Cc: bibo mao <maobibo@loongson.cn>
	Cc: Borislav Betkov <bp@alien8.de>
	Cc: Christoph Lameter (Ampere) <cl@gentwo.org>
	Cc: Dennis Zhou <dennis@kernel.org>
	Cc: Dev Jain <dev.jain@arm.com>
	Cc: Dmitriy Vyukov <dvyukov@google.com>
	Cc: Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>
	Cc: Ingo Molnar <mingo@redhat.com>
	Cc: Jane Chu <jane.chu@oracle.com>
	Cc: Joao Martins <joao.m.martins@oracle.com>
	Cc: Joerg Roedel <joro@8bytes.org>
	Cc: John Hubbard <jhubbard@nvidia.com>
	Cc: Kevin Brodsky <kevin.brodsky@arm.com>
	Cc: Liam Howlett <liam.howlett@oracle.com>
	Cc: Michal Hocko <mhocko@suse.com>
	Cc: Oscar Salvador <osalvador@suse.de>
	Cc: Peter Xu <peterx@redhat.com>
	Cc: Peter Zijlstra <peterz@infradead.org>
	Cc: Qi Zheng <zhengqi.arch@bytedance.com>
	Cc: Ryan Roberts <ryan.roberts@arm.com>
	Cc: Suren Baghdasaryan <surenb@google.com>
	Cc: Tejun Heo <tj@kernel.org>
	Cc: Thomas Gleinxer <tglx@linutronix.de>
	Cc: Thomas Huth <thuth@redhat.com>
	Cc: "Uladzislau Rezki (Sony)" <urezki@gmail.com>
	Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
	Cc: Vlastimil Babka <vbabka@suse.cz>
	Cc: <stable@vger.kernel.org>
	Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit f2d2f95)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	include/linux/pgtable.h
#	mm/percpu.c
#	mm/sparse-vmemmap.c
…ings()

jira KERNEL-1035
cve CVE-2025-39845
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Harry Yoo <harry.yoo@oracle.com>
commit 6659d02
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.1.el9_8/6659d027.failed

Define ARCH_PAGE_TABLE_SYNC_MASK and arch_sync_kernel_mappings() to ensure
page tables are properly synchronized when calling p*d_populate_kernel().

For 5-level paging, synchronization is performed via
pgd_populate_kernel().  In 4-level paging, pgd_populate() is a no-op, so
synchronization is instead performed at the P4D level via
p4d_populate_kernel().

This fixes intermittent boot failures on systems using 4-level paging and
a large amount of persistent memory:

  BUG: unable to handle page fault for address: ffffe70000000034
  #PF: supervisor write access in kernel mode
  #PF: error_code(0x0002) - not-present page
  PGD 0 P4D 0
  Oops: 0002 [#1] SMP NOPTI
  RIP: 0010:__init_single_page+0x9/0x6d
  Call Trace:
   <TASK>
   __init_zone_device_page+0x17/0x5d
   memmap_init_zone_device+0x154/0x1bb
   pagemap_range+0x2e0/0x40f
   memremap_pages+0x10b/0x2f0
   devm_memremap_pages+0x1e/0x60
   dev_dax_probe+0xce/0x2ec [device_dax]
   dax_bus_probe+0x6d/0xc9
   [... snip ...]
   </TASK>

It also fixes a crash in vmemmap_set_pmd() caused by accessing vmemmap
before sync_global_pgds() [1]:

  BUG: unable to handle page fault for address: ffffeb3ff1200000
  #PF: supervisor write access in kernel mode
  #PF: error_code(0x0002) - not-present page
  PGD 0 P4D 0
  Oops: Oops: 0002 [#1] PREEMPT SMP NOPTI
  Tainted: [W]=WARN
  RIP: 0010:vmemmap_set_pmd+0xff/0x230
   <TASK>
   vmemmap_populate_hugepages+0x176/0x180
   vmemmap_populate+0x34/0x80
   __populate_section_memmap+0x41/0x90
   sparse_add_section+0x121/0x3e0
   __add_pages+0xba/0x150
   add_pages+0x1d/0x70
   memremap_pages+0x3dc/0x810
   devm_memremap_pages+0x1c/0x60
   xe_devm_add+0x8b/0x100 [xe]
   xe_tile_init_noalloc+0x6a/0x70 [xe]
   xe_device_probe+0x48c/0x740 [xe]
   [... snip ...]

Link: https://lkml.kernel.org/r/20250818020206.4517-4-harry.yoo@oracle.com
Fixes: 8d40091 ("x86/vmemmap: handle unpopulated sub-pmd ranges")
	Signed-off-by: Harry Yoo <harry.yoo@oracle.com>
Closes: https://lore.kernel.org/linux-mm/20250311114420.240341-1-gwan-gyeong.mun@intel.com [1]
	Suggested-by: Dave Hansen <dave.hansen@linux.intel.com>
	Acked-by: Kiryl Shutsemau <kas@kernel.org>
	Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
	Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
	Acked-by: David Hildenbrand <david@redhat.com>
	Cc: Alexander Potapenko <glider@google.com>
	Cc: Alistair Popple <apopple@nvidia.com>
	Cc: Andrey Konovalov <andreyknvl@gmail.com>
	Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
	Cc: Andy Lutomirski <luto@kernel.org>
	Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
	Cc: Anshuman Khandual <anshuman.khandual@arm.com>
	Cc: Ard Biesheuvel <ardb@kernel.org>
	Cc: Arnd Bergmann <arnd@arndb.de>
	Cc: bibo mao <maobibo@loongson.cn>
	Cc: Borislav Betkov <bp@alien8.de>
	Cc: Christoph Lameter (Ampere) <cl@gentwo.org>
	Cc: Dennis Zhou <dennis@kernel.org>
	Cc: Dev Jain <dev.jain@arm.com>
	Cc: Dmitriy Vyukov <dvyukov@google.com>
	Cc: Ingo Molnar <mingo@redhat.com>
	Cc: Jane Chu <jane.chu@oracle.com>
	Cc: Joao Martins <joao.m.martins@oracle.com>
	Cc: Joerg Roedel <joro@8bytes.org>
	Cc: John Hubbard <jhubbard@nvidia.com>
	Cc: Kevin Brodsky <kevin.brodsky@arm.com>
	Cc: Liam Howlett <liam.howlett@oracle.com>
	Cc: Michal Hocko <mhocko@suse.com>
	Cc: Oscar Salvador <osalvador@suse.de>
	Cc: Peter Xu <peterx@redhat.com>
	Cc: Peter Zijlstra <peterz@infradead.org>
	Cc: Qi Zheng <zhengqi.arch@bytedance.com>
	Cc: Ryan Roberts <ryan.roberts@arm.com>
	Cc: Suren Baghdasaryan <surenb@google.com>
	Cc: Tejun Heo <tj@kernel.org>
	Cc: Thomas Gleinxer <tglx@linutronix.de>
	Cc: Thomas Huth <thuth@redhat.com>
	Cc: "Uladzislau Rezki (Sony)" <urezki@gmail.com>
	Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
	Cc: Vlastimil Babka <vbabka@suse.cz>
	Cc: <stable@vger.kernel.org>
	Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 6659d02)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	arch/x86/include/asm/pgtable_64_types.h
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author David Hildenbrand <david@redhat.com>
commit e135826
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.1.el9_8/e135826b.failed

hugetlb rmap handling differs quite a lot from "ordinary" rmap code.  For
example, hugetlb currently only supports entire mappings, and treats any
mapping as mapped using a single "logical PTE".  Let's move it out of the
way so we can overhaul our "ordinary" rmap.  implementation/interface.

Let's introduce and use hugetlb_remove_rmap() and remove the hugetlb code
from page_remove_rmap().  This effectively removes one check on the
small-folio path as well.

Add sanity checks that we end up with the right folios in the right
functions.

Note: all possible candidates that need care are page_remove_rmap() that
      pass compound=true.

Link: https://lkml.kernel.org/r/20231220224504.646757-3-david@redhat.com
	Signed-off-by: David Hildenbrand <david@redhat.com>
	Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
	Reviewed-by: Ryan Roberts <ryan.roberts@arm.com>
	Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
	Reviewed-by: Muchun Song <songmuchun@bytedance.com>
	Cc: Hugh Dickins <hughd@google.com>
	Cc: Muchun Song <muchun.song@linux.dev>
	Cc: Peter Xu <peterx@redhat.com>
	Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit e135826)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	mm/hugetlb.c
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author David Hildenbrand (Red Hat) <david@kernel.org>
commit a8682d5

PMD page table unsharing no longer touches the refcount of a PMD page
table.  Also, it is not about dropping the refcount of a "PMD page" but
the "PMD page table".

Let's just simplify by saying that the PMD page table was unmapped,
consequently also unmapping the folio that was mapped into this page.

This code should be deduplicated in the future.

Link: https://lkml.kernel.org/r/20251223214037.580860-4-david@kernel.org
Fixes: 59d9094 ("mm: hugetlb: independent PMD page table shared count")
	Signed-off-by: David Hildenbrand (Red Hat) <david@kernel.org>
	Reviewed-by: Rik van Riel <riel@surriel.com>
	Tested-by: Laurence Oberman <loberman@redhat.com>
	Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
	Acked-by: Oscar Salvador <osalvador@suse.de>
	Cc: Liu Shixin <liushixin2@huawei.com>
	Cc: Harry Yoo <harry.yoo@oracle.com>
	Cc: Lance Yang <lance.yang@linux.dev>
	Cc: "Uschakow, Stanislav" <suschako@amazon.de>
	Cc: <stable@vger.kernel.org>
	Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit a8682d5)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>
jira KERNEL-1035
cve CVE-2024-57883
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Liu Shixin <liushixin2@huawei.com>
commit 59d9094
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.1.el9_8/59d9094d.failed

The folio refcount may be increased unexpectly through try_get_folio() by
caller such as split_huge_pages.  In huge_pmd_unshare(), we use refcount
to check whether a pmd page table is shared.  The check is incorrect if
the refcount is increased by the above caller, and this can cause the page
table leaked:

 BUG: Bad page state in process sh  pfn:109324
 page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x66 pfn:0x109324
 flags: 0x17ffff800000000(node=0|zone=2|lastcpupid=0xfffff)
 page_type: f2(table)
 raw: 017ffff800000000 0000000000000000 0000000000000000 0000000000000000
 raw: 0000000000000066 0000000000000000 00000000f2000000 0000000000000000
 page dumped because: nonzero mapcount
 ...
 CPU: 31 UID: 0 PID: 7515 Comm: sh Kdump: loaded Tainted: G    B              6.13.0-rc2master+ #7
 Tainted: [B]=BAD_PAGE
 Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015
 Call trace:
  show_stack+0x20/0x38 (C)
  dump_stack_lvl+0x80/0xf8
  dump_stack+0x18/0x28
  bad_page+0x8c/0x130
  free_page_is_bad_report+0xa4/0xb0
  free_unref_page+0x3cc/0x620
  __folio_put+0xf4/0x158
  split_huge_pages_all+0x1e0/0x3e8
  split_huge_pages_write+0x25c/0x2d8
  full_proxy_write+0x64/0xd8
  vfs_write+0xcc/0x280
  ksys_write+0x70/0x110
  __arm64_sys_write+0x24/0x38
  invoke_syscall+0x50/0x120
  el0_svc_common.constprop.0+0xc8/0xf0
  do_el0_svc+0x24/0x38
  el0_svc+0x34/0x128
  el0t_64_sync_handler+0xc8/0xd0
  el0t_64_sync+0x190/0x198

The issue may be triggered by damon, offline_page, page_idle, etc, which
will increase the refcount of page table.

1. The page table itself will be discarded after reporting the
   "nonzero mapcount".

2. The HugeTLB page mapped by the page table miss freeing since we
   treat the page table as shared and a shared page table will not be
   unmapped.

Fix it by introducing independent PMD page table shared count.  As
described by comment, pt_index/pt_mm/pt_frag_refcount are used for s390
gmap, x86 pgds and powerpc, pt_share_count is used for x86/arm64/riscv
pmds, so we can reuse the field as pt_share_count.

Link: https://lkml.kernel.org/r/20241216071147.3984217-1-liushixin2@huawei.com
Fixes: 39dde65 ("[PATCH] shared page table for hugetlb page")
	Signed-off-by: Liu Shixin <liushixin2@huawei.com>
	Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
	Cc: Ken Chen <kenneth.w.chen@intel.com>
	Cc: Muchun Song <muchun.song@linux.dev>
	Cc: Nanyong Sun <sunnanyong@huawei.com>
	Cc: Jane Chu <jane.chu@oracle.com>
	Cc: <stable@vger.kernel.org>
	Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 59d9094)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	mm/hugetlb.c
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Jane Chu <jane.chu@oracle.com>
commit 14967a9
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.1.el9_8/14967a9c.failed

commit 59d9094 ("mm: hugetlb: independent PMD page table shared
count") introduced ->pt_share_count dedicated to hugetlb PMD share count
tracking, but omitted fixing copy_hugetlb_page_range(), leaving the
function relying on page_count() for tracking that no longer works.

When lazy page table copy for hugetlb is disabled, that is, revert commit
bcd51a3 ("hugetlb: lazy page table copies in fork()") fork()'ing with
hugetlb PMD sharing quickly lockup -

[  239.446559] watchdog: BUG: soft lockup - CPU#75 stuck for 27s!
[  239.446611] RIP: 0010:native_queued_spin_lock_slowpath+0x7e/0x2e0
[  239.446631] Call Trace:
[  239.446633]  <TASK>
[  239.446636]  _raw_spin_lock+0x3f/0x60
[  239.446639]  copy_hugetlb_page_range+0x258/0xb50
[  239.446645]  copy_page_range+0x22b/0x2c0
[  239.446651]  dup_mmap+0x3e2/0x770
[  239.446654]  dup_mm.constprop.0+0x5e/0x230
[  239.446657]  copy_process+0xd17/0x1760
[  239.446660]  kernel_clone+0xc0/0x3e0
[  239.446661]  __do_sys_clone+0x65/0xa0
[  239.446664]  do_syscall_64+0x82/0x930
[  239.446668]  ? count_memcg_events+0xd2/0x190
[  239.446671]  ? syscall_trace_enter+0x14e/0x1f0
[  239.446676]  ? syscall_exit_work+0x118/0x150
[  239.446677]  ? arch_exit_to_user_mode_prepare.constprop.0+0x9/0xb0
[  239.446681]  ? clear_bhb_loop+0x30/0x80
[  239.446684]  ? clear_bhb_loop+0x30/0x80
[  239.446686]  entry_SYSCALL_64_after_hwframe+0x76/0x7e

There are two options to resolve the potential latent issue:
  1. warn against PMD sharing in copy_hugetlb_page_range(),
  2. fix it.
This patch opts for the second option.
While at it, simplify the comment, the details are not actually relevant
anymore.

Link: https://lkml.kernel.org/r/20250916004520.1604530-1-jane.chu@oracle.com
Fixes: 59d9094 ("mm: hugetlb: independent PMD page table shared count")
	Signed-off-by: Jane Chu <jane.chu@oracle.com>
	Reviewed-by: Harry Yoo <harry.yoo@oracle.com>
	Acked-by: Oscar Salvador <osalvador@suse.de>
	Acked-by: David Hildenbrand <david@redhat.com>
	Cc: Jann Horn <jannh@google.com>
	Cc: Liu Shixin <liushixin2@huawei.com>
	Cc: Muchun Song <muchun.song@linux.dev>
	Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 14967a9)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	include/linux/mm_types.h
#	mm/hugetlb.c
jira KERNEL-1035
cve CVE-2026-23100
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author David Hildenbrand (Red Hat) <david@kernel.org>
commit ca1a47c

Patch series "mm/hugetlb: fixes for PMD table sharing (incl.  using
mmu_gather)", v3.

One functional fix, one performance regression fix, and two related
comment fixes.

I cleaned up my prototype I recently shared [1] for the performance fix,
deferring most of the cleanups I had in the prototype to a later point.
While doing that I identified the other things.

The goal of this patch set is to be backported to stable trees "fairly"
easily. At least patch #1 and #4.

Patch #1 fixes hugetlb_pmd_shared() not detecting any sharing
Patch #2 + #3 are simple comment fixes that patch #4 interacts with.
Patch #4 is a fix for the reported performance regression due to excessive
IPI broadcasts during fork()+exit().

The last patch is all about TLB flushes, IPIs and mmu_gather.
Read: complicated

There are plenty of cleanups in the future to be had + one reasonable
optimization on x86. But that's all out of scope for this series.

Runtime tested, with a focus on fixing the performance regression using
the original reproducer [2] on x86.

This patch (of 4):

We switched from (wrongly) using the page count to an independent shared
count.  Now, shared page tables have a refcount of 1 (excluding
speculative references) and instead use ptdesc->pt_share_count to identify
sharing.

We didn't convert hugetlb_pmd_shared(), so right now, we would never
detect a shared PMD table as such, because sharing/unsharing no longer
touches the refcount of a PMD table.

Page migration, like mbind() or migrate_pages() would allow for migrating
folios mapped into such shared PMD tables, even though the folios are not
exclusive.  In smaps we would account them as "private" although they are
"shared", and we would be wrongly setting the PM_MMAP_EXCLUSIVE in the
pagemap interface.

Fix it by properly using ptdesc_pmd_is_shared() in hugetlb_pmd_shared().

Link: https://lkml.kernel.org/r/20251223214037.580860-1-david@kernel.org
Link: https://lkml.kernel.org/r/20251223214037.580860-2-david@kernel.org
Link: https://lore.kernel.org/all/8cab934d-4a56-44aa-b641-bfd7e23bd673@kernel.org/ [1]
Link: https://lore.kernel.org/all/8cab934d-4a56-44aa-b641-bfd7e23bd673@kernel.org/ [2]
Fixes: 59d9094 ("mm: hugetlb: independent PMD page table shared count")
	Signed-off-by: David Hildenbrand (Red Hat) <david@kernel.org>
	Reviewed-by: Rik van Riel <riel@surriel.com>
	Reviewed-by: Lance Yang <lance.yang@linux.dev>
	Tested-by: Lance Yang <lance.yang@linux.dev>
	Reviewed-by: Harry Yoo <harry.yoo@oracle.com>
	Tested-by: Laurence Oberman <loberman@redhat.com>
	Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
	Acked-by: Oscar Salvador <osalvador@suse.de>
	Cc: Liu Shixin <liushixin2@huawei.com>
	Cc: Uschakow, Stanislav" <suschako@amazon.de>
	Cc: <stable@vger.kernel.org>
	Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit ca1a47c)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author David Hildenbrand (Red Hat) <david@kernel.org>
commit 3937027
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.1.el9_8/3937027c.failed

Ever since we stopped using the page count to detect shared PMD page
tables, these comments are outdated.

The only reason we have to flush the TLB early is because once we drop the
i_mmap_rwsem, the previously shared page table could get freed (to then
get reallocated and used for other purpose).  So we really have to flush
the TLB before that could happen.

So let's simplify the comments a bit.

The "If we unshared PMDs, the TLB flush was not recorded in mmu_gather."
part introduced as in commit a4a118f ("hugetlbfs: flush TLBs
correctly after huge_pmd_unshare") was confusing: sure it is recorded in
the mmu_gather, otherwise tlb_flush_mmu_tlbonly() wouldn't do anything.
So let's drop that comment while at it as well.

We'll centralize these comments in a single helper as we rework the code
next.

Link: https://lkml.kernel.org/r/20251223214037.580860-3-david@kernel.org
Fixes: 59d9094 ("mm: hugetlb: independent PMD page table shared count")
	Signed-off-by: David Hildenbrand (Red Hat) <david@kernel.org>
	Reviewed-by: Rik van Riel <riel@surriel.com>
	Tested-by: Laurence Oberman <loberman@redhat.com>
	Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
	Acked-by: Oscar Salvador <osalvador@suse.de>
	Reviewed-by: Harry Yoo <harry.yoo@oracle.com>
	Cc: Liu Shixin <liushixin2@huawei.com>
	Cc: Lance Yang <lance.yang@linux.dev>
	Cc: "Uschakow, Stanislav" <suschako@amazon.de>
	Cc: <stable@vger.kernel.org>
	Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 3937027)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	mm/hugetlb.c
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Fan Ni <fan.ni@samsung.com>
commit b0752f1
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.1.el9_8/b0752f1a.failed

Patch series "Let unmap_hugepage_range() and several related functions
take folio instead of page", v4.

This patch (of 4):

unmap_ref_private() has only a single user, which passes in &folio->page.
Let it take the folio directly.

Link: https://lkml.kernel.org/r/20250505182345.506888-2-nifan.cxl@gmail.com
Link: https://lkml.kernel.org/r/20250505182345.506888-3-nifan.cxl@gmail.com
	Signed-off-by: Fan Ni <fan.ni@samsung.com>
	Reviewed-by: Muchun Song <muchun.song@linux.dev>
	Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
	Reviewed-by: Oscar Salvador <osalvador@suse.de>
	Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
	Acked-by: David Hildenbrand <david@redhat.com>
	Cc: "Vishal Moola (Oracle)" <vishal.moola@gmail.com>
	Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit b0752f1)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	mm/hugetlb.c
…page

jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Fan Ni <fan.ni@samsung.com>
commit 81edb1b
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.1.el9_8/81edb1ba.failed

The function unmap_hugepage_range() has two kinds of users:
1) unmap_ref_private(), which passes in the head page of a folio.  Since
   unmap_ref_private() already takes folio and there are no other uses
   of the folio struct in the function, it is natural for
   unmap_hugepage_range() to take folio also.
2) All other uses, which pass in NULL pointer.

In both cases, we can pass in folio. Refactor unmap_hugepage_range() to
take folio.

Link: https://lkml.kernel.org/r/20250505182345.506888-4-nifan.cxl@gmail.com
	Signed-off-by: Fan Ni <fan.ni@samsung.com>
	Reviewed-by: Muchun Song <muchun.song@linux.dev>
	Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
	Reviewed-by: Oscar Salvador <osalvador@suse.de>
	Acked-by: David Hildenbrand <david@redhat.com>
	Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
	Cc: "Vishal Moola (Oracle)" <vishal.moola@gmail.com>
	Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 81edb1b)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	mm/hugetlb.c
…f page

jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Fan Ni <fan.ni@samsung.com>
commit 7f4b606
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.1.el9_8/7f4b6065.failed

The function __unmap_hugepage_range() has two kinds of users:
1) unmap_hugepage_range(), which passes in the head page of a folio.
   Since unmap_hugepage_range() already takes folio and there are no other
   uses of the folio struct in the function, it is natural for
   __unmap_hugepage_range() to take folio also.
2) All other uses, which pass in NULL pointer.

In both cases, we can pass in folio. Refactor __unmap_hugepage_range() to
take folio.

Link: https://lkml.kernel.org/r/20250505182345.506888-5-nifan.cxl@gmail.com
	Signed-off-by: Fan Ni <fan.ni@samsung.com>
	Acked-by: David Hildenbrand <david@redhat.com>
	Reviewed-by: Oscar Salvador <osalvador@suse.de>
	Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
	Cc: Muchun Song <muchun.song@linux.dev>
	Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
	Cc: "Vishal Moola (Oracle)" <vishal.moola@gmail.com>
	Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 7f4b606)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	mm/hugetlb.c
…ange()

jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Fan Ni <fan.ni@samsung.com>
commit 0527559
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.1.el9_8/05275594.failed

In __unmap_hugepage_range(), the "page" pointer always points to the first
page of a huge page, which guarantees there is a folio associating with
it.  Convert the "page" pointer to use folio.

Link: https://lkml.kernel.org/r/20250505182345.506888-6-nifan.cxl@gmail.com
	Signed-off-by: Fan Ni <fan.ni@samsung.com>
	Reviewed-by: Oscar Salvador <osalvador@suse.de>
	Acked-by: David Hildenbrand <david@redhat.com>
	Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
	Cc: Muchun Song <muchun.song@linux.dev>
	Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
	Cc: "Vishal Moola (Oracle)" <vishal.moola@gmail.com>
	Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 0527559)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	mm/hugetlb.c
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Jeongjun Park <aha310510@gmail.com>
commit 21cc2b5
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.1.el9_8/21cc2b5c.failed

When restoring a reservation for an anonymous page, we need to check to
freeing a surplus.  However, __unmap_hugepage_range() causes data race
because it reads h->surplus_huge_pages without the protection of
hugetlb_lock.

And adjust_reservation is a boolean variable that indicates whether
reservations for anonymous pages in each folio should be restored.
Therefore, it should be initialized to false for each round of the loop.
However, this variable is not initialized to false except when defining
the current adjust_reservation variable.

This means that once adjust_reservation is set to true even once within
the loop, reservations for anonymous pages will be restored
unconditionally in all subsequent rounds, regardless of the folio's state.

To fix this, we need to add the missing hugetlb_lock, unlock the
page_table_lock earlier so that we don't lock the hugetlb_lock inside the
page_table_lock lock, and initialize adjust_reservation to false on each
round within the loop.

Link: https://lkml.kernel.org/r/20250823182115.1193563-1-aha310510@gmail.com
Fixes: df7a6d1 ("mm/hugetlb: restore the reservation if needed")
	Signed-off-by: Jeongjun Park <aha310510@gmail.com>
	Reported-by: syzbot+417aeb05fd190f3a6da9@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=417aeb05fd190f3a6da9
	Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
	Cc: Breno Leitao <leitao@debian.org>
	Cc: David Hildenbrand <david@redhat.com>
	Cc: Muchun Song <muchun.song@linux.dev>
	Cc: Oscar Salvador <osalvador@suse.de>
	Cc: <stable@vger.kernel.org>
	Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 21cc2b5)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	mm/hugetlb.c
…ing mmu_gather

jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author David Hildenbrand (Red Hat) <david@kernel.org>
commit 8ce720d
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.1.el9_8/8ce720d5.failed

As reported, ever since commit 1013af4 ("mm/hugetlb: fix
huge_pmd_unshare() vs GUP-fast race") we can end up in some situations
where we perform so many IPI broadcasts when unsharing hugetlb PMD page
tables that it severely regresses some workloads.

In particular, when we fork()+exit(), or when we munmap() a large
area backed by many shared PMD tables, we perform one IPI broadcast per
unshared PMD table.

There are two optimizations to be had:

(1) When we process (unshare) multiple such PMD tables, such as during
    exit(), it is sufficient to send a single IPI broadcast (as long as
    we respect locking rules) instead of one per PMD table.

    Locking prevents that any of these PMD tables could get reused before
    we drop the lock.

(2) When we are not the last sharer (> 2 users including us), there is
    no need to send the IPI broadcast. The shared PMD tables cannot
    become exclusive (fully unshared) before an IPI will be broadcasted
    by the last sharer.

    Concurrent GUP-fast could walk into a PMD table just before we
    unshared it. It could then succeed in grabbing a page from the
    shared page table even after munmap() etc succeeded (and supressed
    an IPI). But there is not difference compared to GUP-fast just
    sleeping for a while after grabbing the page and re-enabling IRQs.

    Most importantly, GUP-fast will never walk into page tables that are
    no-longer shared, because the last sharer will issue an IPI
    broadcast.

    (if ever required, checking whether the PUD changed in GUP-fast
     after grabbing the page like we do in the PTE case could handle
     this)

So let's rework PMD sharing TLB flushing + IPI sync to use the mmu_gather
infrastructure so we can implement these optimizations and demystify the
code at least a bit. Extend the mmu_gather infrastructure to be able to
deal with our special hugetlb PMD table sharing implementation.

To make initialization of the mmu_gather easier when working on a single
VMA (in particular, when dealing with hugetlb), provide
tlb_gather_mmu_vma().

We'll consolidate the handling for (full) unsharing of PMD tables in
tlb_unshare_pmd_ptdesc() and tlb_flush_unshared_tables(), and track
in "struct mmu_gather" whether we had (full) unsharing of PMD tables.

Because locking is very special (concurrent unsharing+reuse must be
prevented), we disallow deferring flushing to tlb_finish_mmu() and instead
require an explicit earlier call to tlb_flush_unshared_tables().

From hugetlb code, we call huge_pmd_unshare_flush() where we make sure
that the expected lock protecting us from concurrent unsharing+reuse is
still held.

Check with a VM_WARN_ON_ONCE() in tlb_finish_mmu() that
tlb_flush_unshared_tables() was properly called earlier.

Document it all properly.

Notes about tlb_remove_table_sync_one() interaction with unsharing:

There are two fairly tricky things:

(1) tlb_remove_table_sync_one() is a NOP on architectures without
    CONFIG_MMU_GATHER_RCU_TABLE_FREE.

    Here, the assumption is that the previous TLB flush would send an
    IPI to all relevant CPUs. Careful: some architectures like x86 only
    send IPIs to all relevant CPUs when tlb->freed_tables is set.

    The relevant architectures should be selecting
    MMU_GATHER_RCU_TABLE_FREE, but x86 might not do that in stable
    kernels and it might have been problematic before this patch.

    Also, the arch flushing behavior (independent of IPIs) is different
    when tlb->freed_tables is set. Do we have to enlighten them to also
    take care of tlb->unshared_tables? So far we didn't care, so
    hopefully we are fine. Of course, we could be setting
    tlb->freed_tables as well, but that might then unnecessarily flush
    too much, because the semantics of tlb->freed_tables are a bit
    fuzzy.

    This patch changes nothing in this regard.

(2) tlb_remove_table_sync_one() is not a NOP on architectures with
    CONFIG_MMU_GATHER_RCU_TABLE_FREE that actually don't need a sync.

    Take x86 as an example: in the common case (!pv, !X86_FEATURE_INVLPGB)
    we still issue IPIs during TLB flushes and don't actually need the
    second tlb_remove_table_sync_one().

    This optimized can be implemented on top of this, by checking e.g., in
    tlb_remove_table_sync_one() whether we really need IPIs. But as
    described in (1), it really must honor tlb->freed_tables then to
    send IPIs to all relevant CPUs.

Notes on TLB flushing changes:

(1) Flushing for non-shared PMD tables

    We're converting from flush_hugetlb_tlb_range() to
    tlb_remove_huge_tlb_entry(). Given that we properly initialize the
    MMU gather in tlb_gather_mmu_vma() to be hugetlb aware, similar to
    __unmap_hugepage_range(), that should be fine.

(2) Flushing for shared PMD tables

    We're converting from various things (flush_hugetlb_tlb_range(),
    tlb_flush_pmd_range(), flush_tlb_range()) to tlb_flush_pmd_range().

    tlb_flush_pmd_range() achieves the same that
    tlb_remove_huge_tlb_entry() would achieve in these scenarios.
    Note that tlb_remove_huge_tlb_entry() also calls
    __tlb_remove_tlb_entry(), however that is only implemented on
    powerpc, which does not support PMD table sharing.

    Similar to (1), tlb_gather_mmu_vma() should make sure that TLB
    flushing keeps on working as expected.

Further, note that the ptdesc_pmd_pts_dec() in huge_pmd_share() is not a
concern, as we are holding the i_mmap_lock the whole time, preventing
concurrent unsharing. That ptdesc_pmd_pts_dec() usage will be removed
separately as a cleanup later.

There are plenty more cleanups to be had, but they have to wait until
this is fixed.

[david@kernel.org: fix kerneldoc]
  Link: https://lkml.kernel.org/r/f223dd74-331c-412d-93fc-69e360a5006c@kernel.org
Link: https://lkml.kernel.org/r/20251223214037.580860-5-david@kernel.org
Fixes: 1013af4 ("mm/hugetlb: fix huge_pmd_unshare() vs GUP-fast race")
	Signed-off-by: David Hildenbrand (Red Hat) <david@kernel.org>
	Reported-by: Uschakow, Stanislav" <suschako@amazon.de>
Closes: https://lore.kernel.org/all/4d3878531c76479d9f8ca9789dc6485d@amazon.de/
	Tested-by: Laurence Oberman <loberman@redhat.com>
	Acked-by: Harry Yoo <harry.yoo@oracle.com>
	Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
	Cc: Lance Yang <lance.yang@linux.dev>
	Cc: Liu Shixin <liushixin2@huawei.com>
	Cc: Oscar Salvador <osalvador@suse.de>
	Cc: Rik van Riel <riel@surriel.com>
	Cc: <stable@vger.kernel.org>
	Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 8ce720d)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	mm/hugetlb.c
#	mm/mmu_gather.c
#	mm/rmap.c
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Ivan Vecera <ivecera@redhat.com>
commit 5d41f95

The output pin phase adjustment functions incorrectly negate the phase
compensation value.

Per the ZL3073x datasheet, the output phase compensation register is
simply a signed two's complement integer where:
 - Positive values move the phase later in time
 - Negative values move the phase earlier in time

No negation is required. The erroneous negation caused phase adjustments
to be applied in the wrong direction.

Note that input pin phase adjustment correctly uses negation because the
hardware has an inverted convention for input references (positive moves
phase earlier, negative moves phase later).

Fixes: 6287262 ("dpll: zl3073x: Add support to adjust phase")
	Signed-off-by: Ivan Vecera <ivecera@redhat.com>
	Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Link: https://patch.msgid.link/20260205181055.129768-1-ivecera@redhat.com
	Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(cherry picked from commit 5d41f95)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Stefano Garzarella <sgarzare@redhat.com>
commit df137da

During virtio_transport_release() we can schedule a delayed work to
perform the closing of the socket before destruction.

The destructor is called either when the socket is really destroyed
(reference counter to zero), or it can also be called when we are
de-assigning the transport.

In the former case, we are sure the delayed work has completed, because
it holds a reference until it completes, so the destructor will
definitely be called after the delayed work is finished.
But in the latter case, the destructor is called by AF_VSOCK core, just
after the release(), so there may still be delayed work scheduled.

Refactor the code, moving the code to delete the close work already in
the do_close() to a new function. Invoke it during destruction to make
sure we don't leave any pending work.

Fixes: c0cfa2d ("vsock: add multi-transports support")
	Cc: stable@vger.kernel.org
	Reported-by: Hyunwoo Kim <v4bel@theori.io>
Closes: https://lore.kernel.org/netdev/Z37Sh+utS+iV3+eb@v4bel-B760M-AORUS-ELITE-AX/
	Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
	Reviewed-by: Luigi Leonardi <leonardi@redhat.com>
	Tested-by: Hyunwoo Kim <v4bel@theori.io>
	Signed-off-by: Paolo Abeni <pabeni@redhat.com>

(cherry picked from commit df137da)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Stefano Garzarella <sgarzare@redhat.com>
commit a24009b

Transport's release() and destruct() are called when de-assigning the
vsock transport. These callbacks can touch some socket state like
sock flags, sk_state, and peer_shutdown.

Since we are reassigning the socket to a new transport during
vsock_connect(), let's reset these fields to have a clean state with
the new transport.

Fixes: c0cfa2d ("vsock: add multi-transports support")
	Cc: stable@vger.kernel.org
	Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
	Reviewed-by: Luigi Leonardi <leonardi@redhat.com>
	Signed-off-by: Paolo Abeni <pabeni@redhat.com>

(cherry picked from commit a24009b)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Budimir Markovic <markovicbudimir@gmail.com>
commit aba0c94

It is possible for a vsock to autobind to VMADDR_PORT_ANY. This can
cause a use-after-free when a connection is made to the bound socket.
The socket returned by accept() also has port VMADDR_PORT_ANY but is not
on the list of unbound sockets. Binding it will result in an extra
refcount decrement similar to the one fixed in fcdd224 (vsock: Keep
the binding until socket destruction).

Modify the check in __vsock_bind_connectible() to also prevent binding
to VMADDR_PORT_ANY.

Fixes: d021c34 ("VSOCK: Introduce VM Sockets")
	Reported-by: Budimir Markovic <markovicbudimir@gmail.com>
	Signed-off-by: Budimir Markovic <markovicbudimir@gmail.com>
	Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://patch.msgid.link/20250807041811.678-1-markovicbudimir@gmail.com
	Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(cherry picked from commit aba0c94)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Stefano Garzarella <sgarzare@redhat.com>
commit f7c877e

Syzbot reported a potential lock inversion deadlock between
vsock_register_mutex and sk_lock-AF_VSOCK when vsock_linger() is called.

The issue was introduced by commit 687aa0c ("vsock: Fix
transport_* TOCTOU") which added vsock_register_mutex locking in
vsock_assign_transport() around the transport->release() call, that can
call vsock_linger(). vsock_assign_transport() can be called with sk_lock
held. vsock_linger() calls sk_wait_event() that temporarily releases and
re-acquires sk_lock. During this window, if another thread hold
vsock_register_mutex while trying to acquire sk_lock, a circular
dependency is created.

Fix this by releasing vsock_register_mutex before calling
transport->release() and vsock_deassign_transport(). This is safe
because we don't need to hold vsock_register_mutex while releasing the
old transport, and we ensure the new transport won't disappear by
obtaining a module reference first via try_module_get().

	Reported-by: syzbot+10e35716f8e4929681fa@syzkaller.appspotmail.com
	Tested-by: syzbot+10e35716f8e4929681fa@syzkaller.appspotmail.com
Fixes: 687aa0c ("vsock: Fix transport_* TOCTOU")
	Cc: mhal@rbox.co
	Cc: stable@vger.kernel.org
	Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://patch.msgid.link/20251021121718.137668-1-sgarzare@redhat.com
	Signed-off-by: Paolo Abeni <pabeni@redhat.com>

(cherry picked from commit f7c877e)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Stefano Garzarella <sgarzare@redhat.com>
commit d8ee3cf

vhost_vsock_get() uses hash_for_each_possible_rcu() to find the
`vhost_vsock` associated with the `guest_cid`. hash_for_each_possible_rcu()
should only be called within an RCU read section, as mentioned in the
following comment in include/linux/rculist.h:

/**
 * hlist_for_each_entry_rcu - iterate over rcu list of given type
 * @pos:	the type * to use as a loop cursor.
 * @Head:	the head for your list.
 * @member:	the name of the hlist_node within the struct.
 * @cond:	optional lockdep expression if called from non-RCU protection.
 *
 * This list-traversal primitive may safely run concurrently with
 * the _rcu list-mutation primitives such as hlist_add_head_rcu()
 * as long as the traversal is guarded by rcu_read_lock().
 */

Currently, all calls to vhost_vsock_get() are between rcu_read_lock()
and rcu_read_unlock() except for calls in vhost_vsock_set_cid() and
vhost_vsock_reset_orphans(). In both cases, the current code is safe,
but we can make improvements to make it more robust.

About vhost_vsock_set_cid(), when building the kernel with
CONFIG_PROVE_RCU_LIST enabled, we get the following RCU warning when the
user space issues `ioctl(dev, VHOST_VSOCK_SET_GUEST_CID, ...)` :

  WARNING: suspicious RCU usage
  6.18.0-rc7 #62 Not tainted
  -----------------------------
  drivers/vhost/vsock.c:74 RCU-list traversed in non-reader section!!

  other info that might help us debug this:

  rcu_scheduler_active = 2, debug_locks = 1
  1 lock held by rpc-libvirtd/3443:
   #0: ffffffffc05032a8 (vhost_vsock_mutex){+.+.}-{4:4}, at: vhost_vsock_dev_ioctl+0x2ff/0x530 [vhost_vsock]

  stack backtrace:
  CPU: 2 UID: 0 PID: 3443 Comm: rpc-libvirtd Not tainted 6.18.0-rc7 #62 PREEMPT(none)
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-7.fc42 06/10/2025
  Call Trace:
   <TASK>
   dump_stack_lvl+0x75/0xb0
   dump_stack+0x14/0x1a
   lockdep_rcu_suspicious.cold+0x4e/0x97
   vhost_vsock_get+0x8f/0xa0 [vhost_vsock]
   vhost_vsock_dev_ioctl+0x307/0x530 [vhost_vsock]
   __x64_sys_ioctl+0x4f2/0xa00
   x64_sys_call+0xed0/0x1da0
   do_syscall_64+0x73/0xfa0
   entry_SYSCALL_64_after_hwframe+0x76/0x7e
   ...
   </TASK>

This is not a real problem, because the vhost_vsock_get() caller, i.e.
vhost_vsock_set_cid(), holds the `vhost_vsock_mutex` used by the hash
table writers. Anyway, to prevent that warning, add lockdep_is_held()
condition to hash_for_each_possible_rcu() to verify that either the
caller is in an RCU read section or `vhost_vsock_mutex` is held when
CONFIG_PROVE_RCU_LIST is enabled; and also clarify the comment for
vhost_vsock_get() to better describe the locking requirements and the
scope of the returned pointer validity.

About vhost_vsock_reset_orphans(), currently this function is only
called via vsock_for_each_connected_socket(), which holds the
`vsock_table_lock` spinlock (which is also an RCU read-side critical
section). However, add an explicit RCU read lock there to make the code
more robust and explicit about the RCU requirements, and to prevent
issues if the calling context changes in the future or if
vhost_vsock_reset_orphans() is called from other contexts.

Fixes: 834e772 ("vhost/vsock: fix use-after-free in network stack callers")
	Cc: stefanha@redhat.com
	Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
	Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20251126133826.142496-1-sgarzare@redhat.com>
Message-ID: <20251126210313.GA499503@fedora>
	Acked-by: Jason Wang <jasowang@redhat.com>
	Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit d8ee3cf)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Bobby Eshleman <bobbyeshleman@meta.com>
commit eafb64f
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.1.el9_8/eafb64f4.failed

Add netns logic to vsock core. Additionally, modify transport hook
prototypes to be used by later transport-specific patches (e.g.,
*_seqpacket_allow()).

Namespaces are supported primarily by changing socket lookup functions
(e.g., vsock_find_connected_socket()) to take into account the socket
namespace and the namespace mode before considering a candidate socket a
"match".

This patch also introduces the sysctl /proc/sys/net/vsock/ns_mode to
report the mode and /proc/sys/net/vsock/child_ns_mode to set the mode
for new namespaces.

Add netns functionality (initialization, passing to transports, procfs,
etc...) to the af_vsock socket layer. Later patches that add netns
support to transports depend on this patch.

This patch changes the allocation of random ports for connectible vsocks
in order to avoid leaking the random port range starting point to other
namespaces.

dgram_allow(), stream_allow(), and seqpacket_allow() callbacks are
modified to take a vsk in order to perform logic on namespace modes. In
future patches, the net will also be used for socket
lookups in these functions.

	Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
	Signed-off-by: Bobby Eshleman <bobbyeshleman@meta.com>
Link: https://patch.msgid.link/20260121-vsock-vmtest-v16-1-2859a7512097@meta.com
	Acked-by: Michael S. Tsirkin <mst@redhat.com>
	Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit eafb64f)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	include/net/net_namespace.h
#	net/vmw_vsock/af_vsock.c
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Bobby Eshleman <bobbyeshleman@meta.com>
commit a6ae12a

Associate reply packets with the sending socket. When vsock must reply
with an RST packet and there exists a sending socket (e.g., for
loopback), setting the skb owner to the socket correctly handles
reference counting between the skb and sk (i.e., the sk stays alive
until the skb is freed).

This allows the net namespace to be used for socket lookups for the
duration of the reply skb's lifetime, preventing race conditions between
the namespace lifecycle and vsock socket search using the namespace
pointer.

	Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
	Signed-off-by: Bobby Eshleman <bobbyeshleman@meta.com>
Link: https://patch.msgid.link/20260121-vsock-vmtest-v16-2-2859a7512097@meta.com
	Acked-by: Michael S. Tsirkin <mst@redhat.com>
	Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit a6ae12a)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Bobby Eshleman <bobbyeshleman@meta.com>
commit a696863
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.1.el9_8/a6968632.failed

Add netns support to loopback and vhost. Keep netns disabled for
virtio-vsock, but add necessary changes to comply with common API
updates.

This is the patch in the series when vhost-vsock namespaces actually
come online.

	Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
	Signed-off-by: Bobby Eshleman <bobbyeshleman@meta.com>
Link: https://patch.msgid.link/20260121-vsock-vmtest-v16-3-2859a7512097@meta.com
	Acked-by: Michael S. Tsirkin <mst@redhat.com>
	Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit a696863)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	net/vmw_vsock/virtio_transport.c
#	net/vmw_vsock/virtio_transport_common.c
#	net/vmw_vsock/vsock_loopback.c
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Stefano Garzarella <sgarzare@redhat.com>
commit 9dd3914
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.1.el9_8/9dd39149.failed

When a new network namespace is created, vsock_net_init() correctly
initializes the namespace's mode by reading the parent's `child_ns_mode`
via vsock_net_child_mode(). However, the `child_ns_mode` of the new
namespace was always hardcoded to VSOCK_NET_MODE_GLOBAL, regardless of
its own mode.

This means that if a parent namespace has `child_ns_mode` set to "local",
the child namespace correctly gets mode "local", but its `child_ns_mode`
is reset to "global". As a result, further nested namespaces will
incorrectly get mode "global" instead of inheriting "local", breaking
the expected propagation of the mode through nested namespaces.

Fix this by initializing `child_ns_mode` to the namespace's own mode,
so the setting propagates correctly through all levels of nesting.

Fixes: eafb64f ("vsock: add netns to vsock core")
	Cc: bobbyeshleman@meta.com
	Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
	Reviewed-by: Bobby Eshleman <bobbyeshleman@meta.com>
Link: https://patch.msgid.link/20260212205916.97533-2-sgarzare@redhat.com
	Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(cherry picked from commit 9dd3914)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	net/vmw_vsock/af_vsock.c
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Stefano Garzarella <sgarzare@redhat.com>
commit 6a997f3
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.1.el9_8/6a997f38.failed

A "local" namespace can change its `child_ns_mode` sysctl to "global",
allowing nested namespaces to access global CIDs. This can be exploited
by an unprivileged user who gained CAP_NET_ADMIN through a user
namespace.

Prevent this by rejecting writes that attempt to set `child_ns_mode` to
"global" when the current namespace's mode is "local".

Fixes: eafb64f ("vsock: add netns to vsock core")
	Cc: bobbyeshleman@meta.com
	Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
	Reviewed-by: Bobby Eshleman <bobbyeshleman@meta.com>
Link: https://patch.msgid.link/20260212205916.97533-3-sgarzare@redhat.com
	Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(cherry picked from commit 6a997f3)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	net/vmw_vsock/af_vsock.c
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit 5cc6195
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.1.el9_8/5cc61958.failed

current->nsproxy is should not be accessed directly as syzbot has found
that it could be NULL at times, causing crashes.  Fix up the af_vsock
sysctl handlers to use container_of() to deal with the current net
namespace instead of attempting to rely on current.

This is the same type of change done in commit 7f5611c ("rds:
sysctl: rds_tcp_{rcv,snd}buf: avoid using current->nsproxy")

	Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
	Reviewed-by: Bobby Eshleman <bobbyeshleman@meta.com>
	Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Fixes: eafb64f ("vsock: add netns to vsock core")
Link: https://patch.msgid.link/2026022318-rearview-gallery-ae13@gregkh
	Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(cherry picked from commit 5cc6195)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	net/vmw_vsock/af_vsock.c
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Bobby Eshleman <bobbyeshleman@meta.com>
commit 102eab9
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.1.el9_8/102eab95.failed

Two administrator processes may race when setting child_ns_mode as one
process sets child_ns_mode to "local" and then creates a namespace, but
another process changes child_ns_mode to "global" between the write and
the namespace creation. The first process ends up with a namespace in
"global" mode instead of "local". While this can be detected after the
fact by reading ns_mode and retrying, it is fragile and error-prone.

Make child_ns_mode write-once so that a namespace manager can set it
once and be sure it won't change. Writing a different value after the
first write returns -EBUSY. This applies to all namespaces, including
init_net, where an init process can write "local" to lock all future
namespaces into local mode.

Fixes: eafb64f ("vsock: add netns to vsock core")
	Suggested-by: Daan De Meyer <daan.j.demeyer@gmail.com>
	Suggested-by: Stefano Garzarella <sgarzare@redhat.com>
Co-developed-by: Stefano Garzarella <sgarzare@redhat.com>
	Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
	Signed-off-by: Bobby Eshleman <bobbyeshleman@meta.com>
	Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://patch.msgid.link/20260223-vsock-ns-write-once-v3-2-c0cde6959923@meta.com
	Signed-off-by: Paolo Abeni <pabeni@redhat.com>
(cherry picked from commit 102eab9)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	include/net/af_vsock.h
#	include/net/netns/vsock.h
#	net/vmw_vsock/af_vsock.c
jira KERNEL-1035
cve CVE-2026-23171
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Nikolay Aleksandrov <razor@blackwall.org>
commit e9acda5

Fix a use-after-free which happens due to enslave failure after the new
slave has been added to the array. Since the new slave can be used for Tx
immediately, we can use it after it has been freed by the enslave error
cleanup path which frees the allocated slave memory. Slave update array is
supposed to be called last when further enslave failures are not expected.
Move it after xdp setup to avoid any problems.

It is very easy to reproduce the problem with a simple xdp_pass prog:
 ip l add bond1 type bond mode balance-xor
 ip l set bond1 up
 ip l set dev bond1 xdp object xdp_pass.o sec xdp_pass
 ip l add dumdum type dummy

Then run in parallel:
 while :; do ip l set dumdum master bond1 1>/dev/null 2>&1; done;
 mausezahn bond1 -a own -b rand -A rand -B 1.1.1.1 -c 0 -t tcp "dp=1-1023, flags=syn"

The crash happens almost immediately:
 [  605.602850] Oops: general protection fault, probably for non-canonical address 0xe0e6fc2460000137: 0000 [#1] SMP KASAN NOPTI
 [  605.602916] KASAN: maybe wild-memory-access in range [0x07380123000009b8-0x07380123000009bf]
 [  605.602946] CPU: 0 UID: 0 PID: 2445 Comm: mausezahn Kdump: loaded Tainted: G    B               6.19.0-rc6+ #21 PREEMPT(voluntary)
 [  605.602979] Tainted: [B]=BAD_PAGE
 [  605.602998] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
 [  605.603032] RIP: 0010:netdev_core_pick_tx+0xcd/0x210
 [  605.603063] Code: 48 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 3e 01 00 00 48 b8 00 00 00 00 00 fc ff df 4c 8b 6b 08 49 8d 7d 30 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 25 01 00 00 49 8b 45 30 4c 89 e2 48 89 ee 48 89
 [  605.603111] RSP: 0018:ffff88817b9af348 EFLAGS: 00010213
 [  605.603145] RAX: dffffc0000000000 RBX: ffff88817d28b420 RCX: 0000000000000000
 [  605.603172] RDX: 00e7002460000137 RSI: 0000000000000008 RDI: 07380123000009be
 [  605.603199] RBP: ffff88817b541a00 R08: 0000000000000001 R09: fffffbfff3ed8c0c
 [  605.603226] R10: ffffffff9f6c6067 R11: 0000000000000001 R12: 0000000000000000
 [  605.603253] R13: 073801230000098e R14: ffff88817d28b448 R15: ffff88817b541a84
 [  605.603286] FS:  00007f6570ef67c0(0000) GS:ffff888221dfa000(0000) knlGS:0000000000000000
 [  605.603319] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
 [  605.603343] CR2: 00007f65712fae40 CR3: 000000011371b000 CR4: 0000000000350ef0
 [  605.603373] Call Trace:
 [  605.603392]  <TASK>
 [  605.603410]  __dev_queue_xmit+0x448/0x32a0
 [  605.603434]  ? __pfx_vprintk_emit+0x10/0x10
 [  605.603461]  ? __pfx_vprintk_emit+0x10/0x10
 [  605.603484]  ? __pfx___dev_queue_xmit+0x10/0x10
 [  605.603507]  ? bond_start_xmit+0xbfb/0xc20 [bonding]
 [  605.603546]  ? _printk+0xcb/0x100
 [  605.603566]  ? __pfx__printk+0x10/0x10
 [  605.603589]  ? bond_start_xmit+0xbfb/0xc20 [bonding]
 [  605.603627]  ? add_taint+0x5e/0x70
 [  605.603648]  ? add_taint+0x2a/0x70
 [  605.603670]  ? end_report.cold+0x51/0x75
 [  605.603693]  ? bond_start_xmit+0xbfb/0xc20 [bonding]
 [  605.603731]  bond_start_xmit+0x623/0xc20 [bonding]

Fixes: 9e2ee5c ("net, bonding: Add XDP support to the bonding driver")
	Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
	Reported-by: Chen Zhen <chenzhen126@huawei.com>
Closes: https://lore.kernel.org/netdev/fae17c21-4940-5605-85b2-1d5e17342358@huawei.com/
CC: Jussi Maki <joamaki@gmail.com>
CC: Daniel Borkmann <daniel@iogearbox.net>
	Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://patch.msgid.link/20260123120659.571187-1-razor@blackwall.org
	Signed-off-by: Paolo Abeni <pabeni@redhat.com>

(cherry picked from commit e9acda5)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>
PlaidCat added 16 commits May 19, 2026 18:43
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Petr Oros <poros@redhat.com>
commit efc54fb

Commit 7c01dbf ("iavf: periodically cache PHC time") introduced a
worker to cache PHC time, but failed to stop it during reset or disable.

This creates a race condition where `iavf_reset_task()` or
`iavf_disable_vf()` free adapter resources (AQ) while the worker is still
running. If the worker triggers `iavf_queue_ptp_cmd()` during teardown, it
accesses freed memory/locks, leading to a crash.

Fix this by calling `iavf_ptp_release()` before tearing down the adapter.
This ensures `ptp_clock_unregister()` synchronously cancels the worker and
cleans up the chardev before the backing resources are destroyed.

Fixes: 7c01dbf ("iavf: periodically cache PHC time")
	Signed-off-by: Petr Oros <poros@redhat.com>
	Reviewed-by: Ivan Vecera <ivecera@redhat.com>
	Acked-by: Jacob Keller <jacob.e.keller@intel.com>
	Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
	Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
	Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
	Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
(cherry picked from commit efc54fb)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>
jira KERNEL-1035
cve CVE-2025-38109
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author Amir Tzin <amirtz@nvidia.com>
commit 687560d

Fix shutdown flow UAF when a virtual function is created on the embedded
chip (ECVF) of a BlueField device. In such case the vport acl ingress
table is not properly destroyed.

ECVF functionality is independent of ecpf_vport_exists capability and
thus functions mlx5_eswitch_(enable|disable)_pf_vf_vports() should not
test it when enabling/disabling ECVF vports.

kernel log:
[] refcount_t: underflow; use-after-free.
[] WARNING: CPU: 3 PID: 1 at lib/refcount.c:28
   refcount_warn_saturate+0x124/0x220
----------------
[] Call trace:
[] refcount_warn_saturate+0x124/0x220
[] tree_put_node+0x164/0x1e0 [mlx5_core]
[] mlx5_destroy_flow_table+0x98/0x2c0 [mlx5_core]
[] esw_acl_ingress_table_destroy+0x28/0x40 [mlx5_core]
[] esw_acl_ingress_lgcy_cleanup+0x80/0xf4 [mlx5_core]
[] esw_legacy_vport_acl_cleanup+0x44/0x60 [mlx5_core]
[] esw_vport_cleanup+0x64/0x90 [mlx5_core]
[] mlx5_esw_vport_disable+0xc0/0x1d0 [mlx5_core]
[] mlx5_eswitch_unload_ec_vf_vports+0xcc/0x150 [mlx5_core]
[] mlx5_eswitch_disable_sriov+0x198/0x2a0 [mlx5_core]
[] mlx5_device_disable_sriov+0xb8/0x1e0 [mlx5_core]
[] mlx5_sriov_detach+0x40/0x50 [mlx5_core]
[] mlx5_unload+0x40/0xc4 [mlx5_core]
[] mlx5_unload_one_devl_locked+0x6c/0xe4 [mlx5_core]
[] mlx5_unload_one+0x3c/0x60 [mlx5_core]
[] shutdown+0x7c/0xa4 [mlx5_core]
[] pci_device_shutdown+0x3c/0xa0
[] device_shutdown+0x170/0x340
[] __do_sys_reboot+0x1f4/0x2a0
[] __arm64_sys_reboot+0x2c/0x40
[] invoke_syscall+0x78/0x100
[] el0_svc_common.constprop.0+0x54/0x184
[] do_el0_svc+0x30/0xac
[] el0_svc+0x48/0x160
[] el0t_64_sync_handler+0xa4/0x12c
[] el0t_64_sync+0x1a4/0x1a8
[] --[ end trace 9c4601d68c70030e ]---

Fixes: a7719b2 ("net/mlx5: Add management of EC VF vports")
	Reviewed-by: Daniel Jurgens <danielj@nvidia.com>
	Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
	Signed-off-by: Amir Tzin <amirtz@nvidia.com>
	Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Link: https://patch.msgid.link/20250610151514.1094735-3-mbloch@nvidia.com
	Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(cherry picked from commit 687560d)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>
jira KERNEL-1035
cve CVE-2026-23243
Rebuild_History Non-Buildable kernel-5.14.0-687.5.1.el9_8
commit-author YunJe Shin <yjshin0438@gmail.com>
commit 5551b02

ib_umad_write computes data_len from user-controlled count and the
MAD header sizes. With a mismatched user MAD header size and RMPP
header length, data_len can become negative and reach ib_create_send_mad().
This can make the padding calculation exceed the segment size and trigger
an out-of-bounds memset in alloc_send_rmpp_list().

Add an explicit check to reject negative data_len before creating the
send buffer.

KASAN splat:
[  211.363464] BUG: KASAN: slab-out-of-bounds in ib_create_send_mad+0xa01/0x11b0
[  211.364077] Write of size 220 at addr ffff88800c3fa1f8 by task spray_thread/102
[  211.365867] ib_create_send_mad+0xa01/0x11b0
[  211.365887] ib_umad_write+0x853/0x1c80

Fixes: 2be8e3e ("IB/umad: Add P_Key index support")
	Signed-off-by: YunJe Shin <ioerts@kookmin.ac.kr>
Link: https://patch.msgid.link/20260203100628.1215408-1-ioerts@kookmin.ac.kr
	Signed-off-by: Leon Romanovsky <leon@kernel.org>
(cherry picked from commit 5551b02)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>
Rebuild_History BUILDABLE
Rebuilding Kernel from rpm changelog with Fuzz Limit: 87.50%
Number of commits in upstream range v5.14~1..kernel-mainline: 380232
Number of commits in rpm: 99
Number of commits matched with upstream: 85 (85.86%)
Number of commits in upstream but not in rpm: 380147
Number of commits NOT found in upstream: 14 (14.14%)

Rebuilding Kernel on Branch rocky9_8_rebuild_kernel-5.14.0-687.5.1.el9_8 for kernel-5.14.0-687.5.1.el9_8
Clean Cherry Picks: 43 (50.59%)
Empty Cherry Picks: 42 (49.41%)
_______________________________

Full Details Located here:
ciq/ciq_backports/kernel-5.14.0-687.5.1.el9_8/rebuild.details.txt

Includes:
* git commit header above
* Empty Commits with upstream SHA
* RPM ChangeLog Entries that could not be matched

Individual Empty Commit failures contained in the same containing directory.
The git message for empty commits will have the path for the failed commit.
File names are the first 8 characters of the upstream SHA
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.3.el9_8
commit-author Norbert Szetei <norbert@doyensec.com>
commit 62397b4

The AF_ALG interface fails to unmark the end of a Scatter/Gather List (SGL)
when chaining a new af_alg_tsgl structure. If a sendmsg() fills an SGL
exactly to MAX_SGL_ENTS, the last entry is marked as the end. A subsequent
sendmsg() allocates a new SGL and chains it, but fails to clear the end
marker on the previous SGL's last data entry.

This causes the crypto scatterwalk to hit a premature end, returning NULL
on sg_next() and leading to a kernel panic during dereference.

Fix this by explicitly unmarking the end of the previous SGL when
performing sg_chain() in af_alg_alloc_tsgl().

Fixes: 8ff5909 ("crypto: algif_skcipher - User-space interface for skcipher operations")
	Signed-off-by: Norbert Szetei <norbert@doyensec.com>
	Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit 62397b4)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>
jira KERNEL-1035
cve CVE-2026-31431
Rebuild_History Non-Buildable kernel-5.14.0-687.5.3.el9_8
commit-author Herbert Xu <herbert@gondor.apana.org.au>
commit a664bf3
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.3.el9_8/a664bf3d.failed

This mostly reverts commit 72548b0 except for the copying of
the associated data.

There is no benefit in operating in-place in algif_aead since the
source and destination come from different mappings.  Get rid of
all the complexity added for in-place operation and just copy the
AD directly.

Fixes: 72548b0 ("crypto: algif_aead - copy AAD from src to dst")
	Reported-by: Taeyang Lee <0wn@theori.io>
	Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit a664bf3)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	crypto/algif_aead.c
jira KERNEL-1035
cve CVE-2026-31677
Rebuild_History Non-Buildable kernel-5.14.0-687.5.3.el9_8
commit-author Douya Le <ldy3087146292@gmail.com>
commit 8eceab1
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.3.el9_8/8eceab19.failed

Make af_alg_get_rsgl() limit each RX scatterlist extraction to the
remaining receive buffer budget.

af_alg_get_rsgl() currently uses af_alg_readable() only as a gate
before extracting data into the RX scatterlist. Limit each extraction
to the remaining af_alg_rcvbuf(sk) budget so that receive-side
accounting matches the amount of data attached to the request.

If skcipher cannot obtain enough RX space for at least one chunk while
more data remains to be processed, reject the recvmsg call instead of
rounding the request length down to zero.

Fixes: e870456 ("crypto: algif_skcipher - overhaul memory management")
	Reported-by: Yifan Wu <yifanwucs@gmail.com>
	Reported-by: Juefei Pu <tomapufckgml@gmail.com>
Co-developed-by: Yuan Tan <yuantan098@gmail.com>
	Signed-off-by: Yuan Tan <yuantan098@gmail.com>
	Suggested-by: Xin Liu <bird@lzu.edu.cn>
	Signed-off-by: Douya Le <ldy3087146292@gmail.com>
	Signed-off-by: Ren Wei <n05ec@lzu.edu.cn>
	Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit 8eceab1)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	crypto/algif_skcipher.c
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.3.el9_8
commit-author Herbert Xu <herbert@gondor.apana.org.au>
commit 31d0015
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.3.el9_8/31d00156.failed

When page reassignment was added to af_alg_pull_tsgl the original
loop wasn't updated so it may try to reassign one more page than
necessary.

Add the check to the reassignment so that this does not happen.

Also update the comment which still refers to the obsolete offset
argument.

	Reported-by: syzbot+d23888375c2737c17ba5@syzkaller.appspotmail.com
Fixes: e870456 ("crypto: algif_skcipher - overhaul memory management")
	Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit 31d0015)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	crypto/af_alg.c
…SN spec

jira KERNEL-1035
cve CVE-2026-23060
Rebuild_History Non-Buildable kernel-5.14.0-687.5.3.el9_8
commit-author Taeyang Lee <0wn@theori.io>
commit 2397e92

authencesn assumes an ESP/ESN-formatted AAD. When assoclen is shorter than
the minimum expected length, crypto_authenc_esn_decrypt() can advance past
the end of the destination scatterlist and trigger a NULL pointer dereference
in scatterwalk_map_and_copy(), leading to a kernel panic (DoS).

Add a minimum AAD length check to fail fast on invalid inputs.

Fixes: 104880a ("crypto: authencesn - Convert to new AEAD interface")
Reported-By: Taeyang Lee <0wn@theori.io>
	Signed-off-by: Taeyang Lee <0wn@theori.io>
	Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit 2397e92)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>
…e decryption

jira KERNEL-1035
cve CVE-2026-31431
Rebuild_History Non-Buildable kernel-5.14.0-687.5.3.el9_8
commit-author Herbert Xu <herbert@gondor.apana.org.au>
commit e024941
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.3.el9_8/e0249411.failed

When decrypting data that is not in-place (src != dst), there is
no need to save the high-order sequence bits in dst as it could
simply be re-copied from the source.

However, the data to be hashed need to be rearranged accordingly.

	Reported-by: Taeyang Lee <0wn@theori.io>
Fixes: 104880a ("crypto: authencesn - Convert to new AEAD interface")
	Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Thanks,

	Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit e024941)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	crypto/authencesn.c
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.3.el9_8
commit-author Herbert Xu <herbert@gondor.apana.org.au>
commit 1f48ad3
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.3.el9_8/1f48ad3b.failed

The src SG list offset wasn't set properly when decrypting in-place,
fix it.

	Reported-by: Wolfgang Walter <linux@stwm.de>
Fixes: e024941 ("crypto: authencesn - Do not place hiseq at end of dst for out-of-place decryption")
	Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit 1f48ad3)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	crypto/authencesn.c
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.3.el9_8
commit-author Yucheng Lu <kanolyc@gmail.com>
commit 5db6ef9

authencesn requires either a zero authsize or an authsize of at least
4 bytes because the ESN encrypt/decrypt paths always move 4 bytes of
high-order sequence number data at the end of the authenticated data.

While crypto_authenc_esn_setauthsize() already rejects explicit
non-zero authsizes in the range 1..3, crypto_authenc_esn_create()
still copied auth->digestsize into inst->alg.maxauthsize without
validating it.  The AEAD core then initialized the tfm's default
authsize from that value.

As a result, selecting an ahash with digest size 1..3, such as
cbcmac(cipher_null), exposed authencesn instances whose default
authsize was invalid even though setauthsize() would have rejected the
same value.  AF_ALG could then trigger the ESN tail handling with a
too-short tag and hit an out-of-bounds access.

Reject authencesn instances whose ahash digest size is in the invalid
non-zero range 1..3 so that no tfm can inherit an unsupported default
authsize.

Fixes: f15f05b ("crypto: ccm - switch to separate cbcmac driver")
	Cc: stable@kernel.org
	Reported-by: Yifan Wu <yifanwucs@gmail.com>
	Reported-by: Juefei Pu <tomapufckgml@gmail.com>
Co-developed-by: Yuan Tan <yuantan098@gmail.com>
	Signed-off-by: Yuan Tan <yuantan098@gmail.com>
	Suggested-by: Xin Liu <bird@lzu.edu.cn>
	Tested-by: Yuhang Zheng <z1652074432@gmail.com>
	Reviewed-by: Eric Biggers <ebiggers@kernel.org>
	Signed-off-by: Yucheng Lu <kanolyc@gmail.com>
	Signed-off-by: Ren Wei <n05ec@lzu.edu.cn>
	Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit 5db6ef9)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.3.el9_8
commit-author Herbert Xu <herbert@gondor.apana.org.au>
commit 3d14bd4

The check for the minimum receive buffer size did not take the
tag size into account during decryption.  Fix this by adding the
required extra length.

	Reported-by: syzbot+aa11561819dc42ebbc7c@syzkaller.appspotmail.com
	Reported-by: Daniel Pouzzner <douzzer@mega.nu>
Fixes: d887c52 ("crypto: algif_aead - overhaul memory management")
	Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit 3d14bd4)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>
jira KERNEL-1035
Rebuild_History Non-Buildable kernel-5.14.0-687.5.3.el9_8
commit-author Douya Le <ldy3087146292@gmail.com>
commit 5aa58c3
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
Will be included in final tarball splat. Ref for failed cherry-pick at:
ciq/ciq_backports/kernel-5.14.0-687.5.3.el9_8/5aa58c3a.failed

AF_ALG AEAD AIO requests currently use the socket-wide IV buffer during
request processing.  For async requests, later socket activity can
update that shared state before the original request has fully
completed, which can lead to inconsistent IV handling.

Snapshot the IV into per-request storage when preparing the AEAD
request, so in-flight operations no longer depend on mutable socket
state.

Fixes: d887c52 ("crypto: algif_aead - overhaul memory management")
	Cc: stable@kernel.org
	Reported-by: Yuan Tan <yuantan098@gmail.com>
	Reported-by: Yifan Wu <yifanwucs@gmail.com>
	Reported-by: Juefei Pu <tomapufckgml@gmail.com>
	Reported-by: Xin Liu <bird@lzu.edu.cn>
Co-developed-by: Luxing Yin <tr0jan@lzu.edu.cn>
	Signed-off-by: Luxing Yin <tr0jan@lzu.edu.cn>
	Tested-by: Yucheng Lu <kanolyc@gmail.com>
	Signed-off-by: Douya Le <ldy3087146292@gmail.com>
	Signed-off-by: Ren Wei <n05ec@lzu.edu.cn>
	Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit 5aa58c3)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>

# Conflicts:
#	crypto/algif_aead.c
Rebuild_History BUILDABLE
Rebuilding Kernel from rpm changelog with Fuzz Limit: 87.50%
Number of commits in upstream range v5.14~1..kernel-mainline: 380232
Number of commits in rpm: 14
Number of commits matched with upstream: 10 (71.43%)
Number of commits in upstream but not in rpm: 380222
Number of commits NOT found in upstream: 4 (28.57%)

Rebuilding Kernel on Branch rocky9_8_rebuild_kernel-5.14.0-687.5.3.el9_8 for kernel-5.14.0-687.5.3.el9_8
Clean Cherry Picks: 4 (40.00%)
Empty Cherry Picks: 6 (60.00%)
_______________________________

Full Details Located here:
ciq/ciq_backports/kernel-5.14.0-687.5.3.el9_8/rebuild.details.txt

Includes:
* git commit header above
* Empty Commits with upstream SHA
* RPM ChangeLog Entries that could not be matched

Individual Empty Commit failures contained in the same containing directory.
The git message for empty commits will have the path for the failed commit.
File names are the first 8 characters of the upstream SHA
@PlaidCat PlaidCat self-assigned this May 19, 2026
@PlaidCat
PlaidCat requested review from a team May 19, 2026 23:36
@PlaidCat
PlaidCat marked this pull request as draft May 20, 2026 13:25
Starting 2025.06.26 some of the actions required efltools to have devel
enabled.
@PlaidCat
PlaidCat marked this pull request as ready for review May 20, 2026 18:14

@bmastbergen bmastbergen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥌

@PlaidCat
PlaidCat requested review from a team May 20, 2026 18:52
@jdieter

jdieter commented May 21, 2026

Copy link
Copy Markdown

Just an FYI that there's a newer 9.8 build available: kernel-5.14.0-687.10.1.el9_8. It has the fixes for fragnesia and the dumpable vuln.

@PlaidCat
PlaidCat merged commit 75fb062 into rocky9_8 May 21, 2026
4 checks passed
@PlaidCat
PlaidCat deleted the rocky9_8_rebuild branch May 21, 2026 16:00
@PlaidCat

Copy link
Copy Markdown
Collaborator Author

Just an FYI that there's a newer 9.8 build available: kernel-5.14.0-687.10.1.el9_8. It has the fixes for fragnesia and the dumpable vuln.

Yes thats what i'm running after getting this merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants