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=-2.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_NEOMUTT 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 BD46CC31E4B for ; Fri, 14 Jun 2019 14:45:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A012A2133D for ; Fri, 14 Jun 2019 14:45:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728928AbfFNOpb (ORCPT ); Fri, 14 Jun 2019 10:45:31 -0400 Received: from Chamillionaire.breakpoint.cc ([193.142.43.52]:34600 "EHLO Chamillionaire.breakpoint.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728323AbfFNOpb (ORCPT ); Fri, 14 Jun 2019 10:45:31 -0400 Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.89) (envelope-from ) id 1hbnSK-0006hy-Jw; Fri, 14 Jun 2019 16:45:28 +0200 Date: Fri, 14 Jun 2019 16:45:28 +0200 From: Florian Westphal To: John Hurley Cc: netdev@vger.kernel.org, davem@davemloft.net, fw@strlen.de, jhs@mojatatu.com, simon.horman@netronome.com, jakub.kicinski@netronome.com, oss-drivers@netronome.com Subject: Re: [RFC net-next 2/2] net: sched: protect against stack overflow in TC act_mirred Message-ID: <20190614144528.fmmjqdguqlnonpyt@breakpoint.cc> References: <1560522831-23952-1-git-send-email-john.hurley@netronome.com> <1560522831-23952-3-git-send-email-john.hurley@netronome.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1560522831-23952-3-git-send-email-john.hurley@netronome.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org John Hurley wrote: > TC hooks allow the application of filters and actions to packets at both > ingress and egress of the network stack. It is possible, with poor > configuration, that this can produce loops whereby an ingress hook calls > a mirred egress action that has an egress hook that redirects back to > the first ingress etc. The TC core classifier protects against loops when > doing reclassifies but there is no protection against a packet looping > between multiple hooks and recursively calling act_mirred. This can lead > to stack overflow panics. > > Add a per CPU counter to act_mirred that is incremented for each recursive > call of the action function when processing a packet. If a limit is passed > then the packet is dropped and CPU counter reset. > > Note that this patch does not protect against loops in TC datapaths. Its > aim is to prevent stack overflow kernel panics that can be a consequence > of such loops. LGTM, thanks.