Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2940520pxk; Mon, 21 Sep 2020 00:34:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyx5FWdTWBIUQG2KKzm/DYfzrkodHXPR79KPWXrBBSdaLeqz6q5Bjc6TZVrnYjeMVHvEnTl X-Received: by 2002:aa7:da09:: with SMTP id r9mr51701068eds.7.1600673675903; Mon, 21 Sep 2020 00:34:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1600673675; cv=pass; d=google.com; s=arc-20160816; b=DGHAJ5Gwz3BEkIn8aR/8AH6k777oFWEgOUguGgdlXcStGGZFRTTvJJrY7+Of4r4dqM wLE2gQShPsZukGDB0wqDXKWzInT/L3MPSlybcUdtbJISPzPNOBG2qpQnhUlF7XR/9kFi 3AQieGvj0BYH+MASwHEYLooYBmzWHI3KFSFXEflPnlxYkbdDpdo2Mwhs98K0MiTstkek zS94dxoFxSB8goXH/ho2E6M+QKm0sEJNTKG2MR8w+SVw2BmZ4AWocFO9/onS1a4yH5pO hFt4+Zy4CItvosvzh/mmb3vIc815BXjf1HnK0ZuPtkK1Lr3ujnGXfswZOaKQi45lDfjj w93w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=dS1yV9os3Ty8N468x7XG1hAh3a47TnEB83v8a6v6KsQ=; b=FM4/xrRuT9qNTJ4sjuaoOG97chrfoT7YRCjr6MKpNs/MYvVJb8MCi0tgFIEmoo7n7T HYR2vnAEOmuTtwqBI3zwogEZjIpSYlmqVHiqhoCsDD3KcJryk59ikiZDGue6noW1J1+u 8ald0j/zDj5uOAK/ANmS86BOn0GPRB/oa9HpMDq5v5lK7GcWbkt5moibPArqyHngaHUP 0y8xj5JaJm+TAX79bBiK439hJp3bl5UlV0cVNQDPIin0GGRcGry5LOyfahVK8VmsvyGv 6T++IJxI/SMGO4Js0lJ8nLW2WTu4EvXSW52palgIZef3PgY5Ml+Y/Od5CPTzQgosvCPN d8+Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=BH6EGFKy; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qc14si9072608ejb.379.2020.09.21.00.34.11; Mon, 21 Sep 2020 00:34:35 -0700 (PDT) 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; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=BH6EGFKy; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726494AbgIUHcy (ORCPT + 99 others); Mon, 21 Sep 2020 03:32:54 -0400 Received: from mail-eopbgr60075.outbound.protection.outlook.com ([40.107.6.75]:47332 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726503AbgIUHcs (ORCPT ); Mon, 21 Sep 2020 03:32:48 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PWe1PGP31Bnd9MZJQAzwf1p3B2aqrHgGTD//8vu3hMsgvIyvCtpc9cXFsfOOIBGiz+zxzG3ZFLDCqR3WOJFo6qjnPbc+iBW/0P4o/gcxNmorshyXZW5KjL3+mkD4hjxDf2pW7hW/kTmaUNzvOFQLa66VyN+yIbNKuBsDYnzSY30xSH/zHkSA3gu0MFsYn6lBseIfe0x6vy0YO3/joGdUi2oy/mtjCs5N0sFOx59uwjr0SBkbdFvTOsivcGMqnRajOOcMT9dfFgJOXtumV2KCwqwlmmav2VQtHaG8yrKU3mgFyr0ZbZbaIIV+m4EyRnTR4+692jI7hRi4oEp2RSoHTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dS1yV9os3Ty8N468x7XG1hAh3a47TnEB83v8a6v6KsQ=; b=oQeV1LWIv1sbnvdA85XPhQRgcut6VhSHF9tlRecxmT9tZVNzSoxgrRSPvlIWmTAyU4OYtO8VBugegVB6rkqWczMTxuX4kvPsBxNPBAM6ZCZSyYAycoZER/kZMyQhNjJyTDjMyT7ANWzDWys62dSaOdW/CUnp/IJ35JNtkSjiGSOk7FgK1DtWnnxW8KmXVhU/E9nTwO1NSLVIuCBpH0hLxtXIII+hFF4EOdDQoiW5v3TlhsGZQqaBw2hUmxKRV+2xBFkmV5gIp3hMmLeHgP3sauucWPx3HlzJwe6nmeVNWSYEnA4NE3LHzhohVtS8d6DwtNB4RgdaIXBxH7zzVuLfBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dS1yV9os3Ty8N468x7XG1hAh3a47TnEB83v8a6v6KsQ=; b=BH6EGFKyUEHpzXehtqynoTLfuDhU2CaXCclOSIHAHWEb03Jhg8nKOS+jEXKq9/WmW9jtONKT6U2504MCkMXsXX1oZmbM6/ydeoV1zlgBKK0LB+SYwNcGE+pxFIiom3C/iQa3EqyuqRpb735kQayTxOnnU5o7qz7Q1rlIs6SQTuw= Authentication-Results: nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=oss.nxp.com; Received: from VE1PR04MB6608.eurprd04.prod.outlook.com (2603:10a6:803:125::12) by VI1PR0402MB3903.eurprd04.prod.outlook.com (2603:10a6:803:21::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.15; Mon, 21 Sep 2020 07:32:31 +0000 Received: from VE1PR04MB6608.eurprd04.prod.outlook.com ([fe80::34b6:beed:6762:a67c]) by VE1PR04MB6608.eurprd04.prod.outlook.com ([fe80::34b6:beed:6762:a67c%7]) with mapi id 15.20.3391.011; Mon, 21 Sep 2020 07:32:31 +0000 From: Andrei Botila To: Horia Geanta , Aymen Sghaier , Herbert Xu , "David S. Miller" Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 09/12] crypto: caam/qi2 - add xts check for block length equal to zero Date: Mon, 21 Sep 2020 10:32:02 +0300 Message-Id: <20200921073205.24742-10-andrei.botila@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921073205.24742-1-andrei.botila@oss.nxp.com> References: <20200921073205.24742-1-andrei.botila@oss.nxp.com> Content-Type: text/plain X-ClientProxiedBy: AM0PR02CA0016.eurprd02.prod.outlook.com (2603:10a6:208:3e::29) To VE1PR04MB6608.eurprd04.prod.outlook.com (2603:10a6:803:125::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv15007.swis.ro-buh01.nxp.com (83.217.231.2) by AM0PR02CA0016.eurprd02.prod.outlook.com (2603:10a6:208:3e::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.13 via Frontend Transport; Mon, 21 Sep 2020 07:32:30 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [83.217.231.2] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f287febb-7e84-498e-c9de-08d85e007fd1 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3903: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Pep1j9F9s7aVVduWrjVvC+CJcs8ptO8pvIflB66FYdNTTjUGEq7AeRfACGXadMtDI6ITGsNhKfvLi+vRpzk878QNkUQ6A8nCp/5p1LL52pzOVnS0aq9PWcIv6BjtVzcasSwUwG70ZCYgzzWO98GvqND9tCh9VWI8fO925DKQE/fPJpO736vsZ1utOGXCgo9h3J+Tw3LKxlOGKabv5SzbVNt91LEeZtNyHUx3MjU/KZrukY62np3ymlmE6OkqALVU6Fc/gtXm3WOIOxkK3XwgHAbcoouKcLp+MScrX9tWN+dLogDwQyd5/oEEqpLWtgzAYdaIqQx64uODwFzG5utTkaSxSG2fVrzdcq288fjCRoTol0pQuOH2+gExduzYu8ug X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6608.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(376002)(39860400002)(136003)(346002)(396003)(66476007)(66556008)(2906002)(4326008)(44832011)(956004)(2616005)(6512007)(1076003)(8936002)(8676002)(6666004)(52116002)(66946007)(478600001)(316002)(5660300002)(6506007)(6486002)(83380400001)(186003)(16526019)(26005)(86362001)(110136005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: jBzKk+2Fw0fwHAWxxYxGB11lQR7O656RJuCyPeDLX5kKEBfQOkPsTwHfdMukrMnMkPmiTCZBtvEKKnU8PxbtcEAOOHxS3e2QE77chmEmVBG2dvY4RRe4KAh5jv6iKsfeX0V4zMyGVkRXt2D1wYmTm+mJLgonRzWbj5RmrbaUtzBxGhYr7Fo9ltqiH8AVTTHoiTtVct4QsC6iE//8C44Rz4TCa/dRa68ks0t1D6gxppk4SIAMavgcpA+0lXlnc5LtlBGuZ0Ehm4rp7hBC9hdnYeiqYBSBhGBG3yJoFumPyCeK65UjhhmMVtoU5WK8zrvxXXlNZFNe21RF6Y1kjFgJOxSuIabMBm2pCx6dvBxc2yhx8slZblmFTSpniTuivIXM1x7T3razto4aBwS8FkgfNEif7EAhSujuS0+NIskzQSIBnnyv3UWV+sPV0DMIEe8SoWPnkqF2y3y3jPV3hd/KI0giqx6Wyyj0D476ursOCKSRI35TT48kRhH1EpcI8phfDvXfbXLJueC74YCMo3BiOhOaIdTbVTHhxxFMWmlMiCpsvaDmPk+OmYimCeyKkNwmpeJYKxdtLorCDkXhgDIZHFHWsXIYPpfQodnXLDuV0oRreBwrd6DtA46+KtqTJ/5Cu520LXsmiWLwyOx4/zMUBg== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f287febb-7e84-498e-c9de-08d85e007fd1 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6608.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2020 07:32:31.2320 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: djDOvyHv8+1054BuhlPVLLeQCKrf+fBn/jb+XCsz1glUmSZZBCVdwqgsiGNSI1eKUGtq7gH1FoT3/tgHzJ94mg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3903 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Andrei Botila XTS should not return succes when dealing with block length equal to zero. This is different than the rest of the skcipher algorithms. Fixes: 31bb2f0da1b50 ("crypto: caam - check zero-length input") Cc: # v5.4+ Signed-off-by: Andrei Botila --- drivers/crypto/caam/caamalg_qi2.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/caam/caamalg_qi2.c b/drivers/crypto/caam/caamalg_qi2.c index 5d2e554774c9..592f4a0344ff 100644 --- a/drivers/crypto/caam/caamalg_qi2.c +++ b/drivers/crypto/caam/caamalg_qi2.c @@ -1475,7 +1475,12 @@ static int skcipher_encrypt(struct skcipher_request *req) struct caam_request *caam_req = skcipher_request_ctx(req); int ret; - if (!req->cryptlen) + /* + * XTS is expected to return an error even for input length = 0 + * Note that the case input length < block size will be caught during + * HW offloading and return an error. + */ + if (!req->cryptlen && !ctx->fallback) return 0; if (ctx->fallback && (xts_skcipher_ivsize(req) || @@ -1519,7 +1524,12 @@ static int skcipher_decrypt(struct skcipher_request *req) struct caam_request *caam_req = skcipher_request_ctx(req); int ret; - if (!req->cryptlen) + /* + * XTS is expected to return an error even for input length = 0 + * Note that the case input length < block size will be caught during + * HW offloading and return an error. + */ + if (!req->cryptlen && !ctx->fallback) return 0; if (ctx->fallback && (xts_skcipher_ivsize(req) || -- 2.17.1