From: Chao Yu <chao@kernel.org>
To: zangyangyang1 <zangyangyang1@xiaomi.com>, jaegeuk@kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] f2fs_io: Fix integer multiplication overflow error in fiemap
Date: Tue, 23 May 2023 17:59:32 +0800 [thread overview]
Message-ID: <d4a7bc42-6b58-27e3-e9d8-950f698bc43f@kernel.org> (raw)
In-Reply-To: <20230523072421.1616607-1-zangyangyang1@xiaomi.com>
On 2023/5/23 15:24, zangyangyang1 wrote:
> When using fiemap to obtain the block address of files
> larger than 2GB ((2147483647+1) bytes), an integer
> multiplication overflow error will occur.
> This issue is caused by the following code:
> start = atoi(argv[1]) * F2FS_BLKSIZE;
> length = atoi(argv[2]) * F2FS_BLKSIZE;
>
> Signed-off-by: zangyangyang1 <zangyangyang1@xiaomi.com>
> ---
> tools/f2fs_io/f2fs_io.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
> index 5bc0baf..ad6b5f0 100644
> --- a/tools/f2fs_io/f2fs_io.c
> +++ b/tools/f2fs_io/f2fs_io.c
> @@ -809,15 +809,15 @@ static void do_fiemap(int argc, char **argv, const struct cmd_desc *cmd)
> }
>
> memset(fm, 0, sizeof(struct fiemap));
> - start = atoi(argv[1]) * F2FS_BLKSIZE;
> - length = atoi(argv[2]) * F2FS_BLKSIZE;
How about?
start = (long long)atoi(argv[1]) * F2FS_BLKSIZE;
length = (long long)atoi(argv[2]) * F2FS_BLKSIZE;
Thanks,
> - fm->fm_start = start;
> - fm->fm_length = length;
> + start = atoll(argv[1]);
> + length = atoll(argv[2]);
> + fm->fm_start = start * F2FS_BLKSIZE;
> + fm->fm_length = length * F2FS_BLKSIZE;
>
> fd = xopen(argv[3], O_RDONLY | O_LARGEFILE, 0);
>
> printf("Fiemap: offset = %"PRIu64" len = %"PRIu64"\n",
> - start / F2FS_BLKSIZE, length / F2FS_BLKSIZE);
> + start, length);
> if (ioctl(fd, FS_IOC_FIEMAP, fm) < 0)
> die_errno("FIEMAP failed");
>
> --
> 2.40.1
>
> #/******本邮件及其附件含有小米公司的保密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本邮件! This e-mail and its attachments contain confidential information from XIAOMI, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!******/#
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2023-05-23 9:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-23 7:24 [f2fs-dev] [PATCH] f2fs_io: Fix integer multiplication overflow error in fiemap zangyangyang1 via Linux-f2fs-devel
2023-05-23 9:59 ` Chao Yu [this message]
2023-05-23 12:27 ` [f2fs-dev] [PATCH v2] " zangyangyang1 via Linux-f2fs-devel
2023-05-24 3:02 ` Chao Yu
2023-11-09 13:00 ` [f2fs-dev] [PATCH V2] libf2fs: Fix using uninitialized variables error in get_device_info() zangyangyang1 via Linux-f2fs-devel
2023-11-09 15:40 ` zangyangyang1 via Linux-f2fs-devel
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=d4a7bc42-6b58-27e3-e9d8-950f698bc43f@kernel.org \
--to=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=zangyangyang1@xiaomi.com \
/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;
as well as URLs for NNTP newsgroup(s).