Skip to content

Commit

Permalink
erofs: fix potential overflow calculating xattr_isize
Browse files Browse the repository at this point in the history
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.

Fixes: bfb8674 ("staging: erofs: add erofs in-memory stuffs")
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Link: https://lore.kernel.org/r/20230414061810.6479-1-jefflexu@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
  • Loading branch information
Jingbo Xu authored and Gao Xiang committed Apr 16, 2023
1 parent 4fdadd5 commit 1b3567a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/erofs/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,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;
Expand Down

0 comments on commit 1b3567a

Please sign in to comment.