netfilter: xtables: restrict several matches to inet family
This is a partial revert of: commitab4f21e6fb("netfilter: xtables: use NFPROTO_UNSPEC in more extensions") to allow ipv4 and ipv6 only. - xt_mac - xt_owner - xt_physdev These extensions are not used by ebtables in userspace. Moreover, xt_realm is only for ipv4, since dst->tclassid is ipv4 specific. Fixes:ab4f21e6fb("netfilter: xtables: use NFPROTO_UNSPEC in more extensions") Reported-by: "Kito Xu (veritas501)" <hxzene@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
1 parent
6e7066bdb4
commit
b6fe26f86a
4 files changed
+68
-34
No files matched your search
+23
-11
@@ -36,25 +36,37 @@ static bool mac_mt(const struct sk_buff *skb, struct xt_action_param *par)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct xt_match mac_mt_reg __read_mostly = {
|
||||
.name = "mac",
|
||||
.revision = 0,
|
||||
.family = NFPROTO_UNSPEC,
|
||||
.match = mac_mt,
|
||||
.matchsize = sizeof(struct xt_mac_info),
|
||||
.hooks = (1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_IN) |
|
||||
(1 << NF_INET_FORWARD),
|
||||
.me = THIS_MODULE,
|
||||
static struct xt_match mac_mt_reg[] __read_mostly = {
|
||||
{
|
||||
.name = "mac",
|
||||
.family = NFPROTO_IPV4,
|
||||
.match = mac_mt,
|
||||
.matchsize = sizeof(struct xt_mac_info),
|
||||
.hooks = (1 << NF_INET_PRE_ROUTING) |
|
||||
(1 << NF_INET_LOCAL_IN) |
|
||||
(1 << NF_INET_FORWARD),
|
||||
.me = THIS_MODULE,
|
||||
},
|
||||
{
|
||||
.name = "mac",
|
||||
.family = NFPROTO_IPV6,
|
||||
.match = mac_mt,
|
||||
.matchsize = sizeof(struct xt_mac_info),
|
||||
.hooks = (1 << NF_INET_PRE_ROUTING) |
|
||||
(1 << NF_INET_LOCAL_IN) |
|
||||
(1 << NF_INET_FORWARD),
|
||||
.me = THIS_MODULE,
|
||||
},
|
||||
};
|
||||
|
||||
static int __init mac_mt_init(void)
|
||||
{
|
||||
return xt_register_match(&mac_mt_reg);
|
||||
return xt_register_matches(mac_mt_reg, ARRAY_SIZE(mac_mt_reg));
|
||||
}
|
||||
|
||||
static void __exit mac_mt_exit(void)
|
||||
{
|
||||
xt_unregister_match(&mac_mt_reg);
|
||||
xt_unregister_matches(mac_mt_reg, ARRAY_SIZE(mac_mt_reg));
|
||||
}
|
||||
|
||||
module_init(mac_mt_init);
|
||||
|
||||
+25
-12
@@ -127,26 +127,39 @@ owner_mt(const struct sk_buff *skb, struct xt_action_param *par)
|
||||
return true;
|
||||
}
|
||||
|
||||
static struct xt_match owner_mt_reg __read_mostly = {
|
||||
.name = "owner",
|
||||
.revision = 1,
|
||||
.family = NFPROTO_UNSPEC,
|
||||
.checkentry = owner_check,
|
||||
.match = owner_mt,
|
||||
.matchsize = sizeof(struct xt_owner_match_info),
|
||||
.hooks = (1 << NF_INET_LOCAL_OUT) |
|
||||
(1 << NF_INET_POST_ROUTING),
|
||||
.me = THIS_MODULE,
|
||||
static struct xt_match owner_mt_reg[] __read_mostly = {
|
||||
{
|
||||
.name = "owner",
|
||||
.revision = 1,
|
||||
.family = NFPROTO_IPV4,
|
||||
.checkentry = owner_check,
|
||||
.match = owner_mt,
|
||||
.matchsize = sizeof(struct xt_owner_match_info),
|
||||
.hooks = (1 << NF_INET_LOCAL_OUT) |
|
||||
(1 << NF_INET_POST_ROUTING),
|
||||
.me = THIS_MODULE,
|
||||
},
|
||||
{
|
||||
.name = "owner",
|
||||
.revision = 1,
|
||||
.family = NFPROTO_IPV6,
|
||||
.checkentry = owner_check,
|
||||
.match = owner_mt,
|
||||
.matchsize = sizeof(struct xt_owner_match_info),
|
||||
.hooks = (1 << NF_INET_LOCAL_OUT) |
|
||||
(1 << NF_INET_POST_ROUTING),
|
||||
.me = THIS_MODULE,
|
||||
}
|
||||
};
|
||||
|
||||
static int __init owner_mt_init(void)
|
||||
{
|
||||
return xt_register_match(&owner_mt_reg);
|
||||
return xt_register_matches(owner_mt_reg, ARRAY_SIZE(owner_mt_reg));
|
||||
}
|
||||
|
||||
static void __exit owner_mt_exit(void)
|
||||
{
|
||||
xt_unregister_match(&owner_mt_reg);
|
||||
xt_unregister_matches(owner_mt_reg, ARRAY_SIZE(owner_mt_reg));
|
||||
}
|
||||
|
||||
module_init(owner_mt_init);
|
||||
|
||||
+19
-10
@@ -137,24 +137,33 @@ static int physdev_mt_check(const struct xt_mtchk_param *par)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct xt_match physdev_mt_reg __read_mostly = {
|
||||
.name = "physdev",
|
||||
.revision = 0,
|
||||
.family = NFPROTO_UNSPEC,
|
||||
.checkentry = physdev_mt_check,
|
||||
.match = physdev_mt,
|
||||
.matchsize = sizeof(struct xt_physdev_info),
|
||||
.me = THIS_MODULE,
|
||||
static struct xt_match physdev_mt_reg[] __read_mostly = {
|
||||
{
|
||||
.name = "physdev",
|
||||
.family = NFPROTO_IPV4,
|
||||
.checkentry = physdev_mt_check,
|
||||
.match = physdev_mt,
|
||||
.matchsize = sizeof(struct xt_physdev_info),
|
||||
.me = THIS_MODULE,
|
||||
},
|
||||
{
|
||||
.name = "physdev",
|
||||
.family = NFPROTO_IPV6,
|
||||
.checkentry = physdev_mt_check,
|
||||
.match = physdev_mt,
|
||||
.matchsize = sizeof(struct xt_physdev_info),
|
||||
.me = THIS_MODULE,
|
||||
},
|
||||
};
|
||||
|
||||
static int __init physdev_mt_init(void)
|
||||
{
|
||||
return xt_register_match(&physdev_mt_reg);
|
||||
return xt_register_matches(physdev_mt_reg, ARRAY_SIZE(physdev_mt_reg));
|
||||
}
|
||||
|
||||
static void __exit physdev_mt_exit(void)
|
||||
{
|
||||
xt_unregister_match(&physdev_mt_reg);
|
||||
xt_unregister_matches(physdev_mt_reg, ARRAY_SIZE(physdev_mt_reg));
|
||||
}
|
||||
|
||||
module_init(physdev_mt_init);
|
||||
|
||||
@@ -33,7 +33,7 @@ static struct xt_match realm_mt_reg __read_mostly = {
|
||||
.matchsize = sizeof(struct xt_realm_info),
|
||||
.hooks = (1 << NF_INET_POST_ROUTING) | (1 << NF_INET_FORWARD) |
|
||||
(1 << NF_INET_LOCAL_OUT) | (1 << NF_INET_LOCAL_IN),
|
||||
.family = NFPROTO_UNSPEC,
|
||||
.family = NFPROTO_IPV4,
|
||||
.me = THIS_MODULE
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user