[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20090916115015.0aeddc01.kamezawa.hiroyu@jp.fujitsu.com>
Date: Wed, 16 Sep 2009 11:50:15 +0900
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
To: Wu Fengguang <fengguang.wu@...el.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Greg Kroah-Hartman <gregkh@...e.de>,
Hugh Dickins <hugh.dickins@...cali.co.uk>,
Christoph Lameter <cl@...ux-foundation.org>,
Ingo Molnar <mingo@...e.hu>, Tejun Heo <tj@...nel.org>,
Nick Piggin <npiggin@...e.de>,
LKML <linux-kernel@...r.kernel.org>, linux-mm@...ck.org
Subject: Re: [PATCH 2/3] devmem: check vmalloc address on kmem read/write
On Wed, 16 Sep 2009 09:39:41 +0800
Wu Fengguang <fengguang.wu@...el.com> wrote:
> From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
>
> Otherwise vmalloc_to_page() will BUG().
>
> This also makes the kmem read/write implementation aligned with mem(4):
> "References to nonexistent locations cause errors to be returned." Here
> we return -ENXIO (inspired by Hugh) if no bytes have been transfered
> to/from user space, otherwise return partial read/write results.
>
seems reasonable.
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
> CC: Greg Kroah-Hartman <gregkh@...e.de>
> CC: Hugh Dickins <hugh.dickins@...cali.co.uk>
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
> Signed-off-by: Wu Fengguang <fengguang.wu@...el.com>
> ---
> drivers/char/mem.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> --- linux-mm.orig/drivers/char/mem.c 2009-09-16 08:52:17.000000000 +0800
> +++ linux-mm/drivers/char/mem.c 2009-09-16 09:15:03.000000000 +0800
> @@ -443,6 +443,10 @@ static ssize_t read_kmem(struct file *fi
> return -ENOMEM;
> while (count > 0) {
> sz = size_inside_page(p, count);
> + if (!is_vmalloc_or_module_addr((void *)p)) {
> + err = -ENXIO;
> + break;
> + }
> err = vread(kbuf, (char *)p, sz);
> if (err)
> break;
> @@ -543,6 +547,10 @@ static ssize_t write_kmem(struct file *
> unsigned long sz = size_inside_page(p, count);
> unsigned long n;
>
> + if (!is_vmalloc_or_module_addr((void *)p)) {
> + err = -ENXIO;
> + break;
> + }
> n = copy_from_user(kbuf, buf, sz);
> if (n) {
> err = -EFAULT;
>
> --
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists