Return-Path: Received: from userp1040.oracle.com ([156.151.31.81]:34781 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755970AbcCBUYj (ORCPT ); Wed, 2 Mar 2016 15:24:39 -0500 From: Sasha Levin To: stable@vger.kernel.org, stable-commits@vger.kernel.org Cc: Paolo Abeni , "David S. Miller" , Sasha Levin Subject: [added to the 4.1 stable tree] ipv6/udp: use sticky pktinfo egress ifindex on connect() Date: Wed, 2 Mar 2016 15:23:55 -0500 Message-Id: <1456950258-513-11-git-send-email-sasha.levin@oracle.com> In-Reply-To: <1456950258-513-1-git-send-email-sasha.levin@oracle.com> References: <1456950258-513-1-git-send-email-sasha.levin@oracle.com> Sender: stable-owner@vger.kernel.org List-ID: From: Paolo Abeni This patch has been added to the 4.1 stable tree. If you have any objections, please let us know. =============== [ Upstream commit 1cdda91871470f15e79375991bd2eddc6e86ddb1 ] Currently, the egress interface index specified via IPV6_PKTINFO is ignored by __ip6_datagram_connect(), so that RFC 3542 section 6.7 can be subverted when the user space application calls connect() before sendmsg(). Fix it by initializing properly flowi6_oif in connect() before performing the route lookup. Signed-off-by: Paolo Abeni Acked-by: Hannes Frederic Sowa Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv6/datagram.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index 13ca4cf..8e6cb3f 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c @@ -162,6 +162,9 @@ ipv4_connected: fl6.fl6_dport = inet->inet_dport; fl6.fl6_sport = inet->inet_sport; + if (!fl6.flowi6_oif) + fl6.flowi6_oif = np->sticky_pktinfo.ipi6_ifindex; + if (!fl6.flowi6_oif && (addr_type&IPV6_ADDR_MULTICAST)) fl6.flowi6_oif = np->mcast_oif; -- 2.5.0