[Bug 942788] Re: sfdisk without --no-reread is likely to cause race conditions

Steve Langasek steve.langasek at canonical.com
Tue Feb 28 18:22:32 UTC 2012


** Changed in: util-linux (Ubuntu)
       Status: New => Triaged

** Changed in: util-linux (Ubuntu)
   Importance: Undecided => Medium

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to util-linux in Ubuntu.
https://bugs.launchpad.net/bugs/942788

Title:
  sfdisk without --no-reread is likely to cause race conditions

Status in “util-linux” package in Ubuntu:
  Triaged

Bug description:
  If you invoke sfdisk without --no-reread, you're almost guaranteed to
  have race conditions involved.

  Run the following as root:
    DEV=/dev/vdb # or some disk you don't have data on
    printf "1,,L,*\n" > sfdisk.in
    sudo udevadm settle;
    for((i=0;i<100;i++)); do  sfdisk $DEV  <sfdisk.in > out 2>&1 ||
       { echo "FAILED: $i"; cat out; break; } ; echo -n .; udevadm settle; done

  You'll see failure at some point.

  The problem is that unless you pass '--no-reread', sfdisk checks if
  the device is busy by issuing a BLKRRPART ioctl on the device.  That,
  in turn, causes a flurry of udev events that open the disk (such as
  'blkid').  If those udev events don't finish before sfdisk writes the
  partition table and calls BLKRRPART again, the second call will fail.

  To prove that a single run is destined for race condition, turn udevadm debug on with:
    udevadm control --log-priority=debug
  and then just run:
    sfdisk --re-read $DEV
  or
    blockdev --rereadpt $DEV

  That will show you output in /var/log/syslog that shows udev
  responding to events.

  ProblemType: Bug
  DistroRelease: Ubuntu 12.04
  Package: util-linux 2.20.1-1ubuntu2
  ProcVersionSignature: User Name 3.2.0-17.27-virtual 3.2.6
  Uname: Linux 3.2.0-17-virtual x86_64
  ApportVersion: 1.93-0ubuntu2
  Architecture: amd64
  Date: Tue Feb 28 17:36:40 2012
  Ec2AMI: ami-00000000
  Ec2AMIManifest: FIXME
  Ec2AvailabilityZone: nova
  Ec2InstanceType: m1.small
  Ec2Kernel: unavailable
  Ec2Ramdisk: unavailable
  ProcEnviron:
   TERM=screen
   PATH=(custom, user)
   LANG=en_US.UTF-8
   SHELL=/bin/bash
  SourcePackage: util-linux
  UpgradeStatus: No upgrade log present (probably fresh install)

  Related Bugs:
    * bug 937352: cloud-initramfs-tools root partition may not be grown by growpart

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/942788/+subscriptions




More information about the foundations-bugs mailing list