Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2464460yba; Mon, 15 Apr 2019 12:11:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzR203WsTqHQL/c3k86imQwoC592ziZwRiYbXFa2FD/r5zmjoXjBkDWXEkQ0Zwn0vM4O3xh X-Received: by 2002:a63:28c:: with SMTP id 134mr72956014pgc.278.1555355509900; Mon, 15 Apr 2019 12:11:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555355509; cv=none; d=google.com; s=arc-20160816; b=Myi+wURkWXhXuHu39ModDM7O3zXanVYbDSA50kCovz/7r3Oe+sTxbheul3BjdM1SsQ AjNcAcjHhxCzcNA2C9zZOPyHUrXs/SxMPQl5Am5tnv9V5rboD8Lp8kOFpzgOnI3MqW6O e7k36hleGzt3aEBaVO0ikSHkwIdVayaouNAyd+tdjJ7eCImvgxACduBR2zadBGgMrgWJ c1q9J5ObWi+Y4zf34dm3OVeSIjzHA/3q7ONBrQzFKhlunr6GYV6yxomISQHWqfE8AqW2 5m/NZ6duJmjYaY/eMAWwJQf+oeEBoj4QQoCoGRTSLfkEVpYDU7uyR62ELZ3DUZ/kfIB3 mWBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=caDruBGCaMF8EglBOyEeGSWwgf/9O5Iobn3f7p/Ilug=; b=Ev+VnLRrGJLww3iDSLr3NOLtfd9orV7ubDfobf0FCJk0TbSQn6W7kXQDeYqH903gJo sI65tsyvLdZUA2va8dF3RL4wKGukhRI+Y8gBDuyuF2p+lAii8WroWBwxNwj8rKktn8bq NdSerbzEGkg/YFXYudDED5URsqjJ6hF1bPPdCD2ZiBzZ7tml3AqO83W27HPA+mi8AWSV vp0pNzdPdiqSFznfFtnAaVcNfpHoZjB/iSO7bd9q3vap/LkMe6EvDI6b1xKysivPExFz b4YYDJutkM/xVy7PQlqM2LVUVurJk08x5jmqnMFHCZZrRuMD41oWm7Jc7HMklVslf7nz KgKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PLkobY+6; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 32si20357991pld.155.2019.04.15.12.11.33; Mon, 15 Apr 2019 12:11:49 -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=@kernel.org header.s=default header.b=PLkobY+6; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730074AbfDOTKS (ORCPT + 99 others); Mon, 15 Apr 2019 15:10:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:46258 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730041AbfDOTKM (ORCPT ); Mon, 15 Apr 2019 15:10:12 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D72DB218D3; Mon, 15 Apr 2019 19:10:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355411; bh=HCDpqSv2ecceVF6ucEbuH2DN99NaF9GUzIdbj3Y9Ydo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PLkobY+6mmVHr9jPMjkJ6GzTcrqtiJdliGIfNVawX5B5loL/yBxTK44KPIfOyJZrp LK8djWWryUzurMWqAWzwdIc0M+2ZE0cBRIxy2DV1BGoDeOj5SG/tgy624LeY9uSOVf GLRqJNoJRFZ0RzIlHBCiX5IIQEMjQMuSEUnCfn1I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephen Suryaputra , David Ahern , "David S. Miller" , Sasha Levin Subject: [PATCH 5.0 025/117] vrf: check accept_source_route on the original netdevice Date: Mon, 15 Apr 2019 20:59:55 +0200 Message-Id: <20190415183746.166879651@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183744.887851196@linuxfoundation.org> References: <20190415183744.887851196@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 8c83f2df9c6578ea4c5b940d8238ad8a41b87e9e ] Configuration check to accept source route IP options should be made on the incoming netdevice when the skb->dev is an l3mdev master. The route lookup for the source route next hop also needs the incoming netdev. v2->v3: - Simplify by passing the original netdevice down the stack (per David Ahern). Signed-off-by: Stephen Suryaputra Reviewed-by: David Ahern Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- include/net/ip.h | 2 +- net/ipv4/ip_input.c | 7 +++---- net/ipv4/ip_options.c | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/include/net/ip.h b/include/net/ip.h index be3cad9c2e4c..583526aad1d0 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -677,7 +677,7 @@ int ip_options_get_from_user(struct net *net, struct ip_options_rcu **optp, unsigned char __user *data, int optlen); void ip_options_undo(struct ip_options *opt); void ip_forward_options(struct sk_buff *skb); -int ip_options_rcv_srr(struct sk_buff *skb); +int ip_options_rcv_srr(struct sk_buff *skb, struct net_device *dev); /* * Functions provided by ip_sockglue.c diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c index 1f4737b77067..ccf0d31b6ce5 100644 --- a/net/ipv4/ip_input.c +++ b/net/ipv4/ip_input.c @@ -257,11 +257,10 @@ int ip_local_deliver(struct sk_buff *skb) ip_local_deliver_finish); } -static inline bool ip_rcv_options(struct sk_buff *skb) +static inline bool ip_rcv_options(struct sk_buff *skb, struct net_device *dev) { struct ip_options *opt; const struct iphdr *iph; - struct net_device *dev = skb->dev; /* It looks as overkill, because not all IP options require packet mangling. @@ -297,7 +296,7 @@ static inline bool ip_rcv_options(struct sk_buff *skb) } } - if (ip_options_rcv_srr(skb)) + if (ip_options_rcv_srr(skb, dev)) goto drop; } @@ -353,7 +352,7 @@ static int ip_rcv_finish_core(struct net *net, struct sock *sk, } #endif - if (iph->ihl > 5 && ip_rcv_options(skb)) + if (iph->ihl > 5 && ip_rcv_options(skb, dev)) goto drop; rt = skb_rtable(skb); diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c index 32a35043c9f5..3db31bb9df50 100644 --- a/net/ipv4/ip_options.c +++ b/net/ipv4/ip_options.c @@ -612,7 +612,7 @@ void ip_forward_options(struct sk_buff *skb) } } -int ip_options_rcv_srr(struct sk_buff *skb) +int ip_options_rcv_srr(struct sk_buff *skb, struct net_device *dev) { struct ip_options *opt = &(IPCB(skb)->opt); int srrspace, srrptr; @@ -647,7 +647,7 @@ int ip_options_rcv_srr(struct sk_buff *skb) orefdst = skb->_skb_refdst; skb_dst_set(skb, NULL); - err = ip_route_input(skb, nexthop, iph->saddr, iph->tos, skb->dev); + err = ip_route_input(skb, nexthop, iph->saddr, iph->tos, dev); rt2 = skb_rtable(skb); if (err || (rt2->rt_type != RTN_UNICAST && rt2->rt_type != RTN_LOCAL)) { skb_dst_drop(skb); -- 2.19.1