platform_bionic/libc/arch-arm
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 Move the generic arm memcmp.S into the generic directory. 2014-12-15 11:06:34 -08:00
cortex-a7 libc/arm: add cortex-a7 cpu variant 2013-03-23 01:38:22 -07:00
cortex-a8 libc/arm: add cortex-a8 cpu variant 2013-05-15 20:13:28 -07:00
cortex-a9 Clean up <stdlib.h> slightly. 2015-01-26 14:28:41 -08:00
cortex-a15 Clean up <stdlib.h> slightly. 2015-01-26 14:28:41 -08:00
denver Move the generic arm memcmp.S into the generic directory. 2014-12-15 11:06:34 -08:00
generic Clean up <stdlib.h> slightly. 2015-01-26 14:28:41 -08:00
include/machine Add ARM_IRELATIVE relocation 2015-01-08 22:22:27 -08:00
krait Clean up <stdlib.h> slightly. 2015-01-26 14:28:41 -08:00
syscalls Add fchmodat(AT_SYMLINK_NOFOLLOW) and fchmod O_PATH support 2015-02-02 13:17:17 -08:00
arm.mk Clean up <stdlib.h> slightly. 2015-01-26 14:28:41 -08:00