linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Heiko Carstens <hca@linux.ibm.com>,
	Mike Kravetz <mike.kravetz@oracle.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 5.9 098/105] mm/hugetlb: clear compound_nr before freeing gigantic pages
Date: Mon, 14 Dec 2020 18:29:12 +0100	[thread overview]
Message-ID: <20201214172559.997198117@linuxfoundation.org> (raw)
In-Reply-To: <20201214172555.280929671@linuxfoundation.org>

From: Gerald Schaefer <gerald.schaefer@linux.ibm.com>

commit ba9c1201beaa86a773e83be5654602a0667e4a4d upstream.

Commit 1378a5ee451a ("mm: store compound_nr as well as compound_order")
added compound_nr counter to first tail struct page, overlaying with
page->mapping.  The overlay itself is fine, but while freeing gigantic
hugepages via free_contig_range(), a "bad page" check will trigger for
non-NULL page->mapping on the first tail page:

  BUG: Bad page state in process bash  pfn:380001
  page:00000000c35f0856 refcount:0 mapcount:0 mapping:00000000126b68aa index:0x0 pfn:0x380001
  aops:0x0
  flags: 0x3ffff00000000000()
  raw: 3ffff00000000000 0000000000000100 0000000000000122 0000000100000000
  raw: 0000000000000000 0000000000000000 ffffffff00000000 0000000000000000
  page dumped because: non-NULL mapping
  Modules linked in:
  CPU: 6 PID: 616 Comm: bash Not tainted 5.10.0-rc7-next-20201208 #1
  Hardware name: IBM 3906 M03 703 (LPAR)
  Call Trace:
    show_stack+0x6e/0xe8
    dump_stack+0x90/0xc8
    bad_page+0xd6/0x130
    free_pcppages_bulk+0x26a/0x800
    free_unref_page+0x6e/0x90
    free_contig_range+0x94/0xe8
    update_and_free_page+0x1c4/0x2c8
    free_pool_huge_page+0x11e/0x138
    set_max_huge_pages+0x228/0x300
    nr_hugepages_store_common+0xb8/0x130
    kernfs_fop_write+0xd2/0x218
    vfs_write+0xb0/0x2b8
    ksys_write+0xac/0xe0
    system_call+0xe6/0x288
  Disabling lock debugging due to kernel taint

This is because only the compound_order is cleared in
destroy_compound_gigantic_page(), and compound_nr is set to
1U << order == 1 for order 0 in set_compound_order(page, 0).

Fix this by explicitly clearing compound_nr for first tail page after
calling set_compound_order(page, 0).

Link: https://lkml.kernel.org/r/20201208182813.66391-2-gerald.schaefer@linux.ibm.com
Fixes: 1378a5ee451a ("mm: store compound_nr as well as compound_order")
Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: <stable@vger.kernel.org>	[5.9+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 mm/hugetlb.c |    1 +
 1 file changed, 1 insertion(+)

--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1227,6 +1227,7 @@ static void destroy_compound_gigantic_pa
 	}
 
 	set_compound_order(page, 0);
+	page[1].compound_nr = 0;
 	__ClearPageHead(page);
 }
 



  parent reply	other threads:[~2020-12-14 18:17 UTC|newest]

Thread overview: 113+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-14 17:27 [PATCH 5.9 000/105] 5.9.15-rc1 review Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 001/105] Kbuild: do not emit debug info for assembly with LLVM_IAS=1 Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 002/105] mm/zsmalloc.c: drop ZSMALLOC_PGTABLE_MAPPING Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 003/105] kprobes: Remove NMI context check Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 004/105] kprobes: Tell lockdep about kprobe nesting Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 005/105] ASoC: Intel: bytcr_rt5640: Fix HP Pavilion x2 Detachable quirks Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 006/105] tools/bootconfig: Fix to check the write failure correctly Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 007/105] net, xsk: Avoid taking multiple skbuff references Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 008/105] bpftool: Fix error return value in build_btf_type_table Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 009/105] vhost-vdpa: fix page pinning leakage in error path (rework) Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 010/105] powerpc/64s: Fix hash ISA v3.0 TLBIEL instruction generation Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 011/105] batman-adv: Consider fragmentation for needed_headroom Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 012/105] batman-adv: Reserve needed_*room for fragments Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 013/105] batman-adv: Dont always reallocate the fragmentation skb head Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 014/105] ipvs: fix possible memory leak in ip_vs_control_net_init Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 015/105] ibmvnic: handle inconsistent login with reset Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 016/105] ibmvnic: stop free_all_rwi on failed reset Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 017/105] ibmvnic: avoid memset null scrq msgs Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 018/105] ibmvnic: delay next reset if hard reset fails Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 019/105] ibmvnic: track pending login Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 020/105] ibmvnic: send_login should check for crq errors Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 021/105] ibmvnic: reduce wait for completion time Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 022/105] drm/rockchip: Avoid uninitialized use of endpoint id in LVDS Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 023/105] drm/panel: sony-acx565akm: Fix race condition in probe Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 024/105] can: m_can: tcan4x5x_can_probe(): fix error path: remove erroneous clk_disable_unprepare() Greg Kroah-Hartman
2020-12-14 17:27 ` [PATCH 5.9 025/105] can: sja1000: sja1000_err(): dont count arbitration lose as an error Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 026/105] can: sun4i_can: sun4i_can_err(): " Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 027/105] can: c_can: c_can_power_up(): fix error handling Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 028/105] can: kvaser_pciefd: kvaser_pciefd_open(): " Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 029/105] samples/ftrace: Mark my_tramp[12]? global Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 030/105] scsi: storvsc: Fix error return in storvsc_probe() Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 031/105] net: broadcom CNIC: requires MMU Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 032/105] vdpa: mlx5: fix vdpa/vhost dependencies Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 033/105] iwlwifi: pcie: invert values of NO_160 device config entries Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 034/105] perf/x86/intel: Fix a warning on x86_pmu_stop() with large PEBS Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 035/105] usb: ohci-omap: Fix descriptor conversion Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 036/105] zlib: export S390 symbols for zlib modules Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 037/105] mm/mmap.c: fix mmap return value when vma is merged after call_mmap() Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 038/105] phy: usb: Fix incorrect clearing of tca_drv_sel bit in SETUP reg for 7211 Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 039/105] arm64: dts: rockchip: Remove system-power-controller from pmic on Odroid Go Advance Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 040/105] iwlwifi: pcie: limit memory read spin time Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 041/105] arm64: dts: rockchip: Assign a fixed index to mmc devices on rk3399 boards Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 042/105] arm64: dts: rockchip: Reorder LED triggers from mmc devices on rk3399-roc-pc Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 043/105] iwlwifi: sta: set max HE max A-MPDU according to HE capa Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 044/105] iwlwifi: pcie: set LTR to avoid completion timeout Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 045/105] iwlwifi: mvm: fix kernel panic in case of assert during CSA Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 046/105] powerpc: Drop -me200 addition to build flags Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 047/105] arm64: dts: broadcom: clear the warnings caused by empty dma-ranges Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 048/105] ARC: stack unwinding: dont assume non-current task is sleeping Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 049/105] scsi: ufs: Fix unexpected values from ufshcd_read_desc_param() Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 050/105] scsi: ufs: Make sure clk scaling happens only when HBA is runtime ACTIVE Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 051/105] interconnect: qcom: msm8916: Remove rpm-ids from non-RPM nodes Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 052/105] interconnect: qcom: qcs404: Remove GPU and display RPM IDs Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 053/105] ibmvnic: skip tx timeout reset while in resetting Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 054/105] irqchip/gic-v3-its: Unconditionally save/restore the ITS state on suspend Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 055/105] drm/exynos: depend on COMMON_CLK to fix compile tests Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 056/105] spi: spi-nxp-fspi: fix fspi panic by unexpected interrupts Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 057/105] arm-smmu-qcom: Ensure the qcom_scm driver has finished probing Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 058/105] habanalabs/gaudi: fix missing code in ECC handling Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 059/105] btrfs: do nofs allocations when adding and removing qgroup relations Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 060/105] btrfs: fix lockdep splat when enabling and disabling qgroups Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 061/105] soc: fsl: dpio: Get the cpumask through cpumask_of(cpu) Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 062/105] sched/idle: Fix arch_cpu_idle() vs tracing Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 063/105] intel_idle: Fix intel_idle() " Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 064/105] arm64: tegra: Disable the ACONNECT for Jetson TX2 Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 065/105] platform/x86: thinkpad_acpi: add P1 gen3 second fan support Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 066/105] platform/x86: thinkpad_acpi: Do not report SW_TABLET_MODE on Yoga 11e Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 067/105] platform/x86: thinkpad_acpi: Add BAT1 is primary battery quirk for Thinkpad Yoga 11e 4th gen Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 068/105] platform/x86: thinkpad_acpi: Whitelist P15 firmware for dual fan control Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 069/105] platform/x86: acer-wmi: add automatic keyboard background light toggle key as KEY_LIGHTS_TOGGLE Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 070/105] platform/x86: intel-vbtn: Support for tablet mode on HP Pavilion 13 x360 PC Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 071/105] platform/x86: touchscreen_dmi: Add info for the Predia Basic tablet Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 072/105] platform/x86: touchscreen_dmi: Add info for the Irbis TW118 tablet Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 073/105] can: m_can: m_can_dev_setup(): add support for bosch mcan version 3.3.0 Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 074/105] s390: fix irq state tracing Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 075/105] intel_idle: Build fix Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 076/105] media: pulse8-cec: fix duplicate free at disconnect or probe error Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 077/105] media: pulse8-cec: add support for FW v10 and up Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 078/105] mmc: mediatek: Fix system suspend/resume support for CQHCI Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 079/105] mmc: mediatek: Extend recheck_sdio_irq fix to more variants Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 080/105] ktest.pl: Fix incorrect reboot for grub2bls Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 081/105] xen: add helpers for caching grant mapping pages Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 082/105] xen: dont use page->lru for ZONE_DEVICE memory Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 083/105] Input: cm109 - do not stomp on control URB Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 084/105] Input: i8042 - add Acer laptops to the i8042 reset list Greg Kroah-Hartman
2020-12-14 17:28 ` [PATCH 5.9 085/105] pinctrl: jasperlake: Fix HOSTSW_OWN offset Greg Kroah-Hartman
2020-12-14 17:29 ` [PATCH 5.9 086/105] pinctrl: amd: remove debounce filter setting in IRQ type setting Greg Kroah-Hartman
2020-12-14 17:29 ` [PATCH 5.9 087/105] mmc: sdhci-of-arasan: Fix clock registration error for Keem Bay SOC Greg Kroah-Hartman
2020-12-14 17:29 ` [PATCH 5.9 088/105] mmc: block: Fixup condition for CMD13 polling for RPMB requests Greg Kroah-Hartman
2020-12-14 17:29 ` [PATCH 5.9 089/105] drm/amdgpu/disply: set num_crtc earlier Greg Kroah-Hartman
2020-12-14 17:29 ` [PATCH 5.9 090/105] drm/i915/gem: Propagate error from cancelled submit due to context closure Greg Kroah-Hartman
2020-12-14 17:29 ` [PATCH 5.9 091/105] drm/i915/display/dp: Compute the correct slice count for VDSC on DP Greg Kroah-Hartman
2020-12-14 17:29 ` [PATCH 5.9 092/105] drm/i915/gt: Declare gen9 has 64 mocs entries! Greg Kroah-Hartman
2020-12-14 17:29 ` [PATCH 5.9 093/105] drm/i915/gt: Ignore repeated attempts to suspend request flow across reset Greg Kroah-Hartman
2020-12-14 17:29 ` [PATCH 5.9 094/105] drm/i915/gt: Cancel the preemption timeout on responding to it Greg Kroah-Hartman
2020-12-14 17:29 ` [PATCH 5.9 095/105] drm/amdgpu: fix sdma instance fw version and feature version init Greg Kroah-Hartman
2020-12-14 17:29 ` [PATCH 5.9 096/105] kbuild: avoid static_assert for genksyms Greg Kroah-Hartman
2020-12-14 17:29 ` [PATCH 5.9 097/105] proc: use untagged_addr() for pagemap_read addresses Greg Kroah-Hartman
2020-12-14 17:29 ` Greg Kroah-Hartman [this message]
2020-12-14 17:29 ` [PATCH 5.9 099/105] zonefs: fix page reference and BIO leak Greg Kroah-Hartman
2020-12-14 17:29 ` [PATCH 5.9 100/105] scsi: be2iscsi: Revert "Fix a theoretical leak in beiscsi_create_eqs()" Greg Kroah-Hartman
2020-12-14 17:29 ` [PATCH 5.9 101/105] x86/mm/mem_encrypt: Fix definition of PMD_FLAGS_DEC_WP Greg Kroah-Hartman
2020-12-14 17:29 ` [PATCH 5.9 102/105] x86/membarrier: Get rid of a dubious optimization Greg Kroah-Hartman
2020-12-14 17:29 ` [PATCH 5.9 103/105] x86/apic/vector: Fix ordering in vector assignment Greg Kroah-Hartman
2020-12-14 17:29 ` [PATCH 5.9 104/105] x86/kprobes: Fix optprobe to detect INT3 padding correctly Greg Kroah-Hartman
2020-12-14 17:29 ` [PATCH 5.9 105/105] compiler.h: fix barrier_data() on clang Greg Kroah-Hartman
2020-12-14 22:06 ` [PATCH 5.9 000/105] 5.9.15-rc1 review Jeffrin Jose T
2020-12-14 23:53 ` Shuah Khan
2020-12-16 13:20   ` Greg Kroah-Hartman
2020-12-15  2:27 ` Naresh Kamboju
2020-12-16 13:20   ` Greg Kroah-Hartman
2020-12-15 20:32 ` Guenter Roeck
2020-12-16 13:21   ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201214172559.997198117@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=borntraeger@de.ibm.com \
    --cc=gerald.schaefer@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mike.kravetz@oracle.com \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).