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
This commit is contained in:
parent
d57bf449fe
commit
00490ae3f3
@ -113,7 +113,7 @@ int writev(int, const struct iovec*, int) all
|
|||||||
int __fcntl64:fcntl64(int, int, void*) arm,mips,x86
|
int __fcntl64:fcntl64(int, int, void*) arm,mips,x86
|
||||||
int fcntl(int, int, void*) arm64,mips64,x86_64
|
int fcntl(int, int, void*) arm64,mips64,x86_64
|
||||||
int flock(int, int) all
|
int flock(int, int) all
|
||||||
int __fchmod:fchmod(int, mode_t) all
|
int ___fchmod:fchmod(int, mode_t) all
|
||||||
int dup(int) all
|
int dup(int) all
|
||||||
int pipe2(int*, int) all
|
int pipe2(int*, int) all
|
||||||
int dup3(int, 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 __openat:openat(int, const char*, int, mode_t) all
|
||||||
int faccessat(int, const char*, int, int) 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 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:fstatat64(int, const char*, struct stat*, int) arm,mips,x86
|
||||||
int fstatat64|fstatat:newfstatat(int, const char*, struct stat*, int) arm64,x86_64
|
int fstatat64|fstatat:newfstatat(int, const char*, struct stat*, int) arm64,x86_64
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <private/bionic_asm.h>
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
ENTRY(__fchmod)
|
ENTRY(___fchmod)
|
||||||
mov ip, r7
|
mov ip, r7
|
||||||
ldr r7, =__NR_fchmod
|
ldr r7, =__NR_fchmod
|
||||||
swi #0
|
swi #0
|
||||||
@ -11,4 +11,5 @@ ENTRY(__fchmod)
|
|||||||
bxls lr
|
bxls lr
|
||||||
neg r0, r0
|
neg r0, r0
|
||||||
b __set_errno_internal
|
b __set_errno_internal
|
||||||
END(__fchmod)
|
END(___fchmod)
|
||||||
|
.hidden ___fchmod
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <private/bionic_asm.h>
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
ENTRY(__fchmodat)
|
ENTRY(___fchmodat)
|
||||||
mov ip, r7
|
mov ip, r7
|
||||||
ldr r7, =__NR_fchmodat
|
ldr r7, =__NR_fchmodat
|
||||||
swi #0
|
swi #0
|
||||||
@ -11,4 +11,5 @@ ENTRY(__fchmodat)
|
|||||||
bxls lr
|
bxls lr
|
||||||
neg r0, r0
|
neg r0, r0
|
||||||
b __set_errno_internal
|
b __set_errno_internal
|
||||||
END(__fchmodat)
|
END(___fchmodat)
|
||||||
|
.hidden ___fchmodat
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <private/bionic_asm.h>
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
ENTRY(__fchmod)
|
ENTRY(___fchmod)
|
||||||
mov x8, __NR_fchmod
|
mov x8, __NR_fchmod
|
||||||
svc #0
|
svc #0
|
||||||
|
|
||||||
@ -11,5 +11,5 @@ ENTRY(__fchmod)
|
|||||||
b.hi __set_errno_internal
|
b.hi __set_errno_internal
|
||||||
|
|
||||||
ret
|
ret
|
||||||
END(__fchmod)
|
END(___fchmod)
|
||||||
.hidden __fchmod
|
.hidden ___fchmod
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <private/bionic_asm.h>
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
ENTRY(__fchmodat)
|
ENTRY(___fchmodat)
|
||||||
mov x8, __NR_fchmodat
|
mov x8, __NR_fchmodat
|
||||||
svc #0
|
svc #0
|
||||||
|
|
||||||
@ -11,5 +11,5 @@ ENTRY(__fchmodat)
|
|||||||
b.hi __set_errno_internal
|
b.hi __set_errno_internal
|
||||||
|
|
||||||
ret
|
ret
|
||||||
END(__fchmodat)
|
END(___fchmodat)
|
||||||
.hidden __fchmodat
|
.hidden ___fchmodat
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <private/bionic_asm.h>
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
ENTRY(__fchmod)
|
ENTRY(___fchmod)
|
||||||
.set noreorder
|
.set noreorder
|
||||||
.cpload t9
|
.cpload t9
|
||||||
li v0, __NR_fchmod
|
li v0, __NR_fchmod
|
||||||
@ -16,4 +16,5 @@ ENTRY(__fchmod)
|
|||||||
j t9
|
j t9
|
||||||
nop
|
nop
|
||||||
.set reorder
|
.set reorder
|
||||||
END(__fchmod)
|
END(___fchmod)
|
||||||
|
.hidden ___fchmod
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <private/bionic_asm.h>
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
ENTRY(__fchmodat)
|
ENTRY(___fchmodat)
|
||||||
.set noreorder
|
.set noreorder
|
||||||
.cpload t9
|
.cpload t9
|
||||||
li v0, __NR_fchmodat
|
li v0, __NR_fchmodat
|
||||||
@ -16,4 +16,5 @@ ENTRY(__fchmodat)
|
|||||||
j t9
|
j t9
|
||||||
nop
|
nop
|
||||||
.set reorder
|
.set reorder
|
||||||
END(__fchmodat)
|
END(___fchmodat)
|
||||||
|
.hidden ___fchmodat
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <private/bionic_asm.h>
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
ENTRY(__fchmod)
|
ENTRY(___fchmod)
|
||||||
.set push
|
.set push
|
||||||
.set noreorder
|
.set noreorder
|
||||||
li v0, __NR_fchmod
|
li v0, __NR_fchmod
|
||||||
@ -22,5 +22,5 @@ ENTRY(__fchmod)
|
|||||||
j t9
|
j t9
|
||||||
move ra, t0
|
move ra, t0
|
||||||
.set pop
|
.set pop
|
||||||
END(__fchmod)
|
END(___fchmod)
|
||||||
.hidden __fchmod
|
.hidden ___fchmod
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <private/bionic_asm.h>
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
ENTRY(__fchmodat)
|
ENTRY(___fchmodat)
|
||||||
.set push
|
.set push
|
||||||
.set noreorder
|
.set noreorder
|
||||||
li v0, __NR_fchmodat
|
li v0, __NR_fchmodat
|
||||||
@ -22,5 +22,5 @@ ENTRY(__fchmodat)
|
|||||||
j t9
|
j t9
|
||||||
move ra, t0
|
move ra, t0
|
||||||
.set pop
|
.set pop
|
||||||
END(__fchmodat)
|
END(___fchmodat)
|
||||||
.hidden __fchmodat
|
.hidden ___fchmodat
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <private/bionic_asm.h>
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
ENTRY(__fchmod)
|
ENTRY(___fchmod)
|
||||||
pushl %ebx
|
pushl %ebx
|
||||||
.cfi_def_cfa_offset 8
|
.cfi_def_cfa_offset 8
|
||||||
.cfi_rel_offset ebx, 0
|
.cfi_rel_offset ebx, 0
|
||||||
@ -23,4 +23,5 @@ ENTRY(__fchmod)
|
|||||||
popl %ecx
|
popl %ecx
|
||||||
popl %ebx
|
popl %ebx
|
||||||
ret
|
ret
|
||||||
END(__fchmod)
|
END(___fchmod)
|
||||||
|
.hidden ___fchmod
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <private/bionic_asm.h>
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
ENTRY(__fchmodat)
|
ENTRY(___fchmodat)
|
||||||
pushl %ebx
|
pushl %ebx
|
||||||
.cfi_def_cfa_offset 8
|
.cfi_def_cfa_offset 8
|
||||||
.cfi_rel_offset ebx, 0
|
.cfi_rel_offset ebx, 0
|
||||||
@ -28,4 +28,5 @@ ENTRY(__fchmodat)
|
|||||||
popl %ecx
|
popl %ecx
|
||||||
popl %ebx
|
popl %ebx
|
||||||
ret
|
ret
|
||||||
END(__fchmodat)
|
END(___fchmodat)
|
||||||
|
.hidden ___fchmodat
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <private/bionic_asm.h>
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
ENTRY(__fchmod)
|
ENTRY(___fchmod)
|
||||||
movl $__NR_fchmod, %eax
|
movl $__NR_fchmod, %eax
|
||||||
syscall
|
syscall
|
||||||
cmpq $-MAX_ERRNO, %rax
|
cmpq $-MAX_ERRNO, %rax
|
||||||
@ -12,5 +12,5 @@ ENTRY(__fchmod)
|
|||||||
call __set_errno_internal
|
call __set_errno_internal
|
||||||
1:
|
1:
|
||||||
ret
|
ret
|
||||||
END(__fchmod)
|
END(___fchmod)
|
||||||
.hidden __fchmod
|
.hidden ___fchmod
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <private/bionic_asm.h>
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
ENTRY(__fchmodat)
|
ENTRY(___fchmodat)
|
||||||
movl $__NR_fchmodat, %eax
|
movl $__NR_fchmodat, %eax
|
||||||
syscall
|
syscall
|
||||||
cmpq $-MAX_ERRNO, %rax
|
cmpq $-MAX_ERRNO, %rax
|
||||||
@ -12,5 +12,5 @@ ENTRY(__fchmodat)
|
|||||||
call __set_errno_internal
|
call __set_errno_internal
|
||||||
1:
|
1:
|
||||||
ret
|
ret
|
||||||
END(__fchmodat)
|
END(___fchmodat)
|
||||||
.hidden __fchmodat
|
.hidden ___fchmodat
|
@ -33,11 +33,11 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.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 fchmod(int fd, mode_t mode) {
|
||||||
int saved_errno = errno;
|
int saved_errno = errno;
|
||||||
int result = __fchmod(fd, mode);
|
int result = ___fchmod(fd, mode);
|
||||||
|
|
||||||
if ((result == 0) || (errno != EBADF)) {
|
if ((result == 0) || (errno != EBADF)) {
|
||||||
return result;
|
return result;
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
#include "private/ErrnoRestorer.h"
|
#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) {
|
int fchmodat(int dirfd, const char* pathname, mode_t mode, int flags) {
|
||||||
if ((flags & ~AT_SYMLINK_NOFOLLOW) != 0) {
|
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 result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return __fchmodat(dirfd, pathname, mode);
|
return ___fchmodat(dirfd, pathname, mode);
|
||||||
}
|
}
|
||||||
|
@ -286,8 +286,9 @@ def add_footer(pointer_length, stub, syscall):
|
|||||||
for alias in aliases:
|
for alias in aliases:
|
||||||
stub += function_alias % { "func" : syscall["func"], "alias" : alias }
|
stub += function_alias % { "func" : syscall["func"], "alias" : alias }
|
||||||
|
|
||||||
# Use hidden visibility for any functions beginning with underscores.
|
# Use hidden visibility on LP64 for any functions beginning with underscores.
|
||||||
if pointer_length == 64 and syscall["func"].startswith("__"):
|
# 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'
|
stub += '.hidden ' + syscall["func"] + '\n'
|
||||||
|
|
||||||
return stub
|
return stub
|
||||||
|
Loading…
x
Reference in New Issue
Block a user