From nobody Thu Jun 11 00:35:52 2026 Received: from lithops.sigma-star.at (mailout.nod.at [116.203.167.152]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A67E441055 for ; Fri, 27 Feb 2026 15:48:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.167.152 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772207287; cv=none; b=skeJUZ5iHpLOStGh3LGF5TsrPaF5AzxiJ3XB9gjDQgqWQLZfGRwYHU6FWGdH5lr0stsV33ZIMedPYJR6EIjTu3tvCyWuqu1TM/xbqFcyrGiyC51tXG4nBM9M+10RJ0On4fr6U9uZ6jvzIg0AniI2C+RpwDf5DRArSDbffVMvT+U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772207287; c=relaxed/simple; bh=MBp4hVmNByzyiukKFzWJ28n934ywRjtxo4GWdq8NPUc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=nUeVx+nh9SkkdxQaaBBaFARQtpTgr4T708ZGwj8DLPvz+cI0VWHR4YHsZ1VWhutWnEmNLnUX8i5GnXpsqz9pAfhtkMnxyR72Jz+ZpDMJqpb0pRCHvEJ4e8ku3bMhPdtMwZJ/kj86hXbQAtrGu2EQYqTPolSkphEE8ut2k4WJU2I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nod.at; spf=fail smtp.mailfrom=nod.at; arc=none smtp.client-ip=116.203.167.152 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nod.at Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nod.at Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 7B919298599; Fri, 27 Feb 2026 16:48:02 +0100 (CET) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id uXYYvlK_irlM; Fri, 27 Feb 2026 16:48:02 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id E3D0D29859D; Fri, 27 Feb 2026 16:48:01 +0100 (CET) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id TWhppqRt87Zx; Fri, 27 Feb 2026 16:48:01 +0100 (CET) Received: from foxxylove.corp.sigma-star.at (unknown [82.150.214.1]) by lithops.sigma-star.at (Postfix) with ESMTPSA id 96A98298599; Fri, 27 Feb 2026 16:48:01 +0100 (CET) From: Richard Weinberger To: linux-kernel@vger.kernel.org Cc: jdelvare@suse.com, upstream+linux@sigma-star.at, Julian.FRIEDRICH@frequentis.com, Richard Weinberger Subject: [PATCH] dmi-id: Add parameter to relax sysfs permissions Date: Fri, 27 Feb 2026 16:47:43 +0100 Message-ID: <20260227154743.11573-1-richard@nod.at> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Every few years I find myself in a discussion that goes like: user: I hate using dmidecode to read vendor infos, it needs root! me: Just use /sys/class/dmi/id/ user: wow! Neat! *later* user: But, I can't read from product_serial! me: *grrrr* For systems where no confidential information is stored in the DMI IDs allow setting the kernel module parameter dmi_id.relaxed_perms to y. It will make sure the every sysfs attribute has at least 0444 permissions. Signed-off-by: Richard Weinberger --- drivers/firmware/dmi-id.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c index d19c78a78ae3a..a237caf89d526 100644 --- a/drivers/firmware/dmi-id.c +++ b/drivers/firmware/dmi-id.c @@ -12,6 +12,8 @@ #include #include =20 +static bool relaxed_perms; + struct dmi_device_attribute{ struct device_attribute dev_attr; int field; @@ -183,10 +185,14 @@ static struct class dmi_class =3D { static struct device *dmi_dev; =20 /* Initialization */ - -#define ADD_DMI_ATTR(_name, _field) \ - if (dmi_get_system_info(_field)) \ - sys_dmi_attributes[i++] =3D &sys_dmi_##_name##_attr.dev_attr.attr; +#define ADD_DMI_ATTR(_name, _field) \ + ({ \ + if (dmi_get_system_info(_field)) { \ + if (relaxed_perms) \ + sys_dmi_##_name##_attr.dev_attr.attr.mode |=3D 0444; \ + sys_dmi_attributes[i++] =3D &sys_dmi_##_name##_attr.dev_attr.attr;\ + } \ + }) =20 /* In a separate function to keep gcc 3.2 happy - do NOT merge this in dmi_id_init! */ @@ -260,5 +266,6 @@ static int __init dmi_id_init(void) =20 return ret; } - +module_param(relaxed_perms, bool, 0400); +MODULE_PARM_DESC(relaxed_perms, "Allow everyone read access to all IDs"); arch_initcall(dmi_id_init); --=20 2.51.0