after upgrading to 4.2 bash stopped working inside a OpenVZ container

Bug #732322 reported by NIXin
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenVZ Tools
Fix Released
High
vzctl (Ubuntu)
Fix Released
Undecided
Unassigned
Hardy
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: bash

Using openvz on my Debian Squeeze host.
Inside a Ubuntu Natty containter (guest), after upgrading bash package from 4.1-2ubuntu5 to 4.2-0ubuntu2 - bash stops working.
This disables the
"vzctl enter VEID" command, as it chroots the virtual server and runs /bin/bash.
I've debugged this by downgrading back to 4.1-2 by running "vzctl exec VEID apt-get install bash/maverick" - after which "vzctl enter" works again.
I have not tested whether SSH bash login works or with bash 4.2 on a Debian Unstable guest.
I have reproduced the bug on two different host machines though. Not sure what is the cause of the bug.

Revision history for this message
In , Michaelk (michaelk) wrote :

Created attachment 1429
strace sessions of vzctl enter

Hi!

Problem:

When running "vzctl enter <VEID>" the command will hang with latest
version of bash i.e 4.2.7 ( happens with all 4.2.x versions )

I first thought this was bash bug and filed a report to the maintainer
of bash (Chet Ramey) but got back the response below which indicates this
might be a bug in vzctl instead,

Let me know if you need any more information.

There is also a thread discussing this issue at:

https://groups.google.com/group/gnu.bash.bug
https://groups.google.com/group/gnu.bash.bug/browse_thread/thread/0be5df8f41c8b88c#

//Michael

> Hi Chet!
>
> I run 3 different strace sessions (see attached file)
>
> 1. A working session (bash 3.2.25)
>
> # strace -ff -o /tmp/bash_strace/bash_working/bash_working.log vzctl enter 152
>
> 2. A failing session (bash 4.2.7):
>
> # strace -ff -o /tmp/bash_strace/bash_not_working/bash_not_working.log
> vzctl enter 152
>
> for the failing session pstree shows:
>
> bash(23067)---strace(23230)---vzctl(23231)---vzctl(23232)---bash(23233)

I suspect this is a bug in vzctl that was masked by bash-4.1 and previous
versions.

The only change of any significance here is that bash-4.1 closed file
descriptors 3-20 at startup. That's a bug; you can't close fds out
from under libraries like that. This caused mysterious crashes on Mac
OS X, for example when running bash as a login shell under iTerm.
Bash-4.2 sets the fds to close-on-exec instead.

The problem is that vzctl plays fast and loose with file descriptors.
It leaves read and write ends of pipes open in the child process it
forks to exec bash when it uses the other ends internally to communicate
with that child through the pty it opens as the controlling terminal.
The big difference between the non-working and working versions is that
bash-4.2 inherits file descriptors 3, 7, 9, and 10 and leaves them open,
where bash-4.1 closed them.

This results in the the process group that bash-4.2 is using being
orphaned, which makes read() return EOF and the kernel send SIGHUP and
SIGCONT to bash. This is consistent with the strace output.

You can test this by changing shell.c to call close(i) instead of
SET_CLOSE_ON_EXEC(i) around like 541. That's just to prove vzctl has
a bug, however -- I'm not going to revert that change.

Keep in mind that I haven't looked at the vzctl source code, and so don't
have any patches for it. Somehow, though, the file descriptors that
get closed in process 23231 after forking 23232 (in the bash-not-working
set of traces, fds 3,7,9,10) need to get closed in 23233 after 23232 forks
it and before it execs bash.

Let me know how it goes. If you can make the right changes to vzctl and
that fixes the problem, so much the better.

Revision history for this message
In , Openvz-bugs (openvz-bugs) wrote :

I've raised the severity because when an owner of a virtual machine installs Bash 4.2 patchlevel 0 or higher, it is a DoS against the owner of the physical machine :-).

There are times when it is handy to have the vzctl enter option and this bug closes that route.

Revision history for this message
In , Kir Kolyshkin (kolyshkin) wrote :

Guys,

Fix committed into GIT, lightly tested here, works fine for me.
Can you please test it as well?

http://git-ovzcore.sw.ru/?p=vzctl;a=commit;h=e7c40ee697606e43d6242fd3c124e370588ae26f

Will be available in vzctl-3.0.27 (and most probably in vzctl-3.0.26.2, too).

Revision history for this message
In , Openvz-bugs (openvz-bugs) wrote :

I've just tested the patch and checked if it works:

hoefnix2:~# vzctl enter 60
entered into CT 60
ve60:/# pacman -Q bash
bash 4.2.008-1

I hope this speaks for itself :-). Thanks for the quick patch!

Revision history for this message
In , Kir Kolyshkin (kolyshkin) wrote :

Is that ArchLinux that comes with bash-4.2? Are you aware of any other distros already using it? I mean, I am trying to assess does it makes sense to release vzctl-3.0.36.2 immediately, or can it wait (will I have some more fixes)?

Revision history for this message
In , Yettyn (yettyn) wrote :

(In reply to comment #4)
> Is that ArchLinux that comes with bash-4.2? Are you aware of any other distros
> already using it? I mean, I am trying to assess does it makes sense to release
> vzctl-3.0.36.2 immediately, or can it wait (will I have some more fixes)?

Gentoo also provides it and yes I (and other Gentoo users) would very much need vzctl-3.0.36.2, thank you.

Revision history for this message
In , Openvz-bugs (openvz-bugs) wrote :

I'm indeed using Arch Linux for my servers because it is easier to upgrade with small changes than once per two year with very big changes :-).

If I had to make the decission, I probbably would wait. People who use bleeding edge like Arch Linux -- and there I'm probably one of few who uses this distribution -- or Gentoo will find the solution in this bugfix. So I don't see a big hurry. I raised the importance because there was no solution and could raise on DoS against the owner of the physical machine. It has nothing to do with the importance of a new version of vzctl :-).

Revision history for this message
In , Kir Kolyshkin (kolyshkin) wrote :
Revision history for this message
Marc Gariépy (mgariepy) wrote :

the bug is in vzctl itself not in bash.

affects: gnubash → openvz-tools
affects: bash (Ubuntu) → vzctl (Ubuntu)
Changed in openvz-tools:
importance: Unknown → High
status: Unknown → Fix Released
Revision history for this message
Marc Gariépy (mgariepy) wrote :

here is the needed patch.

Revision history for this message
Stéphane Graber (stgraber) wrote :

Marking as fix released as the fix is in Oneiric.
Uploaded Marc's debdiff to hardy-proposed, it'll be processed by the SRU team in the next few days and you'll then be asked to test it.

Just for the record, I had to do the following changes on the provided debdiff:
 - Remove ppa part of version string
 - Target to hardy-proposed
 - Changed bug format to (LP: #xxxxxx)

Changed in vzctl (Ubuntu):
status: New → Fix Released
Changed in vzctl (Ubuntu Hardy):
status: New → Fix Committed
Revision history for this message
Chris Halse Rogers (raof) wrote :

This looks like the bug applies to all releases prior to Oneiric. Do you have any plans to upload this for lucid, maverick, or natty?

tags: added: verification-needed
Revision history for this message
Chris Halse Rogers (raof) wrote : Please test proposed package

Hello NIXin, or anyone else affected,

Accepted vzctl into hardy-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Revision history for this message
Stéphane Graber (stgraber) wrote :

Hi Chris,

The initial target was hardy as it's the last Ubuntu release to ship with an OpenVZ kernel. There's no supported upgrade path for OpenVZ from hardy so the lack of SRU for the other releases won't cause regression on upgrade.

I know that the folks at Revolution Linux have an experimental 10.04 kernel in a PPA, so they (Marc?) might ask for an SRU to 10.04 as well.

Revision history for this message
Michael Jeanson (mjeanson) wrote :

The experimental kernel we use in Lucid requires vzctl 3.0.28.1, so there is no need to SRU the current packaged version which is unusable anyway.

Revision history for this message
Michael Jeanson (mjeanson) wrote :

Tested on a hardy host with a natty container, it works as expected.

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

Thanks for testing Michael. Marking as verification-done.

tags: added: verification-done
removed: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package vzctl - 3.0.22-5ubuntu1.2

---------------
vzctl (3.0.22-5ubuntu1.2) hardy-proposed; urgency=low

  * Fix bash 4.2 problem (LP: #732322)
 -- Marc Gariepy <email address hidden> Thu, 21 Jul 2011 17:12:19 -0400

Changed in vzctl (Ubuntu Hardy):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.