This function only reads from the rlimit pointer (but writes to the
mm_struct pointer which is kept without `const`).
All callees are already const-ified or (internal functions) are being
constified by this patch.
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
---
arch/s390/mm/mmap.c | 4 ++--
arch/sparc/kernel/sys_sparc_64.c | 2 +-
arch/x86/mm/mmap.c | 6 +++---
include/linux/sched/mm.h | 4 ++--
mm/util.c | 6 +++---
5 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
index e188cb6d4946..197c1d9497a7 100644
--- a/arch/s390/mm/mmap.c
+++ b/arch/s390/mm/mmap.c
@@ -47,7 +47,7 @@ static unsigned long mmap_base_legacy(unsigned long rnd)
}
static inline unsigned long mmap_base(unsigned long rnd,
- struct rlimit *rlim_stack)
+ const struct rlimit *rlim_stack)
{
unsigned long gap = rlim_stack->rlim_cur;
unsigned long pad = stack_maxrandom_size() + stack_guard_gap;
@@ -169,7 +169,7 @@ unsigned long arch_get_unmapped_area_topdown(struct file *filp, unsigned long ad
* This function, called very early during the creation of a new
* process VM image, sets up which VM layout function to use:
*/
-void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
+void arch_pick_mmap_layout(struct mm_struct *mm, const struct rlimit *rlim_stack)
{
unsigned long random_factor = 0UL;
diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
index 785e9909340f..55faf2effa46 100644
--- a/arch/sparc/kernel/sys_sparc_64.c
+++ b/arch/sparc/kernel/sys_sparc_64.c
@@ -294,7 +294,7 @@ static unsigned long mmap_rnd(void)
return rnd << PAGE_SHIFT;
}
-void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
+void arch_pick_mmap_layout(struct mm_struct *mm, const struct rlimit *rlim_stack)
{
unsigned long random_factor = mmap_rnd();
unsigned long gap;
diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
index 708f85dc9380..82f3a987f7cf 100644
--- a/arch/x86/mm/mmap.c
+++ b/arch/x86/mm/mmap.c
@@ -80,7 +80,7 @@ unsigned long arch_mmap_rnd(void)
}
static unsigned long mmap_base(unsigned long rnd, unsigned long task_size,
- struct rlimit *rlim_stack)
+ const struct rlimit *rlim_stack)
{
unsigned long gap = rlim_stack->rlim_cur;
unsigned long pad = stack_maxrandom_size(task_size) + stack_guard_gap;
@@ -110,7 +110,7 @@ static unsigned long mmap_legacy_base(unsigned long rnd,
*/
static void arch_pick_mmap_base(unsigned long *base, unsigned long *legacy_base,
unsigned long random_factor, unsigned long task_size,
- struct rlimit *rlim_stack)
+ const struct rlimit *rlim_stack)
{
*legacy_base = mmap_legacy_base(random_factor, task_size);
if (mmap_is_legacy())
@@ -119,7 +119,7 @@ static void arch_pick_mmap_base(unsigned long *base, unsigned long *legacy_base,
*base = mmap_base(random_factor, task_size, rlim_stack);
}
-void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
+void arch_pick_mmap_layout(struct mm_struct *mm, const struct rlimit *rlim_stack)
{
if (mmap_is_legacy())
mm_flags_clear(MMF_TOPDOWN, mm);
diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h
index 2201da0afecc..0232d983b715 100644
--- a/include/linux/sched/mm.h
+++ b/include/linux/sched/mm.h
@@ -178,7 +178,7 @@ static inline void mm_update_next_owner(struct mm_struct *mm)
#endif
extern void arch_pick_mmap_layout(struct mm_struct *mm,
- struct rlimit *rlim_stack);
+ const struct rlimit *rlim_stack);
unsigned long
arch_get_unmapped_area(struct file *filp, unsigned long addr,
@@ -211,7 +211,7 @@ generic_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
unsigned long flags, vm_flags_t vm_flags);
#else
static inline void arch_pick_mmap_layout(struct mm_struct *mm,
- struct rlimit *rlim_stack) {}
+ const struct rlimit *rlim_stack) {}
#endif
static inline bool in_vfork(struct task_struct *tsk)
diff --git a/mm/util.c b/mm/util.c
index 241d2eaf26ca..77462027ad24 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -431,7 +431,7 @@ static int mmap_is_legacy(const struct rlimit *rlim_stack)
#define MIN_GAP (SZ_128M)
#define MAX_GAP (STACK_TOP / 6 * 5)
-static unsigned long mmap_base(unsigned long rnd, struct rlimit *rlim_stack)
+static unsigned long mmap_base(const unsigned long rnd, const struct rlimit *rlim_stack)
{
#ifdef CONFIG_STACK_GROWSUP
/*
@@ -462,7 +462,7 @@ static unsigned long mmap_base(unsigned long rnd, struct rlimit *rlim_stack)
#endif
}
-void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
+void arch_pick_mmap_layout(struct mm_struct *mm, const struct rlimit *rlim_stack)
{
unsigned long random_factor = 0UL;
@@ -478,7 +478,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
}
}
#elif defined(CONFIG_MMU) && !defined(HAVE_ARCH_PICK_MMAP_LAYOUT)
-void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
+void arch_pick_mmap_layout(struct mm_struct *mm, const struct rlimit *rlim_stack)
{
mm->mmap_base = TASK_UNMAPPED_BASE;
mm_flags_clear(MMF_TOPDOWN, mm);
--
2.47.2
On 01.09.25 22:50, Max Kellermann wrote: > This function only reads from the rlimit pointer (but writes to the > mm_struct pointer which is kept without `const`). > > All callees are already const-ified or (internal functions) are being > constified by this patch. > > Signed-off-by: Max Kellermann <max.kellermann@ionos.com> > Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com> > --- Acked-by: David Hildenbrand <david@redhat.com> -- Cheers David / dhildenb
On Mon, Sep 01, 2025 at 10:50:17PM +0200, Max Kellermann wrote: > This function only reads from the rlimit pointer (but writes to the > mm_struct pointer which is kept without `const`). > > All callees are already const-ified or (internal functions) are being > constified by this patch. > > Signed-off-by: Max Kellermann <max.kellermann@ionos.com> > Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com> LGTM, so: Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> > --- > arch/s390/mm/mmap.c | 4 ++-- > arch/sparc/kernel/sys_sparc_64.c | 2 +- > arch/x86/mm/mmap.c | 6 +++--- > include/linux/sched/mm.h | 4 ++-- > mm/util.c | 6 +++--- > 5 files changed, 11 insertions(+), 11 deletions(-) > > diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c > index e188cb6d4946..197c1d9497a7 100644 > --- a/arch/s390/mm/mmap.c > +++ b/arch/s390/mm/mmap.c > @@ -47,7 +47,7 @@ static unsigned long mmap_base_legacy(unsigned long rnd) > } > > static inline unsigned long mmap_base(unsigned long rnd, > - struct rlimit *rlim_stack) > + const struct rlimit *rlim_stack) > { > unsigned long gap = rlim_stack->rlim_cur; > unsigned long pad = stack_maxrandom_size() + stack_guard_gap; > @@ -169,7 +169,7 @@ unsigned long arch_get_unmapped_area_topdown(struct file *filp, unsigned long ad > * This function, called very early during the creation of a new > * process VM image, sets up which VM layout function to use: > */ > -void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack) > +void arch_pick_mmap_layout(struct mm_struct *mm, const struct rlimit *rlim_stack) > { > unsigned long random_factor = 0UL; > > diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c > index 785e9909340f..55faf2effa46 100644 > --- a/arch/sparc/kernel/sys_sparc_64.c > +++ b/arch/sparc/kernel/sys_sparc_64.c > @@ -294,7 +294,7 @@ static unsigned long mmap_rnd(void) > return rnd << PAGE_SHIFT; > } > > -void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack) > +void arch_pick_mmap_layout(struct mm_struct *mm, const struct rlimit *rlim_stack) > { > unsigned long random_factor = mmap_rnd(); > unsigned long gap; > diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c > index 708f85dc9380..82f3a987f7cf 100644 > --- a/arch/x86/mm/mmap.c > +++ b/arch/x86/mm/mmap.c > @@ -80,7 +80,7 @@ unsigned long arch_mmap_rnd(void) > } > > static unsigned long mmap_base(unsigned long rnd, unsigned long task_size, > - struct rlimit *rlim_stack) > + const struct rlimit *rlim_stack) > { > unsigned long gap = rlim_stack->rlim_cur; > unsigned long pad = stack_maxrandom_size(task_size) + stack_guard_gap; > @@ -110,7 +110,7 @@ static unsigned long mmap_legacy_base(unsigned long rnd, > */ > static void arch_pick_mmap_base(unsigned long *base, unsigned long *legacy_base, > unsigned long random_factor, unsigned long task_size, > - struct rlimit *rlim_stack) > + const struct rlimit *rlim_stack) > { > *legacy_base = mmap_legacy_base(random_factor, task_size); > if (mmap_is_legacy()) > @@ -119,7 +119,7 @@ static void arch_pick_mmap_base(unsigned long *base, unsigned long *legacy_base, > *base = mmap_base(random_factor, task_size, rlim_stack); > } > > -void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack) > +void arch_pick_mmap_layout(struct mm_struct *mm, const struct rlimit *rlim_stack) > { > if (mmap_is_legacy()) > mm_flags_clear(MMF_TOPDOWN, mm); > diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h > index 2201da0afecc..0232d983b715 100644 > --- a/include/linux/sched/mm.h > +++ b/include/linux/sched/mm.h > @@ -178,7 +178,7 @@ static inline void mm_update_next_owner(struct mm_struct *mm) > #endif > > extern void arch_pick_mmap_layout(struct mm_struct *mm, > - struct rlimit *rlim_stack); > + const struct rlimit *rlim_stack); > > unsigned long > arch_get_unmapped_area(struct file *filp, unsigned long addr, > @@ -211,7 +211,7 @@ generic_get_unmapped_area_topdown(struct file *filp, unsigned long addr, > unsigned long flags, vm_flags_t vm_flags); > #else > static inline void arch_pick_mmap_layout(struct mm_struct *mm, > - struct rlimit *rlim_stack) {} > + const struct rlimit *rlim_stack) {} > #endif > > static inline bool in_vfork(struct task_struct *tsk) > diff --git a/mm/util.c b/mm/util.c > index 241d2eaf26ca..77462027ad24 100644 > --- a/mm/util.c > +++ b/mm/util.c > @@ -431,7 +431,7 @@ static int mmap_is_legacy(const struct rlimit *rlim_stack) > #define MIN_GAP (SZ_128M) > #define MAX_GAP (STACK_TOP / 6 * 5) > > -static unsigned long mmap_base(unsigned long rnd, struct rlimit *rlim_stack) > +static unsigned long mmap_base(const unsigned long rnd, const struct rlimit *rlim_stack) > { > #ifdef CONFIG_STACK_GROWSUP > /* > @@ -462,7 +462,7 @@ static unsigned long mmap_base(unsigned long rnd, struct rlimit *rlim_stack) > #endif > } > > -void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack) > +void arch_pick_mmap_layout(struct mm_struct *mm, const struct rlimit *rlim_stack) > { > unsigned long random_factor = 0UL; > > @@ -478,7 +478,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack) > } > } > #elif defined(CONFIG_MMU) && !defined(HAVE_ARCH_PICK_MMAP_LAYOUT) > -void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack) > +void arch_pick_mmap_layout(struct mm_struct *mm, const struct rlimit *rlim_stack) > { > mm->mmap_base = TASK_UNMAPPED_BASE; > mm_flags_clear(MMF_TOPDOWN, mm); > -- > 2.47.2 >
© 2016 - 2025 Red Hat, Inc.