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: <20250206102720.0fd57129@gandalf.local.home>
Date: Thu, 6 Feb 2025 10:27:20 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: "Masami Hiramatsu (Google)" <mhiramat@...nel.org>
Cc: 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>, Luis Chamberlain <mcgrof@...nel.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 Thu, 6 Feb 2025 14:28:17 +0900
Masami Hiramatsu (Google) <mhiramat@...nel.org> wrote:

> > --- a/kernel/module/main.c
> > +++ b/kernel/module/main.c
> > @@ -3809,6 +3809,20 @@ bool is_module_text_address(unsigned long addr)
> >  	return ret;
> >  }
> >    
> 
> It is better to add a kerneldoc for this API.

Agreed, but I was planning on this changing. Waiting to hear from the
module maintainers.

> 
> /** 
>  * module_for_each_mod() - iterate all modules
>  * @func: Callback function
>  * @data: User data
>  *
>  * Call the @func with each module in the system. If @func returns !0, this
>  * stops itrating. Note that @func must not sleep since it is called under
>  * the preemption disabled.
>  */
> 
> 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.

Thanks!

-- Steve


> 
> Thank you,
> 
> > +void module_for_each_mod(int(*func)(struct module *mod, void *data), void *data)
> > +{
> > +	struct module *mod;
> > +
> > +	preempt_disable();
> > +	list_for_each_entry_rcu(mod, &modules, list) {
> > +		if (mod->state == MODULE_STATE_UNFORMED)
> > +			continue;
> > +		if (func(mod, data))
> > +			break;
> > +	}
> > +	preempt_enable();
> > +}
> > +
> >  /**
> >   * __module_text_address() - get the module whose code contains an address.
> >   * @addr: the address.
> > -- 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ