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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 8 Aug 2021 12:45:30 +0800
From:   Herbert Xu <herbert@...dor.apana.org.au>
To:     Byungchul Park <byungchul.park@....com>
Cc:     torvalds@...ux-foundation.org, peterz@...radead.org,
        mingo@...hat.com, will@...nel.org, davem@...emloft.net,
        linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org,
        tglx@...utronix.de, rostedt@...dmis.org, joel@...lfernandes.org,
        alexander.levin@...rosoft.com, daniel.vetter@...ll.ch,
        chris@...is-wilson.co.uk, duyuyang@...il.com,
        johannes.berg@...el.com, tj@...nel.org, tytso@....edu,
        willy@...radead.org, david@...morbit.com, amir73il@...il.com,
        bfields@...ldses.org, gregkh@...uxfoundation.org,
        kernel-team@....com
Subject: Re: [REPORT] Request for reviewing crypto code wrt
 wait_for_completion()

On Sat, Aug 07, 2021 at 12:46:39PM +0900, Byungchul Park wrote:
>
> > > THREAD C
> > > --------
> > > C1 cryptomgr_test()
> > > C2    crypto_alg_tested()
> > > C3       complete_all(c)
> > > 
> > > For example, in this situation, I think C3 could wake up both A6 and B9
> > > before THREAD B reaches B10 which is not desired by A6. Say, is it okay
> > > to wake up A6 with B7 ~ B9 having yet to complete?
> > 
> > AFAICS thread C only wakes up test larvals, not instantiation larvals.
> > Please let me know if you have any further issues.
> 
> The both cases looks like to get the larvals from the same list,
> crypto_alg_list, one from crypto_larval_lookup() and the other from
> __crypto_register_alg(). So I thought a single larval can be used at the
> same time both at crypto_wait_for_test() and crypto_alg_mod_lookup() by
> any chance. It would be great if the code ensures it never happens :-)

Perhaps it's not obvious but the distinguishing feature between test
larvals and the other kind of larvals is that test larvals have a
non-null cra_driver_name field.

In crypto_alg_tested we specifically exclude non-test larvals
when doing the lookup.

> The problematic scenario I wanted to ask you looks like - I was
> wondering if it's okay to nest requesting CRYPTO_MSG_ALG_REQUEST and
> CRYPTO_MSG_ALG_REGISTER in a single stack, in other words, if it's okay
> to try CRYPTO_MSG_ALG_REGISTER before completing CRYPTO_MSG_ALG_REQUEST.
> 
> A1 crypto_alg_mod_lookup()
> A2    crypto_probing_notify(CRYPTO_MSG_ALG_REQUEST)
> A3       cryptomgr_schedule_probe()
> A4          kthread_run(cyptomgr_probe) ---> Start THREAD B
> 
> B1 cryptomgr_probe()
> B2    pkcslpad_create()
> B3       crypto_wait_for_test()
> B4          crypto_probing_notify(CRYPTO_MSG_ALG_REGISTER)
> B5             cryptomgr_schedule_test()
> B6                kthread_run(cyptomgr_test) ---> Start THREAD C
> 
> C1 cryptomgr_test()
> C2    crypto_alg_tested()
> C3       complete_all(c) <- *the point* that I'd like to ask you.

Well c in this case can only be a test larval so it cannot wake
up thread A which is waiting on a non-test larval.

> A5    crypto_larval_wait()
> A6       wait_for_completion_killable_timeout(c) /* waiting for B10 */
>          (wake up and go)
> 
> Bx          wait_for_completion_killable(c) /* waiting for C3 */
>             (wake up and go)
> Bx    tmpl->alloc()
> Bx    crupto_register_instance()
> B10   complete_all(c)

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ