From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Jiri Slaby <jslaby@suse.cz>
Cc: jirislaby@gmail.com, akpm@linux-foundation.org,
linux-kernel@vger.kernel.org, Vasiliy Kulikov <segooon@gmail.com>,
Thomas Renninger <trenn@suse.de>, Len Brown <lenb@kernel.org>,
ACPI Devel Maling List <linux-acpi@vger.kernel.org>
Subject: Re: [PATCH -resend 5/6] acpi: ec_sys: access user space with get_user()/put_user()
Date: Thu, 23 May 2013 01:39 +0200 [thread overview]
Message-ID: <28555689.kcgDUFsbsB@vostro.rjw.lan> (raw)
In-Reply-To: <1369227552-11743-5-git-send-email-jslaby@suse.cz>
On Wednesday, May 22, 2013 02:59:11 PM Jiri Slaby wrote:
> From: Vasiliy Kulikov <segooon@gmail.com>
>
> User space pointer may not be dereferenced. Use get_user()/put_user()
> instead and check their return codes.
>
> Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
> Signed-off-by: Thomas Renninger <trenn@suse.de>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Cc: Len Brown <lenb@kernel.org>
> Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
> Cc: linux-acpi@vger.kernel.org
Interesting. It looks like it actually didn't reach linux-acpi.
Anyway, I'm going to queue it up for v3.11.
Thanks,
Rafael
> ---
> drivers/acpi/ec_sys.c | 18 ++++++++++++++----
> 1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
> index 7586544..4e7b798 100644
> --- a/drivers/acpi/ec_sys.c
> +++ b/drivers/acpi/ec_sys.c
> @@ -12,6 +12,7 @@
> #include <linux/acpi.h>
> #include <linux/debugfs.h>
> #include <linux/module.h>
> +#include <linux/uaccess.h>
> #include "internal.h"
>
> MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
> @@ -34,7 +35,6 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
> * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
> */
> unsigned int size = EC_SPACE_SIZE;
> - u8 *data = (u8 *) buf;
> loff_t init_off = *off;
> int err = 0;
>
> @@ -47,9 +47,15 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
> size = count;
>
> while (size) {
> - err = ec_read(*off, &data[*off - init_off]);
> + u8 byte_read;
> + err = ec_read(*off, &byte_read);
> if (err)
> return err;
> + if (put_user(byte_read, buf + *off - init_off)) {
> + if (*off - init_off)
> + return *off - init_off; /* partial read */
> + return -EFAULT;
> + }
> *off += 1;
> size--;
> }
> @@ -65,7 +71,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
>
> unsigned int size = count;
> loff_t init_off = *off;
> - u8 *data = (u8 *) buf;
> int err = 0;
>
> if (*off >= EC_SPACE_SIZE)
> @@ -76,7 +81,12 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
> }
>
> while (size) {
> - u8 byte_write = data[*off - init_off];
> + u8 byte_write;
> + if (get_user(byte_write, buf + *off - init_off)) {
> + if (*off - init_off)
> + return *off - init_off; /* partial write */
> + return -EFAULT;
> + }
> err = ec_write(*off, byte_write);
> if (err)
> return err;
>
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
next prev parent reply other threads:[~2013-05-22 23:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-22 12:59 [PATCH -resend 1/6] mISDN: Add support for group membership check Jiri Slaby
2013-05-22 12:59 ` [PATCH -resend 2/6] ehea: add alias entry for portN properties Jiri Slaby
2013-05-22 12:59 ` [PATCH -resend 3/6] drm/cirrus: Correct register values for 16bpp Jiri Slaby
2013-05-22 12:59 ` [PATCH -resend 4/6] netfilter: Implement RFC 1123 for FTP conntrack Jiri Slaby
2013-05-27 12:20 ` Pablo Neira Ayuso
2013-05-22 12:59 ` [PATCH -resend 5/6] acpi: ec_sys: access user space with get_user()/put_user() Jiri Slaby
2013-05-22 23:39 ` Rafael J. Wysocki [this message]
2013-05-22 12:59 ` [PATCH -resend 6/6] nouveau: Make vga_switcheroo code depend on VGA_SWITCHEROO Jiri Slaby
2013-05-22 19:04 ` [PATCH -resend 1/6] mISDN: Add support for group membership check Sergei Shtylyov
2013-05-22 19:42 ` [PATCH v2 " Jiri Slaby
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=28555689.kcgDUFsbsB@vostro.rjw.lan \
--to=rjw@sisk.pl \
--cc=akpm@linux-foundation.org \
--cc=jirislaby@gmail.com \
--cc=jslaby@suse.cz \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=segooon@gmail.com \
--cc=trenn@suse.de \
/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
all inboxes | Powered by JetHome®