| 1932 | } |
| 1933 | |
| 1934 | static int |
| 1935 | lomac_socket_check_relabel(struct ucred *cred, struct socket *so, |
| 1936 | struct label *solabel, struct label *newlabel) |
| 1937 | { |
| 1938 | struct mac_lomac *subj, *obj, *new; |
| 1939 | int error; |
| 1940 | |
| 1941 | SOCK_LOCK_ASSERT(so); |
| 1942 | |
| 1943 | new = SLOT(newlabel); |
| 1944 | subj = SLOT(cred->cr_label); |
| 1945 | obj = SLOT(solabel); |
| 1946 | |
| 1947 | /* |
| 1948 | * If there is a LOMAC label update for the socket, it may be an |
| 1949 | * update of single. |
| 1950 | */ |
| 1951 | error = lomac_atmostflags(new, MAC_LOMAC_FLAG_SINGLE); |
| 1952 | if (error) |
| 1953 | return (error); |
| 1954 | |
| 1955 | /* |
| 1956 | * To relabel a socket, the old socket single must be in the subject |
| 1957 | * range. |
| 1958 | */ |
| 1959 | if (!lomac_single_in_range(obj, subj)) |
| 1960 | return (EPERM); |
| 1961 | |
| 1962 | /* |
| 1963 | * If the LOMAC label is to be changed, authorize as appropriate. |
| 1964 | */ |
| 1965 | if (new->ml_flags & MAC_LOMAC_FLAG_SINGLE) { |
| 1966 | /* |
| 1967 | * To relabel a socket, the new socket single must be in the |
| 1968 | * subject range. |
| 1969 | */ |
| 1970 | if (!lomac_single_in_range(new, subj)) |
| 1971 | return (EPERM); |
| 1972 | |
| 1973 | /* |
| 1974 | * To change the LOMAC label on the socket to contain EQUAL, |
| 1975 | * the subject must have appropriate privilege. |
| 1976 | */ |
| 1977 | if (lomac_contains_equal(new)) { |
| 1978 | error = lomac_subject_privileged(subj); |
| 1979 | if (error) |
| 1980 | return (error); |
| 1981 | } |
| 1982 | } |
| 1983 | |
| 1984 | return (0); |
| 1985 | } |
| 1986 | |
| 1987 | static int |
| 1988 | lomac_socket_check_visible(struct ucred *cred, struct socket *so, |
nothing calls this directly
no test coverage detected