| 1856 | } |
| 1857 | |
| 1858 | static int |
| 1859 | mls_socket_check_relabel(struct ucred *cred, struct socket *so, |
| 1860 | struct label *solabel, struct label *newlabel) |
| 1861 | { |
| 1862 | struct mac_mls *subj, *obj, *new; |
| 1863 | int error; |
| 1864 | |
| 1865 | SOCK_LOCK_ASSERT(so); |
| 1866 | |
| 1867 | new = SLOT(newlabel); |
| 1868 | subj = SLOT(cred->cr_label); |
| 1869 | obj = SLOT(solabel); |
| 1870 | |
| 1871 | /* |
| 1872 | * If there is an MLS label update for the socket, it may be an |
| 1873 | * update of effective. |
| 1874 | */ |
| 1875 | error = mls_atmostflags(new, MAC_MLS_FLAG_EFFECTIVE); |
| 1876 | if (error) |
| 1877 | return (error); |
| 1878 | |
| 1879 | /* |
| 1880 | * To relabel a socket, the old socket effective must be in the |
| 1881 | * subject range. |
| 1882 | */ |
| 1883 | if (!mls_effective_in_range(obj, subj)) |
| 1884 | return (EPERM); |
| 1885 | |
| 1886 | /* |
| 1887 | * If the MLS label is to be changed, authorize as appropriate. |
| 1888 | */ |
| 1889 | if (new->mm_flags & MAC_MLS_FLAG_EFFECTIVE) { |
| 1890 | /* |
| 1891 | * To relabel a socket, the new socket effective must be in |
| 1892 | * the subject range. |
| 1893 | */ |
| 1894 | if (!mls_effective_in_range(new, subj)) |
| 1895 | return (EPERM); |
| 1896 | |
| 1897 | /* |
| 1898 | * To change the MLS label on the socket to contain EQUAL, |
| 1899 | * the subject must have appropriate privilege. |
| 1900 | */ |
| 1901 | if (mls_contains_equal(new)) { |
| 1902 | error = mls_subject_privileged(subj); |
| 1903 | if (error) |
| 1904 | return (error); |
| 1905 | } |
| 1906 | } |
| 1907 | |
| 1908 | return (0); |
| 1909 | } |
| 1910 | |
| 1911 | static int |
| 1912 | mls_socket_check_visible(struct ucred *cred, struct socket *so, |
nothing calls this directly
no test coverage detected