Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4551325pxv; Tue, 27 Jul 2021 10:01:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzk2bQP/CzGqIbAVl5d4PBmsWZuIX7FhE+EjFZfhBIzzyzD31UcdCWnaHWcF51iT+rEPFVd X-Received: by 2002:a05:6e02:525:: with SMTP id h5mr17039137ils.205.1627405271931; Tue, 27 Jul 2021 10:01:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627405271; cv=none; d=google.com; s=arc-20160816; b=dcOizI260+66FAu4z89eBvDNcAiQPi/uXo3I7fE9tFsa9xDndIvqB31vdFZrQow2Zt jdDJyLTCjK5VbzAzVTvBzPpTslyY+NF5UIlGNHS+ZqG8KmK1S5XFPlDnkU1xb+zR8x+u I7d725ww31RD9S7HQDJMs2DGN3Ze53hJQnGI4T4TPhW5hM5q5hEyhFAOumS36tbcVWHW vdYFzo0Js3gpbnQInuxqvTLZagnpie2Szt5CiT3hVUWQ1Pmad3Xw/Zcy0VrEeK5oTng3 bY/YvB76PqhXVRRr5Z4AfnpnZqhGcglZX8S0/cmAWqc7x33AljHl2y9w4WNL8/w4VfvD waLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=06umT0zgrhbjqNYxTt/dijb316TtIb66gqZamU5hdxM=; b=IdjnoaFWIJ8V6+PdKdE0EF8S7DU9LFrzCK7I3c7n+wCQ43nwx8VixW6yTm2Bpnwgso 13E4PiHqIBd0GjRHi5eZnC4t3Gv54pLwr5VBjnjqWNXdZtrYmV+Jbudkh5rqpcDxzkRP PL78PjcPV1MDaWIE4BWIjg8KqChkQLiNa/SzwoD55WG04+88OEb4tetSgl1drMKOJW2S BrMrv9ovESw67l7OGhX4mZ06x0vdAkqlgP5xBSwIIFAC19L2ZtFzoQxdmlOh3gDZSh2k m2Dm/QfxcdYGYnGJJLw3tMKcCxDkH1/qczrenvjzZ0MnC2gNE7Jk8tUkzgd/UH8IG9qm U+5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sHVfj6ot; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d24si3751594iob.3.2021.07.27.10.00.37; Tue, 27 Jul 2021 10:01:11 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sHVfj6ot; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230130AbhG0Q7r (ORCPT + 99 others); Tue, 27 Jul 2021 12:59:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229861AbhG0Q7q (ORCPT ); Tue, 27 Jul 2021 12:59:46 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87C15C061757 for ; Tue, 27 Jul 2021 09:59:46 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id e19so23105839ejs.9 for ; Tue, 27 Jul 2021 09:59:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=06umT0zgrhbjqNYxTt/dijb316TtIb66gqZamU5hdxM=; b=sHVfj6otChHKWbga7Ddf8n6RnUnQh6ZUFziuMhN2QT+dEW3QkHlt/RrZeeSN5Op6Mq Ku96mKjq9jZ5lMY6kkC6JSm5Az9dKZ8wXJG4DJ/LrzFaopoXJOKINiwggTR207bZaFux 16ow1EAM0hZJKbg8K98iqAzqJrEf2/Gf82mqjvLfuR+7MHBUABKb3V0S3qlXZxsT250s 8pkd0icXd2OTdYYjjom9xOFyOxWsLeczBGz2c79rNZQzBdmoNa8mO82uNdDuPgA3PSXa HckLgl5DFh9CXruGSyqmJPmwLFqhSSlKNHhC6sDU0nxxgTTUrcxaJgTjoabjzlLtiARe Bysw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=06umT0zgrhbjqNYxTt/dijb316TtIb66gqZamU5hdxM=; b=enwfbNyJDdFDvOqI9xi0ECNdJ1ufsWNRxHlZZ96ETxilg3ekvRGPsGdQcukf0BwLCx oyFqE22w6l7uTqI7Zkem1owJIRhUmFqvwm/bmc5bkL5T/jyEAokIaJG3UVKVIYFOqQrY 5SBISwQOL3sQoE7+LAaSszGBzD0J9dX9txjitxUP3jM4Pw19l08r6AsHhUDBk7Y+wt3H F8BMXjKvcU5gvV+yuc8qqj68LDLyl/ZSrqA4J+/KOflVLxmhZNOs/G4B44fBQTeKymSu Xc5cszgVVRvXXhQvg8br64d9MPUzPq7VriXwbL0z1Ddb+qKDWUPewW5pCSkE5Y4JuaVm xJQQ== X-Gm-Message-State: AOAM532nVQWSvuLZ9sDN5eWlx458LqlUi1tpWhpDtapEGdwPgfcjVv7C w4TnB1PdA0pbltgV/lwKZpI= X-Received: by 2002:a17:906:4ad9:: with SMTP id u25mr8141470ejt.106.1627405184530; Tue, 27 Jul 2021 09:59:44 -0700 (PDT) Received: from pswork ([62.96.250.75]) by smtp.gmail.com with ESMTPSA id p18sm1465434edu.8.2021.07.27.09.59.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jul 2021 09:59:44 -0700 (PDT) Date: Tue, 27 Jul 2021 18:59:43 +0200 From: Padmanabha Srinivasaiah To: Sami Tolvanen Cc: Steven Rostedt , Ingo Molnar , Padmanabha Srinivasaiah , Nathan Chancellor , Nick Desaulniers , LKML , clang-built-linux Subject: Re: [PATCH] tracing/syscalls: Clang cfi enable syscall events Message-ID: <20210727165943.GA21786@pswork> References: <20210720221541.16164-1-padmanabha.srinivasaiah@harman.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 26, 2021 at 08:17:45AM -0700, Sami Tolvanen wrote: > Hi, > > On Tue, Jul 20, 2021 at 3:16 PM wrote: > > > > From: Padmanabha Srinivasaiah > > > > With clang cfi syscall symbols are appended with .cfi_jt, > > hence syscall tracer can not find corresponding syscall name. > > And results in no syscall ftrace events with CFI. > > > > To fix this issue, this introduces custom cleanup_syscall_symbol_name() > > to strip postfix ".cfi_jt" before comparing syscall and symbol name. > > > > Signed-off-by: Padmanabha Srinivasaiah > > --- > > kernel/trace/trace_syscalls.c | 22 ++++++++++++++++++++++ > > 1 file changed, 22 insertions(+) > > > > diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c > > index 8bfcd3b09422..dbc253fea34d 100644 > > --- a/kernel/trace/trace_syscalls.c > > +++ b/kernel/trace/trace_syscalls.c > > @@ -79,6 +79,27 @@ trace_get_syscall_nr(struct task_struct *task, struct pt_regs *regs) > > } > > #endif /* ARCH_TRACE_IGNORE_COMPAT_SYSCALLS */ > > > > +#if defined(CONFIG_CFI_CLANG) && defined(CONFIG_LTO_CLANG_THIN) > > +/* > > + * For a syscall symbol, clang generated non-canonical local jump tables > > + * will have entry as .cfi_jt and address of this entry > > + * will be used to replace references to the syscall symbol. > > + * so we will strip the postfix from appended symbol name. > > + */ > > +static inline bool cleanup_syscall_symbol_name(char *s) > > +{ > > + char *res; > > + > > + res = strrchr(s, '.'); > > + if (res) > > + *res = '\0'; > > + > > + return res != NULL; > > +} > > +#else > > +static inline bool cleanup_syscall_symbol_name(char *s) { return false; } > > +#endif > > + > > static __init struct syscall_metadata * > > find_syscall_meta(unsigned long syscall) > > { > > @@ -90,6 +111,7 @@ find_syscall_meta(unsigned long syscall) > > start = __start_syscalls_metadata; > > stop = __stop_syscalls_metadata; > > kallsyms_lookup(syscall, NULL, NULL, NULL, str); > > + cleanup_syscall_symbol_name(str); > > Shouldn't this happen in the kallsyms code instead? We already have > code there to clean up function names, and it seems like we should > just strip the postfix there before returning the name. > > Sami Thanks Sami for the input, yes have regenrated patch: https://lore.kernel.org/lkml/20210727140618.19130-1-treasure4paddy@gmail.com/T/#u