Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3003192yba; Mon, 22 Apr 2019 17:35:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxLatkFtsnvXOgtAbb8l6KY42hmDZsEPf4LLlN9obnKoKpcOPfGrs0qcQrbS/57wr7pAJ98 X-Received: by 2002:a62:b612:: with SMTP id j18mr24089628pff.124.1555979743909; Mon, 22 Apr 2019 17:35:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555979743; cv=none; d=google.com; s=arc-20160816; b=dG4YzDqZcD2bWkZX5923CfBRlrSliA7P9nbdifMFi4AeP4JQIM/V8prZFqLJPmLlUG fBjo+T2D8f+Cp/CBl4DyMnPhykLI4mOnABluwRHoYfNmjII5P2uDWfmoKz17W+bnKzPz XQDnrmSPDPooRpz8JocCghPmkN0UmIccx45a6JAuYDF5l5gLu3jES8r9GWCNboUsPg/X 5vtWJvSOADRBv7yU8Mpe/8fo0k0g7zc3d9TV6mTG9AclMw4u9N7mslgpucZ39+qoOdO+ F8jvLWurM+BEsXdbHMzkQHVY9OKSVl8h+M9Iy1CSvsfaQ2+tGf4PJKFxHWrPc9bkUf9M uK9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1AJV/kYe5OQ7gpDvGl+vpcvgWw9nRXtoFQZWuyt6Q/4=; b=hj6NxrJBtbFuHj+7HZ1VlKXRuh5odvE4cuw5SYIbaJx5+pxHeYTDmuDtLSoG9xbNHa aNShxYvYX7voOoD28HnvFq8j7/IDLngeTK56TIZ8RfsGcKE1w8PGfgj1tscWAZ/6qWXm elBOKR9H28cQ6fCHIJB5zAFGFH/GWAs6fjAFxYiPjVAXyP5uGkFp9eM2gZzSfxxmwApO wFYyGV0NDlaiddtUVQnF+70vtabqNx+QnMBTv+KdBXNTmy8hiAqqD8W1W//Khp1pF/Sb U6Eu8zUILicqHf3U1p8gTWo8y5GGp9Ug9A21mXSSxJ/2r5HdiOGisXOCd9EDwdwq6HMH 7XxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Zce+GI8O; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v12si13632295pgh.303.2019.04.22.17.35.28; Mon, 22 Apr 2019 17:35:43 -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=@kernel.org header.s=default header.b=Zce+GI8O; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732582AbfDVUKj (ORCPT + 99 others); Mon, 22 Apr 2019 16:10:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:42894 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728809AbfDVTma (ORCPT ); Mon, 22 Apr 2019 15:42:30 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1F397214AE; Mon, 22 Apr 2019 19:42:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555962149; bh=evnt4fiL9nbSV34MfUf+X3UBly3Idwn/HCWgRq92zJ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zce+GI8OrQHTw07PLHCIvBqpv0iRmGegluTYg62CafknaITgoosOZoNPZDKY7cWad EPZ6w76cRaF8nvf6evEhYms7MulxiQwavf7OZsduwYVs6lLFXB2vsE/e43j22Cu+LD wwdOoyNq0FttaJ2V9PHvagRPlCFMDTMnQmc6cpwk= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pablo Neira Ayuso , Sasha Levin , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 20/98] netfilter: nf_tables: bogus EBUSY in helper removal from transaction Date: Mon, 22 Apr 2019 15:40:47 -0400 Message-Id: <20190422194205.10404-20-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190422194205.10404-1-sashal@kernel.org> References: <20190422194205.10404-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pablo Neira Ayuso [ Upstream commit 8ffcd32f64633926163cdd07a7d295c500a947d1 ] Proper use counter updates when activating and deactivating the object, otherwise, this hits bogus EBUSY error. Fixes: cd5125d8f518 ("netfilter: nf_tables: split set destruction in deactivate and destroy phase") Reported-by: Laura Garcia Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin (Microsoft) --- net/netfilter/nft_objref.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/net/netfilter/nft_objref.c b/net/netfilter/nft_objref.c index ae178e914486..1dfc621cedaa 100644 --- a/net/netfilter/nft_objref.c +++ b/net/netfilter/nft_objref.c @@ -64,21 +64,34 @@ nla_put_failure: return -1; } -static void nft_objref_destroy(const struct nft_ctx *ctx, - const struct nft_expr *expr) +static void nft_objref_deactivate(const struct nft_ctx *ctx, + const struct nft_expr *expr, + enum nft_trans_phase phase) { struct nft_object *obj = nft_objref_priv(expr); + if (phase == NFT_TRANS_COMMIT) + return; + obj->use--; } +static void nft_objref_activate(const struct nft_ctx *ctx, + const struct nft_expr *expr) +{ + struct nft_object *obj = nft_objref_priv(expr); + + obj->use++; +} + static struct nft_expr_type nft_objref_type; static const struct nft_expr_ops nft_objref_ops = { .type = &nft_objref_type, .size = NFT_EXPR_SIZE(sizeof(struct nft_object *)), .eval = nft_objref_eval, .init = nft_objref_init, - .destroy = nft_objref_destroy, + .activate = nft_objref_activate, + .deactivate = nft_objref_deactivate, .dump = nft_objref_dump, }; -- 2.19.1