erofs: fix null-ptr-deref caused by erofs_xattr_prefixes_init
PATCH 1/1 erofs: fix null-ptr-deref caused by erofs_xattr_prefixes_init
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.
--- fs/erofs/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/erofs/xattr.c +1 -1
@@ -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
Quoted 1 line · Jingbo Xu
Fragments and dedup share one feature bit, and thus packed inode may not
please use the formal name "dedupe".
Quoted 1 line
exist when fragment feature bit (dedup feature bit exactly) is set, e.g.
^ dedupe
Quoted 27 lines
when deduplication feature is in use while fragments feature is not. In this case,
sbi->packed_inodecould 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")Signed-off-by Jingbo Xu <[email protected]>--- fs/erofs/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/erofs/xattr.c +1
-1@@ -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);