Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 227792
b: refs/heads/master
c: 676dac4
h: refs/heads/master
v: v3
  • Loading branch information
Casey Schaufler committed Dec 2, 2010
1 parent 5f3a391 commit c6feb68
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 56 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ad9c2b048b605fbc8d50526e330b88abdd631ab2
refs/heads/master: 676dac4b1bee0469d6932f698aeb77e8489f5861
3 changes: 2 additions & 1 deletion trunk/include/linux/security.h
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,8 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
* @cred points to the credentials to provide the context against which to
* evaluate the security data on the key.
* @perm describes the combination of permissions required of this key.
* Return 0 if permission is granted, -ve error otherwise.
* Return 1 if permission granted, 0 if permission denied and -ve it the
* normal permissions model should be effected.
* @key_getsecurity:
* Get a textual representation of the security context attached to a key
* for the purposes of honouring KEYCTL_GETSECURITY. This function
Expand Down
2 changes: 2 additions & 0 deletions trunk/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 trunk/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 trunk/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 c6feb68

Please sign in to comment.