Commit 580c57f1 authored by Kees Cook's avatar Kees Cook Committed by Linus Torvalds
Browse files

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: default avatarKees Cook <>
Reported-by: default avatarDmitry V. Levin <>
Cc: Andy Lutomirski <>
Cc: Will Drewry <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 3a9af0bd
......@@ -629,7 +629,9 @@ static u32 __seccomp_phase1_filter(int this_syscall, struct seccomp_data *sd)
switch (action) {
/* 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;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment