History

net: fastopen: robustness and endianness fixes for SipHash

Some changes to the TCP fastopen code to make it more robust against future changes in the choice of key/cookie size, etc. - Instead of keeping the SipHash key in an untyped u8[] buffer and casting it to the right type upon use, use the correct type directly. This ensures that the key will appear at the correct alignment if we ever change the way these data structures are allocated. (Currently, they are only allocated via kmalloc so they always appear at the correct alignment) - Use DIV_ROUND_UP when sizing the u64[] array to hold the cookie, so it is always of sufficient size, even if TCP_FASTOPEN_COOKIE_MAX is no longer a multiple of 8. - Drop the 'len' parameter from the tcp_fastopen_reset_cipher() function, which is no longer used. - Add endian swabbing when setting the keys and calculating the hash, to ensure that cookie values are the same for a given key and source/destination address pair regardless of the endianness of the server. Note that none of these are functional changes wrt the current state of the code, with the exception of the swabbing, which only affects big endian systems.

Ard Biesheuvel committed 7 years ago

Commit 438ac881 parent 92ad6325 files · +24 −27Browse files

Showing the changes to include/linux (1 of 5 files). Show all

Unified · Split

include/linux/tcp.h+1−1
@@ -58,7 +58,7 @@ static inline unsigned int tcp_optlen(const struct sk_buff *skb) · 57 unmodified lines
58 58
59/* TCP Fast Open Cookie as stored in memory */59/* TCP Fast Open Cookie as stored in memory */
60struct tcp_fastopen_cookie {60struct tcp_fastopen_cookie {
61 u64 val[TCP_FASTOPEN_COOKIE_MAX / sizeof(u64)];61 __le64 val[DIV_ROUND_UP(TCP_FASTOPEN_COOKIE_MAX, sizeof(u64))];
62 s8 len;62 s8 len;
63 bool exp; /* In RFC6994 experimental option format */63 bool exp; /* In RFC6994 experimental option format */
64};64};

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t