On Tue, Oct 15, 2024 at 12:52 PM Sabyrzhan Tasbolatov
wrote:
>
> > Too bad. I guess we have to duplicate both kasan_check_write and
> > check_object_size before both do_strncpy_from_user calls in
> > strncpy_from_user.
>
> Shall we do it once in strncpy_from_user() as I did in v1?
> Please let me
On Tue, Oct 15, 2024 at 1:10 AM Andrew Morton wrote:
>
> On Mon, 14 Oct 2024 07:57:00 +0500 Sabyrzhan Tasbolatov
> wrote:
>
> > Migrate the copy_user_test to the KUnit framework to verify out-of-bound
> > detection via KASAN reports in copy_from_user(), copy_to_user() and
> > their static functi
id) { }
>
> #endif /* CONFIG_KASAN_KUNIT_TEST */
>
> -#if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST) ||
> IS_ENABLED(CONFIG_KASAN_MODULE_TEST)
> +#if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST)
>
> bool kasan_save_enable_multi_shot(void);
> void kasan_restore_multi_shot(bool enabled);
> diff --git a/mm/kasan/report.c b/mm/kasan/report.c
> index b48c768acc8..3e48668c3e4 100644
> --- a/mm/kasan/report.c
> +++ b/mm/kasan/report.c
> @@ -132,7 +132,7 @@ static bool report_enabled(void)
> return !test_and_set_bit(KASAN_BIT_REPORTED, &kasan_flags);
> }
>
> -#if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST) ||
> IS_ENABLED(CONFIG_KASAN_MODULE_TEST)
> +#if IS_ENABLED(CONFIG_KASAN_KUNIT_TEST)
>
> bool kasan_save_enable_multi_shot(void)
> {
> --
> 2.34.1
>
Reviewed-by: Andrey Konovalov
= __copy_to_user_inatomic(usermem, kmem, size + 1);
> -
> - pr_info("out-of-bounds in strncpy_from_user()\n");
> - unused = strncpy_from_user(kmem, usermem, size + 1);
> -
> - vm_munmap((unsigned long)usermem, PAGE_SIZE);
> - kfree(kmem);
> -}
> -
> -static int __ini
check_object_size(dst, count, false);
> if (user_read_access_begin(src, max)) {
> retval = do_strncpy_from_user(dst, src, count, max);
> user_read_access_end();
> --
> 2.34.1
>
Reviewed-by: Andrey Konovalov
On Sun, Oct 13, 2024 at 3:02 PM Sabyrzhan Tasbolatov
wrote:
>
> diff --git a/Documentation/dev-tools/kasan.rst
> b/Documentation/dev-tools/kasan.rst
> index d7de44f5339..52fdd6b5ef6 100644
> --- a/Documentation/dev-tools/kasan.rst
> +++ b/Documentation/dev-tools/kasan.rst
> @@ -511,17 +511,12 @@
On Sun, Oct 13, 2024 at 3:02 PM Sabyrzhan Tasbolatov
wrote:
>
> Migrate the copy_user_test to the KUnit framework to verify out-of-bound
> detection via KASAN reports in copy_from_user(), copy_to_user() and
> their static functions.
>
> This is the last migrated test in kasan_test_module.c, theref
On Wed, Oct 16, 2019 at 10:41 AM Marco Elver wrote:
>
> Kernel Concurrency Sanitizer (KCSAN) is a dynamic data-race detector for
> kernel space. KCSAN is a sampling watchpoint-based data-race detector.
> See the included Documentation/dev-tools/kcsan.rst for more details.
>
> This patch adds basic
the relaxation of the
> syscall ABI that allows userspace to pass certain tagged pointers to
> kernel syscalls.
>
> Cc: Will Deacon
> Cc: Andrey Konovalov
> Cc: Szabolcs Nagy
> Cc: Kevin Brodsky
> Signed-off-by: Vincenzo Frascino
> Co-developed-by: Catalin Marinas
the relaxation of the
> syscall ABI that allows userspace to pass certain tagged pointers to
> kernel syscalls.
>
> Cc: Will Deacon
> Cc: Andrey Konovalov
> Cc: Szabolcs Nagy
> Cc: Kevin Brodsky
> Signed-off-by: Vincenzo Frascino
> Co-developed-by: Catalin Marinas
ged Address ABI.
>
> Cc: Will Deacon
> Cc: Andrey Konovalov
> Cc: Szabolcs Nagy
> Cc: Kevin Brodsky
> Signed-off-by: Vincenzo Frascino
> Co-developed-by: Catalin Marinas
> Signed-off-by: Catalin Marinas
Acked-by: Andrey Konovalov
> ---
> Documentation/arm64/tagg
GED_ADDR_ENABLE).
> Getting the status of the ABI or disabling it is still allowed.
>
> Signed-off-by: Catalin Marinas
Acked-by: Andrey Konovalov
> ---
> arch/arm64/kernel/process.c | 17 ++---
> 1 file changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/a
g the user addresses on entry to these functions.
>
> Signed-off-by: Catalin Marinas
Acked-by: Andrey Konovalov
> ---
> mm/mmap.c | 5 +
> mm/mremap.c | 6 +-
> 2 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/mm/mmap.c b/mm/mmap.c
> ind
On Thu, Aug 15, 2019 at 5:44 PM Catalin Marinas wrote:
>
> Require that arg{3,4,5} of the PR_{SET,GET}_TAGGED_ADDR_CTRL prctl and
> arg2 of the PR_GET_TAGGED_ADDR_CTRL prctl() are zero rather than ignored
> for future extensions.
>
> Signed-off-by: Catalin Marinas
Acked-by
On Fri, Mar 1, 2019 at 7:37 PM Dave Hansen wrote:
>
> On 3/1/19 8:59 AM, Catalin Marinas wrote:
> >>> So, we have to patch all these sites before the tagged values get to the
> >>> point of hitting the vma lookup functions. Dumb question: Why don't we
> >>> just patch the vma lookup functions the
On Fri, Feb 22, 2019 at 11:55 PM Dave Hansen wrote:
>
> On 2/22/19 4:53 AM, Andrey Konovalov wrote:
> > The following testing approaches has been taken to find potential issues
> > with user pointer untagging:
> >
> > 1. Static testing (with sparse [3] and s
On Fri, Feb 22, 2019 at 5:10 PM Szabolcs Nagy wrote:
>
> On 22/02/2019 15:40, Andrey Konovalov wrote:
> > On Fri, Feb 22, 2019 at 4:35 PM Szabolcs Nagy wrote:
> >>
> >> On 22/02/2019 12:53, Andrey Konovalov wrote:
> >>> This patchset is meant to be m
On Sat, Feb 23, 2019 at 12:07 AM Dave Hansen wrote:
>
> On 2/22/19 4:53 AM, Andrey Konovalov wrote:
> > --- a/mm/mprotect.c
> > +++ b/mm/mprotect.c
> > @@ -578,6 +578,7 @@ static int do_mprotect_pkey(unsigned long start, size_t
> > len,
> > SYSCALL_DEFINE3(mp
On Sat, Feb 23, 2019 at 12:06 AM Dave Hansen wrote:
>
> On 2/22/19 4:53 AM, Andrey Konovalov wrote:
> > userfaultfd_register() and userfaultfd_unregister() use provided user
> > pointers for vma lookups, which can only by done with untagged pointers.
>
> So, we have
On Sat, Feb 23, 2019 at 12:03 AM Dave Hansen wrote:
>
> On 2/22/19 4:53 AM, Andrey Konovalov wrote:
> > --- a/fs/namespace.c
> > +++ b/fs/namespace.c
> > @@ -2730,7 +2730,7 @@ void *copy_mount_options(const void __user * data)
> >
On Fri, Feb 22, 2019 at 4:35 PM Szabolcs Nagy wrote:
>
> On 22/02/2019 12:53, Andrey Konovalov wrote:
> > This patchset is meant to be merged together with "arm64 relaxed ABI" [1].
> >
> > arm64 has a feature called Top Byte Ignore, which allows to embed pointer
strncpy_from_user and strnlen_user accept user addresses as arguments, and
do not go through the same path as copy_from_user and others, so here we
need to handle the case of tagged user addresses separately.
Untag user pointers passed to these functions.
Signed-off-by: Andrey Konovalov
in access_ok and in __uaccess_mask_ptr,
before performing access validity checks.
Note, that this patch only temporarily untags the pointers to perform the
checks, but then passes them as is into the kernel internals.
Reviewed-by: Catalin Marinas
Signed-off-by: Andrey Konovalov
---
arch/arm64
moved untagging pointers returned from __uaccess_mask_ptr.
Changes in v1:
- Rebased onto 4.17-rc1.
Changes in RFC v2:
- Added "#ifndef untagged_addr..." fallback in linux/uaccess.h instead of
defining it for each arch individually.
- Updated Documentation/arm64/tagged-pointers.txt.
- Dro
This commit allows tagged pointers to be passed to the following memory
syscalls: madvise, mbind, get_mempolicy, mincore, mlock, mlock2, brk,
mmap_pgoff, old_mmap, munmap, remap_file_pages, mprotect, pkey_mprotect,
mremap, msync and shmdt.
Signed-off-by: Andrey Konovalov
---
ipc/shm.c | 2
prctl_set_mm() and prctl_set_mm_map() use provided user pointers for vma
lookups, which can only by done with untagged pointers.
Untag user pointers in these functions.
Signed-off-by: Andrey Konovalov
---
kernel/sys.c | 14 ++
1 file changed, 14 insertions(+)
diff --git a/kernel
the address before subtracting.
Signed-off-by: Andrey Konovalov
---
fs/namespace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/namespace.c b/fs/namespace.c
index a677b59efd74..d4b7adef9204 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2730,7 +2730,7 @@ void
Document the changes in Documentation/arm64/tagged-pointers.txt.
Signed-off-by: Andrey Konovalov
---
Documentation/arm64/tagged-pointers.txt | 25 +++--
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/Documentation/arm64/tagged-pointers.txt
b/Documentation
tcp_zerocopy_receive() uses provided user pointers for vma lookups, which
can only by done with untagged pointers.
Untag user pointers in this function.
Signed-off-by: Andrey Konovalov
---
net/ipv4/tcp.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
userfaultfd_register() and userfaultfd_unregister() use provided user
pointers for vma lookups, which can only by done with untagged pointers.
Untag user pointers in these functions.
Signed-off-by: Andrey Konovalov
---
fs/userfaultfd.c | 5 +
1 file changed, 5 insertions(+)
diff --git a
for vma lookup.
Signed-off-by: Andrey Konovalov
---
mm/gup.c | 4
1 file changed, 4 insertions(+)
diff --git a/mm/gup.c b/mm/gup.c
index 75029649baca..b6eda1608bea 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -683,6 +683,8 @@ static long __get_user_pages(struct task_struct *tsk,
struct mm_struct
This patch adds a simple test, that calls the uname syscall with a
tagged user pointer as an argument. Without the kernel accepting tagged
user pointers the test fails with EFAULT.
Signed-off-by: Andrey Konovalov
---
tools/testing/selftests/arm64/.gitignore | 1 +
tools/testing/selftests
seq_print_user_ip() uses provided user pointers for vma lookups, which
can only by done with untagged pointers.
Untag user pointers in this function.
Signed-off-by: Andrey Konovalov
---
kernel/trace/trace_output.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/trace
arm64.
Acked-by: Catalin Marinas
Signed-off-by: Andrey Konovalov
---
include/linux/memory.h | 4
1 file changed, 4 insertions(+)
diff --git a/include/linux/memory.h b/include/linux/memory.h
index a6ddefc60517..fc383bc39ab8 100644
--- a/include/linux/memory.h
+++ b/include/linux/memory.h
On Wed, Jan 9, 2019 at 11:10 AM Vincenzo Frascino
wrote:
>
> On 03/01/2019 18:45, Andrey Konovalov wrote:
> > Instead of changing cache->align to be aligned to KASAN_SHADOW_SCALE_SIZE
> > in kasan_cache_create() we can reuse the ARCH_SLAB_MINALIGN macro.
> >
> >
Defining ARCH_SLAB_MINALIGN in arch/arm64/include/asm/cache.h when KASAN
is off is not needed, as it is defined in defined in include/linux/slab.h
as ifndef.
Signed-off-by: Andrey Konovalov
---
arch/arm64/include/asm/cache.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/arch/arm64
On Wed, Jan 2, 2019 at 9:14 PM Andrew Morton wrote:
>
> On Wed, 2 Jan 2019 18:36:06 +0100 Andrey Konovalov
> wrote:
>
> > Instead of changing cache->align to be aligned to KASAN_SHADOW_SCALE_SIZE
> > in kasan_cache_create() we can reuse the ARCH_SLAB_MINALIGN macro
eping the same tag if the memory don't actually gets
reallocated during krealloc.
Signed-off-by: Andrey Konovalov
---
mm/kasan/common.c | 63 ---
1 file changed, 43 insertions(+), 20 deletions(-)
diff --git a/mm/kasan/common.c b/mm/kasan/comm
operations.
Signed-off-by: Andrey Konovalov
---
mm/slub.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/slub.c b/mm/slub.c
index 36c0befeebd8..1e3d0ec4e200 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3846,6 +3846,8 @@ void __check_heap_object(const void *ptr, unsigned long
n, struct page
with CONFIG_HARDENED_USERCOPY"
patch.
- Added "kasan: fix krealloc handling for tag-based mode" patch.
Andrey Konovalov (3):
kasan, arm64: use ARCH_SLAB_MINALIGN instead of manual aligning
kasan: make tag based mode work with CONFIG_HARDENED_USERCOPY
kasan: fix krealloc handling for tag-bas
Instead of changing cache->align to be aligned to KASAN_SHADOW_SCALE_SIZE
in kasan_cache_create() we can reuse the ARCH_SLAB_MINALIGN macro.
Suggested-by: Vincenzo Frascino
Signed-off-by: Andrey Konovalov
---
arch/arm64/include/asm/cache.h | 6 ++
mm/kasan/common.c | 2 --
operations.
Signed-off-by: Andrey Konovalov
---
mm/slub.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/slub.c b/mm/slub.c
index 36c0befeebd8..1e3d0ec4e200 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3846,6 +3846,8 @@ void __check_heap_object(const void *ptr, unsigned long
n, struct page
Hi Andrew,
This patchset includes an updated "kasan, arm64: use ARCH_SLAB_MINALIGN
instead of manual aligning" patch and fixes for two more issues that
were uncovered while testing with a variety of different config options
enabled.
Thanks!
Andrey Konovalov (3):
kasan,
eping the same tag if the memory don't actually gets
reallocated during krealloc.
Signed-off-by: Andrey Konovalov
---
include/linux/kasan.h | 14 +-
include/linux/slab.h | 4 ++--
mm/kasan/common.c | 20
mm/slab.c | 8
mm/sla
Instead of changing cache->align to be aligned to KASAN_SHADOW_SCALE_SIZE
in kasan_cache_create() we can reuse the ARCH_SLAB_MINALIGN macro.
Suggested-by: Vincenzo Frascino
Signed-off-by: Andrey Konovalov
---
arch/arm64/include/asm/kasan.h | 4
include/linux/slab.h | 1 +
On Tue, Dec 18, 2018 at 9:55 PM Andrew Morton wrote:
>
> On Tue, 18 Dec 2018 14:30:33 +0100 Andrey Konovalov
> wrote:
>
> > Instead of changing cache->align to be aligned to KASAN_SHADOW_SCALE_SIZE
> > in kasan_cache_create() we can reuse the ARCH_SLAB_MINALIGN macro
On Wed, Dec 12, 2018 at 6:01 PM Dave Martin wrote:
>
> On Mon, Dec 10, 2018 at 01:50:57PM +0100, Andrey Konovalov wrote:
> > arm64 has a feature called Top Byte Ignore, which allows to embed pointer
> > tags into the top byte of each pointer. Userspace programs (such as
&g
On Wed, Dec 12, 2018 at 4:02 PM Catalin Marinas wrote:
>
> Hi Andrey,
>
> On Wed, Dec 12, 2018 at 03:23:25PM +0100, Andrey Konovalov wrote:
> > On Mon, Dec 10, 2018 at 3:31 PM Vincenzo Frascino
> > wrote:
> > > On arm64 the TCR_EL1.TBI0 bit has been set since Li
On Mon, Dec 17, 2018 at 9:38 PM Andrew Morton wrote:
>
> On Mon, 17 Dec 2018 20:33:42 +0100 Andrey Konovalov
> wrote:
>
> > > Curiosity, did you try your patches with SLUB red zoning enabled?
> > > Since the area used for the Redzone is just after th
Instead of changing cache->align to be aligned to KASAN_SHADOW_SCALE_SIZE
in kasan_cache_create() we can reuse the ARCH_SLAB_MINALIGN macro.
Suggested-by: Vincenzo Frascino
Signed-off-by: Andrey Konovalov
---
arch/arm64/include/asm/kasan.h | 4
mm/kasan/common.c | 2 --
On Fri, Dec 14, 2018 at 1:34 PM Vincenzo Frascino
wrote:
>
> On 12/12/18 3:04 PM, Andrey Konovalov wrote:
> > On Tue, Dec 11, 2018 at 5:22 PM Vincenzo Frascino
> > wrote:
> >>
> >> Hi Andrey,
> >>
> >> On 06/12/2018 12:24, Andrey Konovalov
On Tue, Dec 11, 2018 at 5:22 PM Vincenzo Frascino
wrote:
>
> Hi Andrey,
>
> On 06/12/2018 12:24, Andrey Konovalov wrote:
> > This commit adds tag-based KASAN specific hooks implementation and
> > adjusts common generic and tag-based KASAN ones.
> >
> > 1. W
m.doc.ihi0044f/IHI0044F_aaelf.pdf
> SPARC ABI: http://math-atlas.sourceforge.net/devel/assembly/abi_sysV_sparc.pdf
>
> Cc: Catalin Marinas
> Cc: Will Deacon
> Cc: Mark Rutland
> Cc: Robin Murphy
> Cc: Kees Cook
> Cc: Kate Stewart
> Cc: Greg Kroah-Hartman
> Cc:
On Tue, Dec 11, 2018 at 4:28 PM Luc Van Oostenryck
wrote:
>
> On Thu, Dec 06, 2018 at 01:24:23PM +0100, Andrey Konovalov wrote:
> > diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
> > index 3e7dafb3ea80..39f668d5066b 100644
> > --- a/includ
On Tue, Dec 11, 2018 at 4:18 PM Will Deacon wrote:
>
> Hi Andrey,
>
> On Thu, Dec 06, 2018 at 01:24:18PM +0100, Andrey Konovalov wrote:
> > This patchset adds a new software tag-based mode to KASAN [1].
> > (Initially this mode was called KHWASAN, but it got renamed,
>
for vma lookup.
Signed-off-by: Andrey Konovalov
---
mm/gup.c | 4
1 file changed, 4 insertions(+)
diff --git a/mm/gup.c b/mm/gup.c
index 8cb68a50dbdf..409aedb1e2d5 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -683,6 +683,8 @@ static long __get_user_pages(struct task_struct *tsk,
struct mm_struct
in access_ok and in __uaccess_mask_ptr,
before performing access validity checks.
Reviewed-by: Catalin Marinas
Signed-off-by: Andrey Konovalov
---
arch/arm64/include/asm/uaccess.h | 11 +++
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/arch/arm64/include/asm/uaccess.h b
mm, arm64: untag user addresses in memory syscalls".
- Rebased onto 3eb2ce82 (4.16-rc7).
Reviewed-by: Luc Van Oostenryck
Signed-off-by: Andrey Konovalov
Andrey Konovalov (8):
arm64: add type casts to untagged_addr macro
uaccess: add untagged_addr definition for other arches
arm64:
This patch makes the untagged_addr macro accept all kinds of address types
(void *, unsigned long, etc.) and allows not to specify type casts in each
place where it is used. This is done by using __typeof__.
Acked-by: Catalin Marinas
Signed-off-by: Andrey Konovalov
---
arch/arm64/include/asm
the address before subtracting.
Signed-off-by: Andrey Konovalov
---
fs/namespace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/namespace.c b/fs/namespace.c
index a7f91265ea67..694dcedb7e7d 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2686,7 +2686,7 @@ void
Document the changes in Documentation/arm64/tagged-pointers.txt.
Signed-off-by: Andrey Konovalov
---
Documentation/arm64/tagged-pointers.txt | 25 +++--
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/Documentation/arm64/tagged-pointers.txt
b/Documentation
strncpy_from_user and strnlen_user accept user addresses as arguments, and
do not go through the same path as copy_from_user and others, so here we
need to handle the case of tagged user addresses separately.
Untag user pointers passed to these functions.
Signed-off-by: Andrey Konovalov
arm64.
Acked-by: Catalin Marinas
Signed-off-by: Andrey Konovalov
---
include/linux/uaccess.h | 4
1 file changed, 4 insertions(+)
diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
index efe79c1cdd47..42b7a4ac65e2 100644
--- a/include/linux/uaccess.h
+++ b/include/linux/uaccess.h
This patch adds a simple test, that calls the uname syscall with a
tagged user pointer as an argument. Without the kernel accepting tagged
user pointers the test fails with EFAULT.
Signed-off-by: Andrey Konovalov
---
tools/testing/selftests/arm64/.gitignore | 1 +
tools/testing/selftests
On Mon, Dec 10, 2018 at 2:35 AM Paul Gortmaker
wrote:
>
> On Thu, Dec 6, 2018 at 7:25 AM Andrey Konovalov wrote:
>>
>> A tag-based KASAN shadow memory cell contains a memory tag, that
>> corresponds to the tag in the top byte of the pointer, that points to that
>&g
On Thu, Nov 29, 2018 at 7:16 PM Catalin Marinas wrote:
>
> Hi Andrey,
>
> On Thu, Nov 08, 2018 at 03:48:10PM +0100, Andrey Konovalov wrote:
> > On Thu, Nov 8, 2018 at 3:36 PM, Andrey Konovalov
> > wrote:
> > > Changes in v8:
> > > - Rebased onto 651022
On Thu, Nov 29, 2018 at 7:23 PM Catalin Marinas wrote:
>
> On Thu, Nov 08, 2018 at 03:36:09PM +0100, Andrey Konovalov wrote:
> > diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
> > index efe79c1cdd47..c045b4eff95e 100644
> > --- a/include/linux/uaccess.h
On Thu, Nov 29, 2018 at 7:22 PM Catalin Marinas wrote:
>
> On Thu, Nov 08, 2018 at 03:36:08PM +0100, Andrey Konovalov wrote:
> > This patch makes the untagged_addr macro accept all kinds of address types
> > (void *, unsigned long, etc.) and allows not to specify type casts
commit adds the CONFIG_KASAN_SW_TAGS config option, this option
is not selectable, as it depends on HAVE_ARCH_KASAN_SW_TAGS, which we will
enable once all the infrastracture code has been added.
Reviewed-by: Andrey Ryabinin
Reviewed-by: Dmitry Vyukov
Signed-off-by: Andrey Konovalov
---
include/linux
Signed-off-by: Andrey Konovalov
---
arch/arm64/Makefile | 11 ++-
arch/arm64/include/asm/memory.h | 7 +++
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 6cb9fc7e9382..99e7d08c6083 100644
--- a/arch/arm64
handler.
- Added a comment about the -recover flag.
- Some minor cleanups and fixes.
- Rebased onto 3215b9d5 (4.16-rc6+).
- Tested on real hardware (Odroid C2 board).
- Added better benchmarks.
[1] https://lkml.org/lkml/2018/7/18/765
[2] https://lkml.org/lkml/2018/4/19/775
Reviewed-by: Andrey Ryabini
Tag-based KASAN reuses a significant part of the generic KASAN code, so
move the common parts to common.c without any functional changes.
Reviewed-by: Andrey Ryabinin
Reviewed-by: Dmitry Vyukov
Signed-off-by: Andrey Konovalov
---
mm/kasan/Makefile | 5 +-
mm/kasan/common.c | 603
Ryabinin
Reviewed-by: Dmitry Vyukov
Signed-off-by: Andrey Konovalov
---
arch/arm64/mm/kasan_init.c | 15 +--
include/linux/kasan.h | 8
mm/kasan/common.c | 3 ++-
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/mm/kasan_init.c b/arch
macro is used. This is done by using __typeof__.
Acked-by: Mark Rutland
Signed-off-by: Andrey Konovalov
---
arch/arm64/include/asm/memory.h | 8
arch/arm64/include/asm/uaccess.h | 7 ---
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/arch/arm64/include/asm/memory.h b
This commit adds a few helper functions, that are meant to be used to
work with tags embedded in the top byte of kernel pointers: to set, to
get or to reset the top byte.
Signed-off-by: Andrey Konovalov
---
arch/arm64/include/asm/kasan.h | 8 +--
arch/arm64/include/asm/memory.h | 12
the logic of the hook implementation is very much similar to
the one provided by generic KASAN. Tag-based KASAN saves allocation and
free stack metadata to the slab object the same way generic KASAN does.
Reviewed-by: Andrey Ryabinin
Reviewed-by: Dmitry Vyukov
Signed-off-by: Andrey Konovalov
ed-by: Andrey Ryabinin
Reviewed-by: Dmitry Vyukov
Signed-off-by: Andrey Konovalov
---
mm/slab.c | 2 +-
mm/slub.c | 24 ++--
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/mm/slab.c b/mm/slab.c
index 26f60a22e5e0..27859fb39889 100644
--- a/mm/slab.c
+++
tag.
2. Tag-based KASAN reports all bugs with the "KASAN: invalid-access"
header.
Also simplify generic KASAN find_first_bad_addr.
Reviewed-by: Andrey Ryabinin
Reviewed-by: Dmitry Vyukov
Signed-off-by: Andrey Konovalov
---
mm/kasan/generic_report.c | 16 ---
mm/kas
on on
untagged (with tags reset) pointers to check whether it's the same memory
region or not.
Reviewed-by: Andrey Ryabinin
Reviewed-by: Dmitry Vyukov
Signed-off-by: Andrey Konovalov
---
mm/slab_common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/slab_com
which
index this object corresponds to.
This patch moves obj_to_index from slab.c to include/linux/slab_def.h to
be reused by KASAN.
Acked-by: Christoph Lameter
Reviewed-by: Andrey Ryabinin
Reviewed-by: Dmitry Vyukov
Signed-off-by: Andrey Konovalov
---
include/linux/slab_def.h
fact that TTBR1 pointers might be
tagged when tag-based KASAN is in use, and uses these helper functions to
perform pointer checks in arch/arm64/mm/fault.c.
Suggested-by: Mark Rutland
Signed-off-by: Andrey Konovalov
---
arch/arm64/mm/fault.c | 31 ++-
1 file change
virt_addr_is_linear (which is used by virt_addr_valid) assumes that the
top byte of the address is 0xff, which isn't always the case with
tag-based KASAN.
This patch resets the tag in this macro.
Reviewed-by: Andrey Ryabinin
Reviewed-by: Dmitry Vyukov
Signed-off-by: Andrey Konovalov
---
On Thu, Dec 6, 2018 at 12:10 PM Will Deacon wrote:
>
> On Thu, Dec 06, 2018 at 11:31:43AM +0100, Andrey Konovalov wrote:
> > On Thu, Nov 29, 2018 at 7:01 PM Will Deacon wrote:
> > >
> > > On Tue, Nov 27, 2018 at 05:55:38PM +0100, Andrey Konovalov wrote:
This patch updates KASAN documentation to reflect the addition of the new
tag-based mode.
Reviewed-by: Andrey Ryabinin
Reviewed-by: Dmitry Vyukov
Signed-off-by: Andrey Konovalov
---
Documentation/dev-tools/kasan.rst | 232 ++
1 file changed, 138 insertions(+), 94
to the brk instructions (to extract information
about the memory access that triggered the mismatch), reads the register
values (x0 contains the guilty address) and reports the bug.
Reviewed-by: Andrey Ryabinin
Reviewed-by: Dmitry Vyukov
Signed-off-by: Andrey Konovalov
---
arch/arm64/include
Now, that all the necessary infrastructure code has been introduced,
select HAVE_ARCH_KASAN_SW_TAGS for arm64 to enable software tag-based
KASAN mode.
Signed-off-by: Andrey Konovalov
---
arch/arm64/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm64/Kconfig b/arch/arm64
-by: Dmitry Vyukov
Signed-off-by: Andrey Konovalov
---
arch/arm64/include/asm/memory.h | 8 +++-
include/linux/mm.h| 29 +
include/linux/page-flags-layout.h | 10 ++
mm/cma.c | 11 +++
mm/kasan/common.c
With tag based KASAN mode the early shadow value is 0xff and not 0x00,
so this patch renames kasan_zero_(page|pte|pmd|pud|p4d) to
kasan_early_shadow_(page|pte|pmd|pud|p4d) to avoid confusion.
Suggested-by: Mark Rutland
Signed-off-by: Andrey Konovalov
---
arch/arm64/mm/kasan_init.c | 43
This patch moves generic KASAN specific error reporting routines to
generic_report.c without any functional changes, leaving common error
reporting code in report.c to be later reused by tag-based KASAN.
Reviewed-by: Andrey Ryabinin
Reviewed-by: Dmitry Vyukov
Signed-off-by: Andrey Konovalov
This patch adds __must_check annotations to kasan hooks that return a
pointer to make sure that a tagged pointer always gets propagated.
Suggested-by: Andrey Ryabinin
Signed-off-by: Andrey Konovalov
---
include/linux/kasan.h | 16 ++--
mm/kasan/common.c | 15 +--
2
-off-by: Andrey Konovalov
---
arch/arm64/include/asm/pgtable-hwdef.h | 1 +
arch/arm64/mm/proc.S | 8 +++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/pgtable-hwdef.h
b/arch/arm64/include/asm/pgtable-hwdef.h
index 1d7d8da2ef9b
This patch adds a "SPDX-License-Identifier: GPL-2.0" mark to all source
files under mm/kasan.
Reviewed-by: Andrey Ryabinin
Reviewed-by: Dmitry Vyukov
Signed-off-by: Andrey Konovalov
---
mm/kasan/common.c | 1 +
mm/kasan/generic.c| 1 +
mm/kasan/generic_report.c | 1 +
: Andrey Konovalov
---
include/linux/kasan.h | 43 +--
include/linux/slab.h | 4 ++--
mm/kasan/kasan.c | 30 ++
mm/slab.c | 12 ++--
mm/slab.h | 2 +-
mm/slab_common.c | 4 ++--
mm
is assigned by kasan_kmalloc.
Signed-off-by: Andrey Konovalov
---
mm/slub.c | 10 +-
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/mm/slub.c b/mm/slub.c
index fdd4a86aa882..8561a32910dd 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3364,16 +3364,16 @@ static void
We now have two KASAN modes: generic KASAN and tag-based KASAN. Rename
kasan.c to generic.c to reflect that. Also rename kasan_init.c to init.c
as it contains initialization code for both KASAN modes.
Reviewed-by: Andrey Ryabinin
Reviewed-by: Dmitry Vyukov
Signed-off-by: Andrey Konovalov
On Thu, Nov 29, 2018 at 7:01 PM Will Deacon wrote:
>
> On Tue, Nov 27, 2018 at 05:55:38PM +0100, Andrey Konovalov wrote:
> > Tag-based KASAN inline instrumentation mode (which embeds checks of shadow
> > memory into the generated code, instead of inserting a callback) g
On Thu, Nov 29, 2018 at 7:01 PM Will Deacon wrote:
>
> On Tue, Nov 27, 2018 at 05:55:41PM +0100, Andrey Konovalov wrote:
> > Now, that all the necessary infrastructure code has been introduced,
> > select HAVE_ARCH_KASAN_SW_TAGS for arm64 to enable software tag-ba
On Tue, Dec 4, 2018 at 11:24 PM Max Filippov wrote:
>
> Hello,
>
> On Tue, Nov 27, 2018 at 9:00 AM Andrey Konovalov
> wrote:
> >
> > This commit splits the current CONFIG_KASAN config option into two:
> > 1. CONFIG_KASAN_GENERIC, that enables the generic KASAN
Signed-off-by: Andrey Konovalov
---
arch/arm64/Makefile | 11 ++-
arch/arm64/include/asm/memory.h | 7 +++
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 6cb9fc7e9382..99e7d08c6083 100644
--- a/arch/arm64
commit adds the CONFIG_KASAN_SW_TAGS config option, this option
is not selectable, as it depends on HAVE_ARCH_KASAN_SW_TAGS, which we will
enable once all the infrastracture code has been added.
Reviewed-by: Andrey Ryabinin
Reviewed-by: Dmitry Vyukov
Signed-off-by: Andrey Konovalov
---
include/linux
1 - 100 of 269 matches
Mail list logo