Skip to content

Commit

Permalink
stress-mmap: add mprotect EACCESS error check for NetBSD
Browse files Browse the repository at this point in the history
NetBSD can throw EACCESS rather than EPERM, so add a check for this.

Signed-off-by: Colin Ian King <[email protected]>
  • Loading branch information
ColinIanKing committed Jan 2, 2024
1 parent c8f7666 commit 27cf140
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions stress-mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,9 +773,13 @@ static int stress_mmap_child(stress_args_t *args, void *ctxt)

*buf64 = val;
ret = mprotect((void *)buf64, page_size, PROT_READ);
if ((ret < 0) && (errno != ENOMEM) && (errno != EPERM)) {
pr_fail("%s: cannot set write-only page to read-only, errno=%d (%s)\n",
args->name, errno, strerror(errno));
if (ret < 0) {
if ((errno != EACCES) &&
(errno != ENOMEM) &&
(errno != EPERM)) {
pr_fail("%s: cannot set write-only page to read-only, errno=%d (%s)\n",
args->name, errno, strerror(errno));
}
} else {
if (*buf64 != val) {
pr_fail("%s: unexpected value in read-only page, "
Expand All @@ -798,9 +802,13 @@ static int stress_mmap_child(stress_args_t *args, void *ctxt)
stress_set_vma_anon_name((void *)buf64, page_size, mmap_name);

ret = mprotect((void *)buf64, page_size, PROT_WRITE);
if ((ret < 0) && (errno != ENOMEM) && (errno != EPERM)) {
pr_fail("%s: cannot set read-only page to write-only, errno=%d (%s)\n",
args->name, errno, strerror(errno));
if (ret < 0) {
if ((errno != EACCES) &&
(errno != ENOMEM) &&
(errno != EPERM)) {
pr_fail("%s: cannot set read-only page to write-only, errno=%d (%s)\n",
args->name, errno, strerror(errno));
}
}
(void)stress_munmap_retry_enomem((void *)buf64, page_size);
}
Expand Down

0 comments on commit 27cf140

Please sign in to comment.