Message ID | 20230106041945.never.831-kees@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp632002wrt; Thu, 5 Jan 2023 20:23:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXs/ubKez8zabykpOVaKuZuPXn1hIXrZfmqMD113VFsILTw2uiogs7KyOk5/hQexV/zlwXEe X-Received: by 2002:a17:906:d047:b0:7b9:62ab:dc3f with SMTP id bo7-20020a170906d04700b007b962abdc3fmr56216858ejb.1.1672978988489; Thu, 05 Jan 2023 20:23:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672978988; cv=none; d=google.com; s=arc-20160816; b=RmJQfLyDcntWzvb9P8Cvd04zbbNtt3UTRS7fpSnA9hl/dEMVoaG4uWWC/ClKwO6p0W MHYAzz47io3bjfSWSyBffjTPqAxJzXsCnQ7KsjQkHMGorwUEK6/vTpYNrjSeOv1/pkMG Lk1PswHHtGGZ/RBlmzrWDv9J5gLSin/dSjimulag+9hjQuTXBTDf85StaKPfwxZaBh8+ wyK8BVuqbiNmZu6Ktcc2bOdIYW2HPJYV2aBPOCpFq7owd9+0zFZm/Hgo24YcoQ6whuZ0 0B5SJaqvWPLXB2S5oGFF467NdKxAYgPpD7pUQcF9OOfb8THTL7NOT4JelsQDAx6LT6LG LkRQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=hu8NtloN+PgTYyanRIE7pi7y6G8HPaI/k/WMITVvahU=; b=tBpZ6fVW3M/OsYBTkh4i+CmADJKxZkS9j54yZCFLiicoPaP60wjcBf2dM9RQVts8dx G0o8mIBYpPJIhaYykm44+O0lkRnPp4M0XDLVbyw104buJNHbkSam467G6tE7BloyF/u7 AVTCs/lF4UoupTl8o/K4SHOL4Ey262HMBH3B3LxFJry4wRCQ5fzkaoD63sBKv8VS6K0w VyGwTkkVSzKBCz3GX68kS5Ez7NDVzKUcVCjVV6NPGJKObglinFAqHc8QStBxwH+3sz/U LEAuKcmtC669DlGnFFtGbVaQmwj7nyGSINx3+K3H7huiwMiEQcR3uSPnWp3g7Ux/MupG iPkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OdblQNQs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw40-20020a1709066a2800b007c118b2d91dsi58426ejc.248.2023.01.05.20.22.44; Thu, 05 Jan 2023 20:23:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@chromium.org header.s=google header.b=OdblQNQs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231631AbjAFEUm (ORCPT <rfc822;tmhikaru@gmail.com> + 99 others); Thu, 5 Jan 2023 23:20:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231485AbjAFETx (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 5 Jan 2023 23:19:53 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBC191659F for <linux-kernel@vger.kernel.org>; Thu, 5 Jan 2023 20:19:52 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id 17so574827pll.0 for <linux-kernel@vger.kernel.org>; Thu, 05 Jan 2023 20:19:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=hu8NtloN+PgTYyanRIE7pi7y6G8HPaI/k/WMITVvahU=; b=OdblQNQsWkunarJky6ssowGDbfTut1JiehmR0XIbfzlvP9zGzN3UF6YHZ2YckEX8Lw Z2zNGXRwzroQNXlC6nccWRULvSTwJzUn0Ya9imOGqk6l2p0gUu4Iuyhry0Xs8gDJnnyi wYy6GF2eJ+E5R47SGTl55Tg4M2Nh0aoqF3Bbk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hu8NtloN+PgTYyanRIE7pi7y6G8HPaI/k/WMITVvahU=; b=AIkrLX3SdLhaIsRwwLIO4v3FL1KkAm4FPXp6M6mHwNUrxU7vhtP33huv3N/MEXqxdF IuKUUL4vVEoIwzoJVhPu4Ps+RjpNTbqZQV3A34K57Jnk+Bf4q1zVwTnDU+iNWkYafvCQ 0RnECR+wBtury9xFJIfLVTrtglkbVUeKlExMk73RAe6fXumVSSQnLGcPFNtSh0u5gB+O HI08SIfd02d0sLHKz28Y9QHIlEch+oBZakwDYMHLbfdUAq/Ubdjxbux1lIF+xYbHicPA vX/G/wNZi25ufGS0DQ54AbyaT78GZx32xzT0Zj6YCGJvl8qJhJ0LhiK2ZV+iQWcbPton LaYA== X-Gm-Message-State: AFqh2krCV1gbBaagfb/waQGdWgZk1bgeNeu56hJLN4Cy4pj6328n1lWz gTNDR9nO6JCWo+89+WYd+rOzdw== X-Received: by 2002:a05:6a20:3d84:b0:b0:1abd:8604 with SMTP id s4-20020a056a203d8400b000b01abd8604mr87791661pzi.41.1672978792438; Thu, 05 Jan 2023 20:19:52 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id z4-20020aa79f84000000b00573a9d13e9esm99431pfr.36.2023.01.05.20.19.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 20:19:51 -0800 (PST) From: Kees Cook <keescook@chromium.org> To: Weili Qian <qianweili@huawei.com> Cc: Kees Cook <keescook@chromium.org>, Nathan Chancellor <nathan@kernel.org>, Zhou Wang <wangzhou1@hisilicon.com>, Herbert Xu <herbert@gondor.apana.org.au>, "David S. Miller" <davem@davemloft.net>, linux-crypto@vger.kernel.org, Nick Desaulniers <ndesaulniers@google.com>, Tom Rix <trix@redhat.com>, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH] crypto: hisilicon: Wipe entire pool on error Date: Thu, 5 Jan 2023 20:19:48 -0800 Message-Id: <20230106041945.never.831-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1263; h=from:subject:message-id; bh=X6glahKc2K5AhGi573gEkEl/ZAg/qb6wVfjT5NagaeU=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBjt6FkGMo4DAMJrJ88UNYYHlYbEA3oaRLMDi+LMFt7 MlcyWbCJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCY7ehZAAKCRCJcvTf3G3AJrdlD/ 9klXK0kVfveHuPruho8dg/ZvBbP1H/ZKgZMeuq9octPINgkBgqGgnphKdHv6I3FBz0h9lUC94M3vZ1 SN9snSK1U9rraulaAplsebe/ma5zOumYBITv4UDqmYIbgp5UraM8+Fu0Ws0r/z9spYVLFJvAx6onMk d8L66wpibWnBQ0Al7c6kam9MKYP6QXYpPqWtpj8TrCJT/N3ABy5qf87KeMHsbWR3sPjcTPPljQXu+y jfgmhbInslE/j5J01pGLMGhFcx1/9zwoT9Xg6l4pOsi3655bOXnBxyyIemp1YaM2yPmwmt66s0RfaL lw/8Y9iTp3B+ACjjjzDY5sJYepHtQPDeGCZdXwC/w7twxdWsvqLvfVjCS6fUdKnQj1aSN0IRZ+awki A9Cl1roFZ4iV2A77XiIXlZY5D4OBBQC5vNIVFBD7Qb3FyX8Nw7jWLyadPJmMzAj5mHYKpnyyH93I3N xKnyzi8+ouYZpohIVB1wLhHDoEEi4nqDBUDi9QV0KiDop2q3TMwT+23QF5eCCP2Ay8jKcVMk32QTO5 4A48zBSX3lRNTi56aeOlHCewiRgEIhj0SmO0+VUGLq2s4V/IWIA4H19honqvtwQH2I3+ojP+C5WZp9 HLp98EGjFlXr6HFpI4yUKG9sZzFAo02W03prZ+xnc2e9kwkcKyzE/9H6qE2A== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754245615505146142?= X-GMAIL-MSGID: =?utf-8?q?1754245615505146142?= |
Series |
crypto: hisilicon: Wipe entire pool on error
|
|
Commit Message
Kees Cook
Jan. 6, 2023, 4:19 a.m. UTC
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 <nathan@kernel.org>
Link: https://github.com/ClangBuiltLinux/linux/issues/1780
Cc: Weili Qian <qianweili@huawei.com>
Cc: Zhou Wang <wangzhou1@hisilicon.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: linux-crypto@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
drivers/crypto/hisilicon/sgl.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
Comments
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 <nathan@kernel.org> > Link: https://github.com/ClangBuiltLinux/linux/issues/1780 > Cc: Weili Qian <qianweili@huawei.com> > Cc: Zhou Wang <wangzhou1@hisilicon.com> > Cc: Herbert Xu <herbert@gondor.apana.org.au> > Cc: "David S. Miller" <davem@davemloft.net> > Cc: linux-crypto@vger.kernel.org > Signed-off-by: Kees Cook <keescook@chromium.org> Thanks for the patch! Tested-by: Nathan Chancellor <nathan@kernel.org> # 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 >
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 <nathan@kernel.org> > Link: https://github.com/ClangBuiltLinux/linux/issues/1780 > Cc: Weili Qian <qianweili@huawei.com> > Cc: Zhou Wang <wangzhou1@hisilicon.com> > Cc: Herbert Xu <herbert@gondor.apana.org.au> > Cc: "David S. Miller" <davem@davemloft.net> > Cc: linux-crypto@vger.kernel.org > Signed-off-by: Kees Cook <keescook@chromium.org> > --- > 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
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);