From: luca.boccassi@gmail.com
To: kexec@lists.infradead.org
Cc: linux-mm@kvack.org, graf@amazon.com, rppt@kernel.org,
pasha.tatashin@soleen.com, pratyush@kernel.org,
Luca Boccassi <luca.boccassi@gmail.com>
Subject: [PATCH] liveupdate: truncate getfile name to NAME_MAX
Date: Tue, 31 Mar 2026 18:54:32 +0100 [thread overview]
Message-ID: <20260331175456.4065874-1-luca.boccassi@gmail.com> (raw)
From: Luca Boccassi <luca.boccassi@gmail.com>
dynamic_dname() harcodes its limit to NAME_MAX bytes, which includes a
NUL terminator and a 'anon_inode:' prefix. If the name passed on goes
above the limit it results in userspace getting a ENAMETOOLONG error.
Truncate the name to NAME_MAX - 12 - 1 characters to ensure this never
fails (accounting for prefix and NUL).
Fixes: 0153094d03df ("liveupdate: luo_session: add sessions support")
Signed-off-by: Luca Boccassi <luca.boccassi@gmail.com>
---
Builds on top of this just sent by Aleksa:
https://lore.kernel.org/linux-fsdevel/20260401-dynamic-dname-name_max-v1-1-8ca20ab2642e@amutable.com/
kernel/liveupdate/luo_session.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/kernel/liveupdate/luo_session.c b/kernel/liveupdate/luo_session.c
index 7836772956406..4a40c7fdfb44f 100644
--- a/kernel/liveupdate/luo_session.c
+++ b/kernel/liveupdate/luo_session.c
@@ -366,11 +366,14 @@ static const struct file_operations luo_session_fops = {
/* Create a "struct file" for session */
static int luo_session_getfile(struct luo_session *session, struct file **filep)
{
- char name_buf[128];
+ char name_buf[NAME_MAX];
struct file *file;
lockdep_assert_held(&session->mutex);
- snprintf(name_buf, sizeof(name_buf), "[luo_session] %s", session->name);
+ /* dynamic_dname() rejects names above NAME_MAX bytes, including NUL terminator
+ * and a 'anon_inode:' prefix. Truncate to NAME_MAX - 12 - 1 to avoid
+ * ENAMETOOLONG. */
+ snprintf(name_buf, NAME_MAX - 12 - 1, "[luo_session] %s", session->name);
file = anon_inode_getfile(name_buf, &luo_session_fops, session, O_RDWR);
if (IS_ERR(file))
return PTR_ERR(file);
--
2.47.3
next reply other threads:[~2026-03-31 17:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 17:54 luca.boccassi [this message]
2026-03-31 18:21 ` [PATCH] liveupdate: truncate getfile name to NAME_MAX Pasha Tatashin
2026-03-31 18:30 ` Luca Boccassi
2026-03-31 19:13 ` Pasha Tatashin
2026-03-31 19:40 ` Luca Boccassi
2026-03-31 19:57 ` Pasha Tatashin
2026-03-31 20:09 ` Luca Boccassi
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=20260331175456.4065874-1-luca.boccassi@gmail.com \
--to=luca.boccassi@gmail.com \
--cc=graf@amazon.com \
--cc=kexec@lists.infradead.org \
--cc=linux-mm@kvack.org \
--cc=pasha.tatashin@soleen.com \
--cc=pratyush@kernel.org \
--cc=rppt@kernel.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