From: Hannes Reinecke <hare@suse.de>
To: Ming Lei <ming.lei@redhat.com>, Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
Yi Zhang <yi.zhang@redhat.com>
Subject: Re: [PATCH] block: make sure that bvec length can't be overflowed
Date: Wed, 17 Apr 2019 13:52:49 +0200 [thread overview]
Message-ID: <b36ab484-ce43-67b7-16d4-bdca59fd9e9a@suse.de> (raw)
In-Reply-To: <20190416153847.8173-1-ming.lei@redhat.com>
On 4/16/19 5:38 PM, Ming Lei wrote:
> bvec->bv_offset may be bigger than PAGE_SIZE sometimes, such as,
> when one bio is splitted in the middle of one bvec via bio_split(),
> and bi_iter.bi_bvec_done is used to build offset of the 1st bvec of
> remained bio.
>
> So we have to make sure that every bvec's offset is less than
> PAGE_SIZE from bio_for_each_segment().
>
> This patch fixes this issue reported by Zhang Yi When running nvme/011.
>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Yi Zhang <yi.zhang@redhat.com>
> Reported-by: Yi Zhang <yi.zhang@redhat.com>
> Fixes: 6dc4f100c175 ("block: allow bio_for_each_segment_all() to iterate over multi-page bvec")
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
> include/linux/bvec.h | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/bvec.h b/include/linux/bvec.h
> index 3bc91879e1e2..f179b370066f 100644
> --- a/include/linux/bvec.h
> +++ b/include/linux/bvec.h
> @@ -160,8 +160,9 @@ static inline void bvec_advance(const struct bio_vec *bvec,
> bv->bv_page = nth_page(bv->bv_page, 1);
> bv->bv_offset = 0;
> } else {
> - bv->bv_page = bvec->bv_page;
> - bv->bv_offset = bvec->bv_offset;
> + bv->bv_page = bvec_nth_page(bvec->bv_page, bvec->bv_offset /
> + PAGE_SIZE);
> + bv->bv_offset = bvec->bv_offset % PAGE_SIZE;
> }
> bv->bv_len = min_t(unsigned int, PAGE_SIZE - bv->bv_offset,
> bvec->bv_len - iter_all->done);
>
Looks okay.
Reviewed-by: Hannes Reinecke <hare@suse.com>
Cheers,
Hannes
--
Dr. Hannes Reinecke Teamlead Storage & Networking
hare@suse.de +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)
prev parent reply other threads:[~2019-04-17 11:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-16 15:38 [PATCH] block: make sure that bvec length can't be overflowed Ming Lei
2019-04-16 16:46 ` Christoph Hellwig
2019-04-16 17:03 ` Jens Axboe
2019-04-17 0:48 ` Ming Lei
2019-04-17 11:52 ` Hannes Reinecke [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=b36ab484-ce43-67b7-16d4-bdca59fd9e9a@suse.de \
--to=hare@suse.de \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=yi.zhang@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox