From: sashiko-bot@kernel.org
To: "Jihong Min" <hurryman2212@gmail.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH 1/5] hwmon: Export sensor and attribute definitions to userspace
Date: Fri, 09 Oct 2026 15:49:28 +0000 [thread overview]
Message-ID: <sashiko-outbox-165799@kernel.org> (raw)
In-Reply-To: <583573c30df45e4498737a89138e6f4f8911c631.1791559095.git.hurryman2212@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] hwmon: UAPI exposure of hwmon_max sentinel and internal bitmasks
--
commit bbc47a707f27865e8c59d7c4ea18a1b742278dfd
Author: Jihong Min <hurryman2212@gmail.com>
hwmon: Export sensor and attribute definitions to userspace
Move sensor types, attribute identifiers and configuration bits to
linux/hwmon.h in the UAPI so kernel and userspace drivers share them.
Keep existing values unchanged and use userspace-safe bit definitions.
> diff --git a/include/uapi/linux/hwmon.h b/include/uapi/linux/hwmon.h
> new file mode 100644
> index 0000000000000..274f9c9dcb87e
> --- /dev/null
> +++ b/include/uapi/linux/hwmon.h
> @@ -0,0 +1,372 @@
[ ... ]
> +enum hwmon_sensor_types {
> + hwmon_chip = 0,
> + hwmon_temp = 1,
> + hwmon_in = 2,
> + hwmon_curr = 3,
> + hwmon_power = 4,
> + hwmon_energy = 5,
> + hwmon_energy64 = 6,
> + hwmon_humidity = 7,
> + hwmon_fan = 8,
> + hwmon_pwm = 9,
> + hwmon_intrusion = 10,
> + hwmon_max = 11,
^^^^^^^^^^^^^^
[Severity: Medium]
Could exporting this expandable max boundary integer to the stable userspace
UAPI header lead to out-of-bounds memory accesses in userspace applications?
If a userspace program statically sizes an array based on hwmon_max, and a
future kernel release adds a new sensor type (incrementing hwmon_max), the
program could index past the end of its array when receiving the new sensor
type.
> +};
> +
> +enum hwmon_chip_attributes {
> + hwmon_chip_temp_reset_history = 0,
> + hwmon_chip_in_reset_history = 1,
> + hwmon_chip_curr_reset_history = 2,
> + hwmon_chip_power_reset_history = 3,
> + hwmon_chip_register_tz = 4,
> + hwmon_chip_update_interval = 5,
> + hwmon_chip_update_interval_us = 6,
> + hwmon_chip_alarms = 7,
> + hwmon_chip_samples = 8,
> + hwmon_chip_curr_samples = 9,
> + hwmon_chip_in_samples = 10,
> + hwmon_chip_power_samples = 11,
> + hwmon_chip_temp_samples = 12,
> + hwmon_chip_beep_enable = 13,
> + hwmon_chip_pec = 14,
> +};
> +
> +#define HWMON_C_TEMP_RESET_HISTORY _BITUL(hwmon_chip_temp_reset_history)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Severity: Medium]
Is it necessary to export these configuration bitmasks to the UAPI?
These bitmasks are strictly used by the kernel-internal struct
hwmon_channel_info and provide no value to userspace. Exporting them allows
and encourages anti-patterns in userspace.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1791531025.git.hurryman2212@gmail.com?part=1
next prev parent reply other threads:[~2026-10-09 15:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 15:38 [PATCH 0/5] hwmon: Introduce uhwmon for userspace implementations Jihong Min
2026-10-09 15:38 ` [PATCH 1/5] hwmon: Export sensor and attribute definitions to userspace Jihong Min
2026-10-09 15:49 ` sashiko-bot [this message]
2026-10-09 15:38 ` [PATCH 2/5] hwmon: Expose attribute validation and string helpers Jihong Min
2026-10-09 15:47 ` sashiko-bot
2026-10-09 15:38 ` [PATCH 3/5] hwmon: Add a generic interface for userspace implementations Jihong Min
2026-10-09 15:56 ` sashiko-bot
2026-10-10 14:50 ` Markus Elfring
2026-10-09 15:38 ` [PATCH 4/5] hwmon: Reject truncated attribute names Jihong Min
2026-10-09 15:44 ` sashiko-bot
2026-10-09 15:38 ` [PATCH 5/5] docs: hwmon: Document the uhwmon userspace interface Jihong Min
2026-10-09 15:55 ` 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=sashiko-outbox-165799@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=hurryman2212@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 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.