Article View: linux.kernel.netdev
Article #6879Re: [PATCH bpf-next 1/2] bpf: Add bpf_ksock_bind() kfunc
From: Mahe Tardy
Date: Fri, 23 Oct 2026 17:10
Date: Fri, 23 Oct 2026 17:10
53 lines
13656 bytes
13656 bytes
On Fri, Oct 23, 2026 at 05:05:10PM +0100, Alan Maguire wrote: > On 10/23/26 9:42 AM, Mahe Tardy wrote: > > On Thu, Oct 22, 2026 at 06:45:34PM +0000, bot+bpf-ci@kernel.org wrote: > >>> bpf: Add bpf_ksock_bind() kfunc > >> > >> TL;DR: bpf_ksock_bind() called from a bpf_wq callback runs with kworker's full > >> capabilities, so a CAP_BPF-only SYSCALL program may bypass the privileged-port > >> (CAP_NET_BIND_SERVICE) check; the review asks whether to block it. > > > > Honestly don't know if it makes sense to prevent it given you are > > creating this kernel socket from a BPF context, if anyone with more > > experience on this can help? > > > > If the answer is yes, I imagine preventing bind() to run from a > > workqueue is the easy answer so that all creds are respected as usual > > and it's not a huge limitation (we mostly care about being able to > > send()/sendto() from a wq). > > > > I suppose one way out of this would be to forbid bind()ing to the privileged > port range; that would sidestep the issue I think. Hard to know how restrictive > that would be in terms of real use cases, what do you think? Yeah this is another way around it but I wonder if keeping the ability to bind from a wq is more important than beeing able to bind on a privileged port. Otherwise we can probably guard bind with: if (current->flags & PF_KTHREAD) no If the assumption is correct i.e. you can load and run any SYSCALL bpf program with just CAP_BPF, then indeed having this would allow you to circumvent a CAP_NET_BIND_SERVICE check which is kinda unexpected even if we could maybe discuss that those are BPF sockets, which are pretty limited for now, etc. The reason why I'm thinking like this: - I already tried to import existing network resources limitation when writing the initial patch set, like limit the number of BPF sockets, and I was told it was unecessary. - I did this whole annoying dance with LSM hooks so that ksock goes through them and I was kinda told that it was maybe also unecessary. But the more I think about this the more I think the concern is valid. > >> > >>> diff --git a/net/core/bpf_ksock.c b/net/core/bpf_ksock.c > >>> index 37168f43c16c..c7b487d90cd0 100644 > >>> --- a/net/core/bpf_ksock.c > >>> +++ b/net/core/bpf_ksock.c > >> [...]
Technical Details
Message-ID:
<atuU-BE4wssJaH4_@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351161-linux-kernel-netdev=dewy.ruReferences:
<20261022181620.247201-1-mahe.tardy@gmail.com> <e31194dd72efd3c182707e870b7e7a6d67b78be23cea06aded0275678373c64c@mail.kernel.org> <atseCFvfx9FbTXP3@gmail.com> <b28db1fb-ea02-4f83-be99-c8d4b180dc6b@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351161-linux-kernel-netdev=dewy.ru
From: mahe.tardy@gmail.com (Mahe Tardy)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH bpf-next 1/2] bpf: Add bpf_ksock_bind() kfunc
Date: Fri, 23 Oct 2026 19:10:16 +0200
Organization: Usenet Network
Message-ID: <atuU-BE4wssJaH4_@gmail.com>
References: <20261022181620.247201-1-mahe.tardy@gmail.com>
<e31194dd72efd3c182707e870b7e7a6d67b78be23cea06aded0275678373c64c@mail.kernel.org>
<atseCFvfx9FbTXP3@gmail.com>
<b28db1fb-ea02-4f83-be99-c8d4b180dc6b@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
logging-data="563059"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Sj04vxyMDcZxPuQlPGCiy0KSMJ0= sha256:UwNqzeenyYjutswCFuc9gHMeLPQgsnaup2Ua2aTCX80=
sha1:9aaeiPQ8dxOEHLTi4Um6jQtfbfA= sha256:jvTvvdTnKpba1q7t9u9iFWVNw6wV+nBySHbjVhguRM8=
Content-Disposition: inline
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 89ADA111531; Fri, 23 Oct 2026 20:11:25 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
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=gmail.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 KtW78ksyLvzK;
Fri, 23 Oct 2026 20:11:19 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-351161-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id EA24011152F; Fri, 23 Oct 2026 20:11:10 +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 BEDC833F05; Fri, 23 Oct 2026 17:10:37 +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=1792775436;
b=rk0XVSM4ESzixFRNOxt19CasVh5SCut9+jj4grcXRSISPHZ6eYDuiHLjHPuuke++luk3
OHcuJ0U3WLBjZEF5iBY/P6cj/K06cJlOw+YQejdPgzGKswWvfoG/4/c/eC1ag7VEVZrZX
7XHmP07tIWPaAkn4gBIhTT63nYkQffV3LxNG0NJUMgEPQYCwoweOb6YdBcD5/KS8fz2n5
Op4dJ6z4dtLyW5OtwsAGWr8GQcLGo4tmtu7DdpI07eCWmIhnI/pevZoA4I0J2NM6ROOT2
gIBN7JnxdrEyhiDW9g2bEMcPB7QPZAwVQKI2XXV5KIlYeW0lju0DnItzIVs8t3Mikdw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792775436;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:Date:From:To:Cc:Subject:Message-ID:
References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
Content-Disposition:In-Reply-To;
bh=Btr7hr0LuMAaYdMP/tMMJLFSICUnfP+fAjhqSakVwX4=;
b=sYLGXx5mdUwJQConicyt4xUM65a+JjuNj3njbjMHjEb19cz7JEoShiUJuDcfYFMeivEJ
LPxIG0YOjlHRqwGHqbtxQn2J9nT/lfE/+9x64wide7PYaHG8AIQfLxJMO4+ZE1bGcuRbb
TRFuc7ixq4WMwvOVvP75JjiC6bTDQyr7AgADvLa3UXxBV6uOaj/Nvwcr9c4x3Z8y++/d4
3d1T80if1pBfzrCMwP81iCFKlSX+gE3vTpOvaoruniMnfHasyvs4ioytehO0RpDrs9NcB
5HFvJiAcGQARFQLf+1oVbrSs393XYr/K85LjMVyPckJ4HMGOuFn5j2jIyKQZaeiYPZQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=AgxEKTUH;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
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 35B81606A321;
Fri, 23 Oct 2026 17:10:36 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=AgxEKTUH
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.174
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1792775435;
b=aU0qqxfneWXxusQTm08RC+f4OgVOg+nN8uq3my/V8SEhhRaJbsuiJ7EfupDkcnp+Fno4
DhwbHsKcJnD1oDHjv3GXp98Jat7xf8xzfvQlDllVQmzXtQbLCPtsUI4tLdrMwP5Ayn0O6
98feav3sk0vU6cviFHssVue8OEwuau51hIZ6ixqpwGCplMImK44+QeL2/U5/7PK+B+5xw
O3lpOjXoXy83jnw+p9NfIci8xOzooiDVi/WFYQrYoovsk0MKw3x/VVNcVfMgVDTOjM7gb
dZ+UPf4j6Y4mJYzWGvoJMQJcCCgUt/9SiFTSQRIiSOSljoCu7eVT+5QWFiWri+14Z5g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792775435;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:
Content-Type:Content-Disposition:In-Reply-To;
bh=Btr7hr0LuMAaYdMP/tMMJLFSICUnfP+fAjhqSakVwX4=;
b=eIoGvAhhAtzRF1c0NC5+BmuKO7FqG94mVh6m6VJrEAweIfRf10jTbvQZWjR6lnC34etN
oxjvjE28XwWtkD/uSh647t+3Fz490T571Lpmmf+1NA2/eNW+ZBRXmt7PBgF90lKeqISUY
kbxRyTkk9v+tJP/p7dx+ORI4+q3aoNIlM8WtS11dou9gB+pSZeiCZUiNW52SW1qGLSiJV
4INi/shtuzexnidoK2c+5yL/Ty5YPi+BElSKxKmUV9ctX5NMEc+UWbwovRQWNSfYf6t0p
WIN0yoQN1Qycz7DeUzGBVD816aXeWOuE8lKLoht2vVTQSkOl0nqL3m3xEqhdYjv3+0Q==
X-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=20251104 header.b=AgxEKTUH;
arc=none smtp.remote-ip=209.85.214.174
X-Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174])
(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 07DD8606A31D
for <netdev@vger.kernel.org>; Fri, 23 Oct 2026 17:10:34 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 07DD8606A31D
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2e60f9af6e6so8810345ad.3
for <netdev@vger.kernel.org>; Fri, 23 Oct 2026 10:10:34 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1792775434; x=1793380234; darn=vger.kernel.org;
h=in-reply-to:content-disposition:content-type:mime-version
:references:message-id:subject:cc:to:from:date:from:to:cc:subject
:date:message-id:reply-to:content-type;
bh=Btr7hr0LuMAaYdMP/tMMJLFSICUnfP+fAjhqSakVwX4=;
b=AgxEKTUHy8ctoDubMdjyFor88pmJ1RUyuatzX0e1CxVswHag9pSZt/fX79EjQFEGNU
UeU4P9O/uPbnk7q2aER+bvaCtX2F4ZXJ2BoPAL8LIUZmukK6ssFsHs8iApGCIRb9OBix
RcZn56fnq9qRI1pqtDeAf+LiZrK5ClPHVu8o7KvZXU4GVrxpMYMjq4u+UQszTMoXvlaN
7NaDsCWT7jwkU0bVC5uBrYfFAvM9qoBViOgJ510w99hI+Y6HDdNk2eO4KGKlPhDmvB9C
C41eXmKdNvYwOPy3XERwh+Ns+0VoJU7ggY2oHXg2tWndpPaAyd8pbgSr0iP0O2nquuQ3
GbVw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1792775434; x=1793380234;
h=in-reply-to:content-disposition:content-type:mime-version
:references:message-id:subject:cc:to:from:date:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=Btr7hr0LuMAaYdMP/tMMJLFSICUnfP+fAjhqSakVwX4=;
b=vOhWhCb1jGAGmL5ddMhI2njVyuNIndhDq+6jMwdv1sg74E9unMjBOY54kyS++L6Zfq
EBjFrVZnGGCKq/g2kkBLn8ds8nTzQz2KP7778cqMz1xVZvKChNkZ+wBgxqc76uwwqw4z
YqPyilV9nimWmS6p15bGnlsNiYnUvIuPoGQT+ZOVF3MnMJouKS8jh9Y/ElygKY4KB6bN
2x685iEfwdVOusBya6LNh32J/Y2KhVqDbVHTaI80qLRhgGwEvaXxCbSKUPSEoqIbW/bK
ZaEv5s9e9zc741AJ603YwabVJHSft2gaJt5LZsNVnibCqqsgBzZVmWVRPiprtqr4vO22
GUxw==
X-Forwarded-Encrypted: i=1; AKwUvByIrT0LUH2boWHqCJz2UOxWFgrx5uLkGxmnbuaYHjgAne0CSxvgqh7ufjN4tvkeUdKBFJFgMrY=@vger.kernel.org
X-Gm-Message-State: AFq9FYItEEdZy9xg9LaKyfxqGm3M+4GvYWUTKgcl6N9z640pUyZ+ATVO
5GL8Z8RY7K3FryafWLth6TsofH9xy90rqLWk8M9V6SjznxKmVBpwdYCU
X-Gm-Gg: AYBFou0zv8Xl3tq5t83PbWCqXu6U5fTwSkLNG8p13lgPp8/lOTRdrvQDVtrPfcpGZfp
/K4LzSrZ5Jnrf+THVvcdhGQl4lvcOgXIbWC7J0wYYQ/X/O/xDcNmhNW2HguhZtHIHCRJ+qgeyTF
DhXIDZ2Xx3awGUPu+BTpLBKv+H5IJevPRbc+pjX7AKPhIx9G1lRkYIDV4yVShslJG6VTVyQXHJA
XvxY+BI/Llc1JRMB5t7lKyoETQrtEcoNqAGNKmUc1CHSzb3PjAY312cR/mefbKZSuOzWqqbImx4
YiKt3p+U8vAgURYJuFmZbPIGNHpQ5in2nuEu94BSGJLHjpKbrNjudtjLyUkn2vdXoGWWCrQSpJ3
yoZe4IUdBOfm7BvrsvhYfA6a31rJZG8TdkP1qujpcUHaw/ATTOMpDVtjjZXqRVkMEvjdmyQG3En
gjB7/u10/8aYxtaOA9XeRWr+bvTi7QQkZ2FFuwJDiMdFGGUVh3JJYgr51f2xKnJKHMflChB2BBG
8ZmD+4etiw63VCTsF0PGn1Yl83Uu4f5nXbxhMmteS0xbjNcMCpuq0h3RVW3Na6/AIGcYnCnWWm1
bWGdtU/2d360nyeT
X-Received: by 2002:a17:90b:1344:b0:3a8:c0cd:57fb with SMTP id 98e67ed59e1d1-3adce0cff80mr2343177a91.42.1792775434342;
Fri, 23 Oct 2026 10:10:34 -0700 (PDT)
X-Received: from gmail.com (deskosmtp.auranext.com. [195.134.167.217])
by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3addd78d4a5sm919619a91.0.2026.10.23.10.10.21
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Fri, 23 Oct 2026 10:10:33 -0700 (PDT)
X-Cc: bot+bpf-ci@kernel.org, bpf@vger.kernel.org, andrii@kernel.org,
ast@kernel.org, daniel@iogearbox.net, davem@davemloft.net,
willemb@google.com, eddyz87@gmail.com, edumazet@google.com,
john.fastabend@gmail.com, kuba@kernel.org, horms@kernel.org,
liamwisehart@meta.com, martin.lau@linux.dev, pabeni@redhat.com,
song@kernel.org, netdev@vger.kernel.org, sdf.kernel@gmail.com,
yonghong.song@linux.dev, jolsa@kernel.org, kuniyu@google.com,
memxor@gmail.com, emil@etsalapatis.com, martin.lau@kernel.org,
mason@kernel.org, ihor.solodrai@linux.dev
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
X-In-Reply-To: <b28db1fb-ea02-4f83-be99-c8d4b180dc6b@kernel.org>