From: sashiko-bot@kernel.org
To: "Zinc Lim" <limzhineng2@gmail.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH net-next 3/6] eth: fbnic: cache hwmon sensor readings
Date: Wed, 22 Jul 2026 22:17:58 +0000 [thread overview]
Message-ID: <20260722221758.D76421F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260721221540.648272-4-limzhineng2@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The hardware monitoring cache expiration check is vulnerable to a 24-day jiffies wraparound bug on 32-bit systems, which can cause the driver to indefinitely serve stale sensor readings.
--
--- Patch [3]: [PATCH net-next 3/6] eth: fbnic: cache hwmon sensor readings ---
commit 4d77f6b947d1d111d9ffbbeb2ef3742b0f54686f
Author: Zinc Lim <limzhineng2@gmail.com>
Subject: eth: fbnic: cache hwmon sensor readings
This commit introduces caching for hardware monitoring sensor readings to
reduce firmware mailbox IPC traffic. It caches the temperature and voltage
values and serves them for the remainder of the current jiffy, using a
sentinel value to ensure the first read always triggers a refresh.
> diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c b/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c
> --- a/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c
> +++ b/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c
[ ... ]
> @@ -25,26 +26,32 @@ static int fbnic_hwmon_sensor_read(struct fbnic_dev *fbd, int id, long *val)
> {
> + struct fbnic_hwmon_cache *cache = &fbd->hwmon_cache;
> struct fbnic_fw_completion *fw_cmpl;
> int err = 0;
> + s32 *cached;
>
> switch (id) {
> case FBNIC_SENSOR_TEMP:
> + cached = &cache->temp_mdeg;
> break;
> case FBNIC_SENSOR_VOLTAGE:
> + cached = &cache->volt_mv;
> break;
> default:
> + return -EINVAL;
> + }
> +
> + if (*cached != FBNIC_SENSOR_NO_DATA &&
> + time_is_after_eq_jiffies(cache->last_read)) {
[Severity: Medium]
Can this cache expiration check cause stale readings on 32-bit systems due to
jiffies wraparound?
If the hwmon sysfs files are not read for ~24.8 days, the jiffies counter will
advance such that the signed subtraction in time_is_after_eq_jiffies()
underflows. This would cause the macro to evaluate to true, resulting in a
cache hit.
Since a cache hit bypasses the firmware read and does not update last_read,
would the driver continually return the same stale cached value for the next
24.8 days until the difference wraps back to negative?
Given the commit message mentions serving reads "for the remainder of the
current jiffy", should this explicitly check for jiffies == cache->last_read
instead?
> + *val = *cached;
> + return 0;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260721221540.648272-1-limzhineng2@gmail.com?part=3
next prev parent reply other threads:[~2026-07-22 22:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 22:15 [PATCH net-next 0/6] eth: fbnic: expand hwmon sensor support Zinc Lim
2026-07-21 22:15 ` [PATCH net-next 1/6] eth: fbnic: move sensor read logic out of fbnic_mac Zinc Lim
2026-07-22 22:17 ` sashiko-bot
2026-07-21 22:15 ` [PATCH net-next 2/6] eth: fbnic: expose all hwmon attributes unconditionally as read-only Zinc Lim
2026-07-22 22:18 ` sashiko-bot
2026-07-21 22:15 ` [PATCH net-next 3/6] eth: fbnic: cache hwmon sensor readings Zinc Lim
2026-07-22 22:17 ` sashiko-bot [this message]
2026-07-21 22:15 ` [PATCH net-next 4/6] eth: fbnic: report temperature and voltage thresholds via hwmon Zinc Lim
2026-07-22 22:18 ` sashiko-bot
2026-07-21 22:15 ` [PATCH net-next 5/6] eth: fbnic: report temperature and voltage alarms " Zinc Lim
2026-07-22 22:17 ` sashiko-bot
2026-07-21 22:15 ` [PATCH net-next 6/6] eth: fbnic: firmware notifies hwmon on sensor threshold events Zinc Lim
2026-07-22 22:18 ` sashiko-bot
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=20260722221758.D76421F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=limzhineng2@gmail.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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