nfqnl_mangle() replaces the skb with skb_copy_expand() when a verdict grows a packet beyond its tailroom. skb_copy_expand() does not copy skb->sk, so the replacement is unowned and freeing the original drops its socket memory charge. The expanded packet is no longer associated with the process that sent it. Therefore xt_owner or xt_cgroup and other socket based matches in later rules no longer matches and a later NFQUEUE reports no uid/gid. In addition, the expanded packet's memory is not counted towards the sender's SO_SNDBUF limit, so the sender can keep producing them while they sit in a queue. Fix this by transferring ownership before freeing the original as skb_cow_data() an skb_expand_head() do. Fixes: e2b58a67b91d ("[NETFILTER]: {ip,ip6,nfnetlink}_queue: fix SKB_LINEAR_ASSERT when mangling packet data") Reported-by: VEGA Signed-off-by: Fernando Fernandez Mancera --- net/netfilter/nfnetlink_queue.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c index 90d887546f7d..fe3b9ce7acb0 100644 --- a/net/netfilter/nfnetlink_queue.c +++ b/net/netfilter/nfnetlink_queue.c @@ -1459,6 +1459,8 @@ nfqnl_mangle(void *data, unsigned int data_len, struct nf_queue_entry *e, int di diff, GFP_ATOMIC); if (!nskb) return -ENOMEM; + if (e->skb->sk) + skb_set_owner_w(nskb, e->skb->sk); kfree_skb(e->skb); e->skb = nskb; } -- 2.56.0