🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #18853

[PATCH iproute2-next 5/5] lib/bpf: check for missing bpf fs mount point

#18853
From: Stephen Hemminger
Date: Thu, 19 Nov 2026 00:15
72 lines
13473 bytes
bpf_get_work_dir() returns NULL when it cannot provide a usable
work directory. It does so even after finding a valid bpffs mount,
because bpf_gen_hierarchy() fails if the tc/ subdirectory cannot be
created: running unprivileged against the default mode=700 mount,
or as root against a read-only one.

iproute2_get_root_path() passed that NULL straight to snprintf("%s"),
which glibc renders as "(null)":

  $ tc filter add dev lo parent ffff: bpf obj prog.o sec egress
  mkdir /sys/fs/bpf/tc/ failed: Permission denied
  Continuing without mounted eBPF fs. Too old kernel?
  mkdir (null)/globals failed: No such file or directory
  Unable to load program

Check for NULL and report it instead. Also check the snprintf()
return, since root_path is handed to libbpf as pin_root_path and a
silently truncated pin root is worse than a hard failure.

The "Continuing without mounted eBPF fs" warning in bpf_init_env()
goes away with it. The legacy loader could carry on without bpffs,
which is what that message described, but the only remaining caller
needs the pin root and now fails, so the warning no longer matched
what happens next. The "Too old kernel?" guess was misleading as
well: the mount is usually present and simply not writable.

Fixes: 6d61a2b55799 ("lib: add libbpf support")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/bpf_util.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/lib/bpf_util.c b/lib/bpf_util.c
index e58e54be..20609339 100644
--- a/lib/bpf_util.c
+++ b/lib/bpf_util.c
@@ -1068,20 +1068,27 @@ static void bpf_init_env(void)
 
 	/* Don't bother in case we fail! */
 	setrlimit(RLIMIT_MEMLOCK, &limit);
-
-	if (!bpf_get_work_dir(BPF_PROG_TYPE_UNSPEC))
-		fprintf(stderr, "Continuing without mounted eBPF fs. Too old kernel?\n");
 }
 
 int iproute2_get_root_path(enum bpf_prog_type type, char *root_path,
 			   size_t len)
 {
+	const char *wrk_dir;
 	int ret;
 
 	bpf_init_env();
 
-	snprintf(root_path, len, "%s/%s",
-		 bpf_get_work_dir(type), BPF_DIR_GLOBALS);
+	wrk_dir = bpf_get_work_dir(type);
+	if (!wrk_dir) {
+		fprintf(stderr, "No mounted eBPF fs to pin maps under\n");
+		return -1;
+	}
+
+	if ((size_t)snprintf(root_path, len, "%s/%s",
+			     wrk_dir, BPF_DIR_GLOBALS) >= len) {
+		fprintf(stderr, "Pin root path for %s too long\n", wrk_dir);
+		return -1;
+	}
 
 	ret = mkdir(root_path, S_IRWXU);
 	if (ret && errno != EEXIST) {
-- 
2.53.0
Technical Details
Message-ID: <20261119001539.2868072-6-stephen@networkplumber.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366569-linux-kernel-netdev=dewy.ru
References: <20261119001539.2868072-1-stephen@networkplumber.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366569-linux-kernel-netdev=dewy.ru
From: stephen@networkplumber.org (Stephen Hemminger)
Newsgroups: linux.kernel.netdev
Subject: [PATCH iproute2-next 5/5] lib/bpf: check for missing bpf fs mount point
Date: Wed, 18 Nov 2026 16:15:09 -0800
Organization: Usenet Network
Message-ID: <20261119001539.2868072-6-stephen@networkplumber.org>
References: <20261119001539.2868072-1-stephen@networkplumber.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2738817"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:BxCCPdXm3/BL6LNQ0O+xXzGOcmU= sha256:M4rYFy0y5l90j2yBQfCv/Orm37TnVxV0WtjRMAOhQAI=
	sha1:GcOJU5sSr4sY2Z285VNPeUDAOpk= sha256:7lyTMaY/fNv8eAB74TRzK7Z4Em25neL6uINMCH2Gs4g=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id E7E95115441; Thu, 19 Nov 2026 03:16:06 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.951
X-Spam-Status: No, score=-2.951 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=networkplumber-org.20260707.gappssmtp.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id xsYLLcQZvjzb;
	Thu, 19 Nov 2026 03:16:04 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-366569-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=quarantine dis=none) header.from=networkplumber.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 6982411544F; Thu, 19 Nov 2026 03:15:54 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 44D73141CCB; Thu, 19 Nov 2026 00:15:52 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795047350;
	b=LAzqzBhOifDaAsDD8JfiaVaaRF9pJJRhONR9jPYqiF+/2qkPKYp+r7M+VHEtZUffKsl1
	 Uy7fkmqNtQyKIeLqUscixyhcDf3H2vVIP7nr69A8s4vNx376dEqmzhkMq52o6wMc2lsaH
	 nnpdrbzEgasBQ0tfBIxB3X4VsvitKeS1eHXA1rBDzngLDpJTsETgtENwfyBfEixNYe3hs
	 CgunUio47Tbyj+wTnmJZ1EVtv2ZI9p8axePByS6KtHYeu6+IxeArXHHsg7zW2FsHoOgYp
	 BqIBnuatTeWCGV5luIZmapBUou/cakQkQxJAoJiS0VDgpU9tvkOjYNxsQ8JwbQVawMw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795047350;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
	 References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=TI7pqw1YFEVzl5TnCMLsZoqHJ7n5u+XR+fwT3PAt6e0=;
	b=1wTvEDXUx1Xnlk6KPFYNd49WrGNupr8Dp6hyxl9HNeDKb48vP395hS7xg841ygCGcZ3/
	 P0EH/ZIZgzAjFNIKpLyWCr/nn1GSkNt6+QqYV3SRe9R6AALKsnz07W545FQbEZstogmea
	 V9EBvmWT2T/KNd2+gY1c+c6zu214JyiErgV0iWD/zNsAn3i+4jFV50emTcbfr52XooelG
	 L/ghK3TTgkbNAYheEemKtqObleImww+1cOEAKoa5o73P6xRl6RbSDZq595EGJy69ywxNA
	 BrZs8RI4SmTiBhE80rxwsiVexHbNoF51yLpRVd/c3JbE8tSZ7XunPAPl1ho2bGR2HTA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=networkplumber-org.20260707.gappssmtp.com header.i=@networkplumber-org.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=ewFn5Cgt;
	dmarc=pass header.from=networkplumber.org;
	spf=pass smtp.mailfrom=networkplumber.org;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id DAA52606A335;
	Thu, 19 Nov 2026 00:15:50 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=networkplumber-org.20260707.gappssmtp.com header.i=@networkplumber-org.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=ewFn5Cgt
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.170
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795047350;
	b=dCj8hMI/ggfaTK2REXF7bFEucWQ79mCzWKZc6LHanoWu9iJ9EP/zIOnc6u9P8xTzOWjG
	 0+bo3fhKKNLZ9Msot0Nv1Cxz82Nxigp9LToEyJ+7a3aIzjglQyLi48rFPCyyI+sBrHASw
	 IynqQtzDDYFghX48wj/KZ07O7147o6oXs3QgeT+I/J3SeUt/n0W1H6B4oLRkQ9QhR5r8B
	 bC3vwCCm1GVzi5UdmnXAuvcZmQmCVJINWdh1rtoV0qmktWR/kD7LWpLqPtvB6jWjNeCts
	 DHfDQox+hep6G05ZVAPp2i7UKSFVQNspR6TRGV6FAynvaohckhQj8r8Pld5+bKrQFBA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795047350;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding;
	bh=TI7pqw1YFEVzl5TnCMLsZoqHJ7n5u+XR+fwT3PAt6e0=;
	b=tYWMLHnCCv+F96dvF/yQ5CwLk7eaPdlYEmsOYi+YQ8lrayMSrOUmw5hTZ9akQePxfCKg
	 2TNGWgVaeT1ZYdqAbmHjrYOdS+ys2LPhWvBNqf4Xzvt2OL1jNkxC8pLz9Iy+MYNZSwWJr
	 HtzZoYPMPnlR05pq82rjVzzouHmKKZYda6fNqItVjwsEg5TGkjc4bHs1uyz6C7nyoNKDR
	 BsfrsyaicuUfSHvTvApBBZqBnvLRgIMTJoFFxV4/MUrU2cGWSpAjEnbdmQNgo9fCOMAip
	 XFUIh8B80DjTN/jc+5IOHz4dzwYce67OtE+zoclhS5y1FajausSC4jeQ6wY373vKuvg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=networkplumber.org;
	spf=pass smtp.mailfrom=networkplumber.org;
	dkim=pass header.d=networkplumber-org.20260707.gappssmtp.com header.i=@networkplumber-org.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=ewFn5Cgt;
	arc=none smtp.remote-ip=209.85.215.170
X-Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170])
	(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 A2B2D606A31C
	for <netdev@vger.kernel.org>; Thu, 19 Nov 2026 00:15:49 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A2B2D606A31C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=networkplumber.org
X-Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-cc147d86bebso276516a12.0
        for <netdev@vger.kernel.org>; Wed, 18 Nov 2026 16:15:49 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=networkplumber-org.20260707.gappssmtp.com; s=20260707; t=1795047349; x=1795652149; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=TI7pqw1YFEVzl5TnCMLsZoqHJ7n5u+XR+fwT3PAt6e0=;
        b=ewFn5CgtlfTp/BcRQcPWRck2Rp4Vsc9Y3ZJ2uA2Ma/7axINGYgokzRcsLSpzwQHQk5
         bBZWwTDmpDoRtUwNSFTF6A4DOU8BmfvBb3f1A3IS8ISinUyH4vTSoo3GIOCH35owdfR1
         WzLpfl4E9gwt8OyVthjjEpUpcVq/tmazPK/mSNJChAk8JIrbIDLlXHy92HDttrGJ5ChC
         NeGorOf2yBTbTEgMeTiLsHu5Eg3nsYtARMDMStRtJyZax1DCx5jYVFRsmA+GWnFskZ+T
         YcgM8H7MpTNlNOkW6zhODF2voyVDjWsRCqQHywoYnyF30qpSUiDij+pww8wZbjUvMfrZ
         BTTw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1795047349; x=1795652149;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
         :to:cc:subject:date:message-id:reply-to:content-type;
        bh=TI7pqw1YFEVzl5TnCMLsZoqHJ7n5u+XR+fwT3PAt6e0=;
        b=lUodtUkQd7gD82f9EwyOTmJw6PMM6xhOW/RFoecs8QHzJpBAQPsw/q8gUOAfWHzAB/
         ac+bqmyDX6TtP0mbZc+mAoRD2bfefm1+MCUhDCJofbBbxsdIzZit+yq2Rp01ija4ZwgW
         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a17:90b:1cc5:b0:3b1:6689:a016 with SMTP id 98e67ed59e1d1-3b3ffa1c69cmr136971a91.16.1795047348966;
        Wed, 18 Nov 2026 16:15:48 -0800 (PST)
X-Received: from phoenix.lan (204-195-112-43.wavecable.com. [204.195.112.43])
        by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b3fe0b62e7sm444278a91.11.2026.11.18.16.15.48
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Wed, 18 Nov 2026 16:15:48 -0800 (PST)
X-Cc: dsahern@kernel.org,
	Stephen Hemminger <stephen@networkplumber.org>,
	Hangbin Liu <haliu@redhat.com>,
	Toke Høiland-Jørgensen <toke@redhat.com>
X-Mailer: git-send-email 2.53.0
X-In-Reply-To: <20261119001539.2868072-1-stephen@networkplumber.org>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list