From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: [PATCH 5/8] netfilter: ipset: Null pointer exception in ipset list:set
Date: Thu, 23 Feb 2017 12:14:06 +0100 [thread overview]
Message-ID: <1487848449-2731-6-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1487848449-2731-1-git-send-email-pablo@netfilter.org>
From: Vishwanath Pai <vpai@akamai.com>
If we use before/after to add an element to an empty list it will cause
a kernel panic.
$> cat crash.restore
create a hash:ip
create b hash:ip
create test list:set timeout 5 size 4
add test b before a
$> ipset -R < crash.restore
Executing the above will crash the kernel.
Signed-off-by: Vishwanath Pai <vpai@akamai.com>
Reviewed-by: Josh Hunt <johunt@akamai.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
---
net/netfilter/ipset/ip_set_list_set.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/net/netfilter/ipset/ip_set_list_set.c b/net/netfilter/ipset/ip_set_list_set.c
index 51077c53d76b..178d4eba013b 100644
--- a/net/netfilter/ipset/ip_set_list_set.c
+++ b/net/netfilter/ipset/ip_set_list_set.c
@@ -260,11 +260,14 @@ list_set_uadd(struct ip_set *set, void *value, const struct ip_set_ext *ext,
else
prev = e;
}
+
+ /* If before/after is used on an empty set */
+ if ((d->before > 0 && !next) ||
+ (d->before < 0 && !prev))
+ return -IPSET_ERR_REF_EXIST;
+
/* Re-add already existing element */
if (n) {
- if ((d->before > 0 && !next) ||
- (d->before < 0 && !prev))
- return -IPSET_ERR_REF_EXIST;
if (!flag_exist)
return -IPSET_ERR_EXIST;
/* Update extensions */
--
2.1.4
next prev parent reply other threads:[~2017-02-23 11:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-23 11:14 [PATCH 0/8] Netfilter fixes for net Pablo Neira Ayuso
2017-02-23 11:14 ` [PATCH 1/8] netfilter: nf_ct_helper: warn when not applying default helper assignment Pablo Neira Ayuso
2017-02-23 11:14 ` [PATCH 2/8] netfilter: ctnetlink: Fix regression in CTA_STATUS processing Pablo Neira Ayuso
2017-02-23 11:14 ` [PATCH 3/8] netfilter: ctnetlink: Fix regression in CTA_HELP processing Pablo Neira Ayuso
2017-02-23 11:14 ` [PATCH 4/8] Fix bug: sometimes valid entries in hash:* types of sets were evicted Pablo Neira Ayuso
2017-02-23 11:14 ` Pablo Neira Ayuso [this message]
2017-02-23 11:14 ` [PATCH 6/8] netfilter: xt_hashlimit: Fix integer divide round to zero Pablo Neira Ayuso
2017-02-23 11:14 ` [PATCH 7/8] netfilter: nfnetlink_queue: fix NFQA_VLAN_MAX definition Pablo Neira Ayuso
2017-02-23 11:14 ` [PATCH 8/8] netfilter: nfnetlink: remove static declaration from err_list Pablo Neira Ayuso
2017-02-23 16:00 ` [PATCH 0/8] Netfilter fixes for net 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=1487848449-2731-6-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).