]> www.infradead.org Git - users/jedix/linux-maple.git/commit
Fix broken audit tests for exec arg len
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 8 Jul 2015 16:33:38 +0000 (09:33 -0700)
committerDhaval Giani <dhaval.giani@oracle.com>
Fri, 20 Jan 2017 22:22:08 +0000 (17:22 -0500)
commit336ed0eb9ab8e965798fd6c428f9274f2063fb73
tree118a1037c94cab60125e07ab92d6d849c0063114
parenta823f8f33615840e0f874282053a8884a3279ce0
Fix broken audit tests for exec arg len

Orabug: 25308128

[ Upstream commit 45820c294fe1b1a9df495d57f40585ef2d069a39 ]

The "fix" in commit 0b08c5e5944 ("audit: Fix check of return value of
strnlen_user()") didn't fix anything, it broke things.  As reported by
Steven Rostedt:

 "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"

because we just subtracted one from the return value.  So testing
against 0 doesn't test for a fault condition, it tests against a
perfectly valid empty string.

Also fix up the usual braindamage wrt using WARN_ON() inside a
conditional - make it part of the conditional and remove the explicit
unlikely() (which is already part of the WARN_ON*() logic, exactly so
that you don't have to write unreadable code.

Reported-and-tested-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Paul Moore <pmoore@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
(cherry picked from commit a4664afa0dffd5340c61511d3da14e30bfd01517)
Signed-off-by: Dhaval Giani <dhaval.giani@oracle.com>
kernel/auditsc.c