Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1659781imm; Wed, 16 May 2018 00:51:39 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr39uqr+Zh+Lxje4975sDA9bO6BVfOHgUNf/gd9NNrQZPZdoqgeS7nALcHe/hwOWQOu1DPB X-Received: by 2002:a17:902:7e05:: with SMTP id b5-v6mr4826257plm.230.1526457099465; Wed, 16 May 2018 00:51:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526457099; cv=none; d=google.com; s=arc-20160816; b=VH8fjPcabCjzEdWxE4HyWx3bAN6UqsSzuglM6k/0SSWUICR1SczAuFb65Gd19Bo59s Zo+UuI4MLjbHDFXknLxBUqH6kjVjAArca3gXohSp6rWzczVCwUNcERQ1ZDAK9GiCs3GK VQdWqqBbiCn/YHYg1tawVLIsbcDg/caMUGagdCZzNST8yLR9yUIeLtXZGK5ylwR0b7mM Dj3VK4re/4YH7qQnSgQzHbX1j7RnvWhDeSr7FU5KlMMP+iF2/AiWrDvGHgffdJcY4HcS 7h6aX7rYD0xf3x9wg8eMw8Z/augbxG2V5XmQv0PhyCY+nKoj9VVsQZPVIaEy4aYIoDC6 nuLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=Mxiil5QCnN02JJNVCKQ708etwmiFrElGvNlQtcwUd0c=; b=cvYnz+uY7KBBu/2Y2ppxohuNc8oU/aW7Q9eoHNIqT2eh/MMnddDnVENmWjcCZxwHZw BKTu0nZ6EGqnilQ+OTG42DdcjhrS5wnxY6AXM5PEysVHIKXViYiAghitoGNVHJ04O5mO mAxmGtRgBgC14LbHe/JtkgV54mqnd6ppDxKXAPH8ea1b9g+EUsgMcH01xpomF1TzIqF2 mxHMs+HKalpo/ww1DA3ncUa9tcaAJ6WMTraVvZXE60C6beqhFQkaJHr77bOwf/n4ZdvQ 35STfZ3czal8P/aWGvb97cwaows4nCzyX9Z0NKtnMXRup3+7D6Gf4XNgzDDd8a+/nFAq lxHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@resnulli-us.20150623.gappssmtp.com header.s=20150623 header.b=IOmEG14l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s9-v6si2212692pfk.46.2018.05.16.00.51.25; Wed, 16 May 2018 00:51:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@resnulli-us.20150623.gappssmtp.com header.s=20150623 header.b=IOmEG14l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752808AbeEPHuf (ORCPT + 99 others); Wed, 16 May 2018 03:50:35 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:54836 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751285AbeEPHub (ORCPT ); Wed, 16 May 2018 03:50:31 -0400 Received: by mail-wm0-f67.google.com with SMTP id f6-v6so5165734wmc.4 for ; Wed, 16 May 2018 00:50:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Mxiil5QCnN02JJNVCKQ708etwmiFrElGvNlQtcwUd0c=; b=IOmEG14lD9hJ0efZK0WtxgpkLy3xD+Dhm2MVLvWwfFdVVZlR0E5ZC+5nQ/Xqmfx5PC 9GVWbgKjPgeIkZHmxYZVvI8F8FS2QOPs4JBkGOnsCuPhWhavAWOpQDOIFR/HkXiVPsBl GRw4AuDzNUn7OQcARprUTGZg2nS5mr08Jst8O0bMKPNwkcRubirpuRXl9exvZ02Pz5IQ 8zI5q4D9VH/bI+g+xoIHHgsaty7UVVk2qOKpSXBqxaIYe5X65KmzpVJdl4ZJ0bm7V7nS As7j5pw/m8Mthi30oCvfuqsaj61DqKaIQkwi6wlgOTOqnvIRQYq/dnX0e/MP+mvFEz0z LuEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Mxiil5QCnN02JJNVCKQ708etwmiFrElGvNlQtcwUd0c=; b=kNnaANdsZtbmTQZj4kkXGBRQyAE2A57AtoAfakAl6qVtmYavy6XJ2T6SXmKdpVy63d 2oXJVuUfPMn6vhu861LTuz9Qwwy7/GzB9T3gcd87qsf3qdFLDKWST16+I9Gvgv1vau/0 6A6dAzjgTw1IAyS7fS6Sjvx0mOrvJKJ+D0HwLciG8be9GQhmeDwp+Somb2UCY3EG2+5u fMRE1Sw+KJAJ4JXpHRBzaB77R3g52QmI058GPEya1cJKN+b/4yiTi6BnLqBXAKwdl8en tpfn9jwogRdEO0ZqqPdSnrkHjuq8b7ZdNndHc4l9YP+OtFfBcqKdsWZaYEo48yra6mYU dGtw== X-Gm-Message-State: ALKqPwcZOQRSMPhnYesyxZgi1t60CCqXuGPlpmTXGLyw2UUUdL2HRZrx 19D3Hm59+H1sxba8nb9vkAH5KQ== X-Received: by 2002:a1c:2856:: with SMTP id o83-v6mr878114wmo.3.1526457030140; Wed, 16 May 2018 00:50:30 -0700 (PDT) Received: from localhost (ip-94-113-127-8.net.upcbroadband.cz. [94.113.127.8]) by smtp.gmail.com with ESMTPSA id h81-v6sm3340527wmd.0.2018.05.16.00.50.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 May 2018 00:50:29 -0700 (PDT) Date: Wed, 16 May 2018 09:50:29 +0200 From: Jiri Pirko To: Vlad Buslov Cc: netdev@vger.kernel.org, davem@davemloft.net, jhs@mojatatu.com, xiyou.wangcong@gmail.com, pablo@netfilter.org, kadlec@blackhole.kfki.hu, fw@strlen.de, ast@kernel.org, daniel@iogearbox.net, edumazet@google.com, keescook@chromium.org, linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, kliteyn@mellanox.com Subject: Re: [PATCH 09/14] net: sched: don't release reference on action overwrite Message-ID: <20180516075029.GD1972@nanopsycho> References: <1526308035-12484-1-git-send-email-vladbu@mellanox.com> <1526308035-12484-10-git-send-email-vladbu@mellanox.com> <20180516074332.GB1972@nanopsycho> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Wed, May 16, 2018 at 09:47:32AM CEST, vladbu@mellanox.com wrote: > >On Wed 16 May 2018 at 07:43, Jiri Pirko wrote: >> Mon, May 14, 2018 at 04:27:10PM CEST, vladbu@mellanox.com wrote: >>>Return from action init function with reference to action taken, >>>even when overwriting existing action. >>> >>>Action init API initializes its fourth argument (pointer to pointer to >>>tc action) to either existing action with same index or newly created >>>action. In case of existing index(and bind argument is zero), init >>>function returns without incrementing action reference counter. Caller >>>of action init then proceeds working with action without actually >>>holding reference to it. This means that action could be deleted >>>concurrently. To prevent such scenario this patch changes action init >> >> Be imperative to the codebase in the patch description. >> >> >>>behavior to always take reference to action before returning >>>successfully. >> >> Where's the balance? Who does the release instead? I'm probably missing >> something. > >I've resplit these patches for V2 to always do take/release in same >patch. Good. Thanks. > >> >>> >>>Signed-off-by: Vlad Buslov >>>--- >>> net/sched/act_bpf.c | 8 ++++---- >>> net/sched/act_connmark.c | 5 +++-- >>> net/sched/act_csum.c | 8 ++++---- >>> net/sched/act_gact.c | 5 +++-- >>> net/sched/act_ife.c | 12 +++++------- >>> net/sched/act_ipt.c | 5 +++-- >>> net/sched/act_mirred.c | 5 ++--- >>> net/sched/act_nat.c | 5 +++-- >>> net/sched/act_pedit.c | 5 +++-- >>> net/sched/act_police.c | 8 +++----- >>> net/sched/act_sample.c | 8 +++----- >>> net/sched/act_simple.c | 5 +++-- >>> net/sched/act_skbedit.c | 5 +++-- >>> net/sched/act_skbmod.c | 8 +++----- >>> net/sched/act_tunnel_key.c | 8 +++----- >>> net/sched/act_vlan.c | 8 +++----- >>> 16 files changed, 51 insertions(+), 57 deletions(-) >>> >>>diff --git a/net/sched/act_bpf.c b/net/sched/act_bpf.c >>>index 5d95c43..5554bf7 100644 >>>--- a/net/sched/act_bpf.c >>>+++ b/net/sched/act_bpf.c >>>@@ -311,9 +311,10 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla, >>> if (bind) >>> return 0; >>> >>>- tcf_idr_release(*act, bind); >>>- if (!replace) >>>+ if (!replace) { >>>+ tcf_idr_release(*act, bind); >>> return -EEXIST; >>>+ } >>> } >>> >>> is_bpf = tb[TCA_ACT_BPF_OPS_LEN] && tb[TCA_ACT_BPF_OPS]; >> >> [...] >