aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2015-02-17 13:48:00 -0800
committerKees Cook <keescook@google.com>2016-04-08 20:49:38 +0000
commit6a8aa6ba8bfec89ad16f964e42ac11d905ad7a1c (patch)
tree1e634486615d455ca9957f7faf44eefb2c5d99da
parent3eccfae5bcffd92126dd3c8c7700311c30cdd9fb (diff)
downloadedison-v3.10-6a8aa6ba8bfec89ad16f964e42ac11d905ad7a1c.tar.gz
BACKPORT: seccomp: cap SECCOMP_RET_ERRNO data to MAX_ERRNO
The value resulting from the SECCOMP_RET_DATA mask could exceed MAX_ERRNO when setting errno during a SECCOMP_RET_ERRNO filter action. This makes sure we have a reliable value being set, so that an invalid errno will not be ignored by userspace. Signed-off-by: Kees Cook <keescook@chromium.org> Reported-by: Dmitry V. Levin <ldv@altlinux.org> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Will Drewry <wad@chromium.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Bug: 27892194 Patchset: seccomp (cherry picked from commit 580c57f1076872ebc2427f898b927944ce170f2d) Signed-off-by: Kees Cook <keescook@google.com> Change-Id: I30c2741f7064914b04b8a2765f1fd40f3a1cbd9e
-rw-r--r--kernel/seccomp.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index 1fbb1a2bc45..ba54fc2f417 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -600,7 +600,9 @@ int __secure_computing(int this_syscall)
ret &= SECCOMP_RET_ACTION;
switch (ret) {
case SECCOMP_RET_ERRNO:
- /* Set the low-order 16-bits as a errno. */
+ /* Set low-order bits as an errno, capped at MAX_ERRNO. */
+ if (data > MAX_ERRNO)
+ data = MAX_ERRNO;
syscall_set_return_value(current, regs,
-data, 0);
goto skip;