* [PATCH 0/2] kasan: a few cleanups
@ 2018-01-11 15:29 Andrey Konovalov
2018-01-11 15:29 ` [PATCH 1/2] kasan: fix prototype author email address Andrey Konovalov
2018-01-11 15:29 ` [PATCH 2/2] kasan: clean up KASAN_SHADOW_SCALE_SHIFT usage Andrey Konovalov
0 siblings, 2 replies; 6+ messages in thread
From: Andrey Konovalov @ 2018-01-11 15:29 UTC (permalink / raw)
To: Andrey Ryabinin, Alexander Potapenko, Dmitry Vyukov,
Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
H . Peter Anvin, kasan-dev, linux-mm, linux-arm-kernel, x86,
linux-kernel
Cc: Kostya Serebryany, Andrey Konovalov
Clean up usage of KASAN_SHADOW_SCALE_SHIFT and fix prototype author email
address.
Andrey Konovalov (2):
kasan: fix prototype author email address
kasan: clean up KASAN_SHADOW_SCALE_SHIFT usage
arch/arm64/include/asm/kasan.h | 3 ++-
arch/arm64/include/asm/memory.h | 3 ++-
arch/arm64/mm/kasan_init.c | 3 ++-
arch/x86/include/asm/kasan.h | 8 ++++++--
include/linux/kasan.h | 2 --
mm/kasan/kasan.c | 2 +-
mm/kasan/report.c | 2 +-
7 files changed, 14 insertions(+), 9 deletions(-)
--
2.16.0.rc1.238.g530d649a79-goog
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] kasan: fix prototype author email address
2018-01-11 15:29 [PATCH 0/2] kasan: a few cleanups Andrey Konovalov
@ 2018-01-11 15:29 ` Andrey Konovalov
2018-01-11 15:29 ` [PATCH 2/2] kasan: clean up KASAN_SHADOW_SCALE_SHIFT usage Andrey Konovalov
1 sibling, 0 replies; 6+ messages in thread
From: Andrey Konovalov @ 2018-01-11 15:29 UTC (permalink / raw)
To: Andrey Ryabinin, Alexander Potapenko, Dmitry Vyukov,
Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
H . Peter Anvin, kasan-dev, linux-mm, linux-arm-kernel, x86,
linux-kernel
Cc: Kostya Serebryany, Andrey Konovalov
Use the new one.
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
---
mm/kasan/kasan.c | 2 +-
mm/kasan/report.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
index 405bba487df5..cb4065f31f7f 100644
--- a/mm/kasan/kasan.c
+++ b/mm/kasan/kasan.c
@@ -5,7 +5,7 @@
* Author: Andrey Ryabinin <ryabinin.a.a@gmail.com>
*
* Some code borrowed from https://github.com/xairy/kasan-prototype by
- * Andrey Konovalov <adech.fo@gmail.com>
+ * Andrey Konovalov <andreyknvl@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
diff --git a/mm/kasan/report.c b/mm/kasan/report.c
index 410c8235e671..eee796a005ac 100644
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -5,7 +5,7 @@
* Author: Andrey Ryabinin <ryabinin.a.a@gmail.com>
*
* Some code borrowed from https://github.com/xairy/kasan-prototype by
- * Andrey Konovalov <adech.fo@gmail.com>
+ * Andrey Konovalov <andreyknvl@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
--
2.16.0.rc1.238.g530d649a79-goog
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] kasan: clean up KASAN_SHADOW_SCALE_SHIFT usage
2018-01-11 15:29 [PATCH 0/2] kasan: a few cleanups Andrey Konovalov
2018-01-11 15:29 ` [PATCH 1/2] kasan: fix prototype author email address Andrey Konovalov
@ 2018-01-11 15:29 ` Andrey Konovalov
2018-01-11 17:33 ` Will Deacon
2018-01-11 21:59 ` Andrey Ryabinin
1 sibling, 2 replies; 6+ messages in thread
From: Andrey Konovalov @ 2018-01-11 15:29 UTC (permalink / raw)
To: Andrey Ryabinin, Alexander Potapenko, Dmitry Vyukov,
Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
H . Peter Anvin, kasan-dev, linux-mm, linux-arm-kernel, x86,
linux-kernel
Cc: Kostya Serebryany, Andrey Konovalov
Right now the fact that KASAN uses a single shadow byte for 8 bytes of
memory is scattered all over the code.
This change defines KASAN_SHADOW_SCALE_SHIFT early in asm include files
and makes use of this constant where necessary.
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
---
arch/arm64/include/asm/kasan.h | 3 ++-
arch/arm64/include/asm/memory.h | 3 ++-
arch/arm64/mm/kasan_init.c | 3 ++-
arch/x86/include/asm/kasan.h | 8 ++++++--
include/linux/kasan.h | 2 --
5 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/arch/arm64/include/asm/kasan.h b/arch/arm64/include/asm/kasan.h
index e266f80e45b7..811643fe7640 100644
--- a/arch/arm64/include/asm/kasan.h
+++ b/arch/arm64/include/asm/kasan.h
@@ -27,7 +27,8 @@
* should satisfy the following equation:
* KASAN_SHADOW_OFFSET = KASAN_SHADOW_END - (1ULL << 61)
*/
-#define KASAN_SHADOW_OFFSET (KASAN_SHADOW_END - (1ULL << (64 - 3)))
+#define KASAN_SHADOW_OFFSET (KASAN_SHADOW_END - (1ULL << \
+ (64 - KASAN_SHADOW_SCALE_SHIFT)))
void kasan_init(void);
void kasan_copy_shadow(pgd_t *pgdir);
diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index d4bae7d6e0d8..50fa96a49792 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -85,7 +85,8 @@
* stack size when KASAN is in use.
*/
#ifdef CONFIG_KASAN
-#define KASAN_SHADOW_SIZE (UL(1) << (VA_BITS - 3))
+#define KASAN_SHADOW_SCALE_SHIFT 3
+#define KASAN_SHADOW_SIZE (UL(1) << (VA_BITS - KASAN_SHADOW_SCALE_SHIFT))
#define KASAN_THREAD_SHIFT 1
#else
#define KASAN_SHADOW_SIZE (0)
diff --git a/arch/arm64/mm/kasan_init.c b/arch/arm64/mm/kasan_init.c
index acba49fb5aac..6e02e6fb4c7b 100644
--- a/arch/arm64/mm/kasan_init.c
+++ b/arch/arm64/mm/kasan_init.c
@@ -135,7 +135,8 @@ static void __init kasan_pgd_populate(unsigned long addr, unsigned long end,
/* The early shadow maps everything to a single page of zeroes */
asmlinkage void __init kasan_early_init(void)
{
- BUILD_BUG_ON(KASAN_SHADOW_OFFSET != KASAN_SHADOW_END - (1UL << 61));
+ BUILD_BUG_ON(KASAN_SHADOW_OFFSET !=
+ KASAN_SHADOW_END - (1UL << (64 - KASAN_SHADOW_SCALE_SHIFT)));
BUILD_BUG_ON(!IS_ALIGNED(KASAN_SHADOW_START, PGDIR_SIZE));
BUILD_BUG_ON(!IS_ALIGNED(KASAN_SHADOW_END, PGDIR_SIZE));
kasan_pgd_populate(KASAN_SHADOW_START, KASAN_SHADOW_END, NUMA_NO_NODE,
diff --git a/arch/x86/include/asm/kasan.h b/arch/x86/include/asm/kasan.h
index b577dd0916aa..737b7ea9bea3 100644
--- a/arch/x86/include/asm/kasan.h
+++ b/arch/x86/include/asm/kasan.h
@@ -4,6 +4,7 @@
#include <linux/const.h>
#define KASAN_SHADOW_OFFSET _AC(CONFIG_KASAN_SHADOW_OFFSET, UL)
+#define KASAN_SHADOW_SCALE_SHIFT 3
/*
* Compiler uses shadow offset assuming that addresses start
@@ -12,12 +13,15 @@
* 'kernel address space start' >> KASAN_SHADOW_SCALE_SHIFT
*/
#define KASAN_SHADOW_START (KASAN_SHADOW_OFFSET + \
- ((-1UL << __VIRTUAL_MASK_SHIFT) >> 3))
+ ((-1UL << __VIRTUAL_MASK_SHIFT) >> \
+ KASAN_SHADOW_SCALE_SHIFT))
/*
* 47 bits for kernel address -> (47 - 3) bits for shadow
* 56 bits for kernel address -> (56 - 3) bits for shadow
*/
-#define KASAN_SHADOW_END (KASAN_SHADOW_START + (1ULL << (__VIRTUAL_MASK_SHIFT - 3)))
+#define KASAN_SHADOW_END (KASAN_SHADOW_START + \
+ (1ULL << (__VIRTUAL_MASK_SHIFT - \
+ KASAN_SHADOW_SCALE_SHIFT)))
#ifndef __ASSEMBLY__
diff --git a/include/linux/kasan.h b/include/linux/kasan.h
index e3eb834c9a35..e9eaa964473a 100644
--- a/include/linux/kasan.h
+++ b/include/linux/kasan.h
@@ -11,8 +11,6 @@ struct task_struct;
#ifdef CONFIG_KASAN
-#define KASAN_SHADOW_SCALE_SHIFT 3
-
#include <asm/kasan.h>
#include <asm/pgtable.h>
--
2.16.0.rc1.238.g530d649a79-goog
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] kasan: clean up KASAN_SHADOW_SCALE_SHIFT usage
2018-01-11 15:29 ` [PATCH 2/2] kasan: clean up KASAN_SHADOW_SCALE_SHIFT usage Andrey Konovalov
@ 2018-01-11 17:33 ` Will Deacon
2018-01-11 21:59 ` Andrey Ryabinin
1 sibling, 0 replies; 6+ messages in thread
From: Will Deacon @ 2018-01-11 17:33 UTC (permalink / raw)
To: Andrey Konovalov
Cc: Andrey Ryabinin, Alexander Potapenko, Dmitry Vyukov,
Catalin Marinas, Thomas Gleixner, Ingo Molnar, H . Peter Anvin,
kasan-dev, linux-mm, linux-arm-kernel, x86, linux-kernel,
Kostya Serebryany
On Thu, Jan 11, 2018 at 04:29:09PM +0100, Andrey Konovalov wrote:
> Right now the fact that KASAN uses a single shadow byte for 8 bytes of
> memory is scattered all over the code.
>
> This change defines KASAN_SHADOW_SCALE_SHIFT early in asm include files
> and makes use of this constant where necessary.
>
> Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
> ---
> arch/arm64/include/asm/kasan.h | 3 ++-
> arch/arm64/include/asm/memory.h | 3 ++-
> arch/arm64/mm/kasan_init.c | 3 ++-
> arch/x86/include/asm/kasan.h | 8 ++++++--
> include/linux/kasan.h | 2 --
> 5 files changed, 12 insertions(+), 7 deletions(-)
For the arm64 parts:
Acked-by: Will Deacon <will.deacon@arm.com>
Will
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] kasan: clean up KASAN_SHADOW_SCALE_SHIFT usage
2018-01-11 15:29 ` [PATCH 2/2] kasan: clean up KASAN_SHADOW_SCALE_SHIFT usage Andrey Konovalov
2018-01-11 17:33 ` Will Deacon
@ 2018-01-11 21:59 ` Andrey Ryabinin
2018-01-12 16:49 ` Andrey Konovalov
1 sibling, 1 reply; 6+ messages in thread
From: Andrey Ryabinin @ 2018-01-11 21:59 UTC (permalink / raw)
To: Andrey Konovalov, Alexander Potapenko, Dmitry Vyukov,
Catalin Marinas, Will Deacon, Thomas Gleixner, Ingo Molnar,
H . Peter Anvin, kasan-dev, linux-mm, linux-arm-kernel, x86,
linux-kernel
Cc: Kostya Serebryany
On 01/11/2018 06:29 PM, Andrey Konovalov wrote:
> diff --git a/arch/arm64/include/asm/kasan.h b/arch/arm64/include/asm/kasan.h
> index e266f80e45b7..811643fe7640 100644
> --- a/arch/arm64/include/asm/kasan.h
> +++ b/arch/arm64/include/asm/kasan.h
> @@ -27,7 +27,8 @@
> * should satisfy the following equation:
> * KASAN_SHADOW_OFFSET = KASAN_SHADOW_END - (1ULL << 61)
Care to update comments as well?
> */
> -#define KASAN_SHADOW_OFFSET (KASAN_SHADOW_END - (1ULL << (64 - 3)))
> +#define KASAN_SHADOW_OFFSET (KASAN_SHADOW_END - (1ULL << \
> + (64 - KASAN_SHADOW_SCALE_SHIFT)))
>
> void kasan_init(void);
> void kasan_copy_shadow(pgd_t *pgdir);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] kasan: clean up KASAN_SHADOW_SCALE_SHIFT usage
2018-01-11 21:59 ` Andrey Ryabinin
@ 2018-01-12 16:49 ` Andrey Konovalov
0 siblings, 0 replies; 6+ messages in thread
From: Andrey Konovalov @ 2018-01-12 16:49 UTC (permalink / raw)
To: Andrey Ryabinin
Cc: Alexander Potapenko, Dmitry Vyukov, Catalin Marinas, Will Deacon,
Thomas Gleixner, Ingo Molnar, H . Peter Anvin, kasan-dev,
Linux Memory Management List, linux-arm-kernel,
the arch/x86 maintainers, LKML, Kostya Serebryany
On Thu, Jan 11, 2018 at 10:59 PM, Andrey Ryabinin
<aryabinin@virtuozzo.com> wrote:
>
>
> On 01/11/2018 06:29 PM, Andrey Konovalov wrote:
>
>> diff --git a/arch/arm64/include/asm/kasan.h b/arch/arm64/include/asm/kasan.h
>> index e266f80e45b7..811643fe7640 100644
>> --- a/arch/arm64/include/asm/kasan.h
>> +++ b/arch/arm64/include/asm/kasan.h
>> @@ -27,7 +27,8 @@
>> * should satisfy the following equation:
>> * KASAN_SHADOW_OFFSET = KASAN_SHADOW_END - (1ULL << 61)
>
> Care to update comments as well?
Sure, done in v2.
>
>> */
>> -#define KASAN_SHADOW_OFFSET (KASAN_SHADOW_END - (1ULL << (64 - 3)))
>> +#define KASAN_SHADOW_OFFSET (KASAN_SHADOW_END - (1ULL << \
>> + (64 - KASAN_SHADOW_SCALE_SHIFT)))
>>
>> void kasan_init(void);
>> void kasan_copy_shadow(pgd_t *pgdir);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-01-12 16:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-11 15:29 [PATCH 0/2] kasan: a few cleanups Andrey Konovalov
2018-01-11 15:29 ` [PATCH 1/2] kasan: fix prototype author email address Andrey Konovalov
2018-01-11 15:29 ` [PATCH 2/2] kasan: clean up KASAN_SHADOW_SCALE_SHIFT usage Andrey Konovalov
2018-01-11 17:33 ` Will Deacon
2018-01-11 21:59 ` Andrey Ryabinin
2018-01-12 16:49 ` Andrey Konovalov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).