From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AED6DC54EBD for ; Sat, 7 Jan 2023 01:55:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236389AbjAGBzd (ORCPT ); Fri, 6 Jan 2023 20:55:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236224AbjAGBzX (ORCPT ); Fri, 6 Jan 2023 20:55:23 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E826F87932; Fri, 6 Jan 2023 17:55:21 -0800 (PST) Received: from kwepemm600009.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Npjsz4cX9zRqsF; Sat, 7 Jan 2023 09:53:43 +0800 (CST) Received: from [10.67.101.184] (10.67.101.184) by kwepemm600009.china.huawei.com (7.193.23.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Sat, 7 Jan 2023 09:55:18 +0800 Subject: Re: [PATCH] crypto: hisilicon: Wipe entire pool on error To: Kees Cook References: <20230106041945.never.831-kees@kernel.org> CC: Nathan Chancellor , Zhou Wang , Herbert Xu , "David S. Miller" , , Nick Desaulniers , Tom Rix , , , From: Weili Qian Message-ID: <7c9e9870-2456-01af-177f-1af62a0055e3@huawei.com> Date: Sat, 7 Jan 2023 09:55:04 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <20230106041945.never.831-kees@kernel.org> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.101.184] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600009.china.huawei.com (7.193.23.164) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/1/6 12:19, 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 > --- > 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); > Thanks for your patch. There is no sensitive data in the pool, so memset zero can be deleted directly. Thanks, Weili