erofs: fix potential overflow calculating xattr_isize
PATCH 1/1 erofs: fix potential overflow calculating xattr_isize
Given on-disk i_xattr_icount is 16 bits and xattr_isize is calculated from i_xattr_icount multiplying 4, xattr_isize has a theoretical maximum of 256K (64K * 4).
Thus declare xattr_isize as unsigned int to avoid the potential overflow.
--- fs/erofs/internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/erofs/internal.h +1 -1
@@ -306,7 +306,7 @@ struct erofs_inode {unsigned char datalayout;unsigned char inode_isize; -unsigned short xattr_isize; +unsigned int xattr_isize;unsigned int xattr_shared_count;unsigned int *xattr_shared_xattrs;
Signature · 1 line
2.19.1.6.gb485710b
Quoted 8 lines · Jingbo Xu
Given on-disk
i_xattr_icountis 16 bits andxattr_isizeis calculated fromi_xattr_icountmultiplying 4,xattr_isizehas a theoretical maximum of 256K (64K * 4).Thus declare
xattr_isizeas unsigned int to avoid the potential overflow.Fixes bfb8674dc044 ("staging: erofs: add erofs in-memory stuffs")Signed-off-by Jingbo Xu <[email protected]>
Thanks for catching this!
Thanks,
Gao Xiang
Quoted 17 lines
--- fs/erofs/internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/erofs/internal.h +1
-1@@ -306,7 +306,7 @@ struct erofs_inode {unsigned char datalayout;unsigned char inode_isize; -unsigned short xattr_isize; +unsigned int xattr_isize;unsigned int xattr_shared_count;unsigned int *xattr_shared_xattrs;
Quoted 8 lines · Jingbo Xu
Given on-disk
i_xattr_icountis 16 bits andxattr_isizeis calculated fromi_xattr_icountmultiplying 4,xattr_isizehas a theoretical maximum of 256K (64K * 4).Thus declare
xattr_isizeas unsigned int to avoid the potential overflow.Fixes bfb8674dc044 ("staging: erofs: add erofs in-memory stuffs")Signed-off-by Jingbo Xu <[email protected]>
Good catch!
Thanks,