diff options
| author | Kamil Rytarowski <n54@gmx.com> | 2018-01-18 11:17:35 +0000 |
|---|---|---|
| committer | Kamil Rytarowski <n54@gmx.com> | 2018-01-18 11:17:35 +0000 |
| commit | 878469cd829757a27fbdca8bc7ce1ca3a8cbd29e (patch) | |
| tree | 1ed5f039bcc9315e83b17ffe2db8db1bdb379537 /compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc | |
| parent | 8872d703ad64fb2c01ed6124f181662562c037b8 (diff) | |
| download | bcm5719-llvm-878469cd829757a27fbdca8bc7ce1ca3a8cbd29e.tar.gz bcm5719-llvm-878469cd829757a27fbdca8bc7ce1ca3a8cbd29e.zip | |
Add new NetBSD interceptors: getgrouplist(3) & getgroupmembership(3)
Summary:
getgrouplist, getgroupmembership -- calculate group access list
Sponsored by <The NetBSD Foundation>
Reviewers: vitalybuka, joerg
Reviewed By: vitalybuka
Subscribers: llvm-commits, kubamracek, #sanitizers
Tags: #sanitizers
Differential Revision: https://reviews.llvm.org/D42064
llvm-svn: 322836
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc')
| -rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc index 71e6aa8e342..f74aff77453 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -6566,6 +6566,46 @@ INTERCEPTOR(int, faccessat, int fd, const char *path, int mode, int flags) { #define INIT_FACCESSAT #endif +#if SANITIZER_INTERCEPT_GETGROUPLIST +INTERCEPTOR(int, getgrouplist, const char *name, u32 basegid, u32 *groups, + int *ngroups) { + void *ctx; + int res; + COMMON_INTERCEPTOR_ENTER(ctx, getgrouplist, name, basegid, groups, ngroups); + if (name) + COMMON_INTERCEPTOR_READ_RANGE(ctx, name, REAL(strlen)(name) + 1); + if (ngroups) + COMMON_INTERCEPTOR_READ_RANGE(ctx, ngroups, sizeof(*ngroups)); + res = REAL(getgrouplist)(name, basegid, groups, ngroups); + if (!res && groups && ngroups) { + COMMON_INTERCEPTOR_WRITE_RANGE(ctx, groups, sizeof(*groups) * (*ngroups)); + COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ngroups, sizeof(*ngroups)); + } + return res; +} + +INTERCEPTOR(int, getgroupmembership, const char *name, u32 basegid, u32 *groups, + int maxgrp, int *ngroups) { + void *ctx; + int res; + COMMON_INTERCEPTOR_ENTER(ctx, getgroupmembership, name, basegid, groups, maxgrp, ngroups); + if (name) + COMMON_INTERCEPTOR_READ_RANGE(ctx, name, REAL(strlen)(name) + 1); + res = REAL(getgroupmembership)(name, basegid, groups, maxgrp, ngroups); + if (!res && groups && ngroups) { + COMMON_INTERCEPTOR_WRITE_RANGE(ctx, groups, sizeof(*groups) * (*ngroups)); + COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ngroups, sizeof(*ngroups)); + } + return res; +} + +#define INIT_GETGROUPLIST \ + COMMON_INTERCEPT_FUNCTION(getgrouplist); \ + COMMON_INTERCEPT_FUNCTION(getgroupmembership); +#else +#define INIT_GETGROUPLIST +#endif + static void InitializeCommonInterceptors() { static u64 metadata_mem[sizeof(MetadataHashMap) / sizeof(u64) + 1]; interceptor_metadata_map = new((void *)&metadata_mem) MetadataHashMap(); @@ -6784,6 +6824,7 @@ static void InitializeCommonInterceptors() { INIT_GID_FROM_GROUP; INIT_ACCESS; INIT_FACCESSAT; + INIT_GETGROUPLIST; #if SANITIZER_NETBSD COMMON_INTERCEPT_FUNCTION(__libc_mutex_lock); |

