Skip to content

Commit 5f7125d

Browse files
Paolo Abenimehmetb0
authored andcommitted
mptcp: handle consistently DSS corruption
BugLink: https://bugs.launchpad.net/bugs/2088231 commit e32d262 upstream. Bugged peer implementation can send corrupted DSS options, consistently hitting a few warning in the data path. Use DEBUG_NET assertions, to avoid the splat on some builds and handle consistently the error, dumping related MIBs and performing fallback and/or reset according to the subflow type. Fixes: 6771bfd ("mptcp: update mptcp ack sequence from work queue") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com> Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Link: https://patch.msgid.link/20241008-net-mptcp-fallback-fixes-v1-1-c6fb8e93e551@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org> [ Conflicts in mib.[ch], because commit 104125b ("mptcp: add mib for infinite map sending") is linked to a new feature, not available in this version. Resolving the conflicts is easy, simply adding the new lines declaring the new "DSS corruptions" MIB entries. Also removed in protocol.c and subflow.c all DEBUG_NET_WARN_ON_ONCE because they are not defined in this version: enough with the MIB counters that have been added in this commit. ] Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Portia Stephens <portia.stephens@canonical.com> Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
1 parent 4453f6b commit 5f7125d

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

net/mptcp/mib.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ static const struct snmp_mib mptcp_snmp_list[] = {
2626
SNMP_MIB_ITEM("MPJoinAckRx", MPTCP_MIB_JOINACKRX),
2727
SNMP_MIB_ITEM("MPJoinAckHMacFailure", MPTCP_MIB_JOINACKMAC),
2828
SNMP_MIB_ITEM("DSSNotMatching", MPTCP_MIB_DSSNOMATCH),
29+
SNMP_MIB_ITEM("DSSCorruptionFallback", MPTCP_MIB_DSSCORRUPTIONFALLBACK),
30+
SNMP_MIB_ITEM("DSSCorruptionReset", MPTCP_MIB_DSSCORRUPTIONRESET),
2931
SNMP_MIB_ITEM("InfiniteMapRx", MPTCP_MIB_INFINITEMAPRX),
3032
SNMP_MIB_ITEM("DSSNoMatchTCP", MPTCP_MIB_DSSTCPMISMATCH),
3133
SNMP_MIB_ITEM("DataCsumErr", MPTCP_MIB_DATACSUMERR),

net/mptcp/mib.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ enum linux_mptcp_mib_field {
1919
MPTCP_MIB_JOINACKRX, /* Received an ACK + MP_JOIN */
2020
MPTCP_MIB_JOINACKMAC, /* HMAC was wrong on ACK + MP_JOIN */
2121
MPTCP_MIB_DSSNOMATCH, /* Received a new mapping that did not match the previous one */
22+
MPTCP_MIB_DSSCORRUPTIONFALLBACK,/* DSS corruption detected, fallback */
23+
MPTCP_MIB_DSSCORRUPTIONRESET, /* DSS corruption detected, MPJ subflow reset */
2224
MPTCP_MIB_INFINITEMAPRX, /* Received an infinite mapping */
2325
MPTCP_MIB_DSSTCPMISMATCH, /* DSS-mapping did not map with TCP's sequence numbers */
2426
MPTCP_MIB_DATACSUMERR, /* The data checksum fail */

net/mptcp/protocol.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,18 @@ static bool mptcp_check_data_fin(struct sock *sk)
554554
return ret;
555555
}
556556

557+
static void mptcp_dss_corruption(struct mptcp_sock *msk, struct sock *ssk)
558+
{
559+
if (READ_ONCE(msk->allow_infinite_fallback)) {
560+
MPTCP_INC_STATS(sock_net(ssk),
561+
MPTCP_MIB_DSSCORRUPTIONFALLBACK);
562+
mptcp_do_fallback(ssk);
563+
} else {
564+
MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_DSSCORRUPTIONRESET);
565+
mptcp_subflow_reset(ssk);
566+
}
567+
}
568+
557569
static bool __mptcp_move_skbs_from_subflow(struct mptcp_sock *msk,
558570
struct sock *ssk,
559571
unsigned int *bytes)
@@ -626,10 +638,12 @@ static bool __mptcp_move_skbs_from_subflow(struct mptcp_sock *msk,
626638
moved += len;
627639
seq += len;
628640

629-
if (WARN_ON_ONCE(map_remaining < len))
630-
break;
641+
if (unlikely(map_remaining < len))
642+
mptcp_dss_corruption(msk, ssk);
631643
} else {
632-
WARN_ON_ONCE(!fin);
644+
if (unlikely(!fin))
645+
mptcp_dss_corruption(msk, ssk);
646+
633647
sk_eat_skb(ssk, skb);
634648
done = true;
635649
}

net/mptcp/subflow.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ static bool skb_is_fully_mapped(struct sock *ssk, struct sk_buff *skb)
847847
unsigned int skb_consumed;
848848

849849
skb_consumed = tcp_sk(ssk)->copied_seq - TCP_SKB_CB(skb)->seq;
850-
if (WARN_ON_ONCE(skb_consumed >= skb->len))
850+
if (unlikely(skb_consumed >= skb->len))
851851
return true;
852852

853853
return skb->len - skb_consumed <= subflow->map_data_len -

0 commit comments

Comments
 (0)