From: Paul Moore <paul@paul-moore.com>
To: Jia-Ju Bai <baijiaju1990@gmail.com>
Cc: Eric Paris <eparis@redhat.com>,
linux-audit@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kernel: auditfilter: Fix a possible null-pointer dereference in audit_watch_path()
Date: Wed, 24 Jul 2019 16:45:52 -0400 [thread overview]
Message-ID: <CAHC9VhQJwif4NXVydmQkTUXgM8Xnp5rG_zscXmKc5_CSYo-e5w@mail.gmail.com> (raw)
In-Reply-To: <20190723124951.25713-1-baijiaju1990@gmail.com>
On Tue, Jul 23, 2019 at 8:50 AM Jia-Ju Bai <baijiaju1990@gmail.com> wrote:
> In audit_find_rule(), there is an if statement on line 894 to check
> whether entry->rule.watch is NULL:
> else if (entry->rule.watch)
>
> If entry->rule.watch is NULL, audit_compare_rule on 910 is called:
> audit_compare_rule(&entry->rule, &e->rule))
>
> In audit_compare_rule(), a->watch is used on line 720:
> if (strcmp(audit_watch_path(a->watch), ...)
>
> In this case, a->watch is NULL, and audit_watch_path() will use:
> watch->path
>
> Thus, a possible null-pointer dereference may occur in this case.
>
> To fix this possible bug, an if statement is added in
> audit_compare_rule() to check a->watch before using a->watch.
>
> This bug is found by a static analysis tool STCheck written by us.
>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> ---
> kernel/auditfilter.c | 2 ++
> 1 file changed, 2 insertions(+)
Thank you for taking the time to analyze the kernel's audit subsystem
and send a report, but I believe this is a false positive.
The only way we can hit the AUDIT_WATCH comparison in
audit_compare_rules is if both rules are AUDIT_WATCH rules, and when
we create the audit_krule entries we ensure that the watch field is
correctly populated for AUDIT_WATCH rules, see the
audit_data_to_entry() and audit_to_watch() functions.
If you disagree with this, please let us know, but as of right now I
don't believe there is a problem here.
> diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
> index b0126e9c0743..b0ad17b14609 100644
> --- a/kernel/auditfilter.c
> +++ b/kernel/auditfilter.c
> @@ -717,6 +717,8 @@ static int audit_compare_rule(struct audit_krule *a, struct audit_krule *b)
> return 1;
> break;
> case AUDIT_WATCH:
> + if (!a->watch)
> + break;
> if (strcmp(audit_watch_path(a->watch),
> audit_watch_path(b->watch)))
> return 1;
> --
> 2.17.0
--
paul moore
www.paul-moore.com
prev parent reply other threads:[~2019-07-24 20:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-23 12:49 [PATCH] kernel: auditfilter: Fix a possible null-pointer dereference in audit_watch_path() Jia-Ju Bai
2019-07-24 20:45 ` Paul Moore [this message]
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=CAHC9VhQJwif4NXVydmQkTUXgM8Xnp5rG_zscXmKc5_CSYo-e5w@mail.gmail.com \
--to=paul@paul-moore.com \
--cc=baijiaju1990@gmail.com \
--cc=eparis@redhat.com \
--cc=linux-audit@redhat.com \
--cc=linux-kernel@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).