[FIX] Preload: use caller address from userspace 21/44421/5
authorVitaliy Cherepanov <v.cherepanov@samsung.com>
Tue, 21 Jul 2015 14:45:09 +0000 (17:45 +0300)
committerVasiliy Ulyanov <v.ulyanov@samsung.com>
Tue, 21 Jul 2015 17:43:28 +0000 (20:43 +0300)
This is a workaround for Tizen OpenGL probes. We cannot obtain the
expected caller address (i.e. the address in the target binary) from
kernel handlers because GL functions are actually called through
third-party libraries. To handle this situation we now pass the proper
address from userspace handlers.

Change-Id: Ibaa2190aed0c1587fa121feb13536b8ff267e680
Signed-off-by: Vitaliy Cherepanov <v.cherepanov@samsung.com>
preload/preload_module.c

index 8895ec8..87575f8 100644 (file)
@@ -758,6 +758,7 @@ static int write_msg_handler(struct kprobe *p, struct pt_regs *regs)
        size_t len;
        unsigned long caller_offset;
        unsigned long call_type_offset;
+       unsigned long caller_addr;
        bool drop;
        int ret;
 
@@ -765,6 +766,7 @@ static int write_msg_handler(struct kprobe *p, struct pt_regs *regs)
        len = swap_get_uarg(regs, 1);
        call_type_p = (char *)swap_get_uarg(regs, 2);
        caller_p = (char *)swap_get_uarg(regs, 3);
+       caller_addr = swap_get_uarg(regs, 4);
 
        ret = __msg_sanitization(user_buf, len, call_type_p, caller_p);
        if (ret != 0) {
@@ -796,6 +798,10 @@ static int write_msg_handler(struct kprobe *p, struct pt_regs *regs)
 
        __write_data_to_msg(buf, len, call_type_offset, caller_offset);
 
+       /* FIXME refactor this hack for opengl tizen probes */
+       if (caller_addr)
+               *(uintptr_t *)(buf + caller_offset) = (uintptr_t)caller_addr;
+
        ret = swap_msg_raw(buf, len);
        if (ret != len)
                printk(PRELOAD_PREFIX "Error writing probe lib message\n");