ima: Print /proc/cmdline and IMA kernel config
RFC PATCH v3 10/10 ima: Print /proc/cmdline and IMA kernel config
Useful for debugging
---
Adding one more commit as it's useful to see config (due problems with test order).
Petr
--- .../kernel/security/integrity/ima/tests/ima_setup.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
testcases/kernel/security/integrity/ima/tests/ima_setup.sh +17 -0
@@ -64,6 +64,21 @@ mount_loop_device() cd mntpoint } +print_ima_config() +{ + local config="/boot/config-$(uname -r)" + local i + + tst_res TINFO "/proc/cmdline: $(cat /proc/cmdline)" + + if [ -r "$config" ]; then + tst_res TINFO "IMA kernel config" + for i in $(grep ^CONFIG_IMA $config); do + tst_res TINFO "$i" + done + fi +} + ima_setup() { SECURITYFS="$(mount_helper securityfs $SYSFS/kernel/security)"
@@ -73,6 +88,8 @@ ima_setup() ASCII_MEASUREMENTS="$IMA_DIR/ascii_runtime_measurements" BINARY_MEASUREMENTS="$IMA_DIR/binary_runtime_measurements" + print_ima_config + if [ "$TST_NEEDS_DEVICE" = 1 ]; then tst_res TINFO "\$TMPDIR is on tmpfs => run on loop device" mount_loop_device
Signature · 1 line
2.16.3
RFC PATCH v3 10/10 ima: Print /proc/cmdline and IMA kernel config
Hi Petr,
testcases/kernel/security/integrity/ima/tests/ima_setup.sh mount_loop_device() · line 69
Quoted 3 lines · Petr Vorel
testcases/kernel/security/integrity/ima/tests/ima_setup.sh +3
-0+print_ima_config() +{ + local config="/boot/config-$(uname -r)"
Just a small remark here: not all distributions have /boot/config-* files in place. I don't remember which ones this were.
Wouldn't it make sense to check this file, if it does not exist check if /proc/config.gz is available?
testcases/kernel/security/integrity/ima/tests/ima_setup.sh mount_loop_device() · line 80
Quoted 11 lines
testcases/kernel/security/integrity/ima/tests/ima_setup.sh +11
-0+ local i + + tst_res TINFO "/proc/cmdline: $(cat /proc/cmdline)" + + if [ -r "$config" ]; then + tst_res TINFO "IMA kernel config" + for i in $(grep ^CONFIG_IMA $config); do + tst_res TINFO "$i" + done + fi +}
Kind regards,
Michael
Signature · 1 line
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
RFC PATCH v3 10/10 ima: Print /proc/cmdline and IMA kernel config
Hi Michael,
thank you for your comment.
Quoted 8 lines · Petr Vorel
testcases/kernel/security/integrity/ima/tests/ima_setup.sh mount_loop_device() · line 69
Quoted 3 lines
testcases/kernel/security/integrity/ima/tests/ima_setup.sh +3
-0+print_ima_config() +{ + local config="/boot/config-$(uname -r)"Just a small remark here: not all distributions have
/boot/config-*files in place. I don't remember which ones this were.
Wouldn't it make sense to check this file, if it does not exist check if/proc/config.gzis available?
I haven't found any normal distro not having config in place (openSUSE/SLE, Debian/Ubuntu, CentOS/Red Hat), but there might be some. I guess most of embedded devices don't have that (it's a question if they have IKCONFIG_PROC=y) but why not to try it.
I wonder if we'd benefit from having these functions in shell API:is_enabled(CONFIG_FOO)is_module(CONFIG_FOO)is_builtin(CONFIG_FOO)
which would do simple grep of either /boot/config-$(uname -r) or /proc/config.gz.
The first three are inspired with kernel macros from include/linux/kconfig.h
Quoted 2 lines
Kind regards,
Michael
Kind regards,
Petr
RFC PATCH v3 10/10 ima: Print /proc/cmdline and IMA kernel config
Hi!
Quoted 7 lines
Quoted 4 lines
Just a small remark here: not all distributions have
/boot/config-*files in place. I don't remember which ones this were.
Wouldn't it make sense to check this file, if it does not exist check if/proc/config.gzis available?I haven't found any normal distro not having config in place (openSUSE/SLE, Debian/Ubuntu, CentOS/Red Hat), but there might be some. I guess most of embedded devices don't have that (it's a question if they have IKCONFIG_PROC=y) but why not to try it.
Embedded usually dont have neither of them.
Also depending on the existence of /boot/config-* is really bad idea, just imagine you compiled and kexeced testing kernel and testcases are starting to fail for no good reason.
Quoted 6 lines
I wonder if we'd benefit from having these functions in shell API:
is_enabled(CONFIG_FOO)is_module(CONFIG_FOO)is_builtin(CONFIG_FOO)which would do simple grep of either /boot/config-$(uname -r) or
/proc/config.gz.
Generally you cannot detect features of the running kernel by the /boot/config-* files. We tried that and it failed miserably.
We cannot rely on /proc/config.gz because many kernels have that disabled to spare some space.
It's sad but the only reasonable way how to detect if kernel does support something is to try to call the syscall/open and read sysfs file/etc. and detect ENOSYS/ENOTTY/etc.
Signature · 2 lines
Cyril Hrubis [email protected]
RFC PATCH v3 10/10 ima: Print /proc/cmdline and IMA kernel config
Hi Cyril,
Quoted 10 lines
Hi!
Quoted 7 lines
Quoted 4 lines
Just a small remark here: not all distributions have
/boot/config-*files in place. I don't remember which ones this were.
Wouldn't it make sense to check this file, if it does not exist check if/proc/config.gzis available?I haven't found any normal distro not having config in place (openSUSE/SLE, Debian/Ubuntu, CentOS/Red Hat), but there might be some. I guess most of embedded devices don't have that (it's a question if they have IKCONFIG_PROC=y) but why not to try it.
Embedded usually dont have neither of them.
I think so as well.
Quoted 3 lines
Also depending on the existence of
/boot/config-*is really bad idea, just imagine you compiled and kexeced testing kernel and testcases are starting to fail for no good reason.
Do you NACK this commit? This code is just for debugging (nothing happen if /boot/config-* doesn't exist)...
Quoted 10 lines
Quoted 6 lines
I wonder if we'd benefit from having these functions in shell API:
is_enabled(CONFIG_FOO)is_module(CONFIG_FOO)is_builtin(CONFIG_FOO)which would do simple grep of either /boot/config-$(uname -r) or
/proc/config.gz.Generally you cannot detect features of the running kernel by the
/boot/config-*files. We tried that and it failed miserably.
Quoted 6 lines
We cannot rely on
/proc/config.gzbecause many kernels have that disabled to spare some space.It's sad but the only reasonable way how to detect if kernel does support something is to try to call the syscall/open and read sysfs file/etc. and detect ENOSYS/ENOTTY/etc.
OK, dropping idea about is_enabled etc. in shell API.
Thanks for your comments.
Kind regards,
Petr
RFC PATCH v3 10/10 ima: Print /proc/cmdline and IMA kernel config
Hi!
Quoted 5 lines
Quoted 3 lines
Also depending on the existence of
/boot/config-*is really bad idea, just imagine you compiled and kexeced testing kernel and testcases are starting to fail for no good reason.Do you NACK this commit? This code is just for debugging (nothing happen if
/boot/config-*doesn't exist)...
It's okay for additional debugging output, but we should not depend on it in any way.
Signature · 2 lines
Cyril Hrubis [email protected]