]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
IMA: Check IMA policy flag
authorLakshmi Ramasubramanian <nramas@linux.microsoft.com>
Wed, 11 Dec 2019 16:47:02 +0000 (08:47 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Feb 2020 07:38:14 +0000 (08:38 +0100)
[ Upstream commit c5563bad88e07017e08cce1142903e501598c80c ]

process_buffer_measurement() may be called prior to IMA being
initialized (for instance, when the IMA hook is called when
a key is added to the .builtin_trusted_keys keyring), which
would result in a kernel panic.

This patch adds the check in process_buffer_measurement()
to return immediately if IMA is not initialized yet.

Signed-off-by: Lakshmi Ramasubramanian <nramas@linux.microsoft.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
security/integrity/ima/ima_main.c

index d7e987baf127419cfe40288aff333c5b474e29fa..9b35db2fc777a73ed63428e8d63014aaa2cea77c 100644 (file)
@@ -655,6 +655,9 @@ void process_buffer_measurement(const void *buf, int size,
        int action = 0;
        u32 secid;
 
+       if (!ima_policy_flag)
+               return;
+
        /*
         * Both LSM hooks and auxilary based buffer measurements are
         * based on policy.  To avoid code duplication, differentiate