git: sys/dev/disk/dm: Add a comment on race on unload

Tomohiro Kusumi tkusumi at crater.dragonflybsd.org
Thu Nov 12 07:09:37 PST 2015


commit 53a07f3ae7313aa58948a60f46428bfc2254dc3c
Author: Tomohiro Kusumi <kusumi.tomohiro at gmail.com>
Date:   Wed Nov 11 20:46:25 2015 +0900

    sys/dev/disk/dm: Add a comment on race on unload
    
    There is a minor race window in dm_modcmd() after the below
    conditional on unloading dm.ko. It's possible to create a new
    device after it gets beyond the conditional with 0.
    
        if (dm_dev_counter > 0)
            return EBUSY;
    
    Running the below a.sh and then b.sh concurrently causes
    kernel panic. Avoiding this race seems to be difficult using
    the existing locks that are all file local ones. The panic
    can be reproduced with or without the previous commit.
    
    ===== a.sh
      #!/usr/local/bin/bash
      while [ 1 ]; do
          kldload dm
          kldunload dm
      done
    
    ===== b.sh
      #!/usr/local/bin/bash
      kldload dm
      while [ 1 ]; do
          dmsetup create zero1 --table '0 100 zero'
          dmsetup remove /dev/mapper/zero1
      done

Summary of changes:
 sys/dev/disk/dm/device-mapper.c | 1 +
 1 file changed, 1 insertion(+)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/53a07f3ae7313aa58948a60f46428bfc2254dc3c


-- 
DragonFly BSD source repository



More information about the Commits mailing list