selinux/stable-5.5 PR 20191126
-----BEGIN PGP SIGNATURE----- iQJIBAABCAAyFiEES0KozwfymdVUl37v6iDy2pc3iXMFAl3dbJIUHHBhdWxAcGF1 bC1tb29yZS5jb20ACgkQ6iDy2pc3iXNEyA/+MYEvQz0BhGBdpHgoCLnUGbEafsxH 2pWnHSupsCi1/9gal4ztVqW6GMQAQe3C4PhEYAnJ0/sIvix5uBMDFehGEwxzj8aQ fOAHYROOsQVQ4D2sfxBfliY0gouTTxFpCK95hvgXR1Y6WP6RBSowS5fmsvfqvz7i qDDZvCLOg5ULPHvpmJR3wRjs8MIbZTOiKg1K0VjJgJGzdvEoFfm2faw6WiHkPwm5 GFiW5PABv1c1Jbe4NL1r85r5iPPZgt+4BygS2QWkx7IVoAvPGhtlkB4Eh0pSESbg n141DwJ79uwI2UDUi0Zfcr1Y9OtH1YveUtxZUNi/NYSdxc9R4SjVZJC0TdjrwjWy K2jKV6gTn6NBLPuk+HAlj29ETF07G/BJDNkaIGqJcJ97t3kjuODb+QA+eFyM/1t7 V1oGMtKm6qGhb6y2bMMzmgftFXB0qrppdklkj+Gs8bNEUTfxPRcJS7tk6CZgOTI0 D5Ikfeu0muflIqug7w7wK8I6s63ZMNoDxZ5Nyy3idm5ZjxcQXp1Ys5x6Axir4lwe 2tvXwgvNV+/1ZEXNBu8Yhh5EDnZ9Wp1ENd/MT8VlZ77KfAPNnhq48uBKjpQD3KY5 wPavTRHTu+mnElqkO2cnjDYVhMYrhtbTCeQBY40wLyQDzbqzCOfLav9jisJnblzU R8iH6YlokDKPTeQ= =x1yB -----END PGP SIGNATURE----- Merge tag 'selinux-pr-20191126' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux Pull selinux updates from Paul Moore: "Only three SELinux patches for v5.5: - Remove the size limit on SELinux policies, the limitation was a lingering vestige and no longer necessary. - Allow file labeling before the policy is loaded. This should ease some of the burden when the policy is initially loaded (no need to relabel files), but it should also help enable some new system concepts which dynamically create the root filesystem in the initrd. - Add support for the "greatest lower bound" policy construct which is defined as the intersection of the MLS range of two SELinux labels" * tag 'selinux-pr-20191126' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux: selinux: default_range glblub implementation selinux: allow labeling before policy is loaded selinux: remove load size limit
This commit is contained in:
commit
ba75082efc
|
@ -3144,6 +3144,9 @@ static int selinux_inode_setxattr(struct dentry *dentry, const char *name,
|
||||||
return dentry_has_perm(current_cred(), dentry, FILE__SETATTR);
|
return dentry_has_perm(current_cred(), dentry, FILE__SETATTR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!selinux_state.initialized)
|
||||||
|
return (inode_owner_or_capable(inode) ? 0 : -EPERM);
|
||||||
|
|
||||||
sbsec = inode->i_sb->s_security;
|
sbsec = inode->i_sb->s_security;
|
||||||
if (!(sbsec->flags & SBLABEL_MNT))
|
if (!(sbsec->flags & SBLABEL_MNT))
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
@ -3227,6 +3230,15 @@ static void selinux_inode_post_setxattr(struct dentry *dentry, const char *name,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!selinux_state.initialized) {
|
||||||
|
/* If we haven't even been initialized, then we can't validate
|
||||||
|
* against a policy, so leave the label as invalid. It may
|
||||||
|
* resolve to a valid label on the next revalidation try if
|
||||||
|
* we've since initialized.
|
||||||
|
*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
rc = security_context_to_sid_force(&selinux_state, value, size,
|
rc = security_context_to_sid_force(&selinux_state, value, size,
|
||||||
&newsid);
|
&newsid);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
|
|
|
@ -40,10 +40,11 @@
|
||||||
#define POLICYDB_VERSION_CONSTRAINT_NAMES 29
|
#define POLICYDB_VERSION_CONSTRAINT_NAMES 29
|
||||||
#define POLICYDB_VERSION_XPERMS_IOCTL 30
|
#define POLICYDB_VERSION_XPERMS_IOCTL 30
|
||||||
#define POLICYDB_VERSION_INFINIBAND 31
|
#define POLICYDB_VERSION_INFINIBAND 31
|
||||||
|
#define POLICYDB_VERSION_GLBLUB 32
|
||||||
|
|
||||||
/* Range of policy versions we understand*/
|
/* Range of policy versions we understand*/
|
||||||
#define POLICYDB_VERSION_MIN POLICYDB_VERSION_BASE
|
#define POLICYDB_VERSION_MIN POLICYDB_VERSION_BASE
|
||||||
#define POLICYDB_VERSION_MAX POLICYDB_VERSION_INFINIBAND
|
#define POLICYDB_VERSION_MAX POLICYDB_VERSION_GLBLUB
|
||||||
|
|
||||||
/* Mask for just the mount related flags */
|
/* Mask for just the mount related flags */
|
||||||
#define SE_MNTMASK 0x0f
|
#define SE_MNTMASK 0x0f
|
||||||
|
|
|
@ -548,10 +548,6 @@ static ssize_t sel_write_load(struct file *file, const char __user *buf,
|
||||||
if (*ppos != 0)
|
if (*ppos != 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
length = -EFBIG;
|
|
||||||
if (count > 64 * 1024 * 1024)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
length = -ENOMEM;
|
length = -ENOMEM;
|
||||||
data = vmalloc(count);
|
data = vmalloc(count);
|
||||||
if (!data)
|
if (!data)
|
||||||
|
|
|
@ -95,6 +95,38 @@ out:
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline int mls_context_glblub(struct context *dst,
|
||||||
|
struct context *c1, struct context *c2)
|
||||||
|
{
|
||||||
|
struct mls_range *dr = &dst->range, *r1 = &c1->range, *r2 = &c2->range;
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
if (r1->level[1].sens < r2->level[0].sens ||
|
||||||
|
r2->level[1].sens < r1->level[0].sens)
|
||||||
|
/* These ranges have no common sensitivities */
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
/* Take the greatest of the low */
|
||||||
|
dr->level[0].sens = max(r1->level[0].sens, r2->level[0].sens);
|
||||||
|
|
||||||
|
/* Take the least of the high */
|
||||||
|
dr->level[1].sens = min(r1->level[1].sens, r2->level[1].sens);
|
||||||
|
|
||||||
|
rc = ebitmap_and(&dr->level[0].cat,
|
||||||
|
&r1->level[0].cat, &r2->level[0].cat);
|
||||||
|
if (rc)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
rc = ebitmap_and(&dr->level[1].cat,
|
||||||
|
&r1->level[1].cat, &r2->level[1].cat);
|
||||||
|
if (rc)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
out:
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
static inline int mls_context_cmp(struct context *c1, struct context *c2)
|
static inline int mls_context_cmp(struct context *c1, struct context *c2)
|
||||||
{
|
{
|
||||||
return ((c1->range.level[0].sens == c2->range.level[0].sens) &&
|
return ((c1->range.level[0].sens == c2->range.level[0].sens) &&
|
||||||
|
|
|
@ -77,6 +77,24 @@ int ebitmap_cpy(struct ebitmap *dst, struct ebitmap *src)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ebitmap_and(struct ebitmap *dst, struct ebitmap *e1, struct ebitmap *e2)
|
||||||
|
{
|
||||||
|
struct ebitmap_node *n;
|
||||||
|
int bit, rc;
|
||||||
|
|
||||||
|
ebitmap_init(dst);
|
||||||
|
|
||||||
|
ebitmap_for_each_positive_bit(e1, n, bit) {
|
||||||
|
if (ebitmap_get_bit(e2, bit)) {
|
||||||
|
rc = ebitmap_set_bit(dst, bit, 1);
|
||||||
|
if (rc < 0)
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef CONFIG_NETLABEL
|
#ifdef CONFIG_NETLABEL
|
||||||
/**
|
/**
|
||||||
* ebitmap_netlbl_export - Export an ebitmap into a NetLabel category bitmap
|
* ebitmap_netlbl_export - Export an ebitmap into a NetLabel category bitmap
|
||||||
|
|
|
@ -124,6 +124,7 @@ static inline void ebitmap_node_clr_bit(struct ebitmap_node *n,
|
||||||
|
|
||||||
int ebitmap_cmp(struct ebitmap *e1, struct ebitmap *e2);
|
int ebitmap_cmp(struct ebitmap *e1, struct ebitmap *e2);
|
||||||
int ebitmap_cpy(struct ebitmap *dst, struct ebitmap *src);
|
int ebitmap_cpy(struct ebitmap *dst, struct ebitmap *src);
|
||||||
|
int ebitmap_and(struct ebitmap *dst, struct ebitmap *e1, struct ebitmap *e2);
|
||||||
int ebitmap_contains(struct ebitmap *e1, struct ebitmap *e2, u32 last_e2bit);
|
int ebitmap_contains(struct ebitmap *e1, struct ebitmap *e2, u32 last_e2bit);
|
||||||
int ebitmap_get_bit(struct ebitmap *e, unsigned long bit);
|
int ebitmap_get_bit(struct ebitmap *e, unsigned long bit);
|
||||||
int ebitmap_set_bit(struct ebitmap *e, unsigned long bit, int value);
|
int ebitmap_set_bit(struct ebitmap *e, unsigned long bit, int value);
|
||||||
|
|
|
@ -529,6 +529,9 @@ int mls_compute_sid(struct policydb *p,
|
||||||
return mls_context_cpy_high(newcontext, tcontext);
|
return mls_context_cpy_high(newcontext, tcontext);
|
||||||
case DEFAULT_TARGET_LOW_HIGH:
|
case DEFAULT_TARGET_LOW_HIGH:
|
||||||
return mls_context_cpy(newcontext, tcontext);
|
return mls_context_cpy(newcontext, tcontext);
|
||||||
|
case DEFAULT_GLBLUB:
|
||||||
|
return mls_context_glblub(newcontext,
|
||||||
|
scontext, tcontext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fallthrough */
|
/* Fallthrough */
|
||||||
|
|
|
@ -160,6 +160,11 @@ static struct policydb_compat_info policydb_compat[] = {
|
||||||
.sym_num = SYM_NUM,
|
.sym_num = SYM_NUM,
|
||||||
.ocon_num = OCON_NUM,
|
.ocon_num = OCON_NUM,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.version = POLICYDB_VERSION_GLBLUB,
|
||||||
|
.sym_num = SYM_NUM,
|
||||||
|
.ocon_num = OCON_NUM,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct policydb_compat_info *policydb_lookup_compat(int version)
|
static struct policydb_compat_info *policydb_lookup_compat(int version)
|
||||||
|
|
|
@ -69,6 +69,7 @@ struct class_datum {
|
||||||
#define DEFAULT_TARGET_LOW 4
|
#define DEFAULT_TARGET_LOW 4
|
||||||
#define DEFAULT_TARGET_HIGH 5
|
#define DEFAULT_TARGET_HIGH 5
|
||||||
#define DEFAULT_TARGET_LOW_HIGH 6
|
#define DEFAULT_TARGET_LOW_HIGH 6
|
||||||
|
#define DEFAULT_GLBLUB 7
|
||||||
char default_range;
|
char default_range;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue