Skip to content
  1. Jul 17, 2019
    • Jan Harkes's avatar
      coda: remove uapi/linux/coda_psdev.h · 6dc280eb
      Jan Harkes authored
      
      
      Nothing is left in this header that is used by userspace.
      
      Link: http://lkml.kernel.org/r/bb11378cef94739f2cf89425dd6d302a52c64480.1558117389.git.jaharkes@cs.cmu.edu
      Signed-off-by: default avatarJan Harkes <jaharkes@cs.cmu.edu>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Colin Ian King <colin.king@canonical.com>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Fabian Frederick <fabf@skynet.be>
      Cc: Mikko Rapeli <mikko.rapeli@iki.fi>
      Cc: Sam Protsenko <semen.protsenko@linaro.org>
      Cc: Yann Droneaud <ydroneaud@opteya.com>
      Cc: Zhouyang Jia <jiazhouyang09@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6dc280eb
    • David Howells's avatar
      coda: move internal defs out of include/linux/ [ver #2] · 8fc8b9df
      David Howells authored
      
      
      Move include/linux/coda_psdev.h to fs/coda/ as there's nothing else that
      uses it.
      
      Link: http://lkml.kernel.org/r/3ceeee0415a929b89fb02700b6b4b3a07938acb8.1558117389.git.jaharkes@cs.cmu.edu
      Link: https://patchwork.kernel.org/patch/10590257/
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarJan Harkes <jaharkes@cs.cmu.edu>
      Cc: Yann Droneaud <ydroneaud@opteya.com>
      Cc: Jan Harkes <jaharkes@cs.cmu.edu>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Colin Ian King <colin.king@canonical.com>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Cc: Fabian Frederick <fabf@skynet.be>
      Cc: Mikko Rapeli <mikko.rapeli@iki.fi>
      Cc: Sam Protsenko <semen.protsenko@linaro.org>
      Cc: Zhouyang Jia <jiazhouyang09@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      8fc8b9df
    • Jan Harkes's avatar
      coda: bump module version · b6a18c60
      Jan Harkes authored
      
      
      The out of tree module version had been bumped several times already,
      but we haven't kept this in-tree one in sync, partly because most
      changes go from here to the out-of-tree copy.
      
      Link: http://lkml.kernel.org/r/8b0ab50a2da2f0180ac32c79d91811b4d1d0bd8b.1558117389.git.jaharkes@cs.cmu.edu
      Signed-off-by: default avatarJan Harkes <jaharkes@cs.cmu.edu>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Colin Ian King <colin.king@canonical.com>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Fabian Frederick <fabf@skynet.be>
      Cc: Mikko Rapeli <mikko.rapeli@iki.fi>
      Cc: Sam Protsenko <semen.protsenko@linaro.org>
      Cc: Yann Droneaud <ydroneaud@opteya.com>
      Cc: Zhouyang Jia <jiazhouyang09@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b6a18c60
    • Dan Carpenter's avatar
      coda: get rid of CODA_FREE() · 936dae45
      Dan Carpenter authored
      
      
      The CODA_FREE() macro just calls kvfree().  We can call that directly
      instead.
      
      Link: http://lkml.kernel.org/r/4950a94fd30ec5f84835dd4ca0bb67c0448672f5.1558117389.git.jaharkes@cs.cmu.edu
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarJan Harkes <jaharkes@cs.cmu.edu>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Colin Ian King <colin.king@canonical.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Fabian Frederick <fabf@skynet.be>
      Cc: Mikko Rapeli <mikko.rapeli@iki.fi>
      Cc: Sam Protsenko <semen.protsenko@linaro.org>
      Cc: Yann Droneaud <ydroneaud@opteya.com>
      Cc: Zhouyang Jia <jiazhouyang09@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      936dae45
    • Dan Carpenter's avatar
      coda: get rid of CODA_ALLOC() · 4dc48193
      Dan Carpenter authored
      
      
      These days we have kvzalloc() so we can delete CODA_ALLOC().
      
      I made a couple related changes in coda_psdev_write().  First, I added
      some error handling to avoid a NULL dereference if the allocation
      failed.  Second, I used kvmalloc() instead of kvzalloc() because we copy
      over the memory on the next line so there is no need to zero it first.
      
      Link: http://lkml.kernel.org/r/e56010c822e7a7cbaa8a238cf82ad31c67eaa800.1558117389.git.jaharkes@cs.cmu.edu
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarJan Harkes <jaharkes@cs.cmu.edu>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Colin Ian King <colin.king@canonical.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Fabian Frederick <fabf@skynet.be>
      Cc: Mikko Rapeli <mikko.rapeli@iki.fi>
      Cc: Sam Protsenko <semen.protsenko@linaro.org>
      Cc: Yann Droneaud <ydroneaud@opteya.com>
      Cc: Zhouyang Jia <jiazhouyang09@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4dc48193
    • Jan Harkes's avatar
      coda: change Coda's user api to use 64-bit time_t in timespec · 5e7c31df
      Jan Harkes authored
      
      
      Move the 32-bit time_t problems to userspace.
      
      Link: http://lkml.kernel.org/r/8d089068823bfb292a4020f773922fbd82ffad39.1558117389.git.jaharkes@cs.cmu.edu
      Signed-off-by: default avatarJan Harkes <jaharkes@cs.cmu.edu>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Colin Ian King <colin.king@canonical.com>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Fabian Frederick <fabf@skynet.be>
      Cc: Mikko Rapeli <mikko.rapeli@iki.fi>
      Cc: Sam Protsenko <semen.protsenko@linaro.org>
      Cc: Yann Droneaud <ydroneaud@opteya.com>
      Cc: Zhouyang Jia <jiazhouyang09@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      5e7c31df
    • Arnd Bergmann's avatar
      coda: stop using 'struct timespec' in user API · 6ced9aa7
      Arnd Bergmann authored
      
      
      We exchange file timestamps with user space using psdev device
      read/write operations with a fixed but architecture specific binary
      layout.
      
      On 32-bit systems, this uses a 'timespec' structure that is defined by
      the C library to contain two 32-bit values for seconds and nanoseconds.
      As we get ready for the year 2038 overflow of the 32-bit signed seconds,
      the kernel now uses 64-bit timestamps internally, and user space will do
      the same change by changing the 'timespec' definition in the future.
      
      Unfortunately, this breaks the layout of the coda_vattr structure, so we
      need to redefine that in terms of something that does not change.  I'm
      introducing a new 'struct vtimespec' structure here that keeps the
      existing layout, and the same change has to be done in the coda user
      space copy of linux/coda.h before anyone can use that on a 32-bit
      architecture with 64-bit time_t.
      
      An open question is what should happen to actual times past y2038, as
      they are now truncated to the last valid date when sent to user space,
      and interpreted as pre-1970 times when a timestamp with the MSB set is
      read back into the kernel.  Alternatively, we could change the new
      timespec64_to_coda()/coda_to_timespec64() functions to use a different
      interpretation and extend the available range further to the future by
      disallowing past timestamps.  This would require more changes in the
      user space side though.
      
      Link: http://lkml.kernel.org/r/562b7324149461743e4fbe2fedbf7c242f7e274a.1558117389.git.jaharkes@cs.cmu.edu
      Link: https://patchwork.kernel.org/patch/10474735/
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarJan Harkes <jaharkes@cs.cmu.edu>
      Acked-by: default avatarJan Harkes <jaharkes@cs.cmu.edu>
      Cc: Colin Ian King <colin.king@canonical.com>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Fabian Frederick <fabf@skynet.be>
      Cc: Mikko Rapeli <mikko.rapeli@iki.fi>
      Cc: Sam Protsenko <semen.protsenko@linaro.org>
      Cc: Yann Droneaud <ydroneaud@opteya.com>
      Cc: Zhouyang Jia <jiazhouyang09@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6ced9aa7
    • Colin Ian King's avatar
      coda: clean up indentation, replace spaces with tab · 85062213
      Colin Ian King authored
      
      
      Trivial fix to clean up indentation, replace spaces with tab
      
      Link: http://lkml.kernel.org/r/ffc2bfa5a37ffcdf891c51b2e2ed618103965b24.1558117389.git.jaharkes@cs.cmu.edu
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarJan Harkes <jaharkes@cs.cmu.edu>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Fabian Frederick <fabf@skynet.be>
      Cc: Mikko Rapeli <mikko.rapeli@iki.fi>
      Cc: Sam Protsenko <semen.protsenko@linaro.org>
      Cc: Yann Droneaud <ydroneaud@opteya.com>
      Cc: Zhouyang Jia <jiazhouyang09@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      85062213
    • Jan Harkes's avatar
      uapi linux/coda_psdev.h: move CODA_REQ_ from uapi to kernel side headers · 2fe7491d
      Jan Harkes authored
      
      
      These constants only used internally and not exposed to userspace.
      
      Link: http://lkml.kernel.org/r/baeafc30dad70d8b422ee679420099c2d8aa7da0.1558117389.git.jaharkes@cs.cmu.edu
      Signed-off-by: default avatarJan Harkes <jaharkes@cs.cmu.edu>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Colin Ian King <colin.king@canonical.com>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Fabian Frederick <fabf@skynet.be>
      Cc: Mikko Rapeli <mikko.rapeli@iki.fi>
      Cc: Sam Protsenko <semen.protsenko@linaro.org>
      Cc: Yann Droneaud <ydroneaud@opteya.com>
      Cc: Zhouyang Jia <jiazhouyang09@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      2fe7491d
    • Jan Harkes's avatar
      coda: don't try to print names that were considered too long · 9a05671d
      Jan Harkes authored
      
      
      Probably safer to just show the unexpected length and debug it from the
      userspace side.
      
      Link: http://lkml.kernel.org/r/582ae759a4fdfa31a64c35de489fa4efabac09d6.1558117389.git.jaharkes@cs.cmu.edu
      Signed-off-by: default avatarJan Harkes <jaharkes@cs.cmu.edu>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Colin Ian King <colin.king@canonical.com>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Fabian Frederick <fabf@skynet.be>
      Cc: Mikko Rapeli <mikko.rapeli@iki.fi>
      Cc: Sam Protsenko <semen.protsenko@linaro.org>
      Cc: Yann Droneaud <ydroneaud@opteya.com>
      Cc: Zhouyang Jia <jiazhouyang09@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9a05671d
    • Sam Protsenko's avatar
      coda: fix build using bare-metal toolchain · b2a57e33
      Sam Protsenko authored
      
      
      The kernel is self-contained project and can be built with bare-metal
      toolchain.  But bare-metal toolchain doesn't define __linux__.  Because
      of this u_quad_t type is not defined when using bare-metal toolchain and
      codafs build fails.  This patch fixes it by defining u_quad_t type
      unconditionally.
      
      Link: http://lkml.kernel.org/r/3cbb40b0a57b6f9923a9d67b53473c0b691a3eaa.1558117389.git.jaharkes@cs.cmu.edu
      Signed-off-by: default avatarSam Protsenko <semen.protsenko@linaro.org>
      Signed-off-by: default avatarJan Harkes <jaharkes@cs.cmu.edu>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Colin Ian King <colin.king@canonical.com>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Fabian Frederick <fabf@skynet.be>
      Cc: Mikko Rapeli <mikko.rapeli@iki.fi>
      Cc: Yann Droneaud <ydroneaud@opteya.com>
      Cc: Zhouyang Jia <jiazhouyang09@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b2a57e33
    • Jan Harkes's avatar
      coda: potential buffer overflow in coda_psdev_write() · 6e51f8aa
      Jan Harkes authored
      
      
      Add checks to make sure the downcall message we got from the Coda cache
      manager is large enough to contain the data it is supposed to have.
      i.e.  when we get a CODA_ZAPDIR we can access &out->coda_zapdir.CodaFid.
      
      Link: http://lkml.kernel.org/r/894fb6b250add09e4e3935f14649f21284a5cb18.1558117389.git.jaharkes@cs.cmu.edu
      Signed-off-by: default avatarJan Harkes <jaharkes@cs.cmu.edu>
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Colin Ian King <colin.king@canonical.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Fabian Frederick <fabf@skynet.be>
      Cc: Mikko Rapeli <mikko.rapeli@iki.fi>
      Cc: Sam Protsenko <semen.protsenko@linaro.org>
      Cc: Yann Droneaud <ydroneaud@opteya.com>
      Cc: Zhouyang Jia <jiazhouyang09@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6e51f8aa
    • Zhouyang Jia's avatar
      coda: add error handling for fget · 02551c23
      Zhouyang Jia authored
      
      
      When fget fails, the lack of error-handling code may cause unexpected
      results.
      
      This patch adds error-handling code after calling fget.
      
      Link: http://lkml.kernel.org/r/2514ec03df9c33b86e56748513267a80dd8004d9.1558117389.git.jaharkes@cs.cmu.edu
      Signed-off-by: default avatarZhouyang Jia <jiazhouyang09@gmail.com>
      Signed-off-by: default avatarJan Harkes <jaharkes@cs.cmu.edu>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Colin Ian King <colin.king@canonical.com>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Fabian Frederick <fabf@skynet.be>
      Cc: Mikko Rapeli <mikko.rapeli@iki.fi>
      Cc: Sam Protsenko <semen.protsenko@linaro.org>
      Cc: Yann Droneaud <ydroneaud@opteya.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      02551c23
    • Mikko Rapeli's avatar
      uapi linux/coda_psdev.h: move upc_req definition from uapi to kernel side headers · f90fb3c7
      Mikko Rapeli authored
      
      
      Only users of upc_req in kernel side fs/coda/psdev.c and
      fs/coda/upcall.c already include linux/coda_psdev.h.
      
      Suggested by Jan Harkes <jaharkes@cs.cmu.edu> in
        https://lore.kernel.org/lkml/20150531111913.GA23377@cs.cmu.edu/
      
      Fixes these include/uapi/linux/coda_psdev.h compilation errors in userspace:
      
        linux/coda_psdev.h:12:19: error: field `uc_chain' has incomplete type
        struct list_head    uc_chain;
                         ^
        linux/coda_psdev.h:13:2: error: unknown type name `caddr_t'
        caddr_t             uc_data;
        ^
        linux/coda_psdev.h:14:2: error: unknown type name `u_short'
        u_short             uc_flags;
        ^
        linux/coda_psdev.h:15:2: error: unknown type name `u_short'
        u_short             uc_inSize;  /* Size is at most 5000 bytes */
        ^
        linux/coda_psdev.h:16:2: error: unknown type name `u_short'
        u_short             uc_outSize;
        ^
        linux/coda_psdev.h:17:2: error: unknown type name `u_short'
        u_short             uc_opcode;  /* copied from data to save lookup */
        ^
        linux/coda_psdev.h:19:2: error: unknown type name `wait_queue_head_t'
        wait_queue_head_t   uc_sleep;   /* process' wait queue */
        ^
      
      Link: http://lkml.kernel.org/r/9f99f5ce6a0563d5266e6cf7aa9585aac2cae971.1558117389.git.jaharkes@cs.cmu.edu
      Signed-off-by: default avatarMikko Rapeli <mikko.rapeli@iki.fi>
      Signed-off-by: default avatarJan Harkes <jaharkes@cs.cmu.edu>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Colin Ian King <colin.king@canonical.com>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Fabian Frederick <fabf@skynet.be>
      Cc: Sam Protsenko <semen.protsenko@linaro.org>
      Cc: Yann Droneaud <ydroneaud@opteya.com>
      Cc: Zhouyang Jia <jiazhouyang09@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f90fb3c7
    • Mikko Rapeli's avatar
      uapi linux/coda.h: use __kernel_pid_t for userspace · 694a58e2
      Mikko Rapeli authored
      
      
      Part of a patch by Mikko Rapeli, as Arnd Bergman commented on the
      original patch.
      
         pid_t might differ between libc and the kernel, so the kernel
         interface has to use types that the kernel defines.
      
      Link: http://lkml.kernel.org/r/f374a71f4d351bc8c8b3ac18ad7765c88d806d10.1558117389.git.jaharkes@cs.cmu.edu
      Signed-off-by: default avatarMikko Rapeli <mikko.rapeli@iki.fi>
      Signed-off-by: default avatarJan Harkes <jaharkes@cs.cmu.edu>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Colin Ian King <colin.king@canonical.com>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Fabian Frederick <fabf@skynet.be>
      Cc: Sam Protsenko <semen.protsenko@linaro.org>
      Cc: Yann Droneaud <ydroneaud@opteya.com>
      Cc: Zhouyang Jia <jiazhouyang09@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      694a58e2
    • Jan Harkes's avatar
      coda: pass the host file in vma->vm_file on mmap · 7fa0a1da
      Jan Harkes authored
      
      
      Patch series "Coda updates".
      
      The following patch series is a collection of various fixes for Coda,
      most of which were collected from linux-fsdevel or linux-kernel but
      which have as yet not found their way upstream.
      
      This patch (of 22):
      
      Various file systems expect that vma->vm_file points at their own file
      handle, several use file_inode(vma->vm_file) to get at their inode or
      use vma->vm_file->private_data.  However the way Coda wrapped mmap on a
      host file broke this assumption, vm_file was still pointing at the Coda
      file and the host file systems would scribble over Coda's inode and
      private file data.
      
      This patch fixes the incorrect expectation and wraps vm_ops->open and
      vm_ops->close to allow Coda to track when the vm_area_struct is
      destroyed so we still release the reference on the Coda file handle at
      the right time.
      
      Link: http://lkml.kernel.org/r/0e850c6e59c0b147dc2dcd51a3af004c948c3697.1558117389.git.jaharkes@cs.cmu.edu
      Signed-off-by: default avatarJan Harkes <jaharkes@cs.cmu.edu>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Colin Ian King <colin.king@canonical.com>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Fabian Frederick <fabf@skynet.be>
      Cc: Mikko Rapeli <mikko.rapeli@iki.fi>
      Cc: Sam Protsenko <semen.protsenko@linaro.org>
      Cc: Yann Droneaud <ydroneaud@opteya.com>
      Cc: Zhouyang Jia <jiazhouyang09@gmail.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      7fa0a1da
    • Anshuman Khandual's avatar
      mm, kprobes: generalize and rename notify_page_fault() as kprobe_page_fault() · b98cca44
      Anshuman Khandual authored
      Architectures which support kprobes have very similar boilerplate around
      calling kprobe_fault_handler().  Use a helper function in kprobes.h to
      unify them, based on the x86 code.
      
      This changes the behaviour for other architectures when preemption is
      enabled.  Previously, they would have disabled preemption while calling
      the kprobe handler.  However, preemption would be disabled if this fault
      was due to a kprobe, so we know the fault was not due to a kprobe
      handler and can simply return failure.
      
      This behaviour was introduced in commit a980c0ef
      
       ("x86/kprobes:
      Refactor kprobes_fault() like kprobe_exceptions_notify()")
      
      [anshuman.khandual@arm.com: export kprobe_fault_handler()]
        Link: http://lkml.kernel.org/r/1561133358-8876-1-git-send-email-anshuman.khandual@arm.com
      Link: http://lkml.kernel.org/r/1560420444-25737-1-git-send-email-anshuman.khandual@arm.com
      Signed-off-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
      Reviewed-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Christophe Leroy <christophe.leroy@c-s.fr>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Cc: Andrey Konovalov <andreyknvl@google.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Vineet Gupta <vgupta@synopsys.com>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Paul Burton <paul.burton@mips.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b98cca44
    • Kees Cook's avatar
      init/Kconfig: fix neighboring typos · 92bae787
      Kees Cook authored
      
      
      This fixes a couple typos I noticed in the slab Kconfig:
      
      	sacrifies -> sacrifices
      	accellerate -> accelerate
      
      Seeing as no other instances of these typos are found elsewhere in the
      kernel and that I originally added one of the two, I can only assume
      working on slab must have caused damage to the spelling centers of my
      brain.
      
      Link: http://lkml.kernel.org/r/201905292203.CD000546EB@keescook
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      92bae787
    • Alexey Dobriyan's avatar
      fs/binfmt_elf.c: delete stale comment · aa94b1dc
      Alexey Dobriyan authored
      "passed_fileno" variable was deleted 11 years ago in 2.6.25.
      
      Link: http://lkml.kernel.org/r/20190529201747.GA23248@avx2
      Fixes: d20894a2
      
       ("Remove a.out interpreter support in ELF loader")
      Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      aa94b1dc
    • YueHaibing's avatar
      fs/binfmt_flat.c: remove set but not used variable 'inode' · 1b113e04
      YueHaibing authored
      
      
      Fixes gcc '-Wunused-but-set-variable' warning:
      
        fs/binfmt_flat.c: In function load_flat_file:
        fs/binfmt_flat.c:419:16: warning: variable inode set but not used [-Wunused-but-set-variable]
      
      It's never used and can be removed.
      
      Link: http://lkml.kernel.org/r/20190525125341.9844-1-yuehaibing@huawei.com
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      1b113e04
    • Matteo Croce's avatar
      checkpatch.pl: warn on duplicate sysctl local variable · 6a8d76cb
      Matteo Croce authored
      
      
      Commit d91bff3011cf ("proc/sysctl: add shared variables for range
      check") adds some shared const variables to be used instead of a local
      copy in each source file.  Warn when a chunk duplicates one of these
      values in a ctl_table struct:
      
          $ scripts/checkpatch.pl 0001-test-commit.patch
          WARNING: duplicated sysctl range checking value 'zero', consider using the shared one in include/linux/sysctl.h
          #27: FILE: arch/arm/kernel/isa.c:48:
          +               .extra1         = &zero,
      
          WARNING: duplicated sysctl range checking value 'int_max', consider using the shared one in include/linux/sysctl.h
          #28: FILE: arch/arm/kernel/isa.c:49:
          +               .extra2         = &int_max,
      
          total: 0 errors, 2 warnings, 14 lines checked
      
      Link: http://lkml.kernel.org/r/20190531131422.14970-1-mcroce@redhat.com
      Signed-off-by: default avatarMatteo Croce <mcroce@redhat.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Joe Perches <joe@perches.com>
      Cc: Aaron Tomlin <atomlin@redhat.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6a8d76cb
    • Michel Lespinasse's avatar
      lib/rbtree: avoid generating code twice for the cached versions · 9f973cb3
      Michel Lespinasse authored
      
      
      As was already noted in rbtree.h, the logic to cache rb_first (or
      rb_last) can easily be implemented externally to the core rbtree api.
      
      Change the implementation to do just that.  Previously the update of
      rb_leftmost was wired deeper into the implmentation, but there were some
      disadvantages to that - mostly, lib/rbtree.c had separate instantiations
      for rb_insert_color() vs rb_insert_color_cached(), as well as rb_erase()
      vs rb_erase_cached(), which were doing exactly the same thing save for
      the rb_leftmost update at the start of either function.
      
         text	   data	    bss	    dec	    hex	filename
         5405	    120	      0	   5525	   1595	lib/rbtree.o-vanilla
         3827	     96	      0	   3923	    f53	lib/rbtree.o-patch
      
      [dave@stgolabs.net: changelog addition]
        Link: http://lkml.kernel.org/r/20190628171416.by5gdizl3rcxk5h5@linux-r8p5
      [akpm@linux-foundation.org: coding-style fixes]
      Link: http://lkml.kernel.org/r/20190628045008.39926-1-walken@google.com
      Signed-off-by: default avatarMichel Lespinasse <walken@google.com>
      Acked-by: default avatarDavidlohr Bueso <dbueso@suse.de>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9f973cb3
    • Alexander Potapenko's avatar
      lib/test_meminit.c: minor test fixes · 4ab7ace4
      Alexander Potapenko authored
      
      
      Fix the following issues in test_meminit.c:
       - |size| in fill_with_garbage_skip() should be signed so that it
         doesn't overflow if it's not aligned on sizeof(*p);
       - fill_with_garbage_skip() should actually skip |skip| bytes;
       - do_kmem_cache_size() should deallocate memory in the RCU case.
      
      Link: http://lkml.kernel.org/r/20190626133135.217355-1-glider@google.com
      Fixes: 7e659650cbda ("lib: introduce test_meminit module")
      Fixes: 94e8988d91c7 ("lib/test_meminit.c: fix -Wmaybe-uninitialized false positive")
      Signed-off-by: default avatarAlexander Potapenko <glider@google.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Kees Cook <keescook@chromium.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4ab7ace4
    • Arnd Bergmann's avatar
      lib/test_meminit.c: fix -Wmaybe-uninitialized false positive · d3a81161
      Arnd Bergmann authored
      
      
      The conditional logic is too complicated for the compiler to fully
      comprehend:
      
        lib/test_meminit.c: In function 'test_meminit_init':
        lib/test_meminit.c:236:5: error: 'buf_copy' may be used uninitialized in this function [-Werror=maybe-uninitialized]
             kfree(buf_copy);
             ^~~~~~~~~~~~~~~
        lib/test_meminit.c:201:14: note: 'buf_copy' was declared here
      
      Simplify it by splitting out the non-rcu section.
      
      Link: http://lkml.kernel.org/r/20190617131210.2190280-1-arnd@arndb.de
      Fixes: af734ee6ec85 ("lib: introduce test_meminit module")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Acked-by: default avatarAlexander Potapenko <glider@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d3a81161
    • Jonathan Corbet's avatar
      lib/string_helpers: fix some kerneldoc warnings · b4658cdd
      Jonathan Corbet authored
      
      
      Due to some sad limitations in how kerneldoc comments are parsed, the
      documentation in lib/string_helpers.c generates these warnings:
      
        lib/string_helpers.c:236: WARNING: Unexpected indentation.
        lib/string_helpers.c:241: WARNING: Block quote ends without a blank line; unexpected unindent.
        lib/string_helpers.c:446: WARNING: Unexpected indentation.
        lib/string_helpers.c:451: WARNING: Block quote ends without a blank line; unexpected unindent.
        lib/string_helpers.c:474: WARNING: Unexpected indentation.
      
      Rework the comments to obtain something like the desired result.
      
      Link: http://lkml.kernel.org/r/20190607110952.409011ba@lwn.net
      Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b4658cdd
    • Anshuman Khandual's avatar
      mm/ioremap: probe platform for p4d huge map support · 0f472d04
      Anshuman Khandual authored
      Finish up what commit c2febafc
      
       ("mm: convert generic code to 5-level
      paging") started while levelling up P4D huge mapping support at par with
      PUD and PMD.  A new arch call back arch_ioremap_p4d_supported() is added
      which just maintains status quo (P4D huge map not supported) on x86,
      arm64 and powerpc.
      
      When HAVE_ARCH_HUGE_VMAP is enabled its just a simple check from the
      arch about the support, hence runtime effects are minimal.
      
      Link: http://lkml.kernel.org/r/1561699231-20991-1-git-send-email-anshuman.khandual@arm.com
      Signed-off-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
      Acked-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Kirill A. Shutemov <kiril...
      0f472d04
    • Anshuman Khandual's avatar
      mm/ioremap: check virtual address alignment while creating huge mappings · 6b95ab42
      Anshuman Khandual authored
      
      
      Virtual address alignment is essential in ensuring correct clearing for
      all intermediate level pgtable entries and freeing associated pgtable
      pages.  An unaligned address can end up randomly freeing pgtable page
      that potentially still contains valid mappings.  Hence also check it's
      alignment along with existing phys_addr check.
      
      Signed-off-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
      Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Cc: Toshi Kani <toshi.kani@hpe.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Chintan Pandya <cpandya@codeaurora.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6b95ab42
    • Alexander Potapenko's avatar
      lib: introduce test_meminit module · 5015a300
      Alexander Potapenko authored
      
      
      Add tests for heap and pagealloc initialization.  These can be used to
      check init_on_alloc and init_on_free implementations as well as other
      approaches to initialization.
      
      Expected test output in the case the kernel provides heap initialization
      (e.g.  when running with either init_on_alloc=1 or init_on_free=1):
      
        test_meminit: all 10 tests in test_pages passed
        test_meminit: all 40 tests in test_kvmalloc passed
        test_meminit: all 60 tests in test_kmemcache passed
        test_meminit: all 10 tests in test_rcu_persistent passed
        test_meminit: all 120 tests passed!
      
      Link: http://lkml.kernel.org/r/20190529123812.43089-4-glider@google.com
      Signed-off-by: default avatarAlexander Potapenko <glider@google.com>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Kostya Serebryany <kcc@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Sandeep Patil <sspatil@android.com>
      Cc: Laura Abbott <labbott@redhat.com>
      Cc: Jann Horn <jannh@google.com>
      Cc: Marco Elver <elver@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      5015a300
    • Kees Cook's avatar
      lib/test_overflow.c: avoid tainting the kernel and fix wrap size · 8e060c21
      Kees Cook authored
      This adds __GFP_NOWARN to the kmalloc()-portions of the overflow test to
      avoid tainting the kernel.  Additionally fixes up the math on wrap size
      to be architecture and page size agnostic.
      
      Link: http://lkml.kernel.org/r/201905282012.0A8767E24@keescook
      Fixes: ca90800a
      
       ("test_overflow: Add memory allocation overflow tests")
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Reported-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Suggested-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: Joe Perches <joe@perches.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      8e060c21
    • Peter Rosin's avatar
      lib/test_string.c: add some testcases for strchr and strnchr · d1a5dc5e
      Peter Rosin authored
      
      
      Make sure that the trailing NUL is considered part of the string and can
      be found.
      
      Link: http://lkml.kernel.org/r/20190506124634.6807-4-peda@axentia.se
      Signed-off-by: default avatarPeter Rosin <peda@axentia.se>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d1a5dc5e
    • Peter Rosin's avatar
      lib/test_string.c: avoid masking memset16/32/64 failures · 33d6e0ff
      Peter Rosin authored
      If a memsetXX implementation is completely broken and fails in the first
      iteration, when i, j, and k are all zero, the failure is masked as zero
      is returned.  Failing in the first iteration is perhaps the most likely
      failure, so this makes the tests pretty much useless.  Avoid the
      situation by always setting a random unused bit in the result on
      failure.
      
      Link: http://lkml.kernel.org/r/20190506124634.6807-3-peda@axentia.se
      Fixes: 03270c13
      
       ("lib/string.c: add testcases for memset16/32/64")
      Signed-off-by: default avatarPeter Rosin <peda@axentia.se>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      33d6e0ff
    • Peter Rosin's avatar
      lib/string.c: allow searching for NUL with strnchr · b0975710
      Peter Rosin authored
      
      
      Patch series "lib/string: search for NUL with strchr/strnchr".
      
      I noticed an inconsistency where strchr and strnchr do not behave the
      same with respect to the trailing NUL.  strchr is standardised and the
      kernel function conforms, and the kernel relies on the behavior.  So,
      naturally strchr stays as-is and strnchr is what I change.
      
      While writing a few tests to verify that my new strnchr loop was sane, I
      noticed that the tests for memset16/32/64 had a problem.  Since it's all
      about the lib/string.c file I made a short series of it all...
      
      This patch (of 3):
      
      strchr considers the terminating NUL to be part of the string, and NUL
      can thus be searched for with that function.  For consistency, do the
      same with strnchr.
      
      Link: http://lkml.kernel.org/r/20190506124634.6807-2-peda@axentia.se
      Signed-off-by: default avatarPeter Rosin <peda@axentia.se>
      Cc: Matthew Wilcox <willy@infradead.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: Linus Torvalds <...
      b0975710
    • Alexey Dobriyan's avatar
      lib/list: tweak LIST_POISON2 for better code generation on x86_64 · 4c6080cd
      Alexey Dobriyan authored
      
      
      list_del() poisoning can generate 2 64-bit immediate loads but it also can
      generate one 64-bit immediate load and an addition:
      
      	48 b8 00 01 00 00 00 00 ad de	movabs rax,0xdead000000000100
      	48 89 47 58			mov    QWORD PTR [rdi+0x58],rax
      	48 05 00 01 00 00   <=====>	add    rax,0x100
      	48 89 47 60			mov    QWORD PTR [rdi+0x60],rax
      
      However on x86_64 not all constants are equal: those within [-128, 127]
      range can be added with shorter "add r64, imm32" instruction:
      
      	48 b8 00 01 00 00 00 00 ad de	movabs rax,0xdead000000000100
      	48 89 47 58			mov    QWORD PTR [rdi+0x58],rax
      	48 83 c0 22	<======>	add    rax,0x22
      	48 89 47 60			mov    QWORD PTR [rdi+0x60],rax
      
      Patch saves 2 bytes per some LIST_POISON2 usage.
      
      (Slightly disappointing) space savings on F29 x86_64 config:
      
      	add/remove: 0/0 grow/shrink: 0/2164 up/down: 0/-5184 (-5184)
      	Function                                     old     new   delta
      	zstd_get_workspace                           548     546      -2
      		...
      	mlx4_delete_all_resources_for_slave         4826    4804     -22
      	Total: Before=83304131, After=83298947, chg -0.01%
      
      New constants are:
      
      	0xdead000000000100
      	0xdead000000000122
      
      Note: LIST_POISON1 can't be changed to ...11 because something in page
      allocator requires low bit unset.
      
      Link: http://lkml.kernel.org/r/20190513191502.GA8492@avx2
      Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
      Cc: Vasiliy Kulikov <segoon@openwall.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4c6080cd
    • Joe Perches's avatar
      get_maintainer: add ability to skip moderated mailing lists · 49662503
      Joe Perches authored
      
      
      Add a command line switch --no-moderated to skip L: mailing lists marked
      with 'moderated'.
      
      Some people prefer not emailing moderated mailing lists as the
      moderation time can be indeterminate and some emails can be
      intentionally dropped by a moderator.
      
      This can cause fragmentation of email threads when some are subscribed
      to a moderated list but others are not and emails are dropped.
      
      Link: http://lkml.kernel.org/r/6f23c2918ad9fc744269feb8f909bdfb105c5afc.camel@perches.com
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
      Tested-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      49662503
    • Qian Cai's avatar
      asm-generic: fix a compilation warning · c296d4dc
      Qian Cai authored
      
      
      Fix this compilation warning on x86 by making flush_cache_vmap() inline.
      
        lib/ioremap.c: In function 'ioremap_page_range':
        lib/ioremap.c:214:16: warning: variable 'start' set but not used [-Wunused-but-set-variable]
          unsigned long start;
                        ^~~~~
      
      While at it, convert all other similar functions to inline for
      consistency.
      
      Link: http://lkml.kernel.org/r/1562594592-15228-1-git-send-email-cai@lca.pw
      Signed-off-by: default avatarQian Cai <cai@lca.pw>
      Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      c296d4dc
    • Stephen Kitt's avatar
      arch/*: remove unused isa_page_to_bus() · 3a7f0adf
      Stephen Kitt authored
      
      
      isa_page_to_bus() is deprecated and is no longer used anywhere.  Remove
      it entirely.
      
      Link: http://lkml.kernel.org/r/20190613161155.16946-1-steve@sk2.org
      Signed-off-by: default avatarStephen Kitt <steve@sk2.org>
      Acked-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      3a7f0adf
    • Masahiro Yamada's avatar
      arch: replace _BITUL() in kernel-space headers with BIT() · fe6ba88b
      Masahiro Yamada authored
      
      
      Now that BIT() can be used from assembly code, we can safely replace
      _BITUL() with equivalent BIT().
      
      UAPI headers are still required to use _BITUL(), but there is no more
      reason to use it in kernel headers.  BIT() is shorter.
      
      Link: http://lkml.kernel.org/r/20190609153941.17249-2-yamada.masahiro@socionext.com
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Vineet Gupta <vgupta@synopsys.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      fe6ba88b
    • Masahiro Yamada's avatar
      linux/bits.h: make BIT(), GENMASK(), and friends available in assembly · 95b980d6
      Masahiro Yamada authored
      
      
      BIT(),  GENMASK(), etc. are useful to define register bits of hardware.
      However, low-level code is often written in assembly, where they are
      not available due to the hard-coded 1UL, 0UL.
      
      In fact, in-kernel headers such as arch/arm64/include/asm/sysreg.h
      use _BITUL() instead of BIT() so that the register bit macros are
      available in assembly.
      
      Using macros in include/uapi/linux/const.h have two reasons:
      
      [1] For use in uapi headers
        We should use underscore-prefixed variants for user-space.
      
      [2] For use in assembly code
        Since _BITUL() uses UL(1) instead of 1UL, it can be used as an
        alternative of BIT().
      
      For [2], it is pretty easy to change BIT() etc. for use in assembly.
      
      This allows to replace _BUTUL() in kernel-space headers with BIT().
      
      Link: http://lkml.kernel.org/r/20190609153941.17249-1-yamada.masahiro@socionext.com
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@synopsys.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      95b980d6
    • Weitao Hou's avatar
      kernel: fix typos and some coding style in comments · 65f50f25
      Weitao Hou authored
      
      
      fix lenght to length
      
      Link: http://lkml.kernel.org/r/20190521050937.4370-1-houweitaoo@gmail.com
      Signed-off-by: default avatarWeitao Hou <houweitaoo@gmail.com>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Colin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      65f50f25
    • Radoslaw Burny's avatar
      fs/proc/proc_sysctl.c: fix the default values of i_uid/i_gid on /proc/sys inodes. · 5ec27ec7
      Radoslaw Burny authored
      Normally, the inode's i_uid/i_gid are translated relative to s_user_ns,
      but this is not a correct behavior for proc.  Since sysctl permission
      check in test_perm is done against GLOBAL_ROOT_[UG]ID, it makes more
      sense to use these values in u_[ug]id of proc inodes.  In other words:
      although uid/gid in the inode is not read during test_perm, the inode
      logically belongs to the root of the namespace.  I have confirmed this
      with Eric Biederman at LPC and in this thread:
        https://lore.kernel.org/lkml/87k1kzjdff.fsf@xmission.com
      
      Consequences
      ============
      
      Since the i_[ug]id values of proc nodes are not used for permissions
      checks, this change usually makes no functional difference.  However, it
      causes an issue in a setup where:
      
       * a namespace container is created without root user in container -
         hence the i_[ug]id of proc nodes are set to INVALID_[UG]ID
      
       * container creator tries to configure it by writing /proc/sys files,
         e.g. writing /proc/sys/kernel/shmmax to configure shared memory limit
      
      Kernel does not allow to open an inode for writing if its i_[ug]id are
      invalid, making it impossible to write shmmax and thus - configure the
      container.
      
      Using a container with no root mapping is apparently rare, but we do use
      this configuration at Google.  Also, we use a generic tool to configure
      the container limits, and the inability to write any of them causes a
      failure.
      
      History
      =======
      
      The invalid uids/gids in inodes first appeared due to 81754357 (fs:
      Update i_[ug]id_(read|write) to translate relative to s_user_ns).
      However, AFAIK, this did not immediately cause any issues.  The
      inability to write to these "invalid" inodes was only caused by a later
      commit 0bd23d09 (vfs: Don't modify inodes with a uid or gid unknown
      to the vfs).
      
      Tested: Used a repro program that creates a user namespace without any
      mapping and stat'ed /proc/$PID/root/proc/sys/kernel/shmmax from outside.
      Before the change, it shows the overflow uid, with the change it's 0.
      The overflow uid indicates that the uid in the inode is not correct and
      thus it is not possible to open the file for writing.
      
      Link: http://lkml.kernel.org/r/20190708115130.250149-1-rburny@google.com
      Fixes: 0bd23d09
      
       ("vfs: Don't modify inodes with a uid or gid unknown to the vfs")
      Signed-off-by: default avatarRadoslaw Burny <rburny@google.com>
      Acked-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: "Eric W . Biederman" <ebiederm@xmission.com>
      Cc: Seth Forshee <seth.forshee@canonical.com>
      Cc: John Sperbeck <jsperbeck@google.com>
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Cc: <stable@vger.kernel.org>	[4.8+]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      5ec27ec7