Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selinux: stop passing selinux_state pointers and their offspring

Linus observed that the pervasive passing of selinux_state pointers
introduced by me in commit aa8e712cee93 ("selinux: wrap global selinux
state") adds overhead and complexity without providing any
benefit. The original idea was to pave the way for SELinux namespaces
but those have not yet been implemented and there isn't currently
a concrete plan to do so. Remove the passing of the selinux_state
pointers, reverting to direct use of the single global selinux_state,
and likewise remove passing of child pointers like the selinux_avc.
The selinux_policy pointer remains as it is needed for atomic switching
of policies.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/oe-kbuild-all/202303101057.mZ3Gv5fK-lkp@intel.com/
Signed-off-by: Stephen Smalley <stephen.smalley.work@gmail.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>

authored by

Stephen Smalley and committed by
Paul Moore
e67b7985 f62ca0b6

+651 -995
+86 -111
security/selinux/avc.c
··· 93 93 94 94 static struct selinux_avc selinux_avc; 95 95 96 - void selinux_avc_init(struct selinux_avc **avc) 96 + void selinux_avc_init(void) 97 97 { 98 98 int i; 99 99 ··· 104 104 } 105 105 atomic_set(&selinux_avc.avc_cache.active_nodes, 0); 106 106 atomic_set(&selinux_avc.avc_cache.lru_hint, 0); 107 - *avc = &selinux_avc; 108 107 } 109 108 110 - unsigned int avc_get_cache_threshold(struct selinux_avc *avc) 109 + unsigned int avc_get_cache_threshold(void) 111 110 { 112 - return avc->avc_cache_threshold; 111 + return selinux_avc.avc_cache_threshold; 113 112 } 114 113 115 - void avc_set_cache_threshold(struct selinux_avc *avc, 116 - unsigned int cache_threshold) 114 + void avc_set_cache_threshold(unsigned int cache_threshold) 117 115 { 118 - avc->avc_cache_threshold = cache_threshold; 116 + selinux_avc.avc_cache_threshold = cache_threshold; 119 117 } 120 118 121 119 static struct avc_callback_node *avc_callbacks __ro_after_init; ··· 148 150 0, SLAB_PANIC, NULL); 149 151 } 150 152 151 - int avc_get_hash_stats(struct selinux_avc *avc, char *page) 153 + int avc_get_hash_stats(char *page) 152 154 { 153 155 int i, chain_len, max_chain_len, slots_used; 154 156 struct avc_node *node; ··· 159 161 slots_used = 0; 160 162 max_chain_len = 0; 161 163 for (i = 0; i < AVC_CACHE_SLOTS; i++) { 162 - head = &avc->avc_cache.slots[i]; 164 + head = &selinux_avc.avc_cache.slots[i]; 163 165 if (!hlist_empty(head)) { 164 166 slots_used++; 165 167 chain_len = 0; ··· 174 176 175 177 return scnprintf(page, PAGE_SIZE, "entries: %d\nbuckets used: %d/%d\n" 176 178 "longest chain: %d\n", 177 - atomic_read(&avc->avc_cache.active_nodes), 179 + atomic_read(&selinux_avc.avc_cache.active_nodes), 178 180 slots_used, AVC_CACHE_SLOTS, max_chain_len); 179 181 } 180 182 ··· 412 414 return audited; 413 415 } 414 416 415 - static inline int avc_xperms_audit(struct selinux_state *state, 416 - u32 ssid, u32 tsid, u16 tclass, 417 + static inline int avc_xperms_audit(u32 ssid, u32 tsid, u16 tclass, 417 418 u32 requested, struct av_decision *avd, 418 419 struct extended_perms_decision *xpd, 419 420 u8 perm, int result, ··· 424 427 requested, avd, xpd, perm, result, &denied); 425 428 if (likely(!audited)) 426 429 return 0; 427 - return slow_avc_audit(state, ssid, tsid, tclass, requested, 430 + return slow_avc_audit(ssid, tsid, tclass, requested, 428 431 audited, denied, result, ad); 429 432 } 430 433 ··· 436 439 avc_cache_stats_incr(frees); 437 440 } 438 441 439 - static void avc_node_delete(struct selinux_avc *avc, struct avc_node *node) 442 + static void avc_node_delete(struct avc_node *node) 440 443 { 441 444 hlist_del_rcu(&node->list); 442 445 call_rcu(&node->rhead, avc_node_free); 443 - atomic_dec(&avc->avc_cache.active_nodes); 446 + atomic_dec(&selinux_avc.avc_cache.active_nodes); 444 447 } 445 448 446 - static void avc_node_kill(struct selinux_avc *avc, struct avc_node *node) 449 + static void avc_node_kill(struct avc_node *node) 447 450 { 448 451 avc_xperms_free(node->ae.xp_node); 449 452 kmem_cache_free(avc_node_cachep, node); 450 453 avc_cache_stats_incr(frees); 451 - atomic_dec(&avc->avc_cache.active_nodes); 454 + atomic_dec(&selinux_avc.avc_cache.active_nodes); 452 455 } 453 456 454 - static void avc_node_replace(struct selinux_avc *avc, 455 - struct avc_node *new, struct avc_node *old) 457 + static void avc_node_replace(struct avc_node *new, struct avc_node *old) 456 458 { 457 459 hlist_replace_rcu(&old->list, &new->list); 458 460 call_rcu(&old->rhead, avc_node_free); 459 - atomic_dec(&avc->avc_cache.active_nodes); 461 + atomic_dec(&selinux_avc.avc_cache.active_nodes); 460 462 } 461 463 462 - static inline int avc_reclaim_node(struct selinux_avc *avc) 464 + static inline int avc_reclaim_node(void) 463 465 { 464 466 struct avc_node *node; 465 467 int hvalue, try, ecx; ··· 467 471 spinlock_t *lock; 468 472 469 473 for (try = 0, ecx = 0; try < AVC_CACHE_SLOTS; try++) { 470 - hvalue = atomic_inc_return(&avc->avc_cache.lru_hint) & 474 + hvalue = atomic_inc_return(&selinux_avc.avc_cache.lru_hint) & 471 475 (AVC_CACHE_SLOTS - 1); 472 - head = &avc->avc_cache.slots[hvalue]; 473 - lock = &avc->avc_cache.slots_lock[hvalue]; 476 + head = &selinux_avc.avc_cache.slots[hvalue]; 477 + lock = &selinux_avc.avc_cache.slots_lock[hvalue]; 474 478 475 479 if (!spin_trylock_irqsave(lock, flags)) 476 480 continue; 477 481 478 482 rcu_read_lock(); 479 483 hlist_for_each_entry(node, head, list) { 480 - avc_node_delete(avc, node); 484 + avc_node_delete(node); 481 485 avc_cache_stats_incr(reclaims); 482 486 ecx++; 483 487 if (ecx >= AVC_CACHE_RECLAIM) { ··· 493 497 return ecx; 494 498 } 495 499 496 - static struct avc_node *avc_alloc_node(struct selinux_avc *avc) 500 + static struct avc_node *avc_alloc_node(void) 497 501 { 498 502 struct avc_node *node; 499 503 ··· 504 508 INIT_HLIST_NODE(&node->list); 505 509 avc_cache_stats_incr(allocations); 506 510 507 - if (atomic_inc_return(&avc->avc_cache.active_nodes) > 508 - avc->avc_cache_threshold) 509 - avc_reclaim_node(avc); 511 + if (atomic_inc_return(&selinux_avc.avc_cache.active_nodes) > 512 + selinux_avc.avc_cache_threshold) 513 + avc_reclaim_node(); 510 514 511 515 out: 512 516 return node; ··· 520 524 memcpy(&node->ae.avd, avd, sizeof(node->ae.avd)); 521 525 } 522 526 523 - static inline struct avc_node *avc_search_node(struct selinux_avc *avc, 524 - u32 ssid, u32 tsid, u16 tclass) 527 + static inline struct avc_node *avc_search_node(u32 ssid, u32 tsid, u16 tclass) 525 528 { 526 529 struct avc_node *node, *ret = NULL; 527 530 int hvalue; 528 531 struct hlist_head *head; 529 532 530 533 hvalue = avc_hash(ssid, tsid, tclass); 531 - head = &avc->avc_cache.slots[hvalue]; 534 + head = &selinux_avc.avc_cache.slots[hvalue]; 532 535 hlist_for_each_entry_rcu(node, head, list) { 533 536 if (ssid == node->ae.ssid && 534 537 tclass == node->ae.tclass && ··· 542 547 543 548 /** 544 549 * avc_lookup - Look up an AVC entry. 545 - * @avc: the access vector cache 546 550 * @ssid: source security identifier 547 551 * @tsid: target security identifier 548 552 * @tclass: target security class ··· 552 558 * then this function returns the avc_node. 553 559 * Otherwise, this function returns NULL. 554 560 */ 555 - static struct avc_node *avc_lookup(struct selinux_avc *avc, 556 - u32 ssid, u32 tsid, u16 tclass) 561 + static struct avc_node *avc_lookup(u32 ssid, u32 tsid, u16 tclass) 557 562 { 558 563 struct avc_node *node; 559 564 560 565 avc_cache_stats_incr(lookups); 561 - node = avc_search_node(avc, ssid, tsid, tclass); 566 + node = avc_search_node(ssid, tsid, tclass); 562 567 563 568 if (node) 564 569 return node; ··· 566 573 return NULL; 567 574 } 568 575 569 - static int avc_latest_notif_update(struct selinux_avc *avc, 570 - int seqno, int is_insert) 576 + static int avc_latest_notif_update(int seqno, int is_insert) 571 577 { 572 578 int ret = 0; 573 579 static DEFINE_SPINLOCK(notif_lock); ··· 574 582 575 583 spin_lock_irqsave(&notif_lock, flag); 576 584 if (is_insert) { 577 - if (seqno < avc->avc_cache.latest_notif) { 585 + if (seqno < selinux_avc.avc_cache.latest_notif) { 578 586 pr_warn("SELinux: avc: seqno %d < latest_notif %d\n", 579 - seqno, avc->avc_cache.latest_notif); 587 + seqno, selinux_avc.avc_cache.latest_notif); 580 588 ret = -EAGAIN; 581 589 } 582 590 } else { 583 - if (seqno > avc->avc_cache.latest_notif) 584 - avc->avc_cache.latest_notif = seqno; 591 + if (seqno > selinux_avc.avc_cache.latest_notif) 592 + selinux_avc.avc_cache.latest_notif = seqno; 585 593 } 586 594 spin_unlock_irqrestore(&notif_lock, flag); 587 595 ··· 590 598 591 599 /** 592 600 * avc_insert - Insert an AVC entry. 593 - * @avc: the access vector cache 594 601 * @ssid: source security identifier 595 602 * @tsid: target security identifier 596 603 * @tclass: target security class ··· 606 615 * the access vectors into a cache entry, returns 607 616 * avc_node inserted. Otherwise, this function returns NULL. 608 617 */ 609 - static struct avc_node *avc_insert(struct selinux_avc *avc, 610 - u32 ssid, u32 tsid, u16 tclass, 618 + static struct avc_node *avc_insert(u32 ssid, u32 tsid, u16 tclass, 611 619 struct av_decision *avd, 612 620 struct avc_xperms_node *xp_node) 613 621 { ··· 616 626 spinlock_t *lock; 617 627 struct hlist_head *head; 618 628 619 - if (avc_latest_notif_update(avc, avd->seqno, 1)) 629 + if (avc_latest_notif_update(avd->seqno, 1)) 620 630 return NULL; 621 631 622 - node = avc_alloc_node(avc); 632 + node = avc_alloc_node(); 623 633 if (!node) 624 634 return NULL; 625 635 626 636 avc_node_populate(node, ssid, tsid, tclass, avd); 627 637 if (avc_xperms_populate(node, xp_node)) { 628 - avc_node_kill(avc, node); 638 + avc_node_kill(node); 629 639 return NULL; 630 640 } 631 641 632 642 hvalue = avc_hash(ssid, tsid, tclass); 633 - head = &avc->avc_cache.slots[hvalue]; 634 - lock = &avc->avc_cache.slots_lock[hvalue]; 643 + head = &selinux_avc.avc_cache.slots[hvalue]; 644 + lock = &selinux_avc.avc_cache.slots_lock[hvalue]; 635 645 spin_lock_irqsave(lock, flag); 636 646 hlist_for_each_entry(pos, head, list) { 637 647 if (pos->ae.ssid == ssid && 638 648 pos->ae.tsid == tsid && 639 649 pos->ae.tclass == tclass) { 640 - avc_node_replace(avc, node, pos); 650 + avc_node_replace(node, pos); 641 651 goto found; 642 652 } 643 653 } ··· 705 715 u32 tcontext_len; 706 716 int rc; 707 717 708 - rc = security_sid_to_context(sad->state, sad->ssid, &scontext, 718 + rc = security_sid_to_context(sad->ssid, &scontext, 709 719 &scontext_len); 710 720 if (rc) 711 721 audit_log_format(ab, " ssid=%d", sad->ssid); 712 722 else 713 723 audit_log_format(ab, " scontext=%s", scontext); 714 724 715 - rc = security_sid_to_context(sad->state, sad->tsid, &tcontext, 725 + rc = security_sid_to_context(sad->tsid, &tcontext, 716 726 &tcontext_len); 717 727 if (rc) 718 728 audit_log_format(ab, " tsid=%d", sad->tsid); ··· 730 740 kfree(scontext); 731 741 732 742 /* in case of invalid context report also the actual context string */ 733 - rc = security_sid_to_context_inval(sad->state, sad->ssid, &scontext, 743 + rc = security_sid_to_context_inval(sad->ssid, &scontext, 734 744 &scontext_len); 735 745 if (!rc && scontext) { 736 746 if (scontext_len && scontext[scontext_len - 1] == '\0') ··· 740 750 kfree(scontext); 741 751 } 742 752 743 - rc = security_sid_to_context_inval(sad->state, sad->tsid, &scontext, 753 + rc = security_sid_to_context_inval(sad->tsid, &scontext, 744 754 &scontext_len); 745 755 if (!rc && scontext) { 746 756 if (scontext_len && scontext[scontext_len - 1] == '\0') ··· 756 766 * Note that it is non-blocking and can be called from under 757 767 * rcu_read_lock(). 758 768 */ 759 - noinline int slow_avc_audit(struct selinux_state *state, 760 - u32 ssid, u32 tsid, u16 tclass, 769 + noinline int slow_avc_audit(u32 ssid, u32 tsid, u16 tclass, 761 770 u32 requested, u32 audited, u32 denied, int result, 762 771 struct common_audit_data *a) 763 772 { ··· 778 789 sad.audited = audited; 779 790 sad.denied = denied; 780 791 sad.result = result; 781 - sad.state = state; 782 792 783 793 a->selinux_audit_data = &sad; 784 794 ··· 815 827 816 828 /** 817 829 * avc_update_node - Update an AVC entry 818 - * @avc: the access vector cache 819 830 * @event : Updating event 820 831 * @perms : Permission mask bits 821 832 * @driver: xperm driver information ··· 831 844 * otherwise, this function updates the AVC entry. The original AVC-entry object 832 845 * will release later by RCU. 833 846 */ 834 - static int avc_update_node(struct selinux_avc *avc, 835 - u32 event, u32 perms, u8 driver, u8 xperm, u32 ssid, 847 + static int avc_update_node(u32 event, u32 perms, u8 driver, u8 xperm, u32 ssid, 836 848 u32 tsid, u16 tclass, u32 seqno, 837 849 struct extended_perms_decision *xpd, 838 850 u32 flags) ··· 842 856 struct hlist_head *head; 843 857 spinlock_t *lock; 844 858 845 - node = avc_alloc_node(avc); 859 + node = avc_alloc_node(); 846 860 if (!node) { 847 861 rc = -ENOMEM; 848 862 goto out; ··· 851 865 /* Lock the target slot */ 852 866 hvalue = avc_hash(ssid, tsid, tclass); 853 867 854 - head = &avc->avc_cache.slots[hvalue]; 855 - lock = &avc->avc_cache.slots_lock[hvalue]; 868 + head = &selinux_avc.avc_cache.slots[hvalue]; 869 + lock = &selinux_avc.avc_cache.slots_lock[hvalue]; 856 870 857 871 spin_lock_irqsave(lock, flag); 858 872 ··· 868 882 869 883 if (!orig) { 870 884 rc = -ENOENT; 871 - avc_node_kill(avc, node); 885 + avc_node_kill(node); 872 886 goto out_unlock; 873 887 } 874 888 ··· 881 895 if (orig->ae.xp_node) { 882 896 rc = avc_xperms_populate(node, orig->ae.xp_node); 883 897 if (rc) { 884 - avc_node_kill(avc, node); 898 + avc_node_kill(node); 885 899 goto out_unlock; 886 900 } 887 901 } ··· 912 926 avc_add_xperms_decision(node, xpd); 913 927 break; 914 928 } 915 - avc_node_replace(avc, node, orig); 929 + avc_node_replace(node, orig); 916 930 out_unlock: 917 931 spin_unlock_irqrestore(lock, flag); 918 932 out: ··· 921 935 922 936 /** 923 937 * avc_flush - Flush the cache 924 - * @avc: the access vector cache 925 938 */ 926 - static void avc_flush(struct selinux_avc *avc) 939 + static void avc_flush(void) 927 940 { 928 941 struct hlist_head *head; 929 942 struct avc_node *node; ··· 931 946 int i; 932 947 933 948 for (i = 0; i < AVC_CACHE_SLOTS; i++) { 934 - head = &avc->avc_cache.slots[i]; 935 - lock = &avc->avc_cache.slots_lock[i]; 949 + head = &selinux_avc.avc_cache.slots[i]; 950 + lock = &selinux_avc.avc_cache.slots_lock[i]; 936 951 937 952 spin_lock_irqsave(lock, flag); 938 953 /* ··· 941 956 */ 942 957 rcu_read_lock(); 943 958 hlist_for_each_entry(node, head, list) 944 - avc_node_delete(avc, node); 959 + avc_node_delete(node); 945 960 rcu_read_unlock(); 946 961 spin_unlock_irqrestore(lock, flag); 947 962 } ··· 949 964 950 965 /** 951 966 * avc_ss_reset - Flush the cache and revalidate migrated permissions. 952 - * @avc: the access vector cache 953 967 * @seqno: policy sequence number 954 968 */ 955 - int avc_ss_reset(struct selinux_avc *avc, u32 seqno) 969 + int avc_ss_reset(u32 seqno) 956 970 { 957 971 struct avc_callback_node *c; 958 972 int rc = 0, tmprc; 959 973 960 - avc_flush(avc); 974 + avc_flush(); 961 975 962 976 for (c = avc_callbacks; c; c = c->next) { 963 977 if (c->events & AVC_CALLBACK_RESET) { ··· 968 984 } 969 985 } 970 986 971 - avc_latest_notif_update(avc, seqno, 0); 987 + avc_latest_notif_update(seqno, 0); 972 988 return rc; 973 989 } 974 990 975 991 /** 976 992 * avc_compute_av - Add an entry to the AVC based on the security policy 977 - * @state: SELinux state pointer 978 993 * @ssid: subject 979 994 * @tsid: object/target 980 995 * @tclass: object class ··· 984 1001 * fails. Don't inline this, since it's the slow-path and just results in a 985 1002 * bigger stack frame. 986 1003 */ 987 - static noinline struct avc_node *avc_compute_av(struct selinux_state *state, 988 - u32 ssid, u32 tsid, u16 tclass, 1004 + static noinline struct avc_node *avc_compute_av(u32 ssid, u32 tsid, u16 tclass, 989 1005 struct av_decision *avd, 990 1006 struct avc_xperms_node *xp_node) 991 1007 { 992 1008 INIT_LIST_HEAD(&xp_node->xpd_head); 993 - security_compute_av(state, ssid, tsid, tclass, avd, &xp_node->xp); 994 - return avc_insert(state->avc, ssid, tsid, tclass, avd, xp_node); 1009 + security_compute_av(ssid, tsid, tclass, avd, &xp_node->xp); 1010 + return avc_insert(ssid, tsid, tclass, avd, xp_node); 995 1011 } 996 1012 997 - static noinline int avc_denied(struct selinux_state *state, 998 - u32 ssid, u32 tsid, 1013 + static noinline int avc_denied(u32 ssid, u32 tsid, 999 1014 u16 tclass, u32 requested, 1000 1015 u8 driver, u8 xperm, unsigned int flags, 1001 1016 struct av_decision *avd) ··· 1001 1020 if (flags & AVC_STRICT) 1002 1021 return -EACCES; 1003 1022 1004 - if (enforcing_enabled(state) && 1023 + if (enforcing_enabled() && 1005 1024 !(avd->flags & AVD_FLAGS_PERMISSIVE)) 1006 1025 return -EACCES; 1007 1026 1008 - avc_update_node(state->avc, AVC_CALLBACK_GRANT, requested, driver, 1027 + avc_update_node(AVC_CALLBACK_GRANT, requested, driver, 1009 1028 xperm, ssid, tsid, tclass, avd->seqno, NULL, flags); 1010 1029 return 0; 1011 1030 } ··· 1017 1036 * as-is the case with ioctls, then multiple may be chained together and the 1018 1037 * driver field is used to specify which set contains the permission. 1019 1038 */ 1020 - int avc_has_extended_perms(struct selinux_state *state, 1021 - u32 ssid, u32 tsid, u16 tclass, u32 requested, 1039 + int avc_has_extended_perms(u32 ssid, u32 tsid, u16 tclass, u32 requested, 1022 1040 u8 driver, u8 xperm, struct common_audit_data *ad) 1023 1041 { 1024 1042 struct avc_node *node; ··· 1038 1058 1039 1059 rcu_read_lock(); 1040 1060 1041 - node = avc_lookup(state->avc, ssid, tsid, tclass); 1061 + node = avc_lookup(ssid, tsid, tclass); 1042 1062 if (unlikely(!node)) { 1043 - avc_compute_av(state, ssid, tsid, tclass, &avd, xp_node); 1063 + avc_compute_av(ssid, tsid, tclass, &avd, xp_node); 1044 1064 } else { 1045 1065 memcpy(&avd, &node->ae.avd, sizeof(avd)); 1046 1066 xp_node = node->ae.xp_node; ··· 1064 1084 goto decision; 1065 1085 } 1066 1086 rcu_read_unlock(); 1067 - security_compute_xperms_decision(state, ssid, tsid, tclass, 1087 + security_compute_xperms_decision(ssid, tsid, tclass, 1068 1088 driver, &local_xpd); 1069 1089 rcu_read_lock(); 1070 - avc_update_node(state->avc, AVC_CALLBACK_ADD_XPERMS, requested, 1090 + avc_update_node(AVC_CALLBACK_ADD_XPERMS, requested, 1071 1091 driver, xperm, ssid, tsid, tclass, avd.seqno, 1072 1092 &local_xpd, 0); 1073 1093 } else { ··· 1081 1101 decision: 1082 1102 denied = requested & ~(avd.allowed); 1083 1103 if (unlikely(denied)) 1084 - rc = avc_denied(state, ssid, tsid, tclass, requested, 1104 + rc = avc_denied(ssid, tsid, tclass, requested, 1085 1105 driver, xperm, AVC_EXTENDED_PERMS, &avd); 1086 1106 1087 1107 rcu_read_unlock(); 1088 1108 1089 - rc2 = avc_xperms_audit(state, ssid, tsid, tclass, requested, 1109 + rc2 = avc_xperms_audit(ssid, tsid, tclass, requested, 1090 1110 &avd, xpd, xperm, rc, ad); 1091 1111 if (rc2) 1092 1112 return rc2; ··· 1095 1115 1096 1116 /** 1097 1117 * avc_perm_nonode - Add an entry to the AVC 1098 - * @state: SELinux state pointer 1099 1118 * @ssid: subject 1100 1119 * @tsid: object/target 1101 1120 * @tclass: object class ··· 1106 1127 * unlikely and needs extra stack space for the new node that we generate, so 1107 1128 * don't inline it. 1108 1129 */ 1109 - static noinline int avc_perm_nonode(struct selinux_state *state, 1110 - u32 ssid, u32 tsid, u16 tclass, 1130 + static noinline int avc_perm_nonode(u32 ssid, u32 tsid, u16 tclass, 1111 1131 u32 requested, unsigned int flags, 1112 1132 struct av_decision *avd) 1113 1133 { 1114 1134 u32 denied; 1115 1135 struct avc_xperms_node xp_node; 1116 1136 1117 - avc_compute_av(state, ssid, tsid, tclass, avd, &xp_node); 1137 + avc_compute_av(ssid, tsid, tclass, avd, &xp_node); 1118 1138 denied = requested & ~(avd->allowed); 1119 1139 if (unlikely(denied)) 1120 - return avc_denied(state, ssid, tsid, tclass, requested, 0, 0, 1140 + return avc_denied(ssid, tsid, tclass, requested, 0, 0, 1121 1141 flags, avd); 1122 1142 return 0; 1123 1143 } 1124 1144 1125 1145 /** 1126 1146 * avc_has_perm_noaudit - Check permissions but perform no auditing. 1127 - * @state: SELinux state 1128 1147 * @ssid: source security identifier 1129 1148 * @tsid: target security identifier 1130 1149 * @tclass: target security class ··· 1141 1164 * auditing, e.g. in cases where a lock must be held for the check but 1142 1165 * should be released for the auditing. 1143 1166 */ 1144 - inline int avc_has_perm_noaudit(struct selinux_state *state, 1145 - u32 ssid, u32 tsid, 1167 + inline int avc_has_perm_noaudit(u32 ssid, u32 tsid, 1146 1168 u16 tclass, u32 requested, 1147 1169 unsigned int flags, 1148 1170 struct av_decision *avd) ··· 1153 1177 return -EACCES; 1154 1178 1155 1179 rcu_read_lock(); 1156 - node = avc_lookup(state->avc, ssid, tsid, tclass); 1180 + node = avc_lookup(ssid, tsid, tclass); 1157 1181 if (unlikely(!node)) { 1158 1182 rcu_read_unlock(); 1159 - return avc_perm_nonode(state, ssid, tsid, tclass, requested, 1183 + return avc_perm_nonode(ssid, tsid, tclass, requested, 1160 1184 flags, avd); 1161 1185 } 1162 1186 denied = requested & ~node->ae.avd.allowed; ··· 1164 1188 rcu_read_unlock(); 1165 1189 1166 1190 if (unlikely(denied)) 1167 - return avc_denied(state, ssid, tsid, tclass, requested, 0, 0, 1191 + return avc_denied(ssid, tsid, tclass, requested, 0, 0, 1168 1192 flags, avd); 1169 1193 return 0; 1170 1194 } 1171 1195 1172 1196 /** 1173 1197 * avc_has_perm - Check permissions and perform any appropriate auditing. 1174 - * @state: SELinux state 1175 1198 * @ssid: source security identifier 1176 1199 * @tsid: target security identifier 1177 1200 * @tclass: target security class ··· 1185 1210 * permissions are granted, -%EACCES if any permissions are denied, or 1186 1211 * another -errno upon other errors. 1187 1212 */ 1188 - int avc_has_perm(struct selinux_state *state, u32 ssid, u32 tsid, u16 tclass, 1213 + int avc_has_perm(u32 ssid, u32 tsid, u16 tclass, 1189 1214 u32 requested, struct common_audit_data *auditdata) 1190 1215 { 1191 1216 struct av_decision avd; 1192 1217 int rc, rc2; 1193 1218 1194 - rc = avc_has_perm_noaudit(state, ssid, tsid, tclass, requested, 0, 1219 + rc = avc_has_perm_noaudit(ssid, tsid, tclass, requested, 0, 1195 1220 &avd); 1196 1221 1197 - rc2 = avc_audit(state, ssid, tsid, tclass, requested, &avd, rc, 1222 + rc2 = avc_audit(ssid, tsid, tclass, requested, &avd, rc, 1198 1223 auditdata); 1199 1224 if (rc2) 1200 1225 return rc2; 1201 1226 return rc; 1202 1227 } 1203 1228 1204 - u32 avc_policy_seqno(struct selinux_state *state) 1229 + u32 avc_policy_seqno(void) 1205 1230 { 1206 - return state->avc->avc_cache.latest_notif; 1231 + return selinux_avc.avc_cache.latest_notif; 1207 1232 } 1208 1233 1209 1234 void avc_disable(void) ··· 1220 1245 * the cache and get that memory back. 1221 1246 */ 1222 1247 if (avc_node_cachep) { 1223 - avc_flush(selinux_state.avc); 1248 + avc_flush(); 1224 1249 /* kmem_cache_destroy(avc_node_cachep); */ 1225 1250 } 1226 1251 }
+208 -341
security/selinux/hooks.c
··· 257 257 258 258 might_sleep_if(may_sleep); 259 259 260 - if (selinux_initialized(&selinux_state) && 260 + if (selinux_initialized() && 261 261 isec->initialized != LABEL_INITIALIZED) { 262 262 if (!may_sleep) 263 263 return -ECHILD; ··· 403 403 const struct task_security_struct *tsec = selinux_cred(cred); 404 404 int rc; 405 405 406 - rc = avc_has_perm(&selinux_state, 407 - tsec->sid, sbsec->sid, SECCLASS_FILESYSTEM, 406 + rc = avc_has_perm(tsec->sid, sbsec->sid, SECCLASS_FILESYSTEM, 408 407 FILESYSTEM__RELABELFROM, NULL); 409 408 if (rc) 410 409 return rc; 411 410 412 - rc = avc_has_perm(&selinux_state, 413 - tsec->sid, sid, SECCLASS_FILESYSTEM, 411 + rc = avc_has_perm(tsec->sid, sid, SECCLASS_FILESYSTEM, 414 412 FILESYSTEM__RELABELTO, NULL); 415 413 return rc; 416 414 } ··· 419 421 { 420 422 const struct task_security_struct *tsec = selinux_cred(cred); 421 423 int rc; 422 - rc = avc_has_perm(&selinux_state, 423 - tsec->sid, sbsec->sid, SECCLASS_FILESYSTEM, 424 + rc = avc_has_perm(tsec->sid, sbsec->sid, SECCLASS_FILESYSTEM, 424 425 FILESYSTEM__RELABELFROM, NULL); 425 426 if (rc) 426 427 return rc; 427 428 428 - rc = avc_has_perm(&selinux_state, 429 - sid, sbsec->sid, SECCLASS_FILESYSTEM, 429 + rc = avc_has_perm(sid, sbsec->sid, SECCLASS_FILESYSTEM, 430 430 FILESYSTEM__ASSOCIATE, NULL); 431 431 return rc; 432 432 } ··· 507 511 508 512 fallback: 509 513 /* No xattr support - try to fallback to genfs if possible. */ 510 - rc = security_genfs_sid(&selinux_state, sb->s_type->name, "/", 514 + rc = security_genfs_sid(sb->s_type->name, "/", 511 515 SECCLASS_DIR, &sid); 512 516 if (rc) 513 517 return -EOPNOTSUPP; ··· 611 615 612 616 mutex_lock(&sbsec->lock); 613 617 614 - if (!selinux_initialized(&selinux_state)) { 618 + if (!selinux_initialized()) { 615 619 if (!opts) { 616 620 /* Defer initialization until selinux_complete_init, 617 621 after the initial policy is loaded and the security ··· 712 716 * Determine the labeling behavior to use for this 713 717 * filesystem type. 714 718 */ 715 - rc = security_fs_use(&selinux_state, sb); 719 + rc = security_fs_use(sb); 716 720 if (rc) { 717 721 pr_warn("%s: security_fs_use(%s) returned %d\n", 718 722 __func__, sb->s_type->name, rc); ··· 737 741 } 738 742 if (sbsec->behavior == SECURITY_FS_USE_XATTR) { 739 743 sbsec->behavior = SECURITY_FS_USE_MNTPOINT; 740 - rc = security_transition_sid(&selinux_state, 741 - current_sid(), 744 + rc = security_transition_sid(current_sid(), 742 745 current_sid(), 743 746 SECCLASS_FILE, NULL, 744 747 &sbsec->mntpoint_sid); ··· 876 881 * if the parent was able to be mounted it clearly had no special lsm 877 882 * mount options. thus we can safely deal with this superblock later 878 883 */ 879 - if (!selinux_initialized(&selinux_state)) 884 + if (!selinux_initialized()) 880 885 return 0; 881 886 882 887 /* ··· 906 911 907 912 if (newsbsec->behavior == SECURITY_FS_USE_NATIVE && 908 913 !(kern_flags & SECURITY_LSM_NATIVE_LABELS) && !set_context) { 909 - rc = security_fs_use(&selinux_state, newsb); 914 + rc = security_fs_use(newsb); 910 915 if (rc) 911 916 goto out; 912 917 } ··· 955 960 if (!s) 956 961 return -EINVAL; 957 962 958 - if (!selinux_initialized(&selinux_state)) { 963 + if (!selinux_initialized()) { 959 964 pr_warn("SELinux: Unable to set superblock options before the security server is initialized\n"); 960 965 return -EINVAL; 961 966 } ··· 992 997 WARN_ON(1); 993 998 return -EINVAL; 994 999 } 995 - rc = security_context_str_to_sid(&selinux_state, s, dst_sid, GFP_KERNEL); 1000 + rc = security_context_str_to_sid(s, dst_sid, GFP_KERNEL); 996 1001 if (rc) 997 1002 pr_warn("SELinux: security_context_str_to_sid (%s) failed with errno=%d\n", 998 1003 s, rc); ··· 1009 1014 u32 len; 1010 1015 int rc; 1011 1016 1012 - rc = security_sid_to_context(&selinux_state, sid, 1013 - &context, &len); 1017 + rc = security_sid_to_context(sid, &context, &len); 1014 1018 if (!rc) { 1015 1019 bool has_comma = strchr(context, ','); 1016 1020 ··· 1032 1038 if (!(sbsec->flags & SE_SBINITIALIZED)) 1033 1039 return 0; 1034 1040 1035 - if (!selinux_initialized(&selinux_state)) 1041 + if (!selinux_initialized()) 1036 1042 return 0; 1037 1043 1038 1044 if (sbsec->flags & FSCONTEXT_MNT) { ··· 1286 1292 path++; 1287 1293 } 1288 1294 } 1289 - rc = security_genfs_sid(&selinux_state, sb->s_type->name, 1295 + rc = security_genfs_sid(sb->s_type->name, 1290 1296 path, tclass, sid); 1291 1297 if (rc == -ENOENT) { 1292 1298 /* No match in policy, mark as unlabeled. */ ··· 1341 1347 return 0; 1342 1348 } 1343 1349 1344 - rc = security_context_to_sid_default(&selinux_state, context, rc, sid, 1350 + rc = security_context_to_sid_default(context, rc, sid, 1345 1351 def_sid, GFP_NOFS); 1346 1352 if (rc) { 1347 1353 char *dev = inode->i_sb->s_id; ··· 1448 1454 sid = sbsec->sid; 1449 1455 1450 1456 /* Try to obtain a transition SID. */ 1451 - rc = security_transition_sid(&selinux_state, task_sid, sid, 1457 + rc = security_transition_sid(task_sid, sid, 1452 1458 sclass, NULL, &sid); 1453 1459 if (rc) 1454 1460 goto out; ··· 1593 1599 return -EINVAL; 1594 1600 } 1595 1601 1596 - rc = avc_has_perm_noaudit(&selinux_state, 1597 - sid, sid, sclass, av, 0, &avd); 1602 + rc = avc_has_perm_noaudit(sid, sid, sclass, av, 0, &avd); 1598 1603 if (!(opts & CAP_OPT_NOAUDIT)) { 1599 - int rc2 = avc_audit(&selinux_state, 1600 - sid, sid, sclass, av, &avd, rc, &ad); 1604 + int rc2 = avc_audit(sid, sid, sclass, av, &avd, rc, &ad); 1601 1605 if (rc2) 1602 1606 return rc2; 1603 1607 } ··· 1621 1629 sid = cred_sid(cred); 1622 1630 isec = selinux_inode(inode); 1623 1631 1624 - return avc_has_perm(&selinux_state, 1625 - sid, isec->sid, isec->sclass, perms, adp); 1632 + return avc_has_perm(sid, isec->sid, isec->sclass, perms, adp); 1626 1633 } 1627 1634 1628 1635 /* Same as inode_has_perm, but pass explicit audit data containing ··· 1694 1703 ad.u.file = file; 1695 1704 1696 1705 if (sid != fsec->sid) { 1697 - rc = avc_has_perm(&selinux_state, 1698 - sid, fsec->sid, 1706 + rc = avc_has_perm(sid, fsec->sid, 1699 1707 SECCLASS_FD, 1700 1708 FD__USE, 1701 1709 &ad); ··· 1737 1747 *_new_isid = tsec->create_sid; 1738 1748 } else { 1739 1749 const struct inode_security_struct *dsec = inode_security(dir); 1740 - return security_transition_sid(&selinux_state, tsec->sid, 1750 + return security_transition_sid(tsec->sid, 1741 1751 dsec->sid, tclass, 1742 1752 name, _new_isid); 1743 1753 } ··· 1765 1775 ad.type = LSM_AUDIT_DATA_DENTRY; 1766 1776 ad.u.dentry = dentry; 1767 1777 1768 - rc = avc_has_perm(&selinux_state, 1769 - sid, dsec->sid, SECCLASS_DIR, 1778 + rc = avc_has_perm(sid, dsec->sid, SECCLASS_DIR, 1770 1779 DIR__ADD_NAME | DIR__SEARCH, 1771 1780 &ad); 1772 1781 if (rc) ··· 1776 1787 if (rc) 1777 1788 return rc; 1778 1789 1779 - rc = avc_has_perm(&selinux_state, 1780 - sid, newsid, tclass, FILE__CREATE, &ad); 1790 + rc = avc_has_perm(sid, newsid, tclass, FILE__CREATE, &ad); 1781 1791 if (rc) 1782 1792 return rc; 1783 1793 1784 - return avc_has_perm(&selinux_state, 1785 - newsid, sbsec->sid, 1794 + return avc_has_perm(newsid, sbsec->sid, 1786 1795 SECCLASS_FILESYSTEM, 1787 1796 FILESYSTEM__ASSOCIATE, &ad); 1788 1797 } ··· 1809 1822 1810 1823 av = DIR__SEARCH; 1811 1824 av |= (kind ? DIR__REMOVE_NAME : DIR__ADD_NAME); 1812 - rc = avc_has_perm(&selinux_state, 1813 - sid, dsec->sid, SECCLASS_DIR, av, &ad); 1825 + rc = avc_has_perm(sid, dsec->sid, SECCLASS_DIR, av, &ad); 1814 1826 if (rc) 1815 1827 return rc; 1816 1828 ··· 1829 1843 return 0; 1830 1844 } 1831 1845 1832 - rc = avc_has_perm(&selinux_state, 1833 - sid, isec->sid, isec->sclass, av, &ad); 1846 + rc = avc_has_perm(sid, isec->sid, isec->sclass, av, &ad); 1834 1847 return rc; 1835 1848 } 1836 1849 ··· 1853 1868 ad.type = LSM_AUDIT_DATA_DENTRY; 1854 1869 1855 1870 ad.u.dentry = old_dentry; 1856 - rc = avc_has_perm(&selinux_state, 1857 - sid, old_dsec->sid, SECCLASS_DIR, 1871 + rc = avc_has_perm(sid, old_dsec->sid, SECCLASS_DIR, 1858 1872 DIR__REMOVE_NAME | DIR__SEARCH, &ad); 1859 1873 if (rc) 1860 1874 return rc; 1861 - rc = avc_has_perm(&selinux_state, 1862 - sid, old_isec->sid, 1875 + rc = avc_has_perm(sid, old_isec->sid, 1863 1876 old_isec->sclass, FILE__RENAME, &ad); 1864 1877 if (rc) 1865 1878 return rc; 1866 1879 if (old_is_dir && new_dir != old_dir) { 1867 - rc = avc_has_perm(&selinux_state, 1868 - sid, old_isec->sid, 1880 + rc = avc_has_perm(sid, old_isec->sid, 1869 1881 old_isec->sclass, DIR__REPARENT, &ad); 1870 1882 if (rc) 1871 1883 return rc; ··· 1872 1890 av = DIR__ADD_NAME | DIR__SEARCH; 1873 1891 if (d_is_positive(new_dentry)) 1874 1892 av |= DIR__REMOVE_NAME; 1875 - rc = avc_has_perm(&selinux_state, 1876 - sid, new_dsec->sid, SECCLASS_DIR, av, &ad); 1893 + rc = avc_has_perm(sid, new_dsec->sid, SECCLASS_DIR, av, &ad); 1877 1894 if (rc) 1878 1895 return rc; 1879 1896 if (d_is_positive(new_dentry)) { 1880 1897 new_isec = backing_inode_security(new_dentry); 1881 1898 new_is_dir = d_is_dir(new_dentry); 1882 - rc = avc_has_perm(&selinux_state, 1883 - sid, new_isec->sid, 1899 + rc = avc_has_perm(sid, new_isec->sid, 1884 1900 new_isec->sclass, 1885 1901 (new_is_dir ? DIR__RMDIR : FILE__UNLINK), &ad); 1886 1902 if (rc) ··· 1898 1918 u32 sid = cred_sid(cred); 1899 1919 1900 1920 sbsec = selinux_superblock(sb); 1901 - return avc_has_perm(&selinux_state, 1902 - sid, sbsec->sid, SECCLASS_FILESYSTEM, perms, ad); 1921 + return avc_has_perm(sid, sbsec->sid, SECCLASS_FILESYSTEM, perms, ad); 1903 1922 } 1904 1923 1905 1924 /* Convert a Linux mode and permission mask to an access vector. */ ··· 1972 1993 1973 1994 static int selinux_binder_set_context_mgr(const struct cred *mgr) 1974 1995 { 1975 - return avc_has_perm(&selinux_state, 1976 - current_sid(), cred_sid(mgr), SECCLASS_BINDER, 1996 + return avc_has_perm(current_sid(), cred_sid(mgr), SECCLASS_BINDER, 1977 1997 BINDER__SET_CONTEXT_MGR, NULL); 1978 1998 } 1979 1999 ··· 1985 2007 int rc; 1986 2008 1987 2009 if (mysid != fromsid) { 1988 - rc = avc_has_perm(&selinux_state, 1989 - mysid, fromsid, SECCLASS_BINDER, 2010 + rc = avc_has_perm(mysid, fromsid, SECCLASS_BINDER, 1990 2011 BINDER__IMPERSONATE, NULL); 1991 2012 if (rc) 1992 2013 return rc; 1993 2014 } 1994 2015 1995 - return avc_has_perm(&selinux_state, fromsid, tosid, 2016 + return avc_has_perm(fromsid, tosid, 1996 2017 SECCLASS_BINDER, BINDER__CALL, NULL); 1997 2018 } 1998 2019 1999 2020 static int selinux_binder_transfer_binder(const struct cred *from, 2000 2021 const struct cred *to) 2001 2022 { 2002 - return avc_has_perm(&selinux_state, 2003 - cred_sid(from), cred_sid(to), 2023 + return avc_has_perm(cred_sid(from), cred_sid(to), 2004 2024 SECCLASS_BINDER, BINDER__TRANSFER, 2005 2025 NULL); 2006 2026 } ··· 2018 2042 ad.u.path = file->f_path; 2019 2043 2020 2044 if (sid != fsec->sid) { 2021 - rc = avc_has_perm(&selinux_state, 2022 - sid, fsec->sid, 2045 + rc = avc_has_perm(sid, fsec->sid, 2023 2046 SECCLASS_FD, 2024 2047 FD__USE, 2025 2048 &ad); ··· 2036 2061 return 0; 2037 2062 2038 2063 isec = backing_inode_security(dentry); 2039 - return avc_has_perm(&selinux_state, 2040 - sid, isec->sid, isec->sclass, file_to_av(file), 2064 + return avc_has_perm(sid, isec->sid, isec->sclass, file_to_av(file), 2041 2065 &ad); 2042 2066 } 2043 2067 ··· 2047 2073 u32 csid = task_sid_obj(child); 2048 2074 2049 2075 if (mode & PTRACE_MODE_READ) 2050 - return avc_has_perm(&selinux_state, 2051 - sid, csid, SECCLASS_FILE, FILE__READ, NULL); 2076 + return avc_has_perm(sid, csid, SECCLASS_FILE, FILE__READ, 2077 + NULL); 2052 2078 2053 - return avc_has_perm(&selinux_state, 2054 - sid, csid, SECCLASS_PROCESS, PROCESS__PTRACE, NULL); 2079 + return avc_has_perm(sid, csid, SECCLASS_PROCESS, PROCESS__PTRACE, 2080 + NULL); 2055 2081 } 2056 2082 2057 2083 static int selinux_ptrace_traceme(struct task_struct *parent) 2058 2084 { 2059 - return avc_has_perm(&selinux_state, 2060 - task_sid_obj(parent), task_sid_obj(current), 2085 + return avc_has_perm(task_sid_obj(parent), task_sid_obj(current), 2061 2086 SECCLASS_PROCESS, PROCESS__PTRACE, NULL); 2062 2087 } 2063 2088 2064 2089 static int selinux_capget(struct task_struct *target, kernel_cap_t *effective, 2065 2090 kernel_cap_t *inheritable, kernel_cap_t *permitted) 2066 2091 { 2067 - return avc_has_perm(&selinux_state, 2068 - current_sid(), task_sid_obj(target), SECCLASS_PROCESS, 2069 - PROCESS__GETCAP, NULL); 2092 + return avc_has_perm(current_sid(), task_sid_obj(target), 2093 + SECCLASS_PROCESS, PROCESS__GETCAP, NULL); 2070 2094 } 2071 2095 2072 2096 static int selinux_capset(struct cred *new, const struct cred *old, ··· 2072 2100 const kernel_cap_t *inheritable, 2073 2101 const kernel_cap_t *permitted) 2074 2102 { 2075 - return avc_has_perm(&selinux_state, 2076 - cred_sid(old), cred_sid(new), SECCLASS_PROCESS, 2103 + return avc_has_perm(cred_sid(old), cred_sid(new), SECCLASS_PROCESS, 2077 2104 PROCESS__SETCAP, NULL); 2078 2105 } 2079 2106 ··· 2139 2168 switch (type) { 2140 2169 case SYSLOG_ACTION_READ_ALL: /* Read last kernel messages */ 2141 2170 case SYSLOG_ACTION_SIZE_BUFFER: /* Return size of the log buffer */ 2142 - return avc_has_perm(&selinux_state, 2143 - current_sid(), SECINITSID_KERNEL, 2171 + return avc_has_perm(current_sid(), SECINITSID_KERNEL, 2144 2172 SECCLASS_SYSTEM, SYSTEM__SYSLOG_READ, NULL); 2145 2173 case SYSLOG_ACTION_CONSOLE_OFF: /* Disable logging to console */ 2146 2174 case SYSLOG_ACTION_CONSOLE_ON: /* Enable logging to console */ 2147 2175 /* Set level of messages printed to console */ 2148 2176 case SYSLOG_ACTION_CONSOLE_LEVEL: 2149 - return avc_has_perm(&selinux_state, 2150 - current_sid(), SECINITSID_KERNEL, 2177 + return avc_has_perm(current_sid(), SECINITSID_KERNEL, 2151 2178 SECCLASS_SYSTEM, SYSTEM__SYSLOG_CONSOLE, 2152 2179 NULL); 2153 2180 } 2154 2181 /* All other syslog types */ 2155 - return avc_has_perm(&selinux_state, 2156 - current_sid(), SECINITSID_KERNEL, 2182 + return avc_has_perm(current_sid(), SECINITSID_KERNEL, 2157 2183 SECCLASS_SYSTEM, SYSTEM__SYSLOG_MOD, NULL); 2158 2184 } 2159 2185 ··· 2217 2249 av |= PROCESS2__NNP_TRANSITION; 2218 2250 if (nosuid) 2219 2251 av |= PROCESS2__NOSUID_TRANSITION; 2220 - rc = avc_has_perm(&selinux_state, 2221 - old_tsec->sid, new_tsec->sid, 2252 + rc = avc_has_perm(old_tsec->sid, new_tsec->sid, 2222 2253 SECCLASS_PROCESS2, av, NULL); 2223 2254 if (!rc) 2224 2255 return 0; ··· 2228 2261 * i.e. SIDs that are guaranteed to only be allowed a subset 2229 2262 * of the permissions of the current SID. 2230 2263 */ 2231 - rc = security_bounded_transition(&selinux_state, old_tsec->sid, 2264 + rc = security_bounded_transition(old_tsec->sid, 2232 2265 new_tsec->sid); 2233 2266 if (!rc) 2234 2267 return 0; ··· 2279 2312 return rc; 2280 2313 } else { 2281 2314 /* Check for a default transition on this program. */ 2282 - rc = security_transition_sid(&selinux_state, old_tsec->sid, 2315 + rc = security_transition_sid(old_tsec->sid, 2283 2316 isec->sid, SECCLASS_PROCESS, NULL, 2284 2317 &new_tsec->sid); 2285 2318 if (rc) ··· 2298 2331 ad.u.file = bprm->file; 2299 2332 2300 2333 if (new_tsec->sid == old_tsec->sid) { 2301 - rc = avc_has_perm(&selinux_state, 2302 - old_tsec->sid, isec->sid, 2334 + rc = avc_has_perm(old_tsec->sid, isec->sid, 2303 2335 SECCLASS_FILE, FILE__EXECUTE_NO_TRANS, &ad); 2304 2336 if (rc) 2305 2337 return rc; 2306 2338 } else { 2307 2339 /* Check permissions for the transition. */ 2308 - rc = avc_has_perm(&selinux_state, 2309 - old_tsec->sid, new_tsec->sid, 2340 + rc = avc_has_perm(old_tsec->sid, new_tsec->sid, 2310 2341 SECCLASS_PROCESS, PROCESS__TRANSITION, &ad); 2311 2342 if (rc) 2312 2343 return rc; 2313 2344 2314 - rc = avc_has_perm(&selinux_state, 2315 - new_tsec->sid, isec->sid, 2345 + rc = avc_has_perm(new_tsec->sid, isec->sid, 2316 2346 SECCLASS_FILE, FILE__ENTRYPOINT, &ad); 2317 2347 if (rc) 2318 2348 return rc; 2319 2349 2320 2350 /* Check for shared state */ 2321 2351 if (bprm->unsafe & LSM_UNSAFE_SHARE) { 2322 - rc = avc_has_perm(&selinux_state, 2323 - old_tsec->sid, new_tsec->sid, 2352 + rc = avc_has_perm(old_tsec->sid, new_tsec->sid, 2324 2353 SECCLASS_PROCESS, PROCESS__SHARE, 2325 2354 NULL); 2326 2355 if (rc) ··· 2328 2365 if (bprm->unsafe & LSM_UNSAFE_PTRACE) { 2329 2366 u32 ptsid = ptrace_parent_sid(); 2330 2367 if (ptsid != 0) { 2331 - rc = avc_has_perm(&selinux_state, 2332 - ptsid, new_tsec->sid, 2368 + rc = avc_has_perm(ptsid, new_tsec->sid, 2333 2369 SECCLASS_PROCESS, 2334 2370 PROCESS__PTRACE, NULL); 2335 2371 if (rc) ··· 2342 2380 /* Enable secure mode for SIDs transitions unless 2343 2381 the noatsecure permission is granted between 2344 2382 the two SIDs, i.e. ahp returns 0. */ 2345 - rc = avc_has_perm(&selinux_state, 2346 - old_tsec->sid, new_tsec->sid, 2383 + rc = avc_has_perm(old_tsec->sid, new_tsec->sid, 2347 2384 SECCLASS_PROCESS, PROCESS__NOATSECURE, 2348 2385 NULL); 2349 2386 bprm->secureexec |= !!rc; ··· 2434 2473 * higher than the default soft limit for cases where the default is 2435 2474 * lower than the hard limit, e.g. RLIMIT_CORE or RLIMIT_STACK. 2436 2475 */ 2437 - rc = avc_has_perm(&selinux_state, 2438 - new_tsec->osid, new_tsec->sid, SECCLASS_PROCESS, 2476 + rc = avc_has_perm(new_tsec->osid, new_tsec->sid, SECCLASS_PROCESS, 2439 2477 PROCESS__RLIMITINH, NULL); 2440 2478 if (rc) { 2441 2479 /* protect against do_prlimit() */ ··· 2473 2513 * This must occur _after_ the task SID has been updated so that any 2474 2514 * kill done after the flush will be checked against the new SID. 2475 2515 */ 2476 - rc = avc_has_perm(&selinux_state, 2477 - osid, sid, SECCLASS_PROCESS, PROCESS__SIGINH, NULL); 2516 + rc = avc_has_perm(osid, sid, SECCLASS_PROCESS, PROCESS__SIGINH, NULL); 2478 2517 if (rc) { 2479 2518 clear_itimer(); 2480 2519 ··· 2800 2841 if (xattr_name) 2801 2842 *xattr_name = XATTR_NAME_SELINUX; 2802 2843 2803 - return security_sid_to_context(&selinux_state, newsid, (char **)ctx, 2844 + return security_sid_to_context(newsid, (char **)ctx, 2804 2845 ctxlen); 2805 2846 } 2806 2847 ··· 2854 2895 isec->initialized = LABEL_INITIALIZED; 2855 2896 } 2856 2897 2857 - if (!selinux_initialized(&selinux_state) || 2898 + if (!selinux_initialized() || 2858 2899 !(sbsec->flags & SBLABEL_MNT)) 2859 2900 return -EOPNOTSUPP; 2860 2901 ··· 2862 2903 *name = XATTR_SELINUX_SUFFIX; 2863 2904 2864 2905 if (value && len) { 2865 - rc = security_sid_to_context_force(&selinux_state, newsid, 2906 + rc = security_sid_to_context_force(newsid, 2866 2907 &context, &clen); 2867 2908 if (rc) 2868 2909 return rc; ··· 2882 2923 struct inode_security_struct *isec; 2883 2924 int rc; 2884 2925 2885 - if (unlikely(!selinux_initialized(&selinux_state))) 2926 + if (unlikely(!selinux_initialized())) 2886 2927 return 0; 2887 2928 2888 2929 isec = selinux_inode(inode); ··· 2906 2947 } else { 2907 2948 isec->sclass = SECCLASS_ANON_INODE; 2908 2949 rc = security_transition_sid( 2909 - &selinux_state, tsec->sid, tsec->sid, 2950 + tsec->sid, tsec->sid, 2910 2951 isec->sclass, name, &isec->sid); 2911 2952 if (rc) 2912 2953 return rc; ··· 2921 2962 ad.type = LSM_AUDIT_DATA_ANONINODE; 2922 2963 ad.u.anonclass = name ? (const char *)name->name : "?"; 2923 2964 2924 - return avc_has_perm(&selinux_state, 2925 - tsec->sid, 2965 + return avc_has_perm(tsec->sid, 2926 2966 isec->sid, 2927 2967 isec->sclass, 2928 2968 FILE__CREATE, ··· 2993 3035 if (IS_ERR(isec)) 2994 3036 return PTR_ERR(isec); 2995 3037 2996 - return avc_has_perm(&selinux_state, 2997 - sid, isec->sid, isec->sclass, FILE__READ, &ad); 3038 + return avc_has_perm(sid, isec->sid, isec->sclass, FILE__READ, &ad); 2998 3039 } 2999 3040 3000 3041 static noinline int audit_inode_permission(struct inode *inode, ··· 3006 3049 ad.type = LSM_AUDIT_DATA_INODE; 3007 3050 ad.u.inode = inode; 3008 3051 3009 - return slow_avc_audit(&selinux_state, 3010 - current_sid(), isec->sid, isec->sclass, perms, 3052 + return slow_avc_audit(current_sid(), isec->sid, isec->sclass, perms, 3011 3053 audited, denied, result, &ad); 3012 3054 } 3013 3055 ··· 3041 3085 if (IS_ERR(isec)) 3042 3086 return PTR_ERR(isec); 3043 3087 3044 - rc = avc_has_perm_noaudit(&selinux_state, 3045 - sid, isec->sid, isec->sclass, perms, 0, 3088 + rc = avc_has_perm_noaudit(sid, isec->sid, isec->sclass, perms, 0, 3046 3089 &avd); 3047 3090 audited = avc_audit_required(perms, &avd, rc, 3048 3091 from_access ? FILE__AUDIT_ACCESS : 0, ··· 3121 3166 return dentry_has_perm(current_cred(), dentry, FILE__SETATTR); 3122 3167 } 3123 3168 3124 - if (!selinux_initialized(&selinux_state)) 3169 + if (!selinux_initialized()) 3125 3170 return (inode_owner_or_capable(idmap, inode) ? 0 : -EPERM); 3126 3171 3127 3172 sbsec = selinux_superblock(inode->i_sb); ··· 3135 3180 ad.u.dentry = dentry; 3136 3181 3137 3182 isec = backing_inode_security(dentry); 3138 - rc = avc_has_perm(&selinux_state, 3139 - sid, isec->sid, isec->sclass, 3183 + rc = avc_has_perm(sid, isec->sid, isec->sclass, 3140 3184 FILE__RELABELFROM, &ad); 3141 3185 if (rc) 3142 3186 return rc; 3143 3187 3144 - rc = security_context_to_sid(&selinux_state, value, size, &newsid, 3188 + rc = security_context_to_sid(value, size, &newsid, 3145 3189 GFP_KERNEL); 3146 3190 if (rc == -EINVAL) { 3147 3191 if (!has_cap_mac_admin(true)) { ··· 3169 3215 3170 3216 return rc; 3171 3217 } 3172 - rc = security_context_to_sid_force(&selinux_state, value, 3218 + rc = security_context_to_sid_force(value, 3173 3219 size, &newsid); 3174 3220 } 3175 3221 if (rc) 3176 3222 return rc; 3177 3223 3178 - rc = avc_has_perm(&selinux_state, 3179 - sid, newsid, isec->sclass, 3224 + rc = avc_has_perm(sid, newsid, isec->sclass, 3180 3225 FILE__RELABELTO, &ad); 3181 3226 if (rc) 3182 3227 return rc; 3183 3228 3184 - rc = security_validate_transition(&selinux_state, isec->sid, newsid, 3229 + rc = security_validate_transition(isec->sid, newsid, 3185 3230 sid, isec->sclass); 3186 3231 if (rc) 3187 3232 return rc; 3188 3233 3189 - return avc_has_perm(&selinux_state, 3190 - newsid, 3234 + return avc_has_perm(newsid, 3191 3235 sbsec->sid, 3192 3236 SECCLASS_FILESYSTEM, 3193 3237 FILESYSTEM__ASSOCIATE, ··· 3225 3273 return; 3226 3274 } 3227 3275 3228 - if (!selinux_initialized(&selinux_state)) { 3276 + if (!selinux_initialized()) { 3229 3277 /* If we haven't even been initialized, then we can't validate 3230 3278 * against a policy, so leave the label as invalid. It may 3231 3279 * resolve to a valid label on the next revalidation try if ··· 3234 3282 return; 3235 3283 } 3236 3284 3237 - rc = security_context_to_sid_force(&selinux_state, value, size, 3285 + rc = security_context_to_sid_force(value, size, 3238 3286 &newsid); 3239 3287 if (rc) { 3240 3288 pr_err("SELinux: unable to map context to SID" ··· 3278 3326 return dentry_has_perm(current_cred(), dentry, FILE__SETATTR); 3279 3327 } 3280 3328 3281 - if (!selinux_initialized(&selinux_state)) 3329 + if (!selinux_initialized()) 3282 3330 return 0; 3283 3331 3284 3332 /* No one is allowed to remove a SELinux security label. ··· 3348 3396 * If we're not initialized yet, then we can't validate contexts, so 3349 3397 * just let vfs_getxattr fall back to using the on-disk xattr. 3350 3398 */ 3351 - if (!selinux_initialized(&selinux_state) || 3399 + if (!selinux_initialized() || 3352 3400 strcmp(name, XATTR_SELINUX_SUFFIX)) 3353 3401 return -EOPNOTSUPP; 3354 3402 ··· 3363 3411 */ 3364 3412 isec = inode_security(inode); 3365 3413 if (has_cap_mac_admin(false)) 3366 - error = security_sid_to_context_force(&selinux_state, 3367 - isec->sid, &context, 3414 + error = security_sid_to_context_force(isec->sid, &context, 3368 3415 &size); 3369 3416 else 3370 - error = security_sid_to_context(&selinux_state, isec->sid, 3417 + error = security_sid_to_context(isec->sid, 3371 3418 &context, &size); 3372 3419 if (error) 3373 3420 return error; ··· 3398 3447 if (!value || !size) 3399 3448 return -EACCES; 3400 3449 3401 - rc = security_context_to_sid(&selinux_state, value, size, &newsid, 3450 + rc = security_context_to_sid(value, size, &newsid, 3402 3451 GFP_KERNEL); 3403 3452 if (rc) 3404 3453 return rc; ··· 3415 3464 { 3416 3465 const int len = sizeof(XATTR_NAME_SELINUX); 3417 3466 3418 - if (!selinux_initialized(&selinux_state)) 3467 + if (!selinux_initialized()) 3419 3468 return 0; 3420 3469 3421 3470 if (buffer && len <= buffer_size) ··· 3491 3540 return rc; 3492 3541 } 3493 3542 3494 - rc = security_context_to_sid(&selinux_state, context, clen, &parent_sid, 3543 + rc = security_context_to_sid(context, clen, &parent_sid, 3495 3544 GFP_KERNEL); 3496 3545 kfree(context); 3497 3546 if (rc) ··· 3506 3555 q.name = kn->name; 3507 3556 q.hash_len = hashlen_string(kn_dir, kn->name); 3508 3557 3509 - rc = security_transition_sid(&selinux_state, tsec->sid, 3558 + rc = security_transition_sid(tsec->sid, 3510 3559 parent_sid, secclass, &q, 3511 3560 &newsid); 3512 3561 if (rc) 3513 3562 return rc; 3514 3563 } 3515 3564 3516 - rc = security_sid_to_context_force(&selinux_state, newsid, 3565 + rc = security_sid_to_context_force(newsid, 3517 3566 &context, &clen); 3518 3567 if (rc) 3519 3568 return rc; ··· 3553 3602 3554 3603 isec = inode_security(inode); 3555 3604 if (sid == fsec->sid && fsec->isid == isec->sid && 3556 - fsec->pseqno == avc_policy_seqno(&selinux_state)) 3605 + fsec->pseqno == avc_policy_seqno()) 3557 3606 /* No change since file_open check. */ 3558 3607 return 0; 3559 3608 ··· 3594 3643 ad.u.op->path = file->f_path; 3595 3644 3596 3645 if (ssid != fsec->sid) { 3597 - rc = avc_has_perm(&selinux_state, 3598 - ssid, fsec->sid, 3646 + rc = avc_has_perm(ssid, fsec->sid, 3599 3647 SECCLASS_FD, 3600 3648 FD__USE, 3601 3649 &ad); ··· 3606 3656 return 0; 3607 3657 3608 3658 isec = inode_security(inode); 3609 - rc = avc_has_extended_perms(&selinux_state, 3610 - ssid, isec->sid, isec->sclass, 3659 + rc = avc_has_extended_perms(ssid, isec->sid, isec->sclass, 3611 3660 requested, driver, xperm, &ad); 3612 3661 out: 3613 3662 return rc; ··· 3675 3726 * private file mapping that will also be writable. 3676 3727 * This has an additional check. 3677 3728 */ 3678 - rc = avc_has_perm(&selinux_state, 3679 - sid, sid, SECCLASS_PROCESS, 3729 + rc = avc_has_perm(sid, sid, SECCLASS_PROCESS, 3680 3730 PROCESS__EXECMEM, NULL); 3681 3731 if (rc) 3682 3732 goto error; ··· 3705 3757 3706 3758 if (addr < CONFIG_LSM_MMAP_MIN_ADDR) { 3707 3759 u32 sid = current_sid(); 3708 - rc = avc_has_perm(&selinux_state, 3709 - sid, sid, SECCLASS_MEMPROTECT, 3760 + rc = avc_has_perm(sid, sid, SECCLASS_MEMPROTECT, 3710 3761 MEMPROTECT__MMAP_ZERO, NULL); 3711 3762 } 3712 3763 ··· 3727 3780 return rc; 3728 3781 } 3729 3782 3730 - if (checkreqprot_get(&selinux_state)) 3783 + if (checkreqprot_get()) 3731 3784 prot = reqprot; 3732 3785 3733 3786 return file_map_prot_check(file, prot, ··· 3741 3794 const struct cred *cred = current_cred(); 3742 3795 u32 sid = cred_sid(cred); 3743 3796 3744 - if (checkreqprot_get(&selinux_state)) 3797 + if (checkreqprot_get()) 3745 3798 prot = reqprot; 3746 3799 3747 3800 if (default_noexec && ··· 3749 3802 int rc = 0; 3750 3803 if (vma->vm_start >= vma->vm_mm->start_brk && 3751 3804 vma->vm_end <= vma->vm_mm->brk) { 3752 - rc = avc_has_perm(&selinux_state, 3753 - sid, sid, SECCLASS_PROCESS, 3805 + rc = avc_has_perm(sid, sid, SECCLASS_PROCESS, 3754 3806 PROCESS__EXECHEAP, NULL); 3755 3807 } else if (!vma->vm_file && 3756 3808 ((vma->vm_start <= vma->vm_mm->start_stack && 3757 3809 vma->vm_end >= vma->vm_mm->start_stack) || 3758 3810 vma_is_stack_for_current(vma))) { 3759 - rc = avc_has_perm(&selinux_state, 3760 - sid, sid, SECCLASS_PROCESS, 3811 + rc = avc_has_perm(sid, sid, SECCLASS_PROCESS, 3761 3812 PROCESS__EXECSTACK, NULL); 3762 3813 } else if (vma->vm_file && vma->anon_vma) { 3763 3814 /* ··· 3847 3902 else 3848 3903 perm = signal_to_av(signum); 3849 3904 3850 - return avc_has_perm(&selinux_state, 3851 - fsec->fown_sid, sid, 3905 + return avc_has_perm(fsec->fown_sid, sid, 3852 3906 SECCLASS_PROCESS, perm, NULL); 3853 3907 } 3854 3908 ··· 3873 3929 * struct as its SID. 3874 3930 */ 3875 3931 fsec->isid = isec->sid; 3876 - fsec->pseqno = avc_policy_seqno(&selinux_state); 3932 + fsec->pseqno = avc_policy_seqno(); 3877 3933 /* 3878 3934 * Since the inode label or policy seqno may have changed 3879 3935 * between the selinux_inode_permission check and the saving ··· 3892 3948 { 3893 3949 u32 sid = current_sid(); 3894 3950 3895 - return avc_has_perm(&selinux_state, 3896 - sid, sid, SECCLASS_PROCESS, PROCESS__FORK, NULL); 3951 + return avc_has_perm(sid, sid, SECCLASS_PROCESS, PROCESS__FORK, NULL); 3897 3952 } 3898 3953 3899 3954 /* ··· 3934 3991 u32 sid = current_sid(); 3935 3992 int ret; 3936 3993 3937 - ret = avc_has_perm(&selinux_state, 3938 - sid, secid, 3994 + ret = avc_has_perm(sid, secid, 3939 3995 SECCLASS_KERNEL_SERVICE, 3940 3996 KERNEL_SERVICE__USE_AS_OVERRIDE, 3941 3997 NULL); ··· 3958 4016 u32 sid = current_sid(); 3959 4017 int ret; 3960 4018 3961 - ret = avc_has_perm(&selinux_state, 3962 - sid, isec->sid, 4019 + ret = avc_has_perm(sid, isec->sid, 3963 4020 SECCLASS_KERNEL_SERVICE, 3964 4021 KERNEL_SERVICE__CREATE_FILES_AS, 3965 4022 NULL); ··· 3975 4034 ad.type = LSM_AUDIT_DATA_KMOD; 3976 4035 ad.u.kmod_name = kmod_name; 3977 4036 3978 - return avc_has_perm(&selinux_state, 3979 - current_sid(), SECINITSID_KERNEL, SECCLASS_SYSTEM, 4037 + return avc_has_perm(current_sid(), SECINITSID_KERNEL, SECCLASS_SYSTEM, 3980 4038 SYSTEM__MODULE_REQUEST, &ad); 3981 4039 } 3982 4040 ··· 3989 4049 3990 4050 /* init_module */ 3991 4051 if (file == NULL) 3992 - return avc_has_perm(&selinux_state, 3993 - sid, sid, SECCLASS_SYSTEM, 4052 + return avc_has_perm(sid, sid, SECCLASS_SYSTEM, 3994 4053 SYSTEM__MODULE_LOAD, NULL); 3995 4054 3996 4055 /* finit_module */ ··· 3999 4060 4000 4061 fsec = selinux_file(file); 4001 4062 if (sid != fsec->sid) { 4002 - rc = avc_has_perm(&selinux_state, 4003 - sid, fsec->sid, SECCLASS_FD, FD__USE, &ad); 4063 + rc = avc_has_perm(sid, fsec->sid, SECCLASS_FD, FD__USE, &ad); 4004 4064 if (rc) 4005 4065 return rc; 4006 4066 } 4007 4067 4008 4068 isec = inode_security(file_inode(file)); 4009 - return avc_has_perm(&selinux_state, 4010 - sid, isec->sid, SECCLASS_SYSTEM, 4069 + return avc_has_perm(sid, isec->sid, SECCLASS_SYSTEM, 4011 4070 SYSTEM__MODULE_LOAD, &ad); 4012 4071 } 4013 4072 ··· 4043 4106 4044 4107 static int selinux_task_setpgid(struct task_struct *p, pid_t pgid) 4045 4108 { 4046 - return avc_has_perm(&selinux_state, 4047 - current_sid(), task_sid_obj(p), SECCLASS_PROCESS, 4109 + return avc_has_perm(current_sid(), task_sid_obj(p), SECCLASS_PROCESS, 4048 4110 PROCESS__SETPGID, NULL); 4049 4111 } 4050 4112 4051 4113 static int selinux_task_getpgid(struct task_struct *p) 4052 4114 { 4053 - return avc_has_perm(&selinux_state, 4054 - current_sid(), task_sid_obj(p), SECCLASS_PROCESS, 4115 + return avc_has_perm(current_sid(), task_sid_obj(p), SECCLASS_PROCESS, 4055 4116 PROCESS__GETPGID, NULL); 4056 4117 } 4057 4118 4058 4119 static int selinux_task_getsid(struct task_struct *p) 4059 4120 { 4060 - return avc_has_perm(&selinux_state, 4061 - current_sid(), task_sid_obj(p), SECCLASS_PROCESS, 4121 + return avc_has_perm(current_sid(), task_sid_obj(p), SECCLASS_PROCESS, 4062 4122 PROCESS__GETSESSION, NULL); 4063 4123 } 4064 4124 ··· 4071 4137 4072 4138 static int selinux_task_setnice(struct task_struct *p, int nice) 4073 4139 { 4074 - return avc_has_perm(&selinux_state, 4075 - current_sid(), task_sid_obj(p), SECCLASS_PROCESS, 4140 + return avc_has_perm(current_sid(), task_sid_obj(p), SECCLASS_PROCESS, 4076 4141 PROCESS__SETSCHED, NULL); 4077 4142 } 4078 4143 4079 4144 static int selinux_task_setioprio(struct task_struct *p, int ioprio) 4080 4145 { 4081 - return avc_has_perm(&selinux_state, 4082 - current_sid(), task_sid_obj(p), SECCLASS_PROCESS, 4146 + return avc_has_perm(current_sid(), task_sid_obj(p), SECCLASS_PROCESS, 4083 4147 PROCESS__SETSCHED, NULL); 4084 4148 } 4085 4149 4086 4150 static int selinux_task_getioprio(struct task_struct *p) 4087 4151 { 4088 - return avc_has_perm(&selinux_state, 4089 - current_sid(), task_sid_obj(p), SECCLASS_PROCESS, 4152 + return avc_has_perm(current_sid(), task_sid_obj(p), SECCLASS_PROCESS, 4090 4153 PROCESS__GETSCHED, NULL); 4091 4154 } 4092 4155 ··· 4098 4167 av |= PROCESS__SETRLIMIT; 4099 4168 if (flags & LSM_PRLIMIT_READ) 4100 4169 av |= PROCESS__GETRLIMIT; 4101 - return avc_has_perm(&selinux_state, 4102 - cred_sid(cred), cred_sid(tcred), 4170 + return avc_has_perm(cred_sid(cred), cred_sid(tcred), 4103 4171 SECCLASS_PROCESS, av, NULL); 4104 4172 } 4105 4173 ··· 4112 4182 later be used as a safe reset point for the soft limit 4113 4183 upon context transitions. See selinux_bprm_committing_creds. */ 4114 4184 if (old_rlim->rlim_max != new_rlim->rlim_max) 4115 - return avc_has_perm(&selinux_state, 4116 - current_sid(), task_sid_obj(p), 4185 + return avc_has_perm(current_sid(), task_sid_obj(p), 4117 4186 SECCLASS_PROCESS, PROCESS__SETRLIMIT, NULL); 4118 4187 4119 4188 return 0; ··· 4120 4191 4121 4192 static int selinux_task_setscheduler(struct task_struct *p) 4122 4193 { 4123 - return avc_has_perm(&selinux_state, 4124 - current_sid(), task_sid_obj(p), SECCLASS_PROCESS, 4194 + return avc_has_perm(current_sid(), task_sid_obj(p), SECCLASS_PROCESS, 4125 4195 PROCESS__SETSCHED, NULL); 4126 4196 } 4127 4197 4128 4198 static int selinux_task_getscheduler(struct task_struct *p) 4129 4199 { 4130 - return avc_has_perm(&selinux_state, 4131 - current_sid(), task_sid_obj(p), SECCLASS_PROCESS, 4200 + return avc_has_perm(current_sid(), task_sid_obj(p), SECCLASS_PROCESS, 4132 4201 PROCESS__GETSCHED, NULL); 4133 4202 } 4134 4203 4135 4204 static int selinux_task_movememory(struct task_struct *p) 4136 4205 { 4137 - return avc_has_perm(&selinux_state, 4138 - current_sid(), task_sid_obj(p), SECCLASS_PROCESS, 4206 + return avc_has_perm(current_sid(), task_sid_obj(p), SECCLASS_PROCESS, 4139 4207 PROCESS__SETSCHED, NULL); 4140 4208 } 4141 4209 ··· 4150 4224 secid = current_sid(); 4151 4225 else 4152 4226 secid = cred_sid(cred); 4153 - return avc_has_perm(&selinux_state, 4154 - secid, task_sid_obj(p), SECCLASS_PROCESS, perm, NULL); 4227 + return avc_has_perm(secid, task_sid_obj(p), SECCLASS_PROCESS, perm, NULL); 4155 4228 } 4156 4229 4157 4230 static void selinux_task_to_inode(struct task_struct *p, ··· 4170 4245 { 4171 4246 u32 sid = current_sid(); 4172 4247 4173 - return avc_has_perm(&selinux_state, sid, sid, SECCLASS_USER_NAMESPACE, 4174 - USER_NAMESPACE__CREATE, NULL); 4248 + return avc_has_perm(sid, sid, SECCLASS_USER_NAMESPACE, 4249 + USER_NAMESPACE__CREATE, NULL); 4175 4250 } 4176 4251 4177 4252 /* Returns error only if unable to parse addresses */ ··· 4429 4504 if (unlikely(err)) 4430 4505 return -EACCES; 4431 4506 4432 - err = security_net_peersid_resolve(&selinux_state, nlbl_sid, 4507 + err = security_net_peersid_resolve(nlbl_sid, 4433 4508 nlbl_type, xfrm_sid, sid); 4434 4509 if (unlikely(err)) { 4435 4510 pr_warn( ··· 4458 4533 int err = 0; 4459 4534 4460 4535 if (skb_sid != SECSID_NULL) 4461 - err = security_sid_mls_copy(&selinux_state, sk_sid, skb_sid, 4536 + err = security_sid_mls_copy(sk_sid, skb_sid, 4462 4537 conn_sid); 4463 4538 else 4464 4539 *conn_sid = sk_sid; ··· 4476 4551 return 0; 4477 4552 } 4478 4553 4479 - return security_transition_sid(&selinux_state, tsec->sid, tsec->sid, 4554 + return security_transition_sid(tsec->sid, tsec->sid, 4480 4555 secclass, NULL, socksid); 4481 4556 } 4482 4557 ··· 4493 4568 ad.u.net = &net; 4494 4569 ad.u.net->sk = sk; 4495 4570 4496 - return avc_has_perm(&selinux_state, 4497 - current_sid(), sksec->sid, sksec->sclass, perms, 4571 + return avc_has_perm(current_sid(), sksec->sid, sksec->sclass, perms, 4498 4572 &ad); 4499 4573 } 4500 4574 ··· 4513 4589 if (rc) 4514 4590 return rc; 4515 4591 4516 - return avc_has_perm(&selinux_state, 4517 - tsec->sid, newsid, secclass, SOCKET__CREATE, NULL); 4592 + return avc_has_perm(tsec->sid, newsid, secclass, SOCKET__CREATE, NULL); 4518 4593 } 4519 4594 4520 4595 static int selinux_socket_post_create(struct socket *sock, int family, ··· 4642 4719 snum, &sid); 4643 4720 if (err) 4644 4721 goto out; 4645 - err = avc_has_perm(&selinux_state, 4646 - sksec->sid, sid, 4722 + err = avc_has_perm(sksec->sid, sid, 4647 4723 sksec->sclass, 4648 4724 SOCKET__NAME_BIND, &ad); 4649 4725 if (err) ··· 4681 4759 else 4682 4760 ad.u.net->v6info.saddr = addr6->sin6_addr; 4683 4761 4684 - err = avc_has_perm(&selinux_state, 4685 - sksec->sid, sid, 4762 + err = avc_has_perm(sksec->sid, sid, 4686 4763 sksec->sclass, node_perm, &ad); 4687 4764 if (err) 4688 4765 goto out; ··· 4779 4858 ad.u.net = &net; 4780 4859 ad.u.net->dport = htons(snum); 4781 4860 ad.u.net->family = address->sa_family; 4782 - err = avc_has_perm(&selinux_state, 4783 - sksec->sid, sid, sksec->sclass, perm, &ad); 4861 + err = avc_has_perm(sksec->sid, sid, sksec->sclass, perm, &ad); 4784 4862 if (err) 4785 4863 return err; 4786 4864 } ··· 4891 4971 ad.u.net = &net; 4892 4972 ad.u.net->sk = other; 4893 4973 4894 - err = avc_has_perm(&selinux_state, 4895 - sksec_sock->sid, sksec_other->sid, 4974 + err = avc_has_perm(sksec_sock->sid, sksec_other->sid, 4896 4975 sksec_other->sclass, 4897 4976 UNIX_STREAM_SOCKET__CONNECTTO, &ad); 4898 4977 if (err) ··· 4899 4980 4900 4981 /* server child socket */ 4901 4982 sksec_new->peer_sid = sksec_sock->sid; 4902 - err = security_sid_mls_copy(&selinux_state, sksec_other->sid, 4983 + err = security_sid_mls_copy(sksec_other->sid, 4903 4984 sksec_sock->sid, &sksec_new->sid); 4904 4985 if (err) 4905 4986 return err; ··· 4922 5003 ad.u.net = &net; 4923 5004 ad.u.net->sk = other->sk; 4924 5005 4925 - return avc_has_perm(&selinux_state, 4926 - ssec->sid, osec->sid, osec->sclass, SOCKET__SENDTO, 5006 + return avc_has_perm(ssec->sid, osec->sid, osec->sclass, SOCKET__SENDTO, 4927 5007 &ad); 4928 5008 } 4929 5009 ··· 4937 5019 err = sel_netif_sid(ns, ifindex, &if_sid); 4938 5020 if (err) 4939 5021 return err; 4940 - err = avc_has_perm(&selinux_state, 4941 - peer_sid, if_sid, 5022 + err = avc_has_perm(peer_sid, if_sid, 4942 5023 SECCLASS_NETIF, NETIF__INGRESS, ad); 4943 5024 if (err) 4944 5025 return err; ··· 4945 5028 err = sel_netnode_sid(addrp, family, &node_sid); 4946 5029 if (err) 4947 5030 return err; 4948 - return avc_has_perm(&selinux_state, 4949 - peer_sid, node_sid, 5031 + return avc_has_perm(peer_sid, node_sid, 4950 5032 SECCLASS_NODE, NODE__RECVFROM, ad); 4951 5033 } 4952 5034 ··· 4968 5052 return err; 4969 5053 4970 5054 if (selinux_secmark_enabled()) { 4971 - err = avc_has_perm(&selinux_state, 4972 - sk_sid, skb->secmark, SECCLASS_PACKET, 5055 + err = avc_has_perm(sk_sid, skb->secmark, SECCLASS_PACKET, 4973 5056 PACKET__RECV, &ad); 4974 5057 if (err) 4975 5058 return err; ··· 5033 5118 selinux_netlbl_err(skb, family, err, 0); 5034 5119 return err; 5035 5120 } 5036 - err = avc_has_perm(&selinux_state, 5037 - sk_sid, peer_sid, SECCLASS_PEER, 5121 + err = avc_has_perm(sk_sid, peer_sid, SECCLASS_PEER, 5038 5122 PEER__RECV, &ad); 5039 5123 if (err) { 5040 5124 selinux_netlbl_err(skb, family, err, 0); ··· 5042 5128 } 5043 5129 5044 5130 if (secmark_active) { 5045 - err = avc_has_perm(&selinux_state, 5046 - sk_sid, skb->secmark, SECCLASS_PACKET, 5131 + err = avc_has_perm(sk_sid, skb->secmark, SECCLASS_PACKET, 5047 5132 PACKET__RECV, &ad); 5048 5133 if (err) 5049 5134 return err; ··· 5068 5155 if (peer_sid == SECSID_NULL) 5069 5156 return -ENOPROTOOPT; 5070 5157 5071 - err = security_sid_to_context(&selinux_state, peer_sid, &scontext, 5158 + err = security_sid_to_context(peer_sid, &scontext, 5072 5159 &scontext_len); 5073 5160 if (err) 5074 5161 return err; ··· 5225 5312 ad.type = LSM_AUDIT_DATA_NET; 5226 5313 ad.u.net = &net; 5227 5314 ad.u.net->sk = asoc->base.sk; 5228 - err = avc_has_perm(&selinux_state, 5229 - sksec->peer_sid, asoc->peer_secid, 5315 + err = avc_has_perm(sksec->peer_sid, asoc->peer_secid, 5230 5316 sksec->sclass, SCTP_SOCKET__ASSOCIATION, 5231 5317 &ad); 5232 5318 if (err) ··· 5446 5534 __tsec = selinux_cred(current_cred()); 5447 5535 tsid = __tsec->sid; 5448 5536 5449 - return avc_has_perm(&selinux_state, 5450 - tsid, sid, SECCLASS_PACKET, PACKET__RELABELTO, 5537 + return avc_has_perm(tsid, sid, SECCLASS_PACKET, PACKET__RELABELTO, 5451 5538 NULL); 5452 5539 } 5453 5540 ··· 5495 5584 * connections unlike traditional sockets - check the TUN driver to 5496 5585 * get a better understanding of why this socket is special */ 5497 5586 5498 - return avc_has_perm(&selinux_state, 5499 - sid, sid, SECCLASS_TUN_SOCKET, TUN_SOCKET__CREATE, 5587 + return avc_has_perm(sid, sid, SECCLASS_TUN_SOCKET, TUN_SOCKET__CREATE, 5500 5588 NULL); 5501 5589 } 5502 5590 ··· 5503 5593 { 5504 5594 struct tun_security_struct *tunsec = security; 5505 5595 5506 - return avc_has_perm(&selinux_state, 5507 - current_sid(), tunsec->sid, SECCLASS_TUN_SOCKET, 5596 + return avc_has_perm(current_sid(), tunsec->sid, SECCLASS_TUN_SOCKET, 5508 5597 TUN_SOCKET__ATTACH_QUEUE, NULL); 5509 5598 } 5510 5599 ··· 5531 5622 u32 sid = current_sid(); 5532 5623 int err; 5533 5624 5534 - err = avc_has_perm(&selinux_state, 5535 - sid, tunsec->sid, SECCLASS_TUN_SOCKET, 5625 + err = avc_has_perm(sid, tunsec->sid, SECCLASS_TUN_SOCKET, 5536 5626 TUN_SOCKET__RELABELFROM, NULL); 5537 5627 if (err) 5538 5628 return err; 5539 - err = avc_has_perm(&selinux_state, 5540 - sid, sid, SECCLASS_TUN_SOCKET, 5629 + err = avc_has_perm(sid, sid, SECCLASS_TUN_SOCKET, 5541 5630 TUN_SOCKET__RELABELTO, NULL); 5542 5631 if (err) 5543 5632 return err; ··· 5589 5682 } 5590 5683 5591 5684 if (secmark_active) 5592 - if (avc_has_perm(&selinux_state, 5593 - peer_sid, skb->secmark, 5685 + if (avc_has_perm(peer_sid, skb->secmark, 5594 5686 SECCLASS_PACKET, PACKET__FORWARD_IN, &ad)) 5595 5687 return NF_DROP; 5596 5688 ··· 5669 5763 return NF_DROP; 5670 5764 5671 5765 if (selinux_secmark_enabled()) 5672 - if (avc_has_perm(&selinux_state, 5673 - sksec->sid, skb->secmark, 5766 + if (avc_has_perm(sksec->sid, skb->secmark, 5674 5767 SECCLASS_PACKET, PACKET__SEND, &ad)) 5675 5768 return NF_DROP_ERR(-ECONNREFUSED); 5676 5769 ··· 5794 5889 return NF_DROP; 5795 5890 5796 5891 if (secmark_active) 5797 - if (avc_has_perm(&selinux_state, 5798 - peer_sid, skb->secmark, 5892 + if (avc_has_perm(peer_sid, skb->secmark, 5799 5893 SECCLASS_PACKET, secmark_perm, &ad)) 5800 5894 return NF_DROP_ERR(-ECONNREFUSED); 5801 5895 ··· 5804 5900 5805 5901 if (sel_netif_sid(state->net, ifindex, &if_sid)) 5806 5902 return NF_DROP; 5807 - if (avc_has_perm(&selinux_state, 5808 - peer_sid, if_sid, 5903 + if (avc_has_perm(peer_sid, if_sid, 5809 5904 SECCLASS_NETIF, NETIF__EGRESS, &ad)) 5810 5905 return NF_DROP_ERR(-ECONNREFUSED); 5811 5906 5812 5907 if (sel_netnode_sid(addrp, family, &node_sid)) 5813 5908 return NF_DROP; 5814 - if (avc_has_perm(&selinux_state, 5815 - peer_sid, node_sid, 5909 + if (avc_has_perm(peer_sid, node_sid, 5816 5910 SECCLASS_NODE, NODE__SENDTO, &ad)) 5817 5911 return NF_DROP_ERR(-ECONNREFUSED); 5818 5912 } ··· 5855 5953 sk->sk_protocol, nlh->nlmsg_type, 5856 5954 secclass_map[sclass - 1].name, 5857 5955 task_pid_nr(current), current->comm); 5858 - if (enforcing_enabled(&selinux_state) && 5859 - !security_get_allow_unknown(&selinux_state)) 5956 + if (enforcing_enabled() && 5957 + !security_get_allow_unknown()) 5860 5958 return rc; 5861 5959 rc = 0; 5862 5960 } else if (rc == -ENOENT) { ··· 5895 5993 ad.type = LSM_AUDIT_DATA_IPC; 5896 5994 ad.u.ipc_id = ipc_perms->key; 5897 5995 5898 - return avc_has_perm(&selinux_state, 5899 - sid, isec->sid, isec->sclass, perms, &ad); 5996 + return avc_has_perm(sid, isec->sid, isec->sclass, perms, &ad); 5900 5997 } 5901 5998 5902 5999 static int selinux_msg_msg_alloc_security(struct msg_msg *msg) ··· 5921 6020 ad.type = LSM_AUDIT_DATA_IPC; 5922 6021 ad.u.ipc_id = msq->key; 5923 6022 5924 - return avc_has_perm(&selinux_state, 5925 - sid, isec->sid, SECCLASS_MSGQ, 6023 + return avc_has_perm(sid, isec->sid, SECCLASS_MSGQ, 5926 6024 MSGQ__CREATE, &ad); 5927 6025 } 5928 6026 ··· 5936 6036 ad.type = LSM_AUDIT_DATA_IPC; 5937 6037 ad.u.ipc_id = msq->key; 5938 6038 5939 - return avc_has_perm(&selinux_state, 5940 - sid, isec->sid, SECCLASS_MSGQ, 6039 + return avc_has_perm(sid, isec->sid, SECCLASS_MSGQ, 5941 6040 MSGQ__ASSOCIATE, &ad); 5942 6041 } 5943 6042 ··· 5949 6050 case IPC_INFO: 5950 6051 case MSG_INFO: 5951 6052 /* No specific object, just general system-wide information. */ 5952 - return avc_has_perm(&selinux_state, 5953 - current_sid(), SECINITSID_KERNEL, 6053 + return avc_has_perm(current_sid(), SECINITSID_KERNEL, 5954 6054 SECCLASS_SYSTEM, SYSTEM__IPC_INFO, NULL); 5955 6055 case IPC_STAT: 5956 6056 case MSG_STAT: ··· 5989 6091 * Compute new sid based on current process and 5990 6092 * message queue this message will be stored in 5991 6093 */ 5992 - rc = security_transition_sid(&selinux_state, sid, isec->sid, 6094 + rc = security_transition_sid(sid, isec->sid, 5993 6095 SECCLASS_MSG, NULL, &msec->sid); 5994 6096 if (rc) 5995 6097 return rc; ··· 5999 6101 ad.u.ipc_id = msq->key; 6000 6102 6001 6103 /* Can this process write to the queue? */ 6002 - rc = avc_has_perm(&selinux_state, 6003 - sid, isec->sid, SECCLASS_MSGQ, 6104 + rc = avc_has_perm(sid, isec->sid, SECCLASS_MSGQ, 6004 6105 MSGQ__WRITE, &ad); 6005 6106 if (!rc) 6006 6107 /* Can this process send the message */ 6007 - rc = avc_has_perm(&selinux_state, 6008 - sid, msec->sid, SECCLASS_MSG, 6108 + rc = avc_has_perm(sid, msec->sid, SECCLASS_MSG, 6009 6109 MSG__SEND, &ad); 6010 6110 if (!rc) 6011 6111 /* Can the message be put in the queue? */ 6012 - rc = avc_has_perm(&selinux_state, 6013 - msec->sid, isec->sid, SECCLASS_MSGQ, 6112 + rc = avc_has_perm(msec->sid, isec->sid, SECCLASS_MSGQ, 6014 6113 MSGQ__ENQUEUE, &ad); 6015 6114 6016 6115 return rc; ··· 6029 6134 ad.type = LSM_AUDIT_DATA_IPC; 6030 6135 ad.u.ipc_id = msq->key; 6031 6136 6032 - rc = avc_has_perm(&selinux_state, 6033 - sid, isec->sid, 6137 + rc = avc_has_perm(sid, isec->sid, 6034 6138 SECCLASS_MSGQ, MSGQ__READ, &ad); 6035 6139 if (!rc) 6036 - rc = avc_has_perm(&selinux_state, 6037 - sid, msec->sid, 6140 + rc = avc_has_perm(sid, msec->sid, 6038 6141 SECCLASS_MSG, MSG__RECEIVE, &ad); 6039 6142 return rc; 6040 6143 } ··· 6050 6157 ad.type = LSM_AUDIT_DATA_IPC; 6051 6158 ad.u.ipc_id = shp->key; 6052 6159 6053 - return avc_has_perm(&selinux_state, 6054 - sid, isec->sid, SECCLASS_SHM, 6160 + return avc_has_perm(sid, isec->sid, SECCLASS_SHM, 6055 6161 SHM__CREATE, &ad); 6056 6162 } 6057 6163 ··· 6065 6173 ad.type = LSM_AUDIT_DATA_IPC; 6066 6174 ad.u.ipc_id = shp->key; 6067 6175 6068 - return avc_has_perm(&selinux_state, 6069 - sid, isec->sid, SECCLASS_SHM, 6176 + return avc_has_perm(sid, isec->sid, SECCLASS_SHM, 6070 6177 SHM__ASSOCIATE, &ad); 6071 6178 } 6072 6179 ··· 6079 6188 case IPC_INFO: 6080 6189 case SHM_INFO: 6081 6190 /* No specific object, just general system-wide information. */ 6082 - return avc_has_perm(&selinux_state, 6083 - current_sid(), SECINITSID_KERNEL, 6191 + return avc_has_perm(current_sid(), SECINITSID_KERNEL, 6084 6192 SECCLASS_SYSTEM, SYSTEM__IPC_INFO, NULL); 6085 6193 case IPC_STAT: 6086 6194 case SHM_STAT: ··· 6130 6240 ad.type = LSM_AUDIT_DATA_IPC; 6131 6241 ad.u.ipc_id = sma->key; 6132 6242 6133 - return avc_has_perm(&selinux_state, 6134 - sid, isec->sid, SECCLASS_SEM, 6243 + return avc_has_perm(sid, isec->sid, SECCLASS_SEM, 6135 6244 SEM__CREATE, &ad); 6136 6245 } 6137 6246 ··· 6145 6256 ad.type = LSM_AUDIT_DATA_IPC; 6146 6257 ad.u.ipc_id = sma->key; 6147 6258 6148 - return avc_has_perm(&selinux_state, 6149 - sid, isec->sid, SECCLASS_SEM, 6259 + return avc_has_perm(sid, isec->sid, SECCLASS_SEM, 6150 6260 SEM__ASSOCIATE, &ad); 6151 6261 } 6152 6262 ··· 6159 6271 case IPC_INFO: 6160 6272 case SEM_INFO: 6161 6273 /* No specific object, just general system-wide information. */ 6162 - return avc_has_perm(&selinux_state, 6163 - current_sid(), SECINITSID_KERNEL, 6274 + return avc_has_perm(current_sid(), SECINITSID_KERNEL, 6164 6275 SECCLASS_SYSTEM, SYSTEM__IPC_INFO, NULL); 6165 6276 case GETPID: 6166 6277 case GETNCNT: ··· 6246 6359 __tsec = selinux_cred(__task_cred(p)); 6247 6360 6248 6361 if (current != p) { 6249 - error = avc_has_perm(&selinux_state, 6250 - current_sid(), __tsec->sid, 6362 + error = avc_has_perm(current_sid(), __tsec->sid, 6251 6363 SECCLASS_PROCESS, PROCESS__GETATTR, NULL); 6252 6364 if (error) 6253 6365 goto bad; ··· 6273 6387 if (!sid) 6274 6388 return 0; 6275 6389 6276 - error = security_sid_to_context(&selinux_state, sid, value, &len); 6390 + error = security_sid_to_context(sid, value, &len); 6277 6391 if (error) 6278 6392 return error; 6279 6393 return len; ··· 6295 6409 * Basic control over ability to set these attributes at all. 6296 6410 */ 6297 6411 if (!strcmp(name, "exec")) 6298 - error = avc_has_perm(&selinux_state, 6299 - mysid, mysid, SECCLASS_PROCESS, 6412 + error = avc_has_perm(mysid, mysid, SECCLASS_PROCESS, 6300 6413 PROCESS__SETEXEC, NULL); 6301 6414 else if (!strcmp(name, "fscreate")) 6302 - error = avc_has_perm(&selinux_state, 6303 - mysid, mysid, SECCLASS_PROCESS, 6415 + error = avc_has_perm(mysid, mysid, SECCLASS_PROCESS, 6304 6416 PROCESS__SETFSCREATE, NULL); 6305 6417 else if (!strcmp(name, "keycreate")) 6306 - error = avc_has_perm(&selinux_state, 6307 - mysid, mysid, SECCLASS_PROCESS, 6418 + error = avc_has_perm(mysid, mysid, SECCLASS_PROCESS, 6308 6419 PROCESS__SETKEYCREATE, NULL); 6309 6420 else if (!strcmp(name, "sockcreate")) 6310 - error = avc_has_perm(&selinux_state, 6311 - mysid, mysid, SECCLASS_PROCESS, 6421 + error = avc_has_perm(mysid, mysid, SECCLASS_PROCESS, 6312 6422 PROCESS__SETSOCKCREATE, NULL); 6313 6423 else if (!strcmp(name, "current")) 6314 - error = avc_has_perm(&selinux_state, 6315 - mysid, mysid, SECCLASS_PROCESS, 6424 + error = avc_has_perm(mysid, mysid, SECCLASS_PROCESS, 6316 6425 PROCESS__SETCURRENT, NULL); 6317 6426 else 6318 6427 error = -EINVAL; ··· 6320 6439 str[size-1] = 0; 6321 6440 size--; 6322 6441 } 6323 - error = security_context_to_sid(&selinux_state, value, size, 6442 + error = security_context_to_sid(value, size, 6324 6443 &sid, GFP_KERNEL); 6325 6444 if (error == -EINVAL && !strcmp(name, "fscreate")) { 6326 6445 if (!has_cap_mac_admin(true)) { ··· 6344 6463 6345 6464 return error; 6346 6465 } 6347 - error = security_context_to_sid_force( 6348 - &selinux_state, 6349 - value, size, &sid); 6466 + error = security_context_to_sid_force(value, size, 6467 + &sid); 6350 6468 } 6351 6469 if (error) 6352 6470 return error; ··· 6368 6488 tsec->create_sid = sid; 6369 6489 } else if (!strcmp(name, "keycreate")) { 6370 6490 if (sid) { 6371 - error = avc_has_perm(&selinux_state, mysid, sid, 6491 + error = avc_has_perm(mysid, sid, 6372 6492 SECCLASS_KEY, KEY__CREATE, NULL); 6373 6493 if (error) 6374 6494 goto abort_change; ··· 6383 6503 6384 6504 /* Only allow single threaded processes to change context */ 6385 6505 if (!current_is_single_threaded()) { 6386 - error = security_bounded_transition(&selinux_state, 6387 - tsec->sid, sid); 6506 + error = security_bounded_transition(tsec->sid, sid); 6388 6507 if (error) 6389 6508 goto abort_change; 6390 6509 } 6391 6510 6392 6511 /* Check permissions for the transition. */ 6393 - error = avc_has_perm(&selinux_state, 6394 - tsec->sid, sid, SECCLASS_PROCESS, 6512 + error = avc_has_perm(tsec->sid, sid, SECCLASS_PROCESS, 6395 6513 PROCESS__DYNTRANSITION, NULL); 6396 6514 if (error) 6397 6515 goto abort_change; ··· 6398 6520 Otherwise, leave SID unchanged and fail. */ 6399 6521 ptsid = ptrace_parent_sid(); 6400 6522 if (ptsid != 0) { 6401 - error = avc_has_perm(&selinux_state, 6402 - ptsid, sid, SECCLASS_PROCESS, 6523 + error = avc_has_perm(ptsid, sid, SECCLASS_PROCESS, 6403 6524 PROCESS__PTRACE, NULL); 6404 6525 if (error) 6405 6526 goto abort_change; ··· 6425 6548 6426 6549 static int selinux_secid_to_secctx(u32 secid, char **secdata, u32 *seclen) 6427 6550 { 6428 - return security_sid_to_context(&selinux_state, secid, 6551 + return security_sid_to_context(secid, 6429 6552 secdata, seclen); 6430 6553 } 6431 6554 6432 6555 static int selinux_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid) 6433 6556 { 6434 - return security_context_to_sid(&selinux_state, secdata, seclen, 6557 + return security_context_to_sid(secdata, seclen, 6435 6558 secid, GFP_KERNEL); 6436 6559 } 6437 6560 ··· 6551 6674 key = key_ref_to_ptr(key_ref); 6552 6675 ksec = key->security; 6553 6676 6554 - return avc_has_perm(&selinux_state, 6555 - sid, ksec->sid, SECCLASS_KEY, perm, NULL); 6677 + return avc_has_perm(sid, ksec->sid, SECCLASS_KEY, perm, NULL); 6556 6678 } 6557 6679 6558 6680 static int selinux_key_getsecurity(struct key *key, char **_buffer) ··· 6561 6685 unsigned len; 6562 6686 int rc; 6563 6687 6564 - rc = security_sid_to_context(&selinux_state, ksec->sid, 6688 + rc = security_sid_to_context(ksec->sid, 6565 6689 &context, &len); 6566 6690 if (!rc) 6567 6691 rc = len; ··· 6575 6699 struct key_security_struct *ksec = key->security; 6576 6700 u32 sid = current_sid(); 6577 6701 6578 - return avc_has_perm(&selinux_state, 6579 - sid, ksec->sid, SECCLASS_KEY, KEY__VIEW, NULL); 6702 + return avc_has_perm(sid, ksec->sid, SECCLASS_KEY, KEY__VIEW, NULL); 6580 6703 } 6581 6704 #endif 6582 6705 #endif ··· 6597 6722 ibpkey.subnet_prefix = subnet_prefix; 6598 6723 ibpkey.pkey = pkey_val; 6599 6724 ad.u.ibpkey = &ibpkey; 6600 - return avc_has_perm(&selinux_state, 6601 - sec->sid, sid, 6725 + return avc_has_perm(sec->sid, sid, 6602 6726 SECCLASS_INFINIBAND_PKEY, 6603 6727 INFINIBAND_PKEY__ACCESS, &ad); 6604 6728 } ··· 6611 6737 struct ib_security_struct *sec = ib_sec; 6612 6738 struct lsm_ibendport_audit ibendport; 6613 6739 6614 - err = security_ib_endport_sid(&selinux_state, dev_name, port_num, 6740 + err = security_ib_endport_sid(dev_name, port_num, 6615 6741 &sid); 6616 6742 6617 6743 if (err) ··· 6621 6747 ibendport.dev_name = dev_name; 6622 6748 ibendport.port = port_num; 6623 6749 ad.u.ibendport = &ibendport; 6624 - return avc_has_perm(&selinux_state, 6625 - sec->sid, sid, 6750 + return avc_has_perm(sec->sid, sid, 6626 6751 SECCLASS_INFINIBAND_ENDPORT, 6627 6752 INFINIBAND_ENDPORT__MANAGE_SUBNET, &ad); 6628 6753 } ··· 6654 6781 6655 6782 switch (cmd) { 6656 6783 case BPF_MAP_CREATE: 6657 - ret = avc_has_perm(&selinux_state, 6658 - sid, sid, SECCLASS_BPF, BPF__MAP_CREATE, 6784 + ret = avc_has_perm(sid, sid, SECCLASS_BPF, BPF__MAP_CREATE, 6659 6785 NULL); 6660 6786 break; 6661 6787 case BPF_PROG_LOAD: 6662 - ret = avc_has_perm(&selinux_state, 6663 - sid, sid, SECCLASS_BPF, BPF__PROG_LOAD, 6788 + ret = avc_has_perm(sid, sid, SECCLASS_BPF, BPF__PROG_LOAD, 6664 6789 NULL); 6665 6790 break; 6666 6791 default: ··· 6698 6827 if (file->f_op == &bpf_map_fops) { 6699 6828 map = file->private_data; 6700 6829 bpfsec = map->security; 6701 - ret = avc_has_perm(&selinux_state, 6702 - sid, bpfsec->sid, SECCLASS_BPF, 6830 + ret = avc_has_perm(sid, bpfsec->sid, SECCLASS_BPF, 6703 6831 bpf_map_fmode_to_av(file->f_mode), NULL); 6704 6832 if (ret) 6705 6833 return ret; 6706 6834 } else if (file->f_op == &bpf_prog_fops) { 6707 6835 prog = file->private_data; 6708 6836 bpfsec = prog->aux->security; 6709 - ret = avc_has_perm(&selinux_state, 6710 - sid, bpfsec->sid, SECCLASS_BPF, 6837 + ret = avc_has_perm(sid, bpfsec->sid, SECCLASS_BPF, 6711 6838 BPF__PROG_RUN, NULL); 6712 6839 if (ret) 6713 6840 return ret; ··· 6719 6850 struct bpf_security_struct *bpfsec; 6720 6851 6721 6852 bpfsec = map->security; 6722 - return avc_has_perm(&selinux_state, 6723 - sid, bpfsec->sid, SECCLASS_BPF, 6853 + return avc_has_perm(sid, bpfsec->sid, SECCLASS_BPF, 6724 6854 bpf_map_fmode_to_av(fmode), NULL); 6725 6855 } 6726 6856 ··· 6729 6861 struct bpf_security_struct *bpfsec; 6730 6862 6731 6863 bpfsec = prog->aux->security; 6732 - return avc_has_perm(&selinux_state, 6733 - sid, bpfsec->sid, SECCLASS_BPF, 6864 + return avc_has_perm(sid, bpfsec->sid, SECCLASS_BPF, 6734 6865 BPF__PROG_RUN, NULL); 6735 6866 } 6736 6867 ··· 6803 6936 else 6804 6937 return -EINVAL; 6805 6938 6806 - return avc_has_perm(&selinux_state, sid, sid, SECCLASS_PERF_EVENT, 6939 + return avc_has_perm(sid, sid, SECCLASS_PERF_EVENT, 6807 6940 requested, NULL); 6808 6941 } 6809 6942 ··· 6834 6967 struct perf_event_security_struct *perfsec = event->security; 6835 6968 u32 sid = current_sid(); 6836 6969 6837 - return avc_has_perm(&selinux_state, sid, perfsec->sid, 6970 + return avc_has_perm(sid, perfsec->sid, 6838 6971 SECCLASS_PERF_EVENT, PERF_EVENT__READ, NULL); 6839 6972 } 6840 6973 ··· 6843 6976 struct perf_event_security_struct *perfsec = event->security; 6844 6977 u32 sid = current_sid(); 6845 6978 6846 - return avc_has_perm(&selinux_state, sid, perfsec->sid, 6979 + return avc_has_perm(sid, perfsec->sid, 6847 6980 SECCLASS_PERF_EVENT, PERF_EVENT__WRITE, NULL); 6848 6981 } 6849 6982 #endif ··· 6858 6991 */ 6859 6992 static int selinux_uring_override_creds(const struct cred *new) 6860 6993 { 6861 - return avc_has_perm(&selinux_state, current_sid(), cred_sid(new), 6994 + return avc_has_perm(current_sid(), cred_sid(new), 6862 6995 SECCLASS_IO_URING, IO_URING__OVERRIDE_CREDS, NULL); 6863 6996 } 6864 6997 ··· 6872 7005 { 6873 7006 int sid = current_sid(); 6874 7007 6875 - return avc_has_perm(&selinux_state, sid, sid, 7008 + return avc_has_perm(sid, sid, 6876 7009 SECCLASS_IO_URING, IO_URING__SQPOLL, NULL); 6877 7010 } 6878 7011 ··· 6894 7027 ad.type = LSM_AUDIT_DATA_FILE; 6895 7028 ad.u.file = file; 6896 7029 6897 - return avc_has_perm(&selinux_state, current_sid(), isec->sid, 7030 + return avc_has_perm(current_sid(), isec->sid, 6898 7031 SECCLASS_IO_URING, IO_URING__CMD, &ad); 6899 7032 } 6900 7033 #endif /* CONFIG_IO_URING */ ··· 7201 7334 pr_info("SELinux: Initializing.\n"); 7202 7335 7203 7336 memset(&selinux_state, 0, sizeof(selinux_state)); 7204 - enforcing_set(&selinux_state, selinux_enforcing_boot); 7337 + enforcing_set(selinux_enforcing_boot); 7205 7338 if (CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE) 7206 7339 pr_err("SELinux: CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE is non-zero. This is deprecated and will be rejected in a future kernel release.\n"); 7207 - checkreqprot_set(&selinux_state, selinux_checkreqprot_boot); 7208 - selinux_avc_init(&selinux_state.avc); 7340 + checkreqprot_set(selinux_checkreqprot_boot); 7341 + selinux_avc_init(); 7209 7342 mutex_init(&selinux_state.status_lock); 7210 7343 mutex_init(&selinux_state.policy_mutex); 7211 7344 ··· 7359 7492 #endif /* CONFIG_NETFILTER */ 7360 7493 7361 7494 #ifdef CONFIG_SECURITY_SELINUX_DISABLE 7362 - int selinux_disable(struct selinux_state *state) 7495 + int selinux_disable(void) 7363 7496 { 7364 - if (selinux_initialized(state)) { 7497 + if (selinux_initialized()) { 7365 7498 /* Not permitted after initial policy load. */ 7366 7499 return -EINVAL; 7367 7500 } 7368 7501 7369 - if (selinux_disabled(state)) { 7502 + if (selinux_disabled()) { 7370 7503 /* Only do this once. */ 7371 7504 return -EINVAL; 7372 7505 } 7373 7506 7374 - selinux_mark_disabled(state); 7507 + selinux_mark_disabled(); 7375 7508 7376 7509 pr_info("SELinux: Disabled at runtime.\n"); 7377 7510
+1 -1
security/selinux/ibpkey.c
··· 141 141 return 0; 142 142 } 143 143 144 - ret = security_ib_pkey_sid(&selinux_state, subnet_prefix, pkey_num, 144 + ret = security_ib_pkey_sid(subnet_prefix, pkey_num, 145 145 sid); 146 146 if (ret) 147 147 goto out;
+16 -21
security/selinux/ima.c
··· 15 15 /* 16 16 * selinux_ima_collect_state - Read selinux configuration settings 17 17 * 18 - * @state: selinux_state 19 - * 20 18 * On success returns the configuration settings string. 21 19 * On error, returns NULL. 22 20 */ 23 - static char *selinux_ima_collect_state(struct selinux_state *state) 21 + static char *selinux_ima_collect_state(void) 24 22 { 25 23 const char *on = "=1;", *off = "=0;"; 26 24 char *buf; ··· 37 39 rc = strscpy(buf, "initialized", buf_len); 38 40 WARN_ON(rc < 0); 39 41 40 - rc = strlcat(buf, selinux_initialized(state) ? on : off, buf_len); 42 + rc = strlcat(buf, selinux_initialized() ? on : off, buf_len); 41 43 WARN_ON(rc >= buf_len); 42 44 43 45 rc = strlcat(buf, "enforcing", buf_len); 44 46 WARN_ON(rc >= buf_len); 45 47 46 - rc = strlcat(buf, enforcing_enabled(state) ? on : off, buf_len); 48 + rc = strlcat(buf, enforcing_enabled() ? on : off, buf_len); 47 49 WARN_ON(rc >= buf_len); 48 50 49 51 rc = strlcat(buf, "checkreqprot", buf_len); 50 52 WARN_ON(rc >= buf_len); 51 53 52 - rc = strlcat(buf, checkreqprot_get(state) ? on : off, buf_len); 54 + rc = strlcat(buf, checkreqprot_get() ? on : off, buf_len); 53 55 WARN_ON(rc >= buf_len); 54 56 55 57 for (i = 0; i < __POLICYDB_CAP_MAX; i++) { 56 58 rc = strlcat(buf, selinux_policycap_names[i], buf_len); 57 59 WARN_ON(rc >= buf_len); 58 60 59 - rc = strlcat(buf, state->policycap[i] ? on : off, buf_len); 61 + rc = strlcat(buf, selinux_state.policycap[i] ? on : off, 62 + buf_len); 60 63 WARN_ON(rc >= buf_len); 61 64 } 62 65 ··· 66 67 67 68 /* 68 69 * selinux_ima_measure_state_locked - Measure SELinux state and hash of policy 69 - * 70 - * @state: selinux state struct 71 70 */ 72 - void selinux_ima_measure_state_locked(struct selinux_state *state) 71 + void selinux_ima_measure_state_locked(void) 73 72 { 74 73 char *state_str = NULL; 75 74 void *policy = NULL; 76 75 size_t policy_len; 77 76 int rc = 0; 78 77 79 - lockdep_assert_held(&state->policy_mutex); 78 + lockdep_assert_held(&selinux_state.policy_mutex); 80 79 81 - state_str = selinux_ima_collect_state(state); 80 + state_str = selinux_ima_collect_state(); 82 81 if (!state_str) { 83 82 pr_err("SELinux: %s: failed to read state.\n", __func__); 84 83 return; ··· 91 94 /* 92 95 * Measure SELinux policy only after initialization is completed. 93 96 */ 94 - if (!selinux_initialized(state)) 97 + if (!selinux_initialized()) 95 98 return; 96 99 97 - rc = security_read_state_kernel(state, &policy, &policy_len); 100 + rc = security_read_state_kernel(&policy, &policy_len); 98 101 if (rc) { 99 102 pr_err("SELinux: %s: failed to read policy %d.\n", __func__, rc); 100 103 return; ··· 109 112 110 113 /* 111 114 * selinux_ima_measure_state - Measure SELinux state and hash of policy 112 - * 113 - * @state: selinux state struct 114 115 */ 115 - void selinux_ima_measure_state(struct selinux_state *state) 116 + void selinux_ima_measure_state(void) 116 117 { 117 - lockdep_assert_not_held(&state->policy_mutex); 118 + lockdep_assert_not_held(&selinux_state.policy_mutex); 118 119 119 - mutex_lock(&state->policy_mutex); 120 - selinux_ima_measure_state_locked(state); 121 - mutex_unlock(&state->policy_mutex); 120 + mutex_lock(&selinux_state.policy_mutex); 121 + selinux_ima_measure_state_locked(); 122 + mutex_unlock(&selinux_state.policy_mutex); 122 123 }
+10 -19
security/selinux/include/avc.h
··· 52 52 u32 audited; 53 53 u32 denied; 54 54 int result; 55 - struct selinux_state *state; 56 55 } __randomize_layout; 57 56 58 57 /* ··· 96 97 return audited; 97 98 } 98 99 99 - int slow_avc_audit(struct selinux_state *state, 100 - u32 ssid, u32 tsid, u16 tclass, 100 + int slow_avc_audit(u32 ssid, u32 tsid, u16 tclass, 101 101 u32 requested, u32 audited, u32 denied, int result, 102 102 struct common_audit_data *a); 103 103 104 104 /** 105 105 * avc_audit - Audit the granting or denial of permissions. 106 - * @state: SELinux state 107 106 * @ssid: source security identifier 108 107 * @tsid: target security identifier 109 108 * @tclass: target security class ··· 119 122 * be performed under a lock, to allow the lock to be released 120 123 * before calling the auditing code. 121 124 */ 122 - static inline int avc_audit(struct selinux_state *state, 123 - u32 ssid, u32 tsid, 125 + static inline int avc_audit(u32 ssid, u32 tsid, 124 126 u16 tclass, u32 requested, 125 127 struct av_decision *avd, 126 128 int result, ··· 129 133 audited = avc_audit_required(requested, avd, result, 0, &denied); 130 134 if (likely(!audited)) 131 135 return 0; 132 - return slow_avc_audit(state, ssid, tsid, tclass, 136 + return slow_avc_audit(ssid, tsid, tclass, 133 137 requested, audited, denied, result, 134 138 a); 135 139 } 136 140 137 141 #define AVC_STRICT 1 /* Ignore permissive mode. */ 138 142 #define AVC_EXTENDED_PERMS 2 /* update extended permissions */ 139 - int avc_has_perm_noaudit(struct selinux_state *state, 140 - u32 ssid, u32 tsid, 143 + int avc_has_perm_noaudit(u32 ssid, u32 tsid, 141 144 u16 tclass, u32 requested, 142 145 unsigned flags, 143 146 struct av_decision *avd); 144 147 145 - int avc_has_perm(struct selinux_state *state, 146 - u32 ssid, u32 tsid, 148 + int avc_has_perm(u32 ssid, u32 tsid, 147 149 u16 tclass, u32 requested, 148 150 struct common_audit_data *auditdata); 149 151 150 - int avc_has_extended_perms(struct selinux_state *state, 151 - u32 ssid, u32 tsid, u16 tclass, u32 requested, 152 + int avc_has_extended_perms(u32 ssid, u32 tsid, u16 tclass, u32 requested, 152 153 u8 driver, u8 perm, struct common_audit_data *ad); 153 154 154 155 155 - u32 avc_policy_seqno(struct selinux_state *state); 156 + u32 avc_policy_seqno(void); 156 157 157 158 #define AVC_CALLBACK_GRANT 1 158 159 #define AVC_CALLBACK_TRY_REVOKE 2 ··· 164 171 int avc_add_callback(int (*callback)(u32 event), u32 events); 165 172 166 173 /* Exported to selinuxfs */ 167 - struct selinux_avc; 168 - int avc_get_hash_stats(struct selinux_avc *avc, char *page); 169 - unsigned int avc_get_cache_threshold(struct selinux_avc *avc); 170 - void avc_set_cache_threshold(struct selinux_avc *avc, 171 - unsigned int cache_threshold); 174 + int avc_get_hash_stats(char *page); 175 + unsigned int avc_get_cache_threshold(void); 176 + void avc_set_cache_threshold(unsigned int cache_threshold); 172 177 173 178 /* Attempt to free avc node cache */ 174 179 void avc_disable(void);
+1 -2
security/selinux/include/avc_ss.h
··· 9 9 10 10 #include <linux/types.h> 11 11 12 - struct selinux_avc; 13 - int avc_ss_reset(struct selinux_avc *avc, u32 seqno); 12 + int avc_ss_reset(u32 seqno); 14 13 15 14 /* Class/perm mapping support */ 16 15 struct security_class_mapping {
+2 -2
security/selinux/include/conditional.h
··· 16 16 int security_get_bools(struct selinux_policy *policy, 17 17 u32 *len, char ***names, int **values); 18 18 19 - int security_set_bools(struct selinux_state *state, u32 len, int *values); 19 + int security_set_bools(u32 len, int *values); 20 20 21 - int security_get_bool_value(struct selinux_state *state, u32 index); 21 + int security_get_bool_value(u32 index); 22 22 23 23 #endif
+4 -6
security/selinux/include/ima.h
··· 14 14 #include "security.h" 15 15 16 16 #ifdef CONFIG_IMA 17 - extern void selinux_ima_measure_state(struct selinux_state *selinux_state); 18 - extern void selinux_ima_measure_state_locked( 19 - struct selinux_state *selinux_state); 17 + extern void selinux_ima_measure_state(void); 18 + extern void selinux_ima_measure_state_locked(void); 20 19 #else 21 - static inline void selinux_ima_measure_state(struct selinux_state *selinux_state) 20 + static inline void selinux_ima_measure_state(void) 22 21 { 23 22 } 24 - static inline void selinux_ima_measure_state_locked( 25 - struct selinux_state *selinux_state) 23 + static inline void selinux_ima_measure_state_locked(void) 26 24 { 27 25 } 28 26 #endif
+65 -106
security/selinux/include/security.h
··· 86 86 /* limitation of boundary depth */ 87 87 #define POLICYDB_BOUNDS_MAXDEPTH 4 88 88 89 - struct selinux_avc; 90 89 struct selinux_policy; 91 90 92 91 struct selinux_state { ··· 102 103 struct page *status_page; 103 104 struct mutex status_lock; 104 105 105 - struct selinux_avc *avc; 106 106 struct selinux_policy __rcu *policy; 107 107 struct mutex policy_mutex; 108 108 } __randomize_layout; 109 109 110 - void selinux_avc_init(struct selinux_avc **avc); 110 + void selinux_avc_init(void); 111 111 112 112 extern struct selinux_state selinux_state; 113 113 114 - static inline bool selinux_initialized(const struct selinux_state *state) 114 + static inline bool selinux_initialized(void) 115 115 { 116 116 /* do a synchronized load to avoid race conditions */ 117 - return smp_load_acquire(&state->initialized); 117 + return smp_load_acquire(&selinux_state.initialized); 118 118 } 119 119 120 - static inline void selinux_mark_initialized(struct selinux_state *state) 120 + static inline void selinux_mark_initialized(void) 121 121 { 122 122 /* do a synchronized write to avoid race conditions */ 123 - smp_store_release(&state->initialized, true); 123 + smp_store_release(&selinux_state.initialized, true); 124 124 } 125 125 126 126 #ifdef CONFIG_SECURITY_SELINUX_DEVELOP 127 - static inline bool enforcing_enabled(struct selinux_state *state) 127 + static inline bool enforcing_enabled(void) 128 128 { 129 - return READ_ONCE(state->enforcing); 129 + return READ_ONCE(selinux_state.enforcing); 130 130 } 131 131 132 - static inline void enforcing_set(struct selinux_state *state, bool value) 132 + static inline void enforcing_set(bool value) 133 133 { 134 - WRITE_ONCE(state->enforcing, value); 134 + WRITE_ONCE(selinux_state.enforcing, value); 135 135 } 136 136 #else 137 - static inline bool enforcing_enabled(struct selinux_state *state) 137 + static inline bool enforcing_enabled(void) 138 138 { 139 139 return true; 140 140 } 141 141 142 - static inline void enforcing_set(struct selinux_state *state, bool value) 142 + static inline void enforcing_set(bool value) 143 143 { 144 144 } 145 145 #endif 146 146 147 - static inline bool checkreqprot_get(const struct selinux_state *state) 147 + static inline bool checkreqprot_get(void) 148 148 { 149 - return READ_ONCE(state->checkreqprot); 149 + return READ_ONCE(selinux_state.checkreqprot); 150 150 } 151 151 152 - static inline void checkreqprot_set(struct selinux_state *state, bool value) 152 + static inline void checkreqprot_set(bool value) 153 153 { 154 154 if (value) 155 155 pr_err("SELinux: https://github.com/SELinuxProject/selinux-kernel/wiki/DEPRECATE-checkreqprot\n"); 156 - WRITE_ONCE(state->checkreqprot, value); 156 + WRITE_ONCE(selinux_state.checkreqprot, value); 157 157 } 158 158 159 159 #ifdef CONFIG_SECURITY_SELINUX_DISABLE 160 - static inline bool selinux_disabled(struct selinux_state *state) 160 + static inline bool selinux_disabled(void) 161 161 { 162 - return READ_ONCE(state->disabled); 162 + return READ_ONCE(selinux_state.disabled); 163 163 } 164 164 165 - static inline void selinux_mark_disabled(struct selinux_state *state) 165 + static inline void selinux_mark_disabled(void) 166 166 { 167 - WRITE_ONCE(state->disabled, true); 167 + WRITE_ONCE(selinux_state.disabled, true); 168 168 } 169 169 #else 170 - static inline bool selinux_disabled(struct selinux_state *state) 170 + static inline bool selinux_disabled(void) 171 171 { 172 172 return false; 173 173 } ··· 235 237 struct selinux_policy_convert_data *convert_data; 236 238 }; 237 239 238 - int security_mls_enabled(struct selinux_state *state); 239 - int security_load_policy(struct selinux_state *state, 240 - void *data, size_t len, 240 + int security_mls_enabled(void); 241 + int security_load_policy(void *data, size_t len, 241 242 struct selinux_load_state *load_state); 242 - void selinux_policy_commit(struct selinux_state *state, 243 - struct selinux_load_state *load_state); 244 - void selinux_policy_cancel(struct selinux_state *state, 245 - struct selinux_load_state *load_state); 246 - int security_read_policy(struct selinux_state *state, 247 - void **data, size_t *len); 248 - int security_read_state_kernel(struct selinux_state *state, 249 - void **data, size_t *len); 250 - int security_policycap_supported(struct selinux_state *state, 251 - unsigned int req_cap); 243 + void selinux_policy_commit(struct selinux_load_state *load_state); 244 + void selinux_policy_cancel(struct selinux_load_state *load_state); 245 + int security_read_policy(void **data, size_t *len); 246 + int security_read_state_kernel(void **data, size_t *len); 247 + int security_policycap_supported(unsigned int req_cap); 252 248 253 249 #define SEL_VEC_MAX 32 254 250 struct av_decision { ··· 279 287 /* definitions of av_decision.flags */ 280 288 #define AVD_FLAGS_PERMISSIVE 0x0001 281 289 282 - void security_compute_av(struct selinux_state *state, 283 - u32 ssid, u32 tsid, 290 + void security_compute_av(u32 ssid, u32 tsid, 284 291 u16 tclass, struct av_decision *avd, 285 292 struct extended_perms *xperms); 286 293 287 - void security_compute_xperms_decision(struct selinux_state *state, 288 - u32 ssid, u32 tsid, u16 tclass, 294 + void security_compute_xperms_decision(u32 ssid, u32 tsid, u16 tclass, 289 295 u8 driver, 290 296 struct extended_perms_decision *xpermd); 291 297 292 - void security_compute_av_user(struct selinux_state *state, 293 - u32 ssid, u32 tsid, 298 + void security_compute_av_user(u32 ssid, u32 tsid, 294 299 u16 tclass, struct av_decision *avd); 295 300 296 - int security_transition_sid(struct selinux_state *state, 297 - u32 ssid, u32 tsid, u16 tclass, 301 + int security_transition_sid(u32 ssid, u32 tsid, u16 tclass, 298 302 const struct qstr *qstr, u32 *out_sid); 299 303 300 - int security_transition_sid_user(struct selinux_state *state, 301 - u32 ssid, u32 tsid, u16 tclass, 304 + int security_transition_sid_user(u32 ssid, u32 tsid, u16 tclass, 302 305 const char *objname, u32 *out_sid); 303 306 304 - int security_member_sid(struct selinux_state *state, u32 ssid, u32 tsid, 305 - u16 tclass, u32 *out_sid); 307 + int security_member_sid(u32 ssid, u32 tsid, u16 tclass, u32 *out_sid); 306 308 307 - int security_change_sid(struct selinux_state *state, u32 ssid, u32 tsid, 308 - u16 tclass, u32 *out_sid); 309 + int security_change_sid(u32 ssid, u32 tsid, u16 tclass, u32 *out_sid); 309 310 310 - int security_sid_to_context(struct selinux_state *state, u32 sid, 311 - char **scontext, u32 *scontext_len); 311 + int security_sid_to_context(u32 sid, char **scontext, u32 *scontext_len); 312 312 313 - int security_sid_to_context_force(struct selinux_state *state, 314 - u32 sid, char **scontext, u32 *scontext_len); 313 + int security_sid_to_context_force(u32 sid, char **scontext, u32 *scontext_len); 315 314 316 - int security_sid_to_context_inval(struct selinux_state *state, 317 - u32 sid, char **scontext, u32 *scontext_len); 315 + int security_sid_to_context_inval(u32 sid, char **scontext, u32 *scontext_len); 318 316 319 - int security_context_to_sid(struct selinux_state *state, 320 - const char *scontext, u32 scontext_len, 317 + int security_context_to_sid(const char *scontext, u32 scontext_len, 321 318 u32 *out_sid, gfp_t gfp); 322 319 323 - int security_context_str_to_sid(struct selinux_state *state, 324 - const char *scontext, u32 *out_sid, gfp_t gfp); 320 + int security_context_str_to_sid(const char *scontext, u32 *out_sid, gfp_t gfp); 325 321 326 - int security_context_to_sid_default(struct selinux_state *state, 327 - const char *scontext, u32 scontext_len, 322 + int security_context_to_sid_default(const char *scontext, u32 scontext_len, 328 323 u32 *out_sid, u32 def_sid, gfp_t gfp_flags); 329 324 330 - int security_context_to_sid_force(struct selinux_state *state, 331 - const char *scontext, u32 scontext_len, 325 + int security_context_to_sid_force(const char *scontext, u32 scontext_len, 332 326 u32 *sid); 333 327 334 - int security_get_user_sids(struct selinux_state *state, 335 - u32 callsid, char *username, 336 - u32 **sids, u32 *nel); 328 + int security_get_user_sids(u32 callsid, char *username, u32 **sids, u32 *nel); 337 329 338 - int security_port_sid(struct selinux_state *state, 339 - u8 protocol, u16 port, u32 *out_sid); 330 + int security_port_sid(u8 protocol, u16 port, u32 *out_sid); 340 331 341 - int security_ib_pkey_sid(struct selinux_state *state, 342 - u64 subnet_prefix, u16 pkey_num, u32 *out_sid); 332 + int security_ib_pkey_sid(u64 subnet_prefix, u16 pkey_num, u32 *out_sid); 343 333 344 - int security_ib_endport_sid(struct selinux_state *state, 345 - const char *dev_name, u8 port_num, u32 *out_sid); 334 + int security_ib_endport_sid(const char *dev_name, u8 port_num, u32 *out_sid); 346 335 347 - int security_netif_sid(struct selinux_state *state, 348 - char *name, u32 *if_sid); 336 + int security_netif_sid(char *name, u32 *if_sid); 349 337 350 - int security_node_sid(struct selinux_state *state, 351 - u16 domain, void *addr, u32 addrlen, 338 + int security_node_sid(u16 domain, void *addr, u32 addrlen, 352 339 u32 *out_sid); 353 340 354 - int security_validate_transition(struct selinux_state *state, 355 - u32 oldsid, u32 newsid, u32 tasksid, 341 + int security_validate_transition(u32 oldsid, u32 newsid, u32 tasksid, 356 342 u16 tclass); 357 343 358 - int security_validate_transition_user(struct selinux_state *state, 359 - u32 oldsid, u32 newsid, u32 tasksid, 344 + int security_validate_transition_user(u32 oldsid, u32 newsid, u32 tasksid, 360 345 u16 tclass); 361 346 362 - int security_bounded_transition(struct selinux_state *state, 363 - u32 oldsid, u32 newsid); 347 + int security_bounded_transition(u32 oldsid, u32 newsid); 364 348 365 - int security_sid_mls_copy(struct selinux_state *state, 366 - u32 sid, u32 mls_sid, u32 *new_sid); 349 + int security_sid_mls_copy(u32 sid, u32 mls_sid, u32 *new_sid); 367 350 368 - int security_net_peersid_resolve(struct selinux_state *state, 369 - u32 nlbl_sid, u32 nlbl_type, 351 + int security_net_peersid_resolve(u32 nlbl_sid, u32 nlbl_type, 370 352 u32 xfrm_sid, 371 353 u32 *peer_sid); 372 354 ··· 348 382 char ***classes, int *nclasses); 349 383 int security_get_permissions(struct selinux_policy *policy, 350 384 char *class, char ***perms, int *nperms); 351 - int security_get_reject_unknown(struct selinux_state *state); 352 - int security_get_allow_unknown(struct selinux_state *state); 385 + int security_get_reject_unknown(void); 386 + int security_get_allow_unknown(void); 353 387 354 388 #define SECURITY_FS_USE_XATTR 1 /* use xattr */ 355 389 #define SECURITY_FS_USE_TRANS 2 /* use transition SIDs, e.g. devpts/tmpfs */ ··· 360 394 #define SECURITY_FS_USE_NATIVE 7 /* use native label support */ 361 395 #define SECURITY_FS_USE_MAX 7 /* Highest SECURITY_FS_USE_XXX */ 362 396 363 - int security_fs_use(struct selinux_state *state, struct super_block *sb); 397 + int security_fs_use(struct super_block *sb); 364 398 365 - int security_genfs_sid(struct selinux_state *state, 366 - const char *fstype, const char *path, u16 sclass, 399 + int security_genfs_sid(const char *fstype, const char *path, u16 sclass, 367 400 u32 *sid); 368 401 369 402 int selinux_policy_genfs_sid(struct selinux_policy *policy, ··· 370 405 u32 *sid); 371 406 372 407 #ifdef CONFIG_NETLABEL 373 - int security_netlbl_secattr_to_sid(struct selinux_state *state, 374 - struct netlbl_lsm_secattr *secattr, 408 + int security_netlbl_secattr_to_sid(struct netlbl_lsm_secattr *secattr, 375 409 u32 *sid); 376 410 377 - int security_netlbl_sid_to_secattr(struct selinux_state *state, 378 - u32 sid, 411 + int security_netlbl_sid_to_secattr(u32 sid, 379 412 struct netlbl_lsm_secattr *secattr); 380 413 #else 381 - static inline int security_netlbl_secattr_to_sid(struct selinux_state *state, 382 - struct netlbl_lsm_secattr *secattr, 414 + static inline int security_netlbl_secattr_to_sid(struct netlbl_lsm_secattr *secattr, 383 415 u32 *sid) 384 416 { 385 417 return -EIDRM; 386 418 } 387 419 388 - static inline int security_netlbl_sid_to_secattr(struct selinux_state *state, 389 - u32 sid, 420 + static inline int security_netlbl_sid_to_secattr(u32 sid, 390 421 struct netlbl_lsm_secattr *secattr) 391 422 { 392 423 return -ENOENT; ··· 394 433 /* 395 434 * status notifier using mmap interface 396 435 */ 397 - extern struct page *selinux_kernel_status_page(struct selinux_state *state); 436 + extern struct page *selinux_kernel_status_page(void); 398 437 399 438 #define SELINUX_KERNEL_STATUS_VERSION 1 400 439 struct selinux_kernel_status { ··· 408 447 */ 409 448 } __packed; 410 449 411 - extern void selinux_status_update_setenforce(struct selinux_state *state, 412 - int enforcing); 413 - extern void selinux_status_update_policyload(struct selinux_state *state, 414 - int seqno); 450 + extern void selinux_status_update_setenforce(int enforcing); 451 + extern void selinux_status_update_policyload(int seqno); 415 452 extern void selinux_complete_init(void); 416 - extern int selinux_disable(struct selinux_state *state); 453 + extern int selinux_disable(void); 417 454 extern void exit_sel_fs(void); 418 455 extern struct path selinux_null; 419 456 extern void selnl_notify_setenforce(int val); ··· 421 462 extern void avtab_cache_init(void); 422 463 extern void ebitmap_cache_init(void); 423 464 extern void hashtab_cache_init(void); 424 - extern int security_sidtab_hash_stats(struct selinux_state *state, char *page); 465 + extern int security_sidtab_hash_stats(char *page); 425 466 426 467 #endif /* _SELINUX_SECURITY_H_ */
+1 -1
security/selinux/netif.c
··· 153 153 goto out; 154 154 } 155 155 156 - ret = security_netif_sid(&selinux_state, dev->name, sid); 156 + ret = security_netif_sid(dev->name, sid); 157 157 if (ret != 0) 158 158 goto out; 159 159 new = kzalloc(sizeof(*new), GFP_ATOMIC);
+6 -11
security/selinux/netlabel.c
··· 46 46 { 47 47 int rc; 48 48 49 - rc = security_netlbl_secattr_to_sid(&selinux_state, secattr, sid); 49 + rc = security_netlbl_secattr_to_sid(secattr, sid); 50 50 if (rc == 0 && 51 51 (secattr->flags & NETLBL_SECATTR_CACHEABLE) && 52 52 (secattr->flags & NETLBL_SECATTR_CACHE)) ··· 77 77 secattr = netlbl_secattr_alloc(GFP_ATOMIC); 78 78 if (secattr == NULL) 79 79 return NULL; 80 - rc = security_netlbl_sid_to_secattr(&selinux_state, sksec->sid, 81 - secattr); 80 + rc = security_netlbl_sid_to_secattr(sksec->sid, secattr); 82 81 if (rc != 0) { 83 82 netlbl_secattr_free(secattr); 84 83 return NULL; ··· 244 245 if (secattr == NULL) { 245 246 secattr = &secattr_storage; 246 247 netlbl_secattr_init(secattr); 247 - rc = security_netlbl_sid_to_secattr(&selinux_state, sid, 248 - secattr); 248 + rc = security_netlbl_sid_to_secattr(sid, secattr); 249 249 if (rc != 0) 250 250 goto skbuff_setsid_return; 251 251 } ··· 281 283 return 0; 282 284 283 285 netlbl_secattr_init(&secattr); 284 - rc = security_netlbl_sid_to_secattr(&selinux_state, 285 - asoc->secid, &secattr); 286 + rc = security_netlbl_sid_to_secattr(asoc->secid, &secattr); 286 287 if (rc != 0) 287 288 goto assoc_request_return; 288 289 ··· 329 332 return 0; 330 333 331 334 netlbl_secattr_init(&secattr); 332 - rc = security_netlbl_sid_to_secattr(&selinux_state, req->secid, 333 - &secattr); 335 + rc = security_netlbl_sid_to_secattr(req->secid, &secattr); 334 336 if (rc != 0) 335 337 goto inet_conn_request_return; 336 338 rc = netlbl_req_setattr(req, &secattr); ··· 459 463 perm = RAWIP_SOCKET__RECVFROM; 460 464 } 461 465 462 - rc = avc_has_perm(&selinux_state, 463 - sksec->sid, nlbl_sid, sksec->sclass, perm, ad); 466 + rc = avc_has_perm(sksec->sid, nlbl_sid, sksec->sclass, perm, ad); 464 467 if (rc == 0) 465 468 return 0; 466 469
+2 -2
security/selinux/netnode.c
··· 204 204 new = kzalloc(sizeof(*new), GFP_ATOMIC); 205 205 switch (family) { 206 206 case PF_INET: 207 - ret = security_node_sid(&selinux_state, PF_INET, 207 + ret = security_node_sid(PF_INET, 208 208 addr, sizeof(struct in_addr), sid); 209 209 if (new) 210 210 new->nsec.addr.ipv4 = *(__be32 *)addr; 211 211 break; 212 212 case PF_INET6: 213 - ret = security_node_sid(&selinux_state, PF_INET6, 213 + ret = security_node_sid(PF_INET6, 214 214 addr, sizeof(struct in6_addr), sid); 215 215 if (new) 216 216 new->nsec.addr.ipv6 = *(struct in6_addr *)addr;
+1 -1
security/selinux/netport.c
··· 148 148 return 0; 149 149 } 150 150 151 - ret = security_port_sid(&selinux_state, protocol, pnum, sid); 151 + ret = security_port_sid(protocol, pnum, sid); 152 152 if (ret != 0) 153 153 goto out; 154 154 new = kzalloc(sizeof(*new), GFP_ATOMIC);
+78 -130
security/selinux/selinuxfs.c
··· 77 77 bool policy_opened; 78 78 struct dentry *policycap_dir; 79 79 unsigned long last_ino; 80 - struct selinux_state *state; 81 80 struct super_block *sb; 82 81 }; 83 82 ··· 89 90 return -ENOMEM; 90 91 91 92 fsi->last_ino = SEL_INO_NEXT - 1; 92 - fsi->state = &selinux_state; 93 93 fsi->sb = sb; 94 94 sb->s_fs_info = fsi; 95 95 return 0; ··· 123 125 static ssize_t sel_read_enforce(struct file *filp, char __user *buf, 124 126 size_t count, loff_t *ppos) 125 127 { 126 - struct selinux_fs_info *fsi = file_inode(filp)->i_sb->s_fs_info; 127 128 char tmpbuf[TMPBUFLEN]; 128 129 ssize_t length; 129 130 130 131 length = scnprintf(tmpbuf, TMPBUFLEN, "%d", 131 - enforcing_enabled(fsi->state)); 132 + enforcing_enabled()); 132 133 return simple_read_from_buffer(buf, count, ppos, tmpbuf, length); 133 134 } 134 135 ··· 136 139 size_t count, loff_t *ppos) 137 140 138 141 { 139 - struct selinux_fs_info *fsi = file_inode(file)->i_sb->s_fs_info; 140 - struct selinux_state *state = fsi->state; 141 142 char *page = NULL; 142 143 ssize_t length; 143 144 int old_value, new_value; ··· 157 162 158 163 new_value = !!new_value; 159 164 160 - old_value = enforcing_enabled(state); 165 + old_value = enforcing_enabled(); 161 166 if (new_value != old_value) { 162 - length = avc_has_perm(&selinux_state, 163 - current_sid(), SECINITSID_SECURITY, 167 + length = avc_has_perm(current_sid(), SECINITSID_SECURITY, 164 168 SECCLASS_SECURITY, SECURITY__SETENFORCE, 165 169 NULL); 166 170 if (length) ··· 170 176 new_value, old_value, 171 177 from_kuid(&init_user_ns, audit_get_loginuid(current)), 172 178 audit_get_sessionid(current)); 173 - enforcing_set(state, new_value); 179 + enforcing_set(new_value); 174 180 if (new_value) 175 - avc_ss_reset(state->avc, 0); 181 + avc_ss_reset(0); 176 182 selnl_notify_setenforce(new_value); 177 - selinux_status_update_setenforce(state, new_value); 183 + selinux_status_update_setenforce(new_value); 178 184 if (!new_value) 179 185 call_blocking_lsm_notifier(LSM_POLICY_CHANGE, NULL); 180 186 181 - selinux_ima_measure_state(state); 187 + selinux_ima_measure_state(); 182 188 } 183 189 length = count; 184 190 out: ··· 198 204 static ssize_t sel_read_handle_unknown(struct file *filp, char __user *buf, 199 205 size_t count, loff_t *ppos) 200 206 { 201 - struct selinux_fs_info *fsi = file_inode(filp)->i_sb->s_fs_info; 202 - struct selinux_state *state = fsi->state; 203 207 char tmpbuf[TMPBUFLEN]; 204 208 ssize_t length; 205 209 ino_t ino = file_inode(filp)->i_ino; 206 210 int handle_unknown = (ino == SEL_REJECT_UNKNOWN) ? 207 - security_get_reject_unknown(state) : 208 - !security_get_allow_unknown(state); 211 + security_get_reject_unknown() : 212 + !security_get_allow_unknown(); 209 213 210 214 length = scnprintf(tmpbuf, TMPBUFLEN, "%d", handle_unknown); 211 215 return simple_read_from_buffer(buf, count, ppos, tmpbuf, length); ··· 216 224 217 225 static int sel_open_handle_status(struct inode *inode, struct file *filp) 218 226 { 219 - struct selinux_fs_info *fsi = file_inode(filp)->i_sb->s_fs_info; 220 - struct page *status = selinux_kernel_status_page(fsi->state); 227 + struct page *status = selinux_kernel_status_page(); 221 228 222 229 if (!status) 223 230 return -ENOMEM; ··· 272 281 size_t count, loff_t *ppos) 273 282 274 283 { 275 - struct selinux_fs_info *fsi = file_inode(file)->i_sb->s_fs_info; 276 284 char *page; 277 285 ssize_t length; 278 286 int new_value; ··· 302 312 goto out; 303 313 304 314 if (new_value) { 305 - enforcing = enforcing_enabled(fsi->state); 306 - length = selinux_disable(fsi->state); 315 + enforcing = enforcing_enabled(); 316 + length = selinux_disable(); 307 317 if (length) 308 318 goto out; 309 319 audit_log(audit_context(), GFP_KERNEL, AUDIT_MAC_STATUS, ··· 365 375 static ssize_t sel_read_mls(struct file *filp, char __user *buf, 366 376 size_t count, loff_t *ppos) 367 377 { 368 - struct selinux_fs_info *fsi = file_inode(filp)->i_sb->s_fs_info; 369 378 char tmpbuf[TMPBUFLEN]; 370 379 ssize_t length; 371 380 372 381 length = scnprintf(tmpbuf, TMPBUFLEN, "%d", 373 - security_mls_enabled(fsi->state)); 382 + security_mls_enabled()); 374 383 return simple_read_from_buffer(buf, count, ppos, tmpbuf, length); 375 384 } 376 385 ··· 386 397 static int sel_open_policy(struct inode *inode, struct file *filp) 387 398 { 388 399 struct selinux_fs_info *fsi = inode->i_sb->s_fs_info; 389 - struct selinux_state *state = fsi->state; 390 400 struct policy_load_memory *plm = NULL; 391 401 int rc; 392 402 393 403 BUG_ON(filp->private_data); 394 404 395 - mutex_lock(&fsi->state->policy_mutex); 405 + mutex_lock(&selinux_state.policy_mutex); 396 406 397 - rc = avc_has_perm(&selinux_state, 398 - current_sid(), SECINITSID_SECURITY, 407 + rc = avc_has_perm(current_sid(), SECINITSID_SECURITY, 399 408 SECCLASS_SECURITY, SECURITY__READ_POLICY, NULL); 400 409 if (rc) 401 410 goto err; ··· 407 420 if (!plm) 408 421 goto err; 409 422 410 - rc = security_read_policy(state, &plm->data, &plm->len); 423 + rc = security_read_policy(&plm->data, &plm->len); 411 424 if (rc) 412 425 goto err; 413 426 ··· 421 434 422 435 filp->private_data = plm; 423 436 424 - mutex_unlock(&fsi->state->policy_mutex); 437 + mutex_unlock(&selinux_state.policy_mutex); 425 438 426 439 return 0; 427 440 err: 428 - mutex_unlock(&fsi->state->policy_mutex); 441 + mutex_unlock(&selinux_state.policy_mutex); 429 442 430 443 if (plm) 431 444 vfree(plm->data); ··· 454 467 struct policy_load_memory *plm = filp->private_data; 455 468 int ret; 456 469 457 - ret = avc_has_perm(&selinux_state, 458 - current_sid(), SECINITSID_SECURITY, 470 + ret = avc_has_perm(current_sid(), SECINITSID_SECURITY, 459 471 SECCLASS_SECURITY, SECURITY__READ_POLICY, NULL); 460 472 if (ret) 461 473 return ret; ··· 607 621 ssize_t length; 608 622 void *data = NULL; 609 623 610 - mutex_lock(&fsi->state->policy_mutex); 624 + mutex_lock(&selinux_state.policy_mutex); 611 625 612 - length = avc_has_perm(&selinux_state, 613 - current_sid(), SECINITSID_SECURITY, 626 + length = avc_has_perm(current_sid(), SECINITSID_SECURITY, 614 627 SECCLASS_SECURITY, SECURITY__LOAD_POLICY, NULL); 615 628 if (length) 616 629 goto out; ··· 628 643 if (copy_from_user(data, buf, count) != 0) 629 644 goto out; 630 645 631 - length = security_load_policy(fsi->state, data, count, &load_state); 646 + length = security_load_policy(data, count, &load_state); 632 647 if (length) { 633 648 pr_warn_ratelimited("SELinux: failed to load policy\n"); 634 649 goto out; ··· 637 652 length = sel_make_policy_nodes(fsi, load_state.policy); 638 653 if (length) { 639 654 pr_warn_ratelimited("SELinux: failed to initialize selinuxfs\n"); 640 - selinux_policy_cancel(fsi->state, &load_state); 655 + selinux_policy_cancel(&load_state); 641 656 goto out; 642 657 } 643 658 644 - selinux_policy_commit(fsi->state, &load_state); 659 + selinux_policy_commit(&load_state); 645 660 646 661 length = count; 647 662 ··· 650 665 from_kuid(&init_user_ns, audit_get_loginuid(current)), 651 666 audit_get_sessionid(current)); 652 667 out: 653 - mutex_unlock(&fsi->state->policy_mutex); 668 + mutex_unlock(&selinux_state.policy_mutex); 654 669 vfree(data); 655 670 return length; 656 671 } ··· 662 677 663 678 static ssize_t sel_write_context(struct file *file, char *buf, size_t size) 664 679 { 665 - struct selinux_fs_info *fsi = file_inode(file)->i_sb->s_fs_info; 666 - struct selinux_state *state = fsi->state; 667 680 char *canon = NULL; 668 681 u32 sid, len; 669 682 ssize_t length; 670 683 671 - length = avc_has_perm(&selinux_state, 672 - current_sid(), SECINITSID_SECURITY, 684 + length = avc_has_perm(current_sid(), SECINITSID_SECURITY, 673 685 SECCLASS_SECURITY, SECURITY__CHECK_CONTEXT, NULL); 674 686 if (length) 675 687 goto out; 676 688 677 - length = security_context_to_sid(state, buf, size, &sid, GFP_KERNEL); 689 + length = security_context_to_sid(buf, size, &sid, GFP_KERNEL); 678 690 if (length) 679 691 goto out; 680 692 681 - length = security_sid_to_context(state, sid, &canon, &len); 693 + length = security_sid_to_context(sid, &canon, &len); 682 694 if (length) 683 695 goto out; 684 696 ··· 696 714 static ssize_t sel_read_checkreqprot(struct file *filp, char __user *buf, 697 715 size_t count, loff_t *ppos) 698 716 { 699 - struct selinux_fs_info *fsi = file_inode(filp)->i_sb->s_fs_info; 700 717 char tmpbuf[TMPBUFLEN]; 701 718 ssize_t length; 702 719 703 720 length = scnprintf(tmpbuf, TMPBUFLEN, "%u", 704 - checkreqprot_get(fsi->state)); 721 + checkreqprot_get()); 705 722 return simple_read_from_buffer(buf, count, ppos, tmpbuf, length); 706 723 } 707 724 708 725 static ssize_t sel_write_checkreqprot(struct file *file, const char __user *buf, 709 726 size_t count, loff_t *ppos) 710 727 { 711 - struct selinux_fs_info *fsi = file_inode(file)->i_sb->s_fs_info; 712 728 char *page; 713 729 ssize_t length; 714 730 unsigned int new_value; 715 731 716 - length = avc_has_perm(&selinux_state, 717 - current_sid(), SECINITSID_SECURITY, 732 + length = avc_has_perm(current_sid(), SECINITSID_SECURITY, 718 733 SECCLASS_SECURITY, SECURITY__SETCHECKREQPROT, 719 734 NULL); 720 735 if (length) ··· 740 761 comm, current->pid); 741 762 } 742 763 743 - checkreqprot_set(fsi->state, (new_value ? 1 : 0)); 764 + checkreqprot_set((new_value ? 1 : 0)); 744 765 if (new_value) 745 766 ssleep(15); 746 767 length = count; 747 768 748 - selinux_ima_measure_state(fsi->state); 769 + selinux_ima_measure_state(); 749 770 750 771 out: 751 772 kfree(page); ··· 761 782 const char __user *buf, 762 783 size_t count, loff_t *ppos) 763 784 { 764 - struct selinux_fs_info *fsi = file_inode(file)->i_sb->s_fs_info; 765 - struct selinux_state *state = fsi->state; 766 785 char *oldcon = NULL, *newcon = NULL, *taskcon = NULL; 767 786 char *req = NULL; 768 787 u32 osid, nsid, tsid; 769 788 u16 tclass; 770 789 int rc; 771 790 772 - rc = avc_has_perm(&selinux_state, 773 - current_sid(), SECINITSID_SECURITY, 791 + rc = avc_has_perm(current_sid(), SECINITSID_SECURITY, 774 792 SECCLASS_SECURITY, SECURITY__VALIDATE_TRANS, NULL); 775 793 if (rc) 776 794 goto out; ··· 805 829 if (sscanf(req, "%s %s %hu %s", oldcon, newcon, &tclass, taskcon) != 4) 806 830 goto out; 807 831 808 - rc = security_context_str_to_sid(state, oldcon, &osid, GFP_KERNEL); 832 + rc = security_context_str_to_sid(oldcon, &osid, GFP_KERNEL); 809 833 if (rc) 810 834 goto out; 811 835 812 - rc = security_context_str_to_sid(state, newcon, &nsid, GFP_KERNEL); 836 + rc = security_context_str_to_sid(newcon, &nsid, GFP_KERNEL); 813 837 if (rc) 814 838 goto out; 815 839 816 - rc = security_context_str_to_sid(state, taskcon, &tsid, GFP_KERNEL); 840 + rc = security_context_str_to_sid(taskcon, &tsid, GFP_KERNEL); 817 841 if (rc) 818 842 goto out; 819 843 820 - rc = security_validate_transition_user(state, osid, nsid, tsid, tclass); 844 + rc = security_validate_transition_user(osid, nsid, tsid, tclass); 821 845 if (!rc) 822 846 rc = count; 823 847 out: ··· 887 911 888 912 static ssize_t sel_write_access(struct file *file, char *buf, size_t size) 889 913 { 890 - struct selinux_fs_info *fsi = file_inode(file)->i_sb->s_fs_info; 891 - struct selinux_state *state = fsi->state; 892 914 char *scon = NULL, *tcon = NULL; 893 915 u32 ssid, tsid; 894 916 u16 tclass; 895 917 struct av_decision avd; 896 918 ssize_t length; 897 919 898 - length = avc_has_perm(&selinux_state, 899 - current_sid(), SECINITSID_SECURITY, 920 + length = avc_has_perm(current_sid(), SECINITSID_SECURITY, 900 921 SECCLASS_SECURITY, SECURITY__COMPUTE_AV, NULL); 901 922 if (length) 902 923 goto out; ··· 912 939 if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3) 913 940 goto out; 914 941 915 - length = security_context_str_to_sid(state, scon, &ssid, GFP_KERNEL); 942 + length = security_context_str_to_sid(scon, &ssid, GFP_KERNEL); 916 943 if (length) 917 944 goto out; 918 945 919 - length = security_context_str_to_sid(state, tcon, &tsid, GFP_KERNEL); 946 + length = security_context_str_to_sid(tcon, &tsid, GFP_KERNEL); 920 947 if (length) 921 948 goto out; 922 949 923 - security_compute_av_user(state, ssid, tsid, tclass, &avd); 950 + security_compute_av_user(ssid, tsid, tclass, &avd); 924 951 925 952 length = scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, 926 953 "%x %x %x %x %u %x", ··· 935 962 936 963 static ssize_t sel_write_create(struct file *file, char *buf, size_t size) 937 964 { 938 - struct selinux_fs_info *fsi = file_inode(file)->i_sb->s_fs_info; 939 - struct selinux_state *state = fsi->state; 940 965 char *scon = NULL, *tcon = NULL; 941 966 char *namebuf = NULL, *objname = NULL; 942 967 u32 ssid, tsid, newsid; ··· 944 973 u32 len; 945 974 int nargs; 946 975 947 - length = avc_has_perm(&selinux_state, 948 - current_sid(), SECINITSID_SECURITY, 976 + length = avc_has_perm(current_sid(), SECINITSID_SECURITY, 949 977 SECCLASS_SECURITY, SECURITY__COMPUTE_CREATE, 950 978 NULL); 951 979 if (length) ··· 1000 1030 objname = namebuf; 1001 1031 } 1002 1032 1003 - length = security_context_str_to_sid(state, scon, &ssid, GFP_KERNEL); 1033 + length = security_context_str_to_sid(scon, &ssid, GFP_KERNEL); 1004 1034 if (length) 1005 1035 goto out; 1006 1036 1007 - length = security_context_str_to_sid(state, tcon, &tsid, GFP_KERNEL); 1037 + length = security_context_str_to_sid(tcon, &tsid, GFP_KERNEL); 1008 1038 if (length) 1009 1039 goto out; 1010 1040 1011 - length = security_transition_sid_user(state, ssid, tsid, tclass, 1041 + length = security_transition_sid_user(ssid, tsid, tclass, 1012 1042 objname, &newsid); 1013 1043 if (length) 1014 1044 goto out; 1015 1045 1016 - length = security_sid_to_context(state, newsid, &newcon, &len); 1046 + length = security_sid_to_context(newsid, &newcon, &len); 1017 1047 if (length) 1018 1048 goto out; 1019 1049 ··· 1036 1066 1037 1067 static ssize_t sel_write_relabel(struct file *file, char *buf, size_t size) 1038 1068 { 1039 - struct selinux_fs_info *fsi = file_inode(file)->i_sb->s_fs_info; 1040 - struct selinux_state *state = fsi->state; 1041 1069 char *scon = NULL, *tcon = NULL; 1042 1070 u32 ssid, tsid, newsid; 1043 1071 u16 tclass; ··· 1043 1075 char *newcon = NULL; 1044 1076 u32 len; 1045 1077 1046 - length = avc_has_perm(&selinux_state, 1047 - current_sid(), SECINITSID_SECURITY, 1078 + length = avc_has_perm(current_sid(), SECINITSID_SECURITY, 1048 1079 SECCLASS_SECURITY, SECURITY__COMPUTE_RELABEL, 1049 1080 NULL); 1050 1081 if (length) ··· 1063 1096 if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3) 1064 1097 goto out; 1065 1098 1066 - length = security_context_str_to_sid(state, scon, &ssid, GFP_KERNEL); 1099 + length = security_context_str_to_sid(scon, &ssid, GFP_KERNEL); 1067 1100 if (length) 1068 1101 goto out; 1069 1102 1070 - length = security_context_str_to_sid(state, tcon, &tsid, GFP_KERNEL); 1103 + length = security_context_str_to_sid(tcon, &tsid, GFP_KERNEL); 1071 1104 if (length) 1072 1105 goto out; 1073 1106 1074 - length = security_change_sid(state, ssid, tsid, tclass, &newsid); 1107 + length = security_change_sid(ssid, tsid, tclass, &newsid); 1075 1108 if (length) 1076 1109 goto out; 1077 1110 1078 - length = security_sid_to_context(state, newsid, &newcon, &len); 1111 + length = security_sid_to_context(newsid, &newcon, &len); 1079 1112 if (length) 1080 1113 goto out; 1081 1114 ··· 1094 1127 1095 1128 static ssize_t sel_write_user(struct file *file, char *buf, size_t size) 1096 1129 { 1097 - struct selinux_fs_info *fsi = file_inode(file)->i_sb->s_fs_info; 1098 - struct selinux_state *state = fsi->state; 1099 1130 char *con = NULL, *user = NULL, *ptr; 1100 1131 u32 sid, *sids = NULL; 1101 1132 ssize_t length; ··· 1101 1136 int i, rc; 1102 1137 u32 len, nsids; 1103 1138 1104 - length = avc_has_perm(&selinux_state, 1105 - current_sid(), SECINITSID_SECURITY, 1139 + length = avc_has_perm(current_sid(), SECINITSID_SECURITY, 1106 1140 SECCLASS_SECURITY, SECURITY__COMPUTE_USER, 1107 1141 NULL); 1108 1142 if (length) ··· 1121 1157 if (sscanf(buf, "%s %s", con, user) != 2) 1122 1158 goto out; 1123 1159 1124 - length = security_context_str_to_sid(state, con, &sid, GFP_KERNEL); 1160 + length = security_context_str_to_sid(con, &sid, GFP_KERNEL); 1125 1161 if (length) 1126 1162 goto out; 1127 1163 1128 - length = security_get_user_sids(state, sid, user, &sids, &nsids); 1164 + length = security_get_user_sids(sid, user, &sids, &nsids); 1129 1165 if (length) 1130 1166 goto out; 1131 1167 1132 1168 length = sprintf(buf, "%u", nsids) + 1; 1133 1169 ptr = buf + length; 1134 1170 for (i = 0; i < nsids; i++) { 1135 - rc = security_sid_to_context(state, sids[i], &newcon, &len); 1171 + rc = security_sid_to_context(sids[i], &newcon, &len); 1136 1172 if (rc) { 1137 1173 length = rc; 1138 1174 goto out; ··· 1156 1192 1157 1193 static ssize_t sel_write_member(struct file *file, char *buf, size_t size) 1158 1194 { 1159 - struct selinux_fs_info *fsi = file_inode(file)->i_sb->s_fs_info; 1160 - struct selinux_state *state = fsi->state; 1161 1195 char *scon = NULL, *tcon = NULL; 1162 1196 u32 ssid, tsid, newsid; 1163 1197 u16 tclass; ··· 1163 1201 char *newcon = NULL; 1164 1202 u32 len; 1165 1203 1166 - length = avc_has_perm(&selinux_state, 1167 - current_sid(), SECINITSID_SECURITY, 1204 + length = avc_has_perm(current_sid(), SECINITSID_SECURITY, 1168 1205 SECCLASS_SECURITY, SECURITY__COMPUTE_MEMBER, 1169 1206 NULL); 1170 1207 if (length) ··· 1183 1222 if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3) 1184 1223 goto out; 1185 1224 1186 - length = security_context_str_to_sid(state, scon, &ssid, GFP_KERNEL); 1225 + length = security_context_str_to_sid(scon, &ssid, GFP_KERNEL); 1187 1226 if (length) 1188 1227 goto out; 1189 1228 1190 - length = security_context_str_to_sid(state, tcon, &tsid, GFP_KERNEL); 1229 + length = security_context_str_to_sid(tcon, &tsid, GFP_KERNEL); 1191 1230 if (length) 1192 1231 goto out; 1193 1232 1194 - length = security_member_sid(state, ssid, tsid, tclass, &newsid); 1233 + length = security_member_sid(ssid, tsid, tclass, &newsid); 1195 1234 if (length) 1196 1235 goto out; 1197 1236 1198 - length = security_sid_to_context(state, newsid, &newcon, &len); 1237 + length = security_sid_to_context(newsid, &newcon, &len); 1199 1238 if (length) 1200 1239 goto out; 1201 1240 ··· 1237 1276 unsigned index = file_inode(filep)->i_ino & SEL_INO_MASK; 1238 1277 const char *name = filep->f_path.dentry->d_name.name; 1239 1278 1240 - mutex_lock(&fsi->state->policy_mutex); 1279 + mutex_lock(&selinux_state.policy_mutex); 1241 1280 1242 1281 ret = -EINVAL; 1243 1282 if (index >= fsi->bool_num || strcmp(name, ··· 1249 1288 if (!page) 1250 1289 goto out_unlock; 1251 1290 1252 - cur_enforcing = security_get_bool_value(fsi->state, index); 1291 + cur_enforcing = security_get_bool_value(index); 1253 1292 if (cur_enforcing < 0) { 1254 1293 ret = cur_enforcing; 1255 1294 goto out_unlock; 1256 1295 } 1257 1296 length = scnprintf(page, PAGE_SIZE, "%d %d", cur_enforcing, 1258 1297 fsi->bool_pending_values[index]); 1259 - mutex_unlock(&fsi->state->policy_mutex); 1298 + mutex_unlock(&selinux_state.policy_mutex); 1260 1299 ret = simple_read_from_buffer(buf, count, ppos, page, length); 1261 1300 out_free: 1262 1301 free_page((unsigned long)page); 1263 1302 return ret; 1264 1303 1265 1304 out_unlock: 1266 - mutex_unlock(&fsi->state->policy_mutex); 1305 + mutex_unlock(&selinux_state.policy_mutex); 1267 1306 goto out_free; 1268 1307 } 1269 1308 ··· 1288 1327 if (IS_ERR(page)) 1289 1328 return PTR_ERR(page); 1290 1329 1291 - mutex_lock(&fsi->state->policy_mutex); 1330 + mutex_lock(&selinux_state.policy_mutex); 1292 1331 1293 - length = avc_has_perm(&selinux_state, 1294 - current_sid(), SECINITSID_SECURITY, 1332 + length = avc_has_perm(current_sid(), SECINITSID_SECURITY, 1295 1333 SECCLASS_SECURITY, SECURITY__SETBOOL, 1296 1334 NULL); 1297 1335 if (length) ··· 1312 1352 length = count; 1313 1353 1314 1354 out: 1315 - mutex_unlock(&fsi->state->policy_mutex); 1355 + mutex_unlock(&selinux_state.policy_mutex); 1316 1356 kfree(page); 1317 1357 return length; 1318 1358 } ··· 1343 1383 if (IS_ERR(page)) 1344 1384 return PTR_ERR(page); 1345 1385 1346 - mutex_lock(&fsi->state->policy_mutex); 1386 + mutex_lock(&selinux_state.policy_mutex); 1347 1387 1348 - length = avc_has_perm(&selinux_state, 1349 - current_sid(), SECINITSID_SECURITY, 1388 + length = avc_has_perm(current_sid(), SECINITSID_SECURITY, 1350 1389 SECCLASS_SECURITY, SECURITY__SETBOOL, 1351 1390 NULL); 1352 1391 if (length) ··· 1357 1398 1358 1399 length = 0; 1359 1400 if (new_value && fsi->bool_pending_values) 1360 - length = security_set_bools(fsi->state, fsi->bool_num, 1401 + length = security_set_bools(fsi->bool_num, 1361 1402 fsi->bool_pending_values); 1362 1403 1363 1404 if (!length) 1364 1405 length = count; 1365 1406 1366 1407 out: 1367 - mutex_unlock(&fsi->state->policy_mutex); 1408 + mutex_unlock(&selinux_state.policy_mutex); 1368 1409 kfree(page); 1369 1410 return length; 1370 1411 } ··· 1462 1503 static ssize_t sel_read_avc_cache_threshold(struct file *filp, char __user *buf, 1463 1504 size_t count, loff_t *ppos) 1464 1505 { 1465 - struct selinux_fs_info *fsi = file_inode(filp)->i_sb->s_fs_info; 1466 - struct selinux_state *state = fsi->state; 1467 1506 char tmpbuf[TMPBUFLEN]; 1468 1507 ssize_t length; 1469 1508 1470 1509 length = scnprintf(tmpbuf, TMPBUFLEN, "%u", 1471 - avc_get_cache_threshold(state->avc)); 1510 + avc_get_cache_threshold()); 1472 1511 return simple_read_from_buffer(buf, count, ppos, tmpbuf, length); 1473 1512 } 1474 1513 ··· 1475 1518 size_t count, loff_t *ppos) 1476 1519 1477 1520 { 1478 - struct selinux_fs_info *fsi = file_inode(file)->i_sb->s_fs_info; 1479 - struct selinux_state *state = fsi->state; 1480 1521 char *page; 1481 1522 ssize_t ret; 1482 1523 unsigned int new_value; 1483 1524 1484 - ret = avc_has_perm(&selinux_state, 1485 - current_sid(), SECINITSID_SECURITY, 1525 + ret = avc_has_perm(current_sid(), SECINITSID_SECURITY, 1486 1526 SECCLASS_SECURITY, SECURITY__SETSECPARAM, 1487 1527 NULL); 1488 1528 if (ret) ··· 1500 1546 if (sscanf(page, "%u", &new_value) != 1) 1501 1547 goto out; 1502 1548 1503 - avc_set_cache_threshold(state->avc, new_value); 1549 + avc_set_cache_threshold(new_value); 1504 1550 1505 1551 ret = count; 1506 1552 out: ··· 1511 1557 static ssize_t sel_read_avc_hash_stats(struct file *filp, char __user *buf, 1512 1558 size_t count, loff_t *ppos) 1513 1559 { 1514 - struct selinux_fs_info *fsi = file_inode(filp)->i_sb->s_fs_info; 1515 - struct selinux_state *state = fsi->state; 1516 1560 char *page; 1517 1561 ssize_t length; 1518 1562 ··· 1518 1566 if (!page) 1519 1567 return -ENOMEM; 1520 1568 1521 - length = avc_get_hash_stats(state->avc, page); 1569 + length = avc_get_hash_stats(page); 1522 1570 if (length >= 0) 1523 1571 length = simple_read_from_buffer(buf, count, ppos, page, length); 1524 1572 free_page((unsigned long)page); ··· 1529 1577 static ssize_t sel_read_sidtab_hash_stats(struct file *filp, char __user *buf, 1530 1578 size_t count, loff_t *ppos) 1531 1579 { 1532 - struct selinux_fs_info *fsi = file_inode(filp)->i_sb->s_fs_info; 1533 - struct selinux_state *state = fsi->state; 1534 1580 char *page; 1535 1581 ssize_t length; 1536 1582 ··· 1536 1586 if (!page) 1537 1587 return -ENOMEM; 1538 1588 1539 - length = security_sidtab_hash_stats(state, page); 1589 + length = security_sidtab_hash_stats(page); 1540 1590 if (length >= 0) 1541 1591 length = simple_read_from_buffer(buf, count, ppos, page, 1542 1592 length); ··· 1702 1752 static ssize_t sel_read_initcon(struct file *file, char __user *buf, 1703 1753 size_t count, loff_t *ppos) 1704 1754 { 1705 - struct selinux_fs_info *fsi = file_inode(file)->i_sb->s_fs_info; 1706 1755 char *con; 1707 1756 u32 sid, len; 1708 1757 ssize_t ret; 1709 1758 1710 1759 sid = file_inode(file)->i_ino&SEL_INO_MASK; 1711 - ret = security_sid_to_context(fsi->state, sid, &con, &len); 1760 + ret = security_sid_to_context(sid, &con, &len); 1712 1761 if (ret) 1713 1762 return ret; 1714 1763 ··· 1801 1852 static ssize_t sel_read_policycap(struct file *file, char __user *buf, 1802 1853 size_t count, loff_t *ppos) 1803 1854 { 1804 - struct selinux_fs_info *fsi = file_inode(file)->i_sb->s_fs_info; 1805 1855 int value; 1806 1856 char tmpbuf[TMPBUFLEN]; 1807 1857 ssize_t length; 1808 1858 unsigned long i_ino = file_inode(file)->i_ino; 1809 1859 1810 - value = security_policycap_supported(fsi->state, i_ino & SEL_INO_MASK); 1860 + value = security_policycap_supported(i_ino & SEL_INO_MASK); 1811 1861 length = scnprintf(tmpbuf, TMPBUFLEN, "%d", value); 1812 1862 1813 1863 return simple_read_from_buffer(buf, count, ppos, tmpbuf, length);
+141 -205
security/selinux/ss/services.c
··· 235 235 } 236 236 } 237 237 238 - int security_mls_enabled(struct selinux_state *state) 238 + int security_mls_enabled(void) 239 239 { 240 240 int mls_enabled; 241 241 struct selinux_policy *policy; 242 242 243 - if (!selinux_initialized(state)) 243 + if (!selinux_initialized()) 244 244 return 0; 245 245 246 246 rcu_read_lock(); 247 - policy = rcu_dereference(state->policy); 247 + policy = rcu_dereference(selinux_state.policy); 248 248 mls_enabled = policy->policydb.mls_enabled; 249 249 rcu_read_unlock(); 250 250 return mls_enabled; ··· 713 713 tclass, avd); 714 714 } 715 715 716 - static int security_validtrans_handle_fail(struct selinux_state *state, 717 - struct selinux_policy *policy, 716 + static int security_validtrans_handle_fail(struct selinux_policy *policy, 718 717 struct sidtab_entry *oentry, 719 718 struct sidtab_entry *nentry, 720 719 struct sidtab_entry *tentry, ··· 739 740 kfree(n); 740 741 kfree(t); 741 742 742 - if (!enforcing_enabled(state)) 743 + if (!enforcing_enabled()) 743 744 return 0; 744 745 return -EPERM; 745 746 } 746 747 747 - static int security_compute_validatetrans(struct selinux_state *state, 748 - u32 oldsid, u32 newsid, u32 tasksid, 748 + static int security_compute_validatetrans(u32 oldsid, u32 newsid, u32 tasksid, 749 749 u16 orig_tclass, bool user) 750 750 { 751 751 struct selinux_policy *policy; ··· 759 761 int rc = 0; 760 762 761 763 762 - if (!selinux_initialized(state)) 764 + if (!selinux_initialized()) 763 765 return 0; 764 766 765 767 rcu_read_lock(); 766 768 767 - policy = rcu_dereference(state->policy); 769 + policy = rcu_dereference(selinux_state.policy); 768 770 policydb = &policy->policydb; 769 771 sidtab = policy->sidtab; 770 772 ··· 811 813 if (user) 812 814 rc = -EPERM; 813 815 else 814 - rc = security_validtrans_handle_fail(state, 815 - policy, 816 + rc = security_validtrans_handle_fail(policy, 816 817 oentry, 817 818 nentry, 818 819 tentry, ··· 826 829 return rc; 827 830 } 828 831 829 - int security_validate_transition_user(struct selinux_state *state, 830 - u32 oldsid, u32 newsid, u32 tasksid, 832 + int security_validate_transition_user(u32 oldsid, u32 newsid, u32 tasksid, 831 833 u16 tclass) 832 834 { 833 - return security_compute_validatetrans(state, oldsid, newsid, tasksid, 835 + return security_compute_validatetrans(oldsid, newsid, tasksid, 834 836 tclass, true); 835 837 } 836 838 837 - int security_validate_transition(struct selinux_state *state, 838 - u32 oldsid, u32 newsid, u32 tasksid, 839 + int security_validate_transition(u32 oldsid, u32 newsid, u32 tasksid, 839 840 u16 orig_tclass) 840 841 { 841 - return security_compute_validatetrans(state, oldsid, newsid, tasksid, 842 + return security_compute_validatetrans(oldsid, newsid, tasksid, 842 843 orig_tclass, false); 843 844 } 844 845 ··· 846 851 * It returns 0, if @newsid is bounded by @oldsid. 847 852 * Otherwise, it returns error code. 848 853 * 849 - * @state: SELinux state 850 854 * @oldsid : current security identifier 851 855 * @newsid : destinated security identifier 852 856 */ 853 - int security_bounded_transition(struct selinux_state *state, 854 - u32 old_sid, u32 new_sid) 857 + int security_bounded_transition(u32 old_sid, u32 new_sid) 855 858 { 856 859 struct selinux_policy *policy; 857 860 struct policydb *policydb; ··· 859 866 int index; 860 867 int rc; 861 868 862 - if (!selinux_initialized(state)) 869 + if (!selinux_initialized()) 863 870 return 0; 864 871 865 872 rcu_read_lock(); 866 - policy = rcu_dereference(state->policy); 873 + policy = rcu_dereference(selinux_state.policy); 867 874 policydb = &policy->policydb; 868 875 sidtab = policy->sidtab; 869 876 ··· 997 1004 } 998 1005 } 999 1006 1000 - void security_compute_xperms_decision(struct selinux_state *state, 1001 - u32 ssid, 1007 + void security_compute_xperms_decision(u32 ssid, 1002 1008 u32 tsid, 1003 1009 u16 orig_tclass, 1004 1010 u8 driver, ··· 1021 1029 memset(xpermd->dontaudit->p, 0, sizeof(xpermd->dontaudit->p)); 1022 1030 1023 1031 rcu_read_lock(); 1024 - if (!selinux_initialized(state)) 1032 + if (!selinux_initialized()) 1025 1033 goto allow; 1026 1034 1027 - policy = rcu_dereference(state->policy); 1035 + policy = rcu_dereference(selinux_state.policy); 1028 1036 policydb = &policy->policydb; 1029 1037 sidtab = policy->sidtab; 1030 1038 ··· 1083 1091 1084 1092 /** 1085 1093 * security_compute_av - Compute access vector decisions. 1086 - * @state: SELinux state 1087 1094 * @ssid: source security identifier 1088 1095 * @tsid: target security identifier 1089 1096 * @orig_tclass: target security class ··· 1092 1101 * Compute a set of access vector decisions based on the 1093 1102 * SID pair (@ssid, @tsid) for the permissions in @tclass. 1094 1103 */ 1095 - void security_compute_av(struct selinux_state *state, 1096 - u32 ssid, 1104 + void security_compute_av(u32 ssid, 1097 1105 u32 tsid, 1098 1106 u16 orig_tclass, 1099 1107 struct av_decision *avd, ··· 1105 1115 struct context *scontext = NULL, *tcontext = NULL; 1106 1116 1107 1117 rcu_read_lock(); 1108 - policy = rcu_dereference(state->policy); 1118 + policy = rcu_dereference(selinux_state.policy); 1109 1119 avd_init(policy, avd); 1110 1120 xperms->len = 0; 1111 - if (!selinux_initialized(state)) 1121 + if (!selinux_initialized()) 1112 1122 goto allow; 1113 1123 1114 1124 policydb = &policy->policydb; ··· 1150 1160 goto out; 1151 1161 } 1152 1162 1153 - void security_compute_av_user(struct selinux_state *state, 1154 - u32 ssid, 1163 + void security_compute_av_user(u32 ssid, 1155 1164 u32 tsid, 1156 1165 u16 tclass, 1157 1166 struct av_decision *avd) ··· 1161 1172 struct context *scontext = NULL, *tcontext = NULL; 1162 1173 1163 1174 rcu_read_lock(); 1164 - policy = rcu_dereference(state->policy); 1175 + policy = rcu_dereference(selinux_state.policy); 1165 1176 avd_init(policy, avd); 1166 - if (!selinux_initialized(state)) 1177 + if (!selinux_initialized()) 1167 1178 goto allow; 1168 1179 1169 1180 policydb = &policy->policydb; ··· 1279 1290 1280 1291 #include "initial_sid_to_string.h" 1281 1292 1282 - int security_sidtab_hash_stats(struct selinux_state *state, char *page) 1293 + int security_sidtab_hash_stats(char *page) 1283 1294 { 1284 1295 struct selinux_policy *policy; 1285 1296 int rc; 1286 1297 1287 - if (!selinux_initialized(state)) { 1298 + if (!selinux_initialized()) { 1288 1299 pr_err("SELinux: %s: called before initial load_policy\n", 1289 1300 __func__); 1290 1301 return -EINVAL; 1291 1302 } 1292 1303 1293 1304 rcu_read_lock(); 1294 - policy = rcu_dereference(state->policy); 1305 + policy = rcu_dereference(selinux_state.policy); 1295 1306 rc = sidtab_hash_stats(policy->sidtab, page); 1296 1307 rcu_read_unlock(); 1297 1308 ··· 1305 1316 return initial_sid_to_string[sid]; 1306 1317 } 1307 1318 1308 - static int security_sid_to_context_core(struct selinux_state *state, 1309 - u32 sid, char **scontext, 1319 + static int security_sid_to_context_core(u32 sid, char **scontext, 1310 1320 u32 *scontext_len, int force, 1311 1321 int only_invalid) 1312 1322 { ··· 1319 1331 *scontext = NULL; 1320 1332 *scontext_len = 0; 1321 1333 1322 - if (!selinux_initialized(state)) { 1334 + if (!selinux_initialized()) { 1323 1335 if (sid <= SECINITSID_NUM) { 1324 1336 char *scontextp; 1325 1337 const char *s = initial_sid_to_string[sid]; ··· 1340 1352 return -EINVAL; 1341 1353 } 1342 1354 rcu_read_lock(); 1343 - policy = rcu_dereference(state->policy); 1355 + policy = rcu_dereference(selinux_state.policy); 1344 1356 policydb = &policy->policydb; 1345 1357 sidtab = policy->sidtab; 1346 1358 ··· 1368 1380 1369 1381 /** 1370 1382 * security_sid_to_context - Obtain a context for a given SID. 1371 - * @state: SELinux state 1372 1383 * @sid: security identifier, SID 1373 1384 * @scontext: security context 1374 1385 * @scontext_len: length in bytes ··· 1376 1389 * into a dynamically allocated string of the correct size. Set @scontext 1377 1390 * to point to this string and set @scontext_len to the length of the string. 1378 1391 */ 1379 - int security_sid_to_context(struct selinux_state *state, 1380 - u32 sid, char **scontext, u32 *scontext_len) 1392 + int security_sid_to_context(u32 sid, char **scontext, u32 *scontext_len) 1381 1393 { 1382 - return security_sid_to_context_core(state, sid, scontext, 1394 + return security_sid_to_context_core(sid, scontext, 1383 1395 scontext_len, 0, 0); 1384 1396 } 1385 1397 1386 - int security_sid_to_context_force(struct selinux_state *state, u32 sid, 1398 + int security_sid_to_context_force(u32 sid, 1387 1399 char **scontext, u32 *scontext_len) 1388 1400 { 1389 - return security_sid_to_context_core(state, sid, scontext, 1401 + return security_sid_to_context_core(sid, scontext, 1390 1402 scontext_len, 1, 0); 1391 1403 } 1392 1404 1393 1405 /** 1394 1406 * security_sid_to_context_inval - Obtain a context for a given SID if it 1395 1407 * is invalid. 1396 - * @state: SELinux state 1397 1408 * @sid: security identifier, SID 1398 1409 * @scontext: security context 1399 1410 * @scontext_len: length in bytes ··· 1402 1417 * this string (or NULL if the context is valid) and set @scontext_len to 1403 1418 * the length of the string (or 0 if the context is valid). 1404 1419 */ 1405 - int security_sid_to_context_inval(struct selinux_state *state, u32 sid, 1420 + int security_sid_to_context_inval(u32 sid, 1406 1421 char **scontext, u32 *scontext_len) 1407 1422 { 1408 - return security_sid_to_context_core(state, sid, scontext, 1423 + return security_sid_to_context_core(sid, scontext, 1409 1424 scontext_len, 1, 1); 1410 1425 } 1411 1426 ··· 1490 1505 return rc; 1491 1506 } 1492 1507 1493 - static int security_context_to_sid_core(struct selinux_state *state, 1494 - const char *scontext, u32 scontext_len, 1508 + static int security_context_to_sid_core(const char *scontext, u32 scontext_len, 1495 1509 u32 *sid, u32 def_sid, gfp_t gfp_flags, 1496 1510 int force) 1497 1511 { ··· 1510 1526 if (!scontext2) 1511 1527 return -ENOMEM; 1512 1528 1513 - if (!selinux_initialized(state)) { 1529 + if (!selinux_initialized()) { 1514 1530 int i; 1515 1531 1516 1532 for (i = 1; i < SECINITSID_NUM; i++) { ··· 1535 1551 } 1536 1552 retry: 1537 1553 rcu_read_lock(); 1538 - policy = rcu_dereference(state->policy); 1554 + policy = rcu_dereference(selinux_state.policy); 1539 1555 policydb = &policy->policydb; 1540 1556 sidtab = policy->sidtab; 1541 1557 rc = string_to_context_struct(policydb, sidtab, scontext2, ··· 1567 1583 1568 1584 /** 1569 1585 * security_context_to_sid - Obtain a SID for a given security context. 1570 - * @state: SELinux state 1571 1586 * @scontext: security context 1572 1587 * @scontext_len: length in bytes 1573 1588 * @sid: security identifier, SID ··· 1577 1594 * Returns -%EINVAL if the context is invalid, -%ENOMEM if insufficient 1578 1595 * memory is available, or 0 on success. 1579 1596 */ 1580 - int security_context_to_sid(struct selinux_state *state, 1581 - const char *scontext, u32 scontext_len, u32 *sid, 1597 + int security_context_to_sid(const char *scontext, u32 scontext_len, u32 *sid, 1582 1598 gfp_t gfp) 1583 1599 { 1584 - return security_context_to_sid_core(state, scontext, scontext_len, 1600 + return security_context_to_sid_core(scontext, scontext_len, 1585 1601 sid, SECSID_NULL, gfp, 0); 1586 1602 } 1587 1603 1588 - int security_context_str_to_sid(struct selinux_state *state, 1589 - const char *scontext, u32 *sid, gfp_t gfp) 1604 + int security_context_str_to_sid(const char *scontext, u32 *sid, gfp_t gfp) 1590 1605 { 1591 - return security_context_to_sid(state, scontext, strlen(scontext), 1606 + return security_context_to_sid(scontext, strlen(scontext), 1592 1607 sid, gfp); 1593 1608 } 1594 1609 ··· 1594 1613 * security_context_to_sid_default - Obtain a SID for a given security context, 1595 1614 * falling back to specified default if needed. 1596 1615 * 1597 - * @state: SELinux state 1598 1616 * @scontext: security context 1599 1617 * @scontext_len: length in bytes 1600 1618 * @sid: security identifier, SID ··· 1609 1629 * Returns -%EINVAL if the context is invalid, -%ENOMEM if insufficient 1610 1630 * memory is available, or 0 on success. 1611 1631 */ 1612 - int security_context_to_sid_default(struct selinux_state *state, 1613 - const char *scontext, u32 scontext_len, 1632 + int security_context_to_sid_default(const char *scontext, u32 scontext_len, 1614 1633 u32 *sid, u32 def_sid, gfp_t gfp_flags) 1615 1634 { 1616 - return security_context_to_sid_core(state, scontext, scontext_len, 1635 + return security_context_to_sid_core(scontext, scontext_len, 1617 1636 sid, def_sid, gfp_flags, 1); 1618 1637 } 1619 1638 1620 - int security_context_to_sid_force(struct selinux_state *state, 1621 - const char *scontext, u32 scontext_len, 1639 + int security_context_to_sid_force(const char *scontext, u32 scontext_len, 1622 1640 u32 *sid) 1623 1641 { 1624 - return security_context_to_sid_core(state, scontext, scontext_len, 1642 + return security_context_to_sid_core(scontext, scontext_len, 1625 1643 sid, SECSID_NULL, GFP_KERNEL, 1); 1626 1644 } 1627 1645 1628 1646 static int compute_sid_handle_invalid_context( 1629 - struct selinux_state *state, 1630 1647 struct selinux_policy *policy, 1631 1648 struct sidtab_entry *sentry, 1632 1649 struct sidtab_entry *tentry, ··· 1656 1679 kfree(s); 1657 1680 kfree(t); 1658 1681 kfree(n); 1659 - if (!enforcing_enabled(state)) 1682 + if (!enforcing_enabled()) 1660 1683 return 0; 1661 1684 return -EACCES; 1662 1685 } ··· 1691 1714 } 1692 1715 } 1693 1716 1694 - static int security_compute_sid(struct selinux_state *state, 1695 - u32 ssid, 1717 + static int security_compute_sid(u32 ssid, 1696 1718 u32 tsid, 1697 1719 u16 orig_tclass, 1698 1720 u32 specified, ··· 1712 1736 int rc = 0; 1713 1737 bool sock; 1714 1738 1715 - if (!selinux_initialized(state)) { 1739 + if (!selinux_initialized()) { 1716 1740 switch (orig_tclass) { 1717 1741 case SECCLASS_PROCESS: /* kernel value */ 1718 1742 *out_sid = ssid; ··· 1730 1754 1731 1755 rcu_read_lock(); 1732 1756 1733 - policy = rcu_dereference(state->policy); 1757 + policy = rcu_dereference(selinux_state.policy); 1734 1758 1735 1759 if (kern) { 1736 1760 tclass = unmap_class(&policy->map, orig_tclass); ··· 1862 1886 1863 1887 /* Check the validity of the context. */ 1864 1888 if (!policydb_context_isvalid(policydb, &newcontext)) { 1865 - rc = compute_sid_handle_invalid_context(state, policy, sentry, 1889 + rc = compute_sid_handle_invalid_context(policy, sentry, 1866 1890 tentry, tclass, 1867 1891 &newcontext); 1868 1892 if (rc) ··· 1884 1908 1885 1909 /** 1886 1910 * security_transition_sid - Compute the SID for a new subject/object. 1887 - * @state: SELinux state 1888 1911 * @ssid: source security identifier 1889 1912 * @tsid: target security identifier 1890 1913 * @tclass: target security class ··· 1896 1921 * if insufficient memory is available, or %0 if the new SID was 1897 1922 * computed successfully. 1898 1923 */ 1899 - int security_transition_sid(struct selinux_state *state, 1900 - u32 ssid, u32 tsid, u16 tclass, 1924 + int security_transition_sid(u32 ssid, u32 tsid, u16 tclass, 1901 1925 const struct qstr *qstr, u32 *out_sid) 1902 1926 { 1903 - return security_compute_sid(state, ssid, tsid, tclass, 1927 + return security_compute_sid(ssid, tsid, tclass, 1904 1928 AVTAB_TRANSITION, 1905 1929 qstr ? qstr->name : NULL, out_sid, true); 1906 1930 } 1907 1931 1908 - int security_transition_sid_user(struct selinux_state *state, 1909 - u32 ssid, u32 tsid, u16 tclass, 1932 + int security_transition_sid_user(u32 ssid, u32 tsid, u16 tclass, 1910 1933 const char *objname, u32 *out_sid) 1911 1934 { 1912 - return security_compute_sid(state, ssid, tsid, tclass, 1935 + return security_compute_sid(ssid, tsid, tclass, 1913 1936 AVTAB_TRANSITION, 1914 1937 objname, out_sid, false); 1915 1938 } 1916 1939 1917 1940 /** 1918 1941 * security_member_sid - Compute the SID for member selection. 1919 - * @state: SELinux state 1920 1942 * @ssid: source security identifier 1921 1943 * @tsid: target security identifier 1922 1944 * @tclass: target security class ··· 1925 1953 * if insufficient memory is available, or %0 if the SID was 1926 1954 * computed successfully. 1927 1955 */ 1928 - int security_member_sid(struct selinux_state *state, 1929 - u32 ssid, 1956 + int security_member_sid(u32 ssid, 1930 1957 u32 tsid, 1931 1958 u16 tclass, 1932 1959 u32 *out_sid) 1933 1960 { 1934 - return security_compute_sid(state, ssid, tsid, tclass, 1961 + return security_compute_sid(ssid, tsid, tclass, 1935 1962 AVTAB_MEMBER, NULL, 1936 1963 out_sid, false); 1937 1964 } 1938 1965 1939 1966 /** 1940 1967 * security_change_sid - Compute the SID for object relabeling. 1941 - * @state: SELinux state 1942 1968 * @ssid: source security identifier 1943 1969 * @tsid: target security identifier 1944 1970 * @tclass: target security class ··· 1948 1978 * if insufficient memory is available, or %0 if the SID was 1949 1979 * computed successfully. 1950 1980 */ 1951 - int security_change_sid(struct selinux_state *state, 1952 - u32 ssid, 1981 + int security_change_sid(u32 ssid, 1953 1982 u32 tsid, 1954 1983 u16 tclass, 1955 1984 u32 *out_sid) 1956 1985 { 1957 - return security_compute_sid(state, 1958 - ssid, tsid, tclass, AVTAB_CHANGE, NULL, 1986 + return security_compute_sid(ssid, tsid, tclass, AVTAB_CHANGE, NULL, 1959 1987 out_sid, false); 1960 1988 } 1961 1989 1962 1990 static inline int convert_context_handle_invalid_context( 1963 - struct selinux_state *state, 1964 1991 struct policydb *policydb, 1965 1992 struct context *context) 1966 1993 { 1967 1994 char *s; 1968 1995 u32 len; 1969 1996 1970 - if (enforcing_enabled(state)) 1997 + if (enforcing_enabled()) 1971 1998 return -EINVAL; 1972 1999 1973 2000 if (!context_struct_to_string(policydb, context, &s, &len)) { ··· 2082 2115 2083 2116 /* Check the validity of the new context. */ 2084 2117 if (!policydb_context_isvalid(args->newp, newc)) { 2085 - rc = convert_context_handle_invalid_context(args->state, 2086 - args->oldp, oldc); 2118 + rc = convert_context_handle_invalid_context(args->oldp, oldc); 2087 2119 if (rc) 2088 2120 goto bad; 2089 2121 } ··· 2101 2135 return 0; 2102 2136 } 2103 2137 2104 - static void security_load_policycaps(struct selinux_state *state, 2105 - struct selinux_policy *policy) 2138 + static void security_load_policycaps(struct selinux_policy *policy) 2106 2139 { 2107 2140 struct policydb *p; 2108 2141 unsigned int i; ··· 2109 2144 2110 2145 p = &policy->policydb; 2111 2146 2112 - for (i = 0; i < ARRAY_SIZE(state->policycap); i++) 2113 - WRITE_ONCE(state->policycap[i], 2147 + for (i = 0; i < ARRAY_SIZE(selinux_state.policycap); i++) 2148 + WRITE_ONCE(selinux_state.policycap[i], 2114 2149 ebitmap_get_bit(&p->policycaps, i)); 2115 2150 2116 2151 for (i = 0; i < ARRAY_SIZE(selinux_policycap_names); i++) ··· 2146 2181 kfree(policy); 2147 2182 } 2148 2183 2149 - void selinux_policy_cancel(struct selinux_state *state, 2150 - struct selinux_load_state *load_state) 2184 + void selinux_policy_cancel(struct selinux_load_state *load_state) 2151 2185 { 2186 + struct selinux_state *state = &selinux_state; 2152 2187 struct selinux_policy *oldpolicy; 2153 2188 2154 2189 oldpolicy = rcu_dereference_protected(state->policy, ··· 2159 2194 kfree(load_state->convert_data); 2160 2195 } 2161 2196 2162 - static void selinux_notify_policy_change(struct selinux_state *state, 2163 - u32 seqno) 2197 + static void selinux_notify_policy_change(u32 seqno) 2164 2198 { 2165 2199 /* Flush external caches and notify userspace of policy load */ 2166 - avc_ss_reset(state->avc, seqno); 2200 + avc_ss_reset(seqno); 2167 2201 selnl_notify_policyload(seqno); 2168 - selinux_status_update_policyload(state, seqno); 2202 + selinux_status_update_policyload(seqno); 2169 2203 selinux_netlbl_cache_invalidate(); 2170 2204 selinux_xfrm_notify_policyload(); 2171 - selinux_ima_measure_state_locked(state); 2205 + selinux_ima_measure_state_locked(); 2172 2206 } 2173 2207 2174 - void selinux_policy_commit(struct selinux_state *state, 2175 - struct selinux_load_state *load_state) 2208 + void selinux_policy_commit(struct selinux_load_state *load_state) 2176 2209 { 2210 + struct selinux_state *state = &selinux_state; 2177 2211 struct selinux_policy *oldpolicy, *newpolicy = load_state->policy; 2178 2212 unsigned long flags; 2179 2213 u32 seqno; ··· 2205 2241 } 2206 2242 2207 2243 /* Load the policycaps from the new policy */ 2208 - security_load_policycaps(state, newpolicy); 2244 + security_load_policycaps(newpolicy); 2209 2245 2210 - if (!selinux_initialized(state)) { 2246 + if (!selinux_initialized()) { 2211 2247 /* 2212 2248 * After first policy load, the security server is 2213 2249 * marked as initialized and ready to handle requests and 2214 2250 * any objects created prior to policy load are then labeled. 2215 2251 */ 2216 - selinux_mark_initialized(state); 2252 + selinux_mark_initialized(); 2217 2253 selinux_complete_init(); 2218 2254 } 2219 2255 ··· 2223 2259 kfree(load_state->convert_data); 2224 2260 2225 2261 /* Notify others of the policy change */ 2226 - selinux_notify_policy_change(state, seqno); 2262 + selinux_notify_policy_change(seqno); 2227 2263 } 2228 2264 2229 2265 /** 2230 2266 * security_load_policy - Load a security policy configuration. 2231 - * @state: SELinux state 2232 2267 * @data: binary policy data 2233 2268 * @len: length of data in bytes 2234 2269 * @load_state: policy load state ··· 2237 2274 * This function will flush the access vector cache after 2238 2275 * loading the new policy. 2239 2276 */ 2240 - int security_load_policy(struct selinux_state *state, void *data, size_t len, 2277 + int security_load_policy(void *data, size_t len, 2241 2278 struct selinux_load_state *load_state) 2242 2279 { 2280 + struct selinux_state *state = &selinux_state; 2243 2281 struct selinux_policy *newpolicy, *oldpolicy; 2244 2282 struct selinux_policy_convert_data *convert_data; 2245 2283 int rc = 0; ··· 2272 2308 goto err_mapping; 2273 2309 } 2274 2310 2275 - if (!selinux_initialized(state)) { 2311 + if (!selinux_initialized()) { 2276 2312 /* First policy load, so no need to preserve state from old policy */ 2277 2313 load_state->policy = newpolicy; 2278 2314 load_state->convert_data = NULL; ··· 2300 2336 goto err_free_isids; 2301 2337 } 2302 2338 2303 - convert_data->args.state = state; 2304 2339 convert_data->args.oldp = &oldpolicy->policydb; 2305 2340 convert_data->args.newp = &newpolicy->policydb; 2306 2341 ··· 2373 2410 2374 2411 /** 2375 2412 * security_port_sid - Obtain the SID for a port. 2376 - * @state: SELinux state 2377 2413 * @protocol: protocol number 2378 2414 * @port: port number 2379 2415 * @out_sid: security identifier 2380 2416 */ 2381 - int security_port_sid(struct selinux_state *state, 2382 - u8 protocol, u16 port, u32 *out_sid) 2417 + int security_port_sid(u8 protocol, u16 port, u32 *out_sid) 2383 2418 { 2384 2419 struct selinux_policy *policy; 2385 2420 struct policydb *policydb; ··· 2385 2424 struct ocontext *c; 2386 2425 int rc; 2387 2426 2388 - if (!selinux_initialized(state)) { 2427 + if (!selinux_initialized()) { 2389 2428 *out_sid = SECINITSID_PORT; 2390 2429 return 0; 2391 2430 } ··· 2393 2432 retry: 2394 2433 rc = 0; 2395 2434 rcu_read_lock(); 2396 - policy = rcu_dereference(state->policy); 2435 + policy = rcu_dereference(selinux_state.policy); 2397 2436 policydb = &policy->policydb; 2398 2437 sidtab = policy->sidtab; 2399 2438 ··· 2425 2464 2426 2465 /** 2427 2466 * security_ib_pkey_sid - Obtain the SID for a pkey. 2428 - * @state: SELinux state 2429 2467 * @subnet_prefix: Subnet Prefix 2430 2468 * @pkey_num: pkey number 2431 2469 * @out_sid: security identifier 2432 2470 */ 2433 - int security_ib_pkey_sid(struct selinux_state *state, 2434 - u64 subnet_prefix, u16 pkey_num, u32 *out_sid) 2471 + int security_ib_pkey_sid(u64 subnet_prefix, u16 pkey_num, u32 *out_sid) 2435 2472 { 2436 2473 struct selinux_policy *policy; 2437 2474 struct policydb *policydb; ··· 2437 2478 struct ocontext *c; 2438 2479 int rc; 2439 2480 2440 - if (!selinux_initialized(state)) { 2481 + if (!selinux_initialized()) { 2441 2482 *out_sid = SECINITSID_UNLABELED; 2442 2483 return 0; 2443 2484 } ··· 2445 2486 retry: 2446 2487 rc = 0; 2447 2488 rcu_read_lock(); 2448 - policy = rcu_dereference(state->policy); 2489 + policy = rcu_dereference(selinux_state.policy); 2449 2490 policydb = &policy->policydb; 2450 2491 sidtab = policy->sidtab; 2451 2492 ··· 2477 2518 2478 2519 /** 2479 2520 * security_ib_endport_sid - Obtain the SID for a subnet management interface. 2480 - * @state: SELinux state 2481 2521 * @dev_name: device name 2482 2522 * @port_num: port number 2483 2523 * @out_sid: security identifier 2484 2524 */ 2485 - int security_ib_endport_sid(struct selinux_state *state, 2486 - const char *dev_name, u8 port_num, u32 *out_sid) 2525 + int security_ib_endport_sid(const char *dev_name, u8 port_num, u32 *out_sid) 2487 2526 { 2488 2527 struct selinux_policy *policy; 2489 2528 struct policydb *policydb; ··· 2489 2532 struct ocontext *c; 2490 2533 int rc; 2491 2534 2492 - if (!selinux_initialized(state)) { 2535 + if (!selinux_initialized()) { 2493 2536 *out_sid = SECINITSID_UNLABELED; 2494 2537 return 0; 2495 2538 } ··· 2497 2540 retry: 2498 2541 rc = 0; 2499 2542 rcu_read_lock(); 2500 - policy = rcu_dereference(state->policy); 2543 + policy = rcu_dereference(selinux_state.policy); 2501 2544 policydb = &policy->policydb; 2502 2545 sidtab = policy->sidtab; 2503 2546 ··· 2530 2573 2531 2574 /** 2532 2575 * security_netif_sid - Obtain the SID for a network interface. 2533 - * @state: SELinux state 2534 2576 * @name: interface name 2535 2577 * @if_sid: interface SID 2536 2578 */ 2537 - int security_netif_sid(struct selinux_state *state, 2538 - char *name, u32 *if_sid) 2579 + int security_netif_sid(char *name, u32 *if_sid) 2539 2580 { 2540 2581 struct selinux_policy *policy; 2541 2582 struct policydb *policydb; ··· 2541 2586 int rc; 2542 2587 struct ocontext *c; 2543 2588 2544 - if (!selinux_initialized(state)) { 2589 + if (!selinux_initialized()) { 2545 2590 *if_sid = SECINITSID_NETIF; 2546 2591 return 0; 2547 2592 } ··· 2549 2594 retry: 2550 2595 rc = 0; 2551 2596 rcu_read_lock(); 2552 - policy = rcu_dereference(state->policy); 2597 + policy = rcu_dereference(selinux_state.policy); 2553 2598 policydb = &policy->policydb; 2554 2599 sidtab = policy->sidtab; 2555 2600 ··· 2591 2636 2592 2637 /** 2593 2638 * security_node_sid - Obtain the SID for a node (host). 2594 - * @state: SELinux state 2595 2639 * @domain: communication domain aka address family 2596 2640 * @addrp: address 2597 2641 * @addrlen: address length in bytes 2598 2642 * @out_sid: security identifier 2599 2643 */ 2600 - int security_node_sid(struct selinux_state *state, 2601 - u16 domain, 2644 + int security_node_sid(u16 domain, 2602 2645 void *addrp, 2603 2646 u32 addrlen, 2604 2647 u32 *out_sid) ··· 2607 2654 int rc; 2608 2655 struct ocontext *c; 2609 2656 2610 - if (!selinux_initialized(state)) { 2657 + if (!selinux_initialized()) { 2611 2658 *out_sid = SECINITSID_NODE; 2612 2659 return 0; 2613 2660 } 2614 2661 2615 2662 retry: 2616 2663 rcu_read_lock(); 2617 - policy = rcu_dereference(state->policy); 2664 + policy = rcu_dereference(selinux_state.policy); 2618 2665 policydb = &policy->policydb; 2619 2666 sidtab = policy->sidtab; 2620 2667 ··· 2678 2725 2679 2726 /** 2680 2727 * security_get_user_sids - Obtain reachable SIDs for a user. 2681 - * @state: SELinux state 2682 2728 * @fromsid: starting SID 2683 2729 * @username: username 2684 2730 * @sids: array of reachable SIDs for user ··· 2690 2738 * number of elements in the array. 2691 2739 */ 2692 2740 2693 - int security_get_user_sids(struct selinux_state *state, 2694 - u32 fromsid, 2741 + int security_get_user_sids(u32 fromsid, 2695 2742 char *username, 2696 2743 u32 **sids, 2697 2744 u32 *nel) ··· 2709 2758 *sids = NULL; 2710 2759 *nel = 0; 2711 2760 2712 - if (!selinux_initialized(state)) 2761 + if (!selinux_initialized()) 2713 2762 return 0; 2714 2763 2715 2764 mysids = kcalloc(maxnel, sizeof(*mysids), GFP_KERNEL); ··· 2719 2768 retry: 2720 2769 mynel = 0; 2721 2770 rcu_read_lock(); 2722 - policy = rcu_dereference(state->policy); 2771 + policy = rcu_dereference(selinux_state.policy); 2723 2772 policydb = &policy->policydb; 2724 2773 sidtab = policy->sidtab; 2725 2774 ··· 2785 2834 } 2786 2835 for (i = 0, j = 0; i < mynel; i++) { 2787 2836 struct av_decision dummy_avd; 2788 - rc = avc_has_perm_noaudit(state, 2789 - fromsid, mysids[i], 2837 + rc = avc_has_perm_noaudit(fromsid, mysids[i], 2790 2838 SECCLASS_PROCESS, /* kernel value */ 2791 2839 PROCESS__TRANSITION, AVC_STRICT, 2792 2840 &dummy_avd); ··· 2858 2908 2859 2909 /** 2860 2910 * security_genfs_sid - Obtain a SID for a file in a filesystem 2861 - * @state: SELinux state 2862 2911 * @fstype: filesystem type 2863 2912 * @path: path from root of mount 2864 2913 * @orig_sclass: file security class ··· 2866 2917 * Acquire policy_rwlock before calling __security_genfs_sid() and release 2867 2918 * it afterward. 2868 2919 */ 2869 - int security_genfs_sid(struct selinux_state *state, 2870 - const char *fstype, 2920 + int security_genfs_sid(const char *fstype, 2871 2921 const char *path, 2872 2922 u16 orig_sclass, 2873 2923 u32 *sid) ··· 2874 2926 struct selinux_policy *policy; 2875 2927 int retval; 2876 2928 2877 - if (!selinux_initialized(state)) { 2929 + if (!selinux_initialized()) { 2878 2930 *sid = SECINITSID_UNLABELED; 2879 2931 return 0; 2880 2932 } 2881 2933 2882 2934 do { 2883 2935 rcu_read_lock(); 2884 - policy = rcu_dereference(state->policy); 2936 + policy = rcu_dereference(selinux_state.policy); 2885 2937 retval = __security_genfs_sid(policy, fstype, path, 2886 2938 orig_sclass, sid); 2887 2939 rcu_read_unlock(); ··· 2901 2953 2902 2954 /** 2903 2955 * security_fs_use - Determine how to handle labeling for a filesystem. 2904 - * @state: SELinux state 2905 2956 * @sb: superblock in question 2906 2957 */ 2907 - int security_fs_use(struct selinux_state *state, struct super_block *sb) 2958 + int security_fs_use(struct super_block *sb) 2908 2959 { 2909 2960 struct selinux_policy *policy; 2910 2961 struct policydb *policydb; ··· 2913 2966 struct superblock_security_struct *sbsec = selinux_superblock(sb); 2914 2967 const char *fstype = sb->s_type->name; 2915 2968 2916 - if (!selinux_initialized(state)) { 2969 + if (!selinux_initialized()) { 2917 2970 sbsec->behavior = SECURITY_FS_USE_NONE; 2918 2971 sbsec->sid = SECINITSID_UNLABELED; 2919 2972 return 0; ··· 2921 2974 2922 2975 retry: 2923 2976 rcu_read_lock(); 2924 - policy = rcu_dereference(state->policy); 2977 + policy = rcu_dereference(selinux_state.policy); 2925 2978 policydb = &policy->policydb; 2926 2979 sidtab = policy->sidtab; 2927 2980 ··· 3014 3067 } 3015 3068 3016 3069 3017 - int security_set_bools(struct selinux_state *state, u32 len, int *values) 3070 + int security_set_bools(u32 len, int *values) 3018 3071 { 3072 + struct selinux_state *state = &selinux_state; 3019 3073 struct selinux_policy *newpolicy, *oldpolicy; 3020 3074 int rc; 3021 3075 u32 i, seqno = 0; 3022 3076 3023 - if (!selinux_initialized(state)) 3077 + if (!selinux_initialized()) 3024 3078 return -EINVAL; 3025 3079 3026 3080 oldpolicy = rcu_dereference_protected(state->policy, ··· 3082 3134 selinux_policy_cond_free(oldpolicy); 3083 3135 3084 3136 /* Notify others of the policy change */ 3085 - selinux_notify_policy_change(state, seqno); 3137 + selinux_notify_policy_change(seqno); 3086 3138 return 0; 3087 3139 } 3088 3140 3089 - int security_get_bool_value(struct selinux_state *state, 3090 - u32 index) 3141 + int security_get_bool_value(u32 index) 3091 3142 { 3092 3143 struct selinux_policy *policy; 3093 3144 struct policydb *policydb; 3094 3145 int rc; 3095 3146 u32 len; 3096 3147 3097 - if (!selinux_initialized(state)) 3148 + if (!selinux_initialized()) 3098 3149 return 0; 3099 3150 3100 3151 rcu_read_lock(); 3101 - policy = rcu_dereference(state->policy); 3152 + policy = rcu_dereference(selinux_state.policy); 3102 3153 policydb = &policy->policydb; 3103 3154 3104 3155 rc = -EFAULT; ··· 3144 3197 * security_sid_mls_copy() - computes a new sid based on the given 3145 3198 * sid and the mls portion of mls_sid. 3146 3199 */ 3147 - int security_sid_mls_copy(struct selinux_state *state, 3148 - u32 sid, u32 mls_sid, u32 *new_sid) 3200 + int security_sid_mls_copy(u32 sid, u32 mls_sid, u32 *new_sid) 3149 3201 { 3150 3202 struct selinux_policy *policy; 3151 3203 struct policydb *policydb; ··· 3156 3210 u32 len; 3157 3211 int rc; 3158 3212 3159 - if (!selinux_initialized(state)) { 3213 + if (!selinux_initialized()) { 3160 3214 *new_sid = sid; 3161 3215 return 0; 3162 3216 } ··· 3166 3220 context_init(&newcon); 3167 3221 3168 3222 rcu_read_lock(); 3169 - policy = rcu_dereference(state->policy); 3223 + policy = rcu_dereference(selinux_state.policy); 3170 3224 policydb = &policy->policydb; 3171 3225 sidtab = policy->sidtab; 3172 3226 ··· 3200 3254 3201 3255 /* Check the validity of the new context. */ 3202 3256 if (!policydb_context_isvalid(policydb, &newcon)) { 3203 - rc = convert_context_handle_invalid_context(state, policydb, 3257 + rc = convert_context_handle_invalid_context(policydb, 3204 3258 &newcon); 3205 3259 if (rc) { 3206 3260 if (!context_struct_to_string(policydb, &newcon, &s, ··· 3234 3288 3235 3289 /** 3236 3290 * security_net_peersid_resolve - Compare and resolve two network peer SIDs 3237 - * @state: SELinux state 3238 3291 * @nlbl_sid: NetLabel SID 3239 3292 * @nlbl_type: NetLabel labeling protocol type 3240 3293 * @xfrm_sid: XFRM SID ··· 3253 3308 * multiple, inconsistent labels | -<errno> | SECSID_NULL 3254 3309 * 3255 3310 */ 3256 - int security_net_peersid_resolve(struct selinux_state *state, 3257 - u32 nlbl_sid, u32 nlbl_type, 3311 + int security_net_peersid_resolve(u32 nlbl_sid, u32 nlbl_type, 3258 3312 u32 xfrm_sid, 3259 3313 u32 *peer_sid) 3260 3314 { ··· 3281 3337 return 0; 3282 3338 } 3283 3339 3284 - if (!selinux_initialized(state)) 3340 + if (!selinux_initialized()) 3285 3341 return 0; 3286 3342 3287 3343 rcu_read_lock(); 3288 - policy = rcu_dereference(state->policy); 3344 + policy = rcu_dereference(selinux_state.policy); 3289 3345 policydb = &policy->policydb; 3290 3346 sidtab = policy->sidtab; 3291 3347 ··· 3426 3482 return rc; 3427 3483 } 3428 3484 3429 - int security_get_reject_unknown(struct selinux_state *state) 3485 + int security_get_reject_unknown(void) 3430 3486 { 3431 3487 struct selinux_policy *policy; 3432 3488 int value; 3433 3489 3434 - if (!selinux_initialized(state)) 3490 + if (!selinux_initialized()) 3435 3491 return 0; 3436 3492 3437 3493 rcu_read_lock(); 3438 - policy = rcu_dereference(state->policy); 3494 + policy = rcu_dereference(selinux_state.policy); 3439 3495 value = policy->policydb.reject_unknown; 3440 3496 rcu_read_unlock(); 3441 3497 return value; 3442 3498 } 3443 3499 3444 - int security_get_allow_unknown(struct selinux_state *state) 3500 + int security_get_allow_unknown(void) 3445 3501 { 3446 3502 struct selinux_policy *policy; 3447 3503 int value; 3448 3504 3449 - if (!selinux_initialized(state)) 3505 + if (!selinux_initialized()) 3450 3506 return 0; 3451 3507 3452 3508 rcu_read_lock(); 3453 - policy = rcu_dereference(state->policy); 3509 + policy = rcu_dereference(selinux_state.policy); 3454 3510 value = policy->policydb.allow_unknown; 3455 3511 rcu_read_unlock(); 3456 3512 return value; ··· 3458 3514 3459 3515 /** 3460 3516 * security_policycap_supported - Check for a specific policy capability 3461 - * @state: SELinux state 3462 3517 * @req_cap: capability 3463 3518 * 3464 3519 * Description: ··· 3466 3523 * supported, false (0) if it isn't supported. 3467 3524 * 3468 3525 */ 3469 - int security_policycap_supported(struct selinux_state *state, 3470 - unsigned int req_cap) 3526 + int security_policycap_supported(unsigned int req_cap) 3471 3527 { 3472 3528 struct selinux_policy *policy; 3473 3529 int rc; 3474 3530 3475 - if (!selinux_initialized(state)) 3531 + if (!selinux_initialized()) 3476 3532 return 0; 3477 3533 3478 3534 rcu_read_lock(); 3479 - policy = rcu_dereference(state->policy); 3535 + policy = rcu_dereference(selinux_state.policy); 3480 3536 rc = ebitmap_get_bit(&policy->policydb.policycaps, req_cap); 3481 3537 rcu_read_unlock(); 3482 3538 ··· 3511 3569 3512 3570 *rule = NULL; 3513 3571 3514 - if (!selinux_initialized(state)) 3572 + if (!selinux_initialized()) 3515 3573 return -EOPNOTSUPP; 3516 3574 3517 3575 switch (field) { ··· 3638 3696 return -ENOENT; 3639 3697 } 3640 3698 3641 - if (!selinux_initialized(state)) 3699 + if (!selinux_initialized()) 3642 3700 return 0; 3643 3701 3644 3702 rcu_read_lock(); ··· 3791 3849 3792 3850 /** 3793 3851 * security_netlbl_secattr_to_sid - Convert a NetLabel secattr to a SELinux SID 3794 - * @state: SELinux state 3795 3852 * @secattr: the NetLabel packet security attributes 3796 3853 * @sid: the SELinux SID 3797 3854 * ··· 3804 3863 * failure. 3805 3864 * 3806 3865 */ 3807 - int security_netlbl_secattr_to_sid(struct selinux_state *state, 3808 - struct netlbl_lsm_secattr *secattr, 3866 + int security_netlbl_secattr_to_sid(struct netlbl_lsm_secattr *secattr, 3809 3867 u32 *sid) 3810 3868 { 3811 3869 struct selinux_policy *policy; ··· 3814 3874 struct context *ctx; 3815 3875 struct context ctx_new; 3816 3876 3817 - if (!selinux_initialized(state)) { 3877 + if (!selinux_initialized()) { 3818 3878 *sid = SECSID_NULL; 3819 3879 return 0; 3820 3880 } ··· 3822 3882 retry: 3823 3883 rc = 0; 3824 3884 rcu_read_lock(); 3825 - policy = rcu_dereference(state->policy); 3885 + policy = rcu_dereference(selinux_state.policy); 3826 3886 policydb = &policy->policydb; 3827 3887 sidtab = policy->sidtab; 3828 3888 ··· 3872 3932 3873 3933 /** 3874 3934 * security_netlbl_sid_to_secattr - Convert a SELinux SID to a NetLabel secattr 3875 - * @state: SELinux state 3876 3935 * @sid: the SELinux SID 3877 3936 * @secattr: the NetLabel packet security attributes 3878 3937 * ··· 3880 3941 * Returns zero on success, negative values on failure. 3881 3942 * 3882 3943 */ 3883 - int security_netlbl_sid_to_secattr(struct selinux_state *state, 3884 - u32 sid, struct netlbl_lsm_secattr *secattr) 3944 + int security_netlbl_sid_to_secattr(u32 sid, struct netlbl_lsm_secattr *secattr) 3885 3945 { 3886 3946 struct selinux_policy *policy; 3887 3947 struct policydb *policydb; 3888 3948 int rc; 3889 3949 struct context *ctx; 3890 3950 3891 - if (!selinux_initialized(state)) 3951 + if (!selinux_initialized()) 3892 3952 return 0; 3893 3953 3894 3954 rcu_read_lock(); 3895 - policy = rcu_dereference(state->policy); 3955 + policy = rcu_dereference(selinux_state.policy); 3896 3956 policydb = &policy->policydb; 3897 3957 3898 3958 rc = -ENOENT; ··· 3941 4003 3942 4004 /** 3943 4005 * security_read_policy - read the policy. 3944 - * @state: selinux_state 3945 4006 * @data: binary policy data 3946 4007 * @len: length of data in bytes 3947 4008 * 3948 4009 */ 3949 - int security_read_policy(struct selinux_state *state, 3950 - void **data, size_t *len) 4010 + int security_read_policy(void **data, size_t *len) 3951 4011 { 4012 + struct selinux_state *state = &selinux_state; 3952 4013 struct selinux_policy *policy; 3953 4014 3954 4015 policy = rcu_dereference_protected( ··· 3965 4028 3966 4029 /** 3967 4030 * security_read_state_kernel - read the policy. 3968 - * @state: selinux_state 3969 4031 * @data: binary policy data 3970 4032 * @len: length of data in bytes 3971 4033 * ··· 3974 4038 * 3975 4039 * This function must be called with policy_mutex held. 3976 4040 */ 3977 - int security_read_state_kernel(struct selinux_state *state, 3978 - void **data, size_t *len) 4041 + int security_read_state_kernel(void **data, size_t *len) 3979 4042 { 3980 4043 int err; 4044 + struct selinux_state *state = &selinux_state; 3981 4045 struct selinux_policy *policy; 3982 4046 3983 4047 policy = rcu_dereference_protected(
-1
security/selinux/ss/services.h
··· 30 30 } __randomize_layout; 31 31 32 32 struct convert_context_args { 33 - struct selinux_state *state; 34 33 struct policydb *oldp; 35 34 struct policydb *newp; 36 35 };
+21 -23
security/selinux/status.c
··· 39 39 * It returns a reference to selinux_status_page. If the status page is 40 40 * not allocated yet, it also tries to allocate it at the first time. 41 41 */ 42 - struct page *selinux_kernel_status_page(struct selinux_state *state) 42 + struct page *selinux_kernel_status_page(void) 43 43 { 44 44 struct selinux_kernel_status *status; 45 45 struct page *result = NULL; 46 46 47 - mutex_lock(&state->status_lock); 48 - if (!state->status_page) { 49 - state->status_page = alloc_page(GFP_KERNEL|__GFP_ZERO); 47 + mutex_lock(&selinux_state.status_lock); 48 + if (!selinux_state.status_page) { 49 + selinux_state.status_page = alloc_page(GFP_KERNEL|__GFP_ZERO); 50 50 51 - if (state->status_page) { 52 - status = page_address(state->status_page); 51 + if (selinux_state.status_page) { 52 + status = page_address(selinux_state.status_page); 53 53 54 54 status->version = SELINUX_KERNEL_STATUS_VERSION; 55 55 status->sequence = 0; 56 - status->enforcing = enforcing_enabled(state); 56 + status->enforcing = enforcing_enabled(); 57 57 /* 58 58 * NOTE: the next policyload event shall set 59 59 * a positive value on the status->policyload, ··· 62 62 */ 63 63 status->policyload = 0; 64 64 status->deny_unknown = 65 - !security_get_allow_unknown(state); 65 + !security_get_allow_unknown(); 66 66 } 67 67 } 68 - result = state->status_page; 69 - mutex_unlock(&state->status_lock); 68 + result = selinux_state.status_page; 69 + mutex_unlock(&selinux_state.status_lock); 70 70 71 71 return result; 72 72 } ··· 76 76 * 77 77 * It updates status of the current enforcing/permissive mode. 78 78 */ 79 - void selinux_status_update_setenforce(struct selinux_state *state, 80 - int enforcing) 79 + void selinux_status_update_setenforce(int enforcing) 81 80 { 82 81 struct selinux_kernel_status *status; 83 82 84 - mutex_lock(&state->status_lock); 85 - if (state->status_page) { 86 - status = page_address(state->status_page); 83 + mutex_lock(&selinux_state.status_lock); 84 + if (selinux_state.status_page) { 85 + status = page_address(selinux_state.status_page); 87 86 88 87 status->sequence++; 89 88 smp_wmb(); ··· 92 93 smp_wmb(); 93 94 status->sequence++; 94 95 } 95 - mutex_unlock(&state->status_lock); 96 + mutex_unlock(&selinux_state.status_lock); 96 97 } 97 98 98 99 /* ··· 101 102 * It updates status of the times of policy reloaded, and current 102 103 * setting of deny_unknown. 103 104 */ 104 - void selinux_status_update_policyload(struct selinux_state *state, 105 - int seqno) 105 + void selinux_status_update_policyload(int seqno) 106 106 { 107 107 struct selinux_kernel_status *status; 108 108 109 - mutex_lock(&state->status_lock); 110 - if (state->status_page) { 111 - status = page_address(state->status_page); 109 + mutex_lock(&selinux_state.status_lock); 110 + if (selinux_state.status_page) { 111 + status = page_address(selinux_state.status_page); 112 112 113 113 status->sequence++; 114 114 smp_wmb(); 115 115 116 116 status->policyload = seqno; 117 - status->deny_unknown = !security_get_allow_unknown(state); 117 + status->deny_unknown = !security_get_allow_unknown(); 118 118 119 119 smp_wmb(); 120 120 status->sequence++; 121 121 } 122 - mutex_unlock(&state->status_lock); 122 + mutex_unlock(&selinux_state.status_lock); 123 123 }
+8 -12
security/selinux/xfrm.c
··· 98 98 ctx->ctx_len = str_len; 99 99 memcpy(ctx->ctx_str, &uctx[1], str_len); 100 100 ctx->ctx_str[str_len] = '\0'; 101 - rc = security_context_to_sid(&selinux_state, ctx->ctx_str, str_len, 101 + rc = security_context_to_sid(ctx->ctx_str, str_len, 102 102 &ctx->ctx_sid, gfp); 103 103 if (rc) 104 104 goto err; 105 105 106 - rc = avc_has_perm(&selinux_state, 107 - tsec->sid, ctx->ctx_sid, 106 + rc = avc_has_perm(tsec->sid, ctx->ctx_sid, 108 107 SECCLASS_ASSOCIATION, ASSOCIATION__SETCONTEXT, NULL); 109 108 if (rc) 110 109 goto err; ··· 139 140 if (!ctx) 140 141 return 0; 141 142 142 - return avc_has_perm(&selinux_state, 143 - tsec->sid, ctx->ctx_sid, 143 + return avc_has_perm(tsec->sid, ctx->ctx_sid, 144 144 SECCLASS_ASSOCIATION, ASSOCIATION__SETCONTEXT, 145 145 NULL); 146 146 } ··· 161 163 if (!selinux_authorizable_ctx(ctx)) 162 164 return -EINVAL; 163 165 164 - rc = avc_has_perm(&selinux_state, 165 - fl_secid, ctx->ctx_sid, 166 + rc = avc_has_perm(fl_secid, ctx->ctx_sid, 166 167 SECCLASS_ASSOCIATION, ASSOCIATION__POLMATCH, NULL); 167 168 return (rc == -EACCES ? -ESRCH : rc); 168 169 } ··· 202 205 /* We don't need a separate SA Vs. policy polmatch check since the SA 203 206 * is now of the same label as the flow and a flow Vs. policy polmatch 204 207 * check had already happened in selinux_xfrm_policy_lookup() above. */ 205 - return (avc_has_perm(&selinux_state, flic_sid, state_sid, 208 + return (avc_has_perm(flic_sid, state_sid, 206 209 SECCLASS_ASSOCIATION, ASSOCIATION__SENDTO, 207 210 NULL) ? 0 : 1); 208 211 } ··· 352 355 if (secid == 0) 353 356 return -EINVAL; 354 357 355 - rc = security_sid_to_context(&selinux_state, secid, &ctx_str, 358 + rc = security_sid_to_context(secid, &ctx_str, 356 359 &str_len); 357 360 if (rc) 358 361 return rc; ··· 421 424 /* This check even when there's no association involved is intended, 422 425 * according to Trent Jaeger, to make sure a process can't engage in 423 426 * non-IPsec communication unless explicitly allowed by policy. */ 424 - return avc_has_perm(&selinux_state, 425 - sk_sid, peer_sid, 427 + return avc_has_perm(sk_sid, peer_sid, 426 428 SECCLASS_ASSOCIATION, ASSOCIATION__RECVFROM, ad); 427 429 } 428 430 ··· 464 468 /* This check even when there's no association involved is intended, 465 469 * according to Trent Jaeger, to make sure a process can't engage in 466 470 * non-IPsec communication unless explicitly allowed by policy. */ 467 - return avc_has_perm(&selinux_state, sk_sid, SECINITSID_UNLABELED, 471 + return avc_has_perm(sk_sid, SECINITSID_UNLABELED, 468 472 SECCLASS_ASSOCIATION, ASSOCIATION__SENDTO, ad); 469 473 }