Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1374040imm; Wed, 23 May 2018 15:09:16 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqyrcPd/8dFjAsSRzk4WzAkhGej84P0RE6JXH9/XWYTdpCiCvEfZXyVbhXj3Zyxbkfauk60 X-Received: by 2002:a17:902:8218:: with SMTP id x24-v6mr4642363pln.57.1527113356930; Wed, 23 May 2018 15:09:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527113356; cv=none; d=google.com; s=arc-20160816; b=Br+kZKczvpESHb1yInE/KDXBtuYIvwOJ1aGdF1kGdIH2ep83ZtvXyxFvfz+G1B28/9 8jDLtxrDEu/UNS0cdpaE3W8tQuKAshl/OxVm21O60M96WciJWTS7uYmxE7dXVObM6qxv UXQQWaK8juU0iZth/w4MlX+hBH8QUWv4cIGl4t1XRDuhEjrvamZgx3zu6zrld8BrcKT0 8mnQ3v7TgglWbcHA+KQ7yn19AcOMa+PDTpVbDnEX+WT7hLFXcDs6Y+SjIsqHt7dGokYf 0Pmud4ZsSv5aBFYHZ09Fdy4wz20OOi5VAtIF/HZyKpG5rvDN4joGTWBFqadRjxnUL2jT LqKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :mime-version:dkim-signature:arc-authentication-results; bh=j4Q7bRb8HHM3N8hJT+aAO6okpwwtwrCPrryZPqdYBv8=; b=Iw3yr9sY6Psny5bo8idX8HcCalb8aweKApYsH/7OR8eUnGcLqidtCKhxcLaPX9ZB8D QgKHU0yL0yze4S49RcbXyP/0t1B8JAfarrkiPmNWPw0Ck9CEhnZSoDmETtVfcKxYJHmG iK5bAr1soYsbabjaOJCoB19e3fM7ocYmHju7shjx8MWCNwBLG1bPfG+Dfs693W2QjB5P p4GqMFWPW2h4RDVlQwwDR6cKJBYDBh7Fh/QEUFPtNyyJmBkBRR7aSN63W5xrcTLM5+eq s6ZQHLA6L9gmetwHwVM+ar74A5rrQmQQhObvGXybYgYbY08Anbk4SsHOtIoXsbM6m3so BqEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=VVBS8Nbw; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 203-v6si19372189pfa.60.2018.05.23.15.09.01; Wed, 23 May 2018 15:09:16 -0700 (PDT) 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; dkim=pass header.i=@google.com header.s=20161025 header.b=VVBS8Nbw; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934381AbeEWWId (ORCPT + 99 others); Wed, 23 May 2018 18:08:33 -0400 Received: from mail-pf0-f176.google.com ([209.85.192.176]:45119 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933791AbeEWWIb (ORCPT ); Wed, 23 May 2018 18:08:31 -0400 Received: by mail-pf0-f176.google.com with SMTP id c10-v6so11146850pfi.12 for ; Wed, 23 May 2018 15:08:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=j4Q7bRb8HHM3N8hJT+aAO6okpwwtwrCPrryZPqdYBv8=; b=VVBS8Nbwp6tzkEvC1OQ1TPCVeRFmKUwJe+EE3i9B8O+m61GQmFhciGv6XYVV38EA1w jFoXq/6JhBpD5NM6t3FRm5cUeh6rbq7tnE3fgANQRLdZf6AJ7rvTJTihu77mZZ1OvjGu vShfG+npyYqqbCcQsSsHOd4Egnys050VEfy0l+BHK8ZakfWDO0moEGx3IpzG9IrnQ94o TwePqsyUu1PKv6CrECPmu7Bxy26UOYRZukSiOHaeS5d/i2pelPPoN4l6zyJcLUXithx7 7d4OK9/odmvdqQUZdgGKrnOGjHGE55xBumjjgOI2PaAwu6gHTBqMkPiEAR7YRJdFBpRN 4B8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=j4Q7bRb8HHM3N8hJT+aAO6okpwwtwrCPrryZPqdYBv8=; b=JSJrZFwA5yGfZ+m+0rEL+OZwhRx21fqCVr/qc0WwT4gllvjI52yHHP8YEr1jeX6D7+ i83LTs8Y1VM1PdrDrhMayL1RDl+vUvBB6hHU4UpxKSjEazZBiYsrifb3DurlK/lMx10/ d2SnkO4Z2VIrYl1raz/WX4stqg0XHB6gjiqhUMVqoqTOdYXUhSs1HmnAc9JBE22B4LRN PXfxYkywg56Xd4Vqpmua4YmHwQ4BKNf6OYYu9yI3ZDkV0lCHujO7RmCiYK+xRWQYjp+W vAqtMJ8PkPeaSxwDtUag31EfRW0ylGWDxiSB6vB7tLV1SvuWeh09n4nuxdIA3NFgd1MU Fvig== X-Gm-Message-State: ALKqPwcfvmff2JH9wL0QtUFHTTFkdujrwc954PdtEguQfM1plWrb4+Zn LQOK8IDpQxQ0rzgSupD6O0Y+0tfxJ3AL2So0PivvFw== X-Received: by 2002:a63:ab45:: with SMTP id k5-v6mr3642715pgp.192.1527113311005; Wed, 23 May 2018 15:08:31 -0700 (PDT) MIME-Version: 1.0 From: Nick Desaulniers Date: Wed, 23 May 2018 15:08:19 -0700 Message-ID: Subject: [clang] stack protector and f1f029c7bf To: hpa@zytor.com Cc: Alistair Strachan , Manoj Gupta , Matthias Kaehlcke , Greg Hackmann , sedat.dilek@gmail.com, tstellar@redhat.com, LKML 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 H. Peter, It was reported [0] that compiling the Linux kernel with Clang + CC_STACKPROTECTOR_STRONG was causing a crash in native_save_fl(), due to how GCC does not emit a stack guard for static inline functions (see Alistair's excellent report in [1]) but Clang does. When working with the LLVM release maintainers, Tom had suggested [2] changing the inline assembly constraint in native_save_fl() from '=rm' to '=r', and Alistair had verified the disassembly: (good) code generated w/o -fstack-protector-strong: native_save_fl: pushfq popq -8(%rsp) movq -8(%rsp), %rax retq (good) code generated w/ =r input constraint: native_save_fl: pushfq popq %rax retq (bad) code generated with -fstack-protector-strong: native_save_fl: subq $24, %rsp movq %fs:40, %rax movq %rax, 16(%rsp) pushfq popq 8(%rsp) movq 8(%rsp), %rax movq %fs:40, %rcx cmpq 16(%rsp), %rcx jne .LBB0_2 addq $24, %rsp retq .LBB0_2: callq __stack_chk_fail It looks like the sugguestion is actually a revert of your commit: ab94fcf528d127fcb490175512a8910f37e5b346: x86: allow "=rm" in native_save_fl() It seemed like there was a question internally about why worry about pop adjusting the stack if the stack could be avoided altogether. I think Sedat can retest this, but I was curious as well about the commit message in ab94fcf528d: "[ Impact: performance ]", but Alistair's analysis of the disassembly seems to indicate there is no performance impact (in fact, looks better as there's one less mov). Is there a reason we should not revert ab94fcf528d12, or maybe a better approach? [0] https://lkml.org/lkml/2018/5/7/534 [1] https://bugs.llvm.org/show_bug.cgi?id=37512#c15 [2] https://bugs.llvm.org/show_bug.cgi?id=37512#c22 -- Thanks, ~Nick Desaulniers