diff options
author | Kees Cook <keescook@chromium.org> | 2015-02-17 13:48:00 -0800 |
---|---|---|
committer | Kees Cook <keescook@google.com> | 2016-04-08 12:49:15 -0700 |
commit | 46e76b0c807df39c2220f5dbb92075157d2dfe63 (patch) | |
tree | 94d0182d9822050a8446d6f466df8ae18c9fe210 | |
parent | 9e06be82e982b19cf0cc74a13a888b367b51ef2d (diff) | |
download | qcom-msm-v3.10-46e76b0c807df39c2220f5dbb92075157d2dfe63.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: 28020023
Patchset: seccomp
(cherry picked from commit 580c57f1076872ebc2427f898b927944ce170f2d)
Signed-off-by: Kees Cook <keescook@google.com>
Change-Id: Ibc3ed0857e83e750f982c403215924361a013cc7
-rw-r--r-- | kernel/seccomp.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/kernel/seccomp.c b/kernel/seccomp.c index 0208bbee21b..39cdd735c0f 100644 --- a/kernel/seccomp.c +++ b/kernel/seccomp.c @@ -625,7 +625,9 @@ int __secure_computing(void) 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; |