dell-wmi: Fix access out of memory
Subsystems (2)
PATCH 1/1 dell-wmi: Fix access out of memory
Without this patch driver dell-wmi is trying to access elements of dynamically allocated array without checking array size. This can lead to memory corruption or kernel panic. This patch adds missing checks for array size.
---
This patch should be probably applied to stable kernel trees as it fixing possible memory corruption.
--- drivers/platform/x86/dell-wmi.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/platform/x86/dell-wmi.c +9 -3
@@ -163,18 +163,24 @@ static void dell_wmi_notify(u32 value, void *context)const struct key_entry *key;int reported_key;u16 *buffer_entry = (u16 *)obj->buffer.pointer; +int buffer_size = obj->buffer.length/2 ; -if (dell_new_hk_type && (buffer_entry[1 ] !=0x10 )) { +if (buffer_size >=2 && dell_new_hk_type && buffer_entry[1 ] !=0x10 ) {pr_info ("Received unknown WMI event (0x%x)\n" , buffer_entry[1 ]);kfree (obj);return ; } -if (dell_new_hk_type || buffer_entry[1 ] ==0x0 ) +if (buffer_size >=3 && (dell_new_hk_type || buffer_entry[1 ] ==0x0 )) reported_key = (int )buffer_entry[2 ]; -else +else if (buffer_size >=2 ) reported_key = (int )buffer_entry[1 ] &0xffff ; +else { +pr_info ("Received unknown WMI event\n" ); +kfree (obj); +return ; + } key =sparse_keymap_entry_from_scancode (dell_wmi_input_dev, reported_key);
Signature · 1 line
1.7.9.5
Quoted 5 lines · Pali Rohár
Without this patch driver dell-wmi is trying to access elements of dynamically allocated array without checking array size. This can lead to memory corruption or kernel panic. This patch adds missing checks for array size.
Signed-off-by Pali Rohár <[email protected]>
Looks good to me. Rafael, any concerns?
Quoted 43 lines
---
This patch should be probably applied to stable kernel trees as it fixing possible memory corruption.--- drivers/platform/x86/dell-wmi.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)drivers/platform/x86/dell-wmi.c +9
-3@@ -163,18 +163,24 @@ static void dell_wmi_notify(u32 value, void *context)const struct key_entry *key;int reported_key;u16 *buffer_entry = (u16 *)obj->buffer.pointer; +int buffer_size = obj->buffer.length/2 ; -if (dell_new_hk_type && (buffer_entry[1 ] !=0x10 )) { +if (buffer_size >=2 && dell_new_hk_type && buffer_entry[1 ] !=0x10 ) {pr_info ("Received unknown WMI event (0x%x)\n" , buffer_entry[1 ]);kfree (obj);return ; } -if (dell_new_hk_type || buffer_entry[1 ] ==0x0 ) +if (buffer_size >=3 && (dell_new_hk_type || buffer_entry[1 ] ==0x0 )) reported_key = (int )buffer_entry[2 ]; -else +else if (buffer_size >=2 ) reported_key = (int )buffer_entry[1 ] &0xffff ; +else { +pr_info ("Received unknown WMI event\n" ); +kfree (obj); +return ; + } key =sparse_keymap_entry_from_scancode (dell_wmi_input_dev, reported_key);Signature · 1 line
1.7.9.5
Signature · 2 lines
Darren Hart Intel Open Source Technology Center
Quoted 8 lines · Darren Hart
Quoted 5 lines · Pali Rohár
Without this patch driver dell-wmi is trying to access elements of dynamically allocated array without checking array size. This can lead to memory corruption or kernel panic. This patch adds missing checks for array size.
Signed-off-by Pali Rohár <[email protected]>Looks good to me. Rafael, any concerns?
Not anything obvious.
Quoted 2 lines
Cc linux-acpi
Thanks!
Quoted 41 lines
Quoted 39 lines
---
This patch should be probably applied to stable kernel trees as it fixing possible memory corruption.--- drivers/platform/x86/dell-wmi.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)drivers/platform/x86/dell-wmi.c +9
-3@@ -163,18 +163,24 @@ static void dell_wmi_notify(u32 value, void *context)const struct key_entry *key;int reported_key;u16 *buffer_entry = (u16 *)obj->buffer.pointer; +int buffer_size = obj->buffer.length/2 ; -if (dell_new_hk_type && (buffer_entry[1 ] !=0x10 )) { +if (buffer_size >=2 && dell_new_hk_type && buffer_entry[1 ] !=0x10 ) {pr_info ("Received unknown WMI event (0x%x)\n" , buffer_entry[1 ]);kfree (obj);return ; } -if (dell_new_hk_type || buffer_entry[1 ] ==0x0 ) +if (buffer_size >=3 && (dell_new_hk_type || buffer_entry[1 ] ==0x0 )) reported_key = (int )buffer_entry[2 ]; -else +else if (buffer_size >=2 ) reported_key = (int )buffer_entry[1 ] &0xffff ; +else { +pr_info ("Received unknown WMI event\n" ); +kfree (obj); +return ; + } key =sparse_keymap_entry_from_scancode (dell_wmi_input_dev, reported_key);
Signature · 6 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Darren Hart
AppliedQuoted 5 lines · Rafael J. Wysocki
Quoted 2 lines · Darren Hart
Quoted 1 line · Pali Rohár
Without this patch driver dell-wmi is trying to access elements of
dynamically
Quoted 1 line
Quoted 1 line
allocated array without checking array size. This can lead to
Quoted 8 lines
memory corruption
Quoted 5 lines
Quoted 3 lines
or kernel panic. This patch adds missing checks for array size.
Signed-off-by Pali Rohár <[email protected]>Looks good to me. Rafael, any concerns?
Not anything obvious.
Queued, thanks.
Quoted 53 lines
Quoted 3 lines
Cc linux-acpiThanks!
Quoted 2 lines
Quoted 2 lines
---
This patch should be probably applied to stable kernel trees as itfixing
Quoted 6 lines
Review
Quoted 6 lines
possible memory corruption.
--- drivers/platform/x86/dell-wmi.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)(quoted diff) +0
-0
b/drivers/platform/x86/dell-wmi.cQuoted 4 lines
drivers/platform/x86/dell-wmi.c static void dell_wmi_notify(u32 value, void
Quoted 4 lines
index 390e8e3..25721bf 100644
drivers/platform/x86/dell-wmi.c +0
-0@@ -163,18 +163,24 @@ static void dell_wmi_notify(u32 value, void*context)
Quoted 7 lines
drivers/platform/x86/dell-wmi.c static void dell_wmi_notify(u32 value, void *context)
Quoted 7 lines
drivers/platform/x86/dell-wmi.c +2
-1const struct key_entry *key;int reported_key;u16 *buffer_entry = (u16 *)obj->buffer.pointer; +int buffer_size = obj->buffer.length/2 ; -if (dell_new_hk_type && (buffer_entry[1 ] !=0x10 )) { + if (buffer_size >= 2 && dell_new_hk_type && buffer_entry[1] !=
0x10) {Quoted 8 lines
drivers/platform/x86/dell-wmi.c static void dell_wmi_notify(u32 value, void *context)
Quoted 8 lines
drivers/platform/x86/dell-wmi.c +1
-1pr_info ("Received unknown WMI event (0x%x)\n" , buffer_entry[1 ]);kfree (obj);return ; } -if (dell_new_hk_type || buffer_entry[1 ] ==0x0 ) + if (buffer_size >= 3 && (dell_new_hk_type || buffer_entry[1] ==
0x0))Quoted 14 lines
Quoted 12 lines
drivers/platform/x86/dell-wmi.c +6
-1reported_key = (int )buffer_entry[2 ]; - else + else if (buffer_size >= 2) reported_key = (int )buffer_entry[1 ] &0xffff ; + else { +pr_info ("Received unknown WMI event\n" ); +kfree (obj); +return ; + } key =sparse_keymap_entry_from_scancode (dell_wmi_input_dev, reported_key);
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Quoted 1 line · On Tuesday 30 September 2014 01:16:23 Darren Hart wrote:
On September 29, 2014 4:26:03 PM PDT, "Rafael J. Wysocki"
Quoted 15 lines · <[email protected]> wrote:
Quoted 15 lines · Darren Hart
Quoted 3 lines · Pali Rohár
Quoted 2 lines
Without this patch driver dell-wmi is trying to access elements of
dynamically
Quoted 2 lines
Quoted 2 lines
allocated array without checking array size. This can lead to
memory corruption
Quoted 3 lines
Quoted 3 lines
or kernel panic. This patch adds missing checks for array size.
Quoted 12 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Pali Rohár <[email protected]>Looks good to me. Rafael, any concerns?
Not anything obvious.
Queued, thanks.
Quoted 4 lines
Quoted 1 line
Cc linux-acpiThanks!
Now I see that this patch is in linus tree. Can you sent it to stable trees too?
Signature · 2 lines
Pali Rohár [email protected]
Quoted 26 lines · Pali Rohár
Quoted 1 line · On Tuesday 30 September 2014 01:16:23 Darren Hart wrote:
On September 29, 2014 4:26:03 PM PDT, "Rafael J. Wysocki"
Quoted 23 lines · <[email protected]> wrote:
Quoted 12 lines · Darren Hart
Quoted 3 lines · Pali Rohár
Quoted 2 lines
Without this patch driver dell-wmi is trying to access elements of
dynamically
Quoted 2 lines
Quoted 2 lines
allocated array without checking array size. This can lead to
memory corruption
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
or kernel panic. This patch adds missing checks for array size.
Signed-off-by Pali Rohár <[email protected]>Looks good to me. Rafael, any concerns?
Not anything obvious.
Queued, thanks.
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Cc linux-acpiThanks!
Now I see that this patch is in linus tree. Can you sent it to stable trees too?
Hi Pali,
Please see Documentation/stable_kernel_rules.txt for details on how to mark patches for stable when you submit them. Now that it is in mainline, the process is a bit more manual, you'll find instructions for how to go about that in the same document.
Thanks,
Signature · 2 lines
Darren Hart Intel Open Source Technology Center