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

Function kern___mac_get_path

freebsd/security/mac/mac_syscalls.c:335–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

333}
334
335static int
336kern___mac_get_path(struct thread *td, const char *path_p, struct mac *mac_p,
337 int follow)
338{
339 char *elements, *buffer;
340 struct nameidata nd;
341 struct label *intlabel;
342 struct mac mac;
343 int error;
344
345 if (!(mac_labeled & MPC_OBJECT_VNODE))
346 return (EINVAL);
347
348 error = copyin(mac_p, &mac, sizeof(mac));
349 if (error)
350 return (error);
351
352 error = mac_check_structmac_consistent(&mac);
353 if (error)
354 return (error);
355
356 elements = malloc(mac.m_buflen, M_MACTEMP, M_WAITOK);
357 error = copyinstr(mac.m_string, elements, mac.m_buflen, NULL);
358 if (error) {
359 free(elements, M_MACTEMP);
360 return (error);
361 }
362
363 buffer = malloc(mac.m_buflen, M_MACTEMP, M_WAITOK | M_ZERO);
364 NDINIT(&nd, LOOKUP, LOCKLEAF | follow, UIO_USERSPACE, path_p, td);
365 error = namei(&nd);
366 if (error)
367 goto out;
368
369 intlabel = mac_vnode_label_alloc();
370 mac_vnode_copy_label(nd.ni_vp->v_label, intlabel);
371 error = mac_vnode_externalize_label(intlabel, elements, buffer,
372 mac.m_buflen);
373 NDFREE(&nd, 0);
374 mac_vnode_label_free(intlabel);
375
376 if (error == 0)
377 error = copyout(buffer, mac.m_string, strlen(buffer)+1);
378
379out:
380 free(buffer, M_MACTEMP);
381 free(elements, M_MACTEMP);
382
383 return (error);
384}
385
386int
387sys___mac_set_fd(struct thread *td, struct __mac_set_fd_args *uap)

Callers 2

sys___mac_get_fileFunction · 0.85
sys___mac_get_linkFunction · 0.85

Calls 12

mallocFunction · 0.85
nameiFunction · 0.85
mac_vnode_label_allocFunction · 0.85
mac_vnode_copy_labelFunction · 0.85
NDFREEFunction · 0.85
mac_vnode_label_freeFunction · 0.85
copyinFunction · 0.50
copyinstrFunction · 0.50
freeFunction · 0.50
copyoutFunction · 0.50

Tested by

no test coverage detected