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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <895360e3-97bb-4188-a91d-eaca3302bd43@linux.dev>
Date: Thu, 25 Jul 2024 11:01:33 +0800
From: Youling Tang <youling.tang@...ux.dev>
To: Christoph Hellwig <hch@...radead.org>
Cc: Arnd Bergmann <arnd@...db.de>, Luis Chamberlain <mcgrof@...nel.org>,
 Chris Mason <clm@...com>, Josef Bacik <josef@...icpanda.com>,
 David Sterba <dsterba@...e.com>, tytso@....edu,
 Andreas Dilger <adilger.kernel@...ger.ca>, Jaegeuk Kim <jaegeuk@...nel.org>,
 Chao Yu <chao@...nel.org>, linux-arch@...r.kernel.org,
 linux-kernel@...r.kernel.org, linux-modules@...r.kernel.org,
 linux-btrfs@...r.kernel.org, linux-ext4@...r.kernel.org,
 linux-f2fs-devel@...ts.sourceforge.net, Youling Tang <tangyouling@...inos.cn>
Subject: Re: [PATCH 1/4] module: Add module_subinit{_noexit} and
 module_subeixt helper macros

On 24/07/2024 23:43, Christoph Hellwig wrote:
> On Wed, Jul 24, 2024 at 09:57:05AM +0800, Youling Tang wrote:
>> module_init(initfn)/module_exit(exitfn) has two definitions (via MODULE):
>> - buindin: uses do_initcalls() to iterate over the contents of the specified
>>    section and executes all initfn functions in the section in the order in
>>    which they are stored (exitfn is not required).
>>
>> - ko: run do_init_module(mod)->do_one_initcall(mod->init) to execute initfn
>>    of the specified module.
>>
>> If we change module_subinit to something like this, not called in
>> module_init,
>> Not only do we want to ensure that exit is executed in reverse order of
>> init, but we also want to ensure the order of init.
> Yes.
>
>> This does not guarantee the order in which init will be executed (although
>> the init/exit order will remain the same)
> Hmm, so the normal built-in initcalls depend on the link order, but when
> they are in the same file, the compiler can reorder them before we even
> get to the linker.
>
> I wonder what a good syntax would be to still avoid the boilerplate
> code.  We'd probably need one macro to actually define the init/exit
> table in a single statement so that it can't be reordered, but that
> would lose the ability to actually declare the module subinit/exit
> handlers in multiple files, which really is the biggest win of this
> scheme as it allows to keep the functions static instead of exposing
> them to other compilation units.
>
> And in fact even in your three converted file systems, most
> subinit/exit handler are in separate files, so maybe instead
> enforcing that there is just one per file and slightly refactoring
> the code so that this is the case might be the best option?
- It doesn't feel good to have only one subinit/exit in a file.
   Assuming that there is only one file in each file, how do we
   ensure that the files are linked in order?(Is it sorted by *.o
   in the Makefile?)

- Even if the order of each init is linked correctly, then the
   runtime will be iterated through the .subinitcall.init section,
   which executes each initfn in sequence (similar to do_initcalls),
   which means that no other code can be inserted between each subinit.


If module_subinit is called in module_init, other code can be inserted
between subinit, similar to the following:

```
static int __init init_example(void)
{
     module_subinit(inita, exita);

     otherthing...

     module_subinit(initb, exitb);

     return 0;
}

module_init(init_example);
```

IMHO, module_subinit() might be better called in module_init().

Thanks,
Youling.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ