327-v4.16-netfilter-nf_tables-remove-nhooks-field-from-struct-.patch 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. From: Pablo Neira Ayuso <pablo@netfilter.org>
  2. Date: Tue, 19 Dec 2017 13:53:45 +0100
  3. Subject: [PATCH] netfilter: nf_tables: remove nhooks field from struct
  4. nft_af_info
  5. We already validate the hook through bitmask, so this check is
  6. superfluous. When removing this, this patch is also fixing a bug in the
  7. new flowtable codebase, since ctx->afi points to the table family
  8. instead of the netdev family which is where the flowtable is really
  9. hooked in.
  10. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  11. ---
  12. --- a/include/net/netfilter/nf_tables.h
  13. +++ b/include/net/netfilter/nf_tables.h
  14. @@ -971,7 +971,6 @@ enum nft_af_flags {
  15. *
  16. * @list: used internally
  17. * @family: address family
  18. - * @nhooks: number of hooks in this family
  19. * @owner: module owner
  20. * @tables: used internally
  21. * @flags: family flags
  22. @@ -979,7 +978,6 @@ enum nft_af_flags {
  23. struct nft_af_info {
  24. struct list_head list;
  25. int family;
  26. - unsigned int nhooks;
  27. struct module *owner;
  28. struct list_head tables;
  29. u32 flags;
  30. --- a/net/bridge/netfilter/nf_tables_bridge.c
  31. +++ b/net/bridge/netfilter/nf_tables_bridge.c
  32. @@ -44,7 +44,6 @@ nft_do_chain_bridge(void *priv,
  33. static struct nft_af_info nft_af_bridge __read_mostly = {
  34. .family = NFPROTO_BRIDGE,
  35. - .nhooks = NF_BR_NUMHOOKS,
  36. .owner = THIS_MODULE,
  37. };
  38. --- a/net/ipv4/netfilter/nf_tables_arp.c
  39. +++ b/net/ipv4/netfilter/nf_tables_arp.c
  40. @@ -29,7 +29,6 @@ nft_do_chain_arp(void *priv,
  41. static struct nft_af_info nft_af_arp __read_mostly = {
  42. .family = NFPROTO_ARP,
  43. - .nhooks = NF_ARP_NUMHOOKS,
  44. .owner = THIS_MODULE,
  45. };
  46. --- a/net/ipv4/netfilter/nf_tables_ipv4.c
  47. +++ b/net/ipv4/netfilter/nf_tables_ipv4.c
  48. @@ -32,7 +32,6 @@ static unsigned int nft_do_chain_ipv4(vo
  49. static struct nft_af_info nft_af_ipv4 __read_mostly = {
  50. .family = NFPROTO_IPV4,
  51. - .nhooks = NF_INET_NUMHOOKS,
  52. .owner = THIS_MODULE,
  53. };
  54. --- a/net/ipv6/netfilter/nf_tables_ipv6.c
  55. +++ b/net/ipv6/netfilter/nf_tables_ipv6.c
  56. @@ -30,7 +30,6 @@ static unsigned int nft_do_chain_ipv6(vo
  57. static struct nft_af_info nft_af_ipv6 __read_mostly = {
  58. .family = NFPROTO_IPV6,
  59. - .nhooks = NF_INET_NUMHOOKS,
  60. .owner = THIS_MODULE,
  61. };
  62. --- a/net/netfilter/nf_tables_api.c
  63. +++ b/net/netfilter/nf_tables_api.c
  64. @@ -1374,9 +1374,6 @@ static int nft_chain_parse_hook(struct n
  65. return -EINVAL;
  66. hook->num = ntohl(nla_get_be32(ha[NFTA_HOOK_HOOKNUM]));
  67. - if (hook->num >= afi->nhooks)
  68. - return -EINVAL;
  69. -
  70. hook->priority = ntohl(nla_get_be32(ha[NFTA_HOOK_PRIORITY]));
  71. type = chain_type[afi->family][NFT_CHAIN_T_DEFAULT];
  72. @@ -5015,7 +5012,7 @@ static int nf_tables_flowtable_parse_hoo
  73. return -EINVAL;
  74. hooknum = ntohl(nla_get_be32(tb[NFTA_FLOWTABLE_HOOK_NUM]));
  75. - if (hooknum >= ctx->afi->nhooks)
  76. + if (hooknum != NF_NETDEV_INGRESS)
  77. return -EINVAL;
  78. priority = ntohl(nla_get_be32(tb[NFTA_FLOWTABLE_HOOK_PRIORITY]));
  79. --- a/net/netfilter/nf_tables_inet.c
  80. +++ b/net/netfilter/nf_tables_inet.c
  81. @@ -40,7 +40,6 @@ static unsigned int nft_do_chain_inet(vo
  82. static struct nft_af_info nft_af_inet __read_mostly = {
  83. .family = NFPROTO_INET,
  84. - .nhooks = NF_INET_NUMHOOKS,
  85. .owner = THIS_MODULE,
  86. };
  87. --- a/net/netfilter/nf_tables_netdev.c
  88. +++ b/net/netfilter/nf_tables_netdev.c
  89. @@ -40,7 +40,6 @@ nft_do_chain_netdev(void *priv, struct s
  90. static struct nft_af_info nft_af_netdev __read_mostly = {
  91. .family = NFPROTO_NETDEV,
  92. - .nhooks = NF_NETDEV_NUMHOOKS,
  93. .owner = THIS_MODULE,
  94. .flags = NFT_AF_NEEDS_DEV,
  95. };