Message ID | 20240103162608.987145-1-arnd@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-15746-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp5120543dyb; Wed, 3 Jan 2024 08:26:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IEAKLjV15cYX90iB410EIDqri2LfmaJultncY4gPg5s6tTfvSWQOqh2WBs1WsZOykHEPQdO X-Received: by 2002:a05:6a21:a5a3:b0:197:7b1f:3917 with SMTP id gd35-20020a056a21a5a300b001977b1f3917mr889219pzc.55.1704299191112; Wed, 03 Jan 2024 08:26:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704299191; cv=none; d=google.com; s=arc-20160816; b=Zwnei3w09WLarwG5UL6Jxf3ycaqr/pATLHvQ2aUrJSc8ZAv/M+N/GwrMb4nyt3fNe0 HZjFjzE2z0lzXl64DvnDSF60/15T8Chda511wGWShCOKqiKGsvPlEolcdl0kyGoFmBTo bkx73KhxV04tjf26CoGAkNVyMGntLQmql+JvawiAWh86Jb5dAvP7/fMV5Yn/W8vbc273 UG5I98VTCtUA9YTE/m0hIbPCCjizDtRUA3qI2d0NIRN1z7QBJyot0UkKN8tez+nhZdbM 1bS4TUYInRbb+EQHRr+ChgKuXR91hqHNUrfum67hC5q96O65M3uX3PiYdcsOnDhdQv1a JXvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=DGFaWeEUz9o22wr7GYaoqYWGyAIW8Iz+aU2OB6uvgv0=; fh=JWKbfnia7JZ1WoZjxvjEQUGwxtN5J0Vb+V9rOUfWfwM=; b=qmXnnBmc9k+Ef305zcaQyFWDeN9doJBS5j694R440elGzicsiBCqD4li/9HU0lmyTT Hw1X33yjEVNWY0u6Q9I2XYKOoYLNUyEtgEmPC6cnk1AKsf5Niwm1uxucPGzPu20LeVZP l2ElBFMoLeU61zDempoUhd1BTMN8I0BXrVKvTpcnV+EgL8rggjw6JFUeaGjxUImFZMrm GcEibKWK0RXh01fY10YDm/g7VlraXa1dOsk4HW0qFDlmnf/t+PhmMgdMIyYTMj11+JtU cB6XfhYJXDoJMBaM0NtGRmnI+9EeCQAKSndwR4HtVrvtr5H0olrnT2OBrxEg2lxWjaEi UeCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dgtnolu1; spf=pass (google.com: domain of linux-kernel+bounces-15746-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15746-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n16-20020a170903111000b001d485a812acsi11494340plh.386.2024.01.03.08.26.30 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 08:26:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15746-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dgtnolu1; spf=pass (google.com: domain of linux-kernel+bounces-15746-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15746-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D83BA281BB0 for <ouuuleilei@gmail.com>; Wed, 3 Jan 2024 16:26:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6B1611BDF3; Wed, 3 Jan 2024 16:26:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dgtnolu1" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6F821BDC3; Wed, 3 Jan 2024 16:26:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28F45C433C7; Wed, 3 Jan 2024 16:26:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704299174; bh=4rFtZTk/CSyYTYOlTo0igxEY+Pn+iCcuCMqZdpDydfA=; h=From:To:Cc:Subject:Date:From; b=dgtnolu1WIZU8u9TNIazyOPm19CpnM1XlsbkNFKQkH8J0QKToEEfqrritT0jYywN4 GTBc0Rclz4+tl+qH0gPvLMbVpJ8g72+YMmC2fQ2YcjSvMez2e1AyZWJsSJPMh4wx3s ny0jcXRCby8yyS59WQxbAXZnGqn1n/6AzYbt9iRqDq7S2WHCkTPn5x/2Ke7UpSKock UQpeffL/NvTlzISkfplQZk2Qr2lH/Fky0h6zu1b781LrXbx0xoCpNsRtX7RD7H78Aq /yBqjMD4kvHmmr6YpuBuMk9heTJGqi+CTY2k218GEcpK5sPcxMEqEHEVtnD0/aE/P9 aHKUTLB89BsGw== From: Arnd Bergmann <arnd@kernel.org> To: Giovanni Cabiddu <giovanni.cabiddu@intel.com>, Herbert Xu <herbert@gondor.apana.org.au>, "David S. Miller" <davem@davemloft.net>, Damian Muszynski <damian.muszynski@intel.com> Cc: Arnd Bergmann <arnd@arndb.de>, Tom Zanussi <tom.zanussi@linux.intel.com>, Jie Wang <jie.wang@intel.com>, qat-linux@intel.com, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] crypto: qat - avoid memcpy() overflow warning Date: Wed, 3 Jan 2024 17:26:02 +0100 Message-Id: <20240103162608.987145-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787087228492810087 X-GMAIL-MSGID: 1787087228492810087 |
Series |
crypto: qat - avoid memcpy() overflow warning
|
|
Commit Message
Arnd Bergmann
Jan. 3, 2024, 4:26 p.m. UTC
From: Arnd Bergmann <arnd@arndb.de> The use of array_size() leads gcc to assume the memcpy() can have a larger limit than actually possible, which triggers a string fortification warning: In file included from include/linux/string.h:296, from include/linux/bitmap.h:12, from include/linux/cpumask.h:12, from include/linux/sched.h:16, from include/linux/delay.h:23, from include/linux/iopoll.h:12, from drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.c:3: In function 'fortify_memcpy_chk', inlined from 'adf_gen4_init_thd2arb_map' at drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.c:401:3: include/linux/fortify-string.h:579:4: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning] 579 | __write_overflow_field(p_size_field, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/fortify-string.h:588:4: error: call to '__read_overflow2_field' declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror=attribute-warning] 588 | __read_overflow2_field(q_size_field, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Add an explicit range check to avoid this. Fixes: 5da6a2d5353e ("crypto: qat - generate dynamically arbiter mappings") Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.c | 3 +++ 1 file changed, 3 insertions(+)
Comments
On Wed, Jan 03, 2024 at 05:26:02PM +0100, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > The use of array_size() leads gcc to assume the memcpy() can have a larger > limit than actually possible, which triggers a string fortification warning: > > In file included from include/linux/string.h:296, > from include/linux/bitmap.h:12, > from include/linux/cpumask.h:12, > from include/linux/sched.h:16, > from include/linux/delay.h:23, > from include/linux/iopoll.h:12, > from drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.c:3: > In function 'fortify_memcpy_chk', > inlined from 'adf_gen4_init_thd2arb_map' at drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.c:401:3: > include/linux/fortify-string.h:579:4: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning] > 579 | __write_overflow_field(p_size_field, size); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > include/linux/fortify-string.h:588:4: error: call to '__read_overflow2_field' declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror=attribute-warning] > 588 | __read_overflow2_field(q_size_field, size); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Add an explicit range check to avoid this. > > Fixes: 5da6a2d5353e ("crypto: qat - generate dynamically arbiter mappings") > Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
On Wed, Jan 03, 2024 at 05:26:02PM +0100, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > The use of array_size() leads gcc to assume the memcpy() can have a larger > limit than actually possible, which triggers a string fortification warning: > > In file included from include/linux/string.h:296, > from include/linux/bitmap.h:12, > from include/linux/cpumask.h:12, > from include/linux/sched.h:16, > from include/linux/delay.h:23, > from include/linux/iopoll.h:12, > from drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.c:3: > In function 'fortify_memcpy_chk', > inlined from 'adf_gen4_init_thd2arb_map' at drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.c:401:3: > include/linux/fortify-string.h:579:4: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning] > 579 | __write_overflow_field(p_size_field, size); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > include/linux/fortify-string.h:588:4: error: call to '__read_overflow2_field' declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror=attribute-warning] > 588 | __read_overflow2_field(q_size_field, size); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Add an explicit range check to avoid this. > > Fixes: 5da6a2d5353e ("crypto: qat - generate dynamically arbiter mappings") > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > --- > drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.c | 3 +++ > 1 file changed, 3 insertions(+) Patch applied. Thanks.
diff --git a/drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.c b/drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.c index 9985683056d5..f752653ccb47 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.c +++ b/drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.c @@ -398,6 +398,9 @@ int adf_gen4_init_thd2arb_map(struct adf_accel_dev *accel_dev) ADF_GEN4_ADMIN_ACCELENGINES; if (srv_id == SVC_DCC) { + if (ae_cnt > ICP_QAT_HW_AE_DELIMITER) + return -EINVAL; + memcpy(thd2arb_map, thrd_to_arb_map_dcc, array_size(sizeof(*thd2arb_map), ae_cnt)); return 0;