1. 04 1月, 2019 1 次提交
    • L
      Remove 'type' argument from access_ok() function · 96d4f267
      Linus Torvalds 提交于
      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: NLinus Torvalds <torvalds@linux-foundation.org>
      96d4f267
  2. 12 11月, 2018 1 次提交
    • V
      ARM: 8813/1: Make aligned 2-byte getuser()/putuser() atomic on ARMv6+ · 344eb553
      Vincent Whitchurch 提交于
      getuser() and putuser() (and there underscored variants) use two
      strb[t]/ldrb[t] instructions when they are asked to get/put 16-bits.
      This means that the read/write is not atomic even when performed to a
      16-bit-aligned address.
      
      This leads to problems with vhost: vhost uses __getuser() to read the
      vring's 16-bit avail.index field, and if it happens to observe a partial
      update of the index, wrong descriptors will be used which will lead to a
      breakdown of the virtio communication.  A similar problem exists for
      __putuser() which is used to write to the vring's used.index field.
      
      The reason these functions use strb[t]/ldrb[t] is because strht/ldrht
      instructions did not exist until ARMv6T2/ARMv7.  So we should be easily
      able to fix this on ARMv7.  Also, since all ARMv6 processors also don't
      actually use the unprivileged instructions anymore for uaccess (since
      CONFIG_CPU_USE_DOMAINS is not used) we can easily fix them too.
      Signed-off-by: NVincent Whitchurch <vincent.whitchurch@axis.com>
      Signed-off-by: NRussell King <rmk+kernel@armlinux.org.uk>
      344eb553
  3. 05 10月, 2018 3 次提交
  4. 03 8月, 2018 2 次提交
    • R
      ARM: spectre-v1: use get_user() for __get_user() · b1cd0a14
      Russell King 提交于
      Fixing __get_user() for spectre variant 1 is not sane: we would have to
      add address space bounds checking in order to validate that the location
      should be accessed, and then zero the address if found to be invalid.
      
      Since __get_user() is supposed to avoid the bounds check, and this is
      exactly what get_user() does, there's no point having two different
      implementations that are doing the same thing.  So, when the Spectre
      workarounds are required, make __get_user() an alias of get_user().
      Acked-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NRussell King <rmk+kernel@armlinux.org.uk>
      b1cd0a14
    • R
      ARM: use __inttype() in get_user() · d09fbb32
      Russell King 提交于
      Borrow the x86 implementation of __inttype() to use in get_user() to
      select an integer type suitable to temporarily hold the result value.
      This is necessary to avoid propagating the volatile nature of the
      result argument, which can cause the following warning:
      
      lib/iov_iter.c:413:5: warning: optimization may eliminate reads and/or writes to register variables [-Wvolatile-register-var]
      Acked-by: NMark Rutland <mark.rutland@arm.com>
      Signed-off-by: NRussell King <rmk+kernel@armlinux.org.uk>
      d09fbb32
  5. 19 5月, 2018 1 次提交
    • S
      ARM: 8768/1: uaccess: remove const to avoid duplicate specifier · db4667a8
      Stefan Agner 提交于
      Some users of get_user use the macro with an argument p which
      is already specified as static. When using clang this leads to
      a duplicate specifier:
          CC      arch/arm/kernel/process.o
        In file included from init/do_mounts.c:15:
        In file included from ./include/linux/tty.h:7:
        In file included from ./include/uapi/linux/termios.h:6:
        In file included from ./arch/arm/include/generated/uapi/asm/termios.h:1:
        ./include/asm-generic/termios.h:25:6: warning: duplicate 'const' declaration
                specifier [-Wduplicate-decl-specifier]
                if (get_user(tmp, &termio->c_iflag) < 0)
                    ^
        ./arch/arm/include/asm/uaccess.h:195:3: note: expanded from macro 'get_user'
                        __get_user_check(x, p);
                        ^
        ./arch/arm/include/asm/uaccess.h:155:12: note: expanded from macro
                '__get_user_check'
                        register const typeof(*(p)) __user *__p asm("r0") = (p);
      
      Remove the const attribute from the register declaration
      to avoid the duplicate const specifier. In a test with ptrace.c
      and traps.c (both using get_user with non-const arguments for p)
      the generated code was exactly the same.
      Signed-off-by: NStefan Agner <stefan@agner.ch>
      Signed-off-by: NRussell King <rmk+kernel@armlinux.org.uk>
      db4667a8
  6. 18 9月, 2017 1 次提交
  7. 08 7月, 2017 1 次提交
    • T
      arm/syscalls: Check address limit on user-mode return · 73ac5d6a
      Thomas Garnier 提交于
      Ensure the address limit is a user-mode segment before returning to
      user-mode. Otherwise a process can corrupt kernel-mode memory and
      elevate privileges [1].
      
      The set_fs function sets the TIF_SETFS flag to force a slow path on
      return. In the slow path, the address limit is checked to be USER_DS if
      needed.
      
      The TIF_SETFS flag is added to _TIF_WORK_MASK shifting _TIF_SYSCALL_WORK
      for arm instruction immediate support. The global work mask is too big
      to used on a single instruction so adapt ret_fast_syscall.
      
      [1] https://bugs.chromium.org/p/project-zero/issues/detail?id=990Signed-off-by: NThomas Garnier <thgarnie@google.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: kernel-hardening@lists.openwall.com
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Miroslav Benes <mbenes@suse.cz>
      Cc: Chris Metcalf <cmetcalf@mellanox.com>
      Cc: Pratyush Anand <panand@redhat.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: Will Drewry <wad@chromium.org>
      Cc: linux-api@vger.kernel.org
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Link: http://lkml.kernel.org/r/20170615011203.144108-2-thgarnie@google.com
      73ac5d6a
  8. 04 7月, 2017 1 次提交
  9. 16 5月, 2017 1 次提交
  10. 29 3月, 2017 3 次提交
  11. 06 3月, 2017 2 次提交
  12. 16 2月, 2017 1 次提交
  13. 16 9月, 2016 1 次提交
  14. 27 7月, 2016 1 次提交
  15. 23 6月, 2016 2 次提交
  16. 15 12月, 2015 1 次提交
  17. 27 8月, 2015 1 次提交
    • R
      ARM: software-based priviledged-no-access support · a5e090ac
      Russell King 提交于
      Provide a software-based implementation of the priviledged no access
      support found in ARMv8.1.
      
      Userspace pages are mapped using a different domain number from the
      kernel and IO mappings.  If we switch the user domain to "no access"
      when we enter the kernel, we can prevent the kernel from touching
      userspace.
      
      However, the kernel needs to be able to access userspace via the
      various user accessor functions.  With the wrapping in the previous
      patch, we can temporarily enable access when the kernel needs user
      access, and re-disable it afterwards.
      
      This allows us to trap non-intended accesses to userspace, eg, caused
      by an inadvertent dereference of the LIST_POISON* values, which, with
      appropriate user mappings setup, can be made to succeed.  This in turn
      can allow use-after-free bugs to be further exploited than would
      otherwise be possible.
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      a5e090ac
  18. 25 8月, 2015 2 次提交
  19. 30 3月, 2015 1 次提交
  20. 13 1月, 2015 2 次提交
    • M
      arm: macro whitespace fixes · 295bb01e
      Michael S. Tsirkin 提交于
      While working on arch/arm/include/asm/uaccess.h, I noticed
      that some macros within this header are made harder to read because they
      violate a coding style rule: space is missing after comma.
      
      Fix it up.
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      295bb01e
    • M
      arm: fix put_user sparse errors · e8b94dea
      Michael S. Tsirkin 提交于
      virtio wants to write bitwise types to userspace using put_user.
      At the moment this triggers sparse errors, since the value is passed
      through an integer.
      
      For example:
      
      	__le32 __user *p;
      	__le32 x;
      	put_user(x, p);
      
      is safe, but currently triggers a sparse warning.
      
      Fix that up using __force.
      
      Note: this does not suppress any useful sparse checks since caller
      assigns x to typeof(*p), which in turn forces all the necessary type
      checks.
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      e8b94dea
  21. 13 9月, 2014 1 次提交
    • V
      ARM: 8137/1: fix get_user BE behavior for target variable with size of 8 bytes · d9981380
      Victor Kamensky 提交于
      e38361d0 'ARM: 8091/2: add get_user() support for 8 byte types' commit
      broke V7 BE get_user call when target var size is 64 bit, but '*ptr' size
      is 32 bit or smaller. e38361d0 changed type of __r2 from 'register
      unsigned long' to 'register typeof(x) __r2 asm("r2")' i.e before the change
      even when target variable size was 64 bit, __r2 was still 32 bit.
      But after e38361d0 commit, for target var of 64 bit size, __r2 became 64
      bit and now it should occupy 2 registers r2, and r3. The issue in BE case
      that r3 register is least significant word of __r2 and r2 register is most
      significant word of __r2. But __get_user_4 still copies result into r2 (most
      significant word of __r2). Subsequent code copies from __r2 into x, but
      for situation described it will pick up only garbage from r3 register.
      
      Special __get_user_64t_(124) functions are introduced. They are similar to
      corresponding __get_user_(124) function but result stored in r3 register
      (lsw in case of 64 bit __r2 in BE image). Those function are used by
      get_user macro in case of BE and target var size is 64bit.
      
      Also changed __get_user_lo8 name into __get_user_32t_8 to get consistent
      naming accross all cases.
      Signed-off-by: NVictor Kamensky <victor.kamensky@linaro.org>
      Suggested-by: NDaniel Thompson <daniel.thompson@linaro.org>
      Reviewed-by: NDaniel Thompson <daniel.thompson@linaro.org>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      d9981380
  22. 18 7月, 2014 1 次提交
    • D
      ARM: 8091/2: add get_user() support for 8 byte types · e38361d0
      Daniel Thompson 提交于
      Recent contributions, including to DRM and binder, introduce 64-bit
      values in their interfaces. A common motivation for this is to allow
      the same ABI for 32- and 64-bit userspaces (and therefore also a shared
      ABI for 32/64 hybrid userspaces). Anyhow, the developers would like to
      avoid gotchas like having to use copy_from_user().
      
      This feature is already implemented on x86-32 and the majority of other
      32-bit architectures. The current list of get_user_8 hold out
      architectures are: arm, avr32, blackfin, m32r, metag, microblaze,
      mn10300, sh.
      
      Credit:
      
          My name sits rather uneasily at the top of this patch. The v1 and
          v2 versions of the patch were written by Rob Clark and to produce v4
          I mostly copied code from Russell King and H. Peter Anvin. However I
          have mangled the patch sufficiently that *blame* is rightfully mine
          even if credit should more widely shared.
      
      Changelog:
      
      v5: updated to use the ret macro (requested by Russell King)
      v4: remove an inlined add on big endian systems (spotted by Russell King),
          used __ARMEB__ rather than BIG_ENDIAN (to match rest of file),
          cleared r3 on EFAULT during __get_user_8.
      v3: fix a couple of checkpatch issues
      v2: pass correct size to check_uaccess, and better handling of narrowing
          double word read with __get_user_xb() (Russell King's suggestion)
      v1: original
      Signed-off-by: NRob Clark <robdclark@gmail.com>
      Signed-off-by: NDaniel Thompson <daniel.thompson@linaro.org>
      Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
      e38361d0
  23. 01 7月, 2014 1 次提交
    • U
      ARM: make user_addr_max more robust · 83de911c
      Uwe Kleine-König 提交于
      With CONFIG_MMU=y get_fs() returns current_thread_info()->addr_limit
      which is initialized as USER_DS (which in turn is defined to TASK_SIZE)
      for userspace processes. At least theoretically
      current_thread_info()->addr_limit is changable by set_fs() to a
      different limit, so checking for KERNEL_DS is more robust.
      
      With !CONFIG_MMU get_fs returns KERNEL_DS. To see what the old variant
      did you'd have to find out that USER_DS == KERNEL_DS which isn't needed
      any more with the variant this patch introduces. So it's a bit easier to
      understand, too.
      
      Also if the limit was changed this limit should be returned, not
      TASK_SIZE.
      Signed-off-by: NUwe Kleine-König <u.kleine-koenig@pengutronix.de>
      83de911c
  24. 26 5月, 2014 1 次提交
  25. 10 2月, 2014 1 次提交
  26. 18 9月, 2013 1 次提交
  27. 10 10月, 2012 1 次提交
    • A
      ARM: warnings in arch/arm/include/asm/uaccess.h · 8e7fc18b
      Arnd Bergmann 提交于
      On NOMMU ARM, the __addr_ok() and __range_ok() macros do not evaluate
      their arguments, which may lead to harmless build warnings in some
      code where the variables are not used otherwise. Adding a cast to void
      gets rid of the warning and does not make any semantic changes.
      
      Without this patch, building at91x40_defconfig results in:
      
      fs/read_write.c: In function 'rw_copy_check_uvector':
      fs/read_write.c:684:9: warning: unused variable 'buf' [-Wunused-variable]
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Acked-by: NGreg Ungerer <gerg@uclinux.org>
      Cc: Russell King <rmk+kernel@arm.linux.org.uk>
      8e7fc18b
  28. 10 9月, 2012 2 次提交
  29. 10 7月, 2012 1 次提交
  30. 29 3月, 2012 1 次提交