[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <200904291258.40667.arnd@arndb.de>
Date: Wed, 29 Apr 2009 12:58:40 +0200
From: Arnd Bergmann <arnd@...db.de>
To: monstr@...str.eu
Cc: Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org, john.williams@...alogix.com
Subject: Re: [PATCH 20/30] microblaze_mmu_v1: uaccess MMU update
On Wednesday 29 April 2009, Michal Simek wrote:
> Here is that change which remove address space problem.
>
> #define __clear_user(addr, n) (memset((__force void *)(addr), 0, (n)), 0)
>
> Am I right?
>
> The same mishmash is for memset_fromio/memset_toio and maybe some others which I want to fix too.
This will work, but a better fix would be to define an inline
function that explicitly takes a __user pointer. This would give
you warnings when code accidentally calls __clear_user on a
kernel pointer (this also adds the might_sleep()):
static inline unsigned long __must_check
__clear_user(void __user *to, unsigned long n)
{
memset((__force void *)addr, 0, n);
return 0;
}
static inline unsigned long __must_check
clear_user(void __user *to, unsigned long n)
{
might_sleep();
if (unlikely(!access_ok(VERIFY_WRITE, to, n)))
return n;
return __clear_user(to, n);
}
The above is just the nommu variant. For mmu, you need to
have exception handling in __clear_user to take care of the
case where the address is part of the user mapping (access_ok)
but not currently mapped.
Arnd <><
--
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