mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
8ddd3a1c207f2f777f01d02110e556a187da73c6
An AMT Request has an unauthenticated, spoofable source address. Allocating tunnel state from that path allowed spoofed Requests to consume tunnel slots or overwrite the nonce and MAC of an established gateway. Keep Requests stateless by deriving the Query MAC from the source address, source port, nonce, and current secret, and retain four secret generations so a gateway can renew its MAC across rotations. Authenticate the Membership Update before decapsulation, and create or refresh tunnel state only once ip_mc_check_igmp() or ipv6_mc_check_mld() has accepted the encapsulated message. Key verified state by the address/port endpoint, enforce global and per-source limits, and silently reject an endpoint that cannot be admitted: withhold the Query rather than send ICMP Host Unreachable to a source address nothing has authenticated yet. A MAC is now accepted only for a bounded time after the Query that carried it. Before, a tunnel copied the secret when a Request created it and never saw it rotate, so its MAC never expired. Now the secret rotates every 60 seconds and four generations are kept, so a MAC is accepted for 180 to 240 seconds. RFC 7450 section 5.2.3.5.4 has a gateway start a query timer when it accepts a Query, with a duration it SHOULD compute from the Query's QQIC (125 seconds here), and section 5.2.3.5.5 has it send a new Request when that timer expires, so a gateway that times its next Request from QQIC renews its MAC inside the window. The in-tree gateway re-Requests every two seconds while its Requests are answered. A gateway that never sends another Request kept working before; now its Updates are dropped as Invalid MAC once the window has passed. So is the first Update after a new join from a gateway that, as section 5.2.3.5.4 also allows, uses a longer timer while it has no group subscriptions to report: it is dropped until that gateway's next Request. Which MACs are accepted changes too. Before, an Update had to carry the nonce and MAC of the latest Request from its address; now any pair minted for its address and port within the window is accepted. The MAC never covered the encapsulated report, so this changes only how long a pair seen by an on-path observer stays usable: off-path senders still cannot produce a valid pair. The secret is now seeded before amt_socket_create() enables the receive path. It was seeded after the socket was created since commitb9022b53ad("amt: add control plane of amt interface"), when there was no receive path yet, and commitcbc21dc1cf("amt: add data plane of amt interface") added amt_rcv() and the per-tunnel copy of the key without moving it. Since then a Request that arrived during amt_dev_open() could get a tunnel whose MAC used an all-zero key (on the first open) or the previous key for the tunnel's whole life. amt_update_tunnel() retries once when it finds its tunnel dead, and the lookup skips dead tunnels, so an Update that races amt_tunnel_expire() creates the replacement instead of being dropped. The Request path's per-source count and the re-check under amt->lock in amt_tunnel_get_or_create() skip them too. Every tunnel is now created by an Update, which stamps last_seen, so amt_tunnel_expire() no longer treats a last_seen of 0 as never refreshed. amt_tunnel_get_or_create() also rechecks netif_running() under amt->lock before it links a tunnel. dev_close() clears the running state before it calls amt_dev_stop(), which drains the list under amt->lock, so an Update still being received while the device goes down cannot link a tunnel after the drain. Every Membership Update, forged ones included, reads the secret generations to check its MAC. Their writers hold amt->lock and update them inside a seqcount, amt->key_seq. The Update path copies them in a key_seq read loop, so reading them takes amt->lock only on PREEMPT_RT, to wait for a writer. Keying by address and port lets one address hold several tunnels; before this patch the Request path looked tunnels up by address alone, so an address normally held only one. amt_max_tunnels_per_src() bounds that at an eighth of max_tunnels, at least one tunnel and at most AMT_MAX_TUNNELS_PER_SRC (16): 16 at the default 128 slots, 2 at 16. One address then holds at most an eighth of a table of eight or more slots, while gateways behind NAT still get several tunnels once the table has 16 or more slots. A configurable limit needs new uAPI, so it is left for net-next. Found by code inspection against RFC 7450; not triggered at runtime. The Sashiko AI review of an earlier posting pointed out the undocumented behaviour changes and that a fixed per-source cap let one address fill a small table. Fixes:cbc21dc1cf("amt: add data plane of amt interface") Signed-off-by: Omar Ramadan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
…
Linux kernel ============ The Linux kernel is the core of any Linux operating system. It manages hardware, system resources, and provides the fundamental services for all other software. Quick Start ----------- * Report a bug: See Documentation/admin-guide/reporting-issues.rst * Get the latest kernel: https://kernel.org * Build the kernel: See Documentation/admin-guide/quickly-build-trimmed-linux.rst * Join the community: https://lore.kernel.org/ Essential Documentation ----------------------- All users should be familiar with: * Building requirements: Documentation/process/changes.rst * Code of Conduct: Documentation/process/code-of-conduct.rst * License: See COPYING Documentation can be built with make htmldocs or viewed online at: https://www.kernel.org/doc/html/latest/ Who Are You? ============ Find your role below: * New Kernel Developer: Getting started with kernel development * Academic Researcher: Studying kernel internals and architecture * Security Expert: Hardening and vulnerability analysis * Backport/Maintenance Engineer: Maintaining stable kernels * System Administrator: Configuring and troubleshooting * Maintainer: Leading subsystems and reviewing patches * Hardware Vendor: Writing drivers for new hardware * Distribution Maintainer: Packaging kernels for distros * AI Coding Assistant: LLMs and AI-powered development tools For Specific Users ================== New Kernel Developer -------------------- Welcome! Start your kernel development journey here: * Getting Started: Documentation/process/development-process.rst * Your First Patch: Documentation/process/submitting-patches.rst * Coding Style: Documentation/process/coding-style.rst * Build System: Documentation/kbuild/index.rst * Development Tools: Documentation/dev-tools/index.rst * Kernel Hacking Guide: Documentation/kernel-hacking/hacking.rst * Core APIs: Documentation/core-api/index.rst Academic Researcher ------------------- Explore the kernel's architecture and internals: * Researcher Guidelines: Documentation/process/researcher-guidelines.rst * Memory Management: Documentation/mm/index.rst * Scheduler: Documentation/scheduler/index.rst * Networking Stack: Documentation/networking/index.rst * Filesystems: Documentation/filesystems/index.rst * RCU (Read-Copy Update): Documentation/RCU/index.rst * Locking Primitives: Documentation/locking/index.rst * Power Management: Documentation/power/index.rst Security Expert --------------- Security documentation and hardening guides: * Security Documentation: Documentation/security/index.rst * LSM Development: Documentation/security/lsm-development.rst * Self Protection: Documentation/security/self-protection.rst * Reporting Vulnerabilities: Documentation/process/security-bugs.rst * CVE Procedures: Documentation/process/cve.rst * Embargoed Hardware Issues: Documentation/process/embargoed-hardware-issues.rst * Security Features: Documentation/userspace-api/seccomp_filter.rst Backport/Maintenance Engineer ----------------------------- Maintain and stabilize kernel versions: * Stable Kernel Rules: Documentation/process/stable-kernel-rules.rst * Backporting Guide: Documentation/process/backporting.rst * Applying Patches: Documentation/process/applying-patches.rst * Subsystem Profile: Documentation/maintainer/maintainer-entry-profile.rst * Git for Maintainers: Documentation/maintainer/configure-git.rst System Administrator -------------------- Configure, tune, and troubleshoot Linux systems: * Admin Guide: Documentation/admin-guide/index.rst * Kernel Parameters: Documentation/admin-guide/kernel-parameters.rst * Sysctl Tuning: Documentation/admin-guide/sysctl/index.rst * Tracing/Debugging: Documentation/trace/index.rst * Performance Security: Documentation/admin-guide/perf-security.rst * Hardware Monitoring: Documentation/hwmon/index.rst Maintainer ---------- Lead kernel subsystems and manage contributions: * Maintainer Handbook: Documentation/maintainer/index.rst * Pull Requests: Documentation/maintainer/pull-requests.rst * Managing Patches: Documentation/maintainer/modifying-patches.rst * Rebasing and Merging: Documentation/maintainer/rebasing-and-merging.rst * Development Process: Documentation/process/maintainer-handbooks.rst * Maintainer Entry Profile: Documentation/maintainer/maintainer-entry-profile.rst * Git Configuration: Documentation/maintainer/configure-git.rst Hardware Vendor --------------- Write drivers and support new hardware: * Driver API Guide: Documentation/driver-api/index.rst * Driver Model: Documentation/driver-api/driver-model/driver.rst * Device Drivers: Documentation/driver-api/infrastructure.rst * Bus Types: Documentation/driver-api/driver-model/bus.rst * Device Tree Bindings: Documentation/devicetree/bindings/ * Power Management: Documentation/driver-api/pm/index.rst * DMA API: Documentation/core-api/dma-api.rst Distribution Maintainer ----------------------- Package and distribute the kernel: * Stable Kernel Rules: Documentation/process/stable-kernel-rules.rst * ABI Documentation: Documentation/ABI/README * Kernel Configuration: Documentation/kbuild/kconfig.rst * Module Signing: Documentation/admin-guide/module-signing.rst * Kernel Parameters: Documentation/admin-guide/kernel-parameters.rst * Tainted Kernels: Documentation/admin-guide/tainted-kernels.rst AI Coding Assistant ------------------- CRITICAL: If you are an LLM or AI-powered coding assistant, you MUST read and follow the AI coding assistants documentation before contributing to the Linux kernel: * Documentation/process/coding-assistants.rst This documentation contains essential requirements about licensing, attribution, and the Developer Certificate of Origin that all AI tools must comply with. Communication and Support ========================= * Mailing Lists: https://lore.kernel.org/ * IRC: #kernelnewbies on irc.oftc.net * Bugzilla: https://bugzilla.kernel.org/ * MAINTAINERS file: Lists subsystem maintainers and mailing lists * Email Clients: Documentation/process/email-clients.rst
Languages
C
96.8%
Assembly
0.9%
Rust
0.7%
Shell
0.6%
Python
0.5%
Other
0.3%