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

Function sys___mac_get_pid

freebsd/security/mac/mac_syscalls.c:84–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82 struct mac *mac_p, int follow);
83
84int
85sys___mac_get_pid(struct thread *td, struct __mac_get_pid_args *uap)
86{
87 char *elements, *buffer;
88 struct mac mac;
89 struct proc *tproc;
90 struct ucred *tcred;
91 int error;
92
93 error = copyin(uap->mac_p, &mac, sizeof(mac));
94 if (error)
95 return (error);
96
97 error = mac_check_structmac_consistent(&mac);
98 if (error)
99 return (error);
100
101 tproc = pfind(uap->pid);
102 if (tproc == NULL)
103 return (ESRCH);
104
105 tcred = NULL; /* Satisfy gcc. */
106 error = p_cansee(td, tproc);
107 if (error == 0)
108 tcred = crhold(tproc->p_ucred);
109 PROC_UNLOCK(tproc);
110 if (error)
111 return (error);
112
113 elements = malloc(mac.m_buflen, M_MACTEMP, M_WAITOK);
114 error = copyinstr(mac.m_string, elements, mac.m_buflen, NULL);
115 if (error) {
116 free(elements, M_MACTEMP);
117 crfree(tcred);
118 return (error);
119 }
120
121 buffer = malloc(mac.m_buflen, M_MACTEMP, M_WAITOK | M_ZERO);
122 error = mac_cred_externalize_label(tcred->cr_label, elements,
123 buffer, mac.m_buflen);
124 if (error == 0)
125 error = copyout(buffer, mac.m_string, strlen(buffer)+1);
126
127 free(buffer, M_MACTEMP);
128 free(elements, M_MACTEMP);
129 crfree(tcred);
130 return (error);
131}
132
133int
134sys___mac_get_proc(struct thread *td, struct __mac_get_proc_args *uap)

Callers

nothing calls this directly

Calls 11

mallocFunction · 0.85
copyinFunction · 0.50
pfindFunction · 0.50
p_canseeFunction · 0.50
crholdFunction · 0.50
copyinstrFunction · 0.50
freeFunction · 0.50
crfreeFunction · 0.50
copyoutFunction · 0.50

Tested by

no test coverage detected