From: Alvaro Neira Ayuso <alvaroneay@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: kaber@trash.net
Subject: [nft PATCH v3] evaluate: fix a crash if we specify ether type or meta nfproto in reject
Date: Mon, 20 Oct 2014 15:32:09 +0200 [thread overview]
Message-ID: <1413811929-21955-1-git-send-email-alvaroneay@gmail.com> (raw)
If we use this rule:
nft add rule bridge filter input \
ether type ip reject with icmp type host-unreachable
or that:
nft add rule inet filter input \
meta nfproto ipv4 reject with icmp type host-unreachable
we have a segfault because we add a network dependency when we already have
network context.
Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
---
src/evaluate.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/evaluate.c b/src/evaluate.c
index d61d76b..1fec120 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -1142,7 +1142,7 @@ static int reject_payload_gen_dependency_tcp(struct eval_ctx *ctx,
return 0;
*payload = payload_expr_alloc(&stmt->location, &proto_tcp,
TCPHDR_UNSPEC);
- return 0;
+ return 1;
}
static int reject_payload_gen_dependency_family(struct eval_ctx *ctx,
@@ -1171,7 +1171,7 @@ static int reject_payload_gen_dependency_family(struct eval_ctx *ctx,
default:
BUG("unknown reject family");
}
- return 0;
+ return 1;
}
static int stmt_reject_gen_dependency(struct eval_ctx *ctx, struct stmt *stmt,
@@ -1179,21 +1179,21 @@ static int stmt_reject_gen_dependency(struct eval_ctx *ctx, struct stmt *stmt,
{
struct expr *payload = NULL;
struct stmt *nstmt;
+ int ret;
switch (stmt->reject.type) {
case NFT_REJECT_TCP_RST:
- if (reject_payload_gen_dependency_tcp(ctx, stmt, &payload) < 0)
- return -1;
+ ret = reject_payload_gen_dependency_tcp(ctx, stmt, &payload);
break;
case NFT_REJECT_ICMP_UNREACH:
- if (reject_payload_gen_dependency_family(ctx, stmt,
- &payload) < 0)
- return -1;
+ ret = reject_payload_gen_dependency_family(ctx, stmt, &payload);
break;
default:
BUG("cannot generate reject dependency for type %d",
stmt->reject.type);
}
+ if (ret <= 0)
+ return ret;
if (payload_gen_dependency(ctx, payload, &nstmt) < 0)
return -1;
--
1.7.10.4
next reply other threads:[~2014-10-20 13:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-20 13:32 Alvaro Neira Ayuso [this message]
2014-10-21 8:12 ` [nft PATCH v3] evaluate: fix a crash if we specify ether type or meta nfproto in reject Pablo Neira Ayuso
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=1413811929-21955-1-git-send-email-alvaroneay@gmail.com \
--to=alvaroneay@gmail.com \
--cc=kaber@trash.net \
--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).