From patchwork Thu Aug 9 14:53:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10561515 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4BC4A1057 for ; Thu, 9 Aug 2018 14:53:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B3D02B559 for ; Thu, 9 Aug 2018 14:53:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38BD92B237; Thu, 9 Aug 2018 14:53:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A37642B5C5 for ; Thu, 9 Aug 2018 14:53:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732440AbeHIRTM (ORCPT ); Thu, 9 Aug 2018 13:19:12 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:55108 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732399AbeHIRTL (ORCPT ); Thu, 9 Aug 2018 13:19:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1533826438; x=1565362438; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=L2Oo1bzdEYY3hWMp3Bc7Whq+0W191dGEJHDqlhJJlIw=; b=P3gLxcxsI+f/PCN7p/G+jrHmDphyU0ZFLKC1tJaDaK/L1v172Ccc4FtG N6t8DAXrhEMc4JIQbHpM8c0M0ksHkk6xW3Tq/BeY4ZiQhBVLPiB4A4d/u zzj484RmVoRmFD7SQ8yj+RpW4RLqYNWNmBNLKKdTQQU9oQow4daWUyAAd nHfwZC7pxfB5ruxh7T2ypA0VxyuejfLmyZHPLBiLl8pTupcTc+wf7gt/h D45e5Mja1KkFBidOH3xyVXae4cdfS0cwRJIESjkjQqI5XKNu5jIAQiwuG v2KQjs4/U+DQlBUgJnaf9BIkzThyEcA6DcvM/ZNRvnl28zk4X2fFJFbyO Q==; X-IronPort-AV: E=Sophos;i="5.53,215,1531756800"; d="scan'208";a="184535012" Received: from mail-sn1nam04lp0084.outbound.protection.outlook.com (HELO NAM04-SN1-obe.outbound.protection.outlook.com) ([216.32.180.84]) by ob1.hgst.iphmx.com with ESMTP; 09 Aug 2018 22:53:57 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lW8ZHIowgu7w5Gj6AZDoWHkpAn0SzCcunPXP7eHSpfU=; b=NOiwQLdNxb2cBjKXw38eH9jRoiimmQXCSFViEQg40xJImQ349ZMIrSBIKwmmtmJgOAHYXIgJtWSdDtI3Yz9jZQ8ETxtI6NITp0BtXrxCcsI1tsKKG37YE/vO1O4LreYuE7UGz6lXRgn9Biz2GJw4n3afFGM6FzXSNmTr4EsvuME= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; Received: from asus.hsd1.ca.comcast.net (174.62.111.89) by DM5PR04MB1196.namprd04.prod.outlook.com (2603:10b6:3:a3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.17; Thu, 9 Aug 2018 14:53:53 +0000 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Tejun Heo , Ming Lei , Alexandru Moise <00moses.alexander00@gmail.com>, Joseph Qi , stable@vger.kernel.org Subject: [PATCH v5 3/3] block: Ensure that a request queue is dissociated from the cgroup controller Date: Thu, 9 Aug 2018 07:53:38 -0700 Message-Id: <20180809145338.6160-4-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180809145338.6160-1-bart.vanassche@wdc.com> References: <20180809145338.6160-1-bart.vanassche@wdc.com> MIME-Version: 1.0 X-Originating-IP: [174.62.111.89] X-ClientProxiedBy: MWHPR15CA0072.namprd15.prod.outlook.com (2603:10b6:301:4c::34) To DM5PR04MB1196.namprd04.prod.outlook.com (2603:10b6:3:a3::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 55ba63c1-689d-4e53-f187-08d5fe07ed53 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:DM5PR04MB1196; X-Microsoft-Exchange-Diagnostics: 1;DM5PR04MB1196;3:FQwHRQ0KgR9YGKoZJMZe34XVRyDVYMWFBN57/PFSxylTqlvnimUn8h0cc3mEx3YIP+zd9UzrEFEHFyOOHGKOE8xl9frqnOvSOq3NtmyRUwHho99Fot4qEYUYeNU0ex29jLrAsS+mAceKj2ziwtDoXsiNLxv/xTxPB4ALHhQv2985wWOc4V48wv3lmF+21gXweD6/iVE68n5RZGCeRSIfYBZgYnaSPJMjMe4VWAib4mpS03thCw6CAbe2A1yMiyMG;25:DhaiXtiVnZmlSfAjfCnHgcafTChBSIENEJbIwUHyaOSn3tj67Es7QWLTrkLm5y6kSPjkc3kR1x5Ct5TdHFcimnUAYelUBbPwZb+poUX+zRKLGZINPk9cuPlzxtRNPNE+sdK1gInTfQIfGJ7AVs0KCTup/x9O1MTpaunAP/p48yzV8AaSLl12zhw4srndnOB7hkeftJeuElhp/ds7QZvtHvmAWyYogkI3uvQyU6NY5f9hrKazz1ezeY/OryO1YKh7CE8ree6skkeSDWg1/KX6F7s+b5+P1CMP4SScJWgWfA2IheKDFDuPTXBQ8fWnlyvQ8WXIwBInlKK7kWwdc47BYA==;31:vcmFT9Ll5pEUU+Mi7/D+7sFvUeAhok3BkW1GY70MVqDn98rh33UTmiviKsR1pTCBTXLwgZcxuJHStAaORa8+mGfr+mhfb9bnByCDKXq24dHw4q4Tqf5ebiXkq2sJ6Myvrb9DTBd4+O0O2bV8wGamCrhZJdNn833f1bKdshi0BJhtJjAP88ME87M0hkBLh9s9vB2oS6zpr2HPbNHIbqvkDPjGlUZ4Ijr32mKg19eiiak= X-MS-TrafficTypeDiagnostic: DM5PR04MB1196: WDCIPOUTBOUND: EOP-TRUE X-Microsoft-Exchange-Diagnostics: 1;DM5PR04MB1196;20:PogAZrasWoJMx4NEqqKVEeizix5N5javkl7HWHRMe2uGp8K34STCfScj6lztXrUsKUQfGXFGbZtYp1diXwxpBJ+ng407PC5YO2K5/Jtodtf6aZQoRSeGBoGxK7tb8lE2+ekgdYxQEVzll+usG9iTTxrNhSkJJmjdfrXz+FnKDRbR7ebPfpUF91+lWmPvJH0WaR356rwSLg9UGOen3jFpFslktHWM+tgXazsQB9fVIwQcUJTowEKLhilYswFrJQZD06Zh0lrJldJiO8K5PH4BvSPExl+hn+S+i7sFZIDmDSyk4LtLq0Stxf77guizc2+srmUUUrvFhbNxU+xQKjwiyTtXPBdtacf9RBUgc+7H8m1x4XDRzXQy8Y8ORdg72nodRLZpqgNRiZk9Pyop02QEXck9PgXbp/a1v3mGmo40ssVGZuXuUYMYvZTYjYPdJKsX0AUtx4CU8yzoUlLZA56cMAHu9OLRbARubQAFKfYNuCAia3RIqcsfMidGy/8j6Pwo;4:97lXSulDkriBnaxAW7DFQVWk63XcRfeS2oQL8zOxeghTPZlS8wyMlCup1QdnEH5YkTS/S18FCdsKq9PL+KQ0jm4iwkYuDcTXnj84kC1dXklGseDrxgEjh5N8fHEo4mdLn0Czw9Qv7Td/tlxdqgbHW5CVvWwaJHdihXGFLECf/zWhrN4Ro5mJxaq4vsfti4aB1MFHc1jn5juk4m5H8MCWVhg40V4N52k/GoaI6p3IzTiQYjNxSY0pW8ldXq0vgmXxDjkKaVAmv/x7M8564jXlxWFBkFFPknr8U2XaqcpF9do14JUSNKljqv2Rdi7P2tgbWBF8B/pMPg36kaR+tBntR4luN2JGd8hDAh0MpaqYtNzx9nNNwJ6R9MW9R728RuzI X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(85827821059158)(168385556255192); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(3231311)(944501410)(52105095)(3002001)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011)(7699016);SRVR:DM5PR04MB1196;BCL:0;PCL:0;RULEID:;SRVR:DM5PR04MB1196; X-Forefront-PRVS: 0759F7A50A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(376002)(366004)(136003)(346002)(39860400002)(199004)(189003)(54906003)(11346002)(486006)(956004)(16526019)(316002)(2906002)(86362001)(446003)(48376002)(52116002)(81156014)(66066001)(476003)(2616005)(81166006)(16586007)(386003)(6506007)(51416003)(6512007)(36756003)(26005)(305945005)(7736002)(8676002)(105586002)(186003)(53936002)(6486002)(50226002)(3846002)(6116002)(5660300001)(8936002)(14444005)(47776003)(68736007)(1076002)(4326008)(39060400002)(25786009)(6666003)(6916009)(76176011)(478600001)(97736004)(50466002)(72206003)(106356001);DIR:OUT;SFP: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Zq+5yka7rvL063txexqvZs9bQgBUJFN4byoZ6H4MmeJgtyNNVbP+5Nuv6z8MoPGtcq9f6E4ReOQ2yB4yYXlGi+AYHQ0I8iZeMYu/Pou5ZEcgkdPuXUWkZuKbzl8iw==;5:+iz3T8qGlI2VrtaCrz5/qezLa60TjpOc/3nvrLH0FVNRfPR1fBtoB8xDms9hnk8PLgKXL8rXnktryQfBjgAREUIuRLPxR4a1TSO5Kfa4AobncsinKfHSja2cT39hz/7nEoX/OJ7cnA6oNfArU9Sv4KhdO6rUIHtp5F5ikruMztM=;7:Ue5cFa4Jv9EbpT7ya+CRTXCvMJJ1bpTxxmDLKjphFV0yj4ainReDDuk8RIhxtXl8xFN8V5D+xSgckTt5y3r6vBMSCIgDZWcdozvqFnLIECRgvE42DU4quXRDrvvTAmElWfY76derbRGURIJQ9M2JiHCpwr5ew0rHJBvBz4YkI1NcEamO0NMaRM7eVULZvZS4q/m44urI3pY5KdFjDQv0nfTiVAGI4H1kJPssrmorGeO7ptkB0/tUSyYCoQOn/MQM SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM5PR04MB1196;20:xC8wnCmksi9ZBATE/yJMsUzHhWb9FNfYCtoWB2Y0PjlMqjJut65qzkPT9tqknlcA+2uVtbhYzQHibknsQwLlYJ5+XvLu8SgrvLDgDYB7jJR5yO9qMNUUdAm91K6mOYEIpMoyqUHIMCI3gKSKmsGV8gybl5/Yf6O0TNHZjVS0aBo= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2018 14:53:53.5220 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 55ba63c1-689d-4e53-f187-08d5fe07ed53 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR04MB1196 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Several block drivers call alloc_disk() followed by put_disk() if something fails before device_add_disk() is called without calling blk_cleanup_queue(). Make sure that also for this scenario a request queue is dissociated from the cgroup controller. This patch avoids that loading the parport_pc, paride and pf drivers triggers the following kernel crash: BUG: KASAN: null-ptr-deref in pi_init+0x42e/0x580 [paride] Read of size 4 at addr 0000000000000008 by task modprobe/744 Call Trace: dump_stack+0x9a/0xeb kasan_report+0x139/0x350 pi_init+0x42e/0x580 [paride] pf_init+0x2bb/0x1000 [pf] do_one_initcall+0x8e/0x405 do_init_module+0xd9/0x2f2 load_module+0x3ab4/0x4700 SYSC_finit_module+0x176/0x1a0 do_syscall_64+0xee/0x2b0 entry_SYSCALL_64_after_hwframe+0x42/0xb7 Reported-by: Alexandru Moise <00moses.alexander00@gmail.com> Fixes: a063057d7c73 ("block: Fix a race between request queue removal and the block cgroup controller") # v4.17 Signed-off-by: Bart Van Assche Tested-by: Alexandru Moise <00moses.alexander00@gmail.com> Reviewed-by: Johannes Thumshirn Cc: Tejun Heo Cc: Christoph Hellwig Cc: Ming Lei Cc: Alexandru Moise <00moses.alexander00@gmail.com> Cc: Joseph Qi Cc: --- block/blk-sysfs.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index ca1984ecbdeb..fcadea471779 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -802,6 +802,21 @@ static void __blk_release_queue(struct work_struct *work) blk_stat_remove_callback(q, q->poll_cb); blk_stat_free_callback(q->poll_cb); + if (!blk_queue_dead(q)) { + /* + * Last reference was dropped without having called + * blk_cleanup_queue(). + */ + WARN_ONCE(blk_queue_init_done(q), + "request queue %p has been registered but blk_cleanup_queue() has not been called for that queue\n", + q); + blk_exit_queue(q); + } + + WARN(blkg_root_lookup(q), + "request queue %p is being released but it has not yet been removed from the blkcg controller\n", + q); + blk_free_queue_stats(q->stats); blk_exit_rl(q, &q->root_rl);