1 #!/bin/bash 1 #!/bin/bash 2 # SPDX-License-Identifier: GPL-2.0 2 # SPDX-License-Identifier: GPL-2.0 3 # Copyright (C) 2018 Joe Lawrence <joe.lawrence 3 # Copyright (C) 2018 Joe Lawrence <joe.lawrence@redhat.com> 4 4 5 . $(dirname $0)/functions.sh 5 . $(dirname $0)/functions.sh 6 6 7 MOD_TEST=test_klp_shadow_vars 7 MOD_TEST=test_klp_shadow_vars 8 8 9 setup_config 9 setup_config 10 10 11 11 12 # - load a module that exercises the shadow va 12 # - load a module that exercises the shadow variable API 13 13 14 start_test "basic shadow variable API" 14 start_test "basic shadow variable API" 15 15 16 load_mod $MOD_TEST 16 load_mod $MOD_TEST 17 unload_mod $MOD_TEST 17 unload_mod $MOD_TEST 18 18 19 check_result "% insmod test_modules/$MOD_TEST. 19 check_result "% insmod test_modules/$MOD_TEST.ko 20 $MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1234) 20 $MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1234) = PTR0 21 $MOD_TEST: got expected NULL result 21 $MOD_TEST: got expected NULL result 22 $MOD_TEST: shadow_ctor: PTR3 -> PTR2 22 $MOD_TEST: shadow_ctor: PTR3 -> PTR2 23 $MOD_TEST: klp_shadow_get_or_alloc(obj=PTR1, i 23 $MOD_TEST: klp_shadow_get_or_alloc(obj=PTR1, id=0x1234, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR2 = PTR3 24 $MOD_TEST: shadow_ctor: PTR6 -> PTR5 24 $MOD_TEST: shadow_ctor: PTR6 -> PTR5 25 $MOD_TEST: klp_shadow_alloc(obj=PTR1, id=0x123 25 $MOD_TEST: klp_shadow_alloc(obj=PTR1, id=0x1235, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR5 = PTR6 26 $MOD_TEST: shadow_ctor: PTR8 -> PTR7 26 $MOD_TEST: shadow_ctor: PTR8 -> PTR7 27 $MOD_TEST: klp_shadow_alloc(obj=PTR9, id=0x123 27 $MOD_TEST: klp_shadow_alloc(obj=PTR9, id=0x1234, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR7 = PTR8 28 $MOD_TEST: shadow_ctor: PTR11 -> PTR10 28 $MOD_TEST: shadow_ctor: PTR11 -> PTR10 29 $MOD_TEST: klp_shadow_alloc(obj=PTR9, id=0x123 29 $MOD_TEST: klp_shadow_alloc(obj=PTR9, id=0x1235, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR10 = PTR11 30 $MOD_TEST: shadow_ctor: PTR13 -> PTR12 30 $MOD_TEST: shadow_ctor: PTR13 -> PTR12 31 $MOD_TEST: klp_shadow_get_or_alloc(obj=PTR14, 31 $MOD_TEST: klp_shadow_get_or_alloc(obj=PTR14, id=0x1234, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR12 = PTR13 32 $MOD_TEST: shadow_ctor: PTR16 -> PTR15 32 $MOD_TEST: shadow_ctor: PTR16 -> PTR15 33 $MOD_TEST: klp_shadow_alloc(obj=PTR14, id=0x12 33 $MOD_TEST: klp_shadow_alloc(obj=PTR14, id=0x1235, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR15 = PTR16 34 $MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1234) 34 $MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1234) = PTR3 35 $MOD_TEST: got expected PTR3 -> PTR2 result 35 $MOD_TEST: got expected PTR3 -> PTR2 result 36 $MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1235) 36 $MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1235) = PTR6 37 $MOD_TEST: got expected PTR6 -> PTR5 result 37 $MOD_TEST: got expected PTR6 -> PTR5 result 38 $MOD_TEST: klp_shadow_get(obj=PTR9, id=0x1234) 38 $MOD_TEST: klp_shadow_get(obj=PTR9, id=0x1234) = PTR8 39 $MOD_TEST: got expected PTR8 -> PTR7 result 39 $MOD_TEST: got expected PTR8 -> PTR7 result 40 $MOD_TEST: klp_shadow_get(obj=PTR9, id=0x1235) 40 $MOD_TEST: klp_shadow_get(obj=PTR9, id=0x1235) = PTR11 41 $MOD_TEST: got expected PTR11 -> PTR10 resul 41 $MOD_TEST: got expected PTR11 -> PTR10 result 42 $MOD_TEST: klp_shadow_get(obj=PTR14, id=0x1234 42 $MOD_TEST: klp_shadow_get(obj=PTR14, id=0x1234) = PTR13 43 $MOD_TEST: got expected PTR13 -> PTR12 resul 43 $MOD_TEST: got expected PTR13 -> PTR12 result 44 $MOD_TEST: klp_shadow_get(obj=PTR14, id=0x1235 44 $MOD_TEST: klp_shadow_get(obj=PTR14, id=0x1235) = PTR16 45 $MOD_TEST: got expected PTR16 -> PTR15 resul 45 $MOD_TEST: got expected PTR16 -> PTR15 result 46 $MOD_TEST: klp_shadow_get_or_alloc(obj=PTR1, i 46 $MOD_TEST: klp_shadow_get_or_alloc(obj=PTR1, id=0x1234, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR2 = PTR3 47 $MOD_TEST: got expected PTR3 -> PTR2 result 47 $MOD_TEST: got expected PTR3 -> PTR2 result 48 $MOD_TEST: klp_shadow_get_or_alloc(obj=PTR9, i 48 $MOD_TEST: klp_shadow_get_or_alloc(obj=PTR9, id=0x1234, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR7 = PTR8 49 $MOD_TEST: got expected PTR8 -> PTR7 result 49 $MOD_TEST: got expected PTR8 -> PTR7 result 50 $MOD_TEST: klp_shadow_get_or_alloc(obj=PTR14, 50 $MOD_TEST: klp_shadow_get_or_alloc(obj=PTR14, id=0x1234, size=8, gfp_flags=GFP_KERNEL), ctor=PTR4, ctor_data=PTR12 = PTR13 51 $MOD_TEST: got expected PTR13 -> PTR12 resul 51 $MOD_TEST: got expected PTR13 -> PTR12 result 52 $MOD_TEST: shadow_dtor(obj=PTR1, shadow_data=P 52 $MOD_TEST: shadow_dtor(obj=PTR1, shadow_data=PTR3) 53 $MOD_TEST: klp_shadow_free(obj=PTR1, id=0x1234 53 $MOD_TEST: klp_shadow_free(obj=PTR1, id=0x1234, dtor=PTR17) 54 $MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1234) 54 $MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1234) = PTR0 55 $MOD_TEST: got expected NULL result 55 $MOD_TEST: got expected NULL result 56 $MOD_TEST: shadow_dtor(obj=PTR9, shadow_data=P 56 $MOD_TEST: shadow_dtor(obj=PTR9, shadow_data=PTR8) 57 $MOD_TEST: klp_shadow_free(obj=PTR9, id=0x1234 57 $MOD_TEST: klp_shadow_free(obj=PTR9, id=0x1234, dtor=PTR17) 58 $MOD_TEST: klp_shadow_get(obj=PTR9, id=0x1234) 58 $MOD_TEST: klp_shadow_get(obj=PTR9, id=0x1234) = PTR0 59 $MOD_TEST: got expected NULL result 59 $MOD_TEST: got expected NULL result 60 $MOD_TEST: shadow_dtor(obj=PTR14, shadow_data= 60 $MOD_TEST: shadow_dtor(obj=PTR14, shadow_data=PTR13) 61 $MOD_TEST: klp_shadow_free(obj=PTR14, id=0x123 61 $MOD_TEST: klp_shadow_free(obj=PTR14, id=0x1234, dtor=PTR17) 62 $MOD_TEST: klp_shadow_get(obj=PTR14, id=0x1234 62 $MOD_TEST: klp_shadow_get(obj=PTR14, id=0x1234) = PTR0 63 $MOD_TEST: got expected NULL result 63 $MOD_TEST: got expected NULL result 64 $MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1235) 64 $MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1235) = PTR6 65 $MOD_TEST: got expected PTR6 -> PTR5 result 65 $MOD_TEST: got expected PTR6 -> PTR5 result 66 $MOD_TEST: klp_shadow_get(obj=PTR9, id=0x1235) 66 $MOD_TEST: klp_shadow_get(obj=PTR9, id=0x1235) = PTR11 67 $MOD_TEST: got expected PTR11 -> PTR10 resul 67 $MOD_TEST: got expected PTR11 -> PTR10 result 68 $MOD_TEST: klp_shadow_get(obj=PTR14, id=0x1235 68 $MOD_TEST: klp_shadow_get(obj=PTR14, id=0x1235) = PTR16 69 $MOD_TEST: got expected PTR16 -> PTR15 resul 69 $MOD_TEST: got expected PTR16 -> PTR15 result 70 $MOD_TEST: klp_shadow_free_all(id=0x1235, dtor 70 $MOD_TEST: klp_shadow_free_all(id=0x1235, dtor=PTR0) 71 $MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1235) 71 $MOD_TEST: klp_shadow_get(obj=PTR1, id=0x1235) = PTR0 72 $MOD_TEST: got expected NULL result 72 $MOD_TEST: got expected NULL result 73 $MOD_TEST: klp_shadow_get(obj=PTR9, id=0x1235) 73 $MOD_TEST: klp_shadow_get(obj=PTR9, id=0x1235) = PTR0 74 $MOD_TEST: got expected NULL result 74 $MOD_TEST: got expected NULL result 75 $MOD_TEST: klp_shadow_get(obj=PTR14, id=0x1235 75 $MOD_TEST: klp_shadow_get(obj=PTR14, id=0x1235) = PTR0 76 $MOD_TEST: got expected NULL result 76 $MOD_TEST: got expected NULL result 77 % rmmod $MOD_TEST" 77 % rmmod $MOD_TEST" 78 78 79 exit 0 79 exit 0
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.