Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754467AbcKYJJM (ORCPT ); Fri, 25 Nov 2016 04:09:12 -0500 Received: from mx2.suse.de ([195.135.220.15]:45217 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751522AbcKYIax (ORCPT ); Fri, 25 Nov 2016 03:30:53 -0500 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" From: Jiri Slaby To: stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Martijn Coenen , Jiri Slaby Subject: [PATCH 3.12 015/127] ANDROID: binder: Clear binder and cookie when setting handle in flat binder struct Date: Fri, 25 Nov 2016 09:28:48 +0100 Message-Id: X-Mailer: git-send-email 2.10.2 In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1662 Lines: 51 From: Arve Hjønnevåg 3.12-stable review patch. If anyone has any objections, please let me know. =============== commit 4afb604e2d14d429ac9e1fd84b952602853b2df5 upstream. Prevents leaking pointers between processes Signed-off-by: Arve Hjønnevåg Signed-off-by: Martijn Coenen Signed-off-by: Jiri Slaby --- drivers/staging/android/binder.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c index 8a436dae9b77..a29a383d160d 100644 --- a/drivers/staging/android/binder.c +++ b/drivers/staging/android/binder.c @@ -1541,7 +1541,9 @@ static void binder_transaction(struct binder_proc *proc, fp->type = BINDER_TYPE_HANDLE; else fp->type = BINDER_TYPE_WEAK_HANDLE; + fp->binder = NULL; fp->handle = ref->desc; + fp->cookie = NULL; binder_inc_ref(ref, fp->type == BINDER_TYPE_HANDLE, &thread->todo); @@ -1584,7 +1586,9 @@ static void binder_transaction(struct binder_proc *proc, return_error = BR_FAILED_REPLY; goto err_binder_get_ref_for_node_failed; } + fp->binder = NULL; fp->handle = new_ref->desc; + fp->cookie = NULL; binder_inc_ref(new_ref, fp->type == BINDER_TYPE_HANDLE, NULL); trace_binder_transaction_ref_to_ref(t, ref, new_ref); @@ -1631,6 +1635,7 @@ static void binder_transaction(struct binder_proc *proc, binder_debug(BINDER_DEBUG_TRANSACTION, " fd %d -> %d\n", fp->handle, target_fd); /* TODO: fput? */ + fp->binder = NULL; fp->handle = target_fd; } break; -- 2.10.2