Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 14 May 2010 14:55:42 +0000 (07:55 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 14 May 2010 14:55:42 +0000 (07:55 -0700)
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6:
  mmap_min_addr check CAP_SYS_RAWIO only for write

arch/microblaze/include/asm/uaccess.h
arch/microblaze/kernel/cpu/cache.c
arch/microblaze/kernel/entry-nommu.S
arch/microblaze/kernel/microblaze_ksyms.c
arch/microblaze/kernel/module.c
arch/microblaze/mm/init.c
arch/microblaze/mm/pgtable.c
arch/microblaze/pci/pci-common.c

index 446bec2..26460d1 100644 (file)
@@ -182,6 +182,39 @@ extern long __user_bad(void);
  * Returns zero on success, or -EFAULT on error.
  * On error, the variable @x is set to zero.
  */
+#define get_user(x, ptr)                                               \
+       __get_user_check((x), (ptr), sizeof(*(ptr)))
+
+#define __get_user_check(x, ptr, size)                                 \
+({                                                                     \
+       unsigned long __gu_val = 0;                                     \
+       const typeof(*(ptr)) __user *__gu_addr = (ptr);                 \
+       int __gu_err = 0;                                               \
+                                                                       \
+       if (access_ok(VERIFY_READ, __gu_addr, size)) {                  \
+               switch (size) {                                         \
+               case 1:                                                 \
+                       __get_user_asm("lbu", __gu_addr, __gu_val,      \
+                                      __gu_err);                       \
+                       break;                                          \
+               case 2:                                                 \
+                       __get_user_asm("lhu", __gu_addr, __gu_val,      \
+                                      __gu_err);                       \
+                       break;                                          \
+               case 4:                                                 \
+                       __get_user_asm("lw", __gu_addr, __gu_val,       \
+                                      __gu_err);                       \
+                       break;                                          \
+               default:                                                \
+                       __gu_err = __user_bad();                        \
+                       break;                                          \
+               }                                                       \
+       } else {                                                        \
+               __gu_err = -EFAULT;                                     \
+       }                                                               \
+       x = (typeof(*(ptr)))__gu_val;                                   \
+       __gu_err;                                                       \
+})
 
 #define __get_user(x, ptr)                                             \
 ({                                                                     \
@@ -206,12 +239,6 @@ extern long __user_bad(void);
 })
 
 
-#define get_user(x, ptr)                                               \
-({                                                                     \
-       access_ok(VERIFY_READ, (ptr), sizeof(*(ptr)))                   \
-               ? __get_user((x), (ptr)) : -EFAULT;                     \
-})
-
 #define __put_user_asm(insn, __gu_ptr, __gu_val, __gu_err)     \
 ({                                                             \
        __asm__ __volatile__ (                                  \
@@ -266,6 +293,42 @@ extern long __user_bad(void);
  *
  * Returns zero on success, or -EFAULT on error.
  */
+#define put_user(x, ptr)                                               \
+       __put_user_check((x), (ptr), sizeof(*(ptr)))
+
+#define __put_user_check(x, ptr, size)                                 \
+({                                                                     \
+       typeof(*(ptr)) __pu_val;                                        \
+       typeof(*(ptr)) __user *__pu_addr = (ptr);                       \
+       int __pu_err = 0;                                               \
+                                                                       \
+       __pu_val = (x);                                                 \
+       if (access_ok(VERIFY_WRITE, __pu_addr, size)) {                 \
+               switch (size) {                                         \
+               case 1:                                                 \
+                       __put_user_asm("sb", __pu_addr, __pu_val,       \
+                                      __pu_err);                       \
+                       break;                                          \
+               case 2:                                                 \
+                       __put_user_asm("sh", __pu_addr, __pu_val,       \
+                                      __pu_err);                       \
+                       break;                                          \
+               case 4:                                                 \
+                       __put_user_asm("sw", __pu_addr, __pu_val,       \
+                                      __pu_err);                       \
+                       break;                                          \
+               case 8:                                                 \
+                       __put_user_asm_8(__pu_addr, __pu_val, __pu_err);\
+                       break;                                          \
+               default:                                                \
+                       __pu_err = __user_bad();                        \
+                       break;                                          \
+               }                                                       \
+       } else {                                                        \
+               __pu_err = -EFAULT;                                     \
+       }                                                               \
+       __pu_err;                                                       \
+})
 
 #define __put_user(x, ptr)                                             \
 ({                                                                     \
@@ -290,18 +353,6 @@ extern long __user_bad(void);
        __gu_err;                                                       \
 })
 
-#ifndef CONFIG_MMU
-
-#define put_user(x, ptr)       __put_user((x), (ptr))
-
-#else /* CONFIG_MMU */
-
-#define put_user(x, ptr)                                               \
-({                                                                     \
-       access_ok(VERIFY_WRITE, (ptr), sizeof(*(ptr)))                  \
-               ? __put_user((x), (ptr)) : -EFAULT;                     \
-})
-#endif /* CONFIG_MMU */
 
 /* copy_to_from_user */
 #define __copy_from_user(to, from, n)  \
index 21c3a92..109876e 100644 (file)
@@ -137,8 +137,9 @@ do {                                                                        \
 do {                                                                   \
        int step = -line_length;                                        \
        int align = ~(line_length - 1);                                 \
+       int count;                                                      \
        end = ((end & align) == end) ? end - line_length : end & align; \
-       int count = end - start;                                        \
+       count = end - start;                                            \
        WARN_ON(count < 0);                                             \
                                                                        \
        __asm__ __volatile__ (" 1:      " #op " %0, %1;                 \
index 391d619..8cc18cd 100644 (file)
@@ -476,6 +476,8 @@ ENTRY(ret_from_fork)
        nop
 
 work_pending:
+       enable_irq
+
        andi    r11, r19, _TIF_NEED_RESCHED
        beqi    r11, 1f
        bralid  r15, schedule
index bc4dcb7..ff85f77 100644 (file)
@@ -52,3 +52,14 @@ EXPORT_SYMBOL_GPL(_ebss);
 extern void _mcount(void);
 EXPORT_SYMBOL(_mcount);
 #endif
+
+/*
+ * Assembly functions that may be used (directly or indirectly) by modules
+ */
+EXPORT_SYMBOL(__copy_tofrom_user);
+EXPORT_SYMBOL(__strncpy_user);
+
+#ifdef CONFIG_OPT_LIB_ASM
+EXPORT_SYMBOL(memcpy);
+EXPORT_SYMBOL(memmove);
+#endif
index cbecf11..0e73f66 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/string.h>
 
 #include <asm/pgtable.h>
+#include <asm/cacheflush.h>
 
 void *module_alloc(unsigned long size)
 {
@@ -151,6 +152,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
 int module_finalize(const Elf32_Ehdr *hdr, const Elf_Shdr *sechdrs,
                struct module *module)
 {
+       flush_dcache();
        return 0;
 }
 
index f42c2dd..cca3579 100644 (file)
@@ -47,6 +47,7 @@ unsigned long memory_start;
 EXPORT_SYMBOL(memory_start);
 unsigned long memory_end; /* due to mm/nommu.c */
 unsigned long memory_size;
+EXPORT_SYMBOL(memory_size);
 
 /*
  * paging_init() sets up the page tables - in fact we've already done this.
index 784557f..59bf233 100644 (file)
@@ -42,6 +42,7 @@
 
 unsigned long ioremap_base;
 unsigned long ioremap_bot;
+EXPORT_SYMBOL(ioremap_bot);
 
 /* The maximum lowmem defaults to 768Mb, but this can be configured to
  * another value.
index 01c8c97..9cb782b 100644 (file)
@@ -1507,7 +1507,7 @@ void pcibios_finish_adding_to_bus(struct pci_bus *bus)
        pci_bus_add_devices(bus);
 
        /* Fixup EEH */
-       eeh_add_device_tree_late(bus);
+       /* eeh_add_device_tree_late(bus); */
 }
 EXPORT_SYMBOL_GPL(pcibios_finish_adding_to_bus);