From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AEB4348CD72 for ; Wed, 29 Jul 2026 13:29:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785331779; cv=none; b=nsN+qJw4pKaIr1C42iqkK0Wtl/tvYXVIKQ8i/RFTEgm1jWUiiQm9UMQY97dINjEAxN+5H5P/YEhrW488Y+j6TN+K1GK1vm6I6CIDsC4/RSyff5Vfm2ZoGVkFB9Z+FHNmK16tSBQVax6VdbR19CBOdTT7FUJIWRJQHP33XS08m6s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785331779; c=relaxed/simple; bh=PHt+aRmkFWbvB8uR6W5QXVfMRltRQJ9Is6QfG2qzQ2A=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=m96ntrKkepYr/iZhz3IX/XKCEDMR3Hc1XuTyGkHyZkIRQ9fWkVdtxk4Jgn+MA/aQsDoDuLKL2EXOeG9z4TdHv1ZIiO8+U6l4+eJ57lRDDZFc3yWneWDinVq7UCC4tYSCHWjW1x6J1OF8pn8cTSv9ZAZQBxtdD9pk1SYJhilIUtI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LHnG/e1q; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LHnG/e1q" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-49558ce01afso6633735e9.1 for ; Wed, 29 Jul 2026 06:29:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785331773; x=1785936573; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:date:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=DK37VB3qMOhbD5yb9Im3WBPoq9gsNNuMseW5SbMeCGk=; b=LHnG/e1qy+rsALO7v0Ccj8HwqpildvCNBXCZr1nm2WojnRGD67GKCIVpoFWPtVl7jq xVN73dmX/fwjmjx6ekQEDm2betmAOuV/QxiXhFz/Kz+X5YW8N4j0fuVxxNbEPBq9UZZj wpn9f7dTv+3HqWnT/VkDAWkMg7DyXujnsPkVO3UbWcQEkQCV6pnyA4ToGCd5ILZngKz7 UlZR4lfFTjKNayXfrzsbduZYnZ1cPdWfDDMZlGyr4FH4HJcrgzBPFnWJnFiwj6TkCqax bhqsoh5HV2QigIOzBX0HT9LyxKjoeUv3rQVB24RrVXSv3ELzHlNtDvvqyFmNrhWiohUS Pe2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785331773; x=1785936573; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=DK37VB3qMOhbD5yb9Im3WBPoq9gsNNuMseW5SbMeCGk=; b=MqNzmPECh97rcXX7ualtJlOKAT2FWHbskh87JQsNhC7og+mNxjW6VWgO8OYnzltVPo PqvukgyA4cSjLxjR4erSj0T2tV71br3JIuqCXjrRLmrqtpCbSMvBgrdNx3r0rURYwv9c q74h0TanIWaavEyJrZCpg7eKmNWE52+hC1hNT8Lz/R6laQxLEJZsdFIoHz5iXPocL/Dg +LXu4EP15K0lRyAJf9M98Sa8TSGfPrWzDNmDj05/VwbcQh5zQtUQXst7OKsg99NOw9mU LNETq9YdgLGyN13QQj68ZEv53jzQrJvWVpcck+bJscAP3FYSpsf5A82ke7MQU3y2aiwW a0jA== X-Forwarded-Encrypted: i=1; AHgh+Rq4irdcYSfpmRVMK2UUve+a7bxb605k5S7j66sF+BsobFSi4Xd4GZJpm5uP3GDZzzQNfA55LjQzZcB59fIhk/g=@vger.kernel.org X-Gm-Message-State: AOJu0YxVgy4HHLZ6rf0JkoBJTpC8bkOWKJakXamX8vClsIgN2vO0XE7E KXbzIljdS6Hmf05CSYvxiD3u5R3V5tyAuTrwq1jBPL0ySwsHaE6ySysfrdsM1g== X-Gm-Gg: AR+sD10BmRN7tOX9qMjn6Y/nDMFXGdGIQ2c3Lxd5QdOzQUQOnhF/rh1iaSQgngtyPSp YMdwR1ZcMvyKKrMEjH1EzkBhXusPtjshQLLsqGrex8anEDkL14OsyZkVVD95rFlXAhDa2g/ZHLQ orkYu064GVtx170Q8YjhmKPu0yBNRUg/7owzm6AkV371TxtN/eHGNZuwTtQaxYnpWIokHGRbSuV IiwnZRNWKUXnDVsgA8MK793FTZs4HGMzt8XE3NKON/l2J7TefOa+cOLj6t9X/qCWtlPqecVJqzQ 9oLZAG+6Gu8uXVoh5AEBhIar+D/DrBuMkVgO5ncy4evWQxdAYeoML3Wu2xo15YnCyrHdZMxwRyd pZFxD0LPQdU7RAlYuMz35Ebmc2XKPv4+BNsMW9GIO88vMylzNI/DyoaXlzijqRnip1cywc75Gd+ 1YhbWDbuEfNoDu7c5GLVoQcI5lv8z57N33BA== X-Received: by 2002:a05:600c:b85:b0:495:6934:414c with SMTP id 5b1f17b1804b1-496c656e6d8mr85293065e9.19.1785331772970; Wed, 29 Jul 2026 06:29:32 -0700 (PDT) Received: from krava ([2a02:8308:a00c:e200::dd7e]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-496c4615681sm158139025e9.11.2026.07.29.06.29.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jul 2026 06:29:32 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Wed, 29 Jul 2026 15:29:30 +0200 To: Andrey Grodzovsky Cc: bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, song@kernel.org, rostedt@goodmis.org, naveen@kernel.org, davem@davemloft.net, mhiramat@kernel.org, stable@vger.kernel.org, linux-open-source@crowdstrike.com Subject: Re: [RFC PATCH bpf-next 1/3] bpf: mark trampoline ftrace_ops permanent Message-ID: References: <20260729005959.3853865-1-andrey.grodzovsky@crowdstrike.com> <20260729005959.3853865-2-andrey.grodzovsky@crowdstrike.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260729005959.3853865-2-andrey.grodzovsky@crowdstrike.com> On Tue, Jul 28, 2026 at 08:59:57PM -0400, Andrey Grodzovsky wrote: > kernel.ftrace_enabled=0 silently kills BPF trampolines (fentry/fexit): > attach still succeeds, the hook stops firing with no error, and > re-enabling silently restores it with no indication anything happened. > > This is a regression, not a new gap: BPF trampolines were already > protected against this the same way livepatch protects itself, via > FTRACE_OPS_FL_PERMANENT on the shared trampoline ftrace_ops. That > protection was silently dropped during a later refactoring and never > restored, so this has been broken for years. > > Both the shared direct_ops (CONFIG_HAVE_SINGLE_FTRACE_DIRECT_OPS > arches) and the per-trampoline ops allocated on other arches (arm64, > s390) are BPF-trampoline-private, not shared with any unrelated > subsystem, so restoring the same unconditional flag is safe and needs > no kernel/trace/ftrace.c changes -- its existing generic sysctl gate > and attach-time refusal already scan the ops list and pick this up > for free. > > Fixes: 00963a2e75a8 ("bpf: Support bpf_trampoline on functions with IPMODIFY (e.g. livepatch)") hum, we did use it before this commit, I completely missed that, thanks Acked-by: Jiri Olsa jirka > Cc: stable@vger.kernel.org > Assisted-by: Claude:claude-sonnet-5 > Signed-off-by: Andrey Grodzovsky > --- > kernel/bpf/trampoline.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/kernel/bpf/trampoline.c b/kernel/bpf/trampoline.c > index 129d07db117e..3d5069091db7 100644 > --- a/kernel/bpf/trampoline.c > +++ b/kernel/bpf/trampoline.c > @@ -224,6 +224,8 @@ void bpf_image_ksym_del(struct bpf_ksym *ksym) > */ > struct ftrace_ops direct_ops = { > .ops_func = bpf_tramp_ftrace_ops_func, > + /* Same protection livepatch gives its own ftrace_ops. */ > + .flags = FTRACE_OPS_FL_PERMANENT, > }; > > static int direct_ops_alloc(struct bpf_trampoline *tr) > @@ -303,6 +305,8 @@ static int direct_ops_alloc(struct bpf_trampoline *tr) > return -ENOMEM; > tr->fops->private = tr; > tr->fops->ops_func = bpf_tramp_ftrace_ops_func; > + /* See the direct_ops initializer above for why. */ > + tr->fops->flags |= FTRACE_OPS_FL_PERMANENT; > return 0; > } > > -- > 2.34.1 >