aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/audit.c
diff options
context:
space:
mode:
authorDavidlohr Bueso <dave@stgolabs.net>2015-02-22 21:20:00 -0500
committerPaul Moore <pmoore@redhat.com>2015-02-23 16:55:47 -0500
commit4766b199ef9e1ca6316ee4f8f9d80c2ba1ed0290 (patch)
tree944e02461fe60016f75677b1661b5a8dd3d20d91 /kernel/audit.c
parent5985de6754a6fc22fbf7e4b6033d4bfa0240a63a (diff)
audit: consolidate handling of mm->exe_file
This patch adds a audit_log_d_path_exe() helper function to share how we handle auditing of the exe_file's path. Used by both audit and auditsc. No functionality is changed. Signed-off-by: Davidlohr Bueso <dbueso@suse.de> [PM: tweaked subject line] Signed-off-by: Paul Moore <pmoore@redhat.com>
Diffstat (limited to 'kernel/audit.c')
-rw-r--r--kernel/audit.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/kernel/audit.c b/kernel/audit.c
index d219bb03a364..684b51d612a3 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1848,11 +1848,24 @@ error_path:
1848} 1848}
1849EXPORT_SYMBOL(audit_log_task_context); 1849EXPORT_SYMBOL(audit_log_task_context);
1850 1850
1851void audit_log_d_path_exe(struct audit_buffer *ab,
1852 struct mm_struct *mm)
1853{
1854 if (!mm) {
1855 audit_log_format(ab, " exe=(null)");
1856 return;
1857 }
1858
1859 down_read(&mm->mmap_sem);
1860 if (mm->exe_file)
1861 audit_log_d_path(ab, " exe=", &mm->exe_file->f_path);
1862 up_read(&mm->mmap_sem);
1863}
1864
1851void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk) 1865void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk)
1852{ 1866{
1853 const struct cred *cred; 1867 const struct cred *cred;
1854 char comm[sizeof(tsk->comm)]; 1868 char comm[sizeof(tsk->comm)];
1855 struct mm_struct *mm = tsk->mm;
1856 char *tty; 1869 char *tty;
1857 1870
1858 if (!ab) 1871 if (!ab)
@@ -1888,13 +1901,7 @@ void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk)
1888 audit_log_format(ab, " comm="); 1901 audit_log_format(ab, " comm=");
1889 audit_log_untrustedstring(ab, get_task_comm(comm, tsk)); 1902 audit_log_untrustedstring(ab, get_task_comm(comm, tsk));
1890 1903
1891 if (mm) { 1904 audit_log_d_path_exe(ab, tsk->mm);
1892 down_read(&mm->mmap_sem);
1893 if (mm->exe_file)
1894 audit_log_d_path(ab, " exe=", &mm->exe_file->f_path);
1895 up_read(&mm->mmap_sem);
1896 } else
1897 audit_log_format(ab, " exe=(null)");
1898 audit_log_task_context(ab); 1905 audit_log_task_context(ab);
1899} 1906}
1900EXPORT_SYMBOL(audit_log_task_info); 1907EXPORT_SYMBOL(audit_log_task_info);