All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Thumshirn <jthumshirn@suse.de>
To: Jens Axboe <axboe@fb.com>
Cc: Hannes Reinecke <hare@suse.de>,
	Bart Van Assche <bvanassche@acm.org>,
	Christoph Hellwig <hch@lst.de>, Jan Kara <jack@suse.cz>,
	Linux Block Layer Mailinglist <linux-block@vger.kernel.org>,
	Linux FSDEVEL Mailinglist <linux-fsdevel@vger.kernel.org>,
	Johannes Thumshirn <jthumshirn@suse.de>
Subject: [PATCH 0/2] add flag for tracking bio allocation
Date: Thu, 21 Mar 2019 13:30:43 +0100	[thread overview]
Message-ID: <20190321123045.32396-1-jthumshirn@suse.de> (raw)

Hannes recently sent a patch in [1] to fix an Oops caused by
__blkdev_direct_IO_simple() doing bio submissions from the stack and which
ended up being freed bio bio_free(). As bio_free() expected a bio which was
allocated by bio_alloc_bioset() it crashed.

I've sent out a different aproach to tackling this problem and both Jens and
Jan leaned to my solution, namely adding another bio flag tracking the
allocation.

As flag is the last available bit, add a compile time check as a safety net,
so we're not accidentially overriding the high 3 bits of bi_flags, which are
used for the BVEC_POOL_IDX().

Note, Jens also staged a patch in his io_uring-next branch taking the last
flag. For this reason patch 2/2 might not be applied in this form, but 1/2 is
still applicable then.

[1] https://lore.kernel.org/linux-block/20190320081253.129688-1-hare@suse.de/

Johannes Thumshirn (2):
  block: bio: ensure newly added bio flags don't override BVEC_POOL_IDX
  bio: introduce BIO_ALLOCED flag and check it in bio_free

 block/bio.c               | 12 ++++++++++++
 include/linux/blk_types.h | 32 ++++++++++++++++++--------------
 2 files changed, 30 insertions(+), 14 deletions(-)

-- 
2.16.4


             reply	other threads:[~2019-03-21 12:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-21 12:30 Johannes Thumshirn [this message]
2019-03-21 12:30 ` [PATCH 1/2] block: bio: ensure newly added bio flags don't override BVEC_POOL_IDX Johannes Thumshirn
2019-03-21 13:18   ` Hannes Reinecke
2019-03-21 13:22     ` Johannes Thumshirn
2019-03-21 14:15   ` Jens Axboe
2019-03-21 14:21     ` Jens Axboe
2019-03-21 14:23       ` Johannes Thumshirn
2019-03-21 14:25         ` Jens Axboe
2019-03-21 15:54           ` Hannes Reinecke
2019-03-22 10:24           ` Johannes Thumshirn
2019-03-21 12:30 ` [PATCH 2/2] bio: introduce BIO_ALLOCED flag and check it in bio_free Johannes Thumshirn

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=20190321123045.32396-1-jthumshirn@suse.de \
    --to=jthumshirn@suse.de \
    --cc=axboe@fb.com \
    --cc=bvanassche@acm.org \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=jack@suse.cz \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.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 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.