Commit 88b86597 authored by Andrey Konovalov's avatar Andrey Konovalov Committed by Linus Torvalds

kasan: rename SHADOW layout macros to META

This is a preparatory commit for the upcoming addition of a new hardware
tag-based (MTE-based) KASAN mode.

Hardware tag-based KASAN won't be using shadow memory, but will reuse
these macros.  Rename "SHADOW" to implementation-neutral "META".

No functional changes.

Link: https://lkml.kernel.org/r/f96244ec59dc17db35173ec352c5592b14aefaf8.1606161801.git.andreyknvl@google.comSigned-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
Signed-off-by: default avatarVincenzo Frascino <vincenzo.frascino@arm.com>
Reviewed-by: default avatarMarco Elver <elver@google.com>
Reviewed-by: default avatarAlexander Potapenko <glider@google.com>
Tested-by: default avatarVincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Branislav Rankov <Branislav.Rankov@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Evgenii Stepanov <eugenis@google.com>
Cc: Kevin Brodsky <kevin.brodsky@arm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent db3de8f7
...@@ -33,11 +33,11 @@ ...@@ -33,11 +33,11 @@
#include "kasan.h" #include "kasan.h"
#include "../slab.h" #include "../slab.h"
/* Shadow layout customization. */ /* Metadata layout customization. */
#define SHADOW_BYTES_PER_BLOCK 1 #define META_BYTES_PER_BLOCK 1
#define SHADOW_BLOCKS_PER_ROW 16 #define META_BLOCKS_PER_ROW 16
#define SHADOW_BYTES_PER_ROW (SHADOW_BLOCKS_PER_ROW * SHADOW_BYTES_PER_BLOCK) #define META_BYTES_PER_ROW (META_BLOCKS_PER_ROW * META_BYTES_PER_BLOCK)
#define SHADOW_ROWS_AROUND_ADDR 2 #define META_ROWS_AROUND_ADDR 2
static unsigned long kasan_flags; static unsigned long kasan_flags;
...@@ -240,7 +240,7 @@ static void print_address_description(void *addr, u8 tag) ...@@ -240,7 +240,7 @@ static void print_address_description(void *addr, u8 tag)
static bool row_is_guilty(const void *row, const void *guilty) static bool row_is_guilty(const void *row, const void *guilty)
{ {
return (row <= guilty) && (guilty < row + SHADOW_BYTES_PER_ROW); return (row <= guilty) && (guilty < row + META_BYTES_PER_ROW);
} }
static int shadow_pointer_offset(const void *row, const void *shadow) static int shadow_pointer_offset(const void *row, const void *shadow)
...@@ -249,7 +249,7 @@ static int shadow_pointer_offset(const void *row, const void *shadow) ...@@ -249,7 +249,7 @@ static int shadow_pointer_offset(const void *row, const void *shadow)
* 3 + (BITS_PER_LONG/8)*2 chars. * 3 + (BITS_PER_LONG/8)*2 chars.
*/ */
return 3 + (BITS_PER_LONG/8)*2 + (shadow - row)*2 + return 3 + (BITS_PER_LONG/8)*2 + (shadow - row)*2 +
(shadow - row) / SHADOW_BYTES_PER_BLOCK + 1; (shadow - row) / META_BYTES_PER_BLOCK + 1;
} }
static void print_memory_metadata(const void *addr) static void print_memory_metadata(const void *addr)
...@@ -259,15 +259,15 @@ static void print_memory_metadata(const void *addr) ...@@ -259,15 +259,15 @@ static void print_memory_metadata(const void *addr)
const void *shadow_row; const void *shadow_row;
shadow_row = (void *)round_down((unsigned long)shadow, shadow_row = (void *)round_down((unsigned long)shadow,
SHADOW_BYTES_PER_ROW) META_BYTES_PER_ROW)
- SHADOW_ROWS_AROUND_ADDR * SHADOW_BYTES_PER_ROW; - META_ROWS_AROUND_ADDR * META_BYTES_PER_ROW;
pr_err("Memory state around the buggy address:\n"); pr_err("Memory state around the buggy address:\n");
for (i = -SHADOW_ROWS_AROUND_ADDR; i <= SHADOW_ROWS_AROUND_ADDR; i++) { for (i = -META_ROWS_AROUND_ADDR; i <= META_ROWS_AROUND_ADDR; i++) {
const void *kaddr = kasan_shadow_to_mem(shadow_row); const void *kaddr = kasan_shadow_to_mem(shadow_row);
char buffer[4 + (BITS_PER_LONG/8)*2]; char buffer[4 + (BITS_PER_LONG/8)*2];
char shadow_buf[SHADOW_BYTES_PER_ROW]; char shadow_buf[META_BYTES_PER_ROW];
snprintf(buffer, sizeof(buffer), snprintf(buffer, sizeof(buffer),
(i == 0) ? ">%px: " : " %px: ", kaddr); (i == 0) ? ">%px: " : " %px: ", kaddr);
...@@ -276,17 +276,17 @@ static void print_memory_metadata(const void *addr) ...@@ -276,17 +276,17 @@ static void print_memory_metadata(const void *addr)
* function, because generic functions may try to * function, because generic functions may try to
* access kasan mapping for the passed address. * access kasan mapping for the passed address.
*/ */
memcpy(shadow_buf, shadow_row, SHADOW_BYTES_PER_ROW); memcpy(shadow_buf, shadow_row, META_BYTES_PER_ROW);
print_hex_dump(KERN_ERR, buffer, print_hex_dump(KERN_ERR, buffer,
DUMP_PREFIX_NONE, SHADOW_BYTES_PER_ROW, 1, DUMP_PREFIX_NONE, META_BYTES_PER_ROW, 1,
shadow_buf, SHADOW_BYTES_PER_ROW, 0); shadow_buf, META_BYTES_PER_ROW, 0);
if (row_is_guilty(shadow_row, shadow)) if (row_is_guilty(shadow_row, shadow))
pr_err("%*c\n", pr_err("%*c\n",
shadow_pointer_offset(shadow_row, shadow), shadow_pointer_offset(shadow_row, shadow),
'^'); '^');
shadow_row += SHADOW_BYTES_PER_ROW; shadow_row += META_BYTES_PER_ROW;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment