]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
binder: use buffer offsets in debug logs
authorTiffany Y. Yang <ynaffit@google.com>
Tue, 1 Apr 2025 20:28:46 +0000 (20:28 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 15 Apr 2025 14:14:49 +0000 (16:14 +0200)
Identify buffer addresses using vma offsets instead of full user
addresses in debug logs or drop them if they are not useful.

Signed-off-by: Tiffany Y. Yang <ynaffit@google.com>
Acked-by: Carlos Llamas <cmllamas@google.com>
Reviewed-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/20250401202846.3510162-2-ynaffit@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/android/binder.c

index 76052006bd8714b03aa0eeccb01f31cc155c5180..9f215391ac7ab20e3e56e66093d88ad6bc7cd4b6 100644 (file)
@@ -3261,20 +3261,16 @@ static void binder_transaction(struct binder_proc *proc,
 
        if (reply)
                binder_debug(BINDER_DEBUG_TRANSACTION,
-                            "%d:%d BC_REPLY %d -> %d:%d, data %016llx-%016llx size %lld-%lld-%lld\n",
+                            "%d:%d BC_REPLY %d -> %d:%d, data size %lld-%lld-%lld\n",
                             proc->pid, thread->pid, t->debug_id,
                             target_proc->pid, target_thread->pid,
-                            (u64)tr->data.ptr.buffer,
-                            (u64)tr->data.ptr.offsets,
                             (u64)tr->data_size, (u64)tr->offsets_size,
                             (u64)extra_buffers_size);
        else
                binder_debug(BINDER_DEBUG_TRANSACTION,
-                            "%d:%d BC_TRANSACTION %d -> %d - node %d, data %016llx-%016llx size %lld-%lld-%lld\n",
+                            "%d:%d BC_TRANSACTION %d -> %d - node %d, data size %lld-%lld-%lld\n",
                             proc->pid, thread->pid, t->debug_id,
                             target_proc->pid, target_node->debug_id,
-                            (u64)tr->data.ptr.buffer,
-                            (u64)tr->data.ptr.offsets,
                             (u64)tr->data_size, (u64)tr->offsets_size,
                             (u64)extra_buffers_size);
 
@@ -4223,20 +4219,21 @@ static int binder_thread_write(struct binder_proc *proc,
                        if (IS_ERR_OR_NULL(buffer)) {
                                if (PTR_ERR(buffer) == -EPERM) {
                                        binder_user_error(
-                                               "%d:%d BC_FREE_BUFFER u%016llx matched unreturned or currently freeing buffer\n",
+                                               "%d:%d BC_FREE_BUFFER matched unreturned or currently freeing buffer at offset %lx\n",
                                                proc->pid, thread->pid,
-                                               (u64)data_ptr);
+                                               (unsigned long)data_ptr - proc->alloc.vm_start);
                                } else {
                                        binder_user_error(
-                                               "%d:%d BC_FREE_BUFFER u%016llx no match\n",
+                                               "%d:%d BC_FREE_BUFFER no match for buffer at offset %lx\n",
                                                proc->pid, thread->pid,
-                                               (u64)data_ptr);
+                                               (unsigned long)data_ptr - proc->alloc.vm_start);
                                }
                                break;
                        }
                        binder_debug(BINDER_DEBUG_FREE_BUFFER,
-                                    "%d:%d BC_FREE_BUFFER u%016llx found buffer %d for %s transaction\n",
-                                    proc->pid, thread->pid, (u64)data_ptr,
+                                    "%d:%d BC_FREE_BUFFER at offset %lx found buffer %d for %s transaction\n",
+                                    proc->pid, thread->pid,
+                                    (unsigned long)data_ptr - proc->alloc.vm_start,
                                     buffer->debug_id,
                                     buffer->transaction ? "active" : "finished");
                        binder_free_buf(proc, thread, buffer, false);
@@ -5053,16 +5050,14 @@ retry:
                trace_binder_transaction_received(t);
                binder_stat_br(proc, thread, cmd);
                binder_debug(BINDER_DEBUG_TRANSACTION,
-                            "%d:%d %s %d %d:%d, cmd %u size %zd-%zd ptr %016llx-%016llx\n",
+                            "%d:%d %s %d %d:%d, cmd %u size %zd-%zd\n",
                             proc->pid, thread->pid,
                             (cmd == BR_TRANSACTION) ? "BR_TRANSACTION" :
                                (cmd == BR_TRANSACTION_SEC_CTX) ?
                                     "BR_TRANSACTION_SEC_CTX" : "BR_REPLY",
                             t->debug_id, t_from ? t_from->proc->pid : 0,
                             t_from ? t_from->pid : 0, cmd,
-                            t->buffer->data_size, t->buffer->offsets_size,
-                            (u64)trd->data.ptr.buffer,
-                            (u64)trd->data.ptr.offsets);
+                            t->buffer->data_size, t->buffer->offsets_size);
 
                if (t_from)
                        binder_thread_dec_tmpref(t_from);