From nobody Mon Feb 9 02:14:25 2026 Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (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 2B348395265 for ; Wed, 4 Feb 2026 08:58:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770195503; cv=none; b=KGrGQinP3Q2929SaRnvlduNy7DRLC/1gtmFF/WHdUZVn2LHGLKCN7tyWWtNOaOZtX9DVbpe+kM34JUkvVBONnVBVVBTd9eK2X3a+U/YEcdqBd2r9NxzIrVJsYqWDqLW8TTeOgXh6frnPVHaOFtCSAlIsMsh3zq0MAdRrAQwH+Dg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770195503; c=relaxed/simple; bh=kMSy5c7vVSWgQsdtb2fYQMhyeIpomZ9NAf+hi6xHiT4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AoIDlZA92I09su6BqemXlY26/xB3zUSO8qZIHrms5vlNp0kZaX9ZYyk7ZnQ377/8Kz7SsRUKoLLfAkpnFzyhqOfTPc2PQue+0c1DkSNERu5jd03RukkIMMgzhX/RzrFEYrwSK9qpj2olfN4dyrfWfUx8co+2RH7LlJIS4YjHMBc= 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=BUAMtQtt; arc=none smtp.client-ip=91.218.175.184 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="BUAMtQtt" 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=1770195501; 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: in-reply-to:in-reply-to:references:references; bh=NeDzn3ZIpPl8RtxQ8UBkT2sOS4jMnERoC4vLjBOwnog=; b=BUAMtQtt/ptCud5saYVIgTmDduA4o+i70Q2mjpckwXNPLtvcR9U/RDQT4TDmvqA/iuFMlk dCvI6XN9z3S2O7OhvNQE2tx6yJ4L80u0P6ACxUFJW3ev+0pZl1NmQLkz45PWlum/9afOHt 8J+SKEK45lPhWSzMVbkN1Rus1GF3dLw= From: Hui Zhu To: Andrew Morton , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Peter Zijlstra , Miguel Ojeda , Nathan Chancellor , Kees Cook , Tejun Heo , Jeff Xu , mkoutny@suse.com, Jan Hendrik Farr , Christian Brauner , Randy Dunlap , Brian Gerst , Masahiro Yamada , davem@davemloft.net, Jakub Kicinski , Jesper Dangaard Brouer , JP Kobryn , Willem de Bruijn , Jason Xing , Paul Chaignon , Anton Protopopov , Amery Hung , Chen Ridong , Lance Yang , Jiayuan Chen , linux-kernel@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: Hui Zhu , Geliang Tang Subject: [RFC PATCH bpf-next v6 06/12] bpf: Pass flags in bpf_link_create for struct_ops Date: Wed, 4 Feb 2026 16:56:27 +0800 Message-ID: <3879deea2efdbc75740e985e6cdbd67a57aa5651.1770194182.git.zhuhui@kylinos.cn> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Hui Zhu To support features like allowing overrides in cgroup hierarchies, we need a way to pass flags from userspace to the kernel when attaching a struct_ops. Extend `bpf_struct_ops_link` to include a `flags` field. This field is populated from `attr->link_create.flags` during link creation. This will allow struct_ops implementations, such as the upcoming memory controller ops, to interpret these flags and modify their attachment behavior accordingly. UAPI Change: This patch updates the comment in include/uapi/linux/bpf.h to reflect that the cgroup-bpf attach flags (such as BPF_F_ALLOW_OVERRIDE) are now applicable to both BPF_PROG_ATTACH and BPF_LINK_CREATE commands. Previously, these flags were only documented for BPF_PROG_ATTACH. The actual flag definitions remain unchanged, so this is a compatible extension of the existing API. Older userspace will continue to work (by not passing flags), and newer userspace can opt-in to the new functionality by setting appropriate flags. Signed-off-by: Geliang Tang Signed-off-by: Hui Zhu --- include/linux/bpf.h | 1 + kernel/bpf/bpf_struct_ops.c | 1 + tools/include/uapi/linux/bpf.h | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 720055d1dbce..13c933cfc614 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -1896,6 +1896,7 @@ struct bpf_struct_ops_link { struct bpf_map __rcu *map; wait_queue_head_t wait_hup; u64 cgroup_id; + u32 flags; }; =20 struct bpf_link_primer { diff --git a/kernel/bpf/bpf_struct_ops.c b/kernel/bpf/bpf_struct_ops.c index c807793e7633..0df608c88403 100644 --- a/kernel/bpf/bpf_struct_ops.c +++ b/kernel/bpf/bpf_struct_ops.c @@ -1392,6 +1392,7 @@ int bpf_struct_ops_link_create(union bpf_attr *attr) cgroup_put(cgrp); } #endif /* CONFIG_CGROUPS */ + link->flags =3D attr->link_create.flags; =20 err =3D bpf_link_prime(&link->link, &link_primer); if (err) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index 3ca7d76e05f0..4e1c5d6d91ae 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h @@ -1185,7 +1185,7 @@ enum bpf_perf_event_type { BPF_PERF_EVENT_EVENT =3D 6, }; =20 -/* cgroup-bpf attach flags used in BPF_PROG_ATTACH command +/* cgroup-bpf attach flags used in BPF_PROG_ATTACH and BPF_LINK_CREATE com= mand * * NONE(default): No further bpf programs allowed in the subtree. * --=20 2.43.0