ebtables: arpreply: Add the standard target sanity check
Subsystems (3)
PATCH v2 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.
Now add one helper function ebt_invalid_target, and we would replace the macro INVALID_TARGET later.
---
v2: Add one helper function ebt_invalid_target instead of INVALID_TARGET, per Pablo
v1: initial version
include/linux/netfilter_bridge/ebtables.h | 5 +++++ net/bridge/netfilter/ebt_arpreply.c | 3 +++ 2 files changed, 8 insertions(+)
include/linux/netfilter_bridge/ebtables.h +5 -0
@@ -125,4 +125,9 @@ extern unsigned int ebt_do_table(struct sk_buff *skb,/* True if the target is not a standard target */ #define INVALID_TARGET (info->target < -NUM_STANDARD_TARGETS || info->target >= 0) +static inline bool ebt_invalid_target (int target) +{ +return (target < -NUM_STANDARD_TARGETS || target >=0 ); +} +#endif
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 (ebt_invalid_target (info->target)) +return -EINVAL ; +return 0 ; }
Signature · 1 line
1.9.1
Quoted 7 lines · On Tue, May 16, 2017 at 09:30:18AM +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.
Quoted 6 lines
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.
Now add one helper function
ebt_invalid_target, and we would replace the macroINVALID_TARGETlater.
Applied, thanks.
There is a few bunch of spots that can use this indeed. Follow up with a patch for nf-next once merge window opens up.
Pablo Neira Ayuso
maintainerQuoted 12 lines · Pablo Neira Ayuso
Quoted 11 lines · On Tue, May 16, 2017 at 09:30:18AM +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.
Quoted 7 lines
Quoted 2 lines
Now add one helper function
ebt_invalid_target, and we would replace the macroINVALID_TARGETlater.Applied, thanks.
There is a few bunch of spots that can use this indeed. Follow up with a patch for nf-next once merge window opens up.
Please, use:
netfilter: ...
as you initial patch subject next time...
Quoted 13 lines · Pablo Neira Ayuso
Quoted 12 lines · Pablo Neira Ayuso
Quoted 11 lines · On Tue, May 16, 2017 at 09:30:18AM +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.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Now add one helper function
ebt_invalid_target, and we would replace the macroINVALID_TARGETlater.Applied, thanks.
There is a few bunch of spots that can use this indeed. Follow up with a patch for nf-next once merge window opens up.
I would pay some attention when nf is merged into nf-next.
Quoted 6 lines
Please, use:
netfilter: ...
as you initial patch subject next time...
OK. I thought the ebtables codes should use prefix "ebtables: ", and I checked it with git log. There were some commits which uses "ebtables" as prefix.
Could I assume both of ebtables and arptables uses the netfilter as prefix?
Regards
Feng
Pablo Neira Ayuso
maintainerQuoted 18 lines · Gao Feng
Quoted 16 lines · Pablo Neira Ayuso
Quoted 15 lines · Pablo Neira Ayuso
Quoted 13 lines · On Tue, May 16, 2017 at 09:30:18AM +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.
Now add one helper function
ebt_invalid_target, and we would replace the macroINVALID_TARGETlater.
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Applied, thanks.
There is a few bunch of spots that can use this indeed. Follow up with a patch for nf-next once merge window opens up.
I would pay some attention when nf is merged into nf-next.
Thanks.
Quoted 10 lines
Quoted 5 lines
Please, use:
netfilter: ...
as you initial patch subject next time...
OK. I thought the ebtables codes should use prefix "ebtables: ", and I checked it with git log. There were some commits which uses "ebtables" as prefix.
Could I assume both of ebtables and arptables uses the netfilter as prefix?
We should converge to netfilter: extension: blah.