Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 201896
b: refs/heads/master
c: b782e0a
h: refs/heads/master
v: v3
  • Loading branch information
Eric Paris authored and James Morris committed Aug 2, 2010
1 parent 8538224 commit ea8e403
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 9 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: d09ca73979460b96d5d4684d588b188be9a1f57d
refs/heads/master: b782e0a68d17894d9a618ffea55b33639faa6bb4
5 changes: 5 additions & 0 deletions trunk/include/linux/lsm_audit.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ struct common_audit_data {
u32 requested;
u32 audited;
u32 denied;
/*
* auditdeny is a bit tricky and unintuitive. See the
* comments in avc.c for it's meaning and usage.
*/
u32 auditdeny;
struct av_decision *avd;
int result;
} selinux_audit_data;
Expand Down
24 changes: 22 additions & 2 deletions trunk/security/selinux/avc.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,29 @@ void avc_audit(u32 ssid, u32 tsid,
struct common_audit_data stack_data;
u32 denied, audited;
denied = requested & ~avd->allowed;
if (denied)
if (denied) {
audited = denied & avd->auditdeny;
else if (result)
/*
* a->selinux_audit_data.auditdeny is TRICKY! Setting a bit in
* this field means that ANY denials should NOT be audited if
* the policy contains an explicit dontaudit rule for that
* permission. Take notice that this is unrelated to the
* actual permissions that were denied. As an example lets
* assume:
*
* denied == READ
* avd.auditdeny & ACCESS == 0 (not set means explicit rule)
* selinux_audit_data.auditdeny & ACCESS == 1
*
* We will NOT audit the denial even though the denied
* permission was READ and the auditdeny checks were for
* ACCESS
*/
if (a &&
a->selinux_audit_data.auditdeny &&
!(a->selinux_audit_data.auditdeny & avd->auditdeny))
audited = 0;
} else if (result)
audited = denied = requested;
else
audited = requested & avd->auditallow;
Expand Down
20 changes: 15 additions & 5 deletions trunk/security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -2644,16 +2644,26 @@ static int selinux_inode_follow_link(struct dentry *dentry, struct nameidata *na
static int selinux_inode_permission(struct inode *inode, int mask)
{
const struct cred *cred = current_cred();
struct common_audit_data ad;
u32 perms;
bool from_access;

from_access = mask & MAY_ACCESS;
mask &= (MAY_READ|MAY_WRITE|MAY_EXEC|MAY_APPEND);

if (!mask) {
/* No permission to check. Existence test. */
/* No permission to check. Existence test. */
if (!mask)
return 0;
}

return inode_has_perm(cred, inode,
file_mask_to_av(inode->i_mode, mask), NULL);
COMMON_AUDIT_DATA_INIT(&ad, FS);
ad.u.fs.inode = inode;

if (from_access)
ad.selinux_audit_data.auditdeny |= FILE__AUDIT_ACCESS;

perms = file_mask_to_av(inode->i_mode, mask);

return inode_has_perm(cred, inode, perms, &ad);
}

static int selinux_inode_setattr(struct dentry *dentry, struct iattr *iattr)
Expand Down
2 changes: 1 addition & 1 deletion trunk/security/selinux/include/classmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"getattr", "setattr", "lock", "relabelfrom", "relabelto", "append"

#define COMMON_FILE_PERMS COMMON_FILE_SOCK_PERMS, "unlink", "link", \
"rename", "execute", "swapon", "quotaon", "mounton"
"rename", "execute", "swapon", "quotaon", "mounton", "audit_access"

#define COMMON_SOCK_PERMS COMMON_FILE_SOCK_PERMS, "bind", "connect", \
"listen", "accept", "getopt", "setopt", "shutdown", "recvfrom", \
Expand Down

0 comments on commit ea8e403

Please sign in to comment.