Re: [PATCH net/next] bridge:Add rcu read lock when delete br port
From: Stephen Hemminger
Date: Mon Aug 04 2014 - 12:29:13 EST
On Mon, 4 Aug 2014 11:37:56 +0800
<lichunhe@xxxxxxxxxx> wrote:
> From: Chunhe Li <lichunhe@xxxxxxxxxx>
>
> In the br_hanle_frame function has a bug, when the bridge receive packets
> which go througth the br_handle_frame, get the net_bridge_port pointer "p",
> but don't check NULL pointer to use it. If somebody delete the bridge port
> at the same time, will call a NULL pointer, trigger kernel panic. I see the
> del_nbp comments, call del_nbp should via RCU, but the caller don't do this.
>
> following steps will make bug happened
> 1.start vm and add the vm interface to a bridge br0,for example,
> brctl addbr br0 tap0
>
> 2.configuer vm interface and br0 same ip subnet, vm ping br0.
>
> 3.add and delete the vm interface port for endless loop.
>
> Signed-off-by: Chunhe Li <lichunhe@xxxxxxxxxx>
This is safe because:
1. br_dev_delete is called with RTNL mutex therefore it is safe with other add/delete
RCU does not block anything
2. br_handle_frame is called with RCU lock (in frame rx)
3. port is not freed until after grace period
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/