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

Function vn_setlabel

freebsd/security/mac/mac_vfs.c:1029–1072  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1027}
1028
1029int
1030vn_setlabel(struct vnode *vp, struct label *intlabel, struct ucred *cred)
1031{
1032 int error;
1033
1034 if (vp->v_mount == NULL) {
1035 /* printf("vn_setlabel: null v_mount\n"); */
1036 if (vp->v_type != VNON)
1037 printf("vn_setlabel: null v_mount with non-VNON\n");
1038 return (EBADF);
1039 }
1040
1041 if ((vp->v_mount->mnt_flag & MNT_MULTILABEL) == 0)
1042 return (EOPNOTSUPP);
1043
1044 /*
1045 * Multi-phase commit. First check the policies to confirm the
1046 * change is OK. Then commit via the filesystem. Finally, update
1047 * the actual vnode label.
1048 *
1049 * Question: maybe the filesystem should update the vnode at the end
1050 * as part of VOP_SETLABEL()?
1051 */
1052 error = mac_vnode_check_relabel(cred, vp, intlabel);
1053 if (error)
1054 return (error);
1055
1056 /*
1057 * VADMIN provides the opportunity for the filesystem to make
1058 * decisions about who is and is not able to modify labels and
1059 * protections on files. This might not be right. We can't assume
1060 * VOP_SETLABEL() will do it, because we might implement that as part
1061 * of vop_stdsetlabel_ea().
1062 */
1063 error = VOP_ACCESS(vp, VADMIN, cred, curthread);
1064 if (error)
1065 return (error);
1066
1067 error = VOP_SETLABEL(vp, intlabel, cred, curthread);
1068 if (error)
1069 return (error);
1070
1071 return (0);
1072}
1073
1074#ifdef DEBUG_VFS_LOCKS
1075void

Callers 2

sys___mac_set_fdFunction · 0.85
kern___mac_set_pathFunction · 0.85

Calls 2

mac_vnode_check_relabelFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected