From patchwork Thu Jan 26 06:18:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 1732029 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Oelm/b/I; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=enVz68oa; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P2VwS4tn8z23h7 for ; Thu, 26 Jan 2023 17:21:42 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=CkzwPJNWeoXQQaa1BwIJd9bdKm28J/+nNqjY5I+dDGA=; b=Oelm/b/IjhmLQw OQKKqfSIlIYeR62/P+csUuE/Sws6fBdHzKRtMaJIWP1EacVbRnlS2ezaYDxh82l31sFshYw7siY68 v0StkMh0arBSqDtf8kKVB+1Hb/S9YvoMprf0lBulOSoYwNdY8XNT2K5ThEMvgk32QYIG8YhkGtkow paPAnx9eGpFT0CJJaPaME+2H/JpsIO8s9xMXiy7VDzsq9IGaILUPk3ybKBnkzcj7gSrGsvLzHRFcR GfYyP9ibqImgv7LfIeP/UjDS2Ec+P5XCQunh56QMzUD3+ieKxMZAD3Q47AOZafTAykeVYHrhuc8PV UC7EURIvo2M8WnlIN0Hw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKvae-009ixP-VA; Thu, 26 Jan 2023 06:18:29 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKvaa-009iwt-6k for openwrt-devel@lists.openwrt.org; Thu, 26 Jan 2023 06:18:26 +0000 Received: by mail-pj1-x1035.google.com with SMTP id z1-20020a17090a66c100b00226f05b9595so905055pjl.0 for ; Wed, 25 Jan 2023 22:18:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=eUVoQrEVevnwWsUTX9ff4tJ92YFXwyhlJq0rusSTfqQ=; b=enVz68oaHvdRbQAzjONsWN9pio+UK8wshaFAjpImgdJVYT+PoVI705lhupGigq2Dci SEoVYGqcoYfihY8QVEAW7D0aqgwo+CWL7xrU8xgjyMbtFP1kqcXes/tdZYbXGxwC5lBO n/edCyRNtOCqMlUCdQ4cOxqwbFoPpYb10OTJfIqvBs3jp7fF5nEZLSMUmiS5RKs/+M5U mrlZR7u9kPDYcMm7blyZoOgIGzeBqYOXiWqwhrlrBDWr93lyUTFFmEN9iKNMPczZqTaI jofJMsIRCCGRmz81/VPjfya31j6ZBB5kBBB1knsqwIBilKvIitD6RsuRZ9Ma1FaSDAdI FfSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=eUVoQrEVevnwWsUTX9ff4tJ92YFXwyhlJq0rusSTfqQ=; b=WN/2I030Jlr/Woe4cASS0QaiJ5kxHB5Y7uJscYKItReIpsCfy3iiSEFrHujOBz+kBY FUsNguwsKtR5rSRoNJkALzWsoFmurHHP+U1LUhjSyC/+MEtb7veh3XDFLQs/aYKRJURt oBLBSeuFsNqc0XfcYC7SQOU3SOA3xoYY3hQwf1/1F3FPYF+LtFSNZx5wocU0+uzYxlib VuTg10SFf1V4hKzugiFZhT6CDz5iK/EVakUQoIvRxj2zt/qU8dV2GWGjmi9F3HAc5Xtf XjbQb34tMb+dbH3ZoV773+zhEdxT/MxcVJCufNPPPVyrETWMiFJOEdlKsaktUddSGDs5 Ptow== X-Gm-Message-State: AO0yUKWnYdhENYOgC9PKE9NeYLa7RacSyp5kOgratOwT300LjOcxVLpz T1Yb5g5AuTPDhJyiVZ0JXja31/Ujahg= X-Google-Smtp-Source: AK7set/T7UtkRwxEuN4bgcIeh3PpW1i342Jr8mwnDqDDdrqntXK1RsWswI2vAGmZL+WBlaZoIceZyg== X-Received: by 2002:a17:90b:1806:b0:22b:fff0:f80c with SMTP id lw6-20020a17090b180600b0022bfff0f80cmr6652948pjb.1.1674713900665; Wed, 25 Jan 2023 22:18:20 -0800 (PST) Received: from localhost ([2600:1700:38c1:1d7f:f66d:4ff:fe3c:3ceb]) by smtp.gmail.com with ESMTPSA id o16-20020a656150000000b004db367c10b0sm146971pgv.46.2023.01.25.22.18.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jan 2023 22:18:20 -0800 (PST) From: Brian Norris To: openwrt-devel@lists.openwrt.org Cc: Ansuel Smith , Brian Norris Subject: [PATCH fstools v2] partname: Correct fstools_partname_fallback_scan comparison Date: Wed, 25 Jan 2023 22:18:15 -0800 Message-Id: <20230126061815.3146071-1-computersforpeace@gmail.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230125_221824_269645_0495AC19 X-CRM114-Status: GOOD ( 14.29 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Commit 1ea5855e980c ("partname: Introduce fstools_partname_fallback_scan option") had two problems: 1. The strcmp() aborted when the param *matched* 1; we wanted the inverse 2. It was too aggressive about skipping the fallback behavior. For devices that had no root= parameter, they would always atte [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1035 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [computersforpeace[at]gmail.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Commit 1ea5855e980c ("partname: Introduce fstools_partname_fallback_scan option") had two problems: 1. The strcmp() aborted when the param *matched* 1; we wanted the inverse 2. It was too aggressive about skipping the fallback behavior. For devices that had no root= parameter, they would always attempt the fallback scan. Fix both of those. Fixes: 1ea5855e980c ("partname: Introduce fstools_partname_fallback_scan option") Signed-off-by: Brian Norris --- Changes in v2: * Also restore the pre-1ea5855e980c fallback behavior when no root= is provided libfstools/partname.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/libfstools/partname.c b/libfstools/partname.c index f42322a49d5b..004b249a7fdb 100644 --- a/libfstools/partname.c +++ b/libfstools/partname.c @@ -121,6 +121,8 @@ static struct volume *partname_volume_find(char *name) char *rootdev = NULL, *devname, *tmp; int j; bool found = false; + bool allow_fallback = false; + bool has_root = false; glob_t gl; if (get_var_from_file("/proc/cmdline", "fstools_ignore_partname", rootparam, sizeof(rootparam))) { @@ -128,24 +130,29 @@ static struct volume *partname_volume_find(char *name) return NULL; } - if (get_var_from_file("/proc/cmdline", "root", rootparam, sizeof(rootparam)) && rootparam[0] == '/') { + /* + * Some device may contains a GPT partition named rootfs_data that may not be suitable. + * To save from regression with old implementation that doesn't use fstools_ignore_partname to + * explicitly say that that partname scan should be ignored, make explicit that scanning each + * partition should be done by providing fstools_partname_fallback_scan=1 and skip partname scan + * in every other case. + */ + if (get_var_from_file("/proc/cmdline", "fstools_partname_fallback_scan", rootparam, sizeof(rootparam))) { + if (!strcmp("1", rootparam)) + allow_fallback = true; + } + + if (get_var_from_file("/proc/cmdline", "root", rootparam, sizeof(rootparam))) + has_root = true; + + if (has_root && rootparam[0] == '/') { rootdev = rootdevname(rootparam); /* find partition on same device as rootfs */ snprintf(ueventgstr, sizeof(ueventgstr), "%s/%s/*/uevent", block_dir_name, rootdev); } else { - /* - * Some device may contains a GPT partition named rootfs_data that may not be suitable. - * To save from regression with old implementation that doesn't use fstools_ignore_partname to - * explicitly say that that parname scan should be ignored, make explicit that scanning each - * partition should be done by providing fstools_partname_fallback_scan=1 and skip partname scan - * in every other case. - */ - if (!get_var_from_file("/proc/cmdline", "fstools_partname_fallback_scan", rootparam, sizeof(rootparam))) + /* For compatibility, devices with root= params must explicitly opt into this fallback. */ + if (has_root && !allow_fallback) return NULL; - - if (!strcmp("1", rootparam)) - return NULL; - /* no useful 'root=' kernel cmdline parameter, find on any block device */ snprintf(ueventgstr, sizeof(ueventgstr), "%s/*/uevent", block_dir_name); }