| Age | Commit message (Collapse) | Author |
|
git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull input fixes from Dmitry Torokhov:
- A fix in input core to tear down force-feedback devices synchronously
on unregistration, preventing use-after-free and faults in unloaded
modules if userspace holds an event node open across driver unbind
- A fix for the da7280 haptic driver to stop advertising FF_GAIN
capability without implementing gain control, preventing a NULL
pointer dereference when userspace writes a gain event
- A fix for the goodix touchscreen driver hardening backup reference
length validation against malformed device configurations to prevent
invalid memory writes during probe and suspend
- A fix for the max77693-haptic driver to disable the chip bias if
enabling the motor regulator fails when opening the device
- A fix for the cyapa touchpad driver to release its runtime PM
reference on interrupted lock acquisition so autosuspend keeps
working
- A fix for the Atari mouse driver and m68k IKBD glue to treat mouse
movement deltas as signed bytes, restoring proper cursor movement
with unsigned-char kernel builds
- An update to the trackpoint driver adding a new JYT_NDT variant ID
found on Lenovo ThinkPad X14 Gen 1 laptops so the device is not
misdetected as a generic PS/2 mouse
- Updates to the xpad driver adding support for Hori Real Arcade Pro 4,
Hori Taiko Controller DX, Hyperkin Xenon, 8BitDo M30, and GameSir G7
Pro controllers
* tag 'input-for-v7.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
Input: destroy force-feedback device on input unregistration
Input: max77693-haptic - disable bias on failed open
Input: trackpoint - add new TP JYT_NDT device variant id 7
m68k: Fix atari mouse movement
Input: xpad.c - add support for Hyperkin Xenon, Hori Taiko Controller DX, and 8BitDo M30
Input: xpad - add support to Hori Real Arcade Pro 4
Input: da7280 - do not advertise FF_GAIN
Input: cyapa - fix runtime PM leak in cyapa_update_rt_suspend_scanrate()
Input: goodix - reject a bak_ref length that cannot hold the checksum
Input: xpad - add GameSir G7 Pro support
|
|
Pull bpf fixes from Alexei Starovoitov:
"Mostly sockmap fixes as promised, plus uprobe ctx rewrite via bpf and
cgroup-bpf fixes.
- Reject writable map iterators on read-only maps (Adethya
Srinivasan)
- Various sockmap fixes (Alexei Starovoitov):
- Clear the redirect target before the sk_msg prog runs
- Check that the redirected message is the cork
- Leave sk_stream_wait_memory() once the socket is dead
- Keep the rest of the cork after a redirect
- Don't let an SK_PASS verdict cover the next message
- Subtract all dropped bytes from the return value of sendmsg()
- Clear the end mark of elements added by bpf_msg_push_data() and
bpf_msg_pop_data()
- Fix ring capacity invariant break in bpf_msg_push_data() (Bo Cao)
- Report RCU-tasks quiescent states in do_check() to fix rcu_tasks
stalls during a long verification (Breno Leitao)
- Various sockmap fixes (Chris Mason):
- Give no progs to a TCP listener
- Check the target of an egress redirect before each send
- Check the TCP state in recvmsg()
- Reset the copy position when corking
- Don't copy 0 bytes into a full cork
- Use a dedicated workqueue for freeing BPF programs to fix a
deadlock between pack_mutex waiters and the vmalloc purge work
(Emil Tsalapatis)
- Fix verifier model mismatch on a narrow read of
__sk_buff.remote_port (Henry Martin)
- Fix bpf-gcc CO-RE relocation in verifier_sockmap_mutate selftest
(Jiayuan Chen)
- Restrict uprobe ctx writes to the registers that ptrace can set
(Jiri Olsa)
- Various sockmap fixes (Josef Bacik):
- Write sg.start when recvmsg() faults
- Don't let an SK_DROP verdict stick
- Clear the resume state of a stopped psock
- Various fixes (Michal Luczaj):
- Fix "unresolved symbol tcp_request_sock" build error with
CONFIG_INET=n
- Restrict iter-context sockmap updates to iter/sockmap
- Restrict bpf_sock_destroy() to iter/{tcp,udp}
- Mark bpf_iter__sockmap::sk as PTR_TRUSTED
- Mark backing_file_alloc/free LSM hooks as untrusted (Sergei
Nizovtsev)
- Various cgroup-bpf fixes (Shakeel Butt):
- Don't read freed effective arrays in BPF_PROG_QUERY
- Don't attach to a removed cgroup
- Protect cgroup_bpf state with its own mutex, so that queries
and the release work don't wait for cgroup_mutex
- Don't lose errors in effective BPF_LSM_CGROUP queries
- Check variable-offset accesses against special fields (Shihuang
Liu)"
* tag 'bpf-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf: (38 commits)
selftests/bpf: Test which ctx registers a uprobe prog can write
bpf: Restrict uprobe ctx writes to the registers ptrace can set
selftests/bpf: Fix bpf-gcc CO-RE relocation in verifier_sockmap_mutate
bpf, cgroup: Don't lose errors in effective BPF_LSM_CGROUP queries
bpf, cgroup: Protect cgroup_bpf state with its own mutex
bpf, cgroup: Don't attach to a removed cgroup
bpf, cgroup: Don't read freed effective arrays in BPF_PROG_QUERY
bpf: Fix verifier model mismatch on __sk_buff.remote_port narrow read
bpf: Fix "unresolved symbol tcp_request_sock" build error
selftests/bpf: Add iter/sockmap bpf_sock_destroy() negative test
bpf: Mark bpf_iter__sockmap::sk as PTR_TRUSTED
bpf: Restrict bpf_sock_destroy() to iter/{tcp,udp}
bpf, docs: Document BPF_ITER_NOSLEEP
selftests/bpf: Add negative test for sockmap update from non-sockmap iter
bpf, sockmap: Restrict iter-context sockmap updates to iter/sockmap
selftests/bpf: Remove sockmap update from bpf_iter_unix
bpf, lsm: Mark backing_file_alloc/free LSM hooks as untrusted
bpf: Report RCU-tasks quiescent states in do_check()
bpf: Check variable-offset accesses against special fields
bpf: Use dedicated workqueue for freeing BPF programs
...
|
|
git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux
Pull block fixes from Jens Axboe:
- NVMe fixes via Keith:
- nvme-tcp fixes for TLS record handling and waiting for an
in-flight TLS handshake callback
- Fix a deadlock on nvme_subsystems_lock in nvme_init_subsystem()
- Fix a gendisk leak in nvme_alloc_ns()
- Stop AEN work before ANA teardown
- Remove namespaces in parallel
- Various nvmet fixes for auth, the file backend, fc, tcp, loop,
and connection failure rollback
- sysfs input validation and kfree_sensitive() for DH-HMAC-CHAP
secrets
- Dead code removal
- Fix a 32-bit overflow in the blk-iocost donation weight calculation
- ublk fixes: validate all parameters for zoned devices, and dispatch
the next fetch after a batch failure
- Fix a pm_only underflow when a runtime resume is retried after a
failed one
- nbd: reclassify sockets in the reconnect path too, to avoid lockdep
false positives
- Take quiesce_lock when removing a queue from the tag set, fixing a
use-after-free in blk_mq_unquiesce_tagset()
- Allow error injection rules to delay bios, and reject unknown status
tags
* tag 'block-7.4-20261119' of git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux: (49 commits)
Documentation: block: document error injection delay feature
block: allow error injection rules to delay bios
block: Reject unknown status tags in error injection rules
blk-mq: take quiesce_lock when removing a queue from the tag set
nbd: Reclassify sockets in the reconnect path
block: Keep RPM_ACTIVE in blk_pre_runtime_resume() when already active
nvme-fabrics: use kfree_sensitive() for the old DH-HMAC-CHAP secret
nvme-sysfs: use kfree_sensitive() for DH-HMAC-CHAP secrets
nvmet: roll back queue bindings on connection failure
nvmet-fc: reject duplicate queue IDs on Create Connection
nvmet-fcloop: free the LS request when delivery fails
nvme-tcp: require the R2T offset to match the data sent
nvmet-tcp: only wait for in-capsule data for inline SGLs
nvme-loop: release the target request when SG setup fails
nvmet-auth: store the DH-CHAP key offset instead of hardcoding it
nvme-tcp: consume TLS records without application data
nvme-tcp: move the TLS record read loop into a helper
nvme-tcp: use an aligned buffer for the TLS record type
nvmet: use overflow-safe range checks in the file backend
nvmet: handle short reads and writes in the file backend
...
|
|
Since commit 7384893d970e ("bpf: Allow uprobe program to change context
registers") a uprobe program can write any field of struct pt_regs.
Some of those fields are not plain user registers. The exit to user
space loads them into the CPU:
arch field exit path ptrace
------ ------ ------------------------------- ------------------
riscv status csrw CSR_STATUS, a0 not in the regset
arm64 pstate msr spsr_el1, x22 valid_user_regs()
x86-64 cs, ss (cs & 3) == 0: iretq to ring 0 set_segment_reg()
x86-64 flags iretq loads IF and IOPL set_flags()
On riscv a program that sets sstatus.SPP in pt_regs.status makes
ret_from_exception return to user code in supervisor mode. On x86-64 a
program that writes a kernel selector to cs makes iretq return to
ring 0.
ptrace guards these fields, but the bpf verifier does not.
Add arch_uprobe_regs_writable(). Each arch lists the registers that
ptrace can set to any value, and kprobe_prog_is_valid_access() rejects
writes to any other offset when the program is loaded:
arm64: x0 to x30, sp, pc
riscv: epc, ra to t6
x86-64: r15 to di, ip, sp
The default is no writes, so arches without a list (and 32-bit x86)
lose ctx writes for uprobe programs. Reads are not affected.
flags on x86-64 and pstate on arm64 become read-only, including the
condition bits that ptrace would let a debugger change. orig_ax is
read-only too.
Kprobe programs that write ctx were already rejected when they were
attached. Those that write one of these fields now fail to load.
Fixes: 7384893d970e ("bpf: Allow uprobe program to change context registers")
Reported-by: rtm@csail.mit.edu
Suggested-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261118084451.12590-2-jolsa@kernel.org
Closes: https://lore.kernel.org/bpf/30318.1794850523@30-11-166.wireless.csail.mit.edu/
|
|
When an input device is unregistered while userspace holds an open file
descriptor to its event node, input_dev_release() is deferred until the
last file descriptor is closed. Because input_ff_destroy() was only
called from input_dev_release(), force-feedback teardown (ff->destroy
and freeing ff->private) could run after the parent driver had already
unbound, freed its device state, or even been unloaded via rmmod,
causing use-after-free errors or page faults in unmapped module text.
Commit ef166ce08801 ("Input: stop force-feedback timer when
unregistering input devices") added a separate ff->stop callback for
ff-memless, but left ff->destroy invoked from input_dev_release().
Once __input_unregister_device() has disconnected all input handlers
(which flushes effects, closes the device, and marks evdev dead) and
deleted the device from sysfs, nothing accesses dev->ff anymore. Call
input_ff_destroy() directly in __input_unregister_device() so that
ff->destroy() always runs synchronously while the driver and its module
are still active, and remove the now-redundant ff->stop callback. Keep
input_ff_destroy() in input_dev_release() (where it is a no-op once
dev->ff is NULL) to handle input_free_device() on devices that were
never registered.
Fixes: 509ca1a93836 ("Input: implement new force feedback interface")
Reported-by: Gideon Heinz <gideonheinz02@gmail.com>
Closes: https://lore.kernel.org/r/CAPb1+K2BxnfQ7VUQ15td5f9pVhn-ARSM9EjfOU8WuW72o+cvPg@mail.gmail.com
Tested-by: Gideon Heinz <gideonheinz02@gmail.com>
Link: https://patch.msgid.link/2f722967b6db0692d4dd4164aff39b62@gmail.com
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
|
|
git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Pull networking fixes from Paolo Abeni:
"Including fixes from netfilter and Bluetooth.
Current release - regressions:
- ipvs: honor the overload state and do not enter it forever
Previous releases - regressions:
- core:
- prevent receive header offset overflow during decapsulation
- avoid truncated transport header offsets
- tcp:
- fix NULL pointer dereference when restarting a fast open listener
- fix the SO_REUSEPORT bind cache admitting a conflicting socket
- sctp: do not free a new asoc peeled off while sendmsg slept
- bridge: fix skb leak of reinjected link-local frames
- bluetooth:
- L2CAP: clear the SDU before the receive callback
- vhci: serialize packet reception with device creation
- ipvs:
- avoid stack overflow from recursive connection expiration
- fix problems during connection deletion
- eth:
- virtio_net: check RX buffer length before DMA sync
- gve: fix RX page refcount overflow from INT_MAX pagecnt_bias
Previous releases - always broken:
- core: make room for the tunnel header in skb_segment_list()
- eth:
- i40e: fix freeing of TX rings on RX allocation failure
- stmmac: fix VXLAN over IPv6 with zero UDP checksum"
* tag 'net-7.4-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (117 commits)
net: prevent receive header offset overflow during decapsulation
tcp: bound the rto_min of a route in tcp_rto_min()
tcp: clamp the samples in tcp_rcv_rtt_update()
tcp: reject RTT samples from TSecr above 120 s
tcp: clamp RTT samples in tcp_rtt_estimator()
tcp: don't let __tcp_set_rto() return 0
net: make room for the tunnel header in skb_segment_list()
udp: use skb_set_transport_header_careful() in __udp6_lib_err_encap()
sctp: use skb_set_transport_header_careful() in sctp_v6_err()
net: openvswitch: use skb_set_transport_header_careful() in parse_ipv6hdr()
ipv6: mcast: use skb_set_transport_header_careful() in ipv6_mc_check_exthdrs()
ipv6: gro: limit the number of extension headers
net: stmmac: dwmac1000: stop hardware from dropping checksum-error packets
net: stmmac: dwmac1000: don't discard frames with only a checksum error
net: stmmac: honour Rx checksum errors in the AF_XDP zero-copy path
veth: wake the peer txq when deleting NAPI
veth: wake a stopped peer txq beyond real_num_tx_queues
iavf: add missing PTP adjustment callbacks
iavf: fix ASQ command buffer leak on init failure
iavf: fix QoS capabilities memory leak
...
|
|
Repeated decapsulation can leave skb->data far from skb->head while
the remaining packet data is still valid. Since the skb header positions
are 16-bit offsets, a later header update can truncate and make header
access use unrelated bytes and eventually crash.
Limit receive headroom to 32 KiB. This is well beyond the headroom of
normal packets while allowing the networking stack to pull enough
headers in a single pass without overflowing 16-bit header offsets.
Tunnel decapsulation re-enters __netif_receive_skb_core(), so its check
protects nested IPIP and GRE. FOU and GUE bypass receive core, so check
their IPv4 and IPv6 resubmission paths too. Together, these checks
prevent 16-bit header-offset truncation in cases of repeated
decapsulation.
Report these rejections with the SKB_RX_HEADROOM drop reason.
Fixes: 1a37e412a022 ("net: Use 16bits for *_headers fields of struct skbuff")
Cc: stable@kernel.org
Suggested-by: Eric Dumazet <edumazet@kernel.org>
Signed-off-by: Chris J Arges <carges@cloudflare.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20261118-prevent_rx_header_offset_overflow-v1-1-92a5be55f994@cloudflare.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull MM fixes from Andrew Morton:
- "maple_tree fixes for 7.3" (Liam R. Howlett):
Fix an RCU reader NULL dereference when the tree is emptied during a
walk, including /proc/PID/maps racing with munmap(). Add tests and
make debug WARN and BUG checks report failures properly
- "mm/kasan: Detect double-free involving kfree_rcu_sheaf()" (Kuniyuki
Iwashima):
Detect double-free when an object enters an RCU sheaf. KASAN could
previously miss it until the object was reused, leading to a later
free of a live object. Add KUnit tests for the different free orders
- "mm: Fix page-table teardown during memory hot-remove" (Muchun Song):
Balance page-table constructors and destructors when hot-remove frees
tables on x86-64, RISC-V and arm64. This fixes NR_PAGETABLE
accounting for tables with and without constructors
- "mm/damon: fix watermark state, kunit pid leak and selftest fake
pass" (SJ Park):
Recompute watermark wait state when DAMON schemes are removed, so
kdamond resumes monitoring. Fix a pid reference leak in KUnit and a
selftest that reports a skipped run as a pass
- An XArray iterator could step backwards when a large page-cache entry
was split, sending filemap_map_pages() outside the PTE page it
locked. The XArray correction and a filemap bound check prevent
out-of-bounds accesses and use-after-free. Another XArray fix
prevents lockless walkers from following a parent pointer into a
freed node
- Userfaultfd now validates the whole write-protection range before
changing any VMA, avoiding partial unprotect without waking blocked
faults. Failed unmaps now abort queued UFFD_EVENT_UNMAPs; previously
they could report a nonexistent unmap, leak the userfaultfd context
and leave later operations returning -EAGAIN. A fork fix clears stale
uffd PTE bits if the new context is released before its event is
read
- Moving the hugetlbfs inode trace event before RCU freeing avoids a
use-after-free of its superblock. Shmem swapin no longer retries
forever on reused swap slots containing a mismatched large swap-cache
folio. Swapoff also avoids a cluster-list loop that can soft-lock
reclaim and leave swapoff hung
- Weighted interleave recalculation now uses one node set throughout,
avoiding a divide-by-zero during memory hotplug. Hwpoison holds the
folio lock when inspecting its mapping and no longer leaks a folio
reference; it also updates poison statistics before notifying
rasdaemon through a trace event
- Cross-node migration now moves NR_FILE_THPS and NR_KERNEL_FILE_PAGES
with page-cache folios, preventing per-node and memcg-node accounting
from retaining stale counts or underflowing after the folios are
freed
* tag 'mm-hotfixes-stable-2026-11-17-19-55' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (27 commits)
xarray: fix index jumping backwards in xas_find()
userfaultfd: validate the whole range before changing write protection
maple_tree: update internal warning and bug_on code
maple_tree: test emptying tree while RCU reading
maple_tree: fix rcu reader NULL dereference after the tree is emptied
mm/vma: read anon_vma carefully in validate_mm()
hugetlbfs: move hugetlbfs_free_inode tracepoint to ->destroy_inode()
selftests/damon/sysfs_memcg_path_leak: define ksft_skip
mm/damon/tests/sysfs-kunit: fix leaked pid reference in add_targets test
mm/damon/core: reset watermark wait state on each iteration
mm/filemap: stop fault-around when the walk steps back
mm: memory-failure: update statistics before emitting the trace event
mm/vma: undo userfaultfd unmap preparation when unmapping fails
userfaultfd: clear uffd state in child PTEs if uffd is released during fork
mm/memory-failure: fix folio refcount leak and min_order_for_split() locking
mm/shmem: fix swapin livelock on a mismatched large swap cache folio
mm/mempolicy: use one node set for interleave weights
xarray: clear the new head's parent before freeing the old head
arm64/mm: fix destructor for unconstructed hotplug page tables
riscv/mm: fix missing destructor for hotplug PUD tables
...
|
|
Error injection can only fail a bio today. Add a delay_us option so that
a rule can hold a bio back first, to model a slow device.
If a matching rule has delay_us set, the bio is held for that long. It is
then failed if the rule also has a status, or resubmitted otherwise.
The resubmission is done through submit_bio_noacct_nocheck(), which is
where the injection hook sits. To avoid the same delay rule being applied
to it again, mark the bio with the BIO_ERROR_INJECTED flag as soon as a
rule matches. This also prevents bios that are split later and resubmitted
from being evaluated for delay (or error injection) again. __bio_clone()
does not propagate the flag, so a clone a stacking driver aims at a lower
device is still evaluated.
The bio is submitted from a workqueue rather than from the timer, because
submitting a bio can sleep. A REQ_NOWAIT bio is failed with BLK_STS_AGAIN
instead of being delayed. Values above 600 seconds are rejected.
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Md Haris Iqbal <haris.iqbal@linux.dev>
Link: https://patch.msgid.link/20261111215838.103356-3-haris.iqbal@linux.dev
Signed-off-by: Jens Axboe <axboe@kernel.dk>
|
|
Unquiescing a tag set can run the hw queues of a queue whose hctxs were
already freed. blk_mq_unquiesce_tagset() walks the tag set's queues
under quiesce_lock and rcu_read_lock(). Commit 71ec3c7d6db8 ("blk-mq:
quiesce a queue that joins a quiesced tag set") added quiesce_lock to
the walks and to adding a queue, but blk_mq_del_queue_tag_set() still
removes a queue without it. The hctxs are then freed right away since
RCU only keeps the request_queue itself alive:
Task A (controller reset) Task B (namespace removal)
blk_mq_unquiesce_tagset()
/* finds q */
blk_mq_del_queue_tag_set(q)
blk_mq_release(q)
/* frees the hctxs */
blk_mq_run_hw_queues(q)
/* reads freed hctxs */
The window is short. On PREEMPT_RT quiesce_lock is a sleeping lock and
the walk can be preempted inside it, which is how it's hit here:
[ 399.851277] BUG: KASAN: slab-use-after-free in blk_mq_run_hw_queues+0x4bd/0x550
[ 399.851328] Read of size 8 at addr ff11000003014148 by task kworker/u9:2/116
[ 399.851352] CPU: 1 UID: 0 PID: 116 Comm: kworker/u9:2 Not tainted 7.3.0-16299-g81cb9aa43246 #1 PREEMPT_RT
[ 399.851425] Workqueue: nvme-reset-wq nvme_loop_reset_ctrl_work
[ 399.851441] Call Trace:
[ 399.851457] <TASK>
[ 399.851551] blk_mq_run_hw_queues+0x4bd/0x550
[ 399.851564] blk_mq_unquiesce_tagset+0x128/0x210
[ 399.851576] nvme_loop_reset_ctrl_work+0x78/0x4c0
[ 399.851600] process_one_work+0x92b/0x16d0
[ 399.851660] worker_thread+0x4e6/0xd60
[ 399.851707] kthread+0x300/0x3e0
[ 399.851727] ret_from_fork+0x4f0/0x6f0
[ 399.851776] ret_from_fork_asm+0x1a/0x30
[ 399.851793] </TASK>
...
[ 399.851988] Freed by task 111:
[ 399.852040] kfree+0x1b3/0x4b0
[ 399.852050] blk_mq_release+0x400/0x550
[ 399.852060] blk_put_queue+0x94/0x120
[ 399.852068] disk_release+0x1bd/0x3f0
[ 399.852102] nvme_free_ns+0x39/0x270
[ 399.852113] nvme_remove_nsid_range+0x2d1/0x4a0
[ 399.852123] nvme_scan_ns_list+0x2cc/0x390
[ 399.852134] nvme_scan_work+0x421/0x9f0
...
With BLK_CGROUP the disk's root blkg holds the queue until a grace
period later, which hides this for NVMe namespaces. It's still open
without BLK_CGROUP, and from reading the code also for queues freed
without a disk (e.g., SCSI device queues on a UFS host).
Take quiesce_lock around the list_del_rcu() as well so that the walk
either finishes with a queue before it leaves the list or never sees
it, and say so in the comment of quiesce_lock. With the fix, KASAN
doesn't report the use-after-free anymore.
This bug was identified and confirmed with the help of a deterministic
hypervisor currently under development. The C reproducer below however
hits it about once every 20 minutes on a PREEMPT_RT kernel.
Fixes: 59e25ef2b413 ("block: Use RCU in blk_mq_[un]quiesce_tagset() instead of set->tag_list_lock")
Cc: stable@vger.kernel.org
Reviewed-by: Mohamed Khalfella <mkhalfella@purestorage.com>
Signed-off-by: Mani Tofigh <mt4022@columbia.edu>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Nilay Shroff <nilay@linux.ibm.com>
Link: https://patch.msgid.link/20261106-blk-mq-del-quiesce-lock-v2-1-cd4f72a6eb03@columbia.edu
Signed-off-by: Jens Axboe <axboe@kernel.dk>
|
|
The ___wait_event() helper for historical reasons took a "0/1" argument
for whether the wait-queue entry should be marked WQ_FLAG_EXCLUSIVE or
not. That didn't really help readability, but it also limited the
wq_flags for that helper to only that one flag.
Just make that macro argument be the actual 'wq_flags' value, which
simplifies the helper, and makes it more generic. It also happens to
make the users of this macro more obvious when an unexplained '1'
argument becomes a more self-explanatory 'WQ_FLAG_EXCLUSIVE'.
Also change the existing users that use that raw ___wait_event()
interface with just a plain schedule() to use the pre-existing helpers
macros: __wait_event_state() and __wait_event_state_exclusive().
[ This is not a bug-fix: it was prep-work for a bug report that turned
out to be just a "don't do that" situation instead. But I also didn't
want to just throw it away or leave it pending, since it just made
some of that grotty code much clearer - Linus]
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Link: https://lore.kernel.org/all/20261111-pipe-epollexclusive-wakeup-v1-1-0af6283e9fda@columbia.edu/
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
|
|
git://git.kernel.org/pub/scm/linux/kernel/git/mm/core
Pull core memory management fixes from David Hildenbrand:
"The main changes are:
- Prevent folio refcount overflows with pagecache folios, mostly
relevant for large folios today. The networking changes for this
will go through the net tree.
- Fix out-of-bounds page table accesses with folded PMDs in 3
scenarios.
- Fix write-sealing of memfd to detect GUP pins with concurrent
(un)mapping more reliably, preventing writes through GUP pins after
write-sealing.
- Fix lost wakeups when splitting large folios.
- Fix exposing uninitialized data through MADV_COLLAPSE to user
space.
The refcount changes also include a related iommufd fix for properly
cleaning up when pinning memfd folios fails, which is now easier to
trigger"
* tag 'mm-core-7.4-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/mm/core:
mm/gup: limit pagecache folio refcount when grabbing references
iommufd: fix cleanup when adding memfd folio pins fails
mm/mmu_gather: flush pending references early before the folio limit
mm: limit pagecache folio refcount when splicing into pipes
mm: limit pagecache folio refcount when mapping pages
mm/huge_memory: prevent losing PG_waiters in __split_folio_to_order()
mm/rmap: fix PTE table overruns during batched reference checks
mm/rmap: fix PTE table overruns during batched unmap
mm/userfaultfd: fix PTE table overruns in UFFDIO_MOVE
mm/memfd: handle GUP pins more reliably when write-sealing
mm/khugepaged: don't map folios that are not uptodate in MADV_COLLAPSE
|
|
active_port is a bitmask with a bit per LAG port. The cited commit
enabled 8 port LAG, but active_port remained 4 bits wide.
Enlarge active_port to 8 bits, as defined in the PRM.
Fixes: e0e6adfe8c20 ("net/mlx5: Enable 8 ports LAG")
Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Reviewed-by: Akiva Goldberger <agoldberger@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20261112182940.3655773-1-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|
Clean up assoc_array library code
I had already gotten rid of this tag locally, because we then decided
to just remove the assoc_array library entirely since it has only one
single user - the key handling code - and that user is getting rewritten
to use rhashtable instead.
But that removal is scheduled for 7.5, and this fixes real bugs and does
clean up some of the code. So while it's all slated for removal, some
of the fixes need back-porting and we might as well remove the
cleaned-up version. Maybe somebody decides they want to resurrect it
for another project - it really is fairly generic library code - they
shouldn't get the messy end state that we decided to jettison.
Background: Nils Ollrogge reported a bug in the assoc_array library and
had a patch to fix it too, but that code was too obscure for me to
follow, so I used some LLM tools to help make sense of it all and found
more issues in the process.
* tag 'assoc-array-fixes-v2':
assoc_array: use assoc_array_parent_link() when splitting a shortcut
assoc_array: find and collapse in deletion without gotos
assoc_array: move deletion's collapse into a function of its own
assoc_array: replace the labels in gc's tree walk with a loop
assoc_array: move gc's folding into a function of its own
assoc_array: keep gc's cleanup out of the live tree on allocation failure
assoc_array: don't chain a new shortcut onto an existing one
assoc_array: choose between splitting a node and a shortcut without gotos
assoc_array: move shortcut creation into a function of its own
assoc_array: move node splitting into a function of its own
assoc_array: fill the segment cache in one place
assoc_array: move in-place insertion into a function of its own
assoc_array: don't lose objects when a root shortcut is split at level 4
assoc_array: don't lose objects when a shortcut is split on a word boundary
assoc_array: correct the documentation of get_key_chunk()'s level argument
|
|
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc/iio driver fixes from Greg KH:
"Here are a bunch of char, misc, and iio driver fixes for reported
problems for 7.4-rc4. Included in here are:
- usual collection of lots of IIO driver fixes for issues
- binder driver fix
- iio, w1, and comedi driver fixes found and fixed by Josef
- comedi driver fix for a reported problem
- other misc driver fixes
All of these have been in linux-next for a while with no reported
issues"
* tag 'char-misc-7.4-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (68 commits)
iio: hid-sensors: fix fractional part for unit exponents -7 and -8
iio: trigger: free the trigger ID after device_del()
iio: hid-sensors: fix a division by zero
iio: humidity: hid-sensor-humidity: Use per-instance callbacks
iio: temperature: hid-sensor-temperature: Use per-instance callbacks
comedi: comedi_bond: Fix leak of opened device references
mei: me: add ice lake point LP iTouch DID
mei: lb: read the MTU once
rust_binder: push BR_TRANSACTION_COMPLETE before BR_FAILED_REPLY
misc: ibmvmc: initialize HMC state before device registration
w1: w1_therm: leave the slaves of other families alone
w1: w1_therm: lock the list of slaves for the bulk read
w1: don't hold list_mutex while a slave is torn down
w1: netlink: drop the slave after the bus is unlocked
w1: ds2805: use the bus mutex to talk on the bus
w1: ds28e04: use the bus mutex to talk on the bus
w1: ds2482: set the strong pull-up with its byte
w1: remove the master's files before taking its locks
w1: use the bus mutex for the "rw" file
misc: bcm-vk: fix DMA allocation memory leak
...
|
|
Pull NFS client fixes from Anna Schumaker:
- Various NFS and SunRPC fixes from Avi Weiss
- Various localio fixes from Mike Snitzer
- Delegated timestamp fixes from Jeff Layton
- CB_NOTIFY_LOCK fixes from Olga Kornievskaia
- Various sunrpc, flexfiles, and xprtrdma fixes from Tim Menninger
* tag 'nfs-for-7.4-2' of git://git.linux-nfs.org/projects/anna/linux-nfs: (26 commits)
NFSv4: Prevent indefinite waits for out-of-order OPEN stateids
NFSv4/flexfiles: limit transport disconnects when cancelling I/O
SUNRPC: add request-scoped disconnects when cancelling tasks
pNFS: avoid repeatedly cancelling I/O for the same lseg
xprtrdma: serialize unmap_sync with xprt_disconnect
NFSv4: remember that the server may send CB_NOTIFY_LOCK
NFSv4: wake blocking lock waiters when a delegated lock is released
NFS: stamp after the server's ctime following a CLONE
NFS: stamp after the server's ctime when truncating under delegated times
NFS: don't let delegated c/mtime stamps go backward
NFS/localio: give the LOCALIO probe a short timeout of its own
NFS/localio: probe again for LOCALIO when localio_enabled is set to Y
NFS/localio: hold the client across an asynchronous LOCALIO probe
SUNRPC: Balance queue accounting when relocating a task
SUNRPC: Balance switch queue length on transport removal
SUNRPC: Fix TCP-with-TLS transport class identification
SUNRPC: preserve transport security policy when cloning clients
SUNRPC: preserve timeout policy when cloning clients
SUNRPC: preserve fatal network errors during RPC binding
sunrpc: instantiate rpc_pipefs dentry before publishing it
...
|
|
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull core syscall fixes from Ingo Molnar:
- Two generic syscall entry code fixes for return code
data type definitions (Florian Bezdeka)
* tag 'core-urgent-2026-11-15' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
entry: Complete syscall_enter_from_user_mode_work() to bool migration
entry: Fix return type of syscall_trace_enter()
|
|
In the Meta fleet, tasks that only read or free cgroup bpf state often
wait minutes for cgroup_mutex:
- In one day, hung-task reports (blocked over 120 seconds) showed this
for BPF_PROG_QUERY on 1,075 hosts, the cgroup bpf release work on 458
hosts and link info on 94 hosts.
- The query callers are a container manager's health checks. Over 30
days, 6,700 hosts reported one hung. The typical wait is 11 minutes,
the longest 75 minutes.
- The cgroup_mutex holder is almost always a cgroup mkdir or rmdir that
is waiting for kernfs_rwsem.
Only attach, detach and replace need cgroup_mutex. They update the
effective arrays of all descendants, so the hierarchy must not change.
Add cgroup_bpf_mutex for the bpf state. Attach, detach and replace take
cgroup_mutex and then cgroup_bpf_mutex. Everything else (query, link
info, the release work, dropping an LSM attach type, freeing a cgroup
storage map) takes only cgroup_bpf_mutex.
cgroup_bpf_inherit() still runs at mkdir with only cgroup_mutex, so mkdir
never waits for cgroup_bpf_mutex. It writes the new cgroup, which no one
else can see yet. What it reads from the ancestors changes only under
cgroup_mutex, and the release work can't run for them because they are
online.
The release work no longer waits for cgroup_mutex, so attach must check
that the cgroup is still alive. The previous patch does that.
With a test delay that makes a mkdir hold cgroup_mutex for 5 seconds,
BPF_PROG_QUERY and link info now return in under a millisecond instead
of 4.6 seconds. Attach and detach still wait.
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261112172721.440275-4-shakeel.butt@linux.dev
|
|
Let's add __folio_ref_count_over_limit() checks in fast and slow GUP
before acquiring additional references or pins.
Keep it simple and use the check for all folio types.
Also propagate try_grab_folio() errors when grabbing additional
references in __get_user_pages() and in memfd_pin_folios(), so hitting
the limit returns -ENOMEM instead of -EFAULT and -EINVAL, respectively.
Keep the existing invalid-refcount warnings.
Fixes: 800d8c63b2e9 ("shmem: add huge pages support")
Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
Fixes: 793917d997df ("mm/readahead: Add large folio readahead")
Cc: stable@vger.kernel.org
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Link: https://patch.msgid.link/20261112-refcount_overflow_stable-v4-5-ad3deef0bd23@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
|
|
When a task zaps mappings (e.g., MADV_DONTNEED), it can drop the PT lock
and defer dropping the folio references. In the meantime, page faults
can refault pagecache folios, creating more references for the same
folios. These deferred references can build up over multiple VMAs.
Let's just request a flush after enqueueing folios whose refcount reached
a certain threshold. Start flushing well before new references are refused,
regardless of the caller's privileges.
When returning "true" from __tlb_remove_folio_pages_size(), PTE zapping
will flush the TLB before dropping the PT lock, but drop the references
afterwards. Refaults can still race with that, but flushing early reduces
the risk of letting others hit the limit.
This is a temporary measure until we have something better.
Reported-by: Chris Mason <mason@kernel.org>
Fixes: 800d8c63b2e9 ("shmem: add huge pages support")
Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
Fixes: 793917d997df ("mm/readahead: Add large folio readahead")
Cc: stable@vger.kernel.org
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Link: https://patch.msgid.link/20261112-refcount_overflow_stable-v4-3-ad3deef0bd23@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
|
|
Similar to mapping pagecache folios into page tables, let's reject
additional references when splicing folios into a pipe if the refcount
is at its limit.
This will prevent more cases of possible folio refcount overflows with
large pagecache folios.
Introduce folio_get_checked() for checked reference acquisition when
the caller already holds a reference. It warns and fails on a non-positive
refcount and rejects additional references at the limit.
Add __folio_ref_count_over_limit() so folio_get_checked() can reuse the
refcount instead of having to read it a second time.
Use folio_get_checked() in splice_folio_into_pipe() and
fuse_ref_folio(), returning -EFAULT on failure, like we already do for
pipe-buffer duplication. Similarly, make try_get_page() use it instead.
Likely try_get_page() should be renamed (or removed) later, as it doesn't
match the folio_try_get() semantics and is confusing.
If we hit the limit after splicing some data, return the number of bytes
already spliced. Teach the callers to handle errors, and stop
filemap_splice_read() if we only spliced part of a folio, so we don't
skip ahead to the next folio: note that we wouldn't run into this
scenario before as we always spliced the requested range.
The check in try_get_page() also covers pipe-buffer duplication by tee()
and partial pipe-to-pipe splicing.
Note that we deliberately will not fall back to the slow path of copying
the folio, particularly as the folio might have an invalid refcount. If
it is ever really required, we can revisit.
Fixes: 800d8c63b2e9 ("shmem: add huge pages support")
Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
Fixes: 793917d997df ("mm/readahead: Add large folio readahead")
Cc: stable@vger.kernel.org
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Link: https://patch.msgid.link/20261112-refcount_overflow_stable-v4-2-ad3deef0bd23@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
|
|
With large file folios, overflowing the folio mapcount and refcount
became possible more easily. For anon folios it is currently not really
an issue: each large anon folio can only be mapped once into a process; on
4k kernels it would be more processes than usually allowed on a system,
and on 16k or 64k kernels the processes alone would consume hundreds of
GiB. Something to be sorted out at some point, but it's not as urgent.
Being able to overflow the refcount is not really big news, but it's about
time that we do something about it because some modern technology might
find ways to abuse it :)
One of the enablers for that was commit ddc58f27f9ee ("mm: drop tail page
refcounting"), however, file thp support was added later.
File folios can be mapped multiple times into the same process, allowing
for processes to hold many references to the same folio.
As a short-term solution, let's introduce two folio refcount limits:
one for ordinary consumers and one for admins. Leave some headroom
before the refcount goes negative, which we really don't want (having
the mapcount go negative is also not expected).
Start reporting SIGBUS and a ratelimited warning if we run into limits.
When restoring mappings from migration entries, instead zap the pte/pmd
entry. We allow for slightly exceeding the limit to keep things simpler.
During fork(), prefer not copying page table entries over failing fork.
For fault-around, check in next_uptodate_folio() before trying to lock
the folio.
Export folio_ref_count_over_limit_slowpath() using EXPORT_SYMBOL_GPL
right away so modules can use it through try_get_page(), where we will
use it next.
Use has_capability_noaudit(current, CAP_SYS_RESOURCE),
so filesystem credential overrides do not affect access to the admin
reserve, and to not generate auditing messages simply because we access
optional reserves.
Don't grant access to the admin reserve from kernel threads, from
interrupt context, where "current" is just the interrupted task, or with
IRQs disabled, as even unaudited capability checks can take locks.
This is far from ideal, but better than all easy alternatives we can
backport comfortably. For now it fixes the big problem: letting
the refcount (+mapcount) go negative and cause trouble.
This is only a temporary fix. Keep the mapping checks explicit and
separate from reference acquisition: most are expected to disappear when
we rework the underlying refcounting.
Check order 0 folios as well for consistency: each
folio_add_file_rmap*() and folio_dup_file_rmap*() needs a prior check.
Adjust the check in folio_get() to just check for invalid refcounts and
drop folio_ref_zero_or_close_to_overflow(): we really don't want
negative refcounts or negative mapcounts. Convert to VM_WARN_ON_FOLIO as
we touch it.
Also, just document -EHWPOISON for copy_present_ptes() while at it.
Note: When zapping file migration entries, uffd-wp is preserved using PTE
markers, but uffd-rwp protection is lost because there is no corresponding
marker. try_to_unmap() already has the same problem when unmapping file
folios, so we'll happily ignore it.
Reported-by: Chris Mason <mason@kernel.org>
Fixes: 800d8c63b2e9 ("shmem: add huge pages support")
Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
Fixes: 793917d997df ("mm/readahead: Add large folio readahead")
Cc: stable@vger.kernel.org
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Acked-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Link: https://patch.msgid.link/20261112-refcount_overflow_stable-v4-1-ad3deef0bd23@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
|
|
With a folded PMD, pmd_addr_end() simply returns the supplied end.
move_present_ptes() can therefore walk past the source or destination
PTE table during UFFDIO_MOVE.
pmd_addr_end() is only intended for page table traversal, in patterns
like "next = pmd_addr_end(addr, end);". With folded PMDs, a higher level
has already clamped the range to the PTE table.
Folded PMDs are uncommon, but can occur even on arm64, for example
with 64K pages and a 42-bit virtual address space.
Extract the calculation from folio_pte_range() into
pte_table_clamped_end() and use it to clamp both ranges. This preserves
the wraparound handling from commit f681d4580d5c ("mm: fix address
wraparound when scanning large folio PTEs").
Fixes: 50944692052b ("userfaultfd: opportunistic TLB-flush batching for present pages in MOVE")
Cc: stable@vger.kernel.org
Reported-by: Chris Mason <mason@kernel.org>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Link: https://patch.msgid.link/20261111-pte_table_clamped_end-v1-1-2dbe339c487a@kernel.org
Reviewed-by: Lokesh Gidra <lokeshgidra@google.com>
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
|
|
BPF program freeing currently runs from the system workqueue. With BPF
program pack allocations, freeing the last program in a pack can take
pack_mutex and call into execmem/vmalloc code to change page permissions.
That path may queue a vmalloc purge helper to the same CPU and wait for it
to finish.
If enough other BPF program free workers are already active on that CPU,
they can all block on pack_mutex and consume the system workqueue active
slots. The worker holding pack_mutex then waits for the vmalloc purge work,
but that purge work cannot run because the queue is full of pack_mutex
waiters:
[ 24.646667] INFO: task kworker/0:4:1291 blocked for more than 10 seconds.
[ 24.646669] Not tainted 7.3.0-00001-gdeaa120a9b25-dirty #11
[ 24.646670] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 24.646671] task:kworker/0:4 state:D stack:0 pid:1291 tgid:1291 ppid:2 task_flags:0x4208060 flags:0x00080000
[ 24.646675] Workqueue: events bpf_prog_free_deferred
[ 24.646678] Call Trace:
[ 24.646680] <TASK>
[ 24.646686] __schedule+0x5bc/0x1430
[ 24.646702] schedule+0x3f/0x100
[ 24.646706] schedule_timeout+0x106/0x110
[ 24.646711] ? srso_alias_return_thunk+0x5/0xfbef5
[ 24.646713] ? mark_held_locks+0x49/0x80
[ 24.646720] ? srso_alias_return_thunk+0x5/0xfbef5
[ 24.646723] ? lockdep_hardirqs_on_prepare+0xdc/0x190
[ 24.646726] ? srso_alias_return_thunk+0x5/0xfbef5
[ 24.646732] __wait_for_common+0xc1/0x1d0
[ 24.646735] ? __pfx_schedule_timeout+0x10/0x10
[ 24.646748] ? __flush_work+0x1f8/0x550
[ 24.646751] __flush_work+0x309/0x550
[ 24.646759] ? __pfx_wq_barrier_func+0x10/0x10
[ 24.646783] __purge_vmap_area_lazy+0x3e4/0x440
[ 24.646796] _vm_unmap_aliases+0x2d5/0x330
[ 24.646810] change_page_attr_set_clr+0xb9/0x580
[ 24.646817] ? srso_alias_return_thunk+0x5/0xfbef5
[ 24.646833] set_memory_nx+0x3b/0x50
[ 24.646838] __execmem_cache_free+0x35/0xb0
[ 24.646848] execmem_free+0x98/0x160
[ 24.646864] bpf_prog_pack_free+0x152/0x190
[ 24.646871] bpf_jit_binary_pack_free+0x17/0x90
[ 24.646876] bpf_jit_free+0x5e/0x130
[ 24.646882] process_one_work+0x289/0x790
[ 24.646886] ? srso_alias_return_thunk+0x5/0xfbef5
[ 24.646888] ? srso_alias_return_thunk+0x5/0xfbef5
[ 24.646902] worker_thread+0x1b3/0x370
[ 24.646908] ? __pfx_worker_thread+0x10/0x10
[ 24.646911] kthread+0xf7/0x130
[ 24.646914] ? __pfx_kthread+0x10/0x10
[ 24.646920] ret_from_fork+0x293/0x300
[ 24.646923] ? __pfx_kthread+0x10/0x10
[ 24.646927] ret_from_fork_asm+0x1a/0x30
[ 24.646947] </TASK>
Move deferred freeing of BPF programs, program images, and trampoline
images to a dedicated workqueue to avoid this deadlock.
Fixes: 72210662c5a2 ("mm: vmalloc: offload free_vmap_area_lock lock")
Reported-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Emil Tsalapatis <emil@etsalapatis.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261109181610.7027-1-emil@etsalapatis.com
|
|
git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Pull networking fixes from Jakub Kicinski:
"Including fixes from netfilter, wireless and bluetooth.
Previous releases - regressions:
- tcp: rate limit receive queue collapsing
- raw: fix ICMP unreachable sent when receive queue is full
- eth: bnxt_en: take RTNL before netif_close() when aborting FW reset
Previous releases - always broken:
- tcp:
- bound snd_cwnd_clamp to TCP_MAX_SND_CWND
- number of fixes for TCP Fast Open
- gro:
- invalidate frag0 after a pull
- avoid parsing headers from shared fragments
- cipso: stop modifying live ip_options_rcu
- udp: do not use a cross-family sk_rx_dst in early demux
- fou: gue: check IP version of held packets for direct IP
encapsulation
- skbuff: preserve fclone lifetime when freeing stolen heads
- eth:
- mlx5e:
- fix crashes on queue stats access to queues without stats
- SHAMPO, disable end padding when relaxed ordering is
- ena: keep the RX buffer mapped if skb allocation fails"
* tag 'net-7.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (227 commits)
selftests: net: add a test for NSH GSO
nsh: limit recursion in nsh_gso_segment()
selftests: tls: Cover the cap on consecutive empty records
selftests: tls: Extend coverage for zero-length records
selftests: tls: Skip the zero_len tests when TLS is unavailable
tls: Consume empty data records in tls_sw_splice_read()
tls: Break the connection after a burst of empty data records
net: phy: c45: select BASE-T1 type for the forced speed
net/mlx5e: Fix false WARN_ON_ONCE in flow steering cleanup on RX init failure
net/mlx5e: IPsec, don't match upper proto selectors in crypto offload TX
tcp: fix request_sock use-after-free during Fast Open accept()
net: usb: cdc_ncm: don't underflow the NDP room check
net: netns: fix INT_MAX nsid cleanup
amt: use ipv6_hdr() in amt_mldv1_leave_handler()
af_unix: Inherit SO_INQ in unix_stream_connect()
tcp: Pass req->rsk_listener to inet_csk_reqsk_queue_drop() in tcp_check_req().
mailmap: add entries for Hangbin Liu
net: virtio: validate outer protocol of UDP tunnel GSO packets
tun: clear stale skb->protocol of NAPI frags skbs
net: virtio: fix UDP tunnel GSO header of VLAN tagged packets
...
|
|
virtio_net_hdr_tnl_to_skb() trusts the virtio header to describe a
UDP tunnel over IPv4 or IPv6, but never checks that the frame actually
carries such outer headers. Because VIRTIO_NET_HDR_F_NEEDS_CSUM is
mandatory for tunnel GSO, __virtio_net_hdr_to_skb() skips the flow
dissector, so virtio_net_hdr_match_proto() is never applied either.
A guest (or a tap writer) can then inject a frame with an arbitrary
outer ethertype, for example ETH_P_NSH, with SKB_GSO_UDP_TUNNEL set.
The GSO stack then runs nsh_gso_segment() on top of the UDP tunnel
segmentation, which assumes a different header layout. The result is
segments with skb->data before skb->head, and a host crash in
skb_under_panic() as soon as a later layer pushes a header:
skbuff: skb_under_panic: ... put:4 ... dev:gretap1
kernel BUG at net/core/skbuff.c:215!
skb_push
__gre_xmit
gre_tap_xmit
...
tun_get_user
Validate the outer headers with the parsing helpers from Michael's
series "net: resolve uncommon partial checksums at ingress":
- locate the L3 header: Ethernet with optional VLAN tags, or the
network header set by the caller. skb->protocol is not trusted when
it disagrees with the frame.
- require the outer L3 protocol to match the declared tunnel type.
- require the outer UDP header exactly at outer_th_offset, after IPv4
options or IPv6 extension headers, and reject fragments.
Unlike the original helpers:
- the callers tell whether the frame starts with an Ethernet header,
with a new has_eth argument of virtio_net_hdr_tnl_to_skb(), instead
of using the device type. tun frames packets from its IFF_TAP and
IFF_TUN flags, and TUNSETLINK can set the device type to any value.
virtio_net and tun_xdp_one() always pass true, tun_get_user() passes
whether the device is IFF_TAP.
- ipv6_find_hdr() stops at an AH header, as Willem suggested in the
review of that series.
Fixes: a2fb4bc4e2a6 ("net: implement virtio helpers to handle UDP GSO tunneling.")
Reported-by: Hassan Sultan <hassansultan@google.com>
Suggested-by: Willem de Bruijn <willemb@google.com>
Link: https://lore.kernel.org/netdev/93d0e37c99711bebdf60c120af03010455c2f2e2.1793276116.git.mst@redhat.com/
Co-developed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Link: https://patch.msgid.link/20261110213628.3476051-4-edumazet@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|
virtio_net_hdr_tnl_from_skb() builds a wrong header for VLAN tagged UDP
tunnel GSO packets.
1) When the skb carries a hwaccel VLAN tag, tun_put_user() inserts the
802.1Q header in the frame it copies to user space or vhost-net, and
passes vlan_hlen = VLAN_HLEN. virtio_net_hdr_from_skb() adds
vlan_hlen to csum_start, but inner_nh_offset and outer_th_offset do
not account for it, and are 4 bytes short of the real inner L3 and
outer UDP headers in the emitted frame.
tun advertises NETIF_F_HW_VLAN_CTAG_TX and NETIF_F_HW_VLAN_STAG_TX
in hw_enc_features, and its vlan_features keep the UDP tunnel GSO
features, so this happens for example with a VLAN filtering bridge
with a tagged port, or with a vlan device on top of a tap.
2) The outer family comes from skb->protocol, which is ETH_P_8021Q or
ETH_P_8021AD when the VLAN tag is in the packet data, so a packet
with an outer IPv6 header is reported as
VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV4. This happens when
__vlan_hwaccel_push_inside() inserted the tag because the device does
not offload it: virtio_net never offloads VLAN insertion but keeps
UDP tunnel GSO in its vlan_features, and tun does the same with VLAN
TX offload disabled, or with QinQ (outer tag offloaded, inner tag in
the data).
The receiver sets inner_network_header and transport_header from these
offsets, and checks them with the wrong outer family. A forwarded
packet that gets segmented again uses the wrong inner headers, and a
receiver checking the outer headers against the virtio header drops
the packet.
Add vlan_hlen to both offsets like csum_start, and take the outer
family from vlan_get_protocol(), which skips VLAN tags in the data.
Fixes: a2fb4bc4e2a6 ("net: implement virtio helpers to handle UDP GSO tunneling.")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/netdev/179421814766.994134.3669228181251158303@kernel.org/
Closes: https://lore.kernel.org/netdev/179433950084.994134.15100186606737698605@kernel.org/
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Link: https://patch.msgid.link/20261110213628.3476051-2-edumazet@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|
git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull power management fixes from Rafael Wysocki:
"These address a few issues in the cpufreq core and drivers, including
issues actually seen in the field, a few issues related to runtime PM,
including a false-positive warning introduced relatively recently and
a long-standing defect in the runtime PM core code related to
autosuspend, and revert a problematic recent update of the intel_rapl
power capping driver.
Specifics:
- Revert a recent update of the intel_rapl power capping driver that
caused perf to return bogus values (Dennis Chen)
- Fix the synchronization of boost state updates in cpufreq
(Christian Loehle)
- Fix issues related to system suspend-resume synchronization in the
cpufreq core and intel_pstate driver (Rafael Wysocki)
- Fix P-state index mismatch in extract_io() in the ACPI cpufreq
driver on systems with defective _PSS (Li RongQing)
- Fix issues related to target frequency caching in cpufreq (Rafael
Wysocki)
- Prevent a false-positive warning in pm_runtime_remove() introduced
by a previous fix during the 7.0 development cycle (Zhou Minqiang)
- Extend a recent improvement related to the handling of suppliers
during device runtime-suspend to some previously missed cases in
which it is relevant for consistency (Brian Norris)
- Update runtime PM documentation to reflect new behavior after
recent changes (Stanley Jhu)
- Add last_busy timestamp updates for devices requested to resume
from runtime suspend that are missing if those devices are not
actually suspended (Rafael Wysocki)"
* tag 'pm-7.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
Revert "powercap: intel_rapl: Expose all package CPUs in PMU cpumask"
PM: runtime: Update last_busy in rpm_resume() for active devices
cpufreq: Fix updates of cached resolved frequency and index
cpufreq: Cache post-resolution target frequency in __resolve_freq()
cpufreq: acpi-cpufreq: fix P-state index mismatch in extract_io()
cpufreq: Serialize global boost updates
cpufreq: Preserve global boost state on failed updates
PM: runtime: Update runtime_pm.rst for non-fatal resume errors
PM: runtime: Only queue an idle check for RPM-linked suppliers (part 2)
PM: runtime: Fix check_flush_dependency warning from pm_runtime_remove
cpufreq: intel_pstate: Use rdmsrq_safe() to read MSR_MISC_PWR_MGMT
cpufreq: intel_pstate: Clear last written P-state value on suspend
cpufreq: Force passing target frequency to driver during resume
cpufreq: Improve suspend-resume synchronization
cpufreq: Hold the policy write lock when changing boost state
|
|
Merge cpufreq fixes and fixes related to runtime PM for 7.4-rc3:
- Fix the synchronization of boost state updates in cpufreq (Christian
Loehle)
- Fix issues related to system suspend-resume synchronization in the
cpufreq core and intel_pstate driver (Rafael Wysocki)
- Fix P-state index mismatch in extract_io() in the ACPI cpufreq driver
on systems with defective _PSS (Li RongQing)
- Fix issues related to target frequency caching in cpufreq (Rafael
Wysocki)
- Prevent a false-positive warning in pm_runtime_remove() introduced
by a previous fix during the 7.0 development cycle (Zhou Minqiang)
- Extend a recent improvement related to the handling of suppliers
during device runtime-suspend to some previously missed cases in
which it is relevant for consistency (Brian Norris)
- Update runtime PM documentation to reflect new behavior after recent
changes (Stanley Jhu)
- Add last_busy timestamp updates for devices requested to resume from
runtime suspend that are missing if those devices are not actually
suspended (Rafael Wysocki)
* pm-cpufreq:
cpufreq: Fix updates of cached resolved frequency and index
cpufreq: Cache post-resolution target frequency in __resolve_freq()
cpufreq: acpi-cpufreq: fix P-state index mismatch in extract_io()
cpufreq: Serialize global boost updates
cpufreq: Preserve global boost state on failed updates
cpufreq: intel_pstate: Use rdmsrq_safe() to read MSR_MISC_PWR_MGMT
cpufreq: intel_pstate: Clear last written P-state value on suspend
cpufreq: Force passing target frequency to driver during resume
cpufreq: Improve suspend-resume synchronization
cpufreq: Hold the policy write lock when changing boost state
* pm-runtime:
PM: runtime: Update last_busy in rpm_resume() for active devices
PM: runtime: Update runtime_pm.rst for non-fatal resume errors
PM: runtime: Only queue an idle check for RPM-linked suppliers (part 2)
PM: runtime: Fix check_flush_dependency warning from pm_runtime_remove
|
|
git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull more vfs fixes from Christian Brauner:
- inode: Let the shrinker reclaim inodes with I_METADATA_WRITEBACK like
any other clean inode and have evict() write out what the bit tracks
unless the inode is being deleted.
Since v7.3 ext2, ext4 without a journal, fat, udf and minix set
I_METADATA_WRITEBACK when they copy an inode into its buffer and only
fsync() and friends clear it again. inode_lru_isolate() took such
inodes off the LRU expecting something to put them back once the bit
was gone but nothing ever did. So they couldn't be reclaimed until
something fsynced them or the filesystem was unmounted.
On ext4 without a journal an atime update was enough to pin an inode,
and creating 60000 small files in a memory cgroup limited to 96M got
the task OOM killed after about 43000 of them. Now all 60000 get
created.
- dcache:
- Give d_set_mounted() a seqlock of its own that d_invalidate()
waits on after unhashing the dentry.
Since v6.17 d_set_mounted() doesn't bump the seqcount of
rename_lock anymore, so a mount racing d_invalidate() could end
up below the unhashed directory. Nobody can reach it there and it
pins the subtree until the mount namespace goes away. With a FUSE
directory 3000 levels deep 151 of 200 bind mounts racing
FUSE_NOTIFY_INVAL_ENTRY ended up there.
- Only take busy secondary roots off ->s_roots in do_one_tree() so
that umount waits for a racing eviction of an idle one. Since
v7.3 it didn't, which ended in busy inodes after unmount and an
iput() on a dead superblock.
- Make a disconnected dentry a secondary root when the mount on it
goes away so that umount finds it and waits for its eviction.
With CAP_DAC_READ_SEARCH such a dentry can be mounted on via
open_by_handle_at() and move_mount() and umount racing its
eviction ended the same way.
- splice:
- Remove pipe buffer stealing as you and David suggested.
fuse and virtio_console were the only users of ->try_steal() and
now always copy, as they already did when a steal failed.
Stealing took page cache folios out of their files and turned
pages into page cache folios and back. SPLICE_F_GIFT and
SPLICE_F_MOVE are still accepted and fuse still advertises
FUSE_SPLICE_MOVE so servers that ask for it mount as before.
- Clamp a ->write_iter() result that is larger than the iterator in
iter_file_splice_write() instead of only warning about it.
Otherwise the pipe releases buffers past its head.
- ns:
-Allocate the namespace id before calling the namespace_init LSM
hook that was added this merge window. Landlock now logs the
allocated id instead of zero when it denies the creation of a
namespace.
-Don't mark the arguments of the namespace_init and namespace_free
hooks as trusted for bpf LSM programs. Both see namespaces that
are only partially set up or on their way out.
- proc: Don't let proc_sys_call_handler() report more bytes written
than it was passed when a cgroup/sysctl bpf program replaced the
value with a longer one. A splice() into the sysctl file then walked
past the pipe head.
- coda: Pass the append state of each write on to the container file
with RWF_APPEND or RWF_NOAPPEND. coda_open() sets O_APPEND on the
container file after its iocb flags were cached, so an O_APPEND write
overwrote existing data instead of appending.
- adfs: Reject big directory entries in adfs_fplus_getnext() whose name
doesn't fit into the name buffer. A crafted image overflowed it on
the stack.
* tag 'vfs-7.4-rc3.fixes.2' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: (28 commits)
nstree: drop ns_tree_add_raw()
ns: allocate the namespace id before the namespace_init hook
bpf: don't mark namespace_init and namespace_free arguments as trusted
splice: replace nosteal_pipe_buf_ops with default_pipe_buf_ops
splice: remove pipe buffer stealing
fuse: don't move pipe buffers into the page cache
virtio_console: copy pipe buffers in splice_write()
fs/adfs: bound directory entry name length in adfs_fplus_getnext()
dcache: let umount find a disconnected ex-mountpoint
dcache: wait for a racing eviction of a secondary root
dcache: let d_invalidate() wait for a d_set_mounted() in flight
fat: drop mmb_sync() from fat_evict_inode()
udf: drop mmb_sync() from udf_evict_inode()
minix: drop mmb_sync() from minix_evict_inode()
ext4: drop mmb_sync() from ext4_evict_inode()
ext2: drop mmb_sync() from ext2_evict_inode()
fs: don't strand I_METADATA_WRITEBACK inodes outside the LRU
fs: set I_METADATA_WRITEBACK in mmb_mark_buffer_dirty()
udf: don't allocate the inode block in udf_sync_inode_metadata()
minix: don't read the inode block in minix_sync_inode_metadata()
...
|
|
https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless
Johannes Berg says:
====================
Various fixes all over, notably:
- mm81x: fix frequency reporting of 2 MHz or wider channels
- rtw88: fix stuck queue for AP on SDIO
- ath12k:
- fix split MSDU decap
- fix reconnect of MLO stations
- fix stuck TX due to lack of MCS 15 support
- mac80211: use-after-free on certain TTLM/update combinations
- nxpwifi: FW response/notification validation
- (and a subset of usual "LLM saw a bug" things)
* tag 'wireless-2026-11-11' of https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless: (40 commits)
wifi: mac80211: fix unlocked STA statistics fallback
wifi: cfg80211: don't truncate the merged MBSSID profile length
wifi: nl80211: fix ERR_PTR use on wdev disappearance
wifi: mac80211: fix use-after-free on TTLM disconnect
wireless: Remove me as ssb maintainer
wifi: mac80211: bound pending OCB station allocations
wifi: mac80211: recheck the OCB station limit before insertion
wifi: mac80211: bound pending IBSS station allocations
wifi: mac80211: recheck the IBSS station limit before insertion
wifi: mac80211: reject invalid EHT guard intervals in airtime estimates
wifi: cfg80211: preserve mesh A-MSDU lengths when adding mesh headers
wifi: mac80211: restore dormant links when link updates fail
wifi: mac80211: recheck injected headers after removing FCS
wifi: mac80211_hwsim: ignore non-generic netlink releases
wifi: cfg80211: release rejected nontransmitted BSS reference
wifi: mac80211: drain link readers before stopping removed links
wifi: mac80211: find STA for beacons belonging to non-TX BSS
wifi: mac80211: do not switch to invalid link
wifi: mac80211: fix use-after-free when MLO link setup is rolled back
wifi: mac80211: abort chanswitch when leaving an IBSS
...
====================
Link: https://patch.msgid.link/20261111133442.225455-8-johannes@sipsolutions.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|
Now that ns_tree_add() doesn't allocate an id anymore it does the same
thing as ns_tree_add_raw(). Switch the remaining ns_tree_add_raw() users
over to ns_tree_add() and drop it. Rename __ns_tree_add_raw() to
__ns_tree_add() while at it.
No functional changes.
Fixes: f675d2e95569 ("lsm: add LSM blob and hooks for namespaces")
Cc: stable@kernel.org # mainline only
Link: https://patch.msgid.link/20261029-work-security-namespace_free-v2-5-65591dbba7b3@kernel.org
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
|
|
Currently the namespace id is allocated only after __ns_common_init()
has called the namespace_init LSM hook. Most namespace types allocate it
in ns_tree_add() right before the namespace is added to the namespace
trees. So the namespace_init hook always sees an id of zero.
The namespace id is the only identifier of a namespace that is never
recycled. A bpf LSM wants to use it to track a namespace from
namespace_init until namespace_free, e.g., by using it as the key into a
map that associates data with the namespace. The inode number doesn't
work for that as it is quickly recycled.
So allocate the id in __ns_common_init() before calling the
namespace_init hook. Every namespace then has its id by the time it is
added to the namespace trees. The initial namespaces still get their
fixed ids, either statically from NS_COMMON_INIT() or for init_net from
ns_common_init(). So ns_tree_add() doesn't need to allocate an id
anymore. Ids are still handed out in creation order so mnt_ns_loop()
keeps working. Mount and ipc namespaces already allocated their id right
after ns_common_init() anyway.
If creating the namespace fails after the id has been allocated the id
is simply never used.
Landlock logs the namespace id when it denies the use of a namespace.
For a denied namespace creation that used to be zero. Now it's the id
that was allocated for the new namespace. That namespace never becomes
visible to userspace but it's the same id that other LSMs see in
namespace_init. Update the Landlock documentation and selftests
accordingly. The selftests can't know the id of a namespace whose
creation was denied so they only check that it isn't zero.
While at it, drop ns_tree_gen_id() as it has no users left.
Reproducer, 100 user and uts namespaces:
bpftrace -e 'fentry:bpf_lsm_namespace_init {
@[args.ns->ns_id ? "set" : "zero"] = count(); }' &
for i in $(seq 100); do unshare -Uu true; done
before: @[zero]: 200
after: @[set]: 200
Fixes: f675d2e95569 ("lsm: add LSM blob and hooks for namespaces")
Cc: stable@kernel.org # mainline only
Link: https://patch.msgid.link/20261029-work-security-namespace_free-v2-4-65591dbba7b3@kernel.org
Reviewed-by: Mickaël Salaün <mic@digikod.net> # Landlock changes
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
|
|
Without ->try_steal(), nosteal_pipe_buf_ops and default_pipe_buf_ops are
the same: generic_pipe_buf_release() and generic_pipe_buf_get().
Keep default_pipe_buf_ops, and use it in skb_splice_bits() and
fuse_dev_splice_read(). Export it in place of nosteal_pipe_buf_ops,
since fuse can be built as a module.
Signed-off-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Link: https://patch.msgid.link/20261110145241.536019-5-kas@kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
|
|
Nothing calls pipe_buf_try_steal() any more. Remove ->try_steal() from
struct pipe_buf_operations, its implementations and the exported
generic_pipe_buf_try_steal().
PIPE_BUF_FLAG_LRU and PIPE_BUF_FLAG_GIFT were set only for stealing, and
go too. page_cache_pipe_buf_release() did nothing but drop the page and
the LRU flag, so page cache and user page buffers use
generic_pipe_buf_release().
vmsplice() still accepts SPLICE_F_GIFT, and splice() SPLICE_F_MOVE.
Both were hints, and nothing acts on them now.
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Link: https://patch.msgid.link/20261110145241.536019-4-kas@kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
|
|
When a mount goes away the reference to its mountpoint is dropped with
dput_to_list() and namespace_unlock() evicts the dentry after dropping
namespace_sem. Nothing pins the filesystem at that point so it can be
unmounted at the same time. That's fine as long as
shrink_dcache_for_umount() finds the dentry. It then either evicts it
itself or waits for the eviction to finish.
But it can't find a disconnected root as those are neither in the tree
nor on ->s_roots. And they can be mounted on:
fd = open_by_handle_at(mnt_fd, handle of a file with no dentry, O_PATH);
tree = open_tree(AT_FDCWD, "/tmp/x", OPEN_TREE_CLONE);
move_mount(tree, "", fd, "", MOVE_MOUNT_F_EMPTY_PATH |
MOVE_MOUNT_T_EMPTY_PATH);
close(fd);
thread A thread B
umount2("/proc/self/fd/<tree>", MNT_DETACH)
namespace_unlock()
up_write(&namespace_sem)
umount of the filesystem
shrink_dcache_for_umount()
evict_inodes()
"Busy inodes after unmount"
shrink_dentry_list()
dentry_kill()
iput() of an inode of a superblock that is gone
So put such a dentry on ->s_roots when it's put on the shrink list. From
then on it's a secondary root like any other.
This needs the previous patch. Otherwise do_one_tree() takes the dentry
off ->s_roots and umount doesn't wait for an eviction in progress.
The stable tag is narrower than the Fixes tag on purpose. Before commit
e9895609cb7f ("wind ->s_roots via ->d_sib instead of ->d_hash") umount
doesn't wait for a secondary root that is being evicted either.
Fixes: 4edbe133f851 ("make struct mountpoint bear the dentry reference to mountpoint, not struct mount")
Cc: stable@vger.kernel.org # v7.2+
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Link: https://patch.msgid.link/20261030-work-dcache-ai-v1-3-cd6b86e0ccc7@kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
|
|
The counters enforcing TC and IPsec packet offload mutual exclusion are
not consistently serialized. IPsec admission conditionally takes
mode_lock for writing, while TC admission holds it only for read.
Neither release path takes the lock, and devices without an eswitch
cannot rely on it at all.
These are per-core-device counters, separate from the eswitch mode and
encapsulation reservations protected by mode_lock. Move them into
mdev->offload_block and protect their checks, increments and decrements
with a dedicated spinlock that is available even without an eswitch.
A spinlock is used because some of these functions are called from
atomic context and is a good fit because the critical sections are and
will stay really short.
IPsec admission then no longer needs mode_lock to update these counters.
Add warnings for unbalanced releases. Keep mlx5_esw_lock() for eswitch
operation admission and temporary mode/encapsulation reservations.
This was found by upstream Sashiko during review of [1], and spun-off
into a fix from the larger patch.
[1]
https://lore.kernel.org/netdev/178907726586.219967.4695695146458742597@kernel.org/
Fixes: c8e350e62fc5 ("net/mlx5e: Make TC and IPsec offloads mutually exclusive on a netdev")
Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
Reviewed-by: Jianbo Liu <jianbol@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20261105211637.1083978-9-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|
rpc_cancel_tasks() allows callers to cancel a selected set of RPC tasks,
but callers that also need to tear down the connection currently have to
disconnect at the rpc_clnt level.
That is broader than necessary for clients with multiple transports. A
cancelled request is associated with a specific rpc_xprt and records the
connection generation on which it was transmitted in rq_connect_cookie.
Add rpc_cancel_tasks_and_disconnect() to cancel matching tasks and mark
matching requests that remain on the transport transmit or receive queues
for conditional transport disconnect when the request is released.
Store the disconnect indication in struct rpc_rqst rather than struct
rpc_task. An RPC task can release one request and later acquire another,
so task-scoped state could otherwise be consumed by a successor request
and disconnect the wrong transport generation.
After cancelling matching tasks, walk the client's transports and mark
matching requests belonging to that client that remain on the transmit
or receive queues. An rpc_xprt may be shared by multiple rpc_clnt
instances, so requests belonging to other clients are not marked.
When a marked request is released, consume the marker under the existing
transport_lock critical section. If the request was transmitted, call
xprt_conditional_disconnect_locked() with its rq_connect_cookie. The
disconnect is skipped if that cookie no longer matches the transport's
current connection generation.
This adds no lock acquisition to the normal request-release path.
Requests that were never transmitted do not trigger this additional
disconnect.
Signed-off-by: Tim Menninger <tmenninger@everpuredata.com>
Signed-off-by: Anna Schumaker <anna.schumaker@hammerspace.com>
|
|
Two processes contending for a POSIX lock on one file see occasional
acquisitions of almost exactly 1, 3 or 7 seconds when the client holds a
delegation, although the holder releases within microseconds.
nfs4_retry_setlk() only parks a waiter on clp->cl_lock_waitq when
NFS_STATE_MAY_NOTIFY_LOCK is set. Otherwise it uses
nfs4_retry_setlk_simple(), which has no waitqueue at all and sleeps on a
bare timeout starting at NFS4_LOCK_MINTIMEOUT and doubling, so a waiter
that loses one poll waits a second, then two, then four.
NFS_STATE_MAY_NOTIFY_LOCK is set in _nfs4_open_and_get_state() from the
OPEN reply rflags. It describes the server, but is recorded per
nfs4_state and can only be learned from a reply. Once a delegation is
held, further opens are satisfied from it with no OPEN on the wire, so
o_res.rflags is zero and the new state starts out believing no callback
can arrive, even though the open that obtained the delegation was told
otherwise.
Record the capability on the nfs_client the first time an OPEN reply
carries it, and apply it to every state built for that client.
nfs_client is the right scope: the flag describes one server,
CB_NOTIFY_LOCK arrives on that client's backchannel, and cl_lock_waitq
is per nfs_client.
This also covers a case the per-state flag misses. After the delegation
is recalled the state has neither NFS_DELEGATED_STATE nor
NFS_STATE_MAY_NOTIFY_LOCK, so locks go to the server and the server does
send CB_NOTIFY_LOCK, but the client is in the backoff loop and ignores
it.
Fixes: a8ce377a5db8 ("nfs: track whether server sets MAY_NOTIFY_LOCK flag")
Assisted-by: Claude Opus 5
Signed-off-by: Olga Kornievskaia <okorniev@redhat.com>
Signed-off-by: Anna Schumaker <anna.schumaker@hammerspace.com>
|
|
git://git.kernel.org/pub/scm/linux/kernel/git/mm/page_alloc
Pull page allocator fixes from Vlastimil Babka:
- Stable fixes for various races of page allocator's reading of
zonelists and memory hotplug activity. These can result in BUGs,
allocation failures or allocations from wrong nodes (Gregory Price,
Josef Bacik)
- Stable fixes for bugs free_pages_nolock(), page_frag allocation, page
isolation, that can trigger WARNs, degraded operation or infinite
loop (Josef Bacik)
* tag 'page_alloc-for-7.4-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/mm/page_alloc:
mm/page_alloc: remove the zone_spans_pfn() check from get_pfnblock_bitmap_bitidx()
mm/memory_hotplug: resize zones under their seqlock
mm: page_isolation: do not take slab pages for free
mm: page_frag: refill the cache for large fragments
mm/page_alloc: clear ->private of deferred free pages
mm/page_alloc: don't undo another isolation in alloc_contig_range
mm/mmzone: remove zonelist_node_idx()
mm/mempolicy: read the zoneref slot once in mempolicy_slab_node()
mm/page_alloc: retry alloc_contig_pages() when the zonelist is rebuilt
mm/hugetlb: retry the pool walk when the zonelist is rebuilt
mm/page_alloc: retry allocations that raced with a zonelist rebuild
mm/mmzone: read each zoneref slot once when filtering by nodemask
mm/page_alloc: snapshot the preferred zone against shrink rebuilds
mm/mmzone: read the zoneref slot once in zonelist_zone()
mm/page_alloc: detect zonelist rebuilds from memory hot-add
mm, page_alloc: pass zone pointer to trace_reclaim_retry_zone
mm/page_alloc: keep the pagesets of an empty zone
mm/page_alloc: reset can_retry_reserves when the slowpath restarts
|
|
git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull vfs fixes from Christian Brauner:
- libfs: Make readdir on tmpfs walk the offset tree in offset order
instead of d_children to avoid skipping entries or relisting the
whole directory
It's faster too. Listing a million entries takes 114ms instead of
146ms, and 113ms instead of 470ms with four processes listing in
parallel
- iomap: Finish the ->iomap_next() conversion that started in v7.3
The nilfs2 and fuse ext_map iomap code added this merge window is
converted so now we can remove the ->iomap_begin()/->iomap_end()
fallback. We waited until the new iomap users from other trees were
in mainline otherwise this would have been very messy
- errseq: Retry with the current value when the cmpxchg() in
errseq_check_and_advance() fails to avoid an old value coming back
later hiding the errors
- aio: Hold an extra count for exit_aio() itself so it can't return
before the last free_ioctx_reqs() callback has called complete()
- pidfd: Fail the namespace ioctls with EREMOTE unless the target is
visible in the caller's pid namespace like PIDFD_GET_INFO does
- eventpoll: Wake the next waiter when a woken waiter returns early
because of a fatal signal to avoid sleeping forever
- backing-file: Pass RWF_NOAPPEND on to synchronous writes to the
backing file
- initrd: Flush the deferred fput() of the ramdisk file before mounting
root
- iov_iter: Take an unsigned long segment count in import_iovec()
The upper 32 bits of the count passed to readv(), writev() and
friends were dropped before the UIO_MAXIOV check
- splice: Advance the pipe tail before checking for a full bvec array
in splice_to_socket(). The last buffer was counted again, so MSG_MORE
was set although the pipe was empty and small TCP transfers waited
for the cork timeout
- vfs:
- Reject negative offsets for SEEK_DATA and SEEK_HOLE in
default_llseek() and use must_set_pos() for its whence handling
- Only clear tv_nsec in timestamp_truncate() when clamping changed
the seconds. Timestamps whose seconds were exactly at a
filesystem time limit lost their subsecond part
- Don't leak the kernel-internal STATX_ATTR_CHANGE_MONOTONIC in
stx_attributes_mask
- Clamp the FIONREAD result to the int range so a file with 4 GiB
left isn't reported as empty
- Fix the SEEK_CUR f_lock check
- selftests: Fix the statmount and mount_setattr tests on 32-bit and
s390, build the fchmodat2 and openat2 tests without sanitizers when
the toolchain lacks the runtimes and fix a clang warning in the
mount-notify test
- docs: Fix a docutils warning in porting.rst
* tag 'vfs-7.4-rc3.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: (28 commits)
fs: fix the SEEK_CUR f_lock condition
splice, net: avoid MSG_MORE when the bvec array fills
aio: don't let exit_aio() return before complete() is done
fs: porting.rst: use literal string to avoid warning
selftests/fs/mount-notify: fix the indentation in the fsmount test
selftests: probe for sanitizer support in fchmodat2 and openat2
selftests/mount_setattr: build with a 64-bit off_t
selftests/statmount: fix format warnings on 32-bit and s390
fs: use must_set_pos() in default_llseek()
fs: reject negative offsets for SEEK_DATA and SEEK_HOLE in default_llseek()
pidfd: restrict task access ioctls to the caller's pid namespace
fs: clamp FIONREAD result to int range
eventpoll: wake the next waiter when a woken waiter is killed
statx: don't leak STATX_ATTR_CHANGE_MONOTONIC in stx_attributes_mask
vfs: preserve subsecond timestamps at filesystem time limits
iov_iter: take an unsigned long segment count in import_iovec()
lib/tests: errseq: add a concurrent check_and_advance test
errseq: don't let errseq_check_and_advance() hide later errors
backing-file: pass RWF_NOAPPEND to synchronous writes
initrd: flush deferred fput() before mounting root
...
|
|
and remove all my E-Mail address references from the wireless sources.
Signed-off-by: Michael Büsch <m@bues.ch>
Link: https://patch.msgid.link/20261101121325.7c334d78@barney
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
|
|
When CONFIG_DEBUG_MAPLE_TREE is set, call WARN_ON() once per site after
the custom information is dumped about the tree. Without using the
kernel's WARN_ON calls, syzbot will not catch issues detected by this
code. The BUG_ON variants now stop instead of dumping and continuing.
Update the non-debug code to call WARN_ON_ONCE() as well.
The userspace tests asserted on dump_stack() but only print on
WARN_ON(), so make WARN() fatal in maple-shared.h and have the maple
test exit with the result of maple_tree_seed().
Link: https://lore.kernel.org/20261103020724.2614498-4-liam@infradead.org
Fixes: f0a1f866aba1 ("maple_tree: add debug BUG_ON and WARN_ON variants")
Signed-off-by: Liam R. Howlett (Google) <liam@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Lorenzo Stoakes <ljs@kernel.org>
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Cc: Chris Mason <mason@kernel.org>
Cc: Alice Ryhl <aliceryhl@google.com>
Cc: Andrew Ballance <andrewjballance@gmail.com>
Cc: <stable@vger.kernel.org>
|
|
Commit 38564710f443 ("mm: implement and use vma_has_anon_rmap(), silence
KCSAN") rather clumsily converted the read of vma->anon_vma into a
vma_has_anon_rmap() without accounting for the separation between
assignment of anon_vma and later use of it.
vma_has_anon_rmap() is intended as an optimistic check, so doesn't need to
protect against a torn read in vma->anon_vma. The caller is expected to
take care of this themselves if they then in fact access the field.
validate_mm() does indeed then reference the field, so resolve the issue
via READ_ONCE(), and simplify the code by separating this into a new
function validate_mm_anon_rmap().
Finally, add a vma_assert_stabilised() to make it clear the required state
of the VMA.
[kas@kernel.org: reduce ifdeffery]
Link: https://lore.kernel.org/auhn01dpDzK47igy@thinkstation
Link: https://lore.kernel.org/20261102-fix-validate_mm-v1-1-5c309614ef15@kernel.org
Fixes: 38564710f443 ("mm: implement and use vma_has_anon_rmap(), silence KCSAN")
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: <syzbot+10e72ea5747737bcd2ad@syzkaller.appspotmail.com>
Closes: https://lore.kernel.org/all/6ae78418.6552420f.2a0efc.005c.GAE@google.com/
Reported-by: Songsen Yang <yangsongsen@insta360.com>
Closes: https://lore.kernel.org/all/20261102074414.10902-1-yangsongsen@insta360.com/
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Jann Horn <jannh@google.com>
Cc: Pedro Falcato <pfalcato@suse.de>
Cc: Kiryl Shutsemau <kas@kernel.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Lance Yang <lance.yang@linux.dev>
|
|
vms_gather_munmap_vmas() collects VMAs to unmap and calls
userfaultfd_unmap_prep() for each of these VMAs. This takes a reference
to the userfaultfd context, raises ctx->mmap_changing and queues an
UFFD_EVENT_UNMAP on the caller's list.
If gathering fails half way, e.g. because one of the VMAs is sealed, or
the operation fails after the VMAs were gathered, the original mappings
stay intact but the queued events remain on the list.
Depending on the caller they are either delivered although nothing was
unmapped (munmap(), mremap(), mmap(MAP_FIXED)), or silently dropped
(brk()). In the latter case the userfaultfd context and the mm_struct it
pins are leaked and mmap_changing is never lowered, so UFFDIO_COPY,
UFFDIO_ZEROPAGE and all other ioctls that check mmap_changing fail with
-EAGAIN forever.
With mseal() this is trivially triggered by an unprivileged process.
Collect the events in do_vmi_align_munmap() on a local list and splice
it to the caller's list only when the unmap completes, because mremap()
may already have events for earlier unmaps on that list.
Drop the pending events with a new userfaultfd_unmap_abort() helper when
do_vmi_align_munmap() or __mmap_setup() fail.
Link: https://lore.kernel.org/20261101-uffd-unmap-abort-v1-1-1588d7a7c61a@kernel.org
Fixes: 65ac132027a8 ("userfaultfd: fix regression in userfaultfd_unmap_prep()")
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Noah Weinberger <NoahWeinberger2003@proton.me>
Reviewed-by: Tal Zussman <tz2294@columbia.edu>
Tested-by: Tal Zussman <tz2294@columbia.edu>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Jann Horn <jannh@google.com>
Cc: Pedro Falcato <pfalcato@suse.de>
Cc: Peter Xu <peterx@redhat.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: <stable@vger.kernel.org>
|
|
Patch series "mm: Fix page-table teardown during memory hot-remove", v3.
Memory hot-remove can free page-table pages allocated through paths with
different constructor state. Some paths run the page-table constructor,
while generic sparse-vmemmap population may not. The x86, RISC-V, and
arm64 teardown paths did not handle that distinction consistently,
leaving constructor/destructor accounting unbalanced.
Make pagetable_free() handle any remaining constructor state before
freeing a page-table page. Callers that already ran pagetable_dtor()
have cleared that state, so the destructor is not run twice. The RISC-V
and arm64 fixes then use this common helper for their memory-hot-remove
paths.
The architecture fixes depend on the common MM change in patch 1, so
this remains a single series. I expect it to go through the MM tree,
with review or acks from the relevant architecture maintainers.
This patch (of 4):
Since commit 49f599666420 ("mm: call ctor/dtor for kernel PTEs"),
pte_alloc_one_kernel() runs the page-table constructor for kernel PTE
tables.
HVO (HugeTLB Vmemmap Optimization) uses pte_alloc_one_kernel() when
splitting a PMD. Restoring the vmemmap backing pages does not collapse
the PTE table, so a later memory hot-remove eventually frees it through
pagetable_free() on x86-64. That releases the page without running the
matching destructor and leaves NR_PAGETABLE elevated.
Make pagetable_free() the common free-side primitive for page-table
pages. It checks PageTable() and runs the destructor only when the
constructor state is still present. Callers that explicitly ran
pagetable_dtor() have already cleared PageTable(), so they are not
destructed twice; pages that never ran a constructor are freed directly.
Link: https://lore.kernel.org/20261023063428.3658761-1-songmuchun@bytedance.com
Link: https://lore.kernel.org/20261023063428.3658761-2-songmuchun@bytedance.com
Fixes: 49f599666420 ("mm: call ctor/dtor for kernel PTEs")
Signed-off-by: Muchun Song <muchun.song@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Reviewed-by: Kevin Brodsky <kevin.brodsky@arm.com>
Acked-by: Dave Hansen <dave.hansen@intel.com>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Paul Walmsley <pjw@kernel.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Björn Töpel <bjorn@rivosinc.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: <stable@vger.kernel.org> # bf9e4e30f353: x86/mm: use pagetable_free()
|
|
Patch series "mm/kasan: Detect double-free involving kfree_rcu_sheaf().",
v3.
Recently, syzbot has reported several weird use-after-free splats.
What they have in common is that "Freed by" points to rcu_free_sheaf(),
whereas the object shown in "Call Trace:" and "Allocated by" is never
supposed to be freed via kfree_rcu().
This means the object was a victim of a double-free somewhere else and
was silently poisoned by rcu_free_sheaf() after being reallocated.
This happens because kfree_rcu_sheaf() queues an object into the RCU
sheaf without invoking any KASAN hooks.
This series enables KASAN to detect double-free involving
kfree_rcu_sheaf() immediately and adds KUnit tests for it.
This patch (of 2):
syzbot reported a weird use-after-free splat. [0]
In the report, an object in the kmalloc-64 cache was freed via
rcu_free_sheaf() while it was still in use, even though the
object should always be freed with kfree() (in xfrm_hash_free()),
implying that the object was a victim of a double-free involving
kfree_rcu() somewhere else.
When kvfree_call_rcu() frees an object via kfree_rcu_sheaf() and
queues it into pcs->rcu_free, debug facilities are skipped, e.g.,
kasan_slab_pre_free(), kasan_record_aux_stack(),
debug_rcu_head_queue(), etc.
As a result, KASAN cannot detect the double-free at the call site.
If the object is still in the KASAN quarantine when the sheaf is
flushed, KASAN can detect the double-free in rcu_free_sheaf(), but
with no trace of the suspect.
Worse yet, once the object is evicted from the quarantine and
reallocated before the sheaf is flushed, rcu_free_sheaf() silently
poisons the live object, resulting in a false-positive use-after-free
report on the new user.
If __kfree_rcu_sheaf() simply calls kasan_slab_pre_free(), we
can detect the second kfree_rcu(), but only while the object is
poisoned in the KASAN quarantine after the first free:
kfree() --(poisoned)--------------------> kfree_rcu()
kfree_rcu() -> rcu_free_sheaf() -(poisoned)-> kfree_rcu()
An object queued in pcs->rcu_free remains unpoisoned until the
sheaf becomes full and rcu_free_sheaf() runs after the RCU
grace period, so a subsequent kfree_rcu() or kfree() before
rcu_free_sheaf() cannot be detected by shadow bytes alone:
kfree_rcu() -(unpoisoned)-> kfree_rcu() -> rcu_free_sheaf() (too late!)
kfree_rcu() -(unpoisoned)-> kfree() -> rcu_free_sheaf() (too late!)
These cases can be detected if we call debug_rcu_head_queue()
before kfree_rcu_sheaf(), but ODEBUG splat only shows the second
free.
To detect these cases with KASAN, we just need a 1-bit flag
to indicate the state, which can reuse an unused bit in struct
kasan_track.pid. (PID_MAX_LIMIT is 1<<22)
The bit is marked along with recording the stack trace when
deferring slab frees in kfree_rcu_sheaf() and checked in
check_slab_allocation() so that any double-free pattern above
can be detected immediately.
Link: https://lore.kernel.org/20261028194014.3671161-1-kuniyu@google.com
Link: https://lore.kernel.org/20261028194014.3671161-2-kuniyu@google.com
Link: https://lore.kernel.org/all/6ac959ee.70ed5d86.2ac85.007d.GAE@google.com/ #[0]
Fixes: ec66e0d59952 ("slab: add sheaf support for batching kfree_rcu() operations")
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Tested-by: Alexander Potapenko <glider@google.com>
Reviewed-by: Alexander Potapenko <glider@google.com>
Reviewed-by: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Harry Yoo <harry@kernel.org>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Hao Li <hao.li@linux.dev>
Cc: Christoph Lameter <cl@gentwo.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: <stable@vger.kernel.org>
|
|
tcp_reqsk_record_syn() allocates saved_syn separately from its request
socket. bpf_sock_ops_get_syn() can load that pointer while processing a
retransmitted SYN under RCU.
There are two ownership transfers which can let another CPU reclaim the
allocation while such a reader is still using it.
First, tcp_move_syn() transfers req->saved_syn to a newly created child
socket. The child can be closed and tcp_saved_syn_free() can reclaim the
allocation before a reader of the old request finishes.
Second, inet_reqsk_clone() shallow-copies request_sock during request
migration. After reqsk_migrate_reset() clears the old request pointer, the
migrated clone owns it. However, a reader which already loaded the pointer
from the old request can still be using it when the clone is released.
I found this through LLM-assisted concurrency fuzzing.
Mark the request-socket saved_syn pointer as RCU protected and use RCU
accessors for its reads and updates. Keep the full-socket pointer plain
because all of its accesses hold the socket lock. Embed an rcu_head in
struct saved_syn and use kfree_rcu() in both teardown paths. This lets a
request-side reader which loaded the object before an ownership transfer
finish.
This follows commit e3f33b0a1d89 ("ipv4: free inet_opt and ireq_opt
after an RCU grace period"), which fixed the same ownership-transfer
pattern for IPv4 options.
The issue was confirmed with KASAN on v7.3-16007-g36aad21d50d1 using
temporary kernel instrumentation to widen the reader and request-migration
window. KASAN reported a slab-use-after-free read in
bpf_sock_ops_get_syn(), with the allocation freed by __reqsk_free() from
reqsk_timer_handler(). The same explicit migration test completed without
a report with deferred reclamation. A patched kernel without the delay
instrumentation also completed a successful migration and seven saved-SYN
reads without a KASAN report.
Fixes: 0813a841566f ("bpf: tcp: Allow bpf prog to write and parse TCP header option")
Fixes: c905dee62232 ("tcp: Migrate TCP_NEW_SYN_RECV requests at retransmitting SYN+ACKs.")
Cc: stable@vger.kernel.org
Signed-off-by: Yingjie Wang <x-professor@outlook.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Link: https://patch.msgid.link/38fa9f2cc476502e9b1c1fef09ebba1df5dd5901.1793795528.git.x-professor@outlook.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|
git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd
Pull key fixes from Jarkko Sakkinen:
- Expand key->datalen and key->quotalen in order to avoid integer
truncation and the leak of quota.
- Enforce KEY_MAX_DESC_SIZE limits across in-kernel and
payload-generated paths.
- Verify the key identity in __key_unlink_begin() as type and
description could also refer to a more recently linked key with
matching properties as the one being unlinked.
- Fix key update race with key GC
* tag 'keys-v7.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd:
KEYS: Protect the update method check against type removal
KEYS: Verify the key identity in __key_unlink_begin
KEYS: Reject descriptions larger than KEY_MAX_DESC_SIZE
KEYS: Expand key->{datalen,quotalen} to unsigned int
|
|
When a socket is over its receive buffer limit and its sk_rcvbuf can
not grow, every incoming segment that needs memory goes through
tcp_prune_queue(), which runs tcp_collapse_ofo_queue() and tcp_collapse()
on the receive queue. Both walk their whole queue, even when there is
nothing left to collapse.
A peer can trigger this walk per packet, without refilling memory:
1) The segment lands last in the out-of-order queue. Since commit
b0e01253a764 ("tcp: refine tcp_prune_ofo_queue() logic"),
tcp_prune_ofo_queue() drops nothing, the segment is dropped and
the queues are unchanged. The peer can send it again forever.
2) The segment lands second to last: one skb is pruned, and one small
segment fills that space again.
3) The out-of-order queue is empty and the receive queue alone is over
the limit (application not reading). Collapsing frees nothing,
the out-of-order segment is dropped, and the window is not closed.
4) Collapsing frees just one skb, enough to queue the segment. The next
segment is over the limit again.
Only allow a collapse if at least 1/8 of sk_rcvbuf of new memory was
queued in the receive queues since the previous collapse. This restores
the "12.5 % of the queue capacity" amortization of the 2018 SegmentSmack
fixes (CVE-2018-5390), using the same unit as the sk_rcvbuf limit, so
that peers sending small (bloated) segments are not penalized.
The credit is the net growth of sk_rmem_alloc in tcp_queue_rcv() and
tcp_data_queue_ofo(), so that:
- Coalescing a segment into the tailroom of the previous skb charges no
memory, and earns no credit.
- An out-of-order segment replacing or covering queued skbs only earns
the memory it adds.
- Duplicates earn nothing.
- Data moved from the out-of-order queue to the receive queue
(tcp_ofo_queue()) is not credited twice.
In-order data is credited too, so that a receive queue filled by
bloated in-order segments can still be collapsed when a hole appears.
In-order segments are rate limited as well: a peer could otherwise send
small in-order segments that each trigger a collapse freeing a single
skb, enough to queue the segment, while the out-of-order queue holds
many skbs that can not be collapsed.
The credit is tracked in a new u32 tp->rcv_collapse_credit, placed in a
hole of the tcp_sock_write_rx group: no other field moves, and tcp_sock
size is unchanged. tcp_queue_rcv() now samples sk_rmem_alloc, and
writes the credit until it saturates at sk_rcvbuf, so that the fast path
stops writing it after a full buffer of new memory. Saturating at the
goal would not work: sk_rcvbuf, and the goal with it, can grow later
(for instance in tcp_clamp_window(), just before the goal is checked),
and a socket over its limit can not earn more credit until the
application reads.
When collapsing is not allowed, tcp_prune_queue() goes directly to
tcp_prune_ofo_queue(), which is cheap in the cases above.
A regular flow can see a difference when it goes over its limit before
1/8 of sk_rcvbuf of new memory was queued since the previous collapse:
out-of-order skbs can be pruned (even for an in-order segment filling a
hole), and an in-order segment that still does not fit is dropped,
with a zero window advertised, where a collapse might have made room.
Fixes: b0e01253a764 ("tcp: refine tcp_prune_ofo_queue() logic")
Reported-by: Chris Mason <mason@kernel.org>
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Neal Cardwell <ncardwell@google.com>
Link: https://patch.msgid.link/20261105124043.1543405-1-edumazet@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|