xtables: symmetric COMPAT_XT_ALIGN definition
Subsystems (2)
PATCH 1/1 xtables: symmetric COMPAT_XT_ALIGN definition
Rewrite COMPAT_XT_ALIGN in terms of dummy structure hack. Compat counters logically have nothing to do with it. Use ALIGN() macro while I'm at it for same types.
---
include/linux/netfilter/x_tables.h | 13 +++++++++---- net/netfilter/x_tables.c | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-)
include/linux/netfilter/x_tables.h +9 -4
@@ -93,8 +93,7 @@ struct _xt_align {__u64 u64; }; -#define XT_ALIGN (s) (((s) + (__alignof__(struct _xt_align)-1)) \ - & ~(__alignof__(struct _xt_align)-1)) +#define XT_ALIGN (s) ALIGN((s), __alignof__(struct _xt_align))/* Standard return verdict, or do jump. */ #define XT_STANDARD_TARGET ""
@@ -571,8 +570,14 @@ struct compat_xt_counters_info {struct compat_xt_counters counters[0 ]; }; -#define COMPAT_XT_ALIGN (s) (((s) + (__alignof__(struct compat_xt_counters)-1)) \ - & ~(__alignof__(struct compat_xt_counters)-1)) +struct _compat_xt_align { +__u8 u8; +__u16 u16; +__u32 u32; +compat_u64 u64; +}; + +#define COMPAT_XT_ALIGN (s) ALIGN((s), __alignof__(struct _compat_xt_align))extern void xt_compat_lock (u_int8_t af);extern void xt_compat_unlock (u_int8_t af);
net/netfilter/x_tables.c +2 -2
@@ -364,7 +364,7 @@ int xt_check_match(struct xt_mtchk_param *par,* ebt_among is exempt from centralized matchsize checking * because it uses a dynamic-size data set. */ -pr_err ("%s_tables: %s match: invalid size %Zu != %u\n" , +pr_err ("%s_tables: %s match: invalid size %u != %u\n" , xt_prefix[par->family], par->match->name,XT_ALIGN (par->match->matchsize), size);return -EINVAL ;
@@ -514,7 +514,7 @@ int xt_check_target(struct xt_tgchk_param *par, unsigned int size, u_int8_t proto, bool inv_proto) { if (XT_ALIGN(par->target->targetsize) != size) { - pr_err("%s_tables: %s target: invalid size %Zu != %u\n", + pr_err("%s_tables: %s target: invalid size %u != %u\n", xt_prefix[par->family], par->target->name, XT_ALIGN(par->target->targetsize), size);return -EINVAL ;
Quoted 14 lines · Alexey Dobriyan
Rewrite
COMPAT_XT_ALIGNin terms of dummy structure hack. Compat counters logically have nothing to do with it. UseALIGN()macro while I'm at it for same types.net/netfilter/x_tables.c +1
-1@@ -514,7 +514,7 @@ int xt_check_target(struct xt_tgchk_param *par, unsigned int size, u_int8_t proto, bool inv_proto) { if (XT_ALIGN(par->target->targetsize) != size) { - pr_err("%s_tables: %s target: invalid size %Zu != %u\n", + pr_err("%s_tables: %s target: invalid size %u != %u\n", xt_prefix[par->family], par->target->name, XT_ALIGN(par->target->targetsize), size);return -EINVAL ;
net/netfilter/x_tables.c int xt_check_match(struct xt_mtchk_param *par, · line 370
Quoted 8 lines
net/netfilter/x_tables.c +1
-1@@ -364,7 +364,7 @@ int xt_check_match(struct xt_mtchk_param *par,* ebt_among is exempt from centralized matchsize checking * because it uses a dynamic-size data set. */ -pr_err ("%s_tables: %s match: invalid size %Zu != %u\n" , +pr_err ("%s_tables: %s match: invalid size %u != %u\n" , xt_prefix[par->family], par->match->name,XT_ALIGN (par->match->matchsize), size);return -EINVAL ;
Why are you changing this? __alignof__ still returns a size_t, and this type promotes through the course of the ALIGN macro.
Quoted 14 lines · Jan Engelhardt
Quoted 13 lines · Alexey Dobriyan
net/netfilter/x_tables.c +1
-1@@ -514,7 +514,7 @@ int xt_check_target(struct xt_tgchk_param *par, unsigned int size, u_int8_t proto, bool inv_proto) { if (XT_ALIGN(par->target->targetsize) != size) { - pr_err("%s_tables: %s target: invalid size %Zu != %u\n", + pr_err("%s_tables: %s target: invalid size %u != %u\n", xt_prefix[par->family], par->target->name, XT_ALIGN(par->target->targetsize), size);return -EINVAL ;@@ -364,7 +364,7 @@ int xt_check_match(struct xt_mtchk_param *par,* ebt_among is exempt from centralized matchsize checking * because it uses a dynamic-size data set. */
Quoted 8 lines
net/netfilter/x_tables.c int xt_check_match(struct xt_mtchk_param *par, · line 370
Quoted 5 lines
net/netfilter/x_tables.c +1
-1-pr_err ("%s_tables: %s match: invalid size %Zu != %u\n" , +pr_err ("%s_tables: %s match: invalid size %u != %u\n" , xt_prefix[par->family], par->match->name,XT_ALIGN (par->match->matchsize), size);return -EINVAL ;Why are you changing this?
__alignof__still returns asize_t, and this type promotes through the course of the ALIGN macro.
alignment is casted to the type of alignee, so it's unsigned int now:
#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
Quoted 3 lines · Alexey Dobriyan
Rewrite
COMPAT_XT_ALIGNin terms of dummy structure hack. Compat counters logically have nothing to do with it. UseALIGN()macro while I'm at it for same types.
Also applied, thanks.