Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2476585yba; Mon, 15 Apr 2019 12:26:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxEmV6Sq+Lcwmyg4KhBNwENAQxISKvAxtQAd2LPRyrU7i6TA0wpCCBNFMnzrSEaRxgrYvH+ X-Received: by 2002:a17:902:8d8b:: with SMTP id v11mr77135866plo.133.1555356415812; Mon, 15 Apr 2019 12:26:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555356415; cv=none; d=google.com; s=arc-20160816; b=ajBDWopg3IGdglq4NT2boyBSEy5Eacgyjm5GHpGzxiuofuBPuRPRuTF6aBaG3tNUj+ zfSnfy1de1EgELoeuZfQT60JtpM5FsT8VCsenXv0jTiE8LtCNUbTQyjGGURJWmhULLuk OLPAtDhjusyDgPYBzai3DOY4/+Yy2ZevARFCbrBQwwjKL8bQ4OOdJy3ApOCNrUE3/Rxy dB2LS+O82LXOFWQQfcILqRGQ6eTdeZ+009h/3dyf3XqFqGZMlYKVEHFhMHMTSWsezBxI fQcrtEkGasFMddDE7SE3xng8e0z/xnlOgNmIvKilc9d1ZL1TmDItU1UYRK2nqHoBBmKd QEkg== 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=xixn0PhRl3X3ujO0iwn/0VWodlChemOnkO8L79xQkz8=; b=O4TJtBUMJEZEkmUU7ZtSTsW6ZtyKBd8BKu2VM3m/y3qQN1KCEE5Ox4B1E3RJzG+gIY B5L8ijOSkZWS//rHUGEeAq2LMl/uWJVjC3+BZz2csAlOAy5uK808wxnddM2qkjOMJkDB WA5ExTRJrPGdfmYtsOupFV2qyTEOT4W1Wp2y5ZUDV+M0ydjbgDLsS4JnbJOx9cD88iDe uU3nKeU1RyQQeyHNVpB/Y+2Nt8PLllempQZXZLZo/WZiXUoY5tyolzkkpLcKl2JiHfNZ UIGRiF7lcO1GnNa3AVE5UfY6oJHGfSxfCpv1SVFm3NUw3KiU/WK8kJD+NrhrNAYyAkQ1 vZKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZAsD+Hnk; 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 n4si12917431pgp.246.2019.04.15.12.26.39; Mon, 15 Apr 2019 12:26:55 -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=ZAsD+Hnk; 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 S1729777AbfDOTZa (ORCPT + 99 others); Mon, 15 Apr 2019 15:25:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:39166 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729234AbfDOTF2 (ORCPT ); Mon, 15 Apr 2019 15:05:28 -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 EDF2920880; Mon, 15 Apr 2019 19:05:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355127; bh=WLCcL36wBtIqF4JbLpROoSGduzawpyTnnAOOlSBSPJY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZAsD+HnkmpNUFTs5QiviNBr/u/cpd7Gs+Lkf5g15sGOZKTuk2gQHU3zp/uYZckYGr meWAaCQqwq7K2WDGQs9bWrZ12Kt0p6LwvnKp2V35/4mT1vuBLFre0jiSsElIjr0vJZ TkzrcIcfen27ZFD4BRxQF/jIUogXqgM/jdzwmkmI= 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 4.19 023/101] vrf: check accept_source_route on the original netdevice Date: Mon, 15 Apr 2019 20:58:21 +0200 Message-Id: <20190415183741.614733227@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183740.341577907@linuxfoundation.org> References: <20190415183740.341577907@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 71d31e4d4391..cfc3dd5ff085 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -648,7 +648,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 bd8ef4f87c79..c3a0683e83df 100644 --- a/net/ipv4/ip_input.c +++ b/net/ipv4/ip_input.c @@ -258,11 +258,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. @@ -298,7 +297,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; } @@ -354,7 +353,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