You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/dev-libs/openssl/files/openssl-1.0.0d-alpha-fix-un...

60 lines
1.3 KiB

fix unaligned access in alpha specific 'OPENSSL_cleanse' function
Debugged with the following simple program:
// gcc cleanse_test.c -o ct -lcrypto
#include <openssl/crypto.h>
int main(void)
{
char buffer [128];
int off;
int sz;
for (off = 0; off < sizeof (buffer); ++off)
for (sz = 0; sz < sizeof (buffer) - off; ++sz)
OPENSSL_cleanse (buffer + off, sz);
return 0;
}
$ prctl --unaligned=signal ./cleanse_test
Bus error
https://bugs.gentoo.org/show_bug.cgi?id=371561
http://cvs.openssl.org/chngview?cn=21233
Reported by Tobias Klausmann <klausman@gentoo.org>
Fixed by Andy Polyakov <appro@openssl.org>
diff --git a/crypto/alphacpuid.pl b/crypto/alphacpuid.pl
index 11f2e30..5b0e21b 100644
--- a/crypto/alphacpuid.pl
+++ b/crypto/alphacpuid.pl
@@ -99,19 +99,19 @@ OPENSSL_cleanse:
beq $0,.Laligned
.Little:
+ subq $0,8,$0
ldq_u $1,0($16)
mov $16,$2
.Lalign:
mskbl $1,$16,$1
lda $16,1($16)
subq $17,1,$17
- subq $0,1,$0
+ addq $0,1,$0
beq $17,.Lout
bne $0,.Lalign
.Lout: stq_u $1,0($2)
beq $17,.Ldone
bic $17,7,$at
- mov $17,$0
beq $at,.Little
.Laligned:
@@ -120,9 +120,7 @@ OPENSSL_cleanse:
lda $16,8($16)
bic $17,7,$at
bne $at,.Laligned
- beq $17,.Ldone
- mov $17,$0
- br .Little
+ bne $17,.Little
.Ldone: ret ($26)
.end OPENSSL_cleanse
___