Bug 4496 - [x32] dropbear key generation hangs on x32
Summary: [x32] dropbear key generation hangs on x32
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: connectivity (show other bugs)
Version: 1.4.1
Hardware: Other x86_64
: Medium+ major
Target Milestone: 1.4.1
Assignee: Nitin Kamble
QA Contact:
URL:
Whiteboard: (autobuilder)
Depends on:
Blocks:
 
Reported: 2013-05-15 06:33 UTC by Saul Wold
Modified: 2013-05-30 22:31 UTC (History)
6 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: ---


Attachments
A patch to fix x32 (4.24 KB, patch)
2013-05-23 21:48 UTC, H.J. Lu
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Saul Wold 2013-05-15 06:33:10 UTC
dropbear fails to correctly generate a key during startup, it hangs the system.  Initial debug shows that a value passed into the mp_div_3() function is invalid. It should be a reasonable value, but instead is a full 64bit integer. This may be due to the way this number is initially stored.

I did not that the mp_int "used" value is different between x86-64 and x32, the
xa86-64 value was 9 while the x32 value was 19.
Comment 1 Nitin Kamble 2013-05-23 19:46:39 UTC
I tried creating x32 qemux86-64 image. And it built booted fine. Then I tried to run this command: 
  dropbearkey -tdss -f private

and it takes forever to finish it.
Comment 2 H.J. Lu 2013-05-23 21:48:51 UTC
Created attachment 1222 [details]
A patch to fix x32

dropbear should use unsigned long long for unsigned 64-bit
integer.
Comment 3 Nitin Kamble 2013-05-23 22:20:26 UTC
I check the HJ's fix with yocto project. And it does fix the issue I was seeing before. Thanks HJ for the quick fix.

I will cook a commit for posting to YP mailing list.

Nitin
Comment 4 Nitin Kamble 2013-05-30 22:31:07 UTC
Fixed by this commit:

commit 676fd3f394a0c0576b63c77ed2184bf5f42c29b6
Author: Nitin A Kamble <nitin.a.kamble@intel.com>
Date:   Thu May 23 16:09:20 2013 +0000

    dropbear: a fix for hang in dropbearkey, built for x32
    
    This commit fixes runtime hang of 'dropbearkey' utility, built for a x32
    target abi system. The hang was observed while generating ssh keys, with
    this command:
      dropbearkey -t dss -f private
    
    The issue is fixed by changing the code, where 'long' in x86_64 mode is
    assumed as 64bit quantity. With the x32 abi, the processor is in x86_64
    mode, but the 'long' is a 32bit quantity. Hence the fix uses 'long long'
    instead of 'long' to define/access 64bit data variables.
    
    Fixes bug:
    [YOCTO #4496]
    
    (From OE-Core rev: 8f5bc47729edb8cb051d81e9ff1680cb8d2eca25)
    
    Signed-off-by: Nitin A Kamble <nitin.a.kamble@intel.com>
    Signed-off-by: Saul Wold <sgw@linux.intel.com>
    Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>