08 Aug, 2018

1 commit


13 Jun, 2018

1 commit


06 Jun, 2018

4 commits

  • Make sure that the memory allocators are behaving as expected in the face
    of overflows of multiplied arguments or when using the array_size()-family
    helpers.

    Example output of new tests (with the expected __alloc_pages_slowpath
    and vmalloc warnings about refusing giant allocations removed):

    [ 93.062076] test_overflow: kmalloc detected saturation
    [ 93.062988] test_overflow: kmalloc_node detected saturation
    [ 93.063818] test_overflow: kzalloc detected saturation
    [ 93.064539] test_overflow: kzalloc_node detected saturation
    [ 93.120386] test_overflow: kvmalloc detected saturation
    [ 93.143458] test_overflow: kvmalloc_node detected saturation
    [ 93.166861] test_overflow: kvzalloc detected saturation
    [ 93.189924] test_overflow: kvzalloc_node detected saturation
    [ 93.221671] test_overflow: vmalloc detected saturation
    [ 93.246326] test_overflow: vmalloc_node detected saturation
    [ 93.270260] test_overflow: vzalloc detected saturation
    [ 93.293824] test_overflow: vzalloc_node detected saturation
    [ 93.294597] test_overflow: devm_kmalloc detected saturation
    [ 93.295383] test_overflow: devm_kzalloc detected saturation
    [ 93.296217] test_overflow: all tests passed

    Signed-off-by: Kees Cook

    Kees Cook
     
  • This adjusts the overflow test to report failures, and prepares to
    add allocation tests.

    Signed-off-by: Kees Cook

    Kees Cook
     
  • Obviously a+b==b+a and a*b==b*a, but the implementation of the fallback
    checks are not entirely symmetric in how they treat a and b. So we might
    as well check the (b,a,r,of) tuple as well as the (a,b,r,of) one for +
    and *. Rather than more copy-paste, factor out the common part to
    check_one_op.

    Signed-off-by: Rasmus Villemoes
    Signed-off-by: Kees Cook

    Rasmus Villemoes
     
  • This adds a small module for testing that the check_*_overflow
    functions work as expected, whether implemented in C or using gcc
    builtins.

    Example output:

    test_overflow: u8 : 18 tests
    test_overflow: s8 : 19 tests
    test_overflow: u16: 17 tests
    test_overflow: s16: 17 tests
    test_overflow: u32: 17 tests
    test_overflow: s32: 17 tests
    test_overflow: u64: 17 tests
    test_overflow: s64: 21 tests

    Signed-off-by: Rasmus Villemoes
    [kees: add output to commit log, drop u64 tests on 32-bit]
    Signed-off-by: Kees Cook

    Rasmus Villemoes