Merge tag 'for-linus' of git://github.com/openrisc/linux
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 14 Aug 2020 21:04:53 +0000 (14:04 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 14 Aug 2020 21:04:53 +0000 (14:04 -0700)
Pull OpenRISC updates from Stafford Horne:
 "A few patches all over the place during this cycle, mostly bug and
  sparse warning fixes for OpenRISC, but a few enhancements too. Note,
  there are 2 non OpenRISC specific fixups.

  Non OpenRISC fixes:

   - In init we need to align the init_task correctly to fix an issue
     with MUTEX_FLAGS, reviewed by Peter Z. No one picked this up so I
     kept it on my tree.

   - In asm-generic/io.h I fixed up some sparse warnings, OK'd by Arnd.
     Arnd asked to merge it via my tree.

  OpenRISC fixes:

   - Many fixes for OpenRISC sprase warnings.

   - Add support OpenRISC SMP tlb flushing rather than always flushing
     the entire TLB on every CPU.

   - Fix bug when dumping stack via /proc/xxx/stack of user threads"

* tag 'for-linus' of git://github.com/openrisc/linux:
  openrisc: uaccess: Add user address space check to access_ok
  openrisc: signal: Fix sparse address space warnings
  openrisc: uaccess: Remove unused macro __addr_ok
  openrisc: uaccess: Use static inline function in access_ok
  openrisc: uaccess: Fix sparse address space warnings
  openrisc: io: Fixup defines and move include to the end
  asm-generic/io.h: Fix sparse warnings on big-endian architectures
  openrisc: Implement proper SMP tlb flushing
  openrisc: Fix oops caused when dumping stack
  openrisc: Add support for external initrd images
  init: Align init_task to avoid conflict with MUTEX_FLAGS
  openrisc: fix __user in raw_copy_to_user()'s prototype

1  2 
arch/openrisc/include/asm/uaccess.h
init/init_task.c

  #define get_fs()      (current_thread_info()->addr_limit)
  #define set_fs(x)     (current_thread_info()->addr_limit = (x))
  
 -#define segment_eq(a, b)      ((a) == (b))
 +#define uaccess_kernel()      (get_fs() == KERNEL_DS)
  
  /* Ensure that the range from addr to addr+size is all within the process'
   * address space
   */
- #define __range_ok(addr, size) (size <= get_fs() && addr <= (get_fs()-size))
+ static inline int __range_ok(unsigned long addr, unsigned long size)
+ {
+       const mm_segment_t fs = get_fs();
  
- /* Ensure that addr is below task's addr_limit */
- #define __addr_ok(addr) ((unsigned long) addr < get_fs())
+       return size <= fs && addr <= (fs - size);
+ }
  
  #define access_ok(addr, size)                                         \
  ({                                                                    \
-       unsigned long __ao_addr = (unsigned long)(addr);                \
-       unsigned long __ao_size = (unsigned long)(size);                \
-       __range_ok(__ao_addr, __ao_size);                               \
+       __chk_user_ptr(addr);                                           \
+       __range_ok((unsigned long)(addr), (size));                      \
  })
  
  /*
@@@ -100,7 -101,7 +101,7 @@@ extern long __put_user_bad(void)
  #define __put_user_check(x, ptr, size)                                        \
  ({                                                                    \
        long __pu_err = -EFAULT;                                        \
-       __typeof__(*(ptr)) *__pu_addr = (ptr);                          \
+       __typeof__(*(ptr)) __user *__pu_addr = (ptr);                   \
        if (access_ok(__pu_addr, size))                 \
                __put_user_size((x), __pu_addr, (size), __pu_err);      \
        __pu_err;                                                       \
@@@ -173,7 -174,7 +174,7 @@@ struct __large_struct 
  #define __get_user_check(x, ptr, size)                                        \
  ({                                                                    \
        long __gu_err = -EFAULT, __gu_val = 0;                          \
-       const __typeof__(*(ptr)) * __gu_addr = (ptr);                   \
+       const __typeof__(*(ptr)) __user *__gu_addr = (ptr);             \
        if (access_ok(__gu_addr, size))                 \
                __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
        (x) = (__force __typeof__(*(ptr)))__gu_val;                     \
@@@ -241,17 -242,17 +242,17 @@@ raw_copy_from_user(void *to, const voi
        return __copy_tofrom_user(to, (__force const void *)from, size);
  }
  static inline unsigned long
- raw_copy_to_user(void *to, const void __user *from, unsigned long size)
+ raw_copy_to_user(void __user *to, const void *from, unsigned long size)
  {
        return __copy_tofrom_user((__force void *)to, from, size);
  }
  #define INLINE_COPY_FROM_USER
  #define INLINE_COPY_TO_USER
  
- extern unsigned long __clear_user(void *addr, unsigned long size);
+ extern unsigned long __clear_user(void __user *addr, unsigned long size);
  
  static inline __must_check unsigned long
- clear_user(void *addr, unsigned long size)
+ clear_user(void __user *addr, unsigned long size)
  {
        if (likely(access_ok(addr, size)))
                size = __clear_user(addr, size);
diff --combined init/init_task.c
@@@ -65,6 -65,7 +65,7 @@@ struct task_struct init_tas
  #ifdef CONFIG_ARCH_TASK_STRUCT_ON_STACK
        __init_task_data
  #endif
+       __aligned(L1_CACHE_BYTES)
  = {
  #ifdef CONFIG_THREAD_INFO_IN_TASK
        .thread_info    = INIT_THREAD_INFO(init_task),
        .trc_holdout_list = LIST_HEAD_INIT(init_task.trc_holdout_list),
  #endif
  #ifdef CONFIG_CPUSETS
 -      .mems_allowed_seq = SEQCNT_ZERO(init_task.mems_allowed_seq),
 +      .mems_allowed_seq = SEQCNT_SPINLOCK_ZERO(init_task.mems_allowed_seq,
 +                                               &init_task.alloc_lock),
  #endif
  #ifdef CONFIG_RT_MUTEXES
        .pi_waiters     = RB_ROOT_CACHED,
  #ifdef CONFIG_SECURITY
        .security       = NULL,
  #endif
 +#ifdef CONFIG_SECCOMP
 +      .seccomp        = { .filter_count = ATOMIC_INIT(0) },
 +#endif
  };
  EXPORT_SYMBOL(init_task);