From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF2CAC282C4 for ; Mon, 4 Feb 2019 11:05:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 816CB2075C for ; Mon, 4 Feb 2019 11:05:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549278306; bh=VLKG/HaDtXkx93/i6ey3ACjlUGPcIZESJzqXd5PYCek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=lynwTrdllukMBaw3wMb6Qw6zpBMdbw3NUd/q3ZUls9Xk7+p0srUJIihCYDfSMuHQJ ic4GRLTeQX1/cqmU9i7kuVDh6QphW73rSbEmCo6J0kliO7MzVVeh0x6vg1Y2XImqx9 Tqdz85/vubK+mt9GN2CBTOcMoKOmnopCM4C6RCII= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727778AbfBDLFF (ORCPT ); Mon, 4 Feb 2019 06:05:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:42840 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731095AbfBDKoy (ORCPT ); Mon, 4 Feb 2019 05:44:54 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 AA8E92070C; Mon, 4 Feb 2019 10:44:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549277094; bh=VLKG/HaDtXkx93/i6ey3ACjlUGPcIZESJzqXd5PYCek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v599c++rEowb+YhkERetc26v6BAru4x1x7o0mSMgcu+Z1W6p1OMrHsPFD2aiNETpR G2/frkhSGb3pdQMwiu65FbtUSBzTenB7eM4+P9Grc8Germ0/tewvuMEy72xtiGp1lv xx/Nbwg2ORV0944URvTo6IrUK0yQJ37A6WxgM5FU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Ahern , "David S. Miller" Subject: [PATCH 4.14 02/46] ipv6: Consider sk_bound_dev_if when binding a socket to an address Date: Mon, 4 Feb 2019 11:36:33 +0100 Message-Id: <20190204103609.055279213@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190204103608.651205056@linuxfoundation.org> References: <20190204103608.651205056@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Ahern [ Upstream commit c5ee066333ebc322a24a00a743ed941a0c68617e ] IPv6 does not consider if the socket is bound to a device when binding to an address. The result is that a socket can be bound to eth0 and then bound to the address of eth1. If the device is a VRF, the result is that a socket can only be bound to an address in the default VRF. Resolve by considering the device if sk_bound_dev_if is set. This problem exists from the beginning of git history. Signed-off-by: David Ahern Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv6/af_inet6.c | 3 +++ 1 file changed, 3 insertions(+) --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -370,6 +370,9 @@ int inet6_bind(struct socket *sock, stru err = -EINVAL; goto out_unlock; } + } + + if (sk->sk_bound_dev_if) { dev = dev_get_by_index_rcu(net, sk->sk_bound_dev_if); if (!dev) { err = -ENODEV;