From: Armin Wolf <W_Armin@gmx.de>
To: Gui-Dong Han <hanguidong02@gmail.com>,
Guenter Roeck <linux@roeck-us.net>
Cc: vt8231@hiddenengine.co.uk, steve.glendinning@shawell.net,
jdelvare@suse.com, linux-hwmon@vger.kernel.org,
linux-kernel@vger.kernel.org, baijiaju1990@gmail.com
Subject: Re: [BUG] hwmon: Widespread TOCTOU vulnerabilities in the hwmon subsystem
Date: Fri, 6 Jun 2025 23:30:22 +0200 [thread overview]
Message-ID: <0a3a06df-5da9-4b39-bf38-0894b8084132@gmx.de> (raw)
In-Reply-To: <CALbr=LYe3p9GW2Z_RUxKG+w2Q1wfWGRW=dRLoTraS7qJ7imdgw@mail.gmail.com>
Am 06.06.25 um 09:03 schrieb Gui-Dong Han:
>> On Thu, Jun 05, 2025 at 07:33:24AM -0700, Guenter Roeck wrote:
>>>> I would like to discuss these issues further and collaborate on the
>>>> best way to address them comprehensively.
>>>>
>>> I'd suggest to start submitting patches, with the goal of minimizing
>>> the scope of changes. Sometimes that may mean expanding the scope of
>>> locks, sometimes it may mean converting macros to functions. When
>>> converting to functions, it doesn't have to be inline functions: I'd
>>> leave that up to the compiler to decide. None of that code is performance
>>> critical.
>>>
>> Actualy, that makes me wonder if it would make sense to introduce
>> subsystem-level locking. We could introduce a lock in struct
>> hwmon_device_attribute and lock it whenever a show or store function
>> executes in drivers/hwmon/hwmon.c. That would only help for drivers
>> using the _with_info API, but it would simplify driver code a lot.
>> Any thoughts on that ?
Hi,
i am against adding a subsystem lock just to work around buggy drivers. Many drivers
should use fine-grained locking to avoid high latencies when reading a single attribute.
Thanks,
Armin Wolf
> Hi Guenter,
>
> Thanks for your quick and insightful feedback!
>
> I agree with your suggestion. Adding a note to
> Documentation/hwmon/submitting-patches.rst about avoiding calculations
> in macros is also a great idea to prevent this class of bugs in the
> future.
>
> Regarding your thoughts on subsystem-level locking, it sounds like a
> promising approach to simplify the drivers using the _with_info API.
> As you mentioned, some drivers don't use this API, so they would still
> require manual fixes.
>
> For the subsystem-level lock itself, I was wondering if a read-write
> semaphore might be more appropriate than a standard mutex. This would
> prevent a single show operation from blocking other concurrent reads.
> I'm not entirely sure about all the implications, but it might be
> worth considering to maintain read performance.
>
> Thanks again for your guidance.
>
> Best regards,
> Gui-Dong Han
>
next prev parent reply other threads:[~2025-06-06 21:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-05 11:49 [BUG] hwmon: Widespread TOCTOU vulnerabilities in the hwmon subsystem Gui-Dong Han
2025-06-05 14:33 ` Guenter Roeck
2025-06-05 14:37 ` Guenter Roeck
2025-06-06 7:03 ` Gui-Dong Han
2025-06-06 21:30 ` Armin Wolf [this message]
2025-06-06 23:20 ` Guenter Roeck
2025-06-09 15:03 ` Armin Wolf
2025-06-09 15:27 ` Guenter Roeck
2025-06-06 23:22 ` Guenter Roeck
2025-06-09 15:06 ` Armin Wolf
2025-11-29 14:42 ` Andy Shevchenko
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=0a3a06df-5da9-4b39-bf38-0894b8084132@gmx.de \
--to=w_armin@gmx.de \
--cc=baijiaju1990@gmail.com \
--cc=hanguidong02@gmail.com \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=steve.glendinning@shawell.net \
--cc=vt8231@hiddenengine.co.uk \
/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