From patchwork Sun Dec 31 00:53:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10138033 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 53DB460233 for ; Sun, 31 Dec 2017 00:53:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41E06287A9 for ; Sun, 31 Dec 2017 00:53:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34CB1287AB; Sun, 31 Dec 2017 00:53:25 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 E37CC287A9 for ; Sun, 31 Dec 2017 00:53:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750982AbdLaAxW (ORCPT ); Sat, 30 Dec 2017 19:53:22 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:51216 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750937AbdLaAxU (ORCPT ); Sat, 30 Dec 2017 19:53:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1514681601; x=1546217601; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version; bh=cwwCj6W49F1Mxa/lI7+V4rvwRCtiB+cn3Oq+1Jj5Yg4=; b=AqE4y9MnmDvIEG81OWK7Qi2EHjN31z+lOadH7ZThnZpBrGP853ejYdy+ Zu70HG7D4SHibiFVaWcgH6l800iDmgV8sZlICnLwlvvucRgC6Oy9uUQTk dYvNAWG4ekVczUbTdbBe8Y5c1LAaxLpvE1MEmMaXb9YS3JfCfJ0P2or11 7kj41qlZ5qpQefSxI88A3tSKAtqwuhOphgFPBRb/j8R05i6jbZ/dFHe/4 IJ0VrOWfQF/TlgzbAOrHw5CEbzyCDIAfSVSHoDLDsKr4a/mI2tBsVJv3e KFR/mauuJh1ahGUjJjklLigJxcyqEMVaC7/z0A65wiPfMcgq5n+0XKrrf w==; X-IronPort-AV: E=Sophos;i="5.45,483,1508774400"; d="scan'208,223";a="67029397" Received: from mail-bn3nam01lp0177.outbound.protection.outlook.com (HELO NAM01-BN3-obe.outbound.protection.outlook.com) ([216.32.180.177]) by ob1.hgst.iphmx.com with ESMTP; 31 Dec 2017 08:53:20 +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; bh=kgqzqPjKgQWc7L2OgxqyOQ4c7xYKm7F5Tw6UbXvf+a8=; b=azW06/ZlRM8cr8emLhiM4vs3DpsjnsJln/P+5KO49QWmGXX66Sw20uZpJlwBAh5KLZzXpoHd8xrN7BmQLbjuIdn1/qrfkVst63dDtJQJshcw6KZcKesexASEjN9zlMtRpBq368PYMFmAx0wquo/JTSg8DZsfZVdyWHalPx+VMjY= Received: from CY1PR0401MB1536.namprd04.prod.outlook.com (10.163.19.154) by CY1PR0401MB1534.namprd04.prod.outlook.com (10.163.19.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.366.8; Sun, 31 Dec 2017 00:53:18 +0000 Received: from CY1PR0401MB1536.namprd04.prod.outlook.com ([10.163.19.154]) by CY1PR0401MB1536.namprd04.prod.outlook.com ([10.163.19.154]) with mapi id 15.20.0366.007; Sun, 31 Dec 2017 00:53:17 +0000 From: Bart Van Assche To: Bart Van Assche , "mail@maciej.szmigiero.name" CC: "hch@lst.de" , "linux-block@vger.kernel.org" , "osandov@fb.com" , "axboe@kernel.dk" Subject: Re: [v2,4/6] pktcdvd: Check queue type before attaching to a queue Thread-Topic: [v2, 4/6] pktcdvd: Check queue type before attaching to a queue Thread-Index: AQHTgbb1mvUM8Qv2PU2KSJryPWcYXqNcoA4A Date: Sun, 31 Dec 2017 00:53:16 +0000 Message-ID: <1514681596.11082.1.camel@wdc.com> References: <20170531214350.31157-5-bart.vanassche@sandisk.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; x-originating-ip: [63.163.107.7] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; CY1PR0401MB1534; 7:kcs1DzmyYNtRlUetZ6hETdtbZsLcscNIYLPykdHP10hnwBFIPLLwfr/g/ztKC42iXzkvPCiMf1KeGfKAAkwVNYMlqPBpFwiA21UObSa4SV+J28sIIwR8mq6AHuPFhbX7FxdSH03Gn9HM5bElv6bkSoSX8aRh8o4se3+36CCrBCtXoqXzZoD2raCZMyrlIVJR2w0zNsA4KB0/uSyPUsCKgW9P2LApQy+28+t7ljBzFjSQgfhUTdsrMrJhnQekaLCE; 20:wrlY1onwhjR8iGp9DcAOwUUux+E3b1c2PwQFKRj+WOdGSkfwMOYCcjnKIjRDpafIKVqLMZaEiZ9Qa9gptGHNUASPKLSskEskZYFiK0dJHUGXjhS8mFOdgj5sDBqOSR5XqLjHopyntQ3+e8TXLnTuBhXPIvPXBj8PaXC0NUNPuJY= x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-ms-office365-filtering-correlation-id: 9ee09ad2-c67c-46d8-1700-08d54fe8e12a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(48565401081)(2017052603307)(7153060)(49563074); SRVR:CY1PR0401MB1534; x-ms-traffictypediagnostic: CY1PR0401MB1534: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(17755550239193); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(102415395)(6040470)(2401047)(5005006)(8121501046)(3231023)(944501075)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041268)(20161123564045)(20161123558120)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:CY1PR0401MB1534; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:CY1PR0401MB1534; x-forefront-prvs: 0538A71254 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(376002)(39380400002)(39860400002)(346002)(366004)(24454002)(199004)(377424004)(189003)(2501003)(4326008)(2950100002)(72206003)(6512007)(1250700005)(53936002)(4001150100001)(6246003)(14454004)(478600001)(86362001)(3846002)(5890100001)(2900100001)(102836004)(25786009)(6116002)(97736004)(66066001)(305945005)(6506007)(76176011)(99286004)(81156014)(36756003)(316002)(54906003)(8676002)(5660300001)(6436002)(99936001)(105586002)(103116003)(110136005)(3660700001)(68736007)(229853002)(6486002)(77096006)(2906002)(3280700002)(81166006)(106356001)(8936002)(7736002)(133343001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR0401MB1534; H:CY1PR0401MB1536.namprd04.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; x-microsoft-antispam-message-info: tJ5jUc0gkqczkD28axCR8uGXwtXr3UQQ01cj+2OptdQ9sPX1ObdlB4dn3oi+W6VegtrOjv/0ahPM6sAe507uVA== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ee09ad2-c67c-46d8-1700-08d54fe8e12a X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Dec 2017 00:53:16.9713 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0401MB1534 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 On Sat, 2017-12-30 at 22:41 +0100, Maciej S. Szmigiero wrote: > This commit causes a NULL pointer dereference when adding a pktcdvd > mapping. > > Reproducing it is simple: > # pktsetup 1 /dev/cdrom > > Specifically, the NULL dereference happens inside bdev_get_queue(bdev), > which is supposed to return bdev->bd_disk->queue, but in this case > bdev->bd_disk is NULL. Would it be possible to test the two attached patches? Thanks, Bart. From 3192cc5f62b3ba9f866bcb245d21231a39745d8d Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sat, 30 Dec 2017 16:44:35 -0800 Subject: [PATCH 2/2] pktcdvd: Fix pkt_setup_dev() error path Since disk_release(disk) calls blk_put_queue() if disk->queue != NULL, clear disk->queue before calling put_disk(). Signed-off-by: Bart Van Assche Cc: --- drivers/block/pktcdvd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index fc8a80ec90e5..c5e930d23a63 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -2765,6 +2765,7 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev) out_new_dev: blk_cleanup_queue(disk->queue); + disk->queue = NULL; out_mem2: put_disk(disk); out_mem: -- 2.15.1