From patchwork Sat Oct 26 14:52:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 11213527 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0143A1951 for ; Sat, 26 Oct 2019 14:54:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C8E362070B for ; Sat, 26 Oct 2019 14:54:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572101641; bh=8sAyKk8mt7SfTyUDT5mY7Ohm9Bw9dXaUue3oAQpCcn0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=BFJodR71EdbV2cJy7jbPmH7nO+LkbDduvs8Qwe2iHNoBJwmtvavHW2kSz5Dn6B9Ll l57Kg5cWKLZiw9vAWGARwqHrxUDl7mMdsMcYkus2ythBSp2yni1Mq29jpc6ONle0mj 64d0lUZz50XZn1TL58LVbNx1IvI/MhHUR9MFQtv0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726217AbfJZOxu (ORCPT ); Sat, 26 Oct 2019 10:53:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:37128 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726162AbfJZOxu (ORCPT ); Sat, 26 Oct 2019 10:53:50 -0400 Received: from e123331-lin.home (lfbn-mar-1-643-104.w90-118.abo.wanadoo.fr [90.118.215.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6285B21655; Sat, 26 Oct 2019 14:53:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572101629; bh=8sAyKk8mt7SfTyUDT5mY7Ohm9Bw9dXaUue3oAQpCcn0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f3RCdZvD8eCd9S97bhOgYSFCNTMqmdGH4PPrcqdk30i+EcTnfEiLS/Z4GzF0pr6WD 4T/84YzYVcEuOjuLCYWcobXCwMrRa56KhuUervq4XhdjawWueKmrqiBX7C09+fQt4E jWD6oJflb3Icjc4bCmV+UjRgxGb7d2w0UVljnQp4= From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: herbert@gondor.apana.org.au, Ard Biesheuvel , linux-omap@vger.kernel.org, Tero Kristo Subject: [PATCH 1/6] crypto: omap-aes - reject invalid input sizes for block modes Date: Sat, 26 Oct 2019 16:52:54 +0200 Message-Id: <20191026145259.16040-2-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191026145259.16040-1-ardb@kernel.org> References: <20191026145259.16040-1-ardb@kernel.org> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Block modes such as ECB and CBC only support input sizes that are a round multiple of the block size, so align with the generic code which returns -EINVAL when encountering inputs that violate this rule. Signed-off-by: Ard Biesheuvel --- drivers/crypto/omap-aes.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c index de05b35283bf..067f4cd7c005 100644 --- a/drivers/crypto/omap-aes.c +++ b/drivers/crypto/omap-aes.c @@ -525,6 +525,9 @@ static int omap_aes_crypt(struct skcipher_request *req, unsigned long mode) struct omap_aes_dev *dd; int ret; + if ((req->cryptlen % AES_BLOCK_SIZE) && !(mode & FLAGS_CTR)) + return -EINVAL; + pr_debug("nbytes: %d, enc: %d, cbc: %d\n", req->cryptlen, !!(mode & FLAGS_ENCRYPT), !!(mode & FLAGS_CBC));