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

Function sys_cap_rights_limit

freebsd/kern/sys_capability.c:269–307  ·  view source on GitHub ↗

* System call to limit rights of the given capability. */

Source from the content-addressed store, hash-verified

267 * System call to limit rights of the given capability.
268 */
269int
270sys_cap_rights_limit(struct thread *td, struct cap_rights_limit_args *uap)
271{
272 cap_rights_t rights;
273 int error, version;
274
275 cap_rights_init_zero(&rights);
276
277 error = copyin(uap->rightsp, &rights, sizeof(rights.cr_rights[0]));
278 if (error != 0)
279 return (error);
280 version = CAPVER(&rights);
281 if (version != CAP_RIGHTS_VERSION_00)
282 return (EINVAL);
283
284 error = copyin(uap->rightsp, &rights,
285 sizeof(rights.cr_rights[0]) * CAPARSIZE(&rights));
286 if (error != 0)
287 return (error);
288 /* Check for race. */
289 if (CAPVER(&rights) != version)
290 return (EINVAL);
291
292 if (!cap_rights_is_valid(&rights))
293 return (EINVAL);
294
295 if (version != CAP_RIGHTS_VERSION) {
296 rights.cr_rights[0] &= ~(0x3ULL << 62);
297 rights.cr_rights[0] |= ((uint64_t)CAP_RIGHTS_VERSION << 62);
298 }
299#ifdef KTRACE
300 if (KTRPOINT(td, KTR_STRUCT))
301 ktrcaprights(&rights);
302#endif
303
304 AUDIT_ARG_FD(uap->fd);
305 AUDIT_ARG_RIGHTS(&rights);
306 return (kern_cap_rights_limit(td, uap->fd, &rights));
307}
308
309/*
310 * System call to query the rights mask associated with a capability.

Callers

nothing calls this directly

Calls 3

cap_rights_is_validFunction · 0.85
kern_cap_rights_limitFunction · 0.85
copyinFunction · 0.50

Tested by

no test coverage detected