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

Function mls_vnode_associate_extattr

freebsd/security/mac_mls/mac_mls.c:2454–2492  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2452}
2453
2454static int
2455mls_vnode_associate_extattr(struct mount *mp, struct label *mplabel,
2456 struct vnode *vp, struct label *vplabel)
2457{
2458 struct mac_mls mm_temp, *source, *dest;
2459 int buflen, error;
2460
2461 source = SLOT(mplabel);
2462 dest = SLOT(vplabel);
2463
2464 buflen = sizeof(mm_temp);
2465 bzero(&mm_temp, buflen);
2466
2467 error = vn_extattr_get(vp, IO_NODELOCKED, MAC_MLS_EXTATTR_NAMESPACE,
2468 MAC_MLS_EXTATTR_NAME, &buflen, (char *) &mm_temp, curthread);
2469 if (error == ENOATTR || error == EOPNOTSUPP) {
2470 /* Fall back to the mntlabel. */
2471 mls_copy_effective(source, dest);
2472 return (0);
2473 } else if (error)
2474 return (error);
2475
2476 if (buflen != sizeof(mm_temp)) {
2477 printf("mls_vnode_associate_extattr: bad size %d\n", buflen);
2478 return (EPERM);
2479 }
2480 if (mls_valid(&mm_temp) != 0) {
2481 printf("mls_vnode_associate_extattr: invalid\n");
2482 return (EPERM);
2483 }
2484 if ((mm_temp.mm_flags & MAC_MLS_FLAGS_BOTH) !=
2485 MAC_MLS_FLAG_EFFECTIVE) {
2486 printf("mls_associated_vnode_extattr: not effective\n");
2487 return (EPERM);
2488 }
2489
2490 mls_copy_effective(&mm_temp, dest);
2491 return (0);
2492}
2493
2494static void
2495mls_vnode_associate_singlelabel(struct mount *mp, struct label *mplabel,

Callers

nothing calls this directly

Calls 5

bzeroFunction · 0.85
vn_extattr_getFunction · 0.85
mls_copy_effectiveFunction · 0.85
mls_validFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected