diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index b652cb0..b17619d 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -31,7 +31,6 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, ei->sysctl_entry = table; inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; - inode->i_flags |= S_PRIVATE; /* tell selinux to ignore this inode */ inode->i_mode = table->mode; if (!table->child) { inode->i_mode |= S_IFREG; diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 51615f6..5f58019 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -1132,8 +1132,23 @@ static int selinux_proc_get_sid(struct dentry *dentry, path = dentry_path(dentry, buffer, PAGE_SIZE); if (IS_ERR(path)) rc = PTR_ERR(path); - else + else { + /* because dentry is not hashed, dentry_path() will + * append "//deleted" to the end of the string. We'll + * remove this as no /proc/ file is named so. */ + int pathlen = strlen(path); + int dellen = strlen("//deleted"); + if ((pathlen > dellen) && strcmp(path + pathlen - dellen, "//deleted") == 0) + path[pathlen-dellen] = '\0'; + + /* each process gets a /proc/PID/ entry. Strip off the + * PID part to get a valid selinux labeling. */ + while (path[1] >= '0' && path[1] <= '9') { + path[1] = '/'; + path++; + } rc = security_genfs_sid("proc", path, tclass, sid); + } free_page((unsigned long)buffer); return rc; } @@ -1464,9 +1479,6 @@ static int inode_has_perm(const struct cred *cred, validate_creds(cred); - if (unlikely(IS_PRIVATE(inode))) - return 0; - sid = cred_sid(cred); isec = inode->i_security;