From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-174.mta1.migadu.com (out-174.mta1.migadu.com [95.215.58.174]) (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 66C5837A839 for ; Mon, 13 Jul 2026 23:52:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783986770; cv=none; b=qS1W5NyjnUTEA8bSfG1oBFuK55jXLDuXXqpZLYsmEDlcYrD3oPitzS/kft7/bo58l8uheQJD05L0iGidTH3r/0iJv1pIfIKjVbS0rteUX531+ZRI3mUA0IheNhAnPDy4i53RRJDPGo+AZMEYYj6NuzcorQeoB+2yGsJoCMnzomw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783986770; c=relaxed/simple; bh=+J3++JMkDbLiJM7fxPf6r4kJ34hj8oTMH32DAWToXGw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=cb6Se8R8lhVZL9thdmLiFLluQoHk5SZLTGfJJAcJPUOP1nACbR9VpZ3pEvygQpCGAvQKbQsdG6lEROImNLWPE+nlkY4obmItpz0GdAhc88CiH8EWv6o7V8GyOxpU2sQ0C4NiImsgtAdVUNeXYdRNghXorRBmfO+EMaA/hCMvue4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Tut9QRKt; arc=none smtp.client-ip=95.215.58.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Tut9QRKt" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1783986756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ILaIFjtY9Rwz9qWraFBYyKxx0ipey5snjKA1oOZlPII=; b=Tut9QRKtOMl7xYNRj/NzRrSyjP/f2+mAlcDZuUg8ygnupYCbPmwffByW5Zn95vMAZFhAID 7Obs+hLhcA1YQJIQGk0wXhbNj1keJKGminOpM/c8WJJAYTYPY1rMRv6/VXNAyXxeSPpomA sRApMB8tyOmbKV8EyuKwtdUN1HwkREY= From: Ihor Solodrai To: Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , Eduard Zingerman , Kumar Kartikeya Dwivedi Cc: Tejun Heo , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: [PATCH bpf v3 0/2] bpf: Fix tracing of kfuncs with implicit args Date: Mon, 13 Jul 2026 16:52:21 -0700 Message-ID: <20260713235223.1639022-1-ihor.solodrai@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Tejun reported an issue where a BPF program tracing a kfunc with KF_IMPLICIT_ARGS can crash the kernel [1]. This is caused by a bug in bpf_check_attach_target(): the btf_func_model for such a kfunc is computed from a wrong BTF prototype. For more details see the commit message of patch #1. The second patch adds a selftest that can catch this situation. The fix is a candidate for 7.1 backport. [1] https://github.com/sched-ext/scx/issues/3687#issuecomment-4906694106 --- v2->v3: * Replace btf_kfunc_accumulated_flags() with btf_kfunc_check_flag() following a discussion with Eduard. Inlining the hook walk is a worse option than a helper, because BTF_KFUNC_HOOK_MAX and co are internal to btf.c and exposing them is uglier. * remove reduntant btf_is_func check (Jiri) * formatting nit (Eduard) v2: https://lore.kernel.org/bpf/20260710192940.3020280-1-ihor.solodrai@linux.dev/ v1->v2: * Take a module reference in btf_attach_func_proto() around the btf_kfunc_accumulated_flags() call (sashiko) v1: https://lore.kernel.org/bpf/20260710005902.2234832-1-ihor.solodrai@linux.dev/ --- Ihor Solodrai (1): bpf: Fix tracing of kfuncs with implicit args Kumar Kartikeya Dwivedi (1): selftests/bpf: Cover tracing implicit kfunc args include/linux/btf.h | 1 + kernel/bpf/btf.c | 29 +++++++ kernel/bpf/verifier.c | 66 ++++++++++++---- .../prog_tests/kfunc_implicit_args_tracing.c | 36 +++++++++ .../bpf/progs/kfunc_implicit_args_tracing.c | 77 +++++++++++++++++++ 5 files changed, 196 insertions(+), 13 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/kfunc_implicit_args_tracing.c create mode 100644 tools/testing/selftests/bpf/progs/kfunc_implicit_args_tracing.c -- 2.55.0