erofs: fix incorrect early exits for invalid metabox-enabled images
PATCH 1/4 erofs: fix incorrect early exits for invalid metabox-enabled images
Crafted EROFS images with metadata compression enabled can trigger incorrect early returns, leading to folio reference leaks.
However, this does not cause system crashes or other severe issues.
--- fs/erofs/super.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/erofs/super.c +3 -2
@@ -330,12 +330,13 @@ static int erofs_read_superblock(struct super_block *sb) } sbi->packed_nid =le64_to_cpu (dsb->packed_nid);if (erofs_sb_has_metabox (sbi)) { + ret = -EFSCORRUPTED ;if (sbi->sb_size <= offsetof(struct erofs_super_block , metabox_nid)) -return -EFSCORRUPTED ; + goto out; sbi->metabox_nid =le64_to_cpu (dsb->metabox_nid);if (sbi->metabox_nid &BIT_ULL (EROFS_DIRENT_NID_METABOX_BIT )) -return -EFSCORRUPTED ;/* self-loop detection */ + goto out;/* self-loop detection */ } sbi->inos =le64_to_cpu (dsb->inos);
Signature · 1 line
2.43.5
PATCH 2/4 erofs: fix incorrect early exits in volume label handling
Crafted EROFS images containing valid volume labels can trigger incorrect early returns, leading to folio reference leaks.
However, this does not cause system crashes or other severe issues.
--- fs/erofs/super.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/erofs/super.c +4 -2
@@ -347,8 +347,10 @@ static int erofs_read_superblock(struct super_block *sb)if (dsb->volume_name[0 ]) { sbi->volume_name =kstrndup (dsb->volume_name,sizeof (dsb->volume_name),GFP_KERNEL ); -if (!sbi->volume_name) -return -ENOMEM ; +if (!sbi->volume_name) { + ret = -ENOMEM ; + goto out; + } }/* parse on-disk compression configurations */
Signature · 1 line
2.43.5
Re: [PATCH 2/4] erofs: fix incorrect early exits in volume label handling
Quoted 7 lines · Gao Xiang
Crafted EROFS images containing valid volume labels can trigger incorrect early returns, leading to folio reference leaks.
However, this does not cause system crashes or other severe issues.
Fixes 1cf12c717741 ("erofs: Add support for FS_IOC_GETFSLABEL")Signed-off-by Gao Xiang <[email protected]>
Thanks,
Hongbo
Quoted 21 lines
--- fs/erofs/super.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)fs/erofs/super.c +4
-2@@ -347,8 +347,10 @@ static int erofs_read_superblock(struct super_block *sb)if (dsb->volume_name[0 ]) { sbi->volume_name =kstrndup (dsb->volume_name,sizeof (dsb->volume_name),GFP_KERNEL ); -if (!sbi->volume_name) -return -ENOMEM ; +if (!sbi->volume_name) { + ret = -ENOMEM ; + goto out; + } }/* parse on-disk compression configurations */
Re: [PATCH 2/4] erofs: fix incorrect early exits in volume label handling
Hi Hongbo,
Quoted 6 lines · Hongbo Li
Quoted 3 lines · Gao Xiang
Crafted EROFS images containing valid volume labels can trigger incorrect early returns, leading to folio reference leaks.
Quoted 6 lines
Quoted 4 lines
However, this does not cause system crashes or other severe issues.
Fixes 1cf12c717741 ("erofs: Add support for FS_IOC_GETFSLABEL")Signed-off-by Gao Xiang <[email protected]>Reviewed-by Hongbo Li <[email protected]>
Since you already reviewed the first two patches, I wonder if you can review the remaining two patches too since they are all trivial?
Thanks,
Gao Xiang
Re: [PATCH 2/4] erofs: fix incorrect early exits in volume label handling
In reply to Gao XiangQuoted 5 lines · Gao Xiang
Crafted EROFS images containing valid volume labels can trigger incorrect early returns, leading to folio reference leaks.
However, this does not cause system crashes or other severe issues.
Will be better to add:
Quoted 2 lines
Fixes 1cf12c717741 ("erofs: Add support for FS_IOC_GETFSLABEL")Signed-off-by Gao Xiang <[email protected]>
Thanks,
PATCH 3/4 erofs: unexport erofs_getxattr()
In reply to Gao XiangNo external users other than those in xattr.c.
--- fs/erofs/xattr.c | 108 +++++++++++++++++++++++------------------------ fs/erofs/xattr.h | 7 --- 2 files changed, 54 insertions(+), 61 deletions(-)
fs/erofs/xattr.c +54 -54
@@ -125,58 +125,6 @@ static int erofs_init_inode_xattrs(struct inode *inode)return ret; } -static bool erofs_xattr_user_list (struct dentry *dentry) -{ -return test_opt (&EROFS_SB (dentry->d_sb)->opt,XATTR_USER ); -} - -static bool erofs_xattr_trusted_list (struct dentry *dentry) -{ -return capable (CAP_SYS_ADMIN ); -} - -static int erofs_xattr_generic_get (const struct xattr_handler *handler, -struct dentry *unused,struct inode *inode, -const char *name,void *buffer,size_t size) -{ -if (handler->flags ==EROFS_XATTR_INDEX_USER && - !test_opt (&EROFS_I_SB (inode)->opt,XATTR_USER )) -return -EOPNOTSUPP ; - -return erofs_getxattr (inode, handler->flags, name, buffer, size); -} - -const struct xattr_handler erofs_xattr_user_handler = { - .prefix =XATTR_USER_PREFIX , - .flags =EROFS_XATTR_INDEX_USER , - .list = erofs_xattr_user_list, - .get = erofs_xattr_generic_get, -}; - -const struct xattr_handler erofs_xattr_trusted_handler = { - .prefix =XATTR_TRUSTED_PREFIX , - .flags =EROFS_XATTR_INDEX_TRUSTED , - .list = erofs_xattr_trusted_list, - .get = erofs_xattr_generic_get, -}; - -#ifdef CONFIG_EROFS_FS_SECURITY -const struct xattr_handler __maybe_unused erofs_xattr_security_handler = { - .prefix =XATTR_SECURITY_PREFIX , - .flags =EROFS_XATTR_INDEX_SECURITY , - .get = erofs_xattr_generic_get, -}; -#endif - -const struct xattr_handler *const erofs_xattr_handlers[] = { - &erofs_xattr_user_handler, - &erofs_xattr_trusted_handler, -#ifdef CONFIG_EROFS_FS_SECURITY - &erofs_xattr_security_handler, -#endif -NULL , -}; -static int erofs_xattr_copy_to_buffer (struct erofs_xattr_iter *it,unsigned int len) {
@@ -391,8 +339,8 @@ static int erofs_xattr_iter_shared(struct erofs_xattr_iter *it,return i ? ret : -ENODATA ; } -int erofs_getxattr (struct inode *inode,int index,const char *name, -void *buffer,size_t buffer_size) +static int erofs_getxattr (struct inode *inode,int index,const char *name, +void *buffer,size_t buffer_size) {int ret;unsigned int hashbit;
@@ -462,6 +410,58 @@ ssize_t erofs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)return ret ? ret : it.buffer_ofs; } +static bool erofs_xattr_user_list (struct dentry *dentry) +{ +return test_opt (&EROFS_SB (dentry->d_sb)->opt,XATTR_USER ); +} + +static bool erofs_xattr_trusted_list (struct dentry *dentry) +{ +return capable (CAP_SYS_ADMIN ); +} + +static int erofs_xattr_generic_get (const struct xattr_handler *handler, +struct dentry *unused,struct inode *inode, +const char *name,void *buffer,size_t size) +{ +if (handler->flags ==EROFS_XATTR_INDEX_USER && + !test_opt (&EROFS_I_SB (inode)->opt,XATTR_USER )) +return -EOPNOTSUPP ; + +return erofs_getxattr (inode, handler->flags, name, buffer, size); +} + +const struct xattr_handler erofs_xattr_user_handler = { + .prefix =XATTR_USER_PREFIX , + .flags =EROFS_XATTR_INDEX_USER , + .list = erofs_xattr_user_list, + .get = erofs_xattr_generic_get, +}; + +const struct xattr_handler erofs_xattr_trusted_handler = { + .prefix =XATTR_TRUSTED_PREFIX , + .flags =EROFS_XATTR_INDEX_TRUSTED , + .list = erofs_xattr_trusted_list, + .get = erofs_xattr_generic_get, +}; + +#ifdef CONFIG_EROFS_FS_SECURITY +const struct xattr_handler __maybe_unused erofs_xattr_security_handler = { + .prefix =XATTR_SECURITY_PREFIX , + .flags =EROFS_XATTR_INDEX_SECURITY , + .get = erofs_xattr_generic_get, +}; +#endif + +const struct xattr_handler *const erofs_xattr_handlers[] = { + &erofs_xattr_user_handler, + &erofs_xattr_trusted_handler, +#ifdef CONFIG_EROFS_FS_SECURITY + &erofs_xattr_security_handler, +#endif +NULL , +}; +void erofs_xattr_prefixes_cleanup (struct super_block *sb) {struct erofs_sb_info *sbi =EROFS_SB (sb);
fs/erofs/xattr.h +0 -7
@@ -45,17 +45,10 @@ extern const struct xattr_handler * const erofs_xattr_handlers[];int erofs_xattr_prefixes_init (struct super_block *sb);void erofs_xattr_prefixes_cleanup (struct super_block *sb); -int erofs_getxattr (struct inode *,int ,const char *,void *,size_t );ssize_t erofs_listxattr (struct dentry *,char *,size_t );#else static inline int erofs_xattr_prefixes_init (struct super_block *sb) {return 0 ; }static inline void erofs_xattr_prefixes_cleanup (struct super_block *sb) {} -static inline int erofs_getxattr (struct inode *inode,int index, -const char *name,void *buffer, -size_t buffer_size) -{ -return -EOPNOTSUPP ; -}#define erofs_listxattr (NULL)#define erofs_xattr_handlers (NULL)
Signature · 1 line
2.43.5
Re: [PATCH 3/4] erofs: unexport erofs_getxattr()
Quoted 3 lines · Gao Xiang
No external users other than those in
xattr.c.Signed-off-by Gao Xiang <[email protected]>
Thanks,
Hongbo
Quoted 160 lines
--- fs/erofs/xattr.c | 108 +++++++++++++++++++++++------------------------ fs/erofs/xattr.h | 7 --- 2 files changed, 54 insertions(+), 61 deletions(-)fs/erofs/xattr.c +54
-54@@ -125,58 +125,6 @@ static int erofs_init_inode_xattrs(struct inode *inode)return ret; } -static bool erofs_xattr_user_list (struct dentry *dentry) -{ -return test_opt (&EROFS_SB (dentry->d_sb)->opt,XATTR_USER ); -} - -static bool erofs_xattr_trusted_list (struct dentry *dentry) -{ -return capable (CAP_SYS_ADMIN ); -} - -static int erofs_xattr_generic_get (const struct xattr_handler *handler, -struct dentry *unused,struct inode *inode, -const char *name,void *buffer,size_t size) -{ -if (handler->flags ==EROFS_XATTR_INDEX_USER && - !test_opt (&EROFS_I_SB (inode)->opt,XATTR_USER )) -return -EOPNOTSUPP ; - -return erofs_getxattr (inode, handler->flags, name, buffer, size); -} - -const struct xattr_handler erofs_xattr_user_handler = { - .prefix =XATTR_USER_PREFIX , - .flags =EROFS_XATTR_INDEX_USER , - .list = erofs_xattr_user_list, - .get = erofs_xattr_generic_get, -}; - -const struct xattr_handler erofs_xattr_trusted_handler = { - .prefix =XATTR_TRUSTED_PREFIX , - .flags =EROFS_XATTR_INDEX_TRUSTED , - .list = erofs_xattr_trusted_list, - .get = erofs_xattr_generic_get, -}; - -#ifdef CONFIG_EROFS_FS_SECURITY -const struct xattr_handler __maybe_unused erofs_xattr_security_handler = { - .prefix =XATTR_SECURITY_PREFIX , - .flags =EROFS_XATTR_INDEX_SECURITY , - .get = erofs_xattr_generic_get, -}; -#endif - -const struct xattr_handler *const erofs_xattr_handlers[] = { - &erofs_xattr_user_handler, - &erofs_xattr_trusted_handler, -#ifdef CONFIG_EROFS_FS_SECURITY - &erofs_xattr_security_handler, -#endif -NULL , -}; -static int erofs_xattr_copy_to_buffer (struct erofs_xattr_iter *it,unsigned int len) {@@ -391,8 +339,8 @@ static int erofs_xattr_iter_shared(struct erofs_xattr_iter *it,return i ? ret : -ENODATA ; } -int erofs_getxattr (struct inode *inode,int index,const char *name, -void *buffer,size_t buffer_size) +static int erofs_getxattr (struct inode *inode,int index,const char *name, +void *buffer,size_t buffer_size) {int ret;unsigned int hashbit;@@ -462,6 +410,58 @@ ssize_t erofs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)return ret ? ret : it.buffer_ofs; } +static bool erofs_xattr_user_list (struct dentry *dentry) +{ +return test_opt (&EROFS_SB (dentry->d_sb)->opt,XATTR_USER ); +} + +static bool erofs_xattr_trusted_list (struct dentry *dentry) +{ +return capable (CAP_SYS_ADMIN ); +} + +static int erofs_xattr_generic_get (const struct xattr_handler *handler, +struct dentry *unused,struct inode *inode, +const char *name,void *buffer,size_t size) +{ +if (handler->flags ==EROFS_XATTR_INDEX_USER && + !test_opt (&EROFS_I_SB (inode)->opt,XATTR_USER )) +return -EOPNOTSUPP ; + +return erofs_getxattr (inode, handler->flags, name, buffer, size); +} + +const struct xattr_handler erofs_xattr_user_handler = { + .prefix =XATTR_USER_PREFIX , + .flags =EROFS_XATTR_INDEX_USER , + .list = erofs_xattr_user_list, + .get = erofs_xattr_generic_get, +}; + +const struct xattr_handler erofs_xattr_trusted_handler = { + .prefix =XATTR_TRUSTED_PREFIX , + .flags =EROFS_XATTR_INDEX_TRUSTED , + .list = erofs_xattr_trusted_list, + .get = erofs_xattr_generic_get, +}; + +#ifdef CONFIG_EROFS_FS_SECURITY +const struct xattr_handler __maybe_unused erofs_xattr_security_handler = { + .prefix =XATTR_SECURITY_PREFIX , + .flags =EROFS_XATTR_INDEX_SECURITY , + .get = erofs_xattr_generic_get, +}; +#endif + +const struct xattr_handler *const erofs_xattr_handlers[] = { + &erofs_xattr_user_handler, + &erofs_xattr_trusted_handler, +#ifdef CONFIG_EROFS_FS_SECURITY + &erofs_xattr_security_handler, +#endif +NULL , +}; +void erofs_xattr_prefixes_cleanup (struct super_block *sb) {struct erofs_sb_info *sbi =EROFS_SB (sb);fs/erofs/xattr.h +0
-7@@ -45,17 +45,10 @@ extern const struct xattr_handler * const erofs_xattr_handlers[];int erofs_xattr_prefixes_init (struct super_block *sb);void erofs_xattr_prefixes_cleanup (struct super_block *sb); -int erofs_getxattr (struct inode *,int ,const char *,void *,size_t );ssize_t erofs_listxattr (struct dentry *,char *,size_t );#else static inline int erofs_xattr_prefixes_init (struct super_block *sb) {return 0 ; }static inline void erofs_xattr_prefixes_cleanup (struct super_block *sb) {} -static inline int erofs_getxattr (struct inode *inode,int index, -const char *name,void *buffer, -size_t buffer_size) -{ -return -EOPNOTSUPP ; -}#define erofs_listxattr (NULL)#define erofs_xattr_handlers (NULL)
Re: [PATCH 3/4] erofs: unexport erofs_getxattr()
In reply to Gao XiangQuoted 3 lines · Gao Xiang
No external users other than those in
xattr.c.Signed-off-by Gao Xiang <[email protected]>
Thanks,
PATCH 4/4 erofs: unexport erofs_xattr_prefix()
In reply to Gao XiangIt can be simply in xattr.c due to no external users.
--- fs/erofs/xattr.c | 27 +++++++++++++++++++++++++++ fs/erofs/xattr.h | 30 ------------------------------ 2 files changed, 27 insertions(+), 30 deletions(-)
fs/erofs/xattr.c +27 -0
@@ -25,6 +25,8 @@ struct erofs_xattr_iter {struct dentry *dentry; }; +static const char *erofs_xattr_prefix (unsigned int idx,struct dentry *dentry); +static int erofs_init_inode_xattrs (struct inode *inode) {struct erofs_inode *const vi =EROFS_I (inode);
@@ -462,6 +464,31 @@ const struct xattr_handler * const erofs_xattr_handlers[] = { NULL, }; +static const char *erofs_xattr_prefix (unsigned int idx,struct dentry *dentry) +{ +const struct xattr_handler *handler =NULL ; + +static const struct xattr_handler *const xattr_handler_map[] = { + [EROFS_XATTR_INDEX_USER ] = &erofs_xattr_user_handler, +#ifdef CONFIG_EROFS_FS_POSIX_ACL + [EROFS_XATTR_INDEX_POSIX_ACL_ACCESS ] = &nop_posix_acl_access, + [EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT ] = &nop_posix_acl_default, +#endif + [EROFS_XATTR_INDEX_TRUSTED ] = &erofs_xattr_trusted_handler, +#ifdef CONFIG_EROFS_FS_SECURITY + [EROFS_XATTR_INDEX_SECURITY ] = &erofs_xattr_security_handler, +#endif + }; + +if (idx && idx <ARRAY_SIZE (xattr_handler_map)) + handler = xattr_handler_map[idx]; + +if (!xattr_handler_can_list (handler, dentry)) +return NULL ; + +return xattr_prefix (handler); +} +void erofs_xattr_prefixes_cleanup (struct super_block *sb) {struct erofs_sb_info *sbi =EROFS_SB (sb);
fs/erofs/xattr.h +0 -30
@@ -11,36 +11,6 @@#include <linux/xattr.h> #ifdef CONFIG_EROFS_FS_XATTR -extern const struct xattr_handler erofs_xattr_user_handler; -extern const struct xattr_handler erofs_xattr_trusted_handler; -extern const struct xattr_handler erofs_xattr_security_handler; - -static inline const char *erofs_xattr_prefix (unsigned int idx, -struct dentry *dentry) -{ -const struct xattr_handler *handler =NULL ; - -static const struct xattr_handler *const xattr_handler_map[] = { - [EROFS_XATTR_INDEX_USER ] = &erofs_xattr_user_handler, -#ifdef CONFIG_EROFS_FS_POSIX_ACL - [EROFS_XATTR_INDEX_POSIX_ACL_ACCESS ] = &nop_posix_acl_access, - [EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT ] = &nop_posix_acl_default, -#endif - [EROFS_XATTR_INDEX_TRUSTED ] = &erofs_xattr_trusted_handler, -#ifdef CONFIG_EROFS_FS_SECURITY - [EROFS_XATTR_INDEX_SECURITY ] = &erofs_xattr_security_handler, -#endif - }; - -if (idx && idx <ARRAY_SIZE (xattr_handler_map)) - handler = xattr_handler_map[idx]; - -if (!xattr_handler_can_list (handler, dentry)) -return NULL ; - -return xattr_prefix (handler); -} -extern const struct xattr_handler *const erofs_xattr_handlers[];int erofs_xattr_prefixes_init (struct super_block *sb);
Signature · 1 line
2.43.5
Re: [PATCH 4/4] erofs: unexport erofs_xattr_prefix()
Quoted 2 lines · Gao Xiang
It can be simply in
xattr.cdue to no external users.
Thanks,
Hongbo
Quoted 92 lines
Signed-off-by Gao Xiang <[email protected]>--- fs/erofs/xattr.c | 27 +++++++++++++++++++++++++++ fs/erofs/xattr.h | 30 ------------------------------ 2 files changed, 27 insertions(+), 30 deletions(-)fs/erofs/xattr.c +27
-0@@ -25,6 +25,8 @@ struct erofs_xattr_iter {struct dentry *dentry; }; +static const char *erofs_xattr_prefix (unsigned int idx,struct dentry *dentry); +static int erofs_init_inode_xattrs (struct inode *inode) {struct erofs_inode *const vi =EROFS_I (inode);@@ -462,6 +464,31 @@ const struct xattr_handler * const erofs_xattr_handlers[] = { NULL, }; +static const char *erofs_xattr_prefix (unsigned int idx,struct dentry *dentry) +{ +const struct xattr_handler *handler =NULL ; + +static const struct xattr_handler *const xattr_handler_map[] = { + [EROFS_XATTR_INDEX_USER ] = &erofs_xattr_user_handler, +#ifdef CONFIG_EROFS_FS_POSIX_ACL + [EROFS_XATTR_INDEX_POSIX_ACL_ACCESS ] = &nop_posix_acl_access, + [EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT ] = &nop_posix_acl_default, +#endif + [EROFS_XATTR_INDEX_TRUSTED ] = &erofs_xattr_trusted_handler, +#ifdef CONFIG_EROFS_FS_SECURITY + [EROFS_XATTR_INDEX_SECURITY ] = &erofs_xattr_security_handler, +#endif + }; + +if (idx && idx <ARRAY_SIZE (xattr_handler_map)) + handler = xattr_handler_map[idx]; + +if (!xattr_handler_can_list (handler, dentry)) +return NULL ; + +return xattr_prefix (handler); +} +void erofs_xattr_prefixes_cleanup (struct super_block *sb) {struct erofs_sb_info *sbi =EROFS_SB (sb);fs/erofs/xattr.h +0
-30@@ -11,36 +11,6 @@#include <linux/xattr.h> #ifdef CONFIG_EROFS_FS_XATTR -extern const struct xattr_handler erofs_xattr_user_handler; -extern const struct xattr_handler erofs_xattr_trusted_handler; -extern const struct xattr_handler erofs_xattr_security_handler; - -static inline const char *erofs_xattr_prefix (unsigned int idx, -struct dentry *dentry) -{ -const struct xattr_handler *handler =NULL ; - -static const struct xattr_handler *const xattr_handler_map[] = { - [EROFS_XATTR_INDEX_USER ] = &erofs_xattr_user_handler, -#ifdef CONFIG_EROFS_FS_POSIX_ACL - [EROFS_XATTR_INDEX_POSIX_ACL_ACCESS ] = &nop_posix_acl_access, - [EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT ] = &nop_posix_acl_default, -#endif - [EROFS_XATTR_INDEX_TRUSTED ] = &erofs_xattr_trusted_handler, -#ifdef CONFIG_EROFS_FS_SECURITY - [EROFS_XATTR_INDEX_SECURITY ] = &erofs_xattr_security_handler, -#endif - }; - -if (idx && idx <ARRAY_SIZE (xattr_handler_map)) - handler = xattr_handler_map[idx]; - -if (!xattr_handler_can_list (handler, dentry)) -return NULL ; - -return xattr_prefix (handler); -} -extern const struct xattr_handler *const erofs_xattr_handlers[];int erofs_xattr_prefixes_init (struct super_block *sb);
PATCH v2 4/4 erofs: unexport erofs_xattr_prefix()
In reply to Gao XiangIt can be simply in xattr.c due to no external users.
---
v2:
- fix sparse warnings:
https://lore.kernel.org/r/[email protected]
fs/erofs/xattr.c | 31 ++++++++++++++++++++++++++++--- fs/erofs/xattr.h | 30 ------------------------------ 2 files changed, 28 insertions(+), 33 deletions(-)
fs/erofs/xattr.c +28 -3
@@ -25,6 +25,8 @@ struct erofs_xattr_iter {struct dentry *dentry; }; +static const char *erofs_xattr_prefix (unsigned int idx,struct dentry *dentry); +static int erofs_init_inode_xattrs (struct inode *inode) {struct erofs_inode *const vi =EROFS_I (inode);
@@ -431,14 +433,14 @@ static int erofs_xattr_generic_get(const struct xattr_handler *handler,return erofs_getxattr (inode, handler->flags, name, buffer, size); } -const struct xattr_handler erofs_xattr_user_handler = { +static const struct xattr_handler erofs_xattr_user_handler = { .prefix =XATTR_USER_PREFIX , .flags =EROFS_XATTR_INDEX_USER , .list = erofs_xattr_user_list, .get = erofs_xattr_generic_get, }; -const struct xattr_handler erofs_xattr_trusted_handler = { +static const struct xattr_handler erofs_xattr_trusted_handler = { .prefix =XATTR_TRUSTED_PREFIX , .flags =EROFS_XATTR_INDEX_TRUSTED , .list = erofs_xattr_trusted_list,
@@ -446,7 +448,7 @@ const struct xattr_handler erofs_xattr_trusted_handler = { };#ifdef CONFIG_EROFS_FS_SECURITY -const struct xattr_handler __maybe_unused erofs_xattr_security_handler = { +static const struct xattr_handler erofs_xattr_security_handler = { .prefix =XATTR_SECURITY_PREFIX , .flags =EROFS_XATTR_INDEX_SECURITY , .get = erofs_xattr_generic_get,
@@ -462,6 +464,29 @@ const struct xattr_handler * const erofs_xattr_handlers[] = { NULL, }; +static const char *erofs_xattr_prefix (unsigned int idx,struct dentry *dentry) +{ +static const struct xattr_handler *const xattr_handler_map[] = { + [EROFS_XATTR_INDEX_USER ] = &erofs_xattr_user_handler, +#ifdef CONFIG_EROFS_FS_POSIX_ACL + [EROFS_XATTR_INDEX_POSIX_ACL_ACCESS ] = &nop_posix_acl_access, + [EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT ] = &nop_posix_acl_default, +#endif + [EROFS_XATTR_INDEX_TRUSTED ] = &erofs_xattr_trusted_handler, +#ifdef CONFIG_EROFS_FS_SECURITY + [EROFS_XATTR_INDEX_SECURITY ] = &erofs_xattr_security_handler, +#endif + }; +const struct xattr_handler *handler =NULL ; + +if (idx && idx <ARRAY_SIZE (xattr_handler_map)) { + handler = xattr_handler_map[idx]; +if (xattr_handler_can_list (handler, dentry)) +return xattr_prefix (handler); + } +return NULL ; +} +void erofs_xattr_prefixes_cleanup (struct super_block *sb) {struct erofs_sb_info *sbi =EROFS_SB (sb);
fs/erofs/xattr.h +0 -30
@@ -11,36 +11,6 @@#include <linux/xattr.h> #ifdef CONFIG_EROFS_FS_XATTR -extern const struct xattr_handler erofs_xattr_user_handler; -extern const struct xattr_handler erofs_xattr_trusted_handler; -extern const struct xattr_handler erofs_xattr_security_handler; - -static inline const char *erofs_xattr_prefix (unsigned int idx, -struct dentry *dentry) -{ -const struct xattr_handler *handler =NULL ; - -static const struct xattr_handler *const xattr_handler_map[] = { - [EROFS_XATTR_INDEX_USER ] = &erofs_xattr_user_handler, -#ifdef CONFIG_EROFS_FS_POSIX_ACL - [EROFS_XATTR_INDEX_POSIX_ACL_ACCESS ] = &nop_posix_acl_access, - [EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT ] = &nop_posix_acl_default, -#endif - [EROFS_XATTR_INDEX_TRUSTED ] = &erofs_xattr_trusted_handler, -#ifdef CONFIG_EROFS_FS_SECURITY - [EROFS_XATTR_INDEX_SECURITY ] = &erofs_xattr_security_handler, -#endif - }; - -if (idx && idx <ARRAY_SIZE (xattr_handler_map)) - handler = xattr_handler_map[idx]; - -if (!xattr_handler_can_list (handler, dentry)) -return NULL ; - -return xattr_prefix (handler); -} -extern const struct xattr_handler *const erofs_xattr_handlers[];int erofs_xattr_prefixes_init (struct super_block *sb);
Signature · 1 line
2.43.5
Re: [PATCH v2 4/4] erofs: unexport erofs_xattr_prefix()
Quoted 4 lines · Gao Xiang
It can be simply in
xattr.cdue to no external users.Reviewed-by Hongbo Li <[email protected]>Signed-off-by Gao Xiang <[email protected]>
Thanks,
Quoted 7 lines · Gao Xiang
Crafted EROFS images with metadata compression enabled can trigger incorrect early returns, leading to folio reference leaks.
However, this does not cause system crashes or other severe issues.
Fixes 414091322c63 ("erofs: implement metadata compression")Signed-off-by Gao Xiang <[email protected]>
Thanks,
Hongbo
Quoted 24 lines
--- fs/erofs/super.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)fs/erofs/super.c +3
-2@@ -330,12 +330,13 @@ static int erofs_read_superblock(struct super_block *sb) } sbi->packed_nid =le64_to_cpu (dsb->packed_nid);if (erofs_sb_has_metabox (sbi)) { + ret = -EFSCORRUPTED ;if (sbi->sb_size <= offsetof(struct erofs_super_block , metabox_nid)) -return -EFSCORRUPTED ; + goto out; sbi->metabox_nid =le64_to_cpu (dsb->metabox_nid);if (sbi->metabox_nid &BIT_ULL (EROFS_DIRENT_NID_METABOX_BIT )) -return -EFSCORRUPTED ;/* self-loop detection */ + goto out;/* self-loop detection */ } sbi->inos =le64_to_cpu (dsb->inos);
Quoted 5 lines · Gao Xiang
Crafted EROFS images with metadata compression enabled can trigger incorrect early returns, leading to folio reference leaks.
However, this does not cause system crashes or other severe issues.
Will be better to add:
Quoted 2 lines
Fixes 414091322c63 ("erofs: implement metadata compression")Signed-off-by Gao Xiang <[email protected]>
Thanks,
Quoted 10 lines · Chao Yu
Quoted 5 lines · Gao Xiang
Crafted EROFS images with metadata compression enabled can trigger incorrect early returns, leading to folio reference leaks.
However, this does not cause system crashes or other severe issues.
Will be better to add:
Hi Chao,
will add later, I current have some environment issue.
Thanks,
Gao Xiang
Quoted 7 lines
Quoted 3 lines
Fixes 414091322c63 ("erofs: implement metadata compression")Signed-off-by Gao Xiang <[email protected]>Reviewed-by Chao Yu <[email protected]>Thanks,