Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2319634rdb; Tue, 3 Oct 2023 18:37:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGLrNqTuDtx94YzeCmSNRJz7UdkYzgXtxhVwXk5dV0e9W7A1SwgW7x3KY4RDFJkQWSSUS+A X-Received: by 2002:a17:902:e889:b0:1c0:bcbc:d66 with SMTP id w9-20020a170902e88900b001c0bcbc0d66mr1569670plg.7.1696383475433; Tue, 03 Oct 2023 18:37:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696383475; cv=none; d=google.com; s=arc-20160816; b=UnS8y2jcr9xEjyqGrgZAP3oIWtm5YBj0J1NClr/kQFKgaUukgV7IfijYvu2VAD5ikO LkRU+Hyk5dm4EIY1w2uimlMIjI6HACFvYLyqg8jUkQSU5lAQp2wqlbzZwI0X2hb4QA94 R8IjlRn/WkEML/URNV4Nq53rgamd1Elx28fLcbfnO7iB34fkWOToU6ydIKDTRGmrvBGZ PCl0EiT6ofXmrmTE9/J/nQ8MVyOy0OHBOEyizWuaDD3FarGNAvwMWTHuL2CDKT1rN9yr oojPI9Fq9iosT6hGFwFTKeIboxf6nb1UKqppVyGXXwUGjqe1BXwd74/Jh7mrAttlaK2F LcUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=9VHezuf6e9/JpzJX3VKCGlSGURCz/ig2Ob6V4gZEJ6g=; fh=+A3dHFZKshARabzsZlJSHeu8D1+4anv5lVNa51lKvLo=; b=RQNspVbIvfXhIjXFxNyDSkl6ZCTI8e8PBaoGFw/AWNCOm02OJ5l7zNsv/aeAhb8VCt cbDzLcKV0+np3Eoux31S2SLgd36D2daoiKaLdfK3Lm7Kprnv7l8lW/D5O9U2+SkfZHUn 7Yga0+3imIm2eQbbV8TyLwS/9OBjPgAMacT5FWyU0aHBSLshYmfOzVJhdHGruQY/YMYL XrBhQAAGeaaebJdMgc1N/IaQ6RZrjMRkUdB91z/pn5afgh9V2DupXys8Q+ZSvFMsi1Bq 6YBdosbasl6BV907FxlZfk8I83ZsiOXfA+aSRl3uh2bSVF4Z/3WLzh1Ja3rfY6HmFKZj TfLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id b14-20020a170903228e00b001c5e1816251si2971722plh.497.2023.10.03.18.37.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 18:37:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 71CAC8229F27; Tue, 3 Oct 2023 18:37:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239633AbjJDBhp (ORCPT + 99 others); Tue, 3 Oct 2023 21:37:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230274AbjJDBho (ORCPT ); Tue, 3 Oct 2023 21:37:44 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EF54AB for ; Tue, 3 Oct 2023 18:37:41 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FBC9C433C7; Wed, 4 Oct 2023 01:37:39 +0000 (UTC) Date: Tue, 3 Oct 2023 21:38:44 -0400 From: Steven Rostedt To: Artem Savkov Cc: Masami Hiramatsu , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , bpf@vger.kernel.org, netdev@vger.kernel.org, Thomas Gleixner , linux-rt-users@vger.kernel.org, Jiri Olsa Subject: Re: [RFC PATCH] tracing: change syscall number type in struct syscall_trace_* Message-ID: <20231003213844.1de0c138@gandalf.local.home> In-Reply-To: <20231002135242.247536-1-asavkov@redhat.com> References: <20231002135242.247536-1-asavkov@redhat.com> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 03 Oct 2023 18:37:52 -0700 (PDT) On Mon, 2 Oct 2023 15:52:42 +0200 Artem Savkov wrote: > linux-rt-devel tree contains a patch that adds an extra member to struct > trace_entry. This causes the offset of args field in struct > trace_event_raw_sys_enter be different from the one in struct > syscall_trace_enter: This patch looks like it's fixing the symptom and not the issue. No code should rely on the two event structures to be related. That's an unwanted coupling, that will likely cause issues down the road (like the RT patch you mentioned). > > struct trace_event_raw_sys_enter { > struct trace_entry ent; /* 0 12 */ > > /* XXX last struct has 3 bytes of padding */ > /* XXX 4 bytes hole, try to pack */ > > long int id; /* 16 8 */ > long unsigned int args[6]; /* 24 48 */ > /* --- cacheline 1 boundary (64 bytes) was 8 bytes ago --- */ > char __data[]; /* 72 0 */ > > /* size: 72, cachelines: 2, members: 4 */ > /* sum members: 68, holes: 1, sum holes: 4 */ > /* paddings: 1, sum paddings: 3 */ > /* last cacheline: 8 bytes */ > }; > > struct syscall_trace_enter { > struct trace_entry ent; /* 0 12 */ > > /* XXX last struct has 3 bytes of padding */ > > int nr; /* 12 4 */ > long unsigned int args[]; /* 16 0 */ > > /* size: 16, cachelines: 1, members: 3 */ > /* paddings: 1, sum paddings: 3 */ > /* last cacheline: 16 bytes */ > }; > > This, in turn, causes perf_event_set_bpf_prog() fail while running bpf > test_profiler testcase because max_ctx_offset is calculated based on the > former struct, while off on the latter: The above appears to be pointing to the real bug. The "is calculated based on the former struct while off on the latter" Why are the two being used together? They are supposed to be *unrelated*! > > 10488 if (is_tracepoint || is_syscall_tp) { > 10489 int off = trace_event_get_offsets(event->tp_event); So basically this is clumping together the raw_syscalls with the syscalls events as if they are the same. But the are not. They are created differently. It's basically like using one structure to get the offsets of another structure. That would be a bug anyplace else in the kernel. Sounds like it's a bug here too. I think the issue is with this code, not the tracing code. We could expose the struct syscall_trace_enter and syscall_trace_exit if the offsets to those are needed. -- Steve > 10490 > 10491 if (prog->aux->max_ctx_offset > off) > 10492 return -EACCES; > 10493 } > > This patch changes the type of nr member in syscall_trace_* structs to > be long so that "args" offset is equal to that in struct > trace_event_raw_sys_enter. >