Re: [PATCH v2] rust: file: handle fd table teardown in file descriptor APIs

From: Al Viro

Date: Tue Sep 29 2026 - 09:55:39 EST


On Tue, Sep 29, 2026 at 01:24:45PM +0100, Gary Guo wrote:

> > In particular, ->release() mentioned upthread should not be allowed
> > to access _anything_ hanging off current, not just descriptor table. Note
> > that the last reference to an opened file might be sitting in an SCM_RIGHTS
> > datagram pruned by AF_UNIX garbage collector; as far as the method is concerned,
> > it might be called from random thread.
>
> This part is protected -- we mark FileDescriptionReservation as `!Send` which
> prevents it being moved to another task. We also take care to make sure that
> the task returned `current!()` is not allowed to be used outside the current
> task.

Not the point - ->release() can't make any assumptions regarding which thread
it will be run in. current won't change under it, but there's nothing
useful you could want with it. If it has non-NULL ->files (or ->mm, or...),
that reference will also remain stable, but any attempt to do anything with
it would be a bug.