From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Miller Subject: Re: [PATCH net,stable] tun: fix vlan packet truncation Date: Tue, 17 Apr 2018 13:47:27 -0400 (EDT) Message-ID: <20180417.134727.1681639113353628332.davem@davemloft.net> References: <20180416220038.21743-1-bjorn@mork.no> Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-8859-1 Content-Transfer-Encoding: 8BIT Cc: netdev@vger.kernel.org, jasowang@redhat.com To: bjorn@mork.no Return-path: Received: from shards.monkeyblade.net ([184.105.139.130]:59118 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753138AbeDQRr3 (ORCPT ); Tue, 17 Apr 2018 13:47:29 -0400 In-Reply-To: <20180416220038.21743-1-bjorn@mork.no> Sender: netdev-owner@vger.kernel.org List-ID: From: Bjørn Mork Date: Tue, 17 Apr 2018 00:00:38 +0200 > diff --git a/drivers/net/tun.c b/drivers/net/tun.c > index 28583aa0c17d..01cf8e3d8edc 100644 > --- a/drivers/net/tun.c > +++ b/drivers/net/tun.c > @@ -1103,13 +1103,6 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev) > > len = run_ebpf_filter(tun, skb, len); > > - /* Trim extra bytes since we may insert vlan proto & TCI > - * in tun_put_user(). > - */ > - len -= skb_vlan_tag_present(skb) ? sizeof(struct veth) : 0; > - if (len <= 0 || pskb_trim(skb, len)) > - goto drop; > - > if (unlikely(skb_orphan_frags_rx(skb, GFP_ATOMIC))) The VLAN business might be bogus, and needs to be removed. However, the pskb_trim() has to stay in some form. I think this is what Jason is trying to say. The semantics of running a BPF program is that the program returns the desired packet length. We must truncate the packet to the length returned by the BPF program, therefore.