Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp456144pxb; Thu, 9 Sep 2021 05:01:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUNgsQLJHmfIl9XaqtHNqGiiPhx5gA9uJDKOPyagFZdhl//8XfRDkalR4kUSNH9UJTsHNZ X-Received: by 2002:a92:db0c:: with SMTP id b12mr2031192iln.171.1631188914510; Thu, 09 Sep 2021 05:01:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631188914; cv=none; d=google.com; s=arc-20160816; b=xkXIU+jIDDtxgYx94AT3cMq9emai0pm0pA/Id8SisDZSokP1SX5Edg9EwhCk+auNJD XCYzTAE/wTxtzeZYOChSNYmlYRdZ2C1KnEUmn2f7B+6X2xKL6qRrfJX/J8ioKvaHerL5 cKxGQol3iUoIJFYpgdlYMtTyG920/Q+I9DnNViM/OdnRAn72vwom1wxYjejjkzKP438L 59Fy35dFlIS/kOGI54mdo6OOgz5WZCchmNlDY9a7dyDYLBsq2WBK2Rhr9MCRXYyqUbjh zmF7KIX61gVW7Eos7ZxJVWHjUtpA8vD/U1GejBIlInBNdGNWp6Bvhq5HHV+lFdlCCBWE zetg== 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=nmbQ5fW07I2JuJKIDYzD7SdtFtLwB+J4R3yeG17ZvZM=; b=i/FliwvO3k88jCni1aUsdLJzOg+4tpsG8FCDgiP34YGre9xc/vB/QON91EoZeE+wr2 F1YInfD5tsHJJmlSPX/xnhtbJNYCLiE3dapBQxZYqNC0QLJ1Te8ppFGOTbeMcnjHx8I/ zZ3IdafmB4M80zFL4uUNXfjETcKG2AYw5lzESLHmgwKEG5d8IcE0as2SVzGT8J4d5GHj 6FBYGuQ4FI1oi/fTApGTvImtvX+TyEaVsovxWbywcHr7xiNyan7lfnb8XLgOaU6wpI+E Wnn3hNYuLIK1pD3oBMzCYnEoZUEExWxnLE4QLec8uqVoMtlfYcmSlzSMN8xkU8gf8/zU MT7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rbcJtQyu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g1si1562572jag.116.2021.09.09.05.01.40; Thu, 09 Sep 2021 05:01:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rbcJtQyu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1343717AbhIIMB2 (ORCPT + 99 others); Thu, 9 Sep 2021 08:01:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:34928 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245627AbhIIL5C (ORCPT ); Thu, 9 Sep 2021 07:57:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1EA90613D2; Thu, 9 Sep 2021 11:45:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187929; bh=C56UGu/jYrwM6Jfi/51pH9IQNP0Jn9eLUHEN3yNrW1s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rbcJtQyu/qnSL0th0tHTiltMsFdsjme9lpDfUDHR1EL7jwv5sHHh6E0SqHQ9F6pKF p4ugv+MuROlcNel4UgszNtj2X7VM77cW5vwRPIHIXiGtqZbuN1AHtzNym3bHALUnUo O2acb638GRiNzgYB9sdZaoKZPKXf2uSRSZ3ctS3MCfpeSM5+dE+IO2Wj2sRDHs29g9 QM4WxcIGMS+P0bRP42Qy8vOzU5LORjSKI4KHQXE4ljUfP0R0RxTjrQjX2itPww9zcM 5JPYRrBMEC3Ct3tuvNPo6FquJ+lBtdeUaq8RijnHo6C8lQCHZE54pLucNHyyLurkb1 TzVR+p70jpB9A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Marc Zyngier , Rob Herring , Sasha Levin , devicetree@vger.kernel.org Subject: [PATCH AUTOSEL 5.14 202/252] of: Don't allow __of_attached_node_sysfs() without CONFIG_SYSFS Date: Thu, 9 Sep 2021 07:40:16 -0400 Message-Id: <20210909114106.141462-202-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Zyngier [ Upstream commit 6211e9cb2f8faf7faae0b6caf844bfe9527cc607 ] Trying to boot without SYSFS, but with OF_DYNAMIC quickly results in a crash: [ 0.088460] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000070 [...] [ 0.103927] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.14.0-rc3 #4179 [ 0.105810] Hardware name: linux,dummy-virt (DT) [ 0.107147] pstate: 80000005 (Nzcv daif -PAN -UAO -TCO BTYPE=--) [ 0.108876] pc : kernfs_find_and_get_ns+0x3c/0x7c [ 0.110244] lr : kernfs_find_and_get_ns+0x3c/0x7c [...] [ 0.134087] Call trace: [ 0.134800] kernfs_find_and_get_ns+0x3c/0x7c [ 0.136054] safe_name+0x4c/0xd0 [ 0.136994] __of_attach_node_sysfs+0xf8/0x124 [ 0.138287] of_core_init+0x90/0xfc [ 0.139296] driver_init+0x30/0x4c [ 0.140283] kernel_init_freeable+0x160/0x1b8 [ 0.141543] kernel_init+0x30/0x140 [ 0.142561] ret_from_fork+0x10/0x18 While not having sysfs isn't a very common option these days, it is still expected that such configuration would work. Paper over it by bailing out from __of_attach_node_sysfs() if CONFIG_SYSFS isn't enabled. Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20210820144722.169226-1-maz@kernel.org Signed-off-by: Rob Herring Signed-off-by: Sasha Levin --- drivers/of/kobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/of/kobj.c b/drivers/of/kobj.c index a32e60b024b8..6675b5e56960 100644 --- a/drivers/of/kobj.c +++ b/drivers/of/kobj.c @@ -119,7 +119,7 @@ int __of_attach_node_sysfs(struct device_node *np) struct property *pp; int rc; - if (!of_kset) + if (!IS_ENABLED(CONFIG_SYSFS) || !of_kset) return 0; np->kobj.kset = of_kset; -- 2.30.2