bionic/tests
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
..
libs Minimize calls to mprotect 2015-01-23 16:30:34 -08:00
Android.build.mk Yet another relocation test 2014-11-19 10:39:05 -08:00
Android.mk Merge "Add <error.h>." 2015-01-26 20:38:46 +00:00
arpa_inet_test.cpp Use the NetBSD inet_ntop until the OpenBSD bug is fixed. 2014-05-13 19:17:46 -07:00
atexit_test.cpp Add atexit test for attributed c-tor/d-tor 2014-08-15 14:22:07 -07:00
BionicDeathTest.h make all bionic death tests not dumpable 2014-11-06 11:09:03 -08:00
buffer_tests.cpp Add strcmp/memcmp testing. 2013-12-03 18:42:41 -08:00
buffer_tests.h Add strcmp/memcmp testing. 2013-12-03 18:42:41 -08:00
complex_test.cpp Fix our <complex.h> support. 2014-11-06 11:16:55 -08:00
ctype_test.cpp Upgrade our <ctype.h> implementation to OpenBSD head. 2014-04-18 10:29:16 -07:00
dirent_test.cpp implement missing seekdir and telldir 2014-11-07 10:20:32 -08:00
dl_test.cpp Fix symbol lookup order during relocation 2014-10-31 11:39:51 -07:00
dlext_test.cpp better gtest runner for bionic 2014-12-13 18:53:34 -08:00
dlfcn_test.cpp Minimize calls to mprotect 2015-01-23 16:30:34 -08:00
error_test.cpp Add <error.h>. 2015-01-26 11:57:11 -08:00
eventfd_test.cpp Make sure that the same tests are on all platforms. 2014-02-06 20:12:21 -08:00
fcntl_test.cpp Add posix_fadvise(3). 2014-09-11 08:45:46 -07:00
fenv_test.cpp Upgrade libm. 2013-02-01 14:51:19 -08:00
file-check-cxx Add compile time test infrastructure for bionic. 2014-10-06 11:38:01 -07:00
fortify_sprintf_warnings.cpp Fix compile-time tests for LP64. 2014-10-08 13:21:29 -07:00
fortify_test.cpp make all bionic death tests not dumpable 2014-11-06 11:09:03 -08:00
ftw_test.cpp Make the ftw(3) tests a bit more thorough. 2014-11-19 15:47:53 -08:00
getauxval_test.cpp Move the meat of <features.h> into <sys/cdefs.h>. 2014-08-19 11:18:20 -07:00
getcwd_test.cpp Fix __pthread_clone on ARM to set errno on failure. 2013-02-11 16:39:10 -08:00
gtest_ex.h Rename test_forked -> test_isolated 2014-11-20 22:53:59 -08:00
gtest_main.cpp Add --gtest-filter as synonym for --gtest_filter in bionic gtest main. 2015-01-28 14:28:14 -08:00
inttypes_test.cpp Pull in upstream fixes to reject invalid bases. 2014-09-23 14:53:10 -07:00
libc_logging_test.cpp Add GNU-compatible strerror_r. 2014-08-28 16:37:09 -07:00
libgen_test.cpp Don't expose non-standard basename_r and dirname_r in LP64. 2014-09-08 16:44:48 -07:00
locale_test.cpp Fix newlocale with a NULL locale name. 2014-11-04 18:03:44 -08:00
malloc_test.cpp Implement malloc_info(3). 2014-08-22 10:23:12 -07:00
math_cos_intel_data.h Improve math tests to allow a specific ulp bound. 2014-11-04 18:00:02 -08:00
math_cosf_intel_data.h Improve math tests to allow a specific ulp bound. 2014-11-04 18:00:02 -08:00
math_data_test.h Improve math tests to allow a specific ulp bound. 2014-11-04 18:00:02 -08:00
math_exp_intel_data.h Improve math tests to allow a specific ulp bound. 2014-11-04 18:00:02 -08:00
math_expf_intel_data.h Improve math tests to allow a specific ulp bound. 2014-11-04 18:00:02 -08:00
math_log_intel_data.h Improve math tests to allow a specific ulp bound. 2014-11-04 18:00:02 -08:00
math_logf_intel_data.h Improve math tests to allow a specific ulp bound. 2014-11-04 18:00:02 -08:00
math_pow_intel_data.h Improve math tests to allow a specific ulp bound. 2014-11-04 18:00:02 -08:00
math_powf_intel_data.h Improve math tests to allow a specific ulp bound. 2014-11-04 18:00:02 -08:00
math_sin_intel_data.h Improve math tests to allow a specific ulp bound. 2014-11-04 18:00:02 -08:00
math_sincos_intel_data.h Improve math tests to allow a specific ulp bound. 2014-11-04 18:00:02 -08:00
math_sincosf_intel_data.h Improve math tests to allow a specific ulp bound. 2014-11-04 18:00:02 -08:00
math_sinf_intel_data.h Improve math tests to allow a specific ulp bound. 2014-11-04 18:00:02 -08:00
math_tan_intel_data.h Improve math tests to allow a specific ulp bound. 2014-11-04 18:00:02 -08:00
math_tanf_intel_data.h Improve math tests to allow a specific ulp bound. 2014-11-04 18:00:02 -08:00
math_test.cpp Improve math tests to allow a specific ulp bound. 2014-11-04 18:00:02 -08:00
mntent_test.cpp Fix our <mntent.h> implementation. 2014-11-13 15:51:36 -08:00
netdb_test.cpp Test that ip6-localhost exists in etc/hosts. 2015-01-13 17:30:51 -08:00
pthread_test.cpp Fix possible leak in pthread_detach. 2015-01-15 10:45:25 -08:00
pty_test.cpp Implement <pty.h>. 2014-12-03 15:55:34 -08:00
regex_test.cpp Consistently use #if defined(__BIONIC__) in tests. 2014-05-13 11:19:57 -07:00
sched_test.cpp Consistently use #if defined(__BIONIC__) in tests. 2014-05-13 11:19:57 -07:00
ScopedSignalHandler.h support _POSIX_REALTIME_SIGNALS 2014-12-08 21:52:43 -08:00
search_test.cpp Implement twalk(3), add unit tests. 2014-07-24 14:55:29 -07:00
semaphore_test.cpp Add semaphore tests, fix sem_destroy. 2014-09-19 17:37:06 -07:00
setjmp_test.cpp Add a test for float registers across setjmp/logjmp. 2015-01-26 20:52:34 -08:00
signal_test.cpp support _POSIX_REALTIME_SIGNALS 2014-12-08 21:52:43 -08:00
sstream_test.cpp Improve the <sstream> test. 2014-04-10 20:44:27 -07:00
stack_protector_test.cpp make stack_protector_DeathTest work for gcc4.9 2014-12-11 17:24:55 -08:00
stack_unwinding_test.cpp restore sigprocmask in setjmp/longjmp test. 2014-12-02 10:35:25 -08:00
stdatomic_test.cpp Switch benchmarks and tests to libc++. 2014-09-30 10:28:30 -07:00
stdint_test.cpp Fixed int fast types for LP64 2014-02-21 16:27:21 +00:00
stdio_ext_test.cpp Implement __fsetlocking. 2015-01-21 10:33:30 -08:00
stdio_test.cpp Fix optimized fread. 2015-01-24 12:35:41 -08:00
stdlib_test.cpp Add POSIX lcong48. 2014-11-06 14:14:37 -08:00
string_posix_strerror_r_test.cpp Fix glibc 2.15 build. 2014-11-12 19:31:21 -08:00
string_test.cpp Add align/overread tests for strlcpy/strlcat. 2014-11-10 13:58:17 -08:00
strings_test.cpp Implement all the POSIX _l functions. 2014-11-06 15:52:22 -08:00
stubs_test.cpp fix shared gid support in getpwnam/getgrnam 2014-11-18 19:58:04 -08:00
sys_epoll_test.cpp bionic: make epoll_event structure packed 2014-05-05 19:48:55 -07:00
sys_mman_test.cpp implement posix_madvise 2014-12-04 11:01:28 -08:00
sys_personality_test.cpp Set linux 32bit personality for 32 bit processes 2015-01-07 16:32:05 -08:00
sys_resource_test.cpp Make sys_resource test more robust. 2015-01-16 13:28:43 -08:00
sys_select_test.cpp Include sys/types.h and sys/wait.h for waitpid 2014-04-01 17:42:31 -07:00
sys_sendfile_test.cpp Make sure that the same tests are on all platforms. 2014-02-06 20:12:21 -08:00
sys_socket_test.cpp better gtest runner for bionic 2014-12-13 18:53:34 -08:00
sys_stat_test.cpp Add fchmodat(AT_SYMLINK_NOFOLLOW) and fchmod O_PATH support 2015-02-02 13:17:17 -08:00
sys_statvfs_test.cpp Implement some of the missing LFS64 support. 2014-02-18 15:39:24 -08:00
sys_syscall_test.cpp Add a unit test for syscall(2). 2013-11-13 13:14:31 -08:00
sys_sysinfo_test.cpp Add functions in sysinfo.h. 2014-11-14 16:22:48 -08:00
sys_time_test.cpp Use VDSO for clock_gettime(2) and gettimeofday(2). 2014-07-16 14:27:43 -07:00
sys_types_test.cpp Fix dev_t (for LP64). 2014-01-03 14:49:37 -08:00
sys_vfs_test.cpp Add missing file from previous change. 2014-02-18 15:48:56 -08:00
system_properties_test.cpp make all bionic death tests not dumpable 2014-11-06 11:09:03 -08:00
TemporaryFile.h CLOEXEC support in fdopen, freopen, and mkostemp/mkostemps. 2014-09-23 18:21:52 -07:00
time_test.cpp support _POSIX_CPUTIME 2014-11-26 17:14:50 -08:00
uchar_test.cpp Move the meat of <features.h> into <sys/cdefs.h>. 2014-08-19 11:18:20 -07:00
uniqueptr_test.cpp Load libraries in breadth-first order 2014-09-08 13:02:50 -07:00
unistd_test.cpp Fix pthread key num calculation. 2014-12-12 17:00:08 -08:00
utmp_test.cpp Implement <pty.h>. 2014-12-03 15:55:34 -08:00
wchar_test.cpp Add missing function prototypes wcpcpy/wcpncpy. 2014-11-13 18:56:12 -08:00