Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp1796438rwl; Thu, 5 Jan 2023 20:22:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXtXPvCpkgywdR/qGcGwk42GUUk/o7ixQVhjQ1m4kG7aSU9pAhSSQxw+hF+HCU1sexOAXNKQ X-Received: by 2002:a05:6402:2296:b0:46a:96b3:22bf with SMTP id cw22-20020a056402229600b0046a96b322bfmr56500058edb.17.1672978949768; Thu, 05 Jan 2023 20:22:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672978949; cv=none; d=google.com; s=arc-20160816; b=j4kDYz6wfgKmlHZhZm0bMY66XyrCjwe1Quc168SWXFg4iZbGH2evZX+9XP4uPF5tgI kY8sL3FBqhJx4tt5ZVSYzFYEdg/OfP7j9NfGNVTnHhpQGpt/Hav5Bb/fpxZOOTAoFv7w 7y1GQOBhe0MCUH/2IbEXY68PrqeI257OwDhKlkjEs2fFUIHABGiPAVtzvfFUhkmR9EkF 0KGOQjTiX0NhGRU+QQFeaCfFd21+lb0l4+TrZHmeEoqzuahbQf0qhCID86z4xH6jojp7 0jl7jDSyBdvz3e+JmN2bxmY9VFSHHfmSXY6CheG1mNkhkl06G0WcWlzO3rLV7IrXDg7m lUfw== 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=NhD7q2RSiPfm9HihQvV1PpXzZaGefsCwomkUHFCcDw3sSzJejpBJsqL0H5B4JPjZWh jNjcYDSmJEGORrQI2CN0vMBJhFy0dSVP3/Qqu+OWX/sAaWfB31EsT7mFuSgPaHeyVTAH R6kVQ9th7lc5OZpLfrc3ss6b19MaRBioNnFUIU5HzqsLjK/KFUjnscG9ojCQAf87E+dI 3qvmQTBDJidaLqAm35aHGnTF7X/NUBHCNhjvbutBq+H9FuBUrwVKM6dxotJR8128shOf ExZxRclXSRoAlVkBYmlozuIm8wTlDBDNg+j/iVSBOBcA9X1L6jQBqCEIRMP1khLGKlhD FMtw== 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-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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a16-20020aa7cf10000000b0048e05d2db31si284792edy.15.2023.01.05.20.21.58; Thu, 05 Jan 2023 20:22:29 -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=@chromium.org header.s=google header.b=OdblQNQs; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229597AbjAFEUf (ORCPT + 99 others); Thu, 5 Jan 2023 23:20:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231495AbjAFETy (ORCPT ); Thu, 5 Jan 2023 23:19:54 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7E1D193DB for ; Thu, 5 Jan 2023 20:19:52 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id z4-20020a17090a170400b00226d331390cso537035pjd.5 for ; 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=anE+TOsYKdJS56siYwPidE7aiwWVlOvZdeAbBshlwAb8G3El4IpXI5YEVJLhHkxFwu zWUiS3kM4Qawoide2HvaduQvxngkcTlsLkf5EvcmCNAZDjbtOT72rwuOs/VD0A3ygfTI C/wT26udUOIsvQpZnlhlh51BHwEBTJr7pt4H6zNYYklob0+idbJPT8k9y/hIZf2dLn7T hRrDY00MUIqCei/V+pKFvelWEIyzwV3OW8NMp4z0/GAVY1S9rzMdb0m+s6i7fPlE5JGW SFJ31TUE2iNgxkI//xzMIdwRiKidJ1Xtv8io0ra2hU4brgmP+UY974iE0e7M8kpCkXAv OJzA== X-Gm-Message-State: AFqh2kp55LplmSIi15IEo4Cb0qUvmKPvMv9Q4X8eg2Q0OLm1zI5ZzSf2 XvuxPv0NAdyPfrVGOid2FAA0Ow== 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 To: Weili Qian Cc: Kees Cook , Nathan Chancellor , 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: [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=unavailable 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 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); -- 2.34.1