All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] seccomp: cap SECCOMP_RET_ERRNO data to MAX_ERRNO
@ 2015-02-06 21:03 Kees Cook
  2015-02-06 22:32 ` Dmitry V. Levin
  0 siblings, 1 reply; 2+ messages in thread
From: Kees Cook @ 2015-02-06 21:03 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, Andy Lutomirski, Will Drewry, Dmitry V. Levin

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.

Reported-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 kernel/seccomp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/seccomp.c b/kernel/seccomp.c
index 4ef9687ac115..4f44028943e6 100644
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -629,7 +629,9 @@ static u32 __seccomp_phase1_filter(int this_syscall, struct seccomp_data *sd)
 
 	switch (action) {
 	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, task_pt_regs(current),
 					 -data, 0);
 		goto skip;
-- 
1.9.1


-- 
Kees Cook
Chrome OS Security

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] seccomp: cap SECCOMP_RET_ERRNO data to MAX_ERRNO
  2015-02-06 21:03 [PATCH] seccomp: cap SECCOMP_RET_ERRNO data to MAX_ERRNO Kees Cook
@ 2015-02-06 22:32 ` Dmitry V. Levin
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry V. Levin @ 2015-02-06 22:32 UTC (permalink / raw)
  To: Kees Cook; +Cc: akpm, linux-kernel, Andy Lutomirski, Will Drewry

On Fri, Feb 06, 2015 at 01:03:09PM -0800, Kees Cook wrote:
> 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.

Acked-by: Dmitry V. Levin <ldv@altlinux.org>


-- 
ldv

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-02-06 22:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-06 21:03 [PATCH] seccomp: cap SECCOMP_RET_ERRNO data to MAX_ERRNO Kees Cook
2015-02-06 22:32 ` Dmitry V. Levin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.