1. 16 Jun, 2023 6 commits
    • Linus Torvalds's avatar
      Merge tag 'for-6.4/dm-fixes' of... · 0e306952
      Linus Torvalds authored
      Merge tag 'for-6.4/dm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm
      
      Pull device mapper fixes from Mike Snitzer:
      
       - Fix DM thinp discard performance regression introduced during this
         merge window where DM core was splitting large discards every 128K
         (max_sectors_kb) rather than every 64M (discard_max_bytes).
      
       - Extend DM core LOCKFS fix, made during 6.4 merge, to also fix race
         between do_mount and dm's do_suspend (in addition to the earlier
         fix's do_mount race with dm's do_resume).
      
       - Fix DM thin metadata operations to first check if the thin-pool is in
         "fail_io" mode; otherwise UAF can occur.
      
       - Fix DM thinp's call to __blkdev_issue_discard to use GFP_NOIO rather
         than GFP_NOWAIT (__blkdev_issue_discard cannot handle NULL return
         from bio_alloc).
      
      * tag 'for-6.4/dm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
        dm: use op specific max_sectors when splitting abnormal io
        dm thin: fix issue_discard to pass GFP_NOIO to __blkdev_issue_discard
        dm thin metadata: check fail_io before using data_sm
        dm: don't lock fs when the map is NULL during suspend or resume
      0e306952
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma · 93fd8eb0
      Linus Torvalds authored
      Pull rdma fixes from Jason Gunthorpe:
       "This is an unusually large bunch of bug fixes for the later rc cycle,
        rxe and mlx5 both dumped a lot of things at once. rxe continues to fix
        itself, and mlx5 is fixing a bunch of "queue counters" related bugs.
      
        There is one highly notable bug fix regarding the qkey. This small
        security check was missed in the original 2005 implementation and it
        allows some significant issues.
      
        Summary:
      
         - Two rtrs bug fixes for error unwind bugs
      
         - Several rxe bug fixes:
            * Incorrect Rx packet validation
            * Using memory without a refcount
            * Syzkaller found use before initialization
            * Regression fix for missing locking with the tasklet conversion
              from this merge window
      
         - Have bnxt report the correct link properties to userspace, this was
           a regression in v6.3
      
         - Several mlx5 bug fixes:
            * Kernel crash triggerable by userspace for the RAW ethernet
              profile
            * Defend against steering refcounting issues created by userspace
            * Incorrect change of QP port affinity parameters in some LAG
              configurations
      
         - Fix mlx5 Q counters:
            * Do not over allocate Q counters to allow userspace to use the
              full port capacity
            * Kernel crash triggered by eswitch due to mis-use of Q counters
            * Incorrect mlx5_device for Q counters in some LAG configurations
      
         - Properly implement the IBA spec restricting privileged qkeys to
           root
      
         - Always an error when reading from a disassociated device's event
           queue
      
         - isert bug fixes:
            * Avoid a deadlock with the CM handler and CM ID destruction
            * Correct list corruption due to incorrect locking
            * Fix a use after free around connection tear down"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma:
        RDMA/rxe: Fix rxe_cq_post
        IB/isert: Fix incorrect release of isert connection
        IB/isert: Fix possible list corruption in CMA handler
        IB/isert: Fix dead lock in ib_isert
        RDMA/mlx5: Fix affinity assignment
        IB/uverbs: Fix to consider event queue closing also upon non-blocking mode
        RDMA/uverbs: Restrict usage of privileged QKEYs
        RDMA/cma: Always set static rate to 0 for RoCE
        RDMA/mlx5: Fix Q-counters query in LAG mode
        RDMA/mlx5: Remove vport Q-counters dependency on normal Q-counters
        RDMA/mlx5: Fix Q-counters per vport allocation
        RDMA/mlx5: Create an indirect flow table for steering anchor
        RDMA/mlx5: Initiate dropless RQ for RAW Ethernet functions
        RDMA/rxe: Fix the use-before-initialization error of resp_pkts
        RDMA/bnxt_re: Fix reporting active_{speed,width} attributes
        RDMA/rxe: Fix ref count error in check_rkey()
        RDMA/rxe: Fix packet length checks
        RDMA/rtrs: Fix rxe_dealloc_pd warning
        RDMA/rtrs: Fix the last iu->buf leak in err path
      93fd8eb0
    • Linus Torvalds's avatar
      Merge tag 'spi-fix-v6.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi · b7feaa49
      Linus Torvalds authored
      Pull spi fixes from Mark Brown:
       "A few more driver specific fixes.
      
        The DesignWare fix is for an issue introduced by conversion to the
        chip select accessor functions and is pretty important but the other
        two are less severe"
      
      * tag 'spi-fix-v6.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi:
        spi: dw: Replace incorrect spi_get_chipselect with set
        spi: fsl-dspi: avoid SCK glitches with continuous transfers
        spi: cadence-quadspi: Add missing check for dma_set_mask
      b7feaa49
    • Linus Torvalds's avatar
      Merge tag 'regulator-fix-v6.4-rc6' of... · eee71c34
      Linus Torvalds authored
      Merge tag 'regulator-fix-v6.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
      
      Pull regulator fix from Mark Brown:
       "The set of regulators described for the Qualcomm PM8550 just seems to
        have been completely wrong and would likely not have worked at all if
        anything tried to actually configure anything except for enabling and
        disabling at runtime"
      
      * tag 'regulator-fix-v6.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator:
        regulator: qcom-rpmh: Fix regulators for PM8550
      eee71c34
    • Linus Torvalds's avatar
      Merge tag 'regmap-fix-v6.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap · 231a1e31
      Linus Torvalds authored
      Pull regmap fix from Mark Brown:
       "Another fix for the maple tree cache, Takashi noticed that unlike
        other caches the maple tree cache didn't check for read only registers
        before trying to sync which would result in spurious syncs for read
        only registers where we don't have a default.
      
        This was due to the check being open coded in the caches, we now check
        in the shared 'does this register need sync' function so that is fixed
        for this and future caches"
      
      * tag 'regmap-fix-v6.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap:
        regmap: regcache: Don't sync read-only registers
      231a1e31
    • Linus Torvalds's avatar
      Merge tag 'media/v6.4-6' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media · c926a55f
      Linus Torvalds authored
      Pull media fixes from Mauro Carvalho Chehab:
       "A fix for dvb-core to avoid a race condition during DVB board
        registration"
      
      * tag 'media/v6.4-6' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media:
        Revert "media: dvb-core: Fix use-after-free on race condition at dvb_frontend"
      c926a55f
  2. 15 Jun, 2023 8 commits
  3. 14 Jun, 2023 5 commits
    • Mauro Carvalho Chehab's avatar
      Revert "media: dvb-core: Fix use-after-free on race condition at dvb_frontend" · ec21a38d
      Mauro Carvalho Chehab authored
      As reported by Thomas Voegtle <tv@lio96.de>, sometimes a DVB card does
      not initialize properly booting Linux 6.4-rc4. This is not always, maybe
      in 3 out of 4 attempts.
      
      After double-checking, the root cause seems to be related to the
      UAF fix, which is causing a race issue:
      
      [   26.332149] tda10071 7-0005: found a 'NXP TDA10071' in cold state, will try to load a firmware
      [   26.340779] tda10071 7-0005: downloading firmware from file 'dvb-fe-tda10071.fw'
      [  989.277402] INFO: task vdr:743 blocked for more than 491 seconds.
      [  989.283504]       Not tainted 6.4.0-rc5-i5 #249
      [  989.288036] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      [  989.295860] task:vdr             state:D stack:0     pid:743   ppid:711    flags:0x00004002
      [  989.295865] Call Trace:
      [  989.295867]  <TASK>
      [  989.295869]  __schedule+0x2ea/0x12d0
      [  989.295877]  ? asm_sysvec_apic_timer_interrupt+0x16/0x20
      [  989.295881]  schedule+0x57/0xc0
      [  989.295884]  schedule_preempt_disabled+0xc/0x20
      [  989.295887]  __mutex_lock.isra.16+0x237/0x480
      [  989.295891]  ? dvb_get_property.isra.10+0x1bc/0xa50
      [  989.295898]  ? dvb_frontend_stop+0x36/0x180
      [  989.338777]  dvb_frontend_stop+0x36/0x180
      [  989.338781]  dvb_frontend_open+0x2f1/0x470
      [  989.338784]  dvb_device_open+0x81/0xf0
      [  989.338804]  ? exact_lock+0x20/0x20
      [  989.338808]  chrdev_open+0x7f/0x1c0
      [  989.338811]  ? generic_permission+0x1a2/0x230
      [  989.338813]  ? link_path_walk.part.63+0x340/0x380
      [  989.338815]  ? exact_lock+0x20/0x20
      [  989.338817]  do_dentry_open+0x18e/0x450
      [  989.374030]  path_openat+0xca5/0xe00
      [  989.374031]  ? terminate_walk+0xec/0x100
      [  989.374034]  ? path_lookupat+0x93/0x140
      [  989.374036]  do_filp_open+0xc0/0x140
      [  989.374038]  ? __call_rcu_common.constprop.91+0x92/0x240
      [  989.374041]  ? __check_object_size+0x147/0x260
      [  989.374043]  ? __check_object_size+0x147/0x260
      [  989.374045]  ? alloc_fd+0xbb/0x180
      [  989.374048]  ? do_sys_openat2+0x243/0x310
      [  989.374050]  do_sys_openat2+0x243/0x310
      [  989.374052]  do_sys_open+0x52/0x80
      [  989.374055]  do_syscall_64+0x5b/0x80
      [  989.421335]  ? __task_pid_nr_ns+0x92/0xa0
      [  989.421337]  ? syscall_exit_to_user_mode+0x20/0x40
      [  989.421339]  ? do_syscall_64+0x67/0x80
      [  989.421341]  ? syscall_exit_to_user_mode+0x20/0x40
      [  989.421343]  ? do_syscall_64+0x67/0x80
      [  989.421345]  entry_SYSCALL_64_after_hwframe+0x63/0xcd
      [  989.421348] RIP: 0033:0x7fe895d067e3
      [  989.421349] RSP: 002b:00007fff933c2ba0 EFLAGS: 00000293 ORIG_RAX: 0000000000000101
      [  989.421351] RAX: ffffffffffffffda RBX: 00007fff933c2c10 RCX: 00007fe895d067e3
      [  989.421352] RDX: 0000000000000802 RSI: 00005594acdce160 RDI: 00000000ffffff9c
      [  989.421353] RBP: 0000000000000802 R08: 0000000000000000 R09: 0000000000000000
      [  989.421353] R10: 0000000000000000 R11: 0000000000000293 R12: 0000000000000001
      [  989.421354] R13: 00007fff933c2ca0 R14: 00000000ffffffff R15: 00007fff933c2c90
      [  989.421355]  </TASK>
      
      This reverts commit 6769a0b7.
      
      Fixes: 6769a0b7 ("media: dvb-core: Fix use-after-free on race condition at dvb_frontend")
      Link: https://lore.kernel.org/all/da5382ad-09d6-20ac-0d53-611594b30861@lio96.de/Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      ec21a38d
    • Bob Pearson's avatar
      RDMA/rxe: Fix rxe_cq_post · 0c7e314a
      Bob Pearson authored
      A recent patch replaced a tasklet execution of cq->comp_handler by a
      direct call. While this made sense it let changes to cq->notify state be
      unprotected and assumed that the cq completion machinery and the ulp done
      callbacks were reentrant. The result is that in some cases completion
      events can be lost. This patch moves the cq->comp_handler call inside of
      the spinlock in rxe_cq_post which solves both issues. This is compatible
      with the matching code in the request notify verb.
      
      Fixes: 78b26a33 ("RDMA/rxe: Remove tasklet call from rxe_cq.c")
      Link: https://lore.kernel.org/r/20230612155032.17036-1-rpearsonhpe@gmail.comSigned-off-by: default avatarBob Pearson <rpearsonhpe@gmail.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      0c7e314a
    • Shyam Prasad N's avatar
      cifs: add a warning when the in-flight count goes negative · e4645cc2
      Shyam Prasad N authored
      We've seen the in-flight count go into negative with some
      internal stress testing in Microsoft.
      
      Adding a WARN when this happens, in hope of understanding
      why this happens when it happens.
      Signed-off-by: default avatarShyam Prasad N <sprasad@microsoft.com>
      Reviewed-by: default avatarBharath SM <bharathsm@microsoft.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      e4645cc2
    • Steve French's avatar
      cifs: fix lease break oops in xfstest generic/098 · c774e677
      Steve French authored
      umount can race with lease break so need to check if
      tcon->ses->server is still valid to send the lease
      break response.
      Reviewed-by: default avatarBharath SM <bharathsm@microsoft.com>
      Reviewed-by: default avatarShyam Prasad N <sprasad@microsoft.com>
      Fixes: 59a556ae ("SMB3: drop reference to cfile before sending oplock break")
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      c774e677
    • Linus Torvalds's avatar
      Merge tag 'nios2_fix_v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/dinguyen/linux · b6dad517
      Linus Torvalds authored
      Pull NIOS2 dts fix from Dinh Nguyen:
      
       - Fix tse_mac "max-frame-size" property
      
      * tag 'nios2_fix_v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/dinguyen/linux:
        nios2: dts: Fix tse_mac "max-frame-size" property
      b6dad517
  4. 13 Jun, 2023 5 commits
  5. 12 Jun, 2023 16 commits
    • Linus Torvalds's avatar
      Merge tag 'mm-hotfixes-stable-2023-06-12-12-22' of... · fb054096
      Linus Torvalds authored
      Merge tag 'mm-hotfixes-stable-2023-06-12-12-22' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
      
      Pull misc fixes from Andrew Morton:
       "19 hotfixes. 14 are cc:stable and the remainder address issues which
        were introduced during this development cycle or which were considered
        inappropriate for a backport"
      
      * tag 'mm-hotfixes-stable-2023-06-12-12-22' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm:
        zswap: do not shrink if cgroup may not zswap
        page cache: fix page_cache_next/prev_miss off by one
        ocfs2: check new file size on fallocate call
        mailmap: add entry for John Keeping
        mm/damon/core: fix divide error in damon_nr_accesses_to_accesses_bp()
        epoll: ep_autoremove_wake_function should use list_del_init_careful
        mm/gup_test: fix ioctl fail for compat task
        nilfs2: reject devices with insufficient block count
        ocfs2: fix use-after-free when unmounting read-only filesystem
        lib/test_vmalloc.c: avoid garbage in page array
        nilfs2: fix possible out-of-bounds segment allocation in resize ioctl
        riscv/purgatory: remove PGO flags
        powerpc/purgatory: remove PGO flags
        x86/purgatory: remove PGO flags
        kexec: support purgatories with .text.hot sections
        mm/uffd: allow vma to merge as much as possible
        mm/uffd: fix vma operation where start addr cuts part of vma
        radix-tree: move declarations to header
        nilfs2: fix incomplete buffer cleanup in nilfs_btnode_abort_change_key()
      fb054096
    • Nhat Pham's avatar
      zswap: do not shrink if cgroup may not zswap · 0bdf0efa
      Nhat Pham authored
      Before storing a page, zswap first checks if the number of stored pages
      exceeds the limit specified by memory.zswap.max, for each cgroup in the
      hierarchy.  If this limit is reached or exceeded, then zswap shrinking is
      triggered and short-circuits the store attempt.
      
      However, since the zswap's LRU is not memcg-aware, this can create the
      following pathological behavior: the cgroup whose zswap limit is 0 will
      evict pages from other cgroups continually, without lowering its own zswap
      usage.  This means the shrinking will continue until the need for swap
      ceases or the pool becomes empty.
      
      As a result of this, we observe a disproportionate amount of zswap
      writeback and a perpetually small zswap pool in our experiments, even
      though the pool limit is never hit.
      
      More generally, a cgroup might unnecessarily evict pages from other
      cgroups before we drive the memcg back below its limit.
      
      This patch fixes the issue by rejecting zswap store attempt without
      shrinking the pool when obj_cgroup_may_zswap() returns false.
      
      [akpm@linux-foundation.org: fix return of unintialized value]
      [akpm@linux-foundation.org: s/ENOSPC/ENOMEM/]
      Link: https://lkml.kernel.org/r/20230530222440.2777700-1-nphamcs@gmail.com
      Link: https://lkml.kernel.org/r/20230530232435.3097106-1-nphamcs@gmail.com
      Fixes: f4840ccf ("zswap: memcg accounting")
      Signed-off-by: default avatarNhat Pham <nphamcs@gmail.com>
      Cc: Dan Streetman <ddstreet@ieee.org>
      Cc: Domenico Cerasuolo <cerasuolodomenico@gmail.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Seth Jennings <sjenning@redhat.com>
      Cc: Vitaly Wool <vitaly.wool@konsulko.com>
      Cc: Yosry Ahmed <yosryahmed@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      0bdf0efa
    • Mike Kravetz's avatar
      page cache: fix page_cache_next/prev_miss off by one · 9425c591
      Mike Kravetz authored
      Ackerley Tng reported an issue with hugetlbfs fallocate here[1].  The
      issue showed up after the conversion of hugetlb page cache lookup code to
      use page_cache_next_miss.  Code in hugetlb fallocate, userfaultfd and GUP
      is now using page_cache_next_miss to determine if a page is present the
      page cache.  The following statement is used.
      
      	present = page_cache_next_miss(mapping, index, 1) != index;
      
      There are two issues with page_cache_next_miss when used in this way.
      1) If the passed value for index is equal to the 'wrap-around' value,
         the same index will always be returned.  This wrap-around value is 0,
         so 0 will be returned even if page is present at index 0.
      2) If there is no gap in the range passed, the last index in the range
         will be returned.  When passed a range of 1 as above, the passed
         index value will be returned even if the page is present.
      The end result is the statement above will NEVER indicate a page is
      present in the cache, even if it is.
      
      As noted by Ackerley in [1], users can see this by hugetlb fallocate
      incorrectly returning EEXIST if pages are already present in the file.  In
      addition, hugetlb pages will not be included in core dumps if they need to
      be brought in via GUP.  userfaultfd UFFDIO_COPY also uses this code and
      will not notice pages already present in the cache.  It may try to
      allocate a new page and potentially return ENOMEM as opposed to EEXIST.
      
      Both page_cache_next_miss and page_cache_prev_miss have similar issues.
      Fix by:
      - Check for index equal to 'wrap-around' value and do not exit early.
      - If no gap is found in range, return index outside range.
      - Update function description to say 'wrap-around' value could be
        returned if passed as index.
      
      [1] https://lore.kernel.org/linux-mm/cover.1683069252.git.ackerleytng@google.com/
      
      Link: https://lkml.kernel.org/r/20230602225747.103865-2-mike.kravetz@oracle.com
      Fixes: d0ce0e47 ("mm/hugetlb: convert hugetlb fault paths to use alloc_hugetlb_folio()")
      Signed-off-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
      Reported-by: default avatarAckerley Tng <ackerleytng@google.com>
      Reviewed-by: default avatarAckerley Tng <ackerleytng@google.com>
      Tested-by: default avatarAckerley Tng <ackerleytng@google.com>
      Cc: Erdem Aktas <erdemaktas@google.com>
      Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
      Cc: Mike Kravetz <mike.kravetz@oracle.com>
      Cc: Muchun Song <songmuchun@bytedance.com>
      Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
      Cc: Vishal Annapurve <vannapurve@google.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      9425c591
    • Luís Henriques's avatar
      ocfs2: check new file size on fallocate call · 26a6ffff
      Luís Henriques authored
      When changing a file size with fallocate() the new size isn't being
      checked.  In particular, the FSIZE ulimit isn't being checked, which makes
      fstest generic/228 fail.  Simply adding a call to inode_newsize_ok() fixes
      this issue.
      
      Link: https://lkml.kernel.org/r/20230529152645.32680-1-lhenriques@suse.deSigned-off-by: default avatarLuís Henriques <lhenriques@suse.de>
      Reviewed-by: default avatarMark Fasheh <mark@fasheh.com>
      Reviewed-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.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>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      26a6ffff
    • John Keeping's avatar
      mailmap: add entry for John Keeping · 0e4d4ef9
      John Keeping authored
      Map my corporate address to my personal one, as I am leaving the
      company.
      
      Link: https://lkml.kernel.org/r/20230531144839.1157112-1-john@keeping.me.ukSigned-off-by: default avatarJohn Keeping <john@keeping.me.uk>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      0e4d4ef9
    • Kefeng Wang's avatar
      mm/damon/core: fix divide error in damon_nr_accesses_to_accesses_bp() · 5ff6e2ff
      Kefeng Wang authored
      If 'aggr_interval' is smaller than 'sample_interval', max_nr_accesses in
      damon_nr_accesses_to_accesses_bp() becomes zero which leads to divide
      error, let's validate the values of them in damon_set_attrs() to fix it,
      which similar to others attrs check.
      
      Link: https://lkml.kernel.org/r/20230527032101.167788-1-wangkefeng.wang@huawei.com
      Fixes: 2f5bef5a ("mm/damon/core: update monitoring results for new monitoring attributes")
      Reported-by: syzbot+841a46899768ec7bec67@syzkaller.appspotmail.com
      Closes: https://syzkaller.appspot.com/bug?extid=841a46899768ec7bec67
      Link: https://lore.kernel.org/damon/00000000000055fc4e05fc975bc2@google.com/Reviewed-by: default avatarSeongJae Park <sj@kernel.org>
      Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      5ff6e2ff
    • Benjamin Segall's avatar
      epoll: ep_autoremove_wake_function should use list_del_init_careful · 2192bba0
      Benjamin Segall authored
      autoremove_wake_function uses list_del_init_careful, so should epoll's
      more aggressive variant.  It only doesn't because it was copied from an
      older wait.c rather than the most recent.
      
      [bsegall@google.com: add comment]
        Link: https://lkml.kernel.org/r/xm26bki0ulsr.fsf_-_@google.com
      Link: https://lkml.kernel.org/r/xm26pm6hvfer.fsf@google.com
      Fixes: a16ceb13 ("epoll: autoremove wakers even more aggressively")
      Signed-off-by: default avatarBen Segall <bsegall@google.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      2192bba0
    • Haibo Li's avatar
      mm/gup_test: fix ioctl fail for compat task · 4f572f00
      Haibo Li authored
      When tools/testing/selftests/mm/gup_test.c is compiled as 32bit, then run
      on arm64 kernel, it reports "ioctl: Inappropriate ioctl for device".
      
      Fix it by filling compat_ioctl in gup_test_fops
      
      Link: https://lkml.kernel.org/r/20230526022125.175728-1-haibo.li@mediatek.comSigned-off-by: default avatarHaibo Li <haibo.li@mediatek.com>
      Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
      Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Cc: Matthias Brugger <matthias.bgg@gmail.com>
      Cc: John Hubbard <jhubbard@nvidia.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      4f572f00
    • Ryusuke Konishi's avatar
      nilfs2: reject devices with insufficient block count · 92c5d1b8
      Ryusuke Konishi authored
      The current sanity check for nilfs2 geometry information lacks checks for
      the number of segments stored in superblocks, so even for device images
      that have been destructively truncated or have an unusually high number of
      segments, the mount operation may succeed.
      
      This causes out-of-bounds block I/O on file system block reads or log
      writes to the segments, the latter in particular causing
      "a_ops->writepages" to repeatedly fail, resulting in sync_inodes_sb() to
      hang.
      
      Fix this issue by checking the number of segments stored in the superblock
      and avoiding mounting devices that can cause out-of-bounds accesses.  To
      eliminate the possibility of overflow when calculating the number of
      blocks required for the device from the number of segments, this also adds
      a helper function to calculate the upper bound on the number of segments
      and inserts a check using it.
      
      Link: https://lkml.kernel.org/r/20230526021332.3431-1-konishi.ryusuke@gmail.comSigned-off-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Reported-by: syzbot+7d50f1e54a12ba3aeae2@syzkaller.appspotmail.com
        Link: https://syzkaller.appspot.com/bug?extid=7d50f1e54a12ba3aeae2Tested-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      92c5d1b8
    • Luís Henriques's avatar
      ocfs2: fix use-after-free when unmounting read-only filesystem · 50d92788
      Luís Henriques authored
      It's trivial to trigger a use-after-free bug in the ocfs2 quotas code using
      fstest generic/452.  After a read-only remount, quotas are suspended and
      ocfs2_mem_dqinfo is freed through ->ocfs2_local_free_info().  When unmounting
      the filesystem, an UAF access to the oinfo will eventually cause a crash.
       
      BUG: KASAN: slab-use-after-free in timer_delete+0x54/0xc0
      Read of size 8 at addr ffff8880389a8208 by task umount/669
      ...
      Call Trace:
       <TASK>
       ...
       timer_delete+0x54/0xc0
       try_to_grab_pending+0x31/0x230
       __cancel_work_timer+0x6c/0x270
       ocfs2_disable_quotas.isra.0+0x3e/0xf0 [ocfs2]
       ocfs2_dismount_volume+0xdd/0x450 [ocfs2]
       generic_shutdown_super+0xaa/0x280
       kill_block_super+0x46/0x70
       deactivate_locked_super+0x4d/0xb0
       cleanup_mnt+0x135/0x1f0
       ...
       </TASK>
      
      Allocated by task 632:
       kasan_save_stack+0x1c/0x40
       kasan_set_track+0x21/0x30
       __kasan_kmalloc+0x8b/0x90
       ocfs2_local_read_info+0xe3/0x9a0 [ocfs2]
       dquot_load_quota_sb+0x34b/0x680
       dquot_load_quota_inode+0xfe/0x1a0
       ocfs2_enable_quotas+0x190/0x2f0 [ocfs2]
       ocfs2_fill_super+0x14ef/0x2120 [ocfs2]
       mount_bdev+0x1be/0x200
       legacy_get_tree+0x6c/0xb0
       vfs_get_tree+0x3e/0x110
       path_mount+0xa90/0xe10
       __x64_sys_mount+0x16f/0x1a0
       do_syscall_64+0x43/0x90
       entry_SYSCALL_64_after_hwframe+0x72/0xdc
      
      Freed by task 650:
       kasan_save_stack+0x1c/0x40
       kasan_set_track+0x21/0x30
       kasan_save_free_info+0x2a/0x50
       __kasan_slab_free+0xf9/0x150
       __kmem_cache_free+0x89/0x180
       ocfs2_local_free_info+0x2ba/0x3f0 [ocfs2]
       dquot_disable+0x35f/0xa70
       ocfs2_susp_quotas.isra.0+0x159/0x1a0 [ocfs2]
       ocfs2_remount+0x150/0x580 [ocfs2]
       reconfigure_super+0x1a5/0x3a0
       path_mount+0xc8a/0xe10
       __x64_sys_mount+0x16f/0x1a0
       do_syscall_64+0x43/0x90
       entry_SYSCALL_64_after_hwframe+0x72/0xdc
      
      Link: https://lkml.kernel.org/r/20230522102112.9031-1-lhenriques@suse.deSigned-off-by: default avatarLuís Henriques <lhenriques@suse.de>
      Reviewed-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
      Tested-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>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      50d92788
    • Lorenzo Stoakes's avatar
      lib/test_vmalloc.c: avoid garbage in page array · 9f6c6ad1
      Lorenzo Stoakes authored
      It turns out that alloc_pages_bulk_array() does not treat the page_array
      parameter as an output parameter, but rather reads the array and skips any
      entries that have already been allocated.
      
      This is somewhat unexpected and breaks this test, as we allocate the pages
      array uninitialised on the assumption it will be overwritten.
      
      As a result, the test was referencing uninitialised data and causing the
      PFN to not be valid and thus a WARN_ON() followed by a null pointer deref
      and panic.
      
      In addition, this is an array of pointers not of struct page objects, so we
      need only allocate an array with elements of pointer size.
      
      We solve both problems by simply using kcalloc() and referencing
      sizeof(struct page *) rather than sizeof(struct page).
      
      Link: https://lkml.kernel.org/r/20230524082424.10022-1-lstoakes@gmail.com
      Fixes: 869cb29a ("lib/test_vmalloc.c: add vm_map_ram()/vm_unmap_ram() test case")
      Signed-off-by: default avatarLorenzo Stoakes <lstoakes@gmail.com>
      Reviewed-by: default avatarUladzislau Rezki (Sony) <urezki@gmail.com>
      Reviewed-by: default avatarBaoquan He <bhe@redhat.com>
      Cc: Christoph Hellwig <hch@infradead.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      9f6c6ad1
    • Ryusuke Konishi's avatar
      nilfs2: fix possible out-of-bounds segment allocation in resize ioctl · fee5eaec
      Ryusuke Konishi authored
      Syzbot reports that in its stress test for resize ioctl, the log writing
      function nilfs_segctor_do_construct hits a WARN_ON in
      nilfs_segctor_truncate_segments().
      
      It turned out that there is a problem with the current implementation of
      the resize ioctl, which changes the writable range on the device (the
      range of allocatable segments) at the end of the resize process.
      
      This order is necessary for file system expansion to avoid corrupting the
      superblock at trailing edge.  However, in the case of a file system
      shrink, if log writes occur after truncating out-of-bounds trailing
      segments and before the resize is complete, segments may be allocated from
      the truncated space.
      
      The userspace resize tool was fine as it limits the range of allocatable
      segments before performing the resize, but it can run into this issue if
      the resize ioctl is called alone.
      
      Fix this issue by changing nilfs_sufile_resize() to update the range of
      allocatable segments immediately after successful truncation of segment
      space in case of file system shrink.
      
      Link: https://lkml.kernel.org/r/20230524094348.3784-1-konishi.ryusuke@gmail.com
      Fixes: 4e33f9ea ("nilfs2: implement resize ioctl")
      Signed-off-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Reported-by: syzbot+33494cd0df2ec2931851@syzkaller.appspotmail.com
      Closes: https://lkml.kernel.org/r/0000000000005434c405fbbafdc5@google.comTested-by: default avatarRyusuke Konishi <konishi.ryusuke@gmail.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      fee5eaec
    • Ricardo Ribalda's avatar
      riscv/purgatory: remove PGO flags · 88ac3bbc
      Ricardo Ribalda authored
      If profile-guided optimization is enabled, the purgatory ends up with
      multiple .text sections.  This is not supported by kexec and crashes the
      system.
      
      Link: https://lkml.kernel.org/r/20230321-kexec_clang16-v7-4-b05c520b7296@chromium.org
      Fixes: 93045705 ("kernel/kexec_file.c: split up __kexec_load_puragory")
      Signed-off-by: default avatarRicardo Ribalda <ribalda@chromium.org>
      Acked-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      Cc: <stable@vger.kernel.org>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Borislav Petkov (AMD) <bp@alien8.de>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Dave Young <dyoung@redhat.com>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Philipp Rudo <prudo@redhat.com>
      Cc: Ross Zwisler <zwisler@google.com>
      Cc: Simon Horman <horms@kernel.org>
      Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tom Rix <trix@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      88ac3bbc
    • Ricardo Ribalda's avatar
      powerpc/purgatory: remove PGO flags · 20188bac
      Ricardo Ribalda authored
      If profile-guided optimization is enabled, the purgatory ends up with
      multiple .text sections.  This is not supported by kexec and crashes the
      system.
      
      Link: https://lkml.kernel.org/r/20230321-kexec_clang16-v7-3-b05c520b7296@chromium.org
      Fixes: 93045705 ("kernel/kexec_file.c: split up __kexec_load_puragory")
      Signed-off-by: default avatarRicardo Ribalda <ribalda@chromium.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: <stable@vger.kernel.org>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Borislav Petkov (AMD) <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Dave Young <dyoung@redhat.com>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Palmer Dabbelt <palmer@rivosinc.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Philipp Rudo <prudo@redhat.com>
      Cc: Ross Zwisler <zwisler@google.com>
      Cc: Simon Horman <horms@kernel.org>
      Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tom Rix <trix@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      20188bac
    • Ricardo Ribalda's avatar
      x86/purgatory: remove PGO flags · 97b6b9cb
      Ricardo Ribalda authored
      If profile-guided optimization is enabled, the purgatory ends up with
      multiple .text sections.  This is not supported by kexec and crashes the
      system.
      
      Link: https://lkml.kernel.org/r/20230321-kexec_clang16-v7-2-b05c520b7296@chromium.org
      Fixes: 93045705 ("kernel/kexec_file.c: split up __kexec_load_puragory")
      Signed-off-by: default avatarRicardo Ribalda <ribalda@chromium.org>
      Cc: <stable@vger.kernel.org>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Borislav Petkov (AMD) <bp@alien8.de>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Dave Young <dyoung@redhat.com>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Palmer Dabbelt <palmer@rivosinc.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Philipp Rudo <prudo@redhat.com>
      Cc: Ross Zwisler <zwisler@google.com>
      Cc: Simon Horman <horms@kernel.org>
      Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tom Rix <trix@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      97b6b9cb
    • Ricardo Ribalda's avatar
      kexec: support purgatories with .text.hot sections · 8652d44f
      Ricardo Ribalda authored
      Patch series "kexec: Fix kexec_file_load for llvm16 with PGO", v7.
      
      When upreving llvm I realised that kexec stopped working on my test
      platform.
      
      The reason seems to be that due to PGO there are multiple .text sections
      on the purgatory, and kexec does not supports that.
      
      
      This patch (of 4):
      
      Clang16 links the purgatory text in two sections when PGO is in use:
      
        [ 1] .text             PROGBITS         0000000000000000  00000040
             00000000000011a1  0000000000000000  AX       0     0     16
        [ 2] .rela.text        RELA             0000000000000000  00003498
             0000000000000648  0000000000000018   I      24     1     8
        ...
        [17] .text.hot.        PROGBITS         0000000000000000  00003220
             000000000000020b  0000000000000000  AX       0     0     1
        [18] .rela.text.hot.   RELA             0000000000000000  00004428
             0000000000000078  0000000000000018   I      24    17     8
      
      And both of them have their range [sh_addr ... sh_addr+sh_size] on the
      area pointed by `e_entry`.
      
      This causes that image->start is calculated twice, once for .text and
      another time for .text.hot. The second calculation leaves image->start
      in a random location.
      
      Because of this, the system crashes immediately after:
      
      kexec_core: Starting new kernel
      
      Link: https://lkml.kernel.org/r/20230321-kexec_clang16-v7-0-b05c520b7296@chromium.org
      Link: https://lkml.kernel.org/r/20230321-kexec_clang16-v7-1-b05c520b7296@chromium.org
      Fixes: 93045705 ("kernel/kexec_file.c: split up __kexec_load_puragory")
      Signed-off-by: default avatarRicardo Ribalda <ribalda@chromium.org>
      Reviewed-by: default avatarRoss Zwisler <zwisler@google.com>
      Reviewed-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Reviewed-by: default avatarPhilipp Rudo <prudo@redhat.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Baoquan He <bhe@redhat.com>
      Cc: Borislav Petkov (AMD) <bp@alien8.de>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Dave Young <dyoung@redhat.com>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Palmer Dabbelt <palmer@rivosinc.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Simon Horman <horms@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tom Rix <trix@redhat.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      8652d44f