aboutsummaryrefslogtreecommitdiffstats
path: root/security/selinux/hooks.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r--security/selinux/hooks.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 4bf4807f2d44..d39b59cf8a08 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -180,7 +180,7 @@ static int inode_alloc_security(struct inode *inode)
180 struct task_security_struct *tsec = current->security; 180 struct task_security_struct *tsec = current->security;
181 struct inode_security_struct *isec; 181 struct inode_security_struct *isec;
182 182
183 isec = kmem_cache_zalloc(sel_inode_cache, GFP_KERNEL); 183 isec = kmem_cache_zalloc(sel_inode_cache, GFP_NOFS);
184 if (!isec) 184 if (!isec)
185 return -ENOMEM; 185 return -ENOMEM;
186 186
@@ -760,13 +760,13 @@ static void selinux_sb_clone_mnt_opts(const struct super_block *oldsb,
760 * this early in the boot process. */ 760 * this early in the boot process. */
761 BUG_ON(!ss_initialized); 761 BUG_ON(!ss_initialized);
762 762
763 /* this might go away sometime down the line if there is a new user
764 * of clone, but for now, nfs better not get here... */
765 BUG_ON(newsbsec->initialized);
766
767 /* how can we clone if the old one wasn't set up?? */ 763 /* how can we clone if the old one wasn't set up?? */
768 BUG_ON(!oldsbsec->initialized); 764 BUG_ON(!oldsbsec->initialized);
769 765
766 /* if fs is reusing a sb, just let its options stand... */
767 if (newsbsec->initialized)
768 return;
769
770 mutex_lock(&newsbsec->lock); 770 mutex_lock(&newsbsec->lock);
771 771
772 newsbsec->flags = oldsbsec->flags; 772 newsbsec->flags = oldsbsec->flags;
@@ -800,7 +800,8 @@ static void selinux_sb_clone_mnt_opts(const struct super_block *oldsb,
800 mutex_unlock(&newsbsec->lock); 800 mutex_unlock(&newsbsec->lock);
801} 801}
802 802
803int selinux_parse_opts_str(char *options, struct security_mnt_opts *opts) 803static int selinux_parse_opts_str(char *options,
804 struct security_mnt_opts *opts)
804{ 805{
805 char *p; 806 char *p;
806 char *context = NULL, *defcontext = NULL; 807 char *context = NULL, *defcontext = NULL;
@@ -1142,7 +1143,7 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
1142 } 1143 }
1143 1144
1144 len = INITCONTEXTLEN; 1145 len = INITCONTEXTLEN;
1145 context = kmalloc(len, GFP_KERNEL); 1146 context = kmalloc(len, GFP_NOFS);
1146 if (!context) { 1147 if (!context) {
1147 rc = -ENOMEM; 1148 rc = -ENOMEM;
1148 dput(dentry); 1149 dput(dentry);
@@ -1160,7 +1161,7 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
1160 } 1161 }
1161 kfree(context); 1162 kfree(context);
1162 len = rc; 1163 len = rc;
1163 context = kmalloc(len, GFP_KERNEL); 1164 context = kmalloc(len, GFP_NOFS);
1164 if (!context) { 1165 if (!context) {
1165 rc = -ENOMEM; 1166 rc = -ENOMEM;
1166 dput(dentry); 1167 dput(dentry);
@@ -1184,7 +1185,8 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
1184 rc = 0; 1185 rc = 0;
1185 } else { 1186 } else {
1186 rc = security_context_to_sid_default(context, rc, &sid, 1187 rc = security_context_to_sid_default(context, rc, &sid,
1187 sbsec->def_sid); 1188 sbsec->def_sid,
1189 GFP_NOFS);
1188 if (rc) { 1190 if (rc) {
1189 printk(KERN_WARNING "%s: context_to_sid(%s) " 1191 printk(KERN_WARNING "%s: context_to_sid(%s) "
1190 "returned %d for dev=%s ino=%ld\n", 1192 "returned %d for dev=%s ino=%ld\n",
@@ -1629,6 +1631,12 @@ static inline u32 file_to_av(struct file *file)
1629 else 1631 else
1630 av |= FILE__WRITE; 1632 av |= FILE__WRITE;
1631 } 1633 }
1634 if (!av) {
1635 /*
1636 * Special file opened with flags 3 for ioctl-only use.
1637 */
1638 av = FILE__IOCTL;
1639 }
1632 1640
1633 return av; 1641 return av;
1634} 1642}
@@ -2422,7 +2430,7 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir,
2422 return -EOPNOTSUPP; 2430 return -EOPNOTSUPP;
2423 2431
2424 if (name) { 2432 if (name) {
2425 namep = kstrdup(XATTR_SELINUX_SUFFIX, GFP_KERNEL); 2433 namep = kstrdup(XATTR_SELINUX_SUFFIX, GFP_NOFS);
2426 if (!namep) 2434 if (!namep)
2427 return -ENOMEM; 2435 return -ENOMEM;
2428 *name = namep; 2436 *name = namep;