From 830f5800acae17b972d264ab65fe54a7f10c1d82 Mon Sep 17 00:00:00 2001 From: Mark Salter Date: Tue, 4 Oct 2011 09:17:36 -0400 Subject: fix default __strnlen_user macro The existing __strnlen_user macro simply resolved to strnlen. However, the count returned by strnlen_user should include the NULL byte. This patch fixes the __strnlen_user macro to include the NULL byte in the count. Signed-off-by: Mark Salter Acked-by: Arnd Bergmann --- include/asm-generic/uaccess.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'include/asm-generic') diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h index ac68c999b6c..9788568f797 100644 --- a/include/asm-generic/uaccess.h +++ b/include/asm-generic/uaccess.h @@ -289,9 +289,14 @@ strncpy_from_user(char *dst, const char __user *src, long count) * Return 0 on exception, a value greater than N if too long */ #ifndef __strnlen_user -#define __strnlen_user strnlen +#define __strnlen_user(s, n) (strnlen((s), (n)) + 1) #endif +/* + * Unlike strnlen, strnlen_user includes the nul terminator in + * its returned count. Callers should check for a returned value + * greater than N as an indication the string is too long. + */ static inline long strnlen_user(const char __user *src, long n) { if (!access_ok(VERIFY_READ, src, 1)) -- cgit v1.2.3 From b7a0556e0f2d6946a57f993c6d1043cf065ccfa8 Mon Sep 17 00:00:00 2001 From: Mark Salter Date: Tue, 4 Oct 2011 09:24:15 -0400 Subject: fixed generic page.h for non-zero PAGE_OFFSET asm-generic/page.h had several problems when used with a non-zero PAGE_OFFSET. This patch adds a default ARCH_PFN_OFFSET and fixes the __va, __pa, and pfn_valid macros to work with non-zero PAGE_OFFSETs. Signed-off-by: Mark Salter Acked-by: Arnd Bergmann --- include/asm-generic/page.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'include/asm-generic') diff --git a/include/asm-generic/page.h b/include/asm-generic/page.h index 75fec18cdc5..f376db24c4a 100644 --- a/include/asm-generic/page.h +++ b/include/asm-generic/page.h @@ -71,10 +71,14 @@ extern unsigned long memory_end; #define PAGE_OFFSET (0) #endif +#ifndef ARCH_PFN_OFFSET +#define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT) +#endif + #ifndef __ASSEMBLY__ -#define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET)) -#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET) +#define __va(x) ((void *)((unsigned long) (x))) +#define __pa(x) ((unsigned long) (x)) #define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) #define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT) @@ -86,7 +90,7 @@ extern unsigned long memory_end; #define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT) #endif -#define pfn_valid(pfn) ((pfn) < max_mapnr) +#define pfn_valid(pfn) ((pfn) >= ARCH_PFN_OFFSET && ((pfn) - ARCH_PFN_OFFSET) < max_mapnr) #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \ ((void *)(kaddr) < (void *)memory_end)) -- cgit v1.2.3 From e66d3c490c7a45daa49c1ae9cc5fe0687d14b823 Mon Sep 17 00:00:00 2001 From: Mark Salter Date: Tue, 4 Oct 2011 09:25:56 -0400 Subject: add missing __iomem to generic iounmap declaration Signed-off-by: Mark Salter Acked-by: Arnd Bergmann --- include/asm-generic/io.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/asm-generic') diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index 912088773a6..c2cf2eda062 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -327,7 +327,7 @@ static inline void __iomem *ioremap(phys_addr_t offset, unsigned long size) #define ioremap_wc ioremap_nocache #endif -static inline void iounmap(void *addr) +static inline void iounmap(void __iomem *addr) { } #endif /* CONFIG_MMU */ -- cgit v1.2.3