From patchwork Mon Oct 16 15:51:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Ryabinin X-Patchwork-Id: 10009031 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 079A260235 for ; Mon, 16 Oct 2017 15:48:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE12926E74 for ; Mon, 16 Oct 2017 15:48:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E29FC28619; Mon, 16 Oct 2017 15:48:53 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C57726E74 for ; Mon, 16 Oct 2017 15:48:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754032AbdJPPsp (ORCPT ); Mon, 16 Oct 2017 11:48:45 -0400 Received: from mail-db5eur01on0116.outbound.protection.outlook.com ([104.47.2.116]:39335 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753802AbdJPPsm (ORCPT ); Mon, 16 Oct 2017 11:48:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=xZ0uR5xeL9ePsS089BUYBKQlEvPGjVPt/zSQdnIgUro=; b=Ksr5cESrHJ86XMImKt9LhKofwFlQLa/g4qtdtDmqxV89D4C2M7j3p9tT6mqZzLNSRqWsY+tqTaSq57uwdGWl5RWvtmKy8KfaBmWQ4fQtuRMR/DSaNWolzsYnjABU/48obk6os6tBMG4z9o7w6RUjtpBza+NDUN7ivNGfQcS5u1c= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aryabinin@virtuozzo.com; Received: from localhost.sw.ru (195.214.232.6) by VI1PR08MB2832.eurprd08.prod.outlook.com (2603:10a6:802:25::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.7; Mon, 16 Oct 2017 15:48:36 +0000 From: Andrey Ryabinin To: Herbert Xu Cc: "David S. Miller" , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Linus Torvalds , Jeffrey Walton , Megha Dey , Tim Chen , Andy Lutomirski , Josh Poimboeuf , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Andrey Ryabinin , stable@vger.kernel.org Subject: [PATCH 1/2] x86/crypto/sha256-mb: fix panic due to unaligned access Date: Mon, 16 Oct 2017 18:51:30 +0300 Message-Id: <20171016155131.10118-1-aryabinin@virtuozzo.com> X-Mailer: git-send-email 2.13.6 MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: AM5PR0701CA0013.eurprd07.prod.outlook.com (2603:10a6:203:51::23) To VI1PR08MB2832.eurprd08.prod.outlook.com (2603:10a6:802:25::31) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d742136f-f691-41ab-6f8b-08d514ad5ddd X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254152)(2017052603199)(201703131423075)(201703031133081)(201702281549075); SRVR:VI1PR08MB2832; X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB2832; 3:nIG2X8OhQgCIdRo3jK+ajOGxWC3h8tcOdOTtdYqg7rffeiFIaIVtpnyZGdSL+BKkQwO30qCv97hdnofO7H35Y1hPYk9Ce2FK2SY11vOsakpWgfbTi/ldUzxyWsi56dPnC5hj24hvLXHVad/bXRetXgzrsblHXanhm0jY7vS0S4OotDNXGGR3GQfFULNRAqX+v3gCe75PCAbCQydW+fnqJWzhP9qXSGkwcTV7x+7JRMTNOeMTKrg4/9w1uhvCS0Uv; 25:flt/TNXhq5YjTGOfA2DZ8jtGrRPdzEXy8YVE6Z1KwzrLWMm5+0esYNqiecUEAItpiRu16cJa7EXadl6p4QaBETdvzoB1i0F44d7U5GxXTP0At+tgXcBFb3UvpJS39XoznSjvTUu4nxqky07r+wQDcaVVVMCHMkFsHWKcGkGaCUamnBTDkQAyt/d21hD3LP2IZnUBIPD5GQH9VoR0h2qOMn0d9sM7EemChs5eDP3BqEb71FjEFX36cGZfOS/QamFtUFG/siwIQUKQzjkuF+S0Fa+PA5G7bQ7H4txEPCxCMQXmZF4eqr4Z7EqwbTN3VPC8bJw9ADicvoBlILDdr64CvQ==; 31:OUUOxoNfsVUnG17KSdfDMujFELFTGroOOdRT9131pQmJD/gfOsZib83qJIS022OX4rkgsKnbn9Lx1MR2qtaiNkfaK0tA0MZbXKb6hDo297gv9kPc69Whie5EdYaRwifyff3HcktjtDrr3C0oH7SUoUV4M79m9A+A9k8epG/tMO8du0Unp9OjvOFt/IBmxa8Y0yWkr+yHZdzJ2/FkIZk+m55CCjxQCaCSlupk+6ieHBo= X-MS-TrafficTypeDiagnostic: VI1PR08MB2832: X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB2832; 20:jgcmJsTp1exfHsY8KEsodmFEncqJ6uznLpunbo3IojzjhENhHmSNNNcu9FvalFDkcPAKs+3d5sm7Tc5b65zq2XYulojthPqSEiSsRFazdThqDElqvpMO/hdEcU31Ak5vjZwcsiFPe4DuU3ZISIlj0uR8+4c58cilMKSzj234R9yWZxH/cGTVTuSxl52sQA4DUfHzDfzhIwGwP6pTVYmnSPO/yjuPmPPfHhO93dKTggkntHgiswyeuhsyCYtOc4Gcj18OKbXQZV0SLFWxsubuIqrX0mqjdtsFhJg7Z0vFJbvYTBPYCuoOaVyiclu7WGSGi02g14kSfGMJC+NqNpinNT+zeh9sA29VEUw0wMSMg/EcjoDhwzbkN3bP/BiR5oHz+aFR/2EqHiYhLyQlo5MtSSVAvSQyhgksSAYlI/mJWic=; 4:VMclxhL24+g7RFFRxvNQRCxnfw5IVX42Z06LoYo7nBbgYPQ9bBt5qVueWqJjtH5qmCW00hPC3hMLQY0wyZuoWHSRu0JrDKJNz/sP3LPfAMDebef2StZkqP0faJcZd11W98iN/2JvmNEi4Fubrn8lfWh9UKvr3CfnG5L0ZQsyxnQdNNWQrtwuAw0s+3zQJ3xhEtfDVl3zCKuKfNPlI8SEOu0S+++U0b9LNyfnouIZGGPf0CFFrcPXJWuseXX5+4UFtThMlvwa8RuBUgOHjlNZ0vqokgoyTKaF3hNzTJs1gfA= X-Exchange-Antispam-Report-Test: UriScan:(9452136761055); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(10201501046)(3002001)(100000703101)(100105400095)(93006095)(93001095)(6041248)(20161123555025)(20161123558100)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:VI1PR08MB2832; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:VI1PR08MB2832; X-Forefront-PRVS: 0462918D61 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6069001)(6009001)(346002)(39830400002)(376002)(199003)(189002)(305945005)(81166006)(81156014)(189998001)(7736002)(54906003)(6512007)(6506006)(36756003)(6116002)(3846002)(8936002)(97736004)(16526018)(69596002)(7416002)(5660300001)(50226002)(4326008)(39060400002)(53936002)(86362001)(68736007)(50986999)(33646002)(50466002)(478600001)(53416004)(66066001)(76506005)(6666003)(6916009)(25786009)(8676002)(2906002)(105586002)(5003940100001)(47776003)(48376002)(1076002)(16586007)(6486002)(106356001)(101416001)(316002); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR08MB2832; H:localhost.sw.ru; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR08MB2832; 23:3KzTaYlJ3T7lUwtkLJlAYiq3yBe8du7ezrmW/oL6P?= =?us-ascii?Q?JMeXAeyzYlBi/ED6HI5MOQixSna7kZtvREartTXqFE+JkmnzAS3T9b6z2o85?= =?us-ascii?Q?pHo510pZGMACTZ5nr1hsaGQJtQ8dAxjwQ4bBAyz1Mcdcbl26gjr1tG+Ws/z/?= =?us-ascii?Q?Iy9YtAtMbRpRpg8tRywFgQ+WZs6QT73ujwXVwiSN9bGAYI5h6YAu4N4tiwrX?= =?us-ascii?Q?fLq97wV9mt/ZtHdqSZYDrZFKBEvGjCA06mLaoAUciuwchdCsN0J2g96ZciuO?= =?us-ascii?Q?+gFRGHE0QCrq+A8FdC7vwud9JfbMwHJ7KpIrtiUW1peeTClBoDSlAbBmVmg7?= =?us-ascii?Q?pzGxdV18v/bjN78/sWlstt8sUaIjrndylSnJ7K01sLYxbZsPCFWFW5IpO4X9?= =?us-ascii?Q?4kDO1PTG9/oGqvIQZPgL+1YSn0QfhEwrKYC2hrB+WeA5oiJDQceNMSKaOAzQ?= =?us-ascii?Q?TNGUsDs84+eEcZnlGglBkDI9aKjds6ZLwLCR4VAK4CRyrKuIU+BOjnkGfsMQ?= =?us-ascii?Q?k/BzSmPMP/MXIOC0ofrWSiYrSW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BrIL+OWtPzP+rAdEqPHEjFGzsgAZmfVbkDg+SWYZ9Hc7XzQkIVgb6jEMfxbG7UjZrmqnt3eAumk2urnTFk46yrn4hzEg8/EhaGX6afQ5cXTYJDZnZT4g1A4Pvbw==; 5:7gFB2mWkiNDHz4CFXZYwujY+n1tSZINTMM53BBKE0A5j9Akbo5xn+ZvKwakGh/z9mWJhM9aDloCPy36rllP6yPHl03asKubsTtXrf9Nzo/nT3q4jZiD0X4QocfadoICUXTnTAlJ4mRU9Sm2I7o5aSQ==; 24:6lCO7ZHVL3xzvyQkbKXLTwqyOuBV1IWv05e6gMdGWbC2h5x/9QQkEDsUPSD3C69qCG/eHMz7lE8POB5AQWDo5Ny/4ailyCgiDRaMUkLOsjM=; 7:1EMC2CtG5EZ1e8bEHynfFV0I8SeQlzcauMGII9GireoqOkgWQqtfxKVN243Vyw2HYDNq+X82JS0PnYTtGRVctq6nsH5NFJJu+nKGrfo17sARPo0SrasI5FBUUoxWP4G0mJAew4Xv52xndtPK/le6sdbcXjjKDBPEql29NcMeuXMKPlC+tzEIXkoeMpEEmMY3Np/aT0JwvG6cvBfTqdn3XAdL5PmEe8hlL+S9BnJc/jA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB2832; 20:RD6v6zbkqxzKDln5Nei4uJCsgGN/cUSmPTXGFysHDpqoF4FGcGcmdzPoecRkLwafpYHT439lkVj/3l+P6H4/rNXPM4A9uNzSHme9ot5Jfvemo3qurR+5C9djN4B9/HtAn75EcJ/xN+GLH4EJnzzoS0JGGY/CQF3/OP2olBanMdg= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2017 15:48:36.6046 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB2832 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP struct sha256_ctx_mgr allocated in sha256_mb_mod_init() via kzalloc() and later passed in sha256_mb_flusher_mgr_flush_avx2() function where instructions vmovdqa used to access the struct. vmovdqa requires 16-bytes aligned argument, but nothing guarantees that struct sha256_ctx_mgr will have that alignment. Unaligned vmovdqa will generate GP fault. Fix this by replacing vmovdqa with vmovdqu which doesn't have alignment requirements. Fixes: a377c6b1876e ("crypto: sha256-mb - submit/flush routines for AVX2") Reported-by: Josh Poimboeuf Signed-off-by: Andrey Ryabinin Cc: Acked-by: Tim Chen --- arch/x86/crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S b/arch/x86/crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S index 8fe6338bcc84..16c4ccb1f154 100644 --- a/arch/x86/crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S +++ b/arch/x86/crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S @@ -155,8 +155,8 @@ LABEL skip_ %I .endr # Find min length - vmovdqa _lens+0*16(state), %xmm0 - vmovdqa _lens+1*16(state), %xmm1 + vmovdqu _lens+0*16(state), %xmm0 + vmovdqu _lens+1*16(state), %xmm1 vpminud %xmm1, %xmm0, %xmm2 # xmm2 has {D,C,B,A} vpalignr $8, %xmm2, %xmm3, %xmm3 # xmm3 has {x,x,D,C} @@ -176,8 +176,8 @@ LABEL skip_ %I vpsubd %xmm2, %xmm0, %xmm0 vpsubd %xmm2, %xmm1, %xmm1 - vmovdqa %xmm0, _lens+0*16(state) - vmovdqa %xmm1, _lens+1*16(state) + vmovdqu %xmm0, _lens+0*16(state) + vmovdqu %xmm1, _lens+1*16(state) # "state" and "args" are the same address, arg1 # len is arg2 @@ -234,8 +234,8 @@ ENTRY(sha256_mb_mgr_get_comp_job_avx2) jc .return_null # Find min length - vmovdqa _lens(state), %xmm0 - vmovdqa _lens+1*16(state), %xmm1 + vmovdqu _lens(state), %xmm0 + vmovdqu _lens+1*16(state), %xmm1 vpminud %xmm1, %xmm0, %xmm2 # xmm2 has {D,C,B,A} vpalignr $8, %xmm2, %xmm3, %xmm3 # xmm3 has {x,x,D,C}