From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2AC012B6C for ; Sat, 9 Dec 2023 11:42:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="v25XDNS3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDD4BC433C7; Sat, 9 Dec 2023 11:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1702122122; bh=CFfoXxwmKEOrqcE5cKBtFLqsco6aPEU/2TJ0Ib6iijo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=v25XDNS3SZ9t5zjGC+NHfZTR5rUnp74LNAxBqAfxJe8X4Nh96m9VT5mT1vIVNBGSP s5XzF9WM0rbW1RXEHdmNDHBBuPcbrVHi6VdnRF2zVCMAjQ62TW7uI0AaHjsormb3HJ rWTzrb0/wwaZ0sZY4GKXWXKsVEFNTBecmPbAE/gc= Date: Sat, 9 Dec 2023 12:41:59 +0100 From: Greg Kroah-Hartman To: Sasha Levin Cc: Carlos Llamas , stable@vger.kernel.org, syzbot+7f10c1653e35933c0f1e@syzkaller.appspotmail.com, Alice Ryhl , Todd Kjos Subject: Re: [PATCH 6.1] binder: fix memory leaks of spam and pending work Message-ID: <2023120940-quotation-reenter-bf58@gregkh> References: <20231208034923.998315-1-cmllamas@google.com> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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: > > [] kmalloc_trace+0x25/0x90 mm/slab_common.c:1114 > > [] kmalloc include/linux/slab.h:599 [inline] > > [] kzalloc include/linux/slab.h:720 [inline] > > [] binder_transaction+0x573/0x4050 drivers/android/binder.c:3152 > > [] binder_thread_write+0x6b5/0x1860 drivers/android/binder.c:4010 > > [] binder_ioctl_write_read drivers/android/binder.c:5066 [inline] > > [] binder_ioctl+0x1b2c/0x3cf0 drivers/android/binder.c:5352 > > [] vfs_ioctl fs/ioctl.c:51 [inline] > > [] __do_sys_ioctl fs/ioctl.c:871 [inline] > > [] __se_sys_ioctl fs/ioctl.c:857 [inline] > > [] __x64_sys_ioctl+0xf2/0x140 fs/ioctl.c:857 > > [] do_syscall_x64 arch/x86/entry/common.c:50 [inline] > > [] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 > > [] 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 > > Signed-off-by: Carlos Llamas > > Reviewed-by: Alice Ryhl > > Acked-by: Todd Kjos > > Link: https://lore.kernel.org/r/20230922175138.230331-1-cmllamas@google.com > > Signed-off-by: Greg Kroah-Hartman > > [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