Skip to content

Commit

Permalink
netfilter: nft_socket: fix erroneous socket assignment
Browse files Browse the repository at this point in the history
The socket assignment is wrong, see skb_orphan():
When skb->destructor callback is not set, but skb->sk is set, this hits BUG().

Link: https://bugzilla.redhat.com/show_bug.cgi?id=1651813
Fixes: 554ced0 ("netfilter: nf_tables: add support for native socket matching")
Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
ffmancera authored and ummakynes committed Sep 2, 2019
1 parent 48bd0d6 commit 039b1f4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions net/netfilter/nft_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ static void nft_socket_eval(const struct nft_expr *expr,
return;
}

/* So that subsequent socket matching not to require other lookups. */
skb->sk = sk;

switch(priv->key) {
case NFT_SOCKET_TRANSPARENT:
nft_reg_store8(dest, inet_sk_transparent(sk));
Expand All @@ -66,6 +63,9 @@ static void nft_socket_eval(const struct nft_expr *expr,
WARN_ON(1);
regs->verdict.code = NFT_BREAK;
}

if (sk != skb->sk)
sock_gen_put(sk);
}

static const struct nla_policy nft_socket_policy[NFTA_SOCKET_MAX + 1] = {
Expand Down

0 comments on commit 039b1f4

Please sign in to comment.