diff options
Diffstat (limited to 'security/selinux/ss/services.c')
-rw-r--r-- | security/selinux/ss/services.c | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c index 4bca49414a40..2aa9d172dc7e 100644 --- a/security/selinux/ss/services.c +++ b/security/selinux/ss/services.c | |||
@@ -2277,7 +2277,7 @@ out: | |||
2277 | } | 2277 | } |
2278 | 2278 | ||
2279 | /** | 2279 | /** |
2280 | * security_genfs_sid - Obtain a SID for a file in a filesystem | 2280 | * __security_genfs_sid - Helper to obtain a SID for a file in a filesystem |
2281 | * @fstype: filesystem type | 2281 | * @fstype: filesystem type |
2282 | * @path: path from root of mount | 2282 | * @path: path from root of mount |
2283 | * @sclass: file security class | 2283 | * @sclass: file security class |
@@ -2286,11 +2286,13 @@ out: | |||
2286 | * Obtain a SID to use for a file in a filesystem that | 2286 | * Obtain a SID to use for a file in a filesystem that |
2287 | * cannot support xattr or use a fixed labeling behavior like | 2287 | * cannot support xattr or use a fixed labeling behavior like |
2288 | * transition SIDs or task SIDs. | 2288 | * transition SIDs or task SIDs. |
2289 | * | ||
2290 | * The caller must acquire the policy_rwlock before calling this function. | ||
2289 | */ | 2291 | */ |
2290 | int security_genfs_sid(const char *fstype, | 2292 | static inline int __security_genfs_sid(const char *fstype, |
2291 | char *path, | 2293 | char *path, |
2292 | u16 orig_sclass, | 2294 | u16 orig_sclass, |
2293 | u32 *sid) | 2295 | u32 *sid) |
2294 | { | 2296 | { |
2295 | int len; | 2297 | int len; |
2296 | u16 sclass; | 2298 | u16 sclass; |
@@ -2301,8 +2303,6 @@ int security_genfs_sid(const char *fstype, | |||
2301 | while (path[0] == '/' && path[1] == '/') | 2303 | while (path[0] == '/' && path[1] == '/') |
2302 | path++; | 2304 | path++; |
2303 | 2305 | ||
2304 | read_lock(&policy_rwlock); | ||
2305 | |||
2306 | sclass = unmap_class(orig_sclass); | 2306 | sclass = unmap_class(orig_sclass); |
2307 | *sid = SECINITSID_UNLABELED; | 2307 | *sid = SECINITSID_UNLABELED; |
2308 | 2308 | ||
@@ -2336,11 +2336,33 @@ int security_genfs_sid(const char *fstype, | |||
2336 | *sid = c->sid[0]; | 2336 | *sid = c->sid[0]; |
2337 | rc = 0; | 2337 | rc = 0; |
2338 | out: | 2338 | out: |
2339 | read_unlock(&policy_rwlock); | ||
2340 | return rc; | 2339 | return rc; |
2341 | } | 2340 | } |
2342 | 2341 | ||
2343 | /** | 2342 | /** |
2343 | * security_genfs_sid - Obtain a SID for a file in a filesystem | ||
2344 | * @fstype: filesystem type | ||
2345 | * @path: path from root of mount | ||
2346 | * @sclass: file security class | ||
2347 | * @sid: SID for path | ||
2348 | * | ||
2349 | * Acquire policy_rwlock before calling __security_genfs_sid() and release | ||
2350 | * it afterward. | ||
2351 | */ | ||
2352 | int security_genfs_sid(const char *fstype, | ||
2353 | char *path, | ||
2354 | u16 orig_sclass, | ||
2355 | u32 *sid) | ||
2356 | { | ||
2357 | int retval; | ||
2358 | |||
2359 | read_lock(&policy_rwlock); | ||
2360 | retval = __security_genfs_sid(fstype, path, orig_sclass, sid); | ||
2361 | read_unlock(&policy_rwlock); | ||
2362 | return retval; | ||
2363 | } | ||
2364 | |||
2365 | /** | ||
2344 | * security_fs_use - Determine how to handle labeling for a filesystem. | 2366 | * security_fs_use - Determine how to handle labeling for a filesystem. |
2345 | * @sb: superblock in question | 2367 | * @sb: superblock in question |
2346 | */ | 2368 | */ |
@@ -2370,7 +2392,8 @@ int security_fs_use(struct super_block *sb) | |||
2370 | } | 2392 | } |
2371 | sbsec->sid = c->sid[0]; | 2393 | sbsec->sid = c->sid[0]; |
2372 | } else { | 2394 | } else { |
2373 | rc = security_genfs_sid(fstype, "/", SECCLASS_DIR, &sbsec->sid); | 2395 | rc = __security_genfs_sid(fstype, "/", SECCLASS_DIR, |
2396 | &sbsec->sid); | ||
2374 | if (rc) { | 2397 | if (rc) { |
2375 | sbsec->behavior = SECURITY_FS_USE_NONE; | 2398 | sbsec->behavior = SECURITY_FS_USE_NONE; |
2376 | rc = 0; | 2399 | rc = 0; |