Re: [patch 4/4] x86: PAT followup - use ioremap for devmem read of reserved regions

Ingo Molnar
2008-01-16T07:34:29Z

* venkatesh.pallipadi@intel.com <venkatesh.pallipadi@intel.com> wrote:

> --- linux-2.6.git.orig/drivers/char/mem.c 2008-01-15 10:05:13.000000000 -0800
> +++ linux-2.6.git/drivers/char/mem.c 2008-01-15 10:05:51.000000000 -0800
> @@ -127,9 +127,14 @@
> * by the kernel or data corruption may occur
> */
> ptr = xlate_dev_mem_ptr(p);
> + if (!ptr)
> + return -EFAULT;
>
> if (copy_to_user(buf, ptr, sz))
> return -EFAULT;
> +
> + unxlate_dev_mem_ptr(p, ptr);

sidenote: drivers/char/mem.c has no locking here, are you sure it's safe
to create a possibly large number of aliases here? At least on 32-bit it
could deplete the vmalloc area. (where all ioremaps go)

since /dev/mem access is strongly discouraged anyway (except perhaps for
debugging purposes), wouldnt it be safer to stick a mutex around these
areas?

Ingo