linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] erofs: fix null-ptr-deref caused by erofs_xattr_prefixes_init
@ 2023-05-15  9:21 Jingbo Xu
  2023-05-15  9:30 ` Gao Xiang
  0 siblings, 1 reply; 2+ messages in thread
From: Jingbo Xu @ 2023-05-15  9:21 UTC (permalink / raw)
  To: xiang, chao, huyue2, linux-erofs; +Cc: linux-kernel

Fragments and dedup share one feature bit, and thus packed inode may not
exist when fragment feature bit (dedup feature bit exactly) is set, e.g.
when deduplication feature is in use while fragments feature is not.  In
this case, sbi->packed_inode could be NULL while fragments feature bit
is set.

Fix this by accessing packed inode only when it exists.

Reported-by: syzbot+902d5a9373ae8f748a94@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=902d5a9373ae8f748a94
Fixes: 9e382914617c ("erofs: add helpers to load long xattr name prefixes")
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
 fs/erofs/xattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c
index cd80499351e0..bbfe7ce170d2 100644
--- a/fs/erofs/xattr.c
+++ b/fs/erofs/xattr.c
@@ -675,7 +675,7 @@ int erofs_xattr_prefixes_init(struct super_block *sb)
 	if (!pfs)
 		return -ENOMEM;
 
-	if (erofs_sb_has_fragments(sbi))
+	if (sbi->packed_inode)
 		buf.inode = sbi->packed_inode;
 	else
 		erofs_init_metabuf(&buf, sb);
-- 
2.19.1.6.gb485710b


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

* Re: [PATCH] erofs: fix null-ptr-deref caused by erofs_xattr_prefixes_init
  2023-05-15  9:21 [PATCH] erofs: fix null-ptr-deref caused by erofs_xattr_prefixes_init Jingbo Xu
@ 2023-05-15  9:30 ` Gao Xiang
  0 siblings, 0 replies; 2+ messages in thread
From: Gao Xiang @ 2023-05-15  9:30 UTC (permalink / raw)
  To: Jingbo Xu, xiang, chao, huyue2, linux-erofs; +Cc: linux-kernel



On 2023/5/15 02:21, Jingbo Xu wrote:
> Fragments and dedup share one feature bit, and thus packed inode may not
please use the formal name "dedupe".

> exist when fragment feature bit (dedup feature bit exactly) is set, e.g.
                                    ^ dedupe

> when deduplication feature is in use while fragments feature is not.  In
> this case, sbi->packed_inode could be NULL while fragments feature bit
> is set.
> 
> Fix this by accessing packed inode only when it exists.
> 
> Reported-by: syzbot+902d5a9373ae8f748a94@syzkaller.appspotmail.com
> Link: https://syzkaller.appspot.com/bug?extid=902d5a9373ae8f748a94
> Fixes: 9e382914617c ("erofs: add helpers to load long xattr name prefixes")
> Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
> ---
>   fs/erofs/xattr.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c
> index cd80499351e0..bbfe7ce170d2 100644
> --- a/fs/erofs/xattr.c
> +++ b/fs/erofs/xattr.c
> @@ -675,7 +675,7 @@ int erofs_xattr_prefixes_init(struct super_block *sb)
>   	if (!pfs)
>   		return -ENOMEM;
>   
> -	if (erofs_sb_has_fragments(sbi))
> +	if (sbi->packed_inode)
>   		buf.inode = sbi->packed_inode;
>   	else
>   		erofs_init_metabuf(&buf, sb);

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

end of thread, other threads:[~2023-05-15  9:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-15  9:21 [PATCH] erofs: fix null-ptr-deref caused by erofs_xattr_prefixes_init Jingbo Xu
2023-05-15  9:30 ` Gao Xiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).