Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1840113pxb; Thu, 16 Sep 2021 17:30:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfvxyelZgQn6AmogL6yaGFCSB4ZU8Z23K9fhzzL5YipTKkPprF4wEHfD7XxCgQ9aF97yXZ X-Received: by 2002:a17:906:e0d8:: with SMTP id gl24mr9175668ejb.413.1631838654261; Thu, 16 Sep 2021 17:30:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631838654; cv=none; d=google.com; s=arc-20160816; b=lejUIcJSigzkjdtbKIvaAR5Lj9ypZjxd/csFhnzbM1+QVg1VHoGCLuAePyLFL49IZo H84XXpu5Yn+Cn2sOIY7mvFzXWYHND+S6c8UFia+mBpJ+sS+9cgDcpix1xDZ53mUHLPnH kOOWSWipF9uHoEYPlwzN9CObHWZihS+aU8edXOe9FR/qOL7++P9aqFC4w0Ke5+SvKUnX Jo5kc7ISDadCe+RGTAKoFNIZ4PS7Lv+ZzzFNELB1bmCOLha8SsDZEhF+LRzRnKlSI8WH M9lvL63H0dOltkjkZmZLAAdp9QbNEDVbuznlMVIKCcz9A5/5lDymzHr1tRmwFUWgmjLA LrJA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nmbQ5fW07I2JuJKIDYzD7SdtFtLwB+J4R3yeG17ZvZM=; b=c7VBXwEZ2PE3f/zch6Y2cctsOv5/W8exdLnWdhMNLXwhqdHzp5EKTWpUw7RPntOvaJ /5k302pZUyXwn+mtuivYbZ6TkwV5trzFBcfbeZvqccXtHpOohF62QY6DXsiS0Slbx2Gz Y8uZqLaD/nogMXFIwZry6Ah3xjuhRomZY7t4mNKjwPst8bAZqt+qnFFSOGVJVoRf8cbT n7ZnyXYJmq1FpOAfBVEYX63f2haZ/Gltr7uX+/DRFr62MwhIc5YPMoI1ide6NR3EYp3s VOWr8Nbvx/opXnjz2jeSClPE77McYeOoGFAIS6e+DgRkTjNnSqz0n/Mz6rYwdUJyFdxf p5/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="eByXJ/ix"; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s4si7192157ejm.735.2021.09.16.17.30.30; Thu, 16 Sep 2021 17:30: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=@linuxfoundation.org header.s=korg header.b="eByXJ/ix"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348909AbhIPRDT (ORCPT + 99 others); Thu, 16 Sep 2021 13:03:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:55312 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245696AbhIPQ4M (ORCPT ); Thu, 16 Sep 2021 12:56:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9F48E6138F; Thu, 16 Sep 2021 16:30:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631809851; bh=C56UGu/jYrwM6Jfi/51pH9IQNP0Jn9eLUHEN3yNrW1s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eByXJ/ixqfeSOPZjZU/OVgmyWhY4pm4myrd/zhe40dD8jRtRHcWvWIg3XaPQcqi3+ YDrIg8SLgLdp2cysp8cbwFtLxZuAI3ceabjzE47JwZhnoLTv1vWBcKiIE3SBOf7Bf4 tArswX2Ij/BjPUo5BFcy6JaAhvBTGk8mtkgqT6VQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier , Rob Herring , Sasha Levin Subject: [PATCH 5.13 306/380] of: Dont allow __of_attached_node_sysfs() without CONFIG_SYSFS Date: Thu, 16 Sep 2021 18:01:03 +0200 Message-Id: <20210916155814.470104685@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155803.966362085@linuxfoundation.org> References: <20210916155803.966362085@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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