Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp766760ybj; Tue, 5 May 2020 07:16:16 -0700 (PDT) X-Google-Smtp-Source: APiQypKiu0Q0ID6+Pu2bhEvZ0Ix5nHuD6/kC6u9tBA/dWPss+Jt3BBFwZqyDdrS3fH6P2qej6IUo X-Received: by 2002:a05:6402:b2a:: with SMTP id bo10mr2916681edb.366.1588688176455; Tue, 05 May 2020 07:16:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588688176; cv=none; d=google.com; s=arc-20160816; b=mzbuvhqZJuLeSPqhXFjdwuobr44BuzzHy0RgwgjVfjKNQ37QyjU/AipeAr2qcXHkRy rOOEwdzzEhQNlCKRA8LfQJxUWLkAXKRU5OVGowr2G2ZgDpUFJhbJ9zd0xssbVb1t8V41 DXb3XGlHx4cn9mkyKLb0zQJEIIU9tfZV5xKOIlEYuxs6GF+kCVZroQRjgWqtygXi0+Yz P5ZC0VP4reTiNGtD3Z3fNZWZOA3IsaDzIAZ/T77I98OZLcvtEldOuuyDHyz3hOa0OCE7 4Mu/ifeV9BQGk1lf0fvN46eSfcA5z8YvBoCuVqTOTSmC4AI/BMHcykAwNgXTxhVEmVHM Yz/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:subject:cc:to:from:date:user-agent:message-id; bh=PICGxaope6cjCN4s4+/DWNlVHHYRD4qe7hykU70q1Mc=; b=Euv/g/tJ+L3Z4eIFwFcseO0tcFA2TV/c7k5WnrvzZH4a3s1qptlVKB/IuvIyGJBrQQ +huNVz4gZXPVn9nrG6BqFI+Rljn4zmcVtr+Wo8L+RUo8zKNEBNhAA/SnIaNnmaU/n1nC +XEQVSjNuKmgqjSLcXPWHQV0uXIF1NfV63OI2aA9oMHMuuEEMS22aQp+DNL1GStvXvaU lM8AfV2udYc6XlHe+DS5Slo9WmZ3da3XIgJ00eeBey7q2caRaFPYUqEIlFDcyWaAvg9K v08Nm0cSlrDSuEL4QB5kTS6WdOAN/y+OhBoaGzH2FtekxLSXVvDJE+6s5c28CZO1pFeb NHlw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s22si1276595edr.441.2020.05.05.07.15.42; Tue, 05 May 2020 07:16:16 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729399AbgEEONu (ORCPT + 99 others); Tue, 5 May 2020 10:13:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729330AbgEEONr (ORCPT ); Tue, 5 May 2020 10:13:47 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 084E3C061A41 for ; Tue, 5 May 2020 07:13:46 -0700 (PDT) Received: from p5de0bf0b.dip0.t-ipconnect.de ([93.224.191.11] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jVyK4-0000N2-8t; Tue, 05 May 2020 16:13:24 +0200 Received: from nanos.tec.linutronix.de (localhost [IPv6:::1]) by nanos.tec.linutronix.de (Postfix) with ESMTP id AFA1A1001F5; Tue, 5 May 2020 16:13:23 +0200 (CEST) Message-Id: <20200505134058.863038566@linutronix.de> User-Agent: quilt/0.65 Date: Tue, 05 May 2020 15:16:10 +0200 From: Thomas Gleixner To: LKML Cc: x86@kernel.org, "Paul E. McKenney" , Andy Lutomirski , Alexandre Chartre , Frederic Weisbecker , Paolo Bonzini , Sean Christopherson , Masami Hiramatsu , Petr Mladek , Steven Rostedt , Joel Fernandes , Boris Ostrovsky , Juergen Gross , Brian Gerst , Mathieu Desnoyers , Josh Poimboeuf , Will Deacon , Borislav Petkov , "Peter Zijlstra (Intel)" Subject: [patch V4 part 1 08/36] x86/doublefault: Remove memmove() call References: <20200505131602.633487962@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-transfer-encoding: 8-bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use of memmove() in #DF is problematic considered tracing and other instrumentation. Remove the memmove() call and simply write out what needs doing; this even clarifies the code, win-win! The code copies from the espfix64 stack to the normal task stack, there is no possible way for that to overlap. Survives selftests/x86, specifically sigreturn_64. Suggested-by: Borislav Petkov Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Thomas Gleixner Acked-by: Andy Lutomirski Link: https://lkml.kernel.org/r/20200220121727.GB507@zn.tnic --- arch/x86/kernel/traps.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -278,6 +278,7 @@ dotraplinkage void do_double_fault(struc regs->ip == (unsigned long)native_irq_return_iret) { struct pt_regs *gpregs = (struct pt_regs *)this_cpu_read(cpu_tss_rw.x86_tss.sp0) - 1; + unsigned long *p = (unsigned long *)regs->sp; /* * regs->sp points to the failing IRET frame on the @@ -285,7 +286,11 @@ dotraplinkage void do_double_fault(struc * in gpregs->ss through gpregs->ip. * */ - memmove(&gpregs->ip, (void *)regs->sp, 5*8); + gpregs->ip = p[0]; + gpregs->cs = p[1]; + gpregs->flags = p[2]; + gpregs->sp = p[3]; + gpregs->ss = p[4]; gpregs->orig_ax = 0; /* Missing (lost) #GP error code */ /*