From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from aserp1040.oracle.com ([141.146.126.69]:29832 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754087AbbEKL0a (ORCPT ); Mon, 11 May 2015 07:26:30 -0400 From: Sasha Levin To: stable@vger.kernel.org, stable-commits@vger.kernel.org Cc: Alistair Strachan , Maarten Lankhorst , Greg Kroah-Hartman , Colin Cross , Sasha Levin Subject: [added to the 3.18 stable tree] staging: android: sync: Fix memory corruption in sync_timeline_signal(). Date: Mon, 11 May 2015 07:17:18 -0400 Message-Id: <1431343152-19437-57-git-send-email-sasha.levin@oracle.com> In-Reply-To: <1431343152-19437-1-git-send-email-sasha.levin@oracle.com> References: <1431343152-19437-1-git-send-email-sasha.levin@oracle.com> Sender: stable-owner@vger.kernel.org List-ID: From: Alistair Strachan This patch has been added to the 3.18 stable tree. If you have any objections, please let us know. =============== [ Upstream commit 8e43c9c75faf2902955bd2ecd7a50a8cc41cb00a ] The android_fence_release() function checks for active sync points by calling list_empty() on the list head embedded on the sync point. However, it is only valid to use list_empty() on nodes that have been initialized with INIT_LIST_HEAD() or list_del_init(). Because the list entry has likely been removed from the active list by sync_timeline_signal(), there is a good chance that this WARN_ON_ONCE() will be hit due to dangling pointers pointing at freed memory (even though the sync drivers did nothing wrong) and memory corruption will ensue as the list entry is removed for a second time, corrupting the active list. This problem can be reproduced quite easily with CONFIG_DEBUG_LIST=y and fences with more than one sync point. Signed-off-by: Alistair Strachan Cc: Maarten Lankhorst Cc: Greg Kroah-Hartman Cc: Colin Cross Cc: stable Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/staging/android/sync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index 7bdb62b..f83e00c 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -114,7 +114,7 @@ void sync_timeline_signal(struct sync_timeline *obj) list_for_each_entry_safe(pt, next, &obj->active_list_head, active_list) { if (fence_is_signaled_locked(&pt->base)) - list_del(&pt->active_list); + list_del_init(&pt->active_list); } spin_unlock_irqrestore(&obj->child_list_lock, flags); -- 2.1.0