Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'stable-4.8' of git://git.infradead.org/users/pcmoore/audit

Pull audit fixes from Paul Moore:
"Two small patches to fix some bugs with the audit-by-executable
functionality we introduced back in v4.3 (both patches are marked
for the stable folks)"

* 'stable-4.8' of git://git.infradead.org/users/pcmoore/audit:
audit: fix exe_file access in audit_exe_compare
mm: introduce get_task_exe_file

+30 -9
+1 -6
fs/proc/base.c
··· 1556 1556 static int proc_exe_link(struct dentry *dentry, struct path *exe_path) 1557 1557 { 1558 1558 struct task_struct *task; 1559 - struct mm_struct *mm; 1560 1559 struct file *exe_file; 1561 1560 1562 1561 task = get_proc_task(d_inode(dentry)); 1563 1562 if (!task) 1564 1563 return -ENOENT; 1565 - mm = get_task_mm(task); 1564 + exe_file = get_task_exe_file(task); 1566 1565 put_task_struct(task); 1567 - if (!mm) 1568 - return -ENOENT; 1569 - exe_file = get_mm_exe_file(mm); 1570 - mmput(mm); 1571 1566 if (exe_file) { 1572 1567 *exe_path = exe_file->f_path; 1573 1568 path_get(&exe_file->f_path);
+1
include/linux/mm.h
··· 2014 2014 2015 2015 extern void set_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file); 2016 2016 extern struct file *get_mm_exe_file(struct mm_struct *mm); 2017 + extern struct file *get_task_exe_file(struct task_struct *task); 2017 2018 2018 2019 extern bool may_expand_vm(struct mm_struct *, vm_flags_t, unsigned long npages); 2019 2020 extern void vm_stat_account(struct mm_struct *, vm_flags_t, long npages);
+5 -3
kernel/audit_watch.c
··· 19 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 20 */ 21 21 22 + #include <linux/file.h> 22 23 #include <linux/kernel.h> 23 24 #include <linux/audit.h> 24 25 #include <linux/kthread.h> ··· 545 544 unsigned long ino; 546 545 dev_t dev; 547 546 548 - rcu_read_lock(); 549 - exe_file = rcu_dereference(tsk->mm->exe_file); 547 + exe_file = get_task_exe_file(tsk); 548 + if (!exe_file) 549 + return 0; 550 550 ino = exe_file->f_inode->i_ino; 551 551 dev = exe_file->f_inode->i_sb->s_dev; 552 - rcu_read_unlock(); 552 + fput(exe_file); 553 553 return audit_mark_compare(mark, ino, dev); 554 554 }
+23
kernel/fork.c
··· 799 799 EXPORT_SYMBOL(get_mm_exe_file); 800 800 801 801 /** 802 + * get_task_exe_file - acquire a reference to the task's executable file 803 + * 804 + * Returns %NULL if task's mm (if any) has no associated executable file or 805 + * this is a kernel thread with borrowed mm (see the comment above get_task_mm). 806 + * User must release file via fput(). 807 + */ 808 + struct file *get_task_exe_file(struct task_struct *task) 809 + { 810 + struct file *exe_file = NULL; 811 + struct mm_struct *mm; 812 + 813 + task_lock(task); 814 + mm = task->mm; 815 + if (mm) { 816 + if (!(task->flags & PF_KTHREAD)) 817 + exe_file = get_mm_exe_file(mm); 818 + } 819 + task_unlock(task); 820 + return exe_file; 821 + } 822 + EXPORT_SYMBOL(get_task_exe_file); 823 + 824 + /** 802 825 * get_task_mm - acquire a reference to the task's mm 803 826 * 804 827 * Returns %NULL if the task has no mm. Checks PF_KTHREAD (meaning