From patchwork Tue Oct 27 13:46:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 289761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA423C5517A for ; Tue, 27 Oct 2020 15:23:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9CDF62064B for ; Tue, 27 Oct 2020 15:23:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603812187; bh=jQOhFd0YiHCpqr5i8OVHdq8eT3h7Aw9M5qjwmy2iSio=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=tk4u9gTeFhJHVl2y2OGdKxwqFJ7BM2n+h9dMX5l0ALoIR1YubNmz+nYOQmoi5DKCQ sFU/J34JvwMe1AZXpucxnB9cRC7g9/SnPD7IR8yC5s7N03jvRh2kspgzPlN4xeujge 42HzEccWQcS3slA2sMh2KseUrMV2ucs2FjRHDjVQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1797370AbgJ0PXG (ORCPT ); Tue, 27 Oct 2020 11:23:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:38018 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1797361AbgJ0PXF (ORCPT ); Tue, 27 Oct 2020 11:23:05 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F276F2076D; Tue, 27 Oct 2020 15:23:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603812184; bh=jQOhFd0YiHCpqr5i8OVHdq8eT3h7Aw9M5qjwmy2iSio=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aMak1tSZdr2Zb7fEVHInrJEAPAeO21xdE/ImeoCNR3oTDfua3MX/d0HGAQGYIQznD MsozLJ3y0l1hZoZ85iMt1xVzflI1oJ6uhFR7o3dK0z6wdVm2+oDB1bh+JtfMEckvgn h/Rl6KpGIDxUUzn7gTHq5DajFvy2C8MH/NfN8YKU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Madhuparna Bhowmik , Jamie Iles , Herbert Xu , Sasha Levin Subject: [PATCH 5.9 122/757] crypto: picoxcell - Fix potential race condition bug Date: Tue, 27 Oct 2020 14:46:12 +0100 Message-Id: <20201027135456.298440440@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135450.497324313@linuxfoundation.org> References: <20201027135450.497324313@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Madhuparna Bhowmik [ Upstream commit 64f4a62e3b17f1e473f971127c2924cae42afc82 ] engine->stat_irq_thresh was initialized after device_create_file() in the probe function, the initialization may race with call to spacc_stat_irq_thresh_store() which updates engine->stat_irq_thresh, therefore initialize it before creating the file in probe function. Found by Linux Driver Verification project (linuxtesting.org). Fixes: ce92136843cb ("crypto: picoxcell - add support for the...") Signed-off-by: Madhuparna Bhowmik Acked-by: Jamie Iles Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/picoxcell_crypto.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/picoxcell_crypto.c b/drivers/crypto/picoxcell_crypto.c index dac6eb37fff93..fb34bf92861d1 100644 --- a/drivers/crypto/picoxcell_crypto.c +++ b/drivers/crypto/picoxcell_crypto.c @@ -1685,11 +1685,6 @@ static int spacc_probe(struct platform_device *pdev) goto err_clk_put; } - ret = device_create_file(&pdev->dev, &dev_attr_stat_irq_thresh); - if (ret) - goto err_clk_disable; - - /* * Use an IRQ threshold of 50% as a default. This seems to be a * reasonable trade off of latency against throughput but can be @@ -1697,6 +1692,10 @@ static int spacc_probe(struct platform_device *pdev) */ engine->stat_irq_thresh = (engine->fifo_sz / 2); + ret = device_create_file(&pdev->dev, &dev_attr_stat_irq_thresh); + if (ret) + goto err_clk_disable; + /* * Configure the interrupts. We only use the STAT_CNT interrupt as we * only submit a new packet for processing when we complete another in