From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: David Anderson <dvander@google.com>
Cc: linux-erofs@lists.ozlabs.org
Subject: Re: [PATCH] erofs-utils: mkfs: fix integer overflow in erofs_blob_remap
Date: Thu, 11 Nov 2021 10:11:38 +0800 [thread overview]
Message-ID: <YYx72rN3ISRcABAI@B-P7TQMD6M-0146.local> (raw)
In-Reply-To: <20211111015527.2717076-1-dvander@google.com>
Hi David,
On Thu, Nov 11, 2021 at 01:55:27AM +0000, David Anderson via Linux-erofs wrote:
> When using --chunksize, partitions greater than 2GiB can fail to build
> due to integer overflow in erofs_blob_remap.
>
> Signed-off-by: David Anderson <dvander@google.com>
Thanks for the report! good catch! Will apply this later.
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
(however, I think it needs several loops for 32-bit platforms.
I will fix it later...)
Thanks,
Gao Xiang
> ---
> include/erofs/io.h | 6 +++---
> lib/blobchunk.c | 2 +-
> lib/io.c | 12 ++++++------
> 3 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/include/erofs/io.h b/include/erofs/io.h
> index 2597c5c..9d73adc 100644
> --- a/include/erofs/io.h
> +++ b/include/erofs/io.h
> @@ -27,9 +27,9 @@ u64 dev_length(void);
>
> extern int erofs_devfd;
>
> -int erofs_copy_file_range(int fd_in, erofs_off_t *off_in,
> - int fd_out, erofs_off_t *off_out,
> - size_t length);
> +ssize_t erofs_copy_file_range(int fd_in, erofs_off_t *off_in,
> + int fd_out, erofs_off_t *off_out,
> + size_t length);
>
> static inline int blk_write(const void *buf, erofs_blk_t blkaddr,
> u32 nblocks)
> diff --git a/lib/blobchunk.c b/lib/blobchunk.c
> index 661c5d0..a0ff79c 100644
> --- a/lib/blobchunk.c
> +++ b/lib/blobchunk.c
> @@ -179,7 +179,7 @@ int erofs_blob_remap(void)
> struct erofs_buffer_head *bh;
> ssize_t length;
> erofs_off_t pos_in, pos_out;
> - int ret;
> + ssize_t ret;
>
> fflush(blobfile);
> length = ftell(blobfile);
> diff --git a/lib/io.c b/lib/io.c
> index cfc062d..279c7dd 100644
> --- a/lib/io.c
> +++ b/lib/io.c
> @@ -259,9 +259,9 @@ int dev_read(void *buf, u64 offset, size_t len)
> return 0;
> }
>
> -static int __erofs_copy_file_range(int fd_in, erofs_off_t *off_in,
> - int fd_out, erofs_off_t *off_out,
> - size_t length)
> +static ssize_t __erofs_copy_file_range(int fd_in, erofs_off_t *off_in,
> + int fd_out, erofs_off_t *off_out,
> + size_t length)
> {
> size_t copied = 0;
> char buf[8192];
> @@ -331,9 +331,9 @@ static int __erofs_copy_file_range(int fd_in, erofs_off_t *off_in,
> return copied;
> }
>
> -int erofs_copy_file_range(int fd_in, erofs_off_t *off_in,
> - int fd_out, erofs_off_t *off_out,
> - size_t length)
> +ssize_t erofs_copy_file_range(int fd_in, erofs_off_t *off_in,
> + int fd_out, erofs_off_t *off_out,
> + size_t length)
> {
> #ifdef HAVE_COPY_FILE_RANGE
> off64_t off64_in = *off_in, off64_out = *off_out;
> --
> 2.34.0.rc0.344.g81b53c2807-goog
prev parent reply other threads:[~2021-11-11 2:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-11 1:55 [PATCH] erofs-utils: mkfs: fix integer overflow in erofs_blob_remap David Anderson via Linux-erofs
2021-11-11 2:11 ` Gao Xiang [this message]
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=YYx72rN3ISRcABAI@B-P7TQMD6M-0146.local \
--to=hsiangkao@linux.alibaba.com \
--cc=dvander@google.com \
--cc=linux-erofs@lists.ozlabs.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;
as well as URLs for NNTP newsgroup(s).