1 //===-- dfsan_interceptors.cpp --------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file is a part of DataFlowSanitizer.
11 // Interceptors for standard library functions.
12 //===----------------------------------------------------------------------===//
14 #include "dfsan/dfsan.h"
15 #include "interception/interception.h"
16 #include "sanitizer_common/sanitizer_common.h"
18 using namespace __sanitizer;
20 INTERCEPTOR(void *, mmap, void *addr, SIZE_T length, int prot, int flags,
21 int fd, OFF_T offset) {
22 void *res = REAL(mmap)(addr, length, prot, flags, fd, offset);
24 dfsan_set_label(0, res, RoundUpTo(length, GetPageSize()));
28 INTERCEPTOR(void *, mmap64, void *addr, SIZE_T length, int prot, int flags,
29 int fd, OFF64_T offset) {
30 void *res = REAL(mmap64)(addr, length, prot, flags, fd, offset);
32 dfsan_set_label(0, res, RoundUpTo(length, GetPageSize()));
37 void InitializeInterceptors() {
38 static int inited = 0;
41 INTERCEPT_FUNCTION(mmap);
42 INTERCEPT_FUNCTION(mmap64);
45 } // namespace __dfsan