Skip to content

Commit 06c03ca

Browse files
buytenhRussell King
authored andcommitted
[ARM] 3117/1: nwfpe kernel memory info leak
Patch from Lennert Buytenhek The routine that nwfpe uses for converting floats/doubles to extended precision fails to zero two bytes of kernel stack. This is not immediately obvious, as the floatx80 structure has 16 bits of implicit padding (by design.) These two bytes are copied to userspace when an stfe is emulated, causing a possible info leak. Make the padding explicit and zero it out in the relevant places. Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent 862184f commit 06c03ca

4 files changed

Lines changed: 16 additions & 8 deletions

File tree

‎arch/arm/nwfpe/fpopcode.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929

3030
#ifdef CONFIG_FPE_NWFPE_XP
3131
const floatx80 floatx80Constant[] = {
32-
{0x0000, 0x0000000000000000ULL}, /* extended 0.0 */
33-
{0x3fff, 0x8000000000000000ULL}, /* extended 1.0 */
34-
{0x4000, 0x8000000000000000ULL}, /* extended 2.0 */
35-
{0x4000, 0xc000000000000000ULL}, /* extended 3.0 */
36-
{0x4001, 0x8000000000000000ULL}, /* extended 4.0 */
37-
{0x4001, 0xa000000000000000ULL}, /* extended 5.0 */
38-
{0x3ffe, 0x8000000000000000ULL}, /* extended 0.5 */
39-
{0x4002, 0xa000000000000000ULL} /* extended 10.0 */
32+
{ .high = 0x0000, .low = 0x0000000000000000ULL},/* extended 0.0 */
33+
{ .high = 0x3fff, .low = 0x8000000000000000ULL},/* extended 1.0 */
34+
{ .high = 0x4000, .low = 0x8000000000000000ULL},/* extended 2.0 */
35+
{ .high = 0x4000, .low = 0xc000000000000000ULL},/* extended 3.0 */
36+
{ .high = 0x4001, .low = 0x8000000000000000ULL},/* extended 4.0 */
37+
{ .high = 0x4001, .low = 0xa000000000000000ULL},/* extended 5.0 */
38+
{ .high = 0x3ffe, .low = 0x8000000000000000ULL},/* extended 0.5 */
39+
{ .high = 0x4002, .low = 0xa000000000000000ULL},/* extended 10.0 */
4040
};
4141
#endif
4242

‎arch/arm/nwfpe/softfloat-specialize‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ static floatx80 commonNaNToFloatx80( commonNaNT a )
332332

333333
z.low = LIT64( 0xC000000000000000 ) | ( a.high>>1 );
334334
z.high = ( ( (bits16) a.sign )<<15 ) | 0x7FFF;
335+
z.__padding = 0;
335336
return z;
336337

337338
}

‎arch/arm/nwfpe/softfloat.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ INLINE floatx80 packFloatx80( flag zSign, int32 zExp, bits64 zSig )
531531

532532
z.low = zSig;
533533
z.high = ( ( (bits16) zSign )<<15 ) + zExp;
534+
z.__padding = 0;
534535
return z;
535536

536537
}
@@ -2831,6 +2832,7 @@ static floatx80 subFloatx80Sigs( struct roundingData *roundData, floatx80 a, flo
28312832
roundData->exception |= float_flag_invalid;
28322833
z.low = floatx80_default_nan_low;
28332834
z.high = floatx80_default_nan_high;
2835+
z.__padding = 0;
28342836
return z;
28352837
}
28362838
if ( aExp == 0 ) {
@@ -2950,6 +2952,7 @@ floatx80 floatx80_mul( struct roundingData *roundData, floatx80 a, floatx80 b )
29502952
roundData->exception |= float_flag_invalid;
29512953
z.low = floatx80_default_nan_low;
29522954
z.high = floatx80_default_nan_high;
2955+
z.__padding = 0;
29532956
return z;
29542957
}
29552958
return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
@@ -3015,6 +3018,7 @@ floatx80 floatx80_div( struct roundingData *roundData, floatx80 a, floatx80 b )
30153018
roundData->exception |= float_flag_invalid;
30163019
z.low = floatx80_default_nan_low;
30173020
z.high = floatx80_default_nan_high;
3021+
z.__padding = 0;
30183022
return z;
30193023
}
30203024
roundData->exception |= float_flag_divbyzero;
@@ -3093,6 +3097,7 @@ floatx80 floatx80_rem( struct roundingData *roundData, floatx80 a, floatx80 b )
30933097
roundData->exception |= float_flag_invalid;
30943098
z.low = floatx80_default_nan_low;
30953099
z.high = floatx80_default_nan_high;
3100+
z.__padding = 0;
30963101
return z;
30973102
}
30983103
normalizeFloatx80Subnormal( bSig, &bExp, &bSig );
@@ -3184,6 +3189,7 @@ floatx80 floatx80_sqrt( struct roundingData *roundData, floatx80 a )
31843189
roundData->exception |= float_flag_invalid;
31853190
z.low = floatx80_default_nan_low;
31863191
z.high = floatx80_default_nan_high;
3192+
z.__padding = 0;
31873193
return z;
31883194
}
31893195
if ( aExp == 0 ) {

‎arch/arm/nwfpe/softfloat.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ typedef unsigned long int float32;
5555
typedef unsigned long long float64;
5656
typedef struct {
5757
unsigned short high;
58+
unsigned short __padding;
5859
unsigned long long low;
5960
} floatx80;
6061

0 commit comments

Comments
 (0)