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

Function shm_prison_set

freebsd/kern/sysv_shm.c:1133–1219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1131}
1132
1133static int
1134shm_prison_set(void *obj, void *data)
1135{
1136 struct prison *pr = obj;
1137 struct prison *tpr, *orpr, *nrpr, *trpr;
1138 struct vfsoptlist *opts = data;
1139 void *rsv;
1140 int jsys, descend;
1141
1142 /*
1143 * sysvshm controls which jail is the root of the associated segments
1144 * (this jail or same as the parent), or if the feature is available
1145 * at all.
1146 */
1147 if (vfs_copyopt(opts, "sysvshm", &jsys, sizeof(jsys)) == ENOENT)
1148 jsys = vfs_flagopt(opts, "allow.sysvipc", NULL, 0)
1149 ? JAIL_SYS_INHERIT
1150 : vfs_flagopt(opts, "allow.nosysvipc", NULL, 0)
1151 ? JAIL_SYS_DISABLE
1152 : -1;
1153 if (jsys == JAIL_SYS_DISABLE) {
1154 prison_lock(pr);
1155 orpr = osd_jail_get(pr, shm_prison_slot);
1156 if (orpr != NULL)
1157 osd_jail_del(pr, shm_prison_slot);
1158 prison_unlock(pr);
1159 if (orpr != NULL) {
1160 if (orpr == pr)
1161 shm_prison_cleanup(pr);
1162 /* Disable all child jails as well. */
1163 FOREACH_PRISON_DESCENDANT(pr, tpr, descend) {
1164 prison_lock(tpr);
1165 trpr = osd_jail_get(tpr, shm_prison_slot);
1166 if (trpr != NULL) {
1167 osd_jail_del(tpr, shm_prison_slot);
1168 prison_unlock(tpr);
1169 if (trpr == tpr)
1170 shm_prison_cleanup(tpr);
1171 } else {
1172 prison_unlock(tpr);
1173 descend = 0;
1174 }
1175 }
1176 }
1177 } else if (jsys != -1) {
1178 if (jsys == JAIL_SYS_NEW)
1179 nrpr = pr;
1180 else {
1181 prison_lock(pr->pr_parent);
1182 nrpr = osd_jail_get(pr->pr_parent, shm_prison_slot);
1183 prison_unlock(pr->pr_parent);
1184 }
1185 rsv = osd_reserve(shm_prison_slot);
1186 prison_lock(pr);
1187 orpr = osd_jail_get(pr, shm_prison_slot);
1188 if (orpr != nrpr)
1189 (void)osd_jail_set_reserved(pr, shm_prison_slot, rsv,
1190 nrpr);

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected