| 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | #ifndef _LINUX_SCHED_COREDUMP_H |
| 3 | #define _LINUX_SCHED_COREDUMP_H |
| 4 | |
| 5 | #include <linux/mm_types.h> |
| 6 | |
| 7 | #define SUID_DUMP_DISABLE 0 /* No setuid dumping */ |
| 8 | #define SUID_DUMP_USER 1 /* Dump as user of process */ |
| 9 | #define SUID_DUMP_ROOT 2 /* Dump as root */ |
| 10 | |
| 11 | static inline unsigned long __mm_flags_get_dumpable(const struct mm_struct *mm) |
| 12 | { |
| 13 | /* |
| 14 | * By convention, dumpable bits are contained in first 32 bits of the |
| 15 | * bitmap, so we can simply access this first unsigned long directly. |
| 16 | */ |
| 17 | return __mm_flags_get_word(mm); |
| 18 | } |
| 19 | |
| 20 | static inline void __mm_flags_set_mask_dumpable(struct mm_struct *mm, int value) |
| 21 | { |
| 22 | __mm_flags_set_mask_bits_word(mm, MMF_DUMPABLE_MASK, bits: value); |
| 23 | } |
| 24 | |
| 25 | extern void set_dumpable(struct mm_struct *mm, int value); |
| 26 | /* |
| 27 | * This returns the actual value of the suid_dumpable flag. For things |
| 28 | * that are using this for checking for privilege transitions, it must |
| 29 | * test against SUID_DUMP_USER rather than treating it as a boolean |
| 30 | * value. |
| 31 | */ |
| 32 | static inline int __get_dumpable(unsigned long mm_flags) |
| 33 | { |
| 34 | return mm_flags & MMF_DUMPABLE_MASK; |
| 35 | } |
| 36 | |
| 37 | static inline int get_dumpable(struct mm_struct *mm) |
| 38 | { |
| 39 | unsigned long flags = __mm_flags_get_dumpable(mm); |
| 40 | |
| 41 | return __get_dumpable(mm_flags: flags); |
| 42 | } |
| 43 | |
| 44 | #endif /* _LINUX_SCHED_COREDUMP_H */ |
| 45 | |