* [PATCH] erofs: fix potential overflow calculating xattr_isize
@ 2023-04-14 6:18 Jingbo Xu
2023-04-14 6:28 ` Gao Xiang
2023-04-16 14:47 ` Chao Yu
0 siblings, 2 replies; 3+ messages in thread
From: Jingbo Xu @ 2023-04-14 6:18 UTC (permalink / raw)
To: xiang, chao, huyue2, linux-erofs; +Cc: linux-kernel
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: bfb8674dc044 ("staging: erofs: add erofs in-memory stuffs")
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
fs/erofs/internal.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 8a563374b518..c86241a32ab3 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -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;
--
2.19.1.6.gb485710b
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] erofs: fix potential overflow calculating xattr_isize
2023-04-14 6:18 [PATCH] erofs: fix potential overflow calculating xattr_isize Jingbo Xu
@ 2023-04-14 6:28 ` Gao Xiang
2023-04-16 14:47 ` Chao Yu
1 sibling, 0 replies; 3+ messages in thread
From: Gao Xiang @ 2023-04-14 6:28 UTC (permalink / raw)
To: Jingbo Xu, xiang, chao, huyue2, linux-erofs; +Cc: linux-kernel
On 2023/4/14 14:18, Jingbo Xu wrote:
> 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: bfb8674dc044 ("staging: erofs: add erofs in-memory stuffs")
> Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Thanks for catching this!
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Thanks,
Gao Xiang
> ---
> fs/erofs/internal.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
> index 8a563374b518..c86241a32ab3 100644
> --- a/fs/erofs/internal.h
> +++ b/fs/erofs/internal.h
> @@ -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;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] erofs: fix potential overflow calculating xattr_isize
2023-04-14 6:18 [PATCH] erofs: fix potential overflow calculating xattr_isize Jingbo Xu
2023-04-14 6:28 ` Gao Xiang
@ 2023-04-16 14:47 ` Chao Yu
1 sibling, 0 replies; 3+ messages in thread
From: Chao Yu @ 2023-04-16 14:47 UTC (permalink / raw)
To: Jingbo Xu, xiang, huyue2, linux-erofs; +Cc: linux-kernel
On 2023/4/14 14:18, Jingbo Xu wrote:
> 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: bfb8674dc044 ("staging: erofs: add erofs in-memory stuffs")
> Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Good catch!
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-04-16 14:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-14 6:18 [PATCH] erofs: fix potential overflow calculating xattr_isize Jingbo Xu
2023-04-14 6:28 ` Gao Xiang
2023-04-16 14:47 ` Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).