]>
Commit | Line | Data |
---|---|---|
688903eb | 1 | /* Copyright (C) 2015-2018 Free Software Foundation, Inc. |
e0043e17 DL |
2 | This file is part of the GNU C Library. |
3 | ||
4 | The GNU C Library is free software; you can redistribute it and/or | |
5 | modify it under the terms of the GNU Lesser General Public | |
6 | License as published by the Free Software Foundation; either | |
7 | version 2.1 of the License, or (at your option) any later version. | |
8 | ||
9 | The GNU C Library is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 | Lesser General Public License for more details. | |
13 | ||
14 | You should have received a copy of the GNU Lesser General Public | |
15 | License along with the GNU C Library; if not, see | |
16 | <http://www.gnu.org/licenses/>. */ | |
17 | ||
18 | #include <sys/personality.h> | |
19 | #include <sysdep.h> | |
20 | ||
21 | extern __typeof (personality) __personality; | |
22 | ||
23 | int | |
24 | __personality (unsigned long persona) | |
25 | { | |
26 | #ifdef PERSONALITY_TRUNCATE_ARGUMENT | |
27 | /* Starting with kernel commit v2.6.21-3117-g97dc32c, the type of | |
28 | task_struct->pesonality is "unsigned int". | |
29 | Starting with kernel commit v2.6.35-rc1-372-g485d527, the personality | |
30 | syscall accepts "unsigned int" instead of "long unsigned int". | |
31 | Inbetween, a personality argument that does not fit into "unsigned int" | |
32 | would result to system call returning -EINVAL. | |
33 | We explicitly truncate the personality argument to "unsigned int" | |
34 | to eliminate the uncertainty. */ | |
35 | persona = (unsigned int) persona; | |
36 | #endif | |
37 | ||
38 | INTERNAL_SYSCALL_DECL (err); | |
39 | long ret = INTERNAL_SYSCALL (personality, err, 1, persona); | |
40 | ||
41 | /* Starting with kernel commit v2.6.29-6609-g11d06b2, the personality syscall | |
42 | never fails. However, 32-bit kernels might flag valid values as errors, so | |
43 | we need to reverse the error setting. We can't use the raw result as some | |
44 | arches split the return/error values. */ | |
45 | if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (ret, err))) | |
46 | ret = -INTERNAL_SYSCALL_ERRNO (ret, err); | |
47 | return ret; | |
48 | } | |
49 | weak_alias (__personality, personality) |