From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: [iptables PATCH 3/3] libxt_SECMARK: Fix for failing target comparison
Date: Tue, 12 May 2020 19:10:18 +0200 [thread overview]
Message-ID: <20200512171018.16871-4-phil@nwl.cc> (raw)
In-Reply-To: <20200512171018.16871-1-phil@nwl.cc>
The kernel fills in structxt_secmark_target_info->secid, so when the
rule is received from kernel it won't match a newly created one. This
prevented delete by rulespec and check commands.
Make use of newly introduced matchmask callback to prepare a mask which
explicitly excludes the secid field.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
extensions/libxt_SECMARK.c | 10 ++++++++++
extensions/libxt_SECMARK.t | 4 ++++
2 files changed, 14 insertions(+)
create mode 100644 extensions/libxt_SECMARK.t
diff --git a/extensions/libxt_SECMARK.c b/extensions/libxt_SECMARK.c
index 6ba8606355daa..e9fd133642f00 100644
--- a/extensions/libxt_SECMARK.c
+++ b/extensions/libxt_SECMARK.c
@@ -6,6 +6,7 @@
* Copyright (C) 2006 Red Hat, Inc., James Morris <jmorris@redhat.com>
*/
#include <stdio.h>
+#include <string.h>
#include <xtables.h>
#include <linux/netfilter/xt_SECMARK.h>
@@ -68,6 +69,14 @@ static void SECMARK_save(const void *ip, const struct xt_entry_target *target)
print_secmark(info);
}
+static void SECMARK_matchmask(void *mask)
+{
+ struct xt_secmark_target_info *info = mask;
+
+ memset(mask, 0xFF, XT_ALIGN(sizeof(struct xt_secmark_target_info)));
+ info->secid = 0;
+}
+
static struct xtables_target secmark_target = {
.family = NFPROTO_UNSPEC,
.name = "SECMARK",
@@ -80,6 +89,7 @@ static struct xtables_target secmark_target = {
.save = SECMARK_save,
.x6_parse = SECMARK_parse,
.x6_options = SECMARK_opts,
+ .matchmask = SECMARK_matchmask,
};
void _init(void)
diff --git a/extensions/libxt_SECMARK.t b/extensions/libxt_SECMARK.t
new file mode 100644
index 0000000000000..39d4c09348bf4
--- /dev/null
+++ b/extensions/libxt_SECMARK.t
@@ -0,0 +1,4 @@
+:INPUT,FORWARD,OUTPUT
+*security
+-j SECMARK --selctx system_u:object_r:firewalld_exec_t:s0;=;OK
+-j SECMARK;;FAIL
--
2.25.1
next prev parent reply other threads:[~2020-05-12 17:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-12 17:10 [iptables PATCH 0/3] Fix SECMARK target comparison Phil Sutter
2020-05-12 17:10 ` [iptables PATCH 1/3] xshared: Share make_delete_mask() between ip{,6}tables Phil Sutter
2020-05-12 17:10 ` [iptables PATCH 2/3] libxtables: Introduce 'matchmask' target callback Phil Sutter
2020-05-12 17:10 ` Phil Sutter [this message]
2020-05-14 12:23 ` [iptables PATCH 0/3] Fix SECMARK target comparison Pablo Neira Ayuso
2020-05-14 13:09 ` Phil Sutter
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=20200512171018.16871-4-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).