Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4736913rwd; Tue, 23 May 2023 11:42:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ466J4uRRJEXZ8lR70sJ1V09IUxraplkv3xkwDRtNPq1ir0SjpUjbyL2ypobgMS9kwwaeBP X-Received: by 2002:a17:90b:46d1:b0:247:529f:92d7 with SMTP id jx17-20020a17090b46d100b00247529f92d7mr15652349pjb.8.1684867354554; Tue, 23 May 2023 11:42:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684867354; cv=none; d=google.com; s=arc-20160816; b=lg1zKdyFapM1t4oENdEvFWMc3RhUPXCZS8g6LCp/oxVb8O7GrwU2xW6Pl0kk2QcIPb DT2ngAhOMEot9hvQy/CmugHJSXZfpdx8laAdVWeTf2GOeM1RIWeR82eFXgVKgeARXmxu nSwsCFXfEV+tEqoX0E5LRptDKTuOksee6GytF0xnYu5dP8GZ5J0t0xz/yS+DDAB67WvO iyoNeDaV/X/eEyb1vVEhq0S41zobABJu9B5K+Xk1Wk/cqTxiOwgOOwz1KXG0YoXG1nK+ SKQstb/xW7vqeX4hRYXJG+SuQzZ6a9LmcECNvM+J/dupRXd3tEkMyk7jI18k6p6jJxLd Cf/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=imyBY9w7Je9cW+KQqEQ5lsdwZ1yC47ryBXCdiWR77Fs=; b=ZGu2+avsIHshk5r7yZ4/I8U7ew/CUR8a4kv9BeC/GMvvwkMI8e/+FGDXAdDfHw51K2 GdCS0KfUOVsIgwljANEtHklWxh1A4e77EkUUh73klMnWSsAknbwZA5lKwVudaFrfHlbo rC9TyIh3Aqudbm7a0gFieNyzvu89DdOFZczJH1H7YaCSLo4uQv983EbG8abGogckoQJL 2Zk0y/PpSNKTsbOaBBt8dQXDF2Pc56XuxTuHpgcTRXqIaoHl72RJrXmH3v5xudWalhaF z7KBhGtRDZBilBnuWXk8dh19Zj06WzznTiBOwydsfuKe/DM/p5GNz1lPfh6klGDs/AEF s5Aw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bk13-20020a056a02028d00b0053b86623b4esi2837298pgb.83.2023.05.23.11.42.20; Tue, 23 May 2023 11:42:34 -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; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238167AbjEWSiD convert rfc822-to-8bit (ORCPT + 99 others); Tue, 23 May 2023 14:38:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237928AbjEWShf (ORCPT ); Tue, 23 May 2023 14:37:35 -0400 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA13018B; Tue, 23 May 2023 11:37:20 -0700 (PDT) Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-94f9cd65b1aso108858166b.0; Tue, 23 May 2023 11:37:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684867022; x=1687459022; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FOckud4CsGpi42vHzY/iN1xEHfyZzu8tYLlnQmf3XXU=; b=lPIgigwZ11iBv8vgKFH9/Ir3BNZpyjgySuC1i1WFp3quETnbhTdcsMvkIczDcTNYXs Pd/Z8dqB3bXIgfzQEQ2gaCjus3zjd2VQpsCl3e28JeeWkdo2jchb8a3ch7rE1EVwV+Er +mnJ9B4tkQA43cmK/bai/cAhBdGZvaBg82H3mUtr96fkuiW28UO2N8i6Vp6b+r09xNpe 9OJvJ6pUihSJAalsJ9NV5vCB+z4UPZ8H3dkRG1JHzjEG7MGk9n88r/BiFrzw5bz9fjs/ BSeEEf0KexWhWQYPpncR+Sxk+z026FBT8tq9RdQyg4GZpNXBAsddQPYlrcqAR89whnfV K2Ag== X-Gm-Message-State: AC+VfDxukIGenn0F+ZJeCtjC39DSnGkh4hpB0K4wMr7pAMkiOkl3qwdV OtfdQUgRPGCsKQ9egjDQ59DGRpmOYlloeHGjcaw= X-Received: by 2002:a17:906:6495:b0:966:2210:4065 with SMTP id e21-20020a170906649500b0096622104065mr14890560ejm.4.1684867022285; Tue, 23 May 2023 11:37:02 -0700 (PDT) MIME-Version: 1.0 References: <20230523074535.249802-1-hch@lst.de> <20230523074535.249802-22-hch@lst.de> In-Reply-To: <20230523074535.249802-22-hch@lst.de> From: "Rafael J. Wysocki" Date: Tue, 23 May 2023 20:36:51 +0200 Message-ID: Subject: Re: [PATCH 21/24] PM: hibernate: don't use early_lookup_bdev in resume_store To: Christoph Hellwig Cc: Jens Axboe , Greg Kroah-Hartman , "Rafael J. Wysocki" , Mike Snitzer , Joern Engel , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Pavel Machek , dm-devel@redhat.com, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-mtd@lists.infradead.org, linux-pm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 23, 2023 at 9:46 AM Christoph Hellwig wrote: > > 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. > > Signed-off-by: Christoph Hellwig > Fixes: 421a5fa1a6cf ("PM / hibernate: use name_to_dev_t to parse resume") Acked-by: Rafael J. Wysocki > --- > 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; > -- > 2.39.2 >