bionic/libc/arch-arm64
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
..
bionic [Arm64] Fix overlapping fp fields in jmp_buf 2015-01-26 16:20:05 -08:00
denver64 Add __memcpy_chk assembly for 64 bit. 2014-09-26 12:47:04 -07:00
generic Add __memcpy_chk assembly for 64 bit. 2014-09-26 12:47:04 -07:00
include/machine Simplify our endian.h implementation. 2014-12-08 20:35:08 -08:00
syscalls Add fchmodat(AT_SYMLINK_NOFOLLOW) and fchmod O_PATH support 2015-02-02 13:17:17 -08:00
arm64.mk Clean up the arm64 setjmp. 2014-12-05 15:05:45 -08:00