05 Dec, 2019

1 commit

  • kmem_cache_alloc_bulk/kmem_cache_free_bulk are used to make multiple
    allocations of the same size to avoid the overhead of multiple
    kmalloc/kfree calls. Extend the kmem_cache tests to make some calls to
    these APIs.

    Link: http://lkml.kernel.org/r/20191107191447.23058-1-labbott@redhat.com
    Signed-off-by: Laura Abbott
    Reviewed-by: Kees Cook
    Tested-by: Alexander Potapenko
    Cc: Laura Abbott
    Cc: Christoph Lameter
    Cc: Nick Desaulniers
    Cc: Kostya Serebryany
    Cc: Dmitry Vyukov
    Cc: Sandeep Patil
    Cc: Jann Horn
    Cc: Marco Elver
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Laura Abbott
     

15 Oct, 2019

1 commit

  • Make sure allocations from kmem_cache_alloc_bulk() and
    kmem_cache_free_bulk() are properly initialized.

    Link: http://lkml.kernel.org/r/20191007091605.30530-2-glider@google.com
    Signed-off-by: Alexander Potapenko
    Cc: Kees Cook
    Cc: Christoph Lameter
    Cc: Laura Abbott
    Cc: Thibaut Sautereau
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexander Potapenko
     

03 Aug, 2019

1 commit

  • kmalloc() shouldn't sleep while in RCU critical section, therefore use
    GFP_ATOMIC instead of GFP_KERNEL.

    The bug was spotted by the 0day kernel testing robot.

    Link: http://lkml.kernel.org/r/20190725121703.210874-1-glider@google.com
    Fixes: 7e659650cbda ("lib: introduce test_meminit module")
    Signed-off-by: Alexander Potapenko
    Reviewed-by: Andrew Morton
    Reported-by: kernel test robot
    Cc: Kees Cook
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexander Potapenko
     

17 Jul, 2019

3 commits

  • Fix the following issues in test_meminit.c:
    - |size| in fill_with_garbage_skip() should be signed so that it
    doesn't overflow if it's not aligned on sizeof(*p);
    - fill_with_garbage_skip() should actually skip |skip| bytes;
    - do_kmem_cache_size() should deallocate memory in the RCU case.

    Link: http://lkml.kernel.org/r/20190626133135.217355-1-glider@google.com
    Fixes: 7e659650cbda ("lib: introduce test_meminit module")
    Fixes: 94e8988d91c7 ("lib/test_meminit.c: fix -Wmaybe-uninitialized false positive")
    Signed-off-by: Alexander Potapenko
    Cc: Arnd Bergmann
    Cc: Kees Cook
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexander Potapenko
     
  • The conditional logic is too complicated for the compiler to fully
    comprehend:

    lib/test_meminit.c: In function 'test_meminit_init':
    lib/test_meminit.c:236:5: error: 'buf_copy' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    kfree(buf_copy);
    ^~~~~~~~~~~~~~~
    lib/test_meminit.c:201:14: note: 'buf_copy' was declared here

    Simplify it by splitting out the non-rcu section.

    Link: http://lkml.kernel.org/r/20190617131210.2190280-1-arnd@arndb.de
    Fixes: af734ee6ec85 ("lib: introduce test_meminit module")
    Signed-off-by: Arnd Bergmann
    Acked-by: Alexander Potapenko
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arnd Bergmann
     
  • Add tests for heap and pagealloc initialization. These can be used to
    check init_on_alloc and init_on_free implementations as well as other
    approaches to initialization.

    Expected test output in the case the kernel provides heap initialization
    (e.g. when running with either init_on_alloc=1 or init_on_free=1):

    test_meminit: all 10 tests in test_pages passed
    test_meminit: all 40 tests in test_kvmalloc passed
    test_meminit: all 60 tests in test_kmemcache passed
    test_meminit: all 10 tests in test_rcu_persistent passed
    test_meminit: all 120 tests passed!

    Link: http://lkml.kernel.org/r/20190529123812.43089-4-glider@google.com
    Signed-off-by: Alexander Potapenko
    Acked-by: Kees Cook
    Cc: Christoph Lameter
    Cc: Nick Desaulniers
    Cc: Kostya Serebryany
    Cc: Dmitry Vyukov
    Cc: Sandeep Patil
    Cc: Laura Abbott
    Cc: Jann Horn
    Cc: Marco Elver
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexander Potapenko