From: Mikulas Patocka <mpatocka@redhat.com>
To: Ivan Abramov <i.abramov@mt-integration.ru>
Cc: Alasdair Kergon <agk@redhat.com>,
Mike Snitzer <snitzer@kernel.org>,
dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org,
lvc-project@linuxtesting.org
Subject: Re: [PATCH 1/1] dm-integrity: Remove unreachable code in dm_integrity_ctr()
Date: Mon, 8 Sep 2025 15:44:59 +0200 (CEST) [thread overview]
Message-ID: <b4a06abf-eb97-055a-a986-6e629c59ca1b@redhat.com> (raw)
In-Reply-To: <20250908120831.135419-1-i.abramov@mt-integration.ru>
Hi
What if someone changes it to a larger type later? I think that if this
branch doesn't do any harm and if it protects us from memory errors
introduced by future changes, we may let it be there.
But I found another bug when looking at this - the user may set tag size
up to MAX_TAG_SIZE (that is 0x1a8) and that gets truncated when it is
assigned in "bi->metadata_size = ic->tag_size". I need to limit
MAX_TAG_SIZE to 255.
Mikulas
On Mon, 8 Sep 2025, Ivan Abramov wrote:
> Since bi->metadata_size is an unsigned char, it's not practically
> possible for it to be > PAGE_SIZE / 2.
>
> Thus, remove the corresponding if statement.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Ivan Abramov <i.abramov@mt-integration.ru>
> ---
> drivers/md/dm-integrity.c | 5 -----
> 1 file changed, 5 deletions(-)
>
> diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
> index efeee0a873c0..b7ad7a5adb56 100644
> --- a/drivers/md/dm-integrity.c
> +++ b/drivers/md/dm-integrity.c
> @@ -4752,11 +4752,6 @@ static int dm_integrity_ctr(struct dm_target *ti, unsigned int argc, char **argv
> ti->error = "The integrity profile is smaller than tag size";
> goto bad;
> }
> - if ((unsigned long)bi->metadata_size > PAGE_SIZE / 2) {
> - r = -EINVAL;
> - ti->error = "Too big tuple size";
> - goto bad;
> - }
> ic->tuple_size = bi->metadata_size;
> if (1 << bi->interval_exp != ic->sectors_per_block << SECTOR_SHIFT) {
> r = -EINVAL;
> --
> 2.39.5
>
>
prev parent reply other threads:[~2025-09-08 13:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-08 12:08 Ivan Abramov
2025-09-08 13:44 ` Mikulas Patocka [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=b4a06abf-eb97-055a-a986-6e629c59ca1b@redhat.com \
--to=mpatocka@redhat.com \
--cc=agk@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=i.abramov@mt-integration.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=snitzer@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
all inboxes | Powered by JetHome®