Skip to contentSkip to conversation

erofs: fix null-ptr-deref caused by erofs_xattr_prefixes_init

PATCH In review Jingbo Xu 3 participants 3 messages May 15, 2023 – May 23, 2023 EROFS file system

lore
Share & tools
lore

Jingbo Xu

author
#0 lore raw

PATCH v2 1/1 erofs: fix null-ptr-deref caused by erofs_xattr_prefixes_init

Fragments and dedupe share one feature bit, and thus packed inode may not exist when fragment feature bit (dedupe 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 [email protected]
Fixes 9e382914617c ("erofs: add helpers to load long xattr name prefixes")

---
v2: polish the commit message (Gao Xiang)

---
 fs/erofs/xattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/erofs/xattr.c +1 -1
index cd80499351e0..bbfe7ce170d2 100644
@@ -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);
Signature · 1 line
2.19.1.6.gb485710b
reviewer Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · On Mon, 15 May 2023 18:39:41 +0800 Jingbo Xu <[email protected]> wrote:

Fragments and dedupe share one feature bit, and thus packed inode may not exist when fragment feature bit (dedupe 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.

Quoted 6 lines

Fix this by accessing packed inode only when it exists.

Reported-by [email protected]
Fixes 9e382914617c ("erofs: add helpers to load long xattr name prefixes")
maintainer Reviewed-by on v2 1/1
#2 lore raw
In reply to Jingbo Xu
Quoted 6 lines · Jingbo Xu

Fragments and dedupe share one feature bit, and thus packed inode may not exist when fragment feature bit (dedupe 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.

Quoted 6 lines

Fix this by accessing packed inode only when it exists.

Reported-by [email protected]
Fixes 9e382914617c ("erofs: add helpers to load long xattr name prefixes")

Thanks,