History

Merge tag 'gcc-plugins-v4.13-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux

Pull structure randomization updates from Kees Cook: "Now that IPC and other changes have landed, enable manual markings for randstruct plugin, including the task_struct. This is the rest of what was staged in -next for the gcc-plugins, and comes in three patches, largest first: - mark "easy" structs with __randomize_layout - mark task_struct with an optional anonymous struct to isolate the __randomize_layout section - mark structs to opt _out_ of automated marking (which will come later) And, FWIW, this continues to pass allmodconfig (normal and patched to enable gcc-plugins) builds of x86_64, i386, arm64, arm, powerpc, and s390 for me" * tag 'gcc-plugins-v4.13-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: randstruct: opt-out externally exposed function pointer structs task_struct: Allow randomized layout randstruct: Mark various structs for randomization

Linus Torvalds committed 9 years ago

Commit e06fdaf2 parents a90c6ac 8acdf5042 files · +97 −66Browse files

Unified · Split

42 files
  1. arch/arm/include/asm/cacheflush.h +1 −1
  2. arch/x86/include/asm/paravirt_types.h +8 −8
  3. arch/x86/include/asm/processor.h +1 −1
  4. fs/mount.h +2 −2
  5. fs/namei.c +1 −1
  6. fs/proc/internal.h +3 −3
  7. include/linux/binfmts.h +2 −2
  8. include/linux/cdev.h +1 −1
  9. include/linux/compiler-gcc.h +12 −1
  10. include/linux/compiler.h +5 −0
  11. include/linux/cred.h +2 −2
  12. include/linux/dcache.h +1 −1
  13. include/linux/fs.h +9 −8
  14. include/linux/fs_struct.h +1 −1
  15. include/linux/ipc.h +1 −1
  16. include/linux/ipc_namespace.h +1 −1
  17. include/linux/key-type.h +2 −2
  18. include/linux/kmod.h +1 −1
  19. include/linux/kobject.h +1 −1
  20. include/linux/lsm_hooks.h +2 −2
  21. include/linux/mm_types.h +2 −2
  22. include/linux/module.h +2 −2
  23. include/linux/mount.h +1 −1
  24. include/linux/msg.h +1 −1
  25. include/linux/path.h +1 −1
  26. include/linux/pid_namespace.h +1 −1
  27. include/linux/proc_ns.h +1 −1
  28. include/linux/sched.h +15 −1
  29. include/linux/sched/signal.h +1 −1
  30. include/linux/sem.h +1 −1
  31. include/linux/shm.h +1 −1
  32. include/linux/sysctl.h +1 −1
  33. include/linux/tty.h +1 −1
  34. include/linux/tty_driver.h +2 −2
  35. include/linux/user_namespace.h +1 −1
  36. include/linux/utsname.h +1 −1
  37. include/net/af_unix.h +1 −1
  38. include/net/neighbour.h +1 −1
  39. include/net/net_namespace.h +1 −1
  40. include/net/sock.h +1 −1
  41. kernel/futex.c +2 −2
  42. security/keys/internal.h +1 −1
arch/arm/include/asm/cacheflush.h+1−1
@@ -116,7 +116,7 @@ struct cpu_cache_fns { · 115 unmodified lines
116 void (*dma_unmap_area)(const void *, size_t, int);116 void (*dma_unmap_area)(const void *, size_t, int);
117 117
118 void (*dma_flush_range)(const void *, const void *);118 void (*dma_flush_range)(const void *, const void *);
119};119} __no_randomize_layout;
120 120
121/*121/*
122 * Select the calling method122 * Select the calling method
arch/x86/include/asm/paravirt_types.h+8−8
@@ -84,7 +84,7 @@ struct pv_init_ops { · 83 unmodified lines
84 */84 */
85 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,85 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
86 unsigned long addr, unsigned len);86 unsigned long addr, unsigned len);
87};87} __no_randomize_layout;
88 88
89 89
90struct pv_lazy_ops {90struct pv_lazy_ops {
@@ -92,12 +92,12 @@ struct pv_lazy_ops { · 1 unmodified line
92 void (*enter)(void);92 void (*enter)(void);
93 void (*leave)(void);93 void (*leave)(void);
94 void (*flush)(void);94 void (*flush)(void);
95};95} __no_randomize_layout;
96 96
97struct pv_time_ops {97struct pv_time_ops {
98 unsigned long long (*sched_clock)(void);98 unsigned long long (*sched_clock)(void);
99 unsigned long long (*steal_clock)(int cpu);99 unsigned long long (*steal_clock)(int cpu);
100};100} __no_randomize_layout;
101 101
102struct pv_cpu_ops {102struct pv_cpu_ops {
103 /* hooks for various privileged instructions */103 /* hooks for various privileged instructions */
@@ -176,7 +176,7 @@ struct pv_cpu_ops { · 72 unmodified lines
176 176
177 void (*start_context_switch)(struct task_struct *prev);177 void (*start_context_switch)(struct task_struct *prev);
178 void (*end_context_switch)(struct task_struct *next);178 void (*end_context_switch)(struct task_struct *next);
179};179} __no_randomize_layout;
180 180
181struct pv_irq_ops {181struct pv_irq_ops {
182 /*182 /*
@@ -199,7 +199,7 @@ struct pv_irq_ops { · 16 unmodified lines
199#ifdef CONFIG_X86_64199#ifdef CONFIG_X86_64
200 void (*adjust_exception_frame)(void);200 void (*adjust_exception_frame)(void);
201#endif201#endif
202};202} __no_randomize_layout;
203 203
204struct pv_mmu_ops {204struct pv_mmu_ops {
205 unsigned long (*read_cr2)(void);205 unsigned long (*read_cr2)(void);
@@ -305,7 +305,7 @@ struct pv_mmu_ops { · 99 unmodified lines
305 an mfn. We can tell which is which from the index. */305 an mfn. We can tell which is which from the index. */
306 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,306 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
307 phys_addr_t phys, pgprot_t flags);307 phys_addr_t phys, pgprot_t flags);
308};308} __no_randomize_layout;
309 309
310struct arch_spinlock;310struct arch_spinlock;
311#ifdef CONFIG_SMP311#ifdef CONFIG_SMP
@@ -322,7 +322,7 @@ struct pv_lock_ops { · 10 unmodified lines
322 void (*kick)(int cpu);322 void (*kick)(int cpu);
323 323
324 struct paravirt_callee_save vcpu_is_preempted;324 struct paravirt_callee_save vcpu_is_preempted;
325};325} __no_randomize_layout;
326 326
327/* This contains all the paravirt structures: we get a convenient327/* This contains all the paravirt structures: we get a convenient
328 * number for each function using the offset which we use to indicate328 * number for each function using the offset which we use to indicate
@@ -334,7 +334,7 @@ struct paravirt_patch_template { · 5 unmodified lines
334 struct pv_irq_ops pv_irq_ops;334 struct pv_irq_ops pv_irq_ops;
335 struct pv_mmu_ops pv_mmu_ops;335 struct pv_mmu_ops pv_mmu_ops;
336 struct pv_lock_ops pv_lock_ops;336 struct pv_lock_ops pv_lock_ops;
337};337} __no_randomize_layout;
338 338
339extern struct pv_info pv_info;339extern struct pv_info pv_info;
340extern struct pv_init_ops pv_init_ops;340extern struct pv_init_ops pv_init_ops;
arch/x86/include/asm/processor.h+1−1
@@ -129,7 +129,7 @@ struct cpuinfo_x86 { · 128 unmodified lines
129 /* Index into per_cpu list: */129 /* Index into per_cpu list: */
130 u16 cpu_index;130 u16 cpu_index;
131 u32 microcode;131 u32 microcode;
132};132} __randomize_layout;
133 133
134struct cpuid_regs {134struct cpuid_regs {
135 u32 eax, ebx, ecx, edx;135 u32 eax, ebx, ecx, edx;
fs/mount.h+2−2
@@ -16,7 +16,7 @@ struct mnt_namespace { · 15 unmodified lines
16 u64 event;16 u64 event;
17 unsigned int mounts; /* # of mounts in the namespace */17 unsigned int mounts; /* # of mounts in the namespace */
18 unsigned int pending_mounts;18 unsigned int pending_mounts;
19};19} __randomize_layout;
20 20
21struct mnt_pcp {21struct mnt_pcp {
22 int mnt_count;22 int mnt_count;
@@ -69,7 +69,7 @@ struct mount { · 46 unmodified lines
69 struct hlist_head mnt_pins;69 struct hlist_head mnt_pins;
70 struct fs_pin mnt_umount;70 struct fs_pin mnt_umount;
71 struct dentry *mnt_ex_mountpoint;71 struct dentry *mnt_ex_mountpoint;
72};72} __randomize_layout;
73 73
74#define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */74#define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */
75 75
fs/namei.c+1−1
@@ -524,7 +524,7 @@ struct nameidata { · 523 unmodified lines
524 struct inode *link_inode;524 struct inode *link_inode;
525 unsigned root_seq;525 unsigned root_seq;
526 int dfd;526 int dfd;
527};527} __randomize_layout;
528 528
529static void set_nameidata(struct nameidata *p, int dfd, struct filename *name)529static void set_nameidata(struct nameidata *p, int dfd, struct filename *name)
530{530{
fs/proc/internal.h+3−3
@@ -51,7 +51,7 @@ struct proc_dir_entry { · 50 unmodified lines
51 spinlock_t pde_unload_lock; /* proc_fops checks and pde_users bumps */51 spinlock_t pde_unload_lock; /* proc_fops checks and pde_users bumps */
52 u8 namelen;52 u8 namelen;
53 char name[];53 char name[];
54};54} __randomize_layout;
55 55
56union proc_op {56union proc_op {
57 int (*proc_get_link)(struct dentry *, struct path *);57 int (*proc_get_link)(struct dentry *, struct path *);
@@ -70,7 +70,7 @@ struct proc_inode { · 12 unmodified lines
70 struct hlist_node sysctl_inodes;70 struct hlist_node sysctl_inodes;
71 const struct proc_ns_operations *ns_ops;71 const struct proc_ns_operations *ns_ops;
72 struct inode vfs_inode;72 struct inode vfs_inode;
73};73} __randomize_layout;
74 74
75/*75/*
76 * General functions76 * General functions
@@ -279,7 +279,7 @@ struct proc_maps_private { · 202 unmodified lines
279#ifdef CONFIG_NUMA279#ifdef CONFIG_NUMA
280 struct mempolicy *task_mempolicy;280 struct mempolicy *task_mempolicy;
281#endif281#endif
282};282} __randomize_layout;
283 283
284struct mm_struct *proc_mem_open(struct inode *inode, unsigned int mode);284struct mm_struct *proc_mem_open(struct inode *inode, unsigned int mode);
285 285
include/linux/binfmts.h+2−2
@@ -46,7 +46,7 @@ struct linux_binprm { · 45 unmodified lines
46 unsigned interp_flags;46 unsigned interp_flags;
47 unsigned interp_data;47 unsigned interp_data;
48 unsigned long loader, exec;48 unsigned long loader, exec;
49};49} __randomize_layout;
50 50
51#define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 051#define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0
52#define BINPRM_FLAGS_ENFORCE_NONDUMP (1 << BINPRM_FLAGS_ENFORCE_NONDUMP_BIT)52#define BINPRM_FLAGS_ENFORCE_NONDUMP (1 << BINPRM_FLAGS_ENFORCE_NONDUMP_BIT)
@@ -81,7 +81,7 @@ struct linux_binfmt { · 28 unmodified lines
81 int (*load_shlib)(struct file *);81 int (*load_shlib)(struct file *);
82 int (*core_dump)(struct coredump_params *cprm);82 int (*core_dump)(struct coredump_params *cprm);
83 unsigned long min_coredump; /* minimal dump size */83 unsigned long min_coredump; /* minimal dump size */
84};84} __randomize_layout;
85 85
86extern void __register_binfmt(struct linux_binfmt *fmt, int insert);86extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
87 87
include/linux/cdev.h+1−1
@@ -17,7 +17,7 @@ struct cdev { · 16 unmodified lines
17 struct list_head list;17 struct list_head list;
18 dev_t dev;18 dev_t dev;
19 unsigned int count;19 unsigned int count;
20};20} __randomize_layout;
21 21
22void cdev_init(struct cdev *, const struct file_operations *);22void cdev_init(struct cdev *, const struct file_operations *);
23 23
include/linux/compiler-gcc.h+12−1
@@ -235,6 +235,7 @@ · 234 unmodified lines
235#endif /* GCC_VERSION >= 40500 */235#endif /* GCC_VERSION >= 40500 */
236 236
237#if GCC_VERSION >= 40600237#if GCC_VERSION >= 40600
238
238/*239/*
239 * When used with Link Time Optimization, gcc can optimize away C functions or240 * When used with Link Time Optimization, gcc can optimize away C functions or
240 * variables which are referenced only from assembly code. __visible tells the241 * variables which are referenced only from assembly code. __visible tells the
@@ -242,7 +243,17 @@ · 1 unmodified line
242 * this.243 * this.
243 */244 */
244#define __visible __attribute__((externally_visible))245#define __visible __attribute__((externally_visible))
245#endif246
247/*
248 * RANDSTRUCT_PLUGIN wants to use an anonymous struct, but it is only
249 * possible since GCC 4.6. To provide as much build testing coverage
250 * as possible, this is used for all GCC 4.6+ builds, and not just on
251 * RANDSTRUCT_PLUGIN builds.
252 */
253#define randomized_struct_fields_start struct {
254#define randomized_struct_fields_end } __randomize_layout;
255
256#endif /* GCC_VERSION >= 40600 */
246 257
247 258
248#if GCC_VERSION >= 40900 && !defined(__CHECKER__)259#if GCC_VERSION >= 40900 && !defined(__CHECKER__)
include/linux/compiler.h+5−0
@@ -452,6 +452,11 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s · 451 unmodified lines
452# define __no_randomize_layout452# define __no_randomize_layout
453#endif453#endif
454 454
455#ifndef randomized_struct_fields_start
456# define randomized_struct_fields_start
457# define randomized_struct_fields_end
458#endif
459
455/*460/*
456 * Tell gcc if a function is cold. The compiler will assume any path461 * Tell gcc if a function is cold. The compiler will assume any path
457 * directly leading to the call is unlikely.462 * directly leading to the call is unlikely.
include/linux/cred.h+2−2
@@ -31,7 +31,7 @@ struct group_info { · 30 unmodified lines
31 atomic_t usage;31 atomic_t usage;
32 int ngroups;32 int ngroups;
33 kgid_t gid[0];33 kgid_t gid[0];
34};34} __randomize_layout;
35 35
36/**36/**
37 * get_group_info - Get a reference to a group info structure37 * get_group_info - Get a reference to a group info structure
@@ -145,7 +145,7 @@ struct cred { · 107 unmodified lines
145 struct user_namespace *user_ns; /* user_ns the caps and keyrings are relative to. */145 struct user_namespace *user_ns; /* user_ns the caps and keyrings are relative to. */
146 struct group_info *group_info; /* supplementary groups for euid/fsgid */146 struct group_info *group_info; /* supplementary groups for euid/fsgid */
147 struct rcu_head rcu; /* RCU deletion hook */147 struct rcu_head rcu; /* RCU deletion hook */
148};148} __randomize_layout;
149 149
150extern void __put_cred(struct cred *);150extern void __put_cred(struct cred *);
151extern void exit_creds(struct task_struct *);151extern void exit_creds(struct task_struct *);
include/linux/dcache.h+1−1
@@ -118,7 +118,7 @@ struct dentry { · 117 unmodified lines
118 struct hlist_bl_node d_in_lookup_hash; /* only for in-lookup ones */118 struct hlist_bl_node d_in_lookup_hash; /* only for in-lookup ones */
119 struct rcu_head d_rcu;119 struct rcu_head d_rcu;
120 } d_u;120 } d_u;
121};121} __randomize_layout;
122 122
123/*123/*
124 * dentry->d_lock spinlock nesting subclasses:124 * dentry->d_lock spinlock nesting subclasses:
include/linux/fs.h+9−8
@@ -296,7 +296,7 @@ struct kiocb { · 295 unmodified lines
296 void *private;296 void *private;
297 int ki_flags;297 int ki_flags;
298 enum rw_hint ki_hint;298 enum rw_hint ki_hint;
299};299} __randomize_layout;
300 300
301static inline bool is_sync_kiocb(struct kiocb *kiocb)301static inline bool is_sync_kiocb(struct kiocb *kiocb)
302{302{
@@ -404,7 +404,7 @@ struct address_space { · 101 unmodified lines
404 struct list_head private_list; /* ditto */404 struct list_head private_list; /* ditto */
405 void *private_data; /* ditto */405 void *private_data; /* ditto */
406 errseq_t wb_err;406 errseq_t wb_err;
407} __attribute__((aligned(sizeof(long))));407} __attribute__((aligned(sizeof(long)))) __randomize_layout;
408 /*408 /*
409 * On most architectures that alignment is already the case; but409 * On most architectures that alignment is already the case; but
410 * must be enforced here for CRIS, to let the least significant bit410 * must be enforced here for CRIS, to let the least significant bit
@@ -447,7 +447,7 @@ struct block_device { · 36 unmodified lines
447 int bd_fsfreeze_count;447 int bd_fsfreeze_count;
448 /* Mutex for freeze */448 /* Mutex for freeze */
449 struct mutex bd_fsfreeze_mutex;449 struct mutex bd_fsfreeze_mutex;
450};450} __randomize_layout;
451 451
452/*452/*
453 * Radix-tree tags, for tagging dirty and writeback pages within the pagecache453 * Radix-tree tags, for tagging dirty and writeback pages within the pagecache
@@ -666,7 +666,7 @@ struct inode { · 212 unmodified lines
666#endif666#endif
667 667
668 void *i_private; /* fs or device private pointer */668 void *i_private; /* fs or device private pointer */
669};669} __randomize_layout;
670 670
671static inline unsigned int i_blocksize(const struct inode *node)671static inline unsigned int i_blocksize(const struct inode *node)
672{672{
@@ -883,7 +883,8 @@ struct file { · 210 unmodified lines
883#endif /* #ifdef CONFIG_EPOLL */883#endif /* #ifdef CONFIG_EPOLL */
884 struct address_space *f_mapping;884 struct address_space *f_mapping;
885 errseq_t f_wb_err;885 errseq_t f_wb_err;
886} __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */886} __randomize_layout
887 __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */
887 888
888struct file_handle {889struct file_handle {
889 __u32 handle_bytes;890 __u32 handle_bytes;
@@ -1020,7 +1021,7 @@ struct file_lock { · 130 unmodified lines
1020 int state; /* state of grant or error if -ve */1021 int state; /* state of grant or error if -ve */
1021 } afs;1022 } afs;
1022 } fl_u;1023 } fl_u;
1023};1024} __randomize_layout;
1024 1025
1025struct file_lock_context {1026struct file_lock_context {
1026 spinlock_t flc_lock;1027 spinlock_t flc_lock;
@@ -1412,7 +1413,7 @@ struct super_block { · 385 unmodified lines
1412 1413
1413 spinlock_t s_inode_wblist_lock;1414 spinlock_t s_inode_wblist_lock;
1414 struct list_head s_inodes_wb; /* writeback inodes */1415 struct list_head s_inodes_wb; /* writeback inodes */
1415};1416} __randomize_layout;
1416 1417
1417/* Helper functions so that in most cases filesystems will1418/* Helper functions so that in most cases filesystems will
1418 * not need to deal directly with kuid_t and kgid_t and can1419 * not need to deal directly with kuid_t and kgid_t and can
@@ -1698,7 +1699,7 @@ struct file_operations { · 279 unmodified lines
1698 u64);1699 u64);
1699 ssize_t (*dedupe_file_range)(struct file *, u64, u64, struct file *,1700 ssize_t (*dedupe_file_range)(struct file *, u64, u64, struct file *,
1700 u64);1701 u64);
1701};1702} __randomize_layout;
1702 1703
1703struct inode_operations {1704struct inode_operations {
1704 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);1705 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
include/linux/fs_struct.h+1−1
@@ -12,7 +12,7 @@ struct fs_struct { · 11 unmodified lines
12 int umask;12 int umask;
13 int in_exec;13 int in_exec;
14 struct path root, pwd;14 struct path root, pwd;
15};15} __randomize_layout;
16 16
17extern struct kmem_cache *fs_cachep;17extern struct kmem_cache *fs_cachep;
18 18
include/linux/ipc.h+1−1
@@ -23,6 +23,6 @@ struct kern_ipc_perm { · 22 unmodified lines
23 23
24 struct rcu_head rcu;24 struct rcu_head rcu;
25 atomic_t refcount;25 atomic_t refcount;
26} ____cacheline_aligned_in_smp;26} ____cacheline_aligned_in_smp __randomize_layout;
27 27
28#endif /* _LINUX_IPC_H */28#endif /* _LINUX_IPC_H */
include/linux/ipc_namespace.h+1−1
@@ -61,7 +61,7 @@ struct ipc_namespace { · 60 unmodified lines
61 struct ucounts *ucounts;61 struct ucounts *ucounts;
62 62
63 struct ns_common ns;63 struct ns_common ns;
64};64} __randomize_layout;
65 65
66extern struct ipc_namespace init_ipc_ns;66extern struct ipc_namespace init_ipc_ns;
67extern spinlock_t mq_lock;67extern spinlock_t mq_lock;
include/linux/key-type.h+2−2
@@ -45,7 +45,7 @@ struct key_preparsed_payload { · 44 unmodified lines
45 size_t datalen; /* Raw datalen */45 size_t datalen; /* Raw datalen */
46 size_t quotalen; /* Quota length for proposed payload */46 size_t quotalen; /* Quota length for proposed payload */
47 time_t expiry; /* Expiry time of key */47 time_t expiry; /* Expiry time of key */
48};48} __randomize_layout;
49 49
50typedef int (*request_key_actor_t)(struct key_construction *key,50typedef int (*request_key_actor_t)(struct key_construction *key,
51 const char *op, void *aux);51 const char *op, void *aux);
@@ -158,7 +158,7 @@ struct key_type { · 106 unmodified lines
158 /* internal fields */158 /* internal fields */
159 struct list_head link; /* link in types list */159 struct list_head link; /* link in types list */
160 struct lock_class_key lock_class; /* key->sem lock class */160 struct lock_class_key lock_class; /* key->sem lock class */
161};161} __randomize_layout;
162 162
163extern struct key_type key_type_keyring;163extern struct key_type key_type_keyring;
164 164
include/linux/kmod.h+1−1
@@ -64,7 +64,7 @@ struct subprocess_info { · 63 unmodified lines
64 int (*init)(struct subprocess_info *info, struct cred *new);64 int (*init)(struct subprocess_info *info, struct cred *new);
65 void (*cleanup)(struct subprocess_info *info);65 void (*cleanup)(struct subprocess_info *info);
66 void *data;66 void *data;
67};67} __randomize_layout;
68 68
69extern int69extern int
70call_usermodehelper(const char *path, char **argv, char **envp, int wait);70call_usermodehelper(const char *path, char **argv, char **envp, int wait);
include/linux/kobject.h+1−1
@@ -172,7 +172,7 @@ struct kset { · 171 unmodified lines
172 spinlock_t list_lock;172 spinlock_t list_lock;
173 struct kobject kobj;173 struct kobject kobj;
174 const struct kset_uevent_ops *uevent_ops;174 const struct kset_uevent_ops *uevent_ops;
175};175} __randomize_layout;
176 176
177extern void kset_init(struct kset *kset);177extern void kset_init(struct kset *kset);
178extern int __must_check kset_register(struct kset *kset);178extern int __must_check kset_register(struct kset *kset);
include/linux/lsm_hooks.h+2−2
@@ -1912,7 +1912,7 @@ struct security_hook_heads { · 1911 unmodified lines
1912 struct list_head audit_rule_match;1912 struct list_head audit_rule_match;
1913 struct list_head audit_rule_free;1913 struct list_head audit_rule_free;
1914#endif /* CONFIG_AUDIT */1914#endif /* CONFIG_AUDIT */
1915};1915} __randomize_layout;
1916 1916
1917/*1917/*
1918 * Security module hook list structure.1918 * Security module hook list structure.
@@ -1923,7 +1923,7 @@ struct security_hook_list { · 4 unmodified lines
1923 struct list_head *head;1923 struct list_head *head;
1924 union security_list_options hook;1924 union security_list_options hook;
1925 char *lsm;1925 char *lsm;
1926};1926} __randomize_layout;
1927 1927
1928/*1928/*
1929 * Initializing a security_hook_list structure takes1929 * Initializing a security_hook_list structure takes
include/linux/mm_types.h+2−2
@@ -342,7 +342,7 @@ struct vm_area_struct { · 341 unmodified lines
342 struct mempolicy *vm_policy; /* NUMA policy for the VMA */342 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
343#endif343#endif
344 struct vm_userfaultfd_ctx vm_userfaultfd_ctx;344 struct vm_userfaultfd_ctx vm_userfaultfd_ctx;
345};345} __randomize_layout;
346 346
347struct core_thread {347struct core_thread {
348 struct task_struct *task;348 struct task_struct *task;
@@ -500,7 +500,7 @@ struct mm_struct { · 151 unmodified lines
500 atomic_long_t hugetlb_usage;500 atomic_long_t hugetlb_usage;
501#endif501#endif
502 struct work_struct async_put_work;502 struct work_struct async_put_work;
503};503} __randomize_layout;
504 504
505extern struct mm_struct init_mm;505extern struct mm_struct init_mm;
506 506
include/linux/module.h+2−2
@@ -45,7 +45,7 @@ struct module_kobject { · 44 unmodified lines
45 struct kobject *drivers_dir;45 struct kobject *drivers_dir;
46 struct module_param_attrs *mp;46 struct module_param_attrs *mp;
47 struct completion *kobj_completion;47 struct completion *kobj_completion;
48};48} __randomize_layout;
49 49
50struct module_attribute {50struct module_attribute {
51 struct attribute attr;51 struct attribute attr;
@@ -475,7 +475,7 @@ struct module { · 423 unmodified lines
475 ctor_fn_t *ctors;475 ctor_fn_t *ctors;
476 unsigned int num_ctors;476 unsigned int num_ctors;
477#endif477#endif
478} ____cacheline_aligned;478} ____cacheline_aligned __randomize_layout;
479#ifndef MODULE_ARCH_INIT479#ifndef MODULE_ARCH_INIT
480#define MODULE_ARCH_INIT {}480#define MODULE_ARCH_INIT {}
481#endif481#endif
include/linux/mount.h+1−1
@@ -67,7 +67,7 @@ struct vfsmount { · 66 unmodified lines
67 struct dentry *mnt_root; /* root of the mounted tree */67 struct dentry *mnt_root; /* root of the mounted tree */
68 struct super_block *mnt_sb; /* pointer to superblock */68 struct super_block *mnt_sb; /* pointer to superblock */
69 int mnt_flags;69 int mnt_flags;
70};70} __randomize_layout;
71 71
72struct file; /* forward dec */72struct file; /* forward dec */
73struct path;73struct path;
include/linux/msg.h+1−1
@@ -29,7 +29,7 @@ struct msg_queue { · 28 unmodified lines
29 struct list_head q_messages;29 struct list_head q_messages;
30 struct list_head q_receivers;30 struct list_head q_receivers;
31 struct list_head q_senders;31 struct list_head q_senders;
32};32} __randomize_layout;
33 33
34/* Helper routines for sys_msgsnd and sys_msgrcv */34/* Helper routines for sys_msgsnd and sys_msgrcv */
35extern long do_msgsnd(int msqid, long mtype, void __user *mtext,35extern long do_msgsnd(int msqid, long mtype, void __user *mtext,
include/linux/path.h+1−1
@@ -7,7 +7,7 @@ struct vfsmount; · 6 unmodified lines
7struct path {7struct path {
8 struct vfsmount *mnt;8 struct vfsmount *mnt;
9 struct dentry *dentry;9 struct dentry *dentry;
10};10} __randomize_layout;
11 11
12extern void path_get(const struct path *);12extern void path_get(const struct path *);
13extern void path_put(const struct path *);13extern void path_put(const struct path *);
include/linux/pid_namespace.h+1−1
@@ -52,7 +52,7 @@ struct pid_namespace { · 51 unmodified lines
52 int hide_pid;52 int hide_pid;
53 int reboot; /* group exit code if this pidns was rebooted */53 int reboot; /* group exit code if this pidns was rebooted */
54 struct ns_common ns;54 struct ns_common ns;
55};55} __randomize_layout;
56 56
57extern struct pid_namespace init_pid_ns;57extern struct pid_namespace init_pid_ns;
58 58
include/linux/proc_ns.h+1−1
@@ -21,7 +21,7 @@ struct proc_ns_operations { · 20 unmodified lines
21 int (*install)(struct nsproxy *nsproxy, struct ns_common *ns);21 int (*install)(struct nsproxy *nsproxy, struct ns_common *ns);
22 struct user_namespace *(*owner)(struct ns_common *ns);22 struct user_namespace *(*owner)(struct ns_common *ns);
23 struct ns_common *(*get_parent)(struct ns_common *ns);23 struct ns_common *(*get_parent)(struct ns_common *ns);
24};24} __randomize_layout;
25 25
26extern const struct proc_ns_operations netns_operations;26extern const struct proc_ns_operations netns_operations;
27extern const struct proc_ns_operations utsns_operations;27extern const struct proc_ns_operations utsns_operations;
include/linux/sched.h+15−1
@@ -426,7 +426,7 @@ struct sched_rt_entity { · 425 unmodified lines
426 /* rq "owned" by this entity/group: */426 /* rq "owned" by this entity/group: */
427 struct rt_rq *my_q;427 struct rt_rq *my_q;
428#endif428#endif
429};429} __randomize_layout;
430 430
431struct sched_dl_entity {431struct sched_dl_entity {
432 struct rb_node rb_node;432 struct rb_node rb_node;
@@ -526,6 +526,13 @@ struct task_struct { · 93 unmodified lines
526#endif526#endif
527 /* -1 unrunnable, 0 runnable, >0 stopped: */527 /* -1 unrunnable, 0 runnable, >0 stopped: */
528 volatile long state;528 volatile long state;
529
530 /*
531 * This begins the randomizable portion of task_struct. Only
532 * scheduling-critical items should be added above here.
533 */
534 randomized_struct_fields_start
535
529 void *stack;536 void *stack;
530 atomic_t usage;537 atomic_t usage;
531 /* Per task flags (PF_*), defined further below: */538 /* Per task flags (PF_*), defined further below: */
@@ -1079,6 +1086,13 @@ struct task_struct { · 547 unmodified lines
1079 /* Used by LSM modules for access restriction: */1086 /* Used by LSM modules for access restriction: */
1080 void *security;1087 void *security;
1081#endif1088#endif
1089
1090 /*
1091 * New fields for task_struct should be added above here, so that
1092 * they are included in the randomized portion of task_struct.
1093 */
1094 randomized_struct_fields_end
1095
1082 /* CPU-specific state of this task: */1096 /* CPU-specific state of this task: */
1083 struct thread_struct thread;1097 struct thread_struct thread;
1084 1098
include/linux/sched/signal.h+1−1
@@ -222,7 +222,7 @@ struct signal_struct { · 221 unmodified lines
222 struct mutex cred_guard_mutex; /* guard against foreign influences on222 struct mutex cred_guard_mutex; /* guard against foreign influences on
223 * credential calculations223 * credential calculations
224 * (notably. ptrace) */224 * (notably. ptrace) */
225};225} __randomize_layout;
226 226
227/*227/*
228 * Bits in flags field of signal_struct.228 * Bits in flags field of signal_struct.
include/linux/sem.h+1−1
@@ -41,7 +41,7 @@ struct sem_array { · 40 unmodified lines
41 unsigned int use_global_lock;/* >0: global lock required */41 unsigned int use_global_lock;/* >0: global lock required */
42 42
43 struct sem sems[];43 struct sem sems[];
44};44} __randomize_layout;
45 45
46#ifdef CONFIG_SYSVIPC46#ifdef CONFIG_SYSVIPC
47 47
include/linux/shm.h+1−1
@@ -22,7 +22,7 @@ struct shmid_kernel /* private to the kernel */ · 21 unmodified lines
22 /* The task created the shm object. NULL if the task is dead. */22 /* The task created the shm object. NULL if the task is dead. */
23 struct task_struct *shm_creator;23 struct task_struct *shm_creator;
24 struct list_head shm_clist; /* list by creator */24 struct list_head shm_clist; /* list by creator */
25};25} __randomize_layout;
26 26
27/* shm_mode upper byte flags */27/* shm_mode upper byte flags */
28#define SHM_DEST 01000 /* segment will be destroyed on last detach */28#define SHM_DEST 01000 /* segment will be destroyed on last detach */
include/linux/sysctl.h+1−1
@@ -120,7 +120,7 @@ struct ctl_table · 119 unmodified lines
120 struct ctl_table_poll *poll;120 struct ctl_table_poll *poll;
121 void *extra1;121 void *extra1;
122 void *extra2;122 void *extra2;
123};123} __randomize_layout;
124 124
125struct ctl_node {125struct ctl_node {
126 struct rb_node node;126 struct rb_node node;
include/linux/tty.h+1−1
@@ -332,7 +332,7 @@ struct tty_struct { · 331 unmodified lines
332 /* If the tty has a pending do_SAK, queue it here - akpm */332 /* If the tty has a pending do_SAK, queue it here - akpm */
333 struct work_struct SAK_work;333 struct work_struct SAK_work;
334 struct tty_port *port;334 struct tty_port *port;
335};335} __randomize_layout;
336 336
337/* Each of a tty's open files has private_data pointing to tty_file_private */337/* Each of a tty's open files has private_data pointing to tty_file_private */
338struct tty_file_private {338struct tty_file_private {
include/linux/tty_driver.h+2−2
@@ -291,7 +291,7 @@ struct tty_operations { · 290 unmodified lines
291 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);291 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
292#endif292#endif
293 const struct file_operations *proc_fops;293 const struct file_operations *proc_fops;
294};294} __randomize_layout;
295 295
296struct tty_driver {296struct tty_driver {
297 int magic; /* magic number for this structure */297 int magic; /* magic number for this structure */
@@ -325,7 +325,7 @@ struct tty_driver { · 27 unmodified lines
325 325
326 const struct tty_operations *ops;326 const struct tty_operations *ops;
327 struct list_head tty_drivers;327 struct list_head tty_drivers;
328};328} __randomize_layout;
329 329
330extern struct list_head tty_drivers;330extern struct list_head tty_drivers;
331 331
include/linux/user_namespace.h+1−1
@@ -66,7 +66,7 @@ struct user_namespace { · 65 unmodified lines
66#endif66#endif
67 struct ucounts *ucounts;67 struct ucounts *ucounts;
68 int ucount_max[UCOUNT_COUNTS];68 int ucount_max[UCOUNT_COUNTS];
69};69} __randomize_layout;
70 70
71struct ucounts {71struct ucounts {
72 struct hlist_node node;72 struct hlist_node node;
include/linux/utsname.h+1−1
@@ -26,7 +26,7 @@ struct uts_namespace { · 25 unmodified lines
26 struct user_namespace *user_ns;26 struct user_namespace *user_ns;
27 struct ucounts *ucounts;27 struct ucounts *ucounts;
28 struct ns_common ns;28 struct ns_common ns;
29};29} __randomize_layout;
30extern struct uts_namespace init_uts_ns;30extern struct uts_namespace init_uts_ns;
31 31
32#ifdef CONFIG_UTS_NS32#ifdef CONFIG_UTS_NS
include/net/af_unix.h+1−1
@@ -37,7 +37,7 @@ struct unix_skb_parms { · 36 unmodified lines
37 u32 secid; /* Security ID */37 u32 secid; /* Security ID */
38#endif38#endif
39 u32 consumed;39 u32 consumed;
40};40} __randomize_layout;
41 41
42#define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb))42#define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb))
43 43
include/net/neighbour.h+1−1
@@ -156,7 +156,7 @@ struct neighbour { · 155 unmodified lines
156 struct rcu_head rcu;156 struct rcu_head rcu;
157 struct net_device *dev;157 struct net_device *dev;
158 u8 primary_key[0];158 u8 primary_key[0];
159};159} __randomize_layout;
160 160
161struct neigh_ops {161struct neigh_ops {
162 int family;162 int family;
include/net/net_namespace.h+1−1
@@ -148,7 +148,7 @@ struct net { · 147 unmodified lines
148#endif148#endif
149 struct sock *diag_nlsk;149 struct sock *diag_nlsk;
150 atomic_t fnhe_genid;150 atomic_t fnhe_genid;
151};151} __randomize_layout;
152 152
153#include <linux/seq_file_net.h>153#include <linux/seq_file_net.h>
154 154
include/net/sock.h+1−1
@@ -1128,7 +1128,7 @@ struct proto { · 1127 unmodified lines
1128 atomic_t socks;1128 atomic_t socks;
1129#endif1129#endif
1130 int (*diag_destroy)(struct sock *sk, int err);1130 int (*diag_destroy)(struct sock *sk, int err);
1131};1131} __randomize_layout;
1132 1132
1133int proto_register(struct proto *prot, int alloc_slab);1133int proto_register(struct proto *prot, int alloc_slab);
1134void proto_unregister(struct proto *prot);1134void proto_unregister(struct proto *prot);
kernel/futex.c+2−2
@@ -212,7 +212,7 @@ struct futex_pi_state { · 211 unmodified lines
212 atomic_t refcount;212 atomic_t refcount;
213 213
214 union futex_key key;214 union futex_key key;
215};215} __randomize_layout;
216 216
217/**217/**
218 * struct futex_q - The hashed futex queue entry, one per waiting task218 * struct futex_q - The hashed futex queue entry, one per waiting task
@@ -246,7 +246,7 @@ struct futex_q { · 27 unmodified lines
246 struct rt_mutex_waiter *rt_waiter;246 struct rt_mutex_waiter *rt_waiter;
247 union futex_key *requeue_pi_key;247 union futex_key *requeue_pi_key;
248 u32 bitset;248 u32 bitset;
249};249} __randomize_layout;
250 250
251static const struct futex_q futex_q_init = {251static const struct futex_q futex_q_init = {
252 /* list gets initialized in queue_me()*/252 /* list gets initialized in queue_me()*/
security/keys/internal.h+1−1
@@ -198,7 +198,7 @@ struct request_key_auth { · 197 unmodified lines
198 void *callout_info;198 void *callout_info;
199 size_t callout_len;199 size_t callout_len;
200 pid_t pid;200 pid_t pid;
201};201} __randomize_layout;
202 202
203extern struct key_type key_type_request_key_auth;203extern struct key_type key_type_request_key_auth;
204extern struct key *request_key_auth_new(struct key *target,204extern struct key *request_key_auth_new(struct key *target,