Skip to contentSkip to conversation

UDF symlink pathComponent header OOB read

PATCH In review David Lee 2 participants 2 messages Jul 17 UDF filesystem

lore
Share & tools
lore

David Lee

author
#0 lore raw

PATCH 1/1 UDF symlink pathComponent header OOB read

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")
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(+)
fs/udf/symlink.c +2 -0
index fe03745..a05d188 100644
@@ -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) {
#1 lore raw
Quoted 9 lines · David Lee

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")
Assisted-by Codex:gpt-5.5

Thanks! I've added the patch to my tree.

Honza

Quoted 20 lines

---
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(+)
fs/udf/symlink.c +2 -0
index fe03745..a05d188 100644
@@ -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) {
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR