Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp508483pxb; Thu, 9 Sep 2021 06:07:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaTHm9igCHe3vrq6dfC2ghfKK5RjX9uq0ReY7bXE8zxbdF5HS/fI+c1l5HBjNkyk1D2uJz X-Received: by 2002:a17:906:2817:: with SMTP id r23mr3394336ejc.285.1631192842396; Thu, 09 Sep 2021 06:07:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631192842; cv=none; d=google.com; s=arc-20160816; b=Xaj1iB2t6vWPylkZHTL8XXzJvAhCtzz2WhlZ+i5IUCM61XeDGL2DS3C4xW6Ns1TyHR MoY2nz6g61mX7/grF1I9qHyMXyZTMDbiQUJGUmW8zr4wJyxwwREBRLv8Kee+QZdpptyx 4Q182GN2Vwse6bPTB/3nHPGz4oU/TSQqI1rzb0gDSQDQAFPLdR7xMsPOTVd/dK13lmMU w0ytdPc+0VTD3PWmrxss94tO/S3d6n2WgEsQIKUZbKUjoJzEASrZ7VNZ/FOqjK3Raq1A p+TN8SElnkfsA4y8qwj48TGsKKh2SWwnASw72zllUCYP4eJw9/SLaGS0yDO5dVnR9HZS 2FYQ== 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=RExc4VpvQaBMAZJ/AthhPk7LidMqWgtGsNrrWQ+RHjl8QR42rNOfu2UWxTdgtRfO7j LUH7ZpfGWE5/yvCbgWUgssztooJirsmrPLnnn7DXLrEXOWYNQdFbvTzOIcK/Xe8zgKmf W1RRCDF8qvChpv7dOGRWnkLMgiSYOLRudURb+uvGS61Xe+3SyHbTq+SAwPROnIyqY6gc MxsOm8elSZxU6L9FK3mDDFVP99SFhdn6LuOyYsE+qjJCl2q/EApbx6fOT3aP6xyoG6+6 RLuk1e1UU0WO2qvSeNM9Wdssj+seUgHCKwmEm5/IQAvXN1H9exddj3xP0V9oLznZ+LBT Ee4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=l0etXWMu; 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 qf26si119199ejc.664.2021.09.09.06.06.35; Thu, 09 Sep 2021 06:07:22 -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=l0etXWMu; 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 S1354638AbhIINBo (ORCPT + 99 others); Thu, 9 Sep 2021 09:01:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:42582 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355329AbhIIMtm (ORCPT ); Thu, 9 Sep 2021 08:49:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1BADC63236; Thu, 9 Sep 2021 11:56:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631188617; bh=C56UGu/jYrwM6Jfi/51pH9IQNP0Jn9eLUHEN3yNrW1s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l0etXWMuWMxcwmQupKHHYeW5NHSf0LOegc87UPNarmZboWvMmK92Pm5oX/M7uvFKH Bj1RTUPHAc/mG9I6gZyXRPkgzUYdc7i3/6SKzPAMPmyLHE6FCYUNO+fP9prj09fKHj nWnOcyiOZg3W9RlFtJJ+dlKRp/X4igvf4H+MEJi5V76GNJKjaUZ22tPdTfi9b05Xv+ 4jwLSacCNxCBIeAfbxYe1n6NR+j2hrzaDVKXsaTmYifkW+cPftizQUAWi46G+NMdch BPtVRjvz5mlIqOqOWM0AO279d6GJ7funNhwwZcIgTgB2muRxXNW1CLVaA5ovNNGd77 jz90nDhIJKxBg== 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.4 087/109] of: Don't allow __of_attached_node_sysfs() without CONFIG_SYSFS Date: Thu, 9 Sep 2021 07:54:44 -0400 Message-Id: <20210909115507.147917-87-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909115507.147917-1-sashal@kernel.org> References: <20210909115507.147917-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