Commit bec60b44 authored by Liping Zhang's avatar Liping Zhang Committed by Greg Kroah-Hartman

netfilter: nfnetlink_queue: fix secctx memory leak


[ Upstream commit 77c1c03c ]

We must call security_release_secctx to free the memory returned by
security_secid_to_secctx, otherwise memory may be leaked forever.

Fixes: ef493bd9 ("netfilter: nfnetlink_queue: add security context information")
Signed-off-by: default avatarLiping Zhang <zlpnobody@gmail.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ff1ddbb3
...@@ -390,7 +390,7 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue, ...@@ -390,7 +390,7 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue,
GFP_ATOMIC); GFP_ATOMIC);
if (!skb) { if (!skb) {
skb_tx_error(entskb); skb_tx_error(entskb);
return NULL; goto nlmsg_failure;
} }
nlh = nlmsg_put(skb, 0, 0, nlh = nlmsg_put(skb, 0, 0,
...@@ -399,7 +399,7 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue, ...@@ -399,7 +399,7 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue,
if (!nlh) { if (!nlh) {
skb_tx_error(entskb); skb_tx_error(entskb);
kfree_skb(skb); kfree_skb(skb);
return NULL; goto nlmsg_failure;
} }
nfmsg = nlmsg_data(nlh); nfmsg = nlmsg_data(nlh);
nfmsg->nfgen_family = entry->state.pf; nfmsg->nfgen_family = entry->state.pf;
...@@ -542,12 +542,17 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue, ...@@ -542,12 +542,17 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue,
} }
nlh->nlmsg_len = skb->len; nlh->nlmsg_len = skb->len;
if (seclen)
security_release_secctx(secdata, seclen);
return skb; return skb;
nla_put_failure: nla_put_failure:
skb_tx_error(entskb); skb_tx_error(entskb);
kfree_skb(skb); kfree_skb(skb);
net_err_ratelimited("nf_queue: error creating packet message\n"); net_err_ratelimited("nf_queue: error creating packet message\n");
nlmsg_failure:
if (seclen)
security_release_secctx(secdata, seclen);
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment