Linux-EROFS Archive mirror
 help / color / mirror / Atom feed
* [PATCH] erofs: explicit cast blkaddr to u64 before shift operation
@ 2023-04-13  3:57 Jia Zhu via Linux-erofs
  2023-04-13  4:27 ` Jingbo Xu
  2023-04-13  4:36 ` Gao Xiang
  0 siblings, 2 replies; 3+ messages in thread
From: Jia Zhu via Linux-erofs @ 2023-04-13  3:57 UTC (permalink / raw
  To: linux-erofs; +Cc: linux-kernel

We should explicitly cast @blkaddr from u32 to u64 before the shift
operation to return the larger type.

Fixes: b1c2d99b18ff ("erofs: avoid hardcoded blocksize for subpage block support")
Signed-off-by: Jia Zhu <zhujia.zj@bytedance.com>
---
 fs/erofs/data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index aa7f9e4f86fb..6fe9a779fa91 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -35,7 +35,7 @@ void *erofs_bread(struct erofs_buf *buf, erofs_blk_t blkaddr,
 		  enum erofs_kmap_type type)
 {
 	struct inode *inode = buf->inode;
-	erofs_off_t offset = blkaddr << inode->i_blkbits;
+	erofs_off_t offset = (erofs_off_t)blkaddr << inode->i_blkbits;
 	pgoff_t index = offset >> PAGE_SHIFT;
 	struct page *page = buf->page;
 	struct folio *folio;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] erofs: explicit cast blkaddr to u64 before shift operation
  2023-04-13  3:57 [PATCH] erofs: explicit cast blkaddr to u64 before shift operation Jia Zhu via Linux-erofs
@ 2023-04-13  4:27 ` Jingbo Xu
  2023-04-13  4:36 ` Gao Xiang
  1 sibling, 0 replies; 3+ messages in thread
From: Jingbo Xu @ 2023-04-13  4:27 UTC (permalink / raw
  To: Jia Zhu, linux-erofs; +Cc: linux-kernel



On 4/13/23 11:57 AM, Jia Zhu wrote:
> We should explicitly cast @blkaddr from u32 to u64 before the shift
> operation to return the larger type.
> 
> Fixes: b1c2d99b18ff ("erofs: avoid hardcoded blocksize for subpage block support")
> Signed-off-by: Jia Zhu <zhujia.zj@bytedance.com>
> ---
>  fs/erofs/data.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/erofs/data.c b/fs/erofs/data.c
> index aa7f9e4f86fb..6fe9a779fa91 100644
> --- a/fs/erofs/data.c
> +++ b/fs/erofs/data.c
> @@ -35,7 +35,7 @@ void *erofs_bread(struct erofs_buf *buf, erofs_blk_t blkaddr,
>  		  enum erofs_kmap_type type)
>  {
>  	struct inode *inode = buf->inode;
> -	erofs_off_t offset = blkaddr << inode->i_blkbits;
> +	erofs_off_t offset = (erofs_off_t)blkaddr << inode->i_blkbits;
>  	pgoff_t index = offset >> PAGE_SHIFT;
>  	struct page *page = buf->page;
>  	struct folio *folio;

LGTM. Thanks for catching this.

Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com>

-- 
Thanks,
Jingbo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] erofs: explicit cast blkaddr to u64 before shift operation
  2023-04-13  3:57 [PATCH] erofs: explicit cast blkaddr to u64 before shift operation Jia Zhu via Linux-erofs
  2023-04-13  4:27 ` Jingbo Xu
@ 2023-04-13  4:36 ` Gao Xiang
  1 sibling, 0 replies; 3+ messages in thread
From: Gao Xiang @ 2023-04-13  4:36 UTC (permalink / raw
  To: Jia Zhu, linux-erofs; +Cc: linux-kernel



On 2023/4/13 11:57, Jia Zhu wrote:
> We should explicitly cast @blkaddr from u32 to u64 before the shift
> operation to return the larger type.
> 
> Fixes: b1c2d99b18ff ("erofs: avoid hardcoded blocksize for subpage block support")
> Signed-off-by: Jia Zhu <zhujia.zj@bytedance.com>

Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>

Let's fold it into the original patch.

Thanks,
Gao Xiang

> ---
>   fs/erofs/data.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/erofs/data.c b/fs/erofs/data.c
> index aa7f9e4f86fb..6fe9a779fa91 100644
> --- a/fs/erofs/data.c
> +++ b/fs/erofs/data.c
> @@ -35,7 +35,7 @@ void *erofs_bread(struct erofs_buf *buf, erofs_blk_t blkaddr,
>   		  enum erofs_kmap_type type)
>   {
>   	struct inode *inode = buf->inode;
> -	erofs_off_t offset = blkaddr << inode->i_blkbits;
> +	erofs_off_t offset = (erofs_off_t)blkaddr << inode->i_blkbits;
>   	pgoff_t index = offset >> PAGE_SHIFT;
>   	struct page *page = buf->page;
>   	struct folio *folio;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-04-13  4:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-13  3:57 [PATCH] erofs: explicit cast blkaddr to u64 before shift operation Jia Zhu via Linux-erofs
2023-04-13  4:27 ` Jingbo Xu
2023-04-13  4:36 ` Gao Xiang

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 read-only IMAP folder(s) and NNTP newsgroup(s).