Message ID | 20230531125535.676098-22-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 k13csp2871500vqr; Wed, 31 May 2023 06:15:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4iR/iPIIU7TbH1PDlUXNreWwwQYICuoMS+1O+fVZAtsi2SN7Ts569ax7oKU4As9F98vKZo X-Received: by 2002:a17:90b:691:b0:256:9b5c:2aa2 with SMTP id m17-20020a17090b069100b002569b5c2aa2mr6159768pjz.6.1685538939906; Wed, 31 May 2023 06:15:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685538939; cv=none; d=google.com; s=arc-20160816; b=ByKGaDlrywqf8vCT0yMD7pm3RLBOX/7tnTRLXkrCMgothymrA7rhWVPl330KFOCj2V x5mi6pg7Zsuuw0iNa6hhEq/2MEI+kUGPg/uy6+qMQmOelFwgm1ThwPWi9QxZ4Cww1WNT +0pir1nj4MCjMz5FMXvTv00rh3qtqJa9JOduU+xXbDyEIYrtE+SKV/k18DJlmwkRJ8id 0ofXV2hV18p8YEovjkqRI3OLxd3R5zyY1i9G7oQQ6z8I8EAO1U0u+FSpiHy56Of44f11 a3j4FdhuRAEoBpixDs5qT/ZIOsIoYlMhB7k0l45mYumf10DYJUt3VjB8W7ZpjsJBBBfq HiDg== 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=KHl92zkNVfdNHhlnKg6mvCa7i8PxAKjKJMOEl5EMWfo=; b=OyqfDJoILGy3QW7d/WMtZiLJLgmyRVj6KeeqbPaHqoC0ovOC8nkgEkIk1H/pKXlZc4 wFBm5yzHuiQ0+wqxaTMB1l67zZuwZ8pf/FEMvXmdJsxBKqv60lO20w/Sy4ZLbiExTYl/ yLq8+CM2QGFXlOVN+1gEMsoMMIGHJvI95e+VRKZDPLm7IRB+ueGByCpNi1F694Vh7b/t z7xUTmJU5OSHzbjEhe5sHWO8EwCFw147Ui91H/p7GpN9zyDxAvLfOjW+bvz0kPQBZ6Di 8cjeQZqHyfXKKAm9XU/+ttb1fFcOK/VSN+6xHMRp3merBUHq8kHE8+vIoKx4bgHO9WN9 94NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=zXlbDoNS; 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-20020a17090ac48400b00230a8355ff1si894625pjt.181.2023.05.31.06.15.27; Wed, 31 May 2023 06:15:39 -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=zXlbDoNS; 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 S236315AbjEaM7W (ORCPT <rfc822;andrewvogler123@gmail.com> + 99 others); Wed, 31 May 2023 08:59:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236263AbjEaM6s (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 31 May 2023 08:58:48 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68C17E47; Wed, 31 May 2023 05:58:16 -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=KHl92zkNVfdNHhlnKg6mvCa7i8PxAKjKJMOEl5EMWfo=; b=zXlbDoNSylqL4+rXHY59rvAEzn Psl/83vgjcjxeiijFDRueZw4ZP9le8jp/jttNlMDkxj8IDlYOW9esWEYrIhI3DBEvOCaQosxnQwiC 3iktIQuAIhFWLW+JW3Ni4cqfvgfaB2xIIzS/rmgyNOUk8mAiHJeHGWzbrtXwxJi+JevIs7Wkd0pbd MEm69n1jz/6nsgkRqtdGlTq/2z31G3mOe7C0owkV4F0r76f85j/wTDnGJPppUudlT34uj90Qf9t1i 4+mzMJhW4bZK0RmsgHOGGOIiH650kf2cSttm+Y2UPmkMMcYdu2k/SEqZMtYwg3WRM9h71LjEA9j3e mNzlbfmA==; 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 1q4LOF-00HS45-0A; Wed, 31 May 2023 12:57:23 +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 21/24] PM: hibernate: don't use early_lookup_bdev in resume_store Date: Wed, 31 May 2023 14:55:32 +0200 Message-Id: <20230531125535.676098-22-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?1767415678997519988?= X-GMAIL-MSGID: =?utf-8?q?1767415678997519988?= |
Series |
[01/24] driver core: return bool from driver_probe_done
|
|
Commit Message
Christoph Hellwig
May 31, 2023, 12:55 p.m. UTC
resume_store is a sysfs attribute written during normal kernel runtime, and it should not use the early_lookup_bdev API that bypasses all normal path based permission checking, and might cause problems with certain container environments renaming devices. Switch to lookup_bdev, which does a normal path lookup instead, and fall back to trying to parse a numeric dev_t just like early_lookup_bdev did. 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. Fixes: 421a5fa1a6cf ("PM / hibernate: use name_to_dev_t to parse resume") Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Rafael J. Wysocki <rafael@kernel.org> --- kernel/power/hibernate.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index c52dedb9f7c8e8..7ae95ec72f9902 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -1178,7 +1178,23 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr, if (!name) return -ENOMEM; - error = early_lookup_bdev(name, &dev); + error = lookup_bdev(name, &dev); + if (error) { + unsigned maj, min, offset; + char *p, dummy; + + if (sscanf(name, "%u:%u%c", &maj, &min, &dummy) == 2 || + sscanf(name, "%u:%u:%u:%c", &maj, &min, &offset, + &dummy) == 3) { + dev = MKDEV(maj, min); + if (maj != MAJOR(dev) || min != MINOR(dev)) + error = -EINVAL; + } else { + dev = new_decode_dev(simple_strtoul(name, &p, 16)); + if (*p) + error = -EINVAL; + } + } kfree(name); if (error) return error;