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

Function sys___mac_set_proc

freebsd/security/mac/mac_syscalls.c:166–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164}
165
166int
167sys___mac_set_proc(struct thread *td, struct __mac_set_proc_args *uap)
168{
169 struct ucred *newcred, *oldcred;
170 struct label *intlabel;
171 struct proc *p;
172 struct mac mac;
173 char *buffer;
174 int error;
175
176 if (!(mac_labeled & MPC_OBJECT_CRED))
177 return (EINVAL);
178
179 error = copyin(uap->mac_p, &mac, sizeof(mac));
180 if (error)
181 return (error);
182
183 error = mac_check_structmac_consistent(&mac);
184 if (error)
185 return (error);
186
187 buffer = malloc(mac.m_buflen, M_MACTEMP, M_WAITOK);
188 error = copyinstr(mac.m_string, buffer, mac.m_buflen, NULL);
189 if (error) {
190 free(buffer, M_MACTEMP);
191 return (error);
192 }
193
194 intlabel = mac_cred_label_alloc();
195 error = mac_cred_internalize_label(intlabel, buffer);
196 free(buffer, M_MACTEMP);
197 if (error)
198 goto out;
199
200 newcred = crget();
201
202 p = td->td_proc;
203 PROC_LOCK(p);
204 oldcred = p->p_ucred;
205
206 error = mac_cred_check_relabel(oldcred, intlabel);
207 if (error) {
208 PROC_UNLOCK(p);
209 crfree(newcred);
210 goto out;
211 }
212
213 setsugid(p);
214 crcopy(newcred, oldcred);
215 mac_cred_relabel(newcred, intlabel);
216 proc_set_cred(p, newcred);
217
218 PROC_UNLOCK(p);
219 crfree(oldcred);
220 mac_proc_vm_revoke(td);
221
222out:
223 mac_cred_label_free(intlabel);

Callers

nothing calls this directly

Calls 15

mallocFunction · 0.85
mac_cred_label_allocFunction · 0.85
mac_cred_check_relabelFunction · 0.85
setsugidFunction · 0.85
crcopyFunction · 0.85
mac_cred_relabelFunction · 0.85
proc_set_credFunction · 0.85
mac_proc_vm_revokeFunction · 0.85
mac_cred_label_freeFunction · 0.85
copyinFunction · 0.50

Tested by

no test coverage detected