Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F148493912
D31730.id94382.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D31730.id94382.diff
View Options
Index: sys/crypto/aesni/aesni_wrap.c
===================================================================
--- sys/crypto/aesni/aesni_wrap.c
+++ sys/crypto/aesni/aesni_wrap.c
@@ -213,9 +213,10 @@
__m128i ctr5, ctr6, ctr7, ctr8;
__m128i BSWAP_EPI64;
__m128i tout[8];
+ __m128i block;
struct blocks8 *top;
const struct blocks8 *blks;
- size_t i, cnt;
+ size_t i, cnt, resid;
BSWAP_EPI64 = _mm_set_epi8(8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7);
@@ -273,12 +274,19 @@
to += AES_BLOCK_LEN;
}
- /* handle remaining partial round */
- if (len % AES_BLOCK_LEN != 0) {
+ /*
+ * Handle remaining partial round. Copy the remaining payload onto the
+ * stack to ensure that the full block can be loaded safely.
+ */
+ resid = len % AES_BLOCK_LEN;
+ if (resid != 0) {
tmp1 = _mm_shuffle_epi8(ctr1, BSWAP_EPI64);
tot = aesni_enc(rounds - 1, key_schedule, tmp1);
- tot = tot ^ _mm_loadu_si128((const __m128i *)from);
- memcpy(to, &tot, len % AES_BLOCK_LEN);
+ block = _mm_setzero_si128();
+ memcpy(&block, from, resid);
+ tot = tot ^ _mm_loadu_si128(&block);
+ memcpy(to, &tot, resid);
+ explicit_bzero(&block, sizeof(block));
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 19, 6:08 AM (8 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29950943
Default Alt Text
D31730.id94382.diff (1 KB)
Attached To
Mode
D31730: aesni: Avoid a potential out-of-bounds load in aes_encrypt_icm()
Attached
Detach File
Event Timeline
Log In to Comment