Skip to content

rust: file: handle fd table teardown in file descriptor APIs - #2646

Closed
vfsci-bot[bot] wants to merge 1 commit into
vfs.base.cifrom
pw/1169889/vfs.base.ci
Closed

vfsci-bot[bot] wants to merge 1 commit into
vfs.base.cifrom
pw/1169889/vfs.base.ci

Conversation

@vfsci-bot

@vfsci-bot vfsci-bot Bot commented Sep 20, 2026

Copy link
Copy Markdown

Series: https://patchwork.kernel.org/project/linux-fsdevel/list/?series=1169889
Submitter: Georgios Androutsopoulos
Version: 1
Patches: 1/1
Message-ID: <20260920200154.1194983-1-georgeandrout13@gmail.com>
Base: vfs.base.ci
Lore: https://lore.kernel.org/linux-fsdevel/20260920200154.1194983-1-georgeandrout13@gmail.com


Automated by ml2pr

Several Rust file descriptor APIs rely on `current->files` being
available. However, `exit_files()` clears it while execution may still
continue on the same task.

This affects `LocalFile::fget()` and the
`FileDescriptorReservation` operations that call
`get_unused_fd_flags()`, `fd_install()`, and `put_unused_fd()`.
`FileDescriptorReservation` cannot cross task boundaries, but remaining
on the same task does not guarantee that `current->files` is still
available when these operations are performed.

Guard the affected operations against a missing `current->files`.
`LocalFile::fget()` returns `EBADF` and
`FileDescriptorReservation::get_unused_fd_flags()` returns `EMFILE`.
For the infallible `fd_install()` and drop paths, warn once and avoid
calling the corresponding C helper when the fd table is already gone.

This prevents NULL dereferences through these safe Rust APIs after
`exit_files()`.

Fixes: 8518498 ("rust: file: add Rust abstraction for `struct file`")
Fixes: 5da9857 ("rust: file: add `FileDescriptorReservation`")
Closes: Rust-for-Linux/linux#1256
Signed-off-by: Georgios Androutsopoulos <georgeandrout13@gmail.com>
@vfsci-bot

vfsci-bot Bot commented Sep 23, 2026

Copy link
Copy Markdown
Author

Superseded by series 1171773 (v2). Closing automatically.


Automated by ml2pr

@vfsci-bot vfsci-bot Bot closed this Sep 23, 2026
@vfsci-bot
vfsci-bot Bot deleted the pw/1169889/vfs.base.ci branch September 23, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant