Skip to content
  1. Oct 04, 2017
    • Oleg Nesterov's avatar
      exec: binfmt_misc: shift filp_close(interp_file) from kill_node() to bm_evict_inode() · 83f91827
      Oleg Nesterov authored
      
      
      To ensure that load_misc_binary() can't use the partially destroyed
      Node, see also the next patch.
      
      The current logic looks wrong in any case, once we close interp_file it
      doesn't make any sense to delay kfree(inode->i_private), this Node is no
      longer valid.  Even if the MISC_FMT_OPEN_FILE/interp_file checks were
      not racy (they are), load_misc_binary() should not try to reopen
      ->interpreter if MISC_FMT_OPEN_FILE is set but ->interp_file is NULL.
      
      And I can't understand why do we use filp_close(), not fput().
      
      Link: http://lkml.kernel.org/r/20170922143644.GA17216@redhat.com
      Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Ben Woodard <woodard@redhat.com>
      Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
      Cc: Jim Foraker <foraker1@llnl.gov>
      Cc: <tdhooge@llnl.gov>
      Cc: Travis Gummels <tgummels@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      83f91827
    • Oleg Nesterov's avatar
      exec: binfmt_misc: don't nullify Node->dentry in kill_node() · baba1b29
      Oleg Nesterov authored
      
      
      kill_node() nullifies/checks Node->dentry to avoid double free.  This
      complicates the next changes and this is very confusing:
      
       - we do not need to check dentry != NULL under entries_lock,
         kill_node() is always called under inode_lock(d_inode(root)) and we
         rely on this inode_lock() anyway, without this lock the
         MISC_FMT_OPEN_FILE cleanup could race with itself.
      
       - if kill_inode() was already called and ->dentry == NULL we should not
         even try to close e->interp_file.
      
      We can change bm_entry_write() to simply check !list_empty(list) before
      kill_node.  Again, we rely on inode_lock(), in particular it saves us
      from the race with bm_status_write(), another caller of kill_node().
      
      Link: http://lkml.kernel.org/r/20170922143641.GA17210@redhat.com
      Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Ben Woodard <woodard@redhat.com>
      Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
      Cc: Jim Foraker <foraker1@llnl.gov>
      Cc: <tdhooge@llnl.gov>
      Cc: Travis Gummels <tgummels@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      baba1b29
    • Oleg Nesterov's avatar
      exec: load_script: kill the onstack interp[BINPRM_BUF_SIZE] array · c2315c18
      Oleg Nesterov authored
      Patch series "exec: binfmt_misc: fix use-after-free, kill
      iname[BINPRM_BUF_SIZE]".
      
      It looks like this code was always wrong, then commit 948b701a
      
      
      ("binfmt_misc: add persistent opened binary handler for containers")
      added more problems.
      
      This patch (of 6):
      
      load_script() can simply use i_name instead, it points into bprm->buf[]
      and nobody can change this memory until we call prepare_binprm().
      
      The only complication is that we need to also change the signature of
      bprm_change_interp() but this change looks good too.
      
      While at it, do whitespace/style cleanups.
      
      NOTE: the real motivation for this change is that people want to
      increase BINPRM_BUF_SIZE, we need to change load_misc_binary() too but
      this looks more complicated because afaics it is very buggy.
      
      Link: http://lkml.kernel.org/r/20170918163446.GA26793@redhat.com
      Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Travis Gummels <tgummels@redhat.com>
      Cc: Ben Woodard <woodard@redhat.com>
      Cc: Jim Foraker <foraker1@llnl.gov>
      Cc: <tdhooge@llnl.gov>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      c2315c18
    • Andrea Arcangeli's avatar
      userfaultfd: non-cooperative: fix fork use after free · 384632e6
      Andrea Arcangeli authored
      When reading the event from the uffd, we put it on a temporary
      fork_event list to detect if we can still access it after releasing and
      retaking the event_wqh.lock.
      
      If fork aborts and removes the event from the fork_event all is fine as
      long as we're still in the userfault read context and fork_event head is
      still alive.
      
      We've to put the event allocated in the fork kernel stack, back from
      fork_event list-head to the event_wqh head, before returning from
      userfaultfd_ctx_read, because the fork_event head lifetime is limited to
      the userfaultfd_ctx_read stack lifetime.
      
      Forgetting to move the event back to its event_wqh place then results in
      __remove_wait_queue(&ctx->event_wqh, &ewq->wq); in
      userfaultfd_event_wait_completion to remove it from a head that has been
      already freed from the reader stack.
      
      This could only happen if resolve_userfault_fork failed (for example if
      there are no file descriptors available to allocate the fork uffd).  If
      it succeeded it was put back correctly.
      
      Furthermore, after find_userfault_evt receives a fork event, the forked
      userfault context in fork_nctx and uwq->msg.arg.reserved.reserved1 can
      be released by the fork thread as soon as the event_wqh.lock is
      released.  Taking a reference on the fork_nctx before dropping the lock
      prevents an use after free in resolve_userfault_fork().
      
      If the fork side aborted and it already released everything, we still
      try to succeed resolve_userfault_fork(), if possible.
      
      Fixes: 893e26e6
      
       ("userfaultfd: non-cooperative: Add fork() event")
      Link: http://lkml.kernel.org/r/20170920180413.26713-1-aarcange@redhat.com
      Signed-off-by: default avatarAndrea Arcangeli <aarcange@redhat.com>
      Reported-by: default avatarMark Rutland <mark.rutland@arm.com>
      Tested-by: default avatarMark Rutland <mark.rutland@arm.com>
      Cc: Pavel Emelyanov <xemul@virtuozzo.com>
      Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
      Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
      Cc: Mike Kravetz <mike.kravetz@oracle.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>
      384632e6
    • Reza Arbab's avatar
      mm/device-public-memory: fix edge case in _vm_normal_page() · 7d790d2d
      Reza Arbab authored
      With device public pages at the end of my memory space, I'm getting
      output from _vm_normal_page():
      
        BUG: Bad page map in process migrate_pages  pte:c0800001ffff0d06 pmd:f95d3000
        addr:00007fff89330000 vm_flags:00100073 anon_vma:c0000000fa899320 mapping:          (null) index:7fff8933
        file:          (null) fault:          (null) mmap:          (null) readpage:          (null)
        CPU: 0 PID: 13963 Comm: migrate_pages Tainted: P    B      OE 4.14.0-rc1-wip #155
        Call Trace:
           dump_stack+0xb0/0xf4 (unreliable)
           print_bad_pte+0x28c/0x340
           _vm_normal_page+0xc0/0x140
           zap_pte_range+0x664/0xc10
           unmap_page_range+0x318/0x670
           unmap_vmas+0x74/0xe0
           exit_mmap+0xe8/0x1f0
           mmput+0xac/0x1f0
           do_exit+0x348/0xcd0
           do_group_exit+0x5c/0xf0
           SyS_exit_group+0x1c/0x20
           system_call+0x58/0x6c
      
      The pfn causing this is the very last one.  Correct the bounds check
      accordingly.
      
      Fixes: df6ad698 ("mm/device-public-memo...
      7d790d2d
    • Shaohua Li's avatar
      mm: fix data corruption caused by lazyfree page · 9625456c
      Shaohua Li authored
      MADV_FREE clears pte dirty bit and then marks the page lazyfree (clear
      SwapBacked).  There is no lock to prevent the page is added to swap
      cache between these two steps by page reclaim.  If page reclaim finds
      such page, it will simply add the page to swap cache without pageout the
      page to swap because the page is marked as clean.  Next time, page fault
      will read data from the swap slot which doesn't have the original data,
      so we have a data corruption.  To fix issue, we mark the page dirty and
      pageout the page.
      
      However, we shouldn't dirty all pages which is clean and in swap cache.
      swapin page is swap cache and clean too.  So we only dirty page which is
      added into swap cache in page reclaim, which shouldn't be swapin page.
      As Minchan suggested, simply dirty the page in add_to_swap can do the
      job.
      
      Fixes: 802a3a92
      
       ("mm: reclaim MADV_FREE pages")
      Link: http://lkml.kernel.org/r/08c84256b007bf3f63c91d94383bd9eb6fee2daa.1506446061.git.shli@fb.com
      Signed-off-by: default avatarShaohua Li <shli@fb.com>
      Reported-by: default avatarArtem Savkov <asavkov@redhat.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Acked-by: default avatarMinchan Kim <minchan@kernel.org>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Hillf Danton <hdanton@sina.com>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Mel Gorman <mgorman@techsingularity.net>
      Cc: <stable@vger.kernel.org>	[4.12+]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9625456c
    • Shaohua Li's avatar
      mm: avoid marking swap cached page as lazyfree · 24c92eb7
      Shaohua Li authored
      MADV_FREE clears pte dirty bit and then marks the page lazyfree (clear
      SwapBacked).  There is no lock to prevent the page is added to swap
      cache between these two steps by page reclaim.  Page reclaim could add
      the page to swap cache and unmap the page.  After page reclaim, the page
      is added back to lru.  At that time, we probably start draining per-cpu
      pagevec and mark the page lazyfree.  So the page could be in a state
      with SwapBacked cleared and PG_swapcache set.  Next time there is a
      refault in the virtual address, do_swap_page can find the page from swap
      cache but the page has PageSwapCache false because SwapBacked isn't set,
      so do_swap_page will bail out and do nothing.  The task will keep
      running into fault handler.
      
      Fixes: 802a3a92
      
       ("mm: reclaim MADV_FREE pages")
      Link: http://lkml.kernel.org/r/6537ef3814398c0073630b03f176263bc81f0902.1506446061.git.shli@fb.com
      Signed-off-by: default avatarShaohua Li <shli@fb.com>
      Reported-by: default avatarArtem Savkov <asavkov@redhat.com>
      Tested-by: default avatarArtem Savkov <asavkov@redhat.com>
      Reviewed-by: default avatarRik van Riel <riel@redhat.com>
      Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Acked-by: default avatarMinchan Kim <minchan@kernel.org>
      Cc: Hillf Danton <hdanton@sina.com>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Mel Gorman <mgorman@techsingularity.net>
      Cc: <stable@vger.kernel.org>	[4.12+]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      24c92eb7
    • Jeff Layton's avatar
      mm: have filemap_check_and_advance_wb_err clear AS_EIO/AS_ENOSPC · f4e222c5
      Jeff Layton authored
      
      
      Eryu noticed that he could sometimes get a leftover error reported when
      it shouldn't be on fsync with ext2 and non-journalled ext4.
      
      The problem is that writeback_single_inode still uses filemap_fdatawait.
      That picks up a previously set AS_EIO flag, which would ordinarily have
      been cleared before.
      
      Since we're mostly using this function as a replacement for
      filemap_check_errors, have filemap_check_and_advance_wb_err clear AS_EIO
      and AS_ENOSPC when reporting an error.  That should allow the new
      function to better emulate the behavior of the old with respect to these
      flags.
      
      Link: http://lkml.kernel.org/r/20170922133331.28812-1-jlayton@kernel.org
      Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
      Reported-by: default avatarEryu Guan <eguan@redhat.com>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f4e222c5
    • Sudip Mukherjee's avatar
      m32r: define CPU_BIG_ENDIAN · 5bdfca64
      Sudip Mukherjee authored
      
      
      The build of m32r allmodconfig is giving lots of build warnings about:
      
        include/linux/byteorder/big_endian.h:7:2:
      	warning: #warning inconsistent configuration,
      		needs CONFIG_CPU_BIG_ENDIAN [-Wcpp]
      	#warning inconsistent configuration, needs CONFIG_CPU_BIG_ENDIAN
      
      Define CPU_BIG_ENDIAN like the way CPU_LITTLE_ENDIAN is defined.
      
      Link: http://lkml.kernel.org/r/1505678083-10320-1-git-send-email-sudipm.mukherjee@gmail.com
      Signed-off-by: default avatarSudip 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>
      5bdfca64
    • Minchan Kim's avatar
      zram: fix null dereference of handle · ae94264e
      Minchan Kim authored
      In testing I found handle passed to zs_map_object in __zram_bvec_read is
      NULL so eh kernel goes oops in pin_object().
      
      The reason is there is no routine to check the slot's freeing after
      getting the slot's lock.  This patch fixes it.
      
      [minchan@kernel.org: v2]
        Link: http://lkml.kernel.org/r/1505887347-10881-1-git-send-email-minchan@kernel.org
      Link: http://lkml.kernel.org/r/1505788488-26723-1-git-send-email-minchan@kernel.org
      Fixes: 1f7319c7
      
       ("zram: partial IO refactoring")
      Signed-off-by: default avatarMinchan Kim <minchan@kernel.org>
      Reviewed-by: default avatarSergey Senozhatsky <sergey.senozhatsky.work@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>
      ae94264e
    • Christophe Leroy's avatar
      mm: fix RODATA_TEST failure "rodata_test: test data was not read only" · a872eb21
      Christophe Leroy authored
      On powerpc, RODATA_TEST fails with message the following messages:
      
        Freeing unused kernel memory: 528K
        rodata_test: test data was not read only
      
      This is because GCC allocates it to .data section:
      
        c0695034 g     O .data	00000004 rodata_test_data
      
      Since commit 056b9d8a ("mm: remove rodata_test_data export, add
      pr_fmt"), rodata_test_data is used only inside rodata_test.c By
      declaring it static, it gets properly allocated into .rodata section
      instead of .data:
      
        c04df710 l     O .rodata	00000004 rodata_test_data
      
      Fixes: 056b9d8a
      
       ("mm: remove rodata_test_data export, add pr_fmt")
      Link: http://lkml.kernel.org/r/20170921093729.1080368AC1@po15668-vm-win7.idsi0.si.c-s.fr
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Jinbum Park <jinb.park7@gmail.com>
      Cc: Segher Boessenkool <segher@kernel.crashing.org>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: <stable@vger.kernel.org>
      Sig...
      a872eb21
    • Ioan Nicu's avatar
      rapidio: remove global irq spinlocks from the subsystem · 31d1e130
      Ioan Nicu authored
      
      
      Locking of config and doorbell operations should be done only if the
      underlying hardware requires it.
      
      This patch removes the global spinlocks from the rapidio subsystem and
      moves them to the mport drivers (fsl_rio and tsi721), only to the
      necessary places.  For example, local config space read and write
      operations (lcread/lcwrite) are atomic in all existing drivers, so there
      should be no need for locking, while the cread/cwrite operations which
      generate maintenance transactions need to be synchronized with a lock.
      
      Later, each driver could chose to use a per-port lock instead of a
      global one, or even more granular locking.
      
      Link: http://lkml.kernel.org/r/20170824113023.GD50104@nokia.com
      Signed-off-by: default avatarIoan Nicu <ioan.nicu.ext@nokia.com>
      Signed-off-by: default avatarFrank Kunz <frank.kunz@nokia.com>
      Acked-by: default avatarAlexandre Bounine <alexandre.bounine@idt.com>
      Cc: Matt Porter <mporter@kernel.crashing.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      31d1e130
    • Arnd Bergmann's avatar
      mm: meminit: mark init_reserved_page as __meminit · 57148a64
      Arnd Bergmann authored
      The function is called from __meminit context and calls other __meminit
      functions but isn't it self mark as such today:
      
        WARNING: vmlinux.o(.text.unlikely+0x4516): Section mismatch in reference from the function init_reserved_page() to the function .meminit.text:early_pfn_to_nid()
        The function init_reserved_page() references the function __meminit early_pfn_to_nid().
        This is often because init_reserved_page lacks a __meminit annotation or the annotation of early_pfn_to_nid is wrong.
      
      On most compilers, we don't notice this because the function gets
      inlined all the time.  Adding __meminit here fixes the harmless warning
      for the old versions and is generally the correct annotation.
      
      Link: http://lkml.kernel.org/r/20170915193149.901180-1-arnd@arndb.de
      Fixes: 7e18adb4
      
       ("mm: meminit: initialise remaining struct pages in parallel with kswapd")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Acked-by: default avatarMel Gorman <mgorman@techsingularity.net>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      57148a64
    • Vitaly Wool's avatar
      z3fold: fix stale list handling · 35529357
      Vitaly Wool authored
      
      
      Fix the situation when clear_bit() is called for page->private before
      the page pointer is actually assigned.  While at it, remove work_busy()
      check because it is costly and does not give 100% guarantee anyway.
      
      Signed-off-by: default avatarVitaly Wool <vitalywool@gmail.com>
      Cc: Dan Streetman <ddstreet@ieee.org>
      Cc: <Oleksiy.Avramchenko@sony.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      35529357
    • Davidlohr Bueso's avatar
      mm,compaction: serialize waitqueue_active() checks (for real) · 6818600f
      Davidlohr Bueso authored
      Andrea brought to my attention that the L->{L,S} guarantees are
      completely bogus for this case.  I was looking at the diagram, from the
      offending commit, when that _is_ the race, we had the load reordered
      already.
      
      What we need is at least S->L semantics, thus simply use
      wq_has_sleeper() to serialize the call for good.
      
      Link: http://lkml.kernel.org/r/20170914175313.GB811@linux-80c1.suse
      Fixes: 46acef04
      
       (mm,compaction: serialize waitqueue_active() checks)
      Signed-off-by: default avatarDavidlohr Bueso <dbueso@suse.de>
      Reported-by: default avatarAndrea Parri <parri.andrea@gmail.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>
      6818600f
    • Sherry Yang's avatar
      android: binder: drop lru lock in isolate callback · a1b2289c
      Sherry Yang authored
      Drop the global lru lock in isolate callback before calling
      zap_page_range which calls cond_resched, and re-acquire the global lru
      lock before returning.  Also change return code to LRU_REMOVED_RETRY.
      
      Use mmput_async when fail to acquire mmap sem in an atomic context.
      
      Fix "BUG: sleeping function called from invalid context"
      errors when CONFIG_DEBUG_ATOMIC_SLEEP is enabled.
      
      Also restore mmput_async, which was initially introduced in commit
      ec8d7c14 ("mm, oom_reaper: do not mmput synchronously from the oom
      reaper context"), and was removed in commit 21292580 ("mm: oom: let
      oom_reap_task and exit_mmap run concurrently").
      
      Link: http://lkml.kernel.org/r/20170914182231.90908-1-sherryy@android.com
      Fixes: f2517eb7
      
       ("android: binder: Add global lru shrinker to binder")
      Signed-off-by: default avatarSherry Yang <sherryy@android.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Reported-by: default avatarKyle Yan <kyan@codeaurora.org>
      Acked-by: default avatarArve Hjønnevåg <arve@android.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: Martijn Coenen <maco@google.com>
      Cc: Todd Kjos <tkjos@google.com>
      Cc: Riley Andrews <riandrews@android.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: Hillf Danton <hdanton@sina.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Hoeun Ryu <hoeun.ryu@gmail.com>
      Cc: Christopher Lameter <cl@linux.com>
      Cc: Vegard Nossum <vegard.nossum@oracle.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      a1b2289c
    • Jérôme Glisse's avatar
      mm/memcg: avoid page count check for zone device · 3f2eb028
      Jérôme Glisse authored
      
      
      Fix for 4.14, zone device page always have an elevated refcount of one
      and thus page count sanity check in uncharge_page() is inappropriate for
      them.
      
      [mhocko@suse.com: nano-optimize VM_BUG_ON in uncharge_page]
      Link: http://lkml.kernel.org/r/20170914190011.5217-1-jglisse@redhat.com
      Signed-off-by: default avatarJérôme Glisse <jglisse@redhat.com>
      Signed-off-by: default avatarMichal Hocko <mhocko@suse.com>
      Reported-by: default avatarEvgeny Baskakov <ebaskakov@nvidia.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      3f2eb028
    • Michal Hocko's avatar
      mm, memcg: remove hotplug locking from try_charge · 72f0184c
      Michal Hocko authored
      The following lockdep splat has been noticed during LTP testing
      
        ======================================================
        WARNING: possible circular locking dependency detected
        4.13.0-rc3-next-20170807 #12 Not tainted
        ------------------------------------------------------
        a.out/4771 is trying to acquire lock:
         (cpu_hotplug_lock.rw_sem){++++++}, at: [<ffffffff812b4668>] drain_all_stock.part.35+0x18/0x140
      
        but task is already holding lock:
         (&mm->mmap_sem){++++++}, at: [<ffffffff8106eb35>] __do_page_fault+0x175/0x530
      
        which lock already depends on the new lock.
      
        the existing dependency chain (in reverse order) is:
      
        -> #3 (&mm->mmap_sem){++++++}:
               lock_acquire+0xc9/0x230
               __might_fault+0x70/0xa0
               _copy_to_user+0x23/0x70
               filldir+0xa7/0x110
               xfs_dir2_sf_getdents.isra.10+0x20c/0x2c0 [xfs]
               xfs_readdir+0x1fa/0x2c0 [xfs]
               xfs_file_readdir+0x30/0x40 [xfs]
               iterate_dir+0x17a/0x1a0
               SyS_getdents+0xb0/0x160
               entry_SYSCALL_64_fastpath+0x1f/0xbe
      
        -> #2 (&type->i_mutex_dir_key#3){++++++}:
               lock_acquire+0xc9/0x230
               down_read+0x51/0xb0
               lookup_slow+0xde/0x210
               walk_component+0x160/0x250
               link_path_walk+0x1a6/0x610
               path_openat+0xe4/0xd50
               do_filp_open+0x91/0x100
               file_open_name+0xf5/0x130
               filp_open+0x33/0x50
               kernel_read_file_from_path+0x39/0x80
               _request_firmware+0x39f/0x880
               request_firmware_direct+0x37/0x50
               request_microcode_fw+0x64/0xe0
               reload_store+0xf7/0x180
               dev_attr_store+0x18/0x30
               sysfs_kf_write+0x44/0x60
               kernfs_fop_write+0x113/0x1a0
               __vfs_write+0x37/0x170
               vfs_write+0xc7/0x1c0
               SyS_write+0x58/0xc0
               do_syscall_64+0x6c/0x1f0
               return_from_SYSCALL_64+0x0/0x7a
      
        -> #1 (microcode_mutex){+.+.+.}:
               lock_acquire+0xc9/0x230
               __mutex_lock+0x88/0x960
               mutex_lock_nested+0x1b/0x20
               microcode_init+0xbb/0x208
               do_one_initcall+0x51/0x1a9
               kernel_init_freeable+0x208/0x2a7
               kernel_init+0xe/0x104
               ret_from_fork+0x2a/0x40
      
        -> #0 (cpu_hotplug_lock.rw_sem){++++++}:
               __lock_acquire+0x153c/0x1550
               lock_acquire+0xc9/0x230
               cpus_read_lock+0x4b/0x90
               drain_all_stock.part.35+0x18/0x140
               try_charge+0x3ab/0x6e0
               mem_cgroup_try_charge+0x7f/0x2c0
               shmem_getpage_gfp+0x25f/0x1050
               shmem_fault+0x96/0x200
               __do_fault+0x1e/0xa0
               __handle_mm_fault+0x9c3/0xe00
               handle_mm_fault+0x16e/0x380
               __do_page_fault+0x24a/0x530
               do_page_fault+0x30/0x80
               page_fault+0x28/0x30
      
        other info that might help us debug this:
      
        Chain exists of:
          cpu_hotplug_lock.rw_sem --> &type->i_mutex_dir_key#3 --> &mm->mmap_sem
      
         Possible unsafe locking scenario:
      
               CPU0                    CPU1
               ----                    ----
          lock(&mm->mmap_sem);
                                       lock(&type->i_mutex_dir_key#3);
                                       lock(&mm->mmap_sem);
          lock(cpu_hotplug_lock.rw_sem);
      
         *** DEADLOCK ***
      
        2 locks held by a.out/4771:
         #0:  (&mm->mmap_sem){++++++}, at: [<ffffffff8106eb35>] __do_page_fault+0x175/0x530
         #1:  (percpu_charge_mutex){+.+...}, at: [<ffffffff812b4c97>] try_charge+0x397/0x6e0
      
      The problem is very similar to the one fixed by commit a459eeb7
      
      
      ("mm, page_alloc: do not depend on cpu hotplug locks inside the
      allocator").  We are taking hotplug locks while we can be sitting on top
      of basically arbitrary locks.  This just calls for problems.
      
      We can get rid of {get,put}_online_cpus, fortunately.  We do not have to
      be worried about races with memory hotplug because drain_local_stock,
      which is called from both the WQ draining and the memory hotplug
      contexts, is always operating on the local cpu stock with IRQs disabled.
      
      The only thing to be careful about is that the target memcg doesn't
      vanish while we are still in drain_all_stock so take a reference on it.
      
      Link: http://lkml.kernel.org/r/20170913090023.28322-1-mhocko@kernel.org
      Signed-off-by: default avatarMichal Hocko <mhocko@suse.com>
      Reported-by: default avatarArtem Savkov <asavkov@redhat.com>
      Tested-by: default avatarArtem Savkov <asavkov@redhat.com>
      Cc: Johannes Weiner <hannes@cmpxchg.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>
      72f0184c
    • Michal Hocko's avatar
      mm, oom_reaper: skip mm structs with mmu notifiers · 4d4bbd85
      Michal Hocko authored
      Andrea has noticed that the oom_reaper doesn't invalidate the range via
      mmu notifiers (mmu_notifier_invalidate_range_start/end) and that can
      corrupt the memory of the kvm guest for example.
      
      tlb_flush_mmu_tlbonly already invokes mmu notifiers but that is not
      sufficient as per Andrea:
      
       "mmu_notifier_invalidate_range cannot be used in replacement of
        mmu_notifier_invalidate_range_start/end. For KVM
        mmu_notifier_invalidate_range is a noop and rightfully so. A MMU
        notifier implementation has to implement either ->invalidate_range
        method or the invalidate_range_start/end methods, not both. And if you
        implement invalidate_range_start/end like KVM is forced to do, calling
        mmu_notifier_invalidate_range in common code is a noop for KVM.
      
        For those MMU notifiers that can get away only implementing
        ->invalidate_range, the ->invalidate_range is implicitly called by
        mmu_notifier_invalidate_range_end(). And only those secondary MMUs
        that share the same pagetable with the primary MMU (like AMD iommuv2)
        can get away only implementing ->invalidate_range"
      
      As the callback is allowed to sleep and the implementation is out of
      hand of the MM it is safer to simply bail out if there is an mmu
      notifier registered.  In order to not fail too early make the
      mm_has_notifiers check under the oom_lock and have a little nap before
      failing to give the current oom victim some more time to exit.
      
      [akpm@linux-foundation.org: coding-style fixes]
      Link: http://lkml.kernel.org/r/20170913113427.2291-1-mhocko@kernel.org
      Fixes: aac45363
      
       ("mm, oom: introduce oom reaper")
      Signed-off-by: default avatarMichal Hocko <mhocko@suse.com>
      Reported-by: default avatarAndrea Arcangeli <aarcange@redhat.com>
      Reviewed-by: default avatarAndrea Arcangeli <aarcange@redhat.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>
      4d4bbd85
    • Vitaly Wool's avatar
      z3fold: fix potential race in z3fold_reclaim_page · d5567c9d
      Vitaly Wool authored
      
      
      It is possible that on a (partially) unsuccessful page reclaim,
      kref_put() called in z3fold_reclaim_page() does not yield page release,
      but the page is released shortly afterwards by another thread.  Then
      z3fold_reclaim_page() would try to list_add() that (released) page again
      which is obviously a bug.
      
      To avoid that, spin_lock() has to be taken earlier, before the
      kref_put() call mentioned earlier.
      
      Link: http://lkml.kernel.org/r/20170913162937.bfff21c7d12b12a5f47639fd@gmail.com
      Signed-off-by: default avatarVitaly Wool <vitalywool@gmail.com>
      Cc: Dan Streetman <ddstreet@ieee.org>
      Cc: <Oleksiy.Avramchenko@sony.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d5567c9d
    • Geert Uytterhoeven's avatar
      sh: sh7269: remove nonexistent GPIO_PH[0-7] to fix pinctrl registration · d9d73e81
      Geert Uytterhoeven authored
      Pinmux_pins[] is initialized through PINMUX_GPIO(), using designated
      array initializers, where the GPIO_* enums serve as indices.  If enum
      values are defined, but never used, pinmux_pins[] contains (zero-filled)
      holes.  Such entries are treated as pin zero, which was registered
      before, thus leading to pinctrl registration failures, as seen on
      sh7722:
      
          sh-pfc pfc-sh7722: pin 0 already registered
          sh-pfc pfc-sh7722: error during pin registration
          sh-pfc pfc-sh7722: could not register: -22
          sh-pfc: probe of pfc-sh7722 failed with error -22
      
      Remove GPIO_PH[0-7] from the enum to fix this.
      
      Link: http://lkml.kernel.org/r/1505205657-18012-5-git-send-email-geert+renesas@glider.be
      Fixes: ef0fa533
      
       ("sh: Add pinmux for sh7269")
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Magnus Damm <magnus.damm@gmail.com>
      Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Cc: Jacopo Mondi <jacopo+renesas@jmondi.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d9d73e81
    • Geert Uytterhoeven's avatar
      sh: sh7264: remove nonexistent GPIO_PH[0-7] to fix pinctrl registration · eae3df7e
      Geert Uytterhoeven authored
      Pinmux_pins[] is initialized through PINMUX_GPIO(), using designated
      array initializers, where the GPIO_* enums serve as indices.  If enum
      values are defined, but never used, pinmux_pins[] contains (zero-filled)
      holes.  Such entries are treated as pin zero, which was registered
      before, thus leading to pinctrl registration failures, as seen on
      sh7722:
      
          sh-pfc pfc-sh7722: pin 0 already registered
          sh-pfc pfc-sh7722: error during pin registration
          sh-pfc pfc-sh7722: could not register: -22
          sh-pfc: probe of pfc-sh7722 failed with error -22
      
      Remove GPIO_PH[0-7] from the enum to fix this.
      
      Link: http://lkml.kernel.org/r/1505205657-18012-4-git-send-email-geert+renesas@glider.be
      Fixes: 41797f75
      
       ("sh: Add pinmux for sh7264")
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Cc: Jacopo Mondi <jacopo+renesas@jmondi.org>
      Cc: Magnus Damm <magnus.damm@gmail.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      eae3df7e
    • Geert Uytterhoeven's avatar
      sh: sh7757: remove nonexistent GPIO_PT[JLNQ]7_RESV to fix pinctrl registration · d8ce38f6
      Geert Uytterhoeven authored
      Commit 3810e960 ("sh: modify pinmux for SH7757 2nd cut") renamed
      GPIO_PT[JLNQ]7 to GPIO_PT[JLNQ]7_RESV, and removed the existing users
      from the pinmux_pins[] array.
      
      However, pinmux_pins[] is initialized through PINMUX_GPIO(), using
      designated array initializers, where the GPIO_* enums serve as indices.
      Hence entries were not really removed, but replaced by (zero-filled)
      holes.  Such entries are treated as pin zero, which was registered
      before, thus leading to pinctrl registration failures, as seen on
      sh7722:
      
          sh-pfc pfc-sh7722: pin 0 already registered
          sh-pfc pfc-sh7722: error during pin registration
          sh-pfc pfc-sh7722: could not register: -22
          sh-pfc: probe of pfc-sh7722 failed with error -22
      
      Remove GPIO_PT[JLNQ]7_RESV from the enum to fix this.
      
      Link: http://lkml.kernel.org/r/1505205657-18012-3-git-send-email-geert+renesas@glider.be
      Fixes: 3810e960
      
       ("sh: modify pinmux for SH7757 2nd cut")
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Cc: Jacopo Mondi <jacopo+renesas@jmondi.org>
      Cc: Magnus Damm <magnus.damm@gmail.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d8ce38f6
    • Geert Uytterhoeven's avatar
      sh: sh7722: remove nonexistent GPIO_PTQ7 to fix pinctrl registration · b78412b8
      Geert Uytterhoeven authored
      Patch series "sh: sh7722/sh7757i/sh7264/sh7269: Fix pinctrl registration",
      v2.
      
      Magnus Damm reported that on sh7722/Migo-R, pinctrl registration fails
      with:
      
          sh-pfc pfc-sh7722: pin 0 already registered
          sh-pfc pfc-sh7722: error during pin registration
          sh-pfc pfc-sh7722: could not register: -22
          sh-pfc: probe of pfc-sh7722 failed with error -22
      
      pinmux_pins[] is initialized through PINMUX_GPIO(), using designated
      array initializers, where the GPIO_* enums serve as indices.  Apparently
      GPIO_PTQ7 was defined in the enum, but never used.  If enum values are
      defined, but never used, pinmux_pins[] contains (zero-filled) holes.
      Hence such entries are treated as pin zero, which was registered before,
      and pinctrl registration fails.
      
      I can't see how this ever worked, as at the time of commit f5e25ae5
      ("sh-pfc: Add sh7722 pinmux support"), pinmux_gpios[] in
      drivers/pinctrl/sh-pfc/pfc-sh7722.c already had the hole, and
      drivers/pinctrl/core.c already had the check.
      
      Some scripting revealed a few more broken drivers:
        - sh7757 has four holes, due to nonexistent GPIO_PT[JLNQ]7_RESV.
        - sh7264 and sh7269 define GPIO_PH[0-7], but don't use it with
          PINMUX_GPIO().
      
      Patch 1 fixes the issue on sh7722, and was tested.  Patches 3-4 should
      fix the issue on the other 3 SoCs, but was untested due to lack of
      hardware.
      
      This patch (of 4):
      
      On sh7722/Migo-R, pinctrl registration fails with:
      
          sh-pfc pfc-sh7722: pin 0 already registered
          sh-pfc pfc-sh7722: error during pin registration
          sh-pfc pfc-sh7722: could not register: -22
          sh-pfc: probe of pfc-sh7722 failed with error -22
      
      pinmux_pins[] is initialized through PINMUX_GPIO(), using designated array
      initializers, where the GPIO_* enums serve as indices.  As GPIO_PTQ7 is
      defined in the enum, but never used, pinmux_pins[] contains a
      (zero-filled) hole.  Hence this entry is treated as pin zero, which was
      registered before, and pinctrl registration fails.
      
      According to the datasheet, port PTQ7 does not exist.  Hence remove
      GPIO_PTQ7 from the enum to fix this.
      
      Link: http://lkml.kernel.org/r/1505205657-18012-2-git-send-email-geert+renesas@glider.be
      Fixes: 8d7b5b0a
      
       ("sh: Add sh7722 pinmux code")
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Reported-by: default avatarMagnus Damm <magnus.damm@gmail.com>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Tested-by: default avatarJacopo Mondi <jacopo+renesas@jmondi.org>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b78412b8
    • Alexandru Moise's avatar
      mm, hugetlb, soft_offline: save compound page order before page migration · 19bfbe22
      Alexandru Moise authored
      This fixes a bug in madvise() where if you'd try to soft offline a
      hugepage via madvise(), while walking the address range you'd end up,
      using the wrong page offset due to attempting to get the compound order
      of a former but presently not compound page, due to dissolving the huge
      page (since commit c3114a84: "mm: hugetlb: soft-offline: dissolve
      source hugepage after successful migration").
      
      As a result I ended up with all my free pages except one being offlined.
      
      Link: http://lkml.kernel.org/r/20170912204306.GA12053@gmail.com
      Fixes: c3114a84
      
       ("mm: hugetlb: soft-offline: dissolve source hugepage after successful migration")
      Signed-off-by: default avatarAlexandru Moise <00moses.alexander00@gmail.com>
      Cc: Anshuman Khandual <khandual@linux.vnet.ibm.com>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Hillf Danton <hdanton@sina.com>
      Cc: Shaohua Li <shli@fb.com>
      Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
      Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
      Cc: Mel Gorman <mgorman@techsingularity.net>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.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>
      19bfbe22
    • Kirill Tkhai's avatar
      ksm: fix unlocked iteration over vmas in cmp_and_merge_page() · 4b22927f
      Kirill Tkhai authored
      In this place mm is unlocked, so vmas or list may change.  Down read
      mmap_sem to protect them from modifications.
      
      Link: http://lkml.kernel.org/r/150512788393.10691.8868381099691121308.stgit@localhost.localdomain
      Fixes: e86c59b1
      
       ("mm/ksm: improve deduplication of zero pages with colouring")
      Signed-off-by: default avatarKirill Tkhai <ktkhai@virtuozzo.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Reviewed-by: default avatarAndrea Arcangeli <aarcange@redhat.com>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: zhong jiang <zhongjiang@huawei.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>
      Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
      Cc: Hugh Dickins <hughd@google.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>
      4b22927f
    • Kirill A. Shutemov's avatar
      include/linux/mm.h: fix typo in VM_MPX definition · fa87b91c
      Kirill A. Shutemov authored
      There's a typo in recent change of VM_MPX definition.  We want it to be
      VM_HIGH_ARCH_4, not VM_HIGH_ARCH_BIT_4.
      
      This bug does cause visible regressions.  In arch_vma_name the vmflags
      are tested against VM_MPX.  With the incorrect value of VM_MPX, a number
      of vmas (such as the stack) test positive and end up being marked as
      "[mpx]" in /proc/N/maps instead of their correct names.
      
      This confuses tools like rr which expect to be able to find familiar
      vmas.
      
      Fixes: df3735c5
      
       ("x86,mpx: make mpx depend on x86-64 to free up VMA flag")
      Link: http://lkml.kernel.org/r/20170918140253.36856-1-kirill.shutemov@linux.intel.com
      Signed-off-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Reviewed-by: default avatarRik van Riel <riel@redhat.com>
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Kyle Huey <me@kylehuey.com>
      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>
      fa87b91c
    • Colin Ian King's avatar
      scripts/spelling.txt: add more spelling mistakes to spelling.txt · e00e5a26
      Colin Ian King authored
      
      
      Here are some of the more spelling mistakes and typos that I've found
      while fixing up spelling mistakes in kernel error message text over the
      past eight weeks.
      
      [akpm@linux-foundation.org: s/|/||/, per Joe]
      Link: http://lkml.kernel.org/r/20170919090818.5989-1-colin.king@canonical.com
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Stephen Boyd <sboyd@codeaurora.org>
      Cc: Joe Perches <joe@perches.com>
      Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      e00e5a26
    • Jean Delvare's avatar
      kernel/params.c: align add_sysfs_param documentation with code · 630cc2b3
      Jean Delvare authored
      This parameter is named kp, so the documentation should use that.
      
      Fixes: 9b473de8
      
       ("param: Fix duplicate module prefixes")
      Link: http://lkml.kernel.org/r/20170919142656.64aea59e@endymion
      Signed-off-by: default avatarJean Delvare <jdelvare@suse.de>
      Acked-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      630cc2b3
    • Sudip Mukherjee's avatar
      alpha: fix build failures · 8ee912da
      Sudip Mukherjee authored
      
      
      The build of alpha allmodconfig is giving error:
      
        arch/alpha/include/asm/mmu_context.h: In function 'ev5_switch_mm':
        arch/alpha/include/asm/mmu_context.h:160:2: error:
      	implicit declaration of function 'task_thread_info';
      	did you mean 'init_thread_info'? [-Werror=implicit-function-declaration]
      
      The file 'mmu_context.h' needed an extra header file.
      
      Link: http://lkml.kernel.org/r/1505668810-7497-1-git-send-email-sudipm.mukherjee@gmail.com
      Signed-off-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: Matt Turner <mattst88@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      8ee912da
    • Linus Torvalds's avatar
      Merge branch 'for-4.14-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq · d81fa669
      Linus Torvalds authored
      Pull workqueue fixlet from Tejun Heo:
       "Minor documentation update"
      
      * 'for-4.14-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq:
        Documentation: core-api: minor workqueue.rst cleanups
      d81fa669
    • Linus Torvalds's avatar
      Merge branch 'for-4.14-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup · 847d9fb4
      Linus Torvalds authored
      Pull cgroup fix from Tejun Heo:
       "The recent migration code updates assumed that migrations always
        execute from the top to the bottom once and didn't clean up internal
        states after each migration round; however, cgroup_transfer_tasks()
        repeats the inner steps multiple times and the garbage internal states
        from the previous iteration led to OOPS.
      
        Waiman fixed the bug by reinitializing the relevant states at the end
        of each migration round"
      
      * 'for-4.14-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
        cgroup: Reinit cgroup_taskset structure before cgroup_migrate_execute() returns
      847d9fb4
    • Linus Torvalds's avatar
      Merge branch 'for-4.14-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu · ff93026d
      Linus Torvalds authored
      Pull percpu fixes from Tejun Heo:
       "Rather important fixes this time.
      
         - The new percpu area allocator had a subtle bug in how it iterates
           the memory regions and could skip viable areas, which led to
           allocation failures for module static percpu variables. Dennis
           fixed the bug and another non-critical one in stat calculation.
      
         - Mark noticed that the generic implementations of percpu local
           atomic reads aren't properly protected against irqs and there's a
           (slim) chance for split reads on some 32bit systems. Generic
           implementations are updated to disable irq when read size is larger
           than ulong size. This may have made some 32bit archs which can do
           atomic local 64bit accesses generate sub-optimal code. We need to
           find them out and implement arch-specific overrides"
      
      * 'for-4.14-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu:
        percpu: fix iteration to prevent skipping over block
        percpu: fix starting offset for chunk statistics traversal
        percpu: make this_cpu_generic_read() atomic w.r.t. interrupts
      ff93026d
    • Linus Torvalds's avatar
      Merge branch 'for-4.14-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata · c1de1591
      Linus Torvalds authored
      Pull libata fixes from Tejun Heo:
       "Nothing too interesting.
      
        Arnd's gcc-7 warning fixes that slipped through the cracks for two
        release cycles (my bad), and two minor low level driver updates"
      
      * 'for-4.14-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata:
        ahci: don't ignore result code of ahci_reset_controller()
        ata_piix: Add Fujitsu-Siemens Lifebook S6120 to short cable IDs
        ata: avoid gcc-7 warning in ata_timing_quantize
      c1de1591
    • Linus Torvalds's avatar
      Merge tag 'usb-4.14-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb · 887c8ba7
      Linus Torvalds authored
      Pull USB fixes from Greg KH:
       "Here are a number of USB fixes for 4.14-rc4 to resolved reported
        issues.
      
        There's a bunch of stuff in here based on the great work Andrey
        Konovalov is doing in fuzzing the USB stack. Lots of bug fixes when
        dealing with corrupted USB descriptors that we've never seen in
        "normal" operation, but is now ensuring the stack is much more
        hardened overall.
      
        There's also the usual XHCI and gadget driver fixes as well, and a
        build error fix, and a few other minor things, full details in the
        shortlog.
      
        All of these have been in linux-next with no reported issues"
      
      * tag 'usb-4.14-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (38 commits)
        usb: dwc3: of-simple: Add compatible for Spreadtrum SC9860 platform
        usb: gadget: udc: atmel: set vbus irqflags explicitly
        usb: gadget: ffs: handle I/O completion in-order
        usb: renesas_usbhs: fix usbhsf_fifo_clear() for RX direction
        usb: renesas_usbhs: fix the BCLR setting condition for non-DCP pipe
        usb: gadget: udc: renesas_usb3: Fix return value of usb3_write_pipe()
        usb: gadget: udc: renesas_usb3: fix Pn_RAMMAP.Pn_MPKT value
        usb: gadget: udc: renesas_usb3: fix for no-data control transfer
        USB: dummy-hcd: Fix erroneous synchronization change
        USB: dummy-hcd: fix infinite-loop resubmission bug
        USB: dummy-hcd: fix connection failures (wrong speed)
        USB: cdc-wdm: ignore -EPIPE from GetEncapsulatedResponse
        USB: devio: Don't corrupt user memory
        USB: devio: Prevent integer overflow in proc_do_submiturb()
        USB: g_mass_storage: Fix deadlock when driver is unbound
        USB: gadgetfs: Fix crash caused by inadequate synchronization
        USB: gadgetfs: fix copy_to_user while holding spinlock
        USB: uas: fix bug in handling of alternate settings
        usb-storage: unusual_devs entry to fix write-access regression for Seagate external drives
        usb-storage: fix bogus hardware error messages for ATA pass-thru devices
        ...
      887c8ba7
    • Linus Torvalds's avatar
      Merge tag 'tty-4.14-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty · 27b3b160
      Linus Torvalds authored
      Pull tty/serial fixes from Greg KH:
       "Here are a small number (5) of patches for some reported TTY and
        serial issues. Nothing major, a documentation update, timing fix,
        error handling fix, name reporting fix, and a timeout issue resolved.
      
        All of these have been in linux-next for a while with no reported
        issues"
      
      * tag 'tty-4.14-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
        serial: sccnxp: Fix error handling in sccnxp_probe()
        tty: serial: lpuart: avoid report NULL interrupt
        serial: bcm63xx: fix timing issue.
        mxser: fix timeout calculation for low rates
        serial: sh-sci: document R8A77970 bindings
      27b3b160
    • Linus Torvalds's avatar
      Merge tag 'staging-4.14-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging · 08bbc4fc
      Linus Torvalds authored
      Pull staging/IIO fixes from Greg KH:
       "Here are some small staging/IIO driver fixes for 4.14-rc4
      
        Most of these have been in my tree for a while due to travels, sorry
        for the delay. They resolve a number of small issues reported by
        people, mostly for the iio drivers. Nothing major in here, full
        details are in the shortlog.
      
        All have been linux-next for a few weeks with no reported issues"
      
      * tag 'staging-4.14-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (23 commits)
        staging: iio: ad7192: Fix - use the dedicated reset function avoiding dma from stack.
        iio: core: Return error for failed read_reg
        iio: ad7793: Fix the serial interface reset
        iio: ad_sigma_delta: Implement a dedicated reset function
        IIO: BME280: Updates to Humidity readings need ctrl_reg write!
        iio: adc: mcp320x: Fix readout of negative voltages
        iio: adc: mcp320x: Fix oops on module unload
        iio: adc: stm32: fix bad error check on max_channels
        iio: trigger: stm32-timer: fix a corner case to write preset
        iio: trigger: stm32-timer: preset shouldn't be buffered
        iio: adc: twl4030: Return an error if we can not enable the vusb3v1 regulator in 'twl4030_madc_probe()'
        iio: adc: twl4030: Disable the vusb3v1 rugulator in the error handling path of 'twl4030_madc_probe()'
        iio: adc: twl4030: Fix an error handling path in 'twl4030_madc_probe()'
        staging: rtl8723bs: avoid null pointer dereference on pmlmepriv
        staging: rtl8723bs: add missing range check on id
        staging: vchiq_2835_arm: Fix NULL ptr dereference in free_pagelist
        staging: speakup: fix speakup-r empty line lockup
        staging: pi433: Move limit check to switch default to kill warning
        staging: r8822be: fix null pointer dereferences with a null driver_adapter
        staging: mt29f_spinand: Enable the read ECC before program the page
        ...
      08bbc4fc
  2. Oct 03, 2017
    • Linus Torvalds's avatar
      Merge tag 'driver-core-4.14-rc4' of... · c4142ed6
      Linus Torvalds authored
      Merge tag 'driver-core-4.14-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
      
      Pull driver core fixes from Greg KH:
       "Here are a few small fixes for 4.14-rc4.
      
        The removal of DRIVER_ATTR() was almost completed by 4.14-rc1, but one
        straggler made it in through some other tree (odds are, one of
        mine...) So there's a simple removal of the last user, and then
        finally the macro is removed from the tree.
      
        There's a fix for old crazy udev instances that insist on reloading a
        module when it is removed from the kernel due to the new uevents for
        bind/unbind. This fixes the reported regression, hopefully some year
        in the future we can drop the workaround, once users update to the
        latest version, but I'm not holding my breath.
      
        And then there's a build fix for a linker warning, and a buffer
        overflow fix to match the PCI fixes you took through the PCI tree in
        the same area.
      
        All of these have been in linux-next for a few weeks while I've been
        traveling, sorry for the delay"
      
      * tag 'driver-core-4.14-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core:
        driver core: remove DRIVER_ATTR
        fpga: altera-cvp: remove DRIVER_ATTR() usage
        driver core: platform: Don't read past the end of "driver_override" buffer
        base: arch_topology: fix section mismatch build warnings
        driver core: suppress sending MODALIAS in UNBIND uevents
      c4142ed6
    • Linus Torvalds's avatar
      Merge tag 'char-misc-4.14-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc · 3a98be09
      Linus Torvalds authored
      Pull char/misc fixes from Greg KH:
       "Here are a handful of char/misc driver fixes for 4.14-rc4.
      
        Nothing major, some binder fixups, hyperv fixes, and other tiny
        things.
      
        All of these have been sitting in my tree for way too long, sorry for
        the delay in getting them to you. All have been in linux-next for a
        few weeks, and despite some people's feeling about if linux-next
        actually tests things, I think it's a good "soak test" for patches"
      
      * tag 'char-misc-4.14-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
        Drivers: hv: fcopy: restore correct transfer length
        vmbus: don't acquire the mutex in vmbus_hvsock_device_unregister()
        intel_th: pci: Add Lewisburg PCH support
        intel_th: pci: Add Cedar Fork PCH support
        stm class: Fix a use-after-free
        nvmem: add missing of_node_put() in of_nvmem_cell_get()
        nvmem: core: return EFBIG on out-of-range write
        auxdisplay: charlcd: properly restore atomic counter on error path
        binder: fix memory corruption in binder_transaction binder
        binder: fix an ret value override
        android: binder: fix type mismatch warning
      3a98be09
    • Ard Biesheuvel's avatar
      ahci: don't ignore result code of ahci_reset_controller() · d312fefe
      Ard Biesheuvel authored
      
      
      ahci_pci_reset_controller() calls ahci_reset_controller(), which may
      fail, but ignores the result code and always returns success. This
      may result in failures like below
      
        ahci 0000:02:00.0: version 3.0
        ahci 0000:02:00.0: enabling device (0000 -> 0003)
        ahci 0000:02:00.0: SSS flag set, parallel bus scan disabled
        ahci 0000:02:00.0: controller reset failed (0xffffffff)
        ahci 0000:02:00.0: failed to stop engine (-5)
          ... repeated many times ...
        ahci 0000:02:00.0: failed to stop engine (-5)
        Unable to handle kernel paging request at virtual address ffff0000093f9018
          ...
        PC is at ahci_stop_engine+0x5c/0xd8 [libahci]
        LR is at ahci_deinit_port.constprop.12+0x1c/0xc0 [libahci]
          ...
        [<ffff000000a17014>] ahci_stop_engine+0x5c/0xd8 [libahci]
        [<ffff000000a196b4>] ahci_deinit_port.constprop.12+0x1c/0xc0 [libahci]
        [<ffff000000a197d8>] ahci_init_controller+0x80/0x168 [libahci]
        [<ffff000000a260f8>] ahci_pci_init_controller+0x60/0x68 [ahci]
        [<ffff000000a26f94>] ahci_init_one+0x75c/0xd88 [ahci]
        [<ffff000008430324>] local_pci_probe+0x3c/0xb8
        [<ffff000008431728>] pci_device_probe+0x138/0x170
        [<ffff000008585e54>] driver_probe_device+0x2dc/0x458
        [<ffff0000085860e4>] __driver_attach+0x114/0x118
        [<ffff000008583ca8>] bus_for_each_dev+0x60/0xa0
        [<ffff000008585638>] driver_attach+0x20/0x28
        [<ffff0000085850b0>] bus_add_driver+0x1f0/0x2a8
        [<ffff000008586ae0>] driver_register+0x60/0xf8
        [<ffff00000842f9b4>] __pci_register_driver+0x3c/0x48
        [<ffff000000a3001c>] ahci_pci_driver_init+0x1c/0x1000 [ahci]
        [<ffff000008083918>] do_one_initcall+0x38/0x120
      
      where an obvious hardware level failure results in an unnecessary 15 second
      delay and a subsequent crash.
      
      So record the result code of ahci_reset_controller() and relay it, rather
      than ignoring it.
      
      Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      d312fefe