Message ID | 20230531125535.676098-21-hch@lst.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2861564vqr; Wed, 31 May 2023 06:03:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7XYQWEvX2LfgiyyvBzdqiM1WFtj1zAIYTarWm7383aTbZBoIxttTlet885MLzFCnysH0vr X-Received: by 2002:a17:903:185:b0:1b0:256:b95e with SMTP id z5-20020a170903018500b001b00256b95emr4905606plg.45.1685538217874; Wed, 31 May 2023 06:03:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685538217; cv=none; d=google.com; s=arc-20160816; b=Md+jC7gWeZY3j9OHgKBAvnu9tLm/4qJAMt5GKcKD/X9sF10Wx9MuNQtoflG7U5qlC4 IFDPbnMr5qEDg93k89caJZpNY+jy/bXo9fOhDYIGCq5jGQ22xumWzLJa92g1KRFHlKVo KVcWbzEGAs3qARVRE46gMwWIFajRLEICmsfcsCzovEDd8AIKYvsmjcVm/MLRJEwyhSvP GSSdvgmB736wCLLFg2PFE5Ec9Kq4AKGox2+pJsN4SGjIjzt+HrlKt6IXP5Xq7k2S3NBy 51hK9uUeDkSh9bM4V6wCuHlGtnqvMwPAY7IO1EwuUJEJ2m4NrDByFYq/YVokFNgnaYmC fFxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LFSs21ZyPovCIm+gI2ZuzefJZm22A6ZE+VVgdwCs8vc=; b=Za5vI0VpCEBOl+S+Id0337EibI7Q0F0omYgzHAcy9FqQf8oJG7J0HzQd1cVfrqPCE+ qnIsuuRuWY8WwQHoW++RdvKcv6hWV1dhkR915eGtDAx4PV/si3bdRHysi9zn4Qszg8/2 A4VYdwdoQh14bXmcgnWKxIR8JlxeCqn46TQehafJsDBAytIX2SzOGOmA5aTrSIvH7zLC wqCN0QclMBsDMazXhakfLtVyd5UpkeMruSeHehu7BT4EtlGNTolQdnv31iRjc14I/7BC aQZJZguBWPhGWzTYbmD47Xko63Nr1en93a0mG9q1uuH+MZD4xtrWWpCpkudBzHIPpE1J yrBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=xFOzU0L1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j4-20020a170902da8400b001990520ebccsi867581plx.587.2023.05.31.06.03.18; Wed, 31 May 2023 06:03:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=xFOzU0L1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236141AbjEaM7N (ORCPT <rfc822;andrewvogler123@gmail.com> + 99 others); Wed, 31 May 2023 08:59:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236248AbjEaM6q (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 31 May 2023 08:58:46 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 236DC1BE; Wed, 31 May 2023 05:58:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=LFSs21ZyPovCIm+gI2ZuzefJZm22A6ZE+VVgdwCs8vc=; b=xFOzU0L1htroO1OMfJ8gBvYVUj 33s4T4AGul2gTCY/trZokBsydhV7ExkjG3uHp6qmZvA4rEVx+ABanSUl0AYJ6fUGn4PYIbmn26eTy UET68mfEstIJ0sRfnZRnHchEz9zbQfF3w0E6RKe2/JNjaDqxBHEFnfB3S/w35FC4ZRfhOJvr0kAtU qWlnro113IEJNlYtlOj/5lGLBUpLfqJatKm4bSZ5hEyFzRYFS8sBbMr8fOEcscmEEhu/LNAOSJxph kuuEPid8OJuSxdNV7XOjCKBPe1N1AEE9T0jiQ696XJ7Ao1CX2RGhqGo6HvdPAhKgXbNcU5Zyi1IXG 6ORYBouQ==; Received: from [2001:4bb8:182:6d06:2e49:a56:513a:92ee] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1q4LOC-00HS1f-0T; Wed, 31 May 2023 12:57:20 +0000 From: Christoph Hellwig <hch@lst.de> To: Jens Axboe <axboe@kernel.dk> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, "Rafael J. Wysocki" <rafael@kernel.org>, Mike Snitzer <snitzer@kernel.org>, Joern Engel <joern@lazybastard.org>, Miquel Raynal <miquel.raynal@bootlin.com>, Richard Weinberger <richard@nod.at>, Vignesh Raghavendra <vigneshr@ti.com>, Pavel Machek <pavel@ucw.cz>, Loic Poulain <loic.poulain@linaro.org>, dm-devel@redhat.com, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-mtd@lists.infradead.org, linux-pm@vger.kernel.org Subject: [PATCH 20/24] dm: only call early_lookup_bdev from early boot context Date: Wed, 31 May 2023 14:55:31 +0200 Message-Id: <20230531125535.676098-21-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230531125535.676098-1-hch@lst.de> References: <20230531125535.676098-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from <hch@infradead.org> by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767414922191238390?= X-GMAIL-MSGID: =?utf-8?q?1767414922191238390?= |
Series |
[01/24] driver core: return bool from driver_probe_done
|
|
Commit Message
Christoph Hellwig
May 31, 2023, 12:55 p.m. UTC
early_lookup_bdev is supposed to only be called from the early boot code, but dm_get_device calls it as a general fallback when lookup_bdev fails, which is problematic because early_lookup_bdev bypasses all normal path based permission checking, and might cause problems with certain container environments renaming devices. Switch to only call early_lookup_bdev when dm is built-in and the system state in not running yet. This means it is still available when tables are constructed by dm-init.c from the kernel command line, but not otherwise. Note that this strictly speaking changes the kernel ABI as the PARTUUID= and PARTLABEL= style syntax is now not available during a running systems. They never were intended for that, but this breaks things we'll have to figure out a way to make them available again. But if avoidable in any way I'd rather avoid that. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Mike Snitzer <snitzer@kernel.org> --- drivers/md/dm-table.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 1576b408768d4b..2fd5826bfce175 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -326,8 +326,11 @@ static int upgrade_mode(struct dm_dev_internal *dd, fmode_t new_mode, /* * Add a device to the list, or just increment the usage count if * it's already present. + * + * Note: the __ref annotation is because this function can call the __init + * marked early_lookup_bdev when called during early boot code from dm-init.c. */ -int dm_get_device(struct dm_target *ti, const char *path, fmode_t mode, +int __ref dm_get_device(struct dm_target *ti, const char *path, fmode_t mode, struct dm_dev **result) { int r; @@ -346,8 +349,10 @@ int dm_get_device(struct dm_target *ti, const char *path, fmode_t mode, return -EOVERFLOW; } else { r = lookup_bdev(path, &dev); - if (r) +#ifndef MODULE + if (r && system_state < SYSTEM_RUNNING) r = early_lookup_bdev(path, &dev); +#endif if (r) return r; }