Re: 2.6.25-rc9: Reported regressions from 2.6.24

From: Patrick McHardy
Date: Sun Apr 13 2008 - 16:22:50 EST


Patrick McHardy wrote:

Bug-Entry : http://bugzilla.kernel.org/show_bug.cgi?id=10323
Subject : panic using bridging on linus kernel 2.6.25-rc6
Submitter : Andy Gospodarek <andy@xxxxxxxxxxxxx>
Date : 2008-03-25 11:40 (20 days old)

This looks like another network-namespace regression.
icmp_send() does:

net = rt->u.dst.dev->nd_net;

The bridge netfilter code attaches a fake dst_entry to the
skb which has dev == NULL when passing it to IPv4 netfilter.

Pavel, do you have a better ideas for fixing this than
instantiating a dst_entry in br_netfilter.c for every
device (or at least for every namespace)?

The description of the problem was not entirely correct, the
bridge-netfilter dst_entry does have a proper device pointer,
it points to a dummy net_device structure however that doesn't
have a namespace associated with it. This blows up in
__ip_route_output_key.

For now I suggest this fix. Andy, could you please test whether it
fixes the problem?


[BRIDGE]: Fix crash in __ip_route_output_key with bridge netfilter

The bridge netfilter code attaches a fake dst_entry with a pointer to a
fake net_device structure to skbs it passes up to IPv4 netfilter. This
leads to crashes when the skb is passed to __ip_route_output_key when
dereferencing the namespace pointer.

Since bridging can currently only operate in the init_net namespace,
the easiest fix for now is to initialize the nd_net pointer of the
fake net_device struct to &init_net.

Should fix bugzilla 10323: http://bugzilla.kernel.org/show_bug.cgi?id=10323

Signed-off-by: Patrick McHardy <kaber@xxxxxxxxx>

diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index 1c0efd8..af7e8be 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -110,7 +110,8 @@ static inline __be16 pppoe_proto(const struct sk_buff *skb)
* ipt_REJECT needs it. Future netfilter modules might
* require us to fill additional fields. */
static struct net_device __fake_net_device = {
- .hard_header_len = ETH_HLEN
+ .hard_header_len = ETH_HLEN,
+ .nd_net = &init_net,
};

static struct rtable __fake_rtable = {