From: Guenter Roeck <linux@roeck-us.net>
To: Gui-Dong Han <hanguidong02@gmail.com>
Cc: juergh@proton.me, linux-hwmon@vger.kernel.org,
linux-kernel@vger.kernel.org, baijiaju1990@gmail.com
Subject: Re: [PATCH] hwmon: (vt1211) Convert macros to functions to avoid TOCTOU
Date: Fri, 21 Nov 2025 07:50:31 -0800 [thread overview]
Message-ID: <9c9b5eb5-ed5f-4b94-a44d-eec829faf22f@roeck-us.net> (raw)
In-Reply-To: <20251120041331.1917570-1-hanguidong02@gmail.com>
On Thu, Nov 20, 2025 at 12:13:31PM +0800, Gui-Dong Han wrote:
> The macros IN_FROM_REG, TEMP_FROM_REG, and RPM_FROM_REG evaluate their
> arguments multiple times. These macros are used in lockless show functions
> involving shared driver data, leading to Time-of-Check to Time-of-Use race
> conditions.
>
> For example, RPM_FROM_REG checks if a value is 0 or 255, and then uses it
> in a division. If the value is modified by another thread to 0 after the
> check but before the division, it causes a divide-by-zero error.
>
> Convert these macros to static functions. This guarantees that arguments
> are evaluated only once (pass-by-value), fixing the race conditions.
> Adhere to the principle of minimal changes by only converting the specific
> macros involved in these lockless contexts.
>
> Link: https://lore.kernel.org/all/CALbr=LYJ_ehtp53HXEVkSpYoub+XYSTU8Rg=o1xxMJ8=5z8B-g@mail.gmail.com/
> Signed-off-by: Gui-Dong Han <hanguidong02@gmail.com>
> ---
Applied.
Thanks,
Guenter
prev parent reply other threads:[~2025-11-21 15:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-20 4:13 Gui-Dong Han
2025-11-21 15:50 ` Guenter Roeck [this message]
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=9c9b5eb5-ed5f-4b94-a44d-eec829faf22f@roeck-us.net \
--to=linux@roeck-us.net \
--cc=baijiaju1990@gmail.com \
--cc=hanguidong02@gmail.com \
--cc=juergh@proton.me \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®