diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT index 800726a5f..82f542cbb 100644 --- a/libc/SYSCALLS.TXT +++ b/libc/SYSCALLS.TXT @@ -253,6 +253,7 @@ int init_module(void *, unsigned long, const char *) 128 int delete_module(const char*, unsigned int) 129 int klogctl:syslog(int, char *, int) 103 int sysinfo(struct sysinfo *) 116 +int personality(unsigned long) 136 # futex int futex(void *, int, int, void *, void *, int) 240 diff --git a/libc/arch-arm/syscalls.mk b/libc/arch-arm/syscalls.mk index 1f2a1cd5e..b7a453252 100644 --- a/libc/arch-arm/syscalls.mk +++ b/libc/arch-arm/syscalls.mk @@ -170,6 +170,7 @@ syscall_src += arch-arm/syscalls/init_module.S syscall_src += arch-arm/syscalls/delete_module.S syscall_src += arch-arm/syscalls/klogctl.S syscall_src += arch-arm/syscalls/sysinfo.S +syscall_src += arch-arm/syscalls/personality.S syscall_src += arch-arm/syscalls/futex.S syscall_src += arch-arm/syscalls/epoll_create.S syscall_src += arch-arm/syscalls/epoll_ctl.S diff --git a/libc/arch-arm/syscalls/personality.S b/libc/arch-arm/syscalls/personality.S new file mode 100644 index 000000000..17ac68661 --- /dev/null +++ b/libc/arch-arm/syscalls/personality.S @@ -0,0 +1,14 @@ +/* autogenerated by gensyscalls.py */ +#include +#include + +ENTRY(personality) + .save {r4, r7} + stmfd sp!, {r4, r7} + ldr r7, =__NR_personality + swi #0 + ldmfd sp!, {r4, r7} + movs r0, r0 + bxpl lr + b __set_syscall_errno +END(personality) diff --git a/libc/arch-sh/syscalls.mk b/libc/arch-sh/syscalls.mk index e6fba58d9..36cc5946c 100644 --- a/libc/arch-sh/syscalls.mk +++ b/libc/arch-sh/syscalls.mk @@ -160,6 +160,7 @@ syscall_src += arch-sh/syscalls/init_module.S syscall_src += arch-sh/syscalls/delete_module.S syscall_src += arch-sh/syscalls/klogctl.S syscall_src += arch-sh/syscalls/sysinfo.S +syscall_src += arch-sh/syscalls/personality.S syscall_src += arch-sh/syscalls/futex.S syscall_src += arch-sh/syscalls/epoll_create.S syscall_src += arch-sh/syscalls/epoll_ctl.S diff --git a/libc/arch-sh/syscalls/personality.S b/libc/arch-sh/syscalls/personality.S new file mode 100644 index 000000000..efc2ea380 --- /dev/null +++ b/libc/arch-sh/syscalls/personality.S @@ -0,0 +1,32 @@ +/* autogenerated by gensyscalls.py */ +#include + + .text + .type personality, @function + .globl personality + .align 4 + +personality: + + /* invoke trap */ + mov.l 0f, r3 /* trap num */ + trapa #(1 + 0x10) + + /* check return value */ + cmp/pz r0 + bt __NR_personality_end + + /* keep error number */ + sts.l pr, @-r15 + mov.l 1f, r1 + jsr @r1 + mov r0, r4 + lds.l @r15+, pr + +__NR_personality_end: + rts + nop + + .align 2 +0: .long __NR_personality +1: .long __set_syscall_errno diff --git a/libc/arch-x86/syscalls.mk b/libc/arch-x86/syscalls.mk index f2634704f..03b4cbd4a 100644 --- a/libc/arch-x86/syscalls.mk +++ b/libc/arch-x86/syscalls.mk @@ -174,6 +174,7 @@ syscall_src += arch-x86/syscalls/init_module.S syscall_src += arch-x86/syscalls/delete_module.S syscall_src += arch-x86/syscalls/klogctl.S syscall_src += arch-x86/syscalls/sysinfo.S +syscall_src += arch-x86/syscalls/personality.S syscall_src += arch-x86/syscalls/futex.S syscall_src += arch-x86/syscalls/epoll_create.S syscall_src += arch-x86/syscalls/epoll_ctl.S diff --git a/libc/arch-x86/syscalls/personality.S b/libc/arch-x86/syscalls/personality.S new file mode 100644 index 000000000..af4f9120f --- /dev/null +++ b/libc/arch-x86/syscalls/personality.S @@ -0,0 +1,23 @@ +/* autogenerated by gensyscalls.py */ +#include + + .text + .type personality, @function + .globl personality + .align 4 + +personality: + pushl %ebx + mov 8(%esp), %ebx + movl $__NR_personality, %eax + int $0x80 + cmpl $-129, %eax + jb 1f + negl %eax + pushl %eax + call __set_errno + addl $4, %esp + orl $-1, %eax +1: + popl %ebx + ret diff --git a/libc/include/sys/linux-syscalls.h b/libc/include/sys/linux-syscalls.h index 5361acec9..e6d7dfb12 100644 --- a/libc/include/sys/linux-syscalls.h +++ b/libc/include/sys/linux-syscalls.h @@ -133,6 +133,7 @@ #define __NR_delete_module (__NR_SYSCALL_BASE + 129) #define __NR_syslog (__NR_SYSCALL_BASE + 103) #define __NR_sysinfo (__NR_SYSCALL_BASE + 116) +#define __NR_personality (__NR_SYSCALL_BASE + 136) #define __NR_futex (__NR_SYSCALL_BASE + 240) #define __NR_poll (__NR_SYSCALL_BASE + 168) diff --git a/libc/include/sys/linux-unistd.h b/libc/include/sys/linux-unistd.h index 867cfe6de..b5ee59139 100644 --- a/libc/include/sys/linux-unistd.h +++ b/libc/include/sys/linux-unistd.h @@ -201,6 +201,7 @@ int init_module (void *, unsigned long, const char *); int delete_module (const char*, unsigned int); int klogctl (int, char *, int); int sysinfo (struct sysinfo *); +int personality (unsigned long); int futex (void *, int, int, void *, void *, int); int epoll_create (int size); int epoll_ctl (int epfd, int op, int fd, struct epoll_event *event); diff --git a/libc/include/sys/personality.h b/libc/include/sys/personality.h new file mode 100644 index 000000000..2199fa74a --- /dev/null +++ b/libc/include/sys/personality.h @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _SYS_PERSONALITY_H_ +#define _SYS_PERSONALITY_H_ + +__BEGIN_DECLS + +/* constants taken from linux-3.0.4/include/linux/personality.h */ + +enum { + UNAME26 = 0x0020000, + ADDR_NO_RANDOMIZE = 0x0040000, + FDPIC_FUNCPTRS = 0x0080000, + MMAP_PAGE_ZERO = 0x0100000, + ADDR_COMPAT_LAYOUT = 0x0200000, + READ_IMPLIES_EXEC = 0x0400000, + ADDR_LIMIT_32BIT = 0x0800000, + SHORT_INODE = 0x1000000, + WHOLE_SECONDS = 0x2000000, + STICKY_TIMEOUTS = 0x4000000, + ADDR_LIMIT_3GB = 0x8000000, +}; + +#define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \ + ADDR_NO_RANDOMIZE | \ + ADDR_COMPAT_LAYOUT | \ + MMAP_PAGE_ZERO) + +enum { + PER_LINUX = 0x0000, + PER_LINUX_32BIT = 0x0000 | ADDR_LIMIT_32BIT, + PER_LINUX_FDPIC = 0x0000 | FDPIC_FUNCPTRS, + PER_SVR4 = 0x0001 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO, + PER_SVR3 = 0x0002 | STICKY_TIMEOUTS | SHORT_INODE, + PER_SCOSVR3 = 0x0003 | STICKY_TIMEOUTS | + WHOLE_SECONDS | SHORT_INODE, + PER_OSR5 = 0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS, + PER_WYSEV386 = 0x0004 | STICKY_TIMEOUTS | SHORT_INODE, + PER_ISCR4 = 0x0005 | STICKY_TIMEOUTS, + PER_BSD = 0x0006, + PER_SUNOS = 0x0006 | STICKY_TIMEOUTS, + PER_XENIX = 0x0007 | STICKY_TIMEOUTS | SHORT_INODE, + PER_LINUX32 = 0x0008, + PER_LINUX32_3GB = 0x0008 | ADDR_LIMIT_3GB, + PER_IRIX32 = 0x0009 | STICKY_TIMEOUTS, + PER_IRIXN32 = 0x000a | STICKY_TIMEOUTS, + PER_IRIX64 = 0x000b | STICKY_TIMEOUTS, + PER_RISCOS = 0x000c, + PER_SOLARIS = 0x000d | STICKY_TIMEOUTS, + PER_UW7 = 0x000e | STICKY_TIMEOUTS | MMAP_PAGE_ZERO, + PER_OSF4 = 0x000f, + PER_HPUX = 0x0010, + PER_MASK = 0x00ff, +}; + +extern int personality (unsigned long persona); + +__END_DECLS + +#endif /* _SYS_PERSONALITY_H_ */