Blame SOURCES/0189-setarch-fix-personality-syscall-return-code-check.patch

4aa97a
From 123ac3f91e1f47108d74e5f294e0f7b6b5ba6033 Mon Sep 17 00:00:00 2001
4aa97a
From: "Dmitry V. Levin" <ldv@altlinux.org>
4aa97a
Date: Sat, 5 Mar 2016 00:22:52 +0300
4aa97a
Subject: [PATCH 189/189] setarch: fix personality syscall return code check
4aa97a
4aa97a
Depending on architecture and kernel version, personality
4aa97a
syscall is either capable or incapable of returning an error.
4aa97a
If the return value is not an error, then it's the previous
4aa97a
personality value, which can be an arbitrary value
4aa97a
undistinguishable from an error value.
4aa97a
To make things clear, a second call is needed.
4aa97a
4aa97a
For more details about personality syscall peculiarities see
4aa97a
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=glibc-2.22-637-ge0043e17dfc5
4aa97a
4aa97a
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
4aa97a
Signed-off-by: Karel Zak <kzak@redhat.com>
4aa97a
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1690102
4aa97a
Upstream: http://github.com/karelzak/util-linux/commit/ae7065760d9bbe776a93a73d88e85c7796acb8cc
4aa97a
---
4aa97a
 sys-utils/setarch.c | 14 ++++++++++++--
4aa97a
 1 file changed, 12 insertions(+), 2 deletions(-)
4aa97a
4aa97a
diff --git a/sys-utils/setarch.c b/sys-utils/setarch.c
4aa97a
index bcde78f4c..0e45cfef9 100644
4aa97a
--- a/sys-utils/setarch.c
4aa97a
+++ b/sys-utils/setarch.c
4aa97a
@@ -223,8 +223,18 @@ set_arch(const char *pers, unsigned long options, int list)
4aa97a
     errx(EXIT_FAILURE, _("%s: Unrecognized architecture"), pers);
4aa97a
 
4aa97a
   pers_value = transitions[i].perval | options;
4aa97a
-  if (personality(pers_value) == -EINVAL)
4aa97a
-    return 1;
4aa97a
+  if (personality(pers_value) < 0) {
4aa97a
+    /*
4aa97a
+     * Depending on architecture and kernel version, personality
4aa97a
+     * syscall is either capable or incapable of returning an error.
4aa97a
+     * If the return value is not an error, then it's the previous
4aa97a
+     * personality value, which can be an arbitrary value
4aa97a
+     * undistinguishable from an error value.
4aa97a
+     * To make things clear, a second call is needed.
4aa97a
+     */
4aa97a
+    if (personality(pers_value) < 0)
4aa97a
+      return 1;
4aa97a
+  }
4aa97a
 
4aa97a
   uname(&un;;
4aa97a
   if(transitions[i].result_arch &&
4aa97a
-- 
4aa97a
2.21.0
4aa97a