Received: by 10.223.185.116 with SMTP id b49csp1874515wrg; Sun, 4 Mar 2018 12:06:43 -0800 (PST) X-Google-Smtp-Source: AG47ELt1kXR5onsmGRCkBmUmO9E/qGaYru4mfQKBFsMEG8Q/2UGQ1CcNkb683K/JWpzZ0PC+qeS/ X-Received: by 10.101.66.136 with SMTP id j8mr10369834pgp.409.1520194003266; Sun, 04 Mar 2018 12:06:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520194003; cv=none; d=google.com; s=arc-20160816; b=l5LMpgBgk469M0XCDIRkfxhLEYTFANXrWpvofh3b9yJnC2Mr/qO1VCwaJJKfjorOIt D5FbkWGW8ocDeFtyCLN3Aib/yfHuP1Fv3VvFFCFOGjZgCyqbzhHBBFzJNTglFA/ptSRY FG6SOvSPlYSM147BrPtj6riBpxfvRrHczFxnWGhhwyKKIEyoOKSQzaJoqQWe9WFrN/Qd aAYt9/TMykELNFlVCIZJCtqVBOI4x6Afdm1bp8anqt5VzAE51cWjNurjIrKN3b20WtoX KxfbQjzajngTtZZLR9ABKpqxk6VZ9OJkEDaxOrcF/I0IwFWhOzpRDsMAJXCmqsTyYVp/ PfAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:message-id:date:subject:cc:to :from:dkim-signature:arc-authentication-results; bh=4mlXMpAC1vRvn2QWdnkAXAeafe7M9oNUlLPePTktU1U=; b=scoGxtePMgqyyiiBE5ouY7gouaT7hto6qUzsMIpOcljvUkj6cehQvYryZ/v9vTE5eC GwLuT04WaSstSGAFm8796VV5/0Pt0G/KeI+OIrfVLU6vUT/WlpKZlDzAOL2dRHFmEUc3 CLjFzWZHeB7sm66ToT2GVTmLaP/rty9Ej0EaCxcgWaS9jKhx3Wk0wl7aNdPuZplxmZMZ NYJ+ZDdZMZcyW/uyW08IqYYRCeShWYHI+C3GIYPkHwfiLGa0KuVrV9pa0pyZeatoVRB2 NAUDW5f5+QIXz44brbzDhBfYkVBZgRXSvy4KtKaT28Cq8rRIJSNH8xbw+X5rTYco4Iks yEBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@Mellanox.com header.s=selector1 header.b=UxGsmj43; 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=NONE sp=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k3si8810342pff.157.2018.03.04.12.06.27; Sun, 04 Mar 2018 12:06:43 -0800 (PST) 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=@Mellanox.com header.s=selector1 header.b=UxGsmj43; 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=NONE sp=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752196AbeCDTER (ORCPT + 99 others); Sun, 4 Mar 2018 14:04:17 -0500 Received: from mail-eopbgr10046.outbound.protection.outlook.com ([40.107.1.46]:56884 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751791AbeCDTEO (ORCPT ); Sun, 4 Mar 2018 14:04:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=4mlXMpAC1vRvn2QWdnkAXAeafe7M9oNUlLPePTktU1U=; b=UxGsmj43dd3ZFf5W+RxQJYBxqg21t/9cxUYX0CFH5VVRDUTDzj7OZqH3JJptPRxufuNqsc/RMTJjwFRK7sKuqCaDVNE0vkOBBgHdo51m9+1tpQzqGkmIeRvI8vwt2wEguW3T5AfpMBJYGWJ0hEgN5JHrb66jUCgXKAtlnYZ37uI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=yossiku@mellanox.com; Received: from dev-l-vrt-187.mtl.labs.mlnx (141.226.120.58) by AM5PR0501MB1987.eurprd05.prod.outlook.com (2603:10a6:203:1a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.548.13; Sun, 4 Mar 2018 19:04:08 +0000 From: yossiku@mellanox.com To: Steffen Klassert , Herbert Xu , "David S. Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Artem Savkov , Yossi Kuperman Subject: [PATCH net] xfrm: Verify MAC header exists before overwriting eth_hdr(skb)->h_proto Date: Sun, 4 Mar 2018 21:03:52 +0200 Message-Id: <1520190232-7208-1-git-send-email-yossiku@mellanox.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [141.226.120.58] X-ClientProxiedBy: AM5PR0102CA0001.eurprd01.prod.exchangelabs.com (2603:10a6:206::14) To AM5PR0501MB1987.eurprd05.prod.outlook.com (2603:10a6:203:1a::9) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d235b7f9-b021-48d3-8946-08d58202b5b1 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060)(7193020);SRVR:AM5PR0501MB1987; X-Microsoft-Exchange-Diagnostics: 1;AM5PR0501MB1987;3:8M8zKMtbcXs5Rsb5PbUkAPc/7DxMA2PgKAvJxe43VPajPNgXHfJMbhnmcJI3WRG+Tzom4XnUNc15jk5uHPtK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yETa+6+9PCJwZJwkpuy8LNs+1MQ2963pKUI53ala5S3KIH+7tBUs4x0h8joZaIYztLGhsdhj82HwVu+F2pN3H6J2wGgxKB2uLdtl9J+C3h4c1hfTiSM7agKIv1VVAzwvM0jw793RVrxxjd/JyOnRFEQft6UVOWJdhTxAj7Z/j6Xf7tsXJRLhF4uNRl9iBryxmwnUyBRR4fLdWuWDU6gS9Chw0b1YE7R2nIfYrgOWr/fjMUhSYW/YpS4n;4:aE+MFRIm7FqnpBp85C+UTXNzKIugymY6zAdx3tUWhABWu3FKEJuSmMfraM2DQInU7XV7cHswnATj77YUOFX7RhAM2RgsbSJsJhFJEDwAlGamGadBVMsXouYSUEAloIMVEpOBRJ7M9qQ0ncwjpBLCD0v3qAqD9ZpmK+re8pMSUbnExZeXjl2oAlMMKYeOQhdH3rMlso/PaGPzRagvQOJVWoSMvJF75k+kO+INCyqVNygpC7khI83l6c22pdkuEcmMFf9W+djLqA35sU//HRMTT8nD1NbRanwhA+GmP18alFWU4sFf/HQyKvz9CPkiEU1S X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85827821059158); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040501)(2401047)(5005006)(8121501046)(3231220)(944501244)(52105095)(10201501046)(93006095)(93001095)(3002001)(6055026)(6041288)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:AM5PR0501MB1987;BCL:0;PCL:0;RULEID:;SRVR:AM5PR0501MB1987; X-Forefront-PRVS: 060166847D X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(376002)(346002)(39860400002)(39380400002)(366004)(396003)(189003)(199004)(33896004)(478600001)(4326008)(48376002)(8936002)(110136005)(54906003)(6666003)(16526019)(186003)(25786009)(9686003)(2906002)(50466002)(36756003)(16586007)(68736007)(6506007)(386003)(39060400002)(6512007)(26005)(305945005)(81156014)(6486002)(52116002)(51416003)(106356001)(97736004)(105586002)(6116002)(3846002)(575784001)(86362001)(316002)(66066001)(81166006)(5660300001)(47776003)(53936002)(85782001)(7736002)(8676002)(107886003)(50226002)(85772001);DIR:OUT;SFP:1101;SCL:1;SRVR:AM5PR0501MB1987;H:dev-l-vrt-187.mtl.labs.mlnx;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;AM5PR0501MB1987;23:CRR92g9PnvxKH5vAlgXj+Ge8NPfti564z0rAKLY?= =?us-ascii?Q?JJvv53R3HZHKz6N9oVDSbclN3DN1SJZrDyHjczilISsJ55/Mmxl+pIDmW4wb?= =?us-ascii?Q?m+SmdazW57PXMS64GNwvbGZQRI/9wWNHnqmpURvgCj0rW4Y7IVM36Z9+pJiy?= =?us-ascii?Q?/ShVxuCdGXQgrbOdSWNoMrRaKGAqAJuONyre02b2mpEy0N4KtYO9i4IqShHw?= =?us-ascii?Q?TjNQ9RjYR7Zgc1XgFFVhQJxtahXc1tNHpcTCVdEq6L8oFyvOYKIrJ5lPgfy5?= =?us-ascii?Q?Bf/OvfwNFRzPcwtW/RE1z4ZRIw89/mazAIjxdHWC3Wy1HzFFYm2PqkADTlaq?= =?us-ascii?Q?sfaJfLOijQi9A6G/BDFEyaVG8yL0sgmDVHNyMlU3EE/2BSkT2OBn62I1jyZa?= =?us-ascii?Q?0MdJ3UkxFyq5av+kCnlQKXbyMU0WlH2bn2UVx4pnkWm6VlUVwqZts3sVvM28?= =?us-ascii?Q?7clJIAVZqng+pidNYC0yY808/GPAfV1FaBp5U+nul+NtXS9OBOmHBbUMqO7b?= =?us-ascii?Q?z9Ij+JEFzwTVyC33RFjDEvAsqoifuwHqT32FLzYb+nxA+gk5fERF8Yo96aqW?= =?us-ascii?Q?wWLwR8ystS9V+5iz0pi1SHmYwB1Lhc+1b91coOBHInJDPQYIdmf8zdwZj8Wn?= =?us-ascii?Q?NQU+6w8tBAGjhlShBahYSTjCzoSOlpDbQVey4Wu8+uqTsoPGY5/03E7bTPSU?= =?us-ascii?Q?yI5uQhfjAcxYViRgflbu7BzZbAThNajrVTAonzolQ1uKUQy5Eooy898wI4WF?= =?us-ascii?Q?lIemRkhmzPEq5Z2uSeGjhODy4JMD/868vI3LCvZrfOiEd21DPsj9vSkFnGUY?= =?us-ascii?Q?aT324nATalBEiQdCoSIvPcQCWqlW7a45HX2a6QVDa04DkbrnEWsMZBgE9I2P?= =?us-ascii?Q?zEiQ5LbiAN23wmW1VcDi17MR224sz19jxE3H/6QX3dqXgvOtf9ewC/KcUf/w?= =?us-ascii?Q?GaOGHvo2GnI1OWcgfDhmDXeuiNKkMMJz3/dKRxwr0cMgGzg/5jHYYJaMnn8T?= =?us-ascii?Q?FTwNyTL3OUvP4g8owUWaHW5maQBeH93i+lqZUjqRmvpt4oZfnt/9154qQ2K2?= =?us-ascii?Q?CnpWlWF52AHOplHmrH8ccDxPfLD7VlSXvD9barK3LKbpJkbp4Z+7+gjSz+Yx?= =?us-ascii?Q?GV47GKRnqntBGAehbiW4EOKsnpG2AMtMyViT3uzq9Jqr8E9pChIgkHTJIjFW?= =?us-ascii?Q?bCYB/zcHU4seNBRxrlRU8/WTt55OhQGACR5lDZVg7g1vH1jLOpPGdfshR1w?= =?us-ascii?Q?=3D=3D?= X-Microsoft-Antispam-Message-Info: kanoFYtatJES/pjfeBLzSLzvN0hlyLOB9lOlNGBysTK+7SuE4lXdqUrtAfq38hF0rlcgD6JrZO4woiAJ2hkePA3ZqXFJmL5lSg/VOmUjk4JbT3+CLJkH9fyXxLBuW/oKPY5VUPo6brgddjKoZg7Z/YVUAlrpt0R467dEEhHMNUkN4OOQ5Cx88aWHoxsRw3zG X-Microsoft-Exchange-Diagnostics: 1;AM5PR0501MB1987;6:7PluEBWCOW+/GdWvEayYv1g14O6BVJEzrJXTBmWqfSg+rE7AqlAUQo9WPf9cmT6SoMsaT8YBtRo/Y5FdRsoBd15lGyvcqF2GG6DBbdrt2GW0l+v9KkaCKRwynYcoTFcUWKKGMHPVl2Ia6IVQwhFhqo6U4Ln4HwKcTeaH+bKT1LPqBPiao9YgjIWoTL6B1rHL2rjokB4WKFy24GFAXk+PhzCsgpDUMno7gqfSBUCiIysfE9vmYzGFCfuX93x+UVCy7+rWLPTTOObD/XI+tV6MsyXwt2mHKyGMq44nOvhwFExzh6NkauMhQsXtel2omYkYYNQGoNVh0TPi92t+zC7KGVrxUi2QYKvq3BuRPNESBpE=;5:dZWzg9OhZlZlynmdlkQVFa12ecc3JzXLgloIisC7OZuXITrPKduGnmj+sSTSUGX3qOPutswlO97DeGNgUwKsHTGbJzW46vvNYT2lLxi3Jsw9m/9JRhflbXwjPZ8WNXbWCnm4W2/E54p8cGOtmJ9QJZaVDgx6k0KO7jVMpOQNXbs=;24:dvbZNwe798qYbC7FRpT1FPHvDlsdkAy9yQre1i+xugcUk6P3TCQfcz4YnyHSjeDLw2M/5dhZk5QpFWgLArxENO3rHp7KtbUMafqLaWsarAc=;7:8s36CKE95S8SLwlwmTj0UdljWVsSaOQPoQIqgslivERYuPp9f9o7xy54y+OBiwQnj/0R/gTkTaNOotmzHmWdC8ZabCuOJsHUOREDM0/CRZWI+tHtmCY7EJvpdm/deN/GMT8oH+O0uQNMeInsRP/nT6fEkmtabqiPK0yXiTlcV3VEWrxeDxoA9d1FI4NYnCgAuHXA+dA4FHw65PUGkjUGzMdW65QNaJ0s8oq0/hKR8SOvv73ckbjyS2f7MgFACAO7 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2018 19:04:08.1555 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d235b7f9-b021-48d3-8946-08d58202b5b1 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0501MB1987 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yossi Kuperman Artem Savkov reported that commit 5efec5c655dd leads to a packet loss under IPSec configuration. It appears that his setup consists of a TUN device, which does not have a MAC header. Make sure MAC header exists. Note: TUN device sets a MAC header pointer, although it does not have one. Fixes: 5efec5c655dd ("xfrm: Fix eth_hdr(skb)->h_proto to reflect inner IP version") Reported-by: Artem Savkov Tested-by: Artem Savkov Signed-off-by: Yossi Kuperman --- net/ipv4/xfrm4_mode_tunnel.c | 3 ++- net/ipv6/xfrm6_mode_tunnel.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/net/ipv4/xfrm4_mode_tunnel.c b/net/ipv4/xfrm4_mode_tunnel.c index 63faeee..2a9764b 100644 --- a/net/ipv4/xfrm4_mode_tunnel.c +++ b/net/ipv4/xfrm4_mode_tunnel.c @@ -92,7 +92,8 @@ static int xfrm4_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb) skb_reset_network_header(skb); skb_mac_header_rebuild(skb); - eth_hdr(skb)->h_proto = skb->protocol; + if (skb->mac_len) + eth_hdr(skb)->h_proto = skb->protocol; err = 0; diff --git a/net/ipv6/xfrm6_mode_tunnel.c b/net/ipv6/xfrm6_mode_tunnel.c index bb935a3..de1b0b8 100644 --- a/net/ipv6/xfrm6_mode_tunnel.c +++ b/net/ipv6/xfrm6_mode_tunnel.c @@ -92,7 +92,8 @@ static int xfrm6_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb) skb_reset_network_header(skb); skb_mac_header_rebuild(skb); - eth_hdr(skb)->h_proto = skb->protocol; + if (skb->mac_len) + eth_hdr(skb)->h_proto = skb->protocol; err = 0; -- 2.8.1