staticinlinebool kasan_sample_page_alloc(unsignedint order)
{ /* Fast-path for when sampling is disabled. */ if (kasan_page_alloc_sample == 1) returntrue;
if (order < kasan_page_alloc_sample_order) returntrue;
/* * Generic KASAN uses per-object metadata to store alloc and free stack traces * and the quarantine link.
*/ staticinlinebool kasan_requires_meta(void)
{ returntrue;
}
#else/* CONFIG_KASAN_GENERIC */
/* * Tag-based KASAN modes do not use per-object metadata: they use the stack * ring to store alloc and free stack traces and do not use qurantine.
*/ staticinlinebool kasan_requires_meta(void)
{ returnfalse;
}
struct kasan_report_info { /* Filled in by kasan_report_*(). */ enum kasan_report_type type; constvoid *access_addr;
size_t access_size; bool is_write; unsignedlong ip;
/* Filled in by the common reporting code. */ constvoid *first_bad_addr; struct kmem_cache *cache; void *object;
size_t alloc_size;
/* Filled in by the mode-specific reporting code. */ constchar *bug_type; struct kasan_track alloc_track; struct kasan_track free_track;
};
/* Do not change the struct layout: compiler ABI. */ struct kasan_source_location { constchar *filename; int line_no; int column_no;
};
/* Do not change the struct layout: compiler ABI. */ struct kasan_global { constvoid *beg; /* Address of the beginning of the global variable. */
size_t size; /* Size of the global variable. */
size_t size_with_redzone; /* Size of the variable + size of the redzone. 32 bytes aligned. */ constvoid *name; constvoid *module_name; /* Name of the module where the global variable is declared. */ unsignedlong has_dynamic_init; /* This is needed for C++. */ #if KASAN_ABI_VERSION >= 4 struct kasan_source_location *location; #endif #if KASAN_ABI_VERSION >= 5 char *odr_indicator; #endif
};
/* Structures for keeping alloc and free meta. */
#ifdef CONFIG_KASAN_GENERIC
/* * Alloc meta contains the allocation-related information about a slab object. * Alloc meta is saved when an object is allocated and is kept until either the * object returns to the slab freelist (leaves quarantine for quarantined * objects or gets freed for the non-quarantined ones) or reallocated via * krealloc or through a mempool. * Alloc meta is stored inside of the object's redzone. * Alloc meta is considered valid whenever it contains non-zero data.
*/ struct kasan_alloc_meta { struct kasan_track alloc_track; /* Free track is stored in kasan_free_meta. */
depot_stack_handle_t aux_stack[2];
};
struct qlist_node { struct qlist_node *next;
};
/* * Free meta is stored either in the object itself or in the redzone after the * object. In the former case, free meta offset is 0. In the latter case, the * offset is between 0 and INT_MAX. INT_MAX marks that free meta is not present.
*/ #define KASAN_NO_FREE_META INT_MAX
/* * Free meta contains the freeing-related information about a slab object. * Free meta is only kept for quarantined objects and for mempool objects until * the object gets allocated again. * Free meta is stored within the object's memory. * Free meta is considered valid whenever the value of the shadow byte that * corresponds to the first 8 bytes of the object is KASAN_SLAB_FREE_META.
*/ struct kasan_free_meta { struct qlist_node quarantine_link; struct kasan_track free_track;
};
/** * kasan_poison - mark the memory range as inaccessible * @addr: range start address, must be aligned to KASAN_GRANULE_SIZE * @size: range size, must be aligned to KASAN_GRANULE_SIZE * @value: value that's written to metadata for the range * @init: whether to initialize the memory range (only for hardware tag-based)
*/ void kasan_poison(constvoid *addr, size_t size, u8 value, bool init);
/** * kasan_unpoison - mark the memory range as accessible * @addr: range start address, must be aligned to KASAN_GRANULE_SIZE * @size: range size, can be unaligned * @init: whether to initialize the memory range (only for hardware tag-based) * * For the tag-based modes, the @size gets aligned to KASAN_GRANULE_SIZE before * marking the range. * For the generic mode, the last granule of the memory range gets partially * unpoisoned based on the @size.
*/ void kasan_unpoison(constvoid *addr, size_t size, bool init);
bool kasan_byte_accessible(constvoid *addr);
#endif/* CONFIG_KASAN_HW_TAGS */
#ifdef CONFIG_KASAN_GENERIC
/** * kasan_poison_last_granule - mark the last granule of the memory range as * inaccessible * @address: range start address, must be aligned to KASAN_GRANULE_SIZE * @size: range size * * This function is only available for the generic mode, as it's the only mode * that has partially poisoned memory granules.
*/ void kasan_poison_last_granule(constvoid *address, size_t size);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.