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

Function mac_proc_vm_revoke_recurse

freebsd/security/mac/mac_process.c:251–372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249}
250
251static void
252mac_proc_vm_revoke_recurse(struct thread *td, struct ucred *cred,
253 struct vm_map *map)
254{
255 vm_map_entry_t prev, vme;
256 int result;
257 vm_prot_t revokeperms;
258 vm_object_t backing_object, object;
259 vm_ooffset_t offset;
260 struct vnode *vp;
261 struct mount *mp;
262
263 if (!mac_mmap_revocation)
264 return;
265
266 prev = &map->header;
267 vm_map_lock(map);
268 for (vme = vm_map_entry_first(map); vme != &map->header;
269 prev = vme, vme = vm_map_entry_succ(prev)) {
270 if (vme->eflags & MAP_ENTRY_IS_SUB_MAP) {
271 mac_proc_vm_revoke_recurse(td, cred,
272 vme->object.sub_map);
273 continue;
274 }
275 /*
276 * Skip over entries that obviously are not shared.
277 */
278 if (vme->eflags & (MAP_ENTRY_COW | MAP_ENTRY_NOSYNC) ||
279 !vme->max_protection)
280 continue;
281 /*
282 * Drill down to the deepest backing object.
283 */
284 offset = vme->offset;
285 object = vme->object.vm_object;
286 if (object == NULL)
287 continue;
288 VM_OBJECT_RLOCK(object);
289 while ((backing_object = object->backing_object) != NULL) {
290 VM_OBJECT_RLOCK(backing_object);
291 offset += object->backing_object_offset;
292 VM_OBJECT_RUNLOCK(object);
293 object = backing_object;
294 }
295 VM_OBJECT_RUNLOCK(object);
296 /*
297 * At the moment, vm_maps and objects aren't considered by
298 * the MAC system, so only things with backing by a normal
299 * object (read: vnodes) are checked.
300 */
301 if (object->type != OBJT_VNODE)
302 continue;
303 vp = (struct vnode *)object->handle;
304 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
305 result = vme->max_protection;
306 mac_vnode_check_mmap_downgrade(cred, vp, &result);
307 VOP_UNLOCK(vp);
308 /*

Callers 1

mac_proc_vm_revokeFunction · 0.85

Calls 13

vm_map_entry_firstFunction · 0.85
vm_map_entry_succFunction · 0.85
vn_lockFunction · 0.85
prot2strFunction · 0.85
vm_object_referenceFunction · 0.85
vn_start_writeFunction · 0.85
vm_object_page_cleanFunction · 0.85
vn_finished_writeFunction · 0.85
vm_object_deallocateFunction · 0.85
vm_map_try_merge_entriesFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected