2017-11-22 17:44:00

by Florian Fainelli

[permalink] [raw]
Subject: kernel BUG at crypto/asymmetric_keys/public_key.c:80

Hi,

(sorry for the cross post)

I am at v4.14-12995-g0c86a6bd85ff and just met the following, attached
is my .config file. Is this a known problem? Thanks!

[ 1.798714] cfg80211: Loading compiled-in X.509 certificates for
regulatory database
[ 1.809390] ------------[ cut here ]------------
[ 1.814020] kernel BUG at crypto/asymmetric_keys/public_key.c:80!
[ 1.820123] Internal error: Oops - BUG: 0 [#1] SMP ARM
[ 1.825273] Modules linked in:
[ 1.828341] CPU: 0 PID: 1 Comm: swapper/0 Not tainted
4.14.0-12995-g0c86a6bd85ff #15
[ 1.836096] Hardware name: Broadcom STB (Flattened Device Tree)
[ 1.842025] task: ee0a0000 task.stack: ee096000
[ 1.846576] PC is at public_key_verify_signature+0x21c/0x260
[ 1.852248] LR is at x509_check_for_self_signed+0xb0/0x10c
[ 1.857743] pc : [<c0525d08>] lr : [<c0526ee8>] psr: 60000013
[ 1.864019] sp : ee097cf8 ip : c0a7a3ae fp : 00000000
[ 1.869252] r10: c248e9d8 r9 : c0b401e0 r8 : ee374040
[ 1.874487] r7 : c0a7a340 r6 : ee374200 r5 : c2404c48 r4 : edac8880
[ 1.881024] r3 : 00000000 r2 : c0b40480 r1 : ee3741c0 r0 : ee374040
[ 1.887563] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM
Segment user
[ 1.894709] Control: 30c5387d Table: 00003000 DAC: fffffffd
[ 1.900465] Process swapper/0 (pid: 1, stack limit = 0xee096210)
[ 1.906481] Stack: (0xee097cf8 to 0xee098000)
[ 1.910845] 7ce0:
60000013 00000000
[ 1.919037] 7d00: 014080c0 c052149c 000011a0 c248e9d8 00000000
c033dcb8 ee097d98 014000c0
[ 1.927229] 7d20: ffffffff 00000001 ed58622e c0a7a634 00000001
ed58622e c0a7a634 c0521530
[ 1.935421] 7d40: c052143c ffffffff ed586200 00000000 00000000
00000000 c0518bc0 c248e9d8
[ 1.943612] 7d60: 00000000 c02416f8 c244bc28 00000000 ed586200
ed586388 ed586384 60000013
[ 1.951804] 7d80: 00000000 c0b400d4 c0518bc0 c248e9d8 00000000
c025de10 00000000 00000000
[ 1.959995] 7da0: 00000000 fffffffe fffffffe 00000000 00000000
c0b400d4 c0518bc0 c0518c34
[ 1.968187] 7dc0: c0a23498 ee096000 00000000 00040e00 ee374302
edac8880 edac8880 ee374200
[ 1.976378] 7de0: c0a7a340 000002a8 c0b401e0 c248e9d8 00000000
c0526ee8 00000000 edac8880
[ 1.984569] 7e00: ee374200 c0525f24 c244d210 ee097e80 c248e9d8
ee097e80 c244d1ac c0526b74
[ 1.992760] 7e20: c244d210 c244b988 c248e9d8 ee097e80 c244d1ac
c0b401e0 c248e9d8 c0524f20
[ 2.000952] 7e40: c2404c48 c244b988 c0a7a340 edac8801 ee02c180
edac8800 00000000 c0511148
[ 2.009143] 7e60: c24b7eda 00000048 60000013 00000000 00000000
c244d1b4 00000000 00000000
[ 2.017335] 7e80: 00000000 00000000 00000000 00000000 00000000
c0a7a340 000002a8 00000000
[ 2.025527] 7ea0: 7fffffff 00040e00 c0a7a340 c24df7b4 000002a8
c0a7a5e8 c0bb10d8 c0b18088
[ 2.033718] 7ec0: 1f030000 c0e47898 000002a8 1f030000 0000000e
00000000 00000000 c2404c48
[ 2.041910] 7ee0: ffffe000 c0e4777c 00000000 c0e6583c c0e74f98
00000008 00000000 c0201bd8
[ 2.050101] 7f00: 60000013 c025dda4 00000000 c0c05a00 c0e005d8
00000000 00000000 00000007
[ 2.058292] 7f20: 00000007 00040e00 00000000 c240d790 00000000
c2404c48 c0e65818 00000000
[ 2.066483] 7f40: 00000000 00040e00 00000000 00040e00 c24a3100
c24a3100 c24a3100 00000109
[ 2.074675] 7f60: c0e65838 c0e6583c c0e74f98 c0e00e6c 00000007
00000007 00000000 c0e005d8
[ 2.082866] 7f80: c09b47f8 00000000 c09b47f8 00000000 00000000
00000000 00000000 00000000
[ 2.091057] 7fa0: 00000000 c09b4800 00000000 c0208920 00000000
00000000 00000000 00000000
[ 2.099248] 7fc0: 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000
[ 2.107440] 7fe0: 00000000 00000000 00000000 00000000 00000013
00000000 60bd36df 5ae9d652
[ 2.115645] [<c0525d08>] (public_key_verify_signature) from
[<c0526ee8>] (x509_check_for_self_signed+0xb0/0x10c)
[ 2.125842] [<c0526ee8>] (x509_check_for_self_signed) from
[<c0525f24>] (x509_cert_parse+0x14c/0x1a8)
[ 2.135080] [<c0525f24>] (x509_cert_parse) from [<c0526b74>]
(x509_key_preparse+0x14/0x18c)
[ 2.143449] [<c0526b74>] (x509_key_preparse) from [<c0524f20>]
(asymmetric_key_preparse+0x54/0xd4)
[ 2.152430] [<c0524f20>] (asymmetric_key_preparse) from [<c0511148>]
(key_create_or_update+0x120/0x3c4)
[ 2.161846] [<c0511148>] (key_create_or_update) from [<c0e47898>]
(regulatory_init_db+0x11c/0x1e4)
[ 2.170828] [<c0e47898>] (regulatory_init_db) from [<c0201bd8>]
(do_one_initcall+0x54/0x18c)
[ 2.179293] [<c0201bd8>] (do_one_initcall) from [<c0e00e6c>]
(kernel_init_freeable+0x140/0x1cc)
[ 2.188011] [<c0e00e6c>] (kernel_init_freeable) from [<c09b4800>]
(kernel_init+0x8/0x110)
[ 2.196210] [<c09b4800>] (kernel_init) from [<c0208920>]
(ret_from_fork+0x14/0x34)
[ 2.203796] Code: ebf8636b eaffffab e7f001f2 e7f001f2 (e7f001f2)
[ 2.209901] ---[ end trace 4ec242c4e6a05178 ]---
[ 2.214553] Kernel panic - not syncing: Attempted to kill init!
exitcode=0x0000000b
--
Florian


Attachments:
config.gz (24.69 kB)

2017-11-24 07:56:39

by Johannes Berg

[permalink] [raw]
Subject: Re: kernel BUG at crypto/asymmetric_keys/public_key.c:80

On Thu, 2017-11-23 at 09:47 -0800, Florian Fainelli wrote:

> Absolutely, please find it enclosed.

Thanks.

This is a bit odd. I didn't think the most likely reason is that you
have

CONFIG_CRYPTO_SHA256=m

but everything else built-in. Thus, when loading the certificate,
there's no way to calculate the digest since that requires sha-256,
hence

BUG_ON(!sig->digest);

If you make CONFIG_CRYPTO_SHA256=y then it should go away.

I guess I'll do this:

diff --git a/net/wireless/Kconfig b/net/wireless/Kconfig
index da91bb547db3..1abcc4fc4df1 100644
--- a/net/wireless/Kconfig
+++ b/net/wireless/Kconfig
@@ -20,6 +20,10 @@ config CFG80211
tristate "cfg80211 - wireless configuration API"
depends on RFKILL || !RFKILL
select FW_LOADER
+ # may need to update this when certificates are changed and are
+ # using a different algorithm, though right now they shouldn't
+ # (this is here rather than below to allow it to be a module)
+ select CRYPTO_SHA256 if CFG80211_USE_KERNEL_REGDB_KEYS
---help---
cfg80211 is the Linux wireless LAN (802.11) configuration API.
Enable this if you have a wireless device.
@@ -113,6 +117,9 @@ config CFG80211_EXTRA_REGDB_KEYDIR
certificates like in the kernel sources (net/wireless/certs/)
that shall be accepted for a signed regulatory database.

+ Note that you need to also select the correct CRYPTO_<hash> modules
+ for your certificates, and if cfg80211 is built-in they also must be.
+
config CFG80211_REG_CELLULAR_HINTS
bool "cfg80211 regulatory support for cellular base station hints"
depends on CFG80211_CERTIFICATION_ONUS


Can you try if that fixes your config for you?

johannes

2017-11-22 18:29:04

by Arend Van Spriel

[permalink] [raw]
Subject: Re: kernel BUG at crypto/asymmetric_keys/public_key.c:80

+ Johannes

On 22-11-17 18:43, Florian Fainelli wrote:
> Hi,
>
> (sorry for the cross post)
>
> I am at v4.14-12995-g0c86a6bd85ff and just met the following, attached
> is my .config file. Is this a known problem? Thanks!
>
> [ 1.798714] cfg80211: Loading compiled-in X.509 certificates for
> regulatory database
> [ 1.809390] ------------[ cut here ]------------
> [ 1.814020] kernel BUG at crypto/asymmetric_keys/public_key.c:80!
> [ 1.820123] Internal error: Oops - BUG: 0 [#1] SMP ARM
> [ 1.825273] Modules linked in:
> [ 1.828341] CPU: 0 PID: 1 Comm: swapper/0 Not tainted
> 4.14.0-12995-g0c86a6bd85ff #15
> [ 1.836096] Hardware name: Broadcom STB (Flattened Device Tree)
> [ 1.842025] task: ee0a0000 task.stack: ee096000
> [ 1.846576] PC is at public_key_verify_signature+0x21c/0x260
> [ 1.852248] LR is at x509_check_for_self_signed+0xb0/0x10c
> [ 1.857743] pc : [<c0525d08>] lr : [<c0526ee8>] psr: 60000013
> [ 1.864019] sp : ee097cf8 ip : c0a7a3ae fp : 00000000
> [ 1.869252] r10: c248e9d8 r9 : c0b401e0 r8 : ee374040
> [ 1.874487] r7 : c0a7a340 r6 : ee374200 r5 : c2404c48 r4 : edac8880
> [ 1.881024] r3 : 00000000 r2 : c0b40480 r1 : ee3741c0 r0 : ee374040
> [ 1.887563] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM
> Segment user
> [ 1.894709] Control: 30c5387d Table: 00003000 DAC: fffffffd
> [ 1.900465] Process swapper/0 (pid: 1, stack limit = 0xee096210)
> [ 1.906481] Stack: (0xee097cf8 to 0xee098000)
> [ 1.910845] 7ce0:
> 60000013 00000000
> [ 1.919037] 7d00: 014080c0 c052149c 000011a0 c248e9d8 00000000
> c033dcb8 ee097d98 014000c0
> [ 1.927229] 7d20: ffffffff 00000001 ed58622e c0a7a634 00000001
> ed58622e c0a7a634 c0521530
> [ 1.935421] 7d40: c052143c ffffffff ed586200 00000000 00000000
> 00000000 c0518bc0 c248e9d8
> [ 1.943612] 7d60: 00000000 c02416f8 c244bc28 00000000 ed586200
> ed586388 ed586384 60000013
> [ 1.951804] 7d80: 00000000 c0b400d4 c0518bc0 c248e9d8 00000000
> c025de10 00000000 00000000
> [ 1.959995] 7da0: 00000000 fffffffe fffffffe 00000000 00000000
> c0b400d4 c0518bc0 c0518c34
> [ 1.968187] 7dc0: c0a23498 ee096000 00000000 00040e00 ee374302
> edac8880 edac8880 ee374200
> [ 1.976378] 7de0: c0a7a340 000002a8 c0b401e0 c248e9d8 00000000
> c0526ee8 00000000 edac8880
> [ 1.984569] 7e00: ee374200 c0525f24 c244d210 ee097e80 c248e9d8
> ee097e80 c244d1ac c0526b74
> [ 1.992760] 7e20: c244d210 c244b988 c248e9d8 ee097e80 c244d1ac
> c0b401e0 c248e9d8 c0524f20
> [ 2.000952] 7e40: c2404c48 c244b988 c0a7a340 edac8801 ee02c180
> edac8800 00000000 c0511148
> [ 2.009143] 7e60: c24b7eda 00000048 60000013 00000000 00000000
> c244d1b4 00000000 00000000
> [ 2.017335] 7e80: 00000000 00000000 00000000 00000000 00000000
> c0a7a340 000002a8 00000000
> [ 2.025527] 7ea0: 7fffffff 00040e00 c0a7a340 c24df7b4 000002a8
> c0a7a5e8 c0bb10d8 c0b18088
> [ 2.033718] 7ec0: 1f030000 c0e47898 000002a8 1f030000 0000000e
> 00000000 00000000 c2404c48
> [ 2.041910] 7ee0: ffffe000 c0e4777c 00000000 c0e6583c c0e74f98
> 00000008 00000000 c0201bd8
> [ 2.050101] 7f00: 60000013 c025dda4 00000000 c0c05a00 c0e005d8
> 00000000 00000000 00000007
> [ 2.058292] 7f20: 00000007 00040e00 00000000 c240d790 00000000
> c2404c48 c0e65818 00000000
> [ 2.066483] 7f40: 00000000 00040e00 00000000 00040e00 c24a3100
> c24a3100 c24a3100 00000109
> [ 2.074675] 7f60: c0e65838 c0e6583c c0e74f98 c0e00e6c 00000007
> 00000007 00000000 c0e005d8
> [ 2.082866] 7f80: c09b47f8 00000000 c09b47f8 00000000 00000000
> 00000000 00000000 00000000
> [ 2.091057] 7fa0: 00000000 c09b4800 00000000 c0208920 00000000
> 00000000 00000000 00000000
> [ 2.099248] 7fc0: 00000000 00000000 00000000 00000000 00000000
> 00000000 00000000 00000000
> [ 2.107440] 7fe0: 00000000 00000000 00000000 00000000 00000013
> 00000000 60bd36df 5ae9d652
> [ 2.115645] [<c0525d08>] (public_key_verify_signature) from
> [<c0526ee8>] (x509_check_for_self_signed+0xb0/0x10c)
> [ 2.125842] [<c0526ee8>] (x509_check_for_self_signed) from
> [<c0525f24>] (x509_cert_parse+0x14c/0x1a8)
> [ 2.135080] [<c0525f24>] (x509_cert_parse) from [<c0526b74>]
> (x509_key_preparse+0x14/0x18c)
> [ 2.143449] [<c0526b74>] (x509_key_preparse) from [<c0524f20>]
> (asymmetric_key_preparse+0x54/0xd4)
> [ 2.152430] [<c0524f20>] (asymmetric_key_preparse) from [<c0511148>]
> (key_create_or_update+0x120/0x3c4)
> [ 2.161846] [<c0511148>] (key_create_or_update) from [<c0e47898>]
> (regulatory_init_db+0x11c/0x1e4)
> [ 2.170828] [<c0e47898>] (regulatory_init_db) from [<c0201bd8>]
> (do_one_initcall+0x54/0x18c)
> [ 2.179293] [<c0201bd8>] (do_one_initcall) from [<c0e00e6c>]
> (kernel_init_freeable+0x140/0x1cc)
> [ 2.188011] [<c0e00e6c>] (kernel_init_freeable) from [<c09b4800>]
> (kernel_init+0x8/0x110)
> [ 2.196210] [<c09b4800>] (kernel_init) from [<c0208920>]
> (ret_from_fork+0x14/0x34)
> [ 2.203796] Code: ebf8636b eaffffab e7f001f2 e7f001f2 (e7f001f2)
> [ 2.209901] ---[ end trace 4ec242c4e6a05178 ]---
> [ 2.214553] Kernel panic - not syncing: Attempted to kill init!
> exitcode=0x0000000b
>

This is the regulatory database stuff that Johannes added. The BUG()
that triggers is here:

int public_key_verify_signature(const struct public_key *pkey,
const struct public_key_signature *sig)
{
struct crypto_wait cwait;
struct crypto_akcipher *tfm;
struct akcipher_request *req;
struct scatterlist sig_sg, digest_sg;
const char *alg_name;
char alg_name_buf[CRYPTO_MAX_ALG_NAME];
void *output;
unsigned int outlen;
int ret = -ENOMEM;

pr_devel("==>%s()\n", __func__);

BUG_ON(!pkey);
BUG_ON(!sig);
>>> BUG_ON(!sig->digest);
BUG_ON(!sig->s);

alg_name = sig->pkey_algo;

Regards,
Arend

2017-11-23 17:48:03

by Florian Fainelli

[permalink] [raw]
Subject: Re: kernel BUG at crypto/asymmetric_keys/public_key.c:80



On 11/23/2017 06:24 AM, Johannes Berg wrote:
> On Wed, 2017-11-22 at 15:07 -0800, Florian Fainelli wrote:
>> On 11/22/2017 10:42 AM, Johannes Berg wrote:
>>> On Wed, 2017-11-22 at 19:29 +0100, Arend van Spriel wrote:
>>>> + Johannes
>>>>
>>>> >>> BUG_ON(!sig->digest);
>>>> BUG_ON(!sig->s);
>>>
>>> I *think* this is the same bug that was reported before, then this
>>> should fix it:
>>>
>>> https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git/commit/?id=d7be102f2945a626f55e0501e52bb31ba3e77b81
>>>
>>> Can you try?
>>
>> My baseline already has this commit actually, is there something else
>> you would want me to check?
>
> Hmm, different problem then - could you put the entire boot log
> somewhere I can read it?

Absolutely, please find it enclosed.
--
Florian


Attachments:
log (21.49 kB)

2017-11-23 14:24:13

by Johannes Berg

[permalink] [raw]
Subject: Re: kernel BUG at crypto/asymmetric_keys/public_key.c:80

On Wed, 2017-11-22 at 15:07 -0800, Florian Fainelli wrote:
> On 11/22/2017 10:42 AM, Johannes Berg wrote:
> > On Wed, 2017-11-22 at 19:29 +0100, Arend van Spriel wrote:
> > > + Johannes
> > >
> > > >>> BUG_ON(!sig->digest);
> > > BUG_ON(!sig->s);
> >
> > I *think* this is the same bug that was reported before, then this
> > should fix it:
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git/commit/?id=d7be102f2945a626f55e0501e52bb31ba3e77b81
> >
> > Can you try?
>
> My baseline already has this commit actually, is there something else
> you would want me to check?

Hmm, different problem then - could you put the entire boot log
somewhere I can read it?

johannes

2017-11-22 23:07:27

by Florian Fainelli

[permalink] [raw]
Subject: Re: kernel BUG at crypto/asymmetric_keys/public_key.c:80

On 11/22/2017 10:42 AM, Johannes Berg wrote:
> On Wed, 2017-11-22 at 19:29 +0100, Arend van Spriel wrote:
>> + Johannes
>>
>> >>> BUG_ON(!sig->digest);
>> BUG_ON(!sig->s);
>
> I *think* this is the same bug that was reported before, then this
> should fix it:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git/commit/?id=d7be102f2945a626f55e0501e52bb31ba3e77b81
>
> Can you try?

My baseline already has this commit actually, is there something else
you would want me to check?

Thanks!
--
Florian

2017-11-22 18:42:44

by Johannes Berg

[permalink] [raw]
Subject: Re: kernel BUG at crypto/asymmetric_keys/public_key.c:80

On Wed, 2017-11-22 at 19:29 +0100, Arend van Spriel wrote:
> + Johannes
>
> >>> BUG_ON(!sig->digest);
> BUG_ON(!sig->s);

I *think* this is the same bug that was reported before, then this
should fix it:

https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git/commit/?id=d7be102f2945a626f55e0501e52bb31ba3e77b81

Can you try?

johannes