lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <x4937xci44a.fsf@segfault.boston.devel.redhat.com>
Date:	Thu, 15 Oct 2015 10:43:49 -0400
From:	Jeff Moyer <jmoyer@...hat.com>
To:	Junichi Nomura <j-nomura@...jp.nec.com>
Cc:	Jens Axboe <axboe@...nel.dk>,
	"linux-kernel\@vger.kernel.org" <linux-kernel@...r.kernel.org>,
	Keith Busch <keith.busch@...el.com>,
	"axboe\@fb.com" <axboe@...com>
Subject: Re: [PATCH] blk-mq: fix use-after-free in blk_mq_free_tag_set()

Junichi Nomura <j-nomura@...jp.nec.com> writes:

> tags is freed in blk_mq_free_rq_map() and should not be used after that.
> The problem doesn't manifest if CONFIG_CPUMASK_OFFSTACK is false because
> free_cpumask_var() is nop.
>
> tags->cpumask is allocated in blk_mq_init_tags() so it's natural to
> free cpumask in its counter part, blk_mq_free_tags().
>
> Fixes: f26cdc8536ad ("blk-mq: Shared tag enhancements")
> Signed-off-by: Jun'ichi Nomura <j-nomura@...jp.nec.com>
> Cc: Keith Busch <keith.busch@...el.com>
> Cc: Jens Axboe <axboe@...com>

Reviewed-by: Jeff Moyer <jmoyer@...hat.com>


> ---
>  block/blk-mq-tag.c | 1 +
>  block/blk-mq.c     | 4 +---
>  2 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
> index ed96474..ec2d119 100644
> --- a/block/blk-mq-tag.c
> +++ b/block/blk-mq-tag.c
> @@ -641,6 +641,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 7785ae9..85f0143 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -2296,10 +2296,8 @@ 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]) {
> +		if (set->tags[i])
>  			blk_mq_free_rq_map(set, set->tags[i], i);
> -			free_cpumask_var(set->tags[i]->cpumask);
> -		}
>  	}
>  
>  	kfree(set->tags);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ