From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753695AbbGIMy4 (ORCPT ); Thu, 9 Jul 2015 08:54:56 -0400 Received: from cantor2.suse.de ([195.135.220.15]:47390 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752506AbbGIMyr (ORCPT ); Thu, 9 Jul 2015 08:54:47 -0400 Date: Thu, 9 Jul 2015 14:54:41 +0200 From: Jan Kara To: Steven Rostedt Cc: LKML , Jan Kara , Paul Moore , Andrew Morton , Linus Torvalds Subject: Re: [PATCH] Revert: audit: Fix check of return value of strnlen_user() Message-ID: <20150709125441.GG2900@quack.suse.cz> References: <20150708112607.03df9c2a@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150708112607.03df9c2a@gandalf.local.home> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: > [] dump_stack+0x41/0x52 > [] warn_slowpath_common+0x9d/0xb4 > [] ? audit_log_exit+0x734/0xb0d > [] ? audit_log_exit+0x734/0xb0d > [] warn_slowpath_null+0x22/0x24 > [] audit_log_exit+0x734/0xb0d > [] __audit_syscall_exit+0x43/0xf6 > [] syscall_trace_leave+0x30/0xe5 > [] 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 > --- > 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 SUSE Labs, CR