In the Linux kernel, the following vulnerability has been resolved:
mm/userfaultfd: only allocate anonvma in CoW mappings
findvmaandprepareanon() can end up allocating an anonvma in VMAs that are not CoW mappings, which is wrong.
If we have a MAPSHARED R/O file mapped, we lack VMSHARED (but do have VMMAYSHARE) and lack VMMAYWRITE.
While uffd later rejects such mappings (uffd registration requires VMMAYWRITE, see comment in validatedstvma) findvmaandprepareanon() still wrongly allocates an anon vma before it validates the vma.
This in turn later confuses copypagerange()->vmaneedscopy() such that we end up calling copyhugetlbpagerange() with ranges that actually do not contain any per-pagetable information that would require copying, which is the basis for PMD-table sharing in the first place.
copyhugetlbpagerange() should not have to worry about shared PMD tables at all: it doesn't make any sense to copy page tables that are shared, as they can be fully recreated later. Ending up in the function with shareable page tables is the real issue.
If a destination PMD table is shared in copyhugetlbpagerange(), it might get concurrently unshared as we are not holding relevant locks, resulting in us using a page table that is no longer mapped and possibly freed after calling:
dstpte = hugeptealloc(dst, dstvma, addr, sz);
To fix it, do not allocate an anonvma in non-CoW mappings and add a safety guard to copyhugetlbpagerange(), making sure that we never end up messing with shared PMD tables in there.
Before commit 867a43a34ff8a ("userfaultfd: use per-vma locks in userfaultfd operations") we would always validate the VMA before allocating an anonvma, and consequently never wrongly allocate an anonvma.
As uffdlockvma() is part of the same lookup machinery and also contains a misleading VMSHARED check, change that one as well directly for consistency.
A follow-up cleanup will stop taking the hugetlbvmalockread(srcvma) lock in copyhugetlbpagerange() entirely. Further, the usage of VMSHARED in userfaultfd code should be cleaned up later to focus on CoW vs. non-CoW mappings.
In the Linux kernel, the following vulnerability has been resolved:
mm/gup: check for overflow when converting nrpages to bytes in GUP-fast
The overflow check in gupfastfallback() only covers the addition to start. The preceding nrpages << PAGESHIFT can already have truncated the length on 32bit.
Users such as RapidIO's riodmatransfer() can derive such page counts from a 64-bit userspace length.
Let's just checkshloverflow() to reject any such overflow with -EOVERFLOW early.
In the Linux kernel, the following vulnerability has been resolved:
x86/mm: Fix global ASID handed out to two processes
On AMD CPUs with INVLPGB, two live processes can get the same MAXASIDAVAILABLE global ASID value. The two then hit each other's TLB entries, so each can read or corrupt the other's memory.
The global ASID space is managed lazily. When a global ASID is freed, its bit is set in the globalasidfreed bitmap. Once the free ASID search reaches the end of the globalasidused bitmap, a global flush is done to really reclaim the lazily freed global ASIDs.
However, the current code can assign the same global ASID to two different processes, if one process is assigned MAXASIDAVAILABLE - 1, another process MAXASIDAVAILABLE, and both stick around (keeping their global ASID numbers in use) until the search wraps around again. At that point a third process could also get assigned MAXASIDAVAILABLE.
the highest ASID stays in use, so it is not handed out again lastglobalasid stays below it, so no reset the clear bits run out findnextzerobit() returns MAXASIDAVAILABLE globalasidavailable > 0, so the failure is not caught MAXASIDAVAILABLE is handed out as an ASID
A search only looks at the bits below MAXASIDAVAILABLE, so it cannot see that this value is in use. The next failed search hands it out again, even if the first process still holds it.
The fix used here is to reset the global ASID space after a failed search, and to search again. If that search fails too, no global ASID is handed out.
The test for !globalasidavailable is removed, because useglobalasid() only calls allocateglobalasid() if globalasidavailable > 0. The remaining test is for a condition that should be impossible.
[ riel: simplify code, massage changelog and comment ]
In the Linux kernel, the following vulnerability has been resolved:
fs/proc/taskmmu: pin mmusers in dopagemapscan()
The PAGEMAPSCAN ioctl takes mmapreadlock() on an mm obtained from /proc/<pid>/pagemap without holding a reference to mmusers.
procmemopen() deliberately grabs only mmcount, so a consumer that touches the address space has to call mmgetnotzero() first. Every other consumer in this file does -- mstart(), doprocmapquery(), showsmapsrollup() and pagemapread() -- but dopagemapscan() does not.
Without that reference the target can reach exitmmap() concurrently, and exitmmap() calls unmapvmas() while holding mmaplock only for reading, which does not exclude the scanner. For ordinary VMAs this is harmless, as freepgtables() and removevma() run afterwards under mmapwritelock. A shared hugetlb VMA is different: hugetlbzapend() frees the VMA's hugetlbvmalock inside the read-locked phase.
walkhugetlbrange() can therefore load vma->vmprivatedata, have the lock freed underneath it, and then downread() a freed rwsemaphore. The load happens before the freeing side clears the pointer, so this is a use-after-free and not a NULL dereference. Any unprivileged user can reach it with no huge pages configured, as hugetlbreservepages() allocates the lock before the VMNORESERVE early return.
Pin mmusers across the scan, the way the other consumers do. mmput() from the exiting task can then no longer reach exitmmap() while a walk is in progress.
[akpm: remove unneeded & undesirable test for !mm]
In the Linux kernel, the following vulnerability has been resolved:
mm/rmap: don't discard lazyfree THPs at PMD level
discardanonfoliopmdlocked() clears a lazyfree THP's PMD before it determines whether the folio can be discarded, and restores it if the folio is dirty or has extra references. It is done under only the PMD lock and the anonvma read lock inside trytounmapone() and no mmap lock is held. The temporarily none PMD causes UAF.
A parallel munmap() or mremap() is supposed to serialize with it on the PMD lock, but zappmdrange() (called by munmap()) and movepagetables() (called by mremap()) do not take the lock when they see the temporarily none PMD and skip the PMD. There is no more page table walk after the none PMD is restored:
- munmap(): freepgtables() waits in unlinkanonvmas() for the anonvma lock, then freepmdrange() drops the restored PMD as bad without removing the rmap, so the folio keeps a stale mapcount.
- whole-VMA MREMAPDONTUNMAP: dontunmapcomplete() unlinks the source VMA from its anonvma while the restored PMD still maps the folio.
- plain mremap(): the THP is not moved but unmapped, so the THP's data is lost.
In the first two cases, the folio stays mapped, but no VMA that maps it is linked to its anonvma. When the anonvma is freed, it is still reachable when one rmap walks the folio. Racing lazyfree reclaim against MREMAPDONTUNMAP as an unprivileged user reproduces a KASAN use-after-free in foliolockanonvmaread() as reported in the Closes link.
One solution is to use an invalidated PMD instead of a cleared one until the discard is committed, but it needs arch fixes first. 1. GUP-fast still follows an invalidated PMD on riscv, LoongArch and s390. 2. sparc64 miscounts thpptecount when an invalidated PMD is set again or cleared.
To keep the fix simple for backport, stop discarding lazyfree THPs at PMD level instead. trytounmapone() splits the PMD and discards the folio at PTE level.
unmaphugepmdlocked() and discardanonfoliopmdlocked() are left in place, unused, to minimize this fix for backport and the invalidated PMD approach is planned as a follow-up series to use them again.
In the Linux kernel, the following vulnerability has been resolved:
KVM: guestmemfd: take the invalidate lock when unbinding a dying file
kvmgmemunbind() takes mapping->invalidatelock only if the getfileactive() succeeds. When the guestmemfd file is dying, its reference count is already zero so getfileactive fails and the binding is removed without holding the invalidate lock.
kvmgmeminvalidate{start,end}() checks f->bindings independently to decide whether to begin or end KVM MMU invalidation. So, the bindings must therefore remain stable between the two calls. Otherwise, unbind can remove a binding after start increments mmuinvalidateinprogress, but before end finds the binding and decrements it. Example, unbind race with memory failure:
CPU 0: memory failure CPU 1: memslot delete ---------------------------------- --------------------------- (guestmemfd file is dying) kvmgmemerrorfolio() kvmgmeminvalidatestart() finds binding mmuinvalidateinprogress++ kvmgmemunbind() getfileactive() fails removes binding kvmgmeminvalidateend() no binding found counter stays elevated
mmuinvalidateretry() then returns 1 forever, so guest page faults retry without ever installing a mapping and the guest hangs.
Remove the distinction between live and dying files in the unbind path. Always use slot->gmem.file and take the invalidate lock when it's non-NULL. Normal unbind callers hold slotslock, which prevents release from clearing the pointer or freeing the file state until unbind completes. Final VM teardown can only see a NULL pointer because guestmemfd pins the KVM until release has cleared all bindings.
In the Linux kernel, the following vulnerability has been resolved:
ipv6: raw: fix use-after-free in rawv6sendhdrinc()
rawv6sendhdrinc() caches the route before handing the skb to l3mdevip6out(). The VRF output path may replace skb->dst and release the original route, leaving the cached pointer stale.
The function later dereferences that pointer for statistics accounting and as the output device passed to NFHOOK(). Its RCU read-side critical section starts after l3mdevip6out(), so it cannot prevent the old route from being reclaimed in between.
Reload the route from the current skb destination after l3mdevip6out() returns.
KASAN reports a slab-use-after-free in rawv6sendmsg(), with the route allocated by ip6dstalloc(), freed by dstdestroy() from rcucore(), and the related RCU callback queued from vrfl3out().
ALSA: hwdep: Serialize DSP load requests
ALSA: usx2y: Initialize idle URBs before submitting streams
In the Linux kernel, the following vulnerability has been resolved:
HID: logitech-hidpp: fix race condition when accessing stale stack pointer
The driver uses hidpp->sendreceivebuf to point to a stack-allocated buffer in the synchronous command path (dohidppsendmessagesync). However, this pointer is not cleared when the function returns.
If an event is processed (e.g. by a different thread) while the sendmutex is held by a new command, but before that command has updated sendreceivebuf, the handler (hidpprawhidppevent) will observe that the mutex is locked and dereference the stale pointer.
This results in an out-of-bounds access on a different thread's kernel stack (or a NULL pointer dereference on the very first command).
Fix this by: 1. Clearing hidpp->sendreceivebuf to NULL before releasing the mutex in the synchronous command path. 2. Moving the assignment of the local 'question' and 'answer' pointers inside the mutexislocked() block in the handler, and adding a NULL check before dereferencing.
In the Linux kernel, the following vulnerability has been resolved:
KVM: x86: Unconditionally reset MMU context when emulating INIT
Force an MMU reset when emulating an INIT even if paging was already disabled, as the MMU page role includes guestmode (L2), i.e. an INIT while L2 is running with CR0.PG=0 will result in KVM running L1 with a stale MMU context.
Alternatively, the reset could be scoped strictly to paging being enabled or L2 being active, but SMM is also encoded in the page role. Even though it should be impossible for the vCPU to be INIT'd while SMM is active, there's zero value in not handling SMM. At that point, the only scenario where KVM doesn't need to reset the MMU context is on an INIT with the vCPU running in Real Mode or Unpaged Protect Mode, and while INIT in those modes is somewhat common, it's far from a hot path and re-initializing the MMU is not expensive, especially when the role isn't changing (KVM elides most of the re-configuration in that case).
Note, like the Fixes commit, this bug only affects nested SVM as INIT is an unconditional intercept on VMX, i.e. it's impossible to emulate INIT while L2 is active.
Temporarily keep the guest TLB flush when CR0.PG is being cleared even though it is fully redundant with the flush that is emitted on all INIT events (KVM itself only does RESET when a vCPU is being created, i.e. when CR0.PG must be '0').
In the Linux kernel, the following vulnerability has been resolved:
ksmbd: fix app-instance non-durable supersede session UAF
ksmbdclosefdappinstanceid() supersedes a prior open that has the same AppInstanceId. It reaches that open's session through opinfo->sess. This pointer is not refcounted.
Session teardown detaches durable handles before it frees the session. It does not detach a non-durable open. That open still points at the session through opinfo->sess after the session is freed. Another session can supersede the open at the same time. The supersede then takes a write lock through the stale pointer, in the freed session's file table.
BUG: KASAN: slab-use-after-free in rawwritelock+0x71/0xd0 Call Trace: rawwritelock+0x71/0xd0 ksmbdclosefdappinstanceid+0xd9/0x670 [ksmbd] smb2open+0x3e10/0xd910 [ksmbd] Freed by task 212: ksmbdsessiondestroy+0x38d/0x480 [ksmbd]
Fix this by looking the session up by opinfo->sessionid. The lookup returns a reference, as smb2breakcollectchannels() does. Recheck that opinfo->sess still points at it before using it.
Do the lookup without mlock held. destroyprevioussession() takes mlock under the session table lock, and taking them in the other order here would deadlock.
In the Linux kernel, the following vulnerability has been resolved:
smb: client: fix slab-out-of-bounds write in idmodetocifsacl()
In idmodetocifsacl(), while the chown branch reserves sizeof(struct smbntsd) + 2 sizeof(struct smbsid) (plus sizeof(struct smbacl) and the worst-case ACE space after commit 0ee150794c75 ("smb: client: fix heap overflow in DACL owner/group rewrite")), the chmod branch only adds 2 sizeof(struct smbace) or 5 sizeof(struct smbace) to secdesclen (or 1 sizeof(struct smbace) on posix).
However, the chmod branch also invokes buildsecdesc() -> copysecdesc(), which unconditionally writes the Owner SID at pnntsd + sidsoffset and the Group SID at pnntsd + sidsoffset + sizeof(struct smbsid) (2 68 = 136 bytes total), and setchmoddacl() always writes a struct smbacl header (8 bytes) even when the source descriptor has dacloffset == 0. When a security descriptor has compact or overlapping Owner/Group SIDs (or dacloffset == 0), calling chmod() under-allocates pnntsd and writes past the end of the slab buffer.
Reserve sizeof(struct smbacl) + 2 sizeof(struct smbsid) (plus sizeof(struct smbntsd) on the posix path) in the chmod branch of idmodetocifsacl().
In the Linux kernel, the following vulnerability has been resolved:
ksmbd: fix use-after-free after a failed durable reconnect
ksmbdreopendurablefd() republishes a detached durable handle in the reconnecting session's file table and takes no reference for that entry. If smb2open() then fails, cleanup relies on the final ksmbdfdput() to remove the volatile id.
Two reconnects of the same handle can both take a lookup reference before either attaches it. If the one that reopens first then fails and drops its references first, the other request makes the final put through ksmbdputdurablefd(). That frees the handle without removing the first session's table entry, so tearing that session down writes to freed memory.
BUG: KASAN: slab-use-after-free in closefiletableids+0x14d/0x740 [ksmbd] Call Trace: closefiletableids+0x14d/0x740 [ksmbd] ksmbddestroyfiletable+0x76/0x100 [ksmbd] ksmbdsessiondestroy+0xf8/0x480 [ksmbd] ksmbddisposesessions+0x13e/0x200 [ksmbd] ksmbdconnsessionscleanup+0x4c3/0x6d0 [ksmbd] Freed by task 1030: ksmbdclosefd+0x97d/0x1000 [ksmbd] smb2open+0x14eb/0xd9f0 [ksmbd]
Commit 3515503322f4 ("ksmbd: fix durable reconnect error path file lifetime") handles a final put made by the reconnecting request, but not one made by another holder.
Remove the volatile id under the file-table lock on this error path, before the references are dropped, as ksmbdclosefd() does on the requestopen path just above. Removal then no longer depends on which holder makes the final put. The stale comment in the reconnect cleanup is updated to match. A successful reconnect is unchanged.
In the Linux kernel, the following vulnerability has been resolved:
nvmet-rdma: reject short connection requests
nvmetrdmaparsecmconnectreq() treats RDMA-CM private data as a struct nvmerdmacmreq but accepts any nonzero privatedatalen. The iWARP path allocates exactly the peer-provided length, so a six-byte MPA request reaches the parser and the hsqsize load reads two bytes past the allocation.
Require the complete request structure before reading any of its fields. The decoded KASAN report is:
BUG: KASAN: slab-out-of-bounds in nvmetrdmacmhandler (drivers/nvme/target/rdma.c:1427 drivers/nvme/target/rdma.c:1475 drivers/nvme/target/rdma.c:1614 drivers/nvme/target/rdma.c:1814) Read of size 2 at addr ff1100010459d366 by task kworker/u16:1/41 Workqueue: iwcmwq cmworkhandler Call Trace: <TASK> dumpstacklvl (lib/dumpstack.c:94 lib/dumpstack.c:120) printreport (mm/kasan/report.c:378 mm/kasan/report.c:482) kasanreport (mm/kasan/report.c:595) nvmetrdmacmhandler (drivers/nvme/target/rdma.c:1427 drivers/nvme/target/rdma.c:1475 drivers/nvme/target/rdma.c:1614 drivers/nvme/target/rdma.c:1814) cmacmeventhandler (drivers/infiniband/core/cma.c:2181) iwconnreqhandler (drivers/infiniband/core/cma.c:2640) cmworkhandler (drivers/infiniband/core/cm.c:2502 drivers/infiniband/core/cm.c:3858) processonework (kernel/workqueue.c:3396) workerthread (kernel/workqueue.c:3479 kernel/workqueue.c:3560) kthread (kernel/kthread.c:436) retfromfork (arch/x86/kernel/process.c:158) retfromforkasm (arch/x86/entry/entry64.S:245) </TASK>
Allocated by task 12: kasankmalloc (mm/kasan/common.c:398 mm/kasan/common.c:415) kmallocnodetrackcallernoprof (mm/slub.c:5414 mm/slub.c:5545) kmemdupnoprof (mm/util.c:138) cmeventhandler (drivers/infiniband/core/iwcm.c:194 drivers/infiniband/core/iwcm.c:1076) siwcmupcall (drivers/infiniband/sw/siw/siwcm.c:408) siwprocmpareq (drivers/infiniband/sw/siw/siwcm.c:750) siwcmworkhandler (drivers/infiniband/sw/siw/siwcm.c:1086)
The buggy address is located 0 bytes to the right of allocated 6-byte region [ff1100010459d360, ff1100010459d366)
In the Linux kernel, the following vulnerability has been resolved:
smb: client: stop processing a read response after a receive error
cifsreaditerfromsocket() may call cifsreconnect() before returning an error. The reconnect path aborts pending mids and invokes their callbacks. The callback can then release the cifsiosubrequest containing rdata.
cifsreadvreceive() nevertheless continues after a negative return and may dereference rdata in cifsreadvdiscard(). KASAN reports the resulting UAF:
BUG: KASAN: slab-use-after-free in cifsreadvreceive Read of size 4 by task cifsd cifsreadvreceive (fs/smb/client/transport.c:1284) cifsdemultiplexthread (fs/smb/client/connect.c:1355) kthread (kernel/kthread.c:436) retfromfork (arch/x86/kernel/process.c:158)
Freed by task 148: netfsputsubrequest (fs/netfs/objects.c:267) netfsreadcollection (fs/netfs/readcollect.c:460) netfswaitforinprogress (fs/netfs/misc.c:462)
Return the socket error immediately, as this path did before the iterator conversion. This also avoids adding a negative length to totalread.
In the Linux kernel, the following vulnerability has been resolved:
ksmbd: fix SMB2 CREATE response buffer overflow
smb2allocaterspbuf() uses the MAXCIFSSMALLBUFFERSIZE (448-byte) buffer for a single SMB2CREATE response. That buffer also holds a 4-byte length field, which only leaves 444 bytes for the SMB2 body.
The AAPL response made this buffer too small. After 8f1b796ff113, a request with AAPL response contexts may need at least 456 bytes. In the 456-byte case, createaaplrspbuf() is appended last, clears 128 bytes, and writes 12 bytes past the allocation.
KASAN reports:
BUG: KASAN: slab-out-of-bounds in createaaplrspbuf+0x31/0x6e0 Write of size 128 at addr ffff88800370954c by task kworker/0:0/9 ... createaaplrspbuf+0x31/0x6e0 smb2open+0x58f9/0xef10 ... smb2allocaterspbuf+0x19d/0x370 ... The buggy address is located 332 bytes inside of allocated 448-byte region [ffff888003709400, ffff8880037095c0)
Reserve enough space for any fixed CREATE response KSMBD can build. Store the required allocation size in the per-dialect values table. This keeps the small buffer for other commands and avoids using the max transaction buffer for every CREATE.
ceph: fix integer overflow in the snap trace bounds check
In the Linux kernel, the following vulnerability has been resolved:
udf: fix return value for non-recorded-allocated extents in udfmapblock()
When someone creates a corrupted UDF filesystem where symlink contains other extent type than EXTRECORDEDALLOCATED, it can leads to a crash like:
Oops: general protection fault KASAN: maybe wild-memory-access RIP: 0010:pagegetlink (fs/namei.c:6503) Call Trace: vfsreadlink (fs/namei.c:6419) doreadlinkat (fs/stat.c:583) x64sysreadlink (fs/stat.c:605 fs/stat.c:602 fs/stat.c:602)
This is because in this case udfmapblock() fails to convert return value of inodebmap() from 1 to 0. Returned '1' propagates through udfbread() all the way up to pagegetlink() where it ends up being treated as a folio pointer with obvious results.
Move the reset to 0 line outside the if, so udfmapblock() returns either 0 or -errno, even if the extent type is not EXTRECORDEDALLOCATED.
In the Linux kernel, the following vulnerability has been resolved:
inet: reject unhashed sockets during established lookups
TCP established ehash lookups are lockless. The socket caches involved use SLABTYPESAFEBYRCU, so memory can be reused before an RCU reader that retained its old address has finished.
After a tuple match, inetlookupestablished() and inet6lookupestablished() acquire a reference and repeat the tuple check. They do not check whether the new object is hashed. If the address is reused for a socket with the same tuple, the lookup can acquire a reference to the new object and return it while its nulls node is unhashed.
A PoC that drives reuse with a SYN cookie request socket reproduced the crash. The new request socket is unhashed and has a NULL rsklistener. A lookup that had loaded the address of the old request socket acquired the reference published by tcpgetcookiesock() and returned the new object. tcpv4rcv() then read skstate through the NULL listener.
The resulting crash was:
BUG: kernel NULL pointer dereference, address: 0000000000000012 #PF: supervisor read access in kernel mode #PF: errorcode(0x0000) - not-present page ... Oops: Oops: 0000 [#1] SMP NOPTI CPU: 4 UID: 0 PID: 0 Comm: swapper/4 Not tainted 7.3.0-00591-g0e135910deec #1 PREEMPT(lazy) ... RIP: 0010:tcpv4rcv+0x44e/0x1280 ... R10: 0000000000000001 R11: 00000000024ca8c0 R12: 0000000000000000 ... CR2: 0000000000000012 CR3: 0000000103d50004 CR4: 0000000000770ef0 ... Call Trace: <IRQ> ? rawlocaldeliver+0xae/0x240 ipprotocoldeliverrcu+0x2d/0x180 iplocaldeliverfinish+0x84/0x100 ipsublistrcvfinish+0x5f/0x70 ipsublistrcv+0x12a/0x1d0 iplistrcv+0xfd/0x130 netifreceiveskblistcore+0x223/0x250 netifreceiveskblistinternal+0x1d2/0x2c0 ? tryfillrecv+0x39/0x7b0 napicompletedone+0x74/0x170 virtnetpoll+0x445/0x600 napipoll+0x27/0x1e0 netrxaction+0x2fe/0x3b0 handlesoftirqs+0xc2/0x2c0 irqexitrcu+0x74/0xd0 commoninterrupt+0x7f/0x90 </IRQ> ... Kernel panic - not syncing: Fatal exception in interrupt
After taking a reference, check whether the nulls node is unhashed in both IPv4 and IPv6 established lookups. If it is unhashed or the tuple no longer matches, drop the reference and restart the lookup.
Lookups racing with the TIMEWAIT hashdance, or with a request being replaced by its child, now restart and find the new socket instead of returning the old one.
Request sockets that were never inserted into ehash can have a nonzero refcount, and a stale lookup can hold a transient reference. Therefore, when SYN cookie, Fast Open, and request migration paths fail after setting a nonzero refcount, release the references held by those paths with reqskput() instead of freeing the request directly.
In the Linux kernel, the following vulnerability has been resolved:
inet: reject unhashed sockets during established lookups
TCP established ehash lookups are lockless. The socket caches involved use SLABTYPESAFEBYRCU, so memory can be reused before an RCU reader that retained its old address has finished.
After a tuple match, inetlookupestablished() and inet6lookupestablished() acquire a reference and repeat the tuple check. They do not check whether the new object is hashed. If the address is reused for a socket with the same tuple, the lookup can acquire a reference to the new object and return it while its nulls node is unhashed.
A PoC that drives reuse with a SYN cookie request socket reproduced the crash. The new request socket is unhashed and has a NULL rsklistener. A lookup that had loaded the address of the old request socket acquired the reference published by tcpgetcookiesock() and returned the new object. tcpv4rcv() then read skstate through the NULL listener.
The resulting crash was:
BUG: kernel NULL pointer dereference, address: 0000000000000012 #PF: supervisor read access in kernel mode #PF: errorcode(0x0000) - not-present page ... Oops: Oops: 0000 [#1] SMP NOPTI CPU: 4 UID: 0 PID: 0 Comm: swapper/4 Not tainted 7.3.0-00591-g0e135910deec #1 PREEMPT(lazy) ... RIP: 0010:tcpv4rcv+0x44e/0x1280 ... R10: 0000000000000001 R11: 00000000024ca8c0 R12: 0000000000000000 ... CR2: 0000000000000012 CR3: 0000000103d50004 CR4: 0000000000770ef0 ... Call Trace: <IRQ> ? rawlocaldeliver+0xae/0x240 ipprotocoldeliverrcu+0x2d/0x180 iplocaldeliverfinish+0x84/0x100 ipsublistrcvfinish+0x5f/0x70 ipsublistrcv+0x12a/0x1d0 iplistrcv+0xfd/0x130 netifreceiveskblistcore+0x223/0x250 netifreceiveskblistinternal+0x1d2/0x2c0 ? tryfillrecv+0x39/0x7b0 napicompletedone+0x74/0x170 virtnetpoll+0x445/0x600 napipoll+0x27/0x1e0 netrxaction+0x2fe/0x3b0 handlesoftirqs+0xc2/0x2c0 irqexitrcu+0x74/0xd0 commoninterrupt+0x7f/0x90 </IRQ> ... Kernel panic - not syncing: Fatal exception in interrupt
After taking a reference, check whether the nulls node is unhashed in both IPv4 and IPv6 established lookups. If it is unhashed or the tuple no longer matches, drop the reference and restart the lookup.
Lookups racing with the TIMEWAIT hashdance, or with a request being replaced by its child, now restart and find the new socket instead of returning the old one.
Request sockets that were never inserted into ehash can have a nonzero refcount, and a stale lookup can hold a transient reference. Therefore, when SYN cookie, Fast Open, and request migration paths fail after setting a nonzero refcount, release the references held by those paths with reqskput() instead of freeing the request directly.
In the Linux kernel, the following vulnerability has been resolved:
xen-netback: Fix XenBus connection failure cleanup
xenvifgetstats and xenvifgetethtoolstats capture vif->numqueues under rcureadlock. We need to unpublish vif->numqueues before synchronizenet to ensure that readers that come afterwards will not read a non-zero vif->numqueues and attempt to access invalid queues.
This is the same cleanup algorithm as used in backenddisconnect and added in commit b17075d5c198 ("xen-netback: fix race condition on XenBus disconnect").
This is XSA-531
In the Linux kernel, the following vulnerability has been resolved:
net: skbuff: propagate shared-frag marker in skbzerocopy()
skbzerocopy() moves frag descriptors from @from into @to and takes a reference on each frag, but it does not copy skbshinfo(from)->flags into skbshinfo(to)->flags. A destination skb holding the same page-cache backed frags as the source therefore reports skbhassharedfrag() as false.
That breaks the invariant relied on by later in-place writers. ESP input checks skbhassharedfrag() before deciding whether an uncloned nonlinear skb can skip skbcowdata(); with the marker lost, an skb that skbzerocopy() built for nfnetlinkqueue or for an openvswitch upcall is decrypted in place, letting an unprivileged user write into the page cache of a root-owned read-only file.
Propagate SKBFLSHAREDFRAG when frag descriptors are copied, as done for the other frag-transfer helpers.
In the Linux kernel, the following vulnerability has been resolved:
iouring/waitid: prevent cancel reference wrap
iowaitid packs the cancellation state into bit 31 of ->refs and uses bits 30:0 as a 31-bit reference counter:
#define IOWAITIDCANCELFLAG BIT(31) #define IOWAITIDREFMASK GENMASK(30, 0)
iowaitidcancel() marks a request canceled, then increments the low bits of ->refs to claim completion ownership. When another path owns the request, the increment remains even though cancellation returns false. The request remains discoverable by cancellation, so repeated failed attempts can wrap the 31-bit reference field to zero. A later cancellation can claim ownership and complete the request a second time.
Use atomicfetchor() when setting the cancel flag and inspect the old flag value. The first cancel attempt continues to the existing ownership increment, preserving its wake and issuer handoff semantics. Later attempts see the cancel flag and return without incrementing the reference field.
This makes repeated failed cancellation attempts idempotent while leaving the first-cancel state transitions unchanged.
In the Linux kernel, the following vulnerability has been resolved:
scsi: libiscsi: Validate the ITT reflected in a Reject PDU
A Reject PDU carries a copy of the header it rejects, and iscsihandlereject() takes the ITT out of that copy to find the task to clean up:
memcpy(&rejectedpdu, data, sizeof(struct iscsihdr)); ... task = iscsiitttotask(conn, rejectedpdu.itt);
That value is whatever the target put there. iscsiitttotask() bounds the index against cmdsmax and checks nothing else, so any task in the pool can be named, and iscsinopoutrsp() then completes it.
An index that has never been used gives a NULL task->conn: the pool is zeroed at session setup and conn is assigned only when a task is allocated. If the task was used and returned, iscsicompletetask() hits its WARNONONCE(task->state == ISCSITASKFREE) and the refcount underflows. An in-flight SCSI command is completed as successful - a 1 MiB read returned 1048576 with none of its buffer written and no warning.
Validate the reflected ITT the way iscsiitttoctask() validates a command ITT, and require the task to be in flight and not a SCSI command.
[ 6.248477] Oops: general protection fault, probably for non-canonical address 0xdffffc000000000c: 0000 [#1] SMP KASAN NOPTI [ 6.249357] KASAN: null-ptr-deref in range [0x0000000000000060-0x0000000000000067] [ 6.249951] CPU: 1 UID: 0 PID: 0 Comm: swapper/1 Not tainted 7.2.0-rc5-ISCSI1-gf5098b6bae76 #1 PREEMPT(lazy) [ 6.250718] Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, archcaps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 [ 6.251616] RIP: 0010:iscsinopoutrsp.constprop.0+0x46/0x160 [ 6.252043] Code: c1 ea 03 48 83 ec 08 80 3c 02 00 0f 85 f5 00 00 00 48 b8 00 00 00 00 00 fc ff df 48 8b 6b 58 48 8d 7d 60 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 c0 00 00 00 48 8b 45 60 48 39 c3 74 50 48 b8 00 [ 6.252813] RSP: 0018:ffff88806c907b80 EFLAGS: 00010206 [ 6.253042] RAX: dffffc0000000000 RBX: ffff88800607e000 RCX: ffffffff8d571a25 [ 6.253345] RDX: 000000000000000c RSI: ffff88806c907c38 RDI: 0000000000000060 [ 6.253642] RBP: 0000000000000000 R08: 0000000000000000 R09: fffffbfff235a504 [ 6.253947] R10: 0000000000000003 R11: 7463656e6e6f6320 R12: 0000000000000000 [ 6.254251] R13: 0000000000000000 R14: ffff88806c907c38 R15: 0000000000000000 [ 6.254549] FS: 0000000000000000(0000) GS:ffff8880d95bc000(0000) knlGS:0000000000000000 [ 6.254887] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 6.255140] CR2: 00007fc393e8ffc0 CR3: 0000000005252006 CR4: 0000000000770ef0 [ 6.255439] PKRU: 55555554 [ 6.255564] Call Trace: [ 6.255674] <IRQ> [ 6.255768] iscsicompletepdu+0x18bf/0x22a0 [ 6.256733] iscsicompletepdu+0x54/0xa0 [ 6.256905] iscsitcpdatarecvdone+0xf4/0x250 [ 6.257103] iscsitcprecvskb+0x31e/0xec0 [ 6.257680] iscsiswtcprecv+0x12f/0x390 [ 6.258061] tcpreadsock+0x1ab/0x810 [ 6.258853] iscsiswtcpdataready+0x18b/0x510 [ 6.259808] tcpdataqueue+0x1f13/0x4cd0 [ 6.260567] tcprcvestablished+0x8a5/0x3a00 [ 6.261931] tcpv4dorcv+0x449/0x960 [ 6.262269] tcpv4rcv+0x2245/0x3bc0
In the Linux kernel, the following vulnerability has been resolved:
scsi: libiscsi: Validate the task named by a management response
iscsicompletepdu() fetches the task for five response types from one place and checks only that the index resolved:
case ISCSIOPLOGOUTRSP: case ISCSIOPLOGINRSP: case ISCSIOPTEXTRSP: case ISCSIOPSCSITMFUNCRSP: case ISCSIOPNOOPIN: task = iscsiitttotask(conn, hdr->itt); if (!task) return ISCSIERRBADITT;
iscsiitttotask() bounds the index against cmdsmax and looks at nothing else, so a target can name any slot in the pool, including one that has never been used. task->conn is then NULL, and both iscsinopoutrsp() and iscsicompletetask() dereference it. One unsolicited NOP-In is enough; a Text Response carrying the same ITT crashes in iscsicompletetask() instead.
Require the task to be in flight and not a SCSI command, the way iscsiitttoctask() does for the command opcodes.
[ 6.298634] Oops: general protection fault, probably for non-canonical address 0xdffffc000000000c: 0000 [#1] SMP KASAN NOPTI [ 6.298642] KASAN: null-ptr-deref in range [0x0000000000000060-0x0000000000000067] [ 6.298652] CPU: 1 UID: 0 PID: 111 Comm: iscsistart Not tainted 7.2.0-rc5-ISCSI1-gf5098b6bae76 #1 PREEMPT(lazy) [ 6.298654] Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, archcaps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 [ 6.298656] RIP: 0010:iscsinopoutrsp.constprop.0+0x46/0x160 [ 6.298691] Code: c1 ea 03 48 83 ec 08 80 3c 02 00 0f 85 f5 00 00 00 48 b8 00 00 00 00 00 fc ff df 48 8b 6b 58 48 8d 7d 60 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 c0 00 00 00 48 8b 45 60 48 39 c3 74 50 48 b8 00 [ 6.298698] RSP: 0018:ffff88806c907be8 EFLAGS: 00010206 [ 6.298701] RAX: dffffc0000000000 RBX: ffff888006116800 RCX: 0000000000000020 [ 6.298702] RDX: 000000000000000c RSI: ffff88800525d578 RDI: 0000000000000060 [ 6.298703] RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 [ 6.298706] R10: 0000000000000020 R11: 0000000000000000 R12: 0000000000000000 [ 6.298706] R13: 000000000000002e R14: ffff8880056eb440 R15: ffff888006116800 [ 6.298707] FS: 00007fc02d1c2740(0000) GS:ffff8880b29bc000(0000) knlGS:0000000000000000 [ 6.298710] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 6.298711] CR2: 000055fe3b56ddf8 CR3: 00000000053b9004 CR4: 0000000000770ef0 [ 6.298712] PKRU: 55555554 [ 6.298713] Call Trace: [ 6.298714] <IRQ> [ 6.298714] iscsicompletepdu+0x13a8/0x22a0 [ 6.298758] iscsicompletepdu+0x54/0xa0 [ 6.298759] iscsitcphdrrecvdone+0x870/0x2c80 [ 6.298778] iscsitcprecvskb+0x31e/0xec0 [ 6.298800] iscsiswtcprecv+0x12f/0x390 [ 6.298804] tcpreadsock+0x1ab/0x810 [ 6.298812] iscsiswtcpdataready+0x18b/0x510 [ 6.298814] tcprcvestablished+0x1f56/0x3a00 [ 6.298842] tcpv4dorcv+0x449/0x960 [ 6.298847] tcpv4rcv+0x2245/0x3bc0
In the Linux kernel, the following vulnerability has been resolved:
net: psp: do not inherit the Rx association on clone
sk->pspassoc sits past skdontcopyend, so sockcopy() copies it into every socket accepted from a listener without taking a reference, while inetsockdestruct() puts for every inet socket. psptwskinit() does refcountinc() for the timewait socket, so a child closing through TIMEWAIT cancels its own put and leaves the association with one reference and N timewait sockets holding the same pointer. Closing the listener frees it, and the timewait timers then put freed memory.
Rejecting the association on a listening socket is not sufficient: a socket can acquire one while established and then be turned back into a listener, because tcpdisconnect() leaves sk->pspassoc in place.
BUG: KASAN: slab-use-after-free in psptwskassocfree+0x6f/0xf0 Write of size 4 at addr ffff888110f9255c by task swapper/7/0 psptwskassocfree+0x6f/0xf0 inettwskput+0xda/0x1b0 calltimerfn+0x53/0x2e0 runtimers+0x764/0xa80 Freed by task 99: kfree+0x1a7/0x500 processonework+0x7ec/0x1100
An association carries a per-connection SPI and key, so a child must not inherit the parent's. Clear it on clone.
In the Linux kernel, the following vulnerability has been resolved:
smb: client: reject SetEA requests that do not fit the request buffer
CIFSSMBSetEA() copies the caller's extended attribute value into the SMB request buffer without checking that it fits. The requirement is stated in the source but was never implemented:
/BB add length check to see if it would fit in negotiated SMB buffer size BB / / if (eavaluelen > buffersize - 512 (enough for header)) / if (eavaluelen) memcpy(parmdata->list.name + namelen + 1, eavalue, eavaluelen);
The only bound applied on the way in is in cifsxattrset():
#define MAXEAVALUESIZE CIFSMaxBufSize ... if (size > MAXEAVALUESIZE)
CIFSMaxBufSize is the full payload capacity of the buffer, so a value of exactly that size leaves no room for the SMB header, the TRANS2 parameter block, the fealist header and the EA name that are written ahead of it in the same object.
SendReceive() already enforces the correct limit on this very length:
if (inlen > CIFSMaxBufSize + MAXCIFSHDRSIZE)
but it is called after the copy has taken place. An unprivileged setxattr(2) on an SMB1 mount with a 250-byte name and a 16384-byte value writes 16384 bytes starting 345 bytes into a 16588-byte cifsrequest object, ending 141 bytes past it:
BUG: KASAN: slab-out-of-bounds in CIFSSMBSetEA+0xabc/0xde0 Write of size 16384 at addr ffff888003aa0159 by task init/68 asanmemcpy+0x3c/0x60 CIFSSMBSetEA+0xabc/0xde0 cifsxattrset+0xd3a/0xff0 vfssetxattr+0x13e/0x1a0 The buggy address is located 345 bytes inside of allocated 16588-byte region
Apply SendReceive()'s limit to the assembled request before the copy rather than after it, and widen the byte counters so the sum cannot wrap before it is tested.
bytecount is also tested against U16MAX, because it is stored in the 16-bit pSMB->ByteCount. That becomes reachable when CIFSMaxBufSize is raised at module load, where it may be set as high as 1024127: with a 5-byte EA name and a 65521-byte value, count is exactly U16MAX while bytecount is 65556, and cputole16() would truncate it to 20 and transmit a frame whose ByteCount does not match its length. Testing bytecount covers count as well, since bytecount is the larger of the two and count's only 16-bit consumer is written after this point.
checkaddoverflow() is evaluated first so that totallen is assigned before it is reported.
In the Linux kernel, the following vulnerability has been resolved:
ntfs: fix incorrect MFT record pointer passed to ntfsattrrecordresize
ntfsnewattrflags() passes the wrong MFT record to ntfsattrrecordresize(). When the attribute is in an extent record, ctx->mrec points to the extent but the function receives the base record pointer m, causing incorrect size calculations in memmove.
Fix by passing ctx->mrec (the actual MFT record containing the attribute) instead of m (the base MFT record) to ntfsattrrecordresize().
In the Linux kernel, the following vulnerability has been resolved:
smb: client: fix heap overflow in cifsdosetacl()
cifssetacl() validates ACL size using posixaclxattrsize():
4 + (count 8) // 4-byte header + 8 bytes per ACE
cifsdosetacl() then calls posixacltocifs() to write the CIFS wire format into the same buffer:
6 + (count 10) // 6-byte header + 10 bytes per ACE
An ACL that passes the xattr-based check in cifssetacl() can overflow the heap when posixacltocifs() writes the larger CIFS format.
Validate the CIFS format size against the remaining buffer space and USHRTMAX before converting--datacount is u16, so sizes above USHRTMAX truncate the on-wire packet length, causing the server to apply a partial ACL. Replace MaxDataCount = 1000 with min(CIFSMaxBufSize, USHRTMAX).