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 <[email protected]>
---
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;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to