lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220517175225.65283-1-schspa@gmail.com>
Date:   Wed, 18 May 2022 01:52:25 +0800
From:   Schspa Shi <schspa@...il.com>
To:     gregkh@...uxfoundation.org, arve@...roid.com, tkjos@...roid.com,
        maco@...roid.com, joel@...lfernandes.org, brauner@...nel.org,
        hridya@...gle.com, surenb@...gle.com, cmllamas@...gle.com
Cc:     linux-kernel@...r.kernel.org, schspa@...il.com,
        syzbot+46fff6434a7f968ecb39@...kaller.appspotmail.com
Subject: [PATCH] binder: fix atomic sleep when get extended error

binder_inner_proc_lock(thread->proc) is a spin lock, copy_to_user can't
be called with in this lock.

Copy it as a local variable, and check the id to make sure the user space
gets the latest error message

Reported-by: syzbot+46fff6434a7f968ecb39@...kaller.appspotmail.com
Fixes: bd32889e841c ("binder: add BINDER_GET_EXTENDED_ERROR ioctl")
Signed-off-by: Schspa Shi <schspa@...il.com>
---
 drivers/android/binder.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index d9253b2a7bd9..5f2e1fa3da74 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -5163,13 +5163,20 @@ static int binder_ioctl_get_extended_error(struct binder_thread *thread,
 					   void __user *ubuf)
 {
 	struct binder_extended_error *ee = &thread->ee;
+	struct binder_extended_error eeb;
 
 	binder_inner_proc_lock(thread->proc);
-	if (copy_to_user(ubuf, ee, sizeof(*ee))) {
-		binder_inner_proc_unlock(thread->proc);
+retry:
+	eeb = *ee;
+	binder_inner_proc_unlock(thread->proc);
+	if (copy_to_user(ubuf, &eeb, sizeof(eeb)))
 		return -EFAULT;
-	}
 
+	binder_inner_proc_lock(thread->proc);
+	if (eeb.id != ee->id) {
+		/* retry to get newest error info */
+		goto retry;
+	}
 	ee->id = 0;
 	ee->command = BR_OK;
 	ee->param = 0;
-- 
2.24.3 (Apple Git-128)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ