mirror of
https://github.com/torvalds/linux.git
synced 2026-10-12 05:17:15 +02:00
Linux kernel source tree
Bryam Vargas says: ==================== net/smc: close the SMC-D teardown window around the ghost send buffer Both patches only matter on the SMC-D DMB-nocopy path, where the ghost send buffer exists, and the only in-tree provider of support_mmapped_rdmb is dibs_loopback. CONFIG_DIBS_LO is default n and its help calls it a testing aid, so on a stock config neither bug is reachable. v1 moved smcd_buf_detach() after the drain. Dust Li replied that it does not fully eliminate the race and asked whether RCU is the better shape. He is right about the first part; I built both and measured them. An SMC-D loopback KASAN rig, one module binary, teardown form selected at runtime. "path" counts connections reaching either teardown site with the link group already unlinked, "armable" how many of those still had both gates in smcd_handle_irq() open when the drain returned, "re-armed" the device arming the tasklet again afterwards: form path armable re-armed upstream 169 73 29 v1 (drain, then detach) 172 78 33 unregister first, then drain 31 0 0 v1 + RCU 24 9 3 Two caveats on that table. The last two arms ran far shorter than the first two, so compare the armable/re-armed ratios rather than the absolute path counts. And the third row also forced tasklet_kill() in the !soft path, which 1/2 does not; that was inert here because smc_lgr_terminate_work() passes soft=true, so the same call ran either way. The reorder alone leaves the window open, which is what Dust saw. RCU doesn't close it either: smcd_buf_detach() both frees the descriptor and clears the field, and RCU defers only the free, so a re-armed tasklet still runs and still finds conn->sndbuf_desc NULL. The gate has to be shut before the drain, and that is 1/2. RCU on the descriptor would still be a reasonable thing to want for the free itself; it just doesn't substitute for 1/2, so I didn't fold it in. Your call if you want it anyway. Caveat on 1/2: the two changes the table covers -- unconditional smc_ism_unset_conn(), and drain before detach -- were measured together, not separately. It also clears conn->sndbuf_desc before freeing it, so a reader that samples the pointer cannot get one that is already freed; that part is by inspection. 2/2 is a second dereference the same teardown reaches, found while running the above. smc_close_stream_wait() calls smc_tx_prepared_sends() from inside sk_wait_event(), which evaluates its condition once with the socket lock released, and a terminating link group clears conn->sndbuf_desc right there. SIOCOUTQ reads the same field by hand, and smc_close_cancel_work() drops the socket lock across two cancel_*_sync() calls, so 2/2 bounds that too. Eight faults across three boots, the earliest 89 seconds in: RIP: smc_close_stream_wait+0x66d [smc] smc_close_active -> __smc_release -> smc_release -> __x64_sys_close The faulting address is NULL plus offsetof(struct smc_buf_desc, len), nothing there is attacker-chosen, and the value read never reaches userspace, so there is no memory-safety primitive and no leak oracle -- it is an oops. The task dies inside close() holding the socket lock, so I would expect the socket to leak with it, but I didn't isolate that from the rig's own effects and I'm not claiming it. Reaching either bug needs a link-group teardown while a socket is parked in that wait. smc_lgr_cleanup_early() off a failed first-contact handshake gets there, as does smc_clc_wait_msg() on a peer DECLINE with FIRST_CONTACT -- both by inspection. The rig instead drove smc_lgr_terminate_sched() from a debug module parameter, so only the initiation is synthetic; the unlink, the deferred worker, smc_conn_free() and smcd_handle_irq() are the unmodified path. Logs and the rig on request. I haven't touched tasklet_unlock_wait() in the !soft path of smc_conn_kill(). It waits out TASKLET_STATE_RUN without clearing TASKLET_STATE_SCHED, but I have no measurement showing that reachable here, so it stays as it is. ==================== Link: https://patch.msgid.link/20260808-b4-disp-22f119e6-v2-0-61647601a6f3@proton.me Signed-off-by: Jakub Kicinski <kuba@kernel.org> |
||
|---|---|---|
| arch | ||
| block | ||
| certs | ||
| crypto | ||
| Documentation | ||
| drivers | ||
| fs | ||
| include | ||
| init | ||
| io_uring | ||
| ipc | ||
| kernel | ||
| lib | ||
| LICENSES | ||
| mm | ||
| net | ||
| rust | ||
| samples | ||
| scripts | ||
| security | ||
| sound | ||
| tools | ||
| usr | ||
| virt | ||
| .clang-format | ||
| .clippy.toml | ||
| .cocciconfig | ||
| .editorconfig | ||
| .get_maintainer.ignore | ||
| .gitattributes | ||
| .gitignore | ||
| .mailmap | ||
| .pylintrc | ||
| .rustfmt.toml | ||
| COPYING | ||
| CREDITS | ||
| Kbuild | ||
| Kconfig | ||
| MAINTAINERS | ||
| Makefile | ||
| README | ||
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