public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali.rohar@gmail.com>
To: Mario Limonciello <mario.limonciello@dell.com>
Cc: dvhart@infradead.org, LKML <linux-kernel@vger.kernel.org>,
	platform-driver-x86@vger.kernel.org, quasisec@google.com
Subject: Re: [PATCH 06/12] platform/x86: dell-wmi-smbios: Add a sysfs interface for SMBIOS tokens
Date: Mon, 25 Sep 2017 18:23:33 +0200	[thread overview]
Message-ID: <20170925162333.GL22190@pali> (raw)
In-Reply-To: <1342f21a4f2c9af86d3033a9af9d9a4d05d27106.1505999739.git.mario.limonciello@dell.com>

On Thursday 21 September 2017 08:57:11 Mario Limonciello wrote:
> Currently userspace tools can access system tokens via the dcdbas
> kernel module and a SMI call that will cause the platform to execute
> SMM code.
> 
> With a goal in mind of deprecating the dcdbas kernel module a different
> method for accessing these tokens from userspace needs to be created.
> 
> This is intentionally marked to only be readable as root as it can
> contain sensitive information about the platform's configuration.

Darren, Andy, any comments? I'm not quite sure if such API is suitable
for long term in kernel.

Basically tokens are list of tuples <id, location, value> with
possibility to active them, right?

Does not kernel have some better API for it?

Also, keep in mind security aspect of tokens. They represent e.g. boot
order priority or enable/disable some machine peripheral.

> Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
> ---
>  .../ABI/testing/sysfs-platform-dell-wmi-smbios     | 16 +++++++++
>  drivers/platform/x86/dell-wmi-smbios.c             | 38 ++++++++++++++++++++++
>  2 files changed, 54 insertions(+)
>  create mode 100644 Documentation/ABI/testing/sysfs-platform-dell-wmi-smbios
> 
> diff --git a/Documentation/ABI/testing/sysfs-platform-dell-wmi-smbios b/Documentation/ABI/testing/sysfs-platform-dell-wmi-smbios
> new file mode 100644
> index 000000000000..6d151f2dffba
> --- /dev/null
> +++ b/Documentation/ABI/testing/sysfs-platform-dell-wmi-smbios
> @@ -0,0 +1,16 @@
> +What:		/sys/devices/platform/<platform>/tokens
> +Date:		October 2017
> +KernelVersion:	4.15
> +Contact:	"Mario Limonciello" <mario.limonciello@dell.com>
> +Description:
> +		A read-only description of Dell platform tokens
> +		available on the machine.
> +
> +		The tokens will be displayed in the following
> +		machine readable format with each token on a
> +		new line:
> +
> +		ID @ Location : value
> +
> +		For example token:
> +		5 @ 5 : 3
> diff --git a/drivers/platform/x86/dell-wmi-smbios.c b/drivers/platform/x86/dell-wmi-smbios.c
> index 7f896701fb7b..c3701fdadf7b 100644
> --- a/drivers/platform/x86/dell-wmi-smbios.c
> +++ b/drivers/platform/x86/dell-wmi-smbios.c
> @@ -189,6 +189,34 @@ static void __init find_tokens(const struct dmi_header *dm, void *dummy)
>  	}
>  }
>  
> +static ssize_t tokens_show(struct device *dev,
> +			   struct device_attribute *attr, char *buf)
> +{
> +	size_t off = 0;
> +	int i;
> +
> +	for (i = 0; i < da_num_tokens; i++) {
> +		if (off > PAGE_SIZE)
> +			break;
> +		off += scnprintf(buf+off, PAGE_SIZE-off, "%x @ %x : %x\n",
> +		da_tokens[i].tokenID, da_tokens[i].location,
> +		da_tokens[i].value);
> +	}
> +
> +	return off;
> +}
> +
> +DEVICE_ATTR(tokens, 0400, tokens_show, NULL);
> +
> +static struct attribute *smbios_attrs[] = {
> +	&dev_attr_tokens.attr,
> +	NULL
> +};
> +
> +static const struct attribute_group smbios_attribute_group = {
> +	.attrs = smbios_attrs,
> +};
> +
>  static int dell_wmi_smbios_probe(struct wmi_device *wdev)
>  {
>  	int ret;
> @@ -206,8 +234,16 @@ static int dell_wmi_smbios_probe(struct wmi_device *wdev)
>  		goto fail_buffer;
>  	}
>  
> +	ret = sysfs_create_group(&wdev->dev.kobj, &smbios_attribute_group);
> +	if (ret)
> +		goto fail_create_group;
> +	kobject_uevent(&wdev->dev.kobj, KOBJ_CHANGE);
> +
>  	return 0;
>  
> +fail_create_group:
> +	free_page((unsigned long)buffer);
> +
>  fail_buffer:
>  	kfree(da_tokens);
>  	return ret;
> @@ -215,8 +251,10 @@ static int dell_wmi_smbios_probe(struct wmi_device *wdev)
>  
>  static int dell_wmi_smbios_remove(struct wmi_device *wdev)
>  {
> +	sysfs_remove_group(&wdev->dev.kobj, &smbios_attribute_group);
>  	kfree(da_tokens);
>  	free_page((unsigned long)buffer);
> +	kobject_uevent(&wdev->dev.kobj, KOBJ_CHANGE);
>  	return 0;
>  }
>  

-- 
Pali Rohár
pali.rohar@gmail.com

  reply	other threads:[~2017-09-25 16:23 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-21 13:57 [PATCH 00/12] Introduce support for Dell SMBIOS over WMI Mario Limonciello
2017-09-21 13:57 ` [PATCH 01/12] platform/x86: dell-wmi: label driver as handling notifications Mario Limonciello
2017-09-25 16:04   ` Pali Rohár
2017-09-25 20:14     ` Mario.Limonciello
2017-09-27 15:43       ` Darren Hart
2017-09-21 13:57 ` [PATCH 02/12] platform/x86: dell-wmi: Don't match on descriptor GUID modalias Mario Limonciello
2017-09-25 16:06   ` Pali Rohár
2017-09-21 13:57 ` [PATCH 03/12] platform/x86: dell-smbios: Add pr_fmt definition to driver Mario Limonciello
2017-09-21 16:22   ` Andy Shevchenko
2017-09-25 16:07   ` Pali Rohár
2017-09-21 13:57 ` [PATCH 04/12] platform/x86: dell-smbios: Switch to a WMI-ACPI interface Mario Limonciello
2017-09-25 16:18   ` Pali Rohár
2017-09-25 19:28     ` Mario.Limonciello
2017-09-27 16:46       ` Darren Hart
2017-09-27 18:29         ` Mario.Limonciello
2017-09-27 19:47   ` Andy Lutomirski
2017-09-27 21:15     ` Mario.Limonciello
2017-09-21 13:57 ` [PATCH 05/12] platform/x86: dell-smbios: rename to dell-wmi-smbios Mario Limonciello
2017-09-21 13:57 ` [PATCH 06/12] platform/x86: dell-wmi-smbios: Add a sysfs interface for SMBIOS tokens Mario Limonciello
2017-09-25 16:23   ` Pali Rohár [this message]
2017-09-25 17:04     ` Andy Shevchenko
2017-09-25 17:31       ` Mario.Limonciello
2017-09-27 16:50         ` Darren Hart
2017-09-27 18:27           ` Mario.Limonciello
2017-09-27 18:31             ` Andy Shevchenko
2017-09-27 18:55               ` Darren Hart
2017-09-27 19:49                 ` Andy Lutomirski
2017-09-27 19:50                   ` Mario.Limonciello
2017-09-21 13:57 ` [PATCH 07/12] platform/x86: dell-wmi-smbios: Use Dell WMI descriptor check Mario Limonciello
2017-09-21 16:44   ` Andy Shevchenko
2017-09-21 20:56     ` Mario.Limonciello
2017-09-21 13:57 ` [PATCH 08/12] platform/x86: wmi: Cleanup exit routine in reverse order of init Mario Limonciello
2017-09-21 13:57 ` [PATCH 09/12] platform/x86: wmi: create character devices when requested by drivers Mario Limonciello
2017-09-21 16:46   ` Andy Shevchenko
2017-09-21 19:21     ` Mario.Limonciello
2017-09-21 13:57 ` [PATCH 10/12] platform/x86: wmi: destroy on cleanup rather than unregister Mario Limonciello
2017-09-21 13:57 ` [PATCH 11/12] platform/x86: dell-wmi-smbios: introduce character device for userspace Mario Limonciello
2017-09-25 16:31   ` Pali Rohár
2017-09-25 16:58     ` Andy Shevchenko
2017-09-25 17:46       ` Mario.Limonciello
2017-09-27 16:59         ` Darren Hart
2017-09-27 18:10           ` Mario.Limonciello
2017-09-27 18:50             ` Darren Hart
2017-09-27 21:12               ` Mario.Limonciello
2017-09-27 21:59                 ` Darren Hart
2017-09-21 13:57 ` [PATCH 12/12] platform/x86: Kconfig: Change the default settings for dell-wmi-smbios Mario Limonciello
2017-09-25 16:13 ` [PATCH 00/12] Introduce support for Dell SMBIOS over WMI Pali Rohár
2017-09-25 16:32   ` Mario.Limonciello
2017-09-25 16:49     ` Pali Rohár
2017-09-25 19:27       ` Mario.Limonciello
2017-09-27 16:39         ` Darren Hart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170925162333.GL22190@pali \
    --to=pali.rohar@gmail.com \
    --cc=dvhart@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mario.limonciello@dell.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=quasisec@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox