mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
mm: Move kasan.h from mm/kasan to include/nuttx/mm
so other parts of the system can use it. Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
+1
-2
@@ -24,13 +24,12 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/mm/kasan.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "kasan.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
+1
-2
@@ -22,6 +22,7 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/mm/kasan.h>
|
||||
#include <nuttx/irq.h>
|
||||
|
||||
#include <assert.h>
|
||||
@@ -30,8 +31,6 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "kasan.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
@@ -1,153 +0,0 @@
|
||||
/****************************************************************************
|
||||
* mm/kasan/kasan.h
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __MM_KASAN_KASAN_H
|
||||
#define __MM_KASAN_KASAN_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_MM_KASAN
|
||||
# define kasan_is_poisoned(addr, size) false
|
||||
# define kasan_poison(addr, size)
|
||||
# define kasan_unpoison(addr, size)
|
||||
# define kasan_register(addr, size)
|
||||
# define kasan_init_early()
|
||||
#else
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: kasan_is_poisoned
|
||||
*
|
||||
* Description:
|
||||
* Check if the memory range is poisoned
|
||||
*
|
||||
* Input Parameters:
|
||||
* addr - range start address
|
||||
* size - range size
|
||||
*
|
||||
* Returned Value:
|
||||
* true if the memory range is poisoned, false otherwise.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
bool kasan_is_poisoned(FAR const void *addr, size_t size);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: kasan_poison
|
||||
*
|
||||
* Description:
|
||||
* Mark the memory range as inaccessible
|
||||
*
|
||||
* Input Parameters:
|
||||
* addr - range start address
|
||||
* size - range size
|
||||
*
|
||||
* Returned Value:
|
||||
* None.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void kasan_poison(FAR const void *addr, size_t size);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: kasan_unpoison
|
||||
*
|
||||
* Description:
|
||||
* Mark the memory range as accessible
|
||||
*
|
||||
* Input Parameters:
|
||||
* addr - range start address
|
||||
* size - range size
|
||||
*
|
||||
* Returned Value:
|
||||
* None.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void kasan_unpoison(FAR const void *addr, size_t size);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: kasan_register
|
||||
*
|
||||
* Description:
|
||||
* Monitor the memory range for invalid access check
|
||||
*
|
||||
* Input Parameters:
|
||||
* addr - range start address
|
||||
* size - range size
|
||||
*
|
||||
* Returned Value:
|
||||
* None.
|
||||
*
|
||||
* Note:
|
||||
* The size is shrinked for the shadow region
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void kasan_register(FAR void *addr, FAR size_t *size);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: kasan_init_early
|
||||
*
|
||||
* Description:
|
||||
* Initialize the kasan early, setup g_region_init variable.
|
||||
* This used for some platfroms clear bss late, and error use kasan before
|
||||
* called kasan_register().
|
||||
*
|
||||
* Input Parameters:
|
||||
* None.
|
||||
*
|
||||
* Returned Value:
|
||||
* None.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void kasan_init_early(void);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_MM_KASAN */
|
||||
|
||||
#endif /* __MM_KASAN_KASAN_H */
|
||||
@@ -31,11 +31,10 @@
|
||||
#include <syslog.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/mm/kasan.h>
|
||||
#include <nuttx/mm/mempool.h>
|
||||
#include <nuttx/sched.h>
|
||||
|
||||
#include "kasan/kasan.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
@@ -32,9 +32,9 @@
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/sched.h>
|
||||
#include <nuttx/mm/mm.h>
|
||||
#include <nuttx/mm/kasan.h>
|
||||
|
||||
#include "mm_heap/mm.h"
|
||||
#include "kasan/kasan.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
|
||||
@@ -31,9 +31,9 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/mm/mm.h>
|
||||
#include <nuttx/mm/kasan.h>
|
||||
|
||||
#include "mm_heap/mm.h"
|
||||
#include "kasan/kasan.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
|
||||
@@ -32,10 +32,10 @@
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/mm/mm.h>
|
||||
#include <nuttx/mm/kasan.h>
|
||||
#include <nuttx/sched.h>
|
||||
|
||||
#include "mm_heap/mm.h"
|
||||
#include "kasan/kasan.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include <nuttx/mm/mm.h>
|
||||
#include <nuttx/mm/kasan.h>
|
||||
|
||||
#include "mm_heap/mm.h"
|
||||
#include "kasan/kasan.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
||||
@@ -33,9 +33,9 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include <nuttx/mm/mm.h>
|
||||
#include <nuttx/mm/kasan.h>
|
||||
|
||||
#include "mm_heap/mm.h"
|
||||
#include "kasan/kasan.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
||||
+1
-2
@@ -40,11 +40,10 @@
|
||||
#include <nuttx/fs/procfs.h>
|
||||
#include <nuttx/mutex.h>
|
||||
#include <nuttx/mm/mm.h>
|
||||
#include <nuttx/sched.h>
|
||||
#include <nuttx/mm/kasan.h>
|
||||
#include <nuttx/mm/mempool.h>
|
||||
|
||||
#include "tlsf/tlsf.h"
|
||||
#include "kasan/kasan.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
|
||||
Reference in New Issue
Block a user