]> granicus.if.org Git - strace/commitdiff
unwind: ignore memory mappings that have no PROT_EXEC bit set
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 13 Jun 2014 14:50:24 +0000 (18:50 +0400)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 13 Jun 2014 15:58:00 +0000 (15:58 +0000)
* unwind.c (build_mmap_cache): For each memory mapping being scanned,
save its PROT_EXEC bit and skip the mapping if it is not set.

unwind.c

index 2e809266429eef0559c8d66f46378b517ea67534..5b0600833055ce1bf02ad754e3ea62aecae39b2a 100644 (file)
--- a/unwind.c
+++ b/unwind.c
@@ -159,11 +159,16 @@ build_mmap_cache(struct tcb* tcp)
        while (fgets(buffer, sizeof(buffer), fp) != NULL) {
                struct mmap_cache_t *entry;
                unsigned long start_addr, end_addr, mmap_offset;
+               char exec_bit;
                char binary_path[PATH_MAX];
 
                if (sscanf(buffer, "%lx-%lx %*c%*c%c%*c %lx %*x:%*x %*d %[^\n]",
-                          &start_addr, &end_addr,
-                          &mmap_offset, binary_path) != 4)
+                          &start_addr, &end_addr, &exec_bit,
+                          &mmap_offset, binary_path) != 5)
+                       continue;
+
+               /* ignore mappings that have no PROT_EXEC bit set */
+               if (exec_bit != 'x')
                        continue;
 
                if (end_addr < start_addr) {
@@ -177,7 +182,6 @@ build_mmap_cache(struct tcb* tcp)
                 */
                if (tcp->mmap_cache_size > 0) {
                        entry = &cache_head[tcp->mmap_cache_size - 1];
-
                        if (entry->start_addr == start_addr &&
                            entry->end_addr == end_addr) {
                                /* duplicate entry, e.g. [vsyscall] */