Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/sys/contrib/openzfs/module/os/linux/zfs/kasan_compat.c
96480 views
1
// SPDX-License-Identifier: CDDL-1.0
2
/*
3
* CDDL HEADER START
4
*
5
* The contents of this file are subject to the terms of the
6
* Common Development and Distribution License (the "License").
7
* You may not use this file except in compliance with the License.
8
*
9
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10
* or https://opensource.org/licenses/CDDL-1.0.
11
* See the License for the specific language governing permissions
12
* and limitations under the License.
13
*
14
* When distributing Covered Code, include this CDDL HEADER in each
15
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16
* If applicable, add the following below this CDDL HEADER, with the
17
* fields enclosed by brackets "[]" replaced with your own identifying
18
* information: Portions Copyright [yyyy] [name of copyright owner]
19
*
20
* CDDL HEADER END
21
*/
22
23
/*
24
* Copyright (c) 2025, Rob Norris <[email protected]>
25
*/
26
27
#ifndef _ZFS_LINUX_KASAN_ENABLED_H
28
#define _ZFS_LINUX_KASAN_ENABLED_H
29
30
#ifdef HAVE_KASAN_ENABLED_GPL_ONLY
31
/*
32
* The kernel supports a runtime setting to enable/disable KASAN. The control
33
* flag kasan_flag_enabled is a GPL-only symbol, which prevents us from
34
* accessing it. Unfortunately, this is called by the header function
35
* kasan_enabled(), which in turn is used to call or skip instrumentation
36
* functions in various header-based kernel facilities. If we inadvertently
37
* call one, the build breaks.
38
*
39
* To work around this, we define our own `kasan_flag_enabled` set to "false",
40
* disabling use of KASAN inside our code. The linker will resolve this symbol
41
* at build time, and so never need to reach out to the off-limits kernel
42
* symbol.
43
*/
44
#include <linux/static_key.h>
45
struct static_key_false kasan_flag_enabled = STATIC_KEY_FALSE_INIT;
46
#endif
47
48
#endif
49
50