kasan: use kasan_addr_to_slab in print_address_description
Use the kasan_addr_to_slab() helper in print_address_description() instead of separately invoking PageSlab() and page_slab(). Link: https://lkml.kernel.org/r/8b744fbf8c3c7fc5d34329ec70b60ee5c8dba66c.1662411799.git.andreyknvl@google.com Signed-off-by: Andrey Konovalov <andreyknvl@google.com> Reviewed-by: Marco Elver <elver@google.com> Cc: Alexander Potapenko <glider@google.com> Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Evgenii Stepanov <eugenis@google.com> Cc: Peter Collingbourne <pcc@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
2c9fb1fd1d
commit
0f282f15dc
|
@ -30,6 +30,13 @@
|
|||
#include "kasan.h"
|
||||
#include "../slab.h"
|
||||
|
||||
struct slab *kasan_addr_to_slab(const void *addr)
|
||||
{
|
||||
if (virt_addr_valid(addr))
|
||||
return virt_to_slab(addr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
depot_stack_handle_t kasan_save_stack(gfp_t flags, bool can_alloc)
|
||||
{
|
||||
unsigned long entries[KASAN_STACK_DEPTH];
|
||||
|
|
|
@ -213,13 +213,6 @@ struct page *kasan_addr_to_page(const void *addr)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct slab *kasan_addr_to_slab(const void *addr)
|
||||
{
|
||||
if (virt_addr_valid(addr))
|
||||
return virt_to_slab(addr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void describe_object_addr(struct kmem_cache *cache, void *object,
|
||||
const void *addr)
|
||||
{
|
||||
|
@ -297,12 +290,12 @@ static inline bool init_task_stack_addr(const void *addr)
|
|||
static void print_address_description(void *addr, u8 tag)
|
||||
{
|
||||
struct page *page = kasan_addr_to_page(addr);
|
||||
struct slab *slab = kasan_addr_to_slab(addr);
|
||||
|
||||
dump_stack_lvl(KERN_ERR);
|
||||
pr_err("\n");
|
||||
|
||||
if (page && PageSlab(page)) {
|
||||
struct slab *slab = page_slab(page);
|
||||
if (slab) {
|
||||
struct kmem_cache *cache = slab->slab_cache;
|
||||
void *object = nearest_obj(cache, slab, addr);
|
||||
|
||||
|
|
Loading…
Reference in New Issue