|
From: Jeremy F. <je...@go...> - 2005-02-22 02:32:04
|
CVS commit by fitzhardinge:
An mlock() will split a mapping in /proc/self/maps, so we need to update the
Segment list to match. These splits can happen even if the mlock() ends up
failing, so do it in the PRE() function.
M +2 -0 core.h 1.88
M +17 -0 vg_syscalls.c 1.252
--- valgrind/coregrind/vg_syscalls.c #1.251:1.252
@@ -1493,6 +1493,20 @@ PRE(sys_sched_setscheduler, 0)
PRE(sys_mlock, MayBlock)
{
+ Addr start, end;
+
PRINT("sys_mlock ( %p, %llu )", arg1, (ULong)arg2);
PRE_REG_READ2(long, "mlock", unsigned long, addr, vki_size_t, len);
+
+ if (!VG_(valid_client_addr)((Addr)arg1, arg2, tid, "mlock"))
+ SYSRES = -VKI_ENOMEM;
+
+ /* mlock() causes the kernel's mappings to be split, so make sure
+ the segment list matches it. This can happen even if the
+ mlock() call ultimately fails, so split here rather than in
+ POST(). */
+ start = PGROUNDDN(arg1);
+ end = PGROUNDUP(arg1+arg2);
+ VG_(split_segment)(start);
+ VG_(split_segment)(end);
}
@@ -1501,4 +1515,7 @@ PRE(sys_munlock, MayBlock)
PRINT("sys_munlock ( %p, %llu )", arg1, (ULong)arg2);
PRE_REG_READ2(long, "munlock", unsigned long, addr, vki_size_t, len);
+
+ if (!VG_(valid_client_addr)((Addr)arg1, arg2, tid, "munlock"))
+ SYSRES = -VKI_ENOMEM;
}
--- valgrind/coregrind/core.h #1.87:1.88
@@ -1248,4 +1248,6 @@ extern Bool VG_(seg_contains)(const
extern Bool VG_(seg_overlaps)(const Segment *s, Addr ptr, SizeT size);
+extern Segment *VG_(split_segment)(Addr a);
+
extern void VG_(pad_address_space) (Addr start);
extern void VG_(unpad_address_space)(Addr start);
|