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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1432854511-33320-13-git-send-email-riandrews@android.com>
Date:	Thu, 28 May 2015 16:08:30 -0700
From:	Riley Andrews <riandrews@...roid.com>
To:	linux-kernel@...r.kernel.org,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Arve Hjønnevåg <arve@...roid.com>,
	Riley Andrews <riandrews@...roid.com>,
	devel@...verdev.osuosl.org
Subject: [PATCH 12/13] android: binder: add function to pass thread errors to userspace

Add a dedicated function for handling errors.

Signed-off-by: Riley Andrews <riandrews@...roid.com>
---
 drivers/android/binder.c | 51 ++++++++++++++++++++++++++++++++----------------
 1 file changed, 34 insertions(+), 17 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index c98436c..a3129d4 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2593,6 +2593,35 @@ static int binder_wait_for_work(struct binder_thread *thread, int non_block,
 	return ret;
 }
 
+static int binder_handle_thread_error(struct binder_thread *thread,
+				      void * __user *ptr, void __user *end)
+{
+	struct binder_proc *proc = thread->proc;
+
+	if (*ptr == end)
+		return 0;
+
+	if (thread->return_error2 != BR_OK) {
+		if (put_user(thread->return_error2, (uint32_t __user *)*ptr))
+			return -EFAULT;
+
+		*ptr += sizeof(uint32_t);
+		binder_stat_br(proc, thread, thread->return_error2);
+		thread->return_error2 = BR_OK;
+
+		if (*ptr == end)
+			return 0;
+	}
+
+	if (put_user(thread->return_error, (uint32_t __user *)*ptr))
+		return -EFAULT;
+
+	*ptr += sizeof(uint32_t);
+	binder_stat_br(proc, thread, thread->return_error);
+	thread->return_error = BR_OK;
+	return 0;
+}
+
 static int binder_thread_read(struct binder_proc *proc,
 			      struct binder_thread *thread,
 			      binder_uintptr_t binder_buffer, size_t size,
@@ -2613,23 +2642,11 @@ static int binder_thread_read(struct binder_proc *proc,
 
 retry:
 	wait_for_proc_work = thread->transaction_stack == NULL &&
-				list_empty(&thread->todo);
-
-	if (thread->return_error != BR_OK && ptr < end) {
-		if (thread->return_error2 != BR_OK) {
-			if (put_user(thread->return_error2, (uint32_t __user *)ptr))
-				return -EFAULT;
-			ptr += sizeof(uint32_t);
-			binder_stat_br(proc, thread, thread->return_error2);
-			thread->return_error2 = BR_OK;
-			if (ptr == end)
-				goto done;
-		}
-		if (put_user(thread->return_error, (uint32_t __user *)ptr))
-			return -EFAULT;
-		ptr += sizeof(uint32_t);
-		binder_stat_br(proc, thread, thread->return_error);
-		thread->return_error = BR_OK;
+			     list_empty(&thread->todo);
+	if (thread->return_error != BR_OK) {
+		ret =  binder_handle_thread_error(thread, &ptr, end);
+		if (ret < 0)
+			return ret;
 		goto done;
 	}
 
-- 
2.2.0.rc0.207.ga3a616c

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ