Bug 2382

Summary: dropbear does not work with poky-tiny
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Reinette Chatre <reinette.chatre>
Component: coreAssignee: Darren Hart <dvhart>
Status: VERIFIED FIXED QA Contact:
Severity: critical    
Priority: Medium CC: corneliux.stoicescu, dvhart, jessica.zhang, meta.mr.watcher, meta.watcher, nitin.a.kamble, shane.wang, song.liu
Version: 1.2   
Target Milestone: 1.3 M3   
Hardware: x86   
OS: Multiple   
Whiteboard: (P2)(done)
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: ---
Bug Depends on: 2443    
Bug Blocks:    

Description Reinette Chatre 2012-05-01 18:41:34 UTC
I am running poky.git from denzil branch with HEAD d20a24310eb43fed9a3f3e75752c9ad45a18cbe4

When I build a poky-tiny image that includes dropbear (ssh) and run the dropbear server from the image on a host then the server segfaults when a client attempts to connect. There is no trace printed, only "Aiee, segfault! You should probably report this as a bug to the developer" is printed on the server console.

dropbear works as expected with successful login when it is built with a full libc like:
DISTRO_FEATURES_LIBC = "${DISTRO_FEATURES_LIBC_DEFAULT}"
Comment 1 Darren Hart 2012-05-01 18:49:37 UTC
Adding Shane as he is listed as the maintainer of dropbear in distro_tracking_fields.

Adding Nitin to assist with libc features.
Comment 2 Shane Wang 2012-05-09 05:11:45 UTC
Lianhao is kindly helping to investigate the segmentation fault.
Comment 3 Lianhao Lu 2012-05-10 10:42:32 UTC
Can not reproduce this bug with eglibc-2.15.

Using the latest poky master (commit 6841abd) with Nitin's patch to fix bug #2443, 
I can't reproduce this bug.

try the followings commands in the target using the core-image-minimal including the dropbear:

#dropbearkey -t rsa -f ./rsa
#dropbear -r ./rsa
#ssh root@127.0.0.1 touch /abc
#ls /abc

All commands succeed.
Comment 4 Lianhao Lu 2012-05-10 11:04:48 UTC
Cannot reproduce this on denzil branch either(eglibc 2.13).

Reinette, 

Could you please give me some information of how to reproduce the segfault?
Comment 5 Darren Hart 2012-05-10 14:04:11 UTC
Lianhao, are you building with DISTRO="poky-tiny" and building from a clean build directory (or at least one that has only been used to build "tiny"?
Comment 6 Reinette Chatre 2012-05-10 16:11:39 UTC
(In reply to comment #3)
> Can not reproduce this bug with eglibc-2.15.
> 
> Using the latest poky master (commit 6841abd) with Nitin's patch to fix bug
> #2443, 
> I can't reproduce this bug.
> 
> try the followings commands in the target using the core-image-minimal
> including the dropbear:
> 
> #dropbearkey -t rsa -f ./rsa
> #dropbear -r ./rsa
> #ssh root@127.0.0.1 touch /abc
> #ls /abc
> 
> All commands succeed.

I have not tried the steps above. I see the segfault when I try to connect via ssh from a different host to the host running this poky-tiny image.
Comment 7 Lianhao Lu 2012-05-10 16:27:18 UTC
Yes, I built core-image-minimal with DISTRO="poky-tiny" from a clean build directory, with IMAGE_INSTALL_append="dropbear"

(In reply to comment #5)
> Lianhao, are you building with DISTRO="poky-tiny" and building from a clean
> build directory (or at least one that has only been used to build "tiny"?
Comment 8 Lianhao Lu 2012-05-10 16:36:18 UTC
(In reply to comment #6)
>I have not tried the steps
> above. I see the segfault when I try to connect via ssh from a different
> host to the host running this poky-tiny image.

By saying poky-tiny image I assume you mean "bitbake core-image-minimal", right?

If I use ssh from a different host, ssh reports something like "can not open pty error" and then exits. The dropbear server is still running without segfault. I think this error happens becuase the poky-tiny configuration doesn't support psuedo tty.

If I tried to use dropbear from different host:

./dbclient -T root@192.168.7.2 touch /abc

still can't reproduce the segfault.
Comment 9 Darren Hart 2012-05-10 16:44:21 UTC
(In reply to comment #8)

> By saying poky-tiny image I assume you mean "bitbake core-image-minimal",
> right?

Right.

> If I use ssh from a different host, ssh reports something like "can not open
> pty error" and then exits. The dropbear server is still running without
> segfault. I think this error happens becuase the poky-tiny configuration
> doesn't support psuedo tty.

Gah, I think you are right about this. I'll need to take a look at this.
Comment 10 Darren Hart 2012-06-08 16:15:08 UTC
The relevant bit from the log:

| make[1]: *** [miniperl] Error 1
| make[1]: Leaving directory `/srv/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-tiny/build/build/tmp/work/i586-poky-linux/perl-5.14.2-r6/perl-5.14.2'
| make[1]: Entering directory `/srv/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-tiny/build/build/tmp/work/i586-poky-linux/perl-5.14.2-r6/perl-5.14.2'
| /bin/ln -s perldelta.pod pod/perl5142delta.pod
| ./miniperl -Ilib autodoc.pl
| make[1]: ./miniperl: Command not found
| make[1]: *** [pod/perlintern.pod] Error 127
| make[1]: Leaving directory `/srv/home/pokybuild/yocto-autobuilder/yocto-slave/nightly-tiny/build/build/tmp/work/i586-poky-linux/perl-5.14.2-r6/perl-5.14.2'
| make: *** [perl] Error 2
| ERRO
NOTE: package perl-5.14.2-r6: task do_compile: Failed

What is miniperl?

Can someone with more experience with the perl recipes have a look at this? Nitin?
Comment 11 Darren Hart 2012-06-08 16:15:51 UTC
Sorry, Comment 10 was for a different bug.
Comment 12 Darren Hart 2012-06-09 00:18:55 UTC
Reinette, does your kernel config include CONFIG_UNIX98_PTYS=y ?
Comment 13 Reinette Chatre 2012-06-11 17:37:35 UTC
(In reply to comment #12)
> Reinette, does your kernel config include CONFIG_UNIX98_PTYS=y ?

It does.
Comment 14 Darren Hart 2012-06-11 17:57:59 UTC
(In reply to comment #13)
> (In reply to comment #12)
> > Reinette, does your kernel config include CONFIG_UNIX98_PTYS=y ?
> 
> It does.

And do you have devpts mounted?

If not, be sure to add the following to your init script (I don't know what you are using for init currently):

  mkdir /dev/pts
  mount none -t devpts /dev/pts
Comment 15 Reinette Chatre 2012-06-11 19:51:01 UTC
(In reply to comment #14)
> (In reply to comment #13)
> > (In reply to comment #12)
> > > Reinette, does your kernel config include CONFIG_UNIX98_PTYS=y ?
> > 
> > It does.
> 
> And do you have devpts mounted?
> 
> If not, be sure to add the following to your init script (I don't know what
> you are using for init currently):
> 
>   mkdir /dev/pts
>   mount none -t devpts /dev/pts

We are doing most startup from inittab. In there we do the following that seems to work ok:
b000::bootwait:/bin/mkdir -p /dev/pts
b001::bootwait:/bin/mount -t devpts devpts /dev/pts -o gid=5,mode=620
Comment 16 Darren Hart 2012-06-11 21:29:08 UTC
(In reply to comment #15)
> We are doing most startup from inittab. In there we do the following that
> seems to work ok:
> b000::bootwait:/bin/mkdir -p /dev/pts
> b001::bootwait:/bin/mount -t devpts devpts /dev/pts -o gid=5,mode=620

OK, good. The segfault occurs with this configuration correct?
Comment 17 Reinette Chatre 2012-06-11 21:59:39 UTC
(In reply to comment #16)
> (In reply to comment #15)
> > We are doing most startup from inittab. In there we do the following that
> > seems to work ok:
> > b000::bootwait:/bin/mkdir -p /dev/pts
> > b001::bootwait:/bin/mount -t devpts devpts /dev/pts -o gid=5,mode=620
> 
> OK, good. The segfault occurs with this configuration correct?

Correct. We have always mounted devpts. Before we had this entry in /etc/inittab we mounted devpts using fstab which initially was obtained from the base-files recipe.
Comment 18 Song Liu 2012-07-04 20:17:29 UTC
Change target to M3. There is a work around according to Darren.
Comment 19 Darren Hart 2012-08-01 19:22:12 UTC
With current master (fd6251ef548da7dbca354754cc0b666b2ccd0c45) I built a poky-tiny core-image-minimal image for qemux86 and booted it in qemu with a tun/tap network setup. Starting dropbear manually and attempting to ssh in failed with:

"PTY allocation request failed on channel 0"

This is the result of /dev/ptmx not existing. By creating it in init provided by tiny-init along with the code to mount /dev/pts I am now able to successfully ssh into the qemu machine from the host machine as root. This patch has been sent to the poky list for review.

This is a different set of symptoms to what Reinette reported, but with this patch in place, it "works for me" on the master branch. I am working with Reinette to see what more may need to be done as she reported this issue against 1.2.
Comment 20 Darren Hart 2012-08-01 22:41:30 UTC
With the following commit,

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=62d42fe3cfa575chttp://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=62d42fe3cfa575cb97b484ccf7b2e9a25cc50770b97b484ccf7b2e9a25cc50770

This is working in master. I've discussed with Reinette and we agreed to close this out despite the different symptoms.
Comment 21 Stoicescu Cornel 2012-10-19 15:30:00 UTC
I can not test and verify this untill 3311 is fixed.
Comment 22 Stoicescu Cornel 2012-11-01 13:28:41 UTC
Verified using testcase:

On host machine:

#sudo /home/cornel/SDD/Yocto/poky/build/tmp/sysroots/x86_64-linux/usr/bin/qemu-system-i386 -kernel tmp/deploy/images/bzImage-qemux86.bin -net nic,vlan=0 -net tap,vlan=0,ifname=tap0 -initrd tmp/deploy/images/core-image-minimal-qemux86.cpio.gz -show-cursor -vga vmware -no-reboot -m 128 --append "vga=0 root=/dev/ram0 rw mem=128M ip=192.168.122.2::192.168.122.1:255.255.255.0 oprofile.timer=1 ramdisk_size=9000K " -nographic

On qemu machine:

#/etc/init.d/dropbear start

On host machine: 

ssh root@192.168.122.2 touch /abc

On target machine:

#ls
abc    boot   etc    init   media  proc   sbin   tmp    var
bin    dev    home   lib    mnt    root   sys    usr

It took me a while to get the correct qemu settings correct but in this setup, ssh with dropbear from a remote machine works. 

Verified.