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

Function kern_cap_ioctls_limit

freebsd/kern/sys_capability.c:418–459  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

416}
417
418int
419kern_cap_ioctls_limit(struct thread *td, int fd, u_long *cmds, size_t ncmds)
420{
421 struct filedesc *fdp;
422 struct filedescent *fdep;
423 u_long *ocmds;
424 int error;
425
426 AUDIT_ARG_FD(fd);
427
428 if (ncmds > IOCTLS_MAX_COUNT) {
429 error = EINVAL;
430 goto out_free;
431 }
432
433 fdp = td->td_proc->p_fd;
434 FILEDESC_XLOCK(fdp);
435
436 fdep = fdeget_locked(fdp, fd);
437 if (fdep == NULL) {
438 error = EBADF;
439 goto out;
440 }
441
442 error = cap_ioctl_limit_check(fdep, cmds, ncmds);
443 if (error != 0)
444 goto out;
445
446 ocmds = fdep->fde_ioctls;
447 seqc_write_begin(&fdep->fde_seqc);
448 fdep->fde_ioctls = cmds;
449 fdep->fde_nioctls = ncmds;
450 seqc_write_end(&fdep->fde_seqc);
451
452 cmds = ocmds;
453 error = 0;
454out:
455 FILEDESC_XUNLOCK(fdp);
456out_free:
457 free(cmds, M_FILECAPS);
458 return (error);
459}
460
461int
462sys_cap_ioctls_limit(struct thread *td, struct cap_ioctls_limit_args *uap)

Callers 1

sys_cap_ioctls_limitFunction · 0.85

Calls 5

fdeget_lockedFunction · 0.85
cap_ioctl_limit_checkFunction · 0.85
seqc_write_beginFunction · 0.85
seqc_write_endFunction · 0.85
freeFunction · 0.70

Tested by

no test coverage detected