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

Function kern___mac_set_path

freebsd/security/mac/mac_syscalls.c:502–552  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

500}
501
502static int
503kern___mac_set_path(struct thread *td, const char *path_p, struct mac *mac_p,
504 int follow)
505{
506 struct label *intlabel;
507 struct nameidata nd;
508 struct mount *mp;
509 struct mac mac;
510 char *buffer;
511 int error;
512
513 if (!(mac_labeled & MPC_OBJECT_VNODE))
514 return (EINVAL);
515
516 error = copyin(mac_p, &mac, sizeof(mac));
517 if (error)
518 return (error);
519
520 error = mac_check_structmac_consistent(&mac);
521 if (error)
522 return (error);
523
524 buffer = malloc(mac.m_buflen, M_MACTEMP, M_WAITOK);
525 error = copyinstr(mac.m_string, buffer, mac.m_buflen, NULL);
526 if (error) {
527 free(buffer, M_MACTEMP);
528 return (error);
529 }
530
531 intlabel = mac_vnode_label_alloc();
532 error = mac_vnode_internalize_label(intlabel, buffer);
533 free(buffer, M_MACTEMP);
534 if (error)
535 goto out;
536
537 NDINIT(&nd, LOOKUP, LOCKLEAF | follow, UIO_USERSPACE, path_p, td);
538 error = namei(&nd);
539 if (error == 0) {
540 error = vn_start_write(nd.ni_vp, &mp, V_WAIT | PCATCH);
541 if (error == 0) {
542 error = vn_setlabel(nd.ni_vp, intlabel,
543 td->td_ucred);
544 vn_finished_write(mp);
545 }
546 }
547
548 NDFREE(&nd, 0);
549out:
550 mac_vnode_label_free(intlabel);
551 return (error);
552}
553
554int
555sys_mac_syscall(struct thread *td, struct mac_syscall_args *uap)

Callers 2

sys___mac_set_fileFunction · 0.85
sys___mac_set_linkFunction · 0.85

Calls 13

mallocFunction · 0.85
mac_vnode_label_allocFunction · 0.85
nameiFunction · 0.85
vn_start_writeFunction · 0.85
vn_setlabelFunction · 0.85
vn_finished_writeFunction · 0.85
NDFREEFunction · 0.85
mac_vnode_label_freeFunction · 0.85
copyinFunction · 0.50
copyinstrFunction · 0.50

Tested by

no test coverage detected