Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp883591pxb; Tue, 3 Nov 2020 15:28:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTa7hj82lmw2mBNoCsDwttwGnfdcuev40SGG2nS3Keg4puf9uPrliYPH/JoNbi0A+qSJQ/ X-Received: by 2002:aa7:c44a:: with SMTP id n10mr5499024edr.145.1604446138210; Tue, 03 Nov 2020 15:28:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604446138; cv=none; d=google.com; s=arc-20160816; b=M/m4jiGSH3ZRSnEhuxp7HcChKxNLl1yVuFeM69ERiy74ollAkufetG51sfdhJbpJ6+ 2GFcsGUYevRFNZDXTHrZshZIr9dKXgrZdYst/S1E9waUv7B+ooxteqpM2zX5Zsl0ehSW ktbGK6g+jkd09DtJcD7SUju0tKhYmR3f0scy6jJuCcNjr96I99pVDsfUCOtxzEqQWPdY H536V3kc7V+0ck+orZufmJ4icOLBH6mayEuWSEcZmQmnxj0mMe6fULt1AUaVPOUKyjhA HQIEAJi+MnIFambqJi2tz/0NvypO6zIslIdjFPlNkGZ3PS2QZliv1B8nF9vWqWMqN1IO ATLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Gil3iGTMW+Cp6BXtexMu/h7ncIPw3bDDfIFjKAORF60=; b=KKyz76drpIL04b1cR0e8upWv9JM2L0pXUITuyEQLQSAE0/lFqMVBB8T11/SkckU6F3 O0Q5RY6aqfkC87yf193CFz+8yT7PMsmUK7jVXWjnamppS31ux5n3LP0ZF4ZFjt1fiZBR +lcBaLurmR4au2tjeagB4vlJI1o7jEikUuCkteckNSbKvV15PvAT8A/GliZuxJCTvRku BfzJHBKmrgJxOC94M7MpTZjcdfRr6b5SPTPiWh6XtLFUEnb6VuB2shyU+d4VC1QxhzVA t4Z8lgASHACmn9dcWqQgSbzUdwvspR6gWmz/4QA076wY99/Twb/UxO2DIUYjV4CDwNZQ 196w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wjTbktvr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j8si105647edp.407.2020.11.03.15.28.35; Tue, 03 Nov 2020 15:28:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wjTbktvr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388116AbgKCV2B (ORCPT + 99 others); Tue, 3 Nov 2020 16:28:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:36240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733199AbgKCVA2 (ORCPT ); Tue, 3 Nov 2020 16:00:28 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 34EA6223FD; Tue, 3 Nov 2020 21:00:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437227; bh=h8VO8aKLMLf4XmZjmCqV56IrKC+YonT/HRfwBjcxFM0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wjTbktvr0vqYhXBGScjD3wmujtEFYhOj29Cwgy2QVRJZZ87V4AwSxuYAq9CEdKBpL ZmmXwSJn+d5QDuSq3lktTBdXdOZsVXtxK1/SoDiCk+Vmlhnfn5OB39/nXXsFZL2x1K LlXV4b1uVdA4dCMqSTfWVURXKutvBzf5eJ1Dtayo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Neuling , Michael Ellerman Subject: [PATCH 5.4 163/214] powerpc: Fix undetected data corruption with P9N DD2.1 VSX CI load emulation Date: Tue, 3 Nov 2020 21:36:51 +0100 Message-Id: <20201103203306.048306295@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Neuling commit 1da4a0272c5469169f78cd76cf175ff984f52f06 upstream. __get_user_atomic_128_aligned() stores to kaddr using stvx which is a VMX store instruction, hence kaddr must be 16 byte aligned otherwise the store won't occur as expected. Unfortunately when we call __get_user_atomic_128_aligned() in p9_hmi_special_emu(), the buffer we pass as kaddr (ie. vbuf) isn't guaranteed to be 16B aligned. This means that the write to vbuf in __get_user_atomic_128_aligned() has the bottom bits of the address truncated. This results in other local variables being overwritten. Also vbuf will not contain the correct data which results in the userspace emulation being wrong and hence undetected user data corruption. In the past we've been mostly lucky as vbuf has ended up aligned but this is fragile and isn't always true. CONFIG_STACKPROTECTOR in particular can change the stack arrangement enough that our luck runs out. This issue only occurs on POWER9 Nimbus <= DD2.1 bare metal. The fix is to align vbuf to a 16 byte boundary. Fixes: 5080332c2c89 ("powerpc/64s: Add workaround for P9 vector CI load issue") Cc: stable@vger.kernel.org # v4.15+ Signed-off-by: Michael Neuling Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20201013043741.743413-1-mikey@neuling.org Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/kernel/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/powerpc/kernel/traps.c +++ b/arch/powerpc/kernel/traps.c @@ -877,7 +877,7 @@ static void p9_hmi_special_emu(struct pt { unsigned int ra, rb, t, i, sel, instr, rc; const void __user *addr; - u8 vbuf[16], *vdst; + u8 vbuf[16] __aligned(16), *vdst; unsigned long ea, msr, msr_mask; bool swap;