From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 612DFC43381 for ; Thu, 28 Feb 2019 18:32:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 43C30218AE for ; Thu, 28 Feb 2019 18:32:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388736AbfB1Sc5 (ORCPT ); Thu, 28 Feb 2019 13:32:57 -0500 Received: from shards.monkeyblade.net ([23.128.96.9]:36472 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732979AbfB1Sc4 (ORCPT ); Thu, 28 Feb 2019 13:32:56 -0500 Received: from localhost (unknown [IPv6:2601:601:9f80:35cd::bf5]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id B078814BA5DDD; Thu, 28 Feb 2019 10:32:55 -0800 (PST) Date: Thu, 28 Feb 2019 10:32:55 -0800 (PST) Message-Id: <20190228.103255.1267406247353659296.davem@davemloft.net> To: lansheng@huawei.com Cc: eric.dumazet@gmail.com, stephen@networkplumber.org, netdev@vger.kernel.org, netem@lists.linux-foundation.org, xuhanbing@huawei.com, zhengshaoyu@huawei.com, jiqin.ji@huawei.com, liuzhiqiang26@huawei.com, yuehaibing@huawei.com Subject: Re: [PATCH v2] net: netem: fix skb length BUG_ON in __skb_to_sgvec From: David Miller In-Reply-To: References: X-Mailer: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Thu, 28 Feb 2019 10:32:56 -0800 (PST) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Sheng Lan Date: Thu, 28 Feb 2019 18:47:58 +0800 > From: Sheng Lan > > It can be reproduced by following steps: > 1. virtio_net NIC is configured with gso/tso on > 2. configure nginx as http server with an index file bigger than 1M bytes > 3. use tc netem to produce duplicate packets and delay: > tc qdisc add dev eth0 root netem delay 100ms 10ms 30% duplicate 90% > 4. continually curl the nginx http server to get index file on client > 5. BUG_ON is seen quickly ... > In __skb_to_sgvec(), the skb->len is not equal to the sum of the skb's > linear data size and nonlinear data size, thus BUG_ON triggered. > Because the skb is cloned and a part of nonlinear data is split off. > > Duplicate packet is cloned in netem_enqueue() and may be delayed > some time in qdisc. When qdisc len reached the limit and returns > NET_XMIT_DROP, the skb will be retransmit later in write queue. > the skb will be fragmented by tso_fragment(), the limit size > that depends on cwnd and mss decrease, the skb's nonlinear > data will be split off. The length of the skb cloned by netem > will not be updated. When we use virtio_net NIC and invoke skb_to_sgvec(), > the BUG_ON trigger. > > To fix it, netem returns NET_XMIT_SUCCESS to upper stack > when it clones a duplicate packet. > > Fixes: 35d889d1 ("sch_netem: fix skb leak in netem_enqueue()") > Signed-off-by: Sheng Lan > Reported-by: Qin Ji > Suggested-by: Eric Dumazet Applied and queued up for -stable, thanks.