public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Revert: audit: Fix check of return value of strnlen_user()
@ 2015-07-08 15:26 Steven Rostedt
  2015-07-08 15:53 ` Linus Torvalds
  2015-07-09 12:54 ` Jan Kara
  0 siblings, 2 replies; 8+ messages in thread
From: Steven Rostedt @ 2015-07-08 15:26 UTC (permalink / raw)
  To: LKML; +Cc: Jan Kara, Paul Moore, Andrew Morton, Linus Torvalds

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.

 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;

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-07-09 12:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox