linux/drivers/android
Mukesh Ojha 2c10a20f5e binder_alloc: Fix sleeping function called from invalid context
36c55ce870 ("binder_alloc: Replace kcalloc with kvcalloc to
mitigate OOM issues") introduced schedule while atomic issue.

[ 2689.152635][ T4275] BUG: sleeping function called from invalid context at mm/vmalloc.c:2847
[ 2689.161291][ T4275] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 4275, name: kworker/1:140
[ 2689.170708][ T4275] preempt_count: 1, expected: 0
[ 2689.175572][ T4275] RCU nest depth: 0, expected: 0
[ 2689.180521][ T4275] INFO: lockdep is turned off.
[ 2689.180523][ T4275] Preemption disabled at:
[ 2689.180525][ T4275] [<ffffffe031f2a2dc>] binder_alloc_deferred_release+0x2c/0x388
..
..
[ 2689.213419][ T4275]  __might_resched+0x174/0x178
[ 2689.213423][ T4275]  __might_sleep+0x48/0x7c
[ 2689.213426][ T4275]  vfree+0x4c/0x15c
[ 2689.213430][ T4275]  kvfree+0x24/0x44
[ 2689.213433][ T4275]  binder_alloc_deferred_release+0x2c0/0x388
[ 2689.213436][ T4275]  binder_proc_dec_tmpref+0x15c/0x2a8
[ 2689.213440][ T4275]  binder_deferred_func+0xa8/0x8ec
[ 2689.213442][ T4275]  process_one_work+0x254/0x59c
[ 2689.213447][ T4275]  worker_thread+0x274/0x3ec
[ 2689.213450][ T4275]  kthread+0x110/0x134
[ 2689.213453][ T4275]  ret_from_fork+0x10/0x20

Fix it by moving the place of kvfree outside of spinlock context.

Fixes: 36c55ce870 ("binder_alloc: Replace kcalloc with kvcalloc to mitigate OOM issues")
Acked-by: Carlos Llamas <cmllamas@google.com>
Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
Link: https://lore.kernel.org/r/20240725062510.2856662-1-quic_mojha@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-07-31 13:48:25 +02:00
..
binder_alloc_selftest.c android: binder: fix a kernel-doc enum warning 2023-12-06 08:48:26 +09:00
binder_alloc.c binder_alloc: Fix sleeping function called from invalid context 2024-07-31 13:48:25 +02:00
binder_alloc.h binder: switch alloc->mutex to spinlock_t 2023-12-05 09:23:41 +09:00
binder_internal.h binder: use bitmap for faster descriptor lookup 2024-07-03 16:21:59 +02:00
binder_trace.h binder: keep vma addresses type as unsigned long 2023-12-05 09:23:38 +09:00
binder.c binder: fix descriptor lookup for context manager 2024-07-31 13:47:48 +02:00
binderfs.c android: removed duplicate linux/errno 2024-01-07 09:48:26 +01:00
dbitmap.h binder: fix descriptor lookup for context manager 2024-07-31 13:47:48 +02:00
Kconfig remove CONFIG_ANDROID 2022-07-01 10:41:09 +02:00
Makefile