Skip to content

Commit

Permalink
Merge branch 'master' of git://git.infradead.org/users/eparis/selinux…
Browse files Browse the repository at this point in the history
… into next

Per pull request, for 3.5.
  • Loading branch information
James Morris committed May 22, 2012
2 parents cffee16 + c737f82 commit ff2bb04
Show file tree
Hide file tree
Showing 33 changed files with 422 additions and 350 deletions.
2 changes: 1 addition & 1 deletion fs/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,

f->f_op = fops_get(inode->i_fop);

error = security_dentry_open(f, cred);
error = security_file_open(f, cred);
if (error)
goto cleanup_all;

Expand Down
6 changes: 0 additions & 6 deletions include/linux/lsm_audit.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ struct common_audit_data {
#define LSM_AUDIT_DATA_KMOD 8
#define LSM_AUDIT_DATA_INODE 9
#define LSM_AUDIT_DATA_DENTRY 10
struct task_struct *tsk;
union {
struct path path;
struct dentry *dentry;
Expand Down Expand Up @@ -93,11 +92,6 @@ int ipv4_skb_to_auditdata(struct sk_buff *skb,
int ipv6_skb_to_auditdata(struct sk_buff *skb,
struct common_audit_data *ad, u8 *proto);

/* Initialize an LSM audit data structure. */
#define COMMON_AUDIT_DATA_INIT(_d, _t) \
{ memset((_d), 0, sizeof(struct common_audit_data)); \
(_d)->type = LSM_AUDIT_DATA_##_t; }

void common_lsm_audit(struct common_audit_data *a,
void (*pre_audit)(struct audit_buffer *, void *),
void (*post_audit)(struct audit_buffer *, void *));
Expand Down
13 changes: 5 additions & 8 deletions include/linux/security.h
Original file line number Diff line number Diff line change
Expand Up @@ -640,10 +640,7 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
* to receive an open file descriptor via socket IPC.
* @file contains the file structure being received.
* Return 0 if permission is granted.
*
* Security hook for dentry
*
* @dentry_open
* @file_open
* Save open-time permission checking state for later use upon
* file_permission, and recheck access if anything has changed
* since inode_permission.
Expand Down Expand Up @@ -1498,7 +1495,7 @@ struct security_operations {
int (*file_send_sigiotask) (struct task_struct *tsk,
struct fown_struct *fown, int sig);
int (*file_receive) (struct file *file);
int (*dentry_open) (struct file *file, const struct cred *cred);
int (*file_open) (struct file *file, const struct cred *cred);

int (*task_create) (unsigned long clone_flags);
void (*task_free) (struct task_struct *task);
Expand Down Expand Up @@ -1757,7 +1754,7 @@ int security_file_set_fowner(struct file *file);
int security_file_send_sigiotask(struct task_struct *tsk,
struct fown_struct *fown, int sig);
int security_file_receive(struct file *file);
int security_dentry_open(struct file *file, const struct cred *cred);
int security_file_open(struct file *file, const struct cred *cred);
int security_task_create(unsigned long clone_flags);
void security_task_free(struct task_struct *task);
int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
Expand Down Expand Up @@ -2228,8 +2225,8 @@ static inline int security_file_receive(struct file *file)
return 0;
}

static inline int security_dentry_open(struct file *file,
const struct cred *cred)
static inline int security_file_open(struct file *file,
const struct cred *cred)
{
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions net/xfrm/xfrm_policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <linux/cache.h>
#include <linux/audit.h>
#include <net/dst.h>
#include <net/flow.h>
#include <net/xfrm.h>
#include <net/ip.h>
#ifdef CONFIG_XFRM_STATISTICS
Expand Down
11 changes: 9 additions & 2 deletions security/apparmor/audit.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static const char *const aa_audit_type[] = {
static void audit_pre(struct audit_buffer *ab, void *ca)
{
struct common_audit_data *sa = ca;
struct task_struct *tsk = sa->tsk ? sa->tsk : current;
struct task_struct *tsk = sa->aad->tsk ? sa->aad->tsk : current;

if (aa_g_audit_header) {
audit_log_format(ab, "apparmor=");
Expand Down Expand Up @@ -149,6 +149,12 @@ static void audit_pre(struct audit_buffer *ab, void *ca)
audit_log_format(ab, " name=");
audit_log_untrustedstring(ab, sa->aad->name);
}

if (sa->aad->tsk) {
audit_log_format(ab, " pid=%d comm=", tsk->pid);
audit_log_untrustedstring(ab, tsk->comm);
}

}

/**
Expand Down Expand Up @@ -205,7 +211,8 @@ int aa_audit(int type, struct aa_profile *profile, gfp_t gfp,
aa_audit_msg(type, sa, cb);

if (sa->aad->type == AUDIT_APPARMOR_KILL)
(void)send_sig_info(SIGKILL, NULL, sa->tsk ? sa->tsk : current);
(void)send_sig_info(SIGKILL, NULL,
sa->aad->tsk ? sa->aad->tsk : current);

if (sa->aad->type == AUDIT_APPARMOR_ALLOWED)
return complain_error(sa->aad->error);
Expand Down
4 changes: 2 additions & 2 deletions security/apparmor/capability.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ static int audit_caps(struct aa_profile *profile, struct task_struct *task,
int type = AUDIT_APPARMOR_AUTO;
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
COMMON_AUDIT_DATA_INIT(&sa, CAP);
sa.type = LSM_AUDIT_DATA_CAP;
sa.aad = &aad;
sa.tsk = task;
sa.u.cap = cap;
sa.aad->tsk = task;
sa.aad->op = OP_CAPABLE;
sa.aad->error = error;

Expand Down
2 changes: 1 addition & 1 deletion security/apparmor/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ int aa_audit_file(struct aa_profile *profile, struct file_perms *perms,
int type = AUDIT_APPARMOR_AUTO;
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
COMMON_AUDIT_DATA_INIT(&sa, NONE);
sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad;
aad.op = op,
aad.fs.request = request;
Expand Down
1 change: 1 addition & 0 deletions security/apparmor/include/audit.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ struct apparmor_audit_data {
void *profile;
const char *name;
const char *info;
struct task_struct *tsk;
union {
void *target;
struct {
Expand Down
2 changes: 1 addition & 1 deletion security/apparmor/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static int aa_audit_ptrace(struct aa_profile *profile,
{
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
COMMON_AUDIT_DATA_INIT(&sa, NONE);
sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad;
aad.op = OP_PTRACE;
aad.target = target;
Expand Down
2 changes: 1 addition & 1 deletion security/apparmor/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void aa_info_message(const char *str)
if (audit_enabled) {
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
COMMON_AUDIT_DATA_INIT(&sa, NONE);
sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad;
aad.info = str;
aa_audit_msg(AUDIT_APPARMOR_STATUS, &sa, NULL);
Expand Down
6 changes: 3 additions & 3 deletions security/apparmor/lsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ static int apparmor_inode_getattr(struct vfsmount *mnt, struct dentry *dentry)
AA_MAY_META_READ);
}

static int apparmor_dentry_open(struct file *file, const struct cred *cred)
static int apparmor_file_open(struct file *file, const struct cred *cred)
{
struct aa_file_cxt *fcxt = file->f_security;
struct aa_profile *profile;
Expand Down Expand Up @@ -589,7 +589,7 @@ static int apparmor_setprocattr(struct task_struct *task, char *name,
} else {
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
COMMON_AUDIT_DATA_INIT(&sa, NONE);
sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad;
aad.op = OP_SETPROCATTR;
aad.info = name;
Expand Down Expand Up @@ -640,9 +640,9 @@ static struct security_operations apparmor_ops = {
.path_chmod = apparmor_path_chmod,
.path_chown = apparmor_path_chown,
.path_truncate = apparmor_path_truncate,
.dentry_open = apparmor_dentry_open,
.inode_getattr = apparmor_inode_getattr,

.file_open = apparmor_file_open,
.file_permission = apparmor_file_permission,
.file_alloc_security = apparmor_file_alloc_security,
.file_free_security = apparmor_file_free_security,
Expand Down
2 changes: 1 addition & 1 deletion security/apparmor/policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ static int audit_policy(int op, gfp_t gfp, const char *name, const char *info,
{
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
COMMON_AUDIT_DATA_INIT(&sa, NONE);
sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad;
aad.op = op;
aad.name = name;
Expand Down
2 changes: 1 addition & 1 deletion security/apparmor/policy_unpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static int audit_iface(struct aa_profile *new, const char *name,
struct aa_profile *profile = __aa_current_profile();
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
COMMON_AUDIT_DATA_INIT(&sa, NONE);
sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad;
if (e)
aad.iface.pos = e->pos - e->start;
Expand Down
2 changes: 1 addition & 1 deletion security/apparmor/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static int audit_resource(struct aa_profile *profile, unsigned int resource,
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};

COMMON_AUDIT_DATA_INIT(&sa, NONE);
sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad;
aad.op = OP_SETRLIMIT,
aad.rlim.rlim = resource;
Expand Down
4 changes: 2 additions & 2 deletions security/capability.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ static int cap_file_receive(struct file *file)
return 0;
}

static int cap_dentry_open(struct file *file, const struct cred *cred)
static int cap_file_open(struct file *file, const struct cred *cred)
{
return 0;
}
Expand Down Expand Up @@ -956,7 +956,7 @@ void __init security_fixup_ops(struct security_operations *ops)
set_to_cap_if_null(ops, file_set_fowner);
set_to_cap_if_null(ops, file_send_sigiotask);
set_to_cap_if_null(ops, file_receive);
set_to_cap_if_null(ops, dentry_open);
set_to_cap_if_null(ops, file_open);
set_to_cap_if_null(ops, task_create);
set_to_cap_if_null(ops, task_free);
set_to_cap_if_null(ops, cred_alloc_blank);
Expand Down
15 changes: 9 additions & 6 deletions security/lsm_audit.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,15 @@ static void dump_common_audit_data(struct audit_buffer *ab,
{
struct task_struct *tsk = current;

if (a->tsk)
tsk = a->tsk;
if (tsk && tsk->pid) {
audit_log_format(ab, " pid=%d comm=", tsk->pid);
audit_log_untrustedstring(ab, tsk->comm);
}
/*
* To keep stack sizes in check force programers to notice if they
* start making this union too large! See struct lsm_network_audit
* as an example of how to deal with large data.
*/
BUILD_BUG_ON(sizeof(a->u) > sizeof(void *)*2);

audit_log_format(ab, " pid=%d comm=", tsk->pid);
audit_log_untrustedstring(ab, tsk->comm);

switch (a->type) {
case LSM_AUDIT_DATA_NONE:
Expand Down
4 changes: 2 additions & 2 deletions security/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,11 +701,11 @@ int security_file_receive(struct file *file)
return security_ops->file_receive(file);
}

int security_dentry_open(struct file *file, const struct cred *cred)
int security_file_open(struct file *file, const struct cred *cred)
{
int ret;

ret = security_ops->dentry_open(file, cred);
ret = security_ops->file_open(file, cred);
if (ret)
return ret;

Expand Down
Loading

0 comments on commit ff2bb04

Please sign in to comment.