Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 | /* * Copyright (c) 2007-2016 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. The rights granted to you under the License * may not be used to create, or enable the creation or redistribution of, * unlawful or unlicensed copies of an Apple operating system, or to * circumvent, violate, or enable the circumvention or violation of, any * terms of an Apple operating system software license agreement. * * Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ /*- * Copyright (c) 1999-2002 Robert N. M. Watson * Copyright (c) 2001-2005 Networks Associates Technology, Inc. * Copyright (c) 2005-2007 SPARTA, Inc. * All rights reserved. * * This software was developed by Robert Watson for the TrustedBSD Project. * * This software was developed for the FreeBSD Project in part by Network * Associates Laboratories, the Security Research Division of Network * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), * as part of the DARPA CHATS research program. * * This software was enhanced by SPARTA ISSO under SPAWAR contract * N66001-04-C-6019 ("SEFOS"). * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD: src/sys/sys/mac_policy.h,v 1.39 2003/04/18 19:57:37 rwatson Exp $ */ /** @file mac_policy.h @brief Kernel Interfaces for MAC policy modules This header defines the list of operations that are defined by the TrustedBSD MAC Framwork on Darwin. MAC Policy modules register with the framework to declare interest in a specific set of operations. If interest in an entry point is not declared, then the policy will be ignored when the Framework evaluates that entry point. */ #ifndef _SECURITY_MAC_POLICY_H_ #define _SECURITY_MAC_POLICY_H_ #ifndef PRIVATE #warning "MAC policy is not KPI, see Technical Q&A QA1574, this header will be removed in next version" #endif #include <security/_label.h> struct attrlist; struct auditinfo; struct bpf_d; struct cs_blob; struct devnode; struct exception_action; struct fileglob; struct ifnet; struct inpcb; struct ipq; struct label; struct mac_module_data; struct mac_policy_conf; struct mbuf; struct mount; struct msg; struct msqid_kernel; struct pipe; struct pseminfo; struct pshminfo; struct sbuf; struct semid_kernel; struct shmid_kernel; struct socket; struct sockopt; struct task; struct thread; struct tty; struct ucred; struct vfs_attr; struct vnode; /** @struct dummy */ #ifndef _KAUTH_CRED_T #define _KAUTH_CRED_T typedef struct ucred *kauth_cred_t; #endif /* !_KAUTH_CRED_T */ #ifndef __IOKIT_PORTS_DEFINED__ #define __IOKIT_PORTS_DEFINED__ #ifdef __cplusplus class OSObject; typedef OSObject *io_object_t; #else struct OSObject; typedef struct OSObject *io_object_t; #endif #endif /* __IOKIT_PORTS_DEFINED__ */ /*- * MAC entry points are generally named using the following template: * * mpo_<object>_<operation>() * * or: * * mpo_<object>_check_<operation>() * * Entry points are sorted by object type. * * It may be desirable also to consider some subsystems as "objects", such * as system, iokit, etc. */ /** @name Entry Points for Label Management These are the entry points corresponding to the life cycle events for kernel objects, such as initialization, creation, and destruction. Most policies (that use labels) will initialize labels by allocating space for policy-specific data. In most cases, it is permitted to sleep during label initialization operations; it will be noted when it is not permitted. Initialization usually will not require doing more than allocating a generic label for the given object. What follows initialization is creation, where a label is made specific to the object it is associated with. Destruction occurs when the label is no longer needed, such as when the corresponding object is destroyed. All necessary cleanup should be performed in label destroy operations. Where possible, the label entry points have identical parameters. If the policy module does not require structure-specific label information, the same function may be registered in the policy operation vector. Many policies will implement two such generic allocation calls: one to handle sleepable requests, and one to handle potentially non-sleepable requests. */ /** @brief Audit event postselection @param cred Subject credential @param syscode Syscall number @param args Syscall arguments @param error Syscall errno @param retval Syscall return value This is the MAC Framework audit postselect, which is called before exiting a syscall to determine if an audit event should be committed. A return value of MAC_AUDIT_NO forces the audit record to be suppressed. Any other return value results in the audit record being committed. @warning The suppression behavior will probably go away in Apple's future version of the audit implementation. @return Return MAC_AUDIT_NO to force suppression of the audit record. Any other value results in the audit record being committed. */ typedef int mpo_audit_check_postselect_t( kauth_cred_t cred, unsigned short syscode, void *args, int error, int retval ); /** @brief Audit event preselection @param cred Subject credential @param syscode Syscall number @param args Syscall arguments This is the MAC Framework audit preselect, which is called before a syscall is entered to determine if an audit event should be created. If the MAC policy forces the syscall to be audited, MAC_AUDIT_YES should be returned. A return value of MAC_AUDIT_NO causes the audit record to be suppressed. Returning MAC_POLICY_DEFAULT indicates that the policy wants to defer to the system's existing preselection mechanism. When policies return different preferences, the Framework decides what action to take based on the following policy. If any policy returns MAC_AUDIT_YES, then create an audit record, else if any policy returns MAC_AUDIT_NO, then suppress the creations of an audit record, else defer to the system's existing preselection mechanism. @warning The audit implementation in Apple's current version is incomplete, so the MAC policies have priority over the system's existing mechanisms. This will probably change in the future version where the audit implementation is more complete. @return Return MAC_AUDIT_YES to force auditing of the syscall, MAC_AUDIT_NO to force no auditing of the syscall, MAC_AUDIT_DEFAULT to allow auditing mechanisms to determine if the syscall is audited. */ typedef int mpo_audit_check_preselect_t( kauth_cred_t cred, unsigned short syscode, void *args ); /** @brief Initialize BPF descriptor label @param label New label to initialize Initialize the label for a newly instantiated BPF descriptor. Sleeping is permitted. */ typedef void mpo_bpfdesc_label_init_t( struct label *label ); /** @brief Destroy BPF descriptor label @param label The label to be destroyed Destroy a BPF descriptor label. Since the BPF descriptor is going out of scope, policy modules should free any internal storage associated with the label so that it may be destroyed. */ typedef void mpo_bpfdesc_label_destroy_t( struct label *label ); /** @brief Associate a BPF descriptor with a label @param cred User credential creating the BPF descriptor @param bpf_d The BPF descriptor @param bpflabel The new label Set the label on a newly created BPF descriptor from the passed subject credential. This call will be made when a BPF device node is opened by a process with the passed subject credential. */ typedef void mpo_bpfdesc_label_associate_t( kauth_cred_t cred, struct bpf_d *bpf_d, struct label *bpflabel ); /** @brief Check whether BPF can read from a network interface @param bpf_d Subject; the BPF descriptor @param bpflabel Policy label for bpf_d @param ifp Object; the network interface @param ifnetlabel Policy label for ifp Determine whether the MAC framework should permit datagrams from the passed network interface to be delivered to the buffers of the passed BPF descriptor. Return (0) for success, or an errno value for failure. Suggested failure: EACCES for label mismatches, EPERM for lack of privilege. */ typedef int mpo_bpfdesc_check_receive_t( struct bpf_d *bpf_d, struct label *bpflabel, struct ifnet *ifp, struct label *ifnetlabel ); /** @brief Indicate desire to change the process label at exec time @param old Existing subject credential @param vp File being executed @param offset Offset of binary within file being executed @param scriptvp Script being executed by interpreter, if any. @param vnodelabel Label corresponding to vp @param scriptvnodelabel Script vnode label @param execlabel Userspace provided execution label @param p Object process @param macpolicyattr MAC policy-specific spawn attribute data @param macpolicyattrlen Length of policy-specific spawn attribute data @see mac_execve @see mpo_cred_label_update_execve_t @see mpo_vnode_check_exec_t Indicate whether this policy intends to update the label of a newly created credential from the existing subject credential (old). This call occurs when a process executes the passed vnode. If a policy returns success from this entry point, the mpo_cred_label_update_execve entry point will later be called with the same parameters. Access has already been checked via the mpo_vnode_check_exec entry point, this entry point is necessary to preserve kernel locking constraints during program execution. The supplied vnode and vnodelabel correspond with the file actually being executed; in the case that the file is interpreted (for example, a script), the label of the original exec-time vnode has been preserved in scriptvnodelabel. The final label, execlabel, corresponds to a label supplied by a user space application through the use of the mac_execve system call. The vnode lock is held during this operation. No changes should be made to the old credential structure. @warning Even if a policy returns 0, it should behave correctly in the presence of an invocation of mpo_cred_label_update_execve, as that call may happen as a result of another policy requesting a transition. @return Non-zero if a transition is required, 0 otherwise. */ typedef int mpo_cred_check_label_update_execve_t( kauth_cred_t old, struct vnode *vp, off_t offset, struct vnode *scriptvp, struct label *vnodelabel, struct label *scriptvnodelabel, struct label *execlabel, struct proc *p, void *macpolicyattr, size_t macpolicyattrlen ); /** @brief Access control check for relabelling processes @param cred Subject credential @param newlabel New label to apply to the user credential @see mpo_cred_label_update_t @see mac_set_proc Determine whether the subject identified by the credential can relabel itself to the supplied new label (newlabel). This access control check is called when the mac_set_proc system call is invoked. A user space application will supply a new value, the value will be internalized and provided in newlabel. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_cred_check_label_update_t( kauth_cred_t cred, struct label *newlabel ); /** @brief Access control check for visibility of other subjects @param u1 Subject credential @param u2 Object credential Determine whether the subject identified by the credential u1 can "see" other subjects with the passed subject credential u2. This call may be made in a number of situations, including inter-process status sysctls used by ps, and in procfs lookups. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch, EPERM for lack of privilege, or ESRCH to hide visibility. */ typedef int mpo_cred_check_visible_t( kauth_cred_t u1, kauth_cred_t u2 ); /** @brief Associate a credential with a new process at fork @param cred credential to inherited by new process @param proc the new process Allow a process to associate the credential with a new process for reference countng purposes. NOTE: the credential can be dis-associated in ways other than exit - so this strategy is flawed - should just catch label destroy callback. */ typedef void mpo_cred_label_associate_fork_t( kauth_cred_t cred, proc_t proc ); /** @brief Create the first process @param cred Subject credential to be labeled Create the subject credential of process 0, the parent of all BSD kernel processes. Policies should update the label in the previously initialized credential structure. */ typedef void mpo_cred_label_associate_kernel_t( kauth_cred_t cred ); /** @brief Create a credential label @param parent_cred Parent credential @param child_cred Child credential Set the label of a newly created credential, most likely using the information in the supplied parent credential. @warning This call is made when crcopy or crdup is invoked on a newly created struct ucred, and should not be confused with a process fork or creation event. */ typedef void mpo_cred_label_associate_t( kauth_cred_t parent_cred, kauth_cred_t child_cred ); /** @brief Create the first process @param cred Subject credential to be labeled Create the subject credential of process 1, the parent of all BSD user processes. Policies should update the label in the previously initialized credential structure. This is the 'init' process. */ typedef void mpo_cred_label_associate_user_t( kauth_cred_t cred ); /** @brief Destroy credential label @param label The label to be destroyed Destroy a user credential label. Since the user credential is going out of scope, policy modules should free any internal storage associated with the label so that it may be destroyed. */ typedef void mpo_cred_label_destroy_t( struct label *label ); /** @brief Externalize a user credential label for auditing @param label Label to be externalized @param element_name Name of the label namespace for which labels should be externalized @param sb String buffer to be filled with a text representation of the label Produce an external representation of the label on a user credential for inclusion in an audit record. An externalized label consists of a text representation of the label contents that will be added to the audit record as part of a text token. Policy-agnostic user space tools will display this externalized version. @return 0 on success, return non-zero if an error occurs while externalizing the label data. */ typedef int mpo_cred_label_externalize_audit_t( struct label *label, char *element_name, struct sbuf *sb ); /** @brief Externalize a user credential label @param label Label to be externalized @param element_name Name of the label namespace for which labels should be externalized @param sb String buffer to be filled with a text representation of the label Produce an external representation of the label on a user credential. An externalized label consists of a text representation of the label contents that can be used with user applications. Policy-agnostic user space tools will display this externalized version. @return 0 on success, return non-zero if an error occurs while externalizing the label data. */ typedef int mpo_cred_label_externalize_t( struct label *label, char *element_name, struct sbuf *sb ); /** @brief Initialize user credential label @param label New label to initialize Initialize the label for a newly instantiated user credential. Sleeping is permitted. */ typedef void mpo_cred_label_init_t( struct label *label ); /** @brief Internalize a user credential label @param label Label to be internalized @param element_name Name of the label namespace for which the label should be internalized @param element_data Text data to be internalized Produce a user credential label from an external representation. An externalized label consists of a text representation of the label contents that can be used with user applications. Policy-agnostic user space tools will forward text version to the kernel for processing by individual policy modules. The policy's internalize entry points will be called only if the policy has registered interest in the label namespace. @return 0 on success, Otherwise, return non-zero if an error occurs while internalizing the label data. */ typedef int mpo_cred_label_internalize_t( struct label *label, char *element_name, char *element_data ); /** @brief Update credential at exec time @param old_cred Existing subject credential @param new_cred New subject credential to be labeled @param p Object process. @param vp File being executed @param offset Offset of binary within file being executed @param scriptvp Script being executed by interpreter, if any. @param vnodelabel Label corresponding to vp @param scriptvnodelabel Script vnode label @param execlabel Userspace provided execution label @param csflags Code signing flags to be set after exec @param macpolicyattr MAC policy-specific spawn attribute data. @param macpolicyattrlen Length of policy-specific spawn attribute data. @see mac_execve @see mpo_cred_check_label_update_execve_t @see mpo_vnode_check_exec_t Update the label of a newly created credential (new) from the existing subject credential (old). This call occurs when a process executes the passed vnode and one of the loaded policy modules has returned success from the mpo_cred_check_label_update_execve entry point. Access has already been checked via the mpo_vnode_check_exec entry point, this entry point is only used to update any policy state. The supplied vnode and vnodelabel correspond with the file actually being executed; in the case that the file is interpreted (for example, a script), the label of the original exec-time vnode has been preserved in scriptvnodelabel. The final label, execlabel, corresponds to a label supplied by a user space application through the use of the mac_execve system call. If non-NULL, the value pointed to by disjointp will be set to 0 to indicate that the old and new credentials are not disjoint, or 1 to indicate that they are. The vnode lock is held during this operation. No changes should be made to the old credential structure. @return 0 on success, Otherwise, return non-zero if update results in termination of child. */ typedef int mpo_cred_label_update_execve_t( kauth_cred_t old_cred, kauth_cred_t new_cred, struct proc *p, struct vnode *vp, off_t offset, struct vnode *scriptvp, struct label *vnodelabel, struct label *scriptvnodelabel, struct label *execlabel, u_int *csflags, void *macpolicyattr, size_t macpolicyattrlen, int *disjointp ); /** @brief Update a credential label @param cred The existing credential @param newlabel A new label to apply to the credential @see mpo_cred_check_label_update_t @see mac_set_proc Update the label on a user credential, using the supplied new label. This is called as a result of a process relabel operation. Access control was already confirmed by mpo_cred_check_label_update. */ typedef void mpo_cred_label_update_t( kauth_cred_t cred, struct label *newlabel ); /** @brief Create a new devfs device @param dev Major and minor numbers of special file @param de "inode" of new device file @param label Destination label @param fullpath Path relative to mount (e.g. /dev) of new device file This entry point labels a new devfs device. The label will likely be based on the path to the device, or the major and minor numbers. The policy should store an appropriate label into 'label'. */ typedef void mpo_devfs_label_associate_device_t( dev_t dev, struct devnode *de, struct label *label, const char *fullpath ); /** @brief Create a new devfs directory @param dirname Name of new directory @param dirnamelen Length of 'dirname' @param de "inode" of new directory @param label Destination label @param fullpath Path relative to mount (e.g. /dev) of new directory This entry point labels a new devfs directory. The label will likely be based on the path of the new directory. The policy should store an appropriate label into 'label'. The devfs root directory is labelled in this way. */ typedef void mpo_devfs_label_associate_directory_t( const char *dirname, int dirnamelen, struct devnode *de, struct label *label, const char *fullpath ); /** @brief Copy a devfs label @param src Source devfs label @param dest Destination devfs label Copy the label information from src to dest. The devfs file system often duplicates (splits) existing device nodes rather than creating new ones. */ typedef void mpo_devfs_label_copy_t( struct label *src, struct label *dest ); /** @brief Destroy devfs label @param label The label to be destroyed Destroy a devfs entry label. Since the object is going out of scope, policy modules should free any internal storage associated with the label so that it may be destroyed. */ typedef void mpo_devfs_label_destroy_t( struct label *label ); /** @brief Initialize devfs label @param label New label to initialize Initialize the label for a newly instantiated devfs entry. Sleeping is permitted. */ typedef void mpo_devfs_label_init_t( struct label *label ); /** @brief Update a devfs label after relabelling its vnode @param mp Devfs mount point @param de Affected devfs directory entry @param delabel Label of devfs directory entry @param vp Vnode associated with de @param vnodelabel New label of vnode Update a devfs label when its vnode is manually relabelled, for example with setfmac(1). Typically, this will simply copy the vnode label into the devfs label. */ typedef void mpo_devfs_label_update_t( struct mount *mp, struct devnode *de, struct label *delabel, struct vnode *vp, struct label *vnodelabel ); /** @brief Access control for sending an exception to an exception action @param crashlabel The crashing process's label @param action Exception action @param exclabel Policy label for exception action Determine whether the the exception message caused by the victim process can be sent to the exception action. The policy may compare credentials in the crashlabel, which are derived from the process at the time the exception occurs, with the credentials in the exclabel, which was set at the time the exception port was set, to determine its decision. Note that any process from which the policy derived any credentials may not exist anymore at the time of this policy operation. Sleeping is permitted. @return Return 0 if the message can be sent, otherwise an appropriate value for errno should be returned. */ typedef int mpo_exc_action_check_exception_send_t( struct label *crashlabel, struct exception_action *action, struct label *exclabel ); /** @brief Associate an exception action label @param action Exception action to label @param exclabel Policy label to be filled in for exception action Set the label on an exception action. */ typedef void mpo_exc_action_label_associate_t( struct exception_action *action, struct label *exclabel ); /** @brief Destroy exception action label @param label The label to be destroyed Destroy the label on an exception action. Since the object is going out of scope, policy modules should free any internal storage associated with the label so that it may be destroyed. Sleeping is permitted. */ typedef void mpo_exc_action_label_destroy_t( struct label *label ); /** @brief Populate an exception action label with process credentials @param label The label to be populated @param proc Process to derive credentials from Populate a label with credentials derived from a process. At exception delivery time, the policy should compare credentials of the process that set an exception ports with the credentials of the process or corpse that experienced the exception. Note that the process that set the port may not exist at that time anymore, so labels should carry copies of live credentials if necessary. */ typedef void mpo_exc_action_label_populate_t( struct label *label, struct proc *proc ); /** @brief Initialize exception action label @param label New label to initialize Initialize a label for an exception action. Usually performs policy specific allocations. Sleeping is permitted. */ typedef int mpo_exc_action_label_init_t( struct label *label ); /** @brief Update the label on an exception action @param action Exception action that the label belongs to (may be NULL if none) @param label Policy label to update @param newlabel New label for update Update the credentials of an exception action from the given label. The policy should copy over any credentials (process and otherwise) from the new label into the label to update. Must not sleep, must be quick and can be called with locks held. */ typedef int mpo_exc_action_label_update_t( struct exception_action *action, struct label *label, struct label *newlabel ); /** @brief Access control for changing the offset of a file descriptor @param cred Subject credential @param fg Fileglob structure @param label Policy label for fg Determine whether the subject identified by the credential can change the offset of the file represented by fg. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_file_check_change_offset_t( kauth_cred_t cred, struct fileglob *fg, struct label *label ); /** @brief Access control for creating a file descriptor @param cred Subject credential Determine whether the subject identified by the credential can allocate a new file descriptor. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_file_check_create_t( kauth_cred_t cred ); /** @brief Access control for duplicating a file descriptor @param cred Subject credential @param fg Fileglob structure @param label Policy label for fg @param newfd New file descriptor number Determine whether the subject identified by the credential can duplicate the fileglob structure represented by fg and as file descriptor number newfd. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_file_check_dup_t( kauth_cred_t cred, struct fileglob *fg, struct label *label, int newfd ); /** @brief Access control check for fcntl @param cred Subject credential @param fg Fileglob structure @param label Policy label for fg @param cmd Control operation to be performed; see fcntl(2) @param arg fcnt arguments; see fcntl(2) Determine whether the subject identified by the credential can perform the file control operation indicated by cmd. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_file_check_fcntl_t( kauth_cred_t cred, struct fileglob *fg, struct label *label, int cmd, user_long_t arg ); /** @brief Access control check for mac_get_fd @param cred Subject credential @param fg Fileglob structure @param elements Element buffer @param len Length of buffer Determine whether the subject identified by the credential should be allowed to get an externalized version of the label on the object indicated by fd. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_file_check_get_t( kauth_cred_t cred, struct fileglob *fg, char *elements, int len ); /** @brief Access control for getting the offset of a file descriptor @param cred Subject credential @param fg Fileglob structure @param label Policy label for fg Determine whether the subject identified by the credential can get the offset of the file represented by fg. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_file_check_get_offset_t( kauth_cred_t cred, struct fileglob *fg, struct label *label ); /** @brief Access control for inheriting a file descriptor @param cred Subject credential @param fg Fileglob structure @param label Policy label for fg Determine whether the subject identified by the credential can inherit the fileglob structure represented by fg. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_file_check_inherit_t( kauth_cred_t cred, struct fileglob *fg, struct label *label ); /** @brief Access control check for file ioctl @param cred Subject credential @param fg Fileglob structure @param label Policy label for fg @param cmd The ioctl command; see ioctl(2) Determine whether the subject identified by the credential can perform the ioctl operation indicated by cmd. @warning Since ioctl data is opaque from the standpoint of the MAC framework, policies must exercise extreme care when implementing access control checks. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_file_check_ioctl_t( kauth_cred_t cred, struct fileglob *fg, struct label *label, unsigned int cmd ); /** @brief Access control check for file locking @param cred Subject credential @param fg Fileglob structure @param label Policy label for fg @param op The lock operation (F_GETLK, F_SETLK, F_UNLK) @param fl The flock structure Determine whether the subject identified by the credential can perform the lock operation indicated by op and fl on the file represented by fg. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_file_check_lock_t( kauth_cred_t cred, struct fileglob *fg, struct label *label, int op, struct flock *fl ); /** @brief Check with library validation if a macho slice is allowed to be combined into a proc. @param p Subject process @param fg Fileglob structure @param slice_offset offset of the code slice @param error_message error message returned to user-space in case of error (userspace pointer) @param error_message_size error message size Its a little odd that the MAC/kext writes into userspace since this implies there is only one MAC module that implements this, however the alterantive is to allocate memory in xnu, on the hope that the MAC module will use it, or allocated in the MAC module and then free it in xnu. Either of these are very appeling, so lets go with the slightly more hacky way. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_file_check_library_validation_t( struct proc *p, struct fileglob *fg, off_t slice_offset, user_long_t error_message, size_t error_message_size ); /** @brief Access control check for mapping a file @param cred Subject credential @param fg fileglob representing file to map @param label Policy label associated with vp @param prot mmap protections; see mmap(2) @param flags Type of mapped object; see mmap(2) @param maxprot Maximum rights Determine whether the subject identified by the credential should be allowed to map the file represented by fg with the protections specified in prot. The maxprot field holds the maximum permissions on the new mapping, a combination of VM_PROT_READ, VM_PROT_WRITE, and VM_PROT_EXECUTE. To avoid overriding prior access control checks, a policy should only remove flags from maxprot. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_file_check_mmap_t( kauth_cred_t cred, struct fileglob *fg, struct label *label, int prot, int flags, uint64_t file_pos, int *maxprot ); /** @brief Downgrade the mmap protections @param cred Subject credential @param fg file to map @param label Policy label associated with vp @param prot mmap protections to be downgraded Downgrade the mmap protections based on the subject and object labels. */ typedef void mpo_file_check_mmap_downgrade_t( kauth_cred_t cred, struct fileglob *fg, struct label *label, int *prot ); /** @brief Access control for receiving a file descriptor @param cred Subject credential @param fg Fileglob structure @param label Policy label for fg Determine whether the subject identified by the credential can receive the fileglob structure represented by fg. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_file_check_receive_t( kauth_cred_t cred, struct fileglob *fg, struct label *label ); /** @brief Access control check for mac_set_fd @param cred Subject credential @param fg Fileglob structure @param elements Elements buffer @param len Length of elements buffer Determine whether the subject identified by the credential can perform the mac_set_fd operation. The mac_set_fd operation is used to associate a MAC label with a file. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_file_check_set_t( kauth_cred_t cred, struct fileglob *fg, char *elements, int len ); /** @brief Create file label @param cred Subject credential @param fg Fileglob structure @param label Policy label for fg */ typedef void mpo_file_label_associate_t( kauth_cred_t cred, struct fileglob *fg, struct label *label ); /** @brief Destroy file label @param label The label to be destroyed Destroy the label on a file descriptor. In this entry point, a policy module should free any internal storage associated with label so that it may be destroyed. */ typedef void mpo_file_label_destroy_t( struct label *label ); /** @brief Initialize file label @param label New label to initialize */ typedef void mpo_file_label_init_t( struct label *label ); /** @brief Access control check for relabeling network interfaces @param cred Subject credential @param ifp network interface being relabeled @param ifnetlabel Current label of the network interfaces @param newlabel New label to apply to the network interfaces @see mpo_ifnet_label_update_t Determine whether the subject identified by the credential can relabel the network interface represented by ifp to the supplied new label (newlabel). @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_ifnet_check_label_update_t( kauth_cred_t cred, struct ifnet *ifp, struct label *ifnetlabel, struct label *newlabel ); /** @brief Access control check for relabeling network interfaces @param ifp Network interface mbuf will be transmitted through @param ifnetlabel Label of the network interfaces @param m The mbuf to be transmitted @param mbuflabel Label of the mbuf to be transmitted @param family Address Family, AF_* @param type Type of socket, SOCK_{STREAM,DGRAM,RAW} Determine whether the mbuf with label mbuflabel may be transmitted through the network interface represented by ifp that has the label ifnetlabel. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_ifnet_check_transmit_t( struct ifnet *ifp, struct label *ifnetlabel, struct mbuf *m, struct label *mbuflabel, int family, int type ); /** @brief Create a network interface label @param ifp Network interface labeled @param ifnetlabel Label for the network interface Set the label of a newly created network interface, most likely using the information in the supplied network interface struct. */ typedef void mpo_ifnet_label_associate_t( struct ifnet *ifp, struct label *ifnetlabel ); /** @brief Copy an ifnet label @param src Source ifnet label @param dest Destination ifnet label Copy the label information from src to dest. */ typedef void mpo_ifnet_label_copy_t( struct label *src, struct label *dest ); /** @brief Destroy ifnet label @param label The label to be destroyed Destroy the label on an ifnet label. In this entry point, a policy module should free any internal storage associated with label so that it may be destroyed. */ typedef void mpo_ifnet_label_destroy_t( struct label *label ); /** @brief Externalize an ifnet label @param label Label to be externalized @param element_name Name of the label namespace for which labels should be externalized @param sb String buffer to be filled with a text representation of the label Produce an external representation of the label on an interface. An externalized label consists of a text representation of the label contents that can be used with user applications. Policy-agnostic user space tools will display this externalized version. @return 0 on success, return non-zero if an error occurs while externalizing the label data. */ typedef int mpo_ifnet_label_externalize_t( struct label *label, char *element_name, struct sbuf *sb ); /** @brief Initialize ifnet label @param label New label to initialize */ typedef void mpo_ifnet_label_init_t( struct label *label ); /** @brief Internalize an interface label @param label Label to be internalized @param element_name Name of the label namespace for which the label should be internalized @param element_data Text data to be internalized Produce an interface label from an external representation. An externalized label consists of a text representation of the label contents that can be used with user applications. Policy-agnostic user space tools will forward text version to the kernel for processing by individual policy modules. The policy's internalize entry points will be called only if the policy has registered interest in the label namespace. @return 0 on success, Otherwise, return non-zero if an error occurs while internalizing the label data. */ typedef int mpo_ifnet_label_internalize_t( struct label *label, char *element_name, char *element_data ); /** @brief Recycle up a network interface label @param label The label to be recycled Recycle a network interface label. Darwin caches the struct ifnet of detached ifnets in a "free pool". Before ifnets are returned to the "free pool", policies can cleanup or overwrite any information present in the label. */ typedef void mpo_ifnet_label_recycle_t( struct label *label ); /** @brief Update a network interface label @param cred Subject credential @param ifp The network interface to be relabeled @param ifnetlabel The current label of the network interface @param newlabel A new label to apply to the network interface @see mpo_ifnet_check_label_update_t Update the label on a network interface, using the supplied new label. */ typedef void mpo_ifnet_label_update_t( kauth_cred_t cred, struct ifnet *ifp, struct label *ifnetlabel, struct label *newlabel ); /** @brief Access control check for delivering a packet to a socket @param inp inpcb the socket is associated with @param inplabel Label of the inpcb @param m The mbuf being received @param mbuflabel Label of the mbuf being received @param family Address family, AF_* @param type Type of socket, SOCK_{STREAM,DGRAM,RAW} Determine whether the mbuf with label mbuflabel may be received by the socket associated with inpcb that has the label inplabel. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_inpcb_check_deliver_t( struct inpcb *inp, struct label *inplabel, struct mbuf *m, struct label *mbuflabel, int family, int type ); /** @brief Create an inpcb label @param so Socket containing the inpcb to be labeled @param solabel Label of the socket @param inp inpcb to be labeled @param inplabel Label for the inpcb Set the label of a newly created inpcb, most likely using the information in the socket and/or socket label. */ typedef void mpo_inpcb_label_associate_t( struct socket *so, struct label *solabel, struct inpcb *inp, struct label *inplabel ); /** @brief Destroy inpcb label @param label The label to be destroyed Destroy the label on an inpcb label. In this entry point, a policy module should free any internal storage associated with label so that it may be destroyed. */ typedef void mpo_inpcb_label_destroy_t( struct label *label ); /** @brief Initialize inpcb label @param label New label to initialize @param flag M_WAITOK or M_NOWAIT */ typedef int mpo_inpcb_label_init_t( struct label *label, int flag ); /** @brief Recycle up an inpcb label @param label The label to be recycled Recycle an inpcb label. Darwin allocates the inpcb as part of the socket structure in some cases. For this case we must recycle rather than destroy the inpcb as it will be reused later. */ typedef void mpo_inpcb_label_recycle_t( struct label *label ); /** @brief Update an inpcb label from a socket label @param so Socket containing the inpcb to be relabeled @param solabel New label of the socket @param inp inpcb to be labeled @param inplabel Label for the inpcb Set the label of a newly created inpcb due to a change in the underlying socket label. */ typedef void mpo_inpcb_label_update_t( struct socket *so, struct label *solabel, struct inpcb *inp, struct label *inplabel ); /** @brief Device hardware access control @param devtype Type of device connected This is the MAC Framework device access control, which is called by the I/O Kit when a new device is connected to the system to determine whether that device should be trusted. A list of properties associated with the device is passed as an XML-formatted string. The routine should examine these properties to determine the trustworthiness of the device. A return value of EPERM forces the device to be claimed by a special device driver that will prevent its operation. @warning This is an experimental interface and may change in the future. @return Return EPERM to indicate that the device is untrusted and should not be allowed to operate. Return zero to indicate that the device is trusted and should be allowed to operate normally. */ typedef int mpo_iokit_check_device_t( char *devtype, struct mac_module_data *mdata ); /** @brief Access control check for opening an I/O Kit device @param cred Subject credential @param user_client User client instance @param user_client_type User client type Determine whether the subject identified by the credential can open an I/O Kit device at the passed path of the passed user client class and type. @return Return 0 if access is granted, or an appropriate value for errno should be returned. */ typedef int mpo_iokit_check_open_t( kauth_cred_t cred, io_object_t user_client, unsigned int user_client_type ); /** @brief Access control check for setting I/O Kit device properties @param cred Subject credential @param entry Target device @param properties Property list Determine whether the subject identified by the credential can set properties on an I/O Kit device. @return Return 0 if access is granted, or an appropriate value for errno should be returned. */ typedef int mpo_iokit_check_set_properties_t( kauth_cred_t cred, io_object_t entry, io_object_t properties ); /** @brief Indicate desire to filter I/O Kit devices properties @param cred Subject credential @param entry Target device @see mpo_iokit_check_get_property_t Indicate whether this policy may restrict the subject credential from reading properties of the target device. If a policy returns success from this entry point, the mpo_iokit_check_get_property entry point will later be called for each property that the subject credential tries to read from the target device. This entry point is primarilly to optimize bulk property reads by skipping calls to the mpo_iokit_check_get_property entry point for credentials / devices no MAC policy is interested in. @warning Even if a policy returns 0, it should behave correctly in the presence of an invocation of mpo_iokit_check_get_property, as that call may happen as a result of another policy requesting a transition. @return Non-zero if a transition is required, 0 otherwise. */ typedef int mpo_iokit_check_filter_properties_t( kauth_cred_t cred, io_object_t entry ); /** @brief Access control check for getting I/O Kit device properties @param cred Subject credential @param entry Target device @param name Property name Determine whether the subject identified by the credential can get properties on an I/O Kit device. @return Return 0 if access is granted, or an appropriate value for errno. */ typedef int mpo_iokit_check_get_property_t( kauth_cred_t cred, io_object_t entry, const char *name ); /** @brief Access control check for software HID control @param cred Subject credential Determine whether the subject identified by the credential can control the HID (Human Interface Device) subsystem, such as to post synthetic keypresses, pointer movement and clicks. @return Return 0 if access is granted, or an appropriate value for errno. */ typedef int mpo_iokit_check_hid_control_t( kauth_cred_t cred ); /** @brief Create an IP reassembly queue label @param fragment First received IP fragment @param fragmentlabel Policy label for fragment @param ipq IP reassembly queue to be labeled @param ipqlabel Policy label to be filled in for ipq Set the label on a newly created IP reassembly queue from the mbuf header of the first received fragment. */ typedef void mpo_ipq_label_associate_t( struct mbuf *fragment, struct label *fragmentlabel, struct ipq *ipq, struct label *ipqlabel ); /** @brief Compare an mbuf header label to an ipq label @param fragment IP datagram fragment @param fragmentlabel Policy label for fragment @param ipq IP fragment reassembly queue @param ipqlabel Policy label for ipq Compare the label of the mbuf header containing an IP datagram (fragment) fragment with the label of the passed IP fragment reassembly queue (ipq). Return (1) for a successful match, or (0) for no match. This call is made when the IP stack attempts to find an existing fragment reassembly queue for a newly received fragment; if this fails, a new fragment reassembly queue may be instantiated for the fragment. Policies may use this entry point to prevent the reassembly of otherwise matching IP fragments if policy does not permit them to be reassembled based on the label or other information. */ typedef int mpo_ipq_label_compare_t( struct mbuf *fragment, struct label *fragmentlabel, struct ipq *ipq, struct label *ipqlabel ); /** @brief Destroy IP reassembly queue label @param label The label to be destroyed Destroy the label on an IP fragment queue. In this entry point, a policy module should free any internal storage associated with label so that it may be destroyed. */ typedef void mpo_ipq_label_destroy_t( struct label *label ); /** @brief Initialize IP reassembly queue label @param label New label to initialize @param flag M_WAITOK or M_NOWAIT Initialize the label on a newly instantiated IP fragment reassembly queue. The flag field may be one of M_WAITOK and M_NOWAIT, and should be employed to avoid performing a sleeping malloc(9) during this initialization call. IP fragment reassembly queue allocation frequently occurs in performance sensitive environments, and the implementation should be careful to avoid sleeping or long-lived operations. This entry point is permitted to fail resulting in the failure to allocate the IP fragment reassembly queue. */ typedef int mpo_ipq_label_init_t( struct label *label, int flag ); /** @brief Update the label on an IP fragment reassembly queue @param fragment IP fragment @param fragmentlabel Policy label for fragment @param ipq IP fragment reassembly queue @param ipqlabel Policy label to be updated for ipq Update the label on an IP fragment reassembly queue (ipq) based on the acceptance of the passed IP fragment mbuf header (fragment). */ typedef void mpo_ipq_label_update_t( struct mbuf *fragment, struct label *fragmentlabel, struct ipq *ipq, struct label *ipqlabel ); /** @brief Assign a label to a new mbuf @param bpf_d BPF descriptor @param b_label Policy label for bpf_d @param m Object; mbuf @param m_label Policy label to fill in for m Set the label on the mbuf header of a newly created datagram generated using the passed BPF descriptor. This call is made when a write is performed to the BPF device associated with the passed BPF descriptor. */ typedef void mpo_mbuf_label_associate_bpfdesc_t( struct bpf_d *bpf_d, struct label *b_label, struct mbuf *m, struct label *m_label ); /** @brief Assign a label to a new mbuf @param ifp Interface descriptor @param i_label Existing label of ifp @param m Object; mbuf @param m_label Policy label to fill in for m Label an mbuf based on the interface from which it was received. */ typedef void mpo_mbuf_label_associate_ifnet_t( struct ifnet *ifp, struct label *i_label, struct mbuf *m, struct label *m_label ); /** @brief Assign a label to a new mbuf @param inp inpcb structure @param i_label Existing label of inp @param m Object; mbuf @param m_label Policy label to fill in for m Label an mbuf based on the inpcb from which it was derived. */ typedef void mpo_mbuf_label_associate_inpcb_t( struct inpcb *inp, struct label *i_label, struct mbuf *m, struct label *m_label ); /** @brief Set the label on a newly reassembled IP datagram @param ipq IP fragment reassembly queue @param ipqlabel Policy label for ipq @param mbuf IP datagram to be labeled @param mbuflabel Policy label to be filled in for mbuf Set the label on a newly reassembled IP datagram (mbuf) from the IP fragment reassembly queue (ipq) from which it was generated. */ typedef void mpo_mbuf_label_associate_ipq_t( struct ipq *ipq, struct label *ipqlabel, struct mbuf *mbuf, struct label *mbuflabel ); /** @brief Assign a label to a new mbuf @param ifp Subject; network interface @param i_label Existing label of ifp @param m Object; mbuf @param m_label Policy label to fill in for m Set the label on the mbuf header of a newly created datagram generated for the purposes of a link layer response for the passed interface. This call may be made in a number of situations, including for ARP or ND6 responses in the IPv4 and IPv6 stacks. */ typedef void mpo_mbuf_label_associate_linklayer_t( struct ifnet *ifp, struct label *i_label, struct mbuf *m, struct label *m_label ); /** @brief Assign a label to a new mbuf @param oldmbuf mbuf headerder for existing datagram for existing datagram @param oldmbuflabel Policy label for oldmbuf @param ifp Network interface @param ifplabel Policy label for ifp @param newmbuf mbuf header to be labeled for new datagram @param newmbuflabel Policy label for newmbuf Set the label on the mbuf header of a newly created datagram generated from the existing passed datagram when it is processed by the passed multicast encapsulation interface. This call is made when an mbuf is to be delivered using the virtual interface. */ typedef void mpo_mbuf_label_associate_multicast_encap_t( struct mbuf *oldmbuf, struct label *oldmbuflabel, struct ifnet *ifp, struct label *ifplabel, struct mbuf *newmbuf, struct label *newmbuflabel ); /** @brief Assign a label to a new mbuf @param oldmbuf Received datagram @param oldmbuflabel Policy label for oldmbuf @param newmbuf Newly created datagram @param newmbuflabel Policy label for newmbuf Set the label on the mbuf header of a newly created datagram generated by the IP stack in response to an existing received datagram (oldmbuf). This call may be made in a number of situations, including when responding to ICMP request datagrams. */ typedef void mpo_mbuf_label_associate_netlayer_t( struct mbuf *oldmbuf, struct label *oldmbuflabel, struct mbuf *newmbuf, struct label *newmbuflabel ); /** @brief Assign a label to a new mbuf @param so Socket to label @param so_label Policy label for socket @param m Object; mbuf @param m_label Policy label to fill in for m An mbuf structure is used to store network traffic in transit. When an application sends data to a socket or a pipe, it is wrapped in an mbuf first. This function sets the label on a newly created mbuf header based on the socket sending the data. The contents of the label should be suitable for performing an access check on the receiving side of the communication. Only labeled MBUFs will be presented to the policy via this entrypoint. */ typedef void mpo_mbuf_label_associate_socket_t( socket_t so, struct label *so_label, struct mbuf *m, struct label *m_label ); /** @brief Copy a mbuf label @param src Source label @param dest Destination label Copy the mbuf label information in src into dest. Only called when both source and destination mbufs have labels. */ typedef void mpo_mbuf_label_copy_t( struct label *src, struct label *dest ); /** @brief Destroy mbuf label @param label The label to be destroyed Destroy a mbuf label. Since the object is going out of scope, policy modules should free any internal storage associated with the label so that it may be destroyed. */ typedef void mpo_mbuf_label_destroy_t( struct label *label ); /** @brief Initialize mbuf label @param label New label to initialize @param flag Malloc flags Initialize the label for a newly instantiated mbuf. @warning Since it is possible for the flags to be set to M_NOWAIT, the malloc operation may fail. @return On success, 0, otherwise, an appropriate errno return value. */ typedef int mpo_mbuf_label_init_t( struct label *label, int flag ); /** @brief Access control check for fsctl @param cred Subject credential @param mp The mount point @param label Label associated with the mount point @param cmd Filesystem-dependent request code; see fsctl(2) Determine whether the subject identified by the credential can perform the volume operation indicated by com. @warning The fsctl() system call is directly analogous to ioctl(); since the associated data is opaque from the standpoint of the MAC framework and since these operations can affect many aspects of system operation, policies must exercise extreme care when implementing access control checks. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_mount_check_fsctl_t( kauth_cred_t cred, struct mount *mp, struct label *label, unsigned int cmd ); /** @brief Access control check for the retrieval of file system attributes @param cred Subject credential @param mp The mount structure of the file system @param vfa The attributes requested This entry point determines whether given subject can get information about the given file system. This check happens during statfs() syscalls, but is also used by other parts within the kernel such as the audit system. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. @note Policies may change the contents of vfa to alter the list of file system attributes returned. */ typedef int mpo_mount_check_getattr_t( kauth_cred_t cred, struct mount *mp, struct label *mp_label, struct vfs_attr *vfa ); /** @brief Access control check for mount point relabeling @param cred Subject credential @param mp Object file system mount point @param mntlabel Policy label for fle system mount point Determine whether the subject identified by the credential can relabel the mount point. This call is made when a file system mount is updated. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_mount_check_label_update_t( kauth_cred_t cred, struct mount *mp, struct label *mntlabel ); /** @brief Access control check for mounting a file system @param cred Subject credential @param vp Vnode that is to be the mount point @param vlabel Label associated with the vnode @param cnp Component name for vp @param vfc_name Filesystem type name Determine whether the subject identified by the credential can perform the mount operation on the target vnode. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_mount_check_mount_t( kauth_cred_t cred, struct vnode *vp, struct label *vlabel, struct componentname *cnp, const char *vfc_name ); /** @brief Access control check for fs_snapshot_create @param cred Subject credential @mp Filesystem mount point to create snapshot of @name Name of snapshot to create Determine whether the subject identified by the credential can create a snapshot of the filesystem at the given mount point. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_mount_check_snapshot_create_t( kauth_cred_t cred, struct mount *mp, const char *name ); /** @brief Access control check for fs_snapshot_delete @param cred Subject credential @mp Filesystem mount point to delete snapshot of @name Name of snapshot to delete Determine whether the subject identified by the credential can delete the named snapshot from the filesystem at the given mount point. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_mount_check_snapshot_delete_t( kauth_cred_t cred, struct mount *mp, const char *name ); /** @brief Access control check for fs_snapshot_revert @param cred Subject credential @mp Filesystem mount point to revert to snapshot @name Name of snapshot to revert to Determine whether the subject identified by the credential can revert the filesystem at the given mount point to the named snapshot. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_mount_check_snapshot_revert_t( kauth_cred_t cred, struct mount *mp, const char *name ); /** @brief Access control check remounting a filesystem @param cred Subject credential @param mp The mount point @param mlabel Label currently associated with the mount point Determine whether the subject identified by the credential can perform the remount operation on the target vnode. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_mount_check_remount_t( kauth_cred_t cred, struct mount *mp, struct label *mlabel ); /** @brief Access control check for the settting of file system attributes @param cred Subject credential @param mp The mount structure of the file system @param vfa The attributes requested This entry point determines whether given subject can set information about the given file system, for example the volume name. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_mount_check_setattr_t( kauth_cred_t cred, struct mount *mp, struct label *mp_label, struct vfs_attr *vfa ); /** @brief Access control check for file system statistics @param cred Subject credential @param mp Object file system mount @param mntlabel Policy label for mp Determine whether the subject identified by the credential can see the results of a statfs performed on the file system. This call may be made in a number of situations, including during invocations of statfs(2) and related calls, as well as to determine what file systems to exclude from listings of file systems, such as when getfsstat(2) is invoked. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_mount_check_stat_t( kauth_cred_t cred, struct mount *mp, struct label *mntlabel ); /** @brief Access control check for unmounting a filesystem @param cred Subject credential @param mp The mount point @param mlabel Label associated with the mount point Determine whether the subject identified by the credential can perform the unmount operation on the target vnode. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_mount_check_umount_t( kauth_cred_t cred, struct mount *mp, struct label *mlabel ); /** @brief Create mount labels @param cred Subject credential @param mp Mount point of file system being mounted @param mntlabel Label to associate with the new mount point @see mpo_mount_label_init_t Fill out the labels on the mount point being created by the supplied user credential. This call is made when file systems are first mounted. */ typedef void mpo_mount_label_associate_t( kauth_cred_t cred, struct mount *mp, struct label *mntlabel ); /** @brief Destroy mount label @param label The label to be destroyed Destroy a file system mount label. Since the object is going out of scope, policy modules should free any internal storage associated with the label so that it may be destroyed. */ typedef void mpo_mount_label_destroy_t( struct label *label ); /** @brief Externalize a mount point label @param label Label to be externalized @param element_name Name of the label namespace for which labels should be externalized @param sb String buffer to be filled with a text representation of the label Produce an external representation of the mount point label. An externalized label consists of a text representation of the label contents that can be used with user applications. Policy-agnostic user space tools will display this externalized version. The policy's externalize entry points will be called only if the policy has registered interest in the label namespace. @return 0 on success, return non-zero if an error occurs while externalizing the label data. */ typedef int mpo_mount_label_externalize_t( struct label *label, char *element_name, struct sbuf *sb ); /** @brief Initialize mount point label @param label New label to initialize Initialize the label for a newly instantiated mount structure. This label is typically used to store a default label in the case that the file system has been mounted singlelabel. Since some file systems do not support persistent labels (extended attributes) or are read-only (such as CD-ROMs), it is often necessary to store a default label separately from the label of the mount point itself. Sleeping is permitted. */ typedef void mpo_mount_label_init_t( struct label *label ); /** @brief Internalize a mount point label @param label Label to be internalized @param element_name Name of the label namespace for which the label should be internalized @param element_data Text data to be internalized Produce a mount point file system label from an external representation. An externalized label consists of a text representation of the label contents that can be used with user applications. Policy-agnostic user space tools will forward text version to the kernel for processing by individual policy modules. The policy's internalize entry points will be called only if the policy has registered interest in the label namespace. @return 0 on success, Otherwise, return non-zero if an error occurs while internalizing the label data. */ typedef int mpo_mount_label_internalize_t( struct label *label, char *element_name, char *element_data ); /** @brief Set the label on an IPv4 datagram fragment @param datagram Datagram being fragmented @param datagramlabel Policy label for datagram @param fragment New fragment @param fragmentlabel Policy label for fragment Called when an IPv4 datagram is fragmented into several smaller datagrams. Policies implementing mbuf labels will typically copy the label from the source datagram to the new fragment. */ typedef void mpo_netinet_fragment_t( struct mbuf *datagram, struct label *datagramlabel, struct mbuf *fragment, struct label *fragmentlabel ); /** @brief Set the label on an ICMP reply @param m mbuf containing the ICMP reply @param mlabel Policy label for m A policy may wish to update the label of an mbuf that refers to an ICMP packet being sent in response to an IP packet. This may be called in response to a bad packet or an ICMP request. */ typedef void mpo_netinet_icmp_reply_t( struct mbuf *m, struct label *mlabel ); /** @brief Set the label on a TCP reply @param m mbuf containing the TCP reply @param mlabel Policy label for m Called for outgoing TCP packets not associated with an actual socket. */ typedef void mpo_netinet_tcp_reply_t( struct mbuf *m, struct label *mlabel ); /** @brief Access control check for pipe ioctl @param cred Subject credential @param cpipe Object to be accessed @param pipelabel The label on the pipe @param cmd The ioctl command; see ioctl(2) Determine whether the subject identified by the credential can perform the ioctl operation indicated by cmd. @warning Since ioctl data is opaque from the standpoint of the MAC framework, policies must exercise extreme care when implementing access control checks. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_pipe_check_ioctl_t( kauth_cred_t cred, struct pipe *cpipe, struct label *pipelabel, unsigned int cmd ); /** @brief Access control check for pipe kqfilter @param cred Subject credential @param kn Object knote @param cpipe Object to be accessed @param pipelabel Policy label for the pipe Determine whether the subject identified by the credential can receive the knote on the passed pipe. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_pipe_check_kqfilter_t( kauth_cred_t cred, struct knote *kn, struct pipe *cpipe, struct label *pipelabel ); /** @brief Access control check for pipe relabel @param cred Subject credential @param cpipe Object to be accessed @param pipelabel The current label on the pipe @param newlabel The new label to be used Determine whether the subject identified by the credential can perform a relabel operation on the passed pipe. The cred object holds the credentials of the subject performing the operation. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_pipe_check_label_update_t( kauth_cred_t cred, struct pipe *cpipe, struct label *pipelabel, struct label *newlabel ); /** @brief Access control check for pipe read @param cred Subject credential @param cpipe Object to be accessed @param pipelabel The label on the pipe Determine whether the subject identified by the credential can perform a read operation on the passed pipe. The cred object holds the credentials of the subject performing the operation. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_pipe_check_read_t( kauth_cred_t cred, struct pipe *cpipe, struct label *pipelabel ); /** @brief Access control check for pipe select @param cred Subject credential @param cpipe Object to be accessed @param pipelabel The label on the pipe @param which The operation selected on: FREAD or FWRITE Determine whether the subject identified by the credential can perform a select operation on the passed pipe. The cred object holds the credentials of the subject performing the operation. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_pipe_check_select_t( kauth_cred_t cred, struct pipe *cpipe, struct label *pipelabel, int which ); /** @brief Access control check for pipe stat @param cred Subject credential @param cpipe Object to be accessed @param pipelabel The label on the pipe Determine whether the subject identified by the credential can perform a stat operation on the passed pipe. The cred object holds the credentials of the subject performing the operation. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_pipe_check_stat_t( kauth_cred_t cred, struct pipe *cpipe, struct label *pipelabel ); /** @brief Access control check for pipe write @param cred Subject credential @param cpipe Object to be accessed @param pipelabel The label on the pipe Determine whether the subject identified by the credential can perform a write operation on the passed pipe. The cred object holds the credentials of the subject performing the operation. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_pipe_check_write_t( kauth_cred_t cred, struct pipe *cpipe, struct label *pipelabel ); /** @brief Create a pipe label @param cred Subject credential @param cpipe object to be labeled @param pipelabel Label for the pipe object Create a label for the pipe object being created by the supplied user credential. This call is made when the pipe is being created XXXPIPE(for one or both sides of the pipe?). */ typedef void mpo_pipe_label_associate_t( kauth_cred_t cred, struct pipe *cpipe, struct label *pipelabel ); /** @brief Copy a pipe label @param src Source pipe label @param dest Destination pipe label Copy the pipe label associated with src to dest. XXXPIPE Describe when this is used: most likely during pipe creation to copy from rpipe to wpipe. */ typedef void mpo_pipe_label_copy_t( struct label *src, struct label *dest ); /** @brief Destroy pipe label @param label The label to be destroyed Destroy a pipe label. Since the object is going out of scope, policy modules should free any internal storage associated with the label so that it may be destroyed. */ typedef void mpo_pipe_label_destroy_t( struct label *label ); /** @brief Externalize a pipe label @param label Label to be externalized @param element_name Name of the label namespace for which labels should be externalized @param sb String buffer to be filled with a text representation of the label Produce an external representation of the label on a pipe. An externalized label consists of a text representation of the label contents that can be used with user applications. Policy-agnostic user space tools will display this externalized version. The policy's externalize entry points will be called only if the policy has registered interest in the label namespace. @return 0 on success, return non-zero if an error occurs while externalizing the label data. */ typedef int mpo_pipe_label_externalize_t( struct label *label, char *element_name, struct sbuf *sb ); /** @brief Initialize pipe label @param label New label to initialize Initialize label storage for use with a newly instantiated pipe object. Sleeping is permitted. */ typedef void mpo_pipe_label_init_t( struct label *label ); /** @brief Internalize a pipe label @param label Label to be internalized @param element_name Name of the label namespace for which the label should be internalized @param element_data Text data to be internalized Produce a pipe label from an external representation. An externalized label consists of a text representation of the label contents that can be used with user applications. Policy-agnostic user space tools will forward text version to the kernel for processing by individual policy modules. The policy's internalize entry points will be called only if the policy has registered interest in the label namespace. @return 0 on success, Otherwise, return non-zero if an error occurs while internalizing the label data. */ typedef int mpo_pipe_label_internalize_t( struct label *label, char *element_name, char *element_data ); /** @brief Update a pipe label @param cred Subject credential @param cpipe Object to be labeled @param oldlabel Existing pipe label @param newlabel New label to replace existing label @see mpo_pipe_check_label_update_t The subject identified by the credential has previously requested and was authorized to relabel the pipe; this entry point allows policies to perform the actual relabel operation. Policies should update oldlabel using the label stored in the newlabel parameter. */ typedef void mpo_pipe_label_update_t( kauth_cred_t cred, struct pipe *cpipe, struct label *oldlabel, struct label *newlabel ); /** @brief Policy unload event @param mpc MAC policy configuration This is the MAC Framework policy unload event. This entry point will only be called if the module's policy configuration allows unload (if the MPC_LOADTIME_FLAG_UNLOADOK is set). Most security policies won't want to be unloaded; they should set their flags to prevent this entry point from being called. @warning During this call, the mac policy list mutex is held, so sleep operations cannot be performed, and calls out to other kernel subsystems must be made with caution. @see MPC_LOADTIME_FLAG_UNLOADOK */ typedef void mpo_policy_destroy_t( struct mac_policy_conf *mpc ); /** @brief Policy initialization event @param mpc MAC policy configuration @see mac_policy_register @see mpo_policy_initbsd_t This is the MAC Framework policy initialization event. This entry point is called during mac_policy_register, when the policy module is first registered with the MAC Framework. This is often done very early in the boot process, after the kernel Mach subsystem has been initialized, but prior to the BSD subsystem being initialized. Since the kernel BSD services are not yet available, it is possible that some initialization must occur later, possibly in the mpo_policy_initbsd_t policy entry point, such as registering BSD system controls (sysctls). Policy modules loaded at boot time will be registered and initialized before labeled Mach objects are created. @warning During this call, the mac policy list mutex is held, so sleep operations cannot be performed, and calls out to other kernel subsystems must be made with caution. */ typedef void mpo_policy_init_t( struct mac_policy_conf *mpc ); /** @brief Policy BSD initialization event @param mpc MAC policy configuration @see mpo_policy_init_t This entry point is called after the kernel BSD subsystem has been initialized. By this point, the module should already be loaded, registered, and initialized. Since policy modules are initialized before kernel BSD services are available, this second initialization phase is necessary. At this point, BSD services (memory management, synchronization primitives, vfs, etc.) are available, but the first process has not yet been created. Mach-related objects and tasks will already be fully initialized and may be in use--policies requiring ubiquitous labeling may also want to implement mpo_policy_init_t. @warning During this call, the mac policy list mutex is held, so sleep operations cannot be performed, and calls out to other kernel subsystems must be made with caution. */ typedef void mpo_policy_initbsd_t( struct mac_policy_conf *mpc ); /** @brief Policy extension service @param p Calling process @param call Policy-specific syscall number @param arg Pointer to syscall arguments This entry point provides a policy-multiplexed system call so that policies may provide additional services to user processes without registering specific system calls. The policy name provided during registration is used to demux calls from userland, and the arguments will be forwarded to this entry point. When implementing new services, security modules should be sure to invoke appropriate access control checks from the MAC framework as needed. For example, if a policy implements an augmented signal functionality, it should call the necessary signal access control checks to invoke the MAC framework and other registered policies. @warning Since the format and contents of the policy-specific arguments are unknown to the MAC Framework, modules must perform the required copyin() of the syscall data on their own. No policy mediation is performed, so policies must perform any necessary access control checks themselves. If multiple policies are loaded, they will currently be unable to mediate calls to other policies. @return In the event of an error, an appropriate value for errno should be returned, otherwise return 0 upon success. */ typedef int mpo_policy_syscall_t( struct proc *p, int call, user_addr_t arg ); /** @brief Access control check for POSIX semaphore create @param cred Subject credential @param name String name of the semaphore Determine whether the subject identified by the credential can create a POSIX semaphore specified by name. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_posixsem_check_create_t( kauth_cred_t cred, const char *name ); /** @brief Access control check for POSIX semaphore open @param cred Subject credential @param ps Pointer to semaphore information structure @param semlabel Label associated with the semaphore Determine whether the subject identified by the credential can open the named POSIX semaphore with label semlabel. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_posixsem_check_open_t( kauth_cred_t cred, struct pseminfo *ps, struct label *semlabel ); /** @brief Access control check for POSIX semaphore post @param cred Subject credential @param ps Pointer to semaphore information structure @param semlabel Label associated with the semaphore Determine whether the subject identified by the credential can unlock the named POSIX semaphore with label semlabel. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_posixsem_check_post_t( kauth_cred_t cred, struct pseminfo *ps, struct label *semlabel ); /** @brief Access control check for POSIX semaphore unlink @param cred Subject credential @param ps Pointer to semaphore information structure @param semlabel Label associated with the semaphore @param name String name of the semaphore Determine whether the subject identified by the credential can remove the named POSIX semaphore with label semlabel. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_posixsem_check_unlink_t( kauth_cred_t cred, struct pseminfo *ps, struct label *semlabel, const char *name ); /** @brief Access control check for POSIX semaphore wait @param cred Subject credential @param ps Pointer to semaphore information structure @param semlabel Label associated with the semaphore Determine whether the subject identified by the credential can lock the named POSIX semaphore with label semlabel. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_posixsem_check_wait_t( kauth_cred_t cred, struct pseminfo *ps, struct label *semlabel ); /** @brief Create a POSIX semaphore label @param cred Subject credential @param ps Pointer to semaphore information structure @param semlabel Label to associate with the new semaphore @param name String name of the semaphore Label a new POSIX semaphore. The label was previously initialized and associated with the semaphore. At this time, an appropriate initial label value should be assigned to the object and stored in semalabel. */ typedef void mpo_posixsem_label_associate_t( kauth_cred_t cred, struct pseminfo *ps, struct label *semlabel, const char *name ); /** @brief Destroy POSIX semaphore label @param label The label to be destroyed Destroy a POSIX semaphore label. Since the object is going out of scope, policy modules should free any internal storage associated with the label so that it may be destroyed. */ typedef void mpo_posixsem_label_destroy_t( struct label *label ); /** @brief Initialize POSIX semaphore label @param label New label to initialize Initialize the label for a newly instantiated POSIX semaphore. Sleeping is permitted. */ typedef void mpo_posixsem_label_init_t( struct label *label ); /** @brief Access control check for POSIX shared memory region create @param cred Subject credential @param name String name of the shared memory region Determine whether the subject identified by the credential can create the POSIX shared memory region referenced by name. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_posixshm_check_create_t( kauth_cred_t cred, const char *name ); /** @brief Access control check for mapping POSIX shared memory @param cred Subject credential @param ps Pointer to shared memory information structure @param shmlabel Label associated with the shared memory region @param prot mmap protections; see mmap(2) @param flags shmat flags; see shmat(2) Determine whether the subject identified by the credential can map the POSIX shared memory segment associated with shmlabel. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_posixshm_check_mmap_t( kauth_cred_t cred, struct pshminfo *ps, struct label *shmlabel, int prot, int flags ); /** @brief Access control check for POSIX shared memory region open @param cred Subject credential @param ps Pointer to shared memory information structure @param shmlabel Label associated with the shared memory region @param fflags shm_open(2) open flags ('fflags' encoded) Determine whether the subject identified by the credential can open the POSIX shared memory region. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_posixshm_check_open_t( kauth_cred_t cred, struct pshminfo *ps, struct label *shmlabel, int fflags ); /** @brief Access control check for POSIX shared memory stat @param cred Subject credential @param ps Pointer to shared memory information structure @param shmlabel Label associated with the shared memory region Determine whether the subject identified by the credential can obtain status for the POSIX shared memory segment associated with shmlabel. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_posixshm_check_stat_t( kauth_cred_t cred, struct pshminfo *ps, struct label *shmlabel ); /** @brief Access control check for POSIX shared memory truncate @param cred Subject credential @param ps Pointer to shared memory information structure @param shmlabel Label associated with the shared memory region @param len Length to truncate or extend shared memory segment Determine whether the subject identified by the credential can truncate or extend (to len) the POSIX shared memory segment associated with shmlabel. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_posixshm_check_truncate_t( kauth_cred_t cred, struct pshminfo *ps, struct label *shmlabel, off_t len ); /** @brief Access control check for POSIX shared memory unlink @param cred Subject credential @param ps Pointer to shared memory information structure @param shmlabel Label associated with the shared memory region @param name String name of the shared memory region Determine whether the subject identified by the credential can delete the POSIX shared memory segment associated with shmlabel. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_posixshm_check_unlink_t( kauth_cred_t cred, struct pshminfo *ps, struct label *shmlabel, const char *name ); /** @brief Create a POSIX shared memory region label @param cred Subject credential @param ps Pointer to shared memory information structure @param shmlabel Label to associate with the new shared memory region @param name String name of the shared memory region Label a new POSIX shared memory region. The label was previously initialized and associated with the shared memory region. At this time, an appropriate initial label value should be assigned to the object and stored in shmlabel. */ typedef void mpo_posixshm_label_associate_t( kauth_cred_t cred, struct pshminfo *ps, struct label *shmlabel, const char *name ); /** @brief Destroy POSIX shared memory label @param label The label to be destroyed Destroy a POSIX shared memory region label. Since the object is going out of scope, policy modules should free any internal storage associated with the label so that it may be destroyed. */ typedef void mpo_posixshm_label_destroy_t( struct label *label ); /** @brief Initialize POSIX Shared Memory region label @param label New label to initialize Initialize the label for newly a instantiated POSIX Shared Memory region. Sleeping is permitted. */ typedef void mpo_posixshm_label_init_t( struct label *label ); /** @brief Access control check for privileged operations @param cred Subject credential @param priv Requested privilege (see sys/priv.h) Determine whether the subject identified by the credential can perform a privileged operation. Privileged operations are allowed if the cred is the superuser or any policy returns zero for mpo_priv_grant, unless any policy returns nonzero for mpo_priv_check. @return Return 0 if access is granted, otherwise EPERM should be returned. */ typedef int mpo_priv_check_t( kauth_cred_t cred, int priv ); /** @brief Grant regular users the ability to perform privileged operations @param cred Subject credential @param priv Requested privilege (see sys/priv.h) Determine whether the subject identified by the credential should be allowed to perform a privileged operation that in the absense of any MAC policy it would not be able to perform. Privileged operations are allowed if the cred is the superuser or any policy returns zero for mpo_priv_grant, unless any policy returns nonzero for mpo_priv_check. Unlike other MAC hooks which can only reduce the privilege of a credential, this hook raises the privilege of a credential when it returns 0. Extreme care must be taken when implementing this hook to avoid undermining the security of the system. @return Return 0 if additional privilege is granted, otherwise EPERM should be returned. */ typedef int mpo_priv_grant_t( kauth_cred_t cred, int priv ); /** @brief Access control check for debugging process @param cred Subject credential @param proc Object process Determine whether the subject identified by the credential can debug the passed process. This call may be made in a number of situations, including use of the ptrace(2) and ktrace(2) APIs, as well as for some types of procfs operations. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch, EPERM for lack of privilege, or ESRCH to hide visibility of the target. */ typedef int mpo_proc_check_debug_t( kauth_cred_t cred, struct proc *proc ); /** @brief Access control over fork @param cred Subject credential @param proc Subject process trying to fork Determine whether the subject identified is allowed to fork. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_proc_check_fork_t( kauth_cred_t cred, struct proc *proc ); /** @brief Access control check for setting host special ports. @param cred Subject credential @param id The host special port to set @param port The new value to set for the special port @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_proc_check_set_host_special_port_t( kauth_cred_t cred, int id, struct ipc_port *port ); /** @brief Access control check for setting host exception ports. @param cred Subject credential @param exception Exception port to set @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_proc_check_set_host_exception_port_t( kauth_cred_t cred, unsigned int exception ); /** @brief Access control over pid_suspend and pid_resume @param cred Subject credential @param proc Subject process trying to run pid_suspend or pid_resume @param sr Call is suspend (0) or resume (1) Determine whether the subject identified is allowed to suspend or resume other processes. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_proc_check_suspend_resume_t( kauth_cred_t cred, struct proc *proc, int sr ); /** @brief Access control check for retrieving audit information @param cred Subject credential Determine whether the subject identified by the credential can get audit information such as the audit user ID, the preselection mask, the terminal ID and the audit session ID, using the getaudit() system call. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_proc_check_getaudit_t( kauth_cred_t cred ); /** @brief Access control check for retrieving audit user ID @param cred Subject credential Determine whether the subject identified by the credential can get the user identity being used by the auditing system, using the getauid() system call. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_proc_check_getauid_t( kauth_cred_t cred ); /** @brief Access control check for retrieving Login Context ID @param p0 Calling process @param p Effected process @param pid syscall PID argument Determine if getlcid(2) system call is permitted. Information returned by this system call is similar to that returned via process listings etc. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_proc_check_getlcid_t( struct proc *p0, struct proc *p, pid_t pid ); /** @brief Access control check for retrieving ledger information @param cred Subject credential @param target Object process @param op ledger operation Determine if ledger(2) system call is permitted. Information returned by this system call is similar to that returned via process listings etc. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_proc_check_ledger_t( kauth_cred_t cred, struct proc *target, int op ); /** @brief Access control check for retrieving process information. @param cred Subject credential @param target Target process (may be null, may be zombie) Determine if a credential has permission to access process information as defined by call number and flavor on target process @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_proc_check_proc_info_t( kauth_cred_t cred, struct proc *target, int callnum, int flavor ); /** @brief Access control check for retrieving code signing information. @param cred Subject credential @param target Target process @param op Code signing operation being performed Determine whether the subject identified by the credential should be allowed to get code signing information about the target process. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_proc_check_get_cs_info_t( kauth_cred_t cred, struct proc *target, unsigned int op ); /** @brief Access control check for setting code signing information. @param cred Subject credential @param target Target process @param op Code signing operation being performed. Determine whether the subject identified by the credential should be allowed to set code signing information about the target process. @return Return 0 if permission is granted, otherwise an appropriate value of errno should be returned. */ typedef int mpo_proc_check_set_cs_info_t( kauth_cred_t cred, struct proc *target, unsigned int op ); /** @brief Access control check for mmap MAP_ANON @param proc User process requesting the memory @param cred Subject credential @param u_addr Start address of the memory range @param u_size Length address of the memory range @param prot mmap protections; see mmap(2) @param flags Type of mapped object; see mmap(2) @param maxprot Maximum rights Determine whether the subject identified by the credential should be allowed to obtain anonymous memory using the specified flags and protections on the new mapping. MAP_ANON will always be present in the flags. Certain combinations of flags with a non-NULL addr may cause a mapping to be rejected before this hook is called. The maxprot field holds the maximum permissions on the new mapping, a combination of VM_PROT_READ, VM_PROT_WRITE and VM_PROT_EXECUTE. To avoid overriding prior access control checks, a policy should only remove flags from maxprot. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EPERM for lack of privilege. */ typedef int mpo_proc_check_map_anon_t( struct proc *proc, kauth_cred_t cred, user_addr_t u_addr, user_size_t u_size, int prot, int flags, int *maxprot ); /** @brief Access control check for setting memory protections @param cred Subject credential @param proc User process requesting the change @param addr Start address of the memory range @param size Length address of the memory range @param prot Memory protections, see mmap(2) Determine whether the subject identified by the credential should be allowed to set the specified memory protections on memory mapped in the process proc. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_proc_check_mprotect_t( kauth_cred_t cred, struct proc *proc, user_addr_t addr, user_size_t size, int prot ); /** @brief Access control check for changing scheduling parameters @param cred Subject credential @param proc Object process Determine whether the subject identified by the credential can change the scheduling parameters of the passed process. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch, EPERM for lack of privilege, or ESRCH to limit visibility. */ typedef int mpo_proc_check_sched_t( kauth_cred_t cred, struct proc *proc ); /** @brief Access control check for setting audit information @param cred Subject credential @param ai Audit information Determine whether the subject identified by the credential can set audit information such as the the preselection mask, the terminal ID and the audit session ID, using the setaudit() system call. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_proc_check_setaudit_t( kauth_cred_t cred, struct auditinfo_addr *ai ); /** @brief Access control check for setting audit user ID @param cred Subject credential @param auid Audit user ID Determine whether the subject identified by the credential can set the user identity used by the auditing system, using the setauid() system call. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_proc_check_setauid_t( kauth_cred_t cred, uid_t auid ); /** @brief Access control check for setting the Login Context @param p0 Calling process @param p Effected process @param pid syscall PID argument @param lcid syscall LCID argument Determine if setlcid(2) system call is permitted. See xnu/bsd/kern/kern_prot.c:setlcid() implementation for example of decoding syscall arguments to determine action desired by caller. Five distinct actions are possible: CREATE JOIN LEAVE ADOPT ORPHAN @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_proc_check_setlcid_t( struct proc *p0, struct proc *p, pid_t pid, pid_t lcid ); /** @brief Access control check for delivering signal @param cred Subject credential @param proc Object process @param signum Signal number; see kill(2) Determine whether the subject identified by the credential can deliver the passed signal to the passed process. @warning Programs typically expect to be able to send and receive signals as part or their normal process lifecycle; caution should be exercised when implementing access controls over signal events. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch, EPERM for lack of privilege, or ESRCH to limit visibility. */ typedef int mpo_proc_check_signal_t( kauth_cred_t cred, struct proc *proc, int signum ); /** @brief Access control check for wait @param cred Subject credential @param proc Object process Determine whether the subject identified by the credential can wait for process termination. @warning Caution should be exercised when implementing access controls for wait, since programs often wait for child processes to exit. Failure to be notified of a child process terminating may cause the parent process to hang, or may produce zombie processes. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_proc_check_wait_t( kauth_cred_t cred, struct proc *proc ); /** @brief Inform MAC policies that a process has exited. @param proc Object process Called after all of the process's threads have terminated and it has been removed from the process list. KPI that identifies the process by pid will fail to find the process; KPI that identifies the process by the object process pointer functions normally. proc_exiting() returns true for the object process. */ typedef void mpo_proc_notify_exit_t( struct proc *proc ); /** @brief Destroy process label @param label The label to be destroyed Destroy a process label. Since the object is going out of scope, policy modules should free any internal storage associated with the label so that it may be destroyed. */ typedef void mpo_proc_label_destroy_t( struct label *label ); /** @brief Initialize process label @param label New label to initialize @see mpo_cred_label_init_t Initialize the label for a newly instantiated BSD process structure. Normally, security policies will store the process label in the user credential rather than here in the process structure. However, there are some floating label policies that may need to temporarily store a label in the process structure until it is safe to update the user credential label. Sleeping is permitted. */ typedef void mpo_proc_label_init_t( struct label *label ); /** @brief Access control check for skywalk flow connect @param cred Subject credential @param flow Flow object @param addr Remote address for flow to send data to @param type Flow type (e.g. SOCK_STREAM or SOCK_DGRAM) @param protocol Network protocol (e.g. IPPROTO_TCP) Determine whether the subject identified by the credential can create a flow for sending data to the remote host specified by addr. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_skywalk_flow_check_connect_t( kauth_cred_t cred, void *flow, const struct sockaddr *addr, int type, int protocol ); /** @brief Access control check for skywalk flow listen @param cred Subject credential @param flow Flow object @param addr Local address for flow to listen on @param type Flow type (e.g. SOCK_STREAM or SOCK_DGRAM) @param protocol Network protocol (e.g. IPPROTO_TCP) Determine whether the subject identified by the credential can create a flow for receiving data on the local address specified by addr. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_skywalk_flow_check_listen_t( kauth_cred_t cred, void *flow, const struct sockaddr *addr, int type, int protocol ); /** @brief Access control check for socket accept @param cred Subject credential @param so Object socket @param socklabel Policy label for socket Determine whether the subject identified by the credential can accept() a new connection on the socket from the host specified by addr. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_socket_check_accept_t( kauth_cred_t cred, socket_t so, struct label *socklabel ); /** @brief Access control check for a pending socket accept @param cred Subject credential @param so Object socket @param socklabel Policy label for socket @param addr Address of the listening socket (coming soon) Determine whether the subject identified by the credential can accept() a pending connection on the socket from the host specified by addr. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_socket_check_accepted_t( kauth_cred_t cred, socket_t so, struct label *socklabel, struct sockaddr *addr ); /** @brief Access control check for socket bind @param cred Subject credential @param so Object socket @param socklabel Policy label for socket @param addr Name to assign to the socket Determine whether the subject identified by the credential can bind() the name (addr) to the socket. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_socket_check_bind_t( kauth_cred_t cred, socket_t so, struct label *socklabel, struct sockaddr *addr ); /** @brief Access control check for socket connect @param cred Subject credential @param so Object socket @param socklabel Policy label for socket @param addr Name to assign to the socket Determine whether the subject identified by the credential can connect() the passed socket to the remote host specified by addr. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_socket_check_connect_t( kauth_cred_t cred, socket_t so, struct label *socklabel, struct sockaddr *addr ); /** @brief Access control check for socket() system call. @param cred Subject credential @param domain communication domain @param type socket type @param protocol socket protocol Determine whether the subject identified by the credential can make the socket() call. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_socket_check_create_t( kauth_cred_t cred, int domain, int type, int protocol ); /** @brief Access control check for delivering data to a user's receieve queue @param so The socket data is being delivered to @param so_label The label of so @param m The mbuf whose data will be deposited into the receive queue @param m_label The label of the sender of the data. A socket has a queue for receiving incoming data. When a packet arrives on the wire, it eventually gets deposited into this queue, which the owner of the socket drains when they read from the socket's file descriptor. This function determines whether the socket can receive data from the sender specified by m_label. @warning There is an outstanding design issue surrounding the placement of this function. The check must be placed either before or after the TCP sequence and ACK counters are updated. Placing the check before the counters are updated causes the incoming packet to be resent by the remote if the check rejects it. Placing the check after the counters are updated results in a completely silent drop. As far as each TCP stack is concerned the packet was received, however, the data will not be in the socket's receive queue. Another consideration is that the current design requires using the "failed label" occasionally. In that case, on rejection, we want the remote TCP to resend the data. Because of this, we chose to place this check before the counters are updated, so rejected packets will be resent by the remote host. If a policy keeps rejecting the same packet, eventually the connection will be dropped. Policies have several options if this design causes problems. For example, one options is to sanitize the mbuf such that it is acceptable, then accept it. That may require negotiation between policies as the Framework will not know to re-check the packet. The policy must handle NULL MBUF labels. This will likely be the case for non-local TCP sockets for example. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_socket_check_deliver_t( socket_t so, struct label *so_label, struct mbuf *m, struct label *m_label ); /** @brief Access control check for socket ioctl. @param cred Subject credential @param so Object socket @param cmd The ioctl command; see ioctl(2) @param socklabel Policy label for socket Determine whether the subject identified by the credential can perform the ioctl operation indicated by cmd on the given socket. @warning Since ioctl data is opaque from the standpoint of the MAC framework, and since ioctls can affect many aspects of system operation, policies must exercise extreme care when implementing access control checks. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_socket_check_ioctl_t( kauth_cred_t cred, socket_t so, unsigned int cmd, struct label *socklabel ); /** @brief Access control check for socket kqfilter @param cred Subject credential @param kn Object knote @param so Object socket @param socklabel Policy label for socket Determine whether the subject identified by the credential can receive the knote on the passed socket. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_socket_check_kqfilter_t( kauth_cred_t cred, struct knote *kn, socket_t so, struct label *socklabel ); /** @brief Access control check for socket relabel @param cred Subject credential @param so Object socket @param so_label The current label of so @param newlabel The label to be assigned to so Determine whether the subject identified by the credential can change the label on the socket. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_socket_check_label_update_t( kauth_cred_t cred, socket_t so, struct label *so_label, struct label *newlabel ); /** @brief Access control check for socket listen @param cred Subject credential @param so Object socket @param socklabel Policy label for socket Determine whether the subject identified by the credential can listen() on the passed socket. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_socket_check_listen_t( kauth_cred_t cred, socket_t so, struct label *socklabel ); /** @brief Access control check for socket receive @param cred Subject credential @param so Object socket @param socklabel Policy label for socket Determine whether the subject identified by the credential can receive data from the socket. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_socket_check_receive_t( kauth_cred_t cred, socket_t so, struct label *socklabel ); /** @brief Access control check for socket receive @param cred Subject credential @param sock Object socket @param socklabel Policy label for socket @param saddr Name of the remote socket Determine whether the subject identified by the credential can receive data from the remote host specified by addr. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_socket_check_received_t( kauth_cred_t cred, struct socket *sock, struct label *socklabel, struct sockaddr *saddr ); /** @brief Access control check for socket select @param cred Subject credential @param so Object socket @param socklabel Policy label for socket @param which The operation selected on: FREAD or FWRITE Determine whether the subject identified by the credential can use the socket in a call to select(). @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_socket_check_select_t( kauth_cred_t cred, socket_t so, struct label *socklabel, int which ); /** @brief Access control check for socket send @param cred Subject credential @param so Object socket @param socklabel Policy label for socket @param addr Address being sent to Determine whether the subject identified by the credential can send data to the socket. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_socket_check_send_t( kauth_cred_t cred, socket_t so, struct label *socklabel, struct sockaddr *addr ); /** @brief Access control check for retrieving socket status @param cred Subject credential @param so Object socket @param socklabel Policy label for so Determine whether the subject identified by the credential can execute the stat() system call on the given socket. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_socket_check_stat_t( kauth_cred_t cred, socket_t so, struct label *socklabel ); /** @brief Access control check for setting socket options @param cred Subject credential @param so Object socket @param socklabel Policy label for so @param sopt The options being set Determine whether the subject identified by the credential can execute the setsockopt system call on the given socket. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_socket_check_setsockopt_t( kauth_cred_t cred, socket_t so, struct label *socklabel, struct sockopt *sopt ); /** @brief Access control check for getting socket options @param cred Subject credential @param so Object socket @param socklabel Policy label for so @param sopt The options to get Determine whether the subject identified by the credential can execute the getsockopt system call on the given socket. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_socket_check_getsockopt_t( kauth_cred_t cred, socket_t so, struct label *socklabel, struct sockopt *sopt ); /** @brief Label a socket @param oldsock Listening socket @param oldlabel Policy label associated with oldsock @param newsock New socket @param newlabel Policy label associated with newsock A new socket is created when a connection is accept(2)ed. This function labels the new socket based on the existing listen(2)ing socket. */ typedef void mpo_socket_label_associate_accept_t( socket_t oldsock, struct label *oldlabel, socket_t newsock, struct label *newlabel ); /** @brief Assign a label to a new socket @param cred Credential of the owning process @param so The socket being labeled @param solabel The label @warning cred can be NULL Set the label on a newly created socket from the passed subject credential. This call is made when a socket is created. The credentials may be null if the socket is being created by the kernel. */ typedef void mpo_socket_label_associate_t( kauth_cred_t cred, socket_t so, struct label *solabel ); /** @brief Copy a socket label @param src Source label @param dest Destination label Copy the socket label information in src into dest. */ typedef void mpo_socket_label_copy_t( struct label *src, struct label *dest ); /** @brief Destroy socket label @param label The label to be destroyed Destroy a socket label. Since the object is going out of scope, policy modules should free any internal storage associated with the label so that it may be destroyed. */ typedef void mpo_socket_label_destroy_t( struct label *label ); /** @brief Externalize a socket label @param label Label to be externalized @param element_name Name of the label namespace for which labels should be externalized @param sb String buffer to be filled with a text representation of label Produce an externalized socket label based on the label structure passed. An externalized label consists of a text representation of the label contents that can be used with userland applications and read by the user. If element_name does not match a namespace managed by the policy, simply return 0. Only return nonzero if an error occurs while externalizing the label data. @return In the event of an error, an appropriate value for errno should be returned, otherwise return 0 upon success. */ typedef int mpo_socket_label_externalize_t( struct label *label, char *element_name, struct sbuf *sb ); /** @brief Initialize socket label @param label New label to initialize @param waitok Malloc flags Initialize the label of a newly instantiated socket. The waitok field may be one of M_WAITOK and M_NOWAIT, and should be employed to avoid performing a sleeping malloc(9) during this initialization call. It it not always safe to sleep during this entry point. @warning Since it is possible for the waitok flags to be set to M_NOWAIT, the malloc operation may fail. @return In the event of an error, an appropriate value for errno should be returned, otherwise return 0 upon success. */ typedef int mpo_socket_label_init_t( struct label *label, int waitok ); /** @brief Internalize a socket label @param label Label to be filled in @param element_name Name of the label namespace for which the label should be internalized @param element_data Text data to be internalized Produce an internal socket label structure based on externalized label data in text format. The policy's internalize entry points will be called only if the policy has registered interest in the label namespace. @return In the event of an error, an appropriate value for errno should be returned, otherwise return 0 upon success. */ typedef int mpo_socket_label_internalize_t( struct label *label, char *element_name, char *element_data ); /** @brief Relabel socket @param cred Subject credential @param so Object; socket @param so_label Current label of the socket @param newlabel The label to be assigned to so The subject identified by the credential has previously requested and was authorized to relabel the socket; this entry point allows policies to perform the actual label update operation. @warning XXX This entry point will likely change in future versions. */ typedef void mpo_socket_label_update_t( kauth_cred_t cred, socket_t so, struct label *so_label, struct label *newlabel ); /** @brief Set the peer label on a socket from mbuf @param m Mbuf chain received on socket so @param m_label Label for m @param so Current label for the socket @param so_label Policy label to be filled out for the socket Set the peer label of a socket based on the label of the sender of the mbuf. This is called for every TCP/IP packet received. The first call for a given socket operates on a newly initialized label, and subsequent calls operate on existing label data. @warning Because this can affect performance significantly, it has different sematics than other 'set' operations. Typically, 'set' operations operate on newly initialzed labels and policies do not need to worry about clobbering existing values. In this case, it is too inefficient to initialize and destroy a label every time data is received for the socket. Instead, it is up to the policies to determine how to replace the label data. Most policies should be able to replace the data inline. */ typedef void mpo_socketpeer_label_associate_mbuf_t( struct mbuf *m, struct label *m_label, socket_t so, struct label *so_label ); /** @brief Set the peer label on a socket from socket @param source Local socket @param sourcelabel Policy label for source @param target Peer socket @param targetlabel Policy label to fill in for target Set the peer label on a stream UNIX domain socket from the passed remote socket endpoint. This call will be made when the socket pair is connected, and will be made for both endpoints. Note that this call is only made on connection; it is currently not updated during communication. */ typedef void mpo_socketpeer_label_associate_socket_t( socket_t source, struct label *sourcelabel, socket_t target, struct label *targetlabel ); /** @brief Destroy socket peer label @param label The peer label to be destroyed Destroy a socket peer label. Since the object is going out of scope, policy modules should free any internal storage associated with the label so that it may be destroyed. */ typedef void mpo_socketpeer_label_destroy_t( struct label *label ); /** @brief Externalize a socket peer label @param label Label to be externalized @param element_name Name of the label namespace for which labels should be externalized @param sb String buffer to be filled with a text representation of label Produce an externalized socket peer label based on the label structure passed. An externalized label consists of a text representation of the label contents that can be used with userland applications and read by the user. If element_name does not match a namespace managed by the policy, simply return 0. Only return nonzero if an error occurs while externalizing the label data. @return In the event of an error, an appropriate value for errno should be returned, otherwise return 0 upon success. */ typedef int mpo_socketpeer_label_externalize_t( struct label *label, char *element_name, struct sbuf *sb ); /** @brief Initialize socket peer label @param label New label to initialize @param waitok Malloc flags Initialize the peer label of a newly instantiated socket. The waitok field may be one of M_WAITOK and M_NOWAIT, and should be employed to avoid performing a sleeping malloc(9) during this initialization call. It it not always safe to sleep during this entry point. @warning Since it is possible for the waitok flags to be set to M_NOWAIT, the malloc operation may fail. @return In the event of an error, an appropriate value for errno should be returned, otherwise return 0 upon success. */ typedef int mpo_socketpeer_label_init_t( struct label *label, int waitok ); /** @brief Access control check for enabling accounting @param cred Subject credential @param vp Accounting file @param vlabel Label associated with vp Determine whether the subject should be allowed to enable accounting, based on its label and the label of the accounting log file. See acct(5) for more information. As accounting is disabled by passing NULL to the acct(2) system call, the policy should be prepared for both 'vp' and 'vlabel' to be NULL. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_system_check_acct_t( kauth_cred_t cred, struct vnode *vp, struct label *vlabel ); /** @brief Access control check for audit @param cred Subject credential @param record Audit record @param length Audit record length Determine whether the subject identified by the credential can submit an audit record for inclusion in the audit log via the audit() system call. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_system_check_audit_t( kauth_cred_t cred, void *record, int length ); /** @brief Access control check for controlling audit @param cred Subject credential @param vp Audit file @param vl Label associated with vp Determine whether the subject should be allowed to enable auditing using the auditctl() system call, based on its label and the label of the proposed audit file. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_system_check_auditctl_t( kauth_cred_t cred, struct vnode *vp, struct label *vl ); /** @brief Access control check for manipulating auditing @param cred Subject credential @param cmd Audit control command Determine whether the subject identified by the credential can perform the audit subsystem control operation cmd via the auditon() system call. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_system_check_auditon_t( kauth_cred_t cred, int cmd ); /** @brief Access control check for using CHUD facilities @param cred Subject credential Determine whether the subject identified by the credential can perform performance-related tasks using the CHUD system call. This interface is deprecated. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_system_check_chud_t( kauth_cred_t cred ); /** @brief Access control check for obtaining the host control port @param cred Subject credential Determine whether the subject identified by the credential can obtain the host control port. @return Return 0 if access is granted, or non-zero otherwise. */ typedef int mpo_system_check_host_priv_t( kauth_cred_t cred ); /** @brief Access control check for obtaining system information @param cred Subject credential @param info_type A description of the information requested Determine whether the subject identified by the credential should be allowed to obtain information about the system. This is a generic hook that can be used in a variety of situations where information is being returned that might be considered sensitive. Rather than adding a new MAC hook for every such interface, this hook can be called with a string identifying the type of information requested. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_system_check_info_t( kauth_cred_t cred, const char *info_type ); /** @brief Access control check for calling NFS services @param cred Subject credential Determine whether the subject identified by the credential should be allowed to call nfssrv(2). @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_system_check_nfsd_t( kauth_cred_t cred ); /** @brief Access control check for reboot @param cred Subject credential @param howto howto parameter from reboot(2) Determine whether the subject identified by the credential should be allowed to reboot the system in the specified manner. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_system_check_reboot_t( kauth_cred_t cred, int howto ); /** @brief Access control check for setting system clock @param cred Subject credential Determine whether the subject identified by the credential should be allowed to set the system clock. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_system_check_settime_t( kauth_cred_t cred ); /** @brief Access control check for removing swap devices @param cred Subject credential @param vp Swap device @param label Label associated with vp Determine whether the subject identified by the credential should be allowed to remove vp as a swap device. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_system_check_swapoff_t( kauth_cred_t cred, struct vnode *vp, struct label *label ); /** @brief Access control check for adding swap devices @param cred Subject credential @param vp Swap device @param label Label associated with vp Determine whether the subject identified by the credential should be allowed to add vp as a swap device. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_system_check_swapon_t( kauth_cred_t cred, struct vnode *vp, struct label *label ); /** @brief Access control check for sysctl @param cred Subject credential @param namestring String representation of sysctl name. @param name Integer name; see sysctl(3) @param namelen Length of name array of integers; see sysctl(3) @param old 0 or address where to store old value; see sysctl(3) @param oldlen Length of old buffer; see sysctl(3) @param newvalue 0 or address of new value; see sysctl(3) @param newlen Length of new buffer; see sysctl(3) Determine whether the subject identified by the credential should be allowed to make the specified sysctl(3) transaction. The sysctl(3) call specifies that if the old value is not desired, oldp and oldlenp should be set to NULL. Likewise, if a new value is not to be set, newp should be set to NULL and newlen set to 0. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_system_check_sysctlbyname_t( kauth_cred_t cred, const char *namestring, int *name, u_int namelen, user_addr_t old, /* NULLOK */ size_t oldlen, user_addr_t newvalue, /* NULLOK */ size_t newlen ); /** @brief Access control check for kas_info @param cred Subject credential @param selector Category of information to return. See kas_info.h Determine whether the subject identified by the credential can perform introspection of the kernel address space layout for debugging/performance analysis. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_system_check_kas_info_t( kauth_cred_t cred, int selector ); /** @brief Create a System V message label @param cred Subject credential @param msqptr The message queue the message will be placed in @param msqlabel The label of the message queue @param msgptr The message @param msglabel The label of the message Label the message as its placed in the message queue. */ typedef void mpo_sysvmsg_label_associate_t( kauth_cred_t cred, struct msqid_kernel *msqptr, struct label *msqlabel, struct msg *msgptr, struct label *msglabel ); /** @brief Destroy System V message label @param label The label to be destroyed Destroy a System V message label. Since the object is going out of scope, policy modules should free any internal storage associated with the label so that it may be destroyed. */ typedef void mpo_sysvmsg_label_destroy_t( struct label *label ); /** @brief Initialize System V message label @param label New label to initialize Initialize the label for a newly instantiated System V message. */ typedef void mpo_sysvmsg_label_init_t( struct label *label ); /** @brief Clean up a System V message label @param label The label to be destroyed Clean up a System V message label. Darwin pre-allocates messages at system boot time and re-uses them rather than allocating new ones. Before messages are returned to the "free pool", policies can cleanup or overwrite any information present in the label. */ typedef void mpo_sysvmsg_label_recycle_t( struct label *label ); /** @brief Access control check for System V message enqueuing @param cred Subject credential @param msgptr The message @param msglabel The message's label @param msqptr The message queue @param msqlabel The message queue's label Determine whether the subject identified by the credential can add the given message to the given message queue. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_sysvmsq_check_enqueue_t( kauth_cred_t cred, struct msg *msgptr, struct label *msglabel, struct msqid_kernel *msqptr, struct label *msqlabel ); /** @brief Access control check for System V message reception @param cred The credential of the intended recipient @param msgptr The message @param msglabel The message's label Determine whether the subject identified by the credential can receive the given message. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_sysvmsq_check_msgrcv_t( kauth_cred_t cred, struct msg *msgptr, struct label *msglabel ); /** @brief Access control check for System V message queue removal @param cred The credential of the caller @param msgptr The message @param msglabel The message's label System V message queues are removed using the msgctl() system call. The system will iterate over each messsage in the queue, calling this function for each, to determine whether the caller has the appropriate credentials. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_sysvmsq_check_msgrmid_t( kauth_cred_t cred, struct msg *msgptr, struct label *msglabel ); /** @brief Access control check for msgctl() @param cred The credential of the caller @param msqptr The message queue @param msqlabel The message queue's label This access check is performed to validate calls to msgctl(). @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_sysvmsq_check_msqctl_t( kauth_cred_t cred, struct msqid_kernel *msqptr, struct label *msqlabel, int cmd ); /** @brief Access control check to get a System V message queue @param cred The credential of the caller @param msqptr The message queue requested @param msqlabel The message queue's label On a call to msgget(), if the queue requested already exists, and it is a public queue, this check will be performed before the queue's ID is returned to the user. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_sysvmsq_check_msqget_t( kauth_cred_t cred, struct msqid_kernel *msqptr, struct label *msqlabel ); /** @brief Access control check to receive a System V message from the given queue @param cred The credential of the caller @param msqptr The message queue to receive from @param msqlabel The message queue's label On a call to msgrcv(), this check is performed to determine whether the caller has receive rights on the given queue. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_sysvmsq_check_msqrcv_t( kauth_cred_t cred, struct msqid_kernel *msqptr, struct label *msqlabel ); /** @brief Access control check to send a System V message to the given queue @param cred The credential of the caller @param msqptr The message queue to send to @param msqlabel The message queue's label On a call to msgsnd(), this check is performed to determine whether the caller has send rights on the given queue. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_sysvmsq_check_msqsnd_t( kauth_cred_t cred, struct msqid_kernel *msqptr, struct label *msqlabel ); /** @brief Create a System V message queue label @param cred Subject credential @param msqptr The message queue @param msqlabel The label of the message queue */ typedef void mpo_sysvmsq_label_associate_t( kauth_cred_t cred, struct msqid_kernel *msqptr, struct label *msqlabel ); /** @brief Destroy System V message queue label @param label The label to be destroyed Destroy a System V message queue label. Since the object is going out of scope, policy modules should free any internal storage associated with the label so that it may be destroyed. */ typedef void mpo_sysvmsq_label_destroy_t( struct label *label ); /** @brief Initialize System V message queue label @param label New label to initialize Initialize the label for a newly instantiated System V message queue. */ typedef void mpo_sysvmsq_label_init_t( struct label *label ); /** @brief Clean up a System V message queue label @param label The label to be destroyed Clean up a System V message queue label. Darwin pre-allocates message queues at system boot time and re-uses them rather than allocating new ones. Before message queues are returned to the "free pool", policies can cleanup or overwrite any information present in the label. */ typedef void mpo_sysvmsq_label_recycle_t( struct label *label ); /** @brief Access control check for System V semaphore control operation @param cred Subject credential @param semakptr Pointer to semaphore identifier @param semaklabel Label associated with semaphore @param cmd Control operation to be performed; see semctl(2) Determine whether the subject identified by the credential can perform the operation indicated by cmd on the System V semaphore semakptr. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_sysvsem_check_semctl_t( kauth_cred_t cred, struct semid_kernel *semakptr, struct label *semaklabel, int cmd ); /** @brief Access control check for obtaining a System V semaphore @param cred Subject credential @param semakptr Pointer to semaphore identifier @param semaklabel Label to associate with the semaphore Determine whether the subject identified by the credential can obtain a System V semaphore. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_sysvsem_check_semget_t( kauth_cred_t cred, struct semid_kernel *semakptr, struct label *semaklabel ); /** @brief Access control check for System V semaphore operations @param cred Subject credential @param semakptr Pointer to semaphore identifier @param semaklabel Label associated with the semaphore @param accesstype Flags to indicate access (read and/or write) Determine whether the subject identified by the credential can perform the operations on the System V semaphore indicated by semakptr. The accesstype flags hold the maximum set of permissions from the sem_op array passed to the semop system call. It may contain SEM_R for read-only operations or SEM_A for read/write operations. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_sysvsem_check_semop_t( kauth_cred_t cred, struct semid_kernel *semakptr, struct label *semaklabel, size_t accesstype ); /** @brief Create a System V semaphore label @param cred Subject credential @param semakptr The semaphore being created @param semalabel Label to associate with the new semaphore Label a new System V semaphore. The label was previously initialized and associated with the semaphore. At this time, an appropriate initial label value should be assigned to the object and stored in semalabel. */ typedef void mpo_sysvsem_label_associate_t( kauth_cred_t cred, struct semid_kernel *semakptr, struct label *semalabel ); /** @brief Destroy System V semaphore label @param label The label to be destroyed Destroy a System V semaphore label. Since the object is going out of scope, policy modules should free any internal storage associated with the label so that it may be destroyed. */ typedef void mpo_sysvsem_label_destroy_t( struct label *label ); /** @brief Initialize System V semaphore label @param label New label to initialize Initialize the label for a newly instantiated System V semaphore. Sleeping is permitted. */ typedef void mpo_sysvsem_label_init_t( struct label *label ); /** @brief Clean up a System V semaphore label @param label The label to be cleaned Clean up a System V semaphore label. Darwin pre-allocates semaphores at system boot time and re-uses them rather than allocating new ones. Before semaphores are returned to the "free pool", policies can cleanup or overwrite any information present in the label. */ typedef void mpo_sysvsem_label_recycle_t( struct label *label ); /** @brief Access control check for mapping System V shared memory @param cred Subject credential @param shmsegptr Pointer to shared memory segment identifier @param shmseglabel Label associated with the shared memory segment @param shmflg shmat flags; see shmat(2) Determine whether the subject identified by the credential can map the System V shared memory segment associated with shmsegptr. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_sysvshm_check_shmat_t( kauth_cred_t cred, struct shmid_kernel *shmsegptr, struct label *shmseglabel, int shmflg ); /** @brief Access control check for System V shared memory control operation @param cred Subject credential @param shmsegptr Pointer to shared memory segment identifier @param shmseglabel Label associated with the shared memory segment @param cmd Control operation to be performed; see shmctl(2) Determine whether the subject identified by the credential can perform the operation indicated by cmd on the System V shared memory segment shmsegptr. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_sysvshm_check_shmctl_t( kauth_cred_t cred, struct shmid_kernel *shmsegptr, struct label *shmseglabel, int cmd ); /** @brief Access control check for unmapping System V shared memory @param cred Subject credential @param shmsegptr Pointer to shared memory segment identifier @param shmseglabel Label associated with the shared memory segment Determine whether the subject identified by the credential can unmap the System V shared memory segment associated with shmsegptr. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_sysvshm_check_shmdt_t( kauth_cred_t cred, struct shmid_kernel *shmsegptr, struct label *shmseglabel ); /** @brief Access control check obtaining System V shared memory identifier @param cred Subject credential @param shmsegptr Pointer to shared memory segment identifier @param shmseglabel Label associated with the shared memory segment @param shmflg shmget flags; see shmget(2) Determine whether the subject identified by the credential can get the System V shared memory segment address. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_sysvshm_check_shmget_t( kauth_cred_t cred, struct shmid_kernel *shmsegptr, struct label *shmseglabel, int shmflg ); /** @brief Create a System V shared memory region label @param cred Subject credential @param shmsegptr The shared memory region being created @param shmlabel Label to associate with the new shared memory region Label a new System V shared memory region. The label was previously initialized and associated with the shared memory region. At this time, an appropriate initial label value should be assigned to the object and stored in shmlabel. */ typedef void mpo_sysvshm_label_associate_t( kauth_cred_t cred, struct shmid_kernel *shmsegptr, struct label *shmlabel ); /** @brief Destroy System V shared memory label @param label The label to be destroyed Destroy a System V shared memory region label. Since the object is going out of scope, policy modules should free any internal storage associated with the label so that it may be destroyed. */ typedef void mpo_sysvshm_label_destroy_t( struct label *label ); /** @brief Initialize System V Shared Memory region label @param label New label to initialize Initialize the label for a newly instantiated System V Shared Memory region. Sleeping is permitted. */ typedef void mpo_sysvshm_label_init_t( struct label *label ); /** @brief Clean up a System V Share Memory Region label @param shmlabel The label to be cleaned Clean up a System V Shared Memory Region label. Darwin pre-allocates these objects at system boot time and re-uses them rather than allocating new ones. Before the memory regions are returned to the "free pool", policies can cleanup or overwrite any information present in the label. */ typedef void mpo_sysvshm_label_recycle_t( struct label *shmlabel ); /** @brief Access control check for getting a process's task name @param cred Subject credential @param p Object process Determine whether the subject identified by the credential can get the passed process's task name port. This call is used by the task_name_for_pid(2) API. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch, EPERM for lack of privilege, or ESRCH to hide visibility of the target. */ typedef int mpo_proc_check_get_task_name_t( kauth_cred_t cred, struct proc *p ); /** @brief Access control check for getting a process's task port @param cred Subject credential @param p Object process Determine whether the subject identified by the credential can get the passed process's task control port. This call is used by the task_for_pid(2) API. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch, EPERM for lack of privilege, or ESRCH to hide visibility of the target. */ typedef int mpo_proc_check_get_task_t( kauth_cred_t cred, struct proc *p ); /** @brief Access control check for exposing a process's task port @param cred Subject credential @param p Object process Determine whether the subject identified by the credential can expose the passed process's task control port. This call is used by the accessor APIs like processor_set_tasks() and processor_set_threads(). @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch, EPERM for lack of privilege, or ESRCH to hide visibility of the target. */ typedef int mpo_proc_check_expose_task_t( kauth_cred_t cred, struct proc *p ); /** @brief Check whether task's IPC may inherit across process exec @param p current process instance @param cur_vp vnode pointer to current instance @param cur_offset offset of binary of currently executing image @param img_vp vnode pointer to to be exec'ed image @param img_offset offset into file which is selected for execution @param scriptvp vnode pointer of script file if any. @return Return 0 if access is granted. EPERM if parent does not have any entitlements. EACCESS if mismatch in entitlements */ typedef int mpo_proc_check_inherit_ipc_ports_t( struct proc *p, struct vnode *cur_vp, off_t cur_offset, struct vnode *img_vp, off_t img_offset, struct vnode *scriptvp ); /** @brief Privilege check for a process to run invalid @param p Object process Determine whether the process may execute even though the system determined that it is untrusted (eg unidentified / modified code). @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_proc_check_run_cs_invalid_t( struct proc *p ); /** @brief Perform MAC-related events when a thread returns to user space @param thread Mach (not BSD) thread that is returning This entry point permits policy modules to perform MAC-related events when a thread returns to user space, via a system call return or trap return. */ typedef void mpo_thread_userret_t( struct thread *thread ); /** @brief Check vnode access @param cred Subject credential @param vp Object vnode @param label Label for vp @param acc_mode access(2) flags Determine how invocations of access(2) and related calls by the subject identified by the credential should return when performed on the passed vnode using the passed access flags. This should generally be implemented using the same semantics used in mpo_vnode_check_open. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_access_t( kauth_cred_t cred, struct vnode *vp, struct label *label, int acc_mode ); /** @brief Access control check for changing working directory @param cred Subject credential @param dvp Object; vnode to chdir(2) into @param dlabel Policy label for dvp Determine whether the subject identified by the credential can change the process working directory to the passed vnode. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_chdir_t( kauth_cred_t cred, struct vnode *dvp, struct label *dlabel ); /** @brief Access control check for changing root directory @param cred Subject credential @param dvp Directory vnode @param dlabel Policy label associated with dvp @param cnp Component name for dvp Determine whether the subject identified by the credential should be allowed to chroot(2) into the specified directory (dvp). @return In the event of an error, an appropriate value for errno should be returned, otherwise return 0 upon success. */ typedef int mpo_vnode_check_chroot_t( kauth_cred_t cred, struct vnode *dvp, struct label *dlabel, struct componentname *cnp ); /** @brief Access control check for creating clone @param cred Subject credential @param dvp Vnode of directory to create the clone in @param dlabel Policy label associated with dvp @param vp Vnode of the file to clone from @param label Policy label associated with vp @param cnp Component name for the clone being created Determine whether the subject identified by the credential should be allowed to create a clone of the vnode vp with the name specified by cnp. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_vnode_check_clone_t( kauth_cred_t cred, struct vnode *dvp, struct label *dlabel, struct vnode *vp, struct label *label, struct componentname *cnp ); /** @brief Access control check for creating vnode @param cred Subject credential @param dvp Directory vnode @param dlabel Policy label for dvp @param cnp Component name for dvp @param vap vnode attributes for vap Determine whether the subject identified by the credential can create a vnode with the passed parent directory, passed name information, and passed attribute information. This call may be made in a number of situations, including as a result of calls to open(2) with O_CREAT, mknod(2), mkfifo(2), and others. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_create_t( kauth_cred_t cred, struct vnode *dvp, struct label *dlabel, struct componentname *cnp, struct vnode_attr *vap ); /** @brief Access control check for deleting extended attribute @param cred Subject credential @param vp Object vnode @param vlabel Label associated with vp @param name Extended attribute name Determine whether the subject identified by the credential can delete the extended attribute from the passed vnode. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_deleteextattr_t( kauth_cred_t cred, struct vnode *vp, struct label *vlabel, const char *name ); /** @brief Access control check for exchanging file data @param cred Subject credential @param v1 vnode 1 to swap @param vl1 Policy label for v1 @param v2 vnode 2 to swap @param vl2 Policy label for v2 Determine whether the subject identified by the credential can swap the data in the two supplied vnodes. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_exchangedata_t( kauth_cred_t cred, struct vnode *v1, struct label *vl1, struct vnode *v2, struct label *vl2 ); /** @brief Access control check for executing the vnode @param cred Subject credential @param vp Object vnode to execute @param scriptvp Script being executed by interpreter, if any. @param vnodelabel Label corresponding to vp @param scriptlabel Script vnode label @param execlabel Userspace provided execution label @param cnp Component name for file being executed @param macpolicyattr MAC policy-specific spawn attribute data. @param macpolicyattrlen Length of policy-specific spawn attribute data. Determine whether the subject identified by the credential can execute the passed vnode. Determination of execute privilege is made separately from decisions about any process label transitioning event. The final label, execlabel, corresponds to a label supplied by a user space application through the use of the mac_execve system call. This label will be NULL if the user application uses the the vendor execve(2) call instead of the MAC Framework mac_execve() call. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_exec_t( kauth_cred_t cred, struct vnode *vp, struct vnode *scriptvp, struct label *vnodelabel, struct label *scriptlabel, struct label *execlabel, /* NULLOK */ struct componentname *cnp, u_int *csflags, void *macpolicyattr, size_t macpolicyattrlen ); /** @brief Access control check for fsgetpath @param cred Subject credential @param vp Vnode for which a path will be returned @param label Label associated with the vnode Determine whether the subject identified by the credential can get the path of the given vnode with fsgetpath. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_vnode_check_fsgetpath_t( kauth_cred_t cred, struct vnode *vp, struct label *label ); /** @brief Access control check for retrieving file attributes @param active_cred Subject credential @param file_cred Credential associated with the struct fileproc @param vp Object vnode @param vlabel Policy label for vp @param va Vnode attributes to retrieve Determine whether the subject identified by the credential can get information about the passed vnode. The active_cred hold the credentials of the subject performing the operation, and file_cred holds the credentials of the subject that originally opened the file. This check happens during stat(), lstat(), fstat(), and getattrlist() syscalls. See <sys/vnode.h> for definitions of the attributes. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. @note Policies may change the contents of va to alter the list of file attributes returned. */ typedef int mpo_vnode_check_getattr_t( kauth_cred_t active_cred, kauth_cred_t file_cred, /* NULLOK */ struct vnode *vp, struct label *vlabel, struct vnode_attr *va ); /** @brief Access control check for retrieving file attributes @param cred Subject credential @param vp Object vnode @param vlabel Policy label for vp @param alist List of attributes to retrieve Determine whether the subject identified by the credential can read various attributes of the specified vnode, or the filesystem or volume on which that vnode resides. See <sys/attr.h> for definitions of the attributes. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. Access control covers all attributes requested with this call; the security policy is not permitted to change the set of attributes requested. */ typedef int mpo_vnode_check_getattrlist_t( kauth_cred_t cred, struct vnode *vp, struct label *vlabel, struct attrlist *alist ); /** @brief Access control check for retrieving an extended attribute @param cred Subject credential @param vp Object vnode @param label Policy label for vp @param name Extended attribute name @param uio I/O structure pointer Determine whether the subject identified by the credential can retrieve the extended attribute from the passed vnode. The uio parameter will be NULL when the getxattr(2) call has been made with a NULL data value; this is done to request the size of the data only. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_getextattr_t( kauth_cred_t cred, struct vnode *vp, struct label *label, /* NULLOK */ const char *name, struct uio *uio /* NULLOK */ ); /** @brief Access control check for ioctl @param cred Subject credential @param vp Object vnode @param label Policy label for vp @param cmd Device-dependent request code; see ioctl(2) Determine whether the subject identified by the credential can perform the ioctl operation indicated by com. @warning Since ioctl data is opaque from the standpoint of the MAC framework, and since ioctls can affect many aspects of system operation, policies must exercise extreme care when implementing access control checks. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_vnode_check_ioctl_t( kauth_cred_t cred, struct vnode *vp, struct label *label, unsigned int cmd ); /** @brief Access control check for vnode kqfilter @param active_cred Subject credential @param kn Object knote @param vp Object vnode @param label Policy label for vp Determine whether the subject identified by the credential can receive the knote on the passed vnode. @return Return 0 if access if granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_vnode_check_kqfilter_t( kauth_cred_t active_cred, kauth_cred_t file_cred, /* NULLOK */ struct knote *kn, struct vnode *vp, struct label *label ); /** @brief Access control check for relabel @param cred Subject credential @param vp Object vnode @param vnodelabel Existing policy label for vp @param newlabel Policy label update to later be applied to vp @see mpo_relable_vnode_t Determine whether the subject identified by the credential can relabel the passed vnode to the passed label update. If all policies permit the label change, the actual relabel entry point (mpo_vnode_label_update) will follow. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_vnode_check_label_update_t( struct ucred *cred, struct vnode *vp, struct label *vnodelabel, struct label *newlabel ); /** @brief Access control check for creating link @param cred Subject credential @param dvp Directory vnode @param dlabel Policy label associated with dvp @param vp Link destination vnode @param label Policy label associated with vp @param cnp Component name for the link being created Determine whether the subject identified by the credential should be allowed to create a link to the vnode vp with the name specified by cnp. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_vnode_check_link_t( kauth_cred_t cred, struct vnode *dvp, struct label *dlabel, struct vnode *vp, struct label *label, struct componentname *cnp ); /** @brief Access control check for listing extended attributes @param cred Subject credential @param vp Object vnode @param vlabel Policy label associated with vp Determine whether the subject identified by the credential can retrieve a list of named extended attributes from a vnode. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_vnode_check_listextattr_t( kauth_cred_t cred, struct vnode *vp, struct label *vlabel ); /** @brief Access control check for lookup @param cred Subject credential @param dvp Directory vnode @param dlabel Policy label for dvp @param path Path being looked up @param pathlen Length of path in bytes Determine whether the subject identified by the credential can perform a lookup of the passed path relative to the passed directory vnode. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. @note The path may contain untrusted input. If approved, lookup proceeds on the path; if a component is found to be a symlink then this hook is called again with the updated path. */ typedef int mpo_vnode_check_lookup_preflight_t( kauth_cred_t cred, struct vnode *dvp, struct label *dlabel, const char *path, size_t pathlen ); /** @brief Access control check for lookup @param cred Subject credential @param dvp Object vnode @param dlabel Policy label for dvp @param cnp Component name being looked up Determine whether the subject identified by the credential can perform a lookup in the passed directory vnode for the passed name (cnp). @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_lookup_t( kauth_cred_t cred, struct vnode *dvp, struct label *dlabel, struct componentname *cnp ); /** @brief Access control check for open @param cred Subject credential @param vp Object vnode @param label Policy label associated with vp @param acc_mode open(2) access mode Determine whether the subject identified by the credential can perform an open operation on the passed vnode with the passed access mode. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_open_t( kauth_cred_t cred, struct vnode *vp, struct label *label, int acc_mode ); /** @brief Access control check for read @param active_cred Subject credential @param file_cred Credential associated with the struct fileproc @param vp Object vnode @param label Policy label for vp Determine whether the subject identified by the credential can perform a read operation on the passed vnode. The active_cred hold the credentials of the subject performing the operation, and file_cred holds the credentials of the subject that originally opened the file. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_read_t( kauth_cred_t active_cred, /* SUBJECT */ kauth_cred_t file_cred, /* NULLOK */ struct vnode *vp, /* OBJECT */ struct label *label /* LABEL */ ); /** @brief Access control check for read directory @param cred Subject credential @param dvp Object directory vnode @param dlabel Policy label for dvp Determine whether the subject identified by the credential can perform a readdir operation on the passed directory vnode. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_readdir_t( kauth_cred_t cred, /* SUBJECT */ struct vnode *dvp, /* OBJECT */ struct label *dlabel /* LABEL */ ); /** @brief Access control check for read link @param cred Subject credential @param vp Object vnode @param label Policy label for vp Determine whether the subject identified by the credential can perform a readlink operation on the passed symlink vnode. This call can be made in a number of situations, including an explicit readlink call by the user process, or as a result of an implicit readlink during a name lookup by the process. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_readlink_t( kauth_cred_t cred, struct vnode *vp, struct label *label ); /** @brief Access control check for rename @param cred Subject credential @param dvp Directory vnode @param dlabel Policy label associated with dvp @param vp vnode to be renamed @param label Policy label associated with vp @param cnp Component name for vp @param tdvp Destination directory vnode @param tdlabel Policy label associated with tdvp @param tvp Overwritten vnode @param tlabel Policy label associated with tvp @param tcnp Destination component name Determine whether the subject identified by the credential should be allowed to rename the vnode vp to something else. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_vnode_check_rename_t( kauth_cred_t cred, struct vnode *dvp, struct label *dlabel, struct vnode *vp, struct label *label, struct componentname *cnp, struct vnode *tdvp, struct label *tdlabel, struct vnode *tvp, struct label *tlabel, struct componentname *tcnp ); /** @brief Access control check for rename from @param cred Subject credential @param dvp Directory vnode @param dlabel Policy label associated with dvp @param vp vnode to be renamed @param label Policy label associated with vp @param cnp Component name for vp @see mpo_vnode_check_rename_t @see mpo_vnode_check_rename_to_t Determine whether the subject identified by the credential should be allowed to rename the vnode vp to something else. Due to VFS locking constraints (to make sure proper vnode locks are held during this entry point), the vnode relabel checks had to be split into two parts: relabel_from and relabel to. This hook is deprecated, mpo_vnode_check_rename_t should be used instead. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_vnode_check_rename_from_t( kauth_cred_t cred, struct vnode *dvp, struct label *dlabel, struct vnode *vp, struct label *label, struct componentname *cnp ); /** @brief Access control check for rename to @param cred Subject credential @param dvp Directory vnode @param dlabel Policy label associated with dvp @param vp Overwritten vnode @param label Policy label associated with vp @param samedir Boolean; 1 if the source and destination directories are the same @param cnp Destination component name @see mpo_vnode_check_rename_t @see mpo_vnode_check_rename_from_t Determine whether the subject identified by the credential should be allowed to rename to the vnode vp, into the directory dvp, or to the name represented by cnp. If there is no existing file to overwrite, vp and label will be NULL. Due to VFS locking constraints (to make sure proper vnode locks are held during this entry point), the vnode relabel checks had to be split into two parts: relabel_from and relabel to. This hook is deprecated, mpo_vnode_check_rename_t should be used instead. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_vnode_check_rename_to_t( kauth_cred_t cred, struct vnode *dvp, struct label *dlabel, struct vnode *vp, /* NULLOK */ struct label *label, /* NULLOK */ int samedir, struct componentname *cnp ); /** @brief Access control check for revoke @param cred Subject credential @param vp Object vnode @param label Policy label for vp Determine whether the subject identified by the credential can revoke access to the passed vnode. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_revoke_t( kauth_cred_t cred, struct vnode *vp, struct label *label ); /** @brief Access control check for searchfs @param cred Subject credential @param vp Object vnode @param vlabel Policy label for vp @param alist List of attributes used as search criteria Determine whether the subject identified by the credential can search the vnode using the searchfs system call. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_vnode_check_searchfs_t( kauth_cred_t cred, struct vnode *vp, struct label *vlabel, struct attrlist *alist ); /** @brief Access control check for select @param cred Subject credential @param vp Object vnode @param label Policy label for vp @param which The operation selected on: FREAD or FWRITE Determine whether the subject identified by the credential can select the vnode. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_vnode_check_select_t( kauth_cred_t cred, struct vnode *vp, struct label *label, int which ); /** @brief Access control check for setting ACL @param cred Subject credential @param vp Object node @param label Policy label for vp @param acl ACL structure pointer Determine whether the subject identified by the credential can set an ACL on the specified vnode. The ACL pointer will be NULL when removing an ACL. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_setacl_t( kauth_cred_t cred, struct vnode *vp, struct label *label, struct kauth_acl *acl ); /** @brief Access control check for setting file attributes @param cred Subject credential @param vp Object vnode @param vlabel Policy label for vp @param alist List of attributes to set Determine whether the subject identified by the credential can set various attributes of the specified vnode, or the filesystem or volume on which that vnode resides. See <sys/attr.h> for definitions of the attributes. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. Access control covers all attributes requested with this call. */ typedef int mpo_vnode_check_setattrlist_t( kauth_cred_t cred, struct vnode *vp, struct label *vlabel, struct attrlist *alist ); /** @brief Access control check for setting extended attribute @param cred Subject credential @param vp Object vnode @param label Policy label for vp @param name Extended attribute name @param uio I/O structure pointer Determine whether the subject identified by the credential can set the extended attribute of passed name and passed namespace on the passed vnode. Policies implementing security labels backed into extended attributes may want to provide additional protections for those attributes. Additionally, policies should avoid making decisions based on the data referenced from uio, as there is a potential race condition between this check and the actual operation. The uio may also be NULL if a delete operation is being performed. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_setextattr_t( kauth_cred_t cred, struct vnode *vp, struct label *label, const char *name, struct uio *uio ); /** @brief Access control check for setting flags @param cred Subject credential @param vp Object vnode @param label Policy label for vp @param flags File flags; see chflags(2) Determine whether the subject identified by the credential can set the passed flags on the passed vnode. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_setflags_t( kauth_cred_t cred, struct vnode *vp, struct label *label, u_long flags ); /** @brief Access control check for setting mode @param cred Subject credential @param vp Object vnode @param label Policy label for vp @param mode File mode; see chmod(2) Determine whether the subject identified by the credential can set the passed mode on the passed vnode. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_setmode_t( kauth_cred_t cred, struct vnode *vp, struct label *label, mode_t mode ); /** @brief Access control check for setting uid and gid @param cred Subject credential @param vp Object vnode @param label Policy label for vp @param uid User ID @param gid Group ID Determine whether the subject identified by the credential can set the passed uid and passed gid as file uid and file gid on the passed vnode. The IDs may be set to (-1) to request no update. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_setowner_t( kauth_cred_t cred, struct vnode *vp, struct label *label, uid_t uid, gid_t gid ); /** @brief Access control check for setting timestamps @param cred Subject credential @param vp Object vnode @param label Policy label for vp @param atime Access time; see utimes(2) @param mtime Modification time; see utimes(2) Determine whether the subject identified by the credential can set the passed access timestamps on the passed vnode. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_setutimes_t( kauth_cred_t cred, struct vnode *vp, struct label *label, struct timespec atime, struct timespec mtime ); /** @brief Access control check after determining the code directory hash @param vp vnode vnode to combine into proc @param label label associated with the vnode @param cs_blob the code signature to check @param cs_flags update code signing flags if needed @param signer_type output parameter for the code signature's signer type @param flags operational flag to mpo_vnode_check_signature @param fatal_failure_desc description of fatal failure @param fatal_failure_desc_len failure description len, failure is fatal if non-0 @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. */ typedef int mpo_vnode_check_signature_t( struct vnode *vp, struct label *label, struct cs_blob *cs_blob, unsigned int *cs_flags, unsigned int *signer_type, int flags, char **fatal_failure_desc, size_t *fatal_failure_desc_len ); /** @brief Access control check for stat @param active_cred Subject credential @param file_cred Credential associated with the struct fileproc @param vp Object vnode @param label Policy label for vp Determine whether the subject identified by the credential can stat the passed vnode. See stat(2) for more information. The active_cred hold the credentials of the subject performing the operation, and file_cred holds the credentials of the subject that originally opened the file. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_stat_t( struct ucred *active_cred, struct ucred *file_cred, /* NULLOK */ struct vnode *vp, struct label *label ); /** @brief Access control check for vnode trigger resolution @param cred Subject credential @param dvp Object vnode @param dlabel Policy label for dvp @param cnp Component name that triggered resolution Determine whether the subject identified by the credential can trigger resolution of the passed name (cnp) in the passed directory vnode via an external trigger resolver. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_trigger_resolve_t( kauth_cred_t cred, struct vnode *dvp, struct label *dlabel, struct componentname *cnp ); /** @brief Access control check for truncate/ftruncate @param active_cred Subject credential @param file_cred Credential associated with the struct fileproc @param vp Object vnode @param label Policy label for vp Determine whether the subject identified by the credential can perform a truncate operation on the passed vnode. The active_cred hold the credentials of the subject performing the operation, and file_cred holds the credentials of the subject that originally opened the file. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_truncate_t( kauth_cred_t active_cred, kauth_cred_t file_cred, /* NULLOK */ struct vnode *vp, struct label *label ); /** @brief Access control check for binding UNIX domain socket @param cred Subject credential @param dvp Directory vnode @param dlabel Policy label for dvp @param cnp Component name for dvp @param vap vnode attributes for vap Determine whether the subject identified by the credential can perform a bind operation on a UNIX domain socket with the passed parent directory, passed name information, and passed attribute information. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_uipc_bind_t( kauth_cred_t cred, struct vnode *dvp, struct label *dlabel, struct componentname *cnp, struct vnode_attr *vap ); /** @brief Access control check for connecting UNIX domain socket @param cred Subject credential @param vp Object vnode @param label Policy label associated with vp @param so Socket Determine whether the subject identified by the credential can perform a connect operation on the passed UNIX domain socket vnode. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_uipc_connect_t( kauth_cred_t cred, struct vnode *vp, struct label *label, socket_t so ); /** @brief Access control check for deleting vnode @param cred Subject credential @param dvp Parent directory vnode @param dlabel Policy label for dvp @param vp Object vnode to delete @param label Policy label for vp @param cnp Component name for vp @see mpo_check_rename_to_t Determine whether the subject identified by the credential can delete a vnode from the passed parent directory and passed name information. This call may be made in a number of situations, including as a results of calls to unlink(2) and rmdir(2). Policies implementing this entry point should also implement mpo_check_rename_to to authorize deletion of objects as a result of being the target of a rename. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_unlink_t( kauth_cred_t cred, struct vnode *dvp, struct label *dlabel, struct vnode *vp, struct label *label, struct componentname *cnp ); /** @brief Access control check for write @param active_cred Subject credential @param file_cred Credential associated with the struct fileproc @param vp Object vnode @param label Policy label for vp Determine whether the subject identified by the credential can perform a write operation on the passed vnode. The active_cred hold the credentials of the subject performing the operation, and file_cred holds the credentials of the subject that originally opened the file. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EACCES for label mismatch or EPERM for lack of privilege. */ typedef int mpo_vnode_check_write_t( kauth_cred_t active_cred, kauth_cred_t file_cred, /* NULLOK */ struct vnode *vp, struct label *label ); /** @brief Associate a vnode with a devfs entry @param mp Devfs mount point @param mntlabel Devfs mount point label @param de Devfs directory entry @param delabel Label associated with de @param vp vnode associated with de @param vlabel Label associated with vp Fill in the label (vlabel) for a newly created devfs vnode. The label is typically derived from the label on the devfs directory entry or the label on the filesystem, supplied as parameters. */ typedef void mpo_vnode_label_associate_devfs_t( struct mount *mp, struct label *mntlabel, struct devnode *de, struct label *delabel, struct vnode *vp, struct label *vlabel ); /** @brief Associate a label with a vnode @param mp File system mount point @param mntlabel File system mount point label @param vp Vnode to label @param vlabel Label associated with vp Attempt to retrieve label information for the vnode, vp, from the file system extended attribute store. The label should be stored in the supplied vlabel parameter. If a policy cannot retrieve an extended attribute, sometimes it is acceptible to fallback to using the mntlabel. If the policy requires vnodes to have a valid label elsewhere it MUST NOT return other than temporary errors, and must always provide a valid label of some sort. Returning an error will cause vnode labeling to be retried at a later access. Failure to handle policy centric errors internally (corrupt labels etc.) will result in inaccessible files. @return In the event of an error, an appropriate value for errno should be returned, otherwise return 0 upon success. */ typedef int mpo_vnode_label_associate_extattr_t( struct mount *mp, struct label *mntlabel, struct vnode *vp, struct label *vlabel ); /** @brief Associate a file label with a vnode @param cred User credential @param mp Fdesc mount point @param mntlabel Fdesc mount point label @param fg Fileglob structure @param label Policy label for fg @param vp Vnode to label @param vlabel Label associated with vp Associate label information for the vnode, vp, with the label of the open file descriptor described by fg. The label should be stored in the supplied vlabel parameter. */ typedef void mpo_vnode_label_associate_file_t( struct ucred *cred, struct mount *mp, struct label *mntlabel, struct fileglob *fg, struct label *label, struct vnode *vp, struct label *vlabel ); /** @brief Associate a pipe label with a vnode @param cred User credential for the process that opened the pipe @param cpipe Pipe structure @param pipelabel Label associated with pipe @param vp Vnode to label @param vlabel Label associated with vp Associate label information for the vnode, vp, with the label of the pipe described by the pipe structure cpipe. The label should be stored in the supplied vlabel parameter. */ typedef void mpo_vnode_label_associate_pipe_t( struct ucred *cred, struct pipe *cpipe, struct label *pipelabel, struct vnode *vp, struct label *vlabel ); /** @brief Associate a POSIX semaphore label with a vnode @param cred User credential for the process that create psem @param psem POSIX semaphore structure @param psemlabel Label associated with psem @param vp Vnode to label @param vlabel Label associated with vp Associate label information for the vnode, vp, with the label of the POSIX semaphore described by psem. The label should be stored in the supplied vlabel parameter. */ typedef void mpo_vnode_label_associate_posixsem_t( struct ucred *cred, struct pseminfo *psem, struct label *psemlabel, struct vnode *vp, struct label *vlabel ); /** @brief Associate a POSIX shared memory label with a vnode @param cred User credential for the process that created pshm @param pshm POSIX shared memory structure @param pshmlabel Label associated with pshm @param vp Vnode to label @param vlabel Label associated with vp Associate label information for the vnode, vp, with the label of the POSIX shared memory region described by pshm. The label should be stored in the supplied vlabel parameter. */ typedef void mpo_vnode_label_associate_posixshm_t( struct ucred *cred, struct pshminfo *pshm, struct label *pshmlabel, struct vnode *vp, struct label *vlabel ); /** @brief Associate a label with a vnode @param mp File system mount point @param mntlabel File system mount point label @param vp Vnode to label @param vlabel Label associated with vp On non-multilabel file systems, set the label for a vnode. The label will most likely be based on the file system label. */ typedef void mpo_vnode_label_associate_singlelabel_t( struct mount *mp, struct label *mntlabel, struct vnode *vp, struct label *vlabel ); /** @brief Associate a socket label with a vnode @param cred User credential for the process that opened the socket @param so Socket structure @param solabel Label associated with so @param vp Vnode to label @param vlabel Label associated with vp Associate label information for the vnode, vp, with the label of the open socket described by the socket structure so. The label should be stored in the supplied vlabel parameter. */ typedef void mpo_vnode_label_associate_socket_t( kauth_cred_t cred, socket_t so, struct label *solabel, struct vnode *vp, struct label *vlabel ); /** @brief Copy a vnode label @param src Source vnode label @param dest Destination vnode label Copy the vnode label information from src to dest. On Darwin, this is currently only necessary when executing interpreted scripts, but will later be used if vnode label externalization cannot be an atomic operation. */ typedef void mpo_vnode_label_copy_t( struct label *src, struct label *dest ); /** @brief Destroy vnode label @param label The label to be destroyed Destroy a vnode label. Since the object is going out of scope, policy modules should free any internal storage associated with the label so that it may be destroyed. */ typedef void mpo_vnode_label_destroy_t( struct label *label ); /** @brief Externalize a vnode label for auditing @param label Label to be externalized @param element_name Name of the label namespace for which labels should be externalized @param sb String buffer to be filled with a text representation of the label Produce an external representation of the label on a vnode suitable for inclusion in an audit record. An externalized label consists of a text representation of the label contents that will be added to the audit record as part of a text token. Policy-agnostic user space tools will display this externalized version. @return 0 on success, return non-zero if an error occurs while externalizing the label data. */ typedef int mpo_vnode_label_externalize_audit_t( struct label *label, char *element_name, struct sbuf *sb ); /** @brief Externalize a vnode label @param label Label to be externalized @param element_name Name of the label namespace for which labels should be externalized @param sb String buffer to be filled with a text representation of the label Produce an external representation of the label on a vnode. An externalized label consists of a text representation of the label contents that can be used with user applications. Policy-agnostic user space tools will display this externalized version. @return 0 on success, return non-zero if an error occurs while externalizing the label data. */ typedef int mpo_vnode_label_externalize_t( struct label *label, char *element_name, struct sbuf *sb ); /** @brief Initialize vnode label @param label New label to initialize Initialize label storage for use with a newly instantiated vnode, or for temporary storage associated with the copying in or out of a vnode label. While it is necessary to allocate space for a kernel-resident vnode label, it is not yet necessary to link this vnode with persistent label storage facilities, such as extended attributes. Sleeping is permitted. */ typedef void mpo_vnode_label_init_t( struct label *label ); /** @brief Internalize a vnode label @param label Label to be internalized @param element_name Name of the label namespace for which the label should be internalized @param element_data Text data to be internalized Produce a vnode label from an external representation. An externalized label consists of a text representation of the label contents that can be used with user applications. Policy-agnostic user space tools will forward text version to the kernel for processing by individual policy modules. The policy's internalize entry points will be called only if the policy has registered interest in the label namespace. @return 0 on success, Otherwise, return non-zero if an error occurs while internalizing the label data. */ typedef int mpo_vnode_label_internalize_t( struct label *label, char *element_name, char *element_data ); /** @brief Clean up a vnode label @param label The label to be cleaned for re-use Clean up a vnode label. Darwin (Tiger, 8.x) allocates vnodes on demand, but typically never frees them. Before vnodes are placed back on free lists for re-use, policies can cleanup or overwrite any information present in the label. */ typedef void mpo_vnode_label_recycle_t( struct label *label ); /** @brief Write a label to a extended attribute @param cred Subject credential @param vp The vnode for which the label is being stored @param vlabel Label associated with vp @param intlabel The new label to store Store a new label in the extended attribute corresponding to the supplied vnode. The policy has already authorized the operation; this call must be implemented in order to perform the actual operation. @return In the event of an error, an appropriate value for errno should be returned, otherwise return 0 upon success. @warning XXX After examining the extended attribute implementation on Apple's future release, this entry point may be changed. */ typedef int mpo_vnode_label_store_t( kauth_cred_t cred, struct vnode *vp, struct label *vlabel, struct label *intlabel ); /** @brief Update vnode label from extended attributes @param mp File system mount point @param mntlabel Mount point label @param vp Vnode to label @param vlabel Label associated with vp @param name Name of the xattr @see mpo_vnode_check_setextattr_t When an extended attribute is updated via the Vendor attribute management functions, the MAC vnode label might also require an update. Policies should first determine if 'name' matches their xattr label name. If it does, the kernel is has either replaced or removed the named extended attribute that was previously associated with the vnode. Normally labels should only be modified via MAC Framework label management calls, but sometimes the user space components will directly modify extended attributes. For example, 'cp', 'tar', etc. manage extended attributes in userspace, not the kernel. This entry point is called after the label update has occurred, so it cannot return a failure. However, the operation is preceded by the mpo_vnode_check_setextattr() access control check. If the vnode label needs to be updated the policy should return a non-zero value. The vnode label will be marked for re-association by the framework. */ typedef int mpo_vnode_label_update_extattr_t( struct mount *mp, struct label *mntlabel, struct vnode *vp, struct label *vlabel, const char *name ); /** @brief Update a vnode label @param cred Subject credential @param vp The vnode to relabel @param vnodelabel Existing vnode label @param label New label to replace existing label @see mpo_vnode_check_label_update_t The subject identified by the credential has previously requested and was authorized to relabel the vnode; this entry point allows policies to perform the actual relabel operation. Policies should update vnodelabel using the label stored in the label parameter. */ typedef void mpo_vnode_label_update_t( kauth_cred_t cred, struct vnode *vp, struct label *vnodelabel, struct label *label ); /** @brief Find deatched signatures for a shared library @param p file trying to find the signature @param vp The vnode to relabel @param offset offset in the macho that the signature is requested for (for fat binaries) @param label Existing vnode label */ typedef int mpo_vnode_find_sigs_t( struct proc *p, struct vnode *vp, off_t offset, struct label *label ); /** @brief Create a new vnode, backed by extended attributes @param cred User credential for the creating process @param mp File system mount point @param mntlabel File system mount point label @param dvp Parent directory vnode @param dlabel Parent directory vnode label @param vp Newly created vnode @param vlabel Label to associate with the new vnode @param cnp Component name for vp Write out the label for the newly created vnode, most likely storing the results in a file system extended attribute. Most policies will derive the new vnode label using information from a combination of the subject (user) credential, the file system label, the parent directory label, and potentially the path name component. @return If the operation succeeds, store the new label in vlabel and return 0. Otherwise, return an appropriate errno value. */ typedef int mpo_vnode_notify_create_t( kauth_cred_t cred, struct mount *mp, struct label *mntlabel, struct vnode *dvp, struct label *dlabel, struct vnode *vp, struct label *vlabel, struct componentname *cnp ); /** @brief Inform MAC policies that a vnode has been opened @param cred User credential for the creating process @param vp vnode opened @param label Policy label for the vp @param acc_mode open(2) access mode used Inform Mac policies that a vnode have been successfully opened (passing all MAC polices and DAC). */ typedef void mpo_vnode_notify_open_t( kauth_cred_t cred, struct vnode *vp, struct label *label, int acc_mode ); /** @brief Inform MAC policies that a vnode has been renamed @param cred User credential for the renaming process @param vp Vnode that's being renamed @param label Policy label for vp @param dvp Parent directory for the destination @param dlabel Policy label for dvp @param cnp Component name for the destination Inform MAC policies that a vnode has been renamed. */ typedef void mpo_vnode_notify_rename_t( kauth_cred_t cred, struct vnode *vp, struct label *label, struct vnode *dvp, struct label *dlabel, struct componentname *cnp ); /** @brief Inform MAC policies that a vnode has been linked @param cred User credential for the renaming process @param dvp Parent directory for the destination @param dlabel Policy label for dvp @param vp Vnode that's being linked @param vlabel Policy label for vp @param cnp Component name for the destination Inform MAC policies that a vnode has been linked. */ typedef void mpo_vnode_notify_link_t( kauth_cred_t cred, struct vnode *dvp, struct label *dlabel, struct vnode *vp, struct label *vlabel, struct componentname *cnp ); /** @brief Inform MAC policies that an extended attribute has been removed from a vnode @param cred Subject credential @param vp Object node @param label Policy label for vp @param name Extended attribute name Inform MAC policies that an extended attribute has been removed from a vnode. */ typedef void mpo_vnode_notify_deleteextattr_t( kauth_cred_t cred, struct vnode *vp, struct label *label, const char *name ); /** @brief Inform MAC policies that an ACL has been set on a vnode @param cred Subject credential @param vp Object node @param label Policy label for vp @param acl ACL structure pointer Inform MAC policies that an ACL has been set on a vnode. */ typedef void mpo_vnode_notify_setacl_t( kauth_cred_t cred, struct vnode *vp, struct label *label, struct kauth_acl *acl ); /** @brief Inform MAC policies that an attributes have been set on a vnode @param cred Subject credential @param vp Object vnode @param label Policy label for vp @param alist List of attributes to set Inform MAC policies that an attributes have been set on a vnode. */ typedef void mpo_vnode_notify_setattrlist_t( kauth_cred_t cred, struct vnode *vp, struct label *label, struct attrlist *alist ); /** @brief Inform MAC policies that an extended attribute has been set on a vnode @param cred Subject credential @param vp Object vnode @param label Policy label for vp @param name Extended attribute name @param uio I/O structure pointer Inform MAC policies that an extended attribute has been set on a vnode. */ typedef void mpo_vnode_notify_setextattr_t( kauth_cred_t cred, struct vnode *vp, struct label *label, const char *name, struct uio *uio ); /** @brief Inform MAC policies that flags have been set on a vnode @param cred Subject credential @param vp Object vnode @param label Policy label for vp @param flags File flags; see chflags(2) Inform MAC policies that flags have been set on a vnode. */ typedef void mpo_vnode_notify_setflags_t( kauth_cred_t cred, struct vnode *vp, struct label *label, u_long flags ); /** @brief Inform MAC policies that a new mode has been set on a vnode @param cred Subject credential @param vp Object vnode @param label Policy label for vp @param mode File mode; see chmod(2) Inform MAC policies that a new mode has been set on a vnode. */ typedef void mpo_vnode_notify_setmode_t( kauth_cred_t cred, struct vnode *vp, struct label *label, mode_t mode ); /** @brief Inform MAC policies that new uid/gid have been set on a vnode @param cred Subject credential @param vp Object vnode @param label Policy label for vp @param uid User ID @param gid Group ID Inform MAC policies that new uid/gid have been set on a vnode. */ typedef void mpo_vnode_notify_setowner_t( kauth_cred_t cred, struct vnode *vp, struct label *label, uid_t uid, gid_t gid ); /** @brief Inform MAC policies that new timestamps have been set on a vnode @param cred Subject credential @param vp Object vnode @param label Policy label for vp @param atime Access time; see utimes(2) @param mtime Modification time; see utimes(2) Inform MAC policies that new timestamps have been set on a vnode. */ typedef void mpo_vnode_notify_setutimes_t( kauth_cred_t cred, struct vnode *vp, struct label *label, struct timespec atime, struct timespec mtime ); /** @brief Inform MAC policies that a vnode has been truncated @param cred Subject credential @param file_cred Credential associated with the struct fileproc @param vp Object vnode @param label Policy label for vp Inform MAC policies that a vnode has been truncated. */ typedef void mpo_vnode_notify_truncate_t( kauth_cred_t cred, kauth_cred_t file_cred, struct vnode *vp, struct label *label ); /** @brief Inform MAC policies that a pty slave has been granted @param p Responsible process @param tp tty data structure @param dev Major and minor numbers of device @param label Policy label for tp Inform MAC policies that a pty slave has been granted. */ typedef void mpo_pty_notify_grant_t( proc_t p, struct tty *tp, dev_t dev, struct label *label ); /** @brief Inform MAC policies that a pty master has been closed @param p Responsible process @param tp tty data structure @param dev Major and minor numbers of device @param label Policy label for tp Inform MAC policies that a pty master has been closed. */ typedef void mpo_pty_notify_close_t( proc_t p, struct tty *tp, dev_t dev, struct label *label ); /** @brief Access control check for kext loading @param cred Subject credential @param identifier Kext identifier Determine whether the subject identified by the credential can load the specified kext. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EPERM for lack of privilege. */ typedef int mpo_kext_check_load_t( kauth_cred_t cred, const char *identifier ); /** @brief Access control check for kext unloading @param cred Subject credential @param identifier Kext identifier Determine whether the subject identified by the credential can unload the specified kext. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EPERM for lack of privilege. */ typedef int mpo_kext_check_unload_t( kauth_cred_t cred, const char *identifier ); /** @brief Access control check for querying information about loaded kexts @param cred Subject credential Determine whether the subject identified by the credential can query information about loaded kexts. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EPERM for lack of privilege. */ typedef int mpo_kext_check_query_t( kauth_cred_t cred ); /** @brief Access control check for getting NVRAM variables. @param cred Subject credential @param name NVRAM variable to get Determine whether the subject identifier by the credential can get the value of the named NVRAM variable. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EPERM for lack of privilege. */ typedef int mpo_iokit_check_nvram_get_t( kauth_cred_t cred, const char *name ); /** @brief Access control check for setting NVRAM variables. @param cred Subject credential @param name NVRAM variable to set @param value The new value for the NVRAM variable Determine whether the subject identifier by the credential can set the value of the named NVRAM variable. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EPERM for lack of privilege. */ typedef int mpo_iokit_check_nvram_set_t( kauth_cred_t cred, const char *name, io_object_t value ); /** @brief Access control check for deleting NVRAM variables. @param cred Subject credential @param name NVRAM variable to delete Determine whether the subject identifier by the credential can delete the named NVRAM variable. @return Return 0 if access is granted, otherwise an appropriate value for errno should be returned. Suggested failure: EPERM for lack of privilege. */ typedef int mpo_iokit_check_nvram_delete_t( kauth_cred_t cred, const char *name ); /* * Placeholder for future events that may need mac hooks. */ typedef void mpo_reserved_hook_t(void); /* * Policy module operations. * * Please note that this should be kept in sync with the check assumptions * policy in bsd/kern/policy_check.c (policy_ops struct). */ #define MAC_POLICY_OPS_VERSION 53 /* inc when new reserved slots are taken */ struct mac_policy_ops { mpo_audit_check_postselect_t *mpo_audit_check_postselect; mpo_audit_check_preselect_t *mpo_audit_check_preselect; mpo_bpfdesc_label_associate_t *mpo_bpfdesc_label_associate; mpo_bpfdesc_label_destroy_t *mpo_bpfdesc_label_destroy; mpo_bpfdesc_label_init_t *mpo_bpfdesc_label_init; mpo_bpfdesc_check_receive_t *mpo_bpfdesc_check_receive; mpo_cred_check_label_update_execve_t *mpo_cred_check_label_update_execve; mpo_cred_check_label_update_t *mpo_cred_check_label_update; mpo_cred_check_visible_t *mpo_cred_check_visible; mpo_cred_label_associate_fork_t *mpo_cred_label_associate_fork; mpo_cred_label_associate_kernel_t *mpo_cred_label_associate_kernel; mpo_cred_label_associate_t *mpo_cred_label_associate; mpo_cred_label_associate_user_t *mpo_cred_label_associate_user; mpo_cred_label_destroy_t *mpo_cred_label_destroy; mpo_cred_label_externalize_audit_t *mpo_cred_label_externalize_audit; mpo_cred_label_externalize_t *mpo_cred_label_externalize; mpo_cred_label_init_t *mpo_cred_label_init; mpo_cred_label_internalize_t *mpo_cred_label_internalize; mpo_cred_label_update_execve_t *mpo_cred_label_update_execve; mpo_cred_label_update_t *mpo_cred_label_update; mpo_devfs_label_associate_device_t *mpo_devfs_label_associate_device; mpo_devfs_label_associate_directory_t *mpo_devfs_label_associate_directory; mpo_devfs_label_copy_t *mpo_devfs_label_copy; mpo_devfs_label_destroy_t *mpo_devfs_label_destroy; mpo_devfs_label_init_t *mpo_devfs_label_init; mpo_devfs_label_update_t *mpo_devfs_label_update; mpo_file_check_change_offset_t *mpo_file_check_change_offset; mpo_file_check_create_t *mpo_file_check_create; mpo_file_check_dup_t *mpo_file_check_dup; mpo_file_check_fcntl_t *mpo_file_check_fcntl; mpo_file_check_get_offset_t *mpo_file_check_get_offset; mpo_file_check_get_t *mpo_file_check_get; mpo_file_check_inherit_t *mpo_file_check_inherit; mpo_file_check_ioctl_t *mpo_file_check_ioctl; mpo_file_check_lock_t *mpo_file_check_lock; mpo_file_check_mmap_downgrade_t *mpo_file_check_mmap_downgrade; mpo_file_check_mmap_t *mpo_file_check_mmap; mpo_file_check_receive_t *mpo_file_check_receive; mpo_file_check_set_t *mpo_file_check_set; mpo_file_label_init_t *mpo_file_label_init; mpo_file_label_destroy_t *mpo_file_label_destroy; mpo_file_label_associate_t *mpo_file_label_associate; mpo_ifnet_check_label_update_t *mpo_ifnet_check_label_update; mpo_ifnet_check_transmit_t *mpo_ifnet_check_transmit; mpo_ifnet_label_associate_t *mpo_ifnet_label_associate; mpo_ifnet_label_copy_t *mpo_ifnet_label_copy; mpo_ifnet_label_destroy_t *mpo_ifnet_label_destroy; mpo_ifnet_label_externalize_t *mpo_ifnet_label_externalize; mpo_ifnet_label_init_t *mpo_ifnet_label_init; mpo_ifnet_label_internalize_t *mpo_ifnet_label_internalize; mpo_ifnet_label_update_t *mpo_ifnet_label_update; mpo_ifnet_label_recycle_t *mpo_ifnet_label_recycle; mpo_inpcb_check_deliver_t *mpo_inpcb_check_deliver; mpo_inpcb_label_associate_t *mpo_inpcb_label_associate; mpo_inpcb_label_destroy_t *mpo_inpcb_label_destroy; mpo_inpcb_label_init_t *mpo_inpcb_label_init; mpo_inpcb_label_recycle_t *mpo_inpcb_label_recycle; mpo_inpcb_label_update_t *mpo_inpcb_label_update; mpo_iokit_check_device_t *mpo_iokit_check_device; mpo_ipq_label_associate_t *mpo_ipq_label_associate; mpo_ipq_label_compare_t *mpo_ipq_label_compare; mpo_ipq_label_destroy_t *mpo_ipq_label_destroy; mpo_ipq_label_init_t *mpo_ipq_label_init; mpo_ipq_label_update_t *mpo_ipq_label_update; mpo_file_check_library_validation_t *mpo_file_check_library_validation; mpo_vnode_notify_setacl_t *mpo_vnode_notify_setacl; mpo_vnode_notify_setattrlist_t *mpo_vnode_notify_setattrlist; mpo_vnode_notify_setextattr_t *mpo_vnode_notify_setextattr; mpo_vnode_notify_setflags_t *mpo_vnode_notify_setflags; mpo_vnode_notify_setmode_t *mpo_vnode_notify_setmode; mpo_vnode_notify_setowner_t *mpo_vnode_notify_setowner; mpo_vnode_notify_setutimes_t *mpo_vnode_notify_setutimes; mpo_vnode_notify_truncate_t *mpo_vnode_notify_truncate; mpo_mbuf_label_associate_bpfdesc_t *mpo_mbuf_label_associate_bpfdesc; mpo_mbuf_label_associate_ifnet_t *mpo_mbuf_label_associate_ifnet; mpo_mbuf_label_associate_inpcb_t *mpo_mbuf_label_associate_inpcb; mpo_mbuf_label_associate_ipq_t *mpo_mbuf_label_associate_ipq; mpo_mbuf_label_associate_linklayer_t *mpo_mbuf_label_associate_linklayer; mpo_mbuf_label_associate_multicast_encap_t *mpo_mbuf_label_associate_multicast_encap; mpo_mbuf_label_associate_netlayer_t *mpo_mbuf_label_associate_netlayer; mpo_mbuf_label_associate_socket_t *mpo_mbuf_label_associate_socket; mpo_mbuf_label_copy_t *mpo_mbuf_label_copy; mpo_mbuf_label_destroy_t *mpo_mbuf_label_destroy; mpo_mbuf_label_init_t *mpo_mbuf_label_init; mpo_mount_check_fsctl_t *mpo_mount_check_fsctl; mpo_mount_check_getattr_t *mpo_mount_check_getattr; mpo_mount_check_label_update_t *mpo_mount_check_label_update; mpo_mount_check_mount_t *mpo_mount_check_mount; mpo_mount_check_remount_t *mpo_mount_check_remount; mpo_mount_check_setattr_t *mpo_mount_check_setattr; mpo_mount_check_stat_t *mpo_mount_check_stat; mpo_mount_check_umount_t *mpo_mount_check_umount; mpo_mount_label_associate_t *mpo_mount_label_associate; mpo_mount_label_destroy_t *mpo_mount_label_destroy; mpo_mount_label_externalize_t *mpo_mount_label_externalize; mpo_mount_label_init_t *mpo_mount_label_init; mpo_mount_label_internalize_t *mpo_mount_label_internalize; mpo_netinet_fragment_t *mpo_netinet_fragment; mpo_netinet_icmp_reply_t *mpo_netinet_icmp_reply; mpo_netinet_tcp_reply_t *mpo_netinet_tcp_reply; mpo_pipe_check_ioctl_t *mpo_pipe_check_ioctl; mpo_pipe_check_kqfilter_t *mpo_pipe_check_kqfilter; mpo_pipe_check_label_update_t *mpo_pipe_check_label_update; mpo_pipe_check_read_t *mpo_pipe_check_read; mpo_pipe_check_select_t *mpo_pipe_check_select; mpo_pipe_check_stat_t *mpo_pipe_check_stat; mpo_pipe_check_write_t *mpo_pipe_check_write; mpo_pipe_label_associate_t *mpo_pipe_label_associate; mpo_pipe_label_copy_t *mpo_pipe_label_copy; mpo_pipe_label_destroy_t *mpo_pipe_label_destroy; mpo_pipe_label_externalize_t *mpo_pipe_label_externalize; mpo_pipe_label_init_t *mpo_pipe_label_init; mpo_pipe_label_internalize_t *mpo_pipe_label_internalize; mpo_pipe_label_update_t *mpo_pipe_label_update; mpo_policy_destroy_t *mpo_policy_destroy; mpo_policy_init_t *mpo_policy_init; mpo_policy_initbsd_t *mpo_policy_initbsd; mpo_policy_syscall_t *mpo_policy_syscall; mpo_system_check_sysctlbyname_t *mpo_system_check_sysctlbyname; mpo_proc_check_inherit_ipc_ports_t *mpo_proc_check_inherit_ipc_ports; mpo_vnode_check_rename_t *mpo_vnode_check_rename; mpo_kext_check_query_t *mpo_kext_check_query; mpo_iokit_check_nvram_get_t *mpo_iokit_check_nvram_get; mpo_iokit_check_nvram_set_t *mpo_iokit_check_nvram_set; mpo_iokit_check_nvram_delete_t *mpo_iokit_check_nvram_delete; mpo_proc_check_expose_task_t *mpo_proc_check_expose_task; mpo_proc_check_set_host_special_port_t *mpo_proc_check_set_host_special_port; mpo_proc_check_set_host_exception_port_t *mpo_proc_check_set_host_exception_port; mpo_exc_action_check_exception_send_t *mpo_exc_action_check_exception_send; mpo_exc_action_label_associate_t *mpo_exc_action_label_associate; mpo_exc_action_label_populate_t *mpo_exc_action_label_populate; mpo_exc_action_label_destroy_t *mpo_exc_action_label_destroy; mpo_exc_action_label_init_t *mpo_exc_action_label_init; mpo_exc_action_label_update_t *mpo_exc_action_label_update; mpo_vnode_check_trigger_resolve_t *mpo_vnode_check_trigger_resolve; mpo_reserved_hook_t *mpo_reserved1; mpo_reserved_hook_t *mpo_reserved2; mpo_reserved_hook_t *mpo_reserved3; mpo_skywalk_flow_check_connect_t *mpo_skywalk_flow_check_connect; mpo_skywalk_flow_check_listen_t *mpo_skywalk_flow_check_listen; mpo_posixsem_check_create_t *mpo_posixsem_check_create; mpo_posixsem_check_open_t *mpo_posixsem_check_open; mpo_posixsem_check_post_t *mpo_posixsem_check_post; mpo_posixsem_check_unlink_t *mpo_posixsem_check_unlink; mpo_posixsem_check_wait_t *mpo_posixsem_check_wait; mpo_posixsem_label_associate_t *mpo_posixsem_label_associate; mpo_posixsem_label_destroy_t *mpo_posixsem_label_destroy; mpo_posixsem_label_init_t *mpo_posixsem_label_init; mpo_posixshm_check_create_t *mpo_posixshm_check_create; mpo_posixshm_check_mmap_t *mpo_posixshm_check_mmap; mpo_posixshm_check_open_t *mpo_posixshm_check_open; mpo_posixshm_check_stat_t *mpo_posixshm_check_stat; mpo_posixshm_check_truncate_t *mpo_posixshm_check_truncate; mpo_posixshm_check_unlink_t *mpo_posixshm_check_unlink; mpo_posixshm_label_associate_t *mpo_posixshm_label_associate; mpo_posixshm_label_destroy_t *mpo_posixshm_label_destroy; mpo_posixshm_label_init_t *mpo_posixshm_label_init; mpo_proc_check_debug_t *mpo_proc_check_debug; mpo_proc_check_fork_t *mpo_proc_check_fork; mpo_proc_check_get_task_name_t *mpo_proc_check_get_task_name; mpo_proc_check_get_task_t *mpo_proc_check_get_task; mpo_proc_check_getaudit_t *mpo_proc_check_getaudit; mpo_proc_check_getauid_t *mpo_proc_check_getauid; mpo_proc_check_getlcid_t *mpo_proc_check_getlcid; mpo_proc_check_mprotect_t *mpo_proc_check_mprotect; mpo_proc_check_sched_t *mpo_proc_check_sched; mpo_proc_check_setaudit_t *mpo_proc_check_setaudit; mpo_proc_check_setauid_t *mpo_proc_check_setauid; mpo_proc_check_setlcid_t *mpo_proc_check_setlcid; mpo_proc_check_signal_t *mpo_proc_check_signal; mpo_proc_check_wait_t *mpo_proc_check_wait; mpo_proc_label_destroy_t *mpo_proc_label_destroy; mpo_proc_label_init_t *mpo_proc_label_init; mpo_socket_check_accept_t *mpo_socket_check_accept; mpo_socket_check_accepted_t *mpo_socket_check_accepted; mpo_socket_check_bind_t *mpo_socket_check_bind; mpo_socket_check_connect_t *mpo_socket_check_connect; mpo_socket_check_create_t *mpo_socket_check_create; mpo_socket_check_deliver_t *mpo_socket_check_deliver; mpo_socket_check_kqfilter_t *mpo_socket_check_kqfilter; mpo_socket_check_label_update_t *mpo_socket_check_label_update; mpo_socket_check_listen_t *mpo_socket_check_listen; mpo_socket_check_receive_t *mpo_socket_check_receive; mpo_socket_check_received_t *mpo_socket_check_received; mpo_socket_check_select_t *mpo_socket_check_select; mpo_socket_check_send_t *mpo_socket_check_send; mpo_socket_check_stat_t *mpo_socket_check_stat; mpo_socket_check_setsockopt_t *mpo_socket_check_setsockopt; mpo_socket_check_getsockopt_t *mpo_socket_check_getsockopt; mpo_socket_label_associate_accept_t *mpo_socket_label_associate_accept; mpo_socket_label_associate_t *mpo_socket_label_associate; mpo_socket_label_copy_t *mpo_socket_label_copy; mpo_socket_label_destroy_t *mpo_socket_label_destroy; mpo_socket_label_externalize_t *mpo_socket_label_externalize; mpo_socket_label_init_t *mpo_socket_label_init; mpo_socket_label_internalize_t *mpo_socket_label_internalize; mpo_socket_label_update_t *mpo_socket_label_update; mpo_socketpeer_label_associate_mbuf_t *mpo_socketpeer_label_associate_mbuf; mpo_socketpeer_label_associate_socket_t *mpo_socketpeer_label_associate_socket; mpo_socketpeer_label_destroy_t *mpo_socketpeer_label_destroy; mpo_socketpeer_label_externalize_t *mpo_socketpeer_label_externalize; mpo_socketpeer_label_init_t *mpo_socketpeer_label_init; mpo_system_check_acct_t *mpo_system_check_acct; mpo_system_check_audit_t *mpo_system_check_audit; mpo_system_check_auditctl_t *mpo_system_check_auditctl; mpo_system_check_auditon_t *mpo_system_check_auditon; mpo_system_check_host_priv_t *mpo_system_check_host_priv; mpo_system_check_nfsd_t *mpo_system_check_nfsd; mpo_system_check_reboot_t *mpo_system_check_reboot; mpo_system_check_settime_t *mpo_system_check_settime; mpo_system_check_swapoff_t *mpo_system_check_swapoff; mpo_system_check_swapon_t *mpo_system_check_swapon; mpo_socket_check_ioctl_t *mpo_socket_check_ioctl; mpo_sysvmsg_label_associate_t *mpo_sysvmsg_label_associate; mpo_sysvmsg_label_destroy_t *mpo_sysvmsg_label_destroy; mpo_sysvmsg_label_init_t *mpo_sysvmsg_label_init; mpo_sysvmsg_label_recycle_t *mpo_sysvmsg_label_recycle; mpo_sysvmsq_check_enqueue_t *mpo_sysvmsq_check_enqueue; mpo_sysvmsq_check_msgrcv_t *mpo_sysvmsq_check_msgrcv; mpo_sysvmsq_check_msgrmid_t *mpo_sysvmsq_check_msgrmid; mpo_sysvmsq_check_msqctl_t *mpo_sysvmsq_check_msqctl; mpo_sysvmsq_check_msqget_t *mpo_sysvmsq_check_msqget; mpo_sysvmsq_check_msqrcv_t *mpo_sysvmsq_check_msqrcv; mpo_sysvmsq_check_msqsnd_t *mpo_sysvmsq_check_msqsnd; mpo_sysvmsq_label_associate_t *mpo_sysvmsq_label_associate; mpo_sysvmsq_label_destroy_t *mpo_sysvmsq_label_destroy; mpo_sysvmsq_label_init_t *mpo_sysvmsq_label_init; mpo_sysvmsq_label_recycle_t *mpo_sysvmsq_label_recycle; mpo_sysvsem_check_semctl_t *mpo_sysvsem_check_semctl; mpo_sysvsem_check_semget_t *mpo_sysvsem_check_semget; mpo_sysvsem_check_semop_t *mpo_sysvsem_check_semop; mpo_sysvsem_label_associate_t *mpo_sysvsem_label_associate; mpo_sysvsem_label_destroy_t *mpo_sysvsem_label_destroy; mpo_sysvsem_label_init_t *mpo_sysvsem_label_init; mpo_sysvsem_label_recycle_t *mpo_sysvsem_label_recycle; mpo_sysvshm_check_shmat_t *mpo_sysvshm_check_shmat; mpo_sysvshm_check_shmctl_t *mpo_sysvshm_check_shmctl; mpo_sysvshm_check_shmdt_t *mpo_sysvshm_check_shmdt; mpo_sysvshm_check_shmget_t *mpo_sysvshm_check_shmget; mpo_sysvshm_label_associate_t *mpo_sysvshm_label_associate; mpo_sysvshm_label_destroy_t *mpo_sysvshm_label_destroy; mpo_sysvshm_label_init_t *mpo_sysvshm_label_init; mpo_sysvshm_label_recycle_t *mpo_sysvshm_label_recycle; mpo_proc_notify_exit_t *mpo_proc_notify_exit; mpo_mount_check_snapshot_revert_t *mpo_mount_check_snapshot_revert; mpo_vnode_check_getattr_t *mpo_vnode_check_getattr; mpo_mount_check_snapshot_create_t *mpo_mount_check_snapshot_create; mpo_mount_check_snapshot_delete_t *mpo_mount_check_snapshot_delete; mpo_vnode_check_clone_t *mpo_vnode_check_clone; mpo_proc_check_get_cs_info_t *mpo_proc_check_get_cs_info; mpo_proc_check_set_cs_info_t *mpo_proc_check_set_cs_info; mpo_iokit_check_hid_control_t *mpo_iokit_check_hid_control; mpo_vnode_check_access_t *mpo_vnode_check_access; mpo_vnode_check_chdir_t *mpo_vnode_check_chdir; mpo_vnode_check_chroot_t *mpo_vnode_check_chroot; mpo_vnode_check_create_t *mpo_vnode_check_create; mpo_vnode_check_deleteextattr_t *mpo_vnode_check_deleteextattr; mpo_vnode_check_exchangedata_t *mpo_vnode_check_exchangedata; mpo_vnode_check_exec_t *mpo_vnode_check_exec; mpo_vnode_check_getattrlist_t *mpo_vnode_check_getattrlist; mpo_vnode_check_getextattr_t *mpo_vnode_check_getextattr; mpo_vnode_check_ioctl_t *mpo_vnode_check_ioctl; mpo_vnode_check_kqfilter_t *mpo_vnode_check_kqfilter; mpo_vnode_check_label_update_t *mpo_vnode_check_label_update; mpo_vnode_check_link_t *mpo_vnode_check_link; mpo_vnode_check_listextattr_t *mpo_vnode_check_listextattr; mpo_vnode_check_lookup_t *mpo_vnode_check_lookup; mpo_vnode_check_open_t *mpo_vnode_check_open; mpo_vnode_check_read_t *mpo_vnode_check_read; mpo_vnode_check_readdir_t *mpo_vnode_check_readdir; mpo_vnode_check_readlink_t *mpo_vnode_check_readlink; mpo_vnode_check_rename_from_t *mpo_vnode_check_rename_from; mpo_vnode_check_rename_to_t *mpo_vnode_check_rename_to; mpo_vnode_check_revoke_t *mpo_vnode_check_revoke; mpo_vnode_check_select_t *mpo_vnode_check_select; mpo_vnode_check_setattrlist_t *mpo_vnode_check_setattrlist; mpo_vnode_check_setextattr_t *mpo_vnode_check_setextattr; mpo_vnode_check_setflags_t *mpo_vnode_check_setflags; mpo_vnode_check_setmode_t *mpo_vnode_check_setmode; mpo_vnode_check_setowner_t *mpo_vnode_check_setowner; mpo_vnode_check_setutimes_t *mpo_vnode_check_setutimes; mpo_vnode_check_stat_t *mpo_vnode_check_stat; mpo_vnode_check_truncate_t *mpo_vnode_check_truncate; mpo_vnode_check_unlink_t *mpo_vnode_check_unlink; mpo_vnode_check_write_t *mpo_vnode_check_write; mpo_vnode_label_associate_devfs_t *mpo_vnode_label_associate_devfs; mpo_vnode_label_associate_extattr_t *mpo_vnode_label_associate_extattr; mpo_vnode_label_associate_file_t *mpo_vnode_label_associate_file; mpo_vnode_label_associate_pipe_t *mpo_vnode_label_associate_pipe; mpo_vnode_label_associate_posixsem_t *mpo_vnode_label_associate_posixsem; mpo_vnode_label_associate_posixshm_t *mpo_vnode_label_associate_posixshm; mpo_vnode_label_associate_singlelabel_t *mpo_vnode_label_associate_singlelabel; mpo_vnode_label_associate_socket_t *mpo_vnode_label_associate_socket; mpo_vnode_label_copy_t *mpo_vnode_label_copy; mpo_vnode_label_destroy_t *mpo_vnode_label_destroy; mpo_vnode_label_externalize_audit_t *mpo_vnode_label_externalize_audit; mpo_vnode_label_externalize_t *mpo_vnode_label_externalize; mpo_vnode_label_init_t *mpo_vnode_label_init; mpo_vnode_label_internalize_t *mpo_vnode_label_internalize; mpo_vnode_label_recycle_t *mpo_vnode_label_recycle; mpo_vnode_label_store_t *mpo_vnode_label_store; mpo_vnode_label_update_extattr_t *mpo_vnode_label_update_extattr; mpo_vnode_label_update_t *mpo_vnode_label_update; mpo_vnode_notify_create_t *mpo_vnode_notify_create; mpo_vnode_check_signature_t *mpo_vnode_check_signature; mpo_vnode_check_uipc_bind_t *mpo_vnode_check_uipc_bind; mpo_vnode_check_uipc_connect_t *mpo_vnode_check_uipc_connect; mpo_proc_check_run_cs_invalid_t *mpo_proc_check_run_cs_invalid; mpo_proc_check_suspend_resume_t *mpo_proc_check_suspend_resume; mpo_thread_userret_t *mpo_thread_userret; mpo_iokit_check_set_properties_t *mpo_iokit_check_set_properties; mpo_system_check_chud_t *mpo_system_check_chud; mpo_vnode_check_searchfs_t *mpo_vnode_check_searchfs; mpo_priv_check_t *mpo_priv_check; mpo_priv_grant_t *mpo_priv_grant; mpo_proc_check_map_anon_t *mpo_proc_check_map_anon; mpo_vnode_check_fsgetpath_t *mpo_vnode_check_fsgetpath; mpo_iokit_check_open_t *mpo_iokit_check_open; mpo_proc_check_ledger_t *mpo_proc_check_ledger; mpo_vnode_notify_rename_t *mpo_vnode_notify_rename; mpo_vnode_check_setacl_t *mpo_vnode_check_setacl; mpo_vnode_notify_deleteextattr_t *mpo_vnode_notify_deleteextattr; mpo_system_check_kas_info_t *mpo_system_check_kas_info; mpo_vnode_check_lookup_preflight_t *mpo_vnode_check_lookup_preflight; mpo_vnode_notify_open_t *mpo_vnode_notify_open; mpo_system_check_info_t *mpo_system_check_info; mpo_pty_notify_grant_t *mpo_pty_notify_grant; mpo_pty_notify_close_t *mpo_pty_notify_close; mpo_vnode_find_sigs_t *mpo_vnode_find_sigs; mpo_kext_check_load_t *mpo_kext_check_load; mpo_kext_check_unload_t *mpo_kext_check_unload; mpo_proc_check_proc_info_t *mpo_proc_check_proc_info; mpo_vnode_notify_link_t *mpo_vnode_notify_link; mpo_iokit_check_filter_properties_t *mpo_iokit_check_filter_properties; mpo_iokit_check_get_property_t *mpo_iokit_check_get_property; }; /** @brief MAC policy handle type The MAC handle is used to uniquely identify a loaded policy within the MAC Framework. A variable of this type is set by mac_policy_register(). */ typedef unsigned int mac_policy_handle_t; #define mpc_t struct mac_policy_conf * /** @brief Mac policy configuration This structure specifies the configuration information for a MAC policy module. A policy module developer must supply a short unique policy name, a more descriptive full name, a list of label namespaces and count, a pointer to the registered enty point operations, any load time flags, and optionally, a pointer to a label slot identifier. The Framework will update the runtime flags (mpc_runtime_flags) to indicate that the module has been registered. If the label slot identifier (mpc_field_off) is NULL, the Framework will not provide label storage for the policy. Otherwise, the Framework will store the label location (slot) in this field. The mpc_list field is used by the Framework and should not be modified by policies. */ /* XXX - reorder these for better aligment on 64bit platforms */ struct mac_policy_conf { const char *mpc_name; /** policy name */ const char *mpc_fullname; /** full name */ char const * const *mpc_labelnames; /** managed label namespaces */ unsigned int mpc_labelname_count; /** number of managed label namespaces */ const struct mac_policy_ops *mpc_ops; /** operation vector */ int mpc_loadtime_flags; /** load time flags */ int *mpc_field_off; /** label slot */ int mpc_runtime_flags; /** run time flags */ mpc_t mpc_list; /** List reference */ void *mpc_data; /** module data */ }; /** @brief MAC policy module registration routine This function is called to register a policy with the MAC framework. A policy module will typically call this from the Darwin KEXT registration routine. */ int mac_policy_register(struct mac_policy_conf *mpc, mac_policy_handle_t *handlep, void *xd); /** @brief MAC policy module de-registration routine This function is called to de-register a policy with theD MAC framework. A policy module will typically call this from the Darwin KEXT de-registration routine. */ int mac_policy_unregister(mac_policy_handle_t handle); /* * Framework entry points for the policies to add audit data. */ int mac_audit_text(char *text, mac_policy_handle_t handle); /* * Calls to assist with use of Apple XATTRs within policy modules. */ int mac_vnop_setxattr(struct vnode *, const char *, char *, size_t); int mac_vnop_getxattr(struct vnode *, const char *, char *, size_t, size_t *); int mac_vnop_removexattr(struct vnode *, const char *); /** @brief Set an extended attribute on a vnode-based fileglob. @param fg fileglob representing file to attach the extended attribute @param name extended attribute name @param buf buffer of data to use as the extended attribute value @param len size of buffer Sets the value of an extended attribute on a file. Caller must hold an iocount on the vnode represented by the fileglob. */ int mac_file_setxattr(struct fileglob *fg, const char *name, char *buf, size_t len); /** @brief Get an extended attribute from a vnode-based fileglob. @param fg fileglob representing file to read the extended attribute @param name extended attribute name @param buf buffer of data to hold the extended attribute value @param len size of buffer @param attrlen size of full extended attribute value Gets the value of an extended attribute on a file. Caller must hold an iocount on the vnode represented by the fileglob. */ int mac_file_getxattr(struct fileglob *fg, const char *name, char *buf, size_t len, size_t *attrlen); /** @brief Remove an extended attribute from a vnode-based fileglob. @param fg fileglob representing file to remove the extended attribute @param name extended attribute name Removes the named extended attribute from the file. Caller must hold an iocount on the vnode represented by the fileglob. */ int mac_file_removexattr(struct fileglob *fg, const char *name); /* * Arbitrary limit on how much data will be logged by the audit * entry points above. */ #define MAC_AUDIT_DATA_LIMIT 1024 /* * Values returned by mac_audit_{pre,post}select. To combine the responses * of the security policies into a single decision, * mac_audit_{pre,post}select() choose the greatest value returned. */ #define MAC_AUDIT_DEFAULT 0 /* use system behavior */ #define MAC_AUDIT_NO 1 /* force not auditing this event */ #define MAC_AUDIT_YES 2 /* force auditing this event */ // \defgroup mpc_loadtime_flags Flags for the mpc_loadtime_flags field /** @name Flags for the mpc_loadtime_flags field @see mac_policy_conf This is the complete list of flags that are supported by the mpc_loadtime_flags field of the mac_policy_conf structure. These flags specify the load time behavior of MAC Framework policy modules. */ /*@{*/ /** @brief Flag to indicate registration preference This flag indicates that the policy module must be loaded and initialized early in the boot process. If the flag is specified, attempts to register the module following boot will be rejected. The flag may be used by policies that require pervasive labeling of all system objects, and cannot handle objects that have not been properly initialized by the policy. */ #define MPC_LOADTIME_FLAG_NOTLATE 0x00000001 /** @brief Flag to indicate unload preference This flag indicates that the policy module may be unloaded. If this flag is not set, then the policy framework will reject requests to unload the module. This flag might be used by modules that allocate label state and are unable to free that state at runtime, or for modules that simply do not want to permit unload operations. */ #define MPC_LOADTIME_FLAG_UNLOADOK 0x00000002 /** @brief Unsupported XXX This flag is not yet supported. */ #define MPC_LOADTIME_FLAG_LABELMBUFS 0x00000004 /** @brief Flag to indicate a base policy This flag indicates that the policy module is a base policy. Only one module can declare itself as base, otherwise the boot process will be halted. */ #define MPC_LOADTIME_BASE_POLICY 0x00000008 /*@}*/ /** @brief Policy registration flag @see mac_policy_conf This flag indicates that the policy module has been successfully registered with the TrustedBSD MAC Framework. The Framework will set this flag in the mpc_runtime_flags field of the policy's mac_policy_conf structure after registering the policy. */ #define MPC_RUNTIME_FLAG_REGISTERED 0x00000001 /* * Depends on POLICY_VER */ #ifndef POLICY_VER #define POLICY_VER 1.0 #endif #define MAC_POLICY_SET(handle, mpops, mpname, mpfullname, lnames, lcount, slot, lflags, rflags) \ static struct mac_policy_conf mpname##_mac_policy_conf = { \ .mpc_name = #mpname, \ .mpc_fullname = mpfullname, \ .mpc_labelnames = lnames, \ .mpc_labelname_count = lcount, \ .mpc_ops = mpops, \ .mpc_loadtime_flags = lflags, \ .mpc_field_off = slot, \ .mpc_runtime_flags = rflags \ }; \ \ static kern_return_t \ kmod_start(kmod_info_t *ki, void *xd) \ { \ return mac_policy_register(&mpname##_mac_policy_conf, \ &handle, xd); \ } \ \ static kern_return_t \ kmod_stop(kmod_info_t *ki, void *xd) \ { \ return mac_policy_unregister(handle); \ } \ \ extern kern_return_t _start(kmod_info_t *ki, void *data); \ extern kern_return_t _stop(kmod_info_t *ki, void *data); \ \ KMOD_EXPLICIT_DECL(security.mpname, POLICY_VER, _start, _stop) \ kmod_start_func_t *_realmain = kmod_start; \ kmod_stop_func_t *_antimain = kmod_stop; \ int _kext_apple_cc = __APPLE_CC__ #define LABEL_TO_SLOT(l, s) (l)->l_perpolicy[s] /* * Policy interface to map a struct label pointer to per-policy data. * Typically, policies wrap this in their own accessor macro that casts an * intptr_t to a policy-specific data type. */ intptr_t mac_label_get(struct label *l, int slot); void mac_label_set(struct label *l, int slot, intptr_t v); #define mac_get_mpc(h) (mac_policy_list.entries[h].mpc) /** @name Flags for MAC allocator interfaces These flags are passed to the Darwin kernel allocator routines to indicate whether the allocation is permitted to block or not. Caution should be taken; some operations are not permitted to sleep, and some types of locks cannot be held when sleeping. */ /*@{*/ /** @brief Allocation operations may block If memory is not immediately available, the allocation routine will block (typically sleeping) until memory is available. @warning Inappropriate use of this flag may cause kernel panics. */ #define MAC_WAITOK 0 /** @brief Allocation operations may not block Rather than blocking, the allocator may return an error if memory is not immediately available. This type of allocation will not sleep, preserving locking semantics. */ #define MAC_NOWAIT 1 /*@}*/ #endif /* !_SECURITY_MAC_POLICY_H_ */ |