Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1689354pxb; Sat, 29 Jan 2022 14:03:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJymL5mGyNkukdKFQog2ntOTRdjxo+xln+Xpp/NE4hGNoJwAvKwv93lBBFEW4LwvvULqUDwK X-Received: by 2002:a17:90a:d58d:: with SMTP id v13mr16857831pju.210.1643493824706; Sat, 29 Jan 2022 14:03:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643493824; cv=none; d=google.com; s=arc-20160816; b=l1EsmbwOrswRoXcFdwYQJElyXFvs1pkVUGjmnhmDVPnvNnl54zmWpy8B43RlEfFRrq UiyOSxFzl8Pg+iXg0tI2FWgzz6ojEsAnIy8IVBjuu10wXDjcB7LkHy6IsxseY7gOiDUG gTt5hMSFfrxzQvSYRivMcR3KptKwZkO7iKx+Qr6wUQXVkv+XJdn7cggDsezUOOTSRL1G yjRW0i0zu3EjHAScymDLfERDyZZtQxIppVepRwJtViSreAjx+kd1TNUS03Z17IL+8O1B e3VVnHB5LlkDzLEmJqhLALUC15DLcJD2s46XrpeO92l2We/FISt/56Pm+eujnm6229UK /r8w== 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; bh=6VLPuv7ZdOCwvgKl98M1mhBQbNhMdZbsPF/N2OwMTak=; b=LCet7MHXw7HJrNFVVxeZ2VVEAWp0Q+dsr+hj5ceIwQXKTupABrhXtfhfRJZDEL4z/Q 23PCopnIWfKHa1N84IzpLnNxQon9dmRAqAjZZzR+ACThMzWTIsLY6wnWJzXxtvG9WvZ7 KNCKZARdt24ujgQH25LflU0N/SV7aA15zL0455qJ8mk/yspVh5DY9dMPWsag+5WA67T1 1eu431ys+lda9mTOdaPubQzpN4Map6wN0F/QDK0yYYC50RzB9wI7aS1tW4SR4egGdt8j x6PBFBuFrMLUeV0OOvDI8itxkI+b4c/EN//U1g3XuCIbUxRjWqCncJkhL/xnlpkOKI6Q IJCw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n193si8497815pfd.121.2022.01.29.14.03.21; Sat, 29 Jan 2022 14:03:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237958AbiA1GYa (ORCPT + 99 others); Fri, 28 Jan 2022 01:24:30 -0500 Received: from helcar.hmeau.com ([216.24.177.18]:60602 "EHLO fornost.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346412AbiA1GYa (ORCPT ); Fri, 28 Jan 2022 01:24:30 -0500 Received: from gwarestrin.arnor.me.apana.org.au ([192.168.103.7]) by fornost.hmeau.com with smtp (Exim 4.92 #5 (Debian)) id 1nDKgC-00011H-T4; Fri, 28 Jan 2022 17:24:17 +1100 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Fri, 28 Jan 2022 17:24:16 +1100 Date: Fri, 28 Jan 2022 17:24:16 +1100 From: Herbert Xu To: Kees Cook Cc: Boris Brezillon , Arnaud Ebalard , Srujana Challa , "David S. Miller" , Suheil Chandran , Shijith Thotton , Lukasz Bartosik , linux-crypto@vger.kernel.org, Ard Biesheuvel , Dan Carpenter , Jiapeng Chong , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v3] crypto: octeontx2 - Avoid stack variable overflow Message-ID: References: <20220112203811.3951406-1-keescook@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220112203811.3951406-1-keescook@chromium.org> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, Jan 12, 2022 at 12:38:11PM -0800, Kees Cook wrote: > Building with -Warray-bounds showed a stack variable array index > overflow. Increase the expected size of the array to avoid the warning: > > In file included from ./include/linux/printk.h:555, > from ./include/asm-generic/bug.h:22, > from ./arch/x86/include/asm/bug.h:84, > from ./include/linux/bug.h:5, > from ./include/linux/mmdebug.h:5, > from ./include/linux/gfp.h:5, > from ./include/linux/firmware.h:7, > from drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c:5: > drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c: In function 'otx2_cpt_print_uc_dbg_info': > ./include/linux/dynamic_debug.h:162:33: warning: array subscript 4 is above array bounds of 'u32[4]' {aka 'unsigned int[4]'} [-Warray-bounds] > 162 | _dynamic_func_call(fmt, __dynamic_pr_debug, \ > | ^ > ./include/linux/dynamic_debug.h:134:17: note: in definition of macro '__dynamic_func_call' > 134 | func(&id, ##__VA_ARGS__); \ > | ^~~~ > ./include/linux/dynamic_debug.h:162:9: note: in expansion of macro '_dynamic_func_call' > 162 | _dynamic_func_call(fmt, __dynamic_pr_debug, \ > | ^~~~~~~~~~~~~~~~~~ > ./include/linux/printk.h:570:9: note: in expansion of macro 'dynamic_pr_debug' > 570 | dynamic_pr_debug(fmt, ##__VA_ARGS__) > | ^~~~~~~~~~~~~~~~ > drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c:1807:41: note: in expansion of macro 'pr_debug' > 1807 | pr_debug("Mask: %8.8x %8.8x %8.8x %8.8x %8.8x", > | ^~~~~~~~ > drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c:1765:13: note: while referencing 'mask' > 1765 | u32 mask[4]; > | ^~~~ > > This is justified because the mask size (eng_grps->engs_num) can be at > most 144 (OTX2_CPT_MAX_ENGINES bits), which is larger than available > storage. 4 * 32 == 128, so this must be 5: 5 * 32bit = 160. > > Additionally clear the mask before conversion so trailing bits are zero. > > Cc: Herbert Xu > Cc: Boris Brezillon > Cc: Arnaud Ebalard > Cc: Srujana Challa > Cc: "David S. Miller" > Cc: Suheil Chandran > Cc: Shijith Thotton > Cc: Lukasz Bartosik > Cc: linux-crypto@vger.kernel.org > Fixes: d9d7749773e8 ("crypto: octeontx2 - add apis for custom engine groups") > Acked-by: Ard Biesheuvel > Signed-off-by: Kees Cook > --- > v1: https://lore.kernel.org/lkml/20211215225558.1995027-1-keescook@chromium.org/ > v2: https://lore.kernel.org/lkml/20220105174953.2433019-1-keescook@chromium.org/ > v3: > - Fix commit log math typo > - Add Ack > --- > drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) Patch applied. Thanks. -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt