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=-5.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_MUTT 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 79CFBC43381 for ; Thu, 14 Mar 2019 17:40:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 541AE2184C for ; Thu, 14 Mar 2019 17:40:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727648AbfCNRkm (ORCPT ); Thu, 14 Mar 2019 13:40:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50987 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726485AbfCNRkm (ORCPT ); Thu, 14 Mar 2019 13:40:42 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0782C306C3C5; Thu, 14 Mar 2019 17:40:42 +0000 (UTC) Received: from bistromath.localdomain (ovpn-204-201.brq.redhat.com [10.40.204.201]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3B7251001DFE; Thu, 14 Mar 2019 17:40:39 +0000 (UTC) Date: Thu, 14 Mar 2019 18:40:38 +0100 From: Sabrina Dubroca To: Eric Dumazet Cc: netdev@vger.kernel.org, Jianlin Shi , Stefano Brivio Subject: Re: [PATCH net] net: enforce xmit_recursion for devices with a queue Message-ID: <20190314174038.GA18679@bistromath.localdomain> References: <6d9ed6c448a5c855e05abf19c205f33a66b6ff40.1552557395.git.sd@queasysnail.net> <20190314141505.GA1953@bistromath.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 14 Mar 2019 17:40:42 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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. -- Sabrina