MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mls_vnode_check_relabel

Function mls_vnode_check_relabel

freebsd/security/mac_mls/mac_mls.c:2849–2898  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2847}
2848
2849static int
2850mls_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
2900static int
2901mls_vnode_check_rename_from(struct ucred *cred, struct vnode *dvp,

Callers

nothing calls this directly

Calls 4

mls_atmostflagsFunction · 0.85
mls_effective_in_rangeFunction · 0.85
mls_contains_equalFunction · 0.85
mls_subject_privilegedFunction · 0.85

Tested by

no test coverage detected