From: Samuel Moelius via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: open list <linux-kernel@vger.kernel.org>,
Samuel Moelius <sam.moelius@trailofbits.com>,
"open list:F2FS FILE SYSTEM"
<linux-f2fs-devel@lists.sourceforge.net>
Subject: [f2fs-dev] [PATCH] f2fs: validate inline dentry name lengths before conversion
Date: Wed, 3 Jun 2026 15:49:32 +0000 [thread overview]
Message-ID: <20260603154933.16368-1-sam.moelius@trailofbits.com> (raw)
Inline dentry conversion copies names out of the inline dentry area
before checking that each recorded name length fits in the available
filename slots.
A corrupted image can therefore make the conversion path read past
the inline filename storage while building the regular dentry block.
Validate each inline dentry name length against the inline filename
area before copying it.
Assisted-by: Codex:gpt-5.5-cyber-preview
Signed-off-by: Samuel Moelius <sam.moelius@trailofbits.com>
---
fs/f2fs/inline.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 7aabfc9b43cb..4584dfbe3fb8 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -507,6 +507,10 @@ static int f2fs_add_inline_entries(struct inode *dir, void *inline_dentry)
bit_pos++;
continue;
}
+ if (unlikely(le16_to_cpu(de->name_len) > F2FS_NAME_LEN ||
+ bit_pos + GET_DENTRY_SLOTS(le16_to_cpu(de->name_len)) >
+ d.max))
+ return -EFSCORRUPTED;
/*
* We only need the disk_name and hash to move the dentry.
--
2.43.0
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
WARNING: multiple messages have this Message-ID (diff)
From: Samuel Moelius <sam.moelius@trailofbits.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Samuel Moelius <sam.moelius@trailofbits.com>,
Chao Yu <chao@kernel.org>,
linux-f2fs-devel@lists.sourceforge.net (open list:F2FS FILE
SYSTEM), linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] f2fs: validate inline dentry name lengths before conversion
Date: Wed, 3 Jun 2026 15:49:32 +0000 [thread overview]
Message-ID: <20260603154933.16368-1-sam.moelius@trailofbits.com> (raw)
Inline dentry conversion copies names out of the inline dentry area
before checking that each recorded name length fits in the available
filename slots.
A corrupted image can therefore make the conversion path read past
the inline filename storage while building the regular dentry block.
Validate each inline dentry name length against the inline filename
area before copying it.
Assisted-by: Codex:gpt-5.5-cyber-preview
Signed-off-by: Samuel Moelius <sam.moelius@trailofbits.com>
---
fs/f2fs/inline.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 7aabfc9b43cb..4584dfbe3fb8 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -507,6 +507,10 @@ static int f2fs_add_inline_entries(struct inode *dir, void *inline_dentry)
bit_pos++;
continue;
}
+ if (unlikely(le16_to_cpu(de->name_len) > F2FS_NAME_LEN ||
+ bit_pos + GET_DENTRY_SLOTS(le16_to_cpu(de->name_len)) >
+ d.max))
+ return -EFSCORRUPTED;
/*
* We only need the disk_name and hash to move the dentry.
--
2.43.0
next reply other threads:[~2026-06-03 15:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 15:49 Samuel Moelius via Linux-f2fs-devel [this message]
2026-06-03 15:49 ` [PATCH] f2fs: validate inline dentry name lengths before conversion Samuel Moelius
2026-06-15 3:14 ` Chao Yu
2026-06-15 3:14 ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2026-06-15 15:24 ` Jaegeuk Kim
2026-06-15 15:24 ` [f2fs-dev] " Jaegeuk Kim via Linux-f2fs-devel
-- strict thread matches above, loose matches on Subject: below --
2026-06-03 15:11 Samuel Moelius via Linux-f2fs-devel
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=20260603154933.16368-1-sam.moelius@trailofbits.com \
--to=linux-f2fs-devel@lists.sourceforge.net \
--cc=jaegeuk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sam.moelius@trailofbits.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.