Skip to content

Commit c84f261

Browse files
committed
[compiler-rt][rtsan] chroot interception.
1 parent 585b75e commit c84f261

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ INTERCEPTOR(int, fchdir, int fd) {
254254
return REAL(fchdir)(fd);
255255
}
256256

257+
INTERCEPTOR(int, chroot, const char *path) {
258+
__rtsan_notify_intercepted_call("chroot");
259+
return REAL(chroot)(path);
260+
}
261+
257262
// Streams
258263

259264
INTERCEPTOR(FILE *, fopen, const char *path, const char *mode) {
@@ -1402,6 +1407,7 @@ void __rtsan::InitializeInterceptors() {
14021407
INTERCEPT_FUNCTION(close);
14031408
INTERCEPT_FUNCTION(chdir);
14041409
INTERCEPT_FUNCTION(fchdir);
1410+
INTERCEPT_FUNCTION(chroot);
14051411
INTERCEPT_FUNCTION(fopen);
14061412
RTSAN_MAYBE_INTERCEPT_FOPEN64;
14071413
RTSAN_MAYBE_INTERCEPT_FREOPEN64;

compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,12 @@ TEST(TestRtsanInterceptors, FchdirDiesWhenRealtime) {
457457
ExpectNonRealtimeSurvival(Func);
458458
}
459459

460+
TEST(TestRtsanInterceptors, ChrootDiesWhenRealtime) {
461+
auto Func = []() { chroot("."); };
462+
ExpectRealtimeDeath(Func, "chroot");
463+
ExpectNonRealtimeSurvival(Func);
464+
}
465+
460466
TEST_F(RtsanFileTest, FopenDiesWhenRealtime) {
461467
auto Func = [this]() {
462468
FILE *f = fopen(GetTemporaryFilePath(), "w");

0 commit comments

Comments
 (0)