From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A333A4F55D8 for ; Mon, 19 Oct 2026 12:48:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792414095; cv=none; b=t3/JkxElWc66bEqFqHqqwypG+YZZUiXC3oz5D+66bxEVKsscjMkGqOITCZpMxuVBqVCV3uUa72XS4cRI3gSuYYHspf64tcZWpBl8dBooLCDrsx7/wpI4owO2NxySu6HFj3E329xFFD7Q7qmFlYioAVjGOha9149YAzS3BngJlGk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792414095; c=relaxed/simple; bh=86nGS9uPfGg9gcq8r5vJAaUgJrDwOhpChhHeWKpARi8=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=JGaHjah+Tczo35MPDXh0Qxrgup9wYj89AwC30caKDj5KU0XQGw7ZcVPAjeI/FMkvBbbamAtayAUjB47vawK97uR83IsmExyT2DcT128LLBsHSYSFwKTUHoI4qPdqqr2SYDcR8Nvvm4eoFySad8KrtTC3x+L1uFxnVUQM/WAFFXc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=OFr0PeoV; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=sLW5S1sE; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OFr0PeoV"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="sLW5S1sE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1792414088; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=OLGg1AUZIaGlF5KY0eyTieD5+shq6f3blrp1e976rzg=; b=OFr0PeoVwm5Fev30v9kUTsDJWHZKZGmbBFzxuKAreA2iLtUvvsaI2gyLkFoGo5uEXtF/ls gMDSbbE8NYoA4ejBau/nRco7l/7HO5JKyGShjT2MaUuO1D6Sa7j1QFJdU8wDUSCn0R7r6i OgRJu0X1Z/nNq4LaoEMuFlKuBlPgzc0= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-102-3zcMc627NJyGLs5umPn7nw-1; Mon, 19 Oct 2026 12:47:54 +0000 X-MC-Unique: 3zcMc627NJyGLs5umPn7nw-1 X-Mimecast-MFC-AGG-ID: 3zcMc627NJyGLs5umPn7nw_1792414073 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-48dff112136so1444567f8f.1 for ; Mon, 19 Oct 2026 05:47:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1792414073; x=1793018873; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:content-type :autocrypt:references:in-reply-to:date:cc:to:from:subject:message-id :from:to:cc:subject:date:message-id:reply-to:content-type; bh=OLGg1AUZIaGlF5KY0eyTieD5+shq6f3blrp1e976rzg=; b=sLW5S1sEEbUz8fx3tROBGUFcflsNjQh/GZhT0iLCtzzqeJm4LmlQ56KYlz1+MHSA2S bi9CMRkBinwlmNCks+MTvFr/f/78jYY7TCLQSL1zi+ID47HaD2oeSwJ5lQiSjdNoXn0X Vg0hIOtsUwIJ/4dmaQrneaKyUNo3fPS05vE+Zbj8VXWhyKxkI7KzCfa5QK+OQAvvLNMj IrvlKfm5z/SR2S1IRT+cb6T28DpiGxv+vQXG6nRXlRDkKzCPbjtNJivy83xOWamyk8Qu re3v5cwvOrQ4umXgyk5Jfu9JmUFiKlQ3Cgf9XSOz1cQpbZBgD53nE3GqfWVYuGUTJQHQ gDQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792414073; x=1793018873; h=mime-version:user-agent:content-transfer-encoding:content-type :autocrypt:references:in-reply-to:date:cc:to:from:subject:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=OLGg1AUZIaGlF5KY0eyTieD5+shq6f3blrp1e976rzg=; b=D5QnfttatyaRXjSg/BFOEUmRgxrTJZmqsU/oJuZHaZ9Bp1Vo7oL74wJ4vWG8aohQZc Bezq4ATPaB3URNOJFsudrAEvTTlZa1yYA8fj4ZNh3DoB0Ut7dZwd/BPyjr9zSprcTvFf 3Qw/qFufZm5gOeFo6Y/vK7XKF2YeczSW3HrL87q1CHDU8154PW37Ib3eOphlaa4LvD9u TVHvU9/uvUDDDMxOF6DrBcsHyZr+CIrX/yurUfWzBvSGiVQoY52+zYQJY4HXfF1m9VmT iQyLcpuowLg+MS3ovUckgKknL1l1b9AVEoEjdAfIkzHlOBHrZKUXkuBzWhUPuU4PC9m9 FFpw== X-Forwarded-Encrypted: i=1; AKwUvBzvq0hePjztsbA+Hmg8mPLXSIbMZwJrtMDmuDZxOa0uvzzWKdOhai932Zz92SF2Hu7OiIiIR3/EcVaHJSE=@vger.kernel.org X-Gm-Message-State: AFq9FYIdTYuYnRSoPPK1EJO25x9K7p2cQD8AzckhToNJZqMehJXfu5g6 xWswoXQioNFQjPW6QqThxhkInMy1V6HZ/IJjSNgL1zKyoJ0WGiJYNaP/fbTi2fA5+jcJPkbB+9H ZtLFvNEEVldDdi1HuGe2g2VtEkCFnRqbspdjpcVihufyuohyFnHc5OmBohjZiVs0hdw== X-Gm-Gg: AYBFou2gicwLk0spUaM8YzxM1EhnvmvlnoYisBs5HbK/w2NraQVVkl2qvldnfC8Q5B1 uHe5ytSOEljrt/jdacf6jDq14LVbdmSNLL0w0KU8BeNqIZUl8IBcFSkoy/FYu6e89uhH+3VSmgH BNohtLV54Jl7GeC6cQc1Yv7JO8Av9BcIkgSOXYAd1zZQiCTpN48PqR8wDsFSL7tu9WswtJIU/34 exevy3Ob1PqjM0R2F1K5KKywXOjoQ59XfysvyTy53x7imLvO5+DjVKp2vEMSqdMTKX2W+N78hHO BYX698vJEpJzJnVZUqaMJ12sldxRpUdQioGRSH90PvHBMPF78ziLaVF7JtWVLfU9yuNw5S0prbd RolxyHNAIsmdaB6ODTwiJ+mRc+g== X-Received: by 2002:a05:6000:1448:b0:486:f6dc:52c8 with SMTP id ffacd0b85a97d-48e07f9fae1mr14668788f8f.37.1792414073175; Mon, 19 Oct 2026 05:47:53 -0700 (PDT) X-Received: by 2002:a05:6000:1448:b0:486:f6dc:52c8 with SMTP id ffacd0b85a97d-48e07f9fae1mr14668720f8f.37.1792414072521; Mon, 19 Oct 2026 05:47:52 -0700 (PDT) Received: from gmonaco-thinkpadt14gen3.rmtit.csb ([195.174.134.4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48dfd5008e7sm22653462f8f.43.2026.10.19.05.47.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2026 05:47:51 -0700 (PDT) Message-ID: Subject: Re: [PATCH v2 10/15] tools/rv: Add BPF monitors From: Gabriele Monaco To: Tomas Glozar Cc: John Ogness , Alexei Starovoitov , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, Steven Rostedt , Nam Cao , Wen Yang , Tobias Schaffner , Viktor Malik Date: Mon, 19 Oct 2026 14:47:50 +0200 In-Reply-To: References: <20261001152042.124445-1-gmonaco@redhat.com> <20261001152042.124445-11-gmonaco@redhat.com> <878q3xtptq.fsf@jogness.linutronix.de> <8B3FF026-6159-48CF-8FEA-AF2FACD2E4EB@redhat.com> <87bj8s8ih9.fsf@jogness.linutronix.de> <87v770uuyr.fsf@jogness.linutronix.de> <87ik2zryzo.fsf@jogness.linutronix.de> <0055967d4571e7c8549dfa476fa6b15b93013701.camel@redhat.com> <8580176d216258e9008c344e0529509117dcc18b.camel@redhat.com> Autocrypt: addr=gmonaco@redhat.com; prefer-encrypt=mutual; keydata=mDMEZuK5YxYJKwYBBAHaRw8BAQdAmJ3dM9Sz6/Hodu33Qrf8QH2bNeNbOikqYtxWFLVm0 1a0JEdhYnJpZWxlIE1vbmFjbyA8Z21vbmFjb0BrZXJuZWwub3JnPoiZBBMWCgBBFiEEysoR+AuB3R Zwp6j270psSVh4TfIFAmjKX2MCGwMFCQWjmoAFCwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgk Q70psSVh4TfIQuAD+JulczTN6l7oJjyroySU55Fbjdvo52xiYYlMjPG7dCTsBAMFI7dSL5zg98I+8 cXY1J7kyNsY6/dcipqBM4RMaxXsOtCRHYWJyaWVsZSBNb25hY28gPGdtb25hY29AcmVkaGF0LmNvb T6InAQTFgoARAIbAwUJBaOagAULCQgHAgIiAgYVCgkICwIEFgIDAQIeBwIXgBYhBMrKEfgLgd0WcK eo9u9KbElYeE3yBQJoymCyAhkBAAoJEO9KbElYeE3yjX4BAJ/ETNnlHn8OjZPT77xGmal9kbT1bC1 7DfrYVISWV2Y1AP9HdAMhWNAvtCtN2S1beYjNybuK6IzWYcFfeOV+OBWRDQ== Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.60.2 (3.60.2-2.fc44) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Mon, 2026-10-19 at 13:05 +0200, Tomas Glozar wrote: > On Mon, Oct 19, 2026 at 12:43=E2=80=AFPM Gabriele Monaco wrote: > >=20 > > > One disadvantage of using bpf_trace_printk() for RV violation > > > reporting is that the event will be caught by every instance that > > > enables bpf_trace_printk() and does not explicitly filter rv out. > >=20 > > Yes, that should somewhat be mitigated by the glob filter, though event= s are > > still generated. > >=20 >=20 > Do I understand it correctly that the idea is to modify existing > tracefs instances when enabling an RV monitor to filter our RV-related > bpf_trace_printk events? Not quite. The initial issue is that the current iteration of RV BPF monito= r don't cooperate well with trace-cmd/perf. Alexei suggested we use bpf_print= k and filter out the desired events with plain ftrace glob filters (from trace- cmd/perf). I believe this would be usually equivalent to having a dedicated tracepoint= for RV BPF monitors. E.g. you'd do (roughly): trace-cmd -e bpf_prink --filter 'bpf_string ~ "rv: sleep: * violation" instead of (with a new kfunc) trace-cmd -e rv:error_bpf --filter 'monitor =3D "sleep"' Now, I didn't try either way and don't know what implications there are eit= her way (you seem to know better about this). > > > I can imagine an RV-specific trace event for that, however, it would > > > require a separate kfunc to generate it, and ideally also distinct > > > labeling of a BPF program eligible to call that kfunc. The "rv" > > > userspace tool could then iterate over these labels so the user knows > > > which violation events can be expected to occur on the system. > >=20 > > That'd work too. It's what I initially envisioned but I'm not sure a kf= unc > > producing a tracepoint is something BPF folks would really like (and > > technically > > any other unrelated BPF program could call that, unless there's some ac= cess > > control mechanism I'm not aware of). > >=20 > > Not sure how much it matters in practice against the glob filter, it > > probably > > really depends on the other bpf_printk users (and a mildly better > > usability). > >=20 >=20 > bpf_trace_printk is already a BPF helper producing a tracepoint, this > would be equivalent. Fair point. > Of course, that does not mean we want it, but it > is something we already have in at least one instance. I know of at > least one quirk: you can have a BPF program attached to a tracepoint > that will call bpf_trace_printk(), and a tracefs instance tracing both > bpf_trace_printk() and the original tracepoint. That leads to a new > tracepoint triggering while another tracepoint is already in progress. > I don't know how it is currently handled; from what I recall when > testing RTLA's BPF actions, the bpf_trace_printk() event might get > dropped by the tracefs instance, so I had to use a different way to > signal to userspace in BPF actions test. >=20 > As I said, to prevent unrelated BPF programs from calling the new > tracepoint, you'd need to recognize and track RV BPF programs as a > special type of program, similarly to what your original RFC did. I'm > not sure if that's what we want, but I see some advantages. Yeah, this last step is probably something we don't want. Although it may not be such a bad thing: if we require enough privileges to trigger this tracepoint, then the worst we get is root trying to mess up wi= th monitoring, where it could easily mess up with everything else already. But it definitely needs more thinking. > In addition to better filtering of reactor events, you could separate > reactors from the monitors entirely: you could trigger the tracepoint > unconditionally, and attach reactors as tracepoint triggers to the new > tracepoint. Something like this was already brought up actually and isn't a bad idea, i= t has its strengths and issues but would somewhat work in-kernel as well. But as you said, that's a bigger reactor refactoring and beyond the scope o= f this submission. Thanks, Gabriele >=20 > All of that adds complexity, though, and requires separate discussion, > so it's probably not something relevant for the initial > implementation. I just wanted to mention it so that it doesn't get > lost. >=20 > Tomas