From: Dmitry V. Levin Date: Thu, 19 Feb 2015 16:58:52 +0000 (+0000) Subject: is_negated_errno: sync MAX_ERRNO with the kernel X-Git-Tag: v4.10~99 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fb585db562e66d3a32e810433408d6827021235c;p=strace is_negated_errno: sync MAX_ERRNO with the kernel Linux kernel used to guarantee that the largest errno value will not exceed 4095, but SECCOMP_RET_ERRNO support introduced by kernel commit v3.4-rc2-13-gacf3b2c71ed20c53dc69826683417703c2a88059 inadvertently broke it. The guarantee is back with kernel commit v3.19-8275-g580c57f1076872ebc2427f898b927944ce170f2d. * syscall.c (is_negated_errno): Set maximum errno value to 4095. --- diff --git a/syscall.c b/syscall.c index 2aeb0a37..156dbc8f 100644 --- a/syscall.c +++ b/syscall.c @@ -1584,12 +1584,8 @@ typedef unsigned long kernel_ulong_t; static inline bool is_negated_errno(kernel_ulong_t val) { - /* - * Thanks to SECCOMP_RET_DATA == 0xffff, abnormally large errno - * values could be easily seen when a seccomp filter is used, e.g. - * BPF_STMT(BPF_RET, SECCOMP_RET_ERRNO | SECCOMP_RET_DATA) - */ - kernel_ulong_t max = -(kernel_long_t) 0x10000; /* SECCOMP_RET_DATA + 1 */ + /* Linux kernel defines MAX_ERRNO to 4095. */ + kernel_ulong_t max = -(kernel_long_t) 4095; #if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 if (current_wordsize < sizeof(val)) { @@ -1608,7 +1604,7 @@ is_negated_errno(kernel_ulong_t val) } #endif - return val > max; + return val >= max; } /* Called at each syscall entry.