aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2012-08-24 15:59:07 -0400
committerEric Paris <eparis@redhat.com>2013-07-25 13:03:21 -0400
commita64c54cf0811b8032fdab8c9d52576f0370837fa (patch)
tree2fb17477db2ba91fb2043ece739a898f369b1b36 /security
parent308ab70c465d97cf7e3168961dfd365535de21a6 (diff)
SELinux: pass a superblock to security_fs_use
Rather than passing pointers to memory locations, strings, and other stuff just give up on the separation and give security_fs_use the superblock. It just makes the code easier to read (even if not easier to reuse on some other OS) Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'security')
-rw-r--r--security/selinux/hooks.c2
-rw-r--r--security/selinux/include/security.h3
-rw-r--r--security/selinux/ss/services.c21
3 files changed, 11 insertions, 15 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 5596dc51e21b..ec15a5694b9e 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -677,7 +677,7 @@ static int selinux_set_mnt_opts(struct super_block *sb,
677 sbsec->flags |= SE_SBPROC; 677 sbsec->flags |= SE_SBPROC;
678 678
679 /* Determine the labeling behavior to use for this filesystem type. */ 679 /* Determine the labeling behavior to use for this filesystem type. */
680 rc = security_fs_use(sb->s_type->name, &sbsec->behavior, &sbsec->sid); 680 rc = security_fs_use(sb);
681 if (rc) { 681 if (rc) {
682 printk(KERN_WARNING "%s: security_fs_use(%s) returned %d\n", 682 printk(KERN_WARNING "%s: security_fs_use(%s) returned %d\n",
683 __func__, sb->s_type->name, rc); 683 __func__, sb->s_type->name, rc);
diff --git a/security/selinux/include/security.h b/security/selinux/include/security.h
index 1a73fcd51d56..01a0382c43ca 100644
--- a/security/selinux/include/security.h
+++ b/security/selinux/include/security.h
@@ -171,8 +171,7 @@ int security_get_allow_unknown(void);
171#define SECURITY_FS_USE_NONE 5 /* no labeling support */ 171#define SECURITY_FS_USE_NONE 5 /* no labeling support */
172#define SECURITY_FS_USE_MNTPOINT 6 /* use mountpoint labeling */ 172#define SECURITY_FS_USE_MNTPOINT 6 /* use mountpoint labeling */
173 173
174int security_fs_use(const char *fstype, short unsigned int *behavior, 174int security_fs_use(struct super_block *sb);
175 u32 *sid);
176 175
177int security_genfs_sid(const char *fstype, char *name, u16 sclass, 176int security_genfs_sid(const char *fstype, char *name, u16 sclass,
178 u32 *sid); 177 u32 *sid);
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index 603c638434bb..a90721771615 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -2323,17 +2323,14 @@ out:
2323 2323
2324/** 2324/**
2325 * security_fs_use - Determine how to handle labeling for a filesystem. 2325 * security_fs_use - Determine how to handle labeling for a filesystem.
2326 * @fstype: filesystem type 2326 * @sb: superblock in question
2327 * @behavior: labeling behavior
2328 * @sid: SID for filesystem (superblock)
2329 */ 2327 */
2330int security_fs_use( 2328int security_fs_use(struct super_block *sb)
2331 const char *fstype,
2332 short unsigned int *behavior,
2333 u32 *sid)
2334{ 2329{
2335 int rc = 0; 2330 int rc = 0;
2336 struct ocontext *c; 2331 struct ocontext *c;
2332 struct superblock_security_struct *sbsec = sb->s_security;
2333 const char *fstype = sb->s_type->name;
2337 2334
2338 read_lock(&policy_rwlock); 2335 read_lock(&policy_rwlock);
2339 2336
@@ -2345,21 +2342,21 @@ int security_fs_use(
2345 } 2342 }
2346 2343
2347 if (c) { 2344 if (c) {
2348 *behavior = c->v.behavior; 2345 sbsec->behavior = c->v.behavior;
2349 if (!c->sid[0]) { 2346 if (!c->sid[0]) {
2350 rc = sidtab_context_to_sid(&sidtab, &c->context[0], 2347 rc = sidtab_context_to_sid(&sidtab, &c->context[0],
2351 &c->sid[0]); 2348 &c->sid[0]);
2352 if (rc) 2349 if (rc)
2353 goto out; 2350 goto out;
2354 } 2351 }
2355 *sid = c->sid[0]; 2352 sbsec->sid = c->sid[0];
2356 } else { 2353 } else {
2357 rc = security_genfs_sid(fstype, "/", SECCLASS_DIR, sid); 2354 rc = security_genfs_sid(fstype, "/", SECCLASS_DIR, &sbsec->sid);
2358 if (rc) { 2355 if (rc) {
2359 *behavior = SECURITY_FS_USE_NONE; 2356 sbsec->behavior = SECURITY_FS_USE_NONE;
2360 rc = 0; 2357 rc = 0;
2361 } else { 2358 } else {
2362 *behavior = SECURITY_FS_USE_GENFS; 2359 sbsec->behavior = SECURITY_FS_USE_GENFS;
2363 } 2360 }
2364 } 2361 }
2365 2362