[PATCH 0/6] platform/wmi: Use WMI driver core for size checks

Armin Wolf posted 6 patches 2 months, 2 weeks ago
.../wmi/driver-development-guide.rst          | 11 ++-
drivers/platform/wmi/core.c                   | 89 ++++++++++++++-----
drivers/platform/wmi/internal.h               |  3 +-
drivers/platform/wmi/marshalling.c            |  6 +-
.../platform/wmi/tests/marshalling_kunit.c    | 24 ++++-
drivers/platform/x86/bitland-mifs-wmi.c       | 24 ++---
drivers/platform/x86/dell/dell-wmi-base.c     |  1 +
.../platform/x86/intel/wmi/sbl-fw-update.c    |  7 +-
drivers/platform/x86/intel/wmi/thunderbolt.c  |  2 +-
drivers/platform/x86/lenovo/ideapad-laptop.c  |  1 +
drivers/platform/x86/lenovo/wmi-camera.c      |  1 +
drivers/platform/x86/lenovo/wmi-events.c      |  1 +
drivers/platform/x86/lenovo/ymc.c             |  1 +
drivers/platform/x86/lenovo/yogabook.c        |  2 +-
drivers/platform/x86/redmi-wmi.c              |  1 +
drivers/platform/x86/uniwill/uniwill-wmi.c    |  1 +
drivers/platform/x86/wmi-bmof.c               |  2 +-
drivers/platform/x86/xiaomi-wmi.c             |  1 +
include/linux/wmi.h                           | 15 +++-
19 files changed, 135 insertions(+), 58 deletions(-)
[PATCH 0/6] platform/wmi: Use WMI driver core for size checks
Posted by Armin Wolf 2 months, 2 weeks ago
As suggested by Ilpo, the buffer-based WMI API should assist drivers
in verifying the size of buffers received from WMI methods or blocks.
This patch series implements this suggestion by allowing drivers to
use the WMI driver core to automatically reject undersized buffers.

This avoids a memory allocation for undersized data and simplifies
the size checking code in most WMI drivers. All patches except the
last one have been tested using synthetic ACPI tables and appear to
work just fine.

Armin Wolf (6):
  platform/wmi: Add wmidev_invoke_procedure()
  platform/wmi: Convert drivers to use wmidev_invoke_procedure()
  platform/wmi: Prepare to reject undersized unmarshalling results
  platform/wmi: Extend wmidev_invoke_method() to reject undersized data
  platform/wmi: Extend wmidev_query_block() to reject undersized data
  platform/wmi: Replace .no_notify_data with .min_event_size

 .../wmi/driver-development-guide.rst          | 11 ++-
 drivers/platform/wmi/core.c                   | 89 ++++++++++++++-----
 drivers/platform/wmi/internal.h               |  3 +-
 drivers/platform/wmi/marshalling.c            |  6 +-
 .../platform/wmi/tests/marshalling_kunit.c    | 24 ++++-
 drivers/platform/x86/bitland-mifs-wmi.c       | 24 ++---
 drivers/platform/x86/dell/dell-wmi-base.c     |  1 +
 .../platform/x86/intel/wmi/sbl-fw-update.c    |  7 +-
 drivers/platform/x86/intel/wmi/thunderbolt.c  |  2 +-
 drivers/platform/x86/lenovo/ideapad-laptop.c  |  1 +
 drivers/platform/x86/lenovo/wmi-camera.c      |  1 +
 drivers/platform/x86/lenovo/wmi-events.c      |  1 +
 drivers/platform/x86/lenovo/ymc.c             |  1 +
 drivers/platform/x86/lenovo/yogabook.c        |  2 +-
 drivers/platform/x86/redmi-wmi.c              |  1 +
 drivers/platform/x86/uniwill/uniwill-wmi.c    |  1 +
 drivers/platform/x86/wmi-bmof.c               |  2 +-
 drivers/platform/x86/xiaomi-wmi.c             |  1 +
 include/linux/wmi.h                           | 15 +++-
 19 files changed, 135 insertions(+), 58 deletions(-)

-- 
2.39.5
Re: [PATCH 0/6] platform/wmi: Use WMI driver core for size checks
Posted by Ilpo Järvinen 2 months, 1 week ago
On Mon, 06 Apr 2026 22:32:31 +0200, Armin Wolf wrote:

> As suggested by Ilpo, the buffer-based WMI API should assist drivers
> in verifying the size of buffers received from WMI methods or blocks.
> This patch series implements this suggestion by allowing drivers to
> use the WMI driver core to automatically reject undersized buffers.
> 
> This avoids a memory allocation for undersized data and simplifies
> the size checking code in most WMI drivers. All patches except the
> last one have been tested using synthetic ACPI tables and appear to
> work just fine.
> 
> [...]


Thank you for your contribution, it has been applied to my local
review-ilpo-next branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-next branch only once I've pushed my
local branch there, which might take a while.

The list of commits applied:
[1/6] platform/wmi: Add wmidev_invoke_procedure()
      commit: a6354b385fd18fcd7414052f8f6d13fd27521720
[2/6] platform/wmi: Convert drivers to use wmidev_invoke_procedure()
      commit: dd2dd86f44800911e71127d3f418ee3685197c41
[3/6] platform/wmi: Prepare to reject undersized unmarshalling results
      commit: 668aa6086f04d1bd63f27753d6c2d318c44ae306
[4/6] platform/wmi: Extend wmidev_invoke_method() to reject undersized data
      commit: c6f69ffec0aec2ac783f900b5c17ebff13c58f82
[5/6] platform/wmi: Extend wmidev_query_block() to reject undersized data
      commit: ceed8c1bcffab475facb6d4ee071464d01dd1865
[6/6] platform/wmi: Replace .no_notify_data with .min_event_size
      commit: a99543f1d8f92e11ff3cb2760964490b04864e33

--
 i.
Re: [PATCH 0/6] platform/wmi: Use WMI driver core for size checks
Posted by Armin Wolf 2 months, 1 week ago
Am 10.04.26 um 18:28 schrieb Ilpo Järvinen:
> On Mon, 06 Apr 2026 22:32:31 +0200, Armin Wolf wrote:
> 
>> As suggested by Ilpo, the buffer-based WMI API should assist drivers
>> in verifying the size of buffers received from WMI methods or blocks.
>> This patch series implements this suggestion by allowing drivers to
>> use the WMI driver core to automatically reject undersized buffers.
>>
>> This avoids a memory allocation for undersized data and simplifies
>> the size checking code in most WMI drivers. All patches except the
>> last one have been tested using synthetic ACPI tables and appear to
>> work just fine.
>>
>> [...]
> 
> 
> Thank you for your contribution, it has been applied to my local
> review-ilpo-next branch. Note it will show up in the public
> platform-drivers-x86/review-ilpo-next branch only once I've pushed my
> local branch there, which might take a while.

Thank you :)

> 
> The list of commits applied:
> [1/6] platform/wmi: Add wmidev_invoke_procedure()
>        commit: a6354b385fd18fcd7414052f8f6d13fd27521720
> [2/6] platform/wmi: Convert drivers to use wmidev_invoke_procedure()
>        commit: dd2dd86f44800911e71127d3f418ee3685197c41
> [3/6] platform/wmi: Prepare to reject undersized unmarshalling results
>        commit: 668aa6086f04d1bd63f27753d6c2d318c44ae306
> [4/6] platform/wmi: Extend wmidev_invoke_method() to reject undersized data
>        commit: c6f69ffec0aec2ac783f900b5c17ebff13c58f82
> [5/6] platform/wmi: Extend wmidev_query_block() to reject undersized data
>        commit: ceed8c1bcffab475facb6d4ee071464d01dd1865
> [6/6] platform/wmi: Replace .no_notify_data with .min_event_size
>        commit: a99543f1d8f92e11ff3cb2760964490b04864e33
> 
> --
>   i.
> 
>