From patchwork Mon Dec 19 23:37:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 9480887 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6AD86606DB for ; Mon, 19 Dec 2016 23:40:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5ADFA28407 for ; Mon, 19 Dec 2016 23:40:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E42328410; Mon, 19 Dec 2016 23:40:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5821F28407 for ; Mon, 19 Dec 2016 23:40:01 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cJ7VE-0007m9-IO; Mon, 19 Dec 2016 23:37:56 +0000 Received: from mail-io0-f175.google.com ([209.85.223.175]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cJ7V9-0007JY-Jl for linux-arm-kernel@lists.infradead.org; Mon, 19 Dec 2016 23:37:53 +0000 Received: by mail-io0-f175.google.com with SMTP id d9so166233237ioe.0 for ; Mon, 19 Dec 2016 15:37:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=DJTjeiwrT4EVLRi5HCyADSHdeky+ZUE66Aq/4M0pRq8=; b=nK2pcOwaAmZNADZsZdUNaBC1iz+w9pz7dlNnRUw87YG+yPbwNLjqEC+ORWqdS8pzUU e9IJ4eZdZHKsjMLUxnkQsyDQc8raAUWsEdgAnDhYhbTX9Kv/Z1obvgRUUkv7ZEu2vpry /wu3X+AH6ZNqoYZ53k+8rznsdPrUwhJKF8HTgd8wcIhMNhlm9tWJWbiV1ayZpEb2cMLy oiWOuSHgW197uc0lKKSXQd6QuY009NRc48xZsMABEEiOh1GydPNUcXVBqMH+c12SIkVk CL25LSXjqLuhJfK1PXFKjBwO50wlWC3+Ogrrd5r9v+xUCyAVsfQ6QOrK0aUfp0Zp2yg6 kx6w== X-Gm-Message-State: AIkVDXI75crtL8L11vqwLr0Gzqx6DB+EF+2aHiOBqyRHjA5fVXoM88oEOc95wLHvC0fBViu4 X-Received: by 10.107.159.68 with SMTP id i65mr18914229ioe.153.1482190649965; Mon, 19 Dec 2016 15:37:29 -0800 (PST) Received: from labbott-redhat-machine.redhat.com ([2601:602:9802:a8dc:1722:8a6b:a66c:79eb]) by smtp.gmail.com with ESMTPSA id v74sm9283215ioi.2.2016.12.19.15.37.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Dec 2016 15:37:28 -0800 (PST) From: Laura Abbott To: Herbert Xu , "David S. Miller" , Ard Biesheuvel , Giovanni Cabiddu Subject: [PATCH] crypto: testmgr: Use linear alias for test input Date: Mon, 19 Dec 2016 15:37:26 -0800 Message-Id: <1482190646-7720-1-git-send-email-labbott@redhat.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161219_153751_769037_08FCB021 X-CRM114-Status: GOOD ( 13.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , linux-kernel@vger.kernel.org, Christopher Covington , Laura Abbott , linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Christopher Covington reported a crash on aarch64 on recent Fedora kernels: kernel BUG at ./include/linux/scatterlist.h:140! Internal error: Oops - BUG: 0 [#1] PREEMPT SMP Modules linked in: CPU: 2 PID: 752 Comm: cryptomgr_test Not tainted 4.9.0-11815-ge93b1cc #162 Hardware name: linux,dummy-virt (DT) task: ffff80007c650080 task.stack: ffff800008910000 PC is at sg_init_one+0xa0/0xb8 LR is at sg_init_one+0x24/0xb8 ... [] sg_init_one+0xa0/0xb8 [] test_acomp+0x10c/0x438 [] alg_test_comp+0xb0/0x118 [] alg_test+0x17c/0x2f0 [] cryptomgr_test+0x44/0x50 [] kthread+0xf8/0x128 [] ret_from_fork+0x10/0x50 The test vectors used for input are part of the kernel image. These inputs are passed as a buffer to sg_init_one which eventually blows up with BUG_ON(!virt_addr_valid(buf)). On arm64, virt_addr_valid returns false for the kernel image since virt_to_page will not return the correct page. The kernel image is also aliased to the linear map so get the linear alias and pass that to the scatterlist instead. Reported-by: Christopher Covington Fixes: d7db7a882deb ("crypto: acomp - update testmgr with support for acomp") Signed-off-by: Laura Abbott Acked-by: Ard Biesheuvel --- x86 supports virt_addr_valid working on kernel image addresses but arm64 is more strict. This is the direction things have been moving with my CONFIG_DEBUG_VIRTUAL series for arm64 which is tightening the definition of __pa/__pa_symbol. --- crypto/testmgr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crypto/testmgr.c b/crypto/testmgr.c index f616ad7..f5bac10 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -1464,7 +1464,7 @@ static int test_acomp(struct crypto_acomp *tfm, struct comp_testvec *ctemplate, memset(output, 0, dlen); init_completion(&result.completion); - sg_init_one(&src, ctemplate[i].input, ilen); + sg_init_one(&src, __va(__pa_symbol(ctemplate[i].input)), ilen); sg_init_one(&dst, output, dlen); req = acomp_request_alloc(tfm); @@ -1513,7 +1513,7 @@ static int test_acomp(struct crypto_acomp *tfm, struct comp_testvec *ctemplate, memset(output, 0, dlen); init_completion(&result.completion); - sg_init_one(&src, dtemplate[i].input, ilen); + sg_init_one(&src, __va(__pa_symbol(dtemplate[i].input)), ilen); sg_init_one(&dst, output, dlen); req = acomp_request_alloc(tfm);