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

Function lomac_vnode_associate_extattr

freebsd/security/mac_lomac/mac_lomac.c:2273–2319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2271}
2272
2273static int
2274lomac_vnode_associate_extattr(struct mount *mp, struct label *mplabel,
2275 struct vnode *vp, struct label *vplabel)
2276{
2277 struct mac_lomac ml_temp, *source, *dest;
2278 int buflen, error;
2279
2280 source = SLOT(mplabel);
2281 dest = SLOT(vplabel);
2282
2283 buflen = sizeof(ml_temp);
2284 bzero(&ml_temp, buflen);
2285
2286 error = vn_extattr_get(vp, IO_NODELOCKED, MAC_LOMAC_EXTATTR_NAMESPACE,
2287 MAC_LOMAC_EXTATTR_NAME, &buflen, (char *)&ml_temp, curthread);
2288 if (error == ENOATTR || error == EOPNOTSUPP) {
2289 /* Fall back to the mntlabel. */
2290 lomac_copy_single(source, dest);
2291 return (0);
2292 } else if (error)
2293 return (error);
2294
2295 if (buflen != sizeof(ml_temp)) {
2296 if (buflen != sizeof(ml_temp) - sizeof(ml_temp.ml_auxsingle)) {
2297 printf("lomac_vnode_associate_extattr: bad size %d\n",
2298 buflen);
2299 return (EPERM);
2300 }
2301 bzero(&ml_temp.ml_auxsingle, sizeof(ml_temp.ml_auxsingle));
2302 buflen = sizeof(ml_temp);
2303 (void)vn_extattr_set(vp, IO_NODELOCKED,
2304 MAC_LOMAC_EXTATTR_NAMESPACE, MAC_LOMAC_EXTATTR_NAME,
2305 buflen, (char *)&ml_temp, curthread);
2306 }
2307 if (lomac_valid(&ml_temp) != 0) {
2308 printf("lomac_vnode_associate_extattr: invalid\n");
2309 return (EPERM);
2310 }
2311 if ((ml_temp.ml_flags & MAC_LOMAC_FLAGS_BOTH) !=
2312 MAC_LOMAC_FLAG_SINGLE) {
2313 printf("lomac_vnode_associate_extattr: not single\n");
2314 return (EPERM);
2315 }
2316
2317 lomac_copy_single(&ml_temp, dest);
2318 return (0);
2319}
2320
2321static void
2322lomac_vnode_associate_singlelabel(struct mount *mp, struct label *mplabel,

Callers

nothing calls this directly

Calls 6

bzeroFunction · 0.85
vn_extattr_getFunction · 0.85
lomac_copy_singleFunction · 0.85
vn_extattr_setFunction · 0.85
lomac_validFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected