lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220628194812.1453059-7-alexandr.lobakin@intel.com>
Date:   Tue, 28 Jun 2022 21:47:26 +0200
From:   Alexander Lobakin <alexandr.lobakin@...el.com>
To:     Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>
Cc:     Alexander Lobakin <alexandr.lobakin@...el.com>,
        Larysa Zaremba <larysa.zaremba@...el.com>,
        Michal Swiatkowski <michal.swiatkowski@...ux.intel.com>,
        Jesper Dangaard Brouer <hawk@...nel.org>,
        Björn Töpel <bjorn@...nel.org>,
        Magnus Karlsson <magnus.karlsson@...el.com>,
        Maciej Fijalkowski <maciej.fijalkowski@...el.com>,
        Jonathan Lemon <jonathan.lemon@...il.com>,
        Toke Hoiland-Jorgensen <toke@...hat.com>,
        Lorenzo Bianconi <lorenzo@...nel.org>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        Jesse Brandeburg <jesse.brandeburg@...el.com>,
        John Fastabend <john.fastabend@...il.com>,
        Yajun Deng <yajun.deng@...ux.dev>,
        Willem de Bruijn <willemb@...gle.com>, bpf@...r.kernel.org,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        xdp-hints@...-project.net
Subject: [PATCH RFC bpf-next 06/52] bpf: pass a pointer to union bpf_attr to bpf_link_ops::update_prog()

In order to be able to use any arbitrary data from
bpf_attr::link_update inside the bpf_link_ops::update_prog()
implementations, pass a pointer to the whole attr as a callback
argument.
@new_prog and @old_prog arguments are still here as ::link_update
contains only their FDs.

Signed-off-by: Alexander Lobakin <alexandr.lobakin@...el.com>
---
 include/linux/bpf.h        | 3 ++-
 kernel/bpf/bpf_iter.c      | 1 +
 kernel/bpf/cgroup.c        | 4 +++-
 kernel/bpf/net_namespace.c | 1 +
 kernel/bpf/syscall.c       | 2 +-
 net/bpf/dev.c              | 4 +++-
 6 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index d05e1495a06e..c08690a49011 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -1155,7 +1155,8 @@ struct bpf_link_ops {
 	void (*release)(struct bpf_link *link);
 	void (*dealloc)(struct bpf_link *link);
 	int (*detach)(struct bpf_link *link);
-	int (*update_prog)(struct bpf_link *link, struct bpf_prog *new_prog,
+	int (*update_prog)(struct bpf_link *link, const union bpf_attr *attr,
+			   struct bpf_prog *new_prog,
 			   struct bpf_prog *old_prog);
 	void (*show_fdinfo)(const struct bpf_link *link, struct seq_file *seq);
 	int (*fill_link_info)(const struct bpf_link *link,
diff --git a/kernel/bpf/bpf_iter.c b/kernel/bpf/bpf_iter.c
index 7e8fd49406f6..1d3dcc853f70 100644
--- a/kernel/bpf/bpf_iter.c
+++ b/kernel/bpf/bpf_iter.c
@@ -400,6 +400,7 @@ static void bpf_iter_link_dealloc(struct bpf_link *link)
 }
 
 static int bpf_iter_link_replace(struct bpf_link *link,
+				 const union bpf_attr *attr,
 				 struct bpf_prog *new_prog,
 				 struct bpf_prog *old_prog)
 {
diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c
index 7a394f7c205c..f4d8100dd22f 100644
--- a/kernel/bpf/cgroup.c
+++ b/kernel/bpf/cgroup.c
@@ -664,7 +664,9 @@ static int __cgroup_bpf_replace(struct cgroup *cgrp,
 	return 0;
 }
 
-static int cgroup_bpf_replace(struct bpf_link *link, struct bpf_prog *new_prog,
+static int cgroup_bpf_replace(struct bpf_link *link,
+			      const union bpf_attr *attr,
+			      struct bpf_prog *new_prog,
 			      struct bpf_prog *old_prog)
 {
 	struct bpf_cgroup_link *cg_link;
diff --git a/kernel/bpf/net_namespace.c b/kernel/bpf/net_namespace.c
index 868cc2c43899..5d80a4a9d0bd 100644
--- a/kernel/bpf/net_namespace.c
+++ b/kernel/bpf/net_namespace.c
@@ -162,6 +162,7 @@ static void bpf_netns_link_dealloc(struct bpf_link *link)
 }
 
 static int bpf_netns_link_update_prog(struct bpf_link *link,
+				      const union bpf_attr *attr,
 				      struct bpf_prog *new_prog,
 				      struct bpf_prog *old_prog)
 {
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 7d5af5b99f0d..f7a674656067 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -4614,7 +4614,7 @@ static int link_update(union bpf_attr *attr)
 	}
 
 	if (link->ops->update_prog)
-		ret = link->ops->update_prog(link, new_prog, old_prog);
+		ret = link->ops->update_prog(link, attr, new_prog, old_prog);
 	else
 		ret = -EINVAL;
 
diff --git a/net/bpf/dev.c b/net/bpf/dev.c
index dfe0402947f8..68a7b2c49392 100644
--- a/net/bpf/dev.c
+++ b/net/bpf/dev.c
@@ -619,7 +619,9 @@ static int bpf_xdp_link_fill_link_info(const struct bpf_link *link,
 	return 0;
 }
 
-static int bpf_xdp_link_update(struct bpf_link *link, struct bpf_prog *new_prog,
+static int bpf_xdp_link_update(struct bpf_link *link,
+			       const union bpf_attr *attr,
+			       struct bpf_prog *new_prog,
 			       struct bpf_prog *old_prog)
 {
 	struct bpf_xdp_link *xdp_link = container_of(link, struct bpf_xdp_link, link);
-- 
2.36.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ