In the Linux kernel, the following vulnerability has been resolved:
mlxsw: spectrumptp: Fix napigroreceive() call from GC workqueue context
Currently mlxswsp1ptphtgccollect() is run from the PTP garbage-collection workqueue, rather than the NAPI poll context. For any unmatched PTP entries carrying an SKB, it calls mlxswsp1ptpunmatchedfinish() -> mlxswsp1ptppacketfinish(). For ingress packets, this calls mlxswsprxlistenernomarkfunc(). The end of that function is the following:
skb->protocol = ethtypetrans(skb, skb->dev); napigroreceive(mlxswskbcb(skb)->rxmdinfo.napi, skb);
The napi pointer is one that was placed in the SKB control block when the trapped packet was received in the NAPI context. Later, when the GC reaps the unmatched entry (up to MLXSWSP1PTPHTGCTIMEOUT later), the call to napigroreceive() mutates the NAPI instance's GRO list, which is unsafe if the poll is running concurrently on another CPU.
In mlxswsp1ptphtgccollect(), localbhdisable() is called to prevent softirq processing, but this only applies to the local CPU. Additionally, its comment is stale. It states that mlxswsp1ptpunmatchedfinish() invokes netifreceiveskb(). This has not been accurate since the referenced commit; this patch makes that comment accurate again. mlxswpcinapidevsinit() calls netifthreadedenable() on the NAPI RX netdevice without any conditions. The NAPI instance's poll, which may be running concurrent to the GC, is running as an independently-scheduled kthread which may be on a different CPU. The call to localbhdisable() does not guard against this.
If a tx-timestamp timeout produces an unmatched entry (which can be easily reproduced by running ptp4l and waiting for a port to reach the UNCALIBRATED/SLAVE state) while the owning NAPI thread is in the middle of a poll on another CPU, both sides mutate the GRO list concurrently, as shown below:
[39.846] port 1 (swp1): MASTER to UNCALIBRATED on RSSLAVE listadd corruption. next->prev should be prev (ffff8d620faf4138), but was ffff8d624150f700. (next=ffff8d620faf4138). kernel BUG at lib/listdebug.c:29! Oops: invalid opcode: 0000 [#1] SMP PTI CPU: 1 UID: 0 PID: 539 Comm: napi/mlxswrx-0 Not tainted 6.18.48 #1-NixOS PREEMPT(lazy) Hardware name: Mellanox Technologies Ltd. MSN2410/VMOD0001, BIOS 4.6.5 09/13/2018 RIP: 0010:listaddvalidorreport+0x79/0xb0 RSP: 0018:ffffcdf8c0f27c08 EFLAGS: 00010246 RAX: 0000000000000075 RBX: ffff8d624150fd00 RCX: 0000000000000000 RDX: 0000000000000000 RSI: 0000000000000001 RDI: ffff8d6315d1e540 RBP: ffff8d620faf4070 R08: 0000000000000000 R09: 00000000ffffdfff R10: ffffffffa5c60fe0 R11: ffffcdf8c0f27ab8 R12: 0000000000000003 R13: 000000000000003d R14: 00000000000001bc R15: 0000000000000001 FS: 0000000000000000(0000) GS:ffff8d636f63f000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000562689a60c24 CR3: 000000015f224004 CR4: 00000000001726f0 Call Trace: <TASK> groreceiveskb+0xee/0x230 mlxswsp1ptpgotpacket+0x61/0x140 [mlxswspectrum] mlxswcoreskbreceive+0xdf/0x1b0 [mlxswcore] mlxswpcinapipollcqrx+0x780/0x9d0 [mlxswpci] napipoll+0x31/0x1e0 napithreadedpollloop+0x16b/0x1c0 napithreadedpoll+0x71/0xa0 kthread+0xfb/0x260 retfromfork+0x22d/0x260 retfromforkasm+0x1a/0x30 </TASK> Kernel panic - not syncing: Fatal exception in interrupt
The machinery that leads to this kernel panic has not been changed between 6.18.48 and mainline.
This patch adds an ingress-delivery helper for the PTP packetfinish() path that calls netifreceiveskb() instead of napigroreceive(). netifreceiveskb(), unlike napigroreceive(), can be called from outside of the NAPI instance's poll context, which can occur at the call site for this path. RX stats accounting and the skb->dev assignment are still preserved; the only change is the delivery call itself.
This removes GR ---truncated---
In the Linux kernel, the following vulnerability has been resolved:
xfrm: iptfs: propagate SKBFLSHAREDFRAG in iptfsskbaddfrags()
When iptfsskbaddfrags() copies frag references from the source frag walk into a new SKB, it increments the page reference count via skbfragref() but does not propagate SKBFLSHAREDFRAG to the destination SKB's skbshinfo->flags.
If the source SKB carries shared frags (e.g. from a page-pool backed receive path), the new inner SKB will appear to ESP as having privately owned frags. A subsequent espinput() call for a nested transport-mode SA then takes the no-COW fast path and decrypts in place, writing over pages that are still referenced by the outer IPTFS SKB. This causes kernel-visible memory corruption and can trigger a panic.
All other frag-transfer helpers in the kernel (skbtrycoalesce, skbgroreceive, pskbcopyfclone, skbshift, skbsegment) correctly propagate SKBFLSHAREDFRAG; align iptfsskbaddfrags() with this convention by setting the flag inside the loop immediately after skbfragref() and nrfrags++, so every exit path that attaches a frag unconditionally propagates SKBFLSHAREDFRAG.
In the Linux kernel, the following vulnerability has been resolved:
In the Linux kernel, the following vulnerability has been resolved:
perf/aux: Fix page UAF in maprange()
maprange() reads rb->auxpages[], rb->auxnrpages and rb->auxpgoff via perfmmaptopage() while holding only event->mmapmutex. Those fields are serialized by rb->auxmutex, and mmapmutex is per event.
Thus, two events sharing one rb via PERFEVENTIOCSETOUTPUT can race rballocaux() with maprange(), leading to a page-UAF scenario as follows:
CPU 0 CPU 1 ===== ===== rballocaux() maprange() [1]: allocate rb->auxpages[0] [2]: rb->auxnrpages++ [3]: perfmmaptopage() returns rb->auxpages[0] [4]: map it as VMPFNMAP [5]: rb->auxpgoff = 1
munmap the page [6]: free rb->auxpages[0]
Pages mapped as VMPFNMAP have no refcount protection, so CPU 1 holds a mapping to a freed physical frame.
Fix this by taking rb->auxmutex across the page walk in maprange().
In the Linux kernel, the following vulnerability has been resolved:
fuse-uring: Avoid queue->stopped races and set/read that value under lock
There are several readers of queue->stopped that check the value under lock, but fuseuringcommitfetch() did not and actually the value was not set under the lock in fuseuringabortendrequests() either. Especially in fuseuringcommitfetch it is important to check under a lock, because due to races 'struct fusereq' might be freed with fuserequestend, but another thread/cpu might already do teardown work.
In the Linux kernel, the following vulnerability has been resolved:
fuse-uring: Avoid use-after-free in fuseuringasyncstopqueues
fuseuringasyncstopqueues() might run when the last reference on ring->queuerefs was already dropped.
In order to avoid an early destruction a reference on struct fuseconn is now taken before starting fuseuringasyncstopqueues() and that reference is only released when that delayed work queue terminates.
In the Linux kernel, the following vulnerability has been resolved:
fuse-uring: make a fusereq on SQE commit only findable after memcpy
Bad userspace might try to trick us and send commit SQEs request unique / commit-id of requests that are not even send to fuse-server (iouringcmddone() not called) yet.
fuseuringcommitfetch() ends the fuse request when the ring entry has a wrong state, but that could have caused a use-after-free with the memcpy operations in fuseuringsendintask(). In order to avoid such races the call of fuseuringaddtopq() is moved after the copy operations and just before completing the io-uring request - malicious userspace cannot find the request anymore until all prepration work in fuse-client/kernel is completed.
This also moves fuseuringaddtopq() a bit up in the code to avoid a forward declaration. Also not with a preparation commit, to make it easier to back port to older kernels.
In the Linux kernel, the following vulnerability has been resolved:
virt: sev-guest: Explicitly leak pages in unknown state
When setmemory{encrypted,decrypted}() fail, the user cannot know at which point the function failed, meaning that the pages are left in an unknown state from the point of view of the caller.
Since the pages may be left in an unencrypted state, they are not suitable for general use, and cannot be returned safely to the buddy allocator. Avoid the issue by never freeing the pages, and then do the proper accounting by calling snpleakpages().
In the Linux kernel, the following vulnerability has been resolved:
fprobe: Fix unregisterfprobe() to wait for RCU grace period
Commit 4346ba1604093 ("fprobe: Rewrite fprobe on function-graph tracer") changed fprobe to register struct fprobe to an rcu-hlist, but it forgot to wait for RCU GP. Thus there can be use-after-free if the fprobe is released right after unregistering. This can be happened on fprobe event and sample module code.
To fix this issue, add synchronizercu() in unregisterfprobe().
Note that BPF is OK because fprobe is used as a part of bpfkprobemultilink. This unregisters its fprobe in bpfkprobemultilinkrelease() and it is deallocated via bpfkprobemultilinkdealloc(), which is invoked from bpflinkdeferdeallocrcugp() RCU callback.
For BPF, this also introduced unregisterfprobeasync() which does NOT wait for RCU grace priod.
In the Linux kernel, the following vulnerability has been resolved:
netfs: Fix cancellation of a DIO and single read subrequests
When the preparation of a new subrequest for a read fails, if the subrequest has already been added to the stream->subrequests list, it can't simply be put and abandoned as the collector may see it. Also, if it hasn't been queued yet, it has two outstanding refs that both need to be put. Both DIO read and single-read dispatch fail at this; further, both differ in the order they do things to the way buffered read works.
Fix cancellation of both DIO-read and single-read subrequests that failed preparation by the following steps:
(1) Harmonise all three reads (buffered, dio, single) to queue the subreq before prepping it.
(2) Make all three call netfsqueueread() to do the queuing.
(3) Set NETFSRREQALLQUEUED independently of the queuing as we don't know the length of the subreq at this point.
(4) In all cases, set the error and NETFSSREQFAILED flag on the subreq and then call netfsreadsubreqterminated() to deal with it. This will pass responsibility off to the collector for dealing with it.
In the Linux kernel, the following vulnerability has been resolved:
afs: Fix the locking used by afsgetlink()
The afs filesystem in the kernel doesn't do locking correctly for symbolic links. There are a number of problems:
(1) It doesn't do any locking around afsreadsingle() to prevent races between multiple ->getlink() calls, thereby allowing the possibility of leaks.
(2) It doesn't use RCU barriering when accessing the buffer pointers during RCU pathwalk.
(3) It can race with another thread updating the contents of the symlink if a third party updated it on the server.
Fix this by the following means:
(0) Move symlink handling into its own file as this makes it more complicated.
(1) Take the validatelock around afsreadsingle() to prevent races between multiple ->getlink() calls.
(2) Keep a separate copy of the symlink contents with an rcuhead. This is always going to be a lot smaller than a page, so it can be kmalloc'd and save quite a bit of memory. It also needs a refcount for non-RCU pathwalk.
(3) Split the symlink read and write-to-cache routines in afs from those for directories.
(4) Discard the I/O buffer as soon as the write-to-cache completes as this is a full page (plus a folioqueue).
(5) If there's no cache, discard the I/O buffer immediately after reading and copying if there is no cache.
In the Linux kernel, the following vulnerability has been resolved:
xfrm: iptfs: reset runtime state when cloning SAs
iptfsclonestate() clones the IPTFS mode data with kmemdup(). This copies runtime objects which must not be shared with the original SA, including the embedded skbuffhead, hrtimers, spinlock, and in-flight reassembly/reorder state.
If xfrmstatemigrate() fails after clonestate() but before the later initstate() call has reinitialized those fields, the cloned state can be destroyed by xfrmstategctask() with list and timer state copied from the original SA. With queued packets this lets the clone splice and free skbs owned by the original IPTFS queue, leading to use-after-free and double-free reports in iptfsdestroystate() and skb release paths.
Reinitialize the clone's runtime state before publishing it through x->modedata. Because clonestate() now publishes a destroyable modedata object before initstate(), take the mode callback module reference there. Avoid taking it again from iptfsinitstate() for the same object.
In the Linux kernel, the following vulnerability has been resolved:
tee: optee: prevent use-after-free when the client exits before the supplicant
Commit 70b0d6b0a199 ("tee: optee: Fix supplicant wait loop") made the client wait as killable so it can be interrupted during shutdown or after a supplicant crash. This changes the original lifetime expectations: the client task can now terminate while the supplicant is still processing its request.
If the client exits first it removes the request from its queue and kfree()s it, while the request ID remains in supp->idr. A subsequent lookup on the supplicant path then dereferences freed memory, leading to a use-after-free.
Serialise access to the request with supp->mutex:
Hold supp->mutex in opteesupprecv() and opteesuppsend() while looking up and touching the request. Let opteesuppthrdreq() notice that the client has terminated and signal opteesuppsend() accordingly.
With these changes the request cannot be freed while the supplicant still has a reference, eliminating the race.
In the Linux kernel, the following vulnerability has been resolved:
xfrm: iptfs: fix use-after-free on firstskb in inputprocesspayload
inputprocesspayload() stores firstskb into xtfs->ranewskb under droplock when starting partial reassembly, then unlocks and breaks out of the processing loop. The post-loop check reads xtfs->ranewskb without the lock to decide whether firstskb is still owned:
if (firstskb && firstiplen && !defer && firstskb != xtfs->ranewskb)
Between spinunlock and this read, a concurrent CPU running iptfsreassemcont() (or the droptimer hrtimer) can complete reassembly, NULL xtfs->ranewskb, and free the skb. The check then evaluates firstskb != NULL as true, and pskbtrim/ipsummed/consumeskb operate on the freed skb — a use-after-free in skbuffheadcache.
Replace the unlocked read with a local bool that records whether firstskb was handed to the reassembly state in the current call. The flag is set after the existing spinunlock, before the break, using the pointer equality that is stable at that point (firstskb == skb iff firstskb was stored in ranewskb).
In the Linux kernel, the following vulnerability has been resolved:
virt: sev-guest: Do not use host-controlled page order in cleanup path
When issuing an extended guest request (SVMVMGEXITEXTGUESTREQUEST), getextreport() allocates a buffer to retrieve a certificate blob from the host, keeping track of its size in reportreq->certslen.
However, the host may return SNPGUESTVMMERRINVALIDLEN, indicating an invalid buffer size, as well as the expected length of such buffer. getextreport() subsequently updates reportreq->certslen with the host-controlled value, and cleans up the buffer by computing a page order from such value. This is incorrect, as the host-provided length may not match the page order of the original allocation, potentially resulting in corruption in the page allocator.
Fix this by using allocpagesexact() instead, and reusing @npages to compute the size passed to freepagesexact(). For consistency, also use @npages to compute the size when allocating the pages, even though this last change has no functional effect.
In the Linux kernel, the following vulnerability has been resolved:
bpf: Fix a potential use-after-free of BTF object
Refcounting in the checkpseudobtfid() function is incorrect: the checkpseudobtfid() function might get called with a zero refcounted btf. Fix this, and patch related code accordingly.
v3: rephrase a comment (AI) v2: fix a refcount leak introduced in v1 (AI)
In the Linux kernel, the following vulnerability has been resolved:
bpf: Fix memory access flags in helper prototypes
After commit 37cce22dbd51 ("bpf: verifier: Refactor helper access type tracking"), the verifier started relying on the access type flags in helper function prototypes to perform memory access optimizations.
Currently, several helper functions utilizing ARGPTRTOMEM lack the corresponding MEMRDONLY or MEMWRITE flags. This omission causes the verifier to incorrectly assume that the buffer contents are unchanged across the helper call. Consequently, the verifier may optimize away subsequent reads based on this wrong assumption, leading to correctness issues.
For bpfgetstackprotorawtp, the original MEMRDONLY was incorrect since the helper writes to the buffer. Change it to ARGPTRTOUNINITMEM which correctly indicates write access to potentially uninitialized memory.
Similar issues were recently addressed for specific helpers in commit ac44dcc788b9 ("bpf: Fix verifier assumptions of bpfdpath's output buffer") and commit 2eb7648558a7 ("bpf: Specify access type of bpfsysctlgetname args").
Fix these prototypes by adding the correct memory access flags.
In the Linux kernel, the following vulnerability has been resolved:
spi: rockchip-sfc: Fix double-free in remove() callback
The driver uses devmspiregistercontroller() for registration, which automatically unregisters the controller via devm cleanup when the device is removed. The manual call to spiunregistercontroller() in the remove() callback can lead to a double-free.
And to make sure controller is unregistered before DMA buffer is unmapped, switch to use spiregistercontroller() in probe().
In the Linux kernel, the following vulnerability has been resolved:
mm/damon/core: clear walkcontrol on inactive context in damoswalk()
damoswalk() sets ctx->walkcontrol to the caller-provided control structure before checking whether the context is running. If the context is inactive (damonisrunning() returns false), the function returns -EINVAL without clearing ctx->walkcontrol. This leaves a dangling pointer to a stack-allocated structure that will be freed when the caller returns.
This is structurally identical to the bug fixed in commit f9132fbc2e83 ("mm/damon/core: remove callcontrol in inactive contexts") for damoncall(), which had the same pattern of linking a control object and returning an error without unlinking it.
The dangling walkcontrol pointer can cause: 1. Use-after-free if the context is later started and kdamond   dereferences ctx->walkcontrol (e.g., in damoswalkcancel()   which writes to control->canceled and calls complete()) 2. Permanent -EBUSY from subsequent damoswalk() calls, since the   stale pointer is non-NULL
Nonetheless, the real user impact is quite restrictive. The use-after-free is impossible because there is no damoswalk() callers who starts the context later. The permanent -EBUSY can actually confuse users, as DAMON is not running. But the symptom is kept only while the context is turned off. Turning it on again will make DAMON internally uses a newly generated damonctx object that doesn't have the invalid damoswalkcontrol pointer, so everything will work fine again.
Fix this by clearing ctx->walkcontrol under walkcontrollock before returning -EINVAL, mirroring the fix pattern from f9132fbc2e83.
In the Linux kernel, the following vulnerability has been resolved:
mailbox: mchp-ipc-sbi: fix out-of-bounds access in mchpipcgetclusteraggrirq()
The clustercfg array is dynamically allocated to hold per-CPU configuration structures, with its size based on the number of online CPUs. Previously, this array was indexed using hartid, which may be non-contiguous or exceed the bounds of the array, leading to out-of-bounds access. Switch to using cpuid as the index, as it is guaranteed to be within the valid range provided by foreachonlinecpu().
In the Linux kernel, the following vulnerability has been resolved:
mm: call ->freefolio() directly in foliounmapinvalidate()
We can only call filemapfreefolio() if we have a reference to (or hold a lock on) the mapping. Otherwise, we've already removed the folio from the mapping so it no longer pins the mapping and the mapping can be removed, causing a use-after-free when accessing mapping->aops.
Follow the same pattern as removemapping() and load the freefolio function pointer before dropping the lock on the mapping. That lets us make filemapfreefolio() static as this was the only caller outside filemap.c.
In the Linux kernel, the following vulnerability has been resolved:
xfrm: iptfs: validate inner IPv4 header length in IPTFS payload
Add validation of the inner IPv4 packet totlen and ihl fields parsed from decrypted IPTFS payloads in inputprocesspayload(). A crafted ESP packet containing an inner IPv4 header with totlen=0 causes an infinite loop: iplen=0 leads to capturelen=min(0, remaining)=0, so the data offset never advances and the while(data < tail) loop never terminates, spinning forever in softirq context.
Reject inner IPv4 packets where totlen < ihl4 or ihl4 < sizeof(struct iphdr), which catches both the totlen=0 case and malformed ihl values. The normal IP stack performs this validation in iprcvcore(), but IPTFS extracts and processes inner packets before they reach that layer.
In the Linux kernel, the following vulnerability has been resolved:
xfrm: iptfs: only publish modedata after clone setup
iptfsclonestate() stores x->modedata before allocating the reorder window. If that allocation fails, the code frees the cloned state and returns -ENOMEM, leaving x->modedata pointing at freed memory.
The xfrm clone unwind later runs destroystate() through x->modedata, so the failed clone path tears down IPTFS state that clonestate() already freed.
Keep the cloned IPTFS state private until all allocations succeed so failed clones leave x->modedata unset. The destroy path already handles a NULL modedata pointer.
In the Linux kernel, the following vulnerability has been resolved:
dmaengine: idxd: Fix possible invalid memory access after FLR
In the case that the first Function Level Reset (FLR) concludes correctly, but in the second FLR the scratch area for the saved configuration cannot be allocated, it's possible for a invalid memory access to happen.
Always set the deallocated scratch area to NULL after FLR completes.
In the Linux kernel, the following vulnerability has been resolved:
Bluetooth: L2CAP: Fix use-after-free in l2capunregisteruser
After commit ab4eedb790ca ("Bluetooth: L2CAP: Fix corrupted list in hcichandel"), l2capconndel() uses conn->lock to protect access to conn->users. However, l2capregisteruser() and l2capunregisteruser() don't use conn->lock, creating a race condition where these functions can access conn->users and conn->hchan concurrently with l2capconndel().
This can lead to use-after-free and list corruption bugs, as reported by syzbot.
Fix this by changing l2capregisteruser() and l2capunregisteruser() to use conn->lock instead of hcidevlock(), ensuring consistent locking for the l2capconn structure.
In the Linux kernel, the following vulnerability has been resolved:
perf/core: Fix refcount bug and potential UAF in perfmmap
Syzkaller reported a refcountt: addition on 0; use-after-free warning in perfmmap.
The issue is caused by a race condition between a failing mmap() setup and a concurrent mmap() on a dependent event (e.g., using output redirection).
In perfmmap(), the ringbuffer (rb) is allocated and assigned to event->rb with the mmapmutex held. The mutex is then released to perform maprange().
If maprange() fails, perfmmapclose() is called to clean up. However, since the mutex was dropped, another thread attaching to this event (via inherited events or output redirection) can acquire the mutex, observe the valid event->rb pointer, and attempt to increment its reference count. If the cleanup path has already dropped the reference count to zero, this results in a use-after-free or refcount saturation warning.
Fix this by extending the scope of mmapmutex to cover the maprange() call. This ensures that the ring buffer initialization and mapping (or cleanup on failure) happens atomically effectively, preventing other threads from accessing a half-initialized or dying ring buffer.
In the Linux kernel, the following vulnerability has been resolved:
cgroup/dmem: avoid pool UAF
An UAF issue was observed:
BUG: KASAN: slab-use-after-free in pagecounteruncharge+0x65/0x150 Write of size 8 at addr ffff888106715440 by task insmod/527
CPU: 4 UID: 0 PID: 527 Comm: insmod 6.19.0-rc7-next-20260129+ #11 Tainted: [O]=OOTMODULE Call Trace: <TASK> dumpstacklvl+0x82/0xd0 kasanreport+0xca/0x100 kasancheckrange+0x39/0x1c0 pagecounteruncharge+0x65/0x150 dmemcgroupuncharge+0x1f/0x260
Allocated by task 527:
Freed by task 0:
The buggy address belongs to the object at ffff888106715400 which belongs to the cache kmalloc-512 of size 512 The buggy address is located 64 bytes inside of freed 512-byte region [ffff888106715400, ffff888106715600)
The buggy address belongs to the physical page:
Memory state around the buggy address: ffff888106715300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888106715380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888106715400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888106715480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888106715500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
The issue occurs because a pool can still be held by a caller after its associated memory region is unregistered. The current implementation frees the pool even if users still hold references to it (e.g., before uncharge operations complete).
This patch adds a reference counter to each pool, ensuring that a pool is only freed when its reference count drops to zero.
In the Linux kernel, the following vulnerability has been resolved:
netfs: Fix early read unlock of page with EOF in middle
The read result collection for buffered reads seems to run ahead of the completion of subrequests under some circumstances, as can be seen in the following log snippet:
9pclientres: client 18446612686390831168 response P9TREAD tag 0 err 0 ... netfssreq: R=00001b55[1] DOWN TERM f=192 s=0 5fb2/5fb2 s=5 e=0 ... netfscollectfolio: R=00001b55 ix=00004 r=4000-5000 t=4000/5fb2 netfsfolio: i=157f3 ix=00004-00004 read-done netfsfolio: i=157f3 ix=00004-00004 read-unlock netfscollectfolio: R=00001b55 ix=00005 r=5000-5fb2 t=5000/5fb2 netfsfolio: i=157f3 ix=00005-00005 read-done netfsfolio: i=157f3 ix=00005-00005 read-unlock ... netfscollectstream: R=00001b55[0:] cto=5fb2 frn=ffffffff netfscollectstate: R=00001b55 col=5fb2 cln=6000 n=c netfscollectstream: R=00001b55[0:] cto=5fb2 frn=ffffffff netfscollectstate: R=00001b55 col=5fb2 cln=6000 n=8 ... netfssreq: R=00001b55[2] ZERO SUBMT f=000 s=5fb2 0/4e s=0 e=0 netfssreq: R=00001b55[2] ZERO TERM f=102 s=5fb2 4e/4e s=5 e=0
The 'cto=5fb2' indicates the collected file pos we've collected results to so far - but we still have 0x4e more bytes to go - so we shouldn't have collected folio ix=00005 yet. The 'ZERO' subreq that clears the tail happens after we unlock the folio, allowing the application to see the uncleared tail through mmap.
The problem is that netfsreadunlockfolios() will unlock a folio in which the amount of read results collected hits EOF position - but the ZERO subreq lies beyond that and so happens after.
Fix this by changing the end check to always be the end of the folio and never the end of the file.
In the future, I should look at clearing to the end of the folio here rather than adding a ZERO subreq to do this. On the other hand, the ZERO subreq can run in parallel with an async READ subreq. Further, the ZERO subreq may still be necessary to, say, handle extents in a ceph file that don't have any backing store and are thus implicitly all zeros.
This can be reproduced by creating a file, the size of which doesn't align to a page boundary, e.g. 24998 (0x5fb2) bytes and then doing something like:
xfsio -c "mmap -r 0 0x6000" -c "madvise -d 0 0x6000" \ -c "mread -v 0 0x6000" /xfstest.test/x
The last 0x4e bytes should all be 00, but if the tail hasn't been cleared yet, you may see rubbish there. This can be reproduced with kafs by modifying the kernel to disable the call to netfsreadsubreqprogress() and to stop afsissueread() from doing the async call for NETFSREADAHEAD. Reproduction can be made easier by inserting an mdelay(100) in netfsissueread() for the ZERO-subreq case.
AFS and CIFS are normally unlikely to show this as they dispatch READ ops asynchronously, which allows the ZERO-subreq to finish first. 9P's READ op is completely synchronous, so the ZERO-subreq will always happen after. It isn't seen all the time, though, because the collection may be done in a worker thread.
In the Linux kernel, the following vulnerability has been resolved:
ice: fix Rx page leak on multi-buffer frames
The iceputrxmbuf() function handles calling iceputrxbuf() for each buffer in the current frame. This function was introduced as part of handling multi-buffer XDP support in the ice driver.
It works by iterating over the buffers from firstdesc up to 1 plus the total number of fragments in the frame, cached from before the XDP program was executed.
If the hardware posts a descriptor with a size of 0, the logic used in iceputrxmbuf() breaks. Such descriptors get skipped and don't get added as fragments in iceaddxdpfrag. Since the buffer isn't counted as a fragment, we do not iterate over it in iceputrxmbuf(), and thus we don't call iceputrxbuf().
Because we don't call iceputrxbuf(), we don't attempt to re-use the page or free it. This leaves a stale page in the ring, as we don't increment nexttoalloc.
The icereuserxpage() assumes that the nexttoalloc has been incremented properly, and that it always points to a buffer with a NULL page. Since this function doesn't check, it will happily recycle a page over the top of the nexttoalloc buffer, losing track of the old page.
Note that this leak only occurs for multi-buffer frames. The iceputrxmbuf() function always handles at least one buffer, so a single-buffer frame will always get handled correctly. It is not clear precisely why the hardware hands us descriptors with a size of 0 sometimes, but it happens somewhat regularly with "jumbo frames" used by 9K MTU.
To fix iceputrxmbuf(), we need to make sure to call iceputrxbuf() on all buffers between firstdesc and nexttoclean. Borrow the logic of a similar function in i40e used for this same purpose. Use the same logic also in icegetpgcnts().
Instead of iterating over just the number of fragments, use a loop which iterates until the current index reaches to the nexttoclean element just past the current frame. Unlike i40e, the iceputrxmbuf() function does call iceputrxbuf() on the last buffer of the frame indicating the end of packet.
For non-linear (multi-buffer) frames, we need to take care when adjusting the pagecntbias. An XDP program might release fragments from the tail of the frame, in which case that fragment page is already released. Only update the pagecntbias for the first descriptor and fragments still remaining post-XDP program. Take care to only access the shared info for fragmented buffers, as this avoids a significant cache miss.
The xdpxmit value only needs to be updated if an XDP program is run, and only once per packet. Drop the xdpxmit pointer argument from iceputrxmbuf(). Instead, set xdpxmit in the icecleanrxirq() function directly. This avoids needing to pass the argument and avoids an extra bit-wise OR for each buffer in the frame.
Move the increment of the ntc local variable to ensure its updated before all calls to icegetpgcnts() or iceputrxmbuf(), as the loop logic requires the index of the element just after the current frame.
Now that we use an index pointer in the ring to identify the packet, we no longer need to track or cache the number of fragments in the rxring.
In the Linux kernel, the following vulnerability has been resolved:
zram: fix slot write race condition
Parallel concurrent writes to the same zram index result in leaked zsmalloc handles. Schematically we can have something like this:
CPU0 CPU1 zramslotlock() zsfree(handle) zramslotlock() zramslotlock() zsfree(handle) zramslotlock()
compress compress handle = zsmalloc() handle = zsmalloc() zramslotlock zramsethandle(handle) zramslotlock zramslotlock zramsethandle(handle) zramslotlock
Either CPU0 or CPU1 zsmalloc handle will leak because zsfree() is done too early. In fact, we need to reset zram entry right before we set its new handle, all under the same slot lock scope.