aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2012-10-10 15:25:23 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-10-12 00:32:01 -0400
commitbfcec7087458812f575d9022b2d151641f34ee84 (patch)
tree6c0f7dd3b016992da8d113ceeaae404c6abc03a1 /fs
parent78e2e802a8519031e5858595070b39713e26340d (diff)
audit: set the name_len in audit_inode for parent lookups
Currently, this gets set mostly by happenstance when we call into audit_inode_child. While that might be a little more efficient, it seems wrong. If the syscall ends up failing before audit_inode_child ever gets called, then you'll have an audit_names record that shows the full path but has the parent inode info attached. Fix this by passing in a parent flag when we call audit_inode that gets set to the value of LOOKUP_PARENT. We can then fix up the pathname for the audit entry correctly from the get-go. While we're at it, clean up the no-op macro for audit_inode in the !CONFIG_AUDITSYSCALL case. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/namei.c14
-rw-r--r--fs/open.c4
-rw-r--r--fs/xattr.c8
3 files changed, 13 insertions, 13 deletions
diff --git a/fs/namei.c b/fs/namei.c
index a7ad35c66807..6a92d988573f 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1973,7 +1973,7 @@ static int do_path_lookup(int dfd, const char *name,
1973 retval = path_lookupat(dfd, name, flags | LOOKUP_REVAL, nd); 1973 retval = path_lookupat(dfd, name, flags | LOOKUP_REVAL, nd);
1974 1974
1975 if (likely(!retval)) 1975 if (likely(!retval))
1976 audit_inode(name, nd->path.dentry); 1976 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
1977 return retval; 1977 return retval;
1978} 1978}
1979 1979
@@ -2648,7 +2648,7 @@ static int do_last(struct nameidata *nd, struct path *path,
2648 error = complete_walk(nd); 2648 error = complete_walk(nd);
2649 if (error) 2649 if (error)
2650 return error; 2650 return error;
2651 audit_inode(pathname, nd->path.dentry); 2651 audit_inode(pathname, nd->path.dentry, 0);
2652 if (open_flag & O_CREAT) { 2652 if (open_flag & O_CREAT) {
2653 error = -EISDIR; 2653 error = -EISDIR;
2654 goto out; 2654 goto out;
@@ -2658,7 +2658,7 @@ static int do_last(struct nameidata *nd, struct path *path,
2658 error = complete_walk(nd); 2658 error = complete_walk(nd);
2659 if (error) 2659 if (error)
2660 return error; 2660 return error;
2661 audit_inode(pathname, dir); 2661 audit_inode(pathname, dir, 0);
2662 goto finish_open; 2662 goto finish_open;
2663 } 2663 }
2664 2664
@@ -2687,7 +2687,7 @@ static int do_last(struct nameidata *nd, struct path *path,
2687 if (error) 2687 if (error)
2688 return error; 2688 return error;
2689 2689
2690 audit_inode(pathname, dir); 2690 audit_inode(pathname, dir, 0);
2691 error = -EISDIR; 2691 error = -EISDIR;
2692 /* trailing slashes? */ 2692 /* trailing slashes? */
2693 if (nd->last.name[nd->last.len]) 2693 if (nd->last.name[nd->last.len])
@@ -2717,7 +2717,7 @@ retry_lookup:
2717 !S_ISREG(file->f_path.dentry->d_inode->i_mode)) 2717 !S_ISREG(file->f_path.dentry->d_inode->i_mode))
2718 will_truncate = false; 2718 will_truncate = false;
2719 2719
2720 audit_inode(pathname, file->f_path.dentry); 2720 audit_inode(pathname, file->f_path.dentry, 0);
2721 goto opened; 2721 goto opened;
2722 } 2722 }
2723 2723
@@ -2734,7 +2734,7 @@ retry_lookup:
2734 * create/update audit record if it already exists. 2734 * create/update audit record if it already exists.
2735 */ 2735 */
2736 if (path->dentry->d_inode) 2736 if (path->dentry->d_inode)
2737 audit_inode(pathname, path->dentry); 2737 audit_inode(pathname, path->dentry, 0);
2738 2738
2739 /* 2739 /*
2740 * If atomic_open() acquired write access it is dropped now due to 2740 * If atomic_open() acquired write access it is dropped now due to
@@ -2799,7 +2799,7 @@ finish_lookup:
2799 error = -ENOTDIR; 2799 error = -ENOTDIR;
2800 if ((nd->flags & LOOKUP_DIRECTORY) && !nd->inode->i_op->lookup) 2800 if ((nd->flags & LOOKUP_DIRECTORY) && !nd->inode->i_op->lookup)
2801 goto out; 2801 goto out;
2802 audit_inode(pathname, nd->path.dentry); 2802 audit_inode(pathname, nd->path.dentry, 0);
2803finish_open: 2803finish_open:
2804 if (!S_ISREG(nd->inode->i_mode)) 2804 if (!S_ISREG(nd->inode->i_mode))
2805 will_truncate = false; 2805 will_truncate = false;
diff --git a/fs/open.c b/fs/open.c
index 44da0feeca2c..a015437e1535 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -478,7 +478,7 @@ SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode)
478 478
479 file = fget(fd); 479 file = fget(fd);
480 if (file) { 480 if (file) {
481 audit_inode(NULL, file->f_path.dentry); 481 audit_inode(NULL, file->f_path.dentry, 0);
482 err = chmod_common(&file->f_path, mode); 482 err = chmod_common(&file->f_path, mode);
483 fput(file); 483 fput(file);
484 } 484 }
@@ -588,7 +588,7 @@ SYSCALL_DEFINE3(fchown, unsigned int, fd, uid_t, user, gid_t, group)
588 error = mnt_want_write_file(f.file); 588 error = mnt_want_write_file(f.file);
589 if (error) 589 if (error)
590 goto out_fput; 590 goto out_fput;
591 audit_inode(NULL, f.file->f_path.dentry); 591 audit_inode(NULL, f.file->f_path.dentry, 0);
592 error = chown_common(&f.file->f_path, user, group); 592 error = chown_common(&f.file->f_path, user, group);
593 mnt_drop_write_file(f.file); 593 mnt_drop_write_file(f.file);
594out_fput: 594out_fput:
diff --git a/fs/xattr.c b/fs/xattr.c
index 1780f062dbaf..e164dddb8e96 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -412,7 +412,7 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
412 if (!f.file) 412 if (!f.file)
413 return error; 413 return error;
414 dentry = f.file->f_path.dentry; 414 dentry = f.file->f_path.dentry;
415 audit_inode(NULL, dentry); 415 audit_inode(NULL, dentry, 0);
416 error = mnt_want_write_file(f.file); 416 error = mnt_want_write_file(f.file);
417 if (!error) { 417 if (!error) {
418 error = setxattr(dentry, name, value, size, flags); 418 error = setxattr(dentry, name, value, size, flags);
@@ -507,7 +507,7 @@ SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, name,
507 507
508 if (!f.file) 508 if (!f.file)
509 return error; 509 return error;
510 audit_inode(NULL, f.file->f_path.dentry); 510 audit_inode(NULL, f.file->f_path.dentry, 0);
511 error = getxattr(f.file->f_path.dentry, name, value, size); 511 error = getxattr(f.file->f_path.dentry, name, value, size);
512 fdput(f); 512 fdput(f);
513 return error; 513 return error;
@@ -586,7 +586,7 @@ SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
586 586
587 if (!f.file) 587 if (!f.file)
588 return error; 588 return error;
589 audit_inode(NULL, f.file->f_path.dentry); 589 audit_inode(NULL, f.file->f_path.dentry, 0);
590 error = listxattr(f.file->f_path.dentry, list, size); 590 error = listxattr(f.file->f_path.dentry, list, size);
591 fdput(f); 591 fdput(f);
592 return error; 592 return error;
@@ -655,7 +655,7 @@ SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
655 if (!f.file) 655 if (!f.file)
656 return error; 656 return error;
657 dentry = f.file->f_path.dentry; 657 dentry = f.file->f_path.dentry;
658 audit_inode(NULL, dentry); 658 audit_inode(NULL, dentry, 0);
659 error = mnt_want_write_file(f.file); 659 error = mnt_want_write_file(f.file);
660 if (!error) { 660 if (!error) {
661 error = removexattr(dentry, name); 661 error = removexattr(dentry, name);