Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp329694ybi; Fri, 7 Jun 2019 08:43:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwblVJKk6xWMurQPtxIX+6o4KkzRCo0TFeGTFmxlwiT4hyEFPB/r/COtOcHZySkpqVWa2jk X-Received: by 2002:a65:4306:: with SMTP id j6mr3375861pgq.418.1559922238565; Fri, 07 Jun 2019 08:43:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559922238; cv=none; d=google.com; s=arc-20160816; b=jhgW3D0ChVxvlPE7ayrIz6iyQMng4Kmw1Io9ciO/EE5GdZwSkSzLLp57hHS82y3dZu 1jfBRDXrKqTnD9YmvgM0bC8d5FctjQdZymIyR/sYoClem3WoYbsI0DagRxIfNWqVWDUW KDFVlW42YmUnxgd4HLgSQ6pOIAHXmXSn1G/1UajRn4ZVG+zC2eakRUpjedE7opz4r3je rZgGiLHFPfA63z2P9hGUICoVmGpmDemiB2vLIbLhbSLZcTD0E3RuX+xLeQMBgnkRKjdv aNe5VAiZfPDJnC1iQ47cB4bTHCO3+6J4s9oFZtZuo8SkyJP7RU7a/cr6MrBR23A+CD4v jPog== 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=x6cH+xVI5t5/DJUJnGoOZS/a3zpvuswmVN0w3+fZ7ro=; b=c5XICjo0feSvGooqr7EpYwBN4ygr/D9vvjU5wwUaoJ6mY+3SRE9fKgmfaJuAoy4jbt BFgyq4f0k+84+vCPbd1v+BwZ3bIKheu9Ommtu/7fHnggSX5gBuRTwlIxhbrzLRfKWl2v 3dG5zfOD9OAdUvskQaOaVEPYUk1iziF5J328etBeQyfXd7Z+Q4BU9TrFCiLKaLQUMkvb e2xnKGbJYwnDo4ddxTH0eY24rfYugTMIu3doPQT6Xyen8wIDXQMbCeeBaawe9bFPlEFf vnnKQ52uOEVO+3NvmaPvmAnICnwlWNFahbpIypKkDS8Ux5D+BAw147tkltC70Yh8lw5Y 7fKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2J8GYcKQ; 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 c7si2135645pgk.411.2019.06.07.08.43.40; Fri, 07 Jun 2019 08:43:58 -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=2J8GYcKQ; 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 S1730048AbfFGPk2 (ORCPT + 99 others); Fri, 7 Jun 2019 11:40:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:49592 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728783AbfFGPk0 (ORCPT ); Fri, 7 Jun 2019 11:40:26 -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 DAD0520840; Fri, 7 Jun 2019 15:40:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559922026; bh=Tu1jLYk41rN3icIKDcHiqaa1kMYEw7AOF/WFlKAypHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2J8GYcKQoNcSS38tWiTl9gHeqoEBBIThYjVkjBL8OfkhTRX2u1dZkbu6sEI/w4zAc uoNI9UcrXhvks1FvuMkgjBLcXHPbn5HAcP9PzUbMy7lAvlU+zqco+YpIw/t4b04T0p tqXfaOnh+EDzjcoSOj+CELV4J/gf+aRCneo8dgvA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Manning , David Ahern , "David S. Miller" Subject: [PATCH 4.14 02/69] ipv6: Consider sk_bound_dev_if when binding a raw socket to an address Date: Fri, 7 Jun 2019 17:38:43 +0200 Message-Id: <20190607153848.551262124@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190607153848.271562617@linuxfoundation.org> References: <20190607153848.271562617@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 From: Mike Manning [ Upstream commit 72f7cfab6f93a8ea825fab8ccfb016d064269f7f ] 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. Signed-off-by: Mike Manning Reviewed-by: David Ahern Tested-by: David Ahern Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv6/raw.c | 2 ++ 1 file changed, 2 insertions(+) --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c @@ -288,7 +288,9 @@ static int rawv6_bind(struct sock *sk, s /* Binding to link-local address requires an interface */ if (!sk->sk_bound_dev_if) goto out_unlock; + } + if (sk->sk_bound_dev_if) { err = -ENODEV; dev = dev_get_by_index_rcu(sock_net(sk), sk->sk_bound_dev_if);