linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* crypto: template instantiation (maybe pcrypt) bug since 6.12
@ 2025-07-25 18:05 Vegard Nossum
  0 siblings, 0 replies; only message in thread
From: Vegard Nossum @ 2025-07-25 18:05 UTC (permalink / raw)
  To: Herbert Xu, Steffen Klassert
  Cc: Eric Biggers, Russell King, Ard Biesheuvel, Stephan Mueller,
	linux-crypto


Hi,

I've found an issue on mainline (since v6.12) where the pcrypt()
template seems completely broken:

$ python -c "import socket; socket.socket(socket.AF_ALG, 
socket.SOCK_SEQPACKET, 0).bind(('aead', 'pcrypt(ccm(aes))'))"
...
OSError: [Errno 36] File name too long

and then...

$ grep 'pcrypt(' /proc/crypto
driver       : 
pcrypt(pcrypt(pcrypt(pcrypt(pcrypt(pcrypt(pcrypt(pcrypt(pcrypt(pcrypt(ccm_base(ctr(aes-generic),cbcmac(aes-generic))))))))))))
driver       : 
pcrypt(pcrypt(pcrypt(pcrypt(pcrypt(pcrypt(pcrypt(pcrypt(pcrypt(ccm_base(ctr(aes-generic),cbcmac(aes-generic)))))))))))
driver       : 
pcrypt(pcrypt(pcrypt(pcrypt(pcrypt(pcrypt(pcrypt(pcrypt(ccm_base(ctr(aes-generic),cbcmac(aes-generic))))))))))
driver       : 
pcrypt(pcrypt(pcrypt(pcrypt(pcrypt(pcrypt(pcrypt(ccm_base(ctr(aes-generic),cbcmac(aes-generic)))))))))
driver       : 
pcrypt(pcrypt(pcrypt(pcrypt(pcrypt(pcrypt(ccm_base(ctr(aes-generic),cbcmac(aes-generic))))))))
driver       : 
pcrypt(pcrypt(pcrypt(pcrypt(pcrypt(ccm_base(ctr(aes-generic),cbcmac(aes-generic)))))))
driver       : 
pcrypt(pcrypt(pcrypt(pcrypt(ccm_base(ctr(aes-generic),cbcmac(aes-generic))))))
driver       : 
pcrypt(pcrypt(pcrypt(ccm_base(ctr(aes-generic),cbcmac(aes-generic)))))
driver       : 
pcrypt(pcrypt(ccm_base(ctr(aes-generic),cbcmac(aes-generic))))
driver       : pcrypt(ccm_base(ctr(aes-generic),cbcmac(aes-generic)))

Yeah... :-)

I've bisected it to these two commits:

e7a4142b35ce489fc8908d75596c51549711ade0 -- hangs
795f85fca229a88543a0a706039f901106bf11c1 -- bad

Basically pcrypt() seems trying to instantiate itself on the algorithm
it just registered (...a larval?).

I made this handy stack trace to try to understand what the flow is
since it involves multiple notifiers and kthreads:

bind
- alg_bind
   - aead_bind
     - crypto_alloc_tfm_node // loops over:
       - crypto_alg_mod_lookup
         - crypto_larval_lookup
           - crypto_alg_lookup
             - __crypto_alg_lookup // iterates over crypto_alg_list
         - crypto_larval_wait
           - crypto_alg_lookup
             - __crypto_alg_lookup // iterates over crypto_alg_list
         - crypto_probing_notify
           - blocking_notifier_call_chain
             - cryptomgr_notify
               - cryptomgr_schedule_probe
                 - cryptomgr_probe <-- switch threads!
                   - pcrypt_create
                     - pcrypt_create_aead
                       - pcrypt_init_instance
                     - aead_register_instance
                       - crypto_register_instance
                         - __crypto_register_alg // iterates over 
crypto_alg_list (+ adds to it)
                           - crypto_alg_finish_registration // iterates 
over crypto_alg_list
                             - crypto_notify

I tried a bunch of stuff but unfortunately I didn't manage to come up
with a fix on my own so far, maybe it's easy for somebody who already
knows this code though.

You'll obviously need these to run the repro:

CONFIG_CRYPTO_USER_API=y
CONFIG_CRYPTO_USER_API_AEAD=y
CONFIG_CRYPTO_PCRYPT=y
CONFIG_CRYPTO_CCM=y
CONFIG_CRYPTO_AES=y

I do think it's probably a generic template instantiation issue but I
just happened to run into it for pcrypt.


Vegard

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-07-25 18:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-25 18:05 crypto: template instantiation (maybe pcrypt) bug since 6.12 Vegard Nossum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).