The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
lsan.h
Go to the documentation of this file.
1#pragma once
2/*
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16 */
17
18/** Integration with the leak sanitizer interface
19 *
20 * @file src/lib/util/lsan.h
21 *
22 * @copyright 2018 The FreeRADIUS server project
23 */
24RCSIDH(lsan_h, "$Id: 5ea10c942b87fb041a7b3daa4f1d15d030e4b5c6 $")
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/*
31 * clangd doesn't inherit all the implicit includes of clang.
32 */
33#ifdef __clangd__
34# undef HAVE_SANITIZER_LSAN_INTERFACE_H
35#endif
36
37/*
38 * Include both ASAN and LSAN headers if they're defined.
39 */
40#ifdef HAVE_SANITIZER_LSAN_INTERFACE_H
41# include <sanitizer/lsan_interface.h>
42# include <sanitizer/asan_interface.h>
43
44/*
45 * Run code in an "LSAN disabled" context.
46 */
47# define LSAN_DISABLE(_x) __lsan_disable(); _x; __lsan_enable()
48
49#elif defined(FR_ASAN_HARDEN)
50/*
51 * Manually wiping memory isn't as good as ASAN, but it can be
52 * done at the byte level. ASAN poisoning is done on 8 byte
53 * boundaries.
54 */
55# define ASAN_POISON_MEMORY_REGION(_start, _end) memset((_start), 0x00, (_end))
56# define ASAN_UNPOISON_MEMORY_REGION(_start, _end)
57# define LSAN_DISABLE(_x) _x
58#else
59/*
60 * Nothing available, don't use any of the ASAN / LSAN features.
61 */
62# define ASAN_POISON_MEMORY_REGION(_start, _size)
63# define ASAN_UNPOISON_MEMORY_REGION(_start, _size)
64# define LSAN_DISABLE(_x) _x
65#endif
66
67#ifdef __cplusplus
68}
69#endif
#define RCSIDH(h, id)
Definition build.h:513