Path: blob/main/sys/contrib/openzfs/module/os/linux/zfs/kasan_compat.c
96480 views
// SPDX-License-Identifier: CDDL-1.01/*2* CDDL HEADER START3*4* The contents of this file are subject to the terms of the5* Common Development and Distribution License (the "License").6* You may not use this file except in compliance with the License.7*8* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE9* or https://opensource.org/licenses/CDDL-1.0.10* See the License for the specific language governing permissions11* and limitations under the License.12*13* When distributing Covered Code, include this CDDL HEADER in each14* file and include the License file at usr/src/OPENSOLARIS.LICENSE.15* If applicable, add the following below this CDDL HEADER, with the16* fields enclosed by brackets "[]" replaced with your own identifying17* information: Portions Copyright [yyyy] [name of copyright owner]18*19* CDDL HEADER END20*/2122/*23* Copyright (c) 2025, Rob Norris <[email protected]>24*/2526#ifndef _ZFS_LINUX_KASAN_ENABLED_H27#define _ZFS_LINUX_KASAN_ENABLED_H2829#ifdef HAVE_KASAN_ENABLED_GPL_ONLY30/*31* The kernel supports a runtime setting to enable/disable KASAN. The control32* flag kasan_flag_enabled is a GPL-only symbol, which prevents us from33* accessing it. Unfortunately, this is called by the header function34* kasan_enabled(), which in turn is used to call or skip instrumentation35* functions in various header-based kernel facilities. If we inadvertently36* call one, the build breaks.37*38* To work around this, we define our own `kasan_flag_enabled` set to "false",39* disabling use of KASAN inside our code. The linker will resolve this symbol40* at build time, and so never need to reach out to the off-limits kernel41* symbol.42*/43#include <linux/static_key.h>44struct static_key_false kasan_flag_enabled = STATIC_KEY_FALSE_INIT;45#endif4647#endif484950