summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2026-06-09i2c: bcm-kona: fix spelling mistake in timeout-check commentStepan Ionichev
Fix a spelling mistake in the timeout-check comment. No functional change. Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com> Acked-by: Ray Jui <ray.jui@broadcom.com> Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Link: https://lore.kernel.org/r/20260503165925.1738-1-sozdayvek@gmail.com
2026-06-09i2c: cadence: Add shutdown handlerAjay Neeli
During system reboot or kexec, in-flight I2C transfers can cause spurious interrupts or leave the bus in an undefined state. Add a shutdown handler that marks the adapter suspended and resets the controller, ensuring a clean handoff. Signed-off-by: Ajay Neeli <ajay.neeli@amd.com> Acked-by: Michal Simek <michal.simek@amd.com> Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com> Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Link: https://lore.kernel.org/r/20260430053050.3590173-1-ajay.neeli@amd.com
2026-06-09accel/ivpu: Fix signed integer truncation in IPC receiveAndrzej Kacprowski
Fix potential buffer overflow where firmware-supplied data_size is cast to signed int before being used in min_t(). Large unsigned values (>= 0x80000000) become negative, causing unsigned wraparound and oversized memcpy operations that can overflow the stack buffer. Change min_t(int, ...) to min() as both values are unsigned and can be handled by min() without explicit cast. Fixes: 3b434a3445ff ("accel/ivpu: Use threaded IRQ to handle JOB done messages") Cc: stable@vger.kernel.org # v6.12+ Signed-off-by: Andrzej Kacprowski <andrzej.kacprowski@linux.intel.com> Reviewed-by: Karol Wachowski <karol.wachowski@linux.intel.com> Signed-off-by: Karol Wachowski <karol.wachowski@linux.intel.com> Link: https://patch.msgid.link/20260601161643.229342-1-andrzej.kacprowski@linux.intel.com
2026-06-09Merge tag 'drm-misc-next-fixes-2026-06-05' of ↵Dave Airlie
https://gitlab.freedesktop.org/drm/misc/kernel into drm-next drm-misc-next-fixes for v7.2-rc1: - Revert last minute IS_ERR_OR_NULL changes in nouveau/gsp. - Fix build warning in drm scheduler. - Flush caches and TLB before v3d runtime suspend. - Fix a trace and debug command in amdxdna. - Fix heap buffer address validation when PASID is disabled in amdxdna. Signed-off-by: Dave Airlie <airlied@redhat.com> From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Link: https://patch.msgid.link/a4a5bf50-3fc8-4faf-884b-08121687124a@linux.intel.com
2026-06-08net: openvswitch: fix possible kfree_skb of ERR_PTRAdrian Moreno
After the patch in the "Fixes" tag, the allocation of the "reply" skb can happen either before or after locking the ovs_mutex. However, error cleanups still follow the classical reversed order, assuming "reply" is allocated before locking: it is freed after unlocking. If "reply" allocation happens after locking the mutex and it fails, "reply" is left with an ERR_PTR, and execution jumps to the correspondent cleanup stage which will try to free an invalid pointer. Fix this by setting the pointer to NULL after having saved its error value. Fixes: 893f139b9a6c ("openvswitch: Minimize ovs_flow_cmd_new|set critical sections.") Signed-off-by: Adrian Moreno <amorenoz@redhat.com> Reviewed-by: Aaron Conole <aconole@redhat.com> Acked-by: Eelco Chaudron <echaudro@redhat.com> Link: https://patch.msgid.link/20260604121946.942164-1-amorenoz@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-06-08Merge branch 'tls-receive-path-fixes-and-clean-ups'Jakub Kicinski
Chuck Lever says: ==================== tls: receive-path fixes and clean-ups I'd like to encourage in-kernel kTLS consumers (NFSD, NVMe/TCP) to coalesce on the use of read_sock. While auditing read_sock for that purpose, Hannes and Sabrina flagged a few rough edges in the receive paths. This series is a set of clean-ups, not a performance series. Async batch decryption and its submit/deliver scaffolding were dropped during previous review: async_capable is always false for TLS 1.3, the version NFSD and NVMe/TCP both require, so async-related improvements were unreachable for the in-kernel consumers this work targets. A subsequent series will introduce infrastructure to support KeyUpdate for in-kernel kTLS consumers, which need to handle TLS Alert messages that trigger a tlshd upcall. ==================== Link: https://patch.msgid.link/20260604-tls-read-sock-v12-0-b114efa6e3e2@oracle.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-06-08tls: Flush backlog before waiting for a new recordChuck Lever
While lock_sock is held, incoming TCP segments land on sk->sk_backlog rather than sk->sk_receive_queue. tls_rx_rec_wait() inspects only sk_receive_queue, so backlog data remains invisible. For non-blocking callers (read_sock, and recvmsg or splice_read with MSG_DONTWAIT) this causes a spurious -EAGAIN. For blocking callers it forces an unnecessary sleep/wakeup cycle. Flush the backlog inside tls_rx_rec_wait() before checking sk_receive_queue so the strparser can parse newly-arrived segments immediately. On the next loop iteration tls_read_flush_backlog() may redundantly flush, but this path is cold and the cost is negligible. Backlog processing can run tcp_reset(), which calls tcp_done_with_error() to set sk->sk_err = ECONNRESET and then tcp_done() to set sk->sk_shutdown = SHUTDOWN_MASK. The pre-existing top-of-loop sk_err check already ran before the flush, so the freshly-set error would be masked by the next-line sk_shutdown test returning 0 (EOF). Re-check sk_err immediately before the sk_shutdown test so a connection abort surfaces as -ECONNRESET rather than a clean EOF. Commit f508262ae9f2 ("tls: Preserve sk_err across recvmsg() when data has been copied") gave the top-of-loop sk_err check a has_copied split. The recheck applies the same handling: when the caller has already copied bytes, sk_err is reported but preserved so the error surfaces on the next call; otherwise sock_error() consumes it so the error is reported exactly once. Suggested-by: Sabrina Dubroca <sd@queasysnail.net> Link: https://lore.kernel.org/netdev/ahgHgQ84RCc8uYrG@krikkit/ Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Reviewed-by: Sabrina Dubroca <sd@queasysnail.net> Link: https://patch.msgid.link/20260604-tls-read-sock-v12-6-b114efa6e3e2@oracle.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-06-08tls: Suppress spurious saved_data_ready on all receive pathsChuck Lever
Each record release via tls_strp_msg_done() triggered tls_strp_check_rcv(), which called tls_rx_msg_ready() and fired saved_data_ready(). During a multi-record receive, the first N-1 wakeups are pure overhead: the caller is already running and will pick up subsequent records on the next loop iteration. The recvmsg and splice_read paths share this waste. Suppress per-record notifications and emit a single one on reader exit. tls_rx_rec_done() releases the current record and parses the next without announcing; tls_strp_check_rcv() gains a bool announce parameter so callers can request the quiet form. tls_rx_reader_release() fires the deferred announce on exit through tls_rx_msg_maybe_announce(), an idempotent helper that calls saved_data_ready() only when a record is parsed and has not yet been announced. To keep the final notification idempotent against records that the BH or the worker has already announced, tls_strparser gains a msg_announced bit. tls_rx_msg_maybe_announce() sets the bit when firing saved_data_ready(); the bit is cleared whenever the parsed record is wiped, by tls_strp_msg_consume() on consumption or by tls_strp_msg_load() when the lower socket loses bytes from under the parse. A second call for the same parsed record -- as when recvmsg() satisfies the request from ctx->rx_list without touching the strparser -- becomes a no-op. With no remaining callers, tls_strp_msg_done() is removed. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Reviewed-by: Hannes Reinecke <hare@kernel.org> Reviewed-by: Sabrina Dubroca <sd@queasysnail.net> Link: https://patch.msgid.link/20260604-tls-read-sock-v12-5-b114efa6e3e2@oracle.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-06-08tls: Factor tls_strp_msg_consume() from tls_strp_msg_done()Chuck Lever
tls_strp_msg_done() conflates releasing the current record with checking for the next one via tls_strp_check_rcv(). A subsequent patch needs to release a record without immediately triggering that check, so the release step is separated into tls_strp_msg_consume(). tls_strp_msg_done() is preserved as a wrapper for existing callers. Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Reviewed-by: Sabrina Dubroca <sd@queasysnail.net> Link: https://patch.msgid.link/20260604-tls-read-sock-v12-4-b114efa6e3e2@oracle.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-06-08tls: Move decrypt-failure abort into tls_rx_one_record()Chuck Lever
Three receive paths -- recvmsg, read_sock, and splice_read -- each follow tls_rx_one_record() with the same tls_err_abort() call. Consolidate the abort into tls_rx_one_record() so the decrypt-and-abort sequence lives in one place. A tls_check_pending_rekey() failure after successful decryption no longer triggers tls_err_abort(). That path fires only when skb_copy_bits() fails on a valid skb, which is not a realistic scenario. Suggested-by: Sabrina Dubroca <sd@queasysnail.net> Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Sabrina Dubroca <sd@queasysnail.net> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Link: https://patch.msgid.link/20260604-tls-read-sock-v12-3-b114efa6e3e2@oracle.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-06-08tls: Re-present partially-consumed records in tls_sw_read_sock()Chuck Lever
The tls_sw_read_sock() loop releases the current skb whether read_actor() consumed the full record or only a prefix. When the actor takes only part of the record and leaves desc->count non-zero, the remainder is lost: skb is neither requeued nor freed, and the next iteration overwrites it during dequeue or tls_rx_rec_wait(). No mainline consumer reaches this path today. The only in-tree TLS read_sock user is nvme/tcp, whose actor nvme_tcp_recv_skb() loops until the input length is exhausted and returns either the full length or a negative error. The path becomes reachable with the upcoming NFSD svcsock receive built on read_sock_cmsg. Its data actor, svc_tcp_recv_actor(), parses an RPC fragment stream incrementally and returns at fragment boundaries. When a TLS record carries the tail of one RPC fragment plus the head of the next, the actor returns fewer bytes than offered while leaving desc->count non-zero, and without re-presentation the trailing fragment header vanishes. __tcp_read_sock() handles the equivalent case for plain TCP by leaving the unread bytes available for the next iteration to re-present, via sequence-number re-lookup. Adopt the same loop-level behavior: when read_actor() consumes only part of the record, update rxm->offset and rxm->full_len and requeue the skb to the head of rx_list so the next iteration re-presents the unread bytes. Switch the open-ended for-loop to "while (desc->count)" so the partial- and full-consume arms share a single exit check and read_actor() is not re-invoked once desc->count is exhausted. Cc: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Reviewed-by: Hannes Reinecke <hare@kernel.org> Reviewed-by: Sabrina Dubroca <sd@queasysnail.net> Link: https://patch.msgid.link/20260604-tls-read-sock-v12-2-b114efa6e3e2@oracle.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-06-08tls: Avoid evaluating freed skb in tls_sw_read_sock() loopChuck Lever
tls_sw_read_sock() ends its receive loop with while (skb), but the else branch in the body calls consume_skb(skb) before the predicate is re-evaluated. A pointer becomes indeterminate when the object it points to reaches end-of-lifetime (C2011 6.2.4p2), and using an indeterminate value is undefined behavior (Annex J.2). The pointer is not dereferenced today -- the predicate either exits the loop or skb is overwritten at the top of the next iteration -- but any future change that adds a dereference between consume_skb() and the predicate would silently introduce a use-after-free. Replace the do/while form with an explicit for(;;) loop so termination happens through a break statement rather than predicate evaluation of a freed pointer. Cc: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Reviewed-by: Hannes Reinecke <hare@kernel.org> Reviewed-by: Sabrina Dubroca <sd@queasysnail.net> Link: https://patch.msgid.link/20260604-tls-read-sock-v12-1-b114efa6e3e2@oracle.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-06-08remoteproc: qcom: pas: Drop start/stop completion from struct qcom_pasShawn Guo
The completion start_done and stop_done are leftover from commit 6103b1a616ab ("remoteproc: qcom: adsp: Use common q6v5 helpers"). Clean them up. Signed-off-by: Shawn Guo <shengchao.guo@oss.qualcomm.com> Link: https://lore.kernel.org/r/20260525073836.1579375-1-shengchao.guo@oss.qualcomm.com Signed-off-by: Bjorn Andersson <andersson@kernel.org>
2026-06-08remoteproc: qcom: pas: Add Shikra remoteproc supportBibek Kumar Patro
Add the CDSP, LPAICP and MPSS Peripheral Authentication Service support for the Qualcomm Shikra SoC. Signed-off-by: Bibek Kumar Patro <bibek.patro@oss.qualcomm.com> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> Signed-off-by: Komal Bajaj <komal.bajaj@oss.qualcomm.com> Link: https://lore.kernel.org/r/20260521-shikra-rproc-v3-2-2fca0bbe1ad7@oss.qualcomm.com Signed-off-by: Bjorn Andersson <andersson@kernel.org>
2026-06-08dt-bindings: remoteproc: qcom,shikra-pas: Document Shikra PAS remoteprocsKomal Bajaj
Document the bindings for the CDSP, LPAICP and MPSS PAS on the Shikra SoC. Signed-off-by: Bibek Kumar Patro <bibek.patro@oss.qualcomm.com> Signed-off-by: Komal Bajaj <komal.bajaj@oss.qualcomm.com> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://lore.kernel.org/r/20260521-shikra-rproc-v3-1-2fca0bbe1ad7@oss.qualcomm.com Signed-off-by: Bjorn Andersson <andersson@kernel.org>
2026-06-08dt-bindings: remoteproc: Add Shikra RPM processor compatibleKomal Bajaj
Add compatible for the Qualcomm Shikra RPM processor. Signed-off-by: Komal Bajaj <komal.bajaj@oss.qualcomm.com> Signed-off-by: Sneh Mankad <sneh.mankad@oss.qualcomm.com> Acked-by: Rob Herring (Arm) <robh@kernel.org> Link: https://lore.kernel.org/r/20260508-shikra_mailbox_and_rpm_changes-v3-2-698f8e5fb339@oss.qualcomm.com Signed-off-by: Bjorn Andersson <andersson@kernel.org>
2026-06-08hwspinlock: qcom: avoid uninitialized struct membersWolfram Sang
The reg_field is allocated on stack, so using the REG_FIELD macro will ensure that unused members do not have uninitialized values. Fixes: 19a0f61224d2 ("hwspinlock: qcom: Add support for Qualcomm HW Mutex block") Link: https://sashiko.dev/#/patchset/20260319105947.6237-1-wsa%2Brenesas%40sang-engineering.com Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Link: https://lore.kernel.org/r/20260512091339.31085-2-wsa+renesas@sang-engineering.com Signed-off-by: Bjorn Andersson <andersson@kernel.org>
2026-06-08remoteproc: qcom: Unify user-visible "Qualcomm" nameKrzysztof Kozlowski
Various names for Qualcomm as a company are used in user-visible config options: QCOM, Qualcomm and Qualcomm Technologies. Switch to unified "Qualcomm" so it will be easier for users to identify the options when for example running menuconfig. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://lore.kernel.org/r/20260422083334.84294-2-krzysztof.kozlowski@oss.qualcomm.com Signed-off-by: Bjorn Andersson <andersson@kernel.org>
2026-06-08remoteproc: qcom: Fix leak when custom dump_segments addition failsWasim Nazir
Free allocated minidump_region 'name' in qcom_add_minidump_segments() when failing before adding the region to 'dump_segments'. Otherwise, the 'name' is not tracked and is never freed by qcom_minidump_cleanup(). Return error when adding to 'dump_segments' fails. Cc: stable@vger.kernel.org # v5.11 Fixes: 8ed8485c4f05 ("remoteproc: qcom: Add capability to collect minidumps") Reviewed-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com> Signed-off-by: Wasim Nazir <wasim.nazir@oss.qualcomm.com> Link: https://lore.kernel.org/r/20260318-rproc-memleak-v2-1-ade70ab858f2@oss.qualcomm.com Signed-off-by: Bjorn Andersson <andersson@kernel.org>
2026-06-08remoteproc: qcom_q6v5_wcss: drop redundant wcss_q6_bcr_resetAlexandru Gagniuc
The wcss_q6_bcr_reset used on QCS404, and wcss_q6_reset used on IPQ are the same. "BCR reset" is redundant, and likely a mistake. Use the documented "wcss_q6_reset" instead. Drop ".wcss_q6_reset_required" from the descriptor, since all targets now need it. This changes the bindings expectations, however, it actually fixes the driver to consume the intended ones (qcom,q6v5.txt), which lists "wcss_q6_reset" and *not* "wcss_q6_bcr_reset" Fixes: 0af65b9b915e ("remoteproc: qcom: wcss: Add non pas wcss Q6 support for QCS404") Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Link: https://lore.kernel.org/r/20251208223315.3540680-1-mr.nuke.me@gmail.com Signed-off-by: Bjorn Andersson <andersson@kernel.org>
2026-06-08dt-bindings: remoteproc: qcom,sm8550-pas: Add Hawi CDSP compatibleMukesh Ojha
Document compatible string for the CDSP Peripheral Authentication Service on the Hawi SoC, which is compatible with the Qualcomm SM8550 SoC except for the one additional interrupt ("shutdown-ack") and similar to the Qualcomm Kaanapali SoC, "global_sync_mem" is not managed by the kernel so it remains unlisted. Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com> Acked-by: Rob Herring (Arm) <robh@kernel.org> Link: https://lore.kernel.org/r/20260427190614.3679937-2-mukesh.ojha@oss.qualcomm.com Signed-off-by: Bjorn Andersson <andersson@kernel.org>
2026-06-08dt-bindings: remoteproc: qcom,sm8550-pas: Add Hawi ADSP compatibleMukesh Ojha
Document compatible string for the ADSP Peripheral Authentication Service on the Hawi SoC, which is compatible with the Qualcomm SM8550 ADSP PAS and can fallback to SM8550 except for the one additional interrupt ("shutdown-ack"). Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com> Acked-by: Rob Herring (Arm) <robh@kernel.org> Link: https://lore.kernel.org/r/20260427190614.3679937-1-mukesh.ojha@oss.qualcomm.com Signed-off-by: Bjorn Andersson <andersson@kernel.org>
2026-06-09Merge patch series "`zerocopy` support"Miguel Ojeda
Introduce support for `zerocopy` [1][2]: Fast, safe, compile error. Pick two. Zerocopy makes zero-cost memory manipulation effortless. We write `unsafe` so you don't have to. It essentially provides derivable traits (e.g. `FromBytes`) and macros (e.g. `transmute!`) for safely converting between byte sequences and other types. Having such support allows us to remove some `unsafe` code. It is among the most downloaded Rust crates (top #50 recent, top #100 all-time downloads; according to crates.io), and it is also used by the Rust compiler itself. The series starts with a few preparation commits, then the `zerocopy` and `zerocopy-derive` crates are added. Finally, an example patch using it is on top, removing one `unsafe impl`. I had to adapt the crates slightly (just +2/-3 lines), but both patches could potentially be provided upstream eventually. Please see the commits for details. In total, it is about ~39k lines added, ~32k without counting `benches/` which are just for documentation purposes. See the cover letter for `syn` for some more details about depending on third-party crates in commit 54e3eae85562 ("Merge patch series "`syn` support""). The codegen of an isolated example function similar to the patch on top is essentially identical. It also turns out that (for that particular case) `zerocopy`'s version, even under `debug-assertions` enabled, has no remaining panics, unlike a few in the current code (because the compiler can prove the remaining `ub_checks` statically). So their "fast, safe" does indeed check out -- at least in that case. P.S. This version of `zerocopy` has already the unstable `Ptr{,Inner}` types -- to play with them, please use: make ... KRUSTFLAGS=--cfg=zerocopy_unstable_ptr Link: https://github.com/google/zerocopy [1] Link: https://docs.rs/zerocopy [2] Link: https://patch.msgid.link/20260608141439.182634-1-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-08if_ether.h: add 802.1AC, warn about GRE 0x00FEDavid 'equinox' Lamparter
Because LLC wasn't complicated/annoying enough, there's 2 more "ethertypes" being used for it: - 0x8870 is pretty "normal", it got standardized in 802.1AC-2016/Cor1-2018 for transporting LLC frames > 1500 bytes. It simply replaces the length value (which is no longer encoded, and must now be derived from the packet.) The actual value dates back to 2001; https://datatracker.ietf.org/doc/html/draft-ietf-isis-ext-eth-01 (it was used without "proper" standardization for a long time) - 0x00fe is a doozy - actually "invalid" depending on how you look at it; it's used in GRE (and possibly GENEVE) tunnels to transport the IS-IS routing protocol. https://seclists.org/tcpdump/2002/q4/61 is the best/oldest source I could find. It's inspired by the 0xfe SAP value, a GRE packet with protocol 0x00fe is followed by a payload "as if" it was Ethernet with "<length> 0xfe 0xfe 0x03". (Again the length isn't encoded explicitly anymore.) The 0x00fe value is quite close to other values the kernel is using internally for various things (after all they "won't clash for 1500 types"). Except this one does clash, and if someone unknowingly starts using it for something internal... we end up in a world of pain in getting IS-IS running on GRE tunnels. Hence the "WARNING". Signed-off-by: David 'equinox' Lamparter <equinox@diac24.net> Cc: Andrew Lunn <andrew+netdev@lunn.ch> Link: https://patch.msgid.link/20260605164144.81184-1-equinox@diac24.net Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-06-09gpu: nova-core: firmware: parse `FalconUCodeDescV2` via `zerocopy`Miguel Ojeda
Now that we have `zerocopy` support, we can avoid some `unsafe` code. For instance, for `FalconUCodeDescV2`, we can replace the `unsafe impl FromBytes` by safely deriving `zerocopy`'s `FromBytes` and then calling `read_from_prefix`. Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Acked-by: Danilo Krummrich <dakr@kernel.org> Link: https://patch.msgid.link/20260608141439.182634-20-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-09rust: prelude: add `zerocopy{,_derive}::FromBytes`Miguel Ojeda
In order to easily use `FromBytes`, add it to the prelude. This adds both the trait (`zerocopy::FromBytes`) as well as the derive macro (`zerocopy_derive::FromBytes`). We will be adding more as we need them. Link: https://patch.msgid.link/20260608141439.182634-19-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-09rust: zerocopy-derive: enable support in kbuildMiguel Ojeda
With all the new files in place and ready from the new crate, enable the support for it in the build system. In addition, skip formatting for this vendored crate. Link: https://patch.msgid.link/20260608141439.182634-18-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-09rust: zerocopy-derive: add `README.md`Miguel Ojeda
Originally, when the Rust upstream `alloc` standard library crate was vendored in commit 057b8d257107 ("rust: adapt `alloc` crate to the kernel"), a `README.md` file was added to explain the provenance and licensing of the source files. Thus do the same for the `zerocopy-derive` crate. Cc: Joshua Liebow-Feeser <joshlf@google.com> Cc: Jack Wrenn <jswrenn@google.com> Link: https://patch.msgid.link/20260608141439.182634-17-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-09rust: zerocopy-derive: avoid generating non-ASCII identifiersMiguel Ojeda
Linux is built with `-Dnon_ascii_idents`. However, `zerocopy-derive` uses a non-ASCII character (`ẕ`) internally, which in turn triggers the lint when attempting to use derives like `FromBytes`: error: identifier contains non-ASCII characters --> rust/kernel/lib.rs:153:9 | 153 | a: u32, | ^ | = note: requested on the command line with `-D non-ascii-idents` This was already noticed by another project using `#![deny(non_ascii_idents)]` [1]. `zerocopy` added an `#[allow(non_ascii_idents)]` [2], but it does not work since, at the moment, the `non_ascii_idents` lint is a `crate_level_only` one, and thus `allow`s only work at the crate root level. Due to this, an issue about relaxing this restriction was created in upstream Rust [3] some months ago. Thus work around it here by using another prefix. The likelihood of a collision is very small for us, since we control the callers, and this will hopefully be fixed soon at either the `zerocopy` or the Rust level. I filed an issue [4] about it with upstream `zerocopy` as requested and we discussed this with upstream Rust and `zerocopy`: the Rust issue got nominated and a PR [5] to relax the restriction was submitted by Joshua. Upstream `zerocopy` prefers that approach, so if Rust merges it, then it means we will be able to remove the workaround when we bump the MSRV, thus likely late 2027, since we follow Debian Stable. Cc: Joshua Liebow-Feeser <joshlf@google.com> Cc: Jack Wrenn <jswrenn@google.com> Link: https://github.com/google/zerocopy/issues/2880 [1] Link: https://github.com/google/zerocopy/pull/2882 [2] Link: https://github.com/rust-lang/rust/issues/151025 [3] Link: https://github.com/google/zerocopy/issues/3427 [4] Link: https://github.com/rust-lang/rust/pull/157497 [5] Link: https://patch.msgid.link/20260608141439.182634-16-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-09rust: zerocopy-derive: add SPDX License IdentifiersMiguel Ojeda
Originally, when the Rust upstream `alloc` standard library crate was vendored, the SPDX License Identifiers were added to every file so that the license on those was clear. The same happened with the vendoring of `proc_macro2`, `quote` and `syn`. Please see: commit 057b8d257107 ("rust: adapt `alloc` crate to the kernel") commit 69942c0a8965 ("rust: syn: add SPDX License Identifiers") commit ddfa1b279d08 ("rust: quote: add SPDX License Identifiers") commit a9acfceb9614 ("rust: proc-macro2: add SPDX License Identifiers") Thus do the same for the `zerocopy-derive` crate. This makes `scripts/spdxcheck.py` pass: use parentheses like commit 06e9bfc1e57d ("ionic: make spdxcheck.py happy") did since we have two `OR` operators in the expression (three licenses). Finally, as requested, I filed an issue [1] with upstream about it. Cc: Joshua Liebow-Feeser <joshlf@google.com> Cc: Jack Wrenn <jswrenn@google.com> Link: https://github.com/google/zerocopy/issues/3428 [1] Link: https://patch.msgid.link/20260608141439.182634-15-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-09rust: zerocopy-derive: import crateMiguel Ojeda
This is a subset of the Rust `zerocopy-derive` crate, version v0.8.50 (released 2026-05-31), licensed under "BSD-2-Clause OR Apache-2.0 OR MIT", from: https://github.com/google/zerocopy/tree/v0.8.50/zerocopy-derive/src The files are copied as-is, with no modifications whatsoever (not even adding the SPDX identifiers). For copyright details, please see: https://github.com/google/zerocopy/blob/v0.8.50/README.md?plain=1 https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-BSD https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-APACHE https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-MIT The next two patches modify these files as needed for use within the kernel. This patch split allows reviewers to double-check the import and to clearly see the differences introduced. The following script may be used to verify the contents: for path in $(cd rust/zerocopy-derive/ && find . -type f); do curl --silent --show-error --location \ https://github.com/google/zerocopy/raw/v0.8.50/zerocopy-derive/src/$path \ | diff --unified rust/zerocopy-derive/$path - && echo $path: OK done Cc: Joshua Liebow-Feeser <joshlf@google.com> Cc: Jack Wrenn <jswrenn@google.com> Link: https://patch.msgid.link/20260608141439.182634-14-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-09rust: zerocopy: enable support in kbuildMiguel Ojeda
With all the new files in place and ready from the new crate, enable the support for it in the build system. In addition, skip formatting for this vendored crate. Finally, there are no generated symbols expected from `zerocopy`, thus skip adding the `exports` generation. Link: https://patch.msgid.link/20260608141439.182634-13-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-09rust: zerocopy: add `README.md`Miguel Ojeda
Originally, when the Rust upstream `alloc` standard library crate was vendored in commit 057b8d257107 ("rust: adapt `alloc` crate to the kernel"), a `README.md` file was added to explain the provenance and licensing of the source files. Thus do the same for the `zerocopy` crate. Cc: Joshua Liebow-Feeser <joshlf@google.com> Cc: Jack Wrenn <jswrenn@google.com> Link: https://patch.msgid.link/20260608141439.182634-12-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-09rust: zerocopy: remove float `Display` supportMiguel Ojeda
The kernel builds `core` with the `no_fp_fmt_parse` `--cfg`, which means we do not have support for formatting floating point primitives. However, `zerocopy` expects those implementations to exist: error[E0277]: `f32` doesn't implement `core::fmt::Display` --> rust/zerocopy/src/byteorder.rs:172:29 | 172 | $trait::fmt(&self.get(), f) | ----------- ^^^^^^^^^^^ the trait `core::fmt::Display` is not implemented for `f32` | | | required by a bound introduced by this call ... 907 | / define_type!( 908 | | An, 909 | | "A 32-bit floating point number", 910 | | F32, ... | 922 | | [] 923 | | ); | |_- in this macro invocation | = help: the following other types implement trait `core::fmt::Display`: i128 i16 i32 i64 i8 isize u128 u16 and 4 others = note: this error originates in the macro `impl_fmt_trait` which comes from the expansion of the macro `define_type` (in Nightly builds, run with -Z macro-backtrace for more info) Thus work around it by skipping those implementations in `zerocopy`. Ideally, `zerocopy` would have the equivalent of `no_fp_fmt_parse`; and, indeed, upstream just added it [1] after I filed an issue [2] about it as requested. We can try it in a future update of our vendored copy. Cc: Joshua Liebow-Feeser <joshlf@google.com> Cc: Jack Wrenn <jswrenn@google.com> Link: https://github.com/google/zerocopy/pull/3429 [1] Link: https://github.com/google/zerocopy/issues/3426 [2] Link: https://patch.msgid.link/20260608141439.182634-11-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-09rust: zerocopy: add SPDX License IdentifiersMiguel Ojeda
Originally, when the Rust upstream `alloc` standard library crate was vendored, the SPDX License Identifiers were added to every file so that the license on those was clear. The same happened with the vendoring of `proc_macro2`, `quote` and `syn`. Please see: commit 057b8d257107 ("rust: adapt `alloc` crate to the kernel") commit 69942c0a8965 ("rust: syn: add SPDX License Identifiers") commit ddfa1b279d08 ("rust: quote: add SPDX License Identifiers") commit a9acfceb9614 ("rust: proc-macro2: add SPDX License Identifiers") Thus do the same for the `zerocopy` crate. This makes `scripts/spdxcheck.py` pass: use parentheses like commit 06e9bfc1e57d ("ionic: make spdxcheck.py happy") did since we have two `OR` operators in the expression (three licenses). SPDX identifiers are not added to the `benches` files because they are included in rendered documentation. Nevertheless, the `README.md` to be added by a later commit mentions the license. Finally, as requested, I filed an issue [1] with upstream about it. Cc: Joshua Liebow-Feeser <joshlf@google.com> Cc: Jack Wrenn <jswrenn@google.com> Link: https://github.com/google/zerocopy/issues/3428 [1] Link: https://patch.msgid.link/20260608141439.182634-10-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-09rust: zerocopy: import crateMiguel Ojeda
This is a subset of the Rust `zerocopy` crate, version v0.8.50 (released 2026-05-31), licensed under "BSD-2-Clause OR Apache-2.0 OR MIT", from: https://github.com/google/zerocopy/tree/v0.8.50 The files are copied as-is, with no modifications whatsoever (not even adding the SPDX identifiers). The `benches` folder is added (i.e. not just `src` like in other cases) since the files there are included in the rendered documentation, as well as the `rustdoc` CSS style file that is needed to make those visually more understandable. For copyright details, please see: https://github.com/google/zerocopy/blob/v0.8.50/README.md?plain=1 https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-BSD https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-APACHE https://github.com/google/zerocopy/blob/v0.8.50/LICENSE-MIT The next two patches modify these files as needed for use within the kernel. This patch split allows reviewers to double-check the import and to clearly see the differences introduced. The following script may be used to verify the contents: for path in $(cd rust/zerocopy/ && find . -type f); do curl --silent --show-error --location \ https://github.com/google/zerocopy/raw/v0.8.50/$path \ | diff --unified rust/zerocopy/$path - && echo $path: OK done Cc: Joshua Liebow-Feeser <joshlf@google.com> Cc: Jack Wrenn <jswrenn@google.com> Link: https://patch.msgid.link/20260608141439.182634-9-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-09rust: kbuild: support `skip_clippy` for `rustc_procmacro`Miguel Ojeda
Certain vendored crates, like the upcoming `zerocopy-derive`, do not need to be built with Clippy since we `--cap-lints=allow` them anyway. Thus add support to skip Clippy for proc macro crates. Acked-by: Nicolas Schier <nsc@kernel.org> Link: https://patch.msgid.link/20260608141439.182634-8-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-09rust: kbuild: support per-target environment variablesMiguel Ojeda
Certain vendored crates, like the upcoming `zerocopy`, use extra environment variables (e.g. via `env!`). Thus add support to easily specify those. Acked-by: Nicolas Schier <nsc@kernel.org> Link: https://patch.msgid.link/20260608141439.182634-7-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-09rust: kbuild: define `procmacro-extension` variableMiguel Ojeda
Since we are adding one more proc macro crate (`zerocopy-derive`), we are refactoring their handling. Thus, instead of using `libmacros_extension` as the common variable to hold the extension for all of them, use a dedicated variable with a more generic name (including for its implementation). Link: https://patch.msgid.link/20260608141439.182634-6-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-09rust: kbuild: define `procmacro-name` functionMiguel Ojeda
Since we are adding one more proc macro crate (`zerocopy-derive`), we are refactoring their handling. Thus define a `procmacro-name` function and use it to fill the existing variables' values. Reviewed-by: Nicolas Schier <nsc@kernel.org> Link: https://patch.msgid.link/20260608141439.182634-5-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-09rust: sync: add `UniqueArc::as_ptr`Andreas Hindborg
Add an associated function to `UniqueArc` for getting a raw pointer. The implementation defers to the `Arc` implementation. Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20260605-unique-arc-as-ptr-v2-1-425476d2abdb@kernel.org [ Relaxed bound moving it to new `T: ?Sized` impl block. Reworded since it is not a method anymore. Added intra-doc link. - Miguel ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-09rust: kbuild: remove unused variableMiguel Ojeda
Since we are adding one more proc macro crate (`zerocopy-derive`), we are refactoring their handling. `libpin_init_internal_extension` was added to mimic the setup for `macros`, but it is not used, since the extension is expected to be the same. Thus remove it. Reviewed-by: Nicolas Schier <nsc@kernel.org> Link: https://patch.msgid.link/20260608141439.182634-4-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-09rust: inline some init methodsAlexandre Courbot
These methods should be inlined for optimization reasons. Failure to do so can also produce symbol names larger than what `modpost` or `objtool` can handle. Signed-off-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Gary Guo <gary@garyguo.net> Link: https://patch.msgid.link/20260605-nova-exports-v4-1-e948c287407c@nvidia.com Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-09rust: kbuild: show the right `quiet_cmd_rustc_procmacrolibrary`Miguel Ojeda
When Clippy is skipped, `RUSTC` should be shown in `quiet` instead of `CLIPPY` to be accurate and to avoid confusion. Thus do so, matching what we do in `quiet_cmd_rustc_library`. Fixes: 7dbe46c0b11d ("rust: kbuild: add proc macro library support") Reviewed-by: Nicolas Schier <nsc@kernel.org> Link: https://patch.msgid.link/20260608141439.182634-3-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-09scripts: generate_rust_analyzer: support passing env varsMiguel Ojeda
A future commit adding `zerocopy` support will need to pass an environment variable during its build. Thus add support for an `--envs` parameter, similar to `--cfgs`, that allows to pass a map of variables to set for a given crate. This allows us to keep a single source of truth for those values. No change intended in the generated `rust-project.json`. Acked-by: Tamir Duberstein <tamird@kernel.org> Link: https://patch.msgid.link/20260608141439.182634-2-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-09rust: io: use the `bitfield!` macro in `register!`Alexandre Courbot
Replace the local bitfield rules by the equivalent invocation of the `bitfield!` macro. No functional change should be introduced as the `bitfield!` macro has been extracted from the rules of `register!`. Acked-by: Yury Norov <yury.norov@gmail.com> Acked-by: Danilo Krummrich <dakr@kernel.org> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Yury Norov <ynorov@nvidia.com> Link: https://patch.msgid.link/20260606-bitfield-v5-3-b92188820914@nvidia.com Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-09rust: bitfield: Add KUnit tests for bitfieldJoel Fernandes
Add KUnit tests to make sure the macro is working correctly. The unit tests are put behind the new `RUST_BITFIELD_KUNIT_TEST` Kconfig option. Acked-by: Danilo Krummrich <dakr@kernel.org> Reviewed-by: Eliot Courtney <ecourtney@nvidia.com> Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com> [acourbot: - Use a consistent test axis where each test focuses on a single thing. - Rename members to generic name including range for readability. - Add test exercising `try_with`. - Add test checking that unallocated bits are left untouched. ] Co-developed-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Yury Norov <ynorov@nvidia.com> Link: https://patch.msgid.link/20260606-bitfield-v5-2-b92188820914@nvidia.com [ Prefixed test suite name with `rust_` as mentioned. Markdown-formatted a few comments with Markdown. - Miguel ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-09rust: extract `bitfield!` macro from `register!`Alexandre Courbot
Extract the bitfield-defining part of the `register!` macro into an independent macro used to define bitfield types with bounds-checked accessors. Each field is represented as a `Bounded` of the appropriate bit width, ensuring field values are never silently truncated. Fields can optionally be converted to/from custom types, either fallibly or infallibly. Appropriate documentation is also added, and a MAINTAINERS entry created for the new module. Two minor fixups are also applied: the private accessors are inlined, and a couple of missing fully qualified types in the macro are fixed. Acked-by: Yury Norov <ynorov@nvidia.com> Acked-by: Danilo Krummrich <dakr@kernel.org> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Yury Norov <ynorov@nvidia.com> Link: https://patch.msgid.link/20260606-bitfield-v5-1-b92188820914@nvidia.com [ Added some more intra-doc links. - Miguel ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-06-08net: garp: reload skb header pointers after pskb_may_pull()David Carlier
garp_pdu_parse_attr() keeps a pointer into the skb linear area across pskb_may_pull(skb, ga->len), and garp_pdu_parse_msg() dereferences gm on every loop iteration even though the nested parse may pull again. pskb_may_pull() can reallocate the skb head, which would leave those pointers stale. This is not reachable today: GARP PDUs arrive via the 802.2 LLC SAP path, where llc_fixup_skb() already pulls and trims the whole payload into the linear area, so the inner pulls never reallocate. Reload ga after the pull and snapshot gm->attrtype into a local anyway, to harden the parser and match the skb_header_pointer() discipline used by mrp.c. No functional change. Signed-off-by: David Carlier <devnexen@gmail.com> Link: https://patch.msgid.link/20260604141925.237746-1-devnexen@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-06-08ipv6: sit: reload inner IPv6 header after GSO offloadsKyle Zeng
ipip6_tunnel_xmit() caches the inner IPv6 header pointer at function entry and continues using it after iptunnel_handle_offloads(). For GSO skbs, iptunnel_handle_offloads() calls skb_header_unclone(). When the skb header is cloned, skb_header_unclone() can call pskb_expand_head(), which may move the skb head. The pskb_expand_head() contract requires pointers into the skb header to be reloaded after the call. If the later skb_realloc_headroom() branch is not taken, SIT uses the stale iph6 pointer to read the inner hop limit and DS field. That can read from a freed skb head after the old head's remaining clone is released. Reload iph6 after the offload helper succeeds and before subsequent reads from the inner IPv6 header. Keep the existing reload after skb_realloc_headroom(), since that branch can also replace the skb. Fixes: 14909664e4e1 ("sit: Setup and TX path for sit/UDP foo-over-udp encapsulation") Signed-off-by: Kyle Zeng <kylebot@openai.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Reported-by: syzbot+6eb9ca986d80f6f88cf9@syzkaller.appspotmail.com Link: https://patch.msgid.link/20260605073448.6524-1-kylebot@openai.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>