mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 01:53:29 +02:00
mm: constify arch_pick_mmap_layout() for improved const-correctness
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. Link: https://lkml.kernel.org/r/20250901205021.3573313-9-max.kellermann@ionos.com Signed-off-by: Max Kellermann <max.kellermann@ionos.com> Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com> Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Acked-by: David Hildenbrand <david@redhat.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Acked-by: Shakeel Butt <shakeel.butt@linux.dev> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Andreas Larsson <andreas@gaisler.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Axel Rasmussen <axelrasmussen@google.com> Cc: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Borislav Betkov <bp@alien8.de> Cc: Christian Borntraeger <borntraeger@linux.ibm.com> Cc: Christian Brauner <brauner@kernel.org> Cc: Christian Zankel <chris@zankel.net> Cc: David Rientjes <rientjes@google.com> Cc: David S. Miller <davem@davemloft.net> Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Helge Deller <deller@gmx.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Hugh Dickins <hughd@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Bottomley <james.bottomley@HansenPartnership.com> Cc: Jan Kara <jack@suse.cz> Cc: Jocelyn Falempe <jfalempe@redhat.com> Cc: Liam Howlett <liam.howlett@oracle.com> Cc: Mark Brown <broonie@kernel.org> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Max Filippov <jcmvbkbc@gmail.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Michal Hocko <mhocko@suse.com> Cc: "Nysal Jan K.A" <nysal@linux.ibm.com> Cc: Oscar Salvador <osalvador@suse.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Russel King <linux@armlinux.org.uk> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Thomas Gleinxer <tglx@linutronix.de> Cc: Thomas Huth <thuth@redhat.com> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Wei Xu <weixugc@google.com> Cc: Yuanchu Xie <yuanchu@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
e7f778767d
commit
a955cca372
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user