Hugh Dickins
e89c53fcd2
memfd: fix F_SEAL_WRITE after shmem huge page allocated
...
commit f2b277c4d1c63a85127e8aa2588e9cc3bd21cb99 upstream.
Wangyong reports: after enabling tmpfs filesystem to support transparent
hugepage with the following command:
echo always > /sys/kernel/mm/transparent_hugepage/shmem_enabled
the docker program tries to add F_SEAL_WRITE through the following
command, but it fails unexpectedly with errno EBUSY:
fcntl(5, F_ADD_SEALS, F_SEAL_WRITE) = -1.
That is because memfd_tag_pins() and memfd_wait_for_pins() were never
updated for shmem huge pages: checking page_mapcount() against
page_count() is hopeless on THP subpages - they need to check
total_mapcount() against page_count() on THP heads only.
Make memfd_tag_pins() (compared > 1) as strict as memfd_wait_for_pins()
(compared != 1): either can be justified, but given the non-atomic
total_mapcount() calculation, it is better now to be strict. Bear in
mind that total_mapcount() itself scans all of the THP subpages, when
choosing to take an XA_CHECK_SCHED latency break.
Also fix the unlikely xa_is_value() case in memfd_wait_for_pins(): if a
page has been swapped out since memfd_tag_pins(), then its refcount must
have fallen, and so it can safely be untagged.
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Hugh Dickins <[email protected] >
Reported-by: Zeal Robot <[email protected] >
Reported-by: wangyong <[email protected] >
Cc: Mike Kravetz <[email protected] >
Cc: Matthew Wilcox (Oracle) <[email protected] >
Cc: CGEL ZTE <[email protected] >
Cc: Kirill A. Shutemov <[email protected] >
Cc: Song Liu <[email protected] >
Cc: Yang Yang <[email protected] >
Cc: <[email protected] >
Signed-off-by: Andrew Morton <[email protected] >
Signed-off-by: Linus Torvalds <[email protected] >
Signed-off-by: Greg Kroah-Hartman <[email protected] >
2022-03-08 19:07:49 +01:00
..
kasan
kasan: fix incorrect arguments passing in kasan_add_zero_shadow
2021-01-27 11:47:53 +01:00
backing-dev.c
mm: bdi: initialize bdi_min_ratio when bdi is unregistered
2021-12-14 14:49:00 +01:00
balloon_compaction.c
cleancache.c
cma.c
cma: don't quit at first error when activating reserved areas
2020-09-03 11:26:51 +02:00
cma.h
cma_debug.c
compaction.c
mm/compaction: fix misbehaviors of fast_find_migrateblock()
2021-03-04 10:26:39 +01:00
debug.c
debug_page_ref.c
dmapool.c
early_ioremap.c
fadvise.c
failslab.c
filemap.c
mm/filemap: fix storing to a THP shadow entry
2021-06-10 13:37:15 +02:00
frame_vector.c
frontswap.c
gup.c
mm/gup: fix gup_fast with dynamic page table folding
2020-10-01 13:18:24 +02:00
gup_benchmark.c
highmem.c
hmm.c
huge_memory.c
mm/huge_memory.c: don't discard hugepage if other processes are mapping it
2021-07-14 16:53:47 +02:00
hugetlb.c
hugetlbfs: flush TLBs correctly after huge_pmd_unshare
2021-11-26 10:47:23 +01:00
hugetlb_cgroup.c
hwpoison-inject.c
init-mm.c
internal.h
mm/thp: fix vma_address() if virtual address below file offset
2021-06-30 08:47:52 -04:00
interval_tree.c
Kconfig
mm/zsmalloc.c: drop ZSMALLOC_PGTABLE_MAPPING
2020-12-16 10:56:59 +01:00
Kconfig.debug
khugepaged.c
khugepaged: fix wrong result value for trace_mm_collapse_huge_page_isolate()
2021-05-19 10:08:27 +02:00
kmemleak-test.c
kmemleak.c
mm/kmemleak: avoid scanning potential huge holes
2022-02-08 18:24:28 +01:00
ksm.c
ksm: fix potential missing rmap_item for stable_node
2021-05-19 10:08:27 +02:00
list_lru.c
mm: list_lru: set shrinker map bit when child nr_items is not zero
2020-12-11 13:23:31 +01:00
maccess.c
madvise.c
mm: validate pmd after splitting
2020-10-01 13:18:21 +02:00
Makefile
memblock.c
memblock: use kfree() to release kmalloced memblock regions
2022-03-02 11:41:18 +01:00
memcontrol.c
mm, memcg: avoid stale protection values when cgroup is above protection
2021-08-26 08:36:22 -04:00
memfd.c
memfd: fix F_SEAL_WRITE after shmem huge page allocated
2022-03-08 19:07:49 +01:00
memory-failure.c
mm/memory-failure: make sure wait for page writeback in memory_failure
2021-06-23 14:41:23 +02:00
memory.c
mm/thp: unmap_mapping_page() to fix THP truncate_cleanup_page()
2021-06-30 08:47:53 -04:00
memory_hotplug.c
mm/memory_hotplug: use "unsigned long" for PFN in zone_for_pfn_range()
2021-09-22 12:26:43 +02:00
mempolicy.c
mm: mempolicy: fix THP allocations escaping mempolicy restrictions
2021-12-29 12:23:37 +01:00
mempool.c
memremap.c
memtest.c
migrate.c
mm, thp: use head page in __migration_entry_wait()
2021-06-30 08:47:52 -04:00
mincore.c
mlock.c
mm_init.c
mmap.c
mm/mmap.c: initialize align_offset explicitly for vm_unmapped_area
2020-10-01 13:17:54 +02:00
mmu_context.c
mm: fix kthread_use_mm() vs TLB invalidate
2020-09-03 11:26:51 +02:00
mmu_gather.c
mmu_notifier.c
mmzone.c
mprotect.c
mremap.c
mm: Fix mremap not considering huge pmd devmap
2020-06-07 13:18:46 +02:00
msync.c
nommu.c
oom_kill.c
mm, oom: do not trigger out_of_memory from the #PF
2021-11-17 09:48:50 +01:00
page-writeback.c
page_alloc.c
mm/page_alloc.c: do not warn allocation failure on zone DMA if no managed pages
2022-01-27 09:19:28 +01:00
page_counter.c
mm/page_counter.c: fix protection usage propagation
2020-08-21 13:05:27 +02:00
page_ext.c
page_idle.c
page_io.c
swap: fix swapfile read/write offset
2021-03-07 12:20:49 +01:00
page_isolation.c
mm/memory_hotplug: drain per-cpu pages again during memory offline
2020-09-23 12:40:47 +02:00
page_owner.c
mm/page_owner: change split_page_owner to take a count
2020-10-29 09:57:52 +01:00
page_poison.c
page_vma_mapped.c
mm/thp: another PVMW_SYNC fix in page_vma_mapped_walk()
2021-06-30 08:47:55 -04:00
pagewalk.c
mm: pagewalk: fix termination condition in walk_pte_range()
2020-10-01 13:17:30 +02:00
percpu-internal.h
percpu-km.c
percpu-stats.c
percpu-vm.c
percpu.c
percpu: fix first chunk size calculation for populated bitmap
2020-09-23 12:40:45 +02:00
pgtable-generic.c
mm/thp: fix __split_huge_pmd_locked() on shmem migration entry
2021-06-30 08:47:52 -04:00
process_vm_access.c
readahead.c
rmap.c
mm/thp: fix page_address_in_vma() on file THP tails
2021-06-30 08:47:53 -04:00
rodata_test.c
shmem.c
shmem: fix a race between shmem_unused_huge_shrink and shmem_evict_inode
2022-01-27 09:19:29 +01:00
shuffle.c
mm/shuffle: don't move pages between zones and don't read garbage memmaps
2020-09-03 11:26:51 +02:00
shuffle.h
slab.c
slab.h
mm: kmemleak: slob: respect SLAB_NOLEAKTRACE flag
2021-11-26 10:47:21 +01:00
slab_common.c
mm: slab: fix kmem_cache_create failed when sysfs node not destroyed
2021-07-25 14:35:14 +02:00
slob.c
slub.c
mm, slub: fix potential memoryleak in kmem_cache_open()
2021-10-27 09:54:28 +02:00
sparse-vmemmap.c
sparse.c
mm/sparse: add the missing sparse_buffer_fini() in error branch
2021-05-14 09:44:32 +02:00
swap.c
swap_cgroup.c
swap_slots.c
swap_state.c
mm/swap_state: fix a data race in swapin_nr_pages
2020-10-01 13:18:08 +02:00
swapfile.c
swap: fix swapfile read/write offset
2021-03-07 12:20:49 +01:00
truncate.c
mm/thp: unmap_mapping_page() to fix THP truncate_cleanup_page()
2021-06-30 08:47:53 -04:00
usercopy.c
userfaultfd.c
hugetlbfs: hugetlb_fault_mutex_hash() cleanup
2021-03-30 14:35:19 +02:00
util.c
mm: add kvfree_sensitive() for freeing sensitive data objects
2020-06-17 16:40:23 +02:00
vmacache.c
vmalloc.c
mm/vunmap: add cond_resched() in vunmap_pmd_range
2020-09-03 11:26:52 +02:00
vmpressure.c
vmscan.c
mm,vmscan: fix divide by zero in get_scan_count
2021-09-22 12:26:37 +02:00
vmstat.c
workingset.c
z3fold.c
mm/z3fold: fix potential memory leak in z3fold_destroy_pool()
2021-07-14 16:53:47 +02:00
zbud.c
zpool.c
zsmalloc.c
mm/zsmalloc.c: close race window between zs_pool_dec_isolated() and zs_unregister_migration()
2021-11-17 09:48:47 +01:00
zswap.c