Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1383734ybt; Thu, 25 Jun 2020 04:56:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVYUs5pRcDr/g1HzNLE+NhdWs+/3BwhvD2dO+RelrvT6cUtLoIWf/GyrLTt/DDH6zQCYsO X-Received: by 2002:a50:d785:: with SMTP id w5mr30657166edi.212.1593086177359; Thu, 25 Jun 2020 04:56:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593086177; cv=none; d=google.com; s=arc-20160816; b=BPcF2HFK9zwcf3dR6h8i4hzLPUfiTcVGw/36u1vwqzh8vSk0fB1K9R1LAN/MgA9GXY PEG0GKmxf13CH1HgkkHkLqLwUrHM6JrDzWYa0TuOENt3/+xUfWNcIRDOEL7dziDHUnQy Nn7RwXumBbc1wQfkvd6Ivf4DDgHi9nd1pQISQFzuZh3MJm0gHvpGTT9Q0pXezjF5WdM1 iuaj8MXRuGGGR75l5prqaVqwqcj7sWV2AczUAk9hZqrpTzc/ZZ/+iTLZhu9p/c8iRTLw 7RkGrRCi+WtvplxiamGe5MyRXmDOXfszvBxAWG0XTsoKPw594XUULcomrjX24H0CMF0K zvZA== 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 :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=5rdSLJ2FUhPbG1KcVOd3yiI5MShgVNsEqvbcUoD2YYI=; b=k84OxsMqE8KJiW/Vxx9iuS7zOvt8akPWGu0FK5gymd+jvnf7Y49yXgybpS/SqykApa N6DOamCQwLLq4yGYbvxf8Ly2jRF4MivQBvXmf6iJkaGU+RzYXQyu9qh6Qz+Iz30dz4Pc MXNklo5hYfny39y9ZcT7WiMxVWnuCdXpfIpyaydaDLcpDanizMGR6z7Nz2hH+f7ThjLi auPOycerI+jKvqadNZsNEFzpKCF7JB7bFsIZ2F+enB/Du9VYuoWtPmtAHk64fwIg+I9N v3g/H+O9AO2aA9Mh0dcmLZpbpnnyQM2pnsYLX6H00OIv8pOruS7/FMG/0RgM4yQgCb3b LM6w== 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 n26si4732993ejs.214.2020.06.25.04.55.53; Thu, 25 Jun 2020 04:56:17 -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 S2404575AbgFYLye (ORCPT + 99 others); Thu, 25 Jun 2020 07:54:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404364AbgFYLxh (ORCPT ); Thu, 25 Jun 2020 07:53:37 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9773C0613ED; Thu, 25 Jun 2020 04:53:36 -0700 (PDT) Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1joQRh-0005sR-FK; Thu, 25 Jun 2020 13:53:33 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 268D71C047D; Thu, 25 Jun 2020 13:53:33 +0200 (CEST) Date: Thu, 25 Jun 2020 11:53:32 -0000 From: "tip-bot2 for Peter Zijlstra" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/entry] x86/entry: Fixup bad_iret vs noinstr Cc: Marco Elver , "Peter Zijlstra (Intel)" , x86 , LKML In-Reply-To: <20200618144801.760070502@infradead.org> References: <20200618144801.760070502@infradead.org> MIME-Version: 1.0 Message-ID: <159308601294.16989.6717371293673263499.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 The following commit has been merged into the x86/entry branch of tip: Commit-ID: e3a9e681adb779b39565a28b3252c3be1033f994 Gitweb: https://git.kernel.org/tip/e3a9e681adb779b39565a28b3252c3be1033f994 Author: Peter Zijlstra AuthorDate: Wed, 17 Jun 2020 18:21:16 +02:00 Committer: Peter Zijlstra CommitterDate: Thu, 25 Jun 2020 13:45:39 +02:00 x86/entry: Fixup bad_iret vs noinstr vmlinux.o: warning: objtool: fixup_bad_iret()+0x8e: call to memcpy() leaves .noinstr.text section Worse, when KASAN there is no telling what memcpy() actually is. Force the use of __memcpy() which is our assmebly implementation. Reported-by: Marco Elver Suggested-by: Marco Elver Signed-off-by: Peter Zijlstra (Intel) Tested-by: Marco Elver Link: https://lkml.kernel.org/r/20200618144801.760070502@infradead.org --- arch/x86/kernel/traps.c | 6 +++--- arch/x86/lib/memcpy_64.S | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index af75109..a7d1570 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -690,13 +690,13 @@ struct bad_iret_stack *fixup_bad_iret(struct bad_iret_stack *s) (struct bad_iret_stack *)__this_cpu_read(cpu_tss_rw.x86_tss.sp0) - 1; /* Copy the IRET target to the temporary storage. */ - memcpy(&tmp.regs.ip, (void *)s->regs.sp, 5*8); + __memcpy(&tmp.regs.ip, (void *)s->regs.sp, 5*8); /* Copy the remainder of the stack from the current stack. */ - memcpy(&tmp, s, offsetof(struct bad_iret_stack, regs.ip)); + __memcpy(&tmp, s, offsetof(struct bad_iret_stack, regs.ip)); /* Update the entry stack */ - memcpy(new_stack, &tmp, sizeof(tmp)); + __memcpy(new_stack, &tmp, sizeof(tmp)); BUG_ON(!user_mode(&new_stack->regs)); return new_stack; diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S index 56b243b..bbcc05b 100644 --- a/arch/x86/lib/memcpy_64.S +++ b/arch/x86/lib/memcpy_64.S @@ -8,6 +8,8 @@ #include #include +.pushsection .noinstr.text, "ax" + /* * We build a jump to memcpy_orig by default which gets NOPped out on * the majority of x86 CPUs which set REP_GOOD. In addition, CPUs which @@ -184,6 +186,8 @@ SYM_FUNC_START_LOCAL(memcpy_orig) retq SYM_FUNC_END(memcpy_orig) +.popsection + #ifndef CONFIG_UML MCSAFE_TEST_CTL