Skip to content

Commit

Permalink
netfilter: ebt_ulog: fix info leaks
Browse files Browse the repository at this point in the history
The ulog messages leak heap bytes by the means of padding bytes and
incompletely filled string arrays. Fix those by memset(0)'ing the
whole struct before filling it.

Signed-off-by: Mathias Krause <minipli@googlemail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Mathias Krause authored and Pablo Neira Ayuso committed Oct 2, 2013
1 parent c31eeac commit ca0a106
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions net/bridge/netfilter/ebt_ulog.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
ub->qlen++;

pm = nlmsg_data(nlh);
memset(pm, 0, sizeof(*pm));

/* Fill in the ulog data */
pm->version = EBT_ULOG_VERSION;
Expand All @@ -193,8 +194,6 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
pm->hook = hooknr;
if (uloginfo->prefix != NULL)
strcpy(pm->prefix, uloginfo->prefix);
else
*(pm->prefix) = '\0';

if (in) {
strcpy(pm->physindev, in->name);
Expand All @@ -204,16 +203,14 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
strcpy(pm->indev, br_port_get_rcu(in)->br->dev->name);
else
strcpy(pm->indev, in->name);
} else
pm->indev[0] = pm->physindev[0] = '\0';
}

if (out) {
/* If out exists, then out is a bridge port */
strcpy(pm->physoutdev, out->name);
/* rcu_read_lock()ed by nf_hook_slow */
strcpy(pm->outdev, br_port_get_rcu(out)->br->dev->name);
} else
pm->outdev[0] = pm->physoutdev[0] = '\0';
}

if (skb_copy_bits(skb, -ETH_HLEN, pm->data, copy_len) < 0)
BUG();
Expand Down

0 comments on commit ca0a106

Please sign in to comment.