Skip to content

Commit

Permalink
Merge branch 'smack-next-master' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
James Morris committed Dec 2, 2010
2 parents ad9c2b0 + 676dac4 commit fe27d4b
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 54 deletions.
2 changes: 2 additions & 0 deletions include/linux/xattr.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@
#define XATTR_SMACK_SUFFIX "SMACK64"
#define XATTR_SMACK_IPIN "SMACK64IPIN"
#define XATTR_SMACK_IPOUT "SMACK64IPOUT"
#define XATTR_SMACK_EXEC "SMACK64EXEC"
#define XATTR_NAME_SMACK XATTR_SECURITY_PREFIX XATTR_SMACK_SUFFIX
#define XATTR_NAME_SMACKIPIN XATTR_SECURITY_PREFIX XATTR_SMACK_IPIN
#define XATTR_NAME_SMACKIPOUT XATTR_SECURITY_PREFIX XATTR_SMACK_IPOUT
#define XATTR_NAME_SMACKEXEC XATTR_SECURITY_PREFIX XATTR_SMACK_EXEC

#define XATTR_CAPS_SUFFIX "capability"
#define XATTR_NAME_CAPS XATTR_SECURITY_PREFIX XATTR_CAPS_SUFFIX
Expand Down
30 changes: 30 additions & 0 deletions security/smack/smack.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,16 @@ struct socket_smack {
*/
struct inode_smack {
char *smk_inode; /* label of the fso */
char *smk_task; /* label of the task */
struct mutex smk_lock; /* initialization lock */
int smk_flags; /* smack inode flags */
};

struct task_smack {
char *smk_task; /* label used for access control */
char *smk_forked; /* label when forked */
};

#define SMK_INODE_INSTANT 0x01 /* inode is instantiated */

/*
Expand Down Expand Up @@ -242,6 +248,30 @@ static inline char *smk_of_inode(const struct inode *isp)
return sip->smk_inode;
}

/*
* Present a pointer to the smack label in an task blob.
*/
static inline char *smk_of_task(const struct task_smack *tsp)
{
return tsp->smk_task;
}

/*
* Present a pointer to the forked smack label in an task blob.
*/
static inline char *smk_of_forked(const struct task_smack *tsp)
{
return tsp->smk_forked;
}

/*
* Present a pointer to the smack label in the curren task blob.
*/
static inline char *smk_of_current(void)
{
return smk_of_task(current_security());
}

/*
* logging functions
*/
Expand Down
4 changes: 2 additions & 2 deletions security/smack/smack_access.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ int smk_access(char *subject_label, char *object_label, int request,
int smk_curacc(char *obj_label, u32 mode, struct smk_audit_info *a)
{
int rc;
char *sp = current_security();
char *sp = smk_of_current();

rc = smk_access(sp, obj_label, mode, NULL);
if (rc == 0)
Expand All @@ -196,7 +196,7 @@ int smk_curacc(char *obj_label, u32 mode, struct smk_audit_info *a)
* only one that gets privilege and current does not
* have that label.
*/
if (smack_onlycap != NULL && smack_onlycap != current->cred->security)
if (smack_onlycap != NULL && smack_onlycap != sp)
goto out_audit;

if (capable(CAP_MAC_OVERRIDE))
Expand Down
Loading

0 comments on commit fe27d4b

Please sign in to comment.