diff options
author | Willem de Bruijn <willemb@google.com> | 2017-05-17 11:24:47 -0400 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2017-05-18 07:10:03 -0400 |
commit | 751a9c763849f5859cb69ea44b0430d00672f637 (patch) | |
tree | efbea6658744764f2ca567bfe0a9481ac6b55578 | |
parent | c953d63548207a085abcb12a15fefc8a11ffdf0a (diff) |
netfilter: xtables: fix build failure from COMPAT_XT_ALIGN outside CONFIG_COMPAT
The patch in the Fixes references COMPAT_XT_ALIGN in the definition
of XT_DATA_TO_USER, outside an #ifdef CONFIG_COMPAT block.
Split XT_DATA_TO_USER into separate compat and non compat variants and
define the first inside an CONFIG_COMPAT block.
This simplifies both variants by removing branches inside the macro.
Fixes: 324318f0248c ("netfilter: xtables: zero padding in data_to_user")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r-- | net/netfilter/x_tables.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index d17769599c10..1770c1d9b37f 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c | |||
@@ -296,18 +296,17 @@ int xt_data_to_user(void __user *dst, const void *src, | |||
296 | } | 296 | } |
297 | EXPORT_SYMBOL_GPL(xt_data_to_user); | 297 | EXPORT_SYMBOL_GPL(xt_data_to_user); |
298 | 298 | ||
299 | #define XT_DATA_TO_USER(U, K, TYPE, C_SIZE) \ | 299 | #define XT_DATA_TO_USER(U, K, TYPE) \ |
300 | xt_data_to_user(U->data, K->data, \ | 300 | xt_data_to_user(U->data, K->data, \ |
301 | K->u.kernel.TYPE->usersize, \ | 301 | K->u.kernel.TYPE->usersize, \ |
302 | C_SIZE ? : K->u.kernel.TYPE->TYPE##size, \ | 302 | K->u.kernel.TYPE->TYPE##size, \ |
303 | C_SIZE ? COMPAT_XT_ALIGN(C_SIZE) : \ | 303 | XT_ALIGN(K->u.kernel.TYPE->TYPE##size)) |
304 | XT_ALIGN(K->u.kernel.TYPE->TYPE##size)) | ||
305 | 304 | ||
306 | int xt_match_to_user(const struct xt_entry_match *m, | 305 | int xt_match_to_user(const struct xt_entry_match *m, |
307 | struct xt_entry_match __user *u) | 306 | struct xt_entry_match __user *u) |
308 | { | 307 | { |
309 | return XT_OBJ_TO_USER(u, m, match, 0) || | 308 | return XT_OBJ_TO_USER(u, m, match, 0) || |
310 | XT_DATA_TO_USER(u, m, match, 0); | 309 | XT_DATA_TO_USER(u, m, match); |
311 | } | 310 | } |
312 | EXPORT_SYMBOL_GPL(xt_match_to_user); | 311 | EXPORT_SYMBOL_GPL(xt_match_to_user); |
313 | 312 | ||
@@ -315,7 +314,7 @@ int xt_target_to_user(const struct xt_entry_target *t, | |||
315 | struct xt_entry_target __user *u) | 314 | struct xt_entry_target __user *u) |
316 | { | 315 | { |
317 | return XT_OBJ_TO_USER(u, t, target, 0) || | 316 | return XT_OBJ_TO_USER(u, t, target, 0) || |
318 | XT_DATA_TO_USER(u, t, target, 0); | 317 | XT_DATA_TO_USER(u, t, target); |
319 | } | 318 | } |
320 | EXPORT_SYMBOL_GPL(xt_target_to_user); | 319 | EXPORT_SYMBOL_GPL(xt_target_to_user); |
321 | 320 | ||
@@ -614,6 +613,12 @@ void xt_compat_match_from_user(struct xt_entry_match *m, void **dstptr, | |||
614 | } | 613 | } |
615 | EXPORT_SYMBOL_GPL(xt_compat_match_from_user); | 614 | EXPORT_SYMBOL_GPL(xt_compat_match_from_user); |
616 | 615 | ||
616 | #define COMPAT_XT_DATA_TO_USER(U, K, TYPE, C_SIZE) \ | ||
617 | xt_data_to_user(U->data, K->data, \ | ||
618 | K->u.kernel.TYPE->usersize, \ | ||
619 | C_SIZE, \ | ||
620 | COMPAT_XT_ALIGN(C_SIZE)) | ||
621 | |||
617 | int xt_compat_match_to_user(const struct xt_entry_match *m, | 622 | int xt_compat_match_to_user(const struct xt_entry_match *m, |
618 | void __user **dstptr, unsigned int *size) | 623 | void __user **dstptr, unsigned int *size) |
619 | { | 624 | { |
@@ -629,7 +634,7 @@ int xt_compat_match_to_user(const struct xt_entry_match *m, | |||
629 | if (match->compat_to_user((void __user *)cm->data, m->data)) | 634 | if (match->compat_to_user((void __user *)cm->data, m->data)) |
630 | return -EFAULT; | 635 | return -EFAULT; |
631 | } else { | 636 | } else { |
632 | if (XT_DATA_TO_USER(cm, m, match, msize - sizeof(*cm))) | 637 | if (COMPAT_XT_DATA_TO_USER(cm, m, match, msize - sizeof(*cm))) |
633 | return -EFAULT; | 638 | return -EFAULT; |
634 | } | 639 | } |
635 | 640 | ||
@@ -975,7 +980,7 @@ int xt_compat_target_to_user(const struct xt_entry_target *t, | |||
975 | if (target->compat_to_user((void __user *)ct->data, t->data)) | 980 | if (target->compat_to_user((void __user *)ct->data, t->data)) |
976 | return -EFAULT; | 981 | return -EFAULT; |
977 | } else { | 982 | } else { |
978 | if (XT_DATA_TO_USER(ct, t, target, tsize - sizeof(*ct))) | 983 | if (COMPAT_XT_DATA_TO_USER(ct, t, target, tsize - sizeof(*ct))) |
979 | return -EFAULT; | 984 | return -EFAULT; |
980 | } | 985 | } |
981 | 986 | ||