From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.175 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796097214; b=zYlUZR/j9L2KllbR4HOK2Its5Xo44eSLcwJQsiRpGEg73zF9GUyqZUNHosKV/xryKZmz ZbRKK/xChhT2CAmsXS2nhCPmZ/G5RlMUBDOzqAA+S8d5mZa3Mc2LI8QG/NHVKd+mz0MGo 9Uxgl3M6gypkZRiMuYNSkfbQVrxixYFK7xFBAL374XhFi0vMP9fNJEREFMwTIz6tGEpN9 4c9L/vrn9UcqLO1OI8dbo/JljF5spF8XUdqhagbREUYxDZ+rpyJW5hvSfV9r4mo8k9ikl 268bdO6SeQJu/yypV42Y3LLidG82MRvgT0br3LIqTDW3FGubZ5FIAtykLcmKr2OeLfQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796097214; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Content-Type:Date:Message-Id:Cc:Subject:From:To:In-Reply-To: References:Content-Transfer-Encoding:MIME-Version; bh=cSP7oQmsSgVjpKTxLGuxzoCT6AiQFLalcssrbiu5ttE=; b=kvvFQqjQDaZf6hfoY5BvIckfWRyWg5/Exmm4yk1MVsN9nY52bYDyjAtx+WoYouA4zLti v7izD/9pcICYyoT8rVGVi0EWTnNyiBGxEsdNNkm6d1ue9u2zo73/kN91bO290huGgrC/u UJacXHFlOG+dwALCGMiFKLWyg4+fXvh0VaJcumkvgsE2QOdviv2Qy4dAdYXFH7rdUrwoE TujwLF6y+/aHbDcJ4TKIfuifWiHwXiYBl1nTNfzYnsVR8C7hEvRKmJXGajGu/fa23iDQF ZE8BQM2qiLF3RM8AhTGi+tUor2cWzjW71EOKhyp/5iWkGzyJ3Mv3cy/DkmlmapOJjug== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="ed/93Fgj"; arc=none smtp.remote-ip=209.85.214.175 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71E97606A31A for ; Tue, 1 Dec 2026 03:53:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 71E97606A31A 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.a=rsa-sha256 header.s=20260707 header.b=ed/93Fgj Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2f06ff94acfso53793145ad.0 for ; Mon, 30 Nov 2026 19:53:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796097214; x=1796702014; darn=vger.kernel.org; h=mime-version:content-transfer-encoding:references:in-reply-to:to :from:subject:cc:message-id:date:content-type:from:to:cc:subject :date:message-id:reply-to:content-type; bh=cSP7oQmsSgVjpKTxLGuxzoCT6AiQFLalcssrbiu5ttE=; b=ed/93FgjAzfMD8wXBg1WYLVfLIj9jzRs16rBjTdotcVtEVFFTMwitpMwcgg8DUNZi0 N2eBrlwGkvWbjnQz67E8KPVwZU1DX5wmoTJfmHfKwCR4E5HpEpgMHNHtDNMx0yo3fU3I aapKRt1KmuyyF3b44wkkHHedZh7sDCzLKWZJWyQEYs4rytBOFiWo1zVsLEap6M01+5ZB RgUakNhygG7aZ9BhQKJnz2oML+MUSoAoluWOPw2+C3lfuUxRHAZiBmhoqXxoCxoq3PpD 0l6c6FHyB4Snh95WlAi9D35AMmXE5dL92zKbSNEv5pIGU7E9pgWZmmbIC3Cgd9s0S4+n D9vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796097214; x=1796702014; h=mime-version:content-transfer-encoding:references:in-reply-to:to :from:subject:cc:message-id:date:content-type:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=cSP7oQmsSgVjpKTxLGuxzoCT6AiQFLalcssrbiu5ttE=; b=jiw3AQRs5SVjw0pN/JBByoJmqXogF7rs8c4/dN5OCUrGGN5Z0st/88FF3tMESmb+aj tOxuk4hAZ0oCVZkZdF2Ki3XanPJNHYjsrxumn3q/pCfvYs8emHRk5VQdQReDH60lv8Ys QahgyzNVu/hjDZPig2wx28GlN9GVhvPWtyQDqcFhdNkbsSZZ+VgXKxvM16e9WGX395MY dN2Abc1aQcQtLrL8T1ALSHuzfyYGOLG7VBqBp2kG4wD++4TREcSkhForopWmJ2h2PusM xQmWoIs5Tq9oqHI5Nid4ol/1gdWFq6I2tlfjlJ0s2IxrlUa+i0k80gsbOxE2K3L1xEFy dPcg== X-Forwarded-Encrypted: i=1; AL+hErGftY+faq1WU899XpUhu5AJ0LapyAgvqNa1Ye27US/0YUV+tmt/YZJblxKQNl/40XZXhac=@vger.kernel.org X-Gm-Message-State: APuU4Z/XQp6z37cwwNo+lSarU6NCwRPCQ4wYg+nhwhUODfs/2e1wnduE znQVkm0niGHCDsiN9qWD93VFKo+Ca6oNI+juVODsWciSC8AHRXTVrsXi X-Gm-Gg: AZFdTZc58xY68V9UArLo+Taf1Omt02G/PAZ/0+fIMVio3mgNHFZvS74cvm0nMt8i+vF PZmIcEsh1sf3irdz2GhqVrbU9CeFYYoaPGBluIJWeIjr72Mw4yQsbapPyEJqchRHt1cXwGg0kch ThGijiAsFNltmLFQ2klh1N7uPLmIDhk3kXDRJj5TVolasN3DM7v+27qGf8Xu7j/xTAFyT5YlzqG 9rwJ9YxSfEBpQL+NopA/PfVfxbeRrRGx59VIolCZKY8ygK9Jt2JYpGa8JuTBl+LAFgxkd47kEuq P+TotU87o1N7omrY6FhrYOBfmVFzduxRUAXPQmqHCvRg/D2MOTbkP6hDWbVex5SWKuayq+QWGbl 7TEct2CrhCnYVU2ExqLFs6j5EjZ5YVhv0WbwU0efymnStsO1lN4EDwuWiOqFRcxk7EZQCwrYffj YgtfGDYX8yK3TXFAxmbSUvoN0NHgZbHh2kyTkF+LTeR2F55wyCV/o56fD1WJmlIMksrUSlaTrC4 kIbV7M7mafwClCIkVXsKaNeqWzoemXB5f6HQtnIOcsv0uJmtmNyj3DfwBgS2DhnawBzOm5S7eWq 2yfkO3a4RDKjE6yOA56VyvHd/XjK+0o1PXw0G062t3cs95z4PFCIm1CHmrbU0YbqQTZBMX/ksBg 2ySR/wgv+VSbz8DApm1ItVnJ7eqLoBc4at5o= X-Received: by 2002:a17:902:dacc:b0:2ea:19bc:2fe2 with SMTP id d9443c01a7336-2f03ef59bf0mr366160555ad.10.1796097213567; Mon, 30 Nov 2026 19:53:33 -0800 (PST) Received: from localhost ([153.61.198.247]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f03f1215d7sm171093025ad.65.2026.11.30.19.53.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Nov 2026 19:53:33 -0800 (PST) Content-Type: text/plain; charset=UTF-8 Date: Tue, 01 Dec 2026 03:53:32 +0000 Message-Id: Cc: "Martin KaFai Lau" , "Eduard Zingerman" , "Kumar Kartikeya Dwivedi" , "Song Liu" , "Yonghong Song" , "Jiri Olsa" , "John Fastabend" , "Emil Tsalapatis" , "Ihor Solodrai" , "Steven Rostedt" , "Masami Hiramatsu" , "Mathieu Desnoyers" , "JP Kobryn" , , Subject: Re: [PATCH bpf-next v4 4/6] bpf: Check program recursion per task via bpf_ctx From: "Alexei Starovoitov" To: , "Mike Bazov via B4 Relay" , , "Daniel Borkmann" , "Andrii Nakryiko" In-Reply-To: <20261130-bpf-preempt-v2-r2-v4-4-bd28389dfd64@sentinelone.com> References: <20261130-bpf-preempt-v2-r2-v4-0-bd28389dfd64@sentinelone.com> <20261130-bpf-preempt-v2-r2-v4-4-bd28389dfd64@sentinelone.com> Content-Transfer-Encoding: 8bit X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 On Mon, Nov 30, 2026 at 03:54 AM Mike Bazov via B4 Relay wrote: > +static inline struct bpf_run_ctx *bpf_set_run_ctx_prog(struct bpf_run_ctx *new_ctx, > + const struct bpf_prog *prog) Pls use __always_inline to avoid future headaches. > + case BPF_PROG_TYPE_TRACING: > + case BPF_PROG_TYPE_STRUCT_OPS: > + return bpf_prog_check_recur(prog); Dead code. bpf_check_attach_target() rejects these targets. Drop both helpers and check three prog types in bpf_tracing_prog_attach(). > + if (prog->type == BPF_PROG_TYPE_EXT && prog->percpu_state && > + bpf_prog_recur_per_task(tgt_prog)) { > + err = -EINVAL; A sleepable target is preemptible with or without the mark: raw_tp.s target runs attach of a marked extension --------------- ------------ ---------------------------- not marked preemptibly -EINVAL marked preemptibly ok Reject both. Also add bpf_log(). > - bpf_reset_run_ctx(run_ctx->saved_run_ctx); > + bpf_prog_exit_run_ctx(prog, &run_ctx->run_ctx); > + bpf_reset_run_ctx(run_ctx->run_ctx.saved_run_ctx); The order is wrong. Marked progs still lose events. The deferred preemption fires while the frame is linked. P is one raw_tp prog on sys_enter and sched_switch: bpf_prog_exit_run_ctx(P) preempt_enable_notrace() __schedule() trace_sched_switch() bpf_prog_enter_run_ctx(P, old_ctx) old_ctx->prog == P <- dropped, P has exited already Same for an fentry.multi prog that covers the scheduler. Unlink the frame first in all runners, like in the diff in v3 thread. In the trampoline enable preemption after update_prog_stats(). Otherwise off-cpu time goes into run_time_ns. Nothing reads the run_ctx argument. Drop it. pw-bot: cr