Skip to content

Commit 162c797

Browse files
Carlos Llamasgregkh
authored andcommitted
binder: avoid user addresses in debug logs
Prefer logging vma offsets instead of addresses or simply drop the debug log altogether if not useful. Note this covers the instances affected by the switch to store addresses as unsigned long. However, there are other sections in the driver that could do the same. Signed-off-by: Carlos Llamas <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f07b83a commit 162c797

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

drivers/android/binder.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5980,9 +5980,9 @@ static void print_binder_transaction_ilocked(struct seq_file *m,
59805980
}
59815981
if (buffer->target_node)
59825982
seq_printf(m, " node %d", buffer->target_node->debug_id);
5983-
seq_printf(m, " size %zd:%zd data %lx\n",
5983+
seq_printf(m, " size %zd:%zd offset %lx\n",
59845984
buffer->data_size, buffer->offsets_size,
5985-
buffer->user_data);
5985+
proc->alloc.buffer - buffer->user_data);
59865986
}
59875987

59885988
static void print_binder_work_ilocked(struct seq_file *m,

drivers/android/binder_alloc.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ static int binder_install_single_page(struct binder_alloc *alloc,
250250

251251
ret = vm_insert_page(alloc->vma, addr, page);
252252
if (ret) {
253-
pr_err("%d: %s failed to insert page at %lx with %d\n",
254-
alloc->pid, __func__, addr, ret);
253+
pr_err("%d: %s failed to insert page at offset %lx with %d\n",
254+
alloc->pid, __func__, addr - alloc->buffer, ret);
255255
__free_page(page);
256256
ret = -ENOMEM;
257257
goto out;
@@ -305,10 +305,6 @@ static void binder_lru_freelist_del(struct binder_alloc *alloc,
305305
struct binder_lru_page *page;
306306
unsigned long page_addr;
307307

308-
binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,
309-
"%d: pages %lx-%lx\n",
310-
alloc->pid, start, end);
311-
312308
trace_binder_update_page_range(alloc, true, start, end);
313309

314310
for (page_addr = start; page_addr < end; page_addr += PAGE_SIZE) {
@@ -939,8 +935,8 @@ void binder_alloc_deferred_release(struct binder_alloc *alloc)
939935
&alloc->pages[i].lru);
940936
page_addr = alloc->buffer + i * PAGE_SIZE;
941937
binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,
942-
"%s: %d: page %d at %lx %s\n",
943-
__func__, alloc->pid, i, page_addr,
938+
"%s: %d: page %d %s\n",
939+
__func__, alloc->pid, i,
944940
on_lru ? "on lru" : "active");
945941
__free_page(alloc->pages[i].page_ptr);
946942
page_count++;
@@ -974,7 +970,8 @@ void binder_alloc_print_allocated(struct seq_file *m,
974970
for (n = rb_first(&alloc->allocated_buffers); n; n = rb_next(n)) {
975971
buffer = rb_entry(n, struct binder_buffer, rb_node);
976972
seq_printf(m, " buffer %d: %lx size %zd:%zd:%zd %s\n",
977-
buffer->debug_id, buffer->user_data,
973+
buffer->debug_id,
974+
buffer->user_data - alloc->buffer,
978975
buffer->data_size, buffer->offsets_size,
979976
buffer->extra_buffers_size,
980977
buffer->transaction ? "active" : "delivered");

0 commit comments

Comments
 (0)