Received: by 10.223.185.116 with SMTP id b49csp2389113wrg; Thu, 15 Feb 2018 10:52:14 -0800 (PST) X-Google-Smtp-Source: AH8x226pXh1I9cWHCJJyaadU+V2V8h87oSHJhc3K31Tre/VXkkgWibCNQDosJnLPMDofRj15yCAP X-Received: by 10.98.64.132 with SMTP id f4mr3453212pfd.232.1518720734035; Thu, 15 Feb 2018 10:52:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518720734; cv=none; d=google.com; s=arc-20160816; b=ehn7GKvodz8cSS9o/jO33kHhMq3WVd5qxHrt9vfKzWvhGIrSafSgWtbY8jBo2zRxk3 eWUDHbvupQtsYOrAdyhA9x9s0StHH6UWQvAaMK8WuwRbllD3SxgCP7mAMeq6rLR1qmV3 mHyLT6E+Wd+tk1s2GeKuWbWBqtn9bptpwaQk7tGZ1AI2wPZED5thk6ISCnSCh54Fgkgm K4mveYjmw6L05wkOsYvOWFxvjCm6TGn11hMnCvQOcgamsxEVoHNeHB/Fgf88tkDp1UpX tGOETun7tIINp/YmoXjHXPOXj8Wjvcbj+VhcPCZaZMueejfPrzgsXPXDPzdg739JZLCt r4oA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Ch7uMvXPvhYGE+5RDW0c1cq80NrEaHhonngDza9xrVg=; b=wlPKSUYf60aTzsG2v113/hjGhjS4xlrbPzUeRyMQc3OWQL9qlqZSHmjtOHwPM/m/yR 1t8pfJ8UU49RHEqIqzDhRMEk5QRItJ5eHpU7LocP72RhMNH3SeKq9VkasbybqZg9IMau WyIiBRBgwOnYH4Mjvn1Ja5WGH7Cd42S91kXElVe7j3VTkqo/EymUcqH0RHcTY5sGUwwW WwmPbIuh0kPu5dzhqDvuX46VhZEGgS8XVAA1z9XSsu1yKKzO1kWmH9TRrqT9k8YpHjWy u+qwJFv1gS1DncREMJKWGKuzB99Xk917EI9FIr3p0Elxx2rVdUQxTTDy1kjpUZzt30R/ METQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f7si3435286pfa.168.2018.02.15.10.51.59; Thu, 15 Feb 2018 10:52:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162110AbeBOPVf (ORCPT + 99 others); Thu, 15 Feb 2018 10:21:35 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:49088 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162080AbeBOPVb (ORCPT ); Thu, 15 Feb 2018 10:21:31 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A60CED69; Thu, 15 Feb 2018 15:21:30 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Josh Poimboeuf , Alexander Potapenko , Andrey Ryabinin , Andy Lutomirski , Arnd Bergmann , Dmitriy Vyukov , LKP , Linus Torvalds , Matthias Kaehlcke , Miguel Bernal Marin , Peter Zijlstra , Thomas Gleixner , Ingo Molnar Subject: [PATCH 4.4 026/108] x86/asm: Fix inline asm call constraints for GCC 4.4 Date: Thu, 15 Feb 2018 16:16:23 +0100 Message-Id: <20180215151226.199156719@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151222.267507937@linuxfoundation.org> References: <20180215151222.267507937@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Josh Poimboeuf commit 520a13c530aeb5f63e011d668c42db1af19ed349 upstream. The kernel test bot (run by Xiaolong Ye) reported that the following commit: f5caf621ee35 ("x86/asm: Fix inline asm call constraints for Clang") is causing double faults in a kernel compiled with GCC 4.4. Linus subsequently diagnosed the crash pattern and the buggy commit and found that the issue is with this code: register unsigned int __asm_call_sp asm("esp"); #define ASM_CALL_CONSTRAINT "+r" (__asm_call_sp) Even on a 64-bit kernel, it's using ESP instead of RSP. That causes GCC to produce the following bogus code: ffffffff8147461d: 89 e0 mov %esp,%eax ffffffff8147461f: 4c 89 f7 mov %r14,%rdi ffffffff81474622: 4c 89 fe mov %r15,%rsi ffffffff81474625: ba 20 00 00 00 mov $0x20,%edx ffffffff8147462a: 89 c4 mov %eax,%esp ffffffff8147462c: e8 bf 52 05 00 callq ffffffff814c98f0 Despite the absurdity of it backing up and restoring the stack pointer for no reason, the bug is actually the fact that it's only backing up and restoring the lower 32 bits of the stack pointer. The upper 32 bits are getting cleared out, corrupting the stack pointer. So change the '__asm_call_sp' register variable to be associated with the actual full-size stack pointer. This also requires changing the __ASM_SEL() macro to be based on the actual compiled arch size, rather than the CONFIG value, because CONFIG_X86_64 compiles some files with '-m32' (e.g., realmode and vdso). Otherwise Clang fails to build the kernel because it complains about the use of a 64-bit register (RSP) in a 32-bit file. Reported-and-Bisected-and-Tested-by: kernel test robot Diagnosed-by: Linus Torvalds Signed-off-by: Josh Poimboeuf Cc: Alexander Potapenko Cc: Andrey Ryabinin Cc: Andy Lutomirski Cc: Arnd Bergmann Cc: Dmitriy Vyukov Cc: LKP Cc: Linus Torvalds Cc: Matthias Kaehlcke Cc: Miguel Bernal Marin Cc: Peter Zijlstra Cc: Thomas Gleixner Fixes: f5caf621ee35 ("x86/asm: Fix inline asm call constraints for Clang") Link: http://lkml.kernel.org/r/20170928215826.6sdpmwtkiydiytim@treble Signed-off-by: Ingo Molnar Cc: Matthias Kaehlcke Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/asm.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/arch/x86/include/asm/asm.h +++ b/arch/x86/include/asm/asm.h @@ -11,10 +11,12 @@ # define __ASM_FORM_COMMA(x) " " #x "," #endif -#ifdef CONFIG_X86_32 +#ifndef __x86_64__ +/* 32 bit */ # define __ASM_SEL(a,b) __ASM_FORM(a) # define __ASM_SEL_RAW(a,b) __ASM_FORM_RAW(a) #else +/* 64 bit */ # define __ASM_SEL(a,b) __ASM_FORM(b) # define __ASM_SEL_RAW(a,b) __ASM_FORM_RAW(b) #endif