Skip to content

Commit 5efc244

Browse files
Mateusz Guzikpcmoore
authored andcommitted
audit: fix exe_file access in audit_exe_compare
Prior to the change the function would blindly deference mm, exe_file and exe_file->f_inode, each of which could have been NULL or freed. Use get_task_exe_file to safely obtain stable exe_file. Signed-off-by: Mateusz Guzik <mguzik@redhat.com> Acked-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru> Acked-by: Richard Guy Briggs <rgb@redhat.com> Cc: <stable@vger.kernel.org> # 4.3.x Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent cd81a91 commit 5efc244

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

kernel/audit_watch.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2020
*/
2121

22+
#include <linux/file.h>
2223
#include <linux/kernel.h>
2324
#include <linux/audit.h>
2425
#include <linux/kthread.h>
@@ -544,10 +545,11 @@ int audit_exe_compare(struct task_struct *tsk, struct audit_fsnotify_mark *mark)
544545
unsigned long ino;
545546
dev_t dev;
546547

547-
rcu_read_lock();
548-
exe_file = rcu_dereference(tsk->mm->exe_file);
548+
exe_file = get_task_exe_file(tsk);
549+
if (!exe_file)
550+
return 0;
549551
ino = exe_file->f_inode->i_ino;
550552
dev = exe_file->f_inode->i_sb->s_dev;
551-
rcu_read_unlock();
553+
fput(exe_file);
552554
return audit_mark_compare(mark, ino, dev);
553555
}

0 commit comments

Comments
 (0)