* [PATCH 6.1] binder: fix memory leaks of spam and pending work
@ 2023-12-08 3:49 Carlos Llamas
2023-12-09 7:09 ` Sasha Levin
0 siblings, 1 reply; 3+ messages in thread
From: Carlos Llamas @ 2023-12-08 3:49 UTC (permalink / raw)
To: stable
Cc: Carlos Llamas, syzbot+7f10c1653e35933c0f1e, Alice Ryhl, Todd Kjos,
Greg Kroah-Hartman
commit 1aa3aaf8953c84bad398adf6c3cabc9d6685bf7d upstream
A transaction complete work is allocated and queued for each
transaction. Under certain conditions the work->type might be marked as
BINDER_WORK_TRANSACTION_ONEWAY_SPAM_SUSPECT to notify userspace about
potential spamming threads or as BINDER_WORK_TRANSACTION_PENDING when
the target is currently frozen.
However, these work types are not being handled in binder_release_work()
so they will leak during a cleanup. This was reported by syzkaller with
the following kmemleak dump:
BUG: memory leak
unreferenced object 0xffff88810e2d6de0 (size 32):
comm "syz-executor338", pid 5046, jiffies 4294968230 (age 13.590s)
hex dump (first 32 bytes):
e0 6d 2d 0e 81 88 ff ff e0 6d 2d 0e 81 88 ff ff .m-......m-.....
04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff81573b75>] kmalloc_trace+0x25/0x90 mm/slab_common.c:1114
[<ffffffff83d41873>] kmalloc include/linux/slab.h:599 [inline]
[<ffffffff83d41873>] kzalloc include/linux/slab.h:720 [inline]
[<ffffffff83d41873>] binder_transaction+0x573/0x4050 drivers/android/binder.c:3152
[<ffffffff83d45a05>] binder_thread_write+0x6b5/0x1860 drivers/android/binder.c:4010
[<ffffffff83d486dc>] binder_ioctl_write_read drivers/android/binder.c:5066 [inline]
[<ffffffff83d486dc>] binder_ioctl+0x1b2c/0x3cf0 drivers/android/binder.c:5352
[<ffffffff816b25f2>] vfs_ioctl fs/ioctl.c:51 [inline]
[<ffffffff816b25f2>] __do_sys_ioctl fs/ioctl.c:871 [inline]
[<ffffffff816b25f2>] __se_sys_ioctl fs/ioctl.c:857 [inline]
[<ffffffff816b25f2>] __x64_sys_ioctl+0xf2/0x140 fs/ioctl.c:857
[<ffffffff84b30008>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
[<ffffffff84b30008>] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
[<ffffffff84c0008b>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
Fix the leaks by kfreeing these work types in binder_release_work() and
handle them as a BINDER_WORK_TRANSACTION_COMPLETE cleanup.
Cc: stable@vger.kernel.org
Fixes: a7dc1e6f99df ("binder: tell userspace to dump current backtrace when detected oneway spamming")
Reported-by: syzbot+7f10c1653e35933c0f1e@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=7f10c1653e35933c0f1e
Suggested-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Carlos Llamas <cmllamas@google.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Acked-by: Todd Kjos <tkjos@google.com>
Link: https://lore.kernel.org/r/20230922175138.230331-1-cmllamas@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[cmllamas: backport to v6.1 by dropping BINDER_WORK_TRANSACTION_PENDING
as commit 0567461a7a6e is not present. Remove fixes tag accordingly.]
Signed-off-by: Carlos Llamas <cmllamas@google.com>
---
drivers/android/binder.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index e4a6da81cd4b..9cc3a2b1b4fc 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -4788,6 +4788,7 @@ static void binder_release_work(struct binder_proc *proc,
"undelivered TRANSACTION_ERROR: %u\n",
e->cmd);
} break;
+ case BINDER_WORK_TRANSACTION_ONEWAY_SPAM_SUSPECT:
case BINDER_WORK_TRANSACTION_COMPLETE: {
binder_debug(BINDER_DEBUG_DEAD_TRANSACTION,
"undelivered TRANSACTION_COMPLETE\n");
base-commit: c6114c845984144944f1abc07c61de219367a4da
--
2.43.0.472.g3155946c3a-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH 6.1] binder: fix memory leaks of spam and pending work
2023-12-08 3:49 [PATCH 6.1] binder: fix memory leaks of spam and pending work Carlos Llamas
@ 2023-12-09 7:09 ` Sasha Levin
2023-12-09 11:41 ` Greg Kroah-Hartman
0 siblings, 1 reply; 3+ messages in thread
From: Sasha Levin @ 2023-12-09 7:09 UTC (permalink / raw)
To: Carlos Llamas
Cc: stable, syzbot+7f10c1653e35933c0f1e, Alice Ryhl, Todd Kjos,
Greg Kroah-Hartman
On Fri, Dec 08, 2023 at 03:49:23AM +0000, Carlos Llamas wrote:
>commit 1aa3aaf8953c84bad398adf6c3cabc9d6685bf7d upstream
>
>A transaction complete work is allocated and queued for each
>transaction. Under certain conditions the work->type might be marked as
>BINDER_WORK_TRANSACTION_ONEWAY_SPAM_SUSPECT to notify userspace about
>potential spamming threads or as BINDER_WORK_TRANSACTION_PENDING when
>the target is currently frozen.
>
>However, these work types are not being handled in binder_release_work()
>so they will leak during a cleanup. This was reported by syzkaller with
>the following kmemleak dump:
>
>BUG: memory leak
>unreferenced object 0xffff88810e2d6de0 (size 32):
> comm "syz-executor338", pid 5046, jiffies 4294968230 (age 13.590s)
> hex dump (first 32 bytes):
> e0 6d 2d 0e 81 88 ff ff e0 6d 2d 0e 81 88 ff ff .m-......m-.....
> 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> backtrace:
> [<ffffffff81573b75>] kmalloc_trace+0x25/0x90 mm/slab_common.c:1114
> [<ffffffff83d41873>] kmalloc include/linux/slab.h:599 [inline]
> [<ffffffff83d41873>] kzalloc include/linux/slab.h:720 [inline]
> [<ffffffff83d41873>] binder_transaction+0x573/0x4050 drivers/android/binder.c:3152
> [<ffffffff83d45a05>] binder_thread_write+0x6b5/0x1860 drivers/android/binder.c:4010
> [<ffffffff83d486dc>] binder_ioctl_write_read drivers/android/binder.c:5066 [inline]
> [<ffffffff83d486dc>] binder_ioctl+0x1b2c/0x3cf0 drivers/android/binder.c:5352
> [<ffffffff816b25f2>] vfs_ioctl fs/ioctl.c:51 [inline]
> [<ffffffff816b25f2>] __do_sys_ioctl fs/ioctl.c:871 [inline]
> [<ffffffff816b25f2>] __se_sys_ioctl fs/ioctl.c:857 [inline]
> [<ffffffff816b25f2>] __x64_sys_ioctl+0xf2/0x140 fs/ioctl.c:857
> [<ffffffff84b30008>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
> [<ffffffff84b30008>] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
> [<ffffffff84c0008b>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
>
>Fix the leaks by kfreeing these work types in binder_release_work() and
>handle them as a BINDER_WORK_TRANSACTION_COMPLETE cleanup.
>
>Cc: stable@vger.kernel.org
>Fixes: a7dc1e6f99df ("binder: tell userspace to dump current backtrace when detected oneway spamming")
>Reported-by: syzbot+7f10c1653e35933c0f1e@syzkaller.appspotmail.com
>Closes: https://syzkaller.appspot.com/bug?extid=7f10c1653e35933c0f1e
>Suggested-by: Alice Ryhl <aliceryhl@google.com>
>Signed-off-by: Carlos Llamas <cmllamas@google.com>
>Reviewed-by: Alice Ryhl <aliceryhl@google.com>
>Acked-by: Todd Kjos <tkjos@google.com>
>Link: https://lore.kernel.org/r/20230922175138.230331-1-cmllamas@google.com
>Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>[cmllamas: backport to v6.1 by dropping BINDER_WORK_TRANSACTION_PENDING
> as commit 0567461a7a6e is not present. Remove fixes tag accordingly.]
Queued up, thanks!
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH 6.1] binder: fix memory leaks of spam and pending work
2023-12-09 7:09 ` Sasha Levin
@ 2023-12-09 11:41 ` Greg Kroah-Hartman
0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2023-12-09 11:41 UTC (permalink / raw)
To: Sasha Levin
Cc: Carlos Llamas, stable, syzbot+7f10c1653e35933c0f1e, Alice Ryhl,
Todd Kjos
On Sat, Dec 09, 2023 at 02:09:18AM -0500, Sasha Levin wrote:
> On Fri, Dec 08, 2023 at 03:49:23AM +0000, Carlos Llamas wrote:
> > commit 1aa3aaf8953c84bad398adf6c3cabc9d6685bf7d upstream
> >
> > A transaction complete work is allocated and queued for each
> > transaction. Under certain conditions the work->type might be marked as
> > BINDER_WORK_TRANSACTION_ONEWAY_SPAM_SUSPECT to notify userspace about
> > potential spamming threads or as BINDER_WORK_TRANSACTION_PENDING when
> > the target is currently frozen.
> >
> > However, these work types are not being handled in binder_release_work()
> > so they will leak during a cleanup. This was reported by syzkaller with
> > the following kmemleak dump:
> >
> > BUG: memory leak
> > unreferenced object 0xffff88810e2d6de0 (size 32):
> > comm "syz-executor338", pid 5046, jiffies 4294968230 (age 13.590s)
> > hex dump (first 32 bytes):
> > e0 6d 2d 0e 81 88 ff ff e0 6d 2d 0e 81 88 ff ff .m-......m-.....
> > 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > backtrace:
> > [<ffffffff81573b75>] kmalloc_trace+0x25/0x90 mm/slab_common.c:1114
> > [<ffffffff83d41873>] kmalloc include/linux/slab.h:599 [inline]
> > [<ffffffff83d41873>] kzalloc include/linux/slab.h:720 [inline]
> > [<ffffffff83d41873>] binder_transaction+0x573/0x4050 drivers/android/binder.c:3152
> > [<ffffffff83d45a05>] binder_thread_write+0x6b5/0x1860 drivers/android/binder.c:4010
> > [<ffffffff83d486dc>] binder_ioctl_write_read drivers/android/binder.c:5066 [inline]
> > [<ffffffff83d486dc>] binder_ioctl+0x1b2c/0x3cf0 drivers/android/binder.c:5352
> > [<ffffffff816b25f2>] vfs_ioctl fs/ioctl.c:51 [inline]
> > [<ffffffff816b25f2>] __do_sys_ioctl fs/ioctl.c:871 [inline]
> > [<ffffffff816b25f2>] __se_sys_ioctl fs/ioctl.c:857 [inline]
> > [<ffffffff816b25f2>] __x64_sys_ioctl+0xf2/0x140 fs/ioctl.c:857
> > [<ffffffff84b30008>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
> > [<ffffffff84b30008>] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
> > [<ffffffff84c0008b>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
> >
> > Fix the leaks by kfreeing these work types in binder_release_work() and
> > handle them as a BINDER_WORK_TRANSACTION_COMPLETE cleanup.
> >
> > Cc: stable@vger.kernel.org
> > Fixes: a7dc1e6f99df ("binder: tell userspace to dump current backtrace when detected oneway spamming")
> > Reported-by: syzbot+7f10c1653e35933c0f1e@syzkaller.appspotmail.com
> > Closes: https://syzkaller.appspot.com/bug?extid=7f10c1653e35933c0f1e
> > Suggested-by: Alice Ryhl <aliceryhl@google.com>
> > Signed-off-by: Carlos Llamas <cmllamas@google.com>
> > Reviewed-by: Alice Ryhl <aliceryhl@google.com>
> > Acked-by: Todd Kjos <tkjos@google.com>
> > Link: https://lore.kernel.org/r/20230922175138.230331-1-cmllamas@google.com
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > [cmllamas: backport to v6.1 by dropping BINDER_WORK_TRANSACTION_PENDING
> > as commit 0567461a7a6e is not present. Remove fixes tag accordingly.]
>
> Queued up, thanks!
Did you not push this out? I don't see this in the queue at the moment.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-09 11:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-08 3:49 [PATCH 6.1] binder: fix memory leaks of spam and pending work Carlos Llamas
2023-12-09 7:09 ` Sasha Levin
2023-12-09 11:41 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox