All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>, Jan Kara <jack@suse.cz>,
	Paul Moore <pmoore@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] Revert: audit: Fix check of return value of strnlen_user()
Date: Thu, 9 Jul 2015 14:54:41 +0200	[thread overview]
Message-ID: <20150709125441.GG2900@quack.suse.cz> (raw)
In-Reply-To: <20150708112607.03df9c2a@gandalf.local.home>

On Wed 08-07-15 11:26:07, Steven Rostedt wrote:
> When testing 4.2-rc1 I hit this WARNING:
> 
> ------------[ cut here ]------------
> WARNING: CPU: 1 PID: 1639 at /work/autotest/nobackup/linux-test.git/kernel/auditsc.c:1025 audit_log_exit+0x734/0xb0d()
> Modules linked in:
> CPU: 1 PID: 1639 Comm: fstab-decode Not tainted 4.2.0-rc1-test+ #2
> Hardware name: MSI MS-7823/CSM-H87M-G43 (MS-7823), BIOS V1.6 02/22/2014
>  00000000 00000000 f0817eb4 c0cd118d c10224d4 f0817ee4 c0440fbe c1011b30
>  00000001 00000667 c10224d4 00000401 c04ba081 c04ba081 f18e3c00 f1cd5080^M
>  00000000 f0817ef4 c0440ff7 00000009 00000000 f0817f84 c04ba081 f0817f60
> Call Trace:
>  [<c0cd118d>] dump_stack+0x41/0x52
>  [<c0440fbe>] warn_slowpath_common+0x9d/0xb4
>  [<c04ba081>] ? audit_log_exit+0x734/0xb0d
>  [<c04ba081>] ? audit_log_exit+0x734/0xb0d
>  [<c0440ff7>] warn_slowpath_null+0x22/0x24
>  [<c04ba081>] audit_log_exit+0x734/0xb0d
>  [<c04bb7f4>] __audit_syscall_exit+0x43/0xf6
>  [<c040ce27>] syscall_trace_leave+0x30/0xe5
>  [<c0cdbced>] syscall_exit_work+0x19/0x1e
> ---[ end trace 156b2a7afa592deb ]---
> 
> Debugging it, I found that it was triggered by this commit:
> 
> commit 0b08c5e5944 ("audit: Fix check of return value of strnlen_user()")
> 
> Yes, strnlen_user() returns 0 on fault, but if you look at what len is
> set to, than you would notice that on fault len would be -1.

You're right. Thanks for catching this. I don't know what I was thinking
when writing that "fix"...

								Honza

>  len = strnlen_user(p, MAX_ARG_STRLEN) - 1;
> 
> Now the warning triggers on a string of size zero ("\0"), which is a
> legitimate entry.
> 
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> ---
> diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> index 09c65640cad6..ee097948b0a8 100644
> --- a/kernel/auditsc.c
> +++ b/kernel/auditsc.c
> @@ -1021,7 +1021,7 @@ static int audit_log_single_execve_arg(struct audit_context *context,
>  	 * for strings that are too long, we should not have created
>  	 * any.
>  	 */
> -	if (unlikely((len == 0) || len > MAX_ARG_STRLEN - 1)) {
> +	if (unlikely((len == -1) || len > MAX_ARG_STRLEN - 1)) {
>  		WARN_ON(1);
>  		send_sig(SIGKILL, current, 0);
>  		return -1;
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

      parent reply	other threads:[~2015-07-09 12:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-08 15:26 [PATCH] Revert: audit: Fix check of return value of strnlen_user() Steven Rostedt
2015-07-08 15:53 ` Linus Torvalds
2015-07-08 15:59   ` Steven Rostedt
2015-07-08 16:02     ` Steven Rostedt
2015-07-08 16:29       ` Steven Rostedt
2015-07-08 19:06         ` Paul Moore
2015-07-09  4:09         ` Steven Rostedt
2015-07-09 12:54 ` Jan Kara [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=20150709125441.GG2900@quack.suse.cz \
    --to=jack@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmoore@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.