From patchwork Thu Jul 1 18:56:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12354689 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=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 3EDA5C11F69 for ; Thu, 1 Jul 2021 18:59:03 +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 04B0861411 for ; Thu, 1 Jul 2021 18:59:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 04B0861411 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=seco.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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=mUNjVLiSWQVS+jYp/mAqGCPezJFHZKWJad8sFTOmudY=; b=xwMtd9MZbJBZJl qJqccbYXuWUTno5SkLUl693SlXZ7RWtviwqgFK5SlklMJElsXHTGJWBwOhGENewF5+4ZXIT9Swlc7 NugkI6vGPgtzIo8EBgPvTRZv0Whrz0nV9ObnGWaXyIHRq+PtgsuQg8kw82tp6LNaBp5gPwTbAW1I2 dKM7grOUodDRorxmx1ZiTCleevVf+1JYKVRGYG++IimhxGWW70Bd4VGEdgrCmRAv7CpivKoX8yRgQ g25PSQF1cKcqm5gZ6xyJ7RwEPOKzZskE0ijqvrSNICOyXHDw6/Dsax8MJ3ABrWZXwIRf54g7rqS8z PYLbs050XY+DHh7nF4QQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lz1s4-000oM0-QD; Thu, 01 Jul 2021 18:57:09 +0000 Received: from mail-eopbgr10060.outbound.protection.outlook.com ([40.107.1.60] helo=EUR02-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lz1rp-000oKO-NE for linux-arm-kernel@lists.infradead.org; Thu, 01 Jul 2021 18:56:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KI4PQT8VPAc/WOWnWFkeneoOC6CbfVzIcfpo7HiHzPW4ay3Z6QF5+o6iHnAspDGx+FR67VepUAcHSp1B/vWu7OKtmtCmD2dktUaQ+NGBfthuDsfFT47YZYVvww9CxlaCi5ijMhEiStiIPc2CqQX1kvNw/ye78kdKyQ2twFrAXKneovSWVgss4crMmBtoT/GiJ9r7kwXBsmzlD1GM6LYmIvgBISKENtXQP9DGcxOQxcCh37LXMf3xr7bKp/UaI0tulg6bDmU1NK8nZ8i6djWBGpgbhMh/lcTyKQwqLsFsd0zSf1TsAxIuze2XRkCLLQLtTFav9KOXJURNK14xOvo2GQ== 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=TXaNT5h8x65Ho0MMGx4L1WZRy2MK9iFCupo1trGdKeo=; b=ABxlsmTYgRX7wYsBOcpXyGw8yS1nRF6L5Ejuu3yz6C8qRrleKMZ4oLzgxqVtUJoJjgfiIAfGy5D7v1ClcaSxgE1KNnyXkT4BUfAIrOGgLpC1biYdnTPETv2aVbvgK+SaLqQLdTCavGsoNUhZQVyTZhYeJ6IomRCRu4swqFL/yeqoGWdFIMx0p8ppsZ42/e9mhJTBYynYPZ3YN8aMbz8KZ/DPB8HJhx9sh6dZdBP64jjW1bYCKM2tvsEPrfrY2MZ74xtIQghwnmJeP2mi5Fs91e0QOPAMYmKltJOid6mCYpcReWSVgCsS42raeRS0dGxYfDC0hpJacbwWQJg//hdJtw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TXaNT5h8x65Ho0MMGx4L1WZRy2MK9iFCupo1trGdKeo=; b=oNgkY0zzprzQYMfG5nldGSWAHerZEc8+gZbproDZa3KxPabwXIewjzeL9pSTc4f7xkX4tUT6seG6Yjt29nvooMWTzkcoIYXmEHLujUS+umqyZKYMlVNVA7s0+K1z6aYtNzQ6SbXo0sO97tiZNGMLbs+JJHgdPDM1xoC8yrBSEVw= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DBBPR03MB5144.eurprd03.prod.outlook.com (2603:10a6:10:f5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.23; Thu, 1 Jul 2021 18:56:49 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::40d5:3554:c709:6b1b]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::40d5:3554:c709:6b1b%5]) with mapi id 15.20.4264.026; Thu, 1 Jul 2021 18:56:49 +0000 From: Sean Anderson To: linux-crypto@vger.kernel.org, Herbert Xu , "David S . Miller" Cc: =?utf-8?q?Horia_Geant=C4=83?= , Aymen Sghaier , Richard Weinberger , linux-arm-kernel@lists.infradead.org, Marek Vasut , Sean Anderson Subject: [PATCH v2 0/2] crypto: mxs_dcp: Fix an Oops on i.MX6ULL Date: Thu, 1 Jul 2021 14:56:36 -0400 Message-Id: <20210701185638.3437487-1-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 X-Originating-IP: [50.195.82.171] X-ClientProxiedBy: MN2PR15CA0050.namprd15.prod.outlook.com (2603:10b6:208:237::19) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from plantagenet.inhand.com (50.195.82.171) by MN2PR15CA0050.namprd15.prod.outlook.com (2603:10b6:208:237::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.22 via Frontend Transport; Thu, 1 Jul 2021 18:56:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 083a80a4-29bc-46a1-0429-08d93cc1fb44 X-MS-TrafficTypeDiagnostic: DBBPR03MB5144: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bz0kdIuKRAyKMMj6Ltikx9Uk1ua83iOEZyj+VgssMv0kO4bmtAdHPXt9wKYKrB9h0ZsQrcS0YuWZWSrKZTXu5tJJBRuBm/L/xoOQhWVIFeNXiA0uDEUHdM2VugPOmvIe7x6FKzU2gYmUKyyTNrOaRJCPhlEw0mKQvm04vw2tMRGBfMHPgC85c+Ct2AFygRfXda2J1zNOhKbzzJMsExQXgzT41eQnWnOZnnV34joq5EAF5Zn1vVU733lvQVKdKrcMuBMcPDgyDe2DxDcB83Wi1vBYqvyHNPAVniI+OTVgR058dcD29Fk+lJpVomUuS1FGRl3TuvfpoY1qSC9OY+H1SvxvMgK8sEN4NmHEjJkSBnJv8nXX7tpHu0zTNjxR6w5WaBhfxxneBzgPpgeeA3sedKyRw8fb4tL70Z+kG7L/Q6kBG4xF+18qyq5gW7B4965/99Q+H3TNUypcJpXhwCAsk+vktFC/EFs5KbvN6AGI0fuw0HlBI/xYIhD9oUtXbRvYl+cXweLc5UjE6BRhm02CN53UCz9H0OYlRlLci6+uc9CriyQaDEtqTUeWzWu/8Lhd8KCaCIyLJrxexzAXoV8KLur4oZtgIRj7uHmTq1dUu/nqEdOrajydMo03SadtwUKmakKP+Msnwjvi8isoeftHhFANT2LaqorC6pcHweHWo3B+xeYOJzSqfFfp17DaCNC51nUO9epWKIQwcra5draVlX/94KO2S70Rwh/bGdOycK+9e6BmuXJXgyj/4u71o60qQhLAKAph7CiagZuy9v4tP4l52KZCc9dcNepcrDk8sysbYQl78GEmW4ebHQWTNQBGiC4MdHR1rXTIuPMS0XBC9Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR03MB4523.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(396003)(366004)(136003)(39840400004)(376002)(5660300002)(45080400002)(16526019)(66556008)(66946007)(83380400001)(316002)(38100700002)(38350700002)(66476007)(478600001)(26005)(110136005)(4326008)(6666004)(186003)(86362001)(44832011)(54906003)(36756003)(966005)(1076003)(6506007)(956004)(52116002)(8676002)(2616005)(2906002)(107886003)(8936002)(6512007)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?sbDraZHHOoqX0lz2IVxGTmbCtYGT?= =?utf-8?q?jhBbO01oOFixTv6Y2TPFr7zBC2mbputhSMqIzw99KOd5SQu0Azon80HPWJwI3bGPN?= =?utf-8?q?24s+Z/oPbrMW1XT1GpfNUzAeU4P533KmmCf2In79GnZz2ZHATAUP+4ZRWsoomOxa/?= =?utf-8?q?mrMB+DcMhKMZXyOyo4qRfNxXN1VxLgHZEOAJnPzzqzf3wZw366lJe1H1hKq2UNAQ0?= =?utf-8?q?GCH6AW7/YvrAwgCQ4w+z+/NQO/mV+NUJ97yqM0+rRbMdcGjmBMMZgEzpmtSW2QsqT?= =?utf-8?q?hRMrkMpb5GS35tI3XV70fipVPt7hy15g3PzxzYG8WQTGZbDDi7ybF+N5iSeOAocqW?= =?utf-8?q?CMqU8UoYXlF0KwM71Lc0WnrgkAD8iN3ywPbSZWJnuWT2qrYyYGIiioDcygnl/egAk?= =?utf-8?q?eiftvr1SbRxmuHZ0mmJ5daaIhqNrp6ftpHQFRLSjV9h00Vb8ZRihL6c4JmSuZX2Il?= =?utf-8?q?3ObASSXpcibZd92td9YsiYW3czFo0RYIRW3GCODIEpo5U6Qd8tpaed+K5znyyY1IN?= =?utf-8?q?g3OuEPNZSx5ACcI6XaMoNuNBsQtxvBMwZ0aUqrjLlEzBoS5XyeDldfbbaNSggeROG?= =?utf-8?q?purB3GyjFvK/U5iVHTALjWoJ0JX6b6ijCuLZVbHKTvjMkpviv2oRyLW0jTMJ7BJa8?= =?utf-8?q?YQPRgQppesoYkJzh8yv08PpcAjklHnLMuBqkGDjDCuBwZ3kZLSmj7esi2QislNe7a?= =?utf-8?q?t6LV23TSi7BpnTkd02OiisFuXBoBAagWCyPid2OkEjDjcwZCOV5GvyNK/M1XJ5noh?= =?utf-8?q?XbC6FTZ4ErgOn4NtSJwISofZ8LH7xXOkunM8ndaZFNt33DxnWfHE0i9cuI5bkXCBd?= =?utf-8?q?IyWQgJumMc2x0Fr1Su+lT0SQfo0HlGhutiKDZ5BRtuImzrqVGLo/pp7wVjZV/njrO?= =?utf-8?q?N0L2bP+ZF1Fa+8b3zdr53u1yY+Gbda/4xZ3V6KU2WBuN085K9LUjOe65BBwOeGVZZ?= =?utf-8?q?t+ncYE+egqbMb302LpO6vUItuxka0hjTMGu3p9DUe1io+Hfe/Uu6JyR0QnlsFOXBl?= =?utf-8?q?Xo2qUETQtYQOFb0CKqGxyGd25N2BQcZP8QOx5x44iE5ADUUAAmZn5Tzgmsd3EWoJj?= =?utf-8?q?q+o/hqOF1bO2TjdV2j63yAIeNmM7s5y8qzVjF8KTBrYnWic0JiP37rPnRxlVptkZ/?= =?utf-8?q?gpR6j7qmpiQMqq+R11hmuZcIADmKIDHcUOeYKBwxwA7KLa8wmsT9y9zxQ41ZTe4ES?= =?utf-8?q?djLmgijSsR4XGsnvmTuKAaDJ7gfYBJQSv7osgRjxoBlEpdCGDQJN8Rvzu2tp0X80N?= =?utf-8?q?67mAfeu+uNOhx0uj?= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 083a80a4-29bc-46a1-0429-08d93cc1fb44 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2021 18:56:49.3678 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dggxTvLJnDwLtAS+dgMDpMsWueyB513HTZoZmftz5P4nahy9al67Pr3+M+BGyF9YtmkQ/nSD+s57xWTZOoIAjg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR03MB5144 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210701_115653_862740_363E7DC9 X-CRM114-Status: GOOD ( 16.69 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This fixes at least one oops when using the DCP on ULL. However, I got another Oops when running kcapi-dgst-test.sh from the libkcapi test suite [1]: [ 6961.181777] Unable to handle kernel NULL pointer dereference at virtual address 000008f8 [ 6961.190143] pgd = e59542a6 [ 6961.192917] [000008f8] *pgd=00000000 [ 6961.196586] Internal error: Oops: 5 [#1] ARM [ 6961.200877] Modules linked in: crypto_user mxs_dcp cfg80211 rfkill des_generic libdes arc4 libarc4 cbc ecb algif_skcipher sha256_generic libsha256 sha1_generic hmac aes_generic libaes cmac sha512_generic md5 md4 algif_hash af_alg i2c_imx ci_hdrc_imx ci_hdrc i2c_core ulpi roles udc_core imx_sdma usb_common firmware_class usbmisc_imx virt_dma phy_mxs_usb nf_tables nfnetlink ip_tables x_tables ipv6 autofs4 [last unloaded: mxs_dcp] [ 6961.239228] CPU: 0 PID: 469 Comm: mxs_dcp_chan/ae Not tainted 5.10.46-315-tiago #315 [ 6961.246988] Hardware name: Freescale i.MX6 Ultralite (Device Tree) [ 6961.253201] PC is at memcpy+0xc0/0x330 [ 6961.256993] LR is at dcp_chan_thread_aes+0x220/0x94c [mxs_dcp] [ 6961.262847] pc : [] lr : [] psr: 800e0013 [ 6961.269130] sp : cdc09ef4 ip : 00000010 fp : c36e5808 [ 6961.274370] r10: cdcc3150 r9 : 00000000 r8 : bff46000 [ 6961.279613] r7 : c36e59d0 r6 : c2e42840 r5 : cdcc3140 r4 : 00000001 [ 6961.286156] r3 : 000008f9 r2 : 80000000 r1 : 000008f8 r0 : cdc1004f [ 6961.292704] Flags: Nzcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none [ 6961.299860] Control: 10c53c7d Table: 83358059 DAC: 00000051 [ 6961.305628] Process mxs_dcp_chan/ae (pid: 469, stack limit = 0xe1efdc80) [ 6961.312346] Stack: (0xcdc09ef4 to 0xcdc0a000) [ 6961.316726] 9ee0: cdc1004f 00000001 bf13cda4 [ 6961.324930] 9f00: 00000000 00000000 c23b41a0 00000000 c36e59d0 00000001 00000010 00000000 [ 6961.333132] 9f20: 00000000 00000000 c13de2fc 000008f9 8dc13080 00000010 cdcc3150 c21e5010 [ 6961.341335] 9f40: cdc08000 cdc10040 00000001 bf13fa40 cdc11040 c2e42880 00000002 cc861440 [ 6961.349535] 9f60: ffffe000 c33dbe00 c332cb40 cdc08000 00000000 bf13cb84 00000000 c3353c54 [ 6961.357736] 9f80: c33dbe44 c0140d34 cdc08000 c332cb40 c0140c00 00000000 00000000 00000000 [ 6961.365936] 9fa0: 00000000 00000000 00000000 c0100114 00000000 00000000 00000000 00000000 [ 6961.374138] 9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 6961.382338] 9fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000 [ 6961.390567] [] (memcpy) from [] (dcp_chan_thread_aes+0x220/0x94c [mxs_dcp]) [ 6961.399312] [] (dcp_chan_thread_aes [mxs_dcp]) from [] (kthread+0x134/0x160) [ 6961.408137] [] (kthread) from [] (ret_from_fork+0x14/0x20) [ 6961.415377] Exception stack(0xcdc09fb0 to 0xcdc09ff8) [ 6961.420448] 9fa0: 00000000 00000000 00000000 00000000 [ 6961.428647] 9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 6961.436845] 9fe0: 00000000 00000000 00000000 00000000 00000013 00000000 [ 6961.443488] Code: e4808004 e480e004 e8bd01e0 e1b02f82 (14d13001) where dcp_chan_thread_aes+0x220 is the line memcpy(in_buf + actx->fill, src_buf, clen); in mxs_dcp_aes_block_crypt. I also tried with the following patch instead of the one included in this series: --- -- but got the same oops. Unfortunately, I don't have the time to investigate this oops as well. I'd appreciate if anyone else using this device could look into this and see if they encounter the same errors. [1] https://github.com/smuellerDD/libkcapi/blob/master/test/kcapi-dgst-test.sh Changes in v2: - Fix warning when taking the minimum of a u32 and a size_t - Use sg_pcopy_from_buffer to properly deal with partial reads. Sean Anderson (2): crypto: mxs-dcp: Check for DMA mapping errors crypto: mxs_dcp: Use sg_mapping_iter to copy data drivers/crypto/mxs-dcp.c | 81 ++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 37 deletions(-) diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c index f397cc5bf102..54fd24ba1261 100644 --- a/drivers/crypto/mxs-dcp.c +++ b/drivers/crypto/mxs-dcp.c @@ -367,6 +367,7 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq) last_out_len = actx->fill; while (dst && actx->fill) { if (!split) { + kmap(sg_page(dst)); dst_buf = sg_virt(dst); dst_off = 0; } @@ -379,6 +380,7 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq) actx->fill -= rem; if (dst_off == sg_dma_len(dst)) { + kunmap(sg_page(dst)); dst = sg_next(dst); split = 0; } else {