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: stable@vger.kernel.org, davem@davemloft.net
Subject: [-stable-3.8.y 3/9] netfilter: ipset: list:set: fix reference counter update
Date: Tue,  7 May 2013 01:05:22 +0200	[thread overview]
Message-ID: <1367881528-15524-3-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1367881528-15524-1-git-send-email-pablo@netfilter.org>

From: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>

The last element can be replaced or pushed off and in both
cases the reference counter must be updated.

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

[ git cherry-pick 02f815c ]
---
 net/netfilter/ipset/ip_set_list_set.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/net/netfilter/ipset/ip_set_list_set.c b/net/netfilter/ipset/ip_set_list_set.c
index 8371c2b..09c744a 100644
--- a/net/netfilter/ipset/ip_set_list_set.c
+++ b/net/netfilter/ipset/ip_set_list_set.c
@@ -174,9 +174,13 @@ list_set_add(struct list_set *map, u32 i, ip_set_id_t id,
 {
 	const struct set_elem *e = list_set_elem(map, i);
 
-	if (i == map->size - 1 && e->id != IPSET_INVALID_ID)
-		/* Last element replaced: e.g. add new,before,last */
-		ip_set_put_byindex(e->id);
+	if (e->id != IPSET_INVALID_ID) {
+		const struct set_elem *x = list_set_elem(map, map->size - 1);
+
+		/* Last element replaced or pushed off */
+		if (x->id != IPSET_INVALID_ID)
+			ip_set_put_byindex(x->id);
+	}
 	if (with_timeout(map->timeout))
 		list_elem_tadd(map, i, id, ip_set_timeout_set(timeout));
 	else
-- 
1.7.10.4

  parent reply	other threads:[~2013-05-06 23:05 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-06 23:05 [-stable-3.8.y 1/9] ipvs: ip_vs_sip_fill_param() BUG: bad check of return value Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 2/9] netfilter: nf_nat: fix race when unloading protocol modules Pablo Neira Ayuso
2013-05-06 23:05 ` Pablo Neira Ayuso [this message]
2013-05-06 23:05 ` [-stable-3.8.y 4/9] netfilter: nf_ct_sip: don't drop packets with offsets pointing outside the packet Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 5/9] netfilter: ipset: "Directory not empty" error message Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 6/9] netfilter: nf_ct_helper: don't discard helper if it is actually the same Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 7/9] netfilter: ctnetlink: don't permit ct creation with random tuple Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 8/9] netfilter: xt_rpfilter: skip locally generated broadcast/multicast, too Pablo Neira Ayuso
2013-05-06 23:05 ` [-stable-3.8.y 9/9] netfilter: ip6t_NPT: Fix translation for non-multiple of 32 prefix lengths Pablo Neira Ayuso
2013-05-08 22:36 ` [-stable-3.8.y 1/9] ipvs: ip_vs_sip_fill_param() BUG: bad check of return value Greg KH
2013-05-08 23:53   ` Pablo Neira Ayuso
2013-05-09 20:38     ` Greg KH

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=1367881528-15524-3-git-send-email-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=stable@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).