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

Function kern_cap_rights_limit

freebsd/kern/sys_capability.c:232–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232int
233kern_cap_rights_limit(struct thread *td, int fd, cap_rights_t *rights)
234{
235 struct filedesc *fdp;
236 struct filedescent *fdep;
237 u_long *ioctls;
238 int error;
239
240 fdp = td->td_proc->p_fd;
241 FILEDESC_XLOCK(fdp);
242 fdep = fdeget_locked(fdp, fd);
243 if (fdep == NULL) {
244 FILEDESC_XUNLOCK(fdp);
245 return (EBADF);
246 }
247 ioctls = NULL;
248 error = _cap_check(cap_rights(fdp, fd), rights, CAPFAIL_INCREASE);
249 if (error == 0) {
250 seqc_write_begin(&fdep->fde_seqc);
251 fdep->fde_rights = *rights;
252 if (!cap_rights_is_set(rights, CAP_IOCTL)) {
253 ioctls = fdep->fde_ioctls;
254 fdep->fde_ioctls = NULL;
255 fdep->fde_nioctls = 0;
256 }
257 if (!cap_rights_is_set(rights, CAP_FCNTL))
258 fdep->fde_fcntls = 0;
259 seqc_write_end(&fdep->fde_seqc);
260 }
261 FILEDESC_XUNLOCK(fdp);
262 free(ioctls, M_FILECAPS);
263 return (error);
264}
265
266/*
267 * System call to limit rights of the given capability.

Callers 1

sys_cap_rights_limitFunction · 0.85

Calls 6

fdeget_lockedFunction · 0.85
_cap_checkFunction · 0.85
seqc_write_beginFunction · 0.85
seqc_write_endFunction · 0.85
cap_rightsFunction · 0.70
freeFunction · 0.70

Tested by

no test coverage detected