Skip to content

Commit 0907a09

Browse files
committed
selftests/x86/ioperm: Extend testing so the shared bitmap is exercised
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 <[email protected]>
1 parent 4804e38 commit 0907a09

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

tools/testing/selftests/x86/ioperm.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,17 @@ int main(void)
131131
printf("[RUN]\tchild: check that we inherited permissions\n");
132132
expect_ok(0x80);
133133
expect_gp(0xed);
134+
printf("[RUN]\tchild: Extend permissions to 0x81\n");
135+
if (ioperm(0x81, 1, 1) != 0) {
136+
printf("[FAIL]\tioperm(0x81, 1, 1) failed (%d)", errno);
137+
return 1;
138+
}
139+
printf("[RUN]\tchild: Drop permissions to 0x80\n");
140+
if (ioperm(0x80, 1, 0) != 0) {
141+
printf("[FAIL]\tioperm(0x80, 1, 0) failed (%d)", errno);
142+
return 1;
143+
}
144+
expect_gp(0x80);
134145
return 0;
135146
} else {
136147
int status;
@@ -146,8 +157,11 @@ int main(void)
146157
}
147158
}
148159

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

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

0 commit comments

Comments
 (0)