1. 03 6月, 2018 3 次提交
    • M
      powerpc: Use barrier_nospec in copy_from_user() · ddf35cf3
      Michael Ellerman 提交于
      Based on the x86 commit doing the same.
      
      See commit 304ec1b0 ("x86/uaccess: Use __uaccess_begin_nospec()
      and uaccess_try_nospec") and b3bbfb3f ("x86: Introduce
      __uaccess_begin_nospec() and uaccess_try_nospec") for more detail.
      
      In all cases we are ordering the load from the potentially
      user-controlled pointer vs a previous branch based on an access_ok()
      check or similar.
      
      Base on a patch from Michal Suchanek.
      Signed-off-by: NMichal Suchanek <msuchanek@suse.de>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      ddf35cf3
    • M
      powerpc: Check address limit on user-mode return (TIF_FSCHECK) · 3e378680
      Michael Ellerman 提交于
      set_fs() sets the addr_limit, which is used in access_ok() to
      determine if an address is a user or kernel address.
      
      Some code paths use set_fs() to temporarily elevate the addr_limit so
      that kernel code can read/write kernel memory as if it were user
      memory. That is fine as long as the code can't ever return to
      userspace with the addr_limit still elevated.
      
      If that did happen, then userspace can read/write kernel memory as if
      it were user memory, eg. just with write(2). In case it's not clear,
      that is very bad. It has also happened in the past due to bugs.
      
      Commit 5ea0727b ("x86/syscalls: Check address limit on user-mode
      return") added a mechanism to check the addr_limit value before
      returning to userspace. Any call to set_fs() sets a thread flag,
      TIF_FSCHECK, and if we see that on the return to userspace we go out
      of line to check that the addr_limit value is not elevated.
      
      For further info see the above commit, as well as:
        https://lwn.net/Articles/722267/
        https://bugs.chromium.org/p/project-zero/issues/detail?id=990
      
      Verified to work on 64-bit Book3S using a POC that objdumps the system
      call handler, and a modified lkdtm_CORRUPT_USER_DS() that doesn't kill
      the caller.
      
      Before:
        $ sudo ./test-tif-fscheck
        ...
        0000000000000000 <.data>:
               0:       e1 f7 8a 79     rldicl. r10,r12,30,63
               4:       80 03 82 40     bne     0x384
               8:       00 40 8a 71     andi.   r10,r12,16384
               c:       78 0b 2a 7c     mr      r10,r1
              10:       10 fd 21 38     addi    r1,r1,-752
              14:       08 00 c2 41     beq-    0x1c
              18:       58 09 2d e8     ld      r1,2392(r13)
              1c:       00 00 41 f9     std     r10,0(r1)
              20:       70 01 61 f9     std     r11,368(r1)
              24:       78 01 81 f9     std     r12,376(r1)
              28:       70 00 01 f8     std     r0,112(r1)
              2c:       78 00 41 f9     std     r10,120(r1)
              30:       20 00 82 41     beq     0x50
              34:       a6 42 4c 7d     mftb    r10
      
      After:
      
        $ sudo ./test-tif-fscheck
        Killed
      
      And in dmesg:
        Invalid address limit on user-mode return
        WARNING: CPU: 1 PID: 3689 at ../include/linux/syscalls.h:260 do_notify_resume+0x140/0x170
        ...
        NIP [c00000000001ee50] do_notify_resume+0x140/0x170
        LR [c00000000001ee4c] do_notify_resume+0x13c/0x170
        Call Trace:
          do_notify_resume+0x13c/0x170 (unreliable)
          ret_from_except_lite+0x70/0x74
      
      Performance overhead is essentially zero in the usual case, because
      the bit is checked as part of the existing _TIF_USER_WORK_MASK check.
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      3e378680
    • M
      powerpc: Rename thread_struct.fs to addr_limit · ba0635fc
      Michael Ellerman 提交于
      It's called 'fs' for historical reasons, it's named after the x86 'FS'
      register. But we don't have to use that name for the member of
      thread_struct, and in fact arch/x86 doesn't even call it 'fs' anymore.
      
      So rename it to 'addr_limit', which better reflects what it's used
      for, and is also the name used on other arches.
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      ba0635fc
  2. 13 3月, 2018 1 次提交
  3. 13 11月, 2017 1 次提交
  4. 02 11月, 2017 1 次提交
    • G
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman 提交于
      Many source files in the tree are missing licensing information, which
      makes it harder for compliance tools to determine the correct license.
      
      By default all files without license information are under the default
      license of the kernel, which is GPL version 2.
      
      Update the files which contain no license information with the 'GPL-2.0'
      SPDX license identifier.  The SPDX identifier is a legally binding
      shorthand, which can be used instead of the full boiler plate text.
      
      This patch is based on work done by Thomas Gleixner and Kate Stewart and
      Philippe Ombredanne.
      
      How this work was done:
      
      Patches were generated and checked against linux-4.14-rc6 for a subset of
      the use cases:
       - file had no licensing information it it.
       - file was a */uapi/* one with no licensing information in it,
       - file was a */uapi/* one with existing licensing information,
      
      Further patches will be generated in subsequent months to fix up cases
      where non-standard license headers were used, and references to license
      had to be inferred by heuristics based on keywords.
      
      The analysis to determine which SPDX License Identifier to be applied to
      a file was done in a spreadsheet of side by side results from of the
      output of two independent scanners (ScanCode & Windriver) producing SPDX
      tag:value files created by Philippe Ombredanne.  Philippe prepared the
      base worksheet, and did an initial spot review of a few 1000 files.
      
      The 4.13 kernel was the starting point of the analysis with 60,537 files
      assessed.  Kate Stewart did a file by file comparison of the scanner
      results in the spreadsheet to determine which SPDX license identifier(s)
      to be applied to the file. She confirmed any determination that was not
      immediately clear with lawyers working with the Linux Foundation.
      
      Criteria used to select files for SPDX license identifier tagging was:
       - Files considered eligible had to be source code files.
       - Make and config files were included as candidates if they contained >5
         lines of source
       - File already had some variant of a license header in it (even if <5
         lines).
      
      All documentation files were explicitly excluded.
      
      The following heuristics were used to determine which SPDX license
      identifiers to apply.
      
       - when both scanners couldn't find any license traces, file was
         considered to have no license information in it, and the top level
         COPYING file license applied.
      
         For non */uapi/* files that summary was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0                                              11139
      
         and resulted in the first patch in this series.
      
         If that file was a */uapi/* path one, it was "GPL-2.0 WITH
         Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0 WITH Linux-syscall-note                        930
      
         and resulted in the second patch in this series.
      
       - if a file had some form of licensing information in it, and was one
         of the */uapi/* ones, it was denoted with the Linux-syscall-note if
         any GPL family license was found in the file or had no licensing in
         it (per prior point).  Results summary:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|------
         GPL-2.0 WITH Linux-syscall-note                       270
         GPL-2.0+ WITH Linux-syscall-note                      169
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
         LGPL-2.1+ WITH Linux-syscall-note                      15
         GPL-1.0+ WITH Linux-syscall-note                       14
         ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
         LGPL-2.0+ WITH Linux-syscall-note                       4
         LGPL-2.1 WITH Linux-syscall-note                        3
         ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
         ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1
      
         and that resulted in the third patch in this series.
      
       - when the two scanners agreed on the detected license(s), that became
         the concluded license(s).
      
       - when there was disagreement between the two scanners (one detected a
         license but the other didn't, or they both detected different
         licenses) a manual inspection of the file occurred.
      
       - In most cases a manual inspection of the information in the file
         resulted in a clear resolution of the license that should apply (and
         which scanner probably needed to revisit its heuristics).
      
       - When it was not immediately clear, the license identifier was
         confirmed with lawyers working with the Linux Foundation.
      
       - If there was any question as to the appropriate license identifier,
         the file was flagged for further research and to be revisited later
         in time.
      
      In total, over 70 hours of logged manual review was done on the
      spreadsheet to determine the SPDX license identifiers to apply to the
      source files by Kate, Philippe, Thomas and, in some cases, confirmation
      by lawyers working with the Linux Foundation.
      
      Kate also obtained a third independent scan of the 4.13 code base from
      FOSSology, and compared selected files where the other two scanners
      disagreed against that SPDX file, to see if there was new insights.  The
      Windriver scanner is based on an older version of FOSSology in part, so
      they are related.
      
      Thomas did random spot checks in about 500 files from the spreadsheets
      for the uapi headers and agreed with SPDX license identifier in the
      files he inspected. For the non-uapi files Thomas did random spot checks
      in about 15000 files.
      
      In initial set of patches against 4.14-rc6, 3 files were found to have
      copy/paste license identifier errors, and have been fixed to reflect the
      correct identifier.
      
      Additionally Philippe spent 10 hours this week doing a detailed manual
      inspection and review of the 12,461 patched files from the initial patch
      version early this week with:
       - a full scancode scan run, collecting the matched texts, detected
         license ids and scores
       - reviewing anything where there was a license detected (about 500+
         files) to ensure that the applied SPDX license was correct
       - reviewing anything where there was no detection but the patch license
         was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
         SPDX license was correct
      
      This produced a worksheet with 20 files needing minor correction.  This
      worksheet was then exported into 3 different .csv files for the
      different types of files to be modified.
      
      These .csv files were then reviewed by Greg.  Thomas wrote a script to
      parse the csv files and add the proper SPDX tag to the file, in the
      format that the file expected.  This script was further refined by Greg
      based on the output to detect more types of files automatically and to
      distinguish between header and source .c files (which need different
      comment types.)  Finally Greg ran the script using the .csv files to
      generate the patches.
      Reviewed-by: NKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: NPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2441318
  5. 27 9月, 2017 1 次提交
    • M
      powerpc/64s: Add workaround for P9 vector CI load issue · 5080332c
      Michael Neuling 提交于
      POWER9 DD2.1 and earlier has an issue where some cache inhibited
      vector load will return bad data. The workaround is two part, one
      firmware/microcode part triggers HMI interrupts when hitting such
      loads, the other part is this patch which then emulates the
      instructions in Linux.
      
      The affected instructions are limited to lxvd2x, lxvw4x, lxvb16x and
      lxvh8x.
      
      When an instruction triggers the HMI, all threads in the core will be
      sent to the HMI handler, not just the one running the vector load.
      
      In general, these spurious HMIs are detected by the emulation code and
      we just return back to the running process. Unfortunately, if a
      spurious interrupt occurs on a vector load that's to normal memory we
      have no way to detect that it's spurious (unless we walk the page
      tables, which is very expensive). In this case we emulate the load but
      we need do so using a vector load itself to ensure 128bit atomicity is
      preserved.
      
      Some additional debugfs emulated instruction counters are added also.
      Signed-off-by: NMichael Neuling <mikey@neuling.org>
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      [mpe: Switch CONFIG_PPC_BOOK3S_64 to CONFIG_VSX to unbreak the build]
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      5080332c
  6. 04 7月, 2017 1 次提交
  7. 26 6月, 2017 1 次提交
    • M
      powerpc/32: Avoid miscompilation w/GCC 4.6.3 - don't inline copy_to/from_user() · d6bd8194
      Michael Ellerman 提交于
      Larry Finger reported that his Powerbook G4 was no longer booting with v4.12-rc,
      userspace was up but giving weird errors such as:
      
        udevd[64]: starting version 175
        udevd[64]: Unable to receive ctrl message: Bad address.
        modprobe: chdir(4.12-rc1): No such file or directory
      
      He bisected the problem to commit 3448890c ("powerpc: get rid of zeroing,
      switch to RAW_COPY_USER").
      
      Al identified that the problem is actually a miscompilation by GCC 4.6.3, which
      is exposed by the above commit.
      
      Al also pointed out that inlining copy_to/from_user() is probably of little or
      no benefit, which is correct. Using Anton's copy_to_user benchmark, with a
      pathological single byte copy, we see a small increase in performance
      by *removing* inlining:
      
        Before (inlined):
        # time ./copy_to_user -w -l 1 -i 10000000	( x 3 )
        real	0m22.063s
        real	0m22.059s
        real	0m22.076s
      
        After:
        # time ./copy_to_user -w -l 1 -i 10000000	( x 3 )
        real	0m21.325s
        real	0m21.299s
        real	0m21.364s
      
      So as a small performance improvement and to avoid the miscompilation, drop
      inlining copy_to/from_user() on 32-bit.
      
      Fixes: 3448890c ("powerpc: get rid of zeroing, switch to RAW_COPY_USER")
      Reported-by: NLarry Finger <Larry.Finger@lwfinger.net>
      Suggested-by: NAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      d6bd8194
  8. 16 5月, 2017 1 次提交
  9. 07 4月, 2017 1 次提交
  10. 29 3月, 2017 1 次提交
  11. 06 3月, 2017 3 次提交
  12. 02 2月, 2017 3 次提交
  13. 14 11月, 2016 2 次提交
  14. 14 9月, 2016 1 次提交
  15. 07 9月, 2016 1 次提交
    • K
      usercopy: fold builtin_const check into inline function · 81409e9e
      Kees Cook 提交于
      Instead of having each caller of check_object_size() need to remember to
      check for a const size parameter, move the check into check_object_size()
      itself. This actually matches the original implementation in PaX, though
      this commit cleans up the now-redundant builtin_const() calls in the
      various architectures.
      Signed-off-by: NKees Cook <keescook@chromium.org>
      81409e9e
  16. 27 7月, 2016 1 次提交
  17. 04 1月, 2016 1 次提交
  18. 11 6月, 2015 1 次提交
  19. 18 12月, 2014 1 次提交
    • M
      powerpc/uaccess: Allow get_user() with bitwise types · 505e4283
      Michael S. Tsirkin 提交于
      At the moment, if p and x are both of the same bitwise type
      (eg. __le32), get_user(x, p) produces a sparse warning.
      
      This is because *p is loaded into a long then cast back to typeof(*p).
      
      When typeof(*p) is a bitwise type (which is uncommon), such a cast needs
      __force, otherwise sparse produces a warning.
      
      For non-bitwise types __force should have no effect, and should not hide
      any legitimate errors.
      
      Note that we are casting to typeof(*p) not typeof(x). Even with the
      cast, if x and *p are of different types we should get the warning, so I
      think we are not loosing the ability to detect any actual errors.
      
      virtio would like to use bitwise types with get_user() so fix these
      spurious warnings by adding __force.
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      [mpe: Fill in changelog with more details]
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      505e4283
  20. 28 5月, 2013 1 次提交
  21. 18 9月, 2012 1 次提交
  22. 28 5月, 2012 1 次提交
  23. 04 8月, 2008 1 次提交
  24. 22 7月, 2008 1 次提交
  25. 15 5月, 2008 1 次提交
  26. 13 4月, 2007 1 次提交
  27. 04 12月, 2006 1 次提交
  28. 03 5月, 2006 1 次提交
    • P
      powerpc: Fix incorrect might_sleep in __get_user/__put_user on kernel addresses · 6bfd93c3
      Paul Mackerras 提交于
      We have a case where __get_user and __put_user can validly be used
      on kernel addresses in interrupt context - namely, the alignment
      exception handler, as our get/put_unaligned just do a single access
      and rely on the alignment exception handler to fix things up in the
      rare cases where the cpu can't handle it in hardware.  Thus we can
      get alignment exceptions in the network stack at interrupt level.
      The alignment exception handler does a __get_user to read the
      instruction and blows up in might_sleep().
      
      Since a __get_user on a kernel address won't actually ever sleep,
      this makes the might_sleep conditional on the address being less
      than PAGE_OFFSET.
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      6bfd93c3
  29. 10 11月, 2005 1 次提交
    • D
      [PATCH] powerpc: Consolidate asm compatibility macros · 3ddfbcf1
      David Gibson 提交于
      This patch consolidates macros used to generate assembly for
      compatibility across different CPUs or configs.  A new header,
      asm-powerpc/asm-compat.h contains the main compatibility macros.  It
      uses some preprocessor magic to make the macros suitable both for use
      in .S files, and in inline asm in .c files.  Headers (bitops.h,
      uaccess.h, atomic.h, bug.h) which had their own such compatibility
      macros are changed to use asm-compat.h.
      
      ppc_asm.h is now for use in .S files *only*, and a #error enforces
      that.  As such, we're a lot more careless about namespace pollution
      here than in asm-compat.h.
      
      While we're at it, this patch adds a call to the PPC405_ERR77 macro in
      futex.h which should have had it already, but didn't.
      
      Built and booted on pSeries, Maple and iSeries (ARCH=powerpc).  Built
      for 32-bit powermac (ARCH=powerpc) and Walnut (ARCH=ppc).
      Signed-off-by: NDavid Gibson <dwg@au1.ibm.com>
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      3ddfbcf1
  30. 01 11月, 2005 3 次提交