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: <20251029-work-namespace-nstree-listns-v4-17-2e6f823ebdc0@kernel.org>
Date: Wed, 29 Oct 2025 13:20:30 +0100
From: Christian Brauner <brauner@...nel.org>
To: linux-fsdevel@...r.kernel.org, Josef Bacik <josef@...icpanda.com>, 
 Jeff Layton <jlayton@...nel.org>
Cc: Jann Horn <jannh@...gle.com>, Mike Yuan <me@...dnzj.com>, 
 Zbigniew Jędrzejewski-Szmek <zbyszek@...waw.pl>, 
 Lennart Poettering <mzxreary@...inter.de>, 
 Daan De Meyer <daan.j.demeyer@...il.com>, Aleksa Sarai <cyphar@...har.com>, 
 Amir Goldstein <amir73il@...il.com>, Tejun Heo <tj@...nel.org>, 
 Johannes Weiner <hannes@...xchg.org>, Thomas Gleixner <tglx@...utronix.de>, 
 Alexander Viro <viro@...iv.linux.org.uk>, Jan Kara <jack@...e.cz>, 
 linux-kernel@...r.kernel.org, cgroups@...r.kernel.org, bpf@...r.kernel.org, 
 Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, 
 netdev@...r.kernel.org, Arnd Bergmann <arnd@...db.de>, 
 Christian Brauner <brauner@...nel.org>
Subject: [PATCH v4 17/72] nstree: simplify rbtree comparison helpers

They all do the same basic thing.

Signed-off-by: Christian Brauner <brauner@...nel.org>
---
 kernel/nstree.c | 40 +++++++++++-----------------------------
 1 file changed, 11 insertions(+), 29 deletions(-)

diff --git a/kernel/nstree.c b/kernel/nstree.c
index 59ec7d6ba302..1779fa314a7d 100644
--- a/kernel/nstree.c
+++ b/kernel/nstree.c
@@ -109,46 +109,28 @@ static inline struct ns_common *node_to_ns_owner(const struct rb_node *node)
 	return rb_entry(node, struct ns_common, ns_owner_tree_node);
 }
 
-static inline int ns_cmp(struct rb_node *a, const struct rb_node *b)
+static int ns_id_cmp(u64 id_a, u64 id_b)
 {
-	struct ns_common *ns_a = node_to_ns(a);
-	struct ns_common *ns_b = node_to_ns(b);
-	u64 ns_id_a = ns_a->ns_id;
-	u64 ns_id_b = ns_b->ns_id;
-
-	if (ns_id_a < ns_id_b)
+	if (id_a < id_b)
 		return -1;
-	if (ns_id_a > ns_id_b)
+	if (id_a > id_b)
 		return 1;
 	return 0;
 }
 
-static inline int ns_cmp_unified(struct rb_node *a, const struct rb_node *b)
+static int ns_cmp(struct rb_node *a, const struct rb_node *b)
 {
-	struct ns_common *ns_a = node_to_ns_unified(a);
-	struct ns_common *ns_b = node_to_ns_unified(b);
-	u64 ns_id_a = ns_a->ns_id;
-	u64 ns_id_b = ns_b->ns_id;
-
-	if (ns_id_a < ns_id_b)
-		return -1;
-	if (ns_id_a > ns_id_b)
-		return 1;
-	return 0;
+	return ns_id_cmp(node_to_ns(a)->ns_id, node_to_ns(b)->ns_id);
 }
 
-static inline int ns_cmp_owner(struct rb_node *a, const struct rb_node *b)
+static int ns_cmp_unified(struct rb_node *a, const struct rb_node *b)
 {
-	struct ns_common *ns_a = node_to_ns_owner(a);
-	struct ns_common *ns_b = node_to_ns_owner(b);
-	u64 ns_id_a = ns_a->ns_id;
-	u64 ns_id_b = ns_b->ns_id;
+	return ns_id_cmp(node_to_ns_unified(a)->ns_id, node_to_ns_unified(b)->ns_id);
+}
 
-	if (ns_id_a < ns_id_b)
-		return -1;
-	if (ns_id_a > ns_id_b)
-		return 1;
-	return 0;
+static int ns_cmp_owner(struct rb_node *a, const struct rb_node *b)
+{
+	return ns_id_cmp(node_to_ns_owner(a)->ns_id, node_to_ns_owner(b)->ns_id);
 }
 
 void __ns_tree_add_raw(struct ns_common *ns, struct ns_tree *ns_tree)

-- 
2.47.3


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ