Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _LINUX_SCHED_COREDUMP_H
0003 #define _LINUX_SCHED_COREDUMP_H
0004 
0005 #include <linux/mm_types.h>
0006 
0007 #define SUID_DUMP_DISABLE   0   /* No setuid dumping */
0008 #define SUID_DUMP_USER      1   /* Dump as user of process */
0009 #define SUID_DUMP_ROOT      2   /* Dump as root */
0010 
0011 /* mm flags */
0012 
0013 /* for SUID_DUMP_* above */
0014 #define MMF_DUMPABLE_BITS 2
0015 #define MMF_DUMPABLE_MASK ((1 << MMF_DUMPABLE_BITS) - 1)
0016 
0017 extern void set_dumpable(struct mm_struct *mm, int value);
0018 /*
0019  * This returns the actual value of the suid_dumpable flag. For things
0020  * that are using this for checking for privilege transitions, it must
0021  * test against SUID_DUMP_USER rather than treating it as a boolean
0022  * value.
0023  */
0024 static inline int __get_dumpable(unsigned long mm_flags)
0025 {
0026     return mm_flags & MMF_DUMPABLE_MASK;
0027 }
0028 
0029 static inline int get_dumpable(struct mm_struct *mm)
0030 {
0031     return __get_dumpable(mm->flags);
0032 }
0033 
0034 /* coredump filter bits */
0035 #define MMF_DUMP_ANON_PRIVATE   2
0036 #define MMF_DUMP_ANON_SHARED    3
0037 #define MMF_DUMP_MAPPED_PRIVATE 4
0038 #define MMF_DUMP_MAPPED_SHARED  5
0039 #define MMF_DUMP_ELF_HEADERS    6
0040 #define MMF_DUMP_HUGETLB_PRIVATE 7
0041 #define MMF_DUMP_HUGETLB_SHARED  8
0042 #define MMF_DUMP_DAX_PRIVATE    9
0043 #define MMF_DUMP_DAX_SHARED 10
0044 
0045 #define MMF_DUMP_FILTER_SHIFT   MMF_DUMPABLE_BITS
0046 #define MMF_DUMP_FILTER_BITS    9
0047 #define MMF_DUMP_FILTER_MASK \
0048     (((1 << MMF_DUMP_FILTER_BITS) - 1) << MMF_DUMP_FILTER_SHIFT)
0049 #define MMF_DUMP_FILTER_DEFAULT \
0050     ((1 << MMF_DUMP_ANON_PRIVATE) | (1 << MMF_DUMP_ANON_SHARED) |\
0051      (1 << MMF_DUMP_HUGETLB_PRIVATE) | MMF_DUMP_MASK_DEFAULT_ELF)
0052 
0053 #ifdef CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS
0054 # define MMF_DUMP_MASK_DEFAULT_ELF  (1 << MMF_DUMP_ELF_HEADERS)
0055 #else
0056 # define MMF_DUMP_MASK_DEFAULT_ELF  0
0057 #endif
0058                     /* leave room for more dump flags */
0059 #define MMF_VM_MERGEABLE    16  /* KSM may merge identical pages */
0060 #define MMF_VM_HUGEPAGE     17  /* set when mm is available for
0061                        khugepaged */
0062 /*
0063  * This one-shot flag is dropped due to necessity of changing exe once again
0064  * on NFS restore
0065  */
0066 //#define MMF_EXE_FILE_CHANGED  18  /* see prctl_set_mm_exe_file() */
0067 
0068 #define MMF_HAS_UPROBES     19  /* has uprobes */
0069 #define MMF_RECALC_UPROBES  20  /* MMF_HAS_UPROBES can be wrong */
0070 #define MMF_OOM_SKIP        21  /* mm is of no interest for the OOM killer */
0071 #define MMF_UNSTABLE        22  /* mm is unstable for copy_from_user */
0072 #define MMF_HUGE_ZERO_PAGE  23      /* mm has ever used the global huge zero page */
0073 #define MMF_DISABLE_THP     24  /* disable THP for all VMAs */
0074 #define MMF_OOM_VICTIM      25  /* mm is the oom victim */
0075 #define MMF_OOM_REAP_QUEUED 26  /* mm was queued for oom_reaper */
0076 #define MMF_MULTIPROCESS    27  /* mm is shared between processes */
0077 /*
0078  * MMF_HAS_PINNED: Whether this mm has pinned any pages.  This can be either
0079  * replaced in the future by mm.pinned_vm when it becomes stable, or grow into
0080  * a counter on its own. We're aggresive on this bit for now: even if the
0081  * pinned pages were unpinned later on, we'll still keep this bit set for the
0082  * lifecycle of this mm, just for simplicity.
0083  */
0084 #define MMF_HAS_PINNED      28  /* FOLL_PIN has run, never cleared */
0085 #define MMF_DISABLE_THP_MASK    (1 << MMF_DISABLE_THP)
0086 
0087 #define MMF_INIT_MASK       (MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK |\
0088                  MMF_DISABLE_THP_MASK)
0089 
0090 #endif /* _LINUX_SCHED_COREDUMP_H */