gcc-plugins updates for v4.13-rc2
Subsystems (2)
Hi,
Please pull these gcc-plugins changes for v4.13-rc2. Now that IPC and other trees have landed, it's sensible to pull the manual markings portion of randstruct. 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)
Various (trivial) merge conflicts exist due to additions to structures. Since there were more than a couple, I thought I'd just send along how I solved the conflicts when I did the merge to your tree this morning, if it helps:
fs/proc/internal.h +0 -0
@@@ -67,10 -67,10 +67,10 @@@ struct proc_inodestruct proc_dir_entry *pde;struct ctl_table_header *sysctl;struct ctl_table *sysctl_entry; - struct list_head sysctl_inodes; + struct hlist_node sysctl_inodes;const struct proc_ns_operations *ns_ops;struct inode vfs_inode; - }; + } __randomize_layout;/* * General functions
include/linux/fs.h +0 -0
@@@ -295,8 -275,7 +295,8 @@@ struct kiocb void (*ki_complete)(struct kiocb *iocb, long ret, long ret2); void *private; int ki_flags; + enum rw_hint ki_hint; - }; + } __randomize_layout; static inline bool is_sync_kiocb(struct kiocb *kiocb) { gfp_t gfp_mask; /* implicit gfp mask for allocations */ struct list_head private_list; /* ditto */ void *private_data; /* ditto */ + errseq_t wb_err; - } __attribute__((aligned(sizeof(long)))); + } __attribute__((aligned(sizeof(long)))) __randomize_layout; /* * On most architectures that alignment is already the case; but * must be enforced here for CRIS, to let the least significant bit struct list_head f_tfile_llink; #endif /* #ifdef CONFIG_EPOLL */ struct address_space *f_mapping; + errseq_t f_wb_err; - } __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */ + } __randomize_layout + __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */ struct file_handle { __u32 handle_bytes;
include/linux/ipc.h +0 -0
@@@ -20,9 -20,6 +20,9 @@@ struct kern_ipc_permumode_t mode;unsigned long seq;void *security; + + struct rcu_head rcu; + atomic_t refcount; - }____cacheline_aligned_in_smp ; + }____cacheline_aligned_in_smp __randomize_layout;#endif /* _LINUX_IPC_H */
include/linux/sem.h +0 -0
@@@ -39,9 -21,7 +39,9 @@@ struct sem_arrayint sem_nsems;/* no. of semaphores in array */ int complex_count;/* pending complex operations */ unsigned int use_global_lock;/* >0: global lock required */ + + struct sem sems[]; - }; + } __randomize_layout;#ifdef CONFIG_SYSVIPC
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.
Thanks!
-Kees
The following changes since commit ffa47aa678cfaa9b88e8a26cfb115b4768325121:
ARM: Prepare for randomized task_struct (2017-06-30 12:00:50 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git tags/gcc-plugins-v4.13-rc2
for you to fetch changes up to 8acdf5055974e49d337d51ac7011449cfd7b7d05:
randstruct: opt-out externally exposed function pointer structs (2017-06-30 12:00:52 -0700)
----------------------------------------------------------------
Now that IPC and other changes have landed, enable manual markings for randstruct plugin, including the task_struct.
----------------------------------------------------------------
Kees Cook (3):
randstruct: Mark various structs for randomization
task_struct: Allow randomized layout
randstruct: opt-out externally exposed function pointer structs
arch/arm/include/asm/cacheflush.h | 2 +- arch/x86/include/asm/paravirt_types.h | 16 ++++++++-------- arch/x86/include/asm/processor.h | 2 +- fs/mount.h | 4 ++-- fs/namei.c | 2 +- fs/proc/internal.h | 6 +++--- include/linux/binfmts.h | 4 ++-- include/linux/cdev.h | 2 +- include/linux/compiler-gcc.h | 13 ++++++++++++- include/linux/compiler.h | 5 +++++ include/linux/cred.h | 4 ++-- include/linux/dcache.h | 2 +- include/linux/fs.h | 17 +++++++++-------- include/linux/fs_struct.h | 2 +- include/linux/ipc.h | 2 +- include/linux/ipc_namespace.h | 2 +- include/linux/key-type.h | 4 ++-- include/linux/kmod.h | 2 +- include/linux/kobject.h | 2 +- include/linux/lsm_hooks.h | 4 ++-- include/linux/mm_types.h | 4 ++-- include/linux/module.h | 4 ++-- include/linux/mount.h | 2 +- include/linux/msg.h | 2 +- include/linux/path.h | 2 +- include/linux/pid_namespace.h | 2 +- include/linux/proc_ns.h | 2 +- include/linux/sched.h | 16 +++++++++++++++- include/linux/sched/signal.h | 2 +- include/linux/sem.h | 2 +- include/linux/shm.h | 2 +- include/linux/sysctl.h | 2 +- include/linux/tty.h | 2 +- include/linux/tty_driver.h | 4 ++-- include/linux/user_namespace.h | 2 +- include/linux/utsname.h | 2 +- include/net/af_unix.h | 2 +- include/net/neighbour.h | 2 +- include/net/net_namespace.h | 2 +- include/net/sock.h | 2 +- kernel/futex.c | 4 ++-- security/keys/internal.h | 2 +- 42 files changed, 97 insertions(+), 66 deletions(-)
Signature · 2 lines
Kees Cook Pixel Security