An error occurred fetching the project authors.
  1. 18 May, 2020 2 commits
  2. 28 Jan, 2020 3 commits
  3. 16 Dec, 2019 1 commit
  4. 21 Aug, 2019 1 commit
  5. 03 Jul, 2019 1 commit
  6. 21 Apr, 2019 1 commit
    • Christophe Leroy's avatar
      powerpc: Add a framework for Kernel Userspace Access Protection · de78a9c4
      Christophe Leroy authored
      This patch implements a framework for Kernel Userspace Access
      Protection.
      
      Then subarches will have the possibility to provide their own
      implementation by providing setup_kuap() and
      allow/prevent_user_access().
      
      Some platforms will need to know the area accessed and whether it is
      accessed from read, write or both. Therefore source, destination and
      size and handed over to the two functions.
      
      mpe: Rename to allow/prevent rather than unlock/lock, and add
      read/write wrappers. Drop the 32-bit code for now until we have an
      implementation for it. Add kuap to pt_regs for 64-bit as well as
      32-bit. Don't split strings, use pr_crit_ratelimited().
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Signed-off-by: default avatarRussell Currey <ruscur@russell.cc>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      de78a9c4
  7. 04 Mar, 2019 1 commit
    • Linus Torvalds's avatar
      get rid of legacy 'get_ds()' function · 736706be
      Linus Torvalds authored
      Every in-kernel use of this function defined it to KERNEL_DS (either as
      an actual define, or as an inline function).  It's an entirely
      historical artifact, and long long long ago used to actually read the
      segment selector valueof '%ds' on x86.
      
      Which in the kernel is always KERNEL_DS.
      
      Inspired by a patch from Jann Horn that just did this for a very small
      subset of users (the ones in fs/), along with Al who suggested a script.
      I then just took it to the logical extreme and removed all the remaining
      gunk.
      
      Roughly scripted with
      
         git grep -l '(get_ds())' -- :^tools/ | xargs sed -i 's/(get_ds())/(KERNEL_DS)/'
         git grep -lw 'get_ds' -- :^tools/ | xargs sed -i '/^#define get_ds()/d'
      
      plus manual fixups to remove a few unusual usage patterns, the couple of
      inline function cases and to fix up a comment that had become stale.
      
      The 'get_ds()' function remains in an x86 kvm selftest, since in user
      space it actually does something relevant.
      Inspired-by: default avatarJann Horn <jannh@google.com>
      Inspired-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      736706be
  8. 04 Jan, 2019 3 commits
    • Linus Torvalds's avatar
      Fix access_ok() fallout for sparc32 and powerpc · 4caf4ebf
      Linus Torvalds authored
      These two architectures actually had an intentional use of the 'type'
      argument to access_ok() just to avoid warnings.
      
      I had actually noticed the powerpc one, but forgot to then fix it up.
      And I missed the sparc32 case entirely.
      
      This is hopefully all of it.
      Reported-by: default avatarMathieu Malaterre <malat@debian.org>
      Reported-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Fixes: 96d4f267 ("Remove 'type' argument from access_ok() function")
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4caf4ebf
    • Mathieu Malaterre's avatar
      powerpc: Drop use of 'type' from access_ok() · 074400a7
      Mathieu Malaterre authored
      In commit 05a4ab82 ("powerpc/uaccess: fix warning/error with
      access_ok()") an attempt was made to remove a warning by referencing
      the variable `type`. However in commit 96d4f267 ("Remove 'type'
      argument from access_ok() function") the variable `type` has been
      removed, breaking the build:
      
        arch/powerpc/include/asm/uaccess.h:66:32: error: ‘type’ undeclared (first use in this function)
      
      This essentially reverts commit 05a4ab82 ("powerpc/uaccess: fix
      warning/error with access_ok()") to fix the error.
      
      Fixes: 96d4f267 ("Remove 'type' argument from access_ok() function")
      Signed-off-by: default avatarMathieu Malaterre <malat@debian.org>
      [mpe: Reword change log slightly.]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      074400a7
    • Linus Torvalds's avatar
      Remove 'type' argument from access_ok() function · 96d4f267
      Linus Torvalds authored
      Nobody has actually used the type (VERIFY_READ vs VERIFY_WRITE) argument
      of the user address range verification function since we got rid of the
      old racy i386-only code to walk page tables by hand.
      
      It existed because the original 80386 would not honor the write protect
      bit when in kernel mode, so you had to do COW by hand before doing any
      user access.  But we haven't supported that in a long time, and these
      days the 'type' argument is a purely historical artifact.
      
      A discussion about extending 'user_access_begin()' to do the range
      checking resulted this patch, because there is no way we're going to
      move the old VERIFY_xyz interface to that model.  And it's best done at
      the end of the merge window when I've done most of my merges, so let's
      just get this done once and for all.
      
      This patch was mostly done with a sed-script, with manual fix-ups for
      the cases that weren't of the trivial 'access_ok(VERIFY_xyz' form.
      
      There were a couple of notable cases:
      
       - csky still had the old "verify_area()" name as an alias.
      
       - the iter_iov code had magical hardcoded knowledge of the actual
         values of VERIFY_{READ,WRITE} (not that they mattered, since nothing
         really used it)
      
       - microblaze used the type argument for a debug printout
      
      but other than those oddities this should be a total no-op patch.
      
      I tried to fix up all architectures, did fairly extensive grepping for
      access_ok() uses, and the changes are trivial, but I may have missed
      something.  Any missed conversion should be trivially fixable, though.
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      96d4f267
  9. 19 Dec, 2018 1 commit
    • Christophe Leroy's avatar
      powerpc/uaccess: fix warning/error with access_ok() · 05a4ab82
      Christophe Leroy authored
      With the following piece of code, the following compilation warning
      is encountered:
      
      	if (_IOC_DIR(ioc) != _IOC_NONE) {
      		int verify = _IOC_DIR(ioc) & _IOC_READ ? VERIFY_WRITE : VERIFY_READ;
      
      		if (!access_ok(verify, ioarg, _IOC_SIZE(ioc))) {
      
      drivers/platform/test/dev.c: In function 'my_ioctl':
      drivers/platform/test/dev.c:219:7: warning: unused variable 'verify' [-Wunused-variable]
         int verify = _IOC_DIR(ioc) & _IOC_READ ? VERIFY_WRITE : VERIFY_READ;
      
      This patch fixes it by referencing 'type' in the macro allthough
      doing nothing with it.
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      05a4ab82
  10. 19 Sep, 2018 1 commit
  11. 10 Aug, 2018 1 commit
    • Michael Ellerman's avatar
      powerpc/uaccess: Enable get_user(u64, *p) on 32-bit · f7a6947c
      Michael Ellerman authored
      Currently if you build a 32-bit powerpc kernel and use get_user() to
      load a u64 value it will fail to build with eg:
      
        kernel/rseq.o: In function `rseq_get_rseq_cs':
        kernel/rseq.c:123: undefined reference to `__get_user_bad'
      
      This is hitting the check in __get_user_size() that makes sure the
      size we're copying doesn't exceed the size of the destination:
      
        #define __get_user_size(x, ptr, size, retval)
        do {
        	retval = 0;
        	__chk_user_ptr(ptr);
        	if (size > sizeof(x))
        		(x) = __get_user_bad();
      
      Which doesn't immediately make sense because the size of the
      destination is u64, but it's not really, because __get_user_check()
      etc. internally create an unsigned long and copy into that:
      
        #define __get_user_check(x, ptr, size)
        ({
        	long __gu_err = -EFAULT;
        	unsigned long  __gu_val = 0;
      
      The problem being that on 32-bit unsigned long is not big enough to
      hold a u64. We can fix this with a trick from hpa in the x86 code, we
      statically check the type of x and set the type of __gu_val to either
      unsigned long or unsigned long long.
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      f7a6947c
  12. 30 Jul, 2018 1 commit
  13. 03 Jun, 2018 3 commits
    • Michael Ellerman's avatar
      powerpc: Use barrier_nospec in copy_from_user() · ddf35cf3
      Michael Ellerman authored
      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: default avatarMichal Suchanek <msuchanek@suse.de>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      ddf35cf3
    • Michael Ellerman's avatar
      powerpc: Check address limit on user-mode return (TIF_FSCHECK) · 3e378680
      Michael Ellerman authored
      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: default avatarMichael Ellerman <mpe@ellerman.id.au>
      3e378680
    • Michael Ellerman's avatar
      powerpc: Rename thread_struct.fs to addr_limit · ba0635fc
      Michael Ellerman authored
      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: default avatarMichael Ellerman <mpe@ellerman.id.au>
      ba0635fc
  14. 13 Mar, 2018 1 commit
  15. 12 Nov, 2017 1 commit
  16. 02 Nov, 2017 1 commit
    • Greg Kroah-Hartman's avatar
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman authored
      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: default avatarKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: default avatarPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2441318
  17. 26 Sep, 2017 1 commit
    • Michael Neuling's avatar
      powerpc/64s: Add workaround for P9 vector CI load issue · 5080332c
      Michael Neuling authored
      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: default avatarMichael Neuling <mikey@neuling.org>
      Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
      [mpe: Switch CONFIG_PPC_BOOK3S_64 to CONFIG_VSX to unbreak the build]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      5080332c
  18. 03 Jul, 2017 1 commit
  19. 26 Jun, 2017 1 commit
    • Michael Ellerman's avatar
      powerpc/32: Avoid miscompilation w/GCC 4.6.3 - don't inline copy_to/from_user() · d6bd8194
      Michael Ellerman authored
      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: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Suggested-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      d6bd8194
  20. 16 May, 2017 1 commit
  21. 06 Apr, 2017 1 commit
  22. 28 Mar, 2017 1 commit
  23. 06 Mar, 2017 3 commits
  24. 02 Feb, 2017 3 commits
  25. 14 Nov, 2016 2 commits
  26. 13 Sep, 2016 1 commit
  27. 06 Sep, 2016 1 commit
    • Kees Cook's avatar
      usercopy: fold builtin_const check into inline function · 81409e9e
      Kees Cook authored
      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: default avatarKees Cook <keescook@chromium.org>
      81409e9e
  28. 26 Jul, 2016 1 commit