Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull vhost fix from Michael Tsirkin:
"Another high priority bugfix. Working on more"
* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
vhost: reject used ring batches larger than the ring
Revert "vhost: split out-of-order used ring batches at every wrap"
Revert "vhost: split out-of-order used ring batches at every wrap"
This reverts commit 5570a998b884c988dbe105430d7e2d8e9411e37e.
Commit 5570a998b884 ("vhost: split out-of-order used ring batches at
every wrap") addressed completion batches larger than the ring on the
out-of-order path, but did not cover all paths (such as the in-order
dirty-log replay loop).
Revert it; a follow-up patch will address all paths in a more consistent
manner.
Cc: stable at vger.kernel.org
Fixes: 5570a998b884 ("vhost: split out-of-order used ring batches at every wrap")
Signed-off-by: Michael S. Tsirkin <mst at redhat.com>
vhost: reject used ring batches larger than the ring
A compliant driver never has more than vq->num buffers in flight at
once, so a batch accumulated before used->idx advances never exceeds
vq->num.
Reject used count > vq->num in
vhost_add_used_n()/vhost_add_used_n_in_order().
Cc: stable at vger.kernel.org
Reported-by: Seohyeon Maeng <bioloidgp at gmail.com>
Reported-by: minki at morningstarsec.dev
Reported-by: YanXin Li <fadouse at pm.me>
Fixes: e2b3b35eb989 ("vhost_net: batch used ring update in rx")
Fixes: 4afb52c2af44 ("vhost_net: batch update used ring for datacopy TX")
Fixes: bfcde6b64769 ("vhost: fix dirty logging for in-order used ring entries")
Cc: Jason Wang <jasowangio at gmail.com>
Cc: Eugenio Pérez <eperezma at redhat.com>
Message-ID: <66327153423e98bd10778bac1f29c26ba633e02a.1796163071.git.mst at redhat.com>
Signed-off-by: Michael S. Tsirkin <mst at redhat.com>
Merge tag 'uml-fixes-7.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/uml/linux
Pull uml fixes from Johannes Berg:
- vector network driver (NAPI, hardening)
- rust module loading
- FD initialization in time-travel messages
* tag 'uml-fixes-7.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/uml/linux:
um: time-travel: don't use uninitialized fds from START ACK
um: vector: Don't clean up NAPI that was never set up
um: vector: Possible underflow and races fixes
rust: arch/um: Fix loading Rust modules
um: time-travel: don't use uninitialized fds from START ACK
When the kernel connects to an external time-travel controller, it
expects the ACK of its UM_TIMETRAVEL_START message to carry two file
descriptors: the shared memory area and a log file. It reads them with
os_rcv_fd_msg() into an uninitialized on-stack array, and then uses
both array elements whenever the message itself was received in full.
os_rcv_fd_msg() leaves the array untouched if the message came without
an SCM_RIGHTS control message. That is what any controller that does
not implement the shared memory extension sends, which the protocol
allows: such controllers are why the kernel falls back to message
based scheduling. In that case the kernel passes stack garbage to
mmap() and then close()s both values.
With CONFIG_INIT_STACK_ALL_ZERO, the default where the compiler
supports it, the garbage is 0, so the kernel closes its own stdin. The
next file descriptor it opens, the epoll instance used for IRQs, then
becomes fd 0:
[19 lines not shown]
um: vector: Don't clean up NAPI that was never set up
vector_net_open() calls vector_net_close() on any failure once
vp->fds is set, and vector_net_close() then runs napi_disable() and
netif_napi_del() unconditionally. But the NAPI context is only added
and enabled after build_transport_data() and the header buffer
allocations, so a failure in any of those disables a NAPI context that
was never added. napi_disable() locks n->dev, which is still NULL:
ip link set vec0 up (vec0:transport=gre,...,rx_key=1, no tx_key)
Kernel panic - not syncing: Kernel mode fault at addr 0x910
napi_disable+0x4e/0x9e
vector_net_close+0x2b9/0x87d
vector_net_open+0x105d/0x106f
__dev_open+0x244/0x334
Record in vp->napi_enabled whether vector_net_open() got as far as
enabling NAPI, and only disable and delete it in vector_net_close()
when it did. NAPI is still enabled only after the queues and buffers
[10 lines not shown]
Merge tag 'mmc-v7.4-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
Pull MMC fixes from Ulf Hansson:
"MMC core:
- Saturate erase timeout instead of overflowing
- Use GFP_NOIO for SD cache flush buffers
- Fix probing of SDIO functions on ACPI systems
- Mark the end of a truncated scatterlist
- Clear MQRQ_XFER_SINGLE_BLOCK for new requests
- Add ISSI IS22TF128G eMMC to fixed secure erase time quirk
MMC host:
- bcm2835: Restore scatterlist after DMA setup failure
- dw_mmc:
- Fix support for clk-phase in DT
- Fix races at remove
- mmci:
- Fix support for tuning for stm32
- Do not count a data CRC error as a complete transfer
[36 lines not shown]
Merge tag 'keys-v7.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd
Pull key fixes from Jarkko Sakkinen:
- Synchronize key_instantiate_and_link() and key_reject_and_link() with
unregister_key_type() using SRCU, so that a concurrent type removal
does not fail on null deref
- Call rcu_barrier() at module exit so that encrypted_rcu_free() and
trusted_rcu_free() callbacks queued by ->update() cannot run in freed
module memory
- Return user_session directly instead of installing it into the task's
credentials on a lookup without KEY_LOOKUP_CREATE, as mutating struct
cred, as client subsystem will then end up having a stale struct cred
- Reject KEY_LOOKUP_CREATE with -EPERM when the task runs with
overridden credentials, instead of triggering BUG_ON() in
commit_creds()
[7 lines not shown]
Merge tag 'media/v7.4-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media fixes from Mauro Carvalho Chehab:
- two videobuf2 core fixes related to finish prepared buffers on mmap
lock and at VIDIOC_REMOVE_BUFS ioctl
- Intel iPU6:
- fix image height calculus
- address a race contition at ipu6-isys-video
- fix a return condition and print an error at klog if frame
descriptior is not found
- Check if firmware is started before close on suspend
- AMD ISP4:
- fix API mmap dequeue of progressive-only framebuffers
- fix bad lock issues affecting stream start logic
- fix for ivsc csi driver, addressing an issue affecting camera
[13 lines not shown]
Merge tag 'drm-fixes-2026-12-02' of https://gitlab.freedesktop.org/drm/kernel
Pull drm fix from Dave Airlie:
"An out of band pull request for an i915 rcu fix that I want to get
into stable, so let's just make it get there faster.
i915:
- use rcu to free vma"
* tag 'drm-fixes-2026-12-02' of https://gitlab.freedesktop.org/drm/kernel:
i915/vma: use kfree_rcu to make sure vma are freed after a rcu grace period
i915/vma: use kfree_rcu to make sure vma are freed after a rcu grace period
There is a race in the vma lookup and the vma freeing that can race
object close against object execbuffer vma lookups.
execbuffer2 and close on two threads can be raced, so the radix tree
lookup and tryget in eb_lookup_vma can be raced against a freed vma.
The rcu protection in the eb lookup doesn't help because we don't
use rcu around the free path.
This patch adds rcu protection around the vma destruction path.
We could also probably use SLAB_TYPESAFE_BY_RCU but there may be
other submarined vma races in other code that this might not fix,
so let's just force the rcu on free.
Cc: stable at vger.kernel.org
Signed-off-by: Dave Airlie <airlied at redhat.com>
mm: kvmalloc: Bail if called with soft or hard IRQs disabled
The function kvmalloc may call vmalloc under the hood even when
used with GFP_ATOMIC. However, vmalloc uses naked spin locks so
it must not be called if the caller already holds spin locks that
can be used in hard or soft IRQ context.
Use the heuristic irqs_disabled() || in_softirq() to detect such
callers and prevent them from using vmalloc.
Reported-by: Liam R. Howlett (Google) <liam at infradead.org>
Fixes: c6307674ed82 ("mm: kvmalloc: add non-blocking support for vmalloc")
Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
Merge tag 'pmdomain-v7.4-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/linux-pm
Pull pmdomain fixes:
"pmdomain core:
- Wait for device link removals before dropping genpd->dev
- Clear states after freeing them
pmdomain providers:
- Fix some memory leaks and reference countings during probe/remove
- cpuidle-psci: Skip SET_SUSPEND_MODE when OSI is unsupported
- mediatek:
- Fix a couple problems in the probe error path
- Fix silent audio from premature sync_state for mt8183
- qcom: Don't clamp gfx and gmxc before sync_state for rpmhpd
- rockchip:
- Fix a couple problems in the probe error path
- Manage the RK3576 GPU domain supply"
* tag 'pmdomain-v7.4-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/linux-pm:
[16 lines not shown]
Merge tag 'lsm-pr-20261130' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm
Pull lsm fix from Paul Moore:
"A single fix for the LSM framework to ensure that the
security_inode_copy_up() error handling code properly
cleans up after itself"
* tag 'lsm-pr-20261130' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm:
lsm: put the copy up creds when an LSM hook fails
Merge tag 'selinux-pr-20261130' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux
Pull selinux fixes from Paul Moore:
"Two SELinux fixes: one tightens a size check in SELinux's labeled
IPsec code, the other ensures that the source and destination port of
network related SELinux audit denial records (commonly known as "AVC"
records) are properly initialized"
* tag 'selinux-pr-20261130' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
selinux: reject a 65535-byte xfrm context that ctx_len cannot hold
selinux: initialize sport/dport in __ad_net_init()
Merge tag 'clk-fixes-for-linus-v7.4' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux
Pull clk fixes from Brian Masney:
"Qualcomm Glymur GCC:
- Use collapse voting for PCIe and PCIe PHY power domains shared with
other masters, including domains enabled by boot firmware
- Retain USB and USB PHY power domains to preserve configuration and
fix USB host controller resume from suspend
Samsung Exynos:
- Properly handle deferred probe of the AudioSubsystem clock
controller
- Fix integration of clock controller and power domains on Exynos5250
and Exynos5420: be sure device runtime resumed before proceeding
with probe and defer probe till the power domain is available"
[7 lines not shown]
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio fixes from Michael Tsirkin:
"Just a bunch of small fixes all over the place. Nothing stands out
much.
A new test in tools - given we had a bunch of issues around logging
discovered recently, seems prudent to just include it"
* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
virtio: Release the OF node when unregistering the device
vhost: synchronize worker freeing on vhost-net teardown
tools/virtio: add a vhost dirty log test
vhost: set dirty log bits without pinning pages on x86
tools/virtio: vringh_test: check that a split ring must be a power of two
virtio_ring: reject a split ring size that is not a power of two again
virtio-pci: Drop inclusion of <linux/mod_devicetable.h>
virtio_balloon: drain update works on probe error paths
virtio_console: defer HVC polling out of the virtqueue callback
[7 lines not shown]
Merge tag 'qcom-clk-fixes-for-7.4' into clk-fixes
Qualcomm clock fixes for v7.4
Fix Glymur GCC power domain handling for PCIe and USB.
- Use collapse voting for PCIe and PCIe PHY power domains shared with
other masters, including domains enabled by boot firmware.
- Retain USB and USB PHY power domains to preserve configuration and
fix USB host controller resume from suspend.
* tag 'qcom-clk-fixes-for-7.4':
clk: qcom: gcc-glymur: use collapse-voting for PCIe GDSCs
clk: qcom: gcc-glymur: Use PWRSTS_RET_ON flag for USB GDSCs
mmc: bcm2835: restore scatterlist after DMA setup failure
The DMA preparation path shortens the final scatterlist entry
to reserve space for FIFO drain words.
If DMA mapping or descriptor preparation fails, the request
falls back to PIO, but the shortened scatterlist entry is left
unchanged. As a result, the PIO transfer may omit part of the
data, potentially causing corrupted or incomplete I/O.
Restore the entry's original length and clear drain_words
before returning to the fallback path.
This issue was found while investigating a kernel panic on
my Raspberry Pi server.
Fixes: 660fc733bd74 ("mmc: bcm2835: Add new driver for the sdhost controller.")
Cc: stable at vger.kernel.org
Signed-off-by: Artem Novak <artem122novak at gmail.com>
[2 lines not shown]
mmc: rtsx_usb_sdmmc: allow legacy SD init after CMD8 timeout
According to the rts5139 staging driver, SD 1.x cards do not respond
to SD_SEND_IF_COND. On an RTS5129, a preinserted 2 GB SD card times
out on that command and the driver then rejects CMD55 and subsequent
initialization requests with -ENOMEDIUM. This prevents MMC core from
trying the legacy SD path.
Do not suppress card detection on a timeout from a no-data CMD8.
MMC SEND_EXT_CSD uses the same opcode with a data transfer, so retain
the existing timeout handling for that command. Keep refreshing the
physical card state and retain suppression on other discovery timeouts
to stop repeated probes of an empty tray.
Fixes: 7185b6d33b17 ("mmc: rtsx_usb_sdmmc: suppress false CD after init timeout")
Cc: stable at vger.kernel.org
Reported-by: Philipp Jonas <pjjonas at web.de>
Closes: https://lore.kernel.org/r/523eb7d1cc0811df4a5e4c534538f3dd@web.de
Tested-by: Philipp Jonas <pjjonas at web.de>
[2 lines not shown]
tools/virtio: add a vhost dirty log test
Add vhost_log_test, which exercises used-ring dirty logging through the
existing vhost_test module. It sets a log base with VHOST_SET_LOG_BASE,
enables VHOST_VRING_F_LOG on the ring, submits descriptors and checks
the resulting bitmap from userspace. No new kernel interface is needed.
The test covers:
- every bit in a byte, repeated sets, and neighbouring bytes being left
untouched, including the last byte of a page followed by a PROT_NONE
guard page
- a used ring write that spans two log pages, with both bits in the
same bitmap byte and in adjacent bytes
- a log page that has not been faulted in yet, read-only, PROT_NONE
and unmapped log pages, and logging after access is restored
- private (COW) and shared file mappings, checking that the bit reaches
the file after msync/fsync
- eight vrings setting different bits of the same byte concurrently,
[17 lines not shown]
virtio: Release the OF node when unregistering the device
virtio_device_of_init() acquires the OF node reference once during device
registration. virtio_dev_remove() currently puts it on each driver unbind,
although rebinding the driver does not acquire a new reference. Repeated
unbinds can therefore consume references not owned by the virtio device.
Conversely, unregistering a device that never bound to a driver leaves
the reference held.
Move the put to unregister_virtio_device() so it is paired with device
registration. Save the node pointer before device_unregister(), which
can free the virtio device, and put it after unregister has completed the
driver removal.
Fixes: 694a1116b405 ("virtio: Bind virtio device to device-tree node")
Reported-by: sashiko-bot <sashiko-bot at kernel.org>
Link: https://lore.kernel.org/all/sashiko-outbox-203883@kernel.org/
Cc: stable at vger.kernel.org
Signed-off-by: Yige Jiang <yigejiang86 at gmail.com>
[2 lines not shown]
vhost: synchronize worker freeing on vhost-net teardown
vhost_workers_free() only waits for RCU readers when sync is true. Both
vhost-net teardown paths pass false, relying on the assumption recorded
when the sync parameter was introduced (5efd97e6f0c7) that "net and scsi
stop their virtqueues before the workers are freed".
That assumption does not hold when a tap queue is detached while the
socket is still attached. __tun_detach() runs tun_queue_purge() on the
detaching thread, so skb_queue_purge() releases the zerocopy skbs and
vhost_zerocopy_complete() -> vhost_poll_queue() runs there rather than on
the vhost worker. The vhost_dev_flush() calls in vhost_net_flush() and
vhost_dev_stop() only wait for the vhost workers, so the queueing can
still be in flight when vhost_dev_cleanup() frees the worker, and
vhost_worker_queue() then dereferences freed memory.
Pass sync=true from vhost_net_release() and vhost_net_reset_owner() so a
grace period and a flush are observed before the workers are released,
matching the vsock RESET_OWNER path. Both are slow paths, and the extra
[17 lines not shown]
vhost: set dirty log bits without pinning pages on x86
vhost had a TODO to replace page pinning with a version
of set_bit that works on userspace memory, since forever.
It is really best to avoid GUP on fast path entirely.
Implement set_bit_user and use it in vhost, to do just that.
Should not be too hard for non-x86 too.
Reported-by: Khan Zhao <zhaoguohan at kylinos.cn>
Link: https://lore.kernel.org/all/20261112085631.128819-1-zhaoguohan@kylinos.cn/
Signed-off-by: Khan Zhao <zhaoguohan at kylinos.cn>
Signed-off-by: Michael S. Tsirkin <mst at redhat.com>
Message-ID: <20261117083323.89502-2-zhaoguohan at kylinos.cn>
tools/virtio: vringh_test: check that a split ring must be a power of two
vring_new_virtqueue() used to accept a split ring of any size, although
the ring is indexed with num - 1 as a mask. Check that it now refuses
one size short of RINGSIZE.
Without the preceding fix, vringh_test fails with:
vringh_test: vring_new_virtqueue accepted size 255
With it, vring_new_virtqueue() prints:
Bad virtqueue length 255 (not a power of two)
and the rest of the test runs as before.
Signed-off-by: Stjepan Poljak <stjepan.poljak at gmail.com>
Signed-off-by: Michael S. Tsirkin <mst at redhat.com>
Message-ID: <20261112154927.4004184-3-stjepan.poljak at gmail.com>
virtio_ring: reject a split ring size that is not a power of two again
The split ring indexes its avail and used rings with num - 1 as a mask,
so its size must be a power of two. Commit 2a2d1382fe9d ("virtio: Add
improved queue allocation API") moved that check from
vring_new_virtqueue() into the new allocation path, which
vring_new_virtqueue() does not use.
remoteproc calls vring_new_virtqueue() with a ring size from the
firmware, checked only to be non-zero. With 100 entries, for example,
the driver would put buffers 4 and 8 in avail slot 0. The device would
look for them at slots 4 and 8, possibly reading the wrong data.
Put the check back for the split ring; the packed ring has no such
restriction.
Fixes: 2a2d1382fe9d ("virtio: Add improved queue allocation API")
Signed-off-by: Stjepan Poljak <stjepan.poljak at gmail.com>
Reviewed-by: Francesco Valla <francesco at valla.it>
[4 lines not shown]
virtio-pci: Drop inclusion of <linux/mod_devicetable.h>
Among the different device id structures <linux/virtio_pci_legacy.h>
only uses struct virtio_device_id. Include <linux/device-id/virtio.h>
instead of <linux/mod_devicetable.h> to provide that which is more
lightweight and doesn't introduce that many dependencies.
The users of <linux/virtio_pci_legacy.h> also don't rely on this header
to provide the full plethora of definitions. (There are only
drivers/vdpa/alibaba/eni_vdpa.c and drivers/virtio/virtio_pci_common.c
using pci_device_id and these include <linux/pci.h> which is enough to
get it.)
Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig at baylibre.com>
Signed-off-by: Michael S. Tsirkin <mst at redhat.com>
Message-ID: <fc69191474ffd49d50d7e39b13dfe6586f4d3f75.1783354857.git.u.kleine-koenig at baylibre.com>
mmc: sh_mmcif: rework sg_miter handling
This driver is the only one that uses sg_miter_next() to get a persistent
mapping across interrupts, which prevents us from converting the internal
kmap() to a local mapping using SG_MITER_LOCAL flag.
Linus previously attempted to use atomic mappings here, which failed
for the same reason. I gave it another try, with a mapping that is only
active during a single sh_mmcif_mread_block()/sh_mmcif_mwrite_block() call.
This is mainly a revert of the patch that fixed the command 18 timeout,
but tries to solve the problem by updating and checking data->bytes_xfered
to keep track of when the transfer is finished.
Instead of calling sg_miter_stop() on error or completion, this now
always stops the iterator after the data transfer and restarts it during
the following interrupt.
As sashiko-bot comments, there is an inconsistency with the size of
[15 lines not shown]
mmc: core: use GFP_NOIO for SD cache flush buffers
sd_flush_cache() is called from mmc_blk_mq_issue_rq()'s REQ_OP_FLUSH
branch, which runs in the block layer dispatch path with the queue usage
counter held. Both it and sd_write_ext_reg(), which it calls, allocate
a 512-byte buffer with GFP_KERNEL. Under memory pressure that
allocation enters filesystem reclaim, and reclaim may submit I/O back to
the same request queue, closing a cycle against queue freeze:
CPU0 CPU1
---- ----
lock(&q->q_usage_counter(io));
lock(fs_reclaim);
lock(&q->q_usage_counter(io));
lock(&q->elevator_lock);
lockdep reports it on an arm64 Raspberry Pi 5 that boots from an SD
card, with the flush dispatched by blk_mq_requeue_work and the elevator
switch in another thread:
[31 lines not shown]
mmc: mmc_test: Set "cnt" to the allocated size explicitly
Since commit c35fac6481a1d ("mmc: mmc_test: Fix __counted_by handling
after kzalloc_flex() conversion"), mmc_test_alloc_mem() bounds its fill
loop with mem->cnt, relying on kzalloc_flex() to have set it to
"max_segs". kzalloc_flex() only sets the __counted_by() counter when the
compiler supports __builtin_counted_by_ref(). Otherwise mem->cnt is still
zero after the first segment is stored.
Set mem->cnt after the allocation, as that commit's description intends.
Build tested ARCH=x86_64 defconfig with CONFIG_MMC_TEST=m and W=1, with
GCC 16.2.0.
Fixes: c35fac6481a1d ("mmc: mmc_test: Fix __counted_by handling after kzalloc_flex() conversion")
Cc: stable at vger.kernel.org
Signed-off-by: Kees Cook <kees at kernel.org>
Reviewed-by: Adrian Hunter <adrian.hunter at intel.com>
Signed-off-by: Ulf Hansson <ulfh at kernel.org>