summaryrefslogtreecommitdiff
path: root/mm/mmap.c
diff options
context:
space:
mode:
authorXuanye Liu <liuqiye2025@163.com>2025-07-10 10:58:58 +0800
committerAndrew Morton <akpm@linux-foundation.org>2025-07-19 18:59:53 -0700
commite001ef9652c2d931a1126c9d173ec5ea95e9847a (patch)
tree25563ab988d79e0d6ffaa1e373fac89597d3fa17 /mm/mmap.c
parentc809579374f47c8273eaf22a40674ae547f39254 (diff)
mm: simplify min_brk handling in brk()
Set min_brk to mm->start_brk by default, and override it with mm->end_data only when CONFIG_COMPAT_BRK is enabled and brk_randomized is false. This makes the logic clearer with no functional change. Link: https://lkml.kernel.org/r/20250710025859.926355-1-liuqiye2025@163.com Signed-off-by: Xuanye Liu <liuqiye2025@163.com> Reviewed-by: Pedro Falcato <pfalcato@suse.de> Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Cc: Jann Horn <jannh@google.com> Cc: Liam Howlett <liam.howlett@oracle.com> Cc: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/mmap.c')
-rw-r--r--mm/mmap.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/mm/mmap.c b/mm/mmap.c
index 74072369e8fd..1287e92ccdda 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -127,18 +127,15 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
origbrk = mm->brk;
+ min_brk = mm->start_brk;
#ifdef CONFIG_COMPAT_BRK
/*
* CONFIG_COMPAT_BRK can still be overridden by setting
* randomize_va_space to 2, which will still cause mm->start_brk
* to be arbitrarily shifted
*/
- if (current->brk_randomized)
- min_brk = mm->start_brk;
- else
+ if (!current->brk_randomized)
min_brk = mm->end_data;
-#else
- min_brk = mm->start_brk;
#endif
if (brk < min_brk)
goto out;