From patchwork Thu Mar 10 11:53:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Kleibel X-Patchwork-Id: 12776285 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D657CC433FE for ; Thu, 10 Mar 2022 12:29:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237432AbiCJMa6 (ORCPT ); Thu, 10 Mar 2022 07:30:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235393AbiCJMa6 (ORCPT ); Thu, 10 Mar 2022 07:30:58 -0500 Received: from iris.vrvis.at (iris.vrvis.at [92.60.8.8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7990E818A5; Thu, 10 Mar 2022 04:29:57 -0800 (PST) Received: from [10.43.0.34] by iris.vrvis.at with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nSHLq-0005Vw-31; Thu, 10 Mar 2022 12:53:02 +0100 Message-ID: Date: Thu, 10 Mar 2022 12:53:01 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Content-Language: en-US To: stable@vger.kernel.org, Greg Kroah-Hartman From: Valentin Kleibel Cc: Jens Axboe , Justin Sanders , linux-block@vger.kernel.org Subject: [PATCH] block: aoe: fix page fault in freedev() Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org There is a bug in the aoe driver module where every forcible removal of an aoe device (eg. "rmmod aoe" with aoe devices available or "aoe-flush ex.x") leads to a page fault. The code in freedev() calls blk_mq_free_tag_set() before running blk_cleanup_queue() which leads to this issue (drivers/block/aoe/aoedev.c L281ff). This issue was fixed upstream in commit 6560ec9 (aoe: use blk_mq_alloc_disk and blk_cleanup_disk) with the introduction and use of the function blk_cleanup_disk(). This patch applies to kernels 5.4 and 5.10. The function calls are reordered to match the behavior of blk_cleanup_disk() to mitigate this issue. Fixes: 3582dd2 (aoe: convert aoeblk to blk-mq) Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=215647 Signed-off-by: Valentin Kleibel --- drivers/block/aoe/aoedev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c index e2ea2356da06..08c98ea724ea 100644 --- a/drivers/block/aoe/aoedev.c +++ b/drivers/block/aoe/aoedev.c @@ -277,9 +277,9 @@ freedev(struct aoedev *d) if (d->gd) { aoedisk_rm_debugfs(d); del_gendisk(d->gd); + blk_cleanup_queue(d->blkq); put_disk(d->gd); blk_mq_free_tag_set(&d->tag_set); - blk_cleanup_queue(d->blkq); } t = d->targets; e = t + d->ntargets;