Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp2571481rwl; Fri, 6 Jan 2023 08:09:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXu8Ka2+xRv19wllPl51kZ40cbHvczrziA84LIUEGNkhP2wJ5Rttw4JqY5Hn5ex+8YzUCB+C X-Received: by 2002:a17:906:700f:b0:7c0:d1cb:2165 with SMTP id n15-20020a170906700f00b007c0d1cb2165mr47931376ejj.56.1673021375368; Fri, 06 Jan 2023 08:09:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673021375; cv=none; d=google.com; s=arc-20160816; b=Hh8HZsIIYtsILQ9js637+A2AlfnQUk0fGb7VKpAmktV1feyTEvM3Faomf1rA+7rJzI JQj/XCUpXyt7uhzZwiMR9GXmHk8dwNXP+Ydp0VzOQqFjGEC3i0hmP7DkRjEpiLMQYKX8 wFD4UZXnwzxyDLZfu44FQvuNUJq+adA3XkK7GlGvGEfapSNsnfzFKgW1rK9Kl/jW3GqV +qWAHwg5qRqITxcV9ChsXJM/oqn9wIK4njYUNiAQxyREa3DFG5Me9B/3IusAojfJzAjs VNvn0zmYodoITdKpHs+ULk5y8iTJpW/A/H54EaDTxnHYroCoR5ZL8LborWu9fV/xEKXX XRhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=mTl96z9SBAuYdOvEwDhzJbe8IZjznPk88XeY7RegjzE=; b=jl+WPIC0+jNdeoiBgJaXje3ZNWdp7Vhaacgxc3q/FrQytXikkeFb6RSO8/nzJp6Pig NIPlTM4ZqM3ESRvsVOqVBiBB83jUITs2xXm1/hkx7oFfaiV3BLoLgs+skT3aCty6l7/v TotrCe0+qayXElCb3k+uulFjFtK5qEar3ze5I63IipMYpr0oUnI5lJGanlEHRBAKeqhz 1Bd05V3g8ZamXsiqvHXkB/rdDVJVVo/pxXPSzLbSwe/+kmzvg0SjvYpUuAlSkONM6Ghw pLwzsmO7cAZ+U9rYZnjFDtTaUDbqSDwRfA6OvDrArFlDEIszvOE+KSatN9A2fAGu5dYm wLIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rf5RCh3G; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w18-20020a05640234d200b00486c1b099d5si2594006edc.3.2023.01.06.08.09.11; Fri, 06 Jan 2023 08:09:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rf5RCh3G; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232580AbjAFQHq (ORCPT + 99 others); Fri, 6 Jan 2023 11:07:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234908AbjAFQHi (ORCPT ); Fri, 6 Jan 2023 11:07:38 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4773C398; Fri, 6 Jan 2023 08:07:38 -0800 (PST) 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 ECEB0B81CDC; Fri, 6 Jan 2023 16:07:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B1C4C433EF; Fri, 6 Jan 2023 16:07:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673021255; bh=fErnzGHXYp7EafkqUofZ+/wlGIMUeDfiUn5oFwF8PJE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rf5RCh3GLjZ44a5+pgObN4yfEQfuca85fWyqwY9CZgECrt2KCA95nL3BPxHrgxUDb +pvfRs8IjM839H91auovz6a/NnMZrvb5vAD+DKt9FJmUSlpznRfBaT1sEccgEjIBEM ZgW078wbxJSJMD9Tg2QBTWP7b46qFeWULbEb4GQRenp5jUCj6qYgdnF1E8Ze0l29ih X8QNZdNZmqep4Jvplq9Wumr2HR+zq+V7ibhRdJdOm1RGbvxYw3UJXqj1XF4VGELt51 HFVjRATppE+eGlYmy5X5D3qJt2KyhOakr39U2a7Q8edvaazsYp3/sB5Q4zvd6/DcDh XfWEI0sSzSYPA== Date: Fri, 6 Jan 2023 09:07:33 -0700 From: Nathan Chancellor To: Kees Cook Cc: Weili Qian , Zhou Wang , Herbert Xu , "David S. Miller" , linux-crypto@vger.kernel.org, Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: Re: [PATCH] crypto: hisilicon: Wipe entire pool on error Message-ID: References: <20230106041945.never.831-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230106041945.never.831-kees@kernel.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, Jan 05, 2023 at 08:19:48PM -0800, Kees Cook wrote: > To work around a Clang __builtin_object_size bug that shows up under > CONFIG_FORTIFY_SOURCE and UBSAN_BOUNDS, move the per-loop-iteration > mem_block wipe into a single wipe of the entire pool structure after > the loop. > > Reported-by: Nathan Chancellor > Link: https://github.com/ClangBuiltLinux/linux/issues/1780 > Cc: Weili Qian > Cc: Zhou Wang > Cc: Herbert Xu > Cc: "David S. Miller" > Cc: linux-crypto@vger.kernel.org > Signed-off-by: Kees Cook Thanks for the patch! Tested-by: Nathan Chancellor # build > --- > drivers/crypto/hisilicon/sgl.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/crypto/hisilicon/sgl.c b/drivers/crypto/hisilicon/sgl.c > index 2b6f2281cfd6..0974b0041405 100644 > --- a/drivers/crypto/hisilicon/sgl.c > +++ b/drivers/crypto/hisilicon/sgl.c > @@ -124,9 +124,8 @@ struct hisi_acc_sgl_pool *hisi_acc_create_sgl_pool(struct device *dev, > for (j = 0; j < i; j++) { > dma_free_coherent(dev, block_size, block[j].sgl, > block[j].sgl_dma); > - memset(block + j, 0, sizeof(*block)); > } > - kfree(pool); > + kfree_sensitive(pool); > return ERR_PTR(-ENOMEM); > } > EXPORT_SYMBOL_GPL(hisi_acc_create_sgl_pool); > -- > 2.34.1 >