All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Louis Sautier" <sautier.louis@gmail.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH 2/2] scsi: mpt3sas: add hwmon support
Date: Thu, 14 May 2026 01:02:07 +0000	[thread overview]
Message-ID: <20260514010209.5C3ABC19425@smtp.kernel.org> (raw)
In-Reply-To: <20260512214703.655633-3-sautier.louis@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unprivileged user-space processes can flood the HBA firmware with synchronous configuration requests, contending a shared mutex and causing a Denial of Service (DoS).
--

commit 12785f6156b64bc1ece9061e087614ba8f75d567
Author: Louis Sautier <sautier.louis@gmail.com>

scsi: mpt3sas: add hwmon support

This commit adds hardware monitoring support for LSI / Broadcom SAS HBAs,
exposing IOC and board temperature sensors. The readings are obtained by
querying MPI IO Unit Page 7 and exposed to userspace through standard
hwmon sysfs files.

> diff --git a/drivers/scsi/mpt3sas/mpt3sas_hwmon.c b/drivers/scsi/mpt3sas/mpt3sas_hwmon.c
> new file mode 100644
> --- /dev/null
> +++ b/drivers/scsi/mpt3sas/mpt3sas_hwmon.c
[ ... ]
> +static umode_t
> +_hwmon_is_visible(const void *drvdata, enum hwmon_sensor_types type,
> +		  u32 attr, int channel)
> +{
[ ... ]
> +	if (channel == 0 && h->ioc_present)
> +		return 0444;
> +	if (channel == 1 && h->board_present)
> +		return 0444;
> +	return 0;
> +}
[ ... ]
> +static int
> +_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
> +	    u32 attr, int channel, long *val)
> +{
> +	struct mpt3sas_hwmon *h = dev_get_drvdata(dev);
> +	Mpi2ConfigReply_t mpi_reply;
> +	Mpi2IOUnitPage7_t page;
> +	int r;
> +
> +	if (type != hwmon_temp || attr != hwmon_temp_input)
> +		return -EOPNOTSUPP;
> +
> +	r = mpt3sas_config_get_iounit_pg7(h->ioc, &mpi_reply, &page);

Could exposing this read to unprivileged users lead to excessive firmware
requests and mutex contention?

Since the sysfs files are world-readable, any local user can read them in a
tight loop. Every read directly calls mpt3sas_config_get_iounit_pg7(), which
issues synchronous requests to the firmware over the PCIe bus and acquires
the shared config_cmds.mutex:

_hwmon_read() ->
    mpt3sas_config_get_iounit_pg7() ->
        _config_request() ->
            mutex_lock(&ioc->config_cmds.mutex)

Does this allow an unprivileged user to starve other storage subsystem
components that rely on this mutex for administrative tasks or device
discovery?

Could we implement a caching mechanism (for example, caching the readings
for a short period using jiffies) to rate-limit these firmware requests?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260512214703.655633-1-sautier.louis@gmail.com?part=2

  parent reply	other threads:[~2026-05-14  1:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12 21:47 [PATCH 0/2] scsi: mpt3sas: add hwmon support Louis Sautier
2026-05-12 21:47 ` [PATCH 1/2] scsi: mpt3sas: add IO Unit Page 7 config accessor Louis Sautier
2026-05-12 21:47 ` [PATCH 2/2] scsi: mpt3sas: add hwmon support Louis Sautier
2026-05-13  3:57   ` Guenter Roeck
2026-05-14  1:11     ` Louis Sautier
2026-05-14  1:26       ` Guenter Roeck
2026-05-14  1:02   ` sashiko-bot [this message]
2026-05-14  3:39     ` Louis Sautier
2026-05-14  5:17       ` Guenter Roeck
2026-05-14 19:57         ` Louis Sautier
2026-05-14 20:58           ` Guenter Roeck

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=20260514010209.5C3ABC19425@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sautier.louis@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.