netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: [PATCH 2/6] netfilter: nf_tables: fix wrong transaction ordering in set elements
Date: Thu,  5 Jun 2014 17:08:22 +0200	[thread overview]
Message-ID: <1401980906-25290-3-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1401980906-25290-1-git-send-email-pablo@netfilter.org>

The transaction needs to be placed at the end of the commit list,
otherwise event notifications are reordered and we may crash when
releasing object via call_rcu.

This problem was introduced in 60319eb ("netfilter: nf_tables: use new
transaction infrastructure to handle elements").

Reported-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nf_tables_api.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 0478847..9365531 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -3077,7 +3077,7 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,
 		goto err4;
 
 	nft_trans_elem(trans) = elem;
-	list_add(&trans->list, &ctx->net->nft.commit_list);
+	list_add_tail(&trans->list, &ctx->net->nft.commit_list);
 	return 0;
 
 err4:
@@ -3161,7 +3161,7 @@ static int nft_del_setelem(struct nft_ctx *ctx, struct nft_set *set,
 		goto err2;
 
 	nft_trans_elem(trans) = elem;
-	list_add(&trans->list, &ctx->net->nft.commit_list);
+	list_add_tail(&trans->list, &ctx->net->nft.commit_list);
 
 	nft_data_uninit(&elem.key, NFT_DATA_VALUE);
 	if (set->flags & NFT_SET_MAP)
-- 
1.7.10.4

  parent reply	other threads:[~2014-06-05 15:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-05 15:08 [PATCH 0/6] Netfilter/nf_tables fixes for net-next Pablo Neira Ayuso
2014-06-05 15:08 ` [PATCH 1/6] netfilter: nfnetlink_acct: Fix memory leak Pablo Neira Ayuso
2014-06-05 15:08 ` Pablo Neira Ayuso [this message]
2014-06-05 15:08 ` [PATCH 3/6] netfilter: nf_tables: release objects in reverse order in the abort path Pablo Neira Ayuso
2014-06-05 15:08 ` [PATCH 4/6] netfilter: nft_rbtree: introduce locking Pablo Neira Ayuso
2014-06-05 15:08 ` [PATCH 5/6] netfilter: nf_tables: allow to delete several objects from a batch Pablo Neira Ayuso
2014-06-05 15:08 ` [PATCH 6/6] netfilter: nf_tables: atomic allocation in set notifications from rcu callback Pablo Neira Ayuso
2014-06-05 22:35 ` [PATCH 0/6] Netfilter/nf_tables fixes for net-next David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1401980906-25290-3-git-send-email-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).