On 11/7/19 3:42 AM, Miroslav Benes wrote:
On Wed, 6 Nov 2019, Joe Lawrence wrote:
The livepatch selftests compare expected dmesg output to verify kernel behavior. They currently filter out "tainting kernel with TAINT_LIVEPATCH" messages which may be logged when loading livepatch modules.
Further filter the log to also drop "loading out-of-tree module taints kernel" messages in case the klp_test modules have been build without the in-tree module flag.
That is true, but "tainting kernel with TAINT_LIVEPATCH" should be printed out even in this case. check_modinfo_livepatch() is called for all modules and relies on MODINFO(livepatch, Y).
So either the bug is elsewhere or I need one more cup of tea.
I'm only half a cup in this morning myself, but...
In my scenario, I saw in the kernel log:
% modprobe test_klp_livepatch test_klp_livepatch: loading out-of-tree module taints kernel. test_klp_livepatch: module verification failed: signature and/or required key missing - tainting kernel ...
and because check_result() only removes 'tainting' with grep -v, the expected log message failed to match with the actual filtered message because of the first 'taints' message.
So this change just adds more to the filtered out strings:
result = dmesg | grep -v <filtered out strings> | grep <interesting strings>
BTW, none of the callers of check_result() bother to include either taint message since I think they are only ever emitted on the first occurance.
-- Joe