mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
mptcp: remove thmac from subflow ctx
This entry is only used in subflow_finish_connect(). Instead, use the original value from mp_opt, and pass it to subflow_thmac_valid() to do the validation with the given truncated hmac. While at it, rename the variables in subflow_thmac_valid() to avoid confusions about the received one vs the expected one. Reviewed-by: Geliang Tang <geliang@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Link: https://patch.msgid.link/20260926-net-next-mptcp-misc-feat-7-4-v1-1-67af4ab37406@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
3e6a0e83c9
commit
0cb6910130
|
|
@ -593,7 +593,6 @@ struct mptcp_subflow_context {
|
||||||
bool fully_established; /* path validated */
|
bool fully_established; /* path validated */
|
||||||
u32 lent_mem_frag;
|
u32 lent_mem_frag;
|
||||||
u32 remote_nonce;
|
u32 remote_nonce;
|
||||||
u64 thmac;
|
|
||||||
u32 local_nonce;
|
u32 local_nonce;
|
||||||
u32 remote_token;
|
u32 remote_token;
|
||||||
union {
|
union {
|
||||||
|
|
|
||||||
|
|
@ -408,20 +408,21 @@ static struct dst_entry *subflow_v6_route_req(const struct sock *sk,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* validate received truncated hmac and create hmac for third ACK */
|
/* validate received truncated hmac and create hmac for third ACK */
|
||||||
static bool subflow_thmac_valid(struct mptcp_subflow_context *subflow)
|
static bool subflow_thmac_valid(struct mptcp_subflow_context *subflow,
|
||||||
|
u64 thmac)
|
||||||
{
|
{
|
||||||
u8 hmac[SHA256_DIGEST_SIZE];
|
u8 hmac[SHA256_DIGEST_SIZE];
|
||||||
u64 thmac;
|
u64 expected_thmac;
|
||||||
|
|
||||||
subflow_generate_hmac(subflow->remote_key, subflow->local_key,
|
subflow_generate_hmac(subflow->remote_key, subflow->local_key,
|
||||||
subflow->remote_nonce, subflow->local_nonce,
|
subflow->remote_nonce, subflow->local_nonce,
|
||||||
hmac);
|
hmac);
|
||||||
|
|
||||||
thmac = get_unaligned_be64(hmac);
|
expected_thmac = get_unaligned_be64(hmac);
|
||||||
pr_debug("subflow=%p, token=%u, thmac=%llu, subflow->thmac=%llu\n",
|
pr_debug("subflow=%p, token=%u, expected_thmac=%llu, thmac=%llu\n",
|
||||||
subflow, subflow->token, thmac, subflow->thmac);
|
subflow, subflow->token, expected_thmac, thmac);
|
||||||
|
|
||||||
return thmac == subflow->thmac;
|
return expected_thmac == thmac;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mptcp_subflow_reset(struct sock *ssk)
|
void mptcp_subflow_reset(struct sock *ssk)
|
||||||
|
|
@ -575,14 +576,13 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)
|
||||||
}
|
}
|
||||||
|
|
||||||
subflow->backup = mp_opt.backup;
|
subflow->backup = mp_opt.backup;
|
||||||
subflow->thmac = mp_opt.thmac;
|
|
||||||
subflow->remote_nonce = mp_opt.nonce;
|
subflow->remote_nonce = mp_opt.nonce;
|
||||||
WRITE_ONCE(subflow->remote_id, mp_opt.join_id);
|
WRITE_ONCE(subflow->remote_id, mp_opt.join_id);
|
||||||
pr_debug("subflow=%p, thmac=%llu, remote_nonce=%u backup=%d\n",
|
pr_debug("subflow=%p, thmac=%llu, remote_nonce=%u backup=%d\n",
|
||||||
subflow, subflow->thmac, subflow->remote_nonce,
|
subflow, mp_opt.thmac, subflow->remote_nonce,
|
||||||
subflow->backup);
|
subflow->backup);
|
||||||
|
|
||||||
if (!subflow_thmac_valid(subflow)) {
|
if (!subflow_thmac_valid(subflow, mp_opt.thmac)) {
|
||||||
MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_JOINSYNACKMAC);
|
MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_JOINSYNACKMAC);
|
||||||
subflow->reset_reason = MPTCP_RST_EMPTCP;
|
subflow->reset_reason = MPTCP_RST_EMPTCP;
|
||||||
goto do_reset;
|
goto do_reset;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user