diff options
| author | Nick Kralevich <nnk@google.com> | 2015-02-03 11:27:25 -0800 |
|---|---|---|
| committer | Nick Kralevich <nnk@google.com> | 2015-02-03 12:10:30 -0800 |
| commit | 00490ae3f351e07ed4cc2a94b11cba6a22f37311 (patch) | |
| tree | ad09d82701fd1d9cdf44231d8b8789007aa5d8d9 /libc | |
| parent | d57bf449fe6c2dcf35d90d6e4098038ac8a24ecb (diff) | |
| download | bionic-00490ae3f351e07ed4cc2a94b11cba6a22f37311.zip bionic-00490ae3f351e07ed4cc2a94b11cba6a22f37311.tar.gz bionic-00490ae3f351e07ed4cc2a94b11cba6a22f37311.tar.bz2 | |
Ensure raw fchmod/fchmodat syscalls are hidden.
In https://android-review.googlesource.com/#/c/127908/5/libc/SYSCALLS.TXT@116
Elliott said:
for LP64 these will be hidden. for LP32 we were cowards and left
them all public for compatibility (though i don't think we ever
dremeled to see whether it was needed). we don't have an easy
way to recognize additions, though, so we can't prevent adding
new turds.
Add a mechanism to prevent the adding of new turds, and use that
mechanism on the fchmod/fchmodat system calls.
Bug: 19233951
Change-Id: I98f98345970b631a379f348df57858f9fc3d57c0
Diffstat (limited to 'libc')
| -rw-r--r-- | libc/SYSCALLS.TXT | 4 | ||||
| -rw-r--r-- | libc/arch-arm/syscalls/___fchmod.S (renamed from libc/arch-arm/syscalls/__fchmod.S) | 5 | ||||
| -rw-r--r-- | libc/arch-arm/syscalls/___fchmodat.S (renamed from libc/arch-arm/syscalls/__fchmodat.S) | 5 | ||||
| -rw-r--r-- | libc/arch-arm64/syscalls/___fchmod.S (renamed from libc/arch-arm64/syscalls/__fchmod.S) | 6 | ||||
| -rw-r--r-- | libc/arch-arm64/syscalls/___fchmodat.S (renamed from libc/arch-arm64/syscalls/__fchmodat.S) | 6 | ||||
| -rw-r--r-- | libc/arch-mips/syscalls/___fchmod.S (renamed from libc/arch-mips/syscalls/__fchmod.S) | 5 | ||||
| -rw-r--r-- | libc/arch-mips/syscalls/___fchmodat.S (renamed from libc/arch-mips/syscalls/__fchmodat.S) | 5 | ||||
| -rw-r--r-- | libc/arch-mips64/syscalls/___fchmod.S (renamed from libc/arch-mips64/syscalls/__fchmod.S) | 6 | ||||
| -rw-r--r-- | libc/arch-mips64/syscalls/___fchmodat.S (renamed from libc/arch-mips64/syscalls/__fchmodat.S) | 6 | ||||
| -rw-r--r-- | libc/arch-x86/syscalls/___fchmod.S (renamed from libc/arch-x86/syscalls/__fchmod.S) | 5 | ||||
| -rw-r--r-- | libc/arch-x86/syscalls/___fchmodat.S (renamed from libc/arch-x86/syscalls/__fchmodat.S) | 5 | ||||
| -rw-r--r-- | libc/arch-x86_64/syscalls/___fchmod.S (renamed from libc/arch-x86_64/syscalls/__fchmod.S) | 6 | ||||
| -rw-r--r-- | libc/arch-x86_64/syscalls/___fchmodat.S (renamed from libc/arch-x86_64/syscalls/__fchmodat.S) | 6 | ||||
| -rw-r--r-- | libc/bionic/fchmod.cpp | 4 | ||||
| -rw-r--r-- | libc/bionic/fchmodat.cpp | 4 | ||||
| -rwxr-xr-x | libc/tools/gensyscalls.py | 5 |
16 files changed, 45 insertions, 38 deletions
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT index d68a00f..aae7de7 100644 --- a/libc/SYSCALLS.TXT +++ b/libc/SYSCALLS.TXT @@ -113,7 +113,7 @@ int writev(int, const struct iovec*, int) all int __fcntl64:fcntl64(int, int, void*) arm,mips,x86 int fcntl(int, int, void*) arm64,mips64,x86_64 int flock(int, int) all -int __fchmod:fchmod(int, mode_t) all +int ___fchmod:fchmod(int, mode_t) all int dup(int) all int pipe2(int*, int) all int dup3(int, int, int) all @@ -131,7 +131,7 @@ int __getdents64:getdents64(unsigned int, struct dirent*, unsigned int) arm,ar int __openat:openat(int, const char*, int, mode_t) all int faccessat(int, const char*, int, int) all -int __fchmodat:fchmodat(int, const char*, mode_t) all +int ___fchmodat:fchmodat(int, const char*, mode_t) all int fchownat(int, const char*, uid_t, gid_t, int) all int fstatat64|fstatat:fstatat64(int, const char*, struct stat*, int) arm,mips,x86 int fstatat64|fstatat:newfstatat(int, const char*, struct stat*, int) arm64,x86_64 diff --git a/libc/arch-arm/syscalls/__fchmod.S b/libc/arch-arm/syscalls/___fchmod.S index ff888a1..c6da4f8 100644 --- a/libc/arch-arm/syscalls/__fchmod.S +++ b/libc/arch-arm/syscalls/___fchmod.S @@ -2,7 +2,7 @@ #include <private/bionic_asm.h> -ENTRY(__fchmod) +ENTRY(___fchmod) mov ip, r7 ldr r7, =__NR_fchmod swi #0 @@ -11,4 +11,5 @@ ENTRY(__fchmod) bxls lr neg r0, r0 b __set_errno_internal -END(__fchmod) +END(___fchmod) +.hidden ___fchmod diff --git a/libc/arch-arm/syscalls/__fchmodat.S b/libc/arch-arm/syscalls/___fchmodat.S index 4d10f00..91bbda5 100644 --- a/libc/arch-arm/syscalls/__fchmodat.S +++ b/libc/arch-arm/syscalls/___fchmodat.S @@ -2,7 +2,7 @@ #include <private/bionic_asm.h> -ENTRY(__fchmodat) +ENTRY(___fchmodat) mov ip, r7 ldr r7, =__NR_fchmodat swi #0 @@ -11,4 +11,5 @@ ENTRY(__fchmodat) bxls lr neg r0, r0 b __set_errno_internal -END(__fchmodat) +END(___fchmodat) +.hidden ___fchmodat diff --git a/libc/arch-arm64/syscalls/__fchmod.S b/libc/arch-arm64/syscalls/___fchmod.S index 05c67fc..a143c65 100644 --- a/libc/arch-arm64/syscalls/__fchmod.S +++ b/libc/arch-arm64/syscalls/___fchmod.S @@ -2,7 +2,7 @@ #include <private/bionic_asm.h> -ENTRY(__fchmod) +ENTRY(___fchmod) mov x8, __NR_fchmod svc #0 @@ -11,5 +11,5 @@ ENTRY(__fchmod) b.hi __set_errno_internal ret -END(__fchmod) -.hidden __fchmod +END(___fchmod) +.hidden ___fchmod diff --git a/libc/arch-arm64/syscalls/__fchmodat.S b/libc/arch-arm64/syscalls/___fchmodat.S index 2406ea8..1ab3736 100644 --- a/libc/arch-arm64/syscalls/__fchmodat.S +++ b/libc/arch-arm64/syscalls/___fchmodat.S @@ -2,7 +2,7 @@ #include <private/bionic_asm.h> -ENTRY(__fchmodat) +ENTRY(___fchmodat) mov x8, __NR_fchmodat svc #0 @@ -11,5 +11,5 @@ ENTRY(__fchmodat) b.hi __set_errno_internal ret -END(__fchmodat) -.hidden __fchmodat +END(___fchmodat) +.hidden ___fchmodat diff --git a/libc/arch-mips/syscalls/__fchmod.S b/libc/arch-mips/syscalls/___fchmod.S index 9bc491c..ac102ec 100644 --- a/libc/arch-mips/syscalls/__fchmod.S +++ b/libc/arch-mips/syscalls/___fchmod.S @@ -2,7 +2,7 @@ #include <private/bionic_asm.h> -ENTRY(__fchmod) +ENTRY(___fchmod) .set noreorder .cpload t9 li v0, __NR_fchmod @@ -16,4 +16,5 @@ ENTRY(__fchmod) j t9 nop .set reorder -END(__fchmod) +END(___fchmod) +.hidden ___fchmod diff --git a/libc/arch-mips/syscalls/__fchmodat.S b/libc/arch-mips/syscalls/___fchmodat.S index 07ea8f8..d581efa 100644 --- a/libc/arch-mips/syscalls/__fchmodat.S +++ b/libc/arch-mips/syscalls/___fchmodat.S @@ -2,7 +2,7 @@ #include <private/bionic_asm.h> -ENTRY(__fchmodat) +ENTRY(___fchmodat) .set noreorder .cpload t9 li v0, __NR_fchmodat @@ -16,4 +16,5 @@ ENTRY(__fchmodat) j t9 nop .set reorder -END(__fchmodat) +END(___fchmodat) +.hidden ___fchmodat diff --git a/libc/arch-mips64/syscalls/__fchmod.S b/libc/arch-mips64/syscalls/___fchmod.S index 94dd0a1..7c16c54 100644 --- a/libc/arch-mips64/syscalls/__fchmod.S +++ b/libc/arch-mips64/syscalls/___fchmod.S @@ -2,7 +2,7 @@ #include <private/bionic_asm.h> -ENTRY(__fchmod) +ENTRY(___fchmod) .set push .set noreorder li v0, __NR_fchmod @@ -22,5 +22,5 @@ ENTRY(__fchmod) j t9 move ra, t0 .set pop -END(__fchmod) -.hidden __fchmod +END(___fchmod) +.hidden ___fchmod diff --git a/libc/arch-mips64/syscalls/__fchmodat.S b/libc/arch-mips64/syscalls/___fchmodat.S index 79f453f..50f108e 100644 --- a/libc/arch-mips64/syscalls/__fchmodat.S +++ b/libc/arch-mips64/syscalls/___fchmodat.S @@ -2,7 +2,7 @@ #include <private/bionic_asm.h> -ENTRY(__fchmodat) +ENTRY(___fchmodat) .set push .set noreorder li v0, __NR_fchmodat @@ -22,5 +22,5 @@ ENTRY(__fchmodat) j t9 move ra, t0 .set pop -END(__fchmodat) -.hidden __fchmodat +END(___fchmodat) +.hidden ___fchmodat diff --git a/libc/arch-x86/syscalls/__fchmod.S b/libc/arch-x86/syscalls/___fchmod.S index 7ad213e..119a695 100644 --- a/libc/arch-x86/syscalls/__fchmod.S +++ b/libc/arch-x86/syscalls/___fchmod.S @@ -2,7 +2,7 @@ #include <private/bionic_asm.h> -ENTRY(__fchmod) +ENTRY(___fchmod) pushl %ebx .cfi_def_cfa_offset 8 .cfi_rel_offset ebx, 0 @@ -23,4 +23,5 @@ ENTRY(__fchmod) popl %ecx popl %ebx ret -END(__fchmod) +END(___fchmod) +.hidden ___fchmod diff --git a/libc/arch-x86/syscalls/__fchmodat.S b/libc/arch-x86/syscalls/___fchmodat.S index f03c03f..b15bb64 100644 --- a/libc/arch-x86/syscalls/__fchmodat.S +++ b/libc/arch-x86/syscalls/___fchmodat.S @@ -2,7 +2,7 @@ #include <private/bionic_asm.h> -ENTRY(__fchmodat) +ENTRY(___fchmodat) pushl %ebx .cfi_def_cfa_offset 8 .cfi_rel_offset ebx, 0 @@ -28,4 +28,5 @@ ENTRY(__fchmodat) popl %ecx popl %ebx ret -END(__fchmodat) +END(___fchmodat) +.hidden ___fchmodat diff --git a/libc/arch-x86_64/syscalls/__fchmod.S b/libc/arch-x86_64/syscalls/___fchmod.S index ba75f74..7bccbef 100644 --- a/libc/arch-x86_64/syscalls/__fchmod.S +++ b/libc/arch-x86_64/syscalls/___fchmod.S @@ -2,7 +2,7 @@ #include <private/bionic_asm.h> -ENTRY(__fchmod) +ENTRY(___fchmod) movl $__NR_fchmod, %eax syscall cmpq $-MAX_ERRNO, %rax @@ -12,5 +12,5 @@ ENTRY(__fchmod) call __set_errno_internal 1: ret -END(__fchmod) -.hidden __fchmod +END(___fchmod) +.hidden ___fchmod diff --git a/libc/arch-x86_64/syscalls/__fchmodat.S b/libc/arch-x86_64/syscalls/___fchmodat.S index a8fae95..483ec7d 100644 --- a/libc/arch-x86_64/syscalls/__fchmodat.S +++ b/libc/arch-x86_64/syscalls/___fchmodat.S @@ -2,7 +2,7 @@ #include <private/bionic_asm.h> -ENTRY(__fchmodat) +ENTRY(___fchmodat) movl $__NR_fchmodat, %eax syscall cmpq $-MAX_ERRNO, %rax @@ -12,5 +12,5 @@ ENTRY(__fchmodat) call __set_errno_internal 1: ret -END(__fchmodat) -.hidden __fchmodat +END(___fchmodat) +.hidden ___fchmodat diff --git a/libc/bionic/fchmod.cpp b/libc/bionic/fchmod.cpp index 6e020b6..ace8c6b 100644 --- a/libc/bionic/fchmod.cpp +++ b/libc/bionic/fchmod.cpp @@ -33,11 +33,11 @@ #include <unistd.h> #include <stdio.h> -extern "C" int __fchmod(int, mode_t); +extern "C" int ___fchmod(int, mode_t); int fchmod(int fd, mode_t mode) { int saved_errno = errno; - int result = __fchmod(fd, mode); + int result = ___fchmod(fd, mode); if ((result == 0) || (errno != EBADF)) { return result; diff --git a/libc/bionic/fchmodat.cpp b/libc/bionic/fchmodat.cpp index c28e15a..1f83c4b 100644 --- a/libc/bionic/fchmodat.cpp +++ b/libc/bionic/fchmodat.cpp @@ -34,7 +34,7 @@ #include "private/ErrnoRestorer.h" -extern "C" int __fchmodat(int, const char*, mode_t); +extern "C" int ___fchmodat(int, const char*, mode_t); int fchmodat(int dirfd, const char* pathname, mode_t mode, int flags) { if ((flags & ~AT_SYMLINK_NOFOLLOW) != 0) { @@ -63,5 +63,5 @@ int fchmodat(int dirfd, const char* pathname, mode_t mode, int flags) { return result; } - return __fchmodat(dirfd, pathname, mode); + return ___fchmodat(dirfd, pathname, mode); } diff --git a/libc/tools/gensyscalls.py b/libc/tools/gensyscalls.py index 4e24077..7e11418 100755 --- a/libc/tools/gensyscalls.py +++ b/libc/tools/gensyscalls.py @@ -286,8 +286,9 @@ def add_footer(pointer_length, stub, syscall): for alias in aliases: stub += function_alias % { "func" : syscall["func"], "alias" : alias } - # Use hidden visibility for any functions beginning with underscores. - if pointer_length == 64 and syscall["func"].startswith("__"): + # Use hidden visibility on LP64 for any functions beginning with underscores. + # Force hidden visibility for any functions which begin with 3 underscores + if (pointer_length == 64 and syscall["func"].startswith("__")) or syscall["func"].startswith("___"): stub += '.hidden ' + syscall["func"] + '\n' return stub |
