CAP_IOCTLS_LIMIT(2)
Hii bestie!! Welcome to the CAP_IOCTLS_LIMIT(2) page from the System Calls Manual β this is the one about cap_ioctls_limit and cap_ioctls_get managing allowed ioctl commands. Slay π
πΈ NAME πΈ
cap_ioctls_limit, cap_ioctls_get β manage allowed ioctl commands.
β¨ LIBRARY β¨
Standard C Library (libc, -lc) β that's the home base, no cap π«Ά
π¦ SYNOPSIS π¦
Okay so here's the exact spellbook, bestie:
#include <sys/capsicum.h>
int
cap_ioctls_limit(int fd, const unsigned long *cmds, size_t ncmds);
ssize_t
cap_ioctls_get(int fd, unsigned long *cmds, size_t maxcmds);
π DESCRIPTION π
So when a file descriptor is granted the CAP_IOCTL capability right, the list of allowed ioctl(2) commands can be selectively reduced β but never expanded β with the cap_ioctls_limit() system call. Periodt, that boundary is iconic π₯
The cmds argument is an array of ioctl(2) commands, and ncmds says how many elements are in that array. There can be up to 256 elements in the array, bestie. Including an element that has been previously revoked will generate an error. After a successful call, only those listed in the array may be used. π
The list of allowed ioctl commands for a given file descriptor can be obtained with the cap_ioctls_get() system call. The cmds argument points at memory that can hold up to maxcmds values. The function populates the provided buffer with up to maxcmds elements, but always returns the total number of ioctl commands allowed for the given file descriptor. The total number of ioctls commands for the given file descriptor can be obtained by passing NULL as the cmds argument and 0 as the maxcmds argument. π
If all ioctl commands are allowed β meaning the CAP_IOCTL capability right is assigned to the file descriptor and the cap_ioctls_limit() system call was never called for this file descriptor β then the cap_ioctls_get() system call will return CAP_IOCTLS_ALL and will not modify the buffer pointed to by the cmds argument. That's the "all clear" vibe, iykyk β
π RETURN VALUES π
The cap_ioctls_limit() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error. Classic success/fail energy π
The cap_ioctls_get() function, if successful, returns the total number of allowed ioctl commands or the value CAP_IOCTLS_ALL if all ioctls commands are allowed. On failure the value -1 is returned and the global variable errno is set to indicate the error. π«Ά
π₯ ERRORS π₯
The cap_ioctls_limit() and cap_ioctls_get() system calls will fail if:
[EBADF]β Thefdargument is not a valid descriptor.[EFAULT]β Thecmdsargument points at an invalid address.[ENOSYS]β The running kernel was compiled withoutoptions CAPABILITY_MODE.
The cap_ioctls_limit() system call may also return the following errors:
[EINVAL]β Thencmdsargument is greater than256.[ENOTCAPABLE]βcmdswould expand the list of allowedioctl(2)commands.
Bestie, the ENOTCAPABLE one is literally the "no expanding the list" rule showing up to say hi. Respect it fr fr π
π SEE ALSO π
Go give these icons a look:
π§ HISTORY π§
The cap_ioctls_get() and cap_ioctls_limit() system calls first appeared in FreeBSD 8.3. Support for capabilities and capabilities mode was developed as part of the TrustedBSD Project. History ate, honestly π
π AUTHORS π
This function was created by Pawel Jakub Dawidek <pawel@dawidek.net> under sponsorship of the FreeBSD Foundation. Main character author energy, periodt π
π that's the whole page, bestie β source/version: Debian, date: March 9, 2023, manual: CAP_IOCTLS_LIMIT(2) π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2012 The FreeBSD Foundation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms