Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <tglx@linutronix.de>

+15 -1
+15 -1
tools/testing/selftests/x86/ioperm.c
··· 131 131 printf("[RUN]\tchild: check that we inherited permissions\n"); 132 132 expect_ok(0x80); 133 133 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); 134 145 return 0; 135 146 } else { 136 147 int status; ··· 157 146 } 158 147 } 159 148 160 - /* Test the capability checks. */ 149 + /* Verify that the child dropping 0x80 did not affect the parent */ 150 + printf("\tVerify that unsharing the bitmap worked\n"); 151 + expect_ok(0x80); 161 152 153 + /* Test the capability checks. */ 162 154 printf("\tDrop privileges\n"); 163 155 if (setresuid(1, 1, 1) != 0) { 164 156 printf("[WARN]\tDropping privileges failed\n");