From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev,
Sashiko AI Review <sashiko-bot@kernel.org>,
Haoxiang Li <haoxiang_li2024@163.com>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Jiri Kosina <jkosina@suse.com>
Subject: [PATCH 5.10 56/57] HID: sensor: custom: Fix use-after-free in enable_sensor
Date: Tue, 25 Aug 2026 15:27:18 +0200 [thread overview]
Message-ID: <20260825132543.529407147@linuxfoundation.org> (raw)
In-Reply-To: <20260825132541.342390421@linuxfoundation.org>
5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <haoxiang_li2024@163.com>
commit ad8fb82b04422f49530d2aa2753cc81d1c60102c upstream.
enable_sensor_store() can call set_power_report_state(), which
dereferences sensor_inst->power_state and sensor_inst->report_state.
These pointers refer to entries in sensor_inst->fields.
Create the field attributes before exposing the enable_sensor sysfs
attribute, so enable_sensor cannot be accessed before the state it
depends on has been initialized.
On remove, delete enable_sensor before freeing the field attributes,
so a concurrent sysfs write cannot dereference freed memory through
power_state or report_state.
Reported-by: Sashiko AI Review <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/patchset/20260623021950.1736413-1-haoxiang_li2024@163.com?part=1
Fixes: 4a7de0519df5 ("HID: sensor: Custom and Generic sensor support")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/hid/hid-sensor-custom.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
--- a/drivers/hid/hid-sensor-custom.c
+++ b/drivers/hid/hid-sensor-custom.c
@@ -771,26 +771,26 @@ static int hid_sensor_custom_probe(struc
return ret;
}
- ret = sysfs_create_group(&sensor_inst->pdev->dev.kobj,
- &enable_sensor_attr_group);
+ ret = hid_sensor_custom_add_attributes(sensor_inst);
if (ret)
goto err_remove_callback;
- ret = hid_sensor_custom_add_attributes(sensor_inst);
+ ret = sysfs_create_group(&sensor_inst->pdev->dev.kobj,
+ &enable_sensor_attr_group);
if (ret)
- goto err_remove_group;
+ goto err_remove_attributes;
ret = hid_sensor_custom_dev_if_add(sensor_inst);
if (ret)
- goto err_remove_attributes;
+ goto err_remove_group;
return 0;
-err_remove_attributes:
- hid_sensor_custom_remove_attributes(sensor_inst);
err_remove_group:
sysfs_remove_group(&sensor_inst->pdev->dev.kobj,
&enable_sensor_attr_group);
+err_remove_attributes:
+ hid_sensor_custom_remove_attributes(sensor_inst);
err_remove_callback:
sensor_hub_remove_callback(hsdev, hsdev->usage);
@@ -803,9 +803,10 @@ static int hid_sensor_custom_remove(stru
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
hid_sensor_custom_dev_if_remove(sensor_inst);
- hid_sensor_custom_remove_attributes(sensor_inst);
+ /* Remove enable_sensor first as it uses fields via power_state/report_state. */
sysfs_remove_group(&sensor_inst->pdev->dev.kobj,
&enable_sensor_attr_group);
+ hid_sensor_custom_remove_attributes(sensor_inst);
sensor_hub_remove_callback(hsdev, hsdev->usage);
return 0;
next prev parent reply other threads:[~2026-08-25 14:01 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 13:26 [PATCH 5.10 00/57] 5.10.267-rc1 review Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 01/57] Bluetooth: RFCOMM: take rfcomm_mutex for the deferred setup accept Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 02/57] rndis_host: add overflow check in rndis_rx_fixup() Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 03/57] ocfs2: fix missing metadata reservation for large xattrs Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 04/57] ext4: stop retrying saturated xattr cache entries Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 05/57] ext4: clear error before retrying inode xattr space fallback Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 06/57] xfs: validate attr entry pointer before field access Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 07/57] net/x25: fix use-after-free of the socket by its timers Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 08/57] mm/huge_memory: fix huge_zero_pfn race Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 09/57] staging: rtl8723bs: fix OOB read in WMM_param_handler() Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 10/57] misc: fastrpc: separate fastrpc device from channel context Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 11/57] misc: fastrpc: Rework fastrpc_req_munmap Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 12/57] misc: fastrpc: Remove buffer from list prior to unmap operation Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 13/57] net: ipv4: Publish fib_nlmsg_size() Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 14/57] ipv4: Fix fib_nlmsg_size() for RTA_VIA nexthops Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 15/57] NTB: ntb_netdev: Preserve RX queue depth on allocation failure Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 16/57] serial: amba-pl011: synchronize DMA teardown Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 17/57] perf: Fix cgroup state vs ERROR Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 18/57] perf: Fix dangling cgroup pointer in cpuctx Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 19/57] perf/core: Fix group leader use-after-free after sibling detach Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 20/57] packet: use consistent hard_header_len in non-ring send paths Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 21/57] packet: use consistent hard_header_len in TX_RING send path Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 22/57] net/sched: reject overly deep qdisc hierarchies Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 23/57] packet: synchronize pressure clearing with ring reconfiguration Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 24/57] inet: frags: publish queues before arming timer Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 25/57] xfs: fix ilock leak on error in xfs_dq_get_next_id Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 26/57] mmc: atmel-mci: Fix use-after-free in atmci_remove due to race condition Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 27/57] s390/vfio_ccw: Cancel existing workqueues Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 28/57] KVM: arm64: Retry fault if vma_lookup() results become invalid Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 29/57] nfc: digital: clamp SENSF_RES length to the destination buffer Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 30/57] nfc: fdp: bound the device-reported read length and fix an skb leak Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 31/57] nfc: microread: validate target discovery payload lengths Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 32/57] nfc: llcp: bound the connect_sn TLV walk to the skb Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 33/57] nfc: llcp: fix OOB read and u8 offset wrap in TLV parsers Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 34/57] nfc: llcp: reject PDUs shorter than the LLCP header Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 35/57] nfc: pn533: purge fragmented skbs during cleanup Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 36/57] nfc: st21nfca: validate ATR_REQ length against the received frame Greg Kroah-Hartman
2026-08-25 13:26 ` [PATCH 5.10 37/57] nfc: nci: fix out-of-bounds write in nci_target_auto_activated() Greg Kroah-Hartman
2026-08-25 13:27 ` [PATCH 5.10 38/57] nfc: nci: free destination parameters when closing a connection Greg Kroah-Hartman
2026-08-25 13:27 ` [PATCH 5.10 39/57] xfs: bounds-check buffer log items dirty bitmap Greg Kroah-Hartman
2026-08-25 13:27 ` [PATCH 5.10 40/57] ipv4: reject undersized MTUs in ip_do_fragment() Greg Kroah-Hartman
2026-08-25 13:27 ` [PATCH 5.10 41/57] ipv6: fix use-after-free in ip6_finish_output2() Greg Kroah-Hartman
2026-08-25 13:27 ` [PATCH 5.10 42/57] nvmet-fc: fix invalid free in LS IOD error path Greg Kroah-Hartman
2026-08-25 13:27 ` [PATCH 5.10 43/57] nvmet-tcp: Do not WARN on remotely-controlled oversized SGL allocations Greg Kroah-Hartman
2026-08-25 13:27 ` [PATCH 5.10 44/57] gpio: ml-ioh: use raw_spinlock_t for the register lock Greg Kroah-Hartman
2026-08-25 13:27 ` [PATCH 5.10 45/57] libceph: fix OOB read in decode_watchers() via missing bounds check Greg Kroah-Hartman
2026-08-25 13:27 ` [PATCH 5.10 46/57] HID: magicmouse: Prevent out-of-bounds (OOB) read during DOUBLE_REPORT_ID Greg Kroah-Hartman
2026-08-25 13:27 ` [PATCH 5.10 47/57] HID: core: fix OOB read of field->usage in hid_set_field() Greg Kroah-Hartman
2026-08-25 13:27 ` [PATCH 5.10 48/57] Revert "Input: ims-pcu - fix race condition in reset_device sysfs callback" Greg Kroah-Hartman
2026-08-25 13:27 ` [PATCH 5.10 49/57] xfrm: fix sk_dst_cache double-free in xfrm_user_policy() Greg Kroah-Hartman
2026-08-25 13:27 ` [PATCH 5.10 50/57] iomap: adjust read range correctly for non-block-aligned positions Greg Kroah-Hartman
2026-08-25 13:27 ` [PATCH 5.10 51/57] s390/vfio_ccw: Free all memory if cp_init() fails Greg Kroah-Hartman
2026-08-25 13:27 ` [PATCH 5.10 52/57] bpf: reject negative CO-RE accessor indices in bpf_core_parse_spec() Greg Kroah-Hartman
2026-08-25 13:27 ` [PATCH 5.10 53/57] can: use skb hash instead of private variable in headroom Greg Kroah-Hartman
2026-08-25 13:27 ` [PATCH 5.10 54/57] can: isotp: fix timer drain order, wakeup handling and tx_gen ordering Greg Kroah-Hartman
2026-08-25 13:27 ` [PATCH 5.10 55/57] HID: core: fix number/pointer type confusion on long items Greg Kroah-Hartman
2026-08-25 13:27 ` Greg Kroah-Hartman [this message]
2026-08-25 13:27 ` [PATCH 5.10 57/57] HID: hyperv: validate initial device info bounds Greg Kroah-Hartman
2026-08-25 17:47 ` [PATCH 5.10 00/57] 5.10.267-rc1 review Florian Fainelli
2026-08-25 19:26 ` Pavel Machek
2026-08-25 21:14 ` Woody Suwalski
2026-08-26 5:03 ` Barry K. Nathan
2026-08-26 8:02 ` Dominique Martinet
2026-08-26 10:32 ` Brett A C Sheffield
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=20260825132543.529407147@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=haoxiang_li2024@163.com \
--cc=jkosina@suse.com \
--cc=patches@lists.linux.dev \
--cc=sashiko-bot@kernel.org \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=stable@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