Bug when modprobing tcrypt

2009-06-29 Thread Eric Sesterhenn
Hi,

i can repeatedly trigger the following bug when modprobing tcrypt
to test the crypto algorithms with todays -git

[  122.967099] BUG: sleeping function called from invalid context at
kernel/rwsem.c:21
[  122.967398] in_atomic(): 1, irqs_disabled(): 0, pid: 4926, name:
modprobe
[  122.967643] INFO: lockdep is turned off.
[  122.967858] Pid: 4926, comm: modprobe Tainted: G   M
2.6.31-rc1-22297-g5298976 #24
[  122.968176] Call Trace:
[  122.968411]  [] __might_sleep+0xf9/0x101
[  122.968677]  [] down_read+0x16/0x68
[  122.968928]  [] crypto_alg_lookup+0x16/0x34
[  122.969479]  [] crypto_larval_lookup+0x30/0xf9
[  122.969722]  [] crypto_alg_mod_lookup+0x1d/0x62
[  122.969977]  [] crypto_alloc_base+0x1e/0x64
[  122.970271]  [] reset_prng_context+0xab/0x13f
[  122.970523]  [] ? __spin_lock_init+0x27/0x51
[  122.970777]  [] cprng_init+0x2a/0x42
[  122.971012]  [] __crypto_alloc_tfm+0xfa/0x128
[  122.971304]  [] crypto_alloc_base+0x33/0x64
[  122.971556]  [] alg_test_cprng+0x30/0x1f4
[  122.971809]  [] alg_test+0x12f/0x19f
[  122.972103]  [] ? __alloc_pages_nodemask+0x14d/0x481
[  122.972356]  [] do_test+0xf9d/0x163f [tcrypt]
[  122.972613]  [] do_test+0x3a1/0x163f [tcrypt]
[  122.972855]  [] tcrypt_mod_init+0x35/0x7c [tcrypt]
[  122.973488]  [] _stext+0x54/0x12c
[  122.974575]  [] ? tcrypt_mod_init+0x0/0x7c [tcrypt]
[  122.974836]  [] ? up_read+0x16/0x2b
[  122.975126]  [] ? __blocking_notifier_call_chain+0x40/0x4c
[  122.975376]  [] sys_init_module+0xa9/0x1bf
[  122.975635]  [] sysenter_do_call+0x12/0x32

(gdb) l *(crypto_alg_lookup+0x16)
0xc048bf04 is in crypto_alg_lookup (crypto/api.c:201).
196 struct crypto_alg *crypto_alg_lookup(const char *name, u32 type, u32
mask)
197 {
198 struct crypto_alg *alg;
199 
200 down_read(&crypto_alg_sem);
201 alg = __crypto_alg_lookup(name, type, mask);
202 up_read(&crypto_alg_sem);
203 
204 return alg;
205 }

Please let me know if you need further information or have patches to
test.

Regards, Eric

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


BUG in scatterlist.h when loading tcrypt

2008-06-02 Thread Eric Sesterhenn
Hi,

i guess this shouldnt happen, got this
when loading the tcrypt module

[   60.113277] testing ecb(seed) decryption across pages (chunking)
[   60.113309] 
[   60.113311] testing cts(cbc(aes)) encryption
[   60.120984] test 1 (128 bit key):
[   60.121153] [ cut here ]
[   60.121312] kernel BUG at include/linux/scatterlist.h:65!
[   60.121446] invalid opcode:  [#1] PREEMPT DEBUG_PAGEALLOC
[   60.121828] Modules linked in: tcrypt(+)
[   60.122019] 
[   60.122019] Pid: 4100, comm: modprobe Not tainted
(2.6.26-rc4-00103-g1beee8d #7)
[   60.122019] EIP: 0060:[] EFLAGS: 00010216 CPU: 0
[   60.122019] EIP is at cts_cbc_encrypt+0x2f0/0x300
[   60.122019] EAX: c11808e0 EBX: 0010 ECX: c1002000 EDX: c11813c0
[   60.122019] ESI: cbd4a5a0 EDI: cbf47bc0 EBP: cbf47c7c ESP: cbf47b3c
[   60.122019]  DS: 007b ES: 007b FS:  GS: 0033 SS: 0068
[   60.122019] Process modprobe (pid: 4100, ti=cbf47000 task=cbf0ef20
task.ti=cbf47000)
[   60.122019] Stack: 0011  0046 0001 0046
c0a2c4c0  cbf47b60 
[   60.122019]c01464ad cbf47b9c 0046 0046 
cbf47b8c c014048e cbf47ba4 
[   60.122019]00014f76 6f772049 20646c75 656b696c 65687420
0020   
[   60.122019] Call Trace:
[   60.122019]  [] ? put_lock_stats+0xd/0x30
[   60.122019]  [] ? getnstimeofday+0x3e/0x100
[   60.122019]  [] ? hrtimer_interrupt+0x15e/0x190
[   60.122019]  [] ? check_bytes_and_report+0x21/0xc0
[   60.122019]  [] ? slab_pad_check+0x73/0x110
[   60.122019]  [] ? __slab_free+0x63/0x2e0
[   60.122019]  [] ? crypto_cts_encrypt+0xde/0x100
[   60.122019]  [] ? setkey+0xc5/0xf0
[   60.122019]  [] ? async_encrypt+0x38/0x50
[   60.122019]  [] ? test_cipher+0x215/0x840 [tcrypt]
[   60.122019]  [] ? getnstimeofday+0x3e/0x100
[   60.122019]  [] ? clockevents_program_event+0x99/0x110
[   60.122019]  [] ? tick_program_event+0x42/0x70
[   60.122019]  [] ? hrtimer_interrupt+0x15e/0x190
[   60.122019]  [] ? restore_nocheck+0x12/0x15
[   60.122019]  [] ? tcrypt_mod_init+0x1a40/0x1bf4 [tcrypt]
[   60.122019]  [] ? blocking_notifier_call_chain+0x1a/0x20
[   60.122019]  [] ? sys_init_module+0xee/0x18e0
[   60.122019]  [] ? unlock_page+0x24/0x30
[   60.122019]  [] ? __kmalloc+0x0/0x100
[   60.122019]  [] ? sysenter_past_esp+0x6a/0xb1
[   60.122019]  ===
[   60.122019] Code: 0b eb fe 0f 0b eb fe 8d 74 26 00 0f 0b eb fe 0f 0b
eb fe 0f 0b eb fe 8d 74 26 00 0f 0b eb fe 0f 0b eb fe 0f 0b eb fe 8d 74
26 00 <0f> 0b eb fe 8d b6 00 00 00 00 8d bf 00 00 00 00 55 89 e5 83 ec 
[   60.122019] EIP: [] cts_cbc_encrypt+0x2f0/0x300 SS:ESP
0068:cbf47b3c
[   60.174099] ---[ end trace 4865479eed551e02 ]---

easily reproducible, but stack strace looks a bit different

[  353.926510] 
[  353.926512] testing ecb(seed) decryption across pages (chunking)
[  353.926540] 
[  353.926542] testing cts(cbc(aes)) encryption
[  353.930471] test 1 (128 bit key):
[  353.930603] [ cut here ]
[  353.930758] kernel BUG at include/linux/scatterlist.h:65!
[  353.930890] invalid opcode:  [#1] PREEMPT DEBUG_PAGEALLOC
[  353.931017] Modules linked in: tcrypt(+)
[  353.931017] 
[  353.931017] Pid: 4391, comm: modprobe Not tainted
(2.6.26-rc4-00103-g1beee8d #7)
[  353.931017] EIP: 0060:[] EFLAGS: 00010216 CPU: 0
[  353.931017] EIP is at cts_cbc_encrypt+0x2f0/0x300
[  353.931017] EAX: c1181f00 EBX: 0010 ECX: c1002000 EDX: c113a600
[  353.931017] ESI: cf3fb480 EDI: cbff8bc0 EBP: cbff8c7c ESP: cbff8b3c
[  353.931017]  DS: 007b ES: 007b FS:  GS: 0033 SS: 0068
[  353.931017] Process modprobe (pid: 4391, ti=cbff8000 task=cbecafa0
task.ti=cbff8000)
[  353.931017] Stack: 0011  37318b74 39333034 c08a4261
cfae50b8 005a 0008 
[  353.931017]c09b7160 cbff8b74 0001 c11f7c80 cfae4c90
c11f7c80 cbff8bac c0189336 
[  353.931017]0001 6f772049 20646c75 656b696c 65687420
0020   
[  353.931017] Call Trace:
[  353.931017]  [] ? __slab_alloc+0x86/0x5d0
[  353.931017]  [] ? _spin_unlock_irqrestore+0x39/0x70
[  353.931017]  [] ? release_console_sem+0x1bb/0x1e0
[  353.931017]  [] ? check_bytes_and_report+0x21/0xc0
[  353.931017]  [] ? slab_pad_check+0x73/0x110
[  353.931017]  [] ? __slab_free+0x63/0x2e0
[  353.931017]  [] ? crypto_cts_encrypt+0xde/0x100
[  353.931017]  [] ? setkey+0xc5/0xf0
[  353.931017]  [] ? async_encrypt+0x38/0x50
[  353.931017]  [] ? test_cipher+0x215/0x840 [tcrypt]
[  353.931017]  [] ? test_hash+0x1fa/0x4f0 [tcrypt]
[  353.931017]  [] ? tcrypt_mod_init+0x1a40/0x1bf4 [tcrypt]
[  353.931017]  [] ? blocking_notifier_call_chain+0x1a/0x20
[  353.931017]  [] ? sys_init_module+0xee/0x18e0
[  353.931017]  [] ? unlock_page+0x24/0x30
[  353.931017]  [] ? __kmalloc+0x0/0x100
[  353.931017]  [] ? sysenter_past_esp+0x6a/0xb1
[  353.931017]  ===
[  353.931017] Code: 0b eb fe 0f 0b eb fe 8d 74 26 00 0f 0b eb fe 0f 0b
eb fe 0f 0b eb fe 8d 74 26 00 0f 0b eb fe 0f 0b eb fe 0f 0b eb fe 8d 74
26 00 <0f> 0

Dead code in crypto/tcrypt.c

2006-09-26 Thread Eric Sesterhenn
hi,

the following commit added some code in test_hash_cycles() which coverity flags 
as dead code.
http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=e9d41164e2fdd897fe4520c2079eaf6e0ec3

The culprit are the following lines:


for (i = 0; i < 4; i++) {
-   crypto_digest_init(tfm);
+   ret = crypto_hash_init(desc);
+   if (ret)
+   goto out;
for (pcount = 0; pcount < blen; pcount += plen) {
sg_set_buf(sg, p + pcount, plen);
-   crypto_digest_update(tfm, sg, 1);
+   ret = crypto_hash_update(desc, sg, plen);
+   if (ret)
+   goto out;
}
-   crypto_digest_final(tfm, out);
+   crypto_hash_final(desc, out);
+   if (ret)
+   goto out;
}

We check ret before the for loop, and inside it, and
there is no way it can change in between. Are we missing
to assign the return value of crypto_hash_final() to ret?

Greetings, Eric

-
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html