Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1249029 > unrolled thread

Re: [PATCH] blk-mq: use after free when freeing tag sets

Started bySasha Levin <sasha.levin@oracle.com>
First post2015-10-16 20:00 +0200
Last post2015-10-16 20:10 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] blk-mq: use after free when freeing tag sets Sasha Levin <sasha.levin@oracle.com> - 2015-10-16 20:00 +0200
    RE: [PATCH] blk-mq: use after free when freeing tag sets "Busch, Keith" <keith.busch@intel.com> - 2015-10-16 20:10 +0200

#1249029 — Re: [PATCH] blk-mq: use after free when freeing tag sets

FromSasha Levin <sasha.levin@oracle.com>
Date2015-10-16 20:00 +0200
SubjectRe: [PATCH] blk-mq: use after free when freeing tag sets
Message-ID<qkhsl-5d8-1@gated-at.bofh.it>
ping?

On 10/02/2015 09:40 PM, Sasha Levin wrote:
> Commit f26cdc853 ("blk-mq: Shared tag enhancements") has introduced a use after
> free where it tried to free the cpumask var out of the tag set but the tag set
> was already freed by blk_mq_free_rq_map().
> 
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> ---
>  block/blk-mq-tag.c |    1 +
>  block/blk-mq.c     |    7 ++-----
>  2 files changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
> index f6020c6..c03eeb8 100644
> --- a/block/blk-mq-tag.c
> +++ b/block/blk-mq-tag.c
> @@ -628,6 +628,7 @@ void blk_mq_free_tags(struct blk_mq_tags *tags)
>  {
>  	bt_free(&tags->bitmap_tags);
>  	bt_free(&tags->breserved_tags);
> +	free_cpumask_var(tags->cpumask);
>  	kfree(tags);
>  }
>  
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 5692c15..197a615 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -2270,12 +2270,9 @@ void blk_mq_free_tag_set(struct blk_mq_tag_set *set)
>  {
>  	int i;
>  
> -	for (i = 0; i < set->nr_hw_queues; i++) {
> -		if (set->tags[i]) {
> +	for (i = 0; i < set->nr_hw_queues; i++)
> +		if (set->tags[i])
>  			blk_mq_free_rq_map(set, set->tags[i], i);
> -			free_cpumask_var(set->tags[i]->cpumask);
> -		}
> -	}
>  
>  	kfree(set->tags);
>  	set->tags = NULL;
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1249033

From"Busch, Keith" <keith.busch@intel.com>
Date2015-10-16 20:10 +0200
Message-ID<qkhC2-5DI-9@gated-at.bofh.it>
In reply to#1249029
Oh, the same fix was applied from another developer:

https://git.kernel.org/cgit/linux/kernel/git/axboe/linux-block.git/commit/?h=for-linus&id=f42d79ab67322e51b92dd7aa965e310c71352a64

Yours came first, though I just missed it.


> On 10/02/2015 09:40 PM, Sasha Levin wrote:
> > Commit f26cdc853 ("blk-mq: Shared tag enhancements") has introduced a use after
> > free where it tried to free the cpumask var out of the tag set but the tag set
> > was already freed by blk_mq_free_rq_map().
> >
> > Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> > ---
> >  block/blk-mq-tag.c |    1 +
> >  block/blk-mq.c     |    7 ++-----
> >  2 files changed, 3 insertions(+), 5 deletions(-)
> >
> > diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
> > index f6020c6..c03eeb8 100644
> > --- a/block/blk-mq-tag.c
> > +++ b/block/blk-mq-tag.c
> > @@ -628,6 +628,7 @@ void blk_mq_free_tags(struct blk_mq_tags *tags)
> >  {
> >  	bt_free(&tags->bitmap_tags);
> >  	bt_free(&tags->breserved_tags);
> > +	free_cpumask_var(tags->cpumask);
> >  	kfree(tags);
> >  }
> >
> > diff --git a/block/blk-mq.c b/block/blk-mq.c
> > index 5692c15..197a615 100644
> > --- a/block/blk-mq.c
> > +++ b/block/blk-mq.c
> > @@ -2270,12 +2270,9 @@ void blk_mq_free_tag_set(struct blk_mq_tag_set *set)
> >  {
> >  	int i;
> >
> > -	for (i = 0; i < set->nr_hw_queues; i++) {
> > -		if (set->tags[i]) {
> > +	for (i = 0; i < set->nr_hw_queues; i++)
> > +		if (set->tags[i])
> >  			blk_mq_free_rq_map(set, set->tags[i], i);
> > -			free_cpumask_var(set->tags[i]->cpumask);
> > -		}
> > -	}
> >
> >  	kfree(set->tags);
> >  	set->tags = NULL;
> >

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web