netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: "Álvaro Neira Ayuso" <alvaroneay@gmail.com>
Cc: netfilter-devel@vger.kernel.org, kaber@trash.net
Subject: Re: [nft PATCH 2/4 v2] evaluate: fix a crash if we check the transport protocol
Date: Mon, 20 Oct 2014 11:46:47 +0200	[thread overview]
Message-ID: <20141020094647.GA5804@salvia> (raw)
In-Reply-To: <5444D881.6000306@gmail.com>

On Mon, Oct 20, 2014 at 11:40:17AM +0200, Álvaro Neira Ayuso wrote:
> El 20/10/14 10:59, Pablo Neira Ayuso escribió:
> >On Fri, Oct 17, 2014 at 02:24:35PM +0200, Alvaro Neira Ayuso wrote:
> >>Example:
> >>
> >>nft add rule inet filter input meta l4proto udp reject with tcp reset
> >>
> >>When we check if the transport protocol is tcp, we use the network context.
> >>If we don't have this network context, we have a crash.
> >>
> >>Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
> >>---
> >>[no changes in v2]
> >>
> >>  src/evaluate.c |    7 +++++++
> >>  1 file changed, 7 insertions(+)
> >>
> >>diff --git a/src/evaluate.c b/src/evaluate.c
> >>index 4b7bda9..2f71e9b 100644
> >>--- a/src/evaluate.c
> >>+++ b/src/evaluate.c
> >>@@ -1339,6 +1339,13 @@ static int stmt_evaluate_reset(struct eval_ctx *ctx, struct stmt *stmt)
> >>  	if (desc == NULL)
> >>  		return 0;
> >>
> >>+	if (base == NULL) {
> >>+		if (strcmp(desc->name, "tcp") == 0)
> >>+			return 0;
> >>+		else
> >>+			return stmt_error(ctx, stmt,
> >>+				 "you cannot use tcp reset with this protocol");
> >>+	}
> >
> >Can you give a try to this?
> >
> >         if (base == NULL &&
> >             ctx->table.handle.family == NFPROTO_INET)
> >                 base = &proto_inet_service;
> 
> It works. That was another solution that I thought. But we don't
> need to compare the family because the base can be NULL only with
> Inet and Bridge tables.

OK, but better you still check for bridge and inet there. We may
introduce changes later on that may easily break this code because of
this assumption.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2014-10-20  9:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-17 12:24 [nft PATCH 1/4 v2] evaluate: fix a crash if we specify ether type or meta nfproto in reject Alvaro Neira Ayuso
2014-10-17 12:24 ` [nft PATCH 2/4 v2] evaluate: fix a crash if we check the transport protocol Alvaro Neira Ayuso
2014-10-20  8:59   ` Pablo Neira Ayuso
2014-10-20  9:40     ` Álvaro Neira Ayuso
2014-10-20  9:46       ` Pablo Neira Ayuso [this message]
2014-10-20  9:50         ` Álvaro Neira Ayuso
2014-10-17 12:24 ` [nft PATCH 3/4 v2] delinearize: list the icmpx reason with the string associated Alvaro Neira Ayuso
2014-10-17 12:58   ` Pablo Neira Ayuso
2014-10-17 12:24 ` [nft PATCH 4/4 v2] test: update and add the reject tests for ip, ip6, bridge and inet Alvaro Neira Ayuso
2014-10-17 12:55 ` [nft PATCH 1/4 v2] evaluate: fix a crash if we specify ether type or meta nfproto in reject Pablo Neira Ayuso
2014-10-17 13:02   ` Álvaro Neira Ayuso
2014-10-17 13:38     ` Pablo Neira Ayuso
2014-10-17 13:44       ` Álvaro 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=20141020094647.GA5804@salvia \
    --to=pablo@netfilter.org \
    --cc=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).