Skip to content

platform/x86: dell-smbios: Fix call filtering, lifetime and error handling

Rosen Penev platform-driver-x86 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest16 patches 0 repliesNew
  2. v116 patches 0 repliesSuperseded

Changes in v2 from the cover letter

- Patch 3: don't leak token_entries when kasprintf() or sysfs_create_group() fails; fall through to its kfree() and return
ret from a single exit
- v1: https://lore.kernel.org/platform-driver-x86/[email protected]/

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/16platform/x86: dell-smbios: Only allow unprivileged reads of whitelisted tokensdrivers/platform/x86/dell/dell-smbios-base.c+4 -00 replies
2/16platform/x86: dell-smbios: Filter every token at the requested locationdrivers/platform/x86/dell/dell-smbios-base.c+82 -510 replies
3/16platform/x86: dell-smbios: Return the real error from build_tokens_sysfs()drivers/platform/x86/dell/dell-smbios-base.c+7 -30 replies
4/16platform/x86: dell-smbios: Skip 0xDA structures without tokensdrivers/platform/x86/dell/dell-smbios-base.c+3 -00 replies
5/16platform/x86: dell-smbios: Use dev_driver_string() in debug messagesdrivers/platform/x86/dell/dell-smbios-base.c+2 -20 replies
6/16platform/x86: dell-smbios-smm: Use the first 0xDA structure with an SMI portdrivers/platform/x86/dell/dell-smbios-smm.c+12 -00 replies
7/16platform/x86: dell-smbios-smm: Propagate SMI request errorsdrivers/platform/x86/dell/dell-smbios-smm.c+5 -30 replies
8/16platform/x86: dell-smbios-smm: Clear platform_device when it is releaseddrivers/platform/x86/dell/dell-smbios-smm.c+2 -00 replies
9/16platform/x86: dell-smbios-wmi: Don't unregister a driver that failed to registerdrivers/platform/x86/dell/dell-smbios-wmi.c+7 -10 replies
10/16platform/x86: dell-smbios-wmi: Reject buffer sizes too small for a calldrivers/platform/x86/dell/dell-smbios-wmi.c+5 -00 replies
11/16platform/x86: dell-smbios: Don't tie dispatcher entries to the device driverdrivers/platform/x86/dell/dell-smbios-base.c+2 -10 replies
12/16platform/x86: dell-smbios-smm: Set the WSMT test call after clearing the bufferdrivers/platform/x86/dell/dell-smbios-smm.c+1 -10 replies
13/16platform/x86: dell-smbios-wmi: Don't let unprivileged users flood the logdrivers/platform/x86/dell/dell-smbios-wmi.c+5 -50 replies
14/16platform/x86: dell-smbios: Suppress bind attributes of the platform driverdrivers/platform/x86/dell/dell-smbios-base.c+1 -00 replies
15/16platform/x86: dell-smbios: Restrict token sysfs files with their modedrivers/platform/x86/dell/dell-smbios-base.c+2 -80 replies
16/16platform/x86: dell-smbios: Drop smbios_mutex from module exitdrivers/platform/x86/dell/dell-smbios-base.c+0 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 00/16] platform/x86: dell-smbios: Fix call filtering, lifetime and error handling

Fixes for the dell-smbios dispatcher and its SMM and WMI backends.

Patch 1 is security relevant: /dev/wmi/dell-smbios is mode 0444, and the WSMT tokens are whitelisted without a capability for both reads and writes, so any local user can write to the WSMT token location and change the BIOS setting. Patch 2 closes the related gap where tokens sharing a location were filtered by whichever came first. Both were found by code review; I have no WSMT-capable machine to reproduce them on.

Patches 3-11 fix a use-after-free when the dell-smbios.1 device is unbound, an empty token sysfs group, use of an unpopulated SMI port, unchecked SMI and registration errors, and a WMI buffer size underflow.

Patches 1-11 carry Fixes: tags and come first so they can be applied on their own. Patches 12-16 are hardening and cleanups for the next merge window: they stop unprivileged users from flooding the log, restrict the token sysfs files by mode, and tidy up the rest.

These patches were developed with the help of an AI coding assistant (Claude Opus 5.5): it reviewed the drivers, found the issues and drafted the fixes and changelogs. I reviewed every change and I am responsible for them.

All patches build cleanly with W=1.

Tested on a Dell Precision M4800 running v7.2.15, using the equivalent backports built as out-of-tree modules:
- token sysfs files are 0400; unprivileged reads fail, root reads work
- unprivileged non-whitelisted token reads through /dev/wmi/dell-smbios are rejected, and 503 rejected calls logged 10 lines; root calls work
- dell-laptop, dell-pc and dell-wmi work on top, and three unload/reload cycles of the whole stack are clean
The WSMT write fix (patch 1) could not be exercised: this machine has no WSMT tokens. Its seven 0xDA structures all report SMI port 0xb2.

Changes in v2:
- Patch 3: don't leak token_entries when kasprintf() or sysfs_create_group() fails; fall through to its kfree() and return
ret from a single exit
- v1: https://lore.kernel.org/platform-driver-x86/[email protected]/

Rosen Penev (16):
platform/x86: dell-smbios: Only allow unprivileged reads of
whitelisted tokens
platform/x86: dell-smbios: Filter every token at the requested
location
platform/x86: dell-smbios: Return the real error from
build_tokens_sysfs()
platform/x86: dell-smbios: Skip 0xDA structures without tokens platform/x86: dell-smbios: Use dev_driver_string() in debug messages platform/x86: dell-smbios-smm: Use the first 0xDA structure with an
SMI port
platform/x86: dell-smbios-smm: Propagate SMI request errors platform/x86: dell-smbios-smm: Clear platform_device when it is
released
platform/x86: dell-smbios-wmi: Don't unregister a driver that failed
to register
platform/x86: dell-smbios-wmi: Reject buffer sizes too small for a
call
platform/x86: dell-smbios: Don't tie dispatcher entries to the device
driver
platform/x86: dell-smbios-smm: Set the WSMT test call after clearing
the buffer
platform/x86: dell-smbios-wmi: Don't let unprivileged users flood the
log
platform/x86: dell-smbios: Suppress bind attributes of the platform
driver
platform/x86: dell-smbios: Restrict token sysfs files with their mode platform/x86: dell-smbios: Drop smbios_mutex from module exit

 drivers/platform/x86/dell/dell-smbios-base.c | 162 +++++++++++--------
 drivers/platform/x86/dell/dell-smbios-smm.c  |  24 ++-
 drivers/platform/x86/dell/dell-smbios-wmi.c  |  23 ++-
 3 files changed, 136 insertions(+), 73 deletions(-)

base-commit: 2800868f63227c8237d70c41e70d441c919620d6

Signature · 1 line
2.56.1