]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix bug in do_mremap. Also need to allow SkShmC segments.
authorFlorian Krohm <florian@eich-krohm.de>
Tue, 12 May 2015 21:19:25 +0000 (21:19 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Tue, 12 May 2015 21:19:25 +0000 (21:19 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15219

NEWS
coregrind/m_syswrap/syswrap-generic.c
none/tests/linux/Makefile.am
none/tests/linux/mremap4.c [new file with mode: 0644]
none/tests/linux/mremap4.stderr.exp [new file with mode: 0644]
none/tests/linux/mremap4.vgtest [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index d57da2c633ee67ef3aa513e1a9a97659018abd93..647847adf6cb5885892719cae4fc8a4e23415fd1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -182,6 +182,7 @@ n-i-bz  Old STABS code is still being compiled, but never used. Remove it.
 n-i-bz  Fix compilation on distros with glibc < 2.5
 n-i-bz  (vex 3098) Avoid generation of Neon insns on non-Neon hosts
 n-i-bz  Enable rt_sigpending syscall on ppc64 linux.
+n-i-bz  mremap did not work properly on shared memory
 
 
 Release 3.10.1 (25 November 2014)
index a28e50a935d13cb611b6f165664dcbbda9931cd2..fcf5687b21e74b9cea7d88eddaab232339de335b 100644 (file)
@@ -328,7 +328,8 @@ SysRes do_mremap( Addr old_addr, SizeT old_len,
    old_seg = VG_(am_find_nsegment)( old_addr );
    if (old_addr < old_seg->start || old_addr+old_len-1 > old_seg->end)
       goto eINVAL;
-   if (old_seg->kind != SkAnonC && old_seg->kind != SkFileC)
+   if (old_seg->kind != SkAnonC && old_seg->kind != SkFileC &&
+       old_seg->kind != SkShmC)
       goto eINVAL;
 
    vg_assert(old_len > 0);
index 4fb047558374f2ee0b0533ae426370844b27b0ec..46e248628abf7dc8712f672c13c1ca1bbb5b2b5a 100644 (file)
@@ -11,6 +11,7 @@ EXTRA_DIST = \
            mremap.vgtest \
        mremap2.stderr.exp mremap2.stdout.exp mremap2.vgtest \
        mremap3.stderr.exp mremap3.stdout.exp mremap3.vgtest \
+       mremap4.stderr.exp mremap4.vgtest \
        pthread-stack.stderr.exp pthread-stack.vgtest \
        stack-overflow.stderr.exp stack-overflow.vgtest
 
@@ -21,6 +22,7 @@ check_PROGRAMS = \
        mremap \
        mremap2 \
        mremap3 \
+       mremap4 \
        pthread-stack \
        stack-overflow
 
diff --git a/none/tests/linux/mremap4.c b/none/tests/linux/mremap4.c
new file mode 100644 (file)
index 0000000..1f83dab
--- /dev/null
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <sys/stat.h>
+
+
+extern void *mremap(void *, size_t, size_t, int, ...);
+
+int main()
+{
+  int shmid = shmget(IPC_PRIVATE, 100 * 4096, 
+                     IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR);
+  assert(shmid != -1);
+
+  void *addr = shmat(shmid, NULL, 0);
+  assert(addr != (void *)-1);
+
+  addr = mremap(addr, 100 * 4096, 40 * 4096, 0);
+  assert(addr != (void *)-1);
+
+  return 0;
+}
diff --git a/none/tests/linux/mremap4.stderr.exp b/none/tests/linux/mremap4.stderr.exp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/none/tests/linux/mremap4.vgtest b/none/tests/linux/mremap4.vgtest
new file mode 100644 (file)
index 0000000..b6d5b8b
--- /dev/null
@@ -0,0 +1,2 @@
+prog: mremap4
+vgopts: -q