Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3573326pxb; Mon, 24 Jan 2022 12:32:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzA0oPXTj/+WXg6bk0aCXs60tLwnqls1BEnjocDtXFJNMDqMa3ke/bIikdSkrKMCA5EI2aV X-Received: by 2002:a17:90a:2ec4:: with SMTP id h4mr46713pjs.173.1643056278623; Mon, 24 Jan 2022 12:31:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643056278; cv=none; d=google.com; s=arc-20160816; b=uC9nEyizIkx3jObWqEJfftWtNzNxfTpzrquXLyHAWGMaM52XAETFqbiYG/tzUUBJWj jg8uOQmkScK3s0/Hnb54MJsPEdgr4uG11hIsLX9iVlBFg1jC410TWvd0TgHYS4GsSL2W FsGJjlY5ntsiGWNfVmwAyI+fLi5aOX1AAWVL9xqChvxKLjmqwQ/vhGJouWOodKVSi+p2 Oi27WOwS9JhKUsp9vxi5+iheh+Z5uCu+mGJnky6Ph5Ui2ONlgayNUckgN9AYij1UNFMg xbnhJzu7gvkHmKtzemrDUMN5rNSBc8vCuRlsB/hhisSYs3fodF5GJwHozefapS0I0xJ4 /f7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vH+u7KMVl6FPfYhEqZTLPOmf99p6QwHQxmYKD5Uql+E=; b=GV6VMMYIpOYLcGSQBErZkR02RLbGDjDZGAUv4x/Nh8weYq45VQHZ7rt3H5n+d7PG3O quRJaFlEJCulE7wmrsT+5B7vn1FFE9HLoKwTOgSaFtK8Y3DOjbEG+pJaKmd0aqAjaWL+ jnevQiN5q5SJaqsAjBrj8mZSpsSr8/gvjUZXRj9xUdhECCWPa6KPbspUm+3X81F+/Csn 0I0rtBoQLcIodGURvT5tb0PgtBVwFNBGTXb2PKfDq3AtOWttE6be8briu1Jd6bhACEE7 SJ61x6XrlnQApRmbB+fQLxCvHuGvLPW2Jmf6c65ERx3t0deES3pYrv+zOT6C9HAulLDK ywUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uwjxEx33; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d11si14551578pgg.106.2022.01.24.12.31.03; Mon, 24 Jan 2022 12:31:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uwjxEx33; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353647AbiAXTfH (ORCPT + 99 others); Mon, 24 Jan 2022 14:35:07 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:50512 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348040AbiAXT1N (ORCPT ); Mon, 24 Jan 2022 14:27:13 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id F0C9FB8122C; Mon, 24 Jan 2022 19:27:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12A7FC340E7; Mon, 24 Jan 2022 19:27:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643052425; bh=N7iqN2dtcEyo4qkf5F6uhGxw3W2pDTN7WGAfMlTzNYY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uwjxEx33cAJEo04u3CviaqKIkkt/EeUeWYu/1EKatk4nX10lJR5Tse7yr06AMzKkc mo+vGraQvEIbHUDTLnz01EL58NFJZegSs1g0e5v1wtXKFygYxkOSUWzLLBS+IV6p0p V339z8RN/lXTyk/NHwul0hYIAI+PHU5z1N+qyAXE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Wilson , Sumit Semwal , Gustavo Padovan , =?UTF-8?q?Christian=20K=C3=B6nig?= , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= Subject: [PATCH 5.4 027/320] dma_fence_array: Fix PENDING_ERROR leak in dma_fence_array_signaled() Date: Mon, 24 Jan 2022 19:40:11 +0100 Message-Id: <20220124183954.683526569@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183953.750177707@linuxfoundation.org> References: <20220124183953.750177707@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Hellström commit 95d35838880fb040ccb9fe4a48816bd0c8b62df5 upstream. If a dma_fence_array is reported signaled by a call to dma_fence_is_signaled(), it may leak the PENDING_ERROR status. Fix this by clearing the PENDING_ERROR status if we return true in dma_fence_array_signaled(). v2: - Update Cc list, and add R-b. Fixes: 1f70b8b812f3 ("dma-fence: Propagate errors to dma-fence-array container") Cc: Chris Wilson Cc: Sumit Semwal Cc: Gustavo Padovan Cc: Christian König Cc: "Christian König" Cc: linux-media@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linaro-mm-sig@lists.linaro.org Cc: # v5.4+ Signed-off-by: Thomas Hellström Reviewed-by: Christian König Link: https://patchwork.freedesktop.org/patch/msgid/20211129152727.448908-1-thomas.hellstrom@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/dma-buf/dma-fence-array.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/drivers/dma-buf/dma-fence-array.c +++ b/drivers/dma-buf/dma-fence-array.c @@ -104,7 +104,11 @@ static bool dma_fence_array_signaled(str { struct dma_fence_array *array = to_dma_fence_array(fence); - return atomic_read(&array->num_pending) <= 0; + if (atomic_read(&array->num_pending) > 0) + return false; + + dma_fence_array_clear_pending_error(array); + return true; } static void dma_fence_array_release(struct dma_fence *fence)