From: Dmitry V. Levin Date: Mon, 3 Oct 2016 15:51:49 +0000 (+0000) Subject: x86_64: fix is_negated_errno for x32 personality X-Git-Tag: v4.14~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=820adffcd9b23c780e06fc5c216438223d5896ed;p=strace x86_64: fix is_negated_errno for x32 personality * syscall.c (is_negated_errno) [X86_64]: Do not truncate kernel_ulong_t to uint32_t for x32 personality. --- diff --git a/syscall.c b/syscall.c index 90770857..0894733e 100644 --- a/syscall.c +++ b/syscall.c @@ -1174,18 +1174,18 @@ is_negated_errno(kernel_ulong_t val) /* 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)) { +#if defined X86_64 || defined X32 + /* + * current_wordsize is 4 for x32 personality + * but truncation _must not_ be done in it, so + * check current_personality instead. + */ + if (current_personality == 1) { val = (uint32_t) val; max = (uint32_t) max; } -#elif defined X32 - /* - * current_wordsize is 4 even in personality 0 (native X32) - * but truncation _must not_ be done in it. - * can't check current_wordsize here! - */ - if (current_personality != 0) { +#elif SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4 + if (current_wordsize < sizeof(val)) { val = (uint32_t) val; max = (uint32_t) max; }