Skip to content

Commit 68d27ba

Browse files
committed
Merge branch 'mptcp-better-validation-of-mptcpopt_mp_join-option'
Eric Dumazet says: ==================== mptcp: better validation of MPTCPOPT_MP_JOIN option Based on a syzbot report (see 4th patch in the series). We need to be more explicit about which one of the following flag is set by mptcp_parse_option(): - OPTION_MPTCP_MPJ_SYN - OPTION_MPTCP_MPJ_SYNACK - OPTION_MPTCP_MPJ_ACK Then select the appropriate values instead of OPTIONS_MPTCP_MPJ Paolo suggested to do the same for OPTIONS_MPTCP_MPC (5th patch) ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents cbdd50e + 724b00c commit 68d27ba

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

net/mptcp/options.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ static void mptcp_parse_option(const struct sk_buff *skb,
123123
break;
124124

125125
case MPTCPOPT_MP_JOIN:
126-
mp_opt->suboptions |= OPTIONS_MPTCP_MPJ;
127126
if (opsize == TCPOLEN_MPTCP_MPJ_SYN) {
127+
mp_opt->suboptions |= OPTION_MPTCP_MPJ_SYN;
128128
mp_opt->backup = *ptr++ & MPTCPOPT_BACKUP;
129129
mp_opt->join_id = *ptr++;
130130
mp_opt->token = get_unaligned_be32(ptr);
@@ -135,6 +135,7 @@ static void mptcp_parse_option(const struct sk_buff *skb,
135135
mp_opt->backup, mp_opt->join_id,
136136
mp_opt->token, mp_opt->nonce);
137137
} else if (opsize == TCPOLEN_MPTCP_MPJ_SYNACK) {
138+
mp_opt->suboptions |= OPTION_MPTCP_MPJ_SYNACK;
138139
mp_opt->backup = *ptr++ & MPTCPOPT_BACKUP;
139140
mp_opt->join_id = *ptr++;
140141
mp_opt->thmac = get_unaligned_be64(ptr);
@@ -145,11 +146,10 @@ static void mptcp_parse_option(const struct sk_buff *skb,
145146
mp_opt->backup, mp_opt->join_id,
146147
mp_opt->thmac, mp_opt->nonce);
147148
} else if (opsize == TCPOLEN_MPTCP_MPJ_ACK) {
149+
mp_opt->suboptions |= OPTION_MPTCP_MPJ_ACK;
148150
ptr += 2;
149151
memcpy(mp_opt->hmac, ptr, MPTCPOPT_HMAC_LEN);
150152
pr_debug("MP_JOIN hmac");
151-
} else {
152-
mp_opt->suboptions &= ~OPTIONS_MPTCP_MPJ;
153153
}
154154
break;
155155

net/mptcp/subflow.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ static int subflow_check_req(struct request_sock *req,
157157

158158
mptcp_get_options(skb, &mp_opt);
159159

160-
opt_mp_capable = !!(mp_opt.suboptions & OPTIONS_MPTCP_MPC);
161-
opt_mp_join = !!(mp_opt.suboptions & OPTIONS_MPTCP_MPJ);
160+
opt_mp_capable = !!(mp_opt.suboptions & OPTION_MPTCP_MPC_SYN);
161+
opt_mp_join = !!(mp_opt.suboptions & OPTION_MPTCP_MPJ_SYN);
162162
if (opt_mp_capable) {
163163
SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_MPCAPABLEPASSIVE);
164164

@@ -254,8 +254,8 @@ int mptcp_subflow_init_cookie_req(struct request_sock *req,
254254
subflow_init_req(req, sk_listener);
255255
mptcp_get_options(skb, &mp_opt);
256256

257-
opt_mp_capable = !!(mp_opt.suboptions & OPTIONS_MPTCP_MPC);
258-
opt_mp_join = !!(mp_opt.suboptions & OPTIONS_MPTCP_MPJ);
257+
opt_mp_capable = !!(mp_opt.suboptions & OPTION_MPTCP_MPC_ACK);
258+
opt_mp_join = !!(mp_opt.suboptions & OPTION_MPTCP_MPJ_ACK);
259259
if (opt_mp_capable && opt_mp_join)
260260
return -EINVAL;
261261

@@ -486,7 +486,7 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)
486486

487487
mptcp_get_options(skb, &mp_opt);
488488
if (subflow->request_mptcp) {
489-
if (!(mp_opt.suboptions & OPTIONS_MPTCP_MPC)) {
489+
if (!(mp_opt.suboptions & OPTION_MPTCP_MPC_SYNACK)) {
490490
MPTCP_INC_STATS(sock_net(sk),
491491
MPTCP_MIB_MPCAPABLEACTIVEFALLBACK);
492492
mptcp_do_fallback(sk);
@@ -506,7 +506,7 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)
506506
} else if (subflow->request_join) {
507507
u8 hmac[SHA256_DIGEST_SIZE];
508508

509-
if (!(mp_opt.suboptions & OPTIONS_MPTCP_MPJ)) {
509+
if (!(mp_opt.suboptions & OPTION_MPTCP_MPJ_SYNACK)) {
510510
subflow->reset_reason = MPTCP_RST_EMPTCP;
511511
goto do_reset;
512512
}
@@ -783,12 +783,12 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,
783783
* options.
784784
*/
785785
mptcp_get_options(skb, &mp_opt);
786-
if (!(mp_opt.suboptions & OPTIONS_MPTCP_MPC))
786+
if (!(mp_opt.suboptions & OPTION_MPTCP_MPC_ACK))
787787
fallback = true;
788788

789789
} else if (subflow_req->mp_join) {
790790
mptcp_get_options(skb, &mp_opt);
791-
if (!(mp_opt.suboptions & OPTIONS_MPTCP_MPJ) ||
791+
if (!(mp_opt.suboptions & OPTION_MPTCP_MPJ_ACK) ||
792792
!subflow_hmac_valid(req, &mp_opt) ||
793793
!mptcp_can_accept_new_subflow(subflow_req->msk)) {
794794
SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_JOINACKMAC);

0 commit comments

Comments
 (0)