Re: [PATCH v11 0/6] KASAN-KUnit Integration

2020-08-07 Thread Andrey Konovalov
PI" [1] > - This is included in the KUnit 5.9-rci pull request[8] > > I'd _really_ like to get this into 5.9 if possible: we also have some > other changes which depend on some things here. Found a small issue in patch #3, but otherwise: Tested-by: Andrey Konovalov for the

Re: [PATCH v11 0/6] KASAN-KUnit Integration

2020-08-10 Thread Andrey Konovalov
On Sat, Aug 8, 2020 at 5:27 AM David Gow wrote: > > On Fri, Aug 7, 2020 at 9:15 PM 'Andrey Konovalov' via kasan-dev > wrote: > > > > On Wed, Aug 5, 2020 at 6:29 AM David Gow wrote: > > > > > > This patchset contains everything needed to integrat

Re: KMSAN: kernel-infoleak in raw_ioctl

2020-08-10 Thread Andrey Konovalov
On Mon, Aug 10, 2020 at 12:22 PM Dmitry Vyukov wrote: > > On Mon, Aug 10, 2020 at 11:57 AM Greg KH wrote: > > > > On Mon, Aug 10, 2020 at 11:15:38AM +0200, Greg KH wrote: > > > On Mon, Aug 10, 2020 at 11:08:33AM +0200, Greg KH wrote: > > > > On Mon, Aug 10, 2020 at 11:00:07AM +0200, Dmitry Vyukov

Re: [PATCH RFC 1/2] mm: Extract SLAB_QUARANTINE from KASAN

2020-08-18 Thread Andrey Konovalov
g heap spraying. > > > > It may be worth clarifying that this is specifically only direct UAF and > > doesn't help with spray-and-overflow-into-a-neighboring-object attacks > > (i.e. both tend to use sprays, but the former doesn't depend on a write > > over

Re: [PATCH v3] kasan: remove redundant config option

2021-01-11 Thread Andrey Konovalov
On Fri, Jan 8, 2021 at 9:31 PM Arnd Bergmann wrote: > > On Fri, Jan 8, 2021 at 7:56 PM Andrey Konovalov wrote: > > On Fri, Jan 8, 2021 at 5:09 AM Walter Wu wrote: > > > > @@ -2,6 +2,12 @@ > > > CFLAGS_KASAN_NOSANITIZE := -fno-builtin > > > KASAN_SHA

Re: [PATCH v3] kasan: remove redundant config option

2021-01-11 Thread Andrey Konovalov
When enable KASAN stack instrumentation, then for gcc we could do > no prompt and default value y, and for clang prompt and default > value n. > > [1]: https://bugzilla.kernel.org/show_bug.cgi?id=210221 > > Signed-off-by: Walter Wu > Suggested-by: Dmitry Vyukov > Cc: Andrey R

Re: [PATCH v3] kasan: remove redundant config option

2021-01-11 Thread Andrey Konovalov
On Mon, Jan 11, 2021 at 7:59 PM Nathan Chancellor wrote: > > > > -config KASAN_STACK_ENABLE > > > +config KASAN_STACK > > > bool "Enable stack instrumentation (unsafe)" if CC_IS_CLANG && > > > !COMPILE_TEST > > > > Does this syntax mean that KASAN_STACK is only present for > > CC_IS_CLANG

Re: [PATCH v3] kasan: remove redundant config option

2021-01-11 Thread Andrey Konovalov
On Mon, Jan 11, 2021 at 8:11 PM Nathan Chancellor wrote: > > On Mon, Jan 11, 2021 at 08:03:29PM +0100, Andrey Konovalov wrote: > > On Mon, Jan 11, 2021 at 7:59 PM Nathan Chancellor > > wrote: > > > > > > > > -config KASAN_STACK_ENABLE > > > >

Re: [PATCH v3] kasan: remove redundant config option

2021-01-11 Thread Andrey Konovalov
CFLAGS_KASAN := $(CFLAGS_KASAN_SHADOW) \ > $(call cc-param,asan-globals=1) \ > $(call > cc-param,asan-instrumentation-with-call-threshold=$(call_threshold)) \ > -$(call cc-param,asan-stack=$(CONFIG_KASAN_STACK)) \ > +$(call cc-param,asan-stack=$(stack_enable)) \ > $(call cc-param,asan-instrument-allocas=1) > endif > > @@ -42,7 +48,7 @@ else > endif > > CFLAGS_KASAN := -fsanitize=kernel-hwaddress \ > - -mllvm -hwasan-instrument-stack=$(CONFIG_KASAN_STACK) \ > + -mllvm -hwasan-instrument-stack=$(stack_enable) \ > -mllvm -hwasan-use-short-granules=0 \ > $(instrumentation_flags) > > -- > 2.18.0 Reviewed-by: Andrey Konovalov

Are read-only static labels incompatible with kernel modules?

2020-12-07 Thread Andrey Konovalov
Hi, I'm getting a crash when trying to load a module into a kernel that uses __ro_after_init static labels, see the crash below. The label is defined and initialized in the main kernel binary, and is used in the module. Is this not supported? Thanks! [ 15.088489] Unable to handle kernel

Re: [PATCH 03/11] kasan: clean up comments in tests

2021-01-12 Thread Andrey Konovalov
On Tue, Jan 12, 2021 at 8:53 AM Alexander Potapenko wrote: > > On Tue, Jan 5, 2021 at 7:28 PM Andrey Konovalov wrote: > > > > Clarify and update comments and info messages in KASAN tests. > > > > Signed-off-by: Andrey Konovalov > > Link: > >

Re: [PATCH 04/11] kasan: add match-all tag tests

2021-01-12 Thread Andrey Konovalov
On Tue, Jan 12, 2021 at 9:05 AM Alexander Potapenko wrote: > > On Tue, Jan 5, 2021 at 7:28 PM Andrey Konovalov wrote: > > > > Add 3 new tests for tag-based KASAN modes: > > > > 1. Check that match-all pointer tag is not assigned randomly. > > 2. Check that 0

Re: [PATCH 04/11] kasan: add match-all tag tests

2021-01-12 Thread Andrey Konovalov
On Tue, Jan 12, 2021 at 2:17 PM Marco Elver wrote: > > On Tue, Jan 05, 2021 at 07:27PM +0100, Andrey Konovalov wrote: > > Add 3 new tests for tag-based KASAN modes: > > > > 1. Check that match-all pointer tag is not assigned randomly. > > 2. Check that 0xff works as

Re: [PATCH 06/11] kasan: rename CONFIG_TEST_KASAN_MODULE

2021-01-12 Thread Andrey Konovalov
On Tue, Jan 12, 2021 at 9:10 AM Alexander Potapenko wrote: > > On Tue, Jan 5, 2021 at 7:28 PM Andrey Konovalov wrote: > > > > Rename CONFIG_TEST_KASAN_MODULE to CONFIG_KASAN_MODULE_TEST. > > > > This naming is more consistent with the existing CONFIG_KASAN_KUN

Re: [PATCH 06/11] kasan: rename CONFIG_TEST_KASAN_MODULE

2021-01-12 Thread Andrey Konovalov
On Tue, Jan 12, 2021 at 2:33 PM Marco Elver wrote: > > On Tue, Jan 05, 2021 at 07:27PM +0100, Andrey Konovalov wrote: > > Rename CONFIG_TEST_KASAN_MODULE to CONFIG_KASAN_MODULE_TEST. > > > > This naming is more consistent with the existing CONFIG_KASAN_KUNIT_TEST. >

Re: [PATCH 07/11] kasan: add compiler barriers to KUNIT_EXPECT_KASAN_FAIL

2021-01-12 Thread Andrey Konovalov
On Tue, Jan 12, 2021 at 9:18 AM Alexander Potapenko wrote: > > On Tue, Jan 5, 2021 at 7:28 PM Andrey Konovalov wrote: > > > > It might not be obvious to the compiler that the expression must be > > executed between writing and reading to fail_data. In this case, the >

Re: [PATCH 10/11] kasan: fix bug detection via ksize for HW_TAGS mode

2021-01-12 Thread Andrey Konovalov
On Tue, Jan 12, 2021 at 3:32 PM Marco Elver wrote: > > > +/* > > + * Unlike kasan_check_read/write(), kasan_check_byte() is performed even > > for > > + * the hardware tag-based mode that doesn't rely on compiler > > instrumentation. > > + */ > > We have too many check-functions, and the name ne

Re: [PATCH 09/11] kasan: fix memory corruption in kasan_bitops_tags test

2021-01-12 Thread Andrey Konovalov
On Tue, Jan 12, 2021 at 9:30 AM Alexander Potapenko wrote: > > On Tue, Jan 5, 2021 at 7:28 PM Andrey Konovalov wrote: > > > > Since the hardware tag-based KASAN mode might not have a redzone that > > comes after an allocated object (when kasan.mode=prod is enabled), t

Re: [PATCH 08/11] kasan: adopt kmalloc_uaf2 test to HW_TAGS mode

2021-01-12 Thread Andrey Konovalov
On Tue, Jan 12, 2021 at 2:39 PM Marco Elver wrote: > > On Tue, Jan 05, 2021 at 07:27PM +0100, Andrey Konovalov wrote: > > In the kmalloc_uaf2() test, the pointers to the two allocated memory > > blocks might be the same, and the test will fail. With the software >

Re: [PATCH 08/11] kasan: adopt kmalloc_uaf2 test to HW_TAGS mode

2021-01-12 Thread Andrey Konovalov
On Tue, Jan 12, 2021 at 9:26 AM Alexander Potapenko wrote: > > Nit: s/adopt/adapt in the title. > > > > +again: > > ptr1 = kmalloc(size, GFP_KERNEL); > > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr1); > > > > @@ -384,6 +386,13 @@ static void kmalloc_uaf2(struct kunit *test) > >

Re: [PATCH 07/11] kasan: add compiler barriers to KUNIT_EXPECT_KASAN_FAIL

2021-01-12 Thread Andrey Konovalov
On Tue, Jan 12, 2021 at 8:50 PM Andrey Konovalov wrote: > > On Tue, Jan 12, 2021 at 9:18 AM Alexander Potapenko wrote: > > > > On Tue, Jan 5, 2021 at 7:28 PM Andrey Konovalov > > wrote: > > > > > > It might not be obvious to the compiler that the

[PATCH 0/2] kasan: fixes for 5.11-rc

2021-01-13 Thread Andrey Konovalov
Andrey Konovalov (2): kasan, mm: fix conflicts with init_on_alloc/free kasan, arm64: fix pointer tags in KASAN reports arch/arm64/mm/fault.c | 2 ++ mm/slub.c | 7 --- 2 files changed, 6 insertions(+), 3 deletions(-) -- 2.30.0.284.gd98b1dd5eaa7-goog

[PATCH 2/2] kasan, arm64: fix pointer tags in KASAN reports

2021-01-13 Thread Andrey Konovalov
ps://linux-review.googlesource.com/id/I9ced973866036d8679e8f4ae325de547eb969649 Fixes: dceec3ff7807 ("arm64: expose FAR_EL1 tag bits in siginfo") Fixes: 4291e9ee6189 ("kasan, arm64: print report from tag fault handler") Signed-off-by: Andrey Konovalov --- arch/arm64/mm/fault.c | 2 ++

[PATCH 1/2] kasan, mm: fix conflicts with init_on_alloc/free

2021-01-13 Thread Andrey Konovalov
https://linux-review.googlesource.com/id/I50dd32838a666e173fe06c3c5c766f2c36aae901 Fixes: aa1ef4d7b3f67 ("kasan, mm: reset tags when accessing metadata") Reported-by: Dmitry Vyukov Signed-off-by: Andrey Konovalov --- mm/slub.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-)

[PATCH v2 00/14] kasan: HW_TAGS tests support and fixes

2021-01-13 Thread Andrey Konovalov
heck. - Rename kasan_check() to kasan_byte_accessible(). - Add a test for kmem_cache_bulk_alloc(). - Checks that pointer tags are assigned from [KASAN_TAG_MIN, KASAN_TAG_KERNEL). - Don't run tests with kasan.mode=off. Andrey Konovalov (14): kasan: prefix global functions with kasan_ kasan: clarify HW_

[PATCH v2 01/14] kasan: prefix global functions with kasan_

2021-01-13 Thread Andrey Konovalov
lesource.com/id/I719cc93483d4ba288a634dba80ee6b7f2809cd26 Suggested-by: Marco Elver Reviewed-by: Marco Elver Reviewed-by: Alexander Potapenko Signed-off-by: Andrey Konovalov --- mm/kasan/common.c | 47 +++--- mm/kasan/generic.c| 36 ++--- mm/kasan/kasan.

[PATCH v2 02/14] kasan: clarify HW_TAGS impact on TBI

2021-01-13 Thread Andrey Konovalov
Reviewed-by: Alexander Potapenko Signed-off-by: Andrey Konovalov --- Documentation/dev-tools/kasan.rst | 16 +++- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan.rst index 0fc3fb1860c4..26c99852a852 100644

[PATCH v2 03/14] kasan: clean up comments in tests

2021-01-13 Thread Andrey Konovalov
Clarify and update comments in KASAN tests. Link: https://linux-review.googlesource.com/id/I6c816c51fa1e0eb7aa3dead6bda1f339d2af46c8 Signed-off-by: Andrey Konovalov --- lib/test_kasan.c| 59 + lib/test_kasan_module.c | 5 ++-- 2 files changed

[PATCH v2 04/14] kasan: add macros to simplify checking test constraints

2021-01-13 Thread Andrey Konovalov
: Andrey Konovalov --- lib/test_kasan.c | 101 +++ 1 file changed, 31 insertions(+), 70 deletions(-) diff --git a/lib/test_kasan.c b/lib/test_kasan.c index 6f46e27c2af7..714ea27fcc3e 100644 --- a/lib/test_kasan.c +++ b/lib/test_kasan.c @@ -73,6 +73,20

[PATCH v2 05/14] kasan: add match-all tag tests

2021-01-13 Thread Andrey Konovalov
during execution for the SW_TAGS mode. Link: https://linux-review.googlesource.com/id/I78f1375efafa162b37f3abcb2c5bc2f3955dfd8e Signed-off-by: Andrey Konovalov --- lib/test_kasan.c | 92 mm/kasan/kasan.h | 6 2 files changed, 98 insertions

[PATCH v2 06/14] kasan, arm64: allow using KUnit tests with HW_TAGS mode

2021-01-13 Thread Andrey Konovalov
the hardware tag-based mode; fixes come in the next few patches. Link: https://linux-review.googlesource.com/id/Id94dc9eccd33b23cda4950be408c27f879e474c8 Signed-off-by: Andrey Konovalov --- arch/arm64/include/asm/memory.h| 1 + arch/arm64/include/asm/mte-kasan.h | 12 + arch/arm64

[PATCH v2 07/14] kasan: rename CONFIG_TEST_KASAN_MODULE

2021-01-13 Thread Andrey Konovalov
-by: Andrey Konovalov --- Documentation/dev-tools/kasan.rst | 8 lib/Kconfig.kasan | 2 +- lib/Makefile | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan.rst index

[PATCH v2 08/14] kasan: add compiler barriers to KUNIT_EXPECT_KASAN_FAIL

2021-01-13 Thread Andrey Konovalov
and use READ/WRITE_ONCE() for accessing fail_data fields. Link: https://linux-review.googlesource.com/id/I046079f48641a1d36fe627fc8827a9249102fd50 Signed-off-by: Andrey Konovalov --- lib/test_kasan.c | 17 - mm/kasan/report.c | 2 +- 2 files changed, 13 insertions(+), 6 deletions

[PATCH v2 09/14] kasan: adapt kmalloc_uaf2 test to HW_TAGS mode

2021-01-13 Thread Andrey Konovalov
is 1/14, which is quite noticable. Allow up to 16 attempts at generating different tags for the tag-based modes. Link: https://linux-review.googlesource.com/id/Ibfa458ef2804ff465d8eb07434a300bf36388d55 Signed-off-by: Andrey Konovalov --- lib/test_kasan.c | 11 +++ 1 file change

[PATCH v2 14/14] kasan: don't run tests when KASAN is not enabled

2021-01-13 Thread Andrey Konovalov
Don't run KASAN tests when it's disabled with kasan.mode=off to avoid corrupting kernel memory. Link: https://linux-review.googlesource.com/id/I6447af436a69a94bfc35477f6bf4e2122948355e Signed-off-by: Andrey Konovalov --- lib/test_kasan.c | 3 +++ 1 file changed, 3 insertions(+) di

[PATCH v2 13/14] kasan: add a test for kmem_cache_alloc/free_bulk

2021-01-13 Thread Andrey Konovalov
Add a test for kmem_cache_alloc/free_bulk to make sure there are now false-positives when these functions are used. Link: https://linux-review.googlesource.com/id/I2a8bf797aecf81baeac61380c567308f319e263d Signed-off-by: Andrey Konovalov --- lib/test_kasan.c | 39

[PATCH v2 12/14] kasan: add proper page allocator tests

2021-01-13 Thread Andrey Konovalov
: Alexander Potapenko Signed-off-by: Andrey Konovalov --- lib/test_kasan.c | 51 +++- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/lib/test_kasan.c b/lib/test_kasan.c index 710e714dc0cb..5e3d054e5b8c 100644 --- a/lib/test_kasan.c +++ b/lib

[PATCH v2 11/14] kasan: fix bug detection via ksize for HW_TAGS mode

2021-01-13 Thread Andrey Konovalov
s detected via ksize() itself, and via plain accesses that happen later. Link: https://linux-review.googlesource.com/id/Iaabf771881d0f9ce1b969f2a62938e99d3308ec5 Signed-off-by: Andrey Konovalov --- include/linux/kasan-checks.h | 6 ++ include/linux/kasan.h| 16 +++

[PATCH v2 10/14] kasan: fix memory corruption in kasan_bitops_tags test

2021-01-13 Thread Andrey Konovalov
object's boundaries. Link: https://linux-review.googlesource.com/id/I67f51d1ee48f0a8d0fe2658c2a39e4879fe0832a Reviewed-by: Marco Elver Reviewed-by: Alexander Potapenko Signed-off-by: Andrey Konovalov --- lib/test_kasan.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff

Re: [PATCH v4] media: ov8856: Configure sensor for GRBG Bayer for all modes

2021-01-18 Thread Andrey Konovalov
Hi Robert, Thanks for you patch! Reviewed-by: Andrey Konovalov On 18.01.2021 22:01, Robert Foss wrote: The previously added modes 3264x2448 & 1632x1224 are actually configuring the sensor for BGGR mode, this is an issue since the mode that is exposed through V4L incorrectly is set as

Re: [PATCH v4] media: ov8856: Configure sensor for GRBG Bayer for all modes

2021-01-18 Thread Andrey Konovalov
Oops.. I've missed a few mistypes On 18.01.2021 22:18, Andrey Konovalov wrote: Hi Robert, Thanks for you patch! Reviewed-by: Andrey Konovalov On 18.01.2021 22:01, Robert Foss wrote: The previously added modes 3264x2448 & 1632x1224 are actually configuring the sensor for BGGR mode

Re: [PATCH v4] media: ov8856: Configure sensor for GRBG Bayer for all modes

2021-01-18 Thread Andrey Konovalov
ks, Andrey On Mon, 18 Jan 2021 at 20:28, Andrey Konovalov wrote: Oops.. I've missed a few mistypes On 18.01.2021 22:18, Andrey Konovalov wrote: Hi Robert, Thanks for you patch! Reviewed-by: Andrey Konovalov On 18.01.2021 22:01, Robert Foss wrote: The previously added modes 3264x2

[PATCH] kasan, mm: fix resetting page_alloc tags for HW_TAGS

2021-01-19 Thread Andrey Konovalov
t bad accesses to page_alloc allocations on some configurations. Fix this by recovering the tag after the metadata access. Fixes: aa1ef4d7b3f6 ("kasan, mm: reset tags when accessing metadata") Signed-off-by: Andrey Konovalov --- mm/page_alloc.c | 2 ++ 1 file changed, 2 insertions(+)

Re: [PATCH v4 5/5] arm64: mte: Inline mte_assign_mem_tag_range()

2021-01-19 Thread Andrey Konovalov
On Tue, Jan 19, 2021 at 4:45 PM Vincenzo Frascino wrote: > > Hi Catalin, > > On 1/19/21 2:45 PM, Catalin Marinas wrote: > > On Mon, Jan 18, 2021 at 06:30:33PM +, Vincenzo Frascino wrote: > >> mte_assign_mem_tag_range() is called on production KASAN HW hot > >> paths. It makes sense to inline i

Re: [PATCH v4 3/5] kasan: Add report for async mode

2021-01-19 Thread Andrey Konovalov
On Tue, Jan 19, 2021 at 3:46 PM Mark Rutland wrote: > > Given there's no information available, I think it's simpler and > preferable to handle the logging separately, as is done for > kasan_report_invalid_free(). For example, we could do something roughly > like: > > void kasan_report_async(void)

Re: [PATCH v4 2/5] kasan: Add KASAN mode kernel parameter

2021-01-19 Thread Andrey Konovalov
On Mon, Jan 18, 2021 at 7:30 PM Vincenzo Frascino wrote: > --- a/Documentation/dev-tools/kasan.rst > +++ b/Documentation/dev-tools/kasan.rst > @@ -162,6 +162,9 @@ particular KASAN features. > > - ``kasan=off`` or ``=on`` controls whether KASAN is enabled (default: > ``on``). > > +- ``kasan.mode=

Re: [PATCH v4 1/5] arm64: mte: Add asynchronous mode support

2021-01-19 Thread Andrey Konovalov
r_el1, SCTLR_ELx_TCF_MASK, SCTLR_ELx_TCF_SYNC); > + sysreg_clear_set(sctlr_el1, SCTLR_ELx_TCF_MASK, tcf); > isb(); > + > + pr_info_once("MTE: enabled in %s mode at EL1\n", mode); > +} > + > +void mte_enable_kernel_sync(void) > +{ > + __mte_enable_kernel("synchronous", SCTLR_ELx_TCF_SYNC); > +} > + > +void mte_enable_kernel_async(void) > +{ > + __mte_enable_kernel("asynchronous", SCTLR_ELx_TCF_ASYNC); > } > > static void update_sctlr_el1_tcf0(u64 tcf0) > -- > 2.30.0 > Reviewed-by: Andrey Konovalov

Re: [PATCH v4 0/5] arm64: ARMv8.5-A: MTE: Add async mode support

2021-01-19 Thread Andrey Konovalov
On Mon, Jan 18, 2021 at 7:30 PM Vincenzo Frascino wrote: > > This patchset implements the asynchronous mode support for ARMv8.5-A > Memory Tagging Extension (MTE), which is a debugging feature that allows > to detect with the help of the architecture the C and C++ programmatic > memory errors like

Re: [PATCH] kasan: Add explicit preconditions to kasan_report()

2021-01-19 Thread Andrey Konovalov
On Tue, Jan 19, 2021 at 7:57 PM Vincenzo Frascino wrote: > > > > On 1/19/21 6:52 PM, Catalin Marinas wrote: > > On Tue, Jan 19, 2021 at 07:27:43PM +0100, Andrey Konovalov wrote: > >> On Tue, Jan 19, 2021 at 6:26 PM Vincenzo Frascino > >> wrote: > >>&

Re: [PATCH v4 5/5] arm64: mte: Inline mte_assign_mem_tag_range()

2021-01-19 Thread Andrey Konovalov
On Tue, Jan 19, 2021 at 8:00 PM Catalin Marinas wrote: > > On Tue, Jan 19, 2021 at 07:12:40PM +0100, Andrey Konovalov wrote: > > On Tue, Jan 19, 2021 at 4:45 PM Vincenzo Frascino > > wrote: > > > On 1/19/21 2:45 PM, Catalin Marinas wrote: > > > > O

Re: [PATCH] kasan: Add explicit preconditions to kasan_report()

2021-01-19 Thread Andrey Konovalov
An invalid address (e.g. NULL pointer address) passed to the > function when, KASAN_HW_TAGS is enabled, leads to a kernel panic. > > Cc: Andrey Ryabinin > Cc: Alexander Potapenko > Cc: Dmitry Vyukov > Cc: Leon Romanovsky > Cc: Andrey Konovalov > Signed-off-by: Vi

Re: [PATCH] kasan: Add explicit preconditions to kasan_report()

2021-01-19 Thread Andrey Konovalov
On Tue, Jan 19, 2021 at 9:32 PM Vincenzo Frascino wrote: > > This seems not working on arm64 because according to virt_addr_valid 0 is a > valid virtual address, in fact: > > __is_lm_address(0) == true && pfn_valid(virt_to_pfn(0)) == true. > > An option could be to make an exception for virtual ad

[PATCH v2] kcov, usb: hide in_serving_softirq checks in __usb_hcd_giveback_urb

2021-01-07 Thread Andrey Konovalov
Done opencode in_serving_softirq() checks in __usb_hcd_giveback_urb() to avoid cluttering the code, hide them in kcov helpers instead. Fixes: aee9ddb1d371 ("kcov, usb: only collect coverage from __usb_hcd_giveback_urb in softirq") Signed-off-by: Andrey Konovalov --- Changes v1-&g

Re: [PATCH 2/4] arm64: mte: Add asynchronous mode support

2021-01-07 Thread Andrey Konovalov
On Wed, Jan 6, 2021 at 12:56 PM Vincenzo Frascino wrote: > > MTE provides an asynchronous mode for detecting tag exceptions. In > particular instead of triggering a fault the arm64 core updates a > register which is checked by the kernel at the first entry after the tag > exception has occurred. >

Re: [PATCH 2/4] arm64: mte: Add asynchronous mode support

2021-01-07 Thread Andrey Konovalov
On Thu, Jan 7, 2021 at 6:25 PM Vincenzo Frascino wrote: > > Hi Andrey, > > On 1/7/21 4:29 PM, Andrey Konovalov wrote: > > On Wed, Jan 6, 2021 at 12:56 PM Vincenzo Frascino > > wrote: > >> > >> MTE provides an asynchronous mode for detecting tag

Re: [PATCH v2] media: ov8856: Fix Bayer format dependance on mode

2021-01-08 Thread Andrey Konovalov
Hi Robert and Tomasz, On 08.01.2021 12:49, Tomasz Figa wrote: Hi Robert, On Thu, Jan 7, 2021 at 11:21 PM Robert Foss wrote: The Bayer GRBG10 mode used for earlier modes 3280x2460 and 1640x1232 isn't the mode output by the sensor for the 3264x2448 and 1632x1224 modes. Switch from MEDIA_BUS_F

Re: [PATCH v2] media: ov8856: Fix Bayer format dependance on mode

2021-01-08 Thread Andrey Konovalov
Hi Robert, On 08.01.2021 13:46, Andrey Konovalov wrote: Hi Robert and Tomasz, On 08.01.2021 12:49, Tomasz Figa wrote: Hi Robert, On Thu, Jan 7, 2021 at 11:21 PM Robert Foss wrote: The Bayer GRBG10 mode used for earlier modes 3280x2460 and 1640x1232 isn't the mode output by the senso

Re: [PATCH 2/4] arm64: mte: Add asynchronous mode support

2021-01-08 Thread Andrey Konovalov
On Fri, Jan 8, 2021 at 11:44 AM Vincenzo Frascino wrote: > > Hi Andrey, > > On 1/7/21 7:18 PM, Andrey Konovalov wrote: > >> Boolean arguments are generally bad for legibility, hence I tend to avoid > >> them. > >> In this case exposing the constan

Re: [PATCH] kasan: fix incorrect arguments passing in kasan_add_zero_shadow

2021-01-08 Thread Andrey Konovalov
IFT); > + kasan_remove_zero_shadow(start, size); > return ret; > } > -- > 2.25.1 Reviewed-by: Andrey Konovalov

Re: [PATCH] kasan: fix unaligned address is unhandled in kasan_remove_zero_shadow

2021-01-08 Thread Andrey Konovalov
On Sun, Jan 3, 2021 at 2:56 PM Lecopzer Chen wrote: > > During testing kasan_populate_early_shadow and kasan_remove_zero_shadow, > if the shadow start and end address in kasan_remove_zero_shadow() is > not aligned to PMD_SIZE, the remain unaligned PTE won't be removed. > > In the test case for kas

Re: [PATCH 3/3] arm64: Kconfig: support CONFIG_KASAN_VMALLOC

2021-01-08 Thread Andrey Konovalov
On Sun, Jan 3, 2021 at 6:13 PM Lecopzer Chen wrote: > > Now I have no device to test for HW_TAG, so keep it not selected > until someone can test this. > > Signed-off-by: Lecopzer Chen > --- > arch/arm64/Kconfig | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/arm64/Kconfig b/arch/a

Re: [PATCH 0/3] arm64: kasan: support CONFIG_KASAN_VMALLOC

2021-01-08 Thread Andrey Konovalov
san: support KASAN_VMALLOC") > > Signed-off-by: Lecopzer Chen Hi Lecopzer, Thanks for working on this! Acked-by: Andrey Konovalov Tested-by: Andrey Konovalov for the series along with the other two patches minding the nit in patch #3. Will, Catalin, could you please take a look at the arm changes? Thanks!

Re: [PATCH 0/3] arm64: kasan: support CONFIG_KASAN_VMALLOC

2021-01-08 Thread Andrey Konovalov
On Sun, Jan 3, 2021 at 6:12 PM Lecopzer Chen wrote: > > Linux supports KAsan for VMALLOC since commit 3c5c3cfb9ef4da9 > ("kasan: support backing vmalloc space with real shadow memory") > > Acroding to how x86 ported it [1], they early allocated p4d and pgd, > but in arm64 I just simulate how KAsan

Re: [PATCH v3] kasan: remove redundant config option

2021-01-08 Thread Andrey Konovalov
When enable KASAN stack instrumentation, then for gcc we could do > no prompt and default value y, and for clang prompt and default > value n. > > [1]: https://bugzilla.kernel.org/show_bug.cgi?id=210221 > > Signed-off-by: Walter Wu > Suggested-by: Dmitry Vyukov > Cc: Andrey R

Re: [PATCH v1 05/17] media: camss: Refactor VFE HW version support

2021-01-13 Thread Andrey Konovalov
Hi Robert, Thank you for the patch! On 08.01.2021 15:04, Robert Foss wrote: In order to support Qualcomm ISP hardware architectures that diverge from older architectures, the VFE subdevice driver needs to be refactored to better abstract the different ISP architectures. Gen1 represents the CAM

Re: [PATCH v1 04/17] media: camss: Make ISPIF subdevice optional

2021-01-13 Thread Andrey Konovalov
Hi Robert, Thanks for the patch! On 08.01.2021 15:04, Robert Foss wrote: This driver supports multiple architecture versions of the Qualcomm ISP. The CAMSS architecure which this driver is name after, and with the introduction of this series, the Titan architecture. The ISPIF is IP-block that

Re: [PATCH v1 06/17] media: camss: Add support for VFE hardware version Titan 170

2021-01-14 Thread Andrey Konovalov
Hi Robert, Thank you for the patch! On 08.01.2021 15:04, Robert Foss wrote: Add register definitions for version 170 of the Titan architecture and implement support for the RDI output mode. The RDI mode as opposed to the PIX output mode for the VFE unit does not support any ISP functionality.

Re: [PATCH v2 14/14] kasan: don't run tests when KASAN is not enabled

2021-01-14 Thread Andrey Konovalov
On Wed, Jan 13, 2021 at 5:39 PM Marco Elver wrote: > > On Wed, 13 Jan 2021 at 17:22, Andrey Konovalov wrote: > > > > Don't run KASAN tests when it's disabled with kasan.mode=off to avoid > > corrupting kernel memory. > > > > Link:

Re: [PATCH v2 13/14] kasan: add a test for kmem_cache_alloc/free_bulk

2021-01-14 Thread Andrey Konovalov
On Wed, Jan 13, 2021 at 5:38 PM Marco Elver wrote: > > On Wed, 13 Jan 2021 at 17:22, Andrey Konovalov wrote: > > > > Add a test for kmem_cache_alloc/free_bulk to make sure there are now > > false-positives when these functions are used. > > s/now/no/ (but by itsel

Re: [PATCH 1/2] kasan, mm: fix conflicts with init_on_alloc/free

2021-01-14 Thread Andrey Konovalov
On Wed, Jan 13, 2021 at 6:25 PM Vlastimil Babka wrote: > > On 1/13/21 5:03 PM, Andrey Konovalov wrote: > > A few places where SLUB accesses object's data or metadata were missed in > > a previous patch. This leads to false positives with hardware tag-based > > KASAN w

Re: [PATCH v2 11/14] kasan: fix bug detection via ksize for HW_TAGS mode

2021-01-14 Thread Andrey Konovalov
On Wed, Jan 13, 2021 at 5:54 PM Marco Elver wrote: > > > +bool __kasan_check_byte(const void *addr, unsigned long ip); > > +static __always_inline bool kasan_check_byte(const void *addr, unsigned > > long ip) > > +{ > > + if (kasan_enabled()) > > + return __kasan_check_byte(ad

Re: [PATCH v2 11/14] kasan: fix bug detection via ksize for HW_TAGS mode

2021-01-14 Thread Andrey Konovalov
On Wed, Jan 13, 2021 at 5:54 PM Marco Elver wrote: > > > +/* > > + * Unlike kasan_check_read/write(), kasan_check_byte() is performed even > > for > > + * the hardware tag-based mode that doesn't rely on compiler > > instrumentation. > > + */ > > +bool __kasan_check_byte(const void *addr, unsign

[PATCH v2 2/2] kasan, arm64: fix pointer tags in KASAN reports

2021-01-14 Thread Andrey Konovalov
ps://linux-review.googlesource.com/id/I9ced973866036d8679e8f4ae325de547eb969649 Fixes: dceec3ff7807 ("arm64: expose FAR_EL1 tag bits in siginfo") Fixes: 4291e9ee6189 ("kasan, arm64: print report from tag fault handler") Signed-off-by: Andrey Konovalov --- arch/arm64/mm/fault.c | 2 ++

[PATCH v2 0/2] kasan: fixes for 5.11-rc

2021-01-14 Thread Andrey Konovalov
Changes v1->v2: - Update changelog of patch #1. Andrey Konovalov (2): kasan, mm: fix conflicts with init_on_alloc/free kasan, arm64: fix pointer tags in KASAN reports arch/arm64/mm/fault.c | 2 ++ mm/slub.c | 7 --- 2 files changed, 6 insertions(+), 3 deleti

[PATCH v2 1/2] kasan, mm: fix conflicts with init_on_alloc/free

2021-01-14 Thread Andrey Konovalov
Acked-by: Vlastimil Babka Signed-off-by: Andrey Konovalov --- mm/slub.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index dc5b42e700b8..75fb097d990d 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2791,7 +2791,8 @@ static __always_inline void ma

[PATCH v3 00/15] kasan: HW_TAGS tests support and fixes

2021-01-14 Thread Andrey Konovalov
ran with kasan.mode=off. - Move _RET_IP_ to inline wrappers for kasan annotations. Andrey Konovalov (15): kasan: prefix global functions with kasan_ kasan: clarify HW_TAGS impact on TBI kasan: clean up comments in tests kasan: add macros to simplify checking test constraints kasan: add match

[PATCH v3 01/15] kasan: prefix global functions with kasan_

2021-01-14 Thread Andrey Konovalov
lesource.com/id/I719cc93483d4ba288a634dba80ee6b7f2809cd26 Suggested-by: Marco Elver Reviewed-by: Marco Elver Reviewed-by: Alexander Potapenko Signed-off-by: Andrey Konovalov --- mm/kasan/common.c | 47 +++--- mm/kasan/generic.c| 36 ++--- mm/kasan/kasan.

[PATCH v3 03/15] kasan: clean up comments in tests

2021-01-14 Thread Andrey Konovalov
Clarify and update comments in KASAN tests. Link: https://linux-review.googlesource.com/id/I6c816c51fa1e0eb7aa3dead6bda1f339d2af46c8 Reviewed-by: Marco Elver Signed-off-by: Andrey Konovalov --- lib/test_kasan.c| 59 + lib/test_kasan_module.c

[PATCH v3 04/15] kasan: add macros to simplify checking test constraints

2021-01-14 Thread Andrey Konovalov
: Marco Elver Reviewed-by: Alexander Potapenko Signed-off-by: Andrey Konovalov --- lib/test_kasan.c | 101 +++ 1 file changed, 31 insertions(+), 70 deletions(-) diff --git a/lib/test_kasan.c b/lib/test_kasan.c index 6f46e27c2af7..714ea27fcc3e 100644 --- a

[PATCH v3 05/15] kasan: add match-all tag tests

2021-01-14 Thread Andrey Konovalov
during execution for the SW_TAGS mode. Link: https://linux-review.googlesource.com/id/I78f1375efafa162b37f3abcb2c5bc2f3955dfd8e Reviewed-by: Marco Elver Signed-off-by: Andrey Konovalov --- lib/test_kasan.c | 92 mm/kasan/kasan.h | 6 2 files

[PATCH v3 06/15] kasan, arm64: allow using KUnit tests with HW_TAGS mode

2021-01-14 Thread Andrey Konovalov
the hardware tag-based mode; fixes come in the next few patches. Link: https://linux-review.googlesource.com/id/Id94dc9eccd33b23cda4950be408c27f879e474c8 Signed-off-by: Andrey Konovalov --- arch/arm64/include/asm/memory.h| 1 + arch/arm64/include/asm/mte-kasan.h | 12 + arch/arm64

[PATCH v3 02/15] kasan: clarify HW_TAGS impact on TBI

2021-01-14 Thread Andrey Konovalov
Reviewed-by: Alexander Potapenko Signed-off-by: Andrey Konovalov --- Documentation/dev-tools/kasan.rst | 16 +++- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan.rst index 0fc3fb1860c4..26c99852a852 100644

[PATCH v3 08/15] kasan: add compiler barriers to KUNIT_EXPECT_KASAN_FAIL

2021-01-14 Thread Andrey Konovalov
and use READ/WRITE_ONCE() for accessing fail_data fields. Link: https://linux-review.googlesource.com/id/I046079f48641a1d36fe627fc8827a9249102fd50 Reviewed-by: Marco Elver Signed-off-by: Andrey Konovalov --- lib/test_kasan.c | 17 - mm/kasan/report.c | 2 +- 2 files changed, 13

[PATCH v3 07/15] kasan: rename CONFIG_TEST_KASAN_MODULE

2021-01-14 Thread Andrey Konovalov
-by: Andrey Konovalov --- Documentation/dev-tools/kasan.rst | 8 lib/Kconfig.kasan | 2 +- lib/Makefile | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan.rst index

[PATCH v3 09/15] kasan: adapt kmalloc_uaf2 test to HW_TAGS mode

2021-01-14 Thread Andrey Konovalov
is 1/14, which is quite noticable. Allow up to 16 attempts at generating different tags for the tag-based modes. Link: https://linux-review.googlesource.com/id/Ibfa458ef2804ff465d8eb07434a300bf36388d55 Reviewed-by: Marco Elver Reviewed-by: Alexander Potapenko Signed-off-by: Andrey Kono

[PATCH v3 10/15] kasan: fix memory corruption in kasan_bitops_tags test

2021-01-14 Thread Andrey Konovalov
object's boundaries. Link: https://linux-review.googlesource.com/id/I67f51d1ee48f0a8d0fe2658c2a39e4879fe0832a Reviewed-by: Marco Elver Reviewed-by: Alexander Potapenko Signed-off-by: Andrey Konovalov --- lib/test_kasan.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff

[PATCH v3 14/15] kasan: add a test for kmem_cache_alloc/free_bulk

2021-01-14 Thread Andrey Konovalov
Add a test for kmem_cache_alloc/free_bulk to make sure there are no false-positives when these functions are used. Link: https://linux-review.googlesource.com/id/I2a8bf797aecf81baeac61380c567308f319e263d Signed-off-by: Andrey Konovalov --- lib/test_kasan.c | 38

[PATCH v3 15/15] kasan: don't run tests when KASAN is not enabled

2021-01-14 Thread Andrey Konovalov
Don't run KASAN tests when it's disabled with kasan.mode=off to avoid corrupting kernel memory. Link: https://linux-review.googlesource.com/id/I6447af436a69a94bfc35477f6bf4e2122948355e Signed-off-by: Andrey Konovalov --- lib/test_kasan.c | 5 + 1 file changed, 5 insertions(+) di

[PATCH v3 12/15] kasan: fix bug detection via ksize for HW_TAGS mode

2021-01-14 Thread Andrey Konovalov
trace pass _RET_IP_ to __kasan_check_byte(). Also add a new ksize_uaf() test that checks that a use-after-free is detected via ksize() itself, and via plain accesses that happen later. Link: https://linux-review.googlesource.com/id/Iaabf771881d0f9ce1b969f2a62938e99d3308ec5 Signed-off-by: Andrey

[PATCH v3 11/15] kasan: move _RET_IP_ to inline wrappers

2021-01-14 Thread Andrey Konovalov
P_ to those wrappers to simplify annotation call sites. Link: https://linux-review.googlesource.com/id/I8fb3c06d49671305ee184175a39591bc26647a67 Signed-off-by: Andrey Konovalov --- include/linux/kasan.h | 20 +--- mm/mempool.c | 2 +- mm/slab.c | 2 +- mm/s

[PATCH v3 13/15] kasan: add proper page allocator tests

2021-01-14 Thread Andrey Konovalov
: Alexander Potapenko Signed-off-by: Andrey Konovalov --- lib/test_kasan.c | 51 +++- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/lib/test_kasan.c b/lib/test_kasan.c index 566d894ba20b..ab22a653762e 100644 --- a/lib/test_kasan.c +++ b/lib

Re: [PATCH v2 2/2] kasan, arm64: fix pointer tags in KASAN reports

2021-01-15 Thread Andrey Konovalov
On Fri, Jan 15, 2021 at 11:49 AM Catalin Marinas wrote: > > On Thu, Jan 14, 2021 at 08:33:57PM +0100, Andrey Konovalov wrote: > > As of the "arm64: expose FAR_EL1 tag bits in siginfo" patch, the address > > that is passed to report_tag_fault has pointer tags in the for

Re: [PATCH v16 0/9] arm64: ARMv8.5-A: MTE: Add async mode support

2021-03-18 Thread Andrey Konovalov
On Thu, Mar 18, 2021 at 7:56 PM Catalin Marinas wrote: > > On Mon, Mar 15, 2021 at 01:20:10PM +, Vincenzo Frascino wrote: > > This patchset implements the asynchronous mode support for ARMv8.5-A > > Memory Tagging Extension (MTE), which is a debugging feature that allows > > to detect with the

[PATCH] mailmap: update Andrey Konovalov's email address

2021-03-18 Thread Andrey Konovalov
Use my personal email, the @google.com one will stop functioning soon. Signed-off-by: Andrey Konovalov --- .mailmap | 1 + 1 file changed, 1 insertion(+) diff --git a/.mailmap b/.mailmap index 85b93cdefc87..11219fa3b62b 100644 --- a/.mailmap +++ b/.mailmap @@ -36,6 +36,7 @@ Andrew Morton

Re: [PATCH v16 0/9] arm64: ARMv8.5-A: MTE: Add async mode support

2021-03-23 Thread Andrey Konovalov
On Thu, Mar 18, 2021 at 7:56 PM Catalin Marinas wrote: > > On Mon, Mar 15, 2021 at 01:20:10PM +, Vincenzo Frascino wrote: > > This patchset implements the asynchronous mode support for ARMv8.5-A > > Memory Tagging Extension (MTE), which is a debugging feature that allows > > to detect with the

Re: [PATCH] kasan, mm: fix crash with HW_TAGS and DEBUG_PAGEALLOC

2021-03-05 Thread Andrey Konovalov
On Thu, Mar 4, 2021 at 12:23 AM Andrew Morton wrote: > > On Fri, 26 Feb 2021 02:25:37 +0100 Andrey Konovalov > wrote: > > > Currently, kasan_free_nondeferred_pages()->kasan_free_pages() is called > > after debug_pagealloc_unmap_pages(). This causes a crash when >

Re: [PATCH v2 1/2] kasan: initialize shadow to TAG_INVALID for SW_TAGS

2021-03-05 Thread Andrey Konovalov
On Fri, Feb 19, 2021 at 1:22 AM Andrey Konovalov wrote: > > Currently, KASAN_SW_TAGS uses 0xFF as the default tag value for > unallocated memory. The underlying idea is that since that memory > hasn't been allocated yet, it's only supposed to be dereferenced > through

Re: [PATCH] kasan, mm: fix crash with HW_TAGS and DEBUG_PAGEALLOC

2021-03-05 Thread Andrey Konovalov
On Fri, Feb 26, 2021 at 2:25 AM Andrey Konovalov wrote: > > Currently, kasan_free_nondeferred_pages()->kasan_free_pages() is called > after debug_pagealloc_unmap_pages(). This causes a crash when > debug_pagealloc is enabled, as HW_TAGS KASAN can't set tags on an > unmapp

[PATCH v2] kasan, mm: fix crash with HW_TAGS and DEBUG_PAGEALLOC

2021-03-05 Thread Andrey Konovalov
ap_pages() and arch_free_page(), which can also make the page unavailable. Fixes: 94ab5b61ee16 ("kasan, arm64: enable CONFIG_KASAN_HW_TAGS") Cc: Signed-off-by: Andrey Konovalov --- Changes v1->v2: - Move kasan_free_nondeferred_pages() before arch_free_page(). --- mm/page_alloc.c

Re: [PATCH v2] kasan, mm: fix crash with HW_TAGS and DEBUG_PAGEALLOC

2021-03-05 Thread Andrey Konovalov
On Sat, Mar 6, 2021 at 12:50 AM Andrew Morton wrote: > > On Sat, 6 Mar 2021 00:36:33 +0100 Andrey Konovalov > wrote: > > > Currently, kasan_free_nondeferred_pages()->kasan_free_pages() is called > > after debug_pagealloc_unmap_pages(). This causes a crash when >

<    1   2   3   4   5   6   7   8   9   10   >