All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Phil Sutter <phil@nwl.cc>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [nft PATCH 2/4] netlink_delinearize: Avoid potential null pointer deref
Date: Wed, 17 Aug 2016 16:46:18 +0200	[thread overview]
Message-ID: <20160817144618.GB10362@salvia> (raw)
In-Reply-To: <1471017610-3473-3-git-send-email-phil@nwl.cc>

On Fri, Aug 12, 2016 at 06:00:08PM +0200, Phil Sutter wrote:
> As netlink_get_register() may return NULL, we must not pass the returned
> data unchecked to expr_set_type() as that will dereference it. Since the
> parser has failed at that point anyway, by returning early we can skip
> the useless statement allocation that follows in
> netlink_parse_ct_stmt().
> 
> Signed-off-by: Phil Sutter <phil@nwl.cc>
> ---
>  src/netlink_delinearize.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/netlink_delinearize.c b/src/netlink_delinearize.c
> index 12d0b4a277795..6ac2e9690fd39 100644
> --- a/src/netlink_delinearize.c
> +++ b/src/netlink_delinearize.c
> @@ -518,6 +518,8 @@ static void netlink_parse_ct_stmt(struct netlink_parse_ctx *ctx,
>  
>  	sreg = netlink_parse_register(nle, NFTNL_EXPR_CT_SREG);
>  	expr = netlink_get_register(ctx, loc, sreg);
> +	if (!expr)
> +		return;

I would add a netlink_error() by here too.

I can see more spots with this problem, would you send us a patch to
resolve the multiple reincarnations of this problem in one go?

Thanks!

  reply	other threads:[~2016-08-17 14:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-12 16:00 [nft PATCH 0/4] A round of covscan indicated fixes Phil Sutter
2016-08-12 16:00 ` [nft PATCH 1/4] evaluate: Fix datalen checks in expr_evaluate_string() Phil Sutter
2016-08-17 14:41   ` Pablo Neira Ayuso
2016-08-12 16:00 ` [nft PATCH 2/4] netlink_delinearize: Avoid potential null pointer deref Phil Sutter
2016-08-17 14:46   ` Pablo Neira Ayuso [this message]
2016-08-12 16:00 ` [nft PATCH 3/4] proto_find_num: Avoid potential null pointer dereference Phil Sutter
2016-08-17 14:47   ` Pablo Neira Ayuso
2016-08-12 16:00 ` [nft PATCH 4/4] evaluate: Avoid undefined behaviour in concat_subtype_id() Phil Sutter
2016-08-17 14:51   ` 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=20160817144618.GB10362@salvia \
    --to=pablo@netfilter.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=phil@nwl.cc \
    /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.