All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: "Pali Rohár" <pali.rohar@gmail.com>,
	"Jean Delvare" <jdelvare@suse.com>,
	"Jan C Peters" <jcpeters89@gmail.com>,
	"Thorsten Leemhuis" <fedora@leemhuis.info>,
	"David Santamaría Rogado" <howl.nsp@gmail.com>,
	"Peter Saunderson" <peteasa@gmail.com>,
	"Tolga Cakir" <cevelnet@gmail.com>,
	"Austin S. Hemmelgarn" <ahferroin7@gmail.com>,
	Mario_Limonciello@dell.com,
	"Gabriele Mazzotta" <gabriele.mzt@gmail.com>,
	"Michał Kępień" <kernel@kempniu.pl>,
	"Dakota Whipple" <dakotajaywhipple@gmail.com>,
	"Leon Yu" <leon@leonyu.net>
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/6] hwmon: (dell-smm) Restrict fan control and serial number to CAP_SYS_ADMIN by default
Date: Sat, 18 Jun 2016 13:00:41 -0700	[thread overview]
Message-ID: <5765A869.3050008@roeck-us.net> (raw)
In-Reply-To: <1466204089-17030-3-git-send-email-pali.rohar@gmail.com>

On 06/17/2016 03:54 PM, Pali Rohár wrote:
> For security reasons ordinary user must not be able to control fan speed
> via /proc/i8k by default. Some malicious software running under "nobody"
> user could be able to turn fan off and cause HW problems. So this patch
> changes default value of "restricted" parameter to 1.
>
> Also restrict reading of DMI_PRODUCT_SERIAL from /proc/i8k via "restricted"
> parameter. It is because non root user cannot read DMI_PRODUCT_SERIAL from
> sysfs file /sys/class/dmi/id/product_serial.
>
> Old non secure behaviour of file /proc/i8k can be achieved by loading this
> module with "restricted" parameter set to 0.
>
> Note that this patch has effects only for kernels compiled with CONFIG_I8K
> and only for file /proc/i8k. Hwmon interface provided by this driver was
> not changed and root access for setting fan speed was needed also before.
>
> Reported-by: Mario Limonciello <Mario_Limonciello@dell.com>
> Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
> Cc: stable@vger.kernel.org # will need backport

Applied.

Guenter

> ---
>   drivers/hwmon/dell-smm-hwmon.c |   19 ++++++++++++-------
>   1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
> index 480b2fa..c8bd3fdd 100644
> --- a/drivers/hwmon/dell-smm-hwmon.c
> +++ b/drivers/hwmon/dell-smm-hwmon.c
> @@ -67,6 +67,7 @@
>
>   static DEFINE_MUTEX(i8k_mutex);
>   static char bios_version[4];
> +static char bios_machineid[16];
>   static struct device *i8k_hwmon_dev;
>   static u32 i8k_hwmon_flags;
>   static uint i8k_fan_mult = I8K_FAN_MULT;
> @@ -95,13 +96,13 @@ module_param(ignore_dmi, bool, 0);
>   MODULE_PARM_DESC(ignore_dmi, "Continue probing hardware even if DMI data does not match");
>
>   #if IS_ENABLED(CONFIG_I8K)
> -static bool restricted;
> +static bool restricted = true;
>   module_param(restricted, bool, 0);
> -MODULE_PARM_DESC(restricted, "Allow fan control if SYS_ADMIN capability set");
> +MODULE_PARM_DESC(restricted, "Restrict fan control and serial number to CAP_SYS_ADMIN (default: 1)");
>
>   static bool power_status;
>   module_param(power_status, bool, 0600);
> -MODULE_PARM_DESC(power_status, "Report power status in /proc/i8k");
> +MODULE_PARM_DESC(power_status, "Report power status in /proc/i8k (default: 0)");
>   #endif
>
>   static uint fan_mult;
> @@ -397,9 +398,11 @@ i8k_ioctl_unlocked(struct file *fp, unsigned int cmd, unsigned long arg)
>   		break;
>
>   	case I8K_MACHINE_ID:
> -		memset(buff, 0, 16);
> -		strlcpy(buff, i8k_get_dmi_data(DMI_PRODUCT_SERIAL),
> -			sizeof(buff));
> +		if (restricted && !capable(CAP_SYS_ADMIN))
> +			return -EPERM;
> +
> +		memset(buff, 0, sizeof(buff));
> +		strlcpy(buff, bios_machineid, sizeof(buff));
>   		break;
>
>   	case I8K_FN_STATUS:
> @@ -516,7 +519,7 @@ static int i8k_proc_show(struct seq_file *seq, void *offset)
>   	seq_printf(seq, "%s %s %s %d %d %d %d %d %d %d\n",
>   		   I8K_PROC_FMT,
>   		   bios_version,
> -		   i8k_get_dmi_data(DMI_PRODUCT_SERIAL),
> +		   (restricted && !capable(CAP_SYS_ADMIN)) ? "-1" : bios_machineid,
>   		   cpu_temp,
>   		   left_fan, right_fan, left_speed, right_speed,
>   		   ac_power, fn_key);
> @@ -985,6 +988,8 @@ static int __init i8k_probe(void)
>
>   	strlcpy(bios_version, i8k_get_dmi_data(DMI_BIOS_VERSION),
>   		sizeof(bios_version));
> +	strlcpy(bios_machineid, i8k_get_dmi_data(DMI_PRODUCT_SERIAL),
> +		sizeof(bios_machineid));
>
>   	/*
>   	 * Get SMM Dell signature
>


  reply	other threads:[~2016-06-18 20:01 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-17 22:54 [PATCH 0/6] dell-smm-hwmon fixes Pali Rohár
2016-06-17 22:54 ` [PATCH 1/6] hwmon: (dell-smm) Fail in ioctl I8K_BIOS_VERSION when bios version is not a number Pali Rohár
2016-06-18 20:00   ` Guenter Roeck
2016-06-17 22:54 ` [PATCH 2/6] hwmon: (dell-smm) Restrict fan control and serial number to CAP_SYS_ADMIN by default Pali Rohár
2016-06-18 20:00   ` Guenter Roeck [this message]
2016-06-17 22:54 ` [PATCH 3/6] hwmon: (dell-smm) Disallow fan_type() calls on broken machines Pali Rohár
2016-06-18 20:08   ` Guenter Roeck
2016-06-18 22:46     ` Pali Rohár
2016-06-17 22:54 ` [PATCH 4/6] hwmon: (dell-smm) Cache fan_type() calls and change fan detection Pali Rohár
2016-06-19  0:01   ` Tolga Cakir
2016-06-17 22:54 ` [PATCH 5/6] hwmon: (dell-smm) Detect fan with index=2 Pali Rohár
2016-06-19  0:02   ` Tolga Cakir
2016-06-17 22:54 ` [PATCH 6/6] hwmon: (dell-smm) In debug mode log duration of SMM calls Pali Rohár
2016-06-18 12:21 ` [PATCH 0/6] dell-smm-hwmon fixes Pali Rohár
2016-06-18 15:13 ` Guenter Roeck
2016-06-18 15:26   ` Pali Rohár
2016-06-18 16:54     ` Guenter Roeck
2016-06-18 22:39       ` Pali Rohár
2016-06-20  9:12         ` Pali Rohár
2016-06-20 13:24           ` Guenter Roeck
2016-06-23 12:16             ` Pali Rohár
2016-06-23 13:51               ` Guenter Roeck
     [not found]       ` <CA+vQ2zCoGhLT2PUUhcuggJ3oE9Z6vfUW=Z1wgm8Ozz3XdnQoxA@mail.gmail.com>
2016-06-18 22:44         ` Pali Rohár
2016-06-22  8:02 ` Michał Kępień

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=5765A869.3050008@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=Mario_Limonciello@dell.com \
    --cc=ahferroin7@gmail.com \
    --cc=cevelnet@gmail.com \
    --cc=dakotajaywhipple@gmail.com \
    --cc=fedora@leemhuis.info \
    --cc=gabriele.mzt@gmail.com \
    --cc=howl.nsp@gmail.com \
    --cc=jcpeters89@gmail.com \
    --cc=jdelvare@suse.com \
    --cc=kernel@kempniu.pl \
    --cc=leon@leonyu.net \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pali.rohar@gmail.com \
    --cc=peteasa@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.