@@ -108,7 +108,7 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
* of loopback must be dropped.
*/
if (!(dev->flags & IFF_LOOPBACK) &&
- ipv6_addr_loopback(&hdr->daddr))
+ (ipv6_addr_loopback(&hdr->daddr) | ipv6_addr_loopback(&hdr->saddr)))
goto err;
skb->transport_header = skb->network_header + sizeof(*hdr);
@@ -919,6 +919,7 @@ static int ip6_dst_lookup_tail(struct sock *sk,
{
int err;
struct net *net = sock_net(sk);
+ struct net_device *dev_out;
if (*dst == NULL)
*dst = ip6_route_output(net, sk, fl);
@@ -926,6 +927,13 @@ static int ip6_dst_lookup_tail(struct sock *sk,
if ((err = (*dst)->error))
goto out_err_release;
+ dev_out = ip6_dst_idev(*dst)->dev;
+ if (dev_out && ipv6_addr_loopback(&fl->fl6_src) &&
+ !(dev_out->flags & IFF_LOOPBACK)) {
+ err = -EINVAL;
+ goto out_err_release;
+ }
+
if (ipv6_addr_any(&fl->fl6_src)) {
err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev,
&fl->fl6_dst,