fs/udf/symlink.c | 2 ++ 1 file changed, 2 insertions(+)
udf_symlink_filler() can enter udf_pc_to_char() with a partial pathComponent header.
Validate that enough input remains for a complete pathComponent header
before accessing it. Reject malformed symlink data that would otherwise
make udf_pc_to_char() perform an out-of-bounds read.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: David Lee <david.lee@trailofbits.com>
Assisted-by: Codex:gpt-5.5
---
Trail of Bits has a reproducer that triggers a kernel panic demonstrating
this bug and can share it if needed.
fs/udf/symlink.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/udf/symlink.c b/fs/udf/symlink.c
index fe03745..a05d188 100644
--- a/fs/udf/symlink.c
+++ b/fs/udf/symlink.c
@@ -36,6 +36,8 @@ static int udf_pc_to_char(struct super_block *sb, unsigned char *from,
/* Reserve one byte for terminating \0 */
tolen--;
while (elen < fromlen) {
+ if (fromlen - elen < sizeof(struct pathComponent))
+ return -EIO;
pc = (struct pathComponent *)(from + elen);
elen += sizeof(struct pathComponent);
switch (pc->componentType) {
On Fri 17-07-26 10:47:21, David Lee wrote:
> udf_symlink_filler() can enter udf_pc_to_char() with a partial pathComponent header.
>
> Validate that enough input remains for a complete pathComponent header
> before accessing it. Reject malformed symlink data that would otherwise
> make udf_pc_to_char() perform an out-of-bounds read.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: David Lee <david.lee@trailofbits.com>
> Assisted-by: Codex:gpt-5.5
Thanks! I've added the patch to my tree.
Honza
> ---
> Trail of Bits has a reproducer that triggers a kernel panic demonstrating
> this bug and can share it if needed.
>
> fs/udf/symlink.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/udf/symlink.c b/fs/udf/symlink.c
> index fe03745..a05d188 100644
> --- a/fs/udf/symlink.c
> +++ b/fs/udf/symlink.c
> @@ -36,6 +36,8 @@ static int udf_pc_to_char(struct super_block *sb, unsigned char *from,
> /* Reserve one byte for terminating \0 */
> tolen--;
> while (elen < fromlen) {
> + if (fromlen - elen < sizeof(struct pathComponent))
> + return -EIO;
> pc = (struct pathComponent *)(from + elen);
> elen += sizeof(struct pathComponent);
> switch (pc->componentType) {
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
© 2016 - 2026 Red Hat, Inc.