diff options
Diffstat (limited to 'include/linux/sched.h')
-rw-r--r-- | include/linux/sched.h | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index 5c2c885ee52b..b867a4dab38a 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -1903,8 +1903,6 @@ extern void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut, | |||
1903 | #define PF_KTHREAD 0x00200000 /* I am a kernel thread */ | 1903 | #define PF_KTHREAD 0x00200000 /* I am a kernel thread */ |
1904 | #define PF_RANDOMIZE 0x00400000 /* randomize virtual address space */ | 1904 | #define PF_RANDOMIZE 0x00400000 /* randomize virtual address space */ |
1905 | #define PF_SWAPWRITE 0x00800000 /* Allowed to write to swap */ | 1905 | #define PF_SWAPWRITE 0x00800000 /* Allowed to write to swap */ |
1906 | #define PF_SPREAD_PAGE 0x01000000 /* Spread page cache over cpuset */ | ||
1907 | #define PF_SPREAD_SLAB 0x02000000 /* Spread some slab caches over cpuset */ | ||
1908 | #define PF_NO_SETAFFINITY 0x04000000 /* Userland is not allowed to meddle with cpus_allowed */ | 1906 | #define PF_NO_SETAFFINITY 0x04000000 /* Userland is not allowed to meddle with cpus_allowed */ |
1909 | #define PF_MCE_EARLY 0x08000000 /* Early kill for mce process policy */ | 1907 | #define PF_MCE_EARLY 0x08000000 /* Early kill for mce process policy */ |
1910 | #define PF_MUTEX_TESTER 0x20000000 /* Thread belongs to the rt mutex tester */ | 1908 | #define PF_MUTEX_TESTER 0x20000000 /* Thread belongs to the rt mutex tester */ |
@@ -1957,17 +1955,31 @@ static inline void memalloc_noio_restore(unsigned int flags) | |||
1957 | } | 1955 | } |
1958 | 1956 | ||
1959 | /* Per-process atomic flags. */ | 1957 | /* Per-process atomic flags. */ |
1960 | #define PFA_NO_NEW_PRIVS 0x00000001 /* May not gain new privileges. */ | 1958 | #define PFA_NO_NEW_PRIVS 0 /* May not gain new privileges. */ |
1959 | #define PFA_SPREAD_PAGE 1 /* Spread page cache over cpuset */ | ||
1960 | #define PFA_SPREAD_SLAB 2 /* Spread some slab caches over cpuset */ | ||
1961 | 1961 | ||
1962 | static inline bool task_no_new_privs(struct task_struct *p) | ||
1963 | { | ||
1964 | return test_bit(PFA_NO_NEW_PRIVS, &p->atomic_flags); | ||
1965 | } | ||
1966 | 1962 | ||
1967 | static inline void task_set_no_new_privs(struct task_struct *p) | 1963 | #define TASK_PFA_TEST(name, func) \ |
1968 | { | 1964 | static inline bool task_##func(struct task_struct *p) \ |
1969 | set_bit(PFA_NO_NEW_PRIVS, &p->atomic_flags); | 1965 | { return test_bit(PFA_##name, &p->atomic_flags); } |
1970 | } | 1966 | #define TASK_PFA_SET(name, func) \ |
1967 | static inline void task_set_##func(struct task_struct *p) \ | ||
1968 | { set_bit(PFA_##name, &p->atomic_flags); } | ||
1969 | #define TASK_PFA_CLEAR(name, func) \ | ||
1970 | static inline void task_clear_##func(struct task_struct *p) \ | ||
1971 | { clear_bit(PFA_##name, &p->atomic_flags); } | ||
1972 | |||
1973 | TASK_PFA_TEST(NO_NEW_PRIVS, no_new_privs) | ||
1974 | TASK_PFA_SET(NO_NEW_PRIVS, no_new_privs) | ||
1975 | |||
1976 | TASK_PFA_TEST(SPREAD_PAGE, spread_page) | ||
1977 | TASK_PFA_SET(SPREAD_PAGE, spread_page) | ||
1978 | TASK_PFA_CLEAR(SPREAD_PAGE, spread_page) | ||
1979 | |||
1980 | TASK_PFA_TEST(SPREAD_SLAB, spread_slab) | ||
1981 | TASK_PFA_SET(SPREAD_SLAB, spread_slab) | ||
1982 | TASK_PFA_CLEAR(SPREAD_SLAB, spread_slab) | ||
1971 | 1983 | ||
1972 | /* | 1984 | /* |
1973 | * task->jobctl flags | 1985 | * task->jobctl flags |
@@ -2608,9 +2620,22 @@ static inline void setup_thread_stack(struct task_struct *p, struct task_struct | |||
2608 | task_thread_info(p)->task = p; | 2620 | task_thread_info(p)->task = p; |
2609 | } | 2621 | } |
2610 | 2622 | ||
2623 | /* | ||
2624 | * Return the address of the last usable long on the stack. | ||
2625 | * | ||
2626 | * When the stack grows down, this is just above the thread | ||
2627 | * info struct. Going any lower will corrupt the threadinfo. | ||
2628 | * | ||
2629 | * When the stack grows up, this is the highest address. | ||
2630 | * Beyond that position, we corrupt data on the next page. | ||
2631 | */ | ||
2611 | static inline unsigned long *end_of_stack(struct task_struct *p) | 2632 | static inline unsigned long *end_of_stack(struct task_struct *p) |
2612 | { | 2633 | { |
2634 | #ifdef CONFIG_STACK_GROWSUP | ||
2635 | return (unsigned long *)((unsigned long)task_thread_info(p) + THREAD_SIZE) - 1; | ||
2636 | #else | ||
2613 | return (unsigned long *)(task_thread_info(p) + 1); | 2637 | return (unsigned long *)(task_thread_info(p) + 1); |
2638 | #endif | ||
2614 | } | 2639 | } |
2615 | 2640 | ||
2616 | #endif | 2641 | #endif |