Skip to content

Commit

Permalink
Fix userspace GuestMaps (#55)
Browse files Browse the repository at this point in the history
* Fix userspace GuestMaps

* fix
  • Loading branch information
andreafioraldi authored Apr 7, 2024
1 parent fd6a2f3 commit f1e48d6
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions linux-user/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -13679,20 +13679,16 @@ struct libafl_mapinfo {
int flags, is_priv;
};
IntervalTreeNode * libafl_maps_first(IntervalTreeRoot * map_info);
IntervalTreeNode * libafl_maps_next(IntervalTreeNode *node, struct libafl_mapinfo* ret, bool is_root);
IntervalTreeNode * libafl_maps_next(IntervalTreeNode *node, struct libafl_mapinfo* ret);

IntervalTreeNode * libafl_maps_first(IntervalTreeRoot * map_info) {
return interval_tree_iter_first(map_info, 0, -1);
}

IntervalTreeNode * libafl_maps_next(IntervalTreeNode *node, struct libafl_mapinfo* ret, bool is_root) {
IntervalTreeNode * libafl_maps_next(IntervalTreeNode *node, struct libafl_mapinfo* ret) {
if (!node || !ret)
return NULL;

if (is_root) {
return libafl_maps_next(interval_tree_iter_next(node, 0, -1), ret, false);
}

MapInfo *e = container_of(node, MapInfo, itree);

if (h2g_valid(e->itree.start)) {
Expand All @@ -13704,7 +13700,7 @@ IntervalTreeNode * libafl_maps_next(IntervalTreeNode *node, struct libafl_mapinf
max : (uintptr_t) g2h_untagged(GUEST_ADDR_MAX) + 1;

if (!page_check_range(h2g(min), max - min, flags)) {
return libafl_maps_next(interval_tree_iter_next(node, 0, -1), ret, false);
return libafl_maps_next(interval_tree_iter_next(node, 0, -1), ret);
}

int libafl_flags = 0;
Expand All @@ -13721,7 +13717,7 @@ IntervalTreeNode * libafl_maps_next(IntervalTreeNode *node, struct libafl_mapinf

return interval_tree_iter_next(node, 0, -1);
} else {
return libafl_maps_next(interval_tree_iter_next(node, 0, -1), ret, false);
return libafl_maps_next(interval_tree_iter_next(node, 0, -1), ret);
}
}

Expand Down

0 comments on commit f1e48d6

Please sign in to comment.