Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp487250ybl; Thu, 23 Jan 2020 02:24:46 -0800 (PST) X-Google-Smtp-Source: APXvYqwDOYLAeM2VgVI3gBMHOw6qtEELGB6N7Jp9A9BaBX7QJgkE4qnrHxf5JGgXmd23VYQDDD4/ X-Received: by 2002:aca:d985:: with SMTP id q127mr9729099oig.132.1579775086480; Thu, 23 Jan 2020 02:24:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579775086; cv=none; d=google.com; s=arc-20160816; b=V6qFf7aWcMgiDGQapwEfv9fFtz5Y0ZEQaFkWUqfJSKRKMjQOf9Te3LQr3SmlLthHDA mQ3MBffMdBCd6+wQdj5NPeysz0idb7Y0Nmssqqn9gEmHMo3HpX1/dgCs7AaUwpXsC1kT YqWzdyYijGFLtEKPvfVqPYsySTYmGscQN92DtRitpF6IE/CWzNzI8WZ5TqsK4WInip0G +JK6/QvTf5uoz3RlKf3lxG1susZyEZJu1ChdFvOu2cUtT03BxJm1YYdR2C4VWsY39I5O xV5qJPID7eQnx1V8kpnC+0cCt0+9VFxjXmeArEFHdtAIgoQGIMw9QAhfQJDFrhD9dL98 vyRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Q+B2tcpL089Q95u593xkNtaztRy8itf3jjGvjk36B6w=; b=Ms3U35/S0cKZSRkDh2S7DtkUgfozT6H7db1uvOhe71O0+pa1N6iNd1AKGThN5XE9hR 04D9lhaWiYfUj05+0mpyutgVZ7WJofRM6Sw4cpu/nNLDE9ynZXhrxTEkT9yFh4CgX65t FodFkCOQ0EUXLNQld506TnHnJ+fI50Xy2RIZJliPLMzN/E68OczuA/b15mkoeuCOU5al Bo0eXRHiD1jlMvN0+Mu2BkwtGrHXhXshkXs2KuYhUp2a8dnjip7m6Qw5aD0e/CRII8wl nKIfsvDblOCcUZYzPuXX+7w1kWmQ5188HYWgiIgzx5xuepnfk+nHqFAKDRurYKoacSDE gJKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 12si585946oiz.131.2020.01.23.02.24.34; Thu, 23 Jan 2020 02:24:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726968AbgAWKX0 (ORCPT + 99 others); Thu, 23 Jan 2020 05:23:26 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:37490 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726205AbgAWKX0 (ORCPT ); Thu, 23 Jan 2020 05:23:26 -0500 Received: from [154.119.55.242] (helo=elm) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iuZdz-0002Zb-Ck; Thu, 23 Jan 2020 10:23:24 +0000 Date: Thu, 23 Jan 2020 12:23:17 +0200 From: Tyler Hicks To: Stefan Bader Cc: linux-kernel@vger.kernel.org, dm-devel@redhat.com, linux-block@vger.kernel.org, Alasdair Kergon , Mike Snitzer , Jens Axboe Subject: Re: [PATCH 1/1] blk/core: Gracefully handle unset make_request_fn Message-ID: <20200123102316.GB7611@elm> References: <20200123091713.12623-1-stefan.bader@canonical.com> <20200123091713.12623-2-stefan.bader@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200123091713.12623-2-stefan.bader@canonical.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-01-23 11:17:13, Stefan Bader wrote: > When device-mapper adapted for multi-queue functionality, they > also re-organized the way the make-request function was set. > Before, this happened when the device-mapper logical device was > created. Now it is done once the mapping table gets loaded the > first time (this also decides whether the block device is request > or bio based). > > However in generic_make_request(), the request function gets used > without further checks and this happens if one tries to mount such > a partially set up device. > > This can easily be reproduced with the following steps: > - dmsetup create -n test > - mount /dev/dm-<#> /mnt > > This maybe is something which also should be fixed up in device- > mapper. But given there is already a check for an unset queue > pointer and potentially there could be other drivers which do or > might do the same, it sounds like a good move to add another check > to generic_make_request_checks() and to bail out if the request > function has not been set, yet. > > BugLink: https://bugs.launchpad.net/bugs/1860231 > Fixes: ff36ab34583a ("dm: remove request-based logic from make_request_fn wrapper") > Signed-off-by: Stefan Bader I helped debug the crash with Stefan and I think this is the most straightforward fix (and is trivial to backport for stable kernels). I looked at delaying the queue allocation in the dm code until the table load ioctl but I decided that was risky and doesn't help the general case of preventing other subsystems from making this same mistake. Tested-by: Tyler Hicks Reviewed-by: Tyler Hicks Tyler > --- > block/blk-core.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/block/blk-core.c b/block/blk-core.c > index 1075aaff606d..adcd042edd2d 100644 > --- a/block/blk-core.c > +++ b/block/blk-core.c > @@ -884,6 +884,13 @@ generic_make_request_checks(struct bio *bio) > bio_devname(bio, b), (long long)bio->bi_iter.bi_sector); > goto end_io; > } > + if (unlikely(!q->make_request_fn)) { > + printk(KERN_ERR > + "generic_make_request: Trying to access " > + "block-device without request function: %s\n", > + bio_devname(bio, b)); > + goto end_io; > + } > > /* > * Non-mq queues do not honor REQ_NOWAIT, so complete a bio > -- > 2.17.1 >