mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-30 19:06:14 +00:00
Revert "selinux: consider filesystem subtype in policies"
This reverts commit 102aefdda4
.
Tom London reports that it causes sync() to hang on Fedora rawhide:
https://bugzilla.redhat.com/show_bug.cgi?id=1033965
and Josh Boyer bisected it down to this commit. Reverting the commit in
the rawhide kernel fixes the problem.
Eric Paris root-caused it to incorrect subtype matching in that commit
breaking fuse, and has a tentative patch, but by now we're better off
retrying this in 3.14 rather than playing with it any more.
Reported-by: Tom London <selinux@gmail.com>
Bisected-by: Josh Boyer <jwboyer@fedoraproject.org>
Acked-by: Eric Paris <eparis@redhat.com>
Cc: James Morris <jmorris@namei.org>
Cc: Anand Avati <avati@redhat.com>
Cc: Paul Moore <paul@paul-moore.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
0925f2cdf9
commit
29b1deb2a4
2 changed files with 22 additions and 60 deletions
|
@ -95,10 +95,6 @@
|
||||||
#include "audit.h"
|
#include "audit.h"
|
||||||
#include "avc_ss.h"
|
#include "avc_ss.h"
|
||||||
|
|
||||||
#define SB_TYPE_FMT "%s%s%s"
|
|
||||||
#define SB_SUBTYPE(sb) (sb->s_subtype && sb->s_subtype[0])
|
|
||||||
#define SB_TYPE_ARGS(sb) sb->s_type->name, SB_SUBTYPE(sb) ? "." : "", SB_SUBTYPE(sb) ? sb->s_subtype : ""
|
|
||||||
|
|
||||||
extern struct security_operations *security_ops;
|
extern struct security_operations *security_ops;
|
||||||
|
|
||||||
/* SECMARK reference count */
|
/* SECMARK reference count */
|
||||||
|
@ -413,8 +409,8 @@ static int sb_finish_set_opts(struct super_block *sb)
|
||||||
the first boot of the SELinux kernel before we have
|
the first boot of the SELinux kernel before we have
|
||||||
assigned xattr values to the filesystem. */
|
assigned xattr values to the filesystem. */
|
||||||
if (!root_inode->i_op->getxattr) {
|
if (!root_inode->i_op->getxattr) {
|
||||||
printk(KERN_WARNING "SELinux: (dev %s, type "SB_TYPE_FMT") has no "
|
printk(KERN_WARNING "SELinux: (dev %s, type %s) has no "
|
||||||
"xattr support\n", sb->s_id, SB_TYPE_ARGS(sb));
|
"xattr support\n", sb->s_id, sb->s_type->name);
|
||||||
rc = -EOPNOTSUPP;
|
rc = -EOPNOTSUPP;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -422,22 +418,22 @@ static int sb_finish_set_opts(struct super_block *sb)
|
||||||
if (rc < 0 && rc != -ENODATA) {
|
if (rc < 0 && rc != -ENODATA) {
|
||||||
if (rc == -EOPNOTSUPP)
|
if (rc == -EOPNOTSUPP)
|
||||||
printk(KERN_WARNING "SELinux: (dev %s, type "
|
printk(KERN_WARNING "SELinux: (dev %s, type "
|
||||||
SB_TYPE_FMT") has no security xattr handler\n",
|
"%s) has no security xattr handler\n",
|
||||||
sb->s_id, SB_TYPE_ARGS(sb));
|
sb->s_id, sb->s_type->name);
|
||||||
else
|
else
|
||||||
printk(KERN_WARNING "SELinux: (dev %s, type "
|
printk(KERN_WARNING "SELinux: (dev %s, type "
|
||||||
SB_TYPE_FMT") getxattr errno %d\n", sb->s_id,
|
"%s) getxattr errno %d\n", sb->s_id,
|
||||||
SB_TYPE_ARGS(sb), -rc);
|
sb->s_type->name, -rc);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sbsec->behavior > ARRAY_SIZE(labeling_behaviors))
|
if (sbsec->behavior > ARRAY_SIZE(labeling_behaviors))
|
||||||
printk(KERN_ERR "SELinux: initialized (dev %s, type "SB_TYPE_FMT"), unknown behavior\n",
|
printk(KERN_ERR "SELinux: initialized (dev %s, type %s), unknown behavior\n",
|
||||||
sb->s_id, SB_TYPE_ARGS(sb));
|
sb->s_id, sb->s_type->name);
|
||||||
else
|
else
|
||||||
printk(KERN_DEBUG "SELinux: initialized (dev %s, type "SB_TYPE_FMT"), %s\n",
|
printk(KERN_DEBUG "SELinux: initialized (dev %s, type %s), %s\n",
|
||||||
sb->s_id, SB_TYPE_ARGS(sb),
|
sb->s_id, sb->s_type->name,
|
||||||
labeling_behaviors[sbsec->behavior-1]);
|
labeling_behaviors[sbsec->behavior-1]);
|
||||||
|
|
||||||
sbsec->flags |= SE_SBINITIALIZED;
|
sbsec->flags |= SE_SBINITIALIZED;
|
||||||
|
@ -600,6 +596,7 @@ static int selinux_set_mnt_opts(struct super_block *sb,
|
||||||
const struct cred *cred = current_cred();
|
const struct cred *cred = current_cred();
|
||||||
int rc = 0, i;
|
int rc = 0, i;
|
||||||
struct superblock_security_struct *sbsec = sb->s_security;
|
struct superblock_security_struct *sbsec = sb->s_security;
|
||||||
|
const char *name = sb->s_type->name;
|
||||||
struct inode *inode = sbsec->sb->s_root->d_inode;
|
struct inode *inode = sbsec->sb->s_root->d_inode;
|
||||||
struct inode_security_struct *root_isec = inode->i_security;
|
struct inode_security_struct *root_isec = inode->i_security;
|
||||||
u32 fscontext_sid = 0, context_sid = 0, rootcontext_sid = 0;
|
u32 fscontext_sid = 0, context_sid = 0, rootcontext_sid = 0;
|
||||||
|
@ -658,8 +655,8 @@ static int selinux_set_mnt_opts(struct super_block *sb,
|
||||||
strlen(mount_options[i]), &sid);
|
strlen(mount_options[i]), &sid);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
printk(KERN_WARNING "SELinux: security_context_to_sid"
|
printk(KERN_WARNING "SELinux: security_context_to_sid"
|
||||||
"(%s) failed for (dev %s, type "SB_TYPE_FMT") errno=%d\n",
|
"(%s) failed for (dev %s, type %s) errno=%d\n",
|
||||||
mount_options[i], sb->s_id, SB_TYPE_ARGS(sb), rc);
|
mount_options[i], sb->s_id, name, rc);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
switch (flags[i]) {
|
switch (flags[i]) {
|
||||||
|
@ -806,8 +803,7 @@ out:
|
||||||
out_double_mount:
|
out_double_mount:
|
||||||
rc = -EINVAL;
|
rc = -EINVAL;
|
||||||
printk(KERN_WARNING "SELinux: mount invalid. Same superblock, different "
|
printk(KERN_WARNING "SELinux: mount invalid. Same superblock, different "
|
||||||
"security settings for (dev %s, type "SB_TYPE_FMT")\n", sb->s_id,
|
"security settings for (dev %s, type %s)\n", sb->s_id, name);
|
||||||
SB_TYPE_ARGS(sb));
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2480,8 +2476,8 @@ static int selinux_sb_remount(struct super_block *sb, void *data)
|
||||||
rc = security_context_to_sid(mount_options[i], len, &sid);
|
rc = security_context_to_sid(mount_options[i], len, &sid);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
printk(KERN_WARNING "SELinux: security_context_to_sid"
|
printk(KERN_WARNING "SELinux: security_context_to_sid"
|
||||||
"(%s) failed for (dev %s, type "SB_TYPE_FMT") errno=%d\n",
|
"(%s) failed for (dev %s, type %s) errno=%d\n",
|
||||||
mount_options[i], sb->s_id, SB_TYPE_ARGS(sb), rc);
|
mount_options[i], sb->s_id, sb->s_type->name, rc);
|
||||||
goto out_free_opts;
|
goto out_free_opts;
|
||||||
}
|
}
|
||||||
rc = -EINVAL;
|
rc = -EINVAL;
|
||||||
|
@ -2519,8 +2515,8 @@ out_free_secdata:
|
||||||
return rc;
|
return rc;
|
||||||
out_bad_option:
|
out_bad_option:
|
||||||
printk(KERN_WARNING "SELinux: unable to change security options "
|
printk(KERN_WARNING "SELinux: unable to change security options "
|
||||||
"during remount (dev %s, type "SB_TYPE_FMT")\n", sb->s_id,
|
"during remount (dev %s, type=%s)\n", sb->s_id,
|
||||||
SB_TYPE_ARGS(sb));
|
sb->s_type->name);
|
||||||
goto out_free_opts;
|
goto out_free_opts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2334,50 +2334,16 @@ int security_fs_use(struct super_block *sb)
|
||||||
struct ocontext *c;
|
struct ocontext *c;
|
||||||
struct superblock_security_struct *sbsec = sb->s_security;
|
struct superblock_security_struct *sbsec = sb->s_security;
|
||||||
const char *fstype = sb->s_type->name;
|
const char *fstype = sb->s_type->name;
|
||||||
const char *subtype = (sb->s_subtype && sb->s_subtype[0]) ? sb->s_subtype : NULL;
|
|
||||||
struct ocontext *base = NULL;
|
|
||||||
|
|
||||||
read_lock(&policy_rwlock);
|
read_lock(&policy_rwlock);
|
||||||
|
|
||||||
for (c = policydb.ocontexts[OCON_FSUSE]; c; c = c->next) {
|
c = policydb.ocontexts[OCON_FSUSE];
|
||||||
char *sub;
|
while (c) {
|
||||||
int baselen;
|
if (strcmp(fstype, c->u.name) == 0)
|
||||||
|
|
||||||
baselen = strlen(fstype);
|
|
||||||
|
|
||||||
/* if base does not match, this is not the one */
|
|
||||||
if (strncmp(fstype, c->u.name, baselen))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* if there is no subtype, this is the one! */
|
|
||||||
if (!subtype)
|
|
||||||
break;
|
break;
|
||||||
|
c = c->next;
|
||||||
/* skip past the base in this entry */
|
|
||||||
sub = c->u.name + baselen;
|
|
||||||
|
|
||||||
/* entry is only a base. save it. keep looking for subtype */
|
|
||||||
if (sub[0] == '\0') {
|
|
||||||
base = c;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* entry is not followed by a subtype, so it is not a match */
|
|
||||||
if (sub[0] != '.')
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* whew, we found a subtype of this fstype */
|
|
||||||
sub++; /* move past '.' */
|
|
||||||
|
|
||||||
/* exact match of fstype AND subtype */
|
|
||||||
if (!strcmp(subtype, sub))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* in case we had found an fstype match but no subtype match */
|
|
||||||
if (!c)
|
|
||||||
c = base;
|
|
||||||
|
|
||||||
if (c) {
|
if (c) {
|
||||||
sbsec->behavior = c->v.behavior;
|
sbsec->behavior = c->v.behavior;
|
||||||
if (!c->sid[0]) {
|
if (!c->sid[0]) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue