]> git.baikalelectronics.ru Git - kernel.git/commit
samples/seccomp: Zero out members based on seccomp_notif_sizes
authorSargun Dhillon <sargun@sargun.me>
Mon, 30 Dec 2019 20:35:03 +0000 (12:35 -0800)
committerKees Cook <keescook@chromium.org>
Thu, 2 Jan 2020 21:03:39 +0000 (13:03 -0800)
commitf2d052e6a08e1d03484c8209473342471e8a40fa
tree95902c0d8e6275f848b929faa0ed21fd6e7246e3
parenta703976d8e9b2972343d7af9d551c41c680d9d84
samples/seccomp: Zero out members based on seccomp_notif_sizes

The sizes by which seccomp_notif and seccomp_notif_resp are allocated are
based on the SECCOMP_GET_NOTIF_SIZES ioctl. This allows for graceful
extension of these datastructures. If userspace zeroes out the
datastructure based on its version, and it is lagging behind the kernel's
version, it will end up sending trailing garbage. On the other hand,
if it is ahead of the kernel version, it will write extra zero space,
and potentially cause corruption.

Signed-off-by: Sargun Dhillon <sargun@sargun.me>
Suggested-by: Tycho Andersen <tycho@tycho.ws>
Link: https://lore.kernel.org/r/20191230203503.4925-1-sargun@sargun.me
Fixes: e4265eef6405 ("samples: add an example of seccomp user trap")
Cc: stable@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
samples/seccomp/user-trap.c