Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753861AbbEBTNP (ORCPT ); Sat, 2 May 2015 15:13:15 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44605 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752215AbbEBTNG (ORCPT ); Sat, 2 May 2015 15:13:06 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alistair Strachan , Maarten Lankhorst , Colin Cross Subject: [PATCH 4.0 045/220] staging: android: sync: Fix memory corruption in sync_timeline_signal(). Date: Sat, 2 May 2015 20:59:20 +0200 Message-Id: <20150502185856.319293129@linuxfoundation.org> X-Mailer: git-send-email 2.3.7 In-Reply-To: <20150502185854.333748961@linuxfoundation.org> References: <20150502185854.333748961@linuxfoundation.org> User-Agent: quilt/0.64 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1954 Lines: 51 4.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alistair Strachan commit 8e43c9c75faf2902955bd2ecd7a50a8cc41cb00a upstream. 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 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/sync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -114,7 +114,7 @@ void sync_timeline_signal(struct sync_ti 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); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/