linux-stable/include
Matthew Wilcox (Oracle) 9fdcc5b635 mm: turn folio_test_hugetlb into a PageType
commit d99e3140a4 upstream.

The current folio_test_hugetlb() can be fooled by a concurrent folio split
into returning true for a folio which has never belonged to hugetlbfs.
This can't happen if the caller holds a refcount on it, but we have a few
places (memory-failure, compaction, procfs) which do not and should not
take a speculative reference.

Since hugetlb pages do not use individual page mapcounts (they are always
fully mapped and use the entire_mapcount field to record the number of
mappings), the PageType field is available now that page_mapcount()
ignores the value in this field.

In compaction and with CONFIG_DEBUG_VM enabled, the current implementation
can result in an oops, as reported by Luis. This happens since 9c5ccf2db0
("mm: remove HUGETLB_PAGE_DTOR") effectively added some VM_BUG_ON() checks
in the PageHuge() testing path.

[willy@infradead.org: update vmcoreinfo]
  Link: https://lkml.kernel.org/r/ZgGZUvsdhaT1Va-T@casper.infradead.org
Link: https://lkml.kernel.org/r/20240321142448.1645400-6-willy@infradead.org
Fixes: 9c5ccf2db0 ("mm: remove HUGETLB_PAGE_DTOR")
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Reported-by: Luis Chamberlain <mcgrof@kernel.org>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218227
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-05-02 16:35:32 +02:00
..
acpi ACPI: bus: allow _UID matching for integer zero 2024-04-17 11:23:29 +02:00
asm-generic sched: Add missing memory barrier in switch_mm_cid 2024-04-27 17:13:01 +02:00
clocksource
crypto
drm drm: add drm_gem_object_is_shared_for_memory_stats() helper 2024-05-02 16:35:23 +02:00
dt-bindings clk: renesas: r8a779g0: Correct PFC/GPIO parent clocks 2024-03-26 18:17:05 -04:00
keys
kunit
kvm KVM: arm64: Fix host-programmed guest events in nVHE 2024-04-10 16:38:01 +02:00
linux mm: turn folio_test_hugetlb into a PageType 2024-05-02 16:35:32 +02:00
math-emu
media media: mc: Add num_links flag to media_pad 2024-04-03 15:32:03 +02:00
memory
misc
net macsec: Enable devices to advertise whether they update sk_buff md_dst during offloads 2024-05-02 16:35:30 +02:00
pcmcia
ras
rdma
rv
scsi scsi: sd: Fix TCG OPAL unlock on system resume 2024-04-03 15:32:45 +02:00
soc soc: qcom: socinfo: rename PM2250 to PM4125 2024-03-26 18:16:34 -04:00
sound ALSA: hda: Add pplcllpl/u members to hdac_ext_stream 2024-04-10 16:38:15 +02:00
target
trace mm: turn folio_test_hugetlb into a PageType 2024-05-02 16:35:32 +02:00
uapi Input: allocate keycode for Display refresh rate toggle 2024-04-13 13:10:07 +02:00
ufs
vdso
video video/sticore: Remove info field from STI struct 2024-01-12 12:38:37 +01:00
xen