| 2847 | } |
| 2848 | |
| 2849 | static int |
| 2850 | mls_vnode_check_relabel(struct ucred *cred, struct vnode *vp, |
| 2851 | struct label *vplabel, struct label *newlabel) |
| 2852 | { |
| 2853 | struct mac_mls *old, *new, *subj; |
| 2854 | int error; |
| 2855 | |
| 2856 | old = SLOT(vplabel); |
| 2857 | new = SLOT(newlabel); |
| 2858 | subj = SLOT(cred->cr_label); |
| 2859 | |
| 2860 | /* |
| 2861 | * If there is an MLS label update for the vnode, it must be a |
| 2862 | * effective label. |
| 2863 | */ |
| 2864 | error = mls_atmostflags(new, MAC_MLS_FLAG_EFFECTIVE); |
| 2865 | if (error) |
| 2866 | return (error); |
| 2867 | |
| 2868 | /* |
| 2869 | * To perform a relabel of the vnode (MLS label or not), MLS must |
| 2870 | * authorize the relabel. |
| 2871 | */ |
| 2872 | if (!mls_effective_in_range(old, subj)) |
| 2873 | return (EPERM); |
| 2874 | |
| 2875 | /* |
| 2876 | * If the MLS label is to be changed, authorize as appropriate. |
| 2877 | */ |
| 2878 | if (new->mm_flags & MAC_MLS_FLAG_EFFECTIVE) { |
| 2879 | /* |
| 2880 | * To change the MLS label on a vnode, the new vnode label |
| 2881 | * must be in the subject range. |
| 2882 | */ |
| 2883 | if (!mls_effective_in_range(new, subj)) |
| 2884 | return (EPERM); |
| 2885 | |
| 2886 | /* |
| 2887 | * To change the MLS label on the vnode to be EQUAL, the |
| 2888 | * subject must have appropriate privilege. |
| 2889 | */ |
| 2890 | if (mls_contains_equal(new)) { |
| 2891 | error = mls_subject_privileged(subj); |
| 2892 | if (error) |
| 2893 | return (error); |
| 2894 | } |
| 2895 | } |
| 2896 | |
| 2897 | return (0); |
| 2898 | } |
| 2899 | |
| 2900 | static int |
| 2901 | mls_vnode_check_rename_from(struct ucred *cred, struct vnode *dvp, |
nothing calls this directly
no test coverage detected