platform_bionic/libc/arch-x86_64/syscalls
Nick Kralevich 3cbc6c627f Add fchmodat(AT_SYMLINK_NOFOLLOW) and fchmod O_PATH support
Many libc functions have an option to not follow symbolic
links. This is useful to avoid security sensitive code
from inadvertantly following attacker supplied symlinks
and taking inappropriate action on files it shouldn't.
For example, open() has O_NOFOLLOW, chown() has
lchown(), stat() has lstat(), etc.

There is no such equivalent function for chmod(), such as lchmod().
To address this, POSIX introduced fchmodat(AT_SYMLINK_NOFOLLOW),
which is intended to provide a way to perform a chmod operation
which doesn't follow symlinks.

Currently, the Linux kernel doesn't implement AT_SYMLINK_NOFOLLOW.
In GLIBC, attempting to use the AT_SYMLINK_NOFOLLOW flag causes
fchmodat to return ENOTSUP. Details are in "man fchmodat".

Bionic currently differs from GLIBC in that AT_SYMLINK_NOFOLLOW
is silently ignored and treated as if the flag wasn't present.

This patch provides a userspace implementation of
AT_SYMLINK_NOFOLLOW for bionic. Using open(O_PATH | O_NOFOLLOW),
we can provide a way to atomically change the permissions on
files without worrying about race conditions.

As part of this change, we add support for fchmod on O_PATH
file descriptors, because it's relatively straight forward
and could be useful in the future.

The basic idea behind this implementation comes from
https://sourceware.org/bugzilla/show_bug.cgi?id=14578 , specifically
comment #10.

Change-Id: I1eba0cdb2c509d9193ceecf28f13118188a3cfa7
2015-02-02 13:17:17 -08:00
..
__accept4.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__arch_prctl.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__brk.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__clock_gettime.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__clock_nanosleep.S Add clock_settime and clock_nanosleep. 2014-10-13 17:04:10 -07:00
__connect.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__epoll_pwait.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__exit.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__fadvise64.S Add posix_fadvise(3). 2014-09-11 08:45:46 -07:00
__fchmod.S Add fchmodat(AT_SYMLINK_NOFOLLOW) and fchmod O_PATH support 2015-02-02 13:17:17 -08:00
__fchmodat.S Add fchmodat(AT_SYMLINK_NOFOLLOW) and fchmod O_PATH support 2015-02-02 13:17:17 -08:00
__getcpu.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__getcwd.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__getdents64.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__getpid.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__getpriority.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__gettimeofday.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__ioctl.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__openat.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__ppoll.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__pselect6.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__ptrace.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__reboot.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__rt_sigaction.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__rt_sigpending.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__rt_sigprocmask.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__rt_sigqueueinfo.S support _POSIX_REALTIME_SIGNALS 2014-12-08 21:52:43 -08:00
__rt_sigsuspend.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__rt_sigtimedwait.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__sched_getaffinity.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__set_tid_address.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__signalfd4.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__socket.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__timer_create.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__timer_delete.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__timer_getoverrun.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__timer_gettime.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__timer_settime.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
__waitid.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
_exit.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
acct.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
bind.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
capget.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
capset.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
chdir.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
chroot.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
clock_getres.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
clock_settime.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
close.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
delete_module.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
dup.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
dup3.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
epoll_create1.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
epoll_ctl.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
eventfd.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
execve.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
faccessat.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
fallocate.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
fchdir.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
fchown.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
fchownat.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
fcntl.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
fdatasync.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
fgetxattr.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
flistxattr.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
flock.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
fremovexattr.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
fsetxattr.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
fstat64.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
fstatat64.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
fstatfs64.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
fsync.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
ftruncate.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
getegid.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
geteuid.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
getgid.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
getgroups.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
getitimer.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
getpeername.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
getpgid.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
getppid.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
getresgid.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
getresuid.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
getrlimit.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
getrusage.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
getsid.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
getsockname.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
getsockopt.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
getuid.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
getxattr.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
init_module.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
inotify_add_watch.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
inotify_init1.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
inotify_rm_watch.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
kill.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
klogctl.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
lgetxattr.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
linkat.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
listen.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
listxattr.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
llistxattr.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
lremovexattr.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
lseek.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
lsetxattr.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
madvise.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
mincore.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
mkdirat.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
mknodat.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
mlock.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
mlockall.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
mmap.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
mount.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
mprotect.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
mremap.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
msync.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
munlock.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
munlockall.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
munmap.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
nanosleep.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
personality.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
pipe2.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
prctl.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
pread64.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
prlimit64.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
pwrite64.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
read.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
readahead.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
readlinkat.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
readv.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
recvfrom.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
recvmmsg.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
recvmsg.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
removexattr.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
renameat.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
sched_get_priority_max.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
sched_get_priority_min.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
sched_getparam.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
sched_getscheduler.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
sched_rr_get_interval.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
sched_setaffinity.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
sched_setparam.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
sched_setscheduler.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
sched_yield.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
sendfile.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
sendmmsg.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
sendmsg.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
sendto.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
setfsgid.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
setfsuid.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
setgid.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
setgroups.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
sethostname.S Add sethostname(2). 2014-11-07 16:48:27 -08:00
setitimer.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
setns.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
setpgid.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
setpriority.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
setregid.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
setresgid.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
setresuid.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
setreuid.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
setrlimit.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
setsid.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
setsockopt.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
settimeofday.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
setuid.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
setxattr.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
shutdown.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
sigaltstack.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
socketpair.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
splice.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
statfs64.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
swapoff.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
swapon.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
symlinkat.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
sync.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
sysinfo.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
tee.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
tgkill.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
timerfd_create.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
timerfd_gettime.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
timerfd_settime.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
times.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
truncate.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
umask.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
umount2.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
uname.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
unlinkat.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
unshare.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
utimensat.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
vmsplice.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
wait4.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
write.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00
writev.S Ensure __set_errno is still visible on LP32. 2014-09-08 16:46:50 -07:00