* [PATCH] block: bio: ensure newly added bio flags don't override BVEC_POOL_IDX
@ 2019-04-03 9:15 Johannes Thumshirn
2019-04-03 9:57 ` Ming Lei
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Johannes Thumshirn @ 2019-04-03 9:15 UTC (permalink / raw)
To: Jens Axboe
Cc: Linux Block Layer Mailinglist, Linux FSDEVEL Mailinglist,
Christoph Hellwig, Hannes Reinecke, Johannes Thumshirn
With the introduction of BIO_NO_PAGE_REF we've used up all available bits
in bio::bi_flags.
Convert the defines of the flags to an enum and add a BUILD_BUG_ON() call
to make sure no-one adds a new one and thus overrides the BVEC_POOL_IDX
causing crashes.
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
This used to be part of my bio patchset but as it's a) not clear why we
end up calling bio_put() on the on-stack bio and b) the needed prep patch
for the fix introduces a regression, I've decided to sent this patch out
as it's valid on it's own.
I dropped Hannes' and Christoph's R-b though, as the context changed.
---
block/bio.c | 3 +++
include/linux/blk_types.h | 29 ++++++++++++++++-------------
2 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/block/bio.c b/block/bio.c
index 8d516d508ae3..c2592c5d70b9 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -2218,6 +2218,9 @@ static int __init init_bio(void)
bio_slab_nr = 0;
bio_slabs = kcalloc(bio_slab_max, sizeof(struct bio_slab),
GFP_KERNEL);
+
+ BUILD_BUG_ON(BIO_FLAG_LAST > BVEC_POOL_OFFSET);
+
if (!bio_slabs)
panic("bio: can't allocate bios\n");
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 791fee35df88..be418275763c 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -215,21 +215,24 @@ struct bio {
/*
* bio flags
*/
-#define BIO_NO_PAGE_REF 0 /* don't put release vec pages */
-#define BIO_SEG_VALID 1 /* bi_phys_segments valid */
-#define BIO_CLONED 2 /* doesn't own data */
-#define BIO_BOUNCED 3 /* bio is a bounce bio */
-#define BIO_USER_MAPPED 4 /* contains user pages */
-#define BIO_NULL_MAPPED 5 /* contains invalid user pages */
-#define BIO_QUIET 6 /* Make BIO Quiet */
-#define BIO_CHAIN 7 /* chained bio, ->bi_remaining in effect */
-#define BIO_REFFED 8 /* bio has elevated ->bi_cnt */
-#define BIO_THROTTLED 9 /* This bio has already been subjected to
+enum {
+ BIO_NO_PAGE_REF, /* don't put release vec pages */
+ BIO_SEG_VALID, /* bi_phys_segments valid */
+ BIO_CLONED, /* doesn't own data */
+ BIO_BOUNCED, /* bio is a bounce bio */
+ BIO_USER_MAPPED, /* contains user pages */
+ BIO_NULL_MAPPED, /* contains invalid user pages */
+ BIO_QUIET, /* Make BIO Quiet */
+ BIO_CHAIN, /* chained bio, ->bi_remaining in effect */
+ BIO_REFFED, /* bio has elevated ->bi_cnt */
+ BIO_THROTTLED, /* This bio has already been subjected to
* throttling rules. Don't do it again. */
-#define BIO_TRACE_COMPLETION 10 /* bio_endio() should trace the final completion
+ BIO_TRACE_COMPLETION, /* bio_endio() should trace the final completion
* of this bio. */
-#define BIO_QUEUE_ENTERED 11 /* can use blk_queue_enter_live() */
-#define BIO_TRACKED 12 /* set if bio goes through the rq_qos path */
+ BIO_QUEUE_ENTERED, /* can use blk_queue_enter_live() */
+ BIO_TRACKED, /* set if bio goes through the rq_qos path */
+ BIO_FLAG_LAST
+};
/* See BVEC_POOL_OFFSET below before adding new flags */
--
2.16.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] block: bio: ensure newly added bio flags don't override BVEC_POOL_IDX
2019-04-03 9:15 [PATCH] block: bio: ensure newly added bio flags don't override BVEC_POOL_IDX Johannes Thumshirn
@ 2019-04-03 9:57 ` Ming Lei
2019-04-03 12:03 ` Hannes Reinecke
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Ming Lei @ 2019-04-03 9:57 UTC (permalink / raw)
To: Johannes Thumshirn
Cc: Jens Axboe, Linux Block Layer Mailinglist,
Linux FSDEVEL Mailinglist, Christoph Hellwig, Hannes Reinecke
On Wed, Apr 3, 2019 at 5:16 PM Johannes Thumshirn <jthumshirn@suse.de> wrote:
>
> With the introduction of BIO_NO_PAGE_REF we've used up all available bits
> in bio::bi_flags.
>
> Convert the defines of the flags to an enum and add a BUILD_BUG_ON() call
> to make sure no-one adds a new one and thus overrides the BVEC_POOL_IDX
> causing crashes.
>
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
>
> ---
> This used to be part of my bio patchset but as it's a) not clear why we
> end up calling bio_put() on the on-stack bio and b) the needed prep patch
> for the fix introduces a regression, I've decided to sent this patch out
> as it's valid on it's own.
>
> I dropped Hannes' and Christoph's R-b though, as the context changed.
> ---
> block/bio.c | 3 +++
> include/linux/blk_types.h | 29 ++++++++++++++++-------------
> 2 files changed, 19 insertions(+), 13 deletions(-)
>
> diff --git a/block/bio.c b/block/bio.c
> index 8d516d508ae3..c2592c5d70b9 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -2218,6 +2218,9 @@ static int __init init_bio(void)
> bio_slab_nr = 0;
> bio_slabs = kcalloc(bio_slab_max, sizeof(struct bio_slab),
> GFP_KERNEL);
> +
> + BUILD_BUG_ON(BIO_FLAG_LAST > BVEC_POOL_OFFSET);
> +
> if (!bio_slabs)
> panic("bio: can't allocate bios\n");
>
> diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
> index 791fee35df88..be418275763c 100644
> --- a/include/linux/blk_types.h
> +++ b/include/linux/blk_types.h
> @@ -215,21 +215,24 @@ struct bio {
> /*
> * bio flags
> */
> -#define BIO_NO_PAGE_REF 0 /* don't put release vec pages */
> -#define BIO_SEG_VALID 1 /* bi_phys_segments valid */
> -#define BIO_CLONED 2 /* doesn't own data */
> -#define BIO_BOUNCED 3 /* bio is a bounce bio */
> -#define BIO_USER_MAPPED 4 /* contains user pages */
> -#define BIO_NULL_MAPPED 5 /* contains invalid user pages */
> -#define BIO_QUIET 6 /* Make BIO Quiet */
> -#define BIO_CHAIN 7 /* chained bio, ->bi_remaining in effect */
> -#define BIO_REFFED 8 /* bio has elevated ->bi_cnt */
> -#define BIO_THROTTLED 9 /* This bio has already been subjected to
> +enum {
> + BIO_NO_PAGE_REF, /* don't put release vec pages */
> + BIO_SEG_VALID, /* bi_phys_segments valid */
> + BIO_CLONED, /* doesn't own data */
> + BIO_BOUNCED, /* bio is a bounce bio */
> + BIO_USER_MAPPED, /* contains user pages */
> + BIO_NULL_MAPPED, /* contains invalid user pages */
> + BIO_QUIET, /* Make BIO Quiet */
> + BIO_CHAIN, /* chained bio, ->bi_remaining in effect */
> + BIO_REFFED, /* bio has elevated ->bi_cnt */
> + BIO_THROTTLED, /* This bio has already been subjected to
> * throttling rules. Don't do it again. */
> -#define BIO_TRACE_COMPLETION 10 /* bio_endio() should trace the final completion
> + BIO_TRACE_COMPLETION, /* bio_endio() should trace the final completion
> * of this bio. */
> -#define BIO_QUEUE_ENTERED 11 /* can use blk_queue_enter_live() */
> -#define BIO_TRACKED 12 /* set if bio goes through the rq_qos path */
> + BIO_QUEUE_ENTERED, /* can use blk_queue_enter_live() */
> + BIO_TRACKED, /* set if bio goes through the rq_qos path */
> + BIO_FLAG_LAST
> +};
>
> /* See BVEC_POOL_OFFSET below before adding new flags */
Looks fine,
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Thanks,
Ming Lei
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] block: bio: ensure newly added bio flags don't override BVEC_POOL_IDX
2019-04-03 9:15 [PATCH] block: bio: ensure newly added bio flags don't override BVEC_POOL_IDX Johannes Thumshirn
2019-04-03 9:57 ` Ming Lei
@ 2019-04-03 12:03 ` Hannes Reinecke
2019-04-03 15:34 ` Bart Van Assche
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Hannes Reinecke @ 2019-04-03 12:03 UTC (permalink / raw)
To: Johannes Thumshirn, Jens Axboe
Cc: Linux Block Layer Mailinglist, Linux FSDEVEL Mailinglist,
Christoph Hellwig
On 4/3/19 11:15 AM, Johannes Thumshirn wrote:
> With the introduction of BIO_NO_PAGE_REF we've used up all available bits
> in bio::bi_flags.
>
> Convert the defines of the flags to an enum and add a BUILD_BUG_ON() call
> to make sure no-one adds a new one and thus overrides the BVEC_POOL_IDX
> causing crashes.
>
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
>
> ---
> This used to be part of my bio patchset but as it's a) not clear why we
> end up calling bio_put() on the on-stack bio and b) the needed prep patch
> for the fix introduces a regression, I've decided to sent this patch out
> as it's valid on it's own.
>
> I dropped Hannes' and Christoph's R-b though, as the context changed.
> ---
> block/bio.c | 3 +++
> include/linux/blk_types.h | 29 ++++++++++++++++-------------
> 2 files changed, 19 insertions(+), 13 deletions(-)
>
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)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] block: bio: ensure newly added bio flags don't override BVEC_POOL_IDX
2019-04-03 9:15 [PATCH] block: bio: ensure newly added bio flags don't override BVEC_POOL_IDX Johannes Thumshirn
2019-04-03 9:57 ` Ming Lei
2019-04-03 12:03 ` Hannes Reinecke
@ 2019-04-03 15:34 ` Bart Van Assche
2019-04-03 19:50 ` Christoph Hellwig
2019-04-04 15:31 ` Jens Axboe
4 siblings, 0 replies; 6+ messages in thread
From: Bart Van Assche @ 2019-04-03 15:34 UTC (permalink / raw)
To: Johannes Thumshirn, Jens Axboe
Cc: Linux Block Layer Mailinglist, Linux FSDEVEL Mailinglist,
Christoph Hellwig, Hannes Reinecke
On Wed, 2019-04-03 at 11:15 +0200, Johannes Thumshirn wrote:
> With the introduction of BIO_NO_PAGE_REF we've used up all available bits
> in bio::bi_flags.
>
> Convert the defines of the flags to an enum and add a BUILD_BUG_ON() call
> to make sure no-one adds a new one and thus overrides the BVEC_POOL_IDX
> causing crashes.
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] block: bio: ensure newly added bio flags don't override BVEC_POOL_IDX
2019-04-03 9:15 [PATCH] block: bio: ensure newly added bio flags don't override BVEC_POOL_IDX Johannes Thumshirn
` (2 preceding siblings ...)
2019-04-03 15:34 ` Bart Van Assche
@ 2019-04-03 19:50 ` Christoph Hellwig
2019-04-04 15:31 ` Jens Axboe
4 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2019-04-03 19:50 UTC (permalink / raw)
To: Johannes Thumshirn
Cc: Jens Axboe, Linux Block Layer Mailinglist,
Linux FSDEVEL Mailinglist, Christoph Hellwig, Hannes Reinecke
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] block: bio: ensure newly added bio flags don't override BVEC_POOL_IDX
2019-04-03 9:15 [PATCH] block: bio: ensure newly added bio flags don't override BVEC_POOL_IDX Johannes Thumshirn
` (3 preceding siblings ...)
2019-04-03 19:50 ` Christoph Hellwig
@ 2019-04-04 15:31 ` Jens Axboe
4 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2019-04-04 15:31 UTC (permalink / raw)
To: Johannes Thumshirn
Cc: Linux Block Layer Mailinglist, Linux FSDEVEL Mailinglist,
Christoph Hellwig, Hannes Reinecke
On 4/3/19 3:15 AM, Johannes Thumshirn wrote:
> With the introduction of BIO_NO_PAGE_REF we've used up all available bits
> in bio::bi_flags.
>
> Convert the defines of the flags to an enum and add a BUILD_BUG_ON() call
> to make sure no-one adds a new one and thus overrides the BVEC_POOL_IDX
> causing crashes.
Applied for 5.2, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-04-04 15:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-03 9:15 [PATCH] block: bio: ensure newly added bio flags don't override BVEC_POOL_IDX Johannes Thumshirn
2019-04-03 9:57 ` Ming Lei
2019-04-03 12:03 ` Hannes Reinecke
2019-04-03 15:34 ` Bart Van Assche
2019-04-03 19:50 ` Christoph Hellwig
2019-04-04 15:31 ` Jens Axboe
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.