linux-kernelorg-stable/kernel/bpf
Ryan Roberts 9ac09bb9fe mm: consistently use current->mm in mm_get_unmapped_area()
mm_get_unmapped_area() is a wrapper around arch_get_unmapped_area() /
arch_get_unmapped_area_topdown(), both of which search current->mm for
some free space.  Neither take an mm_struct - they implicitly operate on
current->mm.

But the wrapper takes an mm_struct and uses it to decide whether to search
bottom up or top down.  All callers pass in current->mm for this, so
everything is working consistently.  But it feels like an accident waiting
to happen; eventually someone will call that function with a different mm,
expecting to find free space in it, but what gets returned is free space
in the current mm.

So let's simplify by removing the parameter and have the wrapper use
current->mm to decide which end to start at.  Now everything is consistent
and self-documenting.

Link: https://lkml.kernel.org/r/20251003155306.2147572-1-ryan.roberts@arm.com
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Reviewed-by: Dev Jain <dev.jain@arm.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2025-11-16 17:27:57 -08:00
..
preload
Kconfig bpf: Update the bpf_prog_calc_tag to use SHA256 2025-09-18 19:10:20 -07:00
Makefile bpf: callchain sensitive stack liveness tracking using CFG 2025-09-19 09:27:23 -07:00
arena.c mm: consistently use current->mm in mm_get_unmapped_area() 2025-11-16 17:27:57 -08:00
arraymap.c bpf: bpf task work plumbing 2025-09-23 07:34:38 -07:00
bloom_filter.c
bpf_cgrp_storage.c bpf: use rcu_read_lock_dont_migrate() for bpf_cgrp_storage_free() 2025-08-25 18:52:16 -07:00
bpf_inode_storage.c bpf: use rcu_read_lock_dont_migrate() for bpf_inode_storage_free() 2025-08-25 18:52:16 -07:00
bpf_iter.c bpf: use rcu_read_lock_dont_migrate() for bpf_iter_run_prog() 2025-08-25 18:52:16 -07:00
bpf_local_storage.c
bpf_lru_list.c bpf: Replace get_next_cpu() with cpumask_next_wrap() 2025-08-18 15:11:02 +02:00
bpf_lru_list.h
bpf_lsm.c
bpf_struct_ops.c
bpf_task_storage.c bpf: use rcu_read_lock_dont_migrate() for bpf_task_storage_free() 2025-08-25 18:52:16 -07:00
btf.c bpf: Allow union argument in trampoline based programs 2025-09-23 12:07:46 -07:00
btf_iter.c
btf_relocate.c
cgroup.c bpf: WQ_PERCPU added to alloc_workqueue users 2025-09-08 10:04:37 -07:00
cgroup_iter.c
core.c bpf: Enforce expected_attach_type for tailcall compatibility 2025-09-27 06:24:27 -07:00
cpumap.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf after rc5 2025-09-11 09:34:37 -07:00
cpumask.c
crypto.c bpf: Fix out-of-bounds dynptr write in bpf_crypto_crypt 2025-09-09 15:07:57 -07:00
devmap.c
disasm.c
disasm.h
dispatcher.c
dmabuf_iter.c
hashtab.c bpf: bpf task work plumbing 2025-09-23 07:34:38 -07:00
helpers.c bpf: Conditionally include dynptr copy kfuncs 2025-10-24 09:44:47 -07:00
inode.c bpf: Avoid RCU context warning when unpinning htab with internal structs 2025-10-10 10:10:08 -07:00
kmem_cache_iter.c
link_iter.c
liveness.c bpf: Fix memory leak in __lookup_instance error path 2025-10-16 10:45:17 -07:00
local_storage.c
log.c bpf: disable and remove registers chain based liveness 2025-09-19 09:27:23 -07:00
lpm_trie.c
map_in_map.c
map_in_map.h
map_iter.c
memalloc.c bpf: replace use of system_unbound_wq with system_dfl_wq 2025-09-08 10:04:37 -07:00
mmap_unlock_work.h
mprog.c
net_namespace.c
offload.c
percpu_freelist.c
percpu_freelist.h
prog_iter.c
queue_stack_maps.c
range_tree.c
range_tree.h
relo_core.c
reuseport_array.c
ringbuf.c bpf: Sync pending IRQ work before freeing ring buffer 2025-10-21 09:57:48 -07:00
rqspinlock.c rqspinlock: Choose trylock fallback for NMI waiters 2025-09-09 15:10:28 -07:00
rqspinlock.h
stackmap.c bpf-next-6.18 2025-09-30 17:58:11 -07:00
stream.c mm: Allow GFP_ACCOUNT to be used in alloc_pages_nolock(). 2025-09-29 09:42:35 +02:00
syscall.c mm: consistently use current->mm in mm_get_unmapped_area() 2025-11-16 17:27:57 -08:00
sysfs_btf.c
task_iter.c
tcx.c
tnum.c bpf: Improve the general precision of tnum_mul 2025-08-27 15:00:26 -07:00
token.c
trampoline.c bpf: use rcu_read_lock_dont_migrate() for trampoline.c 2025-08-25 18:52:16 -07:00
verifier.c bpf: Reject negative offsets for ALU ops 2025-10-01 15:43:13 -07:00