Commit 1c7ee23
smack: /smack/doi: accept previously used values
[ Upstream commit 33d589e ]
Writing to /smack/doi a value that has ever been
written there in the past disables networking for
non-ambient labels.
E.g.
# cat /smack/doi
3
# netlabelctl -p cipso list
Configured CIPSO mappings (1)
DOI value : 3
mapping type : PASS_THROUGH
# netlabelctl -p map list
Configured NetLabel domain mappings (3)
domain: "_" (IPv4)
protocol: UNLABELED
domain: DEFAULT (IPv4)
protocol: CIPSO, DOI = 3
domain: DEFAULT (IPv6)
protocol: UNLABELED
# cat /smack/ambient
_
# cat /proc/$$/attr/smack/current
_
# ping -c1 10.1.95.12
64 bytes from 10.1.95.12: icmp_seq=1 ttl=64 time=0.964 ms
# echo foo >/proc/$$/attr/smack/current
# ping -c1 10.1.95.12
64 bytes from 10.1.95.12: icmp_seq=1 ttl=64 time=0.956 ms
unknown option 86
# echo 4 >/smack/doi
# echo 3 >/smack/doi
!> [ 214.050395] smk_cipso_doi:691 cipso add rc = -17
# echo 3 >/smack/doi
!> [ 249.402261] smk_cipso_doi:678 remove rc = -2
!> [ 249.402261] smk_cipso_doi:691 cipso add rc = -17
# ping -c1 10.1.95.12
!!> ping: 10.1.95.12: Address family for hostname not supported
# echo _ >/proc/$$/attr/smack/current
# ping -c1 10.1.95.12
64 bytes from 10.1.95.12: icmp_seq=1 ttl=64 time=0.617 ms
This happens because Smack keeps decommissioned DOIs,
fails to re-add them, and consequently refuses to add
the “default” domain map:
# netlabelctl -p cipso list
Configured CIPSO mappings (2)
DOI value : 3
mapping type : PASS_THROUGH
DOI value : 4
mapping type : PASS_THROUGH
# netlabelctl -p map list
Configured NetLabel domain mappings (2)
domain: "_" (IPv4)
protocol: UNLABELED
!> (no ipv4 map for default domain here)
domain: DEFAULT (IPv6)
protocol: UNLABELED
Fix by clearing decommissioned DOI definitions and
serializing concurrent DOI updates with a new lock.
Also:
- allow /smack/doi to live unconfigured, since
adding a map (netlbl_cfg_cipsov4_map_add) may fail.
CIPSO_V4_DOI_UNKNOWN(0) indicates the unconfigured DOI
- add new DOI before removing the old default map,
so the old map remains if the add fails
(2008-02-04, Casey Schaufler)
Fixes: e114e47 ("Smack: Simplified Mandatory Access Control Kernel")
Signed-off-by: Konstantin Andreev <andreev@swemel.ru>
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>1 parent 661d872 commit 1c7ee23
1 file changed
+45
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
| |||
139 | 140 | | |
140 | 141 | | |
141 | 142 | | |
142 | | - | |
| 143 | + | |
143 | 144 | | |
144 | 145 | | |
145 | 146 | | |
| |||
679 | 680 | | |
680 | 681 | | |
681 | 682 | | |
682 | | - | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
683 | 686 | | |
684 | | - | |
| 687 | + | |
| 688 | + | |
685 | 689 | | |
686 | | - | |
| 690 | + | |
687 | 691 | | |
688 | 692 | | |
689 | 693 | | |
690 | | - | |
| 694 | + | |
691 | 695 | | |
692 | | - | |
693 | | - | |
694 | | - | |
695 | | - | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
696 | 700 | | |
697 | | - | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
698 | 706 | | |
699 | | - | |
| 707 | + | |
700 | 708 | | |
701 | 709 | | |
702 | 710 | | |
703 | 711 | | |
704 | 712 | | |
705 | 713 | | |
706 | | - | |
707 | | - | |
708 | | - | |
| 714 | + | |
709 | 715 | | |
710 | | - | |
| 716 | + | |
711 | 717 | | |
712 | | - | |
713 | | - | |
714 | | - | |
715 | | - | |
716 | | - | |
717 | | - | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
718 | 725 | | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
719 | 737 | | |
720 | 738 | | |
721 | 739 | | |
| |||
1617 | 1635 | | |
1618 | 1636 | | |
1619 | 1637 | | |
1620 | | - | |
1621 | | - | |
1622 | | - | |
1623 | 1638 | | |
1624 | | - | |
| 1639 | + | |
1625 | 1640 | | |
1626 | 1641 | | |
1627 | 1642 | | |
| |||
2998 | 3013 | | |
2999 | 3014 | | |
3000 | 3015 | | |
| 3016 | + | |
3001 | 3017 | | |
3002 | 3018 | | |
3003 | 3019 | | |
| |||
3016 | 3032 | | |
3017 | 3033 | | |
3018 | 3034 | | |
3019 | | - | |
| 3035 | + | |
| 3036 | + | |
| 3037 | + | |
| 3038 | + | |
3020 | 3039 | | |
3021 | 3040 | | |
3022 | 3041 | | |
| |||
0 commit comments