All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Sowden <jeremy@azazel.net>
To: Florian Westphal <fw@strlen.de>
Cc: Netfilter Devel <netfilter-devel@vger.kernel.org>
Subject: Re: [PATCH nft 2/2] segtree: fix decomposition of unclosed intervals containing address prefixes
Date: Wed, 21 Sep 2022 20:46:15 +0100	[thread overview]
Message-ID: <YytqB90MypDn7gHr@azazel.net> (raw)
In-Reply-To: <Yyr6C+IKMrCM0hQJ@strlen.de>

[-- Attachment #1: Type: text/plain, Size: 1861 bytes --]

On 2022-09-21, at 13:48:27 +0200, Florian Westphal wrote:
> Jeremy Sowden <jeremy@azazel.net> wrote:
> > @@ -619,24 +622,12 @@ void interval_map_decompose(struct expr *set)
> >
> >  	if (!mpz_cmp(i->value, expr_value(low)->value)) {
> >  		expr_free(i);
> > -		i = low;
> > +		compound_expr_add(set, low);
> >  	} else {
> > -		i = range_expr_alloc(&low->location,
> > -				     expr_clone(expr_value(low)), i);
> > -		i = set_elem_expr_alloc(&low->location, i);
> > -		if (low->etype == EXPR_MAPPING) {
> > -			i = mapping_expr_alloc(&i->location, i,
> > -					       expr_clone(low->right));
> > -			interval_expr_copy(i->left, low->left);
> > -		} else {
> > -			interval_expr_copy(i, low);
> > -		}
> > -		i->flags |= EXPR_F_KERNEL;
> > -
> > +		add_interval(set, low, i);
> >  		expr_free(low);
> >  	}
> >
> > -	compound_expr_add(set, i);
>
> This results in a memory leak:
>
> __interceptor_malloc libsanitizer/asan/asan_malloc_linux.cpp:145
> xmalloc src/utils.c:36
> xzalloc src/utils.c:75
> expr_alloc src/expression.c:46
> constant_expr_alloc src/expression.c:420
> interval_map_decompose src/segtree.c:619

I did try running the new shell test under valgrind: lots of noise, not
a lot of signal. :)

> Before, 'i' was assigned to the compund expr, but thats no longer the
> case.

> Does this look good to you?

Yes, LTGM.

> If so, I will sqash this before applying:
>
> diff --git a/src/segtree.c b/src/segtree.c
> --- a/src/segtree.c
> +++ b/src/segtree.c
> @@ -621,13 +621,14 @@ void interval_map_decompose(struct expr *set)
>  	mpz_bitmask(i->value, i->len);
>
>  	if (!mpz_cmp(i->value, expr_value(low)->value)) {
> -		expr_free(i);
>  		compound_expr_add(set, low);
>  	} else {
>  		add_interval(set, low, i);
>  		expr_free(low);
>  	}
>
> +	expr_free(i);
> +
>  out:
>  	if (catchall)
>  		compound_expr_add(set, catchall);
>

Thanks,

J.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2022-09-21 19:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-18 17:22 [PATCH nft 0/2] Fix listing of sets containing unclosed address prefix intervals Jeremy Sowden
2022-09-18 17:22 ` [PATCH nft 1/2] segtree: refactor decomposition of closed intervals Jeremy Sowden
2022-09-18 17:22 ` [PATCH nft 2/2] segtree: fix decomposition of unclosed intervals containing address prefixes Jeremy Sowden
2022-09-21 11:48   ` Florian Westphal
2022-09-21 19:46     ` Jeremy Sowden [this message]
2022-09-21 20:26       ` Florian Westphal
2022-09-18 21:02 ` [PATCH nft 0/2] Fix listing of sets containing unclosed address prefix intervals Jeremy Sowden

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=YytqB90MypDn7gHr@azazel.net \
    --to=jeremy@azazel.net \
    --cc=fw@strlen.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.