Skip to content

Commit

Permalink
Only check for PROT_{READ,WRITE,EXEC} in assert_segments_match()
Browse files Browse the repository at this point in the history
On arm64, mapping protection flags can include PROT_BTI and PROT_MTE,
but they are not shown in /proc/pid/maps, so if a mapping has one of
these the assert_segments_match() check will fail. Fix it by masking
out flags that are not shown in /proc/pid/maps when doing the check.
  • Loading branch information
pcc committed Jun 25, 2024
1 parent b5f1dc2 commit 87679b6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/AddressSpace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ static void assert_segments_match(Task* t, const KernelMapping& input_m,
err = "starts differ";
} else if (m.end() != km.end()) {
err = "ends differ";
} else if (m.prot() != km.prot()) {
} else if ((m.prot() ^ km.prot()) & KernelMapping::checkable_prot_mask) {
err = "prots differ";
} else if ((m.flags() ^ km.flags()) & KernelMapping::checkable_flags_mask) {
err = "flags differ";
Expand Down
1 change: 1 addition & 0 deletions src/AddressSpace.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class KernelMapping : public MemoryRange {
MAP_PRIVATE | MAP_SHARED | MAP_STACK |
MAP_GROWSDOWN;
static const int checkable_flags_mask = MAP_PRIVATE | MAP_SHARED;
static const int checkable_prot_mask = PROT_READ | PROT_WRITE | PROT_EXEC;
static const dev_t NO_DEVICE = 0;
static const ino_t NO_INODE = 0;

Expand Down

0 comments on commit 87679b6

Please sign in to comment.