netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: [nft PATCH 2/3] monitor: Fix for use after free when printing map elements
Date: Fri, 10 Jan 2020 12:11:13 +0100	[thread overview]
Message-ID: <20200110111114.23952-3-phil@nwl.cc> (raw)
In-Reply-To: <20200110111114.23952-1-phil@nwl.cc>

When populating the dummy set, 'data' field must be cloned just like
'key' field.

Fixes: 343a51702656a ("src: store expr, not dtype to track data in sets")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 src/monitor.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/monitor.c b/src/monitor.c
index 84505eb914bf6..53a8bcd4641d1 100644
--- a/src/monitor.c
+++ b/src/monitor.c
@@ -401,7 +401,8 @@ static int netlink_events_setelem_cb(const struct nlmsghdr *nlh, int type,
 	 */
 	dummyset = set_alloc(monh->loc);
 	dummyset->key = expr_clone(set->key);
-	dummyset->data = set->data;
+	if (set->data)
+		dummyset->data = expr_clone(set->data);
 	dummyset->flags = set->flags;
 	dummyset->init = set_expr_alloc(monh->loc, set);
 
-- 
2.24.1


  parent reply	other threads:[~2020-01-10 11:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-10 11:11 [nft PATCH 0/3] Fixes for monitor/echo mode with maps Phil Sutter
2020-01-10 11:11 ` [nft PATCH 1/3] monitor: Do not decompose non-anonymous sets Phil Sutter
2020-01-10 11:20   ` Pablo Neira Ayuso
2020-01-10 11:11 ` Phil Sutter [this message]
2020-01-10 11:21   ` [nft PATCH 2/3] monitor: Fix for use after free when printing map elements Pablo Neira Ayuso
2020-01-10 11:11 ` [nft PATCH 3/3] tests: monitor: Support running individual test cases Phil Sutter
2020-01-10 11:21   ` 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=20200110111114.23952-3-phil@nwl.cc \
    --to=phil@nwl.cc \
    --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).