Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4434292imm; Mon, 14 May 2018 07:31:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqa+6CurM0MdGNZ1W71k4sLubTybG0y/vllPQQM6QKmOzZIGQLBrDWell2KmK1ik0x6yoGS X-Received: by 2002:a17:902:341:: with SMTP id 59-v6mr10310442pld.324.1526308308931; Mon, 14 May 2018 07:31:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526308308; cv=none; d=google.com; s=arc-20160816; b=AIi4YggxN6GYt2t6vyXTyrLJsIWXJtBn/5E99tBRgdV5ua4TcJ7+V3noirANwJgEcn 9BLmRjUWhfDKXX2TytqQvbRmpmLxbY8uowstjbYSKXrYKX3joSKZUpMDcvpwRR5YWUad T+8aicZZWEtrxkXF6SxKpZu0J4AWN2llgVQzr83JeloyiOm1d4JpRIfGbbyH0Mr0rKrh 9WJJ20Z20yEKZ9KQGAviKh26tjrgpX+e/SCSb4Toh6cHIqCbeBXC96pGQC/XiSQMpzxb kL1rTGN6+qbNNTgv1b+3b4vTS2shjhF/v8sksjR9J4TifvkmxC61YNjVb1WEisXF7lu5 Kozw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=J2mpwI3meBj9+JlMZgMKtRWTmqEjaMgGHRXf5zrvd68=; b=QaC3dxmie2VzniGEjMICffbC801dCPd3hqXl83+U/bTMQwoeuGDZqv0bwYCEhIGDqc lxHz7FErqbteDgOnEjSPoaKaDUK4ITm+Nn9aLl+vHW6C+0h4QBkobFrOBh2cwqV+uVHG LhgobnVBMoJoh4wmd4Z/K/9cjdv3Z9XG7yDdXvsNOUG3gMyXkTPUcRxG7ozrIy3BOfoT 3+IN6vH7lBTqD6HFNk70xaaIUEzpL02Oa4Jo7ytIwayu27G2PW/sImr9gTZkADtZncBq 6yP0TT3fzF8bSvcHARnP6v9bmalkoSBwdbUAz9aVba0chTPPdnIDn/E5xf2tobIatQz/ bFsw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t22-v6si10112975plj.595.2018.05.14.07.31.34; Mon, 14 May 2018 07:31:48 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932622AbeENOaC (ORCPT + 99 others); Mon, 14 May 2018 10:30:02 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:35127 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753971AbeENO1l (ORCPT ); Mon, 14 May 2018 10:27:41 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from vladbu@mellanox.com) with ESMTPS (AES256-SHA encrypted); 14 May 2018 17:29:23 +0300 Received: from reg-r-vrt-018-180.mtr.labs.mlnx (reg-r-vrt-018-180.mtr.labs.mlnx [10.213.18.180]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w4EERXLa002750; Mon, 14 May 2018 17:27:35 +0300 From: Vlad Buslov To: netdev@vger.kernel.org Cc: davem@davemloft.net, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, pablo@netfilter.org, kadlec@blackhole.kfki.hu, fw@strlen.de, ast@kernel.org, daniel@iogearbox.net, edumazet@google.com, vladbu@mellanox.com, keescook@chromium.org, linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, kliteyn@mellanox.com Subject: [PATCH 08/14] net: sched: account for temporary action reference Date: Mon, 14 May 2018 17:27:09 +0300 Message-Id: <1526308035-12484-9-git-send-email-vladbu@mellanox.com> X-Mailer: git-send-email 2.7.5 In-Reply-To: <1526308035-12484-1-git-send-email-vladbu@mellanox.com> References: <1526308035-12484-1-git-send-email-vladbu@mellanox.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org tca_get_fill function has 'bind' and 'ref' arguments that get passed down to action dump function. These arguments values are subtracted from actual reference and bind counter values before writing them to skb. In order to prevent concurrent action delete, RTM_GETACTION handler acquires a reference to action before 'dumping' it and releases it afterwards. This reference is temporal and should not be accounted by userspace clients. (both logically and to preserver current API behavior) Use existing infrastructure of tca_get_fill arguments to subtract that temporary reference and not expose it to userspace. Signed-off-by: Vlad Buslov --- net/sched/act_api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 3f02cd1..2772276e 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -935,7 +935,7 @@ tcf_get_notify(struct net *net, u32 portid, struct nlmsghdr *n, if (!skb) return -ENOBUFS; if (tca_get_fill(skb, actions, portid, n->nlmsg_seq, 0, event, - 0, 0) <= 0) { + 0, 1) <= 0) { NL_SET_ERR_MSG(extack, "Failed to fill netlink attributes while adding TC action"); kfree_skb(skb); return -EINVAL; @@ -1125,7 +1125,7 @@ tcf_del_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions, return -ENOBUFS; if (tca_get_fill(skb, actions, portid, n->nlmsg_seq, 0, RTM_DELACTION, - 0, 1) <= 0) { + 0, 2) <= 0) { NL_SET_ERR_MSG(extack, "Failed to fill netlink TC action attributes"); kfree_skb(skb); return -EINVAL; -- 2.7.5