[PATCH] D55714: [Sanitizer] capsicum variadic api subset
David CARLIER via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 14 10:54:42 PST 2018
devnexen created this revision.
devnexen added reviewers: markj, vitalybuka.
devnexen created this object with visibility "All Users".
Herald added subscribers: Sanitizers, llvm-commits, kubamracek, emaste.
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D55714
Files:
lib/sanitizer_common/sanitizer_common_interceptors.inc
test/sanitizer_common/TestCases/FreeBSD/capsicum.cc
Index: test/sanitizer_common/TestCases/FreeBSD/capsicum.cc
===================================================================
--- test/sanitizer_common/TestCases/FreeBSD/capsicum.cc
+++ test/sanitizer_common/TestCases/FreeBSD/capsicum.cc
@@ -49,6 +49,10 @@
rv = cap_rights_get(STDIN_FILENO, &grights);
assert(rv == 0);
assert(memcmp(&grights, &rights, sizeof(grights)) == 0);
+ cap_rights_t *iptr = cap_rights_set(&rights, CAP_IOCTL);
+ assert(iptr);
+ cap_rights_t *eptr = cap_rights_clear(&rights, CAP_READ);
+ assert(eptr);
printf("rights test: %d\n", rv);
}
Index: lib/sanitizer_common/sanitizer_common_interceptors.inc
===================================================================
--- lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -7844,6 +7844,60 @@
#endif
#if SANITIZER_INTERCEPT_CAPSICUM
+#define CAP_RIGHTS_INIT_INTERCEPTOR(cap_rights_init, rights,...) \
+ { \
+ void *ctx; \
+ COMMON_INTERCEPTOR_ENTER(ctx, cap_rights_init, rights, ##__VA_ARGS__); \
+ if (rights) \
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, rights, sizeof(*rights)); \
+ __sanitizer_cap_rights_t *ret = \
+ REAL(cap_rights_init)(rights, ##__VA_ARGS__); \
+ if (ret) \
+ COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, sizeof(*ret)); \
+ return ret; \
+ }
+
+#define CAP_RIGHTS_SET_INTERCEPTOR(cap_rights_set, rights, ...) \
+ { \
+ void *ctx; \
+ COMMON_INTERCEPTOR_ENTER(ctx, cap_rights_set, rights, ##__VA_ARGS__); \
+ if (rights) \
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, rights, sizeof(*rights)); \
+ __sanitizer_cap_rights_t *ret = \
+ REAL(cap_rights_set)(rights, ##__VA_ARGS__); \
+ if (ret) \
+ COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, sizeof(*ret)); \
+ return ret; \
+ }
+
+#define CAP_RIGHTS_CLEAR_INTERCEPTOR(cap_rights_clear, rights, ...) \
+ { \
+ void *ctx; \
+ COMMON_INTERCEPTOR_ENTER(ctx, cap_rights_clear, rights, ##__VA_ARGS__); \
+ if (rights) \
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, rights, sizeof(*rights)); \
+ __sanitizer_cap_rights_t *ret = \
+ REAL(cap_rights_clear)(rights, ##__VA_ARGS__); \
+ if (ret) \
+ COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, sizeof(*ret)); \
+ return ret; \
+ }
+
+INTERCEPTOR(__sanitizer_cap_rights_t *, cap_rights_init,
+ __sanitizer_cap_rights_t *rights) {
+ CAP_RIGHTS_INIT_INTERCEPTOR(cap_rights_init, rights);
+}
+
+INTERCEPTOR(__sanitizer_cap_rights_t *, cap_rights_set,
+ __sanitizer_cap_rights_t *rights) {
+ CAP_RIGHTS_SET_INTERCEPTOR(cap_rights_set, rights);
+}
+
+INTERCEPTOR(__sanitizer_cap_rights_t *, cap_rights_clear,
+ __sanitizer_cap_rights_t *rights) {
+ CAP_RIGHTS_CLEAR_INTERCEPTOR(cap_rights_clear, rights);
+}
+
INTERCEPTOR(int, cap_rights_limit, int fd,
const __sanitizer_cap_rights_t *rights) {
void *ctx;
@@ -7932,6 +7986,9 @@
return ret;
}
#define INIT_CAPSICUM \
+ COMMON_INTERCEPT_FUNCTION(cap_rights_init); \
+ COMMON_INTERCEPT_FUNCTION(cap_rights_set); \
+ COMMON_INTERCEPT_FUNCTION(cap_rights_clear); \
COMMON_INTERCEPT_FUNCTION(cap_rights_get); \
COMMON_INTERCEPT_FUNCTION(cap_rights_limit); \
COMMON_INTERCEPT_FUNCTION(cap_rights_contains); \
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55714.178255.patch
Type: text/x-patch
Size: 4502 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181214/7decba3f/attachment.bin>
More information about the llvm-commits
mailing list