From 68c4eda1c24d56f3108648c5b1855664d7f0e8cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Str=C3=B6mb=C3=A4ck?= Date: Wed, 18 Mar 2020 12:28:10 +0100 Subject: Added new tests for the validating the syscall number. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Filip Strömbäck --- src/tests/filst/sc-bad-close.c | 64 +++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'src/tests/filst/sc-bad-close.c') diff --git a/src/tests/filst/sc-bad-close.c b/src/tests/filst/sc-bad-close.c index 8331817..17f874a 100644 --- a/src/tests/filst/sc-bad-close.c +++ b/src/tests/filst/sc-bad-close.c @@ -25,43 +25,43 @@ extern int _end_bss; void test_main(void) { - // Get the addres of the first unmapped page in the system. - unsigned page = (unsigned)pg_round_up(&_end_bss); + // Get the addres of the first unmapped page in the system. + unsigned page = (unsigned)pg_round_up(&_end_bss); - // Reserve space for 2 parameters. - unsigned base = page - sizeof(int) * 2; + // Reserve space for 2 parameters. + unsigned base = page - sizeof(int) * 2; - // Call write() with space for 4 parameters (should be fine). - asm volatile ( - "movl %%esp, %%edi;" - "movl %0, %%esp;" // Set stack pointer to right below page boundary. - "movl %1, (%%esp);" // Try to call SYS_CLOSE - "movl $8, 4(%%esp);" // Close fileno #8 - "int $0x30;" - "movl %%edi, %%esp;" // Restore esp. - : - : "r" (base), - "i" (SYS_CLOSE) - : "%esp", "%eax", "%edi"); + // Call write() with space for 4 parameters (should be fine). + asm volatile ( + "movl %%esp, %%edi;" + "movl %0, %%esp;" // Set stack pointer to right below page boundary. + "movl %1, (%%esp);" // Try to call SYS_CLOSE + "movl $8, 4(%%esp);" // Close fileno #8 + "int $0x30;" + "movl %%edi, %%esp;" // Restore esp. + : + : "r" (base), + "i" (SYS_CLOSE) + : "%esp", "%eax", "%edi"); - write(STDOUT_FILENO, "OK\n", 3); + write(STDOUT_FILENO, "OK\n", 3); - // Reserve space for 1 parameter (open requires 2). - base = page - sizeof(int) * 1; + // Reserve space for 1 parameter (open requires 2). + base = page - sizeof(int) * 1; - // Call write() with space for 3 parameters (the kernel should kill us for doing this). - asm volatile ( - "movl %%esp, %%edi;" - "movl %0, %%esp;" // Set stack pointer to right below page boundary. - "movl %1, (%%esp);" // Try to call SYS_CLOSE - // "movl $8, 4(%%esp);" // Close fileno #8 - "int $0x30;" - "movl %%edi, %%esp;" // Restore esp in case we do not crash (as we should). - : - : "r" (base), - "i" (SYS_CLOSE) - : "%esp", "%eax", "%edi"); + // Call write() with space for 3 parameters (the kernel should kill us for doing this). + asm volatile ( + "movl %%esp, %%edi;" + "movl %0, %%esp;" // Set stack pointer to right below page boundary. + "movl %1, (%%esp);" // Try to call SYS_CLOSE + // "movl $8, 4(%%esp);" // Close fileno #8 + "int $0x30;" + "movl %%edi, %%esp;" // Restore esp in case we do not crash (as we should). + : + : "r" (base), + "i" (SYS_CLOSE) + : "%esp", "%eax", "%edi"); - fail("should have died."); + fail("should have died."); } -- cgit v1.2.1