From: Jan Kara <jack@suse.cz>
To: Roman Smirnov <r.smirnov@omp.ru>
Cc: Jan Kara <jack@suse.com>,
linux-kernel@vger.kernel.org, Sergey Shtylyov <s.shtylyov@omp.ru>,
lvc-project@linuxtesting.org
Subject: Re: [PATCH] udf: balloc: prevent integer overflow in udf_bitmap_free_blocks()
Date: Tue, 11 Jun 2024 09:48:50 +0200 [thread overview]
Message-ID: <20240611074850.tiaieba2bswwck6d@quack3> (raw)
In-Reply-To: <20240610072523.12002-1-r.smirnov@omp.ru>
On Mon 10-06-24 10:25:22, Roman Smirnov wrote:
> An overflow may occur if the function is called with the last
> block and an offset greater than zero. It is necessary to add
> a check to avoid this.
>
> Found by Linux Verification Center (linuxtesting.org) with Svace.
>
> Signed-off-by: Roman Smirnov <r.smirnov@omp.ru>
Thanks for the patch! Actually there are overflow checks just a few lines
above the place you modify:
if (bloc->logicalBlockNum + count < count ||
(bloc->logicalBlockNum + count) > partmap->s_partition_len) {
So please update those to take 'offset' into account instead. Also please
use check_add_overflow() for the integer overflow check.
Honza
> ---
> fs/udf/balloc.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
> index ab3ffc355949..cd83bbc7d890 100644
> --- a/fs/udf/balloc.c
> +++ b/fs/udf/balloc.c
> @@ -151,6 +151,13 @@ static void udf_bitmap_free_blocks(struct super_block *sb,
> block = bloc->logicalBlockNum + offset +
> (sizeof(struct spaceBitmapDesc) << 3);
>
> + if (block < offset + (sizeof(struct spaceBitmapDesc) << 3)) {
> + udf_debug("integer overflow: %u + %u + %zu",
> + bloc->logicalBlockNum, offset,
> + sizeof(struct spaceBitmapDesc) << 3);
> + goto error_return;
> + }
> +
> do {
> overflow = 0;
> block_group = block >> (sb->s_blocksize_bits + 3);
> --
> 2.34.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
prev parent reply other threads:[~2024-06-11 7:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-10 7:25 Roman Smirnov
2024-06-10 17:50 ` Sergey Shtylyov
2024-06-10 17:50 ` Sergey Shtylyov
2024-06-11 7:48 ` Jan Kara [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=20240611074850.tiaieba2bswwck6d@quack3 \
--to=jack@suse.cz \
--cc=jack@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=r.smirnov@omp.ru \
--cc=s.shtylyov@omp.ru \
/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
all inboxes | Powered by JetHome®