From: Mimi Zohar <zohar@linux.ibm.com>
To: Christian Brauner <christian.brauner@ubuntu.com>,
Dmitry Kasatkin <dmitry.kasatkin@gmail.com>
Cc: linux-integrity@vger.kernel.org, keyrings@vger.kernel.org,
linux-security-module@vger.kernel.org
Subject: Re: null-ptr-deref in integrity_inode_free()
Date: Wed, 14 Apr 2021 13:46:46 -0400 [thread overview]
Message-ID: <630cc0a27a0db8fd790a767300ae0a7f2540bdc2.camel@linux.ibm.com> (raw)
In-Reply-To: <20210414115055.mayc4aeonsklgwks@wittgenstein>
Hi Christian,
On Wed, 2021-04-14 at 13:50 +0200, Christian Brauner wrote:
> Hey,
>
> [Resending since the previous mail somehow hasn't made it onto the list.]
>
> While working on a patch to port ecryptfs to use clone_private_mount() I
> hit the splat in [1] with v5.12-rc6 (Without any of my changes.). To
> reproduce this you can use the config in [5]. Then run the scripts [2]
> and [3] in two terminals. The kernel command line was [4]:
>
> while true; do ./test.sh; done
> while true; do ./test2.sh; done
>
> and wait for [1] to appear.
>
> The two test scripts aren't specifically designed to trigger this issue.
> They were stress tests for my ecryptfs clone_private_mount() port. They
> just allow to trigger this issue.
>
> From a very uninformed position it seemed that:
>
> void integrity_inode_free(struct inode *inode)
> {
> struct integrity_iint_cache *iint;
>
> if (!IS_IMA(inode))
> return;
Thank you for all the details.
A builtin IMA policy wasn't specified on the boot command line. Unless
a custom IMA policy is loaded, it shouldn't get beyond this
point. Before looking any farther, I would appreciate your confirming
that you've loaded a custom IMA policy. To see if a policy has been
loaded, cat /sys/kernel/security/ima/policy.
thanks,
Mimi
>
> write_lock(&integrity_iint_lock);
> iint = __integrity_iint_find(inode);
> ^^^^^
> >>>>>>> is somehow NULL?
>
> rb_erase(&iint->rb_node, &integrity_iint_tree);
> write_unlock(&integrity_iint_lock);
>
> iint_free(iint);
> }
>
> So I've placed a BUG_ON() in there:
>
> diff --git a/security/integrity/iint.c b/security/integrity/iint.c
> index 0ba01847e836..d5152b5ef517 100644
> --- a/security/integrity/iint.c
> +++ b/security/integrity/iint.c
> @@ -152,6 +152,7 @@ void integrity_inode_free(struct inode *inode)
>
> write_lock(&integrity_iint_lock);
> iint = __integrity_iint_find(inode);
> + BUG_ON(!iint);
> rb_erase(&iint->rb_node, &integrity_iint_tree);
> write_unlock(&integrity_iint_lock);
>
> and indeed, I get:
>
> [ 266.308227] ------------[ cut here ]------------
> [ 266.308592] kernel BUG at security/integrity/iint.c:155!
> [ 266.312120] invalid opcode: 0000 [#1] PREEMPT SMP KASAN
> [ 266.313898] CPU: 0 PID: 5867 Comm: rm Tainted: G E 5.12.0-rc6-clone-private-mount-8a97af3f33b5 #380
> [ 266.317651] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009)/LXD, BIOS 0.0.0 02/06/2015
next parent reply other threads:[~2021-04-14 17:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210414115055.mayc4aeonsklgwks@wittgenstein>
2021-04-14 17:46 ` Mimi Zohar [this message]
2021-04-14 18:19 ` null-ptr-deref in integrity_inode_free() Christian Brauner
2021-04-14 20:21 ` Mimi Zohar
[not found] ` <CAHrFyr67SkruTdYnRYy+OkrEh6wqz1A=DGHZLKE2b0s-_=Cb8g@mail.gmail.com>
2021-04-14 20:36 ` Mimi Zohar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=630cc0a27a0db8fd790a767300ae0a7f2540bdc2.camel@linux.ibm.com \
--to=zohar@linux.ibm.com \
--cc=christian.brauner@ubuntu.com \
--cc=dmitry.kasatkin@gmail.com \
--cc=keyrings@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).