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: <szadjbcldmcirdtgiv6wowqumlk4cbthb37f3e42lzcbt4tnla@ilp4m6quqk4b>
Date: Fri, 20 Jun 2025 11:42:28 +0200
From: Joel Granados <joel.granados@...nel.org>
To: Bert Karwatzki <spasswolf@....de>
Cc: linux-kernel@...r.kernel.org
Subject: Re: register_syctl_init error in linux-next-20250612

On Thu, Jun 19, 2025 at 04:09:04PM +0200, Bert Karwatzki wrote:
> Am Donnerstag, dem 19.06.2025 um 13:50 +0200 schrieb Joel Granados:
> > Hey Bert
> > 
> > Thx for the report.
> > 
> > I just tested on my https://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl.git/log/?h=sysctl-next
> > and can't see the issue. Maybe its something that I'm missing in the
> > configuration. Do you happen to have your the .config that you used?
...
> > > +#endif
> > >  };
> > >  
> > >  int __init sysctl_init_bases(void)
> > > 
> > > 
> > > Bert Karwatzki
> 
> I'm running next-20250617 (but I'll also try your sysctl-next branch) with PREEMPT_RT=y, my current theory is that
> the init_rtmutex_sysctl() is corrupting the rbtree (if I remove init_rtmutex_sysctl() everything works
> (with the same .config)), and in the process removes the overflow{uid,gid} files.

I think that the error occurs when the register gets called several
times for the same path, returns an error resulting in a undefined
state. I see that rtmutex.c is included from 4 files, I also see that the
registration happens 4 times.

I just did not understand what was being done in my initial patch. The
fix is to put the sysctl registration in some "main" file (rtmutx_api?)
and to keep the max_lock_depth variable there as well (like it was
originally)


This is my proposal, Does it solve your issue?


diff --git i/include/linux/rtmutex.h w/include/linux/rtmutex.h
index dc9a51cda97c..fa9f1021541e 100644
--- i/include/linux/rtmutex.h
+++ w/include/linux/rtmutex.h
@@ -18,6 +18,8 @@
 #include <linux/rbtree_types.h>
 #include <linux/spinlock_types_raw.h>
 
+extern int max_lock_depth;
+
 struct rt_mutex_base {
 	raw_spinlock_t		wait_lock;
 	struct rb_root_cached   waiters;
diff --git i/kernel/locking/rtmutex.c w/kernel/locking/rtmutex.c
index 705a0e0fd72a..c80902eacd79 100644
--- i/kernel/locking/rtmutex.c
+++ w/kernel/locking/rtmutex.c
@@ -29,29 +29,6 @@
 #include "rtmutex_common.h"
 #include "lock_events.h"
 
-/*
- * Max number of times we'll walk the boosting chain:
- */
-static int max_lock_depth = 1024;
-
-static const struct ctl_table rtmutex_sysctl_table[] = {
-	{
-		.procname	= "max_lock_depth",
-		.data		= &max_lock_depth,
-		.maxlen		= sizeof(int),
-		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
-	},
-};
-
-static int __init init_rtmutex_sysctl(void)
-{
-	register_sysctl_init("kernel", rtmutex_sysctl_table);
-	return 0;
-}
-
-subsys_initcall(init_rtmutex_sysctl);
-
 #ifndef WW_RT
 # define build_ww_mutex()	(false)
 # define ww_container_of(rtm)	NULL
diff --git i/kernel/locking/rtmutex_api.c w/kernel/locking/rtmutex_api.c
index 9e00ea0e5cfa..4fa1acceaebb 100644
--- i/kernel/locking/rtmutex_api.c
+++ w/kernel/locking/rtmutex_api.c
@@ -8,6 +8,30 @@
 #define RT_MUTEX_BUILD_MUTEX
 #include "rtmutex.c"
 
+/*
+ * Max number of times we'll walk the boosting chain:
+ */
+int max_lock_depth = 1024;
+
+static const struct ctl_table rtmutex_sysctl_table[] = {
+	{
+		.procname	= "max_lock_depth",
+		.data		= &max_lock_depth,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+	},
+};
+
+static int __init init_rtmutex_sysctl(void)
+{
+	printk("registering rtmutex");
+	register_sysctl_init("kernel", rtmutex_sysctl_table);
+	return 0;
+}
+
+subsys_initcall(init_rtmutex_sysctl);
+
 /*
  * Debug aware fast / slowpath lock,trylock,unlock
  *


-- 

Joel Granados

Download attachment "signature.asc" of type "application/pgp-signature" (660 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ