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=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 68B73C43381 for ; Fri, 1 Mar 2019 18:02:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3CA4020857 for ; Fri, 1 Mar 2019 18:02:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387831AbfCASCW (ORCPT ); Fri, 1 Mar 2019 13:02:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39022 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728507AbfCASCW (ORCPT ); Fri, 1 Mar 2019 13:02:22 -0500 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 AF4CE30C0EB4; Fri, 1 Mar 2019 18:02:21 +0000 (UTC) Received: from wlan-180-156.mxp.redhat.com (unknown [10.32.181.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48FAF1001DE9; Fri, 1 Mar 2019 18:02:20 +0000 (UTC) Message-ID: <81d683a7b6ea12e69cb9954b9bad84a9d2a2520f.camel@redhat.com> Subject: Re: [PATCH net 03/16] net/sched: act_csum: validate the control action inside init() From: Davide Caratti To: Cong Wang Cc: "David S. Miller" , Jamal Hadi Salim , Jiri Pirko , Vlad Buslov , Paolo Abeni , Linux Kernel Network Developers In-Reply-To: References: Organization: red hat Content-Type: text/plain; charset="UTF-8" Date: Fri, 01 Mar 2019 19:02:19 +0100 Mime-Version: 1.0 User-Agent: Evolution 3.30.3 (3.30.3-1.fc29) Content-Transfer-Encoding: 7bit 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.40]); Fri, 01 Mar 2019 18:02:21 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, 2019-02-27 at 17:50 -0800, Cong Wang wrote: > > + if (oldchain) > > + tcf_chain_put_by_act(oldchain); > > Do we need to respect RCU grace period here? if I well understand the question, you are worried about tcf_action_goto_chain_exec(), that can dereference 'oldchain' while we are overwriting the action. A call to tcf_chain_put_by_act(oldchain) would decrease refcounts and eventually call kfree(oldchain). But this would result in a use-after-free only in case the chain has only refcount held by 1 action (the one we are overwriting), and 0 filters: is this a condition where packets can go through this action's data plane? In every other case, the chain is refcounted at least by 1 filter. So, normally the worst case would be a packet routed on the wrong chain, which is not much different than what already happens now when a valid 'goto chain' rule is overwritten with another valid 'goto chain' rule. Am I missing something? thank you in advance, -- davide