Skip to content

Commit

Permalink
[NETFILTER]: ebtables: don't compute gap before checking struct type
Browse files Browse the repository at this point in the history
We cannot compute the gap until we know we have a 'struct ebt_entry' and
not 'struct ebt_entries'.  Failure to check can cause crash.

Tested-by: Santiago Garcia Mantinan <[email protected]>
Acked-by: Al Viro <[email protected]>
Signed-off-by: Chuck Ebbert <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Patrick McHardy <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Chuck Ebbert authored and davem330 committed Jan 4, 2007
1 parent bbdc176 commit 44f9a2f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/bridge/netfilter/ebtables.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ ebt_check_entry(struct ebt_entry *e, struct ebt_table_info *newinfo,
struct ebt_entry_target *t;
struct ebt_target *target;
unsigned int i, j, hook = 0, hookmask = 0;
size_t gap = e->next_offset - e->target_offset;
size_t gap;
int ret;

/* don't mess with the struct ebt_entries */
Expand Down Expand Up @@ -660,6 +660,7 @@ ebt_check_entry(struct ebt_entry *e, struct ebt_table_info *newinfo,
if (ret != 0)
goto cleanup_watchers;
t = (struct ebt_entry_target *)(((char *)e) + e->target_offset);
gap = e->next_offset - e->target_offset;
target = find_target_lock(t->u.name, &ret, &ebt_mutex);
if (!target)
goto cleanup_watchers;
Expand Down

0 comments on commit 44f9a2f

Please sign in to comment.