From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 DB146262FC0 for ; Wed, 28 Jan 2026 04:28:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.128.42 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769574513; cv=pass; b=HKppkOrJ1XOqXq9Gz4yh1Ga9mQ7cgwZ+c9zCqFrKthvjxOJMVuSFL5zhfZL0CaJ6JOGC9hXD+HtclwWiIOuqZ/wwQ/uaUvN9jvp55zn8reyR5lI0JSYSf/iNnclE2vtEfx1I1KV0eRXoed8/te77cw2CNCttWbGIkRBvX+uYfqY= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769574513; c=relaxed/simple; bh=j7hShYPeO1N9+zbQK+hb51NpB2ihGqVur4xeazfb+IQ=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=f+jg++YaKdDdZiCoNZDsPvigSWdCOq+YhjoW2BdrOsWtBuEyOyWyThYfW8AChroU5LyXBDCBjXr3EgL/q0BByUwzAST8ni+6gIKTJh29EMjQ2TDQ2pzlvGI/td4J1ceFnkyIfXhIrmiA5NPZrN2HiyXZLzp5NDkf7GzZo0atX0o= ARC-Authentication-Results:i=2; 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=c2O0fzxw; arc=pass smtp.client-ip=209.85.128.42 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="c2O0fzxw" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4801d7c72a5so49369775e9.0 for ; Tue, 27 Jan 2026 20:28:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1769574510; cv=none; d=google.com; s=arc-20240605; b=IWqiCbkX+Q6Yyh3JRRhpImQ6jRjMs5MEPbj1LH8TUufrRPcZIGThayhjAHpUM08Nez YgjMJjKDVzv5EKTTqwC4mtM7n/R/Jo97GxSP5HRmxukumIMOxHWaPcF04sMU1HrsTjPd GBkwN7HmV9dyCzu0GtvFR6wm4mCjPG/waYs5JzO9V34rAReelIz1glXCVSI9frCv9ZmM CX1IaXCf0dyxLm30q8hU+aPdy7qpQNUr4uPHeoOh267VUC/pyyezNZqmzUTcuiKTTgc/ I59qWAMFyFDNQAM/t4SqsLzp+dwNKLN/kdyyyrMhlnWBoocYdXDXG68P4KlJhMcndUIj pAxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=j7hShYPeO1N9+zbQK+hb51NpB2ihGqVur4xeazfb+IQ=; fh=X7kWiXD0aK6E5RHExEYDIIhCL5T7MXFtYYvu75EpkN8=; b=NS57YYfe/rvh5+Sf0i7xBzKrvPHTYrvphJP3ggAl3zynev2hbIhxcXP1oS3+D7Ovgr 5tiXh3JpbDhmO7zhhXcONQhhNpvdu2yHnXwaJtdI7DO1OT4n13f4aNd58Fo3VXXvGfSR sG7scAMZch52FOVoupDHV4ehGKQMf5lIPuMCPUeD4hPUehH1E2YYPhFAyO/ALf0B7E06 0tsreY9AF2jANCgOvNyNED3yhwp3uYzE4ugc6xdBoeIgZPImd7HYLWJaZhqv2ufhkhac Qdq1rIiuc0wCRg+1M4Y7Er/pHzCYuM8fR1xf4P9YtPsAxodWs2zuPv2rl7d8T/f3aWyO xfOA==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769574510; x=1770179310; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=j7hShYPeO1N9+zbQK+hb51NpB2ihGqVur4xeazfb+IQ=; b=c2O0fzxwOis0wfJ4iVtve3ZHMupXRRPMEYFWISdLg0l/GuSQuiTZgP7IzvWBxb+HYk 1HBhdm4lwHRPdd+Gij/a6REta2mpz/AH9f3WxNa7ZsESFaoQ4bUv2zgrVl029k5arVlY hYZK49LR5ob19BXR8iSouG7PsPhC4KZTJM7k9tUh2arhonsuLUZyFPGk2+XfxUjez4kN vlZcZlaKtDUcPaXj4CAHsuqpEnylRWKBqIv17G5twPqnSkysMK2NVGQ6Qwub4TrkP+VQ cRpG+P4Zxeex4EDxSLLoqa6xrN8NiyRbK2e50OlOxiCafDSrm3ixi0eoS5H5aiZMVjLf 0NMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769574510; x=1770179310; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=j7hShYPeO1N9+zbQK+hb51NpB2ihGqVur4xeazfb+IQ=; b=TAx/Tg9YYydd1+b8rjPL4KgKFXF7En1KYZBgYKpHKiX9Hb8hiyRyv8aEe6+bzQhkdH cBGybqPf2UCWubgmMFs3wdY/zEU/SSRaxcT6LwhuK0p6ZpiyXYVtSlZ5cyTc9sqLJKn+ BxqSizygEj9jaE1AHteFhjhGlx/pO66vXFE4oetcFJr4ePRn8Bk7RzYERfjVOsVr1omA 111imDsRcnMWZAVbIr//I8bZXSbwCgPaOEMZXtS8X/p5rb1dTOuJGSV/nzBlk+nm2ETY i1/5hvYFxXcmyS+0g3zF0hJWg+m2PqZqg+JvWvW6rCc0SsSF3Ocg4EtFWPjVGQ1mSfkt 8sjQ== X-Forwarded-Encrypted: i=1; AJvYcCWHtNqRb//D7duGb5/4HclfR9RpD4g9CSqC6HkG+eKrQfma/XfFwolk/0+TgoZRxc2duptrtkmEsC6OjXE=@vger.kernel.org X-Gm-Message-State: AOJu0YyMRBfx2DwUw83WdpdiLh3Fo5I/UOQlKp+OiH+8J5VmS/3u/kWD MPHyoNEldp7tEV0KL5PE3BtTvznpaiw4Ypku1bu0kXGX/uf3hnjRg6DKJtFDNHX5jJmczWhTTN8 hrHNeB/rjqAVgCo3oEpvc7QZcgorR9hI= X-Gm-Gg: AZuq6aKUUiXRevwKiQ8hv9UADRkI2evzLGzvLm3zdIa0sxozKv57hT92eJwT9QZokHI qv/oTjAnfo7v8OPKXQhbh6Wv4ImUyhPOAmRd+9/1VAbQR/wDrmZ48YtkFh8mtaX0meLAF2EfFD7 j1n5+E+HVhb3bVxWvnxU6nYrMUxGO/m9H2YRw7wnkQoYIuInCGzAjvOB/aBHpGdtmMrzy1lVocd I/o/s2N0r3quQ1egJzK/n1ZRzZxA/CHVRk5axtwZV0MM3xquh08YKlTm//aOVlpo2d6HTNGBySK 44AoLFPavWXwnLp1uMbHJRPw8+ZVjuXqQigfzPgyRfMkVLX3dM1SrBBRh/0ZsPkr6jraXGb3zcs 1NEn6CWTxAnjhQA== X-Received: by 2002:a05:600c:154c:b0:477:b734:8c41 with SMTP id 5b1f17b1804b1-48069c3f021mr54274985e9.1.1769574509966; Tue, 27 Jan 2026 20:28:29 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20260122090404.15553-1-chensong_2000@189.cn> In-Reply-To: <20260122090404.15553-1-chensong_2000@189.cn> From: Alexei Starovoitov Date: Tue, 27 Jan 2026 20:28:19 -0800 X-Gm-Features: AZwV_QhD1w-OAF47igZx-CBdBxyMwEcMdyteSlPLOA4DuDwHNBlCzI4bC9Iejr0 Message-ID: Subject: Re: [PATCH v2] kernel/bpf/btf.c: reject to register duplicated kfunc To: chensong_2000@189.cn Cc: Martin KaFai Lau , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , bpf , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jan 22, 2026 at 1:04=E2=80=AFAM wrote: > > From: Song Chen > > I had an ebpf program which calls a kfunc defined and > implemented in one of my kernel modules, they were working > fine in 6.16, but was broken by libbpf in 6.19, the error > message was: > > libbpf: extern (func ksym) 'bpf_strstr': func_proto [5] > incompatible with vmlinux [94389] > > yes, the reason is there is a new added kfunc in kernel 6.19 > which happens to be the same name with my kfunc. However the > error message is not obvious enough to address problem > immediately. I don't quite understand what you're trying to say. "broken by libbpf"?! You mean that kernel 6.19 got new kfunc bpf_strstr() ? Why libbpf error is relevant? You mean you had your own custom .h file where you defined your own kfunc from a custom module and libbpf complained that your bpf_strstr() kfunc definition doesn't match the kernel 6.19 ? and your proposed solution is ... > Therefore, this patches searches duplicated kfunc in > btf_vmlinux before a kernel module attempts to register kfuncs > through register_btf_kfunc_id_set, it prints clear error message > and returns error code if same name kfunc has already implemented > and registered, then developer knows at the first place. Are you saying that the kernel module that supplied bpf_strstr shouldn't be allowed to register its kfunc if kfunc with the same name exists in vmlinux. So insmod will fail? This is debatable. I guess we can add such sanity check, but what about kfunc in module A with the same name as kfunc in module B? Currently libbpf tells kernel both btf FD and kfunc btf ID, though there is a single namespace for all kfuncs from bpf program pov the kernel and libbpf api-s allow a selection. Technically we can hack something in bpf.c to "namespace" kfuncs and say that the kfunc "foo" is in the module "bar". It won't be pretty in C, but possible in principle. Maybe a kfunc with the same name in the module should be allowed to override a kfunc in the kernel. It can be seen as livepatching of kfuncs. imo that's a more interesting use case than helping out-of-tree module to produce nicier error. pw-bot: cr