public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Darren Hart <dvhart@infradead.org>
To: "Pali Rohár" <pali.rohar@gmail.com>
Cc: Matthew Garrett <mjg59@srcf.ucam.org>,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org,
	rjw@rjwysocki.net
Subject: Re: [PATCH] dell-wmi: Fix access out of memory
Date: Mon, 29 Sep 2014 14:30:29 -0700	[thread overview]
Message-ID: <20140929213028.GB34181@vmdeb7> (raw)
In-Reply-To: <1411996251-13455-1-git-send-email-pali.rohar@gmail.com>

On Mon, Sep 29, 2014 at 03:10:51PM +0200, Pali Rohár wrote:
> 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 <pali.rohar@gmail.com>

Looks good to me. Rafael, any concerns?

Cc: linux-acpi

> ---
> 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(-)
> 
> diff --git a/drivers/platform/x86/dell-wmi.c b/drivers/platform/x86/dell-wmi.c
> index 390e8e3..25721bf 100644
> --- a/drivers/platform/x86/dell-wmi.c
> +++ b/drivers/platform/x86/dell-wmi.c
> @@ -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);
> -- 
> 1.7.9.5
> 
> 

-- 
Darren Hart
Intel Open Source Technology Center

       reply	other threads:[~2014-09-29 21:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1411996251-13455-1-git-send-email-pali.rohar@gmail.com>
2014-09-29 21:30 ` Darren Hart [this message]
2014-09-29 23:26   ` [PATCH] dell-wmi: Fix access out of memory Rafael J. Wysocki
2014-09-29 23:16     ` Darren Hart
2014-10-12 16:45       ` Pali Rohár
2014-10-12 22:32         ` Darren Hart

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=20140929213028.GB34181@vmdeb7 \
    --to=dvhart@infradead.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=pali.rohar@gmail.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    /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