From patchwork Tue Jul 20 08:55:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12387853 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EB1BC07E9B for ; Tue, 20 Jul 2021 08:58:14 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1E82461209 for ; Tue, 20 Jul 2021 08:58:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1E82461209 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Jf1VuXUhBuHnDNuQr2uMGm0woCjltRq49nru2HAnEMM=; b=kl/Xp+pOzOYQ8f cYeLeZWxHYY25GSvkHsbEsNLOanRCIlHdnQHiY67high5GSn8GpNuIFFrVlX9tp68UoFRXK1Q2JYO yQU5ly+vpEoiNfbbYv/wtfG8wfmm7O3FyYv19iBd77Bt0+G6fGpGhFglHtaay3HtNOJSSUlz2F7V7 omAqCFTbEvMa7OyENLSYL2s183GALLiemw/rCoTD8SIZ8Z4u3k8igIJgMBW6L9NtJjpdzqrabtTrF AOi3UQuask9JSM2h/VLSQTQTXs2834Ie4LLNBQas3i4PFIRfLUEpzT8U1IIALr2CWkwaY3UtwkYP8 tBgCbjYKPrfvt1yxZDng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5lY5-00CJ3W-Lg; Tue, 20 Jul 2021 08:56:21 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5lXa-00CIrE-0N for linux-arm-kernel@lists.infradead.org; Tue, 20 Jul 2021 08:55:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1626771350; x=1658307350; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bwI9gxWGdNp9j8lflPn0ecNSwTANdGc33doeihFdZBM=; b=rwame6gRRQsvJLELyjkQgpmXGjAnHbQES/qNeQ4FNdKPoCHYRungOumS RRRAaIXwvgarbBft4Q9+4qRru2AK9+Tr8FJeyBfPHr6jkJ5yxkcEJqKhM 67aJotTccW2ZhzqfScPJ3dfMWlo/MlPWN0AxPkdVkT1+GOyDLLqyk9741 glODesyPLwTST74UG/LouOsML9BFptOrPjd1td/kltTP1Lx1ObFKjC1oe l1MJXwsXTWT0Zz3vy2QK3TIrP9W6WFzkEosc9zDNnO1sbS2iADasNUetr okMntECxyMw29NTA7fxyGZmo0LGciLBAaAjteHe0dNnxxHWdsi58HSqNj w==; IronPort-SDR: AsQ9+fN3cEW94XouGCgB6FtnzgJB6gnbcpyPSJXngBjjJnc/p5Q1/brJHQe5Av3RttOKMWiA4X 12ygX0KneBZJ+vxZ6nWRqIfPOSjOP/LsLJ8mWytfAhigl09WGJxqgZ5rLrJNN3291Ddv3nUDDI GB0tQ0iOwzXtEEaOUY4ihvmDWRP8LWhM62uhEtzcmPvN9q1vKdG9XzloiWYkO8D6VEqPbS91nT zV3WWl4gvxZNp7KD36MwVWIa6EZMLbP/CFbdwzzgmUyoBTubtfhl0BQfDqJ4Rvq16qZRrs+73P ae5mULGi1pT0nVdn1ImFmndI X-IronPort-AV: E=Sophos;i="5.84,254,1620716400"; d="scan'208";a="128973620" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 20 Jul 2021 01:55:50 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 20 Jul 2021 01:55:49 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Tue, 20 Jul 2021 01:55:47 -0700 From: Tudor Ambarus To: Subject: [PATCH 4/9] crypto: atmel-aes: Add XTS input length constraint Date: Tue, 20 Jul 2021 11:55:30 +0300 Message-ID: <20210720085535.141486-5-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210720085535.141486-1-tudor.ambarus@microchip.com> References: <20210720085535.141486-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210720_015550_096865_CE74EB19 X-CRM114-Status: UNSURE ( 8.61 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alexandre.belloni@bootlin.com, Tudor Ambarus , linux-kernel@vger.kernel.org, ludovic.desroches@microchip.com, linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Input length smaller than block size does not make sense for XTS. Signed-off-by: Tudor Ambarus --- drivers/crypto/atmel-aes.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/crypto/atmel-aes.c b/drivers/crypto/atmel-aes.c index 9c6d80d1d7a0..4e9515e8dd25 100644 --- a/drivers/crypto/atmel-aes.c +++ b/drivers/crypto/atmel-aes.c @@ -1091,6 +1091,9 @@ static int atmel_aes_crypt(struct skcipher_request *req, unsigned long mode) struct atmel_aes_dev *dd; u32 opmode = mode & AES_FLAGS_OPMODE_MASK; + if (opmode == AES_FLAGS_XTS && req->cryptlen < XTS_BLOCK_SIZE) + return -EINVAL; + if ((opmode == AES_FLAGS_ECB || opmode == AES_FLAGS_CBC) && !IS_ALIGNED(req->cryptlen, crypto_skcipher_blocksize(skcipher))) return -EINVAL;