From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AFCBC2D0A3 for ; Mon, 16 Nov 2020 20:38:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 262D020B80 for ; Mon, 16 Nov 2020 20:38:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731568AbgKPUih convert rfc822-to-8bit (ORCPT ); Mon, 16 Nov 2020 15:38:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:57826 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728374AbgKPUig (ORCPT ); Mon, 16 Nov 2020 15:38:36 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C95B5208C3; Mon, 16 Nov 2020 20:38:35 +0000 (UTC) Date: Mon, 16 Nov 2020 15:38:34 -0500 From: Steven Rostedt To: Sami Tolvanen Cc: Kees Cook , Josh Poimboeuf , Colin Ian King , LKML Subject: Re: [PATCH] samples/ftrace: mark my_tramp[12]? global Message-ID: <20201116153834.57ace64e@gandalf.local.home> In-Reply-To: References: <20201113183414.1446671-1-samitolvanen@google.com> <20201116113931.2b60a191@gandalf.local.home> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 16 Nov 2020 12:10:10 -0800 Sami Tolvanen wrote: > On Mon, Nov 16, 2020 at 8:39 AM Steven Rostedt wrote: > > > > On Fri, 13 Nov 2020 10:34:14 -0800 > > Sami Tolvanen wrote: > > > > > my_tramp[12]? are declared as global functions in C, but they are not > > > marked global in the inline assembly definition. This mismatch confuses > > > Clang's Control-Flow Integrity checking. Fix the definitions by adding > > > .globl. > > > > > > > Actually, since that function is not really global, would it work if you > > removed the "extern" from the my_tramp declaration? > > Unfortunately not, removing the "extern" doesn't seem to change anything. > > > In other words, is there a way to tell C that a function is declared in an > > inline assembly block? > > I'm not sure if there's a way to tell C that a static function is > declared in inline assembly. At least I couldn't find a way that would > make the compiler happy. I'm trying to see the warning. What option makes clang trigger a warning on this? >From user space, I'm just using the following file: #include void my_direct_func(char *str) { printf("%s\n", str); } int test(char *str); asm ( " .pushsection .text, \"ax\", @progbits\n" " .type test, @function\n" " test:" " pushq %rbp\n" " movq %rsp, %rbp\n" " pushq %rdi\n" " call my_direct_func\n" " popq %rdi\n" " leave\n" " ret\n" " .size test, .-test\n" " .popsection\n" ); int main (int argc, char **argv) { test("hello"); return 0; }