https://bugs.kde.org/show_bug.cgi?id=528451
--- Comment #4 from Martin Cermak <[email protected]> --- (In reply to Mark Wielaard from comment #3) > (In reply to Martin Cermak from comment #1) > > Created attachment 198155 [details] > > proposed patch > > This is probably correct. But there are multiple ways > am_relocate_nooverlap_client can fail. > And am_relocate_nooverlap_client is called in two places. > Which check in am_relocate_nooverlap_client precisely fails in this case? Both the two places that can call VG_(am_relocate_nooverlap_client)() are in the do_mremap() function. In this case of mseal01 LTP testcase the one that fails is the first one i.e. in the block if (f_maymove == True && f_fixed == True) { ... }. > Can/Should that be checked explicitly or is any am_relocate_nooverlap_client > failure cause for EPERM? As mentioned, what the testcase does is that it tries to remap portion of memory that is protected with mseal() syscall. In this case kernel says EPERM. My proposed patch in Comment #1 tries to align the memcheck behavior with that. It would probably be ideal to have some shadow data for that in the address space manager, and do an explicit check whether the memory that mremap tries to mess with is or isn't sealed. Looking at the NSegment struct in include/pub_tool_aspacemgr.h:92 there is no flag for it so far. So, what happens is that mseal is passed through to the kernel like this: Catchpoint 2 (call to syscall mseal), 0x00000000580641d2 in do_syscall_WRK () at m_syscall.c:239 (gdb) bt #0 0x00000000580641d2 in do_syscall_WRK () at m_syscall.c:239 #1 0x0000000058064227 in vgPlain_do_syscall (sysno=462, a1=75886592, a2=4096, a3=0, a4=0, a5=0, a6=4096, a7=0, a8=0) at m_syscall.c:1215 #2 0x00000000580cfd0e in vgPlain_client_syscall (tid=1, trc=73) at m_syswrap/syswrap-main.c:2542 #3 0x00000000580c9f59 in handle_syscall (tid=1, trc=73) at m_scheduler/scheduler.c:1214 #4 0x00000000580cade2 in vgPlain_scheduler (tid=1) at m_scheduler/scheduler.c:1588 #5 0x0000000058192061 in thread_wrapper (tidW=1) at m_syswrap/syswrap-linux.c:102 #6 0x00000000581921f1 in run_a_thread_NORETURN (tidW=1) at m_syswrap/syswrap-linux.c:154 #7 0x0000000000000000 in ?? () Later when mremap() is called: Catchpoint 1 (call to syscall mremap), 0x00000000580641d2 in do_syscall_WRK () at m_syscall.c:239 239 } (gdb) bt #0 0x00000000580641d2 in do_syscall_WRK () at m_syscall.c:239 #1 0x0000000058064227 in vgPlain_do_syscall (sysno=25, a1=75878400, a2=32768, a3=8192, a4=3, a5=82210816, a6=0, a7=0, a8=0) at m_syscall.c:1215 #2 0x0000000058079fd9 in vgModuleLocal_am_do_relocate_nooverlap_mapping_NO_NOTIFY (old_addr=75878400, old_len=32768, new_addr=82210816, new_len=8192) at m_aspacemgr/aspacemgr-common.c:249 #3 0x0000000058082e73 in vgPlain_am_relocate_nooverlap_client (need_discard=0x1002dadbde "", old_addr=75878400, old_len=32768, new_addr=82210816, new_len=8192) at m_aspacemgr/aspacemgr-linux.c:3726 #4 0x00000000580d18e9 in do_mremap (old_addr=75878400, old_len=32768, new_addr=82210816, new_len=8192, flags=3, tid=1) at m_syswrap/syswrap-generic.c:421 #5 0x00000000580d92ef in vgSysWrap_generic_sys_mremap_before (tid=1, layout=0x1002dadd40, arrghs=0x10023a7998, status=0x10023a79e0, flags=0x10023a79f8) at m_syswrap/syswrap-generic.c:3169 #6 0x00000000580cf6ca in vgPlain_client_syscall (tid=1, trc=73) at m_syswrap/syswrap-main.c:2400 #7 0x00000000580c9f59 in handle_syscall (tid=1, trc=73) at m_scheduler/scheduler.c:1214 #8 0x00000000580cade2 in vgPlain_scheduler (tid=1) at m_scheduler/scheduler.c:1588 #9 0x0000000058192061 in thread_wrapper (tidW=1) at m_syswrap/syswrap-linux.c:102 #10 0x00000000581921f1 in run_a_thread_NORETURN (tidW=1) at m_syswrap/syswrap-linux.c:154 #11 0x0000000000000000 in ?? () it just fails in the kernel (with rc=1) and that is propagated via vgModuleLocal_am_do_relocate_nooverlap_mapping_NO_NOTIFY() and vgPlain_am_relocate_nooverlap_client() up to do_mremap() where this patch tweaks the error code. So, maybe the right thing would be to add a flag like isSealed to the NSegment struct and take it from there? > What about the other place am_relocate_nooverlap_client is called? Is the > ENOMEM failure there OK? I think the block around the other call site isn't affected by the current patch and should be fine. The testsuite doesn't complain. -- You are receiving this mail because: You are watching all bug changes.
