Linux-f2fs-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] f2fs: validate inline dentry name lengths before conversion
@ 2026-06-03 15:11 Samuel Moelius via Linux-f2fs-devel
  0 siblings, 0 replies; 5+ messages in thread
From: Samuel Moelius via Linux-f2fs-devel @ 2026-06-03 15:11 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Samuel Moelius, open list, open list:F2FS FILE SYSTEM

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 <samuel.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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [f2fs-dev] [PATCH] f2fs: validate inline dentry name lengths before conversion
@ 2026-06-03 15:49 Samuel Moelius via Linux-f2fs-devel
  2026-06-15  3:14 ` Chao Yu via Linux-f2fs-devel
  0 siblings, 1 reply; 5+ messages in thread
From: Samuel Moelius via Linux-f2fs-devel @ 2026-06-03 15:49 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: open list, Samuel Moelius, open list:F2FS FILE SYSTEM

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: validate inline dentry name lengths before conversion
  2026-06-03 15:49 [f2fs-dev] [PATCH] f2fs: validate inline dentry name lengths before conversion Samuel Moelius via Linux-f2fs-devel
@ 2026-06-15  3:14 ` Chao Yu via Linux-f2fs-devel
  2026-06-15 15:24   ` Jaegeuk Kim via Linux-f2fs-devel
  0 siblings, 1 reply; 5+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2026-06-15  3:14 UTC (permalink / raw)
  To: Samuel Moelius, Jaegeuk Kim; +Cc: open list, open list:F2FS FILE SYSTEM

On 6/3/26 23:49, Samuel Moelius wrote:
> 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;

	err = -EFSCORRUPTED;
	goto punch_dentry_pages;

Thanks,

>  
>  		/*
>  		 * We only need the disk_name and hash to move the dentry.



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: validate inline dentry name lengths before conversion
  2026-06-15  3:14 ` Chao Yu via Linux-f2fs-devel
@ 2026-06-15 15:24   ` Jaegeuk Kim via Linux-f2fs-devel
  2026-06-16  2:57     ` Chao Yu via Linux-f2fs-devel
  0 siblings, 1 reply; 5+ messages in thread
From: Jaegeuk Kim via Linux-f2fs-devel @ 2026-06-15 15:24 UTC (permalink / raw)
  To: Chao Yu; +Cc: open list, Samuel Moelius, open list:F2FS FILE SYSTEM

On 06/15, Chao Yu wrote:
> On 6/3/26 23:49, Samuel Moelius wrote:
> > 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;
> 
> 	err = -EFSCORRUPTED;
> 	goto punch_dentry_pages;

Applied with it.

> 
> Thanks,
> 
> >  
> >  		/*
> >  		 * We only need the disk_name and hash to move the dentry.
> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: validate inline dentry name lengths before conversion
  2026-06-15 15:24   ` Jaegeuk Kim via Linux-f2fs-devel
@ 2026-06-16  2:57     ` Chao Yu via Linux-f2fs-devel
  0 siblings, 0 replies; 5+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2026-06-16  2:57 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: open list, Samuel Moelius, open list:F2FS FILE SYSTEM

On 6/15/26 23:24, Jaegeuk Kim wrote:
> On 06/15, Chao Yu wrote:
>> On 6/3/26 23:49, Samuel Moelius wrote:
>>> 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;
>>
>> 	err = -EFSCORRUPTED;
>> 	goto punch_dentry_pages;
> 
> Applied with it.

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,

> 
>>
>> Thanks,
>>
>>>  
>>>  		/*
>>>  		 * We only need the disk_name and hash to move the dentry.
>>



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-06-16  2:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-03 15:49 [f2fs-dev] [PATCH] f2fs: validate inline dentry name lengths before conversion Samuel Moelius via Linux-f2fs-devel
2026-06-15  3:14 ` Chao Yu via Linux-f2fs-devel
2026-06-15 15:24   ` Jaegeuk Kim via Linux-f2fs-devel
2026-06-16  2:57     ` Chao Yu via Linux-f2fs-devel
  -- strict thread matches above, loose matches on Subject: below --
2026-06-03 15:11 Samuel Moelius via Linux-f2fs-devel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox