netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Oester <kernel@linuxace.com>
To: netfilter-devel@vger.kernel.org
Cc: pablo@netfilter.org
Subject: [PATCH] nft: nft_set_attr_get_u32 null pointer deref
Date: Fri, 25 Oct 2013 09:55:31 -0700	[thread overview]
Message-ID: <20131025165531.GA18336@home> (raw)

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

As reported by John Sager, nft_set_attr_get_u32 can cause a segfault because
nft_set_attr_get can return NULL.  Check for a non-NULL pointer before
dereferencing.

This closes netfilter bugzilla #868.

Signed-off-by: Phil Oester <kernel@linuxace.com>


[-- Attachment #2: patch-get_u32 --]
[-- Type: text/plain, Size: 424 bytes --]

diff --git a/src/set.c b/src/set.c
index 74ec1e3..85f73cf 100644
--- a/src/set.c
+++ b/src/set.c
@@ -183,8 +183,8 @@ EXPORT_SYMBOL(nft_set_attr_get_str);
 
 uint32_t nft_set_attr_get_u32(struct nft_set *s, uint16_t attr)
 {
-	uint32_t val = *((uint32_t *)nft_set_attr_get(s, attr));
-	return val;
+	const void *val = nft_set_attr_get(s, attr);
+	return val ? *(uint32_t *)val : 0;
 }
 EXPORT_SYMBOL(nft_set_attr_get_u32);
 

             reply	other threads:[~2013-10-25 16:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-25 16:55 Phil Oester [this message]
2013-10-27 20:34 ` [PATCH] nft: nft_set_attr_get_u32 null pointer deref Pablo Neira Ayuso
2013-10-27 23:29   ` Phil Oester

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=20131025165531.GA18336@home \
    --to=kernel@linuxace.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.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).