From: sashiko-bot@kernel.org
To: "Chris Down" <chris@chrisdown.name>,
"Pasha Tatashin" <pasha.tatashin@soleen.com>,
"Mike Rapoport" <rppt@kernel.org>,
"Pratyush Yadav" <pratyush@kernel.org>
Cc: "Alexander Graf" <graf@amazon.com>,
"Baoquan He" <baoquan.he@linux.dev>,
"Jonathan Corbet" <corbet@lwn.net>,
"Shuah Khan" <skhan@linuxfoundation.org>,
kexec@lists.infradead.org, linux-mm@kvack.org,
kernel-team@meta.com
Subject: Re: [PATCH 3/9] liveupdate: Make failed retrieves distinguishable from dropped files
Date: Thu, 12 Nov 2026 07:54:08 +0000 [thread overview]
Message-ID: <sashiko-outbox-210639@kernel.org> (raw)
In-Reply-To: <772c150d0a90139a327803cecf087f6865702753.1794383544.git.chris@chrisdown.name>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 2 related pre-existing issues it does not
introduce:
- [Critical] liveupdate: uninitialized file pointer in
luo_session_retrieve_fd() [1]
- [High] liveupdate: pointer used as XArray index in luo_preserve_file()
[2]
--
commit acd081aa3a5ef33bac09be5e151d1de15512ea3e
Author: Chris Down <chris@chrisdown.name>
liveupdate: Make failed retrieves distinguishable from dropped files
This commit exposes incoming live update deserialization state and session
and file retrieval counters under /sys/class/misc/liveupdate/incoming/.
> diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c
> index a39992da504fb..3aac1afa05c09 100644
> --- a/kernel/liveupdate/luo_file.c
> +++ b/kernel/liveupdate/luo_file.c
> @@ -543,6 +543,16 @@ void luo_file_unfreeze(struct luo_file_set *file_set,
> memset(file_set_ser, 0, sizeof(*file_set_ser));
> }
>
> +/* Record the first retrieve result. A negative status is permanent. */
> +static void luo_file_set_retrieve_status(struct luo_file *luo_file, int status)
> +{
> + luo_file->retrieve_status = status;
> + if (status > 0)
> + atomic_long_inc(&luo_incoming_stats.files_retrieved);
> + else
> + atomic_long_inc(&luo_incoming_stats.files_failed);
> +}
> +
> /**
> * luo_retrieve_file - Restores a preserved file from a file_set by its token.
> * @file_set: The file_set from which to retrieve the file.
> @@ -611,7 +621,7 @@ int luo_retrieve_file(struct luo_file_set *file_set, u64 token,
> err = luo_file->fh->ops->retrieve(&args);
> if (err) {
> /* Keep the error code for later use. */
> - luo_file->retrieve_status = err;
> + luo_file_set_retrieve_status(luo_file, err);
> return err;
> }
[Severity: Critical]
This problem wasn't introduced by this patch, but can a positive return from
fh->ops->retrieve() cause luo_session_retrieve_fd() to pass an uninitialized
struct file pointer to fd_install() [1]?
If fh->ops->retrieve() returns a positive value, luo_retrieve_file() returns
without initializing *filep (and luo_file_set_retrieve_status() records it as
a retrieved file with status > 0). luo_session_retrieve_fd() only checks
for negative errors before installing the stack variable into the process
file descriptor table:
kernel/liveupdate/luo_session.c:luo_session_retrieve_fd() {
...
struct file *file;
...
err = luo_retrieve_file(&session->file_set, argp->token, &file);
mutex_unlock(&session->mutex);
if (err < 0)
goto err_put_fd;
err = luo_ucmd_respond(ucmd, sizeof(*argp));
if (err)
goto err_put_file;
fd_install(argp->fd, file);
}
luo_ioctl_retrieve_session() has the same pattern with luo_session_retrieve().
Any subsequent syscall on the installed fd dereferences the uninitialized
stack pointer.
> @@ -624,7 +634,7 @@ int luo_retrieve_file(struct luo_file_set *file_set, u64 token,
> luo_file->file, GFP_KERNEL));
>
> *filep = luo_file->file;
> - luo_file->retrieve_status = 1;
> + luo_file_set_retrieve_status(luo_file, 1);
>
> return 0;
> }
[Severity: High]
This problem wasn't introduced by this patch, but why does
luo_preserved_files use raw kernel pointers from luo_get_id() as XArray
indices [2]?
kernel/liveupdate/luo_file.c:luo_get_id() {
return fh->ops->get_id ? fh->ops->get_id(file) : (unsigned long)file;
}
Both luo_preserve_file() and luo_retrieve_file() pass luo_get_id() directly
as the index to xa_insert(&luo_preserved_files, ...). Because XArray is a
radix tree designed for dense small integer indices, indexing it by sparse
64-bit pointer values forces the allocation of up to 11 levels of
intermediate tree nodes per entry, wasting memory and risking OOM.
[1] https://sashiko.dev/#/bug/linux-65e3446e-27d6-4415-82bb-0036dcc7aa0b
[2] https://sashiko.dev/#/bug/linux-80cdb953-2e71-4aca-9067-108b66f83aaa
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1794383544.git.chris@chrisdown.name?part=3
next prev parent reply other threads:[~2026-11-12 7:54 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 7:52 [PATCH 0/9] kho, liveupdate: KHO/LUO observability Chris Down
2026-11-11 7:52 ` [PATCH 1/9] kho: Reclaim the metadata page left reserved after kexec Chris Down
2026-11-11 11:08 ` Breno Leitao
2026-11-11 22:29 ` Pasha Tatashin
2026-11-12 7:54 ` sashiko-bot
2026-11-11 7:53 ` [PATCH 2/9] kho: Make bootmem reservations visible to fleet monitoring Chris Down
2026-11-11 23:14 ` Pasha Tatashin
2026-11-12 7:54 ` sashiko-bot
2026-11-11 7:53 ` [PATCH 3/9] liveupdate: Make failed retrieves distinguishable from dropped files Chris Down
2026-11-12 7:54 ` sashiko-bot [this message]
2026-11-11 7:53 ` [PATCH 4/9] selftests/liveupdate: Catch incorrect file accounting across kexec Chris Down
2026-11-12 7:54 ` sashiko-bot
2026-11-11 7:53 ` [PATCH 5/9] selftests/kho: Catch missing or zero bootmem reports before kexec Chris Down
2026-11-12 7:54 ` sashiko-bot
2026-11-11 7:53 ` [PATCH 6/9] kho: Expose rejected handovers that look like cold boots Chris Down
2026-11-12 7:54 ` sashiko-bot
2026-11-11 7:53 ` [PATCH 7/9] kho: Report how much handover memory is preserved and restored Chris Down
2026-11-12 7:54 ` sashiko-bot
2026-11-11 7:53 ` [PATCH 8/9] liveupdate: Expose the sequence number for consecutive live updates Chris Down
2026-11-12 7:54 ` sashiko-bot
2026-11-11 7:53 ` [PATCH 9/9] selftests/liveupdate: Check handover revival, sequence and memory stats Chris Down
2026-11-12 7:54 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-210639@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=baoquan.he@linux.dev \
--cc=chris@chrisdown.name \
--cc=corbet@lwn.net \
--cc=graf@amazon.com \
--cc=kernel-team@meta.com \
--cc=kexec@lists.infradead.org \
--cc=linux-mm@kvack.org \
--cc=pasha.tatashin@soleen.com \
--cc=pratyush@kernel.org \
--cc=rppt@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox