mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Chao Yu <chao@kernel.org>,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] f2fs: fix to do cast in F2FS_{BLK_TO_BYTES, BTYES_TO_BLK} to avoid overflow
Date: Tue, 19 Nov 2024 09:11:56 +0800	[thread overview]
Message-ID: <6b58469c-2a93-4839-9fb9-4e6ec901c308@kernel.org> (raw)
In-Reply-To: <ZzuCfgTp9m1eqIGa@google.com>

On 2024/11/19 2:07, Jaegeuk Kim wrote:
> I applied this with the below change to avoid build failure.

Thank you!

Thanks,
> 
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -3336,7 +3336,7 @@ loff_t max_file_blocks(struct inode *inode)
>           * fit within U32_MAX + 1 data units.
>           */
> 
> -       result = min(result, F2FS_BYTES_TO_BLK(((loff_t)U32_MAX + 1) * 4096));
> +       result = umin(result, F2FS_BYTES_TO_BLK(((loff_t)U32_MAX + 1) * 4096));
> 
>          return result;
>   }
> 
> On 11/08, Chao Yu wrote:
>> It missed to cast variable to unsigned long long type before
>> bit shift, which will cause overflow, fix it.
>>
>> Fixes: f7ef9b83b583 ("f2fs: introduce macros to convert bytes and blocks in f2fs")
>> Signed-off-by: Chao Yu <chao@kernel.org>
>> ---
>>   include/linux/f2fs_fs.h | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h
>> index b0b821edfd97..3b2ad444c002 100644
>> --- a/include/linux/f2fs_fs.h
>> +++ b/include/linux/f2fs_fs.h
>> @@ -24,10 +24,10 @@
>>   #define NEW_ADDR		((block_t)-1)	/* used as block_t addresses */
>>   #define COMPRESS_ADDR		((block_t)-2)	/* used as compressed data flag */
>>   
>> -#define F2FS_BYTES_TO_BLK(bytes)	((bytes) >> F2FS_BLKSIZE_BITS)
>> -#define F2FS_BLK_TO_BYTES(blk)		((blk) << F2FS_BLKSIZE_BITS)
>> +#define F2FS_BYTES_TO_BLK(bytes)	((unsigned long long)(bytes) >> F2FS_BLKSIZE_BITS)
>> +#define F2FS_BLK_TO_BYTES(blk)		((unsigned long long)(blk) << F2FS_BLKSIZE_BITS)
>>   #define F2FS_BLK_END_BYTES(blk)		(F2FS_BLK_TO_BYTES(blk + 1) - 1)
>> -#define F2FS_BLK_ALIGN(x)			(F2FS_BYTES_TO_BLK((x) + F2FS_BLKSIZE - 1))
>> +#define F2FS_BLK_ALIGN(x)		(F2FS_BYTES_TO_BLK((x) + F2FS_BLKSIZE - 1))
>>   
>>   /* 0, 1(node nid), 2(meta nid) are reserved node id */
>>   #define F2FS_RESERVED_NODE_NUM		3
>> -- 
>> 2.40.1


  reply	other threads:[~2024-11-19  1:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-08  1:25 Chao Yu
2024-11-08  1:25 ` [PATCH 2/4] f2fs: clean up w/ F2FS_{BLK_TO_BYTES,BTYES_TO_BLK} Chao Yu
2024-11-08  1:25 ` [PATCH 3/4] f2fs: fix to adjust appropriate length for fiemap Chao Yu
2024-11-08  1:25 ` [PATCH 4/4] f2fs: fix to requery extent which cross boundary of inquiry Chao Yu
2024-11-18 18:07 ` [PATCH 1/4] f2fs: fix to do cast in F2FS_{BLK_TO_BYTES, BTYES_TO_BLK} to avoid overflow Jaegeuk Kim
2024-11-19  1:11   ` Chao Yu [this message]
2024-11-21 16:20 ` [f2fs-dev] " patchwork-bot+f2fs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6b58469c-2a93-4839-9fb9-4e6ec901c308@kernel.org \
    --to=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome