Thread (19 messages) 19 messages, 4 authors, 2021-03-24

Re: [RFC PATCH 2/2] integrity: double check iint_cache was initialized

From: Mimi Zohar <zohar@linux.ibm.com>
Date: 2021-03-23 12:10:41
Also in: linux-security-module, lkml

On Tue, 2021-03-23 at 10:46 +0900, Tetsuo Handa wrote:
On 2021/03/20 5:03, Mimi Zohar wrote:
quoted
The integrity's "iint_cache" is initialized at security_init().  Only
after an IMA policy is loaded, which is initialized at late_initcall,
is a file's integrity status stored in the "iint_cache".

All integrity_inode_get() callers first verify that the IMA policy has
been loaded, before calling it.  Yet for some reason, it is still being
called, causing a NULL pointer dereference.

qemu-system-x86_64 (...snipped...) lsm=smack (...snipped...)
Hmm, why are you using lsm=smack instead of security=smack ?
Since use of lsm= overrides CONFIG_LSM="lockdown,yama,safesetid,integrity,tomoyo,smack,bpf" settings,
only smack is activated, which means that integrity_iintcache_init() will not be called by

  DEFINE_LSM(integrity) = {
  	.name = "integrity",
  	.init = integrity_iintcache_init,
  };

declaration. That's the reason iint_cache == NULL when integrity_inode_get() is called.
That's exactly the problem, but since we don't control how the system
is configured or which parameters are supplied on the boot command
line, the kernel needs to at least provide some explanation instead of
dereferencing a NULL pointer.

FYI, "security=" is being deprecated.   From Documentation/admin-
guide/kernel-parameters.txt:

       security=  [SECURITY] Choose a legacy "major" security module to
                        enable at boot. This has been deprecated by the
                        "lsm=" parameter.

Please take a look at the newer version of this patch.   Do you want to
add any tags?

thanks,

Mimi
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help