From: "Marek Behún" <kabel@kernel.org>
To: Alex Shumsky <alexthreed@gmail.com>
Cc: u-boot@lists.denx.de, Dan Carpenter <dan.carpenter@linaro.org>,
Qu Wenruo <wqu@suse.com>, Tom Rini <trini@konsulko.com>,
linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] fs: btrfs: fix out of bounds write
Date: Tue, 18 Jun 2024 09:45:53 +0200 [thread overview]
Message-ID: <20240618094553.68a79daf@dellmb> (raw)
In-Reply-To: <20240617194947.1928008-1-alexthreed@gmail.com>
On Mon, 17 Jun 2024 22:49:47 +0300
Alex Shumsky <alexthreed@gmail.com> wrote:
> Fix btrfs_read/read_and_truncate_page write out of bounds of destination
> buffer. Old behavior break bootstd malloc'd buffers of exact file size.
> Previously this OOB write have not been noticed because distroboot usually
> read files into huge static memory areas.
>
> Signed-off-by: Alex Shumsky <alexthreed@gmail.com>
> ---
>
> fs/btrfs/inode.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 4691612eda..b51f578b49 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -640,7 +640,7 @@ static int read_and_truncate_page(struct btrfs_path *path,
> extent_type = btrfs_file_extent_type(leaf, fi);
> if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
> ret = btrfs_read_extent_inline(path, fi, buf);
> - memcpy(dest, buf + page_off, min(page_len, ret));
> + memcpy(dest, buf + page_off, min(min(page_len, ret), len));
Use min3() instead of min(min())
prev parent reply other threads:[~2024-06-18 7:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-17 19:49 [PATCH] fs: btrfs: fix out of bounds write Alex Shumsky
2024-06-17 22:22 ` Qu Wenruo
2024-06-18 6:03 ` David Disseldorp
2024-06-18 6:41 ` Dan Carpenter
2024-06-18 7:45 ` Marek Behún [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=20240618094553.68a79daf@dellmb \
--to=kabel@kernel.org \
--cc=alexthreed@gmail.com \
--cc=dan.carpenter@linaro.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=wqu@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.