netfilter: xt_SECMARK: add new revision to fix structure layout
Subsystems (3)
Phil Sutter
reviewerPATCH 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.
---
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
@@ -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
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
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.
Phil Sutter
reviewerHi 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
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 withxt_secmark_target_info_v1instead. 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.