Skip to content
  1. Feb 01, 2020
    • Wei Yang's avatar
      mm/gup.c: use is_vm_hugetlb_page() to check whether to follow huge · be9d3045
      Wei Yang authored
      
      
      No functional change, just leverage the helper function to improve
      readability as others.
      
      Link: http://lkml.kernel.org/r/20200113070322.26627-1-richardw.yang@linux.intel.com
      Signed-off-by: default avatarWei Yang <richardw.yang@linux.intel.com>
      Acked-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Acked-by: default avatarDavid Rientjes <rientjes@google.com>
      Reviewed-by: default avatarRalph Campbell <rcampbell@nvidia.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      be9d3045
    • Qiujun Huang's avatar
      mm: fix gup_pud_range · 15494520
      Qiujun Huang authored
      
      
      sorry for not processing for a long time.  I met it again.
      
      patch v1   https://lkml.org/lkml/2019/9/20/656
      
      do_machine_check()
        do_memory_failure()
          memory_failure()
            hw_poison_user_mappings()
              try_to_unmap()
                pteval = swp_entry_to_pte(make_hwpoison_entry(subpage));
      
      ...and now we have a swap entry that indicates that the page entry
      refers to a bad (and poisoned) page of memory, but gup_fast() at this
      level of the page table was ignoring swap entries, and incorrectly
      assuming that "!pxd_none() == valid and present".
      
      And this was not just a poisoned page problem, but a generaly swap entry
      problem.  So, any swap entry type (device memory migration, numa
      migration, or just regular swapping) could lead to the same problem.
      
      Fix this by checking for pxd_present(), instead of pxd_none().
      
      Link: http://lkml.kernel.org/r/1578479084-15508-1-git-send-email-hqjagain@gmail.com
      Signed-off-by: default avatarQiujun Huang <hqjagain@gmail.com>
      Cc: John Hubbard <jhubbard@nvidia.com>
      Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      15494520
    • Ira Weiny's avatar
      mm/filemap.c: clean up filemap_write_and_wait() · ddf8f376
      Ira Weiny authored
      
      
      At some point filemap_write_and_wait() and
      filemap_write_and_wait_range() got the exact same implementation with
      the exception of the range being specified in *_range()
      
      Similar to other functions in fs.h which call *_range(..., 0,
      LLONG_MAX), change filemap_write_and_wait() to be a static inline which
      calls filemap_write_and_wait_range()
      
      Link: http://lkml.kernel.org/r/20191129160713.30892-1-ira.weiny@intel.com
      Signed-off-by: default avatarIra Weiny <ira.weiny@intel.com>
      Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
      Reviewed-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ddf8f376
    • Vlastimil Babka's avatar
      mm/debug.c: always print flags in dump_page() · 5b57b8f2
      Vlastimil Babka authored
      Commit 76a1850e ("mm/debug.c: __dump_page() prints an extra line")
      inadvertently removed printing of page flags for pages that are neither
      anon nor ksm nor have a mapping.  Fix that.
      
      Using pr_cont() again would be a solution, but the commit explicitly
      removed its use.  Avoiding the danger of mixing up split lines from
      multiple CPUs might be beneficial for near-panic dumps like this, so fix
      this without reintroducing pr_cont().
      
      Link: http://lkml.kernel.org/r/9f884d5c-ca60-dc7b-219c-c081c755fab6@suse.cz
      Fixes: 76a1850e
      
       ("mm/debug.c: __dump_page() prints an extra line")
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Reported-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
      Reported-by: default avatarMichal Hocko <mhocko@kernel.org>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: David Hildenbrand <david@redhat.com>
      Cc: Qian Cai <cai@lca.pw>
      Cc: Oscar Salvador <osalvador@suse.de>
      Cc: Mel Gorman <mgorman@techsingularity.net>
      Cc: Mike Rapoport <rppt@linux.ibm.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Pavel Tatashin <pavel.tatashin@microsoft.com>
      Cc: Ralph Campbell <rcampbell@nvidia.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      5b57b8f2
    • He Zhe's avatar
      mm/kmemleak: turn kmemleak_lock and object->lock to raw_spinlock_t · 8c96f1bc
      He Zhe authored
      
      
      kmemleak_lock as a rwlock on RT can possibly be acquired in atomic
      context which does work.
      
      Since the kmemleak operation is performed in atomic context make it a
      raw_spinlock_t so it can also be acquired on RT.  This is used for
      debugging and is not enabled by default in a production like environment
      (where performance/latency matters) so it makes sense to make it a
      raw_spinlock_t instead trying to get rid of the atomic context.  Turn
      also the kmemleak_object->lock into raw_spinlock_t which is acquired
      (nested) while the kmemleak_lock is held.
      
      The time spent in "echo scan > kmemleak" slightly improved on 64core box
      with this patch applied after boot.
      
      [bigeasy@linutronix.de: redo the description, update comments. Merge the individual bits:  He Zhe did the kmemleak_lock, Liu Haitao the ->lock and Yongxin Liu forwarded Liu's patch.]
      Link: http://lkml.kernel.org/r/20191219170834.4tah3prf2gdothz4@linutronix.de
      Link: https://lkml.kernel.org/r/20181218150744.GB20197@arrakis.emea.arm.com
      Link: https://lkml.kernel.org/r/1542877459-144382-1-git-send-email-zhe.he@windriver.com
      Link: https://lkml.kernel.org/r/20190927082230.34152-1-yongxin.liu@windriver.com
      Signed-off-by: default avatarHe Zhe <zhe.he@windriver.com>
      Signed-off-by: default avatarLiu Haitao <haitao.liu@windriver.com>
      Signed-off-by: default avatarYongxin Liu <yongxin.liu@windriver.com>
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      8c96f1bc
    • Yu Zhao's avatar
      mm/slub.c: avoid slub allocation while holding list_lock · 90e9f6a6
      Yu Zhao authored
      
      
      If we are already under list_lock, don't call kmalloc().  Otherwise we
      will run into a deadlock because kmalloc() also tries to grab the same
      lock.
      
      Fix the problem by using a static bitmap instead.
      
        WARNING: possible recursive locking detected
        --------------------------------------------
        mount-encrypted/4921 is trying to acquire lock:
        (&(&n->list_lock)->rlock){-.-.}, at: ___slab_alloc+0x104/0x437
      
        but task is already holding lock:
        (&(&n->list_lock)->rlock){-.-.}, at: __kmem_cache_shutdown+0x81/0x3cb
      
        other info that might help us debug this:
         Possible unsafe locking scenario:
      
               CPU0
               ----
          lock(&(&n->list_lock)->rlock);
          lock(&(&n->list_lock)->rlock);
      
         *** DEADLOCK ***
      
      Link: http://lkml.kernel.org/r/20191108193958.205102-2-yuzhao@google.com
      Signed-off-by: default avatarYu Zhao <yuzhao@google.com>
      Acked-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
      Cc: Yu Zhao <yuzhao@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      90e9f6a6
    • wangyan's avatar
      ocfs2: use ocfs2_update_inode_fsync_trans() to access t_tid in handle->h_transaction · 25b69918
      wangyan authored
      
      
      For the uniform format, we use ocfs2_update_inode_fsync_trans() to
      access t_tid in handle->h_transaction
      
      Link: http://lkml.kernel.org/r/6ff9a312-5f7d-0e27-fb51-bc4e062fcd97@huawei.com
      Signed-off-by: default avatarYan Wang <wangyan122@huawei.com>
      Reviewed-by: default avatarJun Piao <piaojun@huawei.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Junxiao Bi <junxiao.bi@oracle.com>
      Cc: Joseph Qi <jiangqi903@gmail.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Gang He <ghe@suse.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      25b69918
    • wangyan's avatar
      ocfs2: fix a NULL pointer dereference when call ocfs2_update_inode_fsync_trans() · 9f16ca48
      wangyan authored
      
      
      I found a NULL pointer dereference in ocfs2_update_inode_fsync_trans(),
      handle->h_transaction may be NULL in this situation:
      
      ocfs2_file_write_iter
        ->__generic_file_write_iter
            ->generic_perform_write
              ->ocfs2_write_begin
                ->ocfs2_write_begin_nolock
                  ->ocfs2_write_cluster_by_desc
                    ->ocfs2_write_cluster
                      ->ocfs2_mark_extent_written
                        ->ocfs2_change_extent_flag
                          ->ocfs2_split_extent
                            ->ocfs2_try_to_merge_extent
                              ->ocfs2_extend_rotate_transaction
                                ->ocfs2_extend_trans
                                  ->jbd2_journal_restart
                                    ->jbd2__journal_restart
                                      // handle->h_transaction is NULL here
                                      ->handle->h_transaction = NULL;
                                      ->start_this_handle
                                        /* journal aborted due to storage
                                           network disconnection, return error */
                                        ->return -EROFS;
                               /* line 3806 in ocfs2_try_to_merge_extent (),
                                  it will ignore ret error. */
                              ->ret = 0;
              ->...
              ->ocfs2_write_end
                ->ocfs2_write_end_nolock
                  ->ocfs2_update_inode_fsync_trans
                    // NULL pointer dereference
                    ->oi->i_sync_tid = handle->h_transaction->t_tid;
      
      The information of NULL pointer dereference as follows:
          JBD2: Detected IO errors while flushing file data on dm-11-45
          Aborting journal on device dm-11-45.
          JBD2: Error -5 detected when updating journal superblock for dm-11-45.
          (dd,22081,3):ocfs2_extend_trans:474 ERROR: status = -30
          (dd,22081,3):ocfs2_try_to_merge_extent:3877 ERROR: status = -30
          Unable to handle kernel NULL pointer dereference at
          virtual address 0000000000000008
          Mem abort info:
            ESR = 0x96000004
            Exception class = DABT (current EL), IL = 32 bits
            SET = 0, FnV = 0
            EA = 0, S1PTW = 0
          Data abort info:
            ISV = 0, ISS = 0x00000004
            CM = 0, WnR = 0
          user pgtable: 4k pages, 48-bit VAs, pgdp = 00000000e74e1338
          [0000000000000008] pgd=0000000000000000
          Internal error: Oops: 96000004 [#1] SMP
          Process dd (pid: 22081, stack limit = 0x00000000584f35a9)
          CPU: 3 PID: 22081 Comm: dd Kdump: loaded
          Hardware name: Huawei TaiShan 2280 V2/BC82AMDD, BIOS 0.98 08/25/2019
          pstate: 60400009 (nZCv daif +PAN -UAO)
          pc : ocfs2_write_end_nolock+0x2b8/0x550 [ocfs2]
          lr : ocfs2_write_end_nolock+0x2a0/0x550 [ocfs2]
          sp : ffff0000459fba70
          x29: ffff0000459fba70 x28: 0000000000000000
          x27: ffff807ccf7f1000 x26: 0000000000000001
          x25: ffff807bdff57970 x24: ffff807caf1d4000
          x23: ffff807cc79e9000 x22: 0000000000001000
          x21: 000000006c6cd000 x20: ffff0000091d9000
          x19: ffff807ccb239db0 x18: ffffffffffffffff
          x17: 000000000000000e x16: 0000000000000007
          x15: ffff807c5e15bd78 x14: 0000000000000000
          x13: 0000000000000000 x12: 0000000000000000
          x11: 0000000000000000 x10: 0000000000000001
          x9 : 0000000000000228 x8 : 000000000000000c
          x7 : 0000000000000fff x6 : ffff807a308ed6b0
          x5 : ffff7e01f10967c0 x4 : 0000000000000018
          x3 : d0bc661572445600 x2 : 0000000000000000
          x1 : 000000001b2e0200 x0 : 0000000000000000
          Call trace:
           ocfs2_write_end_nolock+0x2b8/0x550 [ocfs2]
           ocfs2_write_end+0x4c/0x80 [ocfs2]
           generic_perform_write+0x108/0x1a8
           __generic_file_write_iter+0x158/0x1c8
           ocfs2_file_write_iter+0x668/0x950 [ocfs2]
           __vfs_write+0x11c/0x190
           vfs_write+0xac/0x1c0
           ksys_write+0x6c/0xd8
           __arm64_sys_write+0x24/0x30
           el0_svc_common+0x78/0x130
           el0_svc_handler+0x38/0x78
           el0_svc+0x8/0xc
      
      To prevent NULL pointer dereference in this situation, we use
      is_handle_aborted() before using handle->h_transaction->t_tid.
      
      Link: http://lkml.kernel.org/r/03e750ab-9ade-83aa-b000-b9e81e34e539@huawei.com
      Signed-off-by: default avatarYan Wang <wangyan122@huawei.com>
      Reviewed-by: default avatarJun Piao <piaojun@huawei.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Junxiao Bi <junxiao.bi@oracle.com>
      Cc: Joseph Qi <jiangqi903@gmail.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Gang He <ghe@suse.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9f16ca48
    • Andy Shevchenko's avatar
      ocfs2/dlm: move BITS_TO_BYTES() to bitops.h for wider use · dd3e7cba
      Andy Shevchenko authored
      
      
      There are users already and will be more of BITS_TO_BYTES() macro.  Move
      it to bitops.h for wider use.
      
      In the case of ocfs2 the replacement is identical.
      
      As for bnx2x, there are two places where floor version is used.  In the
      first case to calculate the amount of structures that can fit one memory
      page.  In this case obviously the ceiling variant is correct and
      original code might have a potential bug, if amount of bits % 8 is not
      0.  In the second case the macro is used to calculate bytes transmitted
      in one microsecond.  This will work for all speeds which is multiply of
      1Gbps without any change, for the rest new code will give ceiling value,
      for instance 100Mbps will give 13 bytes, while old code gives 12 bytes
      and the arithmetically correct one is 12.5 bytes.  Further the value is
      used to setup timer threshold which in any case has its own margins due
      to certain resolution.  I don't see here an issue with slightly shifting
      thresholds for low speed connections, the card is supposed to utilize
      highest available rate, which is usually 10Gbps.
      
      Link: http://lkml.kernel.org/r/20200108121316.22411-1-andriy.shevchenko@linux.intel.com
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Reviewed-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
      Acked-by: default avatarSudarsana Reddy Kalluru <skalluru@marvell.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Junxiao Bi <junxiao.bi@oracle.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Gang He <ghe@suse.com>
      Cc: Jun Piao <piaojun@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      dd3e7cba
    • Colin Ian King's avatar
      ocfs2/dlm: remove redundant assignment to ret · d8f18750
      Colin Ian King authored
      
      
      The variable ret is being initialized with a value that is never read
      and it is being updated later with a new value.  The initialization is
      redundant and can be removed.
      
      Addresses Coverity ("Unused value")
      
      Link: http://lkml.kernel.org/r/20191202164833.62865-1-colin.king@canonical.com
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Reviewed-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Junxiao Bi <junxiao.bi@oracle.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Gang He <ghe@suse.com>
      Cc: Jun Piao <piaojun@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d8f18750
    • Masahiro Yamada's avatar
      ocfs2: make local header paths relative to C files · ca322fb6
      Masahiro Yamada authored
      
      
      Gang He reports the failure of building fs/ocfs2/ as an external module
      of the kernel installed on the system:
      
       $ cd fs/ocfs2
       $ make -C /lib/modules/`uname -r`/build M=`pwd` modules
      
      If you want to make it work reliably, I'd recommend to remove ccflags-y
      from the Makefiles, and to make header paths relative to the C files.  I
      think this is the correct usage of the #include "..." directive.
      
      Link: http://lkml.kernel.org/r/20191227022950.14804-1-ghe@suse.com
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarGang He <ghe@suse.com>
      Reported-by: default avatarGang He <ghe@suse.com>
      Reviewed-by: default avatarGang He <ghe@suse.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Junxiao Bi <junxiao.bi@oracle.com>
      Cc: Joseph Qi <jiangqi903@gmail.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Jun Piao <piaojun@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ca322fb6
    • zhengbin's avatar
      ocfs2: remove unneeded semicolons · 5b43d645
      zhengbin authored
      
      
      Fixes coccicheck warnings:
      
        fs/ocfs2/cluster/quorum.c:76:2-3: Unneeded semicolon
        fs/ocfs2/dlmglue.c:573:2-3: Unneeded semicolon
      
      Link: http://lkml.kernel.org/r/6ee3aa16-9078-30b1-df3f-22064950bd98@linux.alibaba.com
      Signed-off-by: default avatarzhengbin <zhengbin13@huawei.com>
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Acked-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Junxiao Bi <junxiao.bi@oracle.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Gang He <ghe@suse.com>
      Cc: Jun Piao <piaojun@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      5b43d645
    • Aditya Pakki's avatar
      fs: ocfs: remove unnecessary assertion in dlm_migrate_lockres · 67e2d2eb
      Aditya Pakki authored
      
      
      In the only caller of dlm_migrate_lockres() - dlm_empty_lockres(),
      target is checked for O2NM_MAX_NODES.  Thus, the assertion in
      dlm_migrate_lockres() is unnecessary and can be removed.  The patch
      eliminates such a check.
      
      Link: http://lkml.kernel.org/r/20191218194111.26041-1-pakki001@umn.edu
      Signed-off-by: default avatarAditya Pakki <pakki001@umn.edu>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Junxiao Bi <junxiao.bi@oracle.com>
      Cc: Joseph Qi <jiangqi903@gmail.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Gang He <ghe@suse.com>
      Cc: Jun Piao <piaojun@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      67e2d2eb
    • Luca Ceresoli's avatar
      scripts/spelling.txt: add "issus" typo · 4efc61c7
      Luca Ceresoli authored
      
      
      Add "issus" and correct it as "issues".
      
      Link: http://lkml.kernel.org/r/20200105221950.8384-1-luca@lucaceresoli.net
      Signed-off-by: default avatarLuca Ceresoli <luca@lucaceresoli.net>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4efc61c7
    • Xiong's avatar
      scripts/spelling.txt: add more spellings to spelling.txt · 2ab1278f
      Xiong authored
      
      
      Here are some of the common spelling mistakes and typos that I've found
      while fixing up spelling mistakes in the kernel.  Most of them still
      exist in more than two source files.
      
      Link: http://lkml.kernel.org/r/20191229143626.51238-1-xndchn@gmail.com
      Signed-off-by: default avatarXiong <xndchn@gmail.com>
      Cc: Colin Ian King <colin.king@canonical.com>
      Cc: Stephen Boyd <sboyd@kernel.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Chris Paterson <chris.paterson2@renesas.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      2ab1278f
    • Yang Shi's avatar
      mm: move_pages: report the number of non-attempted pages · 5984fabb
      Yang Shi authored
      Since commit a49bd4d7 ("mm, numa: rework do_pages_move"), the
      semantic of move_pages() has changed to return the number of
      non-migrated pages if they were result of a non-fatal reasons (usually a
      busy page).
      
      This was an unintentional change that hasn't been noticed except for LTP
      tests which checked for the documented behavior.
      
      There are two ways to go around this change.  We can even get back to
      the original behavior and return -EAGAIN whenever migrate_pages is not
      able to migrate pages due to non-fatal reasons.  Another option would be
      to simply continue with the changed semantic and extend move_pages
      documentation to clarify that -errno is returned on an invalid input or
      when migration simply cannot succeed (e.g.  -ENOMEM, -EBUSY) or the
      number of pages that couldn't have been migrated due to ephemeral
      reasons (e.g.  page is pinned or locked for other reasons).
      
      This patch implements the second option because this behavior is in
      place for some time without anybody complaining and possibly new users
      depending on it.  Also it allows to have a slightly easier error
      handling as the caller knows that it is worth to retry when err > 0.
      
      But since the new semantic would be aborted immediately if migration is
      failed due to ephemeral reasons, need include the number of
      non-attempted pages in the return value too.
      
      Link: http://lkml.kernel.org/r/1580160527-109104-1-git-send-email-yang.shi@linux.alibaba.com
      Fixes: a49bd4d7
      
       ("mm, numa: rework do_pages_move")
      Signed-off-by: default avatarYang Shi <yang.shi@linux.alibaba.com>
      Suggested-by: default avatarMichal Hocko <mhocko@suse.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Reviewed-by: default avatarWei Yang <richardw.yang@linux.intel.com>
      Cc: <stable@vger.kernel.org>    [4.17+]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      5984fabb
    • Wei Yang's avatar
      mm: thp: don't need care deferred split queue in memcg charge move path · fac0516b
      Wei Yang authored
      If compound is true, this means it is a PMD mapped THP.  Which implies
      the page is not linked to any defer list.  So the first code chunk will
      not be executed.
      
      Also with this reason, it would not be proper to add this page to a
      defer list.  So the second code chunk is not correct.
      
      Based on this, we should remove the defer list related code.
      
      [yang.shi@linux.alibaba.com: better patch title]
      Link: http://lkml.kernel.org/r/20200117233836.3434-1-richardw.yang@linux.intel.com
      Fixes: 87eaceb3
      
       ("mm: thp: make deferred split shrinker memcg aware")
      Signed-off-by: default avatarWei Yang <richardw.yang@linux.intel.com>
      Suggested-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Acked-by: default avatarYang Shi <yang.shi@linux.alibaba.com>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
      Cc: <stable@vger.kernel.org>    [5.4+]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      fac0516b
    • Dan Williams's avatar
      mm/memory_hotplug: fix remove_memory() lockdep splat · f1037ec0
      Dan Williams authored
      The daxctl unit test for the dax_kmem driver currently triggers the
      (false positive) lockdep splat below.  It results from the fact that
      remove_memory_block_devices() is invoked under the mem_hotplug_lock()
      causing lockdep entanglements with cpu_hotplug_lock() and sysfs (kernfs
      active state tracking).  It is a false positive because the sysfs
      attribute path triggering the memory remove is not the same attribute
      path associated with memory-block device.
      
      sysfs_break_active_protection() is not applicable since there is no real
      deadlock conflict, instead move memory-block device removal outside the
      lock.  The mem_hotplug_lock() is not needed to synchronize the
      memory-block device removal vs the page online state, that is already
      handled by lock_device_hotplug().  Specifically, lock_device_hotplug()
      is sufficient to allow try_remove_memory() to check the offline state of
      the memblocks and be assured that any in progress online attempts are
      flushed / blocked by kernfs_drain() / attribute removal.
      
      The add_memory() path safely creates memblock devices under the
      mem_hotplug_lock().  There is no kernfs active state synchronization in
      the memblock device_register() path, so nothing to fix there.
      
      This change is only possible thanks to the recent change that refactored
      memory block device removal out of arch_remove_memory() (commit
      4c4b7f9b
      
       "mm/memory_hotplug: remove memory block devices before
      arch_remove_memory()"), and David's due diligence tracking down the
      guarantees afforded by kernfs_drain().  Not flagged for -stable since
      this only impacts ongoing development and lockdep validation, not a
      runtime issue.
      
          ======================================================
          WARNING: possible circular locking dependency detected
          5.5.0-rc3+ #230 Tainted: G           OE
          ------------------------------------------------------
          lt-daxctl/6459 is trying to acquire lock:
          ffff99c7f0003510 (kn->count#241){++++}, at: kernfs_remove_by_name_ns+0x41/0x80
      
          but task is already holding lock:
          ffffffffa76a5450 (mem_hotplug_lock.rw_sem){++++}, at: percpu_down_write+0x20/0xe0
      
          which lock already depends on the new lock.
      
          the existing dependency chain (in reverse order) is:
      
          -> #2 (mem_hotplug_lock.rw_sem){++++}:
                 __lock_acquire+0x39c/0x790
                 lock_acquire+0xa2/0x1b0
                 get_online_mems+0x3e/0xb0
                 kmem_cache_create_usercopy+0x2e/0x260
                 kmem_cache_create+0x12/0x20
                 ptlock_cache_init+0x20/0x28
                 start_kernel+0x243/0x547
                 secondary_startup_64+0xb6/0xc0
      
          -> #1 (cpu_hotplug_lock.rw_sem){++++}:
                 __lock_acquire+0x39c/0x790
                 lock_acquire+0xa2/0x1b0
                 cpus_read_lock+0x3e/0xb0
                 online_pages+0x37/0x300
                 memory_subsys_online+0x17d/0x1c0
                 device_online+0x60/0x80
                 state_store+0x65/0xd0
                 kernfs_fop_write+0xcf/0x1c0
                 vfs_write+0xdb/0x1d0
                 ksys_write+0x65/0xe0
                 do_syscall_64+0x5c/0xa0
                 entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
          -> #0 (kn->count#241){++++}:
                 check_prev_add+0x98/0xa40
                 validate_chain+0x576/0x860
                 __lock_acquire+0x39c/0x790
                 lock_acquire+0xa2/0x1b0
                 __kernfs_remove+0x25f/0x2e0
                 kernfs_remove_by_name_ns+0x41/0x80
                 remove_files.isra.0+0x30/0x70
                 sysfs_remove_group+0x3d/0x80
                 sysfs_remove_groups+0x29/0x40
                 device_remove_attrs+0x39/0x70
                 device_del+0x16a/0x3f0
                 device_unregister+0x16/0x60
                 remove_memory_block_devices+0x82/0xb0
                 try_remove_memory+0xb5/0x130
                 remove_memory+0x26/0x40
                 dev_dax_kmem_remove+0x44/0x6a [kmem]
                 device_release_driver_internal+0xe4/0x1c0
                 unbind_store+0xef/0x120
                 kernfs_fop_write+0xcf/0x1c0
                 vfs_write+0xdb/0x1d0
                 ksys_write+0x65/0xe0
                 do_syscall_64+0x5c/0xa0
                 entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
          other info that might help us debug this:
      
          Chain exists of:
            kn->count#241 --> cpu_hotplug_lock.rw_sem --> mem_hotplug_lock.rw_sem
      
           Possible unsafe locking scenario:
      
                 CPU0                    CPU1
                 ----                    ----
            lock(mem_hotplug_lock.rw_sem);
                                         lock(cpu_hotplug_lock.rw_sem);
                                         lock(mem_hotplug_lock.rw_sem);
            lock(kn->count#241);
      
           *** DEADLOCK ***
      
      No fixes tag as this has been a long standing issue that predated the
      addition of kernfs lockdep annotations.
      
      Link: http://lkml.kernel.org/r/157991441887.2763922.4770790047389427325.stgit@dwillia2-desk3.amr.corp.intel.com
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Cc: Vishal Verma <vishal.l.verma@intel.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Cc: Dave Hansen <dave.hansen@linux.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>
      f1037ec0
    • Wei Yang's avatar
      mm/migrate.c: also overwrite error when it is bigger than zero · dfe9aa23
      Wei Yang authored
      If we get here after successfully adding page to list, err would be 1 to
      indicate the page is queued in the list.
      
      Current code has two problems:
      
        * on success, 0 is not returned
        * on error, if add_page_for_migratioin() return 1, and the following err1
          from do_move_pages_to_node() is set, the err1 is not returned since err
          is 1
      
      And these behaviors break the user interface.
      
      Link: http://lkml.kernel.org/r/20200119065753.21694-1-richardw.yang@linux.intel.com
      Fixes: e0153fc2
      
       ("mm: move_pages: return valid node id in status if the page is already on the target node").
      Signed-off-by: default avatarWei Yang <richardw.yang@linux.intel.com>
      Acked-by: default avatarYang Shi <yang.shi@linux.alibaba.com>
      Cc: John Hubbard <jhubbard@nvidia.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Michal Hocko <mhocko@kernel.org>
      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>
      dfe9aa23
    • Pingfan Liu's avatar
      mm/sparse.c: reset section's mem_map when fully deactivated · 1f503443
      Pingfan Liu authored
      After commit ba72b4c8
      
       ("mm/sparsemem: support sub-section hotplug"),
      when a mem section is fully deactivated, section_mem_map still records
      the section's start pfn, which is not used any more and will be
      reassigned during re-addition.
      
      In analogy with alloc/free pattern, it is better to clear all fields of
      section_mem_map.
      
      Beside this, it breaks the user space tool "makedumpfile" [1], which
      makes assumption that a hot-removed section has mem_map as NULL, instead
      of checking directly against SECTION_MARKED_PRESENT bit.  (makedumpfile
      will be better to change the assumption, and need a patch)
      
      The bug can be reproduced on IBM POWERVM by "drmgr -c mem -r -q 5" ,
      trigger a crash, and save vmcore by makedumpfile
      
      [1]: makedumpfile, commit e73016540293 ("[v1.6.7] Update version")
      
      Link: http://lkml.kernel.org/r/1579487594-28889-1-git-send-email-kernelfans@gmail.com
      Signed-off-by: default avatarPingfan Liu <kernelfans@gmail.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Oscar Salvador <osalvador@suse.de>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Qian Cai <cai@lca.pw>
      Cc: Kazuhito Hagio <k-hagio@ab.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>
      1f503443
    • Dan Carpenter's avatar
      mm/mempolicy.c: fix out of bounds write in mpol_parse_str() · c7a91bc7
      Dan Carpenter authored
      
      
      What we are trying to do is change the '=' character to a NUL terminator
      and then at the end of the function we restore it back to an '='.  The
      problem is there are two error paths where we jump to the end of the
      function before we have replaced the '=' with NUL.
      
      We end up putting the '=' in the wrong place (possibly one element
      before the start of the buffer).
      
      Link: http://lkml.kernel.org/r/20200115055426.vdjwvry44nfug7yy@kili.mountain
      Reported-by: default avatar <syzbot+e64a13c5369a194d67df@syzkaller.appspotmail.com>
      Fixes: 095f1fc4
      
       ("mempolicy: rework shmem mpol parsing and display")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Acked-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Dmitry Vyukov <dvyukov@google.com>
      Cc: Michal Hocko <mhocko@kernel.org>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Cc: Lee Schermerhorn <lee.schermerhorn@hp.com>
      Cc: Andrea Arcangeli <aarcange@redhat.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>
      c7a91bc7
    • Theodore Ts'o's avatar
      memcg: fix a crash in wb_workfn when a device disappears · 68f23b89
      Theodore Ts'o authored
      
      
      Without memcg, there is a one-to-one mapping between the bdi and
      bdi_writeback structures.  In this world, things are fairly
      straightforward; the first thing bdi_unregister() does is to shutdown
      the bdi_writeback structure (or wb), and part of that writeback ensures
      that no other work queued against the wb, and that the wb is fully
      drained.
      
      With memcg, however, there is a one-to-many relationship between the bdi
      and bdi_writeback structures; that is, there are multiple wb objects
      which can all point to a single bdi.  There is a refcount which prevents
      the bdi object from being released (and hence, unregistered).  So in
      theory, the bdi_unregister() *should* only get called once its refcount
      goes to zero (bdi_put will drop the refcount, and when it is zero,
      release_bdi gets called, which calls bdi_unregister).
      
      Unfortunately, del_gendisk() in block/gen_hd.c never got the memo about
      the Brave New memcg World, and calls bdi_unregister directly.  It does
      this without informing the file system, or the memcg code, or anything
      else.  This causes the root wb associated with the bdi to be
      unregistered, but none of the memcg-specific wb's are shutdown.  So when
      one of these wb's are woken up to do delayed work, they try to
      dereference their wb->bdi->dev to fetch the device name, but
      unfortunately bdi->dev is now NULL, thanks to the bdi_unregister()
      called by del_gendisk().  As a result, *boom*.
      
      Fortunately, it looks like the rest of the writeback path is perfectly
      happy with bdi->dev and bdi->owner being NULL, so the simplest fix is to
      create a bdi_dev_name() function which can handle bdi->dev being NULL.
      This also allows us to bulletproof the writeback tracepoints to prevent
      them from dereferencing a NULL pointer and crashing the kernel if one is
      tracing with memcg's enabled, and an iSCSI device dies or a USB storage
      stick is pulled.
      
      The most common way of triggering this will be hotremoval of a device
      while writeback with memcg enabled is going on.  It was triggering
      several times a day in a heavily loaded production environment.
      
      Google Bug Id: 145475544
      
      Link: https://lore.kernel.org/r/20191227194829.150110-1-tytso@mit.edu
      Link: http://lkml.kernel.org/r/20191228005211.163952-1-tytso@mit.edu
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: Chris Mason <clm@fb.com>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Jens Axboe <axboe@kernel.dk>
      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>
      68f23b89
    • Andy Shevchenko's avatar
      lib/test_bitmap: correct test data offsets for 32-bit · 69334ca5
      Andy Shevchenko authored
      On 32-bit platform the size of long is only 32 bits which makes wrong
      offset in the array of 64 bit size.
      
      Calculate offset based on BITS_PER_LONG.
      
      Link: http://lkml.kernel.org/r/20200109103601.45929-1-andriy.shevchenko@linux.intel.com
      Fixes: 30544ed5
      
       ("lib/bitmap: introduce bitmap_replace() helper")
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Reported-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: Yury Norov <yury.norov@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>
      69334ca5
  2. Jan 30, 2020
    • Linus Torvalds's avatar
      Merge tag 'for-linus-hmm' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma · 39bed42d
      Linus Torvalds authored
      Pull mmu_notifier updates from Jason Gunthorpe:
       "This small series revises the names in mmu_notifier to make the code
        clearer and more readable"
      
      * tag 'for-linus-hmm' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma:
        mm/mmu_notifiers: Use 'interval_sub' as the variable for mmu_interval_notifier
        mm/mmu_notifiers: Use 'subscription' as the variable name for mmu_notifier
        mm/mmu_notifier: Rename struct mmu_notifier_mm to mmu_notifier_subscriptions
      39bed42d
    • Linus Torvalds's avatar
      Merge tag 'threads-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux · 83fa805b
      Linus Torvalds authored
      Pull thread management updates from Christian Brauner:
       "Sargun Dhillon over the last cycle has worked on the pidfd_getfd()
        syscall.
      
        This syscall allows for the retrieval of file descriptors of a process
        based on its pidfd. A task needs to have ptrace_may_access()
        permissions with PTRACE_MODE_ATTACH_REALCREDS (suggested by Oleg and
        Andy) on the target.
      
        One of the main use-cases is in combination with seccomp's user
        notification feature. As a reminder, seccomp's user notification
        feature was made available in v5.0. It allows a task to retrieve a
        file descriptor for its seccomp filter. The file descriptor is usually
        handed of to a more privileged supervising process. The supervisor can
        then listen for syscall events caught by the seccomp filter of the
        supervisee and perform actions in lieu of the supervisee, usually
        emulating syscalls. pidfd_getfd() is needed to expand its uses.
      
        There are currently two major users that wait on pidfd_getfd() and one
        future user:
      
         - Netflix, Sargun said, is working on a service mesh where users
           should be able to connect to a dns-based VIP. When a user connects
           to e.g. 1.2.3.4:80 that runs e.g. service "foo" they will be
           redirected to an envoy process. This service mesh uses seccomp user
           notifications and pidfd to intercept all connect calls and instead
           of connecting them to 1.2.3.4:80 connects them to e.g.
           127.0.0.1:8080.
      
         - LXD uses the seccomp notifier heavily to intercept and emulate
           mknod() and mount() syscalls for unprivileged containers/processes.
           With pidfd_getfd() more uses-cases e.g. bridging socket connections
           will be possible.
      
         - The patchset has also seen some interest from the browser corner.
           Right now, Firefox is using a SECCOMP_RET_TRAP sandbox managed by a
           broker process. In the future glibc will start blocking all signals
           during dlopen() rendering this type of sandbox impossible. Hence,
           in the future Firefox will switch to a seccomp-user-nofication
           based sandbox which also makes use of file descriptor retrieval.
           The thread for this can be found at
           https://sourceware.org/ml/libc-alpha/2019-12/msg00079.html
      
        With pidfd_getfd() it is e.g. possible to bridge socket connections
        for the supervisee (binding to a privileged port) and taking actions
        on file descriptors on behalf of the supervisee in general.
      
        Sargun's first version was using an ioctl on pidfds but various people
        pushed for it to be a proper syscall which he duely implemented as
        well over various review cycles. Selftests are of course included.
        I've also added instructions how to deal with merge conflicts below.
      
        There's also a small fix coming from the kernel mentee project to
        correctly annotate struct sighand_struct with __rcu to fix various
        sparse warnings. We've received a few more such fixes and even though
        they are mostly trivial I've decided to postpone them until after -rc1
        since they came in rather late and I don't want to risk introducing
        build warnings.
      
        Finally, there's a new prctl() command PR_{G,S}ET_IO_FLUSHER which is
        needed to avoid allocation recursions triggerable by storage drivers
        that have userspace parts that run in the IO path (e.g. dm-multipath,
        iscsi, etc). These allocation recursions deadlock the device.
      
        The new prctl() allows such privileged userspace components to avoid
        allocation recursions by setting the PF_MEMALLOC_NOIO and
        PF_LESS_THROTTLE flags. The patch carries the necessary acks from the
        relevant maintainers and is routed here as part of prctl()
        thread-management."
      
      * tag 'threads-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux:
        prctl: PR_{G,S}ET_IO_FLUSHER to support controlling memory reclaim
        sched.h: Annotate sighand_struct with __rcu
        test: Add test for pidfd getfd
        arch: wire up pidfd_getfd syscall
        pid: Implement pidfd_getfd syscall
        vfs, fdtable: Add fget_task helper
      83fa805b
    • Linus Torvalds's avatar
      Merge tag 'for-5.6/io_uring-vfs-2020-01-29' of git://git.kernel.dk/linux-block · 896f8d23
      Linus Torvalds authored
      Pull io_uring updates from Jens Axboe:
      
       - Support for various new opcodes (fallocate, openat, close, statx,
         fadvise, madvise, openat2, non-vectored read/write, send/recv, and
         epoll_ctl)
      
       - Faster ring quiesce for fileset updates
      
       - Optimizations for overflow condition checking
      
       - Support for max-sized clamping
      
       - Support for probing what opcodes are supported
      
       - Support for io-wq backend sharing between "sibling" rings
      
       - Support for registering personalities
      
       - Lots of little fixes and improvements
      
      * tag 'for-5.6/io_uring-vfs-2020-01-29' of git://git.kernel.dk/linux-block: (64 commits)
        io_uring: add support for epoll_ctl(2)
        eventpoll: support non-blocking do_epoll_ctl() calls
        eventpoll: abstract out epoll_ctl() handler
        io_uring: fix linked command file table usage
        io_uring: support using a registered personality for commands
        io_uring: allow registering credentials
        io_uring: add io-wq workqueue sharing
        io-wq: allow grabbing existing io-wq
        io_uring/io-wq: don't use static creds/mm assignments
        io-wq: make the io_wq ref counted
        io_uring: fix refcounting with batched allocations at OOM
        io_uring: add comment for drain_next
        io_uring: don't attempt to copy iovec for READ/WRITE
        io_uring: honor IOSQE_ASYNC for linked reqs
        io_uring: prep req when do IOSQE_ASYNC
        io_uring: use labeled array init in io_op_defs
        io_uring: optimise sqe-to-req flags translation
        io_uring: remove REQ_F_IO_DRAINED
        io_uring: file switch work needs to get flushed on exit
        io_uring: hide uring_fd in ctx
        ...
      896f8d23
    • Linus Torvalds's avatar
      Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi · 33c84e89
      Linus Torvalds authored
      Pull SCSI updates from James Bottomley:
       "This series is slightly unusual because it includes Arnd's compat
        ioctl tree here:
      
          1c46a2cf Merge tag 'block-ioctl-cleanup-5.6' into 5.6/scsi-queue
      
        Excluding Arnd's changes, this is mostly an update of the usual
        drivers: megaraid_sas, mpt3sas, qla2xxx, ufs, lpfc, hisi_sas.
      
        There are a couple of core and base updates around error propagation
        and atomicity in the attribute container base we use for the SCSI
        transport classes.
      
        The rest is minor changes and updates"
      
      * tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (149 commits)
        scsi: hisi_sas: Rename hisi_sas_cq.pci_irq_mask
        scsi: hisi_sas: Add prints for v3 hw interrupt converge and automatic affinity
        scsi: hisi_sas: Modify the file permissions of trigger_dump to write only
        scsi: hisi_sas: Replace magic number when handle channel interrupt
        scsi: hisi_sas: replace spin_lock_irqsave/spin_unlock_restore with spin_lock/spin_unlock
        scsi: hisi_sas: use threaded irq to process CQ interrupts
        scsi: ufs: Use UFS device indicated maximum LU number
        scsi: ufs: Add max_lu_supported in struct ufs_dev_info
        scsi: ufs: Delete is_init_prefetch from struct ufs_hba
        scsi: ufs: Inline two functions into their callers
        scsi: ufs: Move ufshcd_get_max_pwr_mode() to ufshcd_device_params_init()
        scsi: ufs: Split ufshcd_probe_hba() based on its called flow
        scsi: ufs: Delete struct ufs_dev_desc
        scsi: ufs: Fix ufshcd_probe_hba() reture value in case ufshcd_scsi_add_wlus() fails
        scsi: ufs-mediatek: enable low-power mode for hibern8 state
        scsi: ufs: export some functions for vendor usage
        scsi: ufs-mediatek: add dbg_register_dump implementation
        scsi: qla2xxx: Fix a NULL pointer dereference in an error path
        scsi: qla1280: Make checking for 64bit support consistent
        scsi: megaraid_sas: Update driver version to 07.713.01.00-rc1
        ...
      33c84e89
    • Linus Torvalds's avatar
      Merge tag 'for-5.6/dm-changes' of... · e9f8ca0a
      Linus Torvalds authored
      Merge tag 'for-5.6/dm-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm
      
      Pull device mapper updates from Mike Snitzer:
      
       - Fix DM core's potential for q->make_request_fn NULL pointer in the
         unlikely case that a DM device is created without a DM table and then
         accessed due to upper-layer userspace code or user error.
      
       - Fix DM thin-provisioning's metadata_pre_commit_callback to not use
         memory after it is free'd. Also refactor code to disallow changing
         the thin-pool's data device once in use -- doing so guarantees smae
         lifetime of pool's data device relative to the pool metadata.
      
       - Fix DM space maps used by DM thinp and DM cache to avoid reuse of a
         already used block. This race was identified with extremely heavy
         snapshot use in the context of DM thin provisioning.
      
       - Fix DM raid's table status relative to an active rebuild.
      
       - Fix DM crypt to use GFP_NOIO rather than GFP_NOFS in call to
         skcipher_request_alloc(). Also fix benbi IV constructor crash if used
         in authenticated mode.
      
       - Add DM crypt support for Elephant diffuser to allow for Bitlocker
         compatibility.
      
       - Fix DM verity target to not prefetch hash blocks for data that has
         already been verified.
      
       - Fix DM writecache's incorrect flush sequence during commit when in
         SSD mode.
      
       - Improve DM writecache's sequential write performance on SSDs.
      
       - Add DM zoned target support for zone sizes smaller than 128MiB.
      
       - Add DM multipath 'queue_if_no_path_timeout_secs' module param to
         allow timeout if path isn't reinstated. This allows users a kernel
         safety-net against IO hanging indefinitely, due to no active paths,
         that has historically only been provided by multipathd userspace.
      
       - Various DM code cleanups to use true/false rather than 1/0, a
         variable rename in dm-dust, and fix for a math error in comment for
         DM thin metadata's ondisk format.
      
      * tag 'for-5.6/dm-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm: (21 commits)
        dm: fix potential for q->make_request_fn NULL pointer
        dm writecache: improve performance of large linear writes on SSDs
        dm mpath: Add timeout mechanism for queue_if_no_path
        dm thin: change data device's flush_bio to be member of struct pool
        dm thin: don't allow changing data device during thin-pool reload
        dm thin: fix use-after-free in metadata_pre_commit_callback
        dm thin metadata: use pool locking at end of dm_pool_metadata_close
        dm writecache: fix incorrect flush sequence when doing SSD mode commit
        dm crypt: fix benbi IV constructor crash if used in authenticated mode
        dm crypt: Implement Elephant diffuser for Bitlocker compatibility
        dm space map common: fix to ensure new block isn't already in use
        dm verity: don't prefetch hash blocks for already-verified data
        dm crypt: fix GFP flags passed to skcipher_request_alloc()
        dm thin metadata: Fix trivial math error in on-disk format documentation
        dm thin metadata: use true/false for bool variable
        dm snapshot: use true/false for bool variable
        dm bio prison v2: use true/false for bool variable
        dm mpath: use true/false for bool variable
        dm zoned: support zone sizes smaller than 128MiB
        dm raid: table line rebuild status fixes
        ...
      e9f8ca0a
    • Linus Torvalds's avatar
      Merge tag 'docs-5.6' of git://git.lwn.net/linux · 05ef8b97
      Linus Torvalds authored
      Pull documentation updates from Jonathan Corbet:
       "It has been a relatively quiet cycle for documentation, but there's
        still a couple of things of note:
      
         - Conversion of the NFS documentation to RST
      
         - A new document on how to help with documentation (and a maintainer
           profile entry too)
      
        Plus the usual collection of typo fixes, etc"
      
      * tag 'docs-5.6' of git://git.lwn.net/linux: (40 commits)
        docs: filesystems: add overlayfs to index.rst
        docs: usb: remove some broken references
        scripts/find-unused-docs: Fix massive false positives
        docs: nvdimm: use ReST notation for subsection
        zram: correct documentation about sysfs node of huge page writeback
        Documentation: zram: various fixes in zram.rst
        Add a maintainer entry profile for documentation
        Add a document on how to contribute to the documentation
        docs: Keep up with the location of NoUri
        Documentation: Call out example SYM_FUNC_* usage as x86-specific
        Documentation: nfs: fault_injection: convert to ReST
        Documentation: nfs: pnfs-scsi-server: convert to ReST
        Documentation: nfs: convert pnfs-block-server to ReST
        Documentation: nfs: idmapper: convert to ReST
        Documentation: convert nfsd-admin-interfaces to ReST
        Documentation: nfs-rdma: convert to ReST
        Documentation: nfsroot.rst: COSMETIC: refill a paragraph
        Documentation: nfsroot.txt: convert to ReST
        Documentation: convert nfs.txt to ReST
        Documentation: filesystems: convert vfat.txt to RST
        ...
      05ef8b97
    • Linus Torvalds's avatar
      Merge tag 'linux-kselftest-5.6-rc1-kunit' of... · 08a3ef8f
      Linus Torvalds authored
      Merge tag 'linux-kselftest-5.6-rc1-kunit' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
      
      Pull Kselftest kunit updates from Shuah Khan:
       "This kunit update consists of:
      
         - Support for building kunit as a module from Alan Maguire
      
         - AppArmor KUnit tests for policy unpack from Mike Salvatore"
      
      * tag 'linux-kselftest-5.6-rc1-kunit' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
        kunit: building kunit as a module breaks allmodconfig
        kunit: update documentation to describe module-based build
        kunit: allow kunit to be loaded as a module
        kunit: remove timeout dependence on sysctl_hung_task_timeout_seconds
        kunit: allow kunit tests to be loaded as a module
        kunit: hide unexported try-catch interface in try-catch-impl.h
        kunit: move string-stream.h to lib/kunit
        apparmor: add AppArmor KUnit tests for policy unpack
      08a3ef8f
    • Linus Torvalds's avatar
      Merge tag 'linux-kselftest-5.6-rc1' of... · ce7ae9d9
      Linus Torvalds authored
      Merge tag 'linux-kselftest-5.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
      
      Pull Kselftest update from Shuah Khan:
       "This Kselftest update consists of several fixes to framework and
        individual tests.
      
        In addition, it enables LKDTM tests adding lkdtm target to kselftest
        Makefile"
      
      * tag 'linux-kselftest-5.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
        selftests/ftrace: fix glob selftest
        selftests: settings: tests can be in subsubdirs
        kselftest: Minimise dependency of get_size on C library interfaces
        selftests/livepatch: Remove unused local variable in set_ftrace_enabled()
        selftests/livepatch: Replace set_dynamic_debug() with setup_config() in README
        selftests/lkdtm: Add tests for LKDTM targets
        selftests: Uninitialized variable in test_cgcore_proc_migration()
        selftests: fix build behaviour on targets' failures
      ce7ae9d9
    • Linus Torvalds's avatar
      Merge tag 'y2038-drivers-for-v5.6-signed' of... · 22b17db4
      Linus Torvalds authored
      Merge tag 'y2038-drivers-for-v5.6-signed' of git://git.kernel.org:/pub/scm/linux/kernel/git/arnd/playground
      
      Pull y2038 updates from Arnd Bergmann:
       "Core, driver and file system changes
      
        These are updates to device drivers and file systems that for some
        reason or another were not included in the kernel in the previous
        y2038 series.
      
        I've gone through all users of time_t again to make sure the kernel is
        in a long-term maintainable state, replacing all remaining references
        to time_t with safe alternatives.
      
        Some related parts of the series were picked up into the nfsd, xfs,
        alsa and v4l2 trees. A final set of patches in linux-mm removes the
        now unused time_t/timeval/timespec types and helper functions after
        all five branches are merged for linux-5.6, ensuring that no new users
        get merged.
      
        As a result, linux-5.6, or my backport of the patches to 5.4 [1],
        should be the first release that can serve as a base for a 32-bit
        system designed to run beyond year 2038, with a few remaining caveats:
      
         - All user space must be compiled with a 64-bit time_t, which will be
           supported in the coming musl-1.2 and glibc-2.32 releases, along
           with installed kernel headers from linux-5.6 or higher.
      
         - Applications that use the system call interfaces directly need to
           be ported to use the time64 syscalls added in linux-5.1 in place of
           the existing system calls. This impacts most users of futex() and
           seccomp() as well as programming languages that have their own
           runtime environment not based on libc.
      
         - Applications that use a private copy of kernel uapi header files or
           their contents may need to update to the linux-5.6 version, in
           particular for sound/asound.h, xfs/xfs_fs.h, linux/input.h,
           linux/elfcore.h, linux/sockios.h, linux/timex.h and
           linux/can/bcm.h.
      
         - A few remaining interfaces cannot be changed to pass a 64-bit
           time_t in a compatible way, so they must be configured to use
           CLOCK_MONOTONIC times or (with a y2106 problem) unsigned 32-bit
           timestamps. Most importantly this impacts all users of 'struct
           input_event'.
      
         - All y2038 problems that are present on 64-bit machines also apply
           to 32-bit machines. In particular this affects file systems with
           on-disk timestamps using signed 32-bit seconds: ext4 with
           ext3-style small inodes, ext2, xfs (to be fixed soon) and ufs"
      
      [1] https://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git/log/?h=y2038-endgame
      
      * tag 'y2038-drivers-for-v5.6-signed' of git://git.kernel.org:/pub/scm/linux/kernel/git/arnd/playground: (21 commits)
        Revert "drm/etnaviv: reject timeouts with tv_nsec >= NSEC_PER_SEC"
        y2038: sh: remove timeval/timespec usage from headers
        y2038: sparc: remove use of struct timex
        y2038: rename itimerval to __kernel_old_itimerval
        y2038: remove obsolete jiffies conversion functions
        nfs: fscache: use timespec64 in inode auxdata
        nfs: fix timstamp debug prints
        nfs: use time64_t internally
        sunrpc: convert to time64_t for expiry
        drm/etnaviv: avoid deprecated timespec
        drm/etnaviv: reject timeouts with tv_nsec >= NSEC_PER_SEC
        drm/msm: avoid using 'timespec'
        hfs/hfsplus: use 64-bit inode timestamps
        hostfs: pass 64-bit timestamps to/from user space
        packet: clarify timestamp overflow
        tsacct: add 64-bit btime field
        acct: stop using get_seconds()
        um: ubd: use 64-bit time_t where possible
        xtensa: ISS: avoid struct timeval
        dlm: use SO_SNDTIMEO_NEW instead of SO_SNDTIMEO_OLD
        ...
      22b17db4
    • Linus Torvalds's avatar
      Merge tag 'printk-for-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk · a4fe2b4d
      Linus Torvalds authored
      Pull printk update from Petr Mladek:
       "Prevent replaying log on all consoles"
      
      * tag 'printk-for-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk:
        printk: fix exclusive_console replaying
      a4fe2b4d
    • Jens Axboe's avatar
      io_uring: add support for epoll_ctl(2) · 3e4827b0
      Jens Axboe authored
      
      
      This adds IORING_OP_EPOLL_CTL, which can perform the same work as the
      epoll_ctl(2) system call.
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      3e4827b0
    • Jens Axboe's avatar
      eventpoll: support non-blocking do_epoll_ctl() calls · 39220e8d
      Jens Axboe authored
      
      
      Also make it available outside of epoll, along with the helper that
      decides if we need to copy the passed in epoll_event.
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      39220e8d
    • Jens Axboe's avatar
      eventpoll: abstract out epoll_ctl() handler · 58e41a44
      Jens Axboe authored
      
      
      No functional changes in this patch.
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      58e41a44
    • Jens Axboe's avatar
      io_uring: fix linked command file table usage · f86cd20c
      Jens Axboe authored
      
      
      We're not consistent in how the file table is grabbed and assigned if we
      have a command linked that requires the use of it.
      
      Add ->file_table to the io_op_defs[] array, and use that to determine
      when to grab the table instead of having the handlers set it if they
      need to defer. This also means we can kill the IO_WQ_WORK_NEEDS_FILES
      flag. We always initialize work->files, so io-wq can just check for
      that.
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      f86cd20c
    • Linus Torvalds's avatar
      Merge tag 'erofs-for-5.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs · 3893c202
      Linus Torvalds authored
      Pull erofs updates from Gao Xiang:
       "A regression fix, several cleanups and (maybe) plus an upcoming new
        mount api convert patch as a part of vfs update are considered
        available for this cycle.
      
        All commits have been in linux-next and tested with no smoke out.
      
        Summary:
      
         - fix an out-of-bound read access introduced in v5.3, which could
           rarely cause data corruption
      
         - various cleanup patches"
      
      * tag 'erofs-for-5.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs:
        erofs: clean up z_erofs_submit_queue()
        erofs: fold in postsubmit_is_all_bypassed()
        erofs: fix out-of-bound read for shifted uncompressed block
        erofs: remove void tagging/untagging of workgroup pointers
        erofs: remove unused tag argument while registering a workgroup
        erofs: remove unused tag argument while finding a workgroup
        erofs: correct indentation of an assigned structure inside a function
      3893c202
    • Linus Torvalds's avatar
      Merge branch 'work.adfs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs · 53070406
      Linus Torvalds authored
      Pull adfs updates from Al Viro:
       "adfs stuff for this cycle"
      
      * 'work.adfs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (42 commits)
        fs/adfs: bigdir: Fix an error code in adfs_fplus_read()
        Documentation: update adfs filesystem documentation
        fs/adfs: mostly divorse inode number from indirect disc address
        fs/adfs: super: add support for E and E+ floppy image formats
        fs/adfs: super: extract filesystem block probe
        fs/adfs: dir: remove debug in adfs_dir_update()
        fs/adfs: super: fix inode dropping
        fs/adfs: bigdir: implement directory update support
        fs/adfs: bigdir: calculate and validate directory checkbyte
        fs/adfs: bigdir: directory validation strengthening
        fs/adfs: bigdir: extract directory validation
        fs/adfs: bigdir: factor out directory entry offset calculation
        fs/adfs: newdir: split out directory commit from update
        fs/adfs: newdir: clean up adfs_f_update()
        fs/adfs: newdir: merge adfs_dir_read() into adfs_f_read()
        fs/adfs: newdir: improve directory validation
        fs/adfs: newdir: factor out directory format validation
        fs/adfs: dir: use pointers to access directory head/tails
        fs/adfs: dir: add more efficient iterate() per-format method
        fs/adfs: dir: switch to iterate_shared method
        ...
      53070406
    • Linus Torvalds's avatar
      Merge branch 'work.openat2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs · 6aee4bad
      Linus Torvalds authored
      Pull openat2 support from Al Viro:
       "This is the openat2() series from Aleksa Sarai.
      
        I'm afraid that the rest of namei stuff will have to wait - it got
        zero review the last time I'd posted #work.namei, and there had been a
        leak in the posted series I'd caught only last weekend. I was going to
        repost it on Monday, but the window opened and the odds of getting any
        review during that... Oh, well.
      
        Anyway, openat2 part should be ready; that _did_ get sane amount of
        review and public testing, so here it comes"
      
      From Aleksa's description of the series:
       "For a very long time, extending openat(2) with new features has been
        incredibly frustrating. This stems from the fact that openat(2) is
        possibly the most famous counter-example to the mantra "don't silently
        accept garbage from userspace" -- it doesn't check whether unknown
        flags are present[1].
      
        This means that (generally) the addition of new flags to openat(2) has
        been fraught with backwards-compatibility issues (O_TMPFILE has to be
        defined as __O_TMPFILE|O_DIRECTORY|[O_RDWR or O_WRONLY] to ensure old
        kernels gave errors, since it's insecure to silently ignore the
        flag[2]). All new security-related flags therefore have a tough road
        to being added to openat(2).
      
        Furthermore, the need for some sort of control over VFS's path
        resolution (to avoid malicious paths resulting in inadvertent
        breakouts) has been a very long-standing desire of many userspace
        applications.
      
        This patchset is a revival of Al Viro's old AT_NO_JUMPS[3] patchset
        (which was a variant of David Drysdale's O_BENEATH patchset[4] which
        was a spin-off of the Capsicum project[5]) with a few additions and
        changes made based on the previous discussion within [6] as well as
        others I felt were useful.
      
        In line with the conclusions of the original discussion of
        AT_NO_JUMPS, the flag has been split up into separate flags. However,
        instead of being an openat(2) flag it is provided through a new
        syscall openat2(2) which provides several other improvements to the
        openat(2) interface (see the patch description for more details). The
        following new LOOKUP_* flags are added:
      
        LOOKUP_NO_XDEV:
      
           Blocks all mountpoint crossings (upwards, downwards, or through
           absolute links). Absolute pathnames alone in openat(2) do not
           trigger this. Magic-link traversal which implies a vfsmount jump is
           also blocked (though magic-link jumps on the same vfsmount are
           permitted).
      
        LOOKUP_NO_MAGICLINKS:
      
           Blocks resolution through /proc/$pid/fd-style links. This is done
           by blocking the usage of nd_jump_link() during resolution in a
           filesystem. The term "magic-links" is used to match with the only
           reference to these links in Documentation/, but I'm happy to change
           the name.
      
           It should be noted that this is different to the scope of
           ~LOOKUP_FOLLOW in that it applies to all path components. However,
           you can do openat2(NO_FOLLOW|NO_MAGICLINKS) on a magic-link and it
           will *not* fail (assuming that no parent component was a
           magic-link), and you will have an fd for the magic-link.
      
           In order to correctly detect magic-links, the introduction of a new
           LOOKUP_MAGICLINK_JUMPED state flag was required.
      
        LOOKUP_BENEATH:
      
           Disallows escapes to outside the starting dirfd's
           tree, using techniques such as ".." or absolute links. Absolute
           paths in openat(2) are also disallowed.
      
           Conceptually this flag is to ensure you "stay below" a certain
           point in the filesystem tree -- but this requires some additional
           to protect against various races that would allow escape using
           "..".
      
           Currently LOOKUP_BENEATH implies LOOKUP_NO_MAGICLINKS, because it
           can trivially beam you around the filesystem (breaking the
           protection). In future, there might be similar safety checks done
           as in LOOKUP_IN_ROOT, but that requires more discussion.
      
        In addition, two new flags are added that expand on the above ideas:
      
        LOOKUP_NO_SYMLINKS:
      
           Does what it says on the tin. No symlink resolution is allowed at
           all, including magic-links. Just as with LOOKUP_NO_MAGICLINKS this
           can still be used with NOFOLLOW to open an fd for the symlink as
           long as no parent path had a symlink component.
      
        LOOKUP_IN_ROOT:
      
           This is an extension of LOOKUP_BENEATH that, rather than blocking
           attempts to move past the root, forces all such movements to be
           scoped to the starting point. This provides chroot(2)-like
           protection but without the cost of a chroot(2) for each filesystem
           operation, as well as being safe against race attacks that
           chroot(2) is not.
      
           If a race is detected (as with LOOKUP_BENEATH) then an error is
           generated, and similar to LOOKUP_BENEATH it is not permitted to
           cross magic-links with LOOKUP_IN_ROOT.
      
           The primary need for this is from container runtimes, which
           currently need to do symlink scoping in userspace[7] when opening
           paths in a potentially malicious container.
      
           There is a long list of CVEs that could have bene mitigated by
           having RESOLVE_THIS_ROOT (such as CVE-2017-1002101,
           CVE-2017-1002102, CVE-2018-15664, and CVE-2019-5736, just to name a
           few).
      
        In order to make all of the above more usable, I'm working on
        libpathrs[8] which is a C-friendly library for safe path resolution.
        It features a userspace-emulated backend if the kernel doesn't support
        openat2(2). Hopefully we can get userspace to switch to using it, and
        thus get openat2(2) support for free once it's ready.
      
        Future work would include implementing things like
        RESOLVE_NO_AUTOMOUNT and possibly a RESOLVE_NO_REMOTE (to allow
        programs to be sure they don't hit DoSes though stale NFS handles)"
      
      * 'work.openat2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
        Documentation: path-lookup: include new LOOKUP flags
        selftests: add openat2(2) selftests
        open: introduce openat2(2) syscall
        namei: LOOKUP_{IN_ROOT,BENEATH}: permit limited ".." resolution
        namei: LOOKUP_IN_ROOT: chroot-like scoped resolution
        namei: LOOKUP_BENEATH: O_BENEATH-like scoped resolution
        namei: LOOKUP_NO_XDEV: block mountpoint crossing
        namei: LOOKUP_NO_MAGICLINKS: block magic-link resolution
        namei: LOOKUP_NO_SYMLINKS: block symlink resolution
        namei: allow set_root() to produce errors
        namei: allow nd_jump_link() to produce errors
        nsfs: clean-up ns_get_path() signature to return int
        namei: only return -ECHILD from follow_dotdot_rcu()
      6aee4bad