Skip to content

Commit

Permalink
mptcp: do not warn on bad input from the network
Browse files Browse the repository at this point in the history
warn_bad_map() produces a kernel WARN on bad input coming
from the network. Use pr_debug() to avoid spamming the system
log.

Additionally, when the right bound check fails, warn_bad_map() reports
the wrong ssn value, let's fix it.

Fixes: 648ef4b ("mptcp: Implement MPTCP receive path")
Closes: #107
Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Paolo Abeni authored and matttbe committed Jun 11, 2021
1 parent 91644f7 commit b511a92
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions net/mptcp/subflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -784,10 +784,10 @@ static u64 expand_seq(u64 old_seq, u16 old_data_len, u64 seq)
return seq | ((old_seq + old_data_len + 1) & GENMASK_ULL(63, 32));
}

static void warn_bad_map(struct mptcp_subflow_context *subflow, u32 ssn)
static void dbg_bad_map(struct mptcp_subflow_context *subflow, u32 ssn)
{
WARN_ONCE(1, "Bad mapping: ssn=%d map_seq=%d map_data_len=%d",
ssn, subflow->map_subflow_seq, subflow->map_data_len);
pr_debug("Bad mapping: ssn=%d map_seq=%d map_data_len=%d",
ssn, subflow->map_subflow_seq, subflow->map_data_len);
}

static bool skb_is_fully_mapped(struct sock *ssk, struct sk_buff *skb)
Expand All @@ -812,13 +812,13 @@ static bool validate_mapping(struct sock *ssk, struct sk_buff *skb)
/* Mapping covers data later in the subflow stream,
* currently unsupported.
*/
warn_bad_map(subflow, ssn);
dbg_bad_map(subflow, ssn);
return false;
}
if (unlikely(!before(ssn, subflow->map_subflow_seq +
subflow->map_data_len))) {
/* Mapping does covers past subflow data, invalid */
warn_bad_map(subflow, ssn + skb->len);
dbg_bad_map(subflow, ssn);
return false;
}
return true;
Expand Down

0 comments on commit b511a92

Please sign in to comment.