2012-01-17 18:34:26

by Francis Moreau

[permalink] [raw]
Subject: question about crypto module dependency

Hello,

I'm wondering how this scenario is supposed to work: let's say a
module A uses 'crc32c' function in lib/libcrc32c.c. In its turn this
function calls crypto_shash_update() which is exported by
crypto/shash.c. But now no module implementing "crc32c" has still been
loaded although crc32c.ko is available. Therefore the initial load of
module A fails although all required modules by the system are
present.

If the above is correct, how should it be handled ?

Thanks
--
Francis


2012-01-18 05:39:36

by Herbert Xu

[permalink] [raw]
Subject: Re: question about crypto module dependency

Francis Moreau <[email protected]> wrote:
> Hello,
>
> I'm wondering how this scenario is supposed to work: let's say a
> module A uses 'crc32c' function in lib/libcrc32c.c. In its turn this
> function calls crypto_shash_update() which is exported by
> crypto/shash.c. But now no module implementing "crc32c" has still been
> loaded although crc32c.ko is available. Therefore the initial load of
> module A fails although all required modules by the system are
> present.
>
> If the above is correct, how should it be handled ?

We'd need to adjust the init priority of libcrc32c and whatever
it depends on.

What is the user in question?

Cheers,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2012-01-18 07:49:13

by Francis Moreau

[permalink] [raw]
Subject: Re: question about crypto module dependency

On Wed, Jan 18, 2012 at 6:39 AM, Herbert Xu <[email protected]> wrote:
> Francis Moreau <[email protected]> wrote:
>> Hello,
>>
>> I'm wondering how this scenario is supposed to work: let's say a
>> module A uses 'crc32c' function in lib/libcrc32c.c. In its turn this
>> function calls crypto_shash_update() which is exported by
>> crypto/shash.c. But now no module implementing "crc32c" has still been
>> loaded although crc32c.ko is available. Therefore the initial load of
>> module A fails although all required modules by the system are
>> present.
>>
>> If the above is correct, how should it be handled ?
>
> We'd need to adjust the init priority of libcrc32c and whatever
> it depends on.

Could you give me some details beacause I don't see how that would work...

Currently we have this : libcrc32c -> shash

where '->' means depend on.

However I think we should have this: libcrc32c -> shash -> crc32c, to
get all modules properly loaded when using libcrc32c.

But it seems not possible because of the way shash is doing the load
of its backends dynamically: it requires that the backend has already
been registered.

>
> What is the user in question?

btrfs

Thanks.
--
Francis

2012-01-18 12:13:29

by Herbert Xu

[permalink] [raw]
Subject: Re: question about crypto module dependency

On Wed, Jan 18, 2012 at 08:49:13AM +0100, Francis Moreau wrote:
>
> > What is the user in question?
>
> btrfs

Hmm, why does it need to do crc32c at module init time?

Cheers,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2012-01-18 13:56:46

by Francis Moreau

[permalink] [raw]
Subject: Re: question about crypto module dependency

On Wed, Jan 18, 2012 at 1:13 PM, Herbert Xu <[email protected]> wrote:
> On Wed, Jan 18, 2012 at 08:49:13AM +0100, Francis Moreau wrote:
>>
>> > What is the user in question?
>>
>> btrfs
>
> Hmm, why does it need to do crc32c at module init time?
>

What do you mean with "at module init time" ?

My point is:

$ grep btrfs /lib/modules/3.2.1/modules.dep
kernel/fs/btrfs/btrfs.ko: kernel/lib/zlib_deflate/zlib_deflate.ko
kernel/lib/libcrc32c.ko

and

$ grep libcrc32c.ko: /lib/modules/3.2.1-1.1-desktop/modules.dep
kernel/lib/libcrc32c.ko:

So there's no dependency here to 'pull' a crc32c backend, therefore
"crypto_alloc_shash("crc32c", 0, 0)" used by libcrc32c at load time
fails.

Thanks
--
Francis

2012-01-18 22:25:18

by Herbert Xu

[permalink] [raw]
Subject: Re: question about crypto module dependency

On Wed, Jan 18, 2012 at 02:56:45PM +0100, Francis Moreau wrote:
>
> What do you mean with "at module init time" ?
>
> My point is:
>
> $ grep btrfs /lib/modules/3.2.1/modules.dep
> kernel/fs/btrfs/btrfs.ko: kernel/lib/zlib_deflate/zlib_deflate.ko
> kernel/lib/libcrc32c.ko
>
> and
>
> $ grep libcrc32c.ko: /lib/modules/3.2.1-1.1-desktop/modules.dep
> kernel/lib/libcrc32c.ko:
>
> So there's no dependency here to 'pull' a crc32c backend, therefore
> "crypto_alloc_shash("crc32c", 0, 0)" used by libcrc32c at load time
> fails.

We have a Kconfig dependency and the rest is taken care of by
modprobe.

Perhaps your problem is really with mkinitramfs?

Cheers,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2012-01-19 08:10:49

by Francis Moreau

[permalink] [raw]
Subject: Re: question about crypto module dependency

On Wed, Jan 18, 2012 at 11:25 PM, Herbert Xu
<[email protected]> wrote:
> On Wed, Jan 18, 2012 at 02:56:45PM +0100, Francis Moreau wrote:
>>
>> What do you mean with "at module init time" ?
>>
>> My point is:
>>
>> ? $ grep btrfs /lib/modules/3.2.1/modules.dep
>> ? kernel/fs/btrfs/btrfs.ko: kernel/lib/zlib_deflate/zlib_deflate.ko
>> kernel/lib/libcrc32c.ko
>>
>> and
>>
>> ? $ grep libcrc32c.ko: /lib/modules/3.2.1-1.1-desktop/modules.dep
>> ? kernel/lib/libcrc32c.ko:
>>
>> So there's no dependency here to 'pull' a crc32c backend, therefore
>> "crypto_alloc_shash("crc32c", 0, 0)" used by libcrc32c at load time
>> fails.
>
> We have a Kconfig dependency and the rest is taken care of by
> modprobe.

Hmm could you please be more verbose and details how it's supposed to work ?

How things are supposed to work when :

- crc32c module is not loaded
- libcrc32c module is not loaded
- btrfs is not loaded

and I issue: "modprobe btrfs" ?

>
> Perhaps your problem is really with mkinitramfs?
>

For now I can't tell, I did describe the issue I'm facing (it's not a
theoritical one) but you still haven't described how this is supposed
to work.

And after reading the code, I don't see how the use case I described
previously can work without some user space tweakings. But should
userpsace stuff have knowledge of such module deps ?

Thanks for your time.
--
Francis

2012-01-19 11:58:34

by Herbert Xu

[permalink] [raw]
Subject: Re: question about crypto module dependency

On Thu, Jan 19, 2012 at 09:10:48AM +0100, Francis Moreau wrote:
>
> How things are supposed to work when :
>
> - crc32c module is not loaded
> - libcrc32c module is not loaded
> - btrfs is not loaded
>
> and I issue: "modprobe btrfs" ?

When libcrc32c is loaded it'll automatically load crc32c through
the Crypto API.

Cheers,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2012-01-19 12:26:30

by Francis Moreau

[permalink] [raw]
Subject: Re: question about crypto module dependency

On Thu, Jan 19, 2012 at 12:58 PM, Herbert Xu
<[email protected]> wrote:
> On Thu, Jan 19, 2012 at 09:10:48AM +0100, Francis Moreau wrote:
>>
>> How things are supposed to work when :
>>
>> ? - crc32c module is not loaded
>> ? - libcrc32c module is not loaded
>> ? - btrfs is not loaded
>>
>> and I issue: "modprobe btrfs" ?
>
> When libcrc32c is loaded it'll automatically load crc32c through
> the Crypto API.
>

Did you try ?
--
Francis

2012-01-19 12:28:43

by Herbert Xu

[permalink] [raw]
Subject: Re: question about crypto module dependency

On Thu, Jan 19, 2012 at 01:26:30PM +0100, Francis Moreau wrote:
> On Thu, Jan 19, 2012 at 12:58 PM, Herbert Xu
> <[email protected]> wrote:
> > On Thu, Jan 19, 2012 at 09:10:48AM +0100, Francis Moreau wrote:
> >>
> >> How things are supposed to work when :
> >>
> >> ? - crc32c module is not loaded
> >> ? - libcrc32c module is not loaded
> >> ? - btrfs is not loaded
> >>
> >> and I issue: "modprobe btrfs" ?
> >
> > When libcrc32c is loaded it'll automatically load crc32c through
> > the Crypto API.
> >
>
> Did you try ?

Yes it works on my machine.

Cheers,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2012-01-22 14:47:54

by Francis Moreau

[permalink] [raw]
Subject: Re: question about crypto module dependency

On Thu, Jan 19, 2012 at 1:28 PM, Herbert Xu <[email protected]> wrote:
> On Thu, Jan 19, 2012 at 01:26:30PM +0100, Francis Moreau wrote:
>> On Thu, Jan 19, 2012 at 12:58 PM, Herbert Xu
>> <[email protected]> wrote:
>> > On Thu, Jan 19, 2012 at 09:10:48AM +0100, Francis Moreau wrote:
>> >>
>> >> How things are supposed to work when :
>> >>
>> >> ? - crc32c module is not loaded
>> >> ? - libcrc32c module is not loaded
>> >> ? - btrfs is not loaded
>> >>
>> >> and I issue: "modprobe btrfs" ?
>> >
>> > When libcrc32c is loaded it'll automatically load crc32c through
>> > the Crypto API.
>> >
>>
>> Did you try ?
>
> Yes it works on my machine.
>

Ok, It's acutally the user space tools which are confused: they don't
have a way to track the dependency therefore crc32c is not included in
my initrd.

I'm wondering how this could be fixed... I could hard code the
dependency in userspace but it looks like an ugly workaround.

Thanks
--
Francis