Skip to contentSkip to conversation

netfilter: xt_SECMARK: add new revision to fix structure layout

PATCH Superseded Phil Sutter 2 participants 4 messages Apr 29, 2021 – Apr 30, 2021

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 netfilter: xt_SECMARK: add new revision to fix structure layout

From: Pablo Neira Ayuso <[email protected]>

This extension breaks when trying to delete rules, add a new revision to fix this.

Fixes 5e6874cdb8de ("[SECMARK]: Add xtables SECMARK target")

---
Formal submission of this patch which I received in private. Used it to implement user space side and thereby discovered a bug:
secmark_tg_check_v1() would not populate the legacy data structure with the 'secid' value initialized in the new data structure, thereby breaking functionality for old user space.

---
 include/uapi/linux/netfilter/xt_SECMARK.h |  6 ++
 net/netfilter/xt_SECMARK.c                | 87 ++++++++++++++++++-----
 2 files changed, 74 insertions(+), 19 deletions(-)
include/uapi/linux/netfilter/xt_SECMARK.h +6 -0
index 1f2a708413f5d..f412c87e675c1 100644
@@ -20,4 +20,10 @@ struct xt_secmark_target_info {
 	char secctx[SECMARK_SECCTX_MAX];
 };
 
+struct xt_secmark_tginfo {
+	__u8 mode;
+	char secctx[SECMARK_SECCTX_MAX];
+	__u32 secid;
+};
+
 #endif /*_XT_SECMARK_H_target */
net/netfilter/xt_SECMARK.c +68 -19

125 lines not on this page · raw message

Signature · 1 line
2.31.0
#1 lore raw
Quoted 9 lines · Phil Sutter

This extension breaks when trying to delete rules, add a new revision to fix this.

include/uapi/linux/netfilter/xt_SECMARK.h +0 -0
index 1f2a708413f5d..f412c87e675c1 100644

include/uapi/linux/netfilter/xt_SECMARK.h struct xt_secmark_target_info { · line 27

Quoted 8 lines
include/uapi/linux/netfilter/xt_SECMARK.h +5 -0
@@ -20,4 +20,10 @@ struct xt_secmark_target_info {
 	char secctx[SECMARK_SECCTX_MAX];
 };
 
+struct xt_secmark_tginfo {
+	__u8 mode;
+	char secctx[SECMARK_SECCTX_MAX];
+	__u32 secid;
+};

that should be struct xt_secmark_tginfo_v1.

include/uapi/linux/netfilter/xt_SECMARK.h struct xt_secmark_target_info {

Quoted 4 lines
include/uapi/linux/netfilter/xt_SECMARK.h +4 -0
+		.name		= "SECMARK",
+		.revision	= 1,
+		.family		= NFPROTO_UNSPEC,
+		.checkentry	= secmark_tg_check_v2,

Can't have revision=1 and then call it _v2. That's just confusing.

author reviewer
#2 lore raw

Hi Jan,

On Thu, Apr 29, 2021 at 05:11:49PM +0200, Jan Engelhardt wrote:
[...]

Quoted 7 lines

include/uapi/linux/netfilter/xt_SECMARK.h struct xt_secmark_target_info { · line 27

Quoted 5 lines
include/uapi/linux/netfilter/xt_SECMARK.h +5 -0
+struct xt_secmark_tginfo {
+	__u8 mode;
+	char secctx[SECMARK_SECCTX_MAX];
+	__u32 secid;
+};

that should be struct xt_secmark_tginfo_v1.

The v0 struct is called xt_secmark_target_info, I guess Pablo tried to shorten the name a bit. In conforming to "the standard", I'd then go with xt_secmark_target_info_v1 instead. Fine with you?

Quoted 6 lines

net/netfilter/xt_SECMARK.c static void secmark_tg_destroy(const struct xt_tgdtor_param *par) · line 170

Quoted 4 lines
net/netfilter/xt_SECMARK.c +4 -0
+		.name		= "SECMARK",
+		.revision	= 1,
+		.family		= NFPROTO_UNSPEC,
+		.checkentry	= secmark_tg_check_v2,

Can't have revision=1 and then call it _v2. That's just confusing.

ACK, I missed that.

Thanks, Phil

#3 lore raw
Quoted 10 lines · Phil Sutter

On Thu, Apr 29, 2021 at 05:11:49PM +0200, Jan Engelhardt wrote:
[...]

Quoted 7 lines

include/uapi/linux/netfilter/xt_SECMARK.h struct xt_secmark_target_info { · line 27

Quoted 5 lines
include/uapi/linux/netfilter/xt_SECMARK.h +5 -0
+struct xt_secmark_tginfo {
+	__u8 mode;
+	char secctx[SECMARK_SECCTX_MAX];
+	__u32 secid;
+};

that should be struct xt_secmark_tginfo_v1.

Quoted 3 lines

The v0 struct is called xt_secmark_target_info, I guess Pablo tried to shorten the name a bit. In conforming to "the standard", I'd then go with xt_secmark_target_info_v1 instead. Fine with you?

That's ok.

Quoted 5 lines
Quoted 3 lines

net/netfilter/xt_SECMARK.c static void secmark_tg_destroy(const struct xt_tgdtor_param *par) · line 170

Quoted 1 line
net/netfilter/xt_SECMARK.c +1 -0
+		.checkentry	= secmark_tg_check_v2,

Can't have revision=1 and then call it _v2. That's just confusing.

ACK, I missed that.