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: <Z7T50DxEL7NYkr8H@bombadil.infradead.org>
Date: Tue, 18 Feb 2025 13:21:20 -0800
From: Luis Chamberlain <mcgrof@...nel.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: "Masami Hiramatsu (Google)" <mhiramat@...nel.org>,
	linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
	Mark Rutland <mark.rutland@....com>,
	Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Petr Pavlu <petr.pavlu@...e.com>,
	Sami Tolvanen <samitolvanen@...gle.com>,
	Daniel Gomez <da.gomez@...sung.com>, linux-modules@...r.kernel.org
Subject: Re: [PATCH 5/8] module: Add module_for_each_mod() function

On Fri, Feb 14, 2025 at 05:30:17PM -0500, Steven Rostedt wrote:
> On Thu, 6 Feb 2025 10:27:20 -0500
> Steven Rostedt <rostedt@...dmis.org> wrote:
> 
> > > BTW, do we really need to disable preempt or is it enough to call
> > > rcu_read_lock()?  
> > 
> > Bah, as I expected this function to be changed, I didn't spend too much
> > time on looking at its implementation. I just cut and pasted how the other
> > loops worked. But yes, it should not be disabling preemption. In fact, I
> > think the module code itself should not be disabling preemption!
> > 
> > I'll have to go and look into that.
> 
> It really looks like it requires preempt_disable(), as the code in
> kernel/module/main.c has in several places:
> 
> 	preempt_disable();
> 
> 	list_for_each_entry_rcu(mod, &modules, list) {
> 		[..]
> 	}
> 
> 	preempt_enable();
> 
> Or
> 
> 	module_assert_mutex_or_preempt();
> 
> 	[..]
> 
> 	list_for_each_entry_rcu(mod, &modules, list,
> 				lockdep_is_held(&module_mutex)) {
> 
> 
> So it looks like it either requires preempt_disable or holding the
> module_mutex.
> 
> As I need to call this with trace_types_lock held, and there's a place
> where trace_types_lock is within a module callback, I don't think it's safe
> to take that lock in that loop, otherwise we have the ABBA deadlock.
> 
> Luis,
> 
> Is this patch OK, and also is there any plan to move the module code to
> using just rcu_read_lock instead of preempt_disable?

The patch is not OK, you're looking at old code, look at
modules-next and as Petr suggested look at Sebastian's recently
merged work.

git remote add korg-modules git://git.kernel.org/pub/scm/linux/kernel/git/modules/linux.git

  Luis

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ