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