mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-31 22:34:33 +01:00
The coredump logic is slightly different from other users in that it both stores mm flags and additionally sets and gets using masks. Since the MMF_DUMPABLE_* flags must remain as they are for uABI reasons, and of course these are within the first 32-bits of the flags, it is reasonable to provide access to these in the same fashion so this logic can all still keep working as it has been. Therefore, introduce coredump-specific helpers __mm_flags_get_dumpable() and __mm_flags_set_mask_dumpable() for this purpose, and update all core dump users of mm flags to use these. [[email protected]: abstract set_mask_bits() invocation to mm_types.h to satisfy ARC] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/2a5075f7e3c5b367d988178c79a3063d12ee53a9.1755012943.git.lorenzo.stoakes@oracle.com Signed-off-by: Lorenzo Stoakes <[email protected]> Reviewed-by: Liam R. Howlett <[email protected]> Reviewed-by: Mike Rapoport (Microsoft) <[email protected]> Reviewed-by: Christian Brauner <[email protected]> Acked-by: David Hildenbrand <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Gordeev <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Al Viro <[email protected]> Cc: Andreas Larsson <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Baolin Wang <[email protected]> Cc: Barry Song <[email protected]> Cc: Ben Segall <[email protected]> Cc: Borislav Betkov <[email protected]> Cc: Chengming Zhou <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: David Rientjes <[email protected]> Cc: David S. Miller <[email protected]> Cc: Dev Jain <[email protected]> Cc: Dietmar Eggemann <[email protected]> Cc: Gerald Schaefer <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jan Kara <[email protected]> Cc: Jann Horn <[email protected]> Cc: Jason Gunthorpe <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: John Hubbard <[email protected]> Cc: Juri Lelli <[email protected]> Cc: Kan Liang <[email protected]> Cc: Kees Cook <[email protected]> Cc: Marc Rutland <[email protected]> Cc: Mariano Pache <[email protected]> Cc: "Masami Hiramatsu (Google)" <[email protected]> Cc: Mateusz Guzik <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Mel Gorman <mgorman <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Namhyung kim <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Peter Xu <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ryan Roberts <[email protected]> Cc: Shakeel Butt <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Cc: Sven Schnelle <[email protected]> Cc: Thomas Gleinxer <[email protected]> Cc: Valentin Schneider <[email protected]> Cc: Vasily Gorbik <[email protected]> Cc: Vincent Guittot <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: xu xin <[email protected]> Cc: Zi Yan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
45 lines
1.2 KiB
C
45 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _LINUX_SCHED_COREDUMP_H
|
|
#define _LINUX_SCHED_COREDUMP_H
|
|
|
|
#include <linux/mm_types.h>
|
|
|
|
#define SUID_DUMP_DISABLE 0 /* No setuid dumping */
|
|
#define SUID_DUMP_USER 1 /* Dump as user of process */
|
|
#define SUID_DUMP_ROOT 2 /* Dump as root */
|
|
|
|
static inline unsigned long __mm_flags_get_dumpable(struct mm_struct *mm)
|
|
{
|
|
/*
|
|
* By convention, dumpable bits are contained in first 32 bits of the
|
|
* bitmap, so we can simply access this first unsigned long directly.
|
|
*/
|
|
return __mm_flags_get_word(mm);
|
|
}
|
|
|
|
static inline void __mm_flags_set_mask_dumpable(struct mm_struct *mm, int value)
|
|
{
|
|
__mm_flags_set_mask_bits_word(mm, MMF_DUMPABLE_MASK, value);
|
|
}
|
|
|
|
extern void set_dumpable(struct mm_struct *mm, int value);
|
|
/*
|
|
* This returns the actual value of the suid_dumpable flag. For things
|
|
* that are using this for checking for privilege transitions, it must
|
|
* test against SUID_DUMP_USER rather than treating it as a boolean
|
|
* value.
|
|
*/
|
|
static inline int __get_dumpable(unsigned long mm_flags)
|
|
{
|
|
return mm_flags & MMF_DUMPABLE_MASK;
|
|
}
|
|
|
|
static inline int get_dumpable(struct mm_struct *mm)
|
|
{
|
|
unsigned long flags = __mm_flags_get_dumpable(mm);
|
|
|
|
return __get_dumpable(flags);
|
|
}
|
|
|
|
#endif /* _LINUX_SCHED_COREDUMP_H */
|