Re: [PATCH v4 08/19] liveupdate: Let file handlers retrieve into an existing file

From: Christian Brauner

Date: Fri Nov 20 2026 - 04:23:48 EST


On Wed, Nov 11, 2026 at 12:23:46AM +0000, David Matlack wrote:
> A file that is restored into an existing file is already open in the
> caller, so installing a new file descriptor for it would just leave
> userspace with two file descriptors for the same open file. Retrieving
> the token again later still returns a new file descriptor, like for any
> other file that was already retrieved.

Thanks, this looks way better.

One thing: Please just install a new fd like for every other retrieve.
I think it's pretty meaningless to return the fd number the userspace
just passed to the ioctl.

The fd number is also not useful as it's not tied to anything. The shmem
handler looks the fd up once and LUO keeps a reference to the struct
file:

CLASS(fd, target)(arg->fd);
[...]
args->file = get_file(file);
args->fd = arg->fd;

Which means, another thread can close() that fd or dup2() something else
over it before the ioctl returns and the fd you hand back refers to a
different file fucking over the caller (shared fdtable etc pp).

That also gets rid of @fd in struct liveupdate_file_op_args and the
special case in luo_session_retrieve_fd(). And a retrieve into an
existing file then behaves exactly like retrieving the token again.