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=-3.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 6781FC43381 for ; Thu, 14 Mar 2019 17:51:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3D05B20811 for ; Thu, 14 Mar 2019 17:51:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BweayB1/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727660AbfCNRvx (ORCPT ); Thu, 14 Mar 2019 13:51:53 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:40610 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726888AbfCNRvw (ORCPT ); Thu, 14 Mar 2019 13:51:52 -0400 Received: by mail-pf1-f194.google.com with SMTP id y124so4341405pfy.7 for ; Thu, 14 Mar 2019 10:51:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=9wr47eDY3zy8nbI2WA5Ws++HDB1OPkJYlS5L2Yqcfd8=; b=BweayB1/0RwYk1HrFJxnPV8VRFSQNIVyzi5hLDqqsY6uyPT6h9IPCq4dwK8sDQCMP2 wHVVobXzTS17xg8x1xN9r5qvdZwxi0YuW2/RP3y+jtslePZNgGFhDwCllm9E5FYNP7P+ jIivthhw6xUIBO5hilRMc4J4EYJPnLESeBovY5l/J9/yYo7dc0UpiEkCTnfWjLv3FgRD 9O6k6opc0LBqtosyEPnGXc0gtXnvkfQbsn+rMtTuaqQvYnzLxO8/WUDi1Wi+5wJqLwSJ pNK1YFUuk48Xwd9ETw2fTfP5IDnOJalLdjJz+7TmfIeSviKaPLARTl1LFTKUrNRUhueY v0GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=9wr47eDY3zy8nbI2WA5Ws++HDB1OPkJYlS5L2Yqcfd8=; b=Fwa3RavJuH7q1ce/XOZn489eRwQk9CCh4T4HZanI82XxkYqXmz0vXoM1xNH3tz69Lq zfPvJc/l2UTzdfelgdh4hiu0nT8ERqYSmpPaxBHFuqxU2D0ca7s6rSgloeGmqc/6A1CY Jw+trBCLe7we/mf9rppxOaKfMwHLYsBEphLcQenJBcFlcWThAdEDg6cHSkix8fpipCLm ejKq92ZgnaEdnACAw984cqiWgSUJxHtxrnd0lRhgi26LKxYeBvdd4YY55vPgdRE/f0gH dhIFVt/ONLblF6Y4fRTY8Av08aEydmddQvdSRxLOOmNIW0aMns9tZt8d2e/soWIXdxhL 5mnA== X-Gm-Message-State: APjAAAUdm9MxwuyBkSwjnARCZCWhZyMDjiI8pTMoBC/VYn9DpA9wOYlt 2iDWSIi5dBzJKEWNb76SrtU= X-Google-Smtp-Source: APXvYqyg4i+wINH2YDxIw0wzjtq+gHuo7gbOicKF7bo75sgoU5J9upMwaoCECd4n4gWNcN9w1bAQdg== X-Received: by 2002:aa7:90c7:: with SMTP id k7mr49988073pfk.186.1552585911517; Thu, 14 Mar 2019 10:51:51 -0700 (PDT) Received: from ?IPv6:2620:15c:2c1:200:55c7:81e6:c7d8:94b? ([2620:15c:2c1:200:55c7:81e6:c7d8:94b]) by smtp.gmail.com with ESMTPSA id u18sm35679819pfa.176.2019.03.14.10.51.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Mar 2019 10:51:50 -0700 (PDT) Subject: Re: [PATCH net] net: enforce xmit_recursion for devices with a queue To: Sabrina Dubroca , Eric Dumazet Cc: netdev@vger.kernel.org, Jianlin Shi , Stefano Brivio References: <6d9ed6c448a5c855e05abf19c205f33a66b6ff40.1552557395.git.sd@queasysnail.net> <20190314141505.GA1953@bistromath.localdomain> <20190314174038.GA18679@bistromath.localdomain> From: Eric Dumazet Message-ID: Date: Thu, 14 Mar 2019 10:51:49 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190314174038.GA18679@bistromath.localdomain> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 03/14/2019 10:40 AM, Sabrina Dubroca wrote: > 2019-03-14, 07:56:10 -0700, Eric Dumazet wrote: >> >> >> On 03/14/2019 07:15 AM, Sabrina Dubroca wrote: >>> 2019-03-14, 05:58:03 -0700, Eric Dumazet wrote: >>>> >>>> >>>> On 03/14/2019 03:15 AM, Sabrina Dubroca wrote: >>>>> Commit 745e20f1b626 ("net: add a recursion limit in xmit path") >>>>> introduced a recursion limit, but it only applies to devices without a >>>>> queue. Virtual devices with a queue (either because they don't have >>>>> the IFF_NO_QUEUE flag, or because the administrator added one) can >>>>> still cause an unbounded recursion, via __dev_queue_xmit -> >>>>> __dev_xmit_skb -> qdisc_run -> __qdisc_run -> qdisc_restart -> >>>>> sch_direct_xmit -> dev_hard_start_xmit . Jianlin reported this in a >>>>> setup with 16 gretap devices stacked on top of one another. >>>>> >>>>> This patch prevents the stack overflow by incrementing xmit_recursion in >>>>> code paths that can call dev_hard_start_xmit() (like commit 745e20f1b626 >>>>> did). If the recursion limit is exceeded, the packet is enqueued and the >>>>> qdisc is scheduled. >>>>> >>>>> Reported-by: Jianlin Shi >>>>> Signed-off-by: Sabrina Dubroca >>>>> Reviewed-by: Stefano Brivio >>>> >>>> Hi Sabrina, thanks for the patch. >>>> >>>> Can't we detect this in the control path instead ? >>> >>> I don't see how. You could have a perfectly reasonable set of gretap >>> devices that trigger this situation from simply reshuffling the IP >>> addresses: >>> >>> gretap$x remote 1.1.$((x-1)).{1,2} >>> (all those addresses set on a single veth device) >>> >>> Then you move those addresses to the corresponding device >>> (1.1.${x}.{1,2} on gretap$x), and your machine crashes. >>> >> >> If this only can be done with gretap, why gretap cant implement the protection, >> outside of the fast path ? > > It's not just gretap. VXLAN will do the same as long as you add a > qdisc. I expect other types of tunnels to behave like that. > It might make sense to add a helper using dev_queue_xmit() for tunnel users. Then remove the xmit recursion stuff out of the dev_queue_xmit() Lets make the fast path fast again.