From: Roman Smirnov <r.smirnov@omp.ru>
To: "kbusch@kernel.org" <kbusch@kernel.org>
Cc: Karina Yankevich <k.yankevich@omp.ru>,
"lvc-patches@linuxtesting.org" <lvc-patches@linuxtesting.org>,
"axboe@kernel.dk" <axboe@kernel.dk>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
Sergey Shtylyov <s.shtylyov@omp.ru>
Subject: Re: [bug report] block: integer overflow in __bvec_gap_to_prev()
Date: Thu, 13 Jun 2024 15:27:37 +0000 [thread overview]
Message-ID: <e5e80f92f59c9fea9f9e33bae355d0031ca9e93b.camel@omp.ru> (raw)
In-Reply-To: <ZmhqFLdCW6aXriqP@kbusch-mbp.dhcp.thefacebook.com>
On Tue, 2024-06-11 at 09:15 -0600, Keith Busch wrote:
> On Tue, Jun 11, 2024 at 02:23:48PM +0000, Roman Smirnov wrote:
> > Hello.
> >
> > There is a case of integer overflow in __bvec_gap_to_prev():
> >
> > ((bprv->bv_offset + bprv->bv_len) & lim->virt_boundary_mask);
> >
> > bio_vec can cross multiple pages:
> >
> > https://lore.kernel.org/lkml/20190215111324.30129-1-ming.lei@redhat.com/t/
> >
> > So, in case bio has one bio_vec bv_len can have a maximum value of UINT_MAX.
> > The check happens in bio_full(). In the case when bv_len is equal to
> > UINT_MAX and bv_offset is greater than zero, an overflow may occur.
>
> Does it matter? The lower bits checked against the mask should be the
> same regardless of overflow.
There are several other places where this kind of thing happens:
https://elixir.bootlin.com/linux/latest/source/block/blk-merge.c#L292
https://elixir.bootlin.com/linux/latest/source/block/blk.h#L331
I think in those cases overflow would make a difference.
I also found a comment before __bio_add_page(). It says that the
caller should watch out for free space in bio:
https://elixir.bootlin.com/linux/latest/source/block/bio.c#L1075
But what happens if it doesn't keep a check on it? Such code
won't get into the kernel?
prev parent reply other threads:[~2024-06-13 15:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-11 14:23 Roman Smirnov
2024-06-11 15:15 ` Keith Busch
2024-06-13 15:27 ` Roman Smirnov [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=e5e80f92f59c9fea9f9e33bae355d0031ca9e93b.camel@omp.ru \
--to=r.smirnov@omp.ru \
--cc=axboe@kernel.dk \
--cc=k.yankevich@omp.ru \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-patches@linuxtesting.org \
--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®