From: Mike Snitzer <snitzer@kernel.org>
To: Jens Axboe <axboe@kernel.dk>, Mikulas Patocka <mpatocka@redhat.com>
Cc: linux-block@vger.kernel.org,
"Darrick J. Wong" <djwong@kernel.org>,
dm-devel@redhat.com, Christoph Hellwig <hch@lst.de>,
Matthew Wilcox <willy@infradead.org>
Subject: Re: [dm-devel] block: fix a crash when bio_for_each_folio_all iterates over an empty bio
Date: Tue, 18 Apr 2023 11:20:33 -0400 [thread overview]
Message-ID: <ZD61QWC6TW59anIM@redhat.com> (raw)
In-Reply-To: <alpine.LRH.2.21.2304171433370.17217@file01.intranet.prod.int.rdu2.redhat.com>
On Mon, Apr 17 2023 at 3:11P -0400,
Mikulas Patocka <mpatocka@redhat.com> wrote:
> If we use bio_for_each_folio_all on an empty bio, it will access the first
> bio vector unconditionally (it is uninitialized) and it may crash
> depending on the uninitialized data.
>
> This patch fixes it by checking the parameter "i" against "bio->bi_vcnt"
> and returning NULL fi->folio if it is out of range.
>
> The patch also drops the test "if (fi->_i + 1 < bio->bi_vcnt)" from
> bio_next_folio because the same condition is already being checked in
> bio_first_folio.
>
> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
This fix is a prereq for this dm-crypt patch to use folios:
https://patchwork.kernel.org/project/dm-devel/patch/alpine.LRH.2.21.2302161619430.5436@file01.intranet.prod.int.rdu2.redhat.com/
Mikulas explained why an empty bio is possible here:
https://listman.redhat.com/archives/dm-devel/2023-April/053916.html
Reviewed-by: Mike Snitzer <snitzer@kernel.org>
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
WARNING: multiple messages have this Message-ID (diff)
From: Mike Snitzer <snitzer@kernel.org>
To: Jens Axboe <axboe@kernel.dk>, Mikulas Patocka <mpatocka@redhat.com>
Cc: Matthew Wilcox <willy@infradead.org>,
Christoph Hellwig <hch@lst.de>,
"Darrick J. Wong" <djwong@kernel.org>,
dm-devel@redhat.com, linux-block@vger.kernel.org
Subject: Re: block: fix a crash when bio_for_each_folio_all iterates over an empty bio
Date: Tue, 18 Apr 2023 11:20:33 -0400 [thread overview]
Message-ID: <ZD61QWC6TW59anIM@redhat.com> (raw)
In-Reply-To: <alpine.LRH.2.21.2304171433370.17217@file01.intranet.prod.int.rdu2.redhat.com>
On Mon, Apr 17 2023 at 3:11P -0400,
Mikulas Patocka <mpatocka@redhat.com> wrote:
> If we use bio_for_each_folio_all on an empty bio, it will access the first
> bio vector unconditionally (it is uninitialized) and it may crash
> depending on the uninitialized data.
>
> This patch fixes it by checking the parameter "i" against "bio->bi_vcnt"
> and returning NULL fi->folio if it is out of range.
>
> The patch also drops the test "if (fi->_i + 1 < bio->bi_vcnt)" from
> bio_next_folio because the same condition is already being checked in
> bio_first_folio.
>
> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
This fix is a prereq for this dm-crypt patch to use folios:
https://patchwork.kernel.org/project/dm-devel/patch/alpine.LRH.2.21.2302161619430.5436@file01.intranet.prod.int.rdu2.redhat.com/
Mikulas explained why an empty bio is possible here:
https://listman.redhat.com/archives/dm-devel/2023-April/053916.html
Reviewed-by: Mike Snitzer <snitzer@kernel.org>
next prev parent reply other threads:[~2023-04-18 15:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-17 19:11 [dm-devel] [PATCH] block: fix a crash when bio_for_each_folio_all iterates over an empty bio Mikulas Patocka
2023-04-17 19:11 ` Mikulas Patocka
2023-04-17 19:32 ` [dm-devel] " Matthew Wilcox
2023-04-17 19:32 ` Matthew Wilcox
2023-04-17 19:56 ` [dm-devel] " Mikulas Patocka
2023-04-17 19:56 ` Mikulas Patocka
2023-04-18 4:57 ` [dm-devel] " Christoph Hellwig
2023-04-18 4:57 ` Christoph Hellwig
2023-04-18 15:20 ` Mike Snitzer [this message]
2023-04-18 15:20 ` Mike Snitzer
2023-06-09 13:22 ` [dm-devel] " Mike Snitzer
2023-06-09 13:22 ` Mike Snitzer
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=ZD61QWC6TW59anIM@redhat.com \
--to=snitzer@kernel.org \
--cc=axboe@kernel.dk \
--cc=djwong@kernel.org \
--cc=dm-devel@redhat.com \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=mpatocka@redhat.com \
--cc=willy@infradead.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 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.