From patchwork Fri Oct 2 10:39:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Abeni X-Patchwork-Id: 267718 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D577EC4363D for ; Fri, 2 Oct 2020 10:40:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 453ED206CD for ; Fri, 2 Oct 2020 10:40:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Yi3QjD1b" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387621AbgJBKkI (ORCPT ); Fri, 2 Oct 2020 06:40:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:52784 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbgJBKkG (ORCPT ); Fri, 2 Oct 2020 06:40:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601635205; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=feUdseSmCaw/fcpaZPYQzD3oFiZbEy6o4GMETibwx2Y=; b=Yi3QjD1bcxNSkjt8pEAvm6YsRyUVAy9jSbc3/gFLmqbVgF20Fh+H/ml0SFeSzIIug6OW94 tikAK6yUOpfPQXpnRez7Mc0d+u1C36JjS8ULQ9oXLtBn3Z21veL8MAzFlYpbbq0rX59Lcu Zkoa7ahwAfZDZiM9MmHb7G37SQVThSU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-44-X3MJidXTOXK6-XIVYbyIpA-1; Fri, 02 Oct 2020 06:40:01 -0400 X-MC-Unique: X3MJidXTOXK6-XIVYbyIpA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7104F1019625; Fri, 2 Oct 2020 10:40:00 +0000 (UTC) Received: from gerbillo.redhat.com (ovpn-113-189.ams2.redhat.com [10.36.113.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 915577EB7C; Fri, 2 Oct 2020 10:39:58 +0000 (UTC) From: Paolo Abeni To: netdev@vger.kernel.org Cc: Florian Westphal , mptcp@lists.01.org, "David S. Miller" Subject: [PATCH net] tcp: fix syn cookied MPTCP request socket leak Date: Fri, 2 Oct 2020 12:39:44 +0200 Message-Id: <867cc806e4dfeb200e84b37addff2e2847f44c0e.1601635086.git.pabeni@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org If a syn-cookies request socket don't pass MPTCP-level validation done in syn_recv_sock(), we need to release it immediately, or it will be leaked. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/89 Fixes: 9466a1ccebbe ("mptcp: enable JOIN requests even if cookies are in use") Reported-and-tested-by: Geliang Tang Reviewed-by: Matthieu Baerts Signed-off-by: Paolo Abeni --- net/ipv4/syncookies.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c index f0794f0232ba..e03756631541 100644 --- a/net/ipv4/syncookies.c +++ b/net/ipv4/syncookies.c @@ -214,7 +214,7 @@ struct sock *tcp_get_cookie_sock(struct sock *sk, struct sk_buff *skb, sock_rps_save_rxhash(child, skb); if (rsk_drop_req(req)) { - refcount_set(&req->rsk_refcnt, 2); + reqsk_put(req); return child; }