]> granicus.if.org Git - strace/commitdiff
is_negated_errno: sync MAX_ERRNO with the kernel
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 19 Feb 2015 16:58:52 +0000 (16:58 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 19 Feb 2015 16:58:52 +0000 (16:58 +0000)
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.

syscall.c

index 2aeb0a373d7da36e5fa016557265522d3c6c416d..156dbc8f98a678121364e625d80dbda7110ebadb 100644 (file)
--- 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.