Commit 11d4dd0b authored by Li RongQing's avatar Li RongQing Committed by Pablo Neira Ayuso

netfilter: convert the proto argument from u8 to u16

The proto in struct xt_match and struct xt_target is u16, when
calling xt_check_target/match, their proto argument is u8,
and will cause truncation, it is harmless to ip packet, since
ip proto is u8

if a etable's match/target has proto that is u16, will cause
the check failure.

and convert be16 to short in bridge/netfilter/ebtables.c
Signed-off-by: default avatarZhang Yu <zhangyu31@baidu.com>
Signed-off-by: default avatarLi RongQing <lirongqing@baidu.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 3e511d56
...@@ -289,9 +289,9 @@ bool xt_find_jump_offset(const unsigned int *offsets, ...@@ -289,9 +289,9 @@ bool xt_find_jump_offset(const unsigned int *offsets,
int xt_check_proc_name(const char *name, unsigned int size); int xt_check_proc_name(const char *name, unsigned int size);
int xt_check_match(struct xt_mtchk_param *, unsigned int size, u_int8_t proto, int xt_check_match(struct xt_mtchk_param *, unsigned int size, u16 proto,
bool inv_proto); bool inv_proto);
int xt_check_target(struct xt_tgchk_param *, unsigned int size, u_int8_t proto, int xt_check_target(struct xt_tgchk_param *, unsigned int size, u16 proto,
bool inv_proto); bool inv_proto);
int xt_match_to_user(const struct xt_entry_match *m, int xt_match_to_user(const struct xt_entry_match *m,
......
...@@ -381,7 +381,7 @@ ebt_check_match(struct ebt_entry_match *m, struct xt_mtchk_param *par, ...@@ -381,7 +381,7 @@ ebt_check_match(struct ebt_entry_match *m, struct xt_mtchk_param *par,
par->match = match; par->match = match;
par->matchinfo = m->data; par->matchinfo = m->data;
ret = xt_check_match(par, m->match_size, ret = xt_check_match(par, m->match_size,
e->ethproto, e->invflags & EBT_IPROTO); ntohs(e->ethproto), e->invflags & EBT_IPROTO);
if (ret < 0) { if (ret < 0) {
module_put(match->me); module_put(match->me);
return ret; return ret;
...@@ -418,7 +418,7 @@ ebt_check_watcher(struct ebt_entry_watcher *w, struct xt_tgchk_param *par, ...@@ -418,7 +418,7 @@ ebt_check_watcher(struct ebt_entry_watcher *w, struct xt_tgchk_param *par,
par->target = watcher; par->target = watcher;
par->targinfo = w->data; par->targinfo = w->data;
ret = xt_check_target(par, w->watcher_size, ret = xt_check_target(par, w->watcher_size,
e->ethproto, e->invflags & EBT_IPROTO); ntohs(e->ethproto), e->invflags & EBT_IPROTO);
if (ret < 0) { if (ret < 0) {
module_put(watcher->me); module_put(watcher->me);
return ret; return ret;
...@@ -744,7 +744,7 @@ ebt_check_entry(struct ebt_entry *e, struct net *net, ...@@ -744,7 +744,7 @@ ebt_check_entry(struct ebt_entry *e, struct net *net,
tgpar.target = target; tgpar.target = target;
tgpar.targinfo = t->data; tgpar.targinfo = t->data;
ret = xt_check_target(&tgpar, t->target_size, ret = xt_check_target(&tgpar, t->target_size,
e->ethproto, e->invflags & EBT_IPROTO); ntohs(e->ethproto), e->invflags & EBT_IPROTO);
if (ret < 0) { if (ret < 0) {
module_put(target->me); module_put(target->me);
goto cleanup_watchers; goto cleanup_watchers;
......
...@@ -461,7 +461,7 @@ int xt_check_proc_name(const char *name, unsigned int size) ...@@ -461,7 +461,7 @@ int xt_check_proc_name(const char *name, unsigned int size)
EXPORT_SYMBOL(xt_check_proc_name); EXPORT_SYMBOL(xt_check_proc_name);
int xt_check_match(struct xt_mtchk_param *par, int xt_check_match(struct xt_mtchk_param *par,
unsigned int size, u_int8_t proto, bool inv_proto) unsigned int size, u16 proto, bool inv_proto)
{ {
int ret; int ret;
...@@ -984,7 +984,7 @@ bool xt_find_jump_offset(const unsigned int *offsets, ...@@ -984,7 +984,7 @@ bool xt_find_jump_offset(const unsigned int *offsets,
EXPORT_SYMBOL(xt_find_jump_offset); EXPORT_SYMBOL(xt_find_jump_offset);
int xt_check_target(struct xt_tgchk_param *par, int xt_check_target(struct xt_tgchk_param *par,
unsigned int size, u_int8_t proto, bool inv_proto) unsigned int size, u16 proto, bool inv_proto)
{ {
int ret; int ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment