@@ -1490,17 +1490,6 @@ static int string_to_context_struct(struct policydb *pol,
1490
1490
return rc ;
1491
1491
}
1492
1492
1493
- static int context_struct_to_sid (struct selinux_state * state ,
1494
- struct context * context , u32 * sid )
1495
- {
1496
- struct sidtab * sidtab = state -> ss -> sidtab ;
1497
-
1498
- if (!context -> hash )
1499
- context_add_hash (context );
1500
-
1501
- return sidtab_context_to_sid (sidtab , context , sid );
1502
- }
1503
-
1504
1493
static int security_context_to_sid_core (struct selinux_state * state ,
1505
1494
const char * scontext , u32 scontext_len ,
1506
1495
u32 * sid , u32 def_sid , gfp_t gfp_flags ,
@@ -1555,7 +1544,7 @@ static int security_context_to_sid_core(struct selinux_state *state,
1555
1544
str = NULL ;
1556
1545
} else if (rc )
1557
1546
goto out_unlock ;
1558
- rc = context_struct_to_sid ( state , & context , sid );
1547
+ rc = sidtab_context_to_sid ( sidtab , & context , sid );
1559
1548
context_destroy (& context );
1560
1549
out_unlock :
1561
1550
read_unlock (& state -> ss -> policy_rwlock );
@@ -1865,7 +1854,7 @@ static int security_compute_sid(struct selinux_state *state,
1865
1854
goto out_unlock ;
1866
1855
}
1867
1856
/* Obtain the sid for the context. */
1868
- rc = context_struct_to_sid ( state , & newcontext , out_sid );
1857
+ rc = sidtab_context_to_sid ( sidtab , & newcontext , out_sid );
1869
1858
out_unlock :
1870
1859
read_unlock (& state -> ss -> policy_rwlock );
1871
1860
context_destroy (& newcontext );
@@ -2017,7 +2006,6 @@ static int convert_context(struct context *oldc, struct context *newc, void *p)
2017
2006
context_init (newc );
2018
2007
newc -> str = s ;
2019
2008
newc -> len = oldc -> len ;
2020
- newc -> hash = oldc -> hash ;
2021
2009
return 0 ;
2022
2010
}
2023
2011
kfree (s );
@@ -2094,8 +2082,6 @@ static int convert_context(struct context *oldc, struct context *newc, void *p)
2094
2082
goto bad ;
2095
2083
}
2096
2084
2097
- context_add_hash (newc );
2098
-
2099
2085
return 0 ;
2100
2086
bad :
2101
2087
/* Map old representation to string and save it. */
@@ -2105,7 +2091,6 @@ static int convert_context(struct context *oldc, struct context *newc, void *p)
2105
2091
context_destroy (newc );
2106
2092
newc -> str = s ;
2107
2093
newc -> len = len ;
2108
- context_add_hash (newc );
2109
2094
pr_info ("SELinux: Context %s became invalid (unmapped).\n" ,
2110
2095
newc -> str );
2111
2096
return 0 ;
@@ -2322,12 +2307,14 @@ int security_port_sid(struct selinux_state *state,
2322
2307
u8 protocol , u16 port , u32 * out_sid )
2323
2308
{
2324
2309
struct policydb * policydb ;
2310
+ struct sidtab * sidtab ;
2325
2311
struct ocontext * c ;
2326
2312
int rc = 0 ;
2327
2313
2328
2314
read_lock (& state -> ss -> policy_rwlock );
2329
2315
2330
2316
policydb = & state -> ss -> policydb ;
2317
+ sidtab = state -> ss -> sidtab ;
2331
2318
2332
2319
c = policydb -> ocontexts [OCON_PORT ];
2333
2320
while (c ) {
@@ -2340,7 +2327,7 @@ int security_port_sid(struct selinux_state *state,
2340
2327
2341
2328
if (c ) {
2342
2329
if (!c -> sid [0 ]) {
2343
- rc = context_struct_to_sid ( state , & c -> context [0 ],
2330
+ rc = sidtab_context_to_sid ( sidtab , & c -> context [0 ],
2344
2331
& c -> sid [0 ]);
2345
2332
if (rc )
2346
2333
goto out ;
@@ -2365,12 +2352,14 @@ int security_ib_pkey_sid(struct selinux_state *state,
2365
2352
u64 subnet_prefix , u16 pkey_num , u32 * out_sid )
2366
2353
{
2367
2354
struct policydb * policydb ;
2355
+ struct sidtab * sidtab ;
2368
2356
struct ocontext * c ;
2369
2357
int rc = 0 ;
2370
2358
2371
2359
read_lock (& state -> ss -> policy_rwlock );
2372
2360
2373
2361
policydb = & state -> ss -> policydb ;
2362
+ sidtab = state -> ss -> sidtab ;
2374
2363
2375
2364
c = policydb -> ocontexts [OCON_IBPKEY ];
2376
2365
while (c ) {
@@ -2384,7 +2373,7 @@ int security_ib_pkey_sid(struct selinux_state *state,
2384
2373
2385
2374
if (c ) {
2386
2375
if (!c -> sid [0 ]) {
2387
- rc = context_struct_to_sid ( state ,
2376
+ rc = sidtab_context_to_sid ( sidtab ,
2388
2377
& c -> context [0 ],
2389
2378
& c -> sid [0 ]);
2390
2379
if (rc )
@@ -2409,12 +2398,14 @@ int security_ib_endport_sid(struct selinux_state *state,
2409
2398
const char * dev_name , u8 port_num , u32 * out_sid )
2410
2399
{
2411
2400
struct policydb * policydb ;
2401
+ struct sidtab * sidtab ;
2412
2402
struct ocontext * c ;
2413
2403
int rc = 0 ;
2414
2404
2415
2405
read_lock (& state -> ss -> policy_rwlock );
2416
2406
2417
2407
policydb = & state -> ss -> policydb ;
2408
+ sidtab = state -> ss -> sidtab ;
2418
2409
2419
2410
c = policydb -> ocontexts [OCON_IBENDPORT ];
2420
2411
while (c ) {
@@ -2429,7 +2420,7 @@ int security_ib_endport_sid(struct selinux_state *state,
2429
2420
2430
2421
if (c ) {
2431
2422
if (!c -> sid [0 ]) {
2432
- rc = context_struct_to_sid ( state , & c -> context [0 ],
2423
+ rc = sidtab_context_to_sid ( sidtab , & c -> context [0 ],
2433
2424
& c -> sid [0 ]);
2434
2425
if (rc )
2435
2426
goto out ;
@@ -2452,12 +2443,14 @@ int security_netif_sid(struct selinux_state *state,
2452
2443
char * name , u32 * if_sid )
2453
2444
{
2454
2445
struct policydb * policydb ;
2446
+ struct sidtab * sidtab ;
2455
2447
int rc = 0 ;
2456
2448
struct ocontext * c ;
2457
2449
2458
2450
read_lock (& state -> ss -> policy_rwlock );
2459
2451
2460
2452
policydb = & state -> ss -> policydb ;
2453
+ sidtab = state -> ss -> sidtab ;
2461
2454
2462
2455
c = policydb -> ocontexts [OCON_NETIF ];
2463
2456
while (c ) {
@@ -2468,11 +2461,11 @@ int security_netif_sid(struct selinux_state *state,
2468
2461
2469
2462
if (c ) {
2470
2463
if (!c -> sid [0 ] || !c -> sid [1 ]) {
2471
- rc = context_struct_to_sid ( state , & c -> context [0 ],
2464
+ rc = sidtab_context_to_sid ( sidtab , & c -> context [0 ],
2472
2465
& c -> sid [0 ]);
2473
2466
if (rc )
2474
2467
goto out ;
2475
- rc = context_struct_to_sid ( state , & c -> context [1 ],
2468
+ rc = sidtab_context_to_sid ( sidtab , & c -> context [1 ],
2476
2469
& c -> sid [1 ]);
2477
2470
if (rc )
2478
2471
goto out ;
@@ -2513,12 +2506,14 @@ int security_node_sid(struct selinux_state *state,
2513
2506
u32 * out_sid )
2514
2507
{
2515
2508
struct policydb * policydb ;
2509
+ struct sidtab * sidtab ;
2516
2510
int rc ;
2517
2511
struct ocontext * c ;
2518
2512
2519
2513
read_lock (& state -> ss -> policy_rwlock );
2520
2514
2521
2515
policydb = & state -> ss -> policydb ;
2516
+ sidtab = state -> ss -> sidtab ;
2522
2517
2523
2518
switch (domain ) {
2524
2519
case AF_INET : {
@@ -2560,7 +2555,7 @@ int security_node_sid(struct selinux_state *state,
2560
2555
2561
2556
if (c ) {
2562
2557
if (!c -> sid [0 ]) {
2563
- rc = context_struct_to_sid ( state ,
2558
+ rc = sidtab_context_to_sid ( sidtab ,
2564
2559
& c -> context [0 ],
2565
2560
& c -> sid [0 ]);
2566
2561
if (rc )
@@ -2644,17 +2639,12 @@ int security_get_user_sids(struct selinux_state *state,
2644
2639
usercon .role = i + 1 ;
2645
2640
ebitmap_for_each_positive_bit (& role -> types , tnode , j ) {
2646
2641
usercon .type = j + 1 ;
2647
- /*
2648
- * The same context struct is reused here so the hash
2649
- * must be reset.
2650
- */
2651
- usercon .hash = 0 ;
2652
2642
2653
2643
if (mls_setup_user_range (policydb , fromcon , user ,
2654
2644
& usercon ))
2655
2645
continue ;
2656
2646
2657
- rc = context_struct_to_sid ( state , & usercon , & sid );
2647
+ rc = sidtab_context_to_sid ( sidtab , & usercon , & sid );
2658
2648
if (rc )
2659
2649
goto out_unlock ;
2660
2650
if (mynel < maxnel ) {
@@ -2725,6 +2715,7 @@ static inline int __security_genfs_sid(struct selinux_state *state,
2725
2715
u32 * sid )
2726
2716
{
2727
2717
struct policydb * policydb = & state -> ss -> policydb ;
2718
+ struct sidtab * sidtab = state -> ss -> sidtab ;
2728
2719
int len ;
2729
2720
u16 sclass ;
2730
2721
struct genfs * genfs ;
@@ -2759,7 +2750,7 @@ static inline int __security_genfs_sid(struct selinux_state *state,
2759
2750
goto out ;
2760
2751
2761
2752
if (!c -> sid [0 ]) {
2762
- rc = context_struct_to_sid ( state , & c -> context [0 ], & c -> sid [0 ]);
2753
+ rc = sidtab_context_to_sid ( sidtab , & c -> context [0 ], & c -> sid [0 ]);
2763
2754
if (rc )
2764
2755
goto out ;
2765
2756
}
@@ -2801,6 +2792,7 @@ int security_genfs_sid(struct selinux_state *state,
2801
2792
int security_fs_use (struct selinux_state * state , struct super_block * sb )
2802
2793
{
2803
2794
struct policydb * policydb ;
2795
+ struct sidtab * sidtab ;
2804
2796
int rc = 0 ;
2805
2797
struct ocontext * c ;
2806
2798
struct superblock_security_struct * sbsec = sb -> s_security ;
@@ -2809,6 +2801,7 @@ int security_fs_use(struct selinux_state *state, struct super_block *sb)
2809
2801
read_lock (& state -> ss -> policy_rwlock );
2810
2802
2811
2803
policydb = & state -> ss -> policydb ;
2804
+ sidtab = state -> ss -> sidtab ;
2812
2805
2813
2806
c = policydb -> ocontexts [OCON_FSUSE ];
2814
2807
while (c ) {
@@ -2820,7 +2813,7 @@ int security_fs_use(struct selinux_state *state, struct super_block *sb)
2820
2813
if (c ) {
2821
2814
sbsec -> behavior = c -> v .behavior ;
2822
2815
if (!c -> sid [0 ]) {
2823
- rc = context_struct_to_sid ( state , & c -> context [0 ],
2816
+ rc = sidtab_context_to_sid ( sidtab , & c -> context [0 ],
2824
2817
& c -> sid [0 ]);
2825
2818
if (rc )
2826
2819
goto out ;
@@ -3068,7 +3061,7 @@ int security_sid_mls_copy(struct selinux_state *state,
3068
3061
goto out_unlock ;
3069
3062
}
3070
3063
}
3071
- rc = context_struct_to_sid ( state , & newcon , new_sid );
3064
+ rc = sidtab_context_to_sid ( sidtab , & newcon , new_sid );
3072
3065
out_unlock :
3073
3066
read_unlock (& state -> ss -> policy_rwlock );
3074
3067
context_destroy (& newcon );
@@ -3661,7 +3654,7 @@ int security_netlbl_secattr_to_sid(struct selinux_state *state,
3661
3654
if (!mls_context_isvalid (policydb , & ctx_new ))
3662
3655
goto out_free ;
3663
3656
3664
- rc = context_struct_to_sid ( state , & ctx_new , sid );
3657
+ rc = sidtab_context_to_sid ( sidtab , & ctx_new , sid );
3665
3658
if (rc )
3666
3659
goto out_free ;
3667
3660
0 commit comments