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

Function msg_prison_set

freebsd/kern/sysv_msg.c:1534–1619  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1532}
1533
1534static int
1535msg_prison_set(void *obj, void *data)
1536{
1537 struct prison *pr = obj;
1538 struct prison *tpr, *orpr, *nrpr, *trpr;
1539 struct vfsoptlist *opts = data;
1540 void *rsv;
1541 int jsys, descend;
1542
1543 /*
1544 * sysvmsg controls which jail is the root of the associated msgs (this
1545 * jail or same as the parent), or if the feature is available at all.
1546 */
1547 if (vfs_copyopt(opts, "sysvmsg", &jsys, sizeof(jsys)) == ENOENT)
1548 jsys = vfs_flagopt(opts, "allow.sysvipc", NULL, 0)
1549 ? JAIL_SYS_INHERIT
1550 : vfs_flagopt(opts, "allow.nosysvipc", NULL, 0)
1551 ? JAIL_SYS_DISABLE
1552 : -1;
1553 if (jsys == JAIL_SYS_DISABLE) {
1554 prison_lock(pr);
1555 orpr = osd_jail_get(pr, msg_prison_slot);
1556 if (orpr != NULL)
1557 osd_jail_del(pr, msg_prison_slot);
1558 prison_unlock(pr);
1559 if (orpr != NULL) {
1560 if (orpr == pr)
1561 msg_prison_cleanup(pr);
1562 /* Disable all child jails as well. */
1563 FOREACH_PRISON_DESCENDANT(pr, tpr, descend) {
1564 prison_lock(tpr);
1565 trpr = osd_jail_get(tpr, msg_prison_slot);
1566 if (trpr != NULL) {
1567 osd_jail_del(tpr, msg_prison_slot);
1568 prison_unlock(tpr);
1569 if (trpr == tpr)
1570 msg_prison_cleanup(tpr);
1571 } else {
1572 prison_unlock(tpr);
1573 descend = 0;
1574 }
1575 }
1576 }
1577 } else if (jsys != -1) {
1578 if (jsys == JAIL_SYS_NEW)
1579 nrpr = pr;
1580 else {
1581 prison_lock(pr->pr_parent);
1582 nrpr = osd_jail_get(pr->pr_parent, msg_prison_slot);
1583 prison_unlock(pr->pr_parent);
1584 }
1585 rsv = osd_reserve(msg_prison_slot);
1586 prison_lock(pr);
1587 orpr = osd_jail_get(pr, msg_prison_slot);
1588 if (orpr != nrpr)
1589 (void)osd_jail_set_reserved(pr, msg_prison_slot, rsv,
1590 nrpr);
1591 else

Callers

nothing calls this directly

Calls 7

vfs_copyoptFunction · 0.85
vfs_flagoptFunction · 0.85
prison_lockFunction · 0.85
prison_unlockFunction · 0.85
msg_prison_cleanupFunction · 0.85
osd_reserveFunction · 0.85
osd_free_reservedFunction · 0.85

Tested by

no test coverage detected