https://bugs.kde.org/show_bug.cgi?id=505228

Mark Wielaard <m...@klomp.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |m...@klomp.org

--- Comment #3 from Mark Wielaard <m...@klomp.org> ---
Looks good in general, if the program uses mseal on their own address blocks
that should in general be harmless for valgrind since we don't want to unmmap
or mprotect normal pages after the program has. But the current check is wrong
imho:

+PRE(sys_mseal)
+{
+    /* int mseal(void *addr, size_t len, unsigned long flags) */
+    PRINT("sys_mseal ( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %#" FMT_REGWORD
"x, )", ARG1, ARG2, ARG3);
+    PRE_REG_READ3(int, "mseal", void *, addr,  vki_size_t, len, int, flags);
+    if (ARG1 != 0) {
+        PRE_MEM_READ( "mseal (addr)", ARG1, ARG2 ); 
+    }
+}

First, is 0/NULL really special?
Second, PRE_MEM_READ checks if all memory given to the kernel is addressable
and defined.
But I think it doesn't really have to be defined. It does however have to be
addresses the program itself manages, not valgrind memory.
So instead I think the check should be something like:

   if (!ML_(valid_client_addr)(ARG1, ARG2, tid, "mseal"))
      SET_STATUS_Failure(VKI_ENOMEM);

So the syscall fails early if it isn't program memory.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to