kernel_optimize_test/ipc
Kees Cook ade9f91b32 ipc: add missing container_of()s for randstruct
When building with the randstruct gcc plugin, the layout of the IPC
structs will be randomized, which requires any sub-structure accesses to
use container_of().  The proc display handlers were missing the needed
container_of()s since the iterator is passing in the top-level struct
kern_ipc_perm.

This would lead to crashes when running the "lsipc" program after the
system had IPC registered (e.g. after starting up Gnome):

  general protection fault: 0000 [#1] PREEMPT SMP
  ...
  RIP: 0010:shm_add_rss_swap.isra.1+0x13/0xa0
  ...
  Call Trace:
    sysvipc_shm_proc_show+0x5e/0x150
    sysvipc_proc_show+0x1a/0x30
    seq_read+0x2e9/0x3f0
  ...

Link: http://lkml.kernel.org/r/20170730205950.GA55841@beast
Fixes: 3859a271a0 ("randstruct: Mark various structs for randomization")
Signed-off-by: Kees Cook <keescook@chromium.org>
Reported-by: Dominik Brodowski <linux@dominikbrodowski.net>
Acked-by: Davidlohr Bueso <dave@stgolabs.net>
Acked-by: Manfred Spraul <manfred@colorfullife.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-08-02 17:16:12 -07:00
..
compat.c
ipc_sysctl.c
Makefile mqueue: move compat syscalls to native ones 2017-07-04 13:13:49 -04:00
mq_sysctl.c
mqueue.c mqueue: fix a use-after-free in sys_mq_notify() 2017-07-09 14:37:19 -07:00
msg.c ipc: add missing container_of()s for randstruct 2017-08-02 17:16:12 -07:00
msgutil.c
namespace.c
sem.c ipc: add missing container_of()s for randstruct 2017-08-02 17:16:12 -07:00
shm.c ipc: add missing container_of()s for randstruct 2017-08-02 17:16:12 -07:00
syscall.c
util.c ipc: move atomic_set() to where it is needed 2017-07-12 16:26:02 -07:00
util.h ipc/util.h: update documentation for ipc_getref() and ipc_putref() 2017-07-12 16:26:02 -07:00