Skip to content

Commit c953d63

Browse files
gfreewindummakynes
authored andcommitted
ebtables: arpreply: Add the standard target sanity check
The info->target comes 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 needs to validate anything coming from userspace. If the target is 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. Signed-off-by: Gao Feng <gfree.wind@vip.163.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 5910544 commit c953d63

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

‎include/linux/netfilter_bridge/ebtables.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,9 @@ extern unsigned int ebt_do_table(struct sk_buff *skb,
125125
/* True if the target is not a standard target */
126126
#define INVALID_TARGET (info->target < -NUM_STANDARD_TARGETS || info->target >= 0)
127127

128+
static inline bool ebt_invalid_target(int target)
129+
{
130+
return (target < -NUM_STANDARD_TARGETS || target >= 0);
131+
}
132+
128133
#endif

‎net/bridge/netfilter/ebt_arpreply.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ static int ebt_arpreply_tg_check(const struct xt_tgchk_param *par)
6868
if (e->ethproto != htons(ETH_P_ARP) ||
6969
e->invflags & EBT_IPROTO)
7070
return -EINVAL;
71+
if (ebt_invalid_target(info->target))
72+
return -EINVAL;
73+
7174
return 0;
7275
}
7376

0 commit comments

Comments
 (0)