Skip to content
  1. Dec 16, 2017
  2. Dec 15, 2017
    • Ingo Molnar's avatar
      tools/headers: Synchronize kernel <-> tooling headers · 643e345c
      Ingo Molnar authored
      
      
      Two kernel headers got modified recently, which are used by tooling as well:
      
       tools/include/uapi/linux/kvm.h
       arch/x86/include/asm/cpufeatures.h
      
      None of those changes have an effect on tooling, so do a plain copy.
      
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      643e345c
    • Linus Torvalds's avatar
      Merge tag 'pm-4.15-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm · 032b4cc8
      Linus Torvalds authored
      Pull power management fix from Rafael Wysocki:
       "This fixes an issue in two recent commits that may cause
        pm_runtime_enable() to be called for too many times for some devices
        during the "thaw" transition belonging to hibernation"
      
      * tag 'pm-4.15-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
        PM / sleep: Avoid excess pm_runtime_enable() calls in device_resume()
      032b4cc8
    • Linus Torvalds's avatar
      Merge tag 'trace-v4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace · 04243787
      Linus Torvalds authored
      Pull tracing fixes from Steven Rostedt:
       "Various fix-ups:
      
         - comment fixes
      
         - build fix
      
         - better memory alloction (don't use NR_CPUS)
      
         - configuration fix
      
         - build warning fix
      
         - enhanced callback parameter (to simplify users of trace hooks)
      
         - give up on stack tracing when RCU isn't watching (it's a lost
           cause)"
      
      * tag 'trace-v4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
        tracing: Have stack trace not record if RCU is not watching
        tracing: Pass export pointer as argument to ->write()
        ring-buffer: Remove unused function __rb_data_page_index()
        tracing: make PREEMPTIRQ_EVENTS depend on TRACING
        tracing: Allocate mask_str buffer dynamically
        tracing: always define trace_{irq,preempt}_{enable_disable}
        tracing: Fix code comments in trace.c
      04243787
    • Steven Rostedt (VMware)'s avatar
      tracing: Have stack trace not record if RCU is not watching · b00d607b
      Steven Rostedt (VMware) authored
      
      
      The stack tracer records a stack dump whenever it sees a stack usage that is
      more than what it ever saw before. This can happen at any function that is
      being traced. If it happens when the CPU is going idle (or other strange
      locations), RCU may not be watching, and in this case, the recording of the
      stack trace will trigger a warning. There's been lots of efforts to make
      hacks to allow stack tracing to proceed even if RCU is not watching, but
      this only causes more issues to appear. Simply do not trace a stack if RCU
      is not watching. It probably isn't a bad stack anyway.
      
      Acked-by: default avatar"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      b00d607b
    • Linus Torvalds's avatar
      Merge tag 'pci-v4.15-fixes-1' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci · c4f988ee
      Linus Torvalds authored
      Pull PCI fixes from Bjorn Helgaas:
      
       - add a pci_get_domain_bus_and_slot() stub for the CONFIG_PCI=n case to
         avoid build breakage in the v4.16 merge window if a
         pci_get_bus_and_slot() -> pci_get_domain_bus_and_slot() patch gets
         merged before the PCI tree (Randy Dunlap)
      
       - fix an AMD boot regression in the 64bit BAR support added in v4.15
         (Christian König)
      
       - fix an R-Car use-after-free that causes a crash if no PCIe card is
         present (Geert Uytterhoeven)
      
      * tag 'pci-v4.15-fixes-1' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci:
        PCI: rcar: Fix use-after-free in probe error path
        x86/PCI: Only enable a 64bit BAR on single-socket AMD Family 15h
        x86/PCI: Fix infinite loop in search for 64bit BAR placement
        PCI: Add pci_get_domain_bus_and_slot() stub
      c4f988ee
    • Linus Torvalds's avatar
      Merge branch 'akpm' (patches from Andrew) · 18d40eae
      Linus Torvalds authored
      Merge misc fixes from Andrew Morton:
       "17 fixes"
      
      * emailed patches from Andrew Morton <akpm@linux-foundation.org>:
        arch: define weak abort()
        mm, oom_reaper: fix memory corruption
        kernel: make groups_sort calling a responsibility group_info allocators
        mm/frame_vector.c: release a semaphore in 'get_vaddr_frames()'
        tools/slabinfo-gnuplot: force to use bash shell
        kcov: fix comparison callback signature
        mm/slab.c: do not hash pointers when debugging slab
        mm/page_alloc.c: avoid excessive IRQ disabled times in free_unref_page_list()
        mm/memory.c: mark wp_huge_pmd() inline to prevent build failure
        scripts/faddr2line: fix CROSS_COMPILE unset error
        Documentation/vm/zswap.txt: update with same-value filled page feature
        exec: avoid gcc-8 warning for get_task_comm
        autofs: fix careless error in recent commit
        string.h: workaround for increased stack usage
        mm/kmemleak.c: make cond_resched() rate-limiting more efficient
        lib/rbtree,drm/mm: add rbtree_replace_node_cached()
        include/linux/idr.h: add #include <linux/bug.h>
      18d40eae
    • Sudip Mukherjee's avatar
      arch: define weak abort() · 7c2c11b2
      Sudip Mukherjee authored
      gcc toggle -fisolate-erroneous-paths-dereference (default at -O2
      onwards) isolates faulty code paths such as null pointer access, divide
      by zero etc.  If gcc port doesnt implement __builtin_trap, an abort() is
      generated which causes kernel link error.
      
      In this case, gcc is generating abort due to 'divide by zero' in
      lib/mpi/mpih-div.c.
      
      Currently 'frv' and 'arc' are failing.  Previously other arch was also
      broken like m32r was fixed by commit d22e3d69
      
       ("m32r: fix build
      failure").
      
      Let's define this weak function which is common for all arch and fix the
      problem permanently.  We can even remove the arch specific 'abort' after
      this is done.
      
      Link: http://lkml.kernel.org/r/1513118956-8718-1-git-send-email-sudipm.mukherjee@gmail.com
      Signed-off-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Cc: Alexey Brodkin <Alexey.Brodkin@synopsys.com>
      Cc: Vineet Gupta <Vineet.Gupta1@synopsys.com>
      Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      7c2c11b2
    • Michal Hocko's avatar
      mm, oom_reaper: fix memory corruption · 4837fe37
      Michal Hocko authored
      David Rientjes has reported the following memory corruption while the
      oom reaper tries to unmap the victims address space
      
        BUG: Bad page map in process oom_reaper  pte:6353826300000000 pmd:00000000
        addr:00007f50cab1d000 vm_flags:08100073 anon_vma:ffff9eea335603f0 mapping:          (null) index:7f50cab1d
        file:          (null) fault:          (null) mmap:          (null) readpage:          (null)
        CPU: 2 PID: 1001 Comm: oom_reaper
        Call Trace:
           unmap_page_range+0x1068/0x1130
           __oom_reap_task_mm+0xd5/0x16b
           oom_reaper+0xff/0x14c
           kthread+0xc1/0xe0
      
      Tetsuo Handa has noticed that the synchronization inside exit_mmap is
      insufficient.  We only synchronize with the oom reaper if
      tsk_is_oom_victim which is not true if the final __mmput is called from
      a different context than the oom victim exit path.  This can trivially
      happen from context of any task which has grabbed mm reference (e.g.  to
      read /proc/<pid>/ file which requires mm etc.).
      
      The race would look like this
      
        oom_reaper		oom_victim		task
      						mmget_not_zero
      			do_exit
      			  mmput
        __oom_reap_task_mm				mmput
        						  __mmput
      						    exit_mmap
      						      remove_vma
          unmap_page_range
      
      Fix this issue by providing a new mm_is_oom_victim() helper which
      operates on the mm struct rather than a task.  Any context which
      operates on a remote mm struct should use this helper in place of
      tsk_is_oom_victim.  The flag is set in mark_oom_victim and never cleared
      so it is stable in the exit_mmap path.
      
      Debugged by Tetsuo Handa.
      
      Link: http://lkml.kernel.org/r/20171210095130.17110-1-mhocko@kernel.org
      Fixes: 21292580
      
       ("mm: oom: let oom_reap_task and exit_mmap run concurrently")
      Signed-off-by: default avatarMichal Hocko <mhocko@suse.com>
      Reported-by: default avatarDavid Rientjes <rientjes@google.com>
      Acked-by: default avatarDavid Rientjes <rientjes@google.com>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Andrea Argangeli <andrea@kernel.org>
      Cc: <stable@vger.kernel.org>	[4.14]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4837fe37
    • Thiago Rafael Becker's avatar
      kernel: make groups_sort calling a responsibility group_info allocators · bdcf0a42
      Thiago Rafael Becker authored
      
      
      In testing, we found that nfsd threads may call set_groups in parallel
      for the same entry cached in auth.unix.gid, racing in the call of
      groups_sort, corrupting the groups for that entry and leading to
      permission denials for the client.
      
      This patch:
       - Make groups_sort globally visible.
       - Move the call to groups_sort to the modifiers of group_info
       - Remove the call to groups_sort from set_groups
      
      Link: http://lkml.kernel.org/r/20171211151420.18655-1-thiago.becker@gmail.com
      Signed-off-by: default avatarThiago Rafael Becker <thiago.becker@gmail.com>
      Reviewed-by: default avatarMatthew Wilcox <mawilcox@microsoft.com>
      Reviewed-by: default avatarNeilBrown <neilb@suse.com>
      Acked-by: default avatar"J. Bruce Fields" <bfields@fieldses.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.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>
      bdcf0a42
    • Christophe JAILLET's avatar
      mm/frame_vector.c: release a semaphore in 'get_vaddr_frames()' · 1f704fd0
      Christophe JAILLET authored
      A semaphore is acquired before this check, so we must release it before
      leaving.
      
      Link: http://lkml.kernel.org/r/20171211211009.4971-1-christophe.jaillet@wanadoo.fr
      Fixes: b7f0554a
      
       ("mm: fail get_vaddr_frames() for filesystem-dax mappings")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: David Sterba <dsterba@suse.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      1f704fd0
    • Liu, Changcheng's avatar
      tools/slabinfo-gnuplot: force to use bash shell · 0b265c3b
      Liu, Changcheng authored
      
      
      On some linux distributions, the default link of sh is dash which
      deoesn't support split array like "${var//,/ }"
      
      It's better to force to use bash shell directly.
      
      Link: http://lkml.kernel.org/r/20171208093751.GA175471@sofia
      Signed-off-by: default avatarLiu Changcheng <changcheng.liu@intel.com>
      Reviewed-by: default avatarSergey Senozhatsky <sergey.senozhatsky@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      0b265c3b
    • Dmitry Vyukov's avatar
      kcov: fix comparison callback signature · 689d77f0
      Dmitry Vyukov authored
      Fix a silly copy-paste bug.  We truncated u32 args to u16.
      
      Link: http://lkml.kernel.org/r/20171207101134.107168-1-dvyukov@google.com
      Fixes: ded97d2c
      
       ("kcov: support comparison operands collection")
      Signed-off-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Cc: syzkaller@googlegroups.com
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Vegard Nossum <vegard.nossum@oracle.com>
      Cc: Quentin Casasnovas <quentin.casasnovas@oracle.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      689d77f0
    • Geert Uytterhoeven's avatar
      mm/slab.c: do not hash pointers when debugging slab · 85c3e4a5
      Geert Uytterhoeven authored
      If CONFIG_DEBUG_SLAB/CONFIG_DEBUG_SLAB_LEAK are enabled, the slab code
      prints extra debug information when e.g.  corruption is detected.  This
      includes pointers, which are not very useful when hashed.
      
      Fix this by using %px to print unhashed pointers instead where it makes
      sense, and by removing the printing of a last user pointer referring to
      code.
      
      [geert+renesas@glider.be: v2]
        Link: http://lkml.kernel.org/r/1513179267-2509-1-git-send-email-geert+renesas@glider.be
      Link: http://lkml.kernel.org/r/1512641861-5113-1-git-send-email-geert+renesas@glider.be
      Fixes: ad67b74d
      
       ("printk: hash addresses printed with %p")
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Acked-by: default avatarChristoph Lameter <cl@linux.com>
      Acked-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Cc: "Tobin C . Harding" <me@tobin.cc>
      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>
      85c3e4a5
    • Lucas Stach's avatar
      mm/page_alloc.c: avoid excessive IRQ disabled times in free_unref_page_list() · c24ad77d
      Lucas Stach authored
      Since commit 9cca35d4 ("mm, page_alloc: enable/disable IRQs once
      when freeing a list of pages") we see excessive IRQ disabled times of up
      to 25ms on an embedded ARM system (tracing overhead included).
      
      This is due to graphics buffers being freed back to the system via
      release_pages().  Graphics buffers can be huge, so it's not hard to hit
      cases where the list of pages to free has 2048 entries.  Disabling IRQs
      while freeing all those pages is clearly not a good idea.
      
      Introduce a batch limit, which allows IRQ servicing once every few
      pages.  The batch count is the same as used in other parts of the MM
      subsystem when dealing with IRQ disabled regions.
      
      Link: http://lkml.kernel.org/r/20171207170314.4419-1-l.stach@pengutronix.de
      Fixes: 9cca35d4
      
       ("mm, page_alloc: enable/disable IRQs once when freeing a list of pages")
      Signed-off-by: default avatarLucas Stach <l.stach@pengutronix.de>
      Acked-by: default avatarMel Gorman <mgorman@techsingularity.net>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      c24ad77d
    • Geert Uytterhoeven's avatar
      mm/memory.c: mark wp_huge_pmd() inline to prevent build failure · 183f24aa
      Geert Uytterhoeven authored
      With gcc 4.1.2:
      
          mm/memory.o: In function `wp_huge_pmd':
          memory.c:(.text+0x9b4): undefined reference to `do_huge_pmd_wp_page'
      
      Interestingly, wp_huge_pmd() is emitted in the assembler output, but
      never called.
      
      Apparently replacing the call to pmd_write() in __handle_mm_fault() by a
      call to the more complex pmd_access_permitted() reduced the ability of
      the compiler to remove unused code.
      
      Fix this by marking wp_huge_pmd() inline, like was done in commit
      91a90140 ("mm/memory.c: mark create_huge_pmd() inline to prevent
      build failure") for a similar problem.
      
      [akpm@linux-foundation.org: add comment]
      Link: http://lkml.kernel.org/r/1512335500-10889-1-git-send-email-geert@linux-m68k.org
      Fixes: c7da82b8
      
       ("mm: replace pmd_write with pmd_access_permitted in fault + gup paths")
      Signed-off-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      183f24aa
    • Liu, Changcheng's avatar
      scripts/faddr2line: fix CROSS_COMPILE unset error · 4cc90b4c
      Liu, Changcheng authored
      faddr2line hit var unbound error when CROSS_COMPILE isn't set since
      nounset option is set in bash script.
      
      Link: http://lkml.kernel.org/r/20171206013022.GA83929@sofia
      Fixes: 95a87982
      
       ("scripts/faddr2line: extend usage on generic arch")
      Signed-off-by: default avatarLiu Changcheng <changcheng.liu@intel.com>
      Reported-by: default avatarRichard Weinberger <richard.weinberger@gmail.com>
      Reviewed-by: default avatarRichard Weinberger <richard@nod.at>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Philippe Ombredanne <pombredanne@nexb.com>
      Cc: NeilBrown <neilb@suse.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4cc90b4c
    • Srividya Desireddy's avatar
      Documentation/vm/zswap.txt: update with same-value filled page feature · 51f73fff
      Srividya Desireddy authored
      
      
      Update zswap document with details on same-value filled pages
      identification feature.  The usage of zswap.same_filled_pages_enabled
      module parameter is explained.
      
      Link: http://lkml.kernel.org/r/20171206114852epcms5p6973b02a9f455d5d3c765eafda0fe2631@epcms5p6
      Signed-off-by: default avatarSrividya Desireddy <srividya.dr@samsung.com>
      Acked-by: default avatarDan Streetman <ddstreet@ieee.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      51f73fff
    • Arnd Bergmann's avatar
      exec: avoid gcc-8 warning for get_task_comm · 3756f640
      Arnd Bergmann authored
      
      
      gcc-8 warns about using strncpy() with the source size as the limit:
      
        fs/exec.c:1223:32: error: argument to 'sizeof' in 'strncpy' call is the same expression as the source; did you mean to use the size of the destination? [-Werror=sizeof-pointer-memaccess]
      
      This is indeed slightly suspicious, as it protects us from source
      arguments without NUL-termination, but does not guarantee that the
      destination is terminated.
      
      This keeps the strncpy() to ensure we have properly padded target
      buffer, but ensures that we use the correct length, by passing the
      actual length of the destination buffer as well as adding a build-time
      check to ensure it is exactly TASK_COMM_LEN.
      
      There are only 23 callsites which I all reviewed to ensure this is
      currently the case.  We could get away with doing only the check or
      passing the right length, but it doesn't hurt to do both.
      
      Link: http://lkml.kernel.org/r/20171205151724.1764896-1-arnd@arndb.de
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Suggested-by: default avatarKees Cook <keescook@chromium.org>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Acked-by: default avatarIngo Molnar <mingo@kernel.org>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Serge Hallyn <serge@hallyn.com>
      Cc: James Morris <james.l.morris@oracle.com>
      Cc: Aleksa Sarai <asarai@suse.de>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Frederic Weisbecker <frederic@kernel.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>
      3756f640
    • NeilBrown's avatar
      autofs: fix careless error in recent commit · 302ec300
      NeilBrown authored
      Commit ecc0c469 ("autofs: don't fail mount for transient error") was
      meant to replace an 'if' with a 'switch', but instead added the 'switch'
      leaving the case in place.
      
      Link: http://lkml.kernel.org/r/87zi6wstmw.fsf@notabene.neil.brown.name
      Fixes: ecc0c469
      
       ("autofs: don't fail mount for transient error")
      Reported-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
      Signed-off-by: default avatarNeilBrown <neilb@suse.com>
      Cc: Ian Kent <raven@themaw.net>
      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>
      302ec300
    • Arnd Bergmann's avatar
      string.h: workaround for increased stack usage · 146734b0
      Arnd Bergmann authored
      The hardened strlen() function causes rather large stack usage in at
      least one file in the kernel, in particular when CONFIG_KASAN is
      enabled:
      
        drivers/media/usb/em28xx/em28xx-dvb.c: In function 'em28xx_dvb_init':
        drivers/media/usb/em28xx/em28xx-dvb.c:2062:1: error: the frame size of 3256 bytes is larger than 204 bytes [-Werror=frame-larger-than=]
      
      Analyzing this problem led to the discovery that gcc fails to merge the
      stack slots for the i2c_board_info[] structures after we strlcpy() into
      them, due to the 'noreturn' attribute on the source string length check.
      
      I reported this as a gcc bug, but it is unlikely to get fixed for gcc-8,
      since it is relatively easy to work around, and it gets triggered
      rarely.  An earlier workaround I did added an empty inline assembly
      statement before the call to fortify_panic(), which works surprisingly
      well, but is really ugly and unintuitive.
      
      This is a new approach to the same problem, this time addressing it by
      not calling the 'extern __real_strnlen()' function for string constants
      where __builtin_strlen() is a compile-time constant and therefore known
      to be safe.
      
      We do this by checking if the last character in the string is a
      compile-time constant '\0'.  If it is, we can assume that strlen() of
      the string is also constant.
      
      As a side-effect, this should also improve the object code output for
      any other call of strlen() on a string constant.
      
      [akpm@linux-foundation.org: add comment]
      Link: http://lkml.kernel.org/r/20171205215143.3085755-1-arnd@arndb.de
      Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82365
      Link: https://patchwork.kernel.org/patch/9980413/
      Link: https://patchwork.kernel.org/patch/9974047/
      Fixes: 6974f0c4
      
       ("include/linux/string.h: add the option of fortified string.h functions")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
      Cc: Daniel Micay <danielmicay@gmail.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Martin Wilck <mwilck@suse.com>
      Cc: Dan Williams <dan.j.williams@intel.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>
      146734b0
    • Andrew Morton's avatar
      mm/kmemleak.c: make cond_resched() rate-limiting more efficient · 13ab183d
      Andrew Morton authored
      Commit bde5f6bc ("kmemleak: add scheduling point to
      kmemleak_scan()") tries to rate-limit the frequency of cond_resched()
      calls, but does it in a way which might incur an expensive division
      operation in the inner loop.  Simplify this.
      
      Fixes: bde5f6bc
      
       ("kmemleak: add scheduling point to kmemleak_scan()")
      Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Cc: Yisheng Xie <xieyisheng1@huawei.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Michal Hocko <mhocko@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      13ab183d
    • Chris Wilson's avatar
      lib/rbtree,drm/mm: add rbtree_replace_node_cached() · 338f1d9d
      Chris Wilson authored
      Add a variant of rbtree_replace_node() that maintains the leftmost cache
      of struct rbtree_root_cached when replacing nodes within the rbtree.
      
      As drm_mm is the only rb_replace_node() being used on an interval tree,
      the mistake looks fairly self-contained.  Furthermore the only user of
      drm_mm_replace_node() is its testsuite...
      
      Testcase: igt/drm_mm/replace
      
      Link: http://lkml.kernel.org/r/20171122100729.3742-1-chris@chris-wilson.co.uk
      Link: https://patchwork.freedesktop.org/patch/msgid/20171109212435.9265-1-chris@chris-wilson.co.uk
      Fixes: f808c13f
      
       ("lib/interval_tree: fast overlap detection")
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Reviewed-by: default avatarJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Acked-by: default avatarDavidlohr Bueso <dbueso@suse.de>
      Cc: Jérôme Glisse <jglisse@redhat.com>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      338f1d9d
    • Wei Wang's avatar
      include/linux/idr.h: add #include <linux/bug.h> · c47d7f56
      Wei Wang authored
      The <linux/bug.h> was removed from radix-tree.h by commit f5bba9d1
      ("include/linux/radix-tree.h: remove unneeded #include <linux/bug.h>").
      
      Since that commit, tools/testing/radix-tree/ couldn't pass compilation
      due to tools/testing/radix-tree/idr.c:17: undefined reference to
      WARN_ON_ONCE.  This patch adds the bug.h header to idr.h to solve the
      issue.
      
      Link: http://lkml.kernel.org/r/1511963726-34070-2-git-send-email-wei.w.wang@intel.com
      Fixes: f5bba9d1
      
       ("include/linux/radix-tree.h: remove unneeded #include <linux/bug.h>")
      Signed-off-by: default avatarWei Wang <wei.w.wang@intel.com>
      Cc: Matthew Wilcox <mawilcox@microsoft.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Eric Biggers <ebiggers@google.com>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Michal Hocko <mhocko@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      c47d7f56
    • Linus Torvalds's avatar
      Merge tag '4.15-rc-smb3' of git://git.samba.org/sfrench/cifs-2.6 · d455df0b
      Linus Torvalds authored
      Pull cifs fixes from Steve French:
       "Small SMB3 fixes for stable and 4.15rc"
      
      * tag '4.15-rc-smb3' of git://git.samba.org/sfrench/cifs-2.6:
        CIFS: don't log STATUS_NOT_FOUND errors for DFS
        cifs: fix NULL deref in SMB2_read
      d455df0b
    • Linus Torvalds's avatar
      Merge tag 'drm-misc-fixes-2017-12-14' of git://anongit.freedesktop.org/drm/drm-misc · e375922f
      Linus Torvalds authored
      Pull drm fixes from Daniel Vetter:
      
       - two fixes for new core features
      
       - a corner case fix for the connnector_iter fix from last week (this
         one is cc: stable)
      
       - one vc4 fix
      
      * tag 'drm-misc-fixes-2017-12-14' of git://anongit.freedesktop.org/drm/drm-misc:
        drm/drm_lease: Prevent deadlock in case drm_lease_create() fails
        drm: rework delayed connector cleanup in connector_iter
        drm: Update edid-derived drm_display_info fields at edid property set [v2]
        drm/vc4: Release fence after signalling
      e375922f
  3. Dec 14, 2017
    • Marius Vlad's avatar
      drm/drm_lease: Prevent deadlock in case drm_lease_create() fails · bd36d3ba
      Marius Vlad authored
      
      
      This case can been seen when creating the lease with the same objects passed.
      
      [  605.515097] 2 locks held by testapp/3337:
      [  605.519027]  #0:  (&dev->mode_config.idr_mutex){......}, at: [<ffff0000085f1664>] drm_mode_create_lease_ioctl+0x384/0x858
      [  605.530045]  #1:  (&dev->mode_config.idr_mutex){......}, at: [<ffff0000085f11bc>] drm_lease_destroy+0x2c/0x110
      
      Which was causing the process to hang:
      
      [  605.398827] [<ffff0000080856cc>] __switch_to+0x94/0xa8
      [  605.404030] [<ffff000008c05d00>] __schedule+0x1b0/0x698
      [  605.409322] [<ffff000008c06224>] schedule+0x3c/0xa8
      [  605.414260] [<ffff000008c06628>] schedule_preempt_disabled+0x20/0x38
      [  605.420677] [<ffff000008c07370>] mutex_lock_nested+0x158/0x340
      [  605.426572] [<ffff0000085f11bc>] drm_lease_destroy+0x2c/0x110
      [  605.432389] [<ffff0000085cecf0>] drm_master_put+0xc0/0xc8
      [  605.437845] [<ffff0000085f175c>] drm_mode_create_lease_ioctl+0x47c/0x858
      [  605.444612] [<ffff0000085d4460>] drm_ioctl+0x198/0x448
      [  605.449811] [<ffff000008201134>] do_vfs_ioctl+0xa4/0x748
      [  605.455192] [<ffff000008201864>] SyS_ioctl+0x8c/0xa0
      [  605.460216] [<ffff000008082f4c>] __sys_trace_return+0x0/0x4
      
      drm_mode_create_lease_ioctl() calls drm_lease_create() which acquires a lock
      on dev->mode_config.idr_mutex. In case of failure, drm_lease_create() calls
      drm_master_put() which in turn tries to acquire the same lock when calling
      drm_lease_destroy().
      
      v2: - Reverse the order at exit in case of fail, so that unlocking takes place
      before dropping the reference.
          - Include detail information about deadlock (Daniel Vetter)
      
      Signed-off-by: default avatarMarius Vlad <marius-cristian.vlad@nxp.com>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/20171213181048.32719-1-marius-cristian.vlad@nxp.com
      bd36d3ba
    • Linus Torvalds's avatar
      Merge tag 'xfs-4.15-fixes-5' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux · 7c5cac1b
      Linus Torvalds authored
      Pull xfs fixes from Darrick Wong:
       "Here are a few more bug fixes & cleanups for 4.15-rc4:
      
         - clean up duplicate includes
      
         - remove ancient 'no-alloc' crap code that occasionally caused hard
           fs shutdowns due to lack of proper space reservations
      
         - fix regression in FIEMAP behavior when reporting xattr extents"
      
      * tag 'xfs-4.15-fixes-5' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
        xfs: make iomap_begin functions trim iomaps consistently
        xfs: remove "no-allocation" reservations for file creations
        fs: xfs: remove duplicate includes
      7c5cac1b
    • Linus Torvalds's avatar
      Merge tag 'riscv-for-linus-4.15-rc4-riscv_fixes' of... · 4e746cf4
      Linus Torvalds authored
      Merge tag 'riscv-for-linus-4.15-rc4-riscv_fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/palmer/linux
      
      Pull RISC-V fixes from Palmer Dabbelt:
       "This contains three small fixes:
      
         - A fix to a typo in sys_riscv_flush_icache. This only effects error
           handling, but I think it's a small and obvious enough change that
           it's sane outside the merge window.
      
         - The addition of smp_mb__after_spinlock(), which was recently
           removed due to an incorrect comment. This is largly a comment
           change (as there's a big one now), and while it's necessary for
           complience with the RISC-V memory model the lack of this fence
           shouldn't manifest as a bug on current implementations.
           Nonetheless, it still seems saner to have the fence in 4.15.
      
         - The removal of some of the HVC_RISCV_SBI driver that snuck into the
           arch port. This is compile-time dead code in 4.15 (as the driver
           isn't in yet), and during the review process we found a better way
           to implement early printk on RISC-V. While this change doesn't do
           anything, it will make staging our HVC driver easier: without this
           change the HVC driver we hope to upstream won't build on 4.15
           (because the 4.15 arch code would reference a function that no
           longer exists).
      
        I don't think this is the last patch set we'll want for 4.15: I think
        I'll want to remove some of the first-level irqchip driver that snuck
        in as well, which will look a lot like the HVC patch here. This is
        pending some asm-generic cleanup I'm doing that I haven't quite gotten
        clean enough to send out yet, though, but hopefully it'll be ready by
        next week (and still OK for that late)"
      
       * tag 'riscv-for-linus-4.15-rc4-riscv_fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/palmer/linux:
        RISC-V: Remove unused CONFIG_HVC_RISCV_SBI code
        RISC-V: Resurrect smp_mb__after_spinlock()
        RISC-V: Logical vs Bitwise typo
      4e746cf4
    • Daniel Vetter's avatar
      drm: rework delayed connector cleanup in connector_iter · ea497bb9
      Daniel Vetter authored
      PROBE_DEFER also uses system_wq to reprobe drivers, which means when
      that again fails, and we try to flush the overall system_wq (to get
      all the delayed connectore cleanup work_struct completed), we
      deadlock.
      
      Fix this by using just a single cleanup work, so that we can only
      flush that one and don't block on anything else. That means a free
      list plus locking, a standard pattern.
      
      v2:
      - Correctly free connectors only on last ref. Oops (Chris).
      - use llist_head/node (Chris).
      
      v3
      - Add init_llist_head (Chris).
      
      Fixes: a703c550 ("drm: safely free connectors from connector_iter")
      Fixes: 613051da ("drm: locking&new iterators for connector_list")
      Cc: Ben Widawsky <ben@bwidawsk.net>
      Cc: Dave Airlie <airlied@gmail.com>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Cc: Sean Paul <seanpaul@chromium.org>
      Cc: <stable@vger.kernel.org> # v4.11+: 613051da
      
       ("drm: locking&new iterators for connector_list"
      Cc: <stable@vger.kernel.org> # v4.11+
      Cc: Daniel Vetter <daniel.vetter@intel.com>
      Cc: Jani Nikula <jani.nikula@linux.intel.com>
      Cc: Gustavo Padovan <gustavo@padovan.org>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Javier Martinez Canillas <javier@dowhile0.org>
      Cc: Shuah Khan <shuahkh@osg.samsung.com>
      Cc: Guillaume Tucker <guillaume.tucker@collabora.com>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Kevin Hilman <khilman@baylibre.com>
      Cc: Matt Hart <matthew.hart@linaro.org>
      Cc: Thierry Escande <thierry.escande@collabora.co.uk>
      Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com>
      Cc: Enric Balletbo i Serra <enric.balletbo@collabora.com>
      Tested-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
      Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20171213124936.17914-1-daniel.vetter@ffwll.ch
      ea497bb9
  4. Dec 13, 2017
    • Keith Packard's avatar
      drm: Update edid-derived drm_display_info fields at edid property set [v2] · 4b4df570
      Keith Packard authored
      
      
      There are a set of values in the drm_display_info structure for each
      connector which hold information derived from EDID. These are computed
      in drm_add_display_info. Before this patch, that was only called in
      drm_add_edid_modes. This meant that they were only set when EDID was
      present and never reset when EDID was not, as happened when the
      display was disconnected.
      
      One of these fields, non_desktop, is used from
      drm_mode_connector_update_edid_property, the function responsible for
      assigning the new edid value to the application-visible property.
      
      Various drivers call these two functions (drm_add_edid_modes and
      drm_mode_connector_update_edid_property) in different orders. This
      means that even when EDID is present, the drm_display_info fields may
      not have been computed at the time that
      drm_mode_connector_update_edid_property used the non_desktop value to
      set the non_desktop property.
      
      I've added a public function (drm_reset_display_info) that resets the
      drm_display_info field values to default values and then made the
      drm_add_display_info function public. These two functions are now
      called directly from drm_mode_connector_update_edid_property so that
      the drm_display_info fields are always computed from the current EDID
      information before being used in that function.
      
      This means that the drm_display_info values are often computed twice,
      once when the EDID property it set and a second time when EDID is used
      to compute modes for the device. The alternative would be to uniformly
      ensure that the values were computed once before being used, which
      would require that all drivers reliably invoke the two paths in the
      same order. The computation is inexpensive enough that it seems more
      maintainable in the long term to simply compute them in both paths.
      
      The API to drm_add_display_info has been changed so that it no longer
      takes the set of edid-based quirks as a parameter. Rather, it now
      computes those quirks itself and returns them for further use by
      drm_add_edid_modes.
      
      This patch also includes a number of 'const' additions caused by
      drm_mode_connector_update_edid_property taking a 'const struct edid *'
      parameter and wanting to pass that along to drm_add_display_info.
      
      v2: after review by Daniel Vetter <daniel.vetter@ffwll.ch>
      
      	Removed EXPORT_SYMBOL_GPL for drm_reset_display_info and
      	drm_add_display_info.
      
      	Added FIXME in drm_mode_connector_update_edid_property about
      	potentially merging that with drm_add_edid_modes to avoid
      	the need for two driver calls.
      
      Signed-off-by: default avatarKeith Packard <keithp@keithp.com>
      Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/20171213084427.31199-1-keithp@keithp.com
      (danvet: cherry picked from commit 12a889bf4bca ("drm: rework delayed
      connector cleanup in connector_iter") from drm-misc-next since
      functional conflict with changes in -next and we need to make sure
      both have the right version and nothing gets lost.)
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      4b4df570
    • Linus Torvalds's avatar
      Merge tag 'platform-drivers-x86-v4.15-3' of git://git.infradead.org/linux-platform-drivers-x86 · d39a01ef
      Linus Torvalds authored
      Pull x86 platform driver fixes from Darren Hart:
      
       - Correct an error in the evdev protocol in asus-wireless which results
         in dropped key events in recent versions of libinput
      
       - Add a quirk for keyboard lighting for a specific Dell laptop
      
       - Silence a static analysis warning regarding unchecked return values
         of small kmalloc() allocations in dell-wmi
      
      * tag 'platform-drivers-x86-v4.15-3' of git://git.infradead.org/linux-platform-drivers-x86:
        platform/x86: dell-wmi: check for kmalloc() errors
        platform/x86: asus-wireless: send an EV_SYN/SYN_REPORT between state changes
        platform/x86: dell-laptop: Fix keyboard max lighting for Dell Latitude E6410
      d39a01ef
    • Geert Uytterhoeven's avatar
      PCI: rcar: Fix use-after-free in probe error path · 0c31f1d7
      Geert Uytterhoeven authored
      If CONFIG_DEBUG_SLAB=y, and no PCIe card is inserted, the kernel crashes
      during probe on r8a7791/koelsch:
      
        rcar-pcie fe000000.pcie: PCIe link down
        Unable to handle kernel paging request at virtual address 6b6b6b6b
      
      (seeing this message requires earlycon and keep_bootcon).
      
      Indeed, pci_free_host_bridge() frees the PCI host bridge, including the
      embedded rcar_pcie object, so pci_free_resource_list() must not be called
      afterwards.
      
      To fix this, move the call to pci_free_resource_list() up, and update the
      label name accordingly.
      
      Fixes: ddd535f1
      
       ("PCI: rcar: Fix memory leak when no PCIe card is inserted")
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Acked-by: default avatarSimon Horman <horms+renesas@verge.net.au>
      Acked-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      0c31f1d7
  5. Dec 12, 2017