• Sergey Senozhatsky's avatar
    zram: do not lookup algorithm in backends table · dc899972
    Sergey Senozhatsky authored
    Always use crypto_has_comp() so that crypto can lookup module, call
    usermodhelper to load the modules, wait for usermodhelper to finish and so
    on.  Otherwise crypto will do all of these steps under CPU hot-plug lock
    and this looks like too much stuff to handle under the CPU hot-plug lock. 
    Besides this can end up in a deadlock when usermodhelper triggers a code
    path that attempts to lock the CPU hot-plug lock, that zram already holds.
    
    An example of such deadlock:
    
    - path A. zram grabs CPU hot-plug lock, execs /sbin/modprobe from crypto
      and waits for modprobe to finish
    
    disksize_store
     zcomp_create
      __cpuhp_state_add_instance
       __cpuhp_state_add_instance_cpuslocked
        zcomp_cpu_up_prepare
         crypto_alloc_base
          crypto_alg_mod_lookup
           call_usermodehelper_exec
            wait_for_completion_killable
             do_wait_for_common
              schedule
    
    - path B. async work kthread that brings in scsi device. It wants to
      register CPUHP states at some ...
    dc899972
zcomp.c 5.7 KB