Skip to content

Commit 040b3a2

Browse files
Peter ZijlstraLinus Torvalds
authored andcommitted
audit: fix two bugs in the new execve audit code
copy_from_user() returns the number of bytes not copied, hence 0 is the expected output. axi->mm might not be valid anymore when not equal to current->mm, do not dereference before checking that - thanks to Al for spotting that. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Tested-by: Steve Grubb <sgrubb@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 0af3678 commit 040b3a2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

kernel/auditsc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -824,12 +824,14 @@ static void audit_log_execve_info(struct audit_buffer *ab,
824824
{
825825
int i;
826826
long len, ret;
827-
const char __user *p = (const char __user *)axi->mm->arg_start;
827+
const char __user *p;
828828
char *buf;
829829

830830
if (axi->mm != current->mm)
831831
return; /* execve failed, no additional info */
832832

833+
p = (const char __user *)axi->mm->arg_start;
834+
833835
for (i = 0; i < axi->argc; i++, p += len) {
834836
len = strnlen_user(p, MAX_ARG_STRLEN);
835837
/*
@@ -855,7 +857,7 @@ static void audit_log_execve_info(struct audit_buffer *ab,
855857
* copied them here, and the mm hasn't been exposed to user-
856858
* space yet.
857859
*/
858-
if (!ret) {
860+
if (ret) {
859861
WARN_ON(1);
860862
send_sig(SIGKILL, current, 0);
861863
}

0 commit comments

Comments
 (0)