From: Eric Dumazet <eric.dumazet@gmail.com>
To: Jiri Bohac <jbohac@suse.cz>
Cc: Jay Vosburgh <fubar@us.ibm.com>,
Andy Gospodarek <andy@greyhouse.net>,
netdev@vger.kernel.org
Subject: Re: bonding: don't increase rx_dropped after processing LACPDUs
Date: Wed, 02 May 2012 22:36:49 +0200 [thread overview]
Message-ID: <1335991009.22133.639.camel@edumazet-glaptop> (raw)
In-Reply-To: <20120502202309.GA25355@midget.suse.cz>
On Wed, 2012-05-02 at 22:23 +0200, Jiri Bohac wrote:
> Since commit 3aba891d, bonding processes LACP frames (802.3ad
> mode) with bond_handle_frame(). Currently a copy of the skb is
> made and the original is left to be processed by other
> rx_handlers and the rest of the network stack by returning
> RX_HANDLER_ANOTHER. As there is no protocol handler for
> PKT_TYPE_LACPDU, the frame is dropped and dev->rx_dropped
> increased.
>
> Fix this by making bond_handle_frame() return RX_HANDLER_CONSUMED
> if bonding has processed the LACP frame.
>
> Signed-off-by: Jiri Bohac <jbohac@suse.cz>
>
Nice idea but...
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -1444,8 +1444,9 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb)
> struct sk_buff *skb = *pskb;
> struct slave *slave;
> struct bonding *bond;
> - void (*recv_probe)(struct sk_buff *, struct bonding *,
> + int (*recv_probe)(struct sk_buff *, struct bonding *,
> struct slave *);
> + int ret = RX_HANDLER_ANOTHER;
>
> skb = skb_share_check(skb, GFP_ATOMIC);
> if (unlikely(!skb))
> @@ -1464,8 +1465,10 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb)
> struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC);
>
> if (likely(nskb)) {
> - recv_probe(nskb, bond, slave);
> + ret = recv_probe(nskb, bond, slave);
> dev_kfree_skb(nskb);
> + if (ret == RX_HANDLER_CONSUMED)
> + kfree_skb(skb);
After this point, you have use after free :
if (bond_should_deliver_exact_match(skb, slave, bond)) {
...
}
skb->dev = bond->dev;
...
> }
> }
>
> @@ -1487,7 +1490,7 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb)
> memcpy(eth_hdr(skb)->h_dest, bond->dev->dev_addr, ETH_ALEN);
> }
>
> - return RX_HANDLER_ANOTHER;
> + return ret;
> }
>
next prev parent reply other threads:[~2012-05-02 20:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-02 20:23 bonding: don't increase rx_dropped after processing LACPDUs Jiri Bohac
2012-05-02 20:36 ` Eric Dumazet [this message]
2012-05-02 20:51 ` Jiri Bohac
2012-05-02 23:10 ` Jay Vosburgh
2012-05-04 12:15 ` Jiri Bohac
2012-05-02 23:41 ` David Miller
2012-05-04 12:16 ` Jiri Bohac
2012-05-04 12:19 ` [PATCH v2] " Jiri Bohac
2012-05-04 13:04 ` Eric Dumazet
2012-05-04 13:28 ` [PATCH v3] " Jiri Bohac
2012-05-04 14:53 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1335991009.22133.639.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=andy@greyhouse.net \
--cc=fubar@us.ibm.com \
--cc=jbohac@suse.cz \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox