Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp39650imm; Fri, 25 May 2018 15:38:51 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrcRqYNrwe+Uf5pqP3i7dq1mVG3Jz0mmDGyWdDgdkeWyBX9kjZt0nyCkSrk2c2Rnj0+XG75 X-Received: by 2002:a17:902:bb07:: with SMTP id l7-v6mr4405074pls.128.1527287931661; Fri, 25 May 2018 15:38:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527287931; cv=none; d=google.com; s=arc-20160816; b=QAzjVXYhC9avhux7MfjwwRhqDgnOyupeiEmSLIxqm9jsPljED4SlIQirXX31mqN7Cs bQUeEHvyNoQGUQ6kmrLv5NFj6o2tH99xIAcIpu6COw/YUS489mIhAOkFuo+j9B1OlKqe iq94R0paFigO/2L/lUw+htZUi4EU0PsckavEYJ1cM54aFH6wiGUVXodhDMSoK1QErufF pqnS7d52JlQS41R8pF3S+TTXudpiBYeJtXxajrO8ToTECWzi9rPeAXNveX8QNNfsCo1P 0Wct/C41zGU5qeKuwZ3fVliWW2LF2l6zZ6OoNapz8SS4WYutQfusIdJTGHmeao1oyNu2 CajA== 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 :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=jvq2KxemYE9mhHh2WMHYSiaIcWPxS0B0Ezvss8n63RM=; b=zFB3IQFi7StdQT4hsJLUPK8+NNU3JebYrxlfOwztIcgsxT9L7DeKjJg4Syyijv/jBw VW5eIPOgBYA1a1gmCyJaJylAT8dXZ+1tlKOhk2MdvsLncNV40G+TqxkyxNoU+jEs4+XM VXRkTkpSlDE3JtmDOTo6BLuyWmtpGoopP4CeDy8h2oaibUqFNebMaSWWZzlNUQWw90rC tyevuUFkq2FhoIA5VVYgIurvxrpd9j7/cJ52mAmMHfUGCa+z+vd6Usks6qnhGKFMTSZV jGMVA24W3KfppyaDUJv8XZcDO5h7KtfMURTS8+YuzlEl0oQc/rh3Ww+gIrial/R/oTeG xnCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=IkrpCwZe; 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 a11-v6si19466619pgt.680.2018.05.25.15.38.36; Fri, 25 May 2018 15:38:51 -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=IkrpCwZe; 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 S1030683AbeEYWi0 (ORCPT + 99 others); Fri, 25 May 2018 18:38:26 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:45629 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030394AbeEYWiY (ORCPT ); Fri, 25 May 2018 18:38:24 -0400 Received: by mail-pl0-f65.google.com with SMTP id bi12-v6so3891231plb.12 for ; Fri, 25 May 2018 15:38:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jvq2KxemYE9mhHh2WMHYSiaIcWPxS0B0Ezvss8n63RM=; b=IkrpCwZeOHhRoEB7Iad2wJ40Th2TJisLG7OhzTvP6Gye8aQgBmOBBE/SLrbkChwDyC OmFNvhnDQh6UhJi+5Btmn8fgAJmB7JGez7U1J9oIXa7iPJyE4mkifr0K6D4f1TQuXEHt A98MuO4LmfpKfzO/sICnIuxdxtmt3NUNWwxC8T0l5GUCIvoNI00QEy6i6fWvjAgHsrSg zKNjhb088XYg2l/EiLGibwma3X+OJKhZd3wosefhTXISTyZL1Mf6YJcmbIwWkDP8bwoR 1oHJVPL3Pln1cNx2z4VIr/7jukQCmoIly3Ug8a60zMbLim0sU6rBx+1uD1jjdocAZUlG S1Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jvq2KxemYE9mhHh2WMHYSiaIcWPxS0B0Ezvss8n63RM=; b=HL/jXcIkdpsydsZ1+vLH41q6oNgOPZrSTIKY3qN9wXyKAfgtCvmv5k83UBNppngtcj +v0AXZN1dvkb6T+2JqhhvRLBaIjK80j/659+/+n57vMrExkRH8lbP+okwMTD93zVN7H4 KU0HfNDJa4gLMuLuyQLkBX/PO9f1HVQdAYWn5JFG7XFz9Cp6CgJkTuPEQ/O0BFoL0o6H SEBjyFvB4M6RLThJtKQNeB0XB84F4mNhDS52skzl4Pmsg74CoK9MqJ5aFJHp9AT/BVtB qCoI+OQDzRLl00aZiO1LXu1pXQGj1JzieBI2h4caIrBy+fT2S91xBJWkteLDIyZns46B xTQQ== X-Gm-Message-State: ALKqPwfIZl7CbHRXlmQvFd3A6wWwt1hKPsShHTOmUcws49D+ht+IxTPV XDmWFOWeWf/liDgbqwyh4EH0omXM/pcUjo6o8v6UYQ== X-Received: by 2002:a17:902:1347:: with SMTP id r7-v6mr4290414ple.62.1527287903652; Fri, 25 May 2018 15:38:23 -0700 (PDT) MIME-Version: 1.0 References: <26B017D5-4063-46CB-8768-B0E5E7CD3838@zytor.com> <319FB971-ABB6-4BE7-969B-D87D84853196@zytor.com> <31A5469A-176F-451F-886A-ECD649DDC78C@zytor.com> <38f21c66-fa34-3a77-33bc-d15065c15af9@zytor.com> In-Reply-To: <38f21c66-fa34-3a77-33bc-d15065c15af9@zytor.com> From: Nick Desaulniers Date: Fri, 25 May 2018 15:38:11 -0700 Message-ID: Subject: Re: [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 , Kees Cook 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 On Fri, May 25, 2018 at 2:06 PM H. Peter Anvin wrote: > On 05/25/18 13:36, Nick Desaulniers wrote: > > On Fri, May 25, 2018 at 10:56 AM wrote: > >> You need the extern inline in the .h file and the out-of-line .S file > > I don't see how you can specify to the linker from assembly source that > > this function should be treated as `extern inline`? > "extern inline" is a C directive. In the header file you should provide > the inlinable implementation (which is already there.) It means that "if > you don't want to inline this there is an external implementation > available." oh you put `extern inline` on the definition, not the declaration?! What?! http://m68hc11.serveftp.org/inline-1.php in fact documents that trick. Wow, I've never seen that before. Seems like there's not too many instances in the kernel. This seems to inline native_save_fl() properly into the call sites, but the boot code now fails to link due to multiple definitions when trying link the objects from arch/x86/boot/compressed/ into vmlinux. When disassembling the the arch/x86/boot/compressed/ objects, I can see they're pulling in the `extern inline` c versions, but still outlining them! (gcc and clang). That seems to contradict the statement from the above link: "In no case is the function compiled on its own, not even if you refer to its address explicitly" This is kind of funny; first we were wondering why native_save_fl was getting outlined as a static inline function, which Alistair tracked down to the incorrect use as a function pointer. Now I'm playing why is native_save_fl getting outlined as an extern inline function. If I move the .S file to be in arch/x86/kernel/boot/compressed, the boot code now links but then paravirt.o fails to link. Referring to the .S from both Makefiles results in multiple definitions that the linker doesn't like. (and the boot code still containing outlines). I don't understand how `extern inline` signals to the linker that "this version should be taken if you find no others". From what I can tell with `readelf -a` and `objdump -d`, a function marked `extern inline` vs not look similar. Then again, arch/x86/boot/compressed/Makefile completely resets KBUILD_CFLAGS and KBUILD_AFLAGS, which may be problematic (if there's some kind of command line flag that affects `extern inline` linkage). -- Thanks, ~Nick Desaulniers