From patchwork Thu Apr 20 05:35:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Ellerman X-Patchwork-Id: 9689401 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 1AED5600C8 for ; Thu, 20 Apr 2017 05:35:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B96C24B44 for ; Thu, 20 Apr 2017 05:35:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1A1328459; Thu, 20 Apr 2017 05:35:24 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham 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 ACEFA24B44 for ; Thu, 20 Apr 2017 05:35:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938011AbdDTFfW (ORCPT ); Thu, 20 Apr 2017 01:35:22 -0400 Received: from ozlabs.org ([103.22.144.67]:36307 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938009AbdDTFfW (ORCPT ); Thu, 20 Apr 2017 01:35:22 -0400 Received: by ozlabs.org (Postfix, from userid 1034) id 3w7ndN13xcz9s7M; Thu, 20 Apr 2017 15:35:20 +1000 (AEST) From: Michael Ellerman To: herbert@gondor.apana.org.au Cc: linuxppc-dev@ozlabs.org, dja@axtens.net, linux-crypto@vger.kernel.org Subject: [PATCH v2] powerpc/crypto/crct10dif-vpmsum: Fix missing preempt_disable() Date: Thu, 20 Apr 2017 15:35:09 +1000 Message-Id: <1492666509-4568-1-git-send-email-mpe@ellerman.id.au> X-Mailer: git-send-email 2.7.4 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 In crct10dif_vpmsum() we call enable_kernel_altivec() without first disabling preemption, which is not allowed. It used to be sufficient just to call pagefault_disable(), because that also disabled preemption. But the two were decoupled in commit 8222dbe21e79 ("sched/preempt, mm/fault: Decouple preemption from the page fault logic") in mid 2015. The crct10dif-vpmsum code inherited this bug from the crc32c-vpmsum code on which it was modelled. So add the missing preempt_disable/enable(). We should also call disable_kernel_fp(), although it does nothing by default, there is a debug switch to make it active and all enables should be paired with disables. Fixes: b01df1c16c9a ("crypto: powerpc - Add CRC-T10DIF acceleration") Acked-by: Daniel Axtens Signed-off-by: Michael Ellerman --- arch/powerpc/crypto/crct10dif-vpmsum_glue.c | 3 +++ 1 file changed, 3 insertions(+) v2: No change to the patch. Add dja's ack. Add linux-crypto to Cc. diff --git a/arch/powerpc/crypto/crct10dif-vpmsum_glue.c b/arch/powerpc/crypto/crct10dif-vpmsum_glue.c index bebfc329f746..02ea277863d1 100644 --- a/arch/powerpc/crypto/crct10dif-vpmsum_glue.c +++ b/arch/powerpc/crypto/crct10dif-vpmsum_glue.c @@ -44,10 +44,13 @@ static u16 crct10dif_vpmsum(u16 crci, unsigned char const *p, size_t len) if (len & ~VMX_ALIGN_MASK) { crc <<= 16; + preempt_disable(); pagefault_disable(); enable_kernel_altivec(); crc = __crct10dif_vpmsum(crc, p, len & ~VMX_ALIGN_MASK); + disable_kernel_altivec(); pagefault_enable(); + preempt_enable(); crc >>= 16; }