Received: by 10.213.65.68 with SMTP id h4csp2117900imn; Sun, 8 Apr 2018 20:09:04 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/MTHm0HTRFB2DHYO7LNdNEOVj6kQyKPQ9m62ndUjR/FPFN6aKbdOAFEaeVwJ/cSDFvNj10 X-Received: by 10.101.77.145 with SMTP id p17mr23999952pgq.275.1523243344574; Sun, 08 Apr 2018 20:09:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243344; cv=none; d=google.com; s=arc-20160816; b=LiiRSAuKJdBpJukx5lk8SBCg7idQ/r8QLdmF/FxQ/h9TqHZ7GGPjWKp8H8ynGgaCxf QGhU4IgwfIo9bZ+UOCuKUTz68p5wI2znCpXE//ASmJaldeIMWKvN2qieW5te4VbDs4nd yRZ0OpJDdcLOJrJ6MDy/mesIasEqgnridkInqvFUkK8Ez+6sQsRbAcjvezUdt+D8nGjM wACGnIlbZn4vgZnBSBgXU2sqdTXM507jFxeMhPPZs0trdrHiUWMMNxFdRAZSvQDYCDFa 9i64sYx6GN8uWqFIEvjs2Q4YKLnFpkRGBCPbz07O0K9ofrOrwcREnnsxI+xDtD/e/MgB /GNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=uLdG9zCR1YwYJMwhKohP2P/LJaf1gapoCyrrEa4Ife8=; b=yuXqlwnbf0lo4zS7TXFljrzg4j/zN0RFcelzrhr17U7+uC64CAzeD9nZz6bT7YVojK syfG51ahCcxKmqwECbFtoqVhzv6ZmzxxCwPl1BeO+zZy6VpqgavC4EmFGvJED4bW0R/N SSHPg0pWsOwRHZ6oA2/hetq3D/EGL2KjD+PzfQqgJsELMy0WZO/e9mgfav9JrO4XNeRc gvLWQZMX63Xg3p3vlCdRUs2Vk6mwK9016UUM1vpxylhhqgyay9p68xq236tR1Y6Kbv+U W+MPDb13tYIfED4N+3DTV7Db56dNlOaMI9tQ3zYiZBIUe+zzSRIr7Cc/0/nB69mfuqHn 9DAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=GQnXxV2/; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m6-v6si14236351pls.642.2018.04.08.20.08.27; Sun, 08 Apr 2018 20:09:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=GQnXxV2/; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932177AbeDICUL (ORCPT + 99 others); Sun, 8 Apr 2018 22:20:11 -0400 Received: from mail-sn1nam02on0125.outbound.protection.outlook.com ([104.47.36.125]:10314 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753384AbeDIAaR (ORCPT ); Sun, 8 Apr 2018 20:30:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=uLdG9zCR1YwYJMwhKohP2P/LJaf1gapoCyrrEa4Ife8=; b=GQnXxV2/qBeOEjLJfoNBIt2SaCJCMKCYDZBWlUcFD+0F+e2MQh88IirE95PrGfsYl5ilvfuxCintU9melJnLrdxHaKbRHb5ue9qZvLjgM5RGG8CkN4MfCOt2InzBwtTADalDV0+ODOLblBuHdX6001j8vITij83rEbJ1Pyd8t8A= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:30:14 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:30:14 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Chenbo Feng , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 122/293] tcp: Add a tcp_filter hook before handle ack packet Thread-Topic: [PATCH AUTOSEL for 4.9 122/293] tcp: Add a tcp_filter hook before handle ack packet Thread-Index: AQHTz5kefmQ74nuGU0ScoOG+3jkIxA== Date: Mon, 9 Apr 2018 00:24:28 +0000 Message-ID: <20180409002239.163177-122-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1032;7:9mfAWvJaCjFN3QgBrpj8iJC+GQckPEEshEiBaJOmbN6kkRzLeXEXi6qkDrxdBfrEGqRTcRFNRpD1+nbb4Mvff6rMoQUWZqFCbUF5UjTcBZnYhil7tErdoKOV76gSeXVRQSHH8QHdqLK/gJyoz7uyz1x/JNuyxgj1ycoHylax4Vpl73nsHAt7yRvQyKAdHjSWVwgF9IxnW9yXb8uOpUvNqacQLRK9Bn1k7QrgbYYTO/hmfpJ60LeJcFR4ZwNs2GX+;20:zTMgFxGH+gK+u/K5yXLlwifceKS/Zvkq/Nd6/XxDvC4I7njTSujftw94Q7whtQqdpe5VD/tJ+/AxiivYBAnakPMJIfe4xZ78ORuiiU7V7qYgaG4zYzCd8qWWmFxRseFuMX0Y0GaiGM8IJ26W2GBKO2rorTOOakrLlrQcdnnmsis= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 5d1f3946-bdf9-4c7f-bdde-08d59db10fe5 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1032; x-ms-traffictypediagnostic: DM5PR2101MB1032: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(211936372134217)(153496737603132)(17755550239193); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3002001)(3231221)(944501327)(52105095)(10201501046)(93006095)(93001095)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011);SRVR:DM5PR2101MB1032;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1032; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(346002)(396003)(39860400002)(376002)(366004)(189003)(199004)(5660300001)(76176011)(99286004)(10090500001)(2900100001)(105586002)(305945005)(7736002)(107886003)(2501003)(5250100002)(14454004)(53936002)(4326008)(8936002)(68736007)(25786009)(86612001)(3846002)(66066001)(1076002)(486006)(316002)(72206003)(22452003)(106356001)(186003)(97736004)(6436002)(6116002)(476003)(2616005)(478600001)(6486002)(10290500003)(2906002)(110136005)(54906003)(6512007)(81156014)(81166006)(8676002)(36756003)(11346002)(3660700001)(446003)(6666003)(86362001)(26005)(102836004)(3280700002)(6506007)(59450400001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1032;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 0QSyPxuVbuDAFtRVXgkwyzo1JpFFZkEO3MJS2w7lnLJrY+yWmAWiSP0kjgyD0iCnkEINSt4JOIQ2XFf1axRvbyox1t0Q66aoge4X/LIszxO2tzX7G+S5VH1IxLNFqiSU2qJ5UDHtESN/icX6oAdbrJUXcAfi7vwDQ91it4txVweAVtbC4z15APc1LJrdR+OmNPU0mnhcr8xfyUCjJfu86jBMtTaTo4ij6/fLdW2ycSVNCpO8Wb7hg08czks60J9nJywfo3FVIb0ALAV8XgMQsLi9nT0QPHfdSQU394gr47PPenITF65xy8t4KqN+6eqxOoF6SxSvmEtXONGk/Dg0cWugEd/hRWoZI0XaXAaBOPeaW58YaUJagNivcmiWoYdB2JTr1O0gxHwqpbrmg6va7uv8aYqnPFVrkeW9PROQXoU= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d1f3946-bdf9-4c7f-bdde-08d59db10fe5 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:24:28.1125 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1032 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chenbo Feng [ Upstream commit 8fac365f63c866a00015fa13932d8ffc584518b8 ] Currently in both ipv4 and ipv6 code path, the ack packet received when sk at TCP_NEW_SYN_RECV state is not filtered by socket filter or cgroup filter since it is handled from tcp_child_process and never reaches the tcp_filter inside tcp_v4_rcv or tcp_v6_rcv. Adding a tcp_filter hooks here can make sure all the ingress tcp packet can be correctly filtered. Signed-off-by: Chenbo Feng Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/tcp_ipv4.c | 2 ++ net/ipv6/tcp_ipv6.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index b3960738464e..7294a1106b75 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1677,6 +1677,8 @@ process: } if (nsk =3D=3D sk) { reqsk_put(req); + } else if (tcp_filter(sk, skb)) { + goto discard_and_relse; } else if (tcp_child_process(sk, nsk, skb)) { tcp_v4_send_reset(nsk, skb); goto discard_and_relse; diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index eb624547382f..149b9b3cbd66 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -1447,6 +1447,8 @@ process: if (nsk =3D=3D sk) { reqsk_put(req); tcp_v6_restore_cb(skb); + } else if (tcp_filter(sk, skb)) { + goto discard_and_relse; } else if (tcp_child_process(sk, nsk, skb)) { tcp_v6_send_reset(nsk, skb); goto discard_and_relse; --=20 2.15.1