Skip to content

Commit

Permalink
selftests/x86/ioperm: Extend testing so the shared bitmap is exercised
Browse files Browse the repository at this point in the history
Add code to the fork path which forces the shared bitmap to be duplicated
and the reference count to be dropped. Verify that the child modifications
did not affect the parent.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Thomas Gleixner committed Nov 16, 2019
1 parent 4804e38 commit 0907a09
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tools/testing/selftests/x86/ioperm.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@ int main(void)
printf("[RUN]\tchild: check that we inherited permissions\n");
expect_ok(0x80);
expect_gp(0xed);
printf("[RUN]\tchild: Extend permissions to 0x81\n");
if (ioperm(0x81, 1, 1) != 0) {
printf("[FAIL]\tioperm(0x81, 1, 1) failed (%d)", errno);
return 1;
}
printf("[RUN]\tchild: Drop permissions to 0x80\n");
if (ioperm(0x80, 1, 0) != 0) {
printf("[FAIL]\tioperm(0x80, 1, 0) failed (%d)", errno);
return 1;
}
expect_gp(0x80);
return 0;
} else {
int status;
Expand All @@ -146,8 +157,11 @@ int main(void)
}
}

/* Test the capability checks. */
/* Verify that the child dropping 0x80 did not affect the parent */
printf("\tVerify that unsharing the bitmap worked\n");
expect_ok(0x80);

/* Test the capability checks. */
printf("\tDrop privileges\n");
if (setresuid(1, 1, 1) != 0) {
printf("[WARN]\tDropping privileges failed\n");
Expand Down

0 comments on commit 0907a09

Please sign in to comment.