[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>
This commit is contained in:
parent
510f4006e7
commit
4fc03b9beb
@ -1719,7 +1719,7 @@ do_last:
|
|||||||
* It already exists.
|
* It already exists.
|
||||||
*/
|
*/
|
||||||
mutex_unlock(&dir->d_inode->i_mutex);
|
mutex_unlock(&dir->d_inode->i_mutex);
|
||||||
audit_inode_update(path.dentry->d_inode);
|
audit_inode(pathname, path.dentry->d_inode);
|
||||||
|
|
||||||
error = -EEXIST;
|
error = -EEXIST;
|
||||||
if (flag & O_EXCL)
|
if (flag & O_EXCL)
|
||||||
|
@ -355,7 +355,6 @@ extern void audit_putname(const char *name);
|
|||||||
extern void __audit_inode(const char *name, const struct inode *inode);
|
extern void __audit_inode(const char *name, const struct inode *inode);
|
||||||
extern void __audit_inode_child(const char *dname, const struct inode *inode,
|
extern void __audit_inode_child(const char *dname, const struct inode *inode,
|
||||||
const struct inode *parent);
|
const struct inode *parent);
|
||||||
extern void __audit_inode_update(const struct inode *inode);
|
|
||||||
extern void __audit_ptrace(struct task_struct *t);
|
extern void __audit_ptrace(struct task_struct *t);
|
||||||
|
|
||||||
static inline int audit_dummy_context(void)
|
static inline int audit_dummy_context(void)
|
||||||
@ -378,10 +377,6 @@ static inline void audit_inode_child(const char *dname,
|
|||||||
if (unlikely(!audit_dummy_context()))
|
if (unlikely(!audit_dummy_context()))
|
||||||
__audit_inode_child(dname, inode, parent);
|
__audit_inode_child(dname, inode, parent);
|
||||||
}
|
}
|
||||||
static inline void audit_inode_update(const struct inode *inode) {
|
|
||||||
if (unlikely(!audit_dummy_context()))
|
|
||||||
__audit_inode_update(inode);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void audit_ptrace(struct task_struct *t)
|
static inline void audit_ptrace(struct task_struct *t)
|
||||||
{
|
{
|
||||||
@ -470,10 +465,8 @@ extern int audit_signals;
|
|||||||
#define audit_putname(n) do { ; } while (0)
|
#define audit_putname(n) do { ; } while (0)
|
||||||
#define __audit_inode(n,i) do { ; } while (0)
|
#define __audit_inode(n,i) do { ; } while (0)
|
||||||
#define __audit_inode_child(d,i,p) do { ; } while (0)
|
#define __audit_inode_child(d,i,p) do { ; } while (0)
|
||||||
#define __audit_inode_update(i) do { ; } while (0)
|
|
||||||
#define audit_inode(n,i) do { ; } while (0)
|
#define audit_inode(n,i) do { ; } while (0)
|
||||||
#define audit_inode_child(d,i,p) do { ; } while (0)
|
#define audit_inode_child(d,i,p) do { ; } while (0)
|
||||||
#define audit_inode_update(i) do { ; } while (0)
|
|
||||||
#define auditsc_get_stamp(c,t,s) do { BUG(); } while (0)
|
#define auditsc_get_stamp(c,t,s) do { BUG(); } while (0)
|
||||||
#define audit_get_loginuid(c) ({ -1; })
|
#define audit_get_loginuid(c) ({ -1; })
|
||||||
#define audit_log_task_context(b) do { ; } while (0)
|
#define audit_log_task_context(b) do { ; } while (0)
|
||||||
|
@ -681,6 +681,7 @@ asmlinkage long sys_mq_open(const char __user *u_name, int oflag, mode_t mode,
|
|||||||
|
|
||||||
if (oflag & O_CREAT) {
|
if (oflag & O_CREAT) {
|
||||||
if (dentry->d_inode) { /* entry already exists */
|
if (dentry->d_inode) { /* entry already exists */
|
||||||
|
audit_inode(name, dentry->d_inode);
|
||||||
error = -EEXIST;
|
error = -EEXIST;
|
||||||
if (oflag & O_EXCL)
|
if (oflag & O_EXCL)
|
||||||
goto out;
|
goto out;
|
||||||
@ -693,6 +694,7 @@ asmlinkage long sys_mq_open(const char __user *u_name, int oflag, mode_t mode,
|
|||||||
error = -ENOENT;
|
error = -ENOENT;
|
||||||
if (!dentry->d_inode)
|
if (!dentry->d_inode)
|
||||||
goto out;
|
goto out;
|
||||||
|
audit_inode(name, dentry->d_inode);
|
||||||
filp = do_open(dentry, oflag);
|
filp = do_open(dentry, oflag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -840,6 +842,7 @@ asmlinkage long sys_mq_timedsend(mqd_t mqdes, const char __user *u_msg_ptr,
|
|||||||
if (unlikely(filp->f_op != &mqueue_file_operations))
|
if (unlikely(filp->f_op != &mqueue_file_operations))
|
||||||
goto out_fput;
|
goto out_fput;
|
||||||
info = MQUEUE_I(inode);
|
info = MQUEUE_I(inode);
|
||||||
|
audit_inode(NULL, inode);
|
||||||
|
|
||||||
if (unlikely(!(filp->f_mode & FMODE_WRITE)))
|
if (unlikely(!(filp->f_mode & FMODE_WRITE)))
|
||||||
goto out_fput;
|
goto out_fput;
|
||||||
@ -923,6 +926,7 @@ asmlinkage ssize_t sys_mq_timedreceive(mqd_t mqdes, char __user *u_msg_ptr,
|
|||||||
if (unlikely(filp->f_op != &mqueue_file_operations))
|
if (unlikely(filp->f_op != &mqueue_file_operations))
|
||||||
goto out_fput;
|
goto out_fput;
|
||||||
info = MQUEUE_I(inode);
|
info = MQUEUE_I(inode);
|
||||||
|
audit_inode(NULL, inode);
|
||||||
|
|
||||||
if (unlikely(!(filp->f_mode & FMODE_READ)))
|
if (unlikely(!(filp->f_mode & FMODE_READ)))
|
||||||
goto out_fput;
|
goto out_fput;
|
||||||
|
@ -1475,33 +1475,6 @@ update_context:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* audit_inode_update - update inode info for last collected name
|
|
||||||
* @inode: inode being audited
|
|
||||||
*
|
|
||||||
* When open() is called on an existing object with the O_CREAT flag, the inode
|
|
||||||
* data audit initially collects is incorrect. This additional hook ensures
|
|
||||||
* audit has the inode data for the actual object to be opened.
|
|
||||||
*/
|
|
||||||
void __audit_inode_update(const struct inode *inode)
|
|
||||||
{
|
|
||||||
struct audit_context *context = current->audit_context;
|
|
||||||
int idx;
|
|
||||||
|
|
||||||
if (!context->in_syscall || !inode)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (context->name_count == 0) {
|
|
||||||
context->name_count++;
|
|
||||||
#if AUDIT_DEBUG
|
|
||||||
context->ino_count++;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
idx = context->name_count - 1;
|
|
||||||
|
|
||||||
audit_copy_inode(&context->names[idx], inode);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* auditsc_get_stamp - get local copies of audit_context values
|
* auditsc_get_stamp - get local copies of audit_context values
|
||||||
* @ctx: audit_context for the task
|
* @ctx: audit_context for the task
|
||||||
|
Loading…
x
Reference in New Issue
Block a user