aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/open.c4
-rw-r--r--fs/xattr.c16
-rw-r--r--include/linux/audit.h9
-rw-r--r--ipc/mqueue.c4
-rw-r--r--kernel/auditsc.c5
5 files changed, 24 insertions, 14 deletions
diff --git a/fs/open.c b/fs/open.c
index de92c13b58be..b1bf3d542d5d 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -516,7 +516,7 @@ SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode)
516 int err = -EBADF; 516 int err = -EBADF;
517 517
518 if (f.file) { 518 if (f.file) {
519 audit_inode(NULL, f.file->f_path.dentry, 0); 519 audit_file(f.file);
520 err = chmod_common(&f.file->f_path, mode); 520 err = chmod_common(&f.file->f_path, mode);
521 fdput(f); 521 fdput(f);
522 } 522 }
@@ -642,7 +642,7 @@ SYSCALL_DEFINE3(fchown, unsigned int, fd, uid_t, user, gid_t, group)
642 error = mnt_want_write_file(f.file); 642 error = mnt_want_write_file(f.file);
643 if (error) 643 if (error)
644 goto out_fput; 644 goto out_fput;
645 audit_inode(NULL, f.file->f_path.dentry, 0); 645 audit_file(f.file);
646 error = chown_common(&f.file->f_path, user, group); 646 error = chown_common(&f.file->f_path, user, group);
647 mnt_drop_write_file(f.file); 647 mnt_drop_write_file(f.file);
648out_fput: 648out_fput:
diff --git a/fs/xattr.c b/fs/xattr.c
index 64e83efb742d..4ef698549e31 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -405,16 +405,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
405 const void __user *,value, size_t, size, int, flags) 405 const void __user *,value, size_t, size, int, flags)
406{ 406{
407 struct fd f = fdget(fd); 407 struct fd f = fdget(fd);
408 struct dentry *dentry;
409 int error = -EBADF; 408 int error = -EBADF;
410 409
411 if (!f.file) 410 if (!f.file)
412 return error; 411 return error;
413 dentry = f.file->f_path.dentry; 412 audit_file(f.file);
414 audit_inode(NULL, dentry, 0);
415 error = mnt_want_write_file(f.file); 413 error = mnt_want_write_file(f.file);
416 if (!error) { 414 if (!error) {
417 error = setxattr(dentry, name, value, size, flags); 415 error = setxattr(f.file->f_path.dentry, name, value, size, flags);
418 mnt_drop_write_file(f.file); 416 mnt_drop_write_file(f.file);
419 } 417 }
420 fdput(f); 418 fdput(f);
@@ -509,7 +507,7 @@ SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, name,
509 507
510 if (!f.file) 508 if (!f.file)
511 return error; 509 return error;
512 audit_inode(NULL, f.file->f_path.dentry, 0); 510 audit_file(f.file);
513 error = getxattr(f.file->f_path.dentry, name, value, size); 511 error = getxattr(f.file->f_path.dentry, name, value, size);
514 fdput(f); 512 fdput(f);
515 return error; 513 return error;
@@ -590,7 +588,7 @@ SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
590 588
591 if (!f.file) 589 if (!f.file)
592 return error; 590 return error;
593 audit_inode(NULL, f.file->f_path.dentry, 0); 591 audit_file(f.file);
594 error = listxattr(f.file->f_path.dentry, list, size); 592 error = listxattr(f.file->f_path.dentry, list, size);
595 fdput(f); 593 fdput(f);
596 return error; 594 return error;
@@ -651,16 +649,14 @@ SYSCALL_DEFINE2(lremovexattr, const char __user *, pathname,
651SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name) 649SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
652{ 650{
653 struct fd f = fdget(fd); 651 struct fd f = fdget(fd);
654 struct dentry *dentry;
655 int error = -EBADF; 652 int error = -EBADF;
656 653
657 if (!f.file) 654 if (!f.file)
658 return error; 655 return error;
659 dentry = f.file->f_path.dentry; 656 audit_file(f.file);
660 audit_inode(NULL, dentry, 0);
661 error = mnt_want_write_file(f.file); 657 error = mnt_want_write_file(f.file);
662 if (!error) { 658 if (!error) {
663 error = removexattr(dentry, name); 659 error = removexattr(f.file->f_path.dentry, name);
664 mnt_drop_write_file(f.file); 660 mnt_drop_write_file(f.file);
665 } 661 }
666 fdput(f); 662 fdput(f);
diff --git a/include/linux/audit.h b/include/linux/audit.h
index e58fe7df8b9c..0c04917c2f12 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -130,6 +130,7 @@ extern void audit_putname(struct filename *name);
130#define AUDIT_INODE_HIDDEN 2 /* audit record should be hidden */ 130#define AUDIT_INODE_HIDDEN 2 /* audit record should be hidden */
131extern void __audit_inode(struct filename *name, const struct dentry *dentry, 131extern void __audit_inode(struct filename *name, const struct dentry *dentry,
132 unsigned int flags); 132 unsigned int flags);
133extern void __audit_file(const struct file *);
133extern void __audit_inode_child(const struct inode *parent, 134extern void __audit_inode_child(const struct inode *parent,
134 const struct dentry *dentry, 135 const struct dentry *dentry,
135 const unsigned char type); 136 const unsigned char type);
@@ -183,6 +184,11 @@ static inline void audit_inode(struct filename *name,
183 __audit_inode(name, dentry, flags); 184 __audit_inode(name, dentry, flags);
184 } 185 }
185} 186}
187static inline void audit_file(struct file *file)
188{
189 if (unlikely(!audit_dummy_context()))
190 __audit_file(file);
191}
186static inline void audit_inode_parent_hidden(struct filename *name, 192static inline void audit_inode_parent_hidden(struct filename *name,
187 const struct dentry *dentry) 193 const struct dentry *dentry)
188{ 194{
@@ -357,6 +363,9 @@ static inline void audit_inode(struct filename *name,
357 const struct dentry *dentry, 363 const struct dentry *dentry,
358 unsigned int parent) 364 unsigned int parent)
359{ } 365{ }
366static inline void audit_file(struct file *file)
367{
368}
360static inline void audit_inode_parent_hidden(struct filename *name, 369static inline void audit_inode_parent_hidden(struct filename *name,
361 const struct dentry *dentry) 370 const struct dentry *dentry)
362{ } 371{ }
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 4fcf39af1776..7635a1cf99f3 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -990,7 +990,7 @@ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr,
990 goto out_fput; 990 goto out_fput;
991 } 991 }
992 info = MQUEUE_I(inode); 992 info = MQUEUE_I(inode);
993 audit_inode(NULL, f.file->f_path.dentry, 0); 993 audit_file(f.file);
994 994
995 if (unlikely(!(f.file->f_mode & FMODE_WRITE))) { 995 if (unlikely(!(f.file->f_mode & FMODE_WRITE))) {
996 ret = -EBADF; 996 ret = -EBADF;
@@ -1106,7 +1106,7 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr,
1106 goto out_fput; 1106 goto out_fput;
1107 } 1107 }
1108 info = MQUEUE_I(inode); 1108 info = MQUEUE_I(inode);
1109 audit_inode(NULL, f.file->f_path.dentry, 0); 1109 audit_file(f.file);
1110 1110
1111 if (unlikely(!(f.file->f_mode & FMODE_READ))) { 1111 if (unlikely(!(f.file->f_mode & FMODE_READ))) {
1112 ret = -EBADF; 1112 ret = -EBADF;
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 06820657c8ca..c75522a83678 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1897,6 +1897,11 @@ out:
1897 audit_copy_inode(n, dentry, inode); 1897 audit_copy_inode(n, dentry, inode);
1898} 1898}
1899 1899
1900void __audit_file(const struct file *file)
1901{
1902 __audit_inode(NULL, file->f_path.dentry, 0);
1903}
1904
1900/** 1905/**
1901 * __audit_inode_child - collect inode info for created/removed objects 1906 * __audit_inode_child - collect inode info for created/removed objects
1902 * @parent: inode of dentry parent 1907 * @parent: inode of dentry parent