ebtables: arpreply: Add the standard target sanity check
Subsystems (3)
PATCH 1/1 ebtables: arpreply: Add the standard target sanity check
From: Gao Feng <[email protected]>
The info->target is from userspace and it would be used directly. So we need to add the sanity check to make sure it is a valid standard target, although the ebtables tool has already checked it. Kernel need to check anything from userspace.
If the target was set as an evil value, it would break the ebtables and cause a panic. Because the non-standard target is treated as one offset.
--- net/bridge/netfilter/ebt_arpreply.c | 3 +++ 1 file changed, 3 insertions(+)
net/bridge/netfilter/ebt_arpreply.c +3 -0
@@ -68,6 +68,9 @@ static int ebt_arpreply_tg_check(const struct xt_tgchk_param *par)if (e->ethproto !=htons (ETH_P_ARP ) || e->invflags &EBT_IPROTO )return -EINVAL ; +if (INVALID_TARGET ) +return -EINVAL ; +return 0 ; }
Signature · 1 line
1.9.1
Pablo Neira Ayuso
maintainerQuoted 21 lines · On Fri, May 12, 2017 at 05:44:10PM +0800, [email protected] wrote:
From: Gao Feng <[email protected]>
The
info->targetis from userspace and it would be used directly. So we need to add the sanity check to make sure it is a valid standard target, although the ebtables tool has already checked it. Kernel need to check anything from userspace.If the target was set as an evil value, it would break the ebtables and cause a panic. Because the non-standard target is treated as one offset.
Signed-off-by Gao Feng <[email protected]>--- net/bridge/netfilter/ebt_arpreply.c | 3 +++ 1 file changed, 3 insertions(+)net/bridge/netfilter/ebt_arpreply.c +0
-0
net/bridge/netfilter/ebt_arpreply.c static int ebt_arpreply_tg_check(const struct xt_tgchk_param *par) · line 71
Quoted 4 lines
net/bridge/netfilter/ebt_arpreply.c +1
-0@@ -68,6 +68,9 @@ static int ebt_arpreply_tg_check(const struct xt_tgchk_param *par)if (e->ethproto !=htons (ETH_P_ARP ) || e->invflags &EBT_IPROTO )return -EINVAL ; +if (INVALID_TARGET )
Please, add:
static inline bool ebt_invalid_target(int target)
{
return (target < -NUM_STANDARD_TARGETS || target >= 0);
}and use it in this fix.
So we can get rid of this obscure INVALID_TARGET macro.
Thanks.
Pablo Neira Ayuso
maintainerQuoted 29 lines · Pablo Neira Ayuso
Quoted 21 lines · On Fri, May 12, 2017 at 05:44:10PM +0800, [email protected] wrote:
From: Gao Feng <[email protected]>
The
info->targetis from userspace and it would be used directly. So we need to add the sanity check to make sure it is a valid standard target, although the ebtables tool has already checked it. Kernel need to check anything from userspace.If the target was set as an evil value, it would break the ebtables and cause a panic. Because the non-standard target is treated as one offset.
Signed-off-by Gao Feng <[email protected]>--- net/bridge/netfilter/ebt_arpreply.c | 3 +++ 1 file changed, 3 insertions(+)net/bridge/netfilter/ebt_arpreply.c +0
-0net/bridge/netfilter/ebt_arpreply.c static int ebt_arpreply_tg_check(const struct xt_tgchk_param *par) · line 71
Quoted 4 lines
net/bridge/netfilter/ebt_arpreply.c +1
-0@@ -68,6 +68,9 @@ static int ebt_arpreply_tg_check(const struct xt_tgchk_param *par)if (e->ethproto !=htons (ETH_P_ARP ) || e->invflags &EBT_IPROTO )return -EINVAL ; +if (INVALID_TARGET )Please, add:
Quoted 8 lines
static inline bool
ebt_invalid_target(int target){ return (target < -NUM_STANDARD_TARGETS || target >= 0); }and use it in this fix.
So we can get rid of this obscure
INVALID_TARGETmacro.
Once this propagates to nf-next.git, you can send a follow up patch to use this new function from more spots, so we can kill INVALID_TARGET for good.
Quoted 35 lines · Pablo Neira Ayuso
Quoted 34 lines · Pablo Neira Ayuso
Quoted 21 lines · On Fri, May 12, 2017 at 05:44:10PM +0800, [email protected] wrote:
From: Gao Feng <[email protected]>
The
info->targetis from userspace and it would be used directly. So we need to add the sanity check to make sure it is a valid standard target, although the ebtables tool has already checked it. Kernel need to check anything from userspace.If the target was set as an evil value, it would break the ebtables and cause a panic. Because the non-standard target is treated as one offset.
Signed-off-by Gao Feng <[email protected]>--- net/bridge/netfilter/ebt_arpreply.c | 3 +++ 1 file changed, 3 insertions(+)net/bridge/netfilter/ebt_arpreply.c +0
-0net/bridge/netfilter/ebt_arpreply.c static int ebt_arpreply_tg_check(const struct xt_tgchk_param *par) · line 71
Quoted 4 lines
net/bridge/netfilter/ebt_arpreply.c +1
-0@@ -68,6 +68,9 @@ static int ebt_arpreply_tg_check(const struct xt_tgchk_param *par)if (e->ethproto !=htons (ETH_P_ARP ) || e->invflags &EBT_IPROTO )return -EINVAL ; +if (INVALID_TARGET )Please, add:
static inline bool
ebt_invalid_target(int target){ return (target < -NUM_STANDARD_TARGETS || target >= 0); }
Quoted 7 lines
Quoted 3 lines
and use it in this fix.
So we can get rid of this obscure
INVALID_TARGETmacro.Once this propagates to nf-next.git, you can send a follow up patch to use this new function from more spots, so we can kill
INVALID_TARGETfor good.
OK, no problem.
Regards
Feng