1. 26 Aug, 2021 2 commits
  2. 25 Aug, 2021 8 commits
  3. 24 Aug, 2021 1 commit
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma · 6e764bcd
      Linus Torvalds authored
      Pull rdma fixes from Jason Gunthorpe:
       "Several small fixes, the first three are significant:
      
         - mlx5 crash unloading drivers with a rare HW config
      
         - missing userspace reporting for the new dmabuf objects
      
         - random rxe failure due to missing memory zeroing
      
         - static checker/etc reports: missing spin lock init, null pointer
           deref on error, extra unlock on error path, memory allocation under
           spinlock, missing IRQ vector cleanup
      
         - kconfig typo in the new irdma driver"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma:
        RDMA/rxe: Zero out index member of struct rxe_queue
        RDMA/efa: Free IRQ vectors on error flow
        RDMA/rxe: Fix memory allocation while in a spin lock
        RDMA/bnxt_re: Remove unpaired rtnl unlock in bnxt_re_dev_init()
        IB/hfi1: Fix possible null-pointer dereference in _extend_sdma_tx_descs()
        RDMA/irdma: Use correct kconfig symbol for AUXILIARY_BUS
        RDMA/bnxt_re: Add missing spin lock initialization
        RDMA/uverbs: Track dmabuf memory regions
        RDMA/mlx5: Fix crash when unbind multiport slave
      6e764bcd
  4. 23 Aug, 2021 3 commits
    • Alexey Gladkov's avatar
      ucounts: Increase ucounts reference counter before the security hook · bbb6d0f3
      Alexey Gladkov authored
      We need to increment the ucounts reference counter befor security_prepare_creds()
      because this function may fail and abort_creds() will try to decrement
      this reference.
      
      [   96.465056][ T8641] FAULT_INJECTION: forcing a failure.
      [   96.465056][ T8641] name fail_page_alloc, interval 1, probability 0, space 0, times 0
      [   96.478453][ T8641] CPU: 1 PID: 8641 Comm: syz-executor668 Not tainted 5.14.0-rc6-syzkaller #0
      [   96.487215][ T8641] Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      [   96.497254][ T8641] Call Trace:
      [   96.500517][ T8641]  dump_stack_lvl+0x1d3/0x29f
      [   96.505758][ T8641]  ? show_regs_print_info+0x12/0x12
      [   96.510944][ T8641]  ? log_buf_vmcoreinfo_setup+0x498/0x498
      [   96.516652][ T8641]  should_fail+0x384/0x4b0
      [   96.521141][ T8641]  prepare_alloc_pages+0x1d1/0x5a0
      [   96.526236][ T8641]  __alloc_pages+0x14d/0x5f0
      [   96.530808][ T8641]  ? __rmqueue_pcplist+0x2030/0x2030
      [   96.536073][ T8641]  ? lockdep_hardirqs_on_prepare+0x3e2/0x750
      [   96.542056][ T8641]  ? alloc_pages+0x3f3/0x500
      [   96.546635][ T8641]  allocate_slab+0xf1/0x540
      [   96.551120][ T8641]  ___slab_alloc+0x1cf/0x350
      [   96.555689][ T8641]  ? kzalloc+0x1d/0x30
      [   96.559740][ T8641]  __kmalloc+0x2e7/0x390
      [   96.563980][ T8641]  ? kzalloc+0x1d/0x30
      [   96.568029][ T8641]  kzalloc+0x1d/0x30
      [   96.571903][ T8641]  security_prepare_creds+0x46/0x220
      [   96.577174][ T8641]  prepare_creds+0x411/0x640
      [   96.581747][ T8641]  __sys_setfsuid+0xe2/0x3a0
      [   96.586333][ T8641]  do_syscall_64+0x3d/0xb0
      [   96.590739][ T8641]  entry_SYSCALL_64_after_hwframe+0x44/0xae
      [   96.596611][ T8641] RIP: 0033:0x445a69
      [   96.600483][ T8641] Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 11 15 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
      [   96.620152][ T8641] RSP: 002b:00007f1054173318 EFLAGS: 00000246 ORIG_RAX: 000000000000007a
      [   96.628543][ T8641] RAX: ffffffffffffffda RBX: 00000000004ca4c8 RCX: 0000000000445a69
      [   96.636600][ T8641] RDX: 0000000000000010 RSI: 00007f10541732f0 RDI: 0000000000000000
      [   96.644550][ T8641] RBP: 00000000004ca4c0 R08: 0000000000000001 R09: 0000000000000000
      [   96.652500][ T8641] R10: 0000000000000000 R11: 0000000000000246 R12: 00000000004ca4cc
      [   96.660631][ T8641] R13: 00007fffffe0b62f R14: 00007f1054173400 R15: 0000000000022000
      
      Fixes: 905ae01c ("Add a reference to ucounts for each cred")
      Reported-by: syzbot+01985d7909f9468f013c@syzkaller.appspotmail.com
      Signed-off-by: default avatarAlexey Gladkov <legion@kernel.org>
      Link: https://lkml.kernel.org/r/97433b1742c3331f02ad92de5a4f07d673c90613.1629735352.git.legion@kernel.orgSigned-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      bbb6d0f3
    • Eric W. Biederman's avatar
      ucounts: Fix regression preventing increasing of rlimits in init_user_ns · 5ddf994f
      Eric W. Biederman authored
      "Ma, XinjianX" <xinjianx.ma@intel.com> reported:
      
      > When lkp team run kernel selftests, we found after these series of patches, testcase mqueue: mq_perf_tests
      > in kselftest failed with following message.
      >
      > # selftests: mqueue: mq_perf_tests
      > #
      > # Initial system state:
      > #       Using queue path:                       /mq_perf_tests
      > #       RLIMIT_MSGQUEUE(soft):                  819200
      > #       RLIMIT_MSGQUEUE(hard):                  819200
      > #       Maximum Message Size:                   8192
      > #       Maximum Queue Size:                     10
      > #       Nice value:                             0
      > #
      > # Adjusted system state for testing:
      > #       RLIMIT_MSGQUEUE(soft):                  (unlimited)
      > #       RLIMIT_MSGQUEUE(hard):                  (unlimited)
      > #       Maximum Message Size:                   16777216
      > #       Maximum Queue Size:                     65530
      > #       Nice value:                             -20
      > #       Continuous mode:                        (disabled)
      > #       CPUs to pin:                            3
      > # ./mq_perf_tests: mq_open() at 296: Too many open files
      > not ok 2 selftests: mqueue: mq_perf_tests # exit=1
      > ```
      >
      > Test env:
      > rootfs: debian-10
      > gcc version: 9
      
      After investigation the problem turned out to be that ucount_max for
      the rlimits in init_user_ns was being set to the initial rlimit value.
      The practical problem is that ucount_max provides a limit that
      applications inside the user namespace can not exceed.  Which means in
      practice that rlimits that have been converted to use the ucount
      infrastructure were not able to exceend their initial rlimits.
      
      Solve this by setting the relevant values of ucount_max to
      RLIM_INIFINITY.  A limit in init_user_ns is pointless so the code
      should allow the values to grow as large as possible without riscking
      an underflow or an overflow.
      
      As the ltp test case was a bit of a pain I have reproduced the rlimit failure
      and tested the fix with the following little C program:
      > #include <stdio.h>
      > #include <fcntl.h>
      > #include <sys/stat.h>
      > #include <mqueue.h>
      > #include <sys/time.h>
      > #include <sys/resource.h>
      > #include <errno.h>
      > #include <string.h>
      > #include <stdlib.h>
      > #include <limits.h>
      > #include <unistd.h>
      >
      > int main(int argc, char **argv)
      > {
      > 	struct mq_attr mq_attr;
      > 	struct rlimit rlim;
      > 	mqd_t mqd;
      > 	int ret;
      >
      > 	ret = getrlimit(RLIMIT_MSGQUEUE, &rlim);
      > 	if (ret != 0) {
      > 		fprintf(stderr, "getrlimit(RLIMIT_MSGQUEUE) failed: %s\n", strerror(errno));
      > 		exit(EXIT_FAILURE);
      > 	}
      > 	printf("RLIMIT_MSGQUEUE %lu %lu\n",
      > 	       rlim.rlim_cur, rlim.rlim_max);
      > 	rlim.rlim_cur = RLIM_INFINITY;
      > 	rlim.rlim_max = RLIM_INFINITY;
      > 	ret = setrlimit(RLIMIT_MSGQUEUE, &rlim);
      > 	if (ret != 0) {
      > 		fprintf(stderr, "setrlimit(RLIMIT_MSGQUEUE, RLIM_INFINITY) failed: %s\n", strerror(errno));
      > 		exit(EXIT_FAILURE);
      > 	}
      >
      > 	memset(&mq_attr, 0, sizeof(struct mq_attr));
      > 	mq_attr.mq_maxmsg = 65536 - 1;
      > 	mq_attr.mq_msgsize = 16*1024*1024 - 1;
      >
      > 	mqd = mq_open("/mq_rlimit_test", O_RDONLY|O_CREAT, 0600, &mq_attr);
      > 	if (mqd == (mqd_t)-1) {
      > 		fprintf(stderr, "mq_open failed: %s\n", strerror(errno));
      > 		exit(EXIT_FAILURE);
      > 	}
      > 	ret = mq_close(mqd);
      > 	if (ret) {
      > 		fprintf(stderr, "mq_close failed; %s\n", strerror(errno));
      > 		exit(EXIT_FAILURE);
      > 	}
      >
      > 	return EXIT_SUCCESS;
      > }
      
      Fixes: 6e52a9f0 ("Reimplement RLIMIT_MSGQUEUE on top of ucounts")
      Fixes: d7c9e99a ("Reimplement RLIMIT_MEMLOCK on top of ucounts")
      Fixes: d6469690 ("Reimplement RLIMIT_SIGPENDING on top of ucounts")
      Fixes: 21d1c5e3 ("Reimplement RLIMIT_NPROC on top of ucounts")
      Reported-by: kernel test robot lkp@intel.com
      Acked-by: default avatarAlexey Gladkov <legion@kernel.org>
      Link: https://lkml.kernel.org/r/87eeajswfc.fsf_-_@disp2133Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      5ddf994f
    • Linus Torvalds's avatar
      Revert "media: dvb header files: move some headers to staging" · d5ae8d7f
      Linus Torvalds authored
      This reverts commit 819fbd3d.
      
      It turns out that some user-space applications use these uapi header
      files, so even though the only user of the interface is an old driver
      that was moved to staging, moving the header files causes unnecessary
      pain.
      
      Generally, we really don't want user space to use kernel headers
      directly (exactly because it causes pain when we re-organize), and
      instead copy them as needed.  But these things happen, and the headers
      were in the uapi directory, so I guess it's not entirely unreasonable.
      
      Link: https://lore.kernel.org/lkml/4e3e0d40-df4a-94f8-7c2d-85010b0873c4@web.de/Reported-by: default avatarSoeren Moch <smoch@web.de>
      Cc: stable@kernel.org  # 5.13
      Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d5ae8d7f
  5. 22 Aug, 2021 2 commits
  6. 21 Aug, 2021 9 commits
  7. 20 Aug, 2021 15 commits
    • Jens Axboe's avatar
      io_uring: fix xa_alloc_cycle() error return value check · a30f895a
      Jens Axboe authored
      We currently check for ret != 0 to indicate error, but '1' is a valid
      return and just indicates that the allocation succeeded with a wrap.
      Correct the check to be for < 0, like it was before the xarray
      conversion.
      
      Cc: stable@vger.kernel.org
      Fixes: 61cf9370 ("io_uring: Convert personality_idr to XArray")
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      a30f895a
    • Linus Torvalds's avatar
      Merge tag 'acpi-5.14-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm · fa54d366
      Linus Torvalds authored
      Pull ACPI fixes from Rafael Wysocki:
       "These fix two mistakes in new code.
      
        Specifics:
      
         - Prevent confusing messages from being printed if the PRMT table is
           not present or there are no PRM modules (Aubrey Li).
      
         - Fix the handling of suspend-to-idle entry and exit in the case when
           the Microsoft UUID is used with the Low-Power S0 Idle _DSM
           interface (Mario Limonciello)"
      
      * tag 'acpi-5.14-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
        ACPI: PM: s2idle: Invert Microsoft UUID entry and exit
        ACPI: PRM: Deal with table not present or no module found
      fa54d366
    • Linus Torvalds's avatar
      Merge tag 'pm-5.14-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm · cae68764
      Linus Torvalds authored
      Pull power management fixes from Rafael Wysocki:
       "These fix some issues in the ARM cpufreq drivers and in the operating
        performance points (OPP) framework.
      
        Specifics:
      
         - Fix useless WARN() in the OPP core and prevent a noisy warning
           from being printed by OPP _put functions (Dmitry Osipenko).
      
         - Fix error path when allocation failed in the arm_scmi cpufreq
           driver (Lukasz Luba).
      
         - Blacklist Qualcomm sc8180x and Qualcomm sm8150 in
           cpufreq-dt-platdev (Bjorn Andersson, Thara Gopinath).
      
         - Forbid cpufreq for 1.2 GHz variant in the armada-37xx cpufreq
           driver (Marek Behún)"
      
      * tag 'pm-5.14-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
        opp: Drop empty-table checks from _put functions
        cpufreq: armada-37xx: forbid cpufreq for 1.2 GHz variant
        cpufreq: blocklist Qualcomm sm8150 in cpufreq-dt-platdev
        cpufreq: arm_scmi: Fix error path when allocation failed
        opp: remove WARN when no valid OPPs remain
        cpufreq: blacklist Qualcomm sc8180x in cpufreq-dt-platdev
      cae68764
    • Linus Torvalds's avatar
      Merge branch 'akpm' (patches from Andrew) · ed3bad2e
      Linus Torvalds authored
      Merge misc fixes from Andrew Morton:
       "10 patches.
      
        Subsystems affected by this patch series: MAINTAINERS and mm (shmem,
        pagealloc, tracing, memcg, memory-failure, vmscan, kfence, and
        hugetlb)"
      
      * emailed patches from Andrew Morton <akpm@linux-foundation.org>:
        hugetlb: don't pass page cache pages to restore_reserve_on_error
        kfence: fix is_kfence_address() for addresses below KFENCE_POOL_SIZE
        mm: vmscan: fix missing psi annotation for node_reclaim()
        mm/hwpoison: retry with shake_page() for unhandlable pages
        mm: memcontrol: fix occasional OOMs due to proportional memory.low reclaim
        MAINTAINERS: update ClangBuiltLinux IRC chat
        mmflags.h: add missing __GFP_ZEROTAGS and __GFP_SKIP_KASAN_POISON names
        mm/page_alloc: don't corrupt pcppage_migratetype
        Revert "mm: swap: check if swap backing device is congested or not"
        Revert "mm/shmem: fix shmem_swapin() race with swapoff"
      ed3bad2e
    • Linus Torvalds's avatar
      Merge tag 'drm-fixes-2021-08-20-3' of git://anongit.freedesktop.org/drm/drm · 8ba9fbe1
      Linus Torvalds authored
      Pull drm fixes from Dave Airlie:
       "Regularly scheduled fixes. The ttm one solves a problem of GPU drivers
        failing to load if debugfs is off in Kconfig, otherwise the i915 and
        mediatek, and amdgpu fixes all fairly normal.
      
        Nouveau has a couple of display fixes, but it has a fix for a
        longstanding race condition in it's memory manager code, and the fix
        mostly removes some code that wasn't working properly and has no
        userspace users. This fix makes the diffstat kinda larger but in a
        good (negative line-count) way.
      
        core:
         - fix drm_wait_vblank uapi copying bug
      
        ttm:
         - fix debugfs init when debugfs is off
      
        amdgpu:
         - vega10 SMU workload fix
         - DCN VM fix
         - DCN 3.01 watermark fix
      
        amdkfd:
         - SVM fix
      
        nouveau:
         - ampere display fixes
         - remove MM misfeature to fix a longstanding race condition
      
        i915:
         - tweaked display workaround for all PCHs
         - eDP MSO pipe sanity for ADL-P fix
         - remove unused symbol export
      
        mediatek:
         - AAL output size setting
         - Delete component in remove function"
      
      * tag 'drm-fixes-2021-08-20-3' of git://anongit.freedesktop.org/drm/drm:
        drm/amd/display: Use DCN30 watermark calc for DCN301
        drm/i915/dp: remove superfluous EXPORT_SYMBOL()
        drm/i915/edp: fix eDP MSO pipe sanity checks for ADL-P
        drm/i915: Tweaked Wa_14010685332 for all PCHs
        drm/nouveau: rip out nvkm_client.super
        drm/nouveau: block a bunch of classes from userspace
        drm/nouveau/fifo/nv50-: rip out dma channels
        drm/nouveau/kms/nv50: workaround EFI GOP window channel format differences
        drm/nouveau/disp: power down unused DP links during init
        drm/nouveau: recognise GA107
        drm: Copy drm_wait_vblank to user before returning
        drm/amd/display: Ensure DCN save after VM setup
        drm/amdkfd: fix random KFDSVMRangeTest.SetGetAttributesTest test failure
        drm/amd/pm: change the workload type for some cards
        Revert "drm/amd/pm: fix workload mismatch on vega10"
        drm: ttm: Don't bail from ttm_global_init if debugfs_create_dir fails
        drm/mediatek: Add component_del in OVL and COLOR remove function
        drm/mediatek: Add AAL output size configuration
      8ba9fbe1
    • Linus Torvalds's avatar
      Merge tag 'pci-v5.14-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci · 3db903a8
      Linus Torvalds authored
      Pull PCI fixes from Bjorn Helgaas:
      
       - Add Rahul Tanwar as Intel LGM Gateway PCIe maintainer (Rahul Tanwar)
      
       - Add Jim Quinlan et al as Broadcom STB PCIe maintainers (Jim Quinlan)
      
       - Increase D3hot-to-D0 delay for AMD Renoir/Cezanne XHCI (Marcin
         Bachry)
      
       - Correct iomem_get_mapping() usage for legacy_mem sysfs (Krzysztof
         Wilczyński)
      
      * tag 'pci-v5.14-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci:
        PCI/sysfs: Use correct variable for the legacy_mem sysfs object
        PCI: Increase D3 delay for AMD Renoir/Cezanne XHCI
        MAINTAINERS: Add Jim Quinlan et al as Broadcom STB PCIe maintainers
        MAINTAINERS: Add Rahul Tanwar as Intel LGM Gateway PCIe maintainer
      3db903a8
    • Linus Torvalds's avatar
      Merge tag 'mmc-v5.14-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc · a27c75e5
      Linus Torvalds authored
      Pull MMC host fixes from Ulf Hansson:
      
       - dw_mmc: Fix hang on data CRC error
      
       - mmci: Fix voltage switch procedure for the stm32 variant
      
       - sdhci-iproc: Fix some clock issues for BCM2711
      
       - sdhci-msm: Fixup software timeout value
      
      * tag 'mmc-v5.14-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc:
        mmc: sdhci-iproc: Set SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN on BCM2711
        mmc: sdhci-iproc: Cap min clock frequency on BCM2711
        mmc: sdhci-msm: Update the software timeout value for sdhc
        mmc: mmci: stm32: Check when the voltage switch procedure should be done
        mmc: dw_mmc: Fix hang on data CRC error
      a27c75e5
    • Linus Torvalds's avatar
      Merge tag 'sound-5.14-rc7-2' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound · 43a6473e
      Linus Torvalds authored
      Pull more sound fixes from Takashi Iwai:
       "This is a quick follow up for 5.14: a fix for a very recently
        introduced regression on ASoC Intel Atom driver, and another trivial
        HD-audio quirk for HP laptops"
      
      * tag 'sound-5.14-rc7-2' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
        ASoC: intel: atom: Fix breakage for PCM buffer address setup
        ALSA: hda/realtek: Limit mic boost on HP ProBook 445 G8
      43a6473e
    • Linus Torvalds's avatar
      Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux · 54e9ea3c
      Linus Torvalds authored
      Pull arm64 fixes from Will Deacon:
      
       - Fix cleaning of vDSO directories
      
       - Ensure CNTHCTL_EL2 is fully initialised when booting at EL2
      
      * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux:
        arm64: initialize all of CNTHCTL_EL2
        arm64: clean vdso & vdso32 files
      54e9ea3c
    • Rafael J. Wysocki's avatar
      Merge branch 'acpi-pm' · 0f09f4c4
      Rafael J. Wysocki authored
      * acpi-pm:
        ACPI: PM: s2idle: Invert Microsoft UUID entry and exit
      0f09f4c4
    • Linus Torvalds's avatar
      Merge tag 'iommu-fixes-v5.14-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu · b7d184d3
      Linus Torvalds authored
      Pull iommu fixes from Joerg Roedel:
      
       - Fix for a potential NULL-ptr dereference in IOMMU core code
      
       - Two resource leak fixes
      
       - Cache flush fix in the Intel VT-d driver
      
      * tag 'iommu-fixes-v5.14-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu:
        iommu/vt-d: Fix incomplete cache flush in intel_pasid_tear_down_entry()
        iommu/vt-d: Fix PASID reference leak
        iommu: Check if group is NULL before remove device
        iommu/dma: Fix leak in non-contiguous API
      b7d184d3
    • Rafael J. Wysocki's avatar
      Merge branch 'pm-opp' · f2963c7e
      Rafael J. Wysocki authored
      * pm-opp:
        opp: Drop empty-table checks from _put functions
        opp: remove WARN when no valid OPPs remain
      f2963c7e
    • Xiao Yang's avatar
      RDMA/rxe: Zero out index member of struct rxe_queue · cc4f596c
      Xiao Yang authored
      1) New index member of struct rxe_queue was introduced but not zeroed so
         the initial value of index may be random.
      
      2) The current index is not masked off to index_mask.
      
      In this case producer_addr() and consumer_addr() will get an invalid
      address by the random index and then accessing the invalid address
      triggers the following panic:
      
      "BUG: unable to handle page fault for address: ffff9ae2c07a1414"
      
      Fix the issue by using kzalloc() to zero out index member.
      
      Fixes: 5bcf5a59 ("RDMA/rxe: Protext kernel index from user space")
      Link: https://lore.kernel.org/r/20210820111509.172500-1-yangx.jy@fujitsu.comSigned-off-by: default avatarXiao Yang <yangx.jy@fujitsu.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      cc4f596c
    • Mike Kravetz's avatar
      hugetlb: don't pass page cache pages to restore_reserve_on_error · c7b1850d
      Mike Kravetz authored
      syzbot hit kernel BUG at fs/hugetlbfs/inode.c:532 as described in [1].
      This BUG triggers if the HPageRestoreReserve flag is set on a page in
      the page cache.  It should never be set, as the routine
      huge_add_to_page_cache explicitly clears the flag after adding a page to
      the cache.
      
      The only code other than huge page allocation which sets the flag is
      restore_reserve_on_error.  It will potentially set the flag in rare out
      of memory conditions.  syzbot was injecting errors to cause memory
      allocation errors which exercised this specific path.
      
      The code in restore_reserve_on_error is doing the right thing.  However,
      there are instances where pages in the page cache were being passed to
      restore_reserve_on_error.  This is incorrect, as once a page goes into
      the cache reservation information will not be modified for the page
      until it is removed from the cache.  Error paths do not remove pages
      from the cache, so even in the case of error, the page will remain in
      the cache and no reservation adjustment is needed.
      
      Modify routines that potentially call restore_reserve_on_error with a
      page cache page to no longer do so.
      
      Note on fixes tag: Prior to commit 846be085 ("mm/hugetlb: expand
      restore_reserve_on_error functionality") the routine would not process
      page cache pages because the HPageRestoreReserve flag is not set on such
      pages.  Therefore, this issue could not be trigggered.  The code added
      by commit 846be085 ("mm/hugetlb: expand restore_reserve_on_error
      functionality") is needed and correct.  It exposed incorrect calls to
      restore_reserve_on_error which is the root cause addressed by this
      commit.
      
      [1] https://lore.kernel.org/linux-mm/00000000000050776d05c9b7c7f0@google.com/
      
      Link: https://lkml.kernel.org/r/20210818213304.37038-1-mike.kravetz@oracle.com
      Fixes: 846be085 ("mm/hugetlb: expand restore_reserve_on_error functionality")
      Signed-off-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
      Reported-by: <syzbot+67654e51e54455f1c585@syzkaller.appspotmail.com>
      Cc: Mina Almasry <almasrymina@google.com>
      Cc: Axel Rasmussen <axelrasmussen@google.com>
      Cc: Peter Xu <peterx@redhat.com>
      Cc: Muchun Song <songmuchun@bytedance.com>
      Cc: Michal Hocko <mhocko@suse.com>
      Cc: Naoya Horiguchi <naoya.horiguchi@linux.dev>
      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>
      c7b1850d
    • Marco Elver's avatar
      kfence: fix is_kfence_address() for addresses below KFENCE_POOL_SIZE · a7cb5d23
      Marco Elver authored
      Originally the addr != NULL check was meant to take care of the case
      where __kfence_pool == NULL (KFENCE is disabled).  However, this does
      not work for addresses where addr > 0 && addr < KFENCE_POOL_SIZE.
      
      This can be the case on NULL-deref where addr > 0 && addr < PAGE_SIZE or
      any other faulting access with addr < KFENCE_POOL_SIZE.  While the
      kernel would likely crash, the stack traces and report might be
      confusing due to double faults upon KFENCE's attempt to unprotect such
      an address.
      
      Fix it by just checking that __kfence_pool != NULL instead.
      
      Link: https://lkml.kernel.org/r/20210818130300.2482437-1-elver@google.com
      Fixes: 0ce20dd8 ("mm: add Kernel Electric-Fence infrastructure")
      Signed-off-by: default avatarMarco Elver <elver@google.com>
      Reported-by: default avatarKuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
      Acked-by: default avatarAlexander Potapenko <glider@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: <stable@vger.kernel.org>    [5.12+]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      a7cb5d23