Browse Source

Further refine SIGSEGV vs SIGBUSS semantics. Tweak the LTP rules a bit.

Don Porter 7 years ago
parent
commit
7ce7c064c7

+ 12 - 6
LibOS/shim/src/bookkeep/shim_signal.c

@@ -262,12 +262,18 @@ internal:
             put_vma(vma);
             goto internal;
         }
-        if (vma->file) {
-            /* DEP 3/3/17: If the page fault gives a write error, and
-             * the VMA is read-only, return SIGSEGV+SEGV_ACCERR */
-            if ((context->err & 4) && !(vma->flags & PROT_WRITE)) {
-                    signo = SIGSEGV;
-                    code = SEGV_ACCERR;
+        if (vma->file && vma->file->type == TYPE_FILE) {
+            /* DEP 3/3/17: If the mapping exceeds end of a file (but is in the VMA)
+             * then return a SIGBUS. */
+            uint64_t eof_in_vma = (uint64_t) vma->addr + vma->offset + vma->file->info.file.size;
+            if (arg > eof_in_vma) {
+                signo = SIGBUS;
+                code = BUS_ADRERR;
+            } else if ((context->err & 4) && !(vma->flags & PROT_WRITE)) {
+                /* DEP 3/3/17: If the page fault gives a write error, and
+                 * the VMA is read-only, return SIGSEGV+SEGV_ACCERR */
+                signo = SIGSEGV;
+                code = SEGV_ACCERR;
             } else {
                 /* XXX: need more sophisticated judgement */
                 signo = SIGBUS;

+ 0 - 3
LibOS/shim/test/apps/ltp/PASSED

@@ -628,7 +628,6 @@ tkill01,2
 truncate01,1
 truncate01_64,1
 umask01,1
-umask02,1
 uname01,1
 uname03,1
 unlink05,1
@@ -646,8 +645,6 @@ wait401,2
 waitpid01,1
 waitpid02,1
 waitpid02,3
-waitpid03,1
-waitpid03,2
 waitpid05,1
 waitpid05,11
 waitpid05,14

+ 8 - 0
LibOS/shim/test/apps/ltp/manifest.template

@@ -2,6 +2,14 @@ loader.preload = file:$(SHIMPATH)
 loader.env.LD_LIBRARY_PATH = /lib:/lib64:/usr/lib:/usr/lib64
 loader.debug_type = none
 
+fs.mount.tmp1.type = chroot
+fs.mount.tmp1.path = /tmp
+fs.mount.tmp1.uri = file:/tmp
+
+fs.mount.shm.type = chroot
+fs.mount.shm.path = /dev/shm
+fs.mount.shm.uri = file:/dev/shm
+
 fs.mount.lib.type = chroot
 fs.mount.lib.path = /lib
 fs.mount.lib.uri = file:$(LIBCDIR)