diff options
author | Nitin A Kamble <nitin.a.kamble@intel.com> | 2013-05-23 16:09:20 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-06-03 16:58:12 +0100 |
commit | 66b99274efc0b2d0dcca9297326049d23068e733 (patch) | |
tree | 4717261ba3f59730790bbff9dfa8d07dec86899a /meta | |
parent | d78df944e71950d65319fe1fe9f17b0510bb7be0 (diff) | |
download | poky-66b99274efc0b2d0dcca9297326049d23068e733.tar.gz |
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 master rev: 8f5bc47729edb8cb051d81e9ff1680cb8d2eca25)
(From OE-Core rev: 4f6d55123fe054e8d081722b91aa12d676b42cb3)
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>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/recipes-core/dropbear/dropbear-2012.55/0007-dropbear-fix-for-x32-abi.patch | 140 | ||||
-rw-r--r-- | meta/recipes-core/dropbear/dropbear.inc | 1 |
2 files changed, 141 insertions, 0 deletions
diff --git a/meta/recipes-core/dropbear/dropbear-2012.55/0007-dropbear-fix-for-x32-abi.patch b/meta/recipes-core/dropbear/dropbear-2012.55/0007-dropbear-fix-for-x32-abi.patch new file mode 100644 index 0000000000..b4501211c3 --- /dev/null +++ b/meta/recipes-core/dropbear/dropbear-2012.55/0007-dropbear-fix-for-x32-abi.patch | |||
@@ -0,0 +1,140 @@ | |||
1 | Upstream-Status: Pending | ||
2 | |||
3 | The dropbearkey utility built in x32 abi format, when generating ssh | ||
4 | keys, was getting lost in the infinite loop. | ||
5 | |||
6 | This patch fixes the issue by fixing types of variables and | ||
7 | parameters of functions used in the code, which were getting | ||
8 | undesired size, when compiled with the x32 abi toolchain. | ||
9 | |||
10 | 2013/05/23 | ||
11 | Received this fix from H J Lu. | ||
12 | |||
13 | Signed-Off-By: Nitin A Kamble <nitin.a.kamble@intel.com> | ||
14 | |||
15 | # HG changeset patch | ||
16 | # User H.J. Lu <hjl.tools@gmail.com> | ||
17 | # Date 1369344079 25200 | ||
18 | # Node ID a10a1c46b857cc8a3923c3bb6d1504aa25b6052f | ||
19 | # Parent e76614145aea67f66e4a4257685c771efba21aa1 | ||
20 | Typdef mp_digit to unsigned long long for MP_64BIT | ||
21 | |||
22 | When GCC is used with MP_64BIT, we should typedef mp_digit to unsigned | ||
23 | long long instead of unsigned long since for x32, unsigned long is | ||
24 | 32-bit and unsigned long long is 64-bit and it is safe to use unsigned | ||
25 | long long for 64-bit integer with GCC. | ||
26 | |||
27 | diff -r e76614145aea -r a10a1c46b857 libtommath/tommath.h | ||
28 | --- a/libtommath/tommath.h Thu Apr 18 22:57:47 2013 +0800 | ||
29 | +++ b/libtommath/tommath.h Thu May 23 14:21:19 2013 -0700 | ||
30 | @@ -73,7 +73,7 @@ | ||
31 | typedef signed long long long64; | ||
32 | #endif | ||
33 | |||
34 | - typedef unsigned long mp_digit; | ||
35 | + typedef unsigned long long mp_digit; | ||
36 | typedef unsigned long mp_word __attribute__ ((mode(TI))); | ||
37 | |||
38 | #define DIGIT_BIT 60 | ||
39 | # HG changeset patch | ||
40 | # User H.J. Lu <hjl.tools@gmail.com> | ||
41 | # Date 1369344241 25200 | ||
42 | # Node ID c7555a4cb7ded3a88409ba85f4027baa7af5f536 | ||
43 | # Parent a10a1c46b857cc8a3923c3bb6d1504aa25b6052f | ||
44 | Cast to mp_digit when updating *rho | ||
45 | |||
46 | There is | ||
47 | |||
48 | int | ||
49 | mp_montgomery_setup (mp_int * n, mp_digit * rho) | ||
50 | |||
51 | We should cast to mp_digit instead of unsigned long when updating | ||
52 | *rho since mp_digit may be unsigned long long and unsigned long long | ||
53 | may be different from unsigned long, like in x32. | ||
54 | |||
55 | diff -r a10a1c46b857 -r c7555a4cb7de libtommath/bn_mp_montgomery_setup.c | ||
56 | --- a/libtommath/bn_mp_montgomery_setup.c Thu May 23 14:21:19 2013 -0700 | ||
57 | +++ b/libtommath/bn_mp_montgomery_setup.c Thu May 23 14:24:01 2013 -0700 | ||
58 | @@ -48,7 +48,7 @@ | ||
59 | #endif | ||
60 | |||
61 | /* rho = -1/m mod b */ | ||
62 | - *rho = (unsigned long)(((mp_word)1 << ((mp_word) DIGIT_BIT)) - x) & MP_MASK; | ||
63 | + *rho = (mp_digit)(((mp_word)1 << ((mp_word) DIGIT_BIT)) - x) & MP_MASK; | ||
64 | |||
65 | return MP_OKAY; | ||
66 | } | ||
67 | # HG changeset patch | ||
68 | # User H.J. Lu <hjl.tools@gmail.com> | ||
69 | # Date 1369344541 25200 | ||
70 | # Node ID 7c656e7071a6412688b2f30a529a9afac6c7bf5a | ||
71 | # Parent c7555a4cb7ded3a88409ba85f4027baa7af5f536 | ||
72 | Define LTC_FAST_TYPE to unsigned long long for __x86_64__ | ||
73 | |||
74 | We should define LTC_FAST_TYPE to unsigned long long instead of unsigned | ||
75 | long if __x86_64__ to support x32 where unsigned long long is 64-bit | ||
76 | and unsigned long is 32-bit. | ||
77 | |||
78 | diff -r c7555a4cb7de -r 7c656e7071a6 libtomcrypt/src/headers/tomcrypt_cfg.h | ||
79 | --- a/libtomcrypt/src/headers/tomcrypt_cfg.h Thu May 23 14:24:01 2013 -0700 | ||
80 | +++ b/libtomcrypt/src/headers/tomcrypt_cfg.h Thu May 23 14:29:01 2013 -0700 | ||
81 | @@ -74,7 +74,7 @@ | ||
82 | #define ENDIAN_LITTLE | ||
83 | #define ENDIAN_64BITWORD | ||
84 | #define LTC_FAST | ||
85 | - #define LTC_FAST_TYPE unsigned long | ||
86 | + #define LTC_FAST_TYPE unsigned long long | ||
87 | #endif | ||
88 | |||
89 | /* detect PPC32 */ | ||
90 | # HG changeset patch | ||
91 | # User H.J. Lu <hjl.tools@gmail.com> | ||
92 | # Date 1369344730 25200 | ||
93 | # Node ID a7d4690158fae4ede2c4e5b56233e83730bf38ee | ||
94 | # Parent 7c656e7071a6412688b2f30a529a9afac6c7bf5a | ||
95 | Use unsigned long long aas unsigned 64-bit integer for x86-64 GCC | ||
96 | |||
97 | We should use unsigned long long instead of unsigned long as unsigned | ||
98 | 64-bit integer for x86-64 GCC to support x32 where unsigned long is | ||
99 | 32-bit. | ||
100 | |||
101 | diff -r 7c656e7071a6 -r a7d4690158fa libtomcrypt/src/headers/tomcrypt_macros.h | ||
102 | --- a/libtomcrypt/src/headers/tomcrypt_macros.h Thu May 23 14:29:01 2013 -0700 | ||
103 | +++ b/libtomcrypt/src/headers/tomcrypt_macros.h Thu May 23 14:32:10 2013 -0700 | ||
104 | @@ -343,7 +343,7 @@ | ||
105 | /* 64-bit Rotates */ | ||
106 | #if !defined(__STRICT_ANSI__) && defined(__GNUC__) && defined(__x86_64__) && !defined(LTC_NO_ASM) | ||
107 | |||
108 | -static inline unsigned long ROL64(unsigned long word, int i) | ||
109 | +static inline unsigned long long ROL64(unsigned long long word, int i) | ||
110 | { | ||
111 | asm("rolq %%cl,%0" | ||
112 | :"=r" (word) | ||
113 | @@ -351,7 +351,7 @@ | ||
114 | return word; | ||
115 | } | ||
116 | |||
117 | -static inline unsigned long ROR64(unsigned long word, int i) | ||
118 | +static inline unsigned long long ROR64(unsigned long long word, int i) | ||
119 | { | ||
120 | asm("rorq %%cl,%0" | ||
121 | :"=r" (word) | ||
122 | @@ -361,7 +361,7 @@ | ||
123 | |||
124 | #ifndef LTC_NO_ROLC | ||
125 | |||
126 | -static inline unsigned long ROL64c(unsigned long word, const int i) | ||
127 | +static inline unsigned long long ROL64c(unsigned long long word, const int i) | ||
128 | { | ||
129 | asm("rolq %2,%0" | ||
130 | :"=r" (word) | ||
131 | @@ -369,7 +369,7 @@ | ||
132 | return word; | ||
133 | } | ||
134 | |||
135 | -static inline unsigned long ROR64c(unsigned long word, const int i) | ||
136 | +static inline unsigned long long ROR64c(unsigned long long word, const int i) | ||
137 | { | ||
138 | asm("rorq %2,%0" | ||
139 | :"=r" (word) | ||
140 | |||
diff --git a/meta/recipes-core/dropbear/dropbear.inc b/meta/recipes-core/dropbear/dropbear.inc index 8d94e5bb22..e0d15e674a 100644 --- a/meta/recipes-core/dropbear/dropbear.inc +++ b/meta/recipes-core/dropbear/dropbear.inc | |||
@@ -20,6 +20,7 @@ SRC_URI = "http://matt.ucc.asn.au/dropbear/releases/dropbear-${PV}.tar.gz \ | |||
20 | file://configure.patch \ | 20 | file://configure.patch \ |
21 | file://fix-2kb-keys.patch \ | 21 | file://fix-2kb-keys.patch \ |
22 | file://nopw-option.patch \ | 22 | file://nopw-option.patch \ |
23 | file://0007-dropbear-fix-for-x32-abi.patch \ | ||
23 | file://init \ | 24 | file://init \ |
24 | ${@base_contains('DISTRO_FEATURES', 'pam', '${PAM_SRC_URI}', '', d)} " | 25 | ${@base_contains('DISTRO_FEATURES', 'pam', '${PAM_SRC_URI}', '', d)} " |
25 | 26 | ||