Skip to contentSkip to conversation

Added exe field to audit core dump signal log

PATCH In review Paul Davies C 5 participants 9 messages Nov 14, 2013 – Jul 8, 2015 Audit

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Added exe field to audit core dump signal log

Currently when the coredump signals are logged by the audit system , the actual path to the executable is not logged. Without details of exe , the system admin may not have an exact idea on what program failed.

This patch changes the audit_log_task() so that the path to the exe is also logged.

---
 kernel/auditsc.c |    7 +++++++
 1 file changed, 7 insertions(+)
kernel/auditsc.c +7 -0
index 9845cb3..988de72 100644
@@ -2353,6 +2353,7 @@ static void audit_log_task(struct audit_buffer *ab)
 	kuid_t auid, uid;
 	kgid_t gid;
 	unsigned int sessionid;
+	struct mm_struct *mm = current->mm;
 
 	auid = audit_get_loginuid(current);
 	sessionid = audit_get_sessionid(current);
@@ -2366,6 +2367,12 @@ static void audit_log_task(struct audit_buffer *ab)
 	audit_log_task_context(ab);
 	audit_log_format(ab, " pid=%d comm=", current->pid);
 	audit_log_untrustedstring(ab, current->comm);
+	if (mm) {
+		down_read(&mm->mmap_sem);
+		if (mm->exe_file)
+			audit_log_d_path(ab, " exe=", &mm->exe_file->f_path);
+		up_read(&mm->mmap_sem);
+	}
 }
 
 static void audit_log_abend(struct audit_buffer *ab, char *reason, long signr)
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 6 lines · Paul Davies C

Currently when the coredump signals are logged by the audit system , the actual path to the executable is not logged. Without details of exe , the system admin may not have an exact idea on what program failed.

This patch changes the audit_log_task() so that the path to the exe is also logged.

Out of curiosity, on which platform are you observing this? This sounds related to Bill Roberts' recent cmdline patches.

I also wonder how reliable this is, or whether it could have been changed from under us by deletion or rename after invocation.

This BZ sounds related:

	https://bugzilla.redhat.com/show_bug.cgi?id=837856
	https://bugzilla.redhat.com/show_bug.cgi?id=831684
Quoted 32 lines
---
 kernel/auditsc.c |    7 +++++++
 1 file changed, 7 insertions(+)
kernel/auditsc.c +7 -0
index 9845cb3..988de72 100644
@@ -2353,6 +2353,7 @@ static void audit_log_task(struct audit_buffer *ab)
 	kuid_t auid, uid;
 	kgid_t gid;
 	unsigned int sessionid;
+	struct mm_struct *mm = current->mm;
 
 	auid = audit_get_loginuid(current);
 	sessionid = audit_get_sessionid(current);
@@ -2366,6 +2367,12 @@ static void audit_log_task(struct audit_buffer *ab)
 	audit_log_task_context(ab);
 	audit_log_format(ab, " pid=%d comm=", current->pid);
 	audit_log_untrustedstring(ab, current->comm);
+	if (mm) {
+		down_read(&mm->mmap_sem);
+		if (mm->exe_file)
+			audit_log_d_path(ab, " exe=", &mm->exe_file->f_path);
+		up_read(&mm->mmap_sem);
+	}
 }
 
 static void audit_log_abend(struct audit_buffer *ab, char *reason, long signr)
Signature · 1 line
1.7.9.5

- RGB

--
Richard Guy Briggs <[email protected]>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545

#2 lore raw
Quoted 10 lines · Richard Guy Briggs
Quoted 6 lines · Paul Davies C

Currently when the coredump signals are logged by the audit system , the actual path to the executable is not logged. Without details of exe , the system admin may not have an exact idea on what program failed.

This patch changes the audit_log_task() so that the path to the exe is also logged.

Out of curiosity, on which platform are you observing this? This sounds related to Bill Roberts' recent cmdline patches.

I don't think this is related, looks to me like he want the exe file that started it. Where as I want some abstract field that was set by the VM at application invocation.

Quoted 3 lines

I also wonder how reliable this is, or whether it could have been changed from under us by deletion or rename after invocation.

I don't think paths can ever be trusted 100%... I'm thinking chroots and namespaces might alter what the path is.

Quoted 10 lines

This BZ sounds related:

        https://bugzilla.redhat.com/show_bug.cgi?id=837856
        https://bugzilla.redhat.com/show_bug.cgi?id=831684
Quoted 5 lines
---
 kernel/auditsc.c |    7 +++++++
 1 file changed, 7 insertions(+)
Quoted 9 lines

kernel/auditsc.c static void audit_log_task(struct audit_buffer *ab) · line 2356

Quoted 9 lines
kernel/auditsc.c +1 -0
index 9845cb3..988de72 100644
@@ -2353,6 +2353,7 @@ static void audit_log_task(struct audit_buffer *ab)
      kuid_t auid, uid;
      kgid_t gid;
      unsigned int sessionid;
+     struct mm_struct *mm = current->mm;

Why wouldn't we use:
get_task_mm(current)

Quoted 8 lines

kernel/auditsc.c static void audit_log_task(struct audit_buffer *ab) · line 2370

Quoted 8 lines
kernel/auditsc.c +1 -0
      auid = audit_get_loginuid(current);
      sessionid = audit_get_sessionid(current);
@@ -2366,6 +2367,12 @@ static void audit_log_task(struct audit_buffer *ab)
      audit_log_task_context(ab);
      audit_log_format(ab, " pid=%d comm=", current->pid);
      audit_log_untrustedstring(ab, current->comm);
+     if (mm) {

if using get_task_mm() drop below

Quoted 3 lines

kernel/auditsc.c static void audit_log_task(struct audit_buffer *ab) · line 2373

Quoted 3 lines
kernel/auditsc.c +3 -0
+             down_read(&mm->mmap_sem);
+             if (mm->exe_file)
+                     audit_log_d_path(ab, " exe=", &mm->exe_file->f_path);

if using get_task_mm() change below to mmput(mm);

Quoted 20 lines
Quoted 7 lines
kernel/auditsc.c +2 -1
+             up_read(&mm->mmap_sem);
+     }
 }
 
 static void audit_log_abend(struct audit_buffer *ab, char *reason, long signr)
--

1.7.9.5

- RGB

--
Richard Guy Briggs <[email protected]>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545

--
Linux-audit mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/linux-audit

Signature · 3 lines
Respectfully,

William C Roberts
#3 lore raw
Quoted 55 lines · William Roberts
Quoted 10 lines · Richard Guy Briggs
Quoted 6 lines · Paul Davies C

Currently when the coredump signals are logged by the audit system , the actual path to the executable is not logged. Without details of exe , the system admin may not have an exact idea on what program failed.

This patch changes the audit_log_task() so that the path to the exe is also logged.

Out of curiosity, on which platform are you observing this? This sounds related to Bill Roberts' recent cmdline patches.

I don't think this is related, looks to me like he want the exe file that started it. Where as I want some abstract field that was set by the VM at application invocation.

Quoted 3 lines

I also wonder how reliable this is, or whether it could have been changed from under us by deletion or rename after invocation.

I don't think paths can ever be trusted 100%... I'm thinking chroots and namespaces might alter what the path is.

Quoted 10 lines

This BZ sounds related:

        https://bugzilla.redhat.com/show_bug.cgi?id=837856
        https://bugzilla.redhat.com/show_bug.cgi?id=831684
Quoted 5 lines
---
 kernel/auditsc.c |    7 +++++++
 1 file changed, 7 insertions(+)
Quoted 9 lines

kernel/auditsc.c static void audit_log_task(struct audit_buffer *ab) · line 2356

Quoted 9 lines
kernel/auditsc.c +1 -0
index 9845cb3..988de72 100644
@@ -2353,6 +2353,7 @@ static void audit_log_task(struct audit_buffer *ab)
      kuid_t auid, uid;
      kgid_t gid;
      unsigned int sessionid;
+     struct mm_struct *mm = current->mm;

Why wouldn't we use:
get_task_mm(current)

Quoted 8 lines

kernel/auditsc.c static void audit_log_task(struct audit_buffer *ab) · line 2370

Quoted 8 lines
kernel/auditsc.c +1 -0
      auid = audit_get_loginuid(current);
      sessionid = audit_get_sessionid(current);
@@ -2366,6 +2367,12 @@ static void audit_log_task(struct audit_buffer *ab)
      audit_log_task_context(ab);
      audit_log_format(ab, " pid=%d comm=", current->pid);
      audit_log_untrustedstring(ab, current->comm);
+     if (mm) {

if using get_task_mm() drop below

Quoted 10 lines
Quoted 3 lines

kernel/auditsc.c static void audit_log_task(struct audit_buffer *ab) · line 2373

Quoted 3 lines
kernel/auditsc.c +3 -0
+             down_read(&mm->mmap_sem);
+             if (mm->exe_file)
+                     audit_log_d_path(ab, " exe=", &mm->exe_file->f_path);

if using get_task_mm() change below to mmput(mm);

Quoted 4 lines
Quoted 4 lines
kernel/auditsc.c +2 -0
+             up_read(&mm->mmap_sem);
+     }
 }
 

<snip>
One other thing that I know Steve Grubb is picky on, is the field still needs to be there even if mm is null. We can't have disappearing fields. On error conditions, I've been doing <fieldname>=(null) on my patches.

#4 lore raw
Quoted 11 lines · William Roberts
Quoted 8 lines · William Roberts
Quoted 7 lines · Richard Guy Briggs

kernel/auditsc.c static void audit_log_task(struct audit_buffer *ab) · line 2375

Quoted 6 lines · Paul Davies C
kernel/auditsc.c +6 -0
+     if (mm) {
+             down_read(&mm->mmap_sem);
+             if (mm->exe_file)
+                     audit_log_d_path(ab, " exe=", &mm->exe_file->f_path);
+             up_read(&mm->mmap_sem);
+     }
Quoted 5 lines

<snip>
One other thing that I know Steve Grubb is picky on, is the field still needs to be there even if mm is null. We can't have disappearing fields. On error conditions, I've been doing <fieldname>=(null) on my patches.

Agreed.

- RGB

--
Richard Guy Briggs <[email protected]>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545

#5 lore raw
In reply to William Roberts
Quoted 9 lines · William Roberts
Quoted 8 lines · Richard Guy Briggs
Quoted 6 lines · Paul Davies C

Currently when the coredump signals are logged by the audit system , the actual path to the executable is not logged. Without details of exe , the system admin may not have an exact idea on what program failed.

This patch changes the audit_log_task() so that the path to the exe is also logged.

Quoted 6 lines
Quoted 2 lines

Out of curiosity, on which platform are you observing this? This sounds related to Bill Roberts' recent cmdline patches.

I don't think this is related, looks to me like he want the exe file that started it. Where as I want some abstract field that was set by the VM at application invocation.

I pulled the trigger on send a bit too fast...

I see now where that code came from... It was copied from audit_log_task_info().

Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

+ struct mm_struct *mm = current->mm;

Why wouldn't we use:
get_task_mm(current)

That may be a bit heavy for this usage since we are in the current context.

Quoted 14 lines
Quoted 7 lines

kernel/auditsc.c static void audit_log_task(struct audit_buffer *ab) · line 2370

Quoted 7 lines
      auid = audit_get_loginuid(current);
      sessionid = audit_get_sessionid(current);
kernel/auditsc.c +1 -0
@@ -2366,6 +2367,12 @@ static void audit_log_task(struct audit_buffer *ab)
      audit_log_task_context(ab);
      audit_log_format(ab, " pid=%d comm=", current->pid);
      audit_log_untrustedstring(ab, current->comm);
+     if (mm) {

if using get_task_mm() drop below

Quoted 3 lines

kernel/auditsc.c static void audit_log_task(struct audit_buffer *ab) · line 2373

Quoted 3 lines
kernel/auditsc.c +3 -0
+             down_read(&mm->mmap_sem);
+             if (mm->exe_file)
+                     audit_log_d_path(ab, " exe=", &mm->exe_file->f_path);
Quoted 8 lines

if using get_task_mm() change below to mmput(mm);

Quoted 4 lines

kernel/auditsc.c static void audit_log_task(struct audit_buffer *ab) · line 2375

Quoted 2 lines
kernel/auditsc.c +2 -0
+             up_read(&mm->mmap_sem);
+     }

- RGB

William C Roberts

- RGB

--
Richard Guy Briggs <[email protected]>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545

#6 lore raw
In reply to Paul Davies C

Hello Paul Moore,

Looks like this patch never got picked up. I think we should apply it.

-Steve

Quoted 38 lines · Paul Davies C

Currently when the coredump signals are logged by the audit system , the actual path to the executable is not logged. Without details of exe , the system admin may not have an exact idea on what program failed.

This patch changes the audit_log_task() so that the path to the exe is also logged.

---
 kernel/auditsc.c |    7 +++++++
 1 file changed, 7 insertions(+)
kernel/auditsc.c +7 -0
index 9845cb3..988de72 100644
@@ -2353,6 +2353,7 @@ static void audit_log_task(struct audit_buffer *ab)
 	kuid_t auid, uid;
 	kgid_t gid;
 	unsigned int sessionid;
+	struct mm_struct *mm = current->mm;
 
 	auid = audit_get_loginuid(current);
 	sessionid = audit_get_sessionid(current);
@@ -2366,6 +2367,12 @@ static void audit_log_task(struct audit_buffer *ab)
 	audit_log_task_context(ab);
 	audit_log_format(ab, " pid=%d comm=", current->pid);
 	audit_log_untrustedstring(ab, current->comm);
+	if (mm) {
+		down_read(&mm->mmap_sem);
+		if (mm->exe_file)
+			audit_log_d_path(ab, " exe=", &mm->exe_file->f_path);
+		up_read(&mm->mmap_sem);
+	}
 }
 
 static void audit_log_abend(struct audit_buffer *ab, char *reason, long

signr)

#7 lore raw
Quoted 3 lines · Steve Grubb

Hello Paul Moore,

Looks like this patch never got picked up. I think we should apply it.

Thanks for finding this; did you run into this problem?

Since this was posted back in 2013 it would be nice if someone could do a quick sanity test to show that 1) the problem still exists on current kernels and 2) the patch below fixes it. You get extra credit if you show your work.

The reproducer should be trivial; I'm just dealing with some other issues these next few days.

Quoted 48 lines · Paul Davies C
Quoted 47 lines

Currently when the coredump signals are logged by the audit system , the actual path to the executable is not logged. Without details of exe , the system admin may not have an exact idea on what program failed.

This patch changes the audit_log_task() so that the path to the exe is also
logged.

---

 kernel/auditsc.c |    7 +++++++
 1 file changed, 7 insertions(+)
kernel/auditsc.c +1 -0
index 9845cb3..988de72 100644
@@ -2353,6 +2353,7 @@ static void audit_log_task(struct audit_buffer *ab)
 
 	kuid_t auid, uid;
 	kgid_t gid;
 	unsigned int sessionid;
 
+	struct mm_struct *mm = current->mm;
 
kernel/auditsc.c +6 -0
 	auid = audit_get_loginuid(current);
 	sessionid = audit_get_sessionid(current);
@@ -2366,6 +2367,12 @@ static void audit_log_task(struct audit_buffer *ab)
 
 	audit_log_task_context(ab);
 	audit_log_format(ab, " pid=%d comm=", current->pid);
 	audit_log_untrustedstring(ab, current->comm);
 
+	if (mm) {
+		down_read(&mm->mmap_sem);
+		if (mm->exe_file)
+			audit_log_d_path(ab, " exe=", &mm->exe_file->f_path);
+		up_read(&mm->mmap_sem);
+	}
 

}

static void audit_log_abend(struct audit_buffer *ab, char *reason, long

signr)

Signature · 2 lines
paul moore
security @ redhat
#8 lore raw
Quoted 6 lines · Paul Moore
Quoted 3 lines · Steve Grubb

Hello Paul Moore,

Looks like this patch never got picked up. I think we should apply it.

Thanks for finding this; did you run into this problem?

I was going through old email trying to clear my backlog and saw this one marked for follow up at some point.

Quoted 3 lines

Since this was posted back in 2013 it would be nice if someone could do a quick sanity test to show that 1) the problem still exists on current kernels and

This is the function in question:

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/kernel/auditsc.c?id=refs/tags/v4.2-rc1#n2357

Actually, I missed the call to audit_log_d_path_exe() because I was looking for exe= in the logging string ...so its already fixed.

Sorry for the noise. :-)

-Steve

Quoted 57 lines

2) the patch below fixes it. You get extra credit if you show your work.

The reproducer should be trivial; I'm just dealing with some other issues these next few days.

Quoted 51 lines · Paul Davies C
Quoted 50 lines

Currently when the coredump signals are logged by the audit system , the actual path to the executable is not logged. Without details of exe , the
system admin may not have an exact idea on what program failed.

This patch changes the audit_log_task() so that the path to the exe is also
logged.

---

 kernel/auditsc.c |    7 +++++++
 1 file changed, 7 insertions(+)
kernel/auditsc.c +1 -0
index 9845cb3..988de72 100644
@@ -2353,6 +2353,7 @@ static void audit_log_task(struct audit_buffer
 *ab)
 
 	kuid_t auid, uid;
 	kgid_t gid;
 	unsigned int sessionid;
 
+	struct mm_struct *mm = current->mm;
kernel/auditsc.c +6 -0
 	auid = audit_get_loginuid(current);
 	sessionid = audit_get_sessionid(current);
@@ -2366,6 +2367,12 @@ static void audit_log_task(struct audit_buffer
 *ab)
 
 	audit_log_task_context(ab);
 	audit_log_format(ab, " pid=%d comm=", current->pid);
 	audit_log_untrustedstring(ab, current->comm);
 
+	if (mm) {
+		down_read(&mm->mmap_sem);
+		if (mm->exe_file)
+			audit_log_d_path(ab, " exe=", &mm->exe_file->f_path);
+		up_read(&mm->mmap_sem);
+	}

}

static void audit_log_abend(struct audit_buffer *ab, char *reason, long

signr)