[PATCH 3.10 45/70] netfilter: nf_log: release skbuff on nlmsg put failure

From: Greg Kroah-Hartman
Date: Wed Nov 19 2014 - 16:18:44 EST

3.10-stable review patch. If anyone has any objections, please let me know.


From: Houcheng Lin <houcheng@xxxxxxxxx>

commit b51d3fa364885a2c1e1668f88776c67c95291820 upstream.

The kernel should reserve enough room in the skb so that the DONE
message can always be appended. However, in case of e.g. new attribute
erronously not being size-accounted for, __nfulnl_send() will still
try to put next nlmsg into this full skbuf, causing the skb to be stuck
forever and blocking delivery of further messages.

Fix issue by releasing skb immediately after nlmsg_put error and
WARN() so we can track down the cause of such size mismatch.

[ fw@xxxxxxxxx: add tailroom/len info to WARN ]

Signed-off-by: Houcheng Lin <houcheng@xxxxxxxxx>
Signed-off-by: Florian Westphal <fw@xxxxxxxxx>
Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

net/netfilter/nfnetlink_log.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)

--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -348,26 +348,25 @@ nfulnl_alloc_skb(u32 peer_portid, unsign
return skb;

-static int
+static void
__nfulnl_send(struct nfulnl_instance *inst)
- int status = -1;
if (inst->qlen > 1) {
struct nlmsghdr *nlh = nlmsg_put(inst->skb, 0, 0,
sizeof(struct nfgenmsg),
- if (!nlh)
+ if (WARN_ONCE(!nlh, "bad nlskb size: %u, tailroom %d\n",
+ inst->skb->len, skb_tailroom(inst->skb))) {
+ kfree_skb(inst->skb);
goto out;
+ }
- status = nfnetlink_unicast(inst->skb, inst->net, inst->peer_portid,
+ nfnetlink_unicast(inst->skb, inst->net, inst->peer_portid,
inst->qlen = 0;
inst->skb = NULL;
- return status;

static void

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/