I have figured out this bug. It has nothing to do with nfs. The
"mountall" program is entering an infinite loop in the "cut_options"
function because of a logic error in the string processing.

The cut_options function exists to strip mountall-only options
(showthrough, optional, bootwait, nobootwait) from the option string
that appears in fstab, while preserving the other options -
"rw,users,soft,intr" in the original poster's case.

But cut_options has a bug that causes an infinite loop when there is an
option that it wants to strip, and that option is followed by a comma -
that is, when a strippable option isn't the last option in the list.

You'll only hit the infinite loop if the fstab entry actually needs to
be mounted. You won't see it if you edit fstab to change the option
string for an entry that's already been mounted, or if you add an entry
for a device that doesn't exist.

To repro this on a running system, first kill the mountall process
running with --daemon, then add a line to fstab for a device which COULD
be mounted, but which is NOT currently mounted, and which has a
strippable option (like "nobootwait") followed by some other option.
Like this:

/dev/sda1 /mnt/xxx ext4 nobootwait,ro 0 0

In place of /dev/sda1, use any partition of any block-special device
which is not already mounted. The device you pick doesn't really have to
be mountable as ext4, because mountall will hang before it actually runs
"mount." But the device you pick has to pass all of mountall's other
sanity checks. As for the /mnt/xxx part, mountall will create that mount
point for you if it doesn't exist, so you'll have to delete it after
your experimenting.

Having edited fstab appropriately, run "sudo mountall -v" and watch it
hang and consume 100% CPU. Debug it, and hit ^C, and you will see you're
in cut_options (or else a function that it calls). You are infinite
looping with opts+i pointing to a comma, so j = strcspn(opt+i,",=") is
always zero and you never advance.

As for the fix: honestly, I tried to pick apart the logic with i, j, k,
and +1 and -1 and memmove and i-- but I got all twisted up. When this
logic strips an option, it keeps everything after it (including the
comma) in the case where more options follow. But when that happens,
opt+i ends up pointing at the comma, and from then on you never advance.
If I had to fix this bug myself I would rewrite the string-handling
logic completely, probably copying the options to KEEP from the original
string to the new one instead of using memmove to strip OUT the options
I wanted to remove. But that's just me.

-- 
mountall eats 100% cpu with nfs in fstab
https://bugs.launchpad.net/bugs/574044
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to