platform/x86: asus-wmi: Potential buffer overflow in asus_wmi_evaluate_method_buf()
PATCH 1/1 platform/x86: asus-wmi: Potential buffer overflow in asus_wmi_evaluate_method_buf()
This code tests for if the obj->buffer.length is larger than the buffer but then it just does the memcpy() anyway.
--- drivers/platform/x86/asus-wmi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/platform/x86/asus-wmi.c +6 -2
@@ -371,10 +371,14 @@ static int asus_wmi_evaluate_method_buf(u32 method_id,switch (obj->type) {case ACPI_TYPE_BUFFER : -if (obj->buffer.length > size) +if (obj->buffer.length > size) { err = -ENOSPC ; -if (obj->buffer.length ==0 ) +break ; + } +if (obj->buffer.length ==0 ) { err = -ENODATA ; +break ; + }memcpy (ret_buffer, obj->buffer.pointer, obj->buffer.length);break ;
Signature · 1 line
2.20.1
Hi,
Quoted 5 lines · Dan Carpenter
This code tests for if the
obj->buffer.lengthis larger than the buffer but then it just does thememcpy()anyway.Fixes 0f0ac158d28f ("platform/x86: asus-wmi: Add support for custom fan curves")Signed-off-by Dan Carpenter <[email protected]>
Thank you for your patch, I've applied this patch to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.
Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.
Regards,
Hans
Quoted 25 lines
--- drivers/platform/x86/asus-wmi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/platform/x86/asus-wmi.c +6
-2@@ -371,10 +371,14 @@ static int asus_wmi_evaluate_method_buf(u32 method_id,switch (obj->type) {case ACPI_TYPE_BUFFER : -if (obj->buffer.length > size) +if (obj->buffer.length > size) { err = -ENOSPC ; -if (obj->buffer.length ==0 ) +break ; + } +if (obj->buffer.length ==0 ) { err = -ENODATA ; +break ; + }memcpy (ret_buffer, obj->buffer.pointer, obj->buffer.length);break ;