From: Vincent Jardin <vjardin@free.fr>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Hardware Monitoring <linux-hwmon@vger.kernel.org>
Subject: Re: [RFT PATCH] hwmon: (pmbus) Fix type confusion in notification logic
Date: Sun, 2 Aug 2026 16:18:21 +0200 [thread overview]
Message-ID: <am9RrapJinQ-eKDF@L30177.local> (raw)
In-Reply-To: <20260723211336.3046042-1-linux@roeck-us.net>
Hi Guenter,
> However, data->group.attrs can contain other types like struct
> pmbus_samples_reg or struct pmbus_sensor, which only embed a base
> struct device_attribute.
>
> If da is a struct pmbus_samples_reg, dev_attr is the last member. Casting
> it to struct sensor_device_attribute and reading the index field appears
> to access memory past the end of the allocation, which might trigger a
> slab-out-of-bounds read.
>
> Additionally, if da is a struct pmbus_sensor, casting it causes the index
> field to overlap with the page, phase, and reg fields. Could this produce
> a garbage mask on little-endian systems that spuriously matches the target
> reg, page, and flags during an alert?
>
> Fix the problem by using struct sensor_device_attr in struct pmbus_sensor
> and struct pmbus_label. Since those attributes never trigger a
> notification, set the value of attr->index to -1 for them. Use this value
> to distinguish from boolean attributes which _can_ trigger a notification
> and use the index field to encode mask, page, and register values.
>
> Fixes: f469bde9afd1 ("hwmon: (pmbus/core) Notify hwmon events")
> Cc: Vincent Jardin <vjardin@free.fr>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> RFT: Build-tested only
I tested on my board today but I did cherry pick the the 5 commits from:
https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git/log/?h=hwmon-next
hwmon: (pmbus) Fix type confusion in notification logic <-- this RFT
hwmon: (pmbus/mpq8646) Gate the writes
hwmon: (pmbus) Add MPQ8646 driver
dt-bindings: hwmon: pmbus: add MPS MPQ8646
hwmon: (pmbus/core) export pmbus_check_and_notify_faults()
Beside testing it with the attributes and boolean alarms of the MPQ8646, I did
test it with the board's PSU that is another PMBUus device and exposes some attributes
and boolean alarms too.
Both were OK.
Tested-by: Vincent Jardin <vjardin@free.fr>
best regards,
Vincent
next prev parent reply other threads:[~2026-08-02 14:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 21:13 [RFT PATCH] hwmon: (pmbus) Fix type confusion in notification logic Guenter Roeck
2026-07-23 21:25 ` sashiko-bot
2026-07-23 21:32 ` Vincent Jardin
2026-08-02 14:18 ` Vincent Jardin [this message]
2026-08-02 14:33 ` 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=am9RrapJinQ-eKDF@L30177.local \
--to=vjardin@free.fr \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux@roeck-us.net \
/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