From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.176 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796097214; b=vrERz/IznJl+vcxAjLO/x0fRbHJLqjPbYFVMicTU+/nbmyrxfQ0zoI6wwY9DPvOF6X9S u/cUDyWeDFz5JaFQPVkFNen3Bo1BVrDyVu5hRhnGQHFp8XyDWcc8s1DF4nvsMPKi5Btfv RvuNTw/Ao2Eh7Ght3ofbLLuYMydvG+KQZ+yQ8A9qJLQddbN8VLFQ7PoreY7sc2+UTJ4Rz s0LveblczxujYljs95u6nkHm29uEvGtidh0qzYk8/QSNQiHAvIGu95nwxZ52PcPv/yV0I u9+p7gPDyAuae3ajbjz/ayenySIObYAQQyZJgDWoEN2q0QlV76GoypLkiwstLqAYytQ== 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=3n88CcQNo5gqrpZ3xPslxZmy+qtMAIaBeyFYGLmExAGIz0MxvcdzvHAT3NC1pbr3Xwst U7pkvhaPeCDpgZ7gRPY/9ajJRq6Yeu2YxnNe4HfZPhC/PHkIT7ctA90T/nuTbiDT7u2+6 QD+XloSGmAOfnf5v/fw/0btRIsE3rssXNUDePG1RVULRYEVJn0OTFwwbRpzUD5046cNu3 +HRNrODv/wMLzqXuw2yxOXmDaPZCP6g8F3uvmKtUQm7WzGd9hI6u1W0yzSnfr/u/OWyfZ 7eVdnBaoeNrbn/DSIqhJF5r7MNH2p+Ool5B0ndnI1poM74b3JtA0uaP31O40D/VXtWQ== 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.176 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 72265606A320 for ; Tue, 1 Dec 2026 03:53:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 72265606A320 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-f176.google.com with SMTP id d9443c01a7336-2f06ff94acfso53793155ad.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=HshZ9KzkyeqozuNHh95LmgX4TFQp2r7eOjRjhVyo8FIWZmq9HkoRPgsNlejkCpaJ8X A3WmMBl5e2Yy6o8yQpUH7husD09xnkBoLvDWxAz+WmJJsM1RmyoCfzBtEO2Uy48qV45t 1ROjoyq3rV2pNrWUAUQmk9wuNX72FxRrUuvmgaWfe0FuszGFgfw/+UB89O5gQahgv3k4 8cBfWNFuzSHj3n/Esn1GSha/J5XfsiJJM+CCpQmVGSC0GpMN5GLKX9jbScTz+kshWDRo SYANkt0bZtFpAiJfWLn//pEsSBONNiw9Cr4zQAp8i23NHfI6VNbAZr+KhNz+5Cm5Mj6S 5wtA== X-Forwarded-Encrypted: i=1; AL+hErHxrihTSeDgxX6GWBNw0hb2hAfH5nN2NWIAwlkMX9775pYwVnS9sLHT+G8Z9ZZJZwRLgM2fNQ3iZ2we9ARay4cHy58=@vger.kernel.org X-Gm-Message-State: APuU4Z8pJQINESQ8hSGAI/svvustRp2e/Lv8vDNk+k3jya6Tba2PQCIG lGDBYteLogTwQKHNn+UYiP9Vt60+Mpy0A+pPqQ2c0ojuRKrM6XaJT5X3 X-Gm-Gg: AZFdTZd8Zud1ZJN/Ci4P7C/8mYoFBqMYVUWnxM3Mn6DS6X8qyxm081fzGX+dxYtqXJY QLmh68A4TP2n0hdLugU+bxaf3Rjl07YUO08R4eyPsCiQ8+ecsfq8Cvje6Cxrvt0pacqxFQIb6NN LPyebUkn79SXSFsCHSywGdvIxe0XFl1Rkf7t7rohgizR8tSAP4ZLk5I2rJ/f9uK7DfJQU4dprZR yUGWDT8hnaU7JZhRfTbiy7gs4O/2YJQn3VZrtqQ+fg5mNJVIwYRV+CqGAaQfHX4MiUMdfe5TnwR jQd6wqRCU4q2XVZYOygKVYIgZ+/aEf6uJhTZnNB4Xsz1AukeVAI86HB4+zaX3QrzQrhbJvBui9u Sanplie2Z35cj1zcgXjzuXR+imDHCDniA1RQOF4CwiE9vAYPcqvHtfM8LPTmtRzzuAvhENRI9Kx cU3dQSSTSGvS7yiNjNDruQqONYRI08xHMx9OJxR0abOoj3Olhzke3EGRjKlaLCE8IQ0mvA3G790 bWAw7xbib4djInFDTTXNxPnDMIicxKPBsE/VFEZBDeazD3eAdDRRIMvN566PY/QA9D0sMEepozH 9jjodGHOE83x42yZ8IlOfDZpVXZAag6W6nnQCDUbPVkn67gQ6V7xFi2ptOHBgU1s5rTCkc2Nd01 nLLf0D5jmSHHGQG38g/uFzcZ2kLkEyNoTjQ0= 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: linux-trace-kernel@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