aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmy Griffis <amy.griffis@hp.com>2007-02-13 14:15:01 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2007-05-11 05:38:26 -0400
commit4fc03b9beb2314f3adb9e72b7935a80c577954d1 (patch)
tree81e04534c582923fcdc8212497d1487ddae412a8
parent510f4006e7a82b37b53c17bbe64ec20f3a59302b (diff)
[PATCH] complete message queue auditing
Handle the edge cases for POSIX message queue auditing. Collect inode info when opening an existing mq, and for send/receive operations. Remove audit_inode_update() as it has really evolved into the equivalent of audit_inode(). Signed-off-by: Amy Griffis <amy.griffis@hp.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/namei.c2
-rw-r--r--include/linux/audit.h7
-rw-r--r--ipc/mqueue.c4
-rw-r--r--kernel/auditsc.c27
4 files changed, 5 insertions, 35 deletions
diff --git a/fs/namei.c b/fs/namei.c
index b3780e3fc88e..5e2d98d10c5d 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1719,7 +1719,7 @@ do_last:
1719 * It already exists. 1719 * It already exists.
1720 */ 1720 */
1721 mutex_unlock(&dir->d_inode->i_mutex); 1721 mutex_unlock(&dir->d_inode->i_mutex);
1722 audit_inode_update(path.dentry->d_inode); 1722 audit_inode(pathname, path.dentry->d_inode);
1723 1723
1724 error = -EEXIST; 1724 error = -EEXIST;
1725 if (flag & O_EXCL) 1725 if (flag & O_EXCL)
diff --git a/include/linux/audit.h b/include/linux/audit.h
index fde0f1420cd2..22976ddbd264 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -355,7 +355,6 @@ extern void audit_putname(const char *name);
355extern void __audit_inode(const char *name, const struct inode *inode); 355extern void __audit_inode(const char *name, const struct inode *inode);
356extern void __audit_inode_child(const char *dname, const struct inode *inode, 356extern void __audit_inode_child(const char *dname, const struct inode *inode,
357 const struct inode *parent); 357 const struct inode *parent);
358extern void __audit_inode_update(const struct inode *inode);
359extern void __audit_ptrace(struct task_struct *t); 358extern void __audit_ptrace(struct task_struct *t);
360 359
361static inline int audit_dummy_context(void) 360static inline int audit_dummy_context(void)
@@ -378,10 +377,6 @@ static inline void audit_inode_child(const char *dname,
378 if (unlikely(!audit_dummy_context())) 377 if (unlikely(!audit_dummy_context()))
379 __audit_inode_child(dname, inode, parent); 378 __audit_inode_child(dname, inode, parent);
380} 379}
381static inline void audit_inode_update(const struct inode *inode) {
382 if (unlikely(!audit_dummy_context()))
383 __audit_inode_update(inode);
384}
385 380
386static inline void audit_ptrace(struct task_struct *t) 381static inline void audit_ptrace(struct task_struct *t)
387{ 382{
@@ -470,10 +465,8 @@ extern int audit_signals;
470#define audit_putname(n) do { ; } while (0) 465#define audit_putname(n) do { ; } while (0)
471#define __audit_inode(n,i) do { ; } while (0) 466#define __audit_inode(n,i) do { ; } while (0)
472#define __audit_inode_child(d,i,p) do { ; } while (0) 467#define __audit_inode_child(d,i,p) do { ; } while (0)
473#define __audit_inode_update(i) do { ; } while (0)
474#define audit_inode(n,i) do { ; } while (0) 468#define audit_inode(n,i) do { ; } while (0)
475#define audit_inode_child(d,i,p) do { ; } while (0) 469#define audit_inode_child(d,i,p) do { ; } while (0)
476#define audit_inode_update(i) do { ; } while (0)
477#define auditsc_get_stamp(c,t,s) do { BUG(); } while (0) 470#define auditsc_get_stamp(c,t,s) do { BUG(); } while (0)
478#define audit_get_loginuid(c) ({ -1; }) 471#define audit_get_loginuid(c) ({ -1; })
479#define audit_log_task_context(b) do { ; } while (0) 472#define audit_log_task_context(b) do { ; } while (0)
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index d17821d3f483..fab5707cb5f7 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -681,6 +681,7 @@ asmlinkage long sys_mq_open(const char __user *u_name, int oflag, mode_t mode,
681 681
682 if (oflag & O_CREAT) { 682 if (oflag & O_CREAT) {
683 if (dentry->d_inode) { /* entry already exists */ 683 if (dentry->d_inode) { /* entry already exists */
684 audit_inode(name, dentry->d_inode);
684 error = -EEXIST; 685 error = -EEXIST;
685 if (oflag & O_EXCL) 686 if (oflag & O_EXCL)
686 goto out; 687 goto out;
@@ -693,6 +694,7 @@ asmlinkage long sys_mq_open(const char __user *u_name, int oflag, mode_t mode,
693 error = -ENOENT; 694 error = -ENOENT;
694 if (!dentry->d_inode) 695 if (!dentry->d_inode)
695 goto out; 696 goto out;
697 audit_inode(name, dentry->d_inode);
696 filp = do_open(dentry, oflag); 698 filp = do_open(dentry, oflag);
697 } 699 }
698 700
@@ -840,6 +842,7 @@ asmlinkage long sys_mq_timedsend(mqd_t mqdes, const char __user *u_msg_ptr,
840 if (unlikely(filp->f_op != &mqueue_file_operations)) 842 if (unlikely(filp->f_op != &mqueue_file_operations))
841 goto out_fput; 843 goto out_fput;
842 info = MQUEUE_I(inode); 844 info = MQUEUE_I(inode);
845 audit_inode(NULL, inode);
843 846
844 if (unlikely(!(filp->f_mode & FMODE_WRITE))) 847 if (unlikely(!(filp->f_mode & FMODE_WRITE)))
845 goto out_fput; 848 goto out_fput;
@@ -923,6 +926,7 @@ asmlinkage ssize_t sys_mq_timedreceive(mqd_t mqdes, char __user *u_msg_ptr,
923 if (unlikely(filp->f_op != &mqueue_file_operations)) 926 if (unlikely(filp->f_op != &mqueue_file_operations))
924 goto out_fput; 927 goto out_fput;
925 info = MQUEUE_I(inode); 928 info = MQUEUE_I(inode);
929 audit_inode(NULL, inode);
926 930
927 if (unlikely(!(filp->f_mode & FMODE_READ))) 931 if (unlikely(!(filp->f_mode & FMODE_READ)))
928 goto out_fput; 932 goto out_fput;
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 41d129a78793..25d890e997f2 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1476,33 +1476,6 @@ update_context:
1476} 1476}
1477 1477
1478/** 1478/**
1479 * audit_inode_update - update inode info for last collected name
1480 * @inode: inode being audited
1481 *
1482 * When open() is called on an existing object with the O_CREAT flag, the inode
1483 * data audit initially collects is incorrect. This additional hook ensures
1484 * audit has the inode data for the actual object to be opened.
1485 */
1486void __audit_inode_update(const struct inode *inode)
1487{
1488 struct audit_context *context = current->audit_context;
1489 int idx;
1490
1491 if (!context->in_syscall || !inode)
1492 return;
1493
1494 if (context->name_count == 0) {
1495 context->name_count++;
1496#if AUDIT_DEBUG
1497 context->ino_count++;
1498#endif
1499 }
1500 idx = context->name_count - 1;
1501
1502 audit_copy_inode(&context->names[idx], inode);
1503}
1504
1505/**
1506 * auditsc_get_stamp - get local copies of audit_context values 1479 * auditsc_get_stamp - get local copies of audit_context values
1507 * @ctx: audit_context for the task 1480 * @ctx: audit_context for the task
1508 * @t: timespec to store time recorded in the audit_context 1481 * @t: timespec to store time recorded in the audit_context