Re: [PATCH 4.19 23/30] x86_64: increase stack size for KASAN_EXTRA

2019-02-21 Thread Andrey Ryabinin
On 2/21/19 5:36 PM, Greg Kroah-Hartman wrote: > 4.19-stable review patch. If anyone has any objections, please let me know. > Drop it please. It increases kernel stack up to 4-order which is above PAGE_ALLOC_COSTLY_ORDER. This changes behavior of the fork() by making it fail with -ENOMEM due of

Re: [PATCH] kasan: turn off asan-stack for clang-8 and earlier

2019-02-21 Thread Andrey Ryabinin
On 2/20/19 8:35 PM, Arnd Bergmann wrote: > On Wed, Feb 20, 2019 at 6:00 PM Andrey Ryabinin > wrote: >> On 2/20/19 5:51 PM, Arnd Bergmann wrote: >>> On Wed, Feb 20, 2019 at 3:45 PM Andrey Konovalov >>> wrote: >>> I would have to some more research, b

Re: [PATCH] kasan: turn off asan-stack for clang-8 and earlier

2019-02-20 Thread Andrey Ryabinin
On 2/20/19 5:51 PM, Arnd Bergmann wrote: > On Wed, Feb 20, 2019 at 3:45 PM Andrey Konovalov > wrote: >> >> On Tue, Feb 19, 2019 at 10:49 PM Arnd Bergmann wrote: >>> >>> Building an arm64 allmodconfig kernel with clang results in over 140 >>> warnings >>> about overly large stack frames, the

Re: [PATCH v5 3/3] powerpc/32: Add KASAN support

2019-02-15 Thread Andrey Ryabinin
On 2/15/19 1:10 PM, Christophe Leroy wrote: > > > Le 15/02/2019 à 11:01, Andrey Ryabinin a écrit : >> >> >> On 2/15/19 11:41 AM, Christophe Leroy wrote: >>> >>> >>> Le 14/02/2019 à 23:04, Daniel Axtens a écrit : >>>>

Re: [PATCH v5 3/3] powerpc/32: Add KASAN support

2019-02-15 Thread Andrey Ryabinin
On 2/15/19 11:41 AM, Christophe Leroy wrote: > > > Le 14/02/2019 à 23:04, Daniel Axtens a écrit : >> Hi Christophe, >> >>> --- a/arch/powerpc/include/asm/string.h >>> +++ b/arch/powerpc/include/asm/string.h >>> @@ -27,6 +27,20 @@ extern int memcmp(const void *,const void >>> *,__kernel_size_t

Re: [PATCH v4 3/3] powerpc/32: Add KASAN support

2019-02-12 Thread Andrey Ryabinin
On 2/12/19 2:38 PM, Christophe Leroy wrote: > > > Le 12/02/2019 à 02:08, Daniel Axtens a écrit : >> Andrey Ryabinin writes: >> >>> >>> Christophe, you can specify KASAN_SHADOW_OFFSET either in Kconfig (e.g. >>> x86_64) or >>> in Makefi

Re: [PATCH v4 3/3] powerpc/32: Add KASAN support

2019-02-12 Thread Andrey Ryabinin
On 2/12/19 4:08 AM, Daniel Axtens wrote: > Andrey Ryabinin writes: > >> On 2/11/19 3:25 PM, Andrey Konovalov wrote: >>> On Sat, Feb 9, 2019 at 12:55 PM christophe leroy >>> wrote: >>>> >>>> Hi Andrey, >>>> >>>> Le

Re: [PATCH v4 3/3] powerpc/32: Add KASAN support

2019-02-11 Thread Andrey Ryabinin
On 2/11/19 3:25 PM, Andrey Konovalov wrote: > On Sat, Feb 9, 2019 at 12:55 PM christophe leroy > wrote: >> >> Hi Andrey, >> >> Le 08/02/2019 à 18:40, Andrey Konovalov a écrit : >>> On Fri, Feb 8, 2019 at 6:17 PM Christophe Leroy >>> wrote: Hi Daniel, Le 08/02/2019 à 17:18,

Re: [PATCH] lib/ubsan: default UBSAN_ALIGNMENT to not set

2019-01-30 Thread Andrey Ryabinin
On 1/30/19 4:36 AM, Andrew Morton wrote: > On Fri, 11 Jan 2019 22:01:16 +0300 Andrey Ryabinin > wrote: > >> >> >> On 12/17/18 6:03 PM, Anders Roxell wrote: >>> When booting an allmodconfig kernel, there are a lot of false-positives. >>> With a mes

Re: [PATCH v2] page_poison: play nicely with KASAN

2019-01-15 Thread Andrey Ryabinin
check_memory_region+0x22d/0x250 > memset+0x28/0x40 > kernel_poison_pages+0x29e/0x3d5 > __free_pages_ok+0x75f/0x13e0 > > due to KASAN adds poisoned redzones around slab objects, but the page > poisoning needs to poison the whole page. > > Signed-off-by: Qian Cai > --- > Acked-by: Andrey Ryabinin

Re: [PATCH v3 3/3] powerpc/32: Add KASAN support

2019-01-15 Thread Andrey Ryabinin
On 1/12/19 2:16 PM, Christophe Leroy wrote: > +KASAN_SANITIZE_early_32.o := n > +KASAN_SANITIZE_cputable.o := n > +KASAN_SANITIZE_prom_init.o := n > + Usually it's also good idea to disable branch profiling - define DISABLE_BRANCH_PROFILING either in top of these files or via Makefile. Branch

Re: [PATCH v3 1/3] powerpc/mm: prepare kernel for KAsan on PPC32

2019-01-15 Thread Andrey Ryabinin
On 1/15/19 2:14 PM, Dmitry Vyukov wrote: > On Tue, Jan 15, 2019 at 8:27 AM Christophe Leroy > wrote: >> On 01/14/2019 09:34 AM, Dmitry Vyukov wrote: >>> On Sat, Jan 12, 2019 at 12:16 PM Christophe Leroy >>> wrote: >>> > >>> > In kernel/cputable.c, explicitly use memcpy() in order >>> > to allo

Re: [PATCH] kasan: Remove use after scope bugs detection.

2019-01-14 Thread Andrey Ryabinin
On 1/14/19 4:24 PM, Dmitry Vyukov wrote: > On Fri, Jan 11, 2019 at 7:58 PM Andrey Ryabinin > wrote: >> >> Use after scope bugs detector seems to be almost entirely useless >> for the linux kernel. It exists over two years, but I've seen only >> one valid bu

Re: [PATCH 2/3] mm/vmalloc: do not call kmemleak_free() on not yet accounted memory

2019-01-11 Thread Andrey Ryabinin
On 1/3/19 5:59 PM, Roman Penyaev wrote: > __vmalloc_area_node() calls vfree() on error path, which in turn calls > kmemleak_free(), but area is not yet accounted by kmemleak_vmalloc(). > > Signed-off-by: Roman Penyaev > Cc: Andrew Morton > Cc: Michal Hocko > Cc: Andre

Re: [PATCH 3/3] mm/vmalloc: pass VM_USERMAP flags directly to __vmalloc_node_range()

2019-01-11 Thread Andrey Ryabinin
range() call instead of finding the area > (which obviously takes time) after the allocation. > > Signed-off-by: Roman Penyaev > Cc: Andrew Morton > Cc: Michal Hocko > Cc: Andrey Ryabinin > Cc: Joe Perches > Cc: "Luis R. Rodriguez" > Cc: linux...@kvack.org >

Re: [PATCH 1/3] mm/vmalloc: fix size check for remap_vmalloc_range_partial()

2019-01-11 Thread Andrey Ryabinin
ng vmalloc_to_page() > returns NULL on last guard (non-existing) page. > > Signed-off-by: Roman Penyaev > Cc: Andrew Morton > Cc: Michal Hocko > Cc: Andrey Ryabinin > Cc: Joe Perches > Cc: "Luis R. Rodriguez" > Cc: linux...@kvack.org > Cc: linux-kernel

Re: [PATCH] lib/ubsan: default UBSAN_ALIGNMENT to not set

2019-01-11 Thread Andrey Ryabinin
l that turns > everything into '=m' or '=y' will turn off UBSAN_ALIGNMENT. > > Suggested-by: Arnd Bergmann > Signed-off-by: Anders Roxell > --- Acked-by: Andrey Ryabinin > lib/Kconfig.ubsan | 14 +- > 1 file changed, 9 insertions(+), 5 de

[PATCH] kasan: Remove use after scope bugs detection.

2019-01-11 Thread Andrey Ryabinin
ile preparing this patch I've noticed that we mistakenly enable use-after-scope detection for clang compiler regardless of CONFIG_KASAN_EXTRA setting. This is also fixed now. [1] http://lkml.kernel.org/r/<20171129052106.rhgbjhhis53hk...@wfg-t540p.sh.intel.com> Signed-off-by: Andrey Ry

Re: [RESEND PATCH] x86_64: increase stack size for KASAN_EXTRA

2019-01-11 Thread Andrey Ryabinin
On 1/10/19 12:52 AM, Qian Cai wrote: > If the kernel is configured with KASAN_EXTRA, the stack size is > increasted significantly due to enable this option will set > "-fstack-reuse" to "none" in GCC [1]. As the results, it could trigger > stack overrun quite often with 32k stack size compiled u

Re: [PATCH] kasan: fix kasan_check_read/write definitions

2019-01-11 Thread Andrey Ryabinin
unction. > > Fixes: b1864b828644 ("locking/atomics: build atomic headers as required") > Reported-by: Anders Roxell > Signed-off-by: Arnd Bergmann > --- Acked-by: Andrey Ryabinin

Re: [PATCH] page_poison: plays nicely with KASAN

2019-01-11 Thread Andrey Ryabinin
On 1/8/19 1:36 AM, Qian Cai wrote: > > diff --git a/mm/page_poison.c b/mm/page_poison.c > index f0c15e9017c0..e546b70e592a 100644 > --- a/mm/page_poison.c > +++ b/mm/page_poison.c > @@ -6,6 +6,7 @@ > #include > #include > #include > +#include > > static bool want_page_poisoning __re

Re: [PATCH] mm: cleancache: fix corruption on missed inode invalidation

2018-11-12 Thread Andrey Ryabinin
store shadow entries in page cache") >> To: Andrew Morton >> Cc: Johannes Weiner >> Cc: Mel Gorman >> Cc: Jan Kara >> Cc: Matthew Wilcox >> Cc: Andi Kleen >> Cc: linux...@kvack.org >> Cc: linux-kernel@vger.kernel.org >> Review

[PATCH v2] ubsan: don't mark __ubsan_handle_builtin_unreachable as noreturn

2018-11-07 Thread Andrey Ryabinin
noreturn attribute. [aryabinin: Add information about GCC bug in changelog] Signed-off-by: Arnd Bergmann Signed-off-by: Andrey Ryabinin --- lib/ubsan.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/ubsan.c b/lib/ubsan.c index 59fee96c29a0..e4162f59a81c 10

Re: [PATCH] ubsan: don't mark __ubsan_handle_builtin_unreachable as noreturn

2018-11-07 Thread Andrey Ryabinin
On 11/03/2018 12:27 AM, Olof Johansson wrote: > On Mon, Feb 5, 2018 at 2:31 AM Andrey Ryabinin > wrote: >> >> On 02/05/2018 01:15 PM, Arnd Bergmann wrote: >>> On Mon, Feb 5, 2018 at 10:02 AM, Andrey Ryabinin >>> wrote: >>>> >>>> &

Re: [PATCH v2 2/3] arm64: lib: use C string functions with KASAN enabled.

2018-10-29 Thread Andrey Ryabinin
On 10/29/2018 01:29 PM, Will Deacon wrote: > On Thu, Sep 20, 2018 at 04:56:30PM +0300, Andrey Ryabinin wrote: >> ARM64 has asm implementation of memchr(), memcmp(), str[r]chr(), >> str[n]cmp(), str[n]len(). KASAN don't see memory accesses in asm >> code, thus it can

Re: [PATCH] kernel/kcov: Replace vm_insert_page with vmf_insert_page

2018-09-21 Thread Andrey Ryabinin
On 09/21/2018 04:25 PM, Souptick Joarder wrote: > On Fri, Sep 21, 2018 at 5:22 PM Andrey Ryabinin > wrote: >> On 09/21/2018 01:03 PM, Souptick Joarder wrote: >>> On Fri, Sep 21, 2018 at 3:06 PM Andrey Ryabinin >>> wrote: >>>> >>&

Re: [PATCH] kernel/kcov: Replace vm_insert_page with vmf_insert_page

2018-09-21 Thread Andrey Ryabinin
On 09/21/2018 01:03 PM, Souptick Joarder wrote: > On Fri, Sep 21, 2018 at 3:06 PM Andrey Ryabinin > wrote: >> >> On 09/20/2018 10:12 PM, Souptick Joarder wrote: >>> There is a plan to replace vm_insert_page with new API >>> vmf_insert_page. As part of it,

Re: [PATCH] kernel/kcov: Replace vm_insert_page with vmf_insert_page

2018-09-21 Thread Andrey Ryabinin
On 09/20/2018 10:12 PM, Souptick Joarder wrote: > There is a plan to replace vm_insert_page with new API > vmf_insert_page. As part of it, converting vm_insert_page > to use vmf_insert_page. > > Signed-off-by: Souptick Joarder > --- > kernel/kcov.c | 5 +++-- > 1 file changed, 3 insertions(+), 2

Re: [PATCH] framewarn: expand KASAN_EXTRA exception to KASAN

2018-09-21 Thread Andrey Ryabinin
On 09/21/2018 04:50 AM, Andy Lutomirski wrote: > This patch seems reasonable, but you emailed the wrong people :) > > On Thu, Sep 20, 2018 at 5:15 PM Jason A. Donenfeld wrote: >> >> It turns out that KASAN in general will bloat stack frames in unexpected >> ways, not just KASAN_EXTRA. So, this

md: dead code in md_alloc()

2018-09-20 Thread Andrey Ryabinin
Hi, Kirill noticed that the following piece of code from md_alloc(dev, name) is dead: if (name && dev) /* * Creating /dev/mdNNN via "newarray", so adjust hold_active. */ mddev->hold_active = UNTIL_STOP; md_alloc() is always

[PATCH v2 1/3] linkage.h: Align weak symbols.

2018-09-20 Thread Andrey Ryabinin
Since WEAK() supposed to be used instead of ENTRY() to define weak symbols, but unlike ENTRY() it doesn't have ALIGN directive. It seems there is no actual reason to not have, so let's add ALIGN to WEAK() too. Signed-off-by: Andrey Ryabinin --- include/linux/linkage.h | 1 + 1 file

[PATCH v2 2/3] arm64: lib: use C string functions with KASAN enabled.

2018-09-20 Thread Andrey Ryabinin
m lib/string.c will be used. We can't just remove the asm functions because efistub uses them. And we can't have two non-weak functions either, so declare the asm functions as weak. Reported-by: Kyeongdon Kim Signed-off-by: Andrey Ryabinin --- Changes since v1: - Use WEAK() instead of .we

[PATCH v2 3/3] lib/test_kasan: Add tests for several string/memory API functions

2018-09-20 Thread Andrey Ryabinin
tests for these functions to be sure that we notice the problem on other architectures. Signed-off-by: Andrey Ryabinin --- No changes since v1. lib/test_kasan.c | 70 1 file changed, 70 insertions(+) diff --git a/lib/test_kas

Re: [LKP] [vfree, kvfree] a79ed8bfb2: BUG:sleeping_function_called_from_invalid_context_at_mm/util.c

2018-09-18 Thread Andrey Ryabinin
ply always kmalloc: if ((flags & GFP_KERNEL) != GFP_KERNEL) return kmalloc_node(size, flags, node); So in the above case, kvfree() always frees kmalloced memory -> and never calls vfree(). Signed-off-by: Andrey Ryabinin --- mm/util.c | 2 -- 1 file changed, 2

[PATCH 2/3] mm/vmalloc: Improve vfree() kerneldoc

2018-09-14 Thread Andrey Ryabinin
vfree() might sleep if called not in interrupt context. Explain that in the comment. Signed-off-by: Andrey Ryabinin --- mm/vmalloc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index a728fc492557..d00d42d6bf79 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c

[PATCH 1/3] kvfree(): Fix misleading comment.

2018-09-14 Thread Andrey Ryabinin
vfree() might sleep if called not in interrupt context. So does kvfree() too. Fix misleading kvfree()'s comment about allowed context. Fixes: 04b8e946075d ("mm/util.c: improve kvfree() kerneldoc") Signed-off-by: Andrey Ryabinin --- mm/util.c | 2 +- 1 file changed, 1 insertion

[PATCH 3/3] vfree, kvfree: Add debug might sleeps.

2018-09-14 Thread Andrey Ryabinin
Add might_sleep() calls to vfree(), kvfree() to catch potential sleep-in-atomic bugs earlier. Signed-off-by: Andrey Ryabinin --- mm/util.c| 2 ++ mm/vmalloc.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/mm/util.c b/mm/util.c index 7f1f165f46af..929ed1795bc1 100644 --- a/mm/util.c

Re: [PATCH] arm64: lib: use C string functions with KASAN enabled.

2018-09-11 Thread Andrey Ryabinin
On 09/10/2018 04:06 PM, Will Deacon wrote: > On Mon, Sep 10, 2018 at 01:53:03PM +0100, Mark Rutland wrote: >> On Mon, Sep 10, 2018 at 12:33:22PM +0100, Mark Rutland wrote: >>> On Fri, Sep 07, 2018 at 06:48:10PM +0300, Andrey Ryabinin wrote: >>>> On 09/07/20

Re: [PATCH] arm64: lib: use C string functions with KASAN enabled.

2018-09-07 Thread Andrey Ryabinin
On 09/07/2018 05:56 PM, Will Deacon wrote: > On Thu, Sep 06, 2018 at 08:05:33PM +0300, Andrey Ryabinin wrote: >> ARM64 has asm implementations of memchr(), memcmp(), str[r]chr(), >> str[n]cmp(), str[n]len(). KASAN don't see memory accesses in asm >> code, thus it can

Re: [PATCH v2] arm64: kasan: add interceptors for strcmp/strncmp functions

2018-09-06 Thread Andrey Ryabinin
On 09/05/2018 10:44 AM, Kyeongdon Kim wrote: > > > On 2018-09-05 오전 1:24, Andrey Ryabinin wrote: >> >> >> On 09/04/2018 01:10 PM, Andrey Ryabinin wrote: >> > >> > >> > On 09/04/2018 09:59 AM, Kyeongdon Kim wrote: >> > >> >

[PATCH] arm64: lib: use C string functions with KASAN enabled.

2018-09-06 Thread Andrey Ryabinin
m lib/string.c will be used. Declare asm functions as weak instead of removing them because they still can be used by efistub. Reported-by: Kyeongdon Kim Signed-off-by: Andrey Ryabinin --- arch/arm64/include/asm/string.h | 14 -- arch/arm64/kernel/arm64ksyms.c | 7 +-- arch/arm6

[PATCH] lib/test_kasan: Add tests for several string/memory API functions

2018-09-06 Thread Andrey Ryabinin
tests for these functions to be sure that we notice the problem on other architectures. Signed-off-by: Andrey Ryabinin --- lib/test_kasan.c | 70 1 file changed, 70 insertions(+) diff --git a/lib/test_kasan.c b/lib/test_kasan.c index ec

Re: [PATCH v2] arm64: kasan: add interceptors for strcmp/strncmp functions

2018-09-04 Thread Andrey Ryabinin
On 09/04/2018 01:10 PM, Andrey Ryabinin wrote: > > > On 09/04/2018 09:59 AM, Kyeongdon Kim wrote: > >>>> +#undef strncmp >>>> +int strncmp(const char *cs, const char *ct, size_t len) >>>> +{ >>>> + check_memory_region((unsigne

Re: [PATCH v2] arm64: kasan: add interceptors for strcmp/strncmp functions

2018-09-04 Thread Andrey Ryabinin
On 09/04/2018 09:59 AM, Kyeongdon Kim wrote: >> > +#undef strncmp >> > +int strncmp(const char *cs, const char *ct, size_t len) >> > +{ >> > + check_memory_region((unsigned long)cs, len, false, _RET_IP_); >> > + check_memory_region((unsigned long)ct, len, false, _RET_IP_); >> >> This will cause

Re: [PATCH v2] arm64: kasan: add interceptors for strcmp/strncmp functions

2018-09-03 Thread Andrey Ryabinin
On 08/23/2018 11:56 AM, Kyeongdon Kim wrote: > diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c > index c3bd520..61ad7f1 100644 > --- a/mm/kasan/kasan.c > +++ b/mm/kasan/kasan.c > @@ -304,6 +304,29 @@ void *memcpy(void *dest, const void *src, size_t len) > > return __memcpy(dest, src, l

Re: [PATCH v2] x86/entry/64: wipe KASAN stack shadow before rewind_stack_do_exit()

2018-08-29 Thread Andrey Ryabinin
g, rewind the stack before > do_exit()") > Signed-off-by: Jann Horn > --- Acked-by: Andrey Ryabinin

Re: [PATCH] x86/entry/64: wipe KASAN stack shadow in rewind_stack_do_exit()

2018-08-28 Thread Andrey Ryabinin
On 08/28/2018 01:38 PM, Jann Horn wrote: >> >> >> Why this has to be done in the rewind_stack_do_exit()? >> Are there any problems with calling the kasan_unpoison_task_stack(current) >> from oops_end(), before the rewind_stack_do_exit()? > > Ooh, good point! I didn't see that KASAN instrument

Re: [PATCH] x86/entry/64: wipe KASAN stack shadow in rewind_stack_do_exit()

2018-08-28 Thread Andrey Ryabinin
On 08/25/2018 02:58 AM, Jann Horn wrote: > Reset the KASAN shadow state of the task stack when rewinding RSP. > Without this, a kernel oops will leave parts of the stack poisoned, and > code running under do_exit() can trip over such poisoned regions and cause > nonsensical false-positive KASAN rep

Re: [PATCH] arm64: lib: use c string functions for KASAN support

2018-08-14 Thread Andrey Ryabinin
On 08/14/2018 10:55 AM, Kyeongdon Kim wrote: > Assembly optimized string functions cannot detect KASan bug. > This might have been the intention of the original author. > (not too much important to catch) > > But, I found the obvious uaf problem in strcmp() function. > - in this case, using 32

[PATCH] lib/ubsan: remove null-pointer checks.

2018-08-02 Thread Andrey Ryabinin
d something at NULL (root can do this), with things like SMAP should catch the issue. Signed-off-by: Andrey Ryabinin --- arch/parisc/Kconfig| 1 - arch/s390/Kconfig | 1 - lib/Kconfig.ubsan | 11 --- scripts/Makefile.ubsan | 4 4 files changed, 17 deletions(-) di

[PATCH v2 3/3] fs/fuse, splice_write: reduce allocation size.

2018-07-17 Thread Andrey Ryabinin
The 'bufs' array contains 'pipe->buffers' elements, but the fuse_dev_splice_write() uses only 'pipe->nrbufs' elements. So reduce the allocation size to 'pipe->nrbufs' elements. Signed-off-by: Andrey Ryabinin --- fs/fuse/dev.c | 2 +- 1 file cha

[PATCH v2 1/3] fs/fuse, splice_write: Don't access pipe->buffers without pipe_lock()

2018-07-17 Thread Andrey Ryabinin
x27;bufs' array. Move the bufs allocations inside pipe_lock()/pipe_unlock() to fix this. Fixes: dd3bb14f44a6 ("fuse: support splice() writing to fuse device") Signed-off-by: Andrey Ryabinin Cc: --- fs/fuse/dev.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs

[PATCH v2 2/3] fs/fuse, splice: use kvmalloc to allocate array of pipe_buffer structs.

2018-07-17 Thread Andrey Ryabinin
't need to be physically contiguous, use the kvmalloc_array() to allocate memory. If high order page isn't available, the kvamalloc*() will fallback to 0-order. Signed-off-by: Andrey Ryabinin --- fs/fuse/dev.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/

Re: [PATCH 2/2] fs/fuse, splice_write: reduce allocation size.

2018-07-17 Thread Andrey Ryabinin
On 07/17/2018 05:47 PM, Miklos Szeredi wrote: > On Mon, Jul 16, 2018 at 6:03 PM, Andrey Ryabinin > wrote: >> The 'bufs' array contains 'pipe->buffers' elements, but the >> fuse_dev_splice_write() uses only 'pipe->nrbufs' elements. > >

[PATCH 2/2] fs/fuse, splice_write: reduce allocation size.

2018-07-16 Thread Andrey Ryabinin
The 'bufs' array contains 'pipe->buffers' elements, but the fuse_dev_splice_write() uses only 'pipe->nrbufs' elements. So reduce the allocation size to 'pipe->nrbufs' elements. Signed-off-by: Andrey Ryabinin --- fs/fuse/dev.c | 2 +- 1 file cha

[PATCH 1/2] fs/fuse, splice: use kvmalloc to allocate array of pipe_buffer structs.

2018-07-16 Thread Andrey Ryabinin
't need to be physically contiguous, use the kvmalloc_array() to allocate memory. If high order page isn't available, the kvamalloc*() will fallback to 0-order. Signed-off-by: Andrey Ryabinin --- fs/fuse/dev.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/

Re: [PATCH v2] kernel/memremap, kasan: Make ZONE_DEVICE with work with KASAN

2018-07-02 Thread Andrey Ryabinin
On 06/30/2018 05:33 AM, Andrew Morton wrote: > On Fri, 29 Jun 2018 19:49:32 +0300 Andrey Ryabinin > wrote: > >> KASAN learns about hot added memory via the memory hotplug notifier. >> The devm_memremap_pages() intentionally skips calling memory hotplug >> notifier

[PATCH] mm/fadvise: Fix signed overflow UBSAN complaint

2018-06-29 Thread Andrey Ryabinin
represented in type 'long long int' Use unsigned types to do math. Unsigned overflow is defined so UBSAN will not complain about it. This patch doesn't change generated code. Reported-by: Signed-off-by: Andrey Ryabinin --- mm/fadvise.c | 2 +- 1 file changed, 1 insertion

[PATCH v2] kernel/memremap, kasan: Make ZONE_DEVICE with work with KASAN

2018-06-29 Thread Andrey Ryabinin
evice memory. Reported-by: Dave Chinner Signed-off-by: Andrey Ryabinin Cc: Dan Williams Cc: Dmitry Vyukov Cc: Alexander Potapenko --- Changes since v1: - Compilation fixes. include/linux/kasan.h | 13 ++- kernel/memremap.c | 10 ++ mm/kasan/kasan_init.c

[tip:x86/urgent] x86/mm: Don't free P4D table when it is folded at runtime

2018-06-26 Thread tip-bot for Andrey Ryabinin
Commit-ID: 0e311d237d7f3022b7dafb639b42541bfb42fe94 Gitweb: https://git.kernel.org/tip/0e311d237d7f3022b7dafb639b42541bfb42fe94 Author: Andrey Ryabinin AuthorDate: Mon, 25 Jun 2018 13:24:27 +0300 Committer: Ingo Molnar CommitDate: Tue, 26 Jun 2018 09:21:48 +0200 x86/mm: Don't fre

[PATCH] kernel/memremap, kasan: Make ZONE_DEVICE with work with KASAN

2018-06-25 Thread Andrey Ryabinin
evice memory. Reported-by: Dave Chinner Signed-off-by: Andrey Ryabinin Cc: Dan Williams Cc: Dmitry Vyukov Cc: Alexander Potapenko --- include/linux/kasan.h | 13 ++- kernel/memremap.c | 10 ++ mm/kasan/kasan_init.c | 316 +++--- 3 files ch

Re: [PATCH 1/1] kasan: fix shadow_size calculation error in kasan_module_alloc

2018-06-25 Thread Andrey Ryabinin
gt; ... > memset(ptr, 0, mod->core_layout.size);//crashed > > Unable to handle kernel paging request at virtual address 0f97b000 > .. > Call trace: > [] __asan_storeN+0x174/0x1a8 > [] memset+0x24/0x48 > [] layout_and_allocate+0xcd8/0x1800 >

[PATCH] x86/mm: don't free p4d table when it is folded at runtime.

2018-06-25 Thread Andrey Ryabinin
86/mm: Fold p4d page table layer at runtime") Signed-off-by: Andrey Ryabinin --- arch/x86/include/asm/pgalloc.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h index ada6410fd2ec..fbd578daa66e 100644 --- a/arch/x86/include

Re: [PATCH] slub: fix __kmem_cache_empty for !CONFIG_SLUB_DEBUG

2018-06-20 Thread Andrey Ryabinin
On 06/20/2018 12:33 AM, Shakeel Butt wrote: > For !CONFIG_SLUB_DEBUG, SLUB does not maintain the number of slabs > allocated per node for a kmem_cache. Thus, slabs_node() in > __kmem_cache_empty() will always return 0. So, in such situation, it is > required to check per-cpu slabs to make sure i

Re: Possible regression in "slab, slub: skip unnecessary kasan_cache_shutdown()"

2018-06-19 Thread Andrey Ryabinin
On 06/19/2018 05:51 AM, Jason A. Donenfeld wrote: > Hello Shakeel, > > It may be the case that f9e13c0a5a33d1eaec374d6d4dab53a4f72756a0 has > introduced a regression. I've bisected a failing test to this commit, > and after staring at the my code for a long time, I'm unable to find a > bug that

Re: [PATCH] mm/kasan: Don't vfree() nonexistent vm_area.

2018-05-23 Thread Andrey Ryabinin
On 05/23/2018 12:03 AM, Andrew Morton wrote: > On Tue, 22 May 2018 19:44:06 +0300 Andrey Ryabinin > wrote: > >>> Obviously we can't call vfree() to free memory that wasn't allocated via >>> vmalloc(). Use find_vm_area() to see if we can call vfree(). >&

Re: [PATCH v2 2/2] kasan: fix memory hotplug during boot

2018-05-23 Thread Andrey Ryabinin
On 05/23/2018 12:07 AM, Andrew Morton wrote: > On Tue, 22 May 2018 22:50:12 +0300 Andrey Ryabinin > wrote: > >> >> >> On 05/22/2018 07:36 PM, David Hildenbrand wrote: >>> On 22.05.2018 18:26, Andrey Ryabinin wrote: >>>> >>>> >&

Re: [PATCH v2 2/2] kasan: fix memory hotplug during boot

2018-05-22 Thread Andrey Ryabinin
On 05/22/2018 07:36 PM, David Hildenbrand wrote: > On 22.05.2018 18:26, Andrey Ryabinin wrote: >> >> >> On 05/22/2018 01:07 PM, David Hildenbrand wrote: >>> Using module_init() is wrong. E.g. ACPI adds and onlines memory before >>> our memory notifier g

Re: [PATCH] mm/kasan: Don't vfree() nonexistent vm_area.

2018-05-22 Thread Andrey Ryabinin
On 02/01/2018 07:33 PM, Andrey Ryabinin wrote: > KASAN uses different routines to map shadow for hot added memory and memory > obtained in boot process. Attempt to offline memory onlined by normal boot > process leads to this: > > Trying to vfree() nonexistent vm area (0

Re: [PATCH v2 1/2] kasan: free allocated shadow memory on MEM_CANCEL_ONLINE

2018-05-22 Thread Andrey Ryabinin
On 05/22/2018 01:07 PM, David Hildenbrand wrote: > We have to free memory again when we cancel onlining, otherwise a later > onlining attempt will fail. > > Signed-off-by: David Hildenbrand > --- Fixes: fa69b5989bb0 ("mm/kasan: add support for memory hotplug") Acke

Re: [PATCH v2 2/2] kasan: fix memory hotplug during boot

2018-05-22 Thread Andrey Ryabinin
eproducable with QEMU, just specify a DIMM when starting up. reproducible > > Signed-off-by: David Hildenbrand > --- Fixes: fa69b5989bb0 ("mm/kasan: add support for memory hotplug") Acked-by: Andrey Ryabinin Cc: > mm/kasan/kasan.c | 2 +- > 1 file changed, 1

Re: [PATCH] lib/stackdepot.c: use a non-instrumented version of memcpy()

2018-05-16 Thread Andrey Ryabinin
spent in the instrumentation. > > (A similar change has been previously committed for memcmp()) > > Signed-off-by: Alexander Potapenko > Cc: Andrey Ryabinin > Cc: Dmitry Vyukov > --- > lib/stackdepot.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > dif

Re: [PATCH 2/3] kcov: prefault the kcov_area

2018-05-04 Thread Andrey Ryabinin
On 05/04/2018 05:38 PM, Mark Rutland wrote: > On Fri, May 04, 2018 at 05:36:49PM +0300, Andrey Ryabinin wrote: >> >> >> On 05/04/2018 04:55 PM, Mark Rutland wrote: >> >>> >>> +static void kcov_fault_in_area(struct kcov *kcov) >>> +{ >

Re: [PATCH 2/3] kcov: prefault the kcov_area

2018-05-04 Thread Andrey Ryabinin
On 05/04/2018 04:55 PM, Mark Rutland wrote: > > +static void kcov_fault_in_area(struct kcov *kcov) > +{ > + unsigned long stride = PAGE_SIZE / sizeof(unsigned long); > + unsigned long *area = kcov->area; > + unsigned long offset; > + > + for (offset = 0; offset < kcov->size; of

Re: [PATCH 3/3] sched/core / kcov: avoid kcov_area during task switch

2018-05-04 Thread Andrey Ryabinin
On 05/04/2018 04:55 PM, Mark Rutland wrote: > +#define kcov_prepare_switch(t) \ > +do { \ > + (t)->kcov_mode |= KCOV_IN_CTXSW;\ > +} while (0) > + > +#define kcov_finish_switch(t)\ > +do {

Re: [kcov] watchdog: BUG: soft lockup - CPU#0 stuck for 22s! [swapper/0:1]

2018-04-20 Thread Andrey Ryabinin
On 04/20/2018 07:45 PM, Yury Norov wrote: > On Fri, Apr 20, 2018 at 05:08:23PM +0300, Andrey Ryabinin wrote: >> >> >> On 04/19/2018 06:01 AM, Fengguang Wu wrote: >>> Hello, >>> >>> FYI this happens in mainline kernel 4.17.0-rc1. >>&g

Re: [kcov] watchdog: BUG: soft lockup - CPU#0 stuck for 22s! [swapper/0:1]

2018-04-20 Thread Andrey Ryabinin
On 04/19/2018 06:01 AM, Fengguang Wu wrote: > Hello, > > FYI this happens in mainline kernel 4.17.0-rc1. > It at least dates back to v4.8 . > > [ 25.697463] > [ 25.697463] Start testing find_bit() with random-filled bitmap > [ 25.736615] find_next_bit:30203201 ns, 163965 i

Re: [cfs_trace_lock_tcd] BUG: KASAN: null-ptr-deref in cfs_trace_lock_tcd+0x25/0xeb

2018-04-19 Thread Andrey Ryabinin
On 04/19/2018 04:35 PM, Andrey Ryabinin wrote: > > > On 04/18/2018 09:37 PM, Linus Torvalds wrote: >> Ugh, that lustre code is disgusting. >> >> I thought we were getting rid of it. >> >> Anyway, I started looking at why the stack trace is such an incredi

Re: [cfs_trace_lock_tcd] BUG: KASAN: null-ptr-deref in cfs_trace_lock_tcd+0x25/0xeb

2018-04-19 Thread Andrey Ryabinin
On 04/18/2018 09:37 PM, Linus Torvalds wrote: > Ugh, that lustre code is disgusting. > > I thought we were getting rid of it. > > Anyway, I started looking at why the stack trace is such an incredible > mess, with lots of stale entries. > > The reason (well, _one_ reason) seems to be "ksocknal

Re: [PATCH] kasan: add no_sanitize attribute for clang builds

2018-04-13 Thread Andrey Ryabinin
On 04/13/2018 08:34 PM, Andrey Konovalov wrote: > On Fri, Apr 13, 2018 at 5:31 PM, Andrey Ryabinin > wrote: >> >> >> On 04/12/2018 08:29 PM, Andrey Konovalov wrote: >>> KASAN uses the __no_sanitize_address macro to disable instrumentation >>> of particu

Re: [PATCH] kasan: add no_sanitize attribute for clang builds

2018-04-13 Thread Andrey Ryabinin
On 04/12/2018 08:29 PM, Andrey Konovalov wrote: > KASAN uses the __no_sanitize_address macro to disable instrumentation > of particular functions. Right now it's defined only for GCC build, > which causes false positives when clang is used. > > This patch adds a definition for clang. > > Note,

[PATCH v3 2/2] mm/vmscan: don't mess with pgdat->flags in memcg reclaim

2018-04-06 Thread Andrey Ryabinin
user0m0.487s sys 1m8.505s According to the tracepoint in wait_iff_congested(), the 'cat' spent 50% of the time sleeping there. With the patch, cat don't waste time anymore: # time cat /dev/sda > /dev/null real 5m32.911s user0m0.411s sys

[PATCH v3 1/2] mm/vmscan: don't change pgdat state on base of a single LRU list state

2018-04-06 Thread Andrey Ryabinin
group reclaim may alter global pgdat flags too, which is wrong. But that is separate issue and will be addressed in the next patch. This change will not have any effect on a systems with all workload concentrated in a single cgroup. Signed-off-by: Andrey Ryabinin Reviewed-by: Shakeel Butt Cc

Re: [PATCH v2 3/4] mm/vmscan: Don't change pgdat state on base of a single LRU list state.

2018-04-06 Thread Andrey Ryabinin
On 04/06/2018 07:28 PM, Johannes Weiner wrote: > > This isn't quite equivalent to what we have right now. > > Yes, nr_dirty, nr_unqueued_dirty and nr_congested apply to file pages > only. That part is about waking the flushers and avoiding writing > files in 4k chunks from reclaim context. So t

Re: [PATCH] mm-vmscan-dont-mess-with-pgdat-flags-in-memcg-reclaim-v2-fix

2018-04-06 Thread Andrey Ryabinin
On 04/06/2018 05:37 PM, Shakeel Butt wrote: >> >> @@ -2482,7 +2494,7 @@ static inline bool should_continue_reclaim(struct >> pglist_data *pgdat, >> static bool pgdat_memcg_congested(pg_data_t *pgdat, struct mem_cgroup >> *memcg) >> { >> return test_bit(PGDAT_CONGESTED, &pgdat->flags)

[PATCH] mm-vmscan-dont-mess-with-pgdat-flags-in-memcg-reclaim-v2-fix

2018-04-06 Thread Andrey Ryabinin
laim from node B. Make congestion state per-cgroup-per-node and record it in 'struct mem_cgroup_per_node'. Signed-off-by: Andrey Ryabinin --- include/linux/memcontrol.h | 5 +++-- mm/vmscan.c| 39 +-- 2 files changed, 28 insertions

Re: [PATCH v2 4/4] mm/vmscan: Don't mess with pgdat->flags in memcg reclaim.

2018-04-06 Thread Andrey Ryabinin
On 04/06/2018 05:13 AM, Shakeel Butt wrote: > On Fri, Mar 23, 2018 at 8:20 AM, Andrey Ryabinin > wrote: >> memcg reclaim may alter pgdat->flags based on the state of LRU lists >> in cgroup and its children. PGDAT_WRITEBACK may force kswapd to sleep >> congested_wa

Re: general protection fault in __mem_cgroup_free

2018-04-03 Thread Andrey Ryabinin
ed-by: syzbot+8a5de3cce7cdc70e9...@syzkaller.appspotmail.com > Fixes: 00f3ca2c2d66 ("mm: memcontrol: per-lruvec stats infrastructure") > Signed-off-by: Michal Hocko Reviewed-by: Andrey Ryabinin > --- > mm/memcontrol.c | 3 +++ > 1 file changed, 3 insertions(+) > >

Re: [PATCH] x86/mm: Fix documentation of module mapping with 4-level paging

2018-04-02 Thread Andrey Ryabinin
v > Fixes: f5a40711fa58 ("x86/mm: Set MODULES_END to 0xff00") > Cc: Andrey Ryabinin > --- Acked-by: Andrey Ryabinin > Documentation/x86/x86_64/mm.txt | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/Documentation/x86/x86_64/

Re: [PATCH] slab, slub: skip unnecessary kasan_cache_shutdown()

2018-03-28 Thread Andrey Ryabinin
process_one_work > worker_thread > kthread > ret_from_fork > > This patch is based on the observation that if the kmem_cache to be > destroyed is empty then there should not be any objects of this cache in > the quarantine. > > Without the patch the sc

[PATCH v2 1/4] mm/vmscan: Update stale comments

2018-03-23 Thread Andrey Ryabinin
Update some comments that become stale since transiton from per-zone to per-node reclaim. Signed-off-by: Andrey Ryabinin Acked-by: Michal Hocko --- mm/vmscan.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 4390a8d5be41

[PATCH v2 3/4] mm/vmscan: Don't change pgdat state on base of a single LRU list state.

2018-03-23 Thread Andrey Ryabinin
group reclaim may alter global pgdat flags too, which is wrong. But that is separate issue and will be addressed in the next patch. This change will not have any effect on a systems with all workload concentrated in a single cgroup. Signed-off-by: Andrey Ryabinin --- mm/vmscan.c

[PATCH v2 0/4] vmscan per-cgroup reclaim fixes

2018-03-23 Thread Andrey Ryabinin
rguments is also not very good. Yes, these numbers could be obtained from mm_vmscan_lru_isolate tracepoint, but it's easier when it's all in one place. - Compare with nr_writeback,dirty, etc only isolated file pages as it always was. - Minor changelog tweaks. Andrey Ryabinin (4):

[PATCH v2 2/4] mm/vmscan: remove redundant current_may_throttle() check

2018-03-23 Thread Andrey Ryabinin
Only kswapd can have non-zero nr_immediate, and current_may_throttle() is always true for kswapd (PF_LESS_THROTTLE bit is never set) thus it's enough to check stat.nr_immediate only. Signed-off-by: Andrey Ryabinin Acked-by: Michal Hocko --- mm/vmscan.c | 2 +- 1 file changed, 1 insertion(

[PATCH v2 4/4] mm/vmscan: Don't mess with pgdat->flags in memcg reclaim.

2018-03-23 Thread Andrey Ryabinin
real10m15.054s user0m0.487s sys 1m8.505s According to the tracepoint in wait_iff_congested(), the 'cat' spent 50% of the time sleeping there. With the patch, cat don't waste time anymore: # time cat /dev/sda > /dev/null real5m32.911s us

Re: [PATCH] mm, vmscan, tracing: Use pointer to reclaim_stat struct in trace event

2018-03-23 Thread Andrey Ryabinin
On 03/23/2018 12:10 AM, Andrew Morton wrote: > On Thu, 22 Mar 2018 12:10:03 -0400 Steven Rostedt wrote: > >> >> The trace event trace_mm_vmscan_lru_shrink_inactive() currently has 12 >> parameters! Seven of them are from the reclaim_stat structure. This >> structure is currently local to mm/vms

Re: [PATCH 6/6] mm/vmscan: Don't mess with pgdat->flags in memcg reclaim.

2018-03-21 Thread Andrey Ryabinin
On 03/21/2018 02:43 PM, Michal Hocko wrote: > On Wed 21-03-18 14:14:35, Andrey Ryabinin wrote: >> >> >> On 03/20/2018 06:29 PM, Michal Hocko wrote: >> >>>> Leave all pgdat->flags manipulations to kswapd. kswapd scans the whole >>>> pgdat, so

Re: [PATCH 5/6] mm/vmscan: Don't change pgdat state on base of a single LRU list state.

2018-03-21 Thread Andrey Ryabinin
On 03/21/2018 02:32 PM, Michal Hocko wrote: > On Wed 21-03-18 13:40:32, Andrey Ryabinin wrote: >> On 03/20/2018 06:25 PM, Michal Hocko wrote: >>> On Thu 15-03-18 19:45:52, Andrey Ryabinin wrote: >>>> We have separate LRU list for each memory cgroup. Memory reclaim

Re: [PATCH 6/6] mm/vmscan: Don't mess with pgdat->flags in memcg reclaim.

2018-03-21 Thread Andrey Ryabinin
ng to the tracepoint in wait_iff_congested(), the 'cat' spent 50% >> of the time sleeping there. >> >> With the patch, cat don't waste time anymore: >> >> # time cat /dev/sda > /dev/null >> real5m32.911s >> user0m0.41

Re: [PATCH 5/6] mm/vmscan: Don't change pgdat state on base of a single LRU list state.

2018-03-21 Thread Andrey Ryabinin
On 03/20/2018 06:25 PM, Michal Hocko wrote: > On Thu 15-03-18 19:45:52, Andrey Ryabinin wrote: >> We have separate LRU list for each memory cgroup. Memory reclaim iterates >> over cgroups and calls shrink_inactive_list() every inactive LRU list. >> Based on the

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