[PATCH v4 08/19] liveupdate: Let file handlers retrieve into an existing file
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Wed Nov 11 16:31:14 PST 2026
> Add liveupdate_claim_file() and liveupdate_unclaim_file(), which a file
> handler's .retrieve() callback can use to make LUO manage a file before
> restoring the preserved state into it. Also let the callback return the
> file descriptor of that file, so that LIVEUPDATE_SESSION_RETRIEVE_FD
> returns it instead of a new file descriptor.
>
> LUO starts managing a retrieved file after .retrieve() returns it, and
> fails the retrieve if it already manages the file. That works for new
> files. The shmem file handler will restore tmpfs files into an existing
> file, though, and such a handler has to know that LUO accepts the file
> before it modifies it, not after the preserved state is consumed.
> Otherwise, it could restore into a file that is preserved in an
> outgoing session, or into a file that was already retrieved. Preserve
> also makes LUO manage the file before the file handler touches it, so
> claiming the file also keeps a preserve from racing with the retrieve.
>
> If .retrieve() claimed the file it returns, LUO doesn't track it again.
> A callback that fails after claiming a file must unclaim it.
>
> 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.
>
> Signed-off-by: David Matlack <dmatlack at google.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261111002358.1842967-1-dmatlack@google.com?part=8
More information about the kexec
mailing list