Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5007591iob; Mon, 9 May 2022 06:48:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0ZhfmVxAya5psaEnsdch5F+pFmQ4Z90p/E44MzADuqUS3z7lCDHy45BbRkO0xjbvtvth1 X-Received: by 2002:a17:90b:4b84:b0:1dc:93c0:ba01 with SMTP id lr4-20020a17090b4b8400b001dc93c0ba01mr26595664pjb.70.1652104133014; Mon, 09 May 2022 06:48:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652104133; cv=none; d=google.com; s=arc-20160816; b=bHpDXQ5tlvOdkE8beXK5p2D/Ein3LJj5r+qMyjCLoS5cRNaqj3z5BZ0h1WtSwEOuk0 aFsQ9OBFQqVEfo+ndbQYQQyav4FqeXDv9uyE5//zG7uq/9csABWTSC9od7YY1z/FvGdA SKhipMqCZIFLS/yJ9hbxS3MB4tJyChUVWNnmopwALLPQffng+16wDeT+4cS/yx9m/Zac 6HZDKfg5sLzAJFpJow3Qs3yzo41L5NFcBVWGRNFrAulhi6E9GKbVIIujmiOrmiPV2K5a dWJ7+k+MMQUdtSZoNrjpzfGZxwNsBJmKakBNrv8B6mRn7KrFXhkVlk9ivocL05hdFsP7 bfWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=W4u8DVET/yj3xBHgqw4bQld1IGI9xDXwfrojA/eNTKc=; b=hnoTheiTPi2RHQ4fRDTL49fiqPX9dwJ9ySdandR/i8LAXplFwrg2MvzC3yLA0k1Dew Izp5GaC2coWjX1OgtU5XY1x6LbyYqMztgEomFnruLQ+iEEYF401p7zEGWoCxTskA0rIL jInI1RkU1L3hOPOTs5BqK9eQM8C3AqQtocM6Lwwxu6727cpzIXQbdfCVpqjucFaESxr2 07ZlR3xgHDc3qNi5RjviaN3LxOPtq6KTfV7sbigKs2hGA7IlrtOhzqr7qbX9TrNlSiP6 xgwfl5z9yUfdhmCPwVtPkhr4Dyiv/enJAWQCKMh2jq+dBncjT6r65VSkcGvi0jSdmtz7 q2/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dn7vlnby; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id m6-20020a170902db0600b0015d4d83f206si13734051plx.600.2022.05.09.06.48.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 06:48:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dn7vlnby; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8624A18995A; Mon, 9 May 2022 06:36:50 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236024AbiEINkf (ORCPT + 99 others); Mon, 9 May 2022 09:40:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235956AbiEINke (ORCPT ); Mon, 9 May 2022 09:40:34 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D73F106A6A; Mon, 9 May 2022 06:36:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652103401; x=1683639401; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3C7nf/12hswH/vpZo9pijZ1VuHa7WMnXV2nf+Dogxq8=; b=dn7vlnbyBkqyKh3CZTQNMI27TwJHWhy6Brn0U62NwIIknhN0b1J8xWI7 PUAmlBqftwmMfED8CcAWa/byD/KjTPArn0HB47xtqXEdogK8ZgQdPwfgD w/cJbBif18X7Mr7Pmk3UCvOyc8Gf8xbLTataJwT0TDIVDEmjEc4lk3PKT o6ZnTfDPXduzNQJXbCpd0g531gn8f6s+SpiZyJl3hOWjU2dsTIjnkXAjr 4C8WitrP/Tb1uoQ/IRkZLF9pbr0pyIzhRDUdH2Ma89Ci8CW6rgkiq3wlI enYNfko0HlfTQdEQtpUt7Ovk29fQ304N9KKNCIEkXvtYH/+LZguzxmJ1F Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10341"; a="248952401" X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="248952401" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 May 2022 06:34:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,211,1647327600"; d="scan'208";a="622967601" Received: from silpixa00400314.ir.intel.com (HELO silpixa00400314.ger.corp.intel.com) ([10.237.222.76]) by fmsmga008.fm.intel.com with ESMTP; 09 May 2022 06:34:46 -0700 From: Giovanni Cabiddu To: herbert@gondor.apana.org.au Cc: linux-crypto@vger.kernel.org, qat-linux@intel.com, Vlad Dronov , Giovanni Cabiddu , stable@vger.kernel.org, Adam Guerin , Wojciech Ziemba Subject: [PATCH v3 08/10] crypto: qat - add param check for DH Date: Mon, 9 May 2022 14:34:15 +0100 Message-Id: <20220509133417.56043-9-giovanni.cabiddu@intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220509133417.56043-1-giovanni.cabiddu@intel.com> References: <20220509133417.56043-1-giovanni.cabiddu@intel.com> MIME-Version: 1.0 Organization: Intel Research and Development Ireland Ltd - Co. Reg. #308263 - Collinstown Industrial Park, Leixlip, County Kildare - Ireland Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 Reject requests with a source buffer that is bigger than the size of the key. This is to prevent a possible integer underflow that might happen when copying the source scatterlist into a linear buffer. Cc: stable@vger.kernel.org Signed-off-by: Giovanni Cabiddu Reviewed-by: Adam Guerin Reviewed-by: Wojciech Ziemba --- drivers/crypto/qat/qat_common/qat_asym_algs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c b/drivers/crypto/qat/qat_common/qat_asym_algs.c index 1021202b2fbd..ec094789a628 100644 --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c @@ -235,6 +235,10 @@ static int qat_dh_compute_value(struct kpp_request *req) req->dst_len = ctx->p_size; return -EOVERFLOW; } + + if (req->src_len > ctx->p_size) + return -EINVAL; + memset(msg, '\0', sizeof(*msg)); ICP_QAT_FW_PKE_HDR_VALID_FLAG_SET(msg->pke_hdr, ICP_QAT_FW_COMN_REQ_FLAG_SET); -- 2.35.1